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 c67470e8571d4b391c9c0440b96a9cd1d578fe10 (commit) via a5f35c8236697c090110f3c00875dcec810655f6 (commit) via 5815d5e6aec94722550bf2a5eb9da1bf3dd8abdf (commit) from 9ba3f4f318081d8fc506b58a782375d3b36e19b2 (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/c67470e8571d4b391c9c0440b96a9cd1d578f...
commit c67470e8571d4b391c9c0440b96a9cd1d578fe10 Author: Cyril Hrubis metan@ucw.cz Date: Sun Jun 3 15:33:59 2012 +0200
doc: Add GP_FilterParam into filters.
diff --git a/doc/filters.txt b/doc/filters.txt index 32c9fe0..1abf977 100644 --- a/doc/filters.txt +++ b/doc/filters.txt @@ -69,6 +69,148 @@ int GP_FilterFoo_Raw(const GP_Context *src, GP_Context *dst, GP_ProgressCallback *callback); -------------------------------------------------------------------------------
+Filter Parameters +~~~~~~~~~~~~~~~~~ + +In order to pass, per-channel, filter parameters to a filter, structure called +GP_FilterParams was created. + +[source,c] +------------------------------------------------------------------------------- +#include <GP.h> +/* or */ +#include <filters/GP_FilterParam.h> + +typedef union GP_FilterParamVal { + float f; + uint32_t ui; + int32_t i; + void *ptr; +} GP_FilterParamVal; + +typedef struct GP_FilterParam { + char channel_name[2]; + union GP_FilterParamVal val; +} GP_FilterParam; +------------------------------------------------------------------------------- + +Some filters do take an empty channel_name terminated (empty channel_name is +empty string i.e. "0") array of GP_FilterParam, which is used to describe +per-channel parameters. + + +There are two methods how to construct GP_FilterParam structure. First one is +to use macro that expands to a code which declares and initializes the array on +the stack second uses memory allocated by a malloc(). In both cases the +structure is has initialized channel names and terminator. + +[source,c] +------------------------------------------------------------------------------- +#include <GP.h> +/* or */ +#include <filters/GP_FilterParam.h> + +#define GP_FILTER_PARAMS(pixel_type, name) + GP_FilterParam name[GP_PixelTypes[pixel_type].numchannels + 1]; + GP_FilterParamInitChannels(name, pixel_type); +------------------------------------------------------------------------------- + +Macro that declares and initializes GP_FilterParam structure for a given +pixel_type. + +[source,c] +------------------------------------------------------------------------------- +#include <GP.h> +/* or */ +#include <filters/GP_FilterParam.h> + +GP_FilterParam *GP_FilterParamCreate(GP_PixelType pixel_type); + +void GP_FilterParamDestroy(GP_FilterParam *self); +------------------------------------------------------------------------------- + +Second possible way allocates memory using malloc(). + +Functions for manipulating and querying existing GP_FilterParam follows. + +[source,c] +------------------------------------------------------------------------------- +#include <GP.h> +/* or */ +#include <filters/GP_FilterParam.h> + +void GP_FilterParamInitChannels(GP_FilterParam params[], + GP_PixelType pixel_type); +------------------------------------------------------------------------------- + +Initializes filter param array channel names (accordingly to pixel type) and +terminator. The params array must be large enough to hold number of pixel type +channels plus one. + +[source,c] +------------------------------------------------------------------------------- +#include <GP.h> +/* or */ +#include <filters/GP_FilterParam.h> + +GP_FilterParam *GP_FilterParamChannel(GP_FilterParam params[], + const char *channel_name); +------------------------------------------------------------------------------- + +Does lookup for a given channel name and returns, if found, corresponding +GP_FilterParam, otherwise 'NULL' is returned. + +This function is primary used in filters, where filter, at the start, resolves +all it's parameters. + +[source,c] +------------------------------------------------------------------------------- +#include <GP.h> +/* or */ +#include <filters/GP_FilterParam.h> + +int GP_FilterParamCheckPixelType(GP_FilterParam params[], + GP_PixelType pixel_type); +------------------------------------------------------------------------------- + +Matches param structure against pixel_type. Returns zero if params describes +exactly same channels like pixel_type, non-zero otherwise. + +[source,c] +------------------------------------------------------------------------------- +#include <GP.h> +/* or */ +#include <filters/GP_FilterParam.h> + +void GP_FilterParamSetIntAll(GP_FilterParam params[], int32_t val); + +int GP_FilterParamSetInt(GP_FilterParam params[], const char *channel_name, + int32_t val); + +void GP_FilterParamSetFloatAll(GP_FilterParam params[], float val); + +int GP_FilterParamSetFloat(GP_FilterParam params[], const char *channel_name, + float val); + +void GP_FilterParamSetUIntAll(GP_FilterParam params[], uint32_t val); + +int GP_FilterParamSetUInt(GP_FilterParam params[], const char *channel_name, + uint32_t val); + +void GP_FilterParamSetPtrAll(GP_FilterParam params[], void *ptr); + +int GP_FilterParamSetPtr(GP_FilterParam params[], const char *channel_name, + void *ptr); + +void GP_FilterParamFreePtrAll(GP_FilterParam params[]); +------------------------------------------------------------------------------- + +Parameter setters. Those that sets individual value returns zero on success +(i.e. channel was found) and non-zero otherwise. + +The last one calls free() on all param pointers, which is used to free +allocate memory. + Point operation filters ~~~~~~~~~~~~~~~~~~~~~~~
http://repo.or.cz/w/gfxprim.git/commit/a5f35c8236697c090110f3c00875dcec81065...
commit a5f35c8236697c090110f3c00875dcec810655f6 Author: Cyril Hrubis metan@ucw.cz Date: Sun Jun 3 15:31:48 2012 +0200
filters: Cleanup GP_FilterParams API a little.
diff --git a/include/filters/GP_FilterParam.h b/include/filters/GP_FilterParam.h index 892f166..6520354 100644 --- a/include/filters/GP_FilterParam.h +++ b/include/filters/GP_FilterParam.h @@ -16,7 +16,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, * * Boston, MA 02110-1301 USA * * * - * Copyright (C) 2009-2011 Cyril Hrubis metan@ucw.cz * + * Copyright (C) 2009-2012 Cyril Hrubis metan@ucw.cz * * * *****************************************************************************/
@@ -46,14 +46,27 @@ typedef union GP_FilterParamVal { * Filter takes, empty channel name terminated, arrray of these as parameter. */ typedef struct GP_FilterParam { - //TODO: this must be >= for maximal channel name (now it's 2) + //TODO: this must be > than maximal channel name (now it's 2) char channel_name[2]; union GP_FilterParamVal val; } GP_FilterParam;
/* - * Takes array of filter parameters and returns channel. + * Creates filter param structure large enough for given pixel_type. * + * The returned structure has initalized channel_names and terminator. + */ +GP_FilterParam *GP_FilterParamCreate(GP_PixelType pixel_type); + +/* + * Destroys filter param structure. + */ +void GP_FilterParamDestroy(GP_FilterParam *self); + +/* + * Takes array of filter parameters and returns filter parameter by a channel + * name. + * * Returns NULL if channel wasn't found. */ GP_FilterParam *GP_FilterParamChannel(GP_FilterParam params[], @@ -69,7 +82,7 @@ uint32_t GP_FilterParamChannels(GP_FilterParam params[]); * match. */ int GP_FilterParamCheckPixelType(GP_FilterParam params[], - GP_PixelType type); + GP_PixelType pixel_type);
/* * Returns zero only if params have exactly same channels as array of @@ -85,53 +98,59 @@ int GP_FilterParamCheckChannels(GP_FilterParam params[], GP_FilterParam name[GP_PixelTypes[pixel_type].numchannels + 1]; GP_FilterParamInitChannels(name, pixel_type);
-#define GP_FILTER_PARAMS_INT(pixel_type, name, val) - GP_FILTER_PARAMS(pixel_type, name) - GP_FilterParamSetIntAll(name, val); - -#define GP_FILTER_PARAMS_UINT(pixel_type, name, val) - GP_FILTER_PARAMS(pixel_type, name) - GP_FilterParamSetUIntAll(name, val); - -#define GP_FILTER_PARAMS_FLOAT(pixel_type, name, val) - GP_FILTER_PARAMS(pixel_type, name) - GP_FilterParamSetFloatAll(name, val); - -#define GP_FILTER_PARAMS_PTR(pixel_type, name, ptr) - GP_FILTER_PARAMS(pixel_type, name) - GP_FilterParamSetPtrAll(name, ptr); - /* * Initalize param names and terminator. * * Sets all values to 0. */ void GP_FilterParamInitChannels(GP_FilterParam params[], - GP_PixelType type); + GP_PixelType pixel_type);
/* * Sets all values to integer value. */ -void GP_FilterParamSetIntAll(GP_FilterParam params[], - int32_t val); +void GP_FilterParamSetIntAll(GP_FilterParam params[], int32_t val); + +/* + * Sets integer value. Returns 0 if such value was found, non-zero otherwise. + */ +int GP_FilterParamSetInt(GP_FilterParam params[], const char *channel_name, + int32_t val);
/* * Sets all values to float value. */ -void GP_FilterParamSetFloatAll(GP_FilterParam params[], - float val); +void GP_FilterParamSetFloatAll(GP_FilterParam params[], float val); + +/* + * Sets float value. Returns 0 if such value was found, non-zero otherwise. + */ +int GP_FilterParamSetFloat(GP_FilterParam params[], const char *channel_name, + float val);
/* * Sets all values to unsigned integer value. */ -void GP_FilterParamSetUIntAll(GP_FilterParam params[], - uint32_t val); +void GP_FilterParamSetUIntAll(GP_FilterParam params[], uint32_t val); + +/* + * Sets unsigned integer value. Returns 0 if such value was found, non-zero + * otherwise. + */ +int GP_FilterParamSetUInt(GP_FilterParam params[], const char *channel_name, + uint32_t val);
/* * Sets all values to pointer value. */ -void GP_FilterParamSetPtrAll(GP_FilterParam params[], - void *ptr); +void GP_FilterParamSetPtrAll(GP_FilterParam params[], void *ptr); + +/* + * Sets pointer value. Returns 0 if such value was found, non-zero otherwise. + */ +int GP_FilterParamSetPtr(GP_FilterParam params[], const char *channel_name, + void *ptr); + /* * Call free on all pointer values. */ diff --git a/libs/filters/GP_FilterParam.c b/libs/filters/GP_FilterParam.c index e968a4b..e6c0f6b 100644 --- a/libs/filters/GP_FilterParam.c +++ b/libs/filters/GP_FilterParam.c @@ -16,16 +16,38 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, * * Boston, MA 02110-1301 USA * * * - * Copyright (C) 2009-2011 Cyril Hrubis metan@ucw.cz * + * Copyright (C) 2009-2012 Cyril Hrubis metan@ucw.cz * * * *****************************************************************************/
#include <string.h>
-#include <GP_Debug.h> +#include "core/GP_Debug.h"
#include "GP_FilterParam.h"
+GP_FilterParam *GP_FilterParamCreate(GP_PixelType pixel_type) +{ + GP_FilterParam *ret; + + ret = malloc((GP_PixelTypes[pixel_type].numchannels + 1) + * sizeof(GP_FilterParam)); + + if (ret == NULL) { + GP_WARN("Malloc Failed"); + return NULL; + } + + GP_FilterParamInitChannels(ret, pixel_type); + + return ret; +} + +void GP_FilterParamDestroy(GP_FilterParam *self) +{ + free(self); +} + static unsigned int count_channels(GP_FilterParam params[]) { unsigned int i = 0; @@ -115,6 +137,19 @@ void GP_FilterParamSetIntAll(GP_FilterParam params[], params[i].val.i = val; }
+int GP_FilterParamSetInt(GP_FilterParam params[], const char *channel_name, + int32_t val) +{ + GP_FilterParam *param; + param = GP_FilterParamChannel(params, channel_name); + + if (param == NULL) + return 1; + + param->val.i = val; + return 0; +} + void GP_FilterParamSetFloatAll(GP_FilterParam params[], float val) { @@ -124,6 +159,19 @@ void GP_FilterParamSetFloatAll(GP_FilterParam params[], params[i].val.f = val; }
+int GP_FilterParamSetFloat(GP_FilterParam params[], const char *channel_name, + float val) +{ + GP_FilterParam *param; + param = GP_FilterParamChannel(params, channel_name); + + if (param == NULL) + return 1; + + param->val.f = val; + return 0; +} + void GP_FilterParamSetUIntAll(GP_FilterParam params[], uint32_t val) { @@ -133,6 +181,19 @@ void GP_FilterParamSetUIntAll(GP_FilterParam params[], params[i].val.ui = val; }
+int GP_FilterParamSetUInt(GP_FilterParam params[], const char *channel_name, + uint32_t val) +{ + GP_FilterParam *param; + param = GP_FilterParamChannel(params, channel_name); + + if (param == NULL) + return 1; + + param->val.ui = val; + return 0; +} + void GP_FilterParamSetPtrAll(GP_FilterParam params[], void *ptr) { @@ -142,6 +203,19 @@ void GP_FilterParamSetPtrAll(GP_FilterParam params[], params[i].val.ptr = ptr; }
+int GP_FilterParamSetPtr(GP_FilterParam params[], const char *channel_name, + void *ptr) +{ + GP_FilterParam *param; + param = GP_FilterParamChannel(params, channel_name); + + if (param == NULL) + return 1; + + param->val.ptr = ptr; + return 0; +} + void GP_FilterParamFreePtrAll(GP_FilterParam params[]) { unsigned int i; diff --git a/tests/SDL/showimage.c b/tests/SDL/showimage.c index 90bc393..a63ba78 100644 --- a/tests/SDL/showimage.c +++ b/tests/SDL/showimage.c @@ -51,7 +51,8 @@ void event_loop(void) case SDLK_DOWN: { brightness-=1;
- GP_FILTER_PARAMS_INT(bitmap->pixel_type, param, brightness); + GP_FILTER_PARAMS(bitmap->pixel_type, param); + GP_FilterParamSetIntAll(param, brightness); res = GP_FilterBrightness(bitmap, NULL, param, NULL); printf("brightness = %i %ux%un", brightness, res->w, res->h);
http://repo.or.cz/w/gfxprim.git/commit/5815d5e6aec94722550bf2a5eb9da1bf3dd8a...
commit 5815d5e6aec94722550bf2a5eb9da1bf3dd8abdf Author: Cyril Hrubis metan@ucw.cz Date: Sun Jun 3 13:57:30 2012 +0200
doc: Update common filter API example.
diff --git a/doc/filters.txt b/doc/filters.txt index 9329361..32c9fe0 100644 --- a/doc/filters.txt +++ b/doc/filters.txt @@ -41,17 +41,21 @@ as arguments. /* * Filter common API. */ -GP_Context *GP_FilterFoo(const GP_Context *src, GP_Context *dst, - foo params ..., - GP_ProgressCallback *callback); +int GP_FilterFoo(const GP_Context *src, GP_Context *dst, + foo params ..., + GP_ProgressCallback *callback); + +GP_Context *GP_FilterFooAlloc(const GP_Context *src, + foo params ..., + GP_ProgressCallback *callback); -------------------------------------------------------------------------------
-Filters also exists in _Raw variant (that just takes source context, -destination context, filters parameters and progress callback). These filter -APIs are used for internal implementation and shouldn't be called by user as -the destination is expected to be crafted exactly for storing the filter -result and there are 'NO' sanity checks in place. +Filters also exists in _Raw variant whose interface is similar to the first +type of filter function. These filter APIs are used for internal +implementation and shouldn't be called by user as the destination is expected +to be crafted exactly for storing the filter result and there are 'NO' sanity +checks in place.
'You could use these at your own risk'
@@ -60,9 +64,9 @@ result and there are 'NO' sanity checks in place. /* * Raw filter common API. */ -void GP_FilterFoo_Raw(const GP_Context *src, GP_Context *dst, - foo params ..., - GP_ProgressCallback *callback); +int GP_FilterFoo_Raw(const GP_Context *src, GP_Context *dst, + foo params ..., + GP_ProgressCallback *callback); -------------------------------------------------------------------------------
Point operation filters
-----------------------------------------------------------------------
Summary of changes: doc/filters.txt | 168 +++++++++++++++++++++++++++++++++++--- include/filters/GP_FilterParam.h | 77 +++++++++++------- libs/filters/GP_FilterParam.c | 78 +++++++++++++++++- tests/SDL/showimage.c | 3 +- 4 files changed, 283 insertions(+), 43 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.