This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project gfxprim.git.
The branch, master has been updated via 9dc7c882ccd99e87e0146b367037d89ceb98aef1 (commit) from 4939286022a028a66c62ee082748384a908fed37 (commit)
Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below.
- Log ----------------------------------------------------------------- http://repo.or.cz/w/gfxprim.git/commit/9dc7c882ccd99e87e0146b367037d89ceb98a...
commit 9dc7c882ccd99e87e0146b367037d89ceb98aef1 Author: Cyril Hrubis metan@ucw.cz Date: Mon May 28 19:11:21 2012 +0200
filters: Clamp Floyd-Steinberg result pixels.
Visible owerflows were found on RGB565
diff --git a/libs/filters/GP_FloydSteinberg.gen.c.t b/libs/filters/GP_FloydSteinberg.gen.c.t index 9886945..df22cfb 100644 --- a/libs/filters/GP_FloydSteinberg.gen.c.t +++ b/libs/filters/GP_FloydSteinberg.gen.c.t @@ -1,4 +1,4 @@ -%% extends "base.c.t" +%% extends "common.c.t"
{% block descr %}Floyd Steinberg dithering RGB888 -> any pixel{% endblock %}
@@ -62,7 +62,6 @@ int GP_FilterFloydSteinberg_RGB888_to_{{ pt.name }}_Raw(const GP_Context *src, G val_{{ c[0] }} += errors_{{ c[0] }}[y%2][x]; float err_{{ c[0] }} = val_{{ c[0] }}; - %% if pt.is_gray() GP_Pixel res_{{ c[0] }} = {{ 2 ** c[2] - 1}} * val_{{ c[0] }} / (3 * 255); err_{{ c[0] }} -= res_{{ c[0] }} * (3 * 255) / {{ 2 ** c[2] - 1}}; @@ -72,6 +71,8 @@ int GP_FilterFloydSteinberg_RGB888_to_{{ pt.name }}_Raw(const GP_Context *src, G %% endif
{{ distribute_error("errors_%s"|format(c[0]), 'x', 'y', '(GP_Coord)src->w', 'err_%s'|format(c[0])) }} + + {{ clamp_val("res_%s"|format(c[0]), c[2]) }} %% endfor %% if pt.is_gray() diff --git a/pylib/templates/common.c.t b/pylib/templates/common.c.t index d3fcbd8..785174d 100644 --- a/pylib/templates/common.c.t +++ b/pylib/templates/common.c.t @@ -14,3 +14,10 @@ * Converts channels to params */ {% macro expand_chanslist(chlist) %} {{ chlist[0][0] }}{% for i in chlist %}, {{ i[0] }}{% endfor %}{% endmacro %} + +/* + * Clamps n-bits value + */ +%%macro clamp_val(val, bits) +if ({{ val }} > {{ 2 ** bits - 1 }}) {{ val }} = {{ 2 ** bits - 1}}; +%% endmacro
-----------------------------------------------------------------------
Summary of changes: libs/filters/GP_FloydSteinberg.gen.c.t | 5 +++-- pylib/templates/common.c.t | 7 +++++++ 2 files changed, 10 insertions(+), 2 deletions(-)
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos@gmail.com if you want to unsubscribe, or site admin admin@repo.or.cz if you receive no reply.