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 5777210fdacd7e722325dbad7a3df78bfa587462 (commit) via e8994a4be0338cc1d5edc52ea60612157eed9c2b (commit) via a19d7e22a4d18fc9ada59ce5968b3ea382ff6498 (commit) via b4d70c436ceb9fa60ed951a3a5259db2dc4159d5 (commit) from 9800d72f27df325aa25aaa5b35851551ef010921 (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/5777210fdacd7e722325dbad7a3df78bfa587...
commit 5777210fdacd7e722325dbad7a3df78bfa587462 Author: Cyril Hrubis metan@ucw.cz Date: Tue Nov 29 21:30:22 2011 +0100
filters: Add support for arithmetic filters.
diff --git a/demos/grinder/grinder.c b/demos/grinder/grinder.c index 0d573fd..f9a0675 100644 --- a/demos/grinder/grinder.c +++ b/demos/grinder/grinder.c @@ -500,6 +500,8 @@ static GP_RetCode save_png(GP_Context **c, const char *params) return GP_ESUCCESS; }
+/* noise filter */ + static struct param add_noise_params[] = { {"percents", PARAM_FLOAT, "Percents of noise to add", NULL, NULL}, {"chann", PARAM_STR, "Channel name {R, G, B, A, V, ...}", NULL, NULL}, @@ -562,6 +564,71 @@ static GP_RetCode add_noise(GP_Context **c, const char *params) return GP_ESUCCESS; }
+/* arithmetics */ + +static const char *arithmetic_ops[] = { + "difference", + "addition", + "multiply", + "min", + "max", + NULL +}; + +static struct param arithmetic_params[] = { + {"file", PARAM_STR, "Filename of image to use.", NULL, NULL}, + {"op", PARAM_ENUM, "Arithmetic peration", arithmetic_ops, NULL}, + {NULL, 0, NULL, NULL, NULL} +}; + +static GP_RetCode arithmetic(GP_Context **c, const char *params) +{ + char *file = NULL; + int op = -1; + + if (param_parse(params, arithmetic_params, "arithmetic", param_err, &file, &op)) + return GP_EINVAL; + + if (file == NULL) { + print_error("arithmetic: Filename missing"); + return GP_EINVAL; + } + + GP_Context *img, *res = NULL; + + if (GP_LoadImage(file, &img, progress_callback)) { + print_error("arithmetic: Invalid image."); + return GP_EINVAL; + } + + switch (op) { + case 0: + res = GP_FilterDifference(*c, img, NULL, progress_callback); + break; + case 1: + res = GP_FilterAddition(*c, img, NULL, progress_callback); + break; + case 2: + res = GP_FilterMultiply(*c, img, NULL, progress_callback); + break; + case 3: + res = GP_FilterMin(*c, img, NULL, progress_callback); + break; + case 4: + res = GP_FilterMax(*c, img, NULL, progress_callback); + break; + } + + if (res == NULL) + return GP_EINVAL; + + GP_ContextFree(*c); + + *c = res; + + return GP_ESUCCESS; +} + /* filters */
struct filter { @@ -572,19 +639,20 @@ struct filter { };
static struct filter filter_table[] = { - {"rotate", "rotate image", rotate_params, rotate}, - {"mirror", "mirror vertically/horizontally", mirror_params, mirror}, - {"scale", "scale image to given width and height", scale_params, scale}, - {"resize", "resize image by given ratio", resize_params, resize}, - {"bright", "alter image brightness", bright_params, bright}, - {"contrast", "alter image contrast", contrast_params, contrast}, - {"invert", "inverts image", invert_params, invert}, - {"add_noise", "adds noise", add_noise_params, add_noise}, - {"blur", "gaussian blur", blur_params, blur}, - {"dither", "dithers bitmap", dither_params, dither}, - {"jpg", "save jpg image", save_jpg_params, save_jpg}, - {"png", "save png image", save_png_params, save_png}, - {NULL, NULL, NULL, NULL} + {"rotate", "rotate image", rotate_params, rotate}, + {"mirror", "mirror vertically/horizontally", mirror_params, mirror}, + {"scale", "scale image to given width and height", scale_params, scale}, + {"resize", "resize image by given ratio", resize_params, resize}, + {"bright", "alter image brightness", bright_params, bright}, + {"contrast", "alter image contrast", contrast_params, contrast}, + {"invert", "inverts image", invert_params, invert}, + {"add_noise", "adds noise", add_noise_params, add_noise}, + {"blur", "gaussian blur", blur_params, blur}, + {"dither", "dithers bitmap", dither_params, dither}, + {"arithmetic", "arithmetic operation", arithmetic_params, arithmetic}, + {"jpg", "save jpg image", save_jpg_params, save_jpg}, + {"png", "save png image", save_png_params, save_png}, + {NULL, NULL, NULL, NULL} };
static struct filter *get_filter(const char *name) diff --git a/gen.mk b/gen.mk index 5c957f9..ef10aa4 100644 --- a/gen.mk +++ b/gen.mk @@ -36,7 +36,7 @@ CLEAN+=$(GENSOURCES) $(GENHEADERS) # # Some base dependencies # -$(GENSOURCES): $(TEMPLATE_DIR)/base.c.t +$(GENSOURCES): $(TEMPLATE_DIR)/base.c.t $(TEMPLATE_DIR)/common.c.t $(GENHEADERS): $(TEMPLATE_DIR)/base.h.t
# diff --git a/include/filters/GP_Filters.h b/include/filters/GP_Arithmetic.h similarity index 53% copy from include/filters/GP_Filters.h copy to include/filters/GP_Arithmetic.h index f5cb848..9f1cb20 100644 --- a/include/filters/GP_Filters.h +++ b/include/filters/GP_Arithmetic.h @@ -16,38 +16,65 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, * * Boston, MA 02110-1301 USA * * * - * Copyright (C) 2009-2010 Jiri "BlueBear" Dluhos * - * jiri.bluebear.dluhos@gmail.com * - * * * Copyright (C) 2009-2011 Cyril Hrubis metan@ucw.cz * * * *****************************************************************************/
/*
- GP_Context filters. + Arithmetic filters - compute products of two bitmaps.
*/
-#ifndef GP_FILTERS_H -#define GP_FILTERS_H - -/* Filter per channel parameter passing interface */ -#include "filters/GP_FilterParam.h" +#ifndef FILTERS_GP_ARITHMETIC_H +#define FILTERS_GP_ARITHMETIC_H
-/* Image rotations (90 180 270 grads) and mirroring */ -#include "filters/GP_Rotate.h" +#include "GP_Filter.h"
-/* Point filters, brightness, contrast ... */ -#include "filters/GP_Point.h" +/* + * Addition filter. + * + * Produces clamped addtion. + */ +GP_Context *GP_FilterAddition(const GP_Context *src_a, + const GP_Context *src_b, + GP_Context *dst, + GP_ProgressCallback *callback); +/* + * Multiply filter. + * + * Produces clamped multiplication. + */ +GP_Context *GP_FilterMultiply(const GP_Context *src_a, + const GP_Context *src_b, + GP_Context *dst, + GP_ProgressCallback *callback);
-/* Linear convolution based filters (mostly blurs) */ -#include "filters/GP_Linear.h" +/* + * Difference filter. + * + * Produces symetric difference. + * eg. dst = abs(src_a - src_b) + */ +GP_Context *GP_FilterDifference(const GP_Context *src_a, + const GP_Context *src_b, + GP_Context *dst, + GP_ProgressCallback *callback);
-/* Image scaling (resampling) */ -#include "filters/GP_Resize.h" +/* + * Maximum filter. + */ +GP_Context *GP_FilterMax(const GP_Context *src_a, + const GP_Context *src_b, + GP_Context *dst, + GP_ProgressCallback *callback);
-/* Bitmap dithering */ -#include "filters/GP_Dither.h" +/* + * Minimum filter. + */ +GP_Context *GP_FilterMin(const GP_Context *src_a, + const GP_Context *src_b, + GP_Context *dst, + GP_ProgressCallback *callback);
-#endif /* GP_FILTERS_H */ +#endif /* FILTERS_GP_ARITHMETIC_H */ diff --git a/include/filters/GP_Filters.h b/include/filters/GP_Filters.h index f5cb848..5bd60a8 100644 --- a/include/filters/GP_Filters.h +++ b/include/filters/GP_Filters.h @@ -41,6 +41,9 @@ /* Point filters, brightness, contrast ... */ #include "filters/GP_Point.h"
+/* Addition, difference, min, max ... */ +#include "filters/GP_Arithmetic.h" + /* Linear convolution based filters (mostly blurs) */ #include "filters/GP_Linear.h"
diff --git a/libs/filters/GP_Addition.gen.c.t b/libs/filters/GP_Addition.gen.c.t new file mode 100644 index 0000000..f89ebd4 --- /dev/null +++ b/libs/filters/GP_Addition.gen.c.t @@ -0,0 +1,24 @@ +%% extends "filter.arithmetic.c.t" + +%% block descr +Addition filter -- Addition of two bitmaps. +%% endblock + +%% block body + +{{ filter_arithmetic_include() }} + +%% macro filter_op(chan_name, chan_size) +{{ chan_name }} = {{ chan_name }}_A + {{ chan_name }}_B; +{{ filter_clamp_val(chan_name, chan_size) }} +%% endmacro + +%% call(pt) filter_arithmetic_per_channel('Addition', filter_op) +%% endcall + +%% call(ps) filter_arithmetic_per_bpp('Addition', filter_op) +%% endcall + +{{ filter_arithmetic_functions('Addition') }} + +%% endblock body diff --git a/libs/filters/GP_Difference.gen.c.t b/libs/filters/GP_Difference.gen.c.t new file mode 100644 index 0000000..cf60b97 --- /dev/null +++ b/libs/filters/GP_Difference.gen.c.t @@ -0,0 +1,23 @@ +%% extends "filter.arithmetic.c.t" + +%% block descr +Difference filter -- Symetric difference of two bitmaps. +%% endblock + +%% block body + +{{ filter_arithmetic_include() }} + +%% macro filter_op(chan_name, chan_size) +{{ chan_name }} = GP_ABS({{ chan_name }}_A - {{ chan_name }}_B); +%% endmacro + +%% call(pt) filter_arithmetic_per_channel('Difference', filter_op) +%% endcall + +%% call(ps) filter_arithmetic_per_bpp('Difference', filter_op) +%% endcall + +{{ filter_arithmetic_functions('Difference') }} + +%% endblock body diff --git a/libs/filters/GP_Max.gen.c.t b/libs/filters/GP_Max.gen.c.t new file mode 100644 index 0000000..6e8813d --- /dev/null +++ b/libs/filters/GP_Max.gen.c.t @@ -0,0 +1,23 @@ +%% extends "filter.arithmetic.c.t" + +%% block descr +Max filter -- Choose max for each pixel (and for each channel) for two bitmaps. +%% endblock + +%% block body + +{{ filter_arithmetic_include() }} + +%% macro filter_op(chan_name, chan_size) +{{ chan_name }} = GP_MAX({{ chan_name }}_A, {{ chan_name }}_B); +%% endmacro + +%% call(pt) filter_arithmetic_per_channel('Max', filter_op) +%% endcall + +%% call(ps) filter_arithmetic_per_bpp('Max', filter_op) +%% endcall + +{{ filter_arithmetic_functions('Max') }} + +%% endblock body diff --git a/libs/filters/GP_Min.gen.c.t b/libs/filters/GP_Min.gen.c.t new file mode 100644 index 0000000..b27d303 --- /dev/null +++ b/libs/filters/GP_Min.gen.c.t @@ -0,0 +1,23 @@ +%% extends "filter.arithmetic.c.t" + +%% block descr +Min filter -- Choose min for each pixel (and for each channel) for two bitmaps. +%% endblock + +%% block body + +{{ filter_arithmetic_include() }} + +%% macro filter_op(chan_name, chan_size) +{{ chan_name }} = GP_MIN({{ chan_name }}_A, {{ chan_name }}_B); +%% endmacro + +%% call(pt) filter_arithmetic_per_channel('Min', filter_op) +%% endcall + +%% call(ps) filter_arithmetic_per_bpp('Min', filter_op) +%% endcall + +{{ filter_arithmetic_functions('Min') }} + +%% endblock body diff --git a/libs/filters/GP_Multiply.gen.c.t b/libs/filters/GP_Multiply.gen.c.t new file mode 100644 index 0000000..3bfe7a3 --- /dev/null +++ b/libs/filters/GP_Multiply.gen.c.t @@ -0,0 +1,24 @@ +%% extends "filter.arithmetic.c.t" + +%% block descr +Multiply filter -- Multiplies two images. +%% endblock + +%% block body + +{{ filter_arithmetic_include() }} + +%% macro filter_op(chan_name, chan_size) +{{ chan_name }} = ({{ chan_name }}_A * {{ chan_name }}_B + {{ (2 ** chan_size - 1) // 2}})/ ({{ 2 ** chan_size - 1}}); +{{ filter_clamp_val(chan_name, chan_size) }} +%% endmacro + +%% call(pt) filter_arithmetic_per_channel('Multiply', filter_op) +%% endcall + +%% call(ps) filter_arithmetic_per_bpp('Multiply', filter_op) +%% endcall + +{{ filter_arithmetic_functions('Multiply') }} + +%% endblock body diff --git a/libs/filters/Makefile b/libs/filters/Makefile index e6d8aec..d3f68c2 100644 --- a/libs/filters/Makefile +++ b/libs/filters/Makefile @@ -1,7 +1,11 @@ TOPDIR=../..
-POINT_FILTERS=GP_Contrast.gen.c GP_Brightness.gen.c GP_Invert.gen.c GP_Point.gen.c -ARITHMETIC_FILTERS=GP_Difference.gen.c +POINT_FILTERS=GP_Contrast.gen.c GP_Brightness.gen.c GP_Invert.gen.c+ GP_Point.gen.c + +ARITHMETIC_FILTERS=GP_Difference.gen.c GP_Addition.gen.c GP_Min.gen.c+ GP_Max.gen.c GP_Multiply.gen.c + GENSOURCES=GP_MirrorV.gen.c GP_Rotate.gen.c GP_Dither.gen.c $(POINT_FILTERS) $(ARITHMETIC_FILTERS)
@@ -13,5 +17,6 @@ include $(TOPDIR)/gen.mk include $(TOPDIR)/include.mk include $(TOPDIR)/lib.mk
+$(POINT_FILTERS) $(ARITHMETIC_FILTERS): $(TEMPLATE_DIR)/filter.c.t $(POINT_FILTERS): $(TEMPLATE_DIR)/filter.point.c.t $(ARITHMETIC_FILTERS): $(TEMPLATE_DIR)/filter.arithmetic.c.t diff --git a/pylib/templates/common.c.t b/pylib/templates/common.c.t new file mode 100644 index 0000000..b4af2f8 --- /dev/null +++ b/pylib/templates/common.c.t @@ -0,0 +1,11 @@ +%% extends 'base.c.t' + +/* + * Maybe opts, adds comma on the left side + */ +{% macro maybe_opts_l(opts) %}{% if opts %}, {{ opts }}{% endif %}{% endmacro %} + +/* + * Maybe opts, adds comma on the right side. + */ +{% macro maybe_opts_r(opts) %}{% if opts %}{{ opts }}, {% endif %}{% endmacro %} diff --git a/pylib/templates/filter.arithmetic.c.t b/pylib/templates/filter.arithmetic.c.t new file mode 100644 index 0000000..e083921 --- /dev/null +++ b/pylib/templates/filter.arithmetic.c.t @@ -0,0 +1,154 @@ +%% extends "filter.c.t" + +%% macro filter_arithmetic_include() +{{ filter_include() }} +#include "GP_Arithmetic.h" +%% endmacro + +/* + * Filter per pixel type, used for images with more than one channel per pixel + */ +%% macro filter_arithmetic_per_channel(name, filter_op, opts="") +%% for pt in pixeltypes +%% if not pt.is_unknown() and len(pt.chanslist) > 1 +static int GP_Filter{{ name }}_{{ pt.name }}(const GP_Context *src_a, const GP_Context *src_b, + GP_Context *dst, {{ maybe_opts_r(opts) }}GP_ProgressCallback *callback) +{ +{{ caller(pt) }} + uint32_t x, y, w, h; + + w = GP_MIN(src_a->w, src_b->w); + h = GP_MIN(src_a->h, src_b->h); + + for (y = 0; y < h; y++) { + for (x = 0; x < w; x++) { + GP_Pixel pix_a = GP_GetPixel_Raw_{{ pt.pixelsize.suffix }}(src_a, x, y); + GP_Pixel pix_b = GP_GetPixel_Raw_{{ pt.pixelsize.suffix }}(src_b, x, y); + + %% for c in pt.chanslist + int32_t {{ c[0] }}_A = GP_Pixel_GET_{{ c[0] }}_{{ pt.name }}(pix_a); + int32_t {{ c[0] }}_B = GP_Pixel_GET_{{ c[0] }}_{{ pt.name }}(pix_b); + %% endfor + + %% for c in pt.chanslist + int32_t {{ c[0] }}; + {{ filter_op(c[0], c[2]) }} + %% endfor + + GP_Pixel pix; + pix = GP_Pixel_CREATE_{{ pt.name }}({{ pt.chanslist[0][0] }}{% for c in pt.chanslist[1:] %}, {{ c[0] }}{% endfor %}); + + GP_PutPixel_Raw_{{ pt.pixelsize.suffix }}(dst, x, y, pix); + } + + if (GP_ProgressCallbackReport(callback, y, h, w)) + return 1; + } + + GP_ProgressCallbackDone(callback); + return 0; +} +%% endif +%% endfor +%% endmacro + +/* + * Point filter per bpp (used for 1 channel pixels to save space). + */ +%% macro filter_arithmetic_per_bpp(name, filter_op, opts="") +%% for ps in pixelsizes +%% if ps.size <= 8 and ps.size > 1 +static int GP_Filter{{ name }}_{{ ps.suffix }}(const GP_Context *src_a, const GP_Context *src_b, + GP_Context *dst, {{ maybe_opts_r(opts) }}GP_ProgressCallback *callback) +{ +{{ caller(ps) }} + uint32_t x, y, w, h; + + w = GP_MIN(src_a->w, src_b->w); + h = GP_MIN(src_a->h, src_b->h); + + for (y = 0; y < h; y++) { + for (x = 0; x < w; x++) { + int32_t pix_A = GP_GetPixel_Raw_{{ ps.suffix }}(src_a, x, y); + int32_t pix_B = GP_GetPixel_Raw_{{ ps.suffix }}(src_b, x, y); + int32_t pix; + {{ filter_op('pix', ps.size) }} + GP_PutPixel_Raw_{{ ps.suffix }}(dst, x, y, pix); + } + + if (GP_ProgressCallbackReport(callback, y, h, w)) + return 1; + } + + GP_ProgressCallbackDone(callback); + return 0; +} + +%% endif +%% endfor +%% endmacro + +/* + * Switch per pixel sizes or pixel types. + */ +%% macro filter_arithmetic_functions(name, opts="", params="", fmt="") +int GP_Filter{{ name }}_Raw(const GP_Context *src_a, const GP_Context *src_b, + GP_Context *dst{{ maybe_opts_l(opts) }}, GP_ProgressCallback *callback) +{ + GP_DEBUG(1, "Running filter {{ name }}"); + + switch (src_a->pixel_type) { + %% for pt in pixeltypes + case GP_PIXEL_{{ pt.name }}: + %% if pt.is_unknown() or pt.pixelsize.size < 2 + return 1; + %% elif len(pt.chanslist) == 1: + //TODO: BITENDIAN + return GP_Filter{{ name }}_{{ pt.pixelsize.suffix }}(src_a, src_b, dst{{ maybe_opts_l(params) }}, callback); + %% else + return GP_Filter{{ name }}_{{ pt.name }}(src_a, src_b, dst{{ maybe_opts_l(params) }}, callback); + %% endif + %% endfor + default: + break; + } + + return 1; +} + +GP_Context *GP_Filter{{ name }}(const GP_Context *src_a, const GP_Context *src_b, + GP_Context *dst{{ maybe_opts_l(opts) }}, GP_ProgressCallback *callback) +{ + GP_Context *res = dst; + + GP_ASSERT(src_a->pixel_type == src_b->pixel_type, + "Pixel types for sources must match."); + + GP_Size w = GP_MIN(src_a->w, src_b->w); + GP_Size h = GP_MIN(src_a->h, src_b->h); + + if (res == NULL) { + + res = GP_ContextAlloc(w, h, src_a->pixel_type); + + if (res == NULL) + return NULL; + } else { + GP_ASSERT(src_a->pixel_type == dst->pixel_type, + "The src and dst pixel types must match"); + GP_ASSERT(w <= dst->w && h <= dst->h, + "Destination is not big enough"); + } + + if (GP_Filter{{ name }}_Raw(src_a, src_b, res{{ maybe_opts_l(params) }}, callback)) { + GP_DEBUG(1, "Operation aborted"); + + if (dst == NULL) + GP_ContextFree(res); + + return NULL; + } + + return res; +} +%% endmacro diff --git a/pylib/templates/filter.c.t b/pylib/templates/filter.c.t new file mode 100644 index 0000000..335ffbc --- /dev/null +++ b/pylib/templates/filter.c.t @@ -0,0 +1,58 @@ +%% extends "common.c.t" + +%% macro filter_include() +#include "core/GP_Context.h" +#include "core/GP_Pixel.h" +#include "core/GP_GetPutPixel.h" +#include "core/GP_Debug.h" +#include "GP_Filter.h" +%% endmacro + +/* + * Value clamping macro + */ +%% macro filter_clamp_val(var, size) + if ({{ var }} < 0) + {{ var }} = 0; + + if ({{ var }} > {{ 2 ** size - 1}}) + {{ var }} = {{ 2 ** size - 1}}; +%% endmacro + +/* + * Load parameters from params structure into variables + */ +%% macro filter_params(pt, params, c_type, suffix, id) + GP_ASSERT(GP_FilterParamCheckPixelType({{ params }}, GP_PIXEL_{{ pt.name }}) == 0, + "Invalid params channels for context pixel type"); + + %% for chann in pt.chanslist + {{ c_type }}{{ chann[0] }}{{ suffix }} = (GP_FilterParamChannel({{ params }}, "{{ chann[0] }}"))->val.{{ id }}; + %% endfor +%% endmacro + +%% macro filter_params_raw(pt, params, suffix) + GP_ASSERT(GP_FilterParamCheckPixelType({{ params }}, GP_PIXEL_{{ pt.name }}) == 0, + "Invalid params channels for context pixel type"); + + %% for chann in pt.chanslist + GP_FilterParam *{{ chann[0] }}{{ suffix }} = GP_FilterParamChannel({{ params }}, "{{ chann[0] }}"); + %% endfor +%% endmacro + +/* + * Load parameters from params structure into variable + */ +%% macro filter_param(ps, params, c_type, suffix, id) + GP_ASSERT(GP_FilterParamChannels({{ params }}) != 1, + "Expected only one channel"); + + {{ c_type }}pix{{ suffix }} = {{ params }}[0].val.{{ id }}; +%% endmacro + +%% macro filter_param_raw(ps, params, suffix) + GP_ASSERT(GP_FilterParamChannels({{ params }}) != 1, + "Expected only one channel"); + + GP_FilterParam *pix{{ suffix }} = &{{ params }}[0]; +%% endmacro diff --git a/pylib/templates/filter.point.c.t b/pylib/templates/filter.point.c.t index 88bd6c8..c084efd 100644 --- a/pylib/templates/filter.point.c.t +++ b/pylib/templates/filter.point.c.t @@ -1,48 +1,8 @@ -%% extends "base.c.t" +%% extends "filter.c.t"
-{% macro maybe_opts(opts) %}{% if opts %}, {{ opts }}{% endif %}{% endmacro %} - -{% macro maybe_opts2(opts) %}{% if opts %}{{ opts }}, {% endif %}{% endmacro %} - -%% macro filter_include() -#include "core/GP_Context.h" -#include "core/GP_Pixel.h" -#include "core/GP_GetPutPixel.h" -#include "core/GP_Debug.h" +%% macro filter_point_include() +{{ filter_include() }} #include "GP_Point.h" -#include "GP_Filter.h" -%% endmacro - -/* - * Value clamping macro - */ -%% macro filter_clamp_val(var, size) - if ({{ var }} < 0) - {{ var }} = 0; - - if ({{ var }} > {{ 2 ** size - 1}}) - {{ var }} = {{ 2 ** size - 1}}; -%% endmacro - -/* - * Load parameters from params structure into variables - */ -%% macro filter_params(pt, params, c_type, suffix, id) - GP_ASSERT(GP_FilterParamCheckPixelType({{ params }}, GP_PIXEL_{{ pt.name }}) == 0, - "Invalid params channels for context pixel type"); - - %% for chann in pt.chanslist - {{ c_type }}{{ chann[0] }}{{ suffix }} = (GP_FilterParamChannel({{ params }}, "{{ chann[0] }}"))->val.{{ id }}; - %% endfor -%% endmacro - -%% macro filter_params_raw(pt, params, suffix) - GP_ASSERT(GP_FilterParamCheckPixelType({{ params }}, GP_PIXEL_{{ pt.name }}) == 0, - "Invalid params channels for context pixel type"); - - %% for chann in pt.chanslist - GP_FilterParam *{{ chann[0] }}{{ suffix }} = GP_FilterParamChannel({{ params }}, "{{ chann[0] }}"); - %% endfor %% endmacro
/* @@ -52,7 +12,7 @@ %% for pt in pixeltypes %% if not pt.is_unknown() and len(pt.chanslist) > 1 static int GP_Filter{{ name }}_{{ pt.name }}(const GP_Context *src, GP_Context *dst, - {{ maybe_opts2(opts) }}GP_ProgressCallback *callback) + {{ maybe_opts_r(opts) }}GP_ProgressCallback *callback) { {{ caller(pt) }} uint32_t x, y; @@ -86,30 +46,13 @@ static int GP_Filter{{ name }}_{{ pt.name }}(const GP_Context *src, GP_Context * %% endmacro
/* - * Load parameters from params structure into variable - */ -%% macro filter_param(ps, params, c_type, suffix, id) - GP_ASSERT(GP_FilterParamChannels({{ params }}) != 1, - "Expected only one channel"); - - {{ c_type }}pix{{ suffix }} = {{ params }}[0].val.{{ id }}; -%% endmacro - -%% macro filter_param_raw(ps, params, suffix) - GP_ASSERT(GP_FilterParamChannels({{ params }}) != 1, - "Expected only one channel"); - - GP_FilterParam *pix{{ suffix }} = &{{ params }}[0]; -%% endmacro - -/* * Point filter per bpp (used for 1 channel pixels to save space). */ %% macro filter_point_per_bpp(name, opts="", filter_op) %% for ps in pixelsizes %% if ps.size <= 8 and ps.size > 1 static int GP_Filter{{ name }}_{{ ps.suffix }}(const GP_Context *src, GP_Context *dst, - {{ maybe_opts2(opts) }}GP_ProgressCallback *callback) + {{ maybe_opts_r(opts) }}GP_ProgressCallback *callback) { {{ caller(ps) }} uint32_t x, y; @@ -137,7 +80,7 @@ static int GP_Filter{{ name }}_{{ ps.suffix }}(const GP_Context *src, GP_Context * Switch per pixel sizes or pixel types. */ %% macro filter_functions(name, opts="", params="", fmt="") -int GP_Filter{{ name }}_Raw(const GP_Context *src, GP_Context *dst{{ maybe_opts(opts) }}, +int GP_Filter{{ name }}_Raw(const GP_Context *src, GP_Context *dst{{ maybe_opts_l(opts) }}, GP_ProgressCallback *callback) { GP_DEBUG(1, "Running filter {{ name }}"); @@ -149,9 +92,9 @@ int GP_Filter{{ name }}_Raw(const GP_Context *src, GP_Context *dst{{ maybe_opts( return 1; %% elif len(pt.chanslist) == 1: //TODO: BITENDIAN - return GP_Filter{{ name }}_{{ pt.pixelsize.suffix }}(src, dst{{ maybe_opts(params) }}, callback); + return GP_Filter{{ name }}_{{ pt.pixelsize.suffix }}(src, dst{{ maybe_opts_l(params) }}, callback); %% else - return GP_Filter{{ name }}_{{ pt.name }}(src, dst{{ maybe_opts(params) }}, callback); + return GP_Filter{{ name }}_{{ pt.name }}(src, dst{{ maybe_opts_l(params) }}, callback); %% endif %% endfor default: @@ -161,7 +104,7 @@ int GP_Filter{{ name }}_Raw(const GP_Context *src, GP_Context *dst{{ maybe_opts( return 1; }
-GP_Context *GP_Filter{{ name }}(const GP_Context *src, GP_Context *dst{{ maybe_opts(opts) }}, +GP_Context *GP_Filter{{ name }}(const GP_Context *src, GP_Context *dst{{ maybe_opts_l(opts) }}, GP_ProgressCallback *callback) { GP_Context *res = dst; @@ -178,7 +121,7 @@ GP_Context *GP_Filter{{ name }}(const GP_Context *src, GP_Context *dst{{ maybe_o "Destination is not big enough"); }
- if (GP_Filter{{ name }}_Raw(src, res{{ maybe_opts(params) }}, callback)) { + if (GP_Filter{{ name }}_Raw(src, res{{ maybe_opts_l(params) }}, callback)) { GP_DEBUG(1, "Operation aborted");
if (dst == NULL)
http://repo.or.cz/w/gfxprim.git/commit/e8994a4be0338cc1d5edc52ea60612157eed9...
commit e8994a4be0338cc1d5edc52ea60612157eed9c2b Author: Cyril Hrubis metan@ucw.cz Date: Tue Nov 29 19:26:02 2011 +0100
build: Back at the explicit dependencies.
diff --git a/gen.mk b/gen.mk index 58cd612..5c957f9 100644 --- a/gen.mk +++ b/gen.mk @@ -29,22 +29,15 @@ all: $(GENHEADERS) $(GENSOURCES) TEMPLATE_DIR=$(TOPDIR)/pylib/templates/
# -# ALL templates and potential generated files (not generated automatically) -# NOTE: Currently unused -# -ALL_TEMPLATES=$(shell find $(TOPDIR) -name '*.t') -ALL_GENERATED=$(basename $(ALL_TEMPLATES)) - -# # And clean them # CLEAN+=$(GENSOURCES) $(GENHEADERS)
# -# Add templates as dependencies +# Some base dependencies # -PYTHON_FILES=$(shell find $(TEMPLATE_DIR) -name '*.t') -$(GENSOURCES) $(GENHEADERS): $(PYTHON_FILES) +$(GENSOURCES): $(TEMPLATE_DIR)/base.c.t +$(GENHEADERS): $(TEMPLATE_DIR)/base.h.t
# # Generated files depend on python generators and the template diff --git a/libs/filters/Makefile b/libs/filters/Makefile index 43b0539..e6d8aec 100644 --- a/libs/filters/Makefile +++ b/libs/filters/Makefile @@ -1,7 +1,10 @@ TOPDIR=../.. -GENSOURCES=GP_Contrast.gen.c GP_Brightness.gen.c GP_Invert.gen.c GP_Point.gen.c- GP_MirrorV.gen.c GP_Rotate.gen.c GP_Dither.gen.c GP_Difference.gen.c -GENHEADERS= + +POINT_FILTERS=GP_Contrast.gen.c GP_Brightness.gen.c GP_Invert.gen.c GP_Point.gen.c +ARITHMETIC_FILTERS=GP_Difference.gen.c +GENSOURCES=GP_MirrorV.gen.c GP_Rotate.gen.c GP_Dither.gen.c+ $(POINT_FILTERS) $(ARITHMETIC_FILTERS) + CSOURCES=$(filter-out $(wildcard *.gen.c),$(wildcard *.c)) LIBNAME=filters INCLUDE=core @@ -9,3 +12,6 @@ INCLUDE=core include $(TOPDIR)/gen.mk include $(TOPDIR)/include.mk include $(TOPDIR)/lib.mk + +$(POINT_FILTERS): $(TEMPLATE_DIR)/filter.point.c.t +$(ARITHMETIC_FILTERS): $(TEMPLATE_DIR)/filter.arithmetic.c.t
http://repo.or.cz/w/gfxprim.git/commit/a19d7e22a4d18fc9ada59ce5968b3ea382ff6...
commit a19d7e22a4d18fc9ada59ce5968b3ea382ff6498 Author: Cyril Hrubis metan@ucw.cz Date: Tue Nov 29 19:01:48 2011 +0100
build: Fix and clean up the gen.mk.
diff --git a/gen.mk b/gen.mk index 0d4d937..58cd612 100644 --- a/gen.mk +++ b/gen.mk @@ -14,12 +14,6 @@ GENSOURCES= endif
# -# Headers go into include/core/ -# -INCLUDE_PREFIX=$(TOPDIR)/include/$(LIBNAME)/ -RGENHEADERS=$(addprefix $(INCLUDE_PREFIX),$(GENHEADERS)) - -# # Generate genfiles for generated sources # CSOURCES+=$(GENSOURCES) @@ -27,7 +21,7 @@ CSOURCES+=$(GENSOURCES) # # Make the genrated headers actually build # -all: $(GENHEADERS) +all: $(GENHEADERS) $(GENSOURCES)
# # Base common templates location @@ -47,9 +41,15 @@ ALL_GENERATED=$(basename $(ALL_TEMPLATES)) CLEAN+=$(GENSOURCES) $(GENHEADERS)
# +# Add templates as dependencies +# +PYTHON_FILES=$(shell find $(TEMPLATE_DIR) -name '*.t') +$(GENSOURCES) $(GENHEADERS): $(PYTHON_FILES) + +# # Generated files depend on python generators and the template # -$(GENSOURCES) $(GENHEADERS): %: %.t $(PYTHON_FILES) +$(GENSOURCES) $(GENHEADERS): %: %.t ifdef VERBOSE ${PYTHON} ${TOPDIR}/pylib/bin/generate_file.py -t $(TEMPLATE_DIR) "$@.t" "$@" else diff --git a/libs/filters/Makefile b/libs/filters/Makefile index 3188e17..43b0539 100644 --- a/libs/filters/Makefile +++ b/libs/filters/Makefile @@ -1,6 +1,6 @@ TOPDIR=../.. GENSOURCES=GP_Contrast.gen.c GP_Brightness.gen.c GP_Invert.gen.c GP_Point.gen.c- GP_MirrorV.gen.c GP_Rotate.gen.c GP_Dither.gen.c + GP_MirrorV.gen.c GP_Rotate.gen.c GP_Dither.gen.c GP_Difference.gen.c GENHEADERS= CSOURCES=$(filter-out $(wildcard *.gen.c),$(wildcard *.c)) LIBNAME=filters @@ -9,5 +9,3 @@ INCLUDE=core include $(TOPDIR)/gen.mk include $(TOPDIR)/include.mk include $(TOPDIR)/lib.mk - -$(GENSOURCES): $(TOPDIR)/pylib/templates/filter.point.c.t
http://repo.or.cz/w/gfxprim.git/commit/b4d70c436ceb9fa60ed951a3a5259db2dc415...
commit b4d70c436ceb9fa60ed951a3a5259db2dc4159d5 Author: Cyril Hrubis metan@ucw.cz Date: Tue Nov 29 18:22:11 2011 +0100
TODO: Remove finished TODO.
diff --git a/TODO b/TODO index 9606fe0..ac6d898 100644 --- a/TODO +++ b/TODO @@ -13,8 +13,6 @@ What's not implemented (and should be) - some overall initialization routines - backed event handling
-* Fix contrast - pass GP_Pixel so each channel could have different increment - * Meditate about bit endians and why these aren't separate pixel types (which would make our lives a bit easier)
-----------------------------------------------------------------------
Summary of changes: TODO | 2 - demos/grinder/grinder.c | 94 +++++++++++-- gen.mk | 23 +-- include/filters/{GP_Dither.h => GP_Arithmetic.h} | 60 ++++++--- include/filters/GP_Filters.h | 3 + libs/filters/GP_Addition.gen.c.t | 24 ++++ libs/filters/GP_Difference.gen.c.t | 23 ++++ libs/filters/GP_Max.gen.c.t | 23 ++++ libs/filters/GP_Min.gen.c.t | 23 ++++ libs/filters/GP_Multiply.gen.c.t | 24 ++++ libs/filters/Makefile | 17 ++- pylib/templates/common.c.t | 11 ++ pylib/templates/filter.arithmetic.c.t | 154 ++++++++++++++++++++++ pylib/templates/filter.c.t | 58 ++++++++ pylib/templates/filter.point.c.t | 77 ++---------- 15 files changed, 493 insertions(+), 123 deletions(-) copy include/filters/{GP_Dither.h => GP_Arithmetic.h} (55%) create mode 100644 libs/filters/GP_Addition.gen.c.t create mode 100644 libs/filters/GP_Difference.gen.c.t create mode 100644 libs/filters/GP_Max.gen.c.t create mode 100644 libs/filters/GP_Min.gen.c.t create mode 100644 libs/filters/GP_Multiply.gen.c.t create mode 100644 pylib/templates/common.c.t create mode 100644 pylib/templates/filter.arithmetic.c.t create mode 100644 pylib/templates/filter.c.t
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.