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 eaa73f8e7eea739d3d14c830622c455acd6717c6 (commit) from b704cc579b2db0db8015f46acbc8c69ffcf81aa7 (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/eaa73f8e7eea739d3d14c830622c455acd671...
commit eaa73f8e7eea739d3d14c830622c455acd6717c6 Author: Cyril Hrubis metan@ucw.cz Date: Sat Jul 21 19:17:22 2012 +0200
filters: Median make use of GP_TempAlloc.
diff --git a/libs/filters/GP_Median.c b/libs/filters/GP_Median.c index 9e60d60..db58806 100644 --- a/libs/filters/GP_Median.c +++ b/libs/filters/GP_Median.c @@ -31,38 +31,30 @@
#include <string.h>
-#define HIST_INIT(w) - unsigned int R[w][256]; - unsigned int G[w][256]; - unsigned int B[w][256]; - memset(R, 0, sizeof(R)); - memset(G, 0, sizeof(G)); - memset(B, 0, sizeof(B)); - -static inline void hist_inc(unsigned int h[][256], unsigned int x, unsigned int val) +static inline void hist_inc(unsigned int *h, unsigned int x, unsigned int val) { - h[x][val]++; + h[256 * x + val]++; }
-static inline void hist_dec(unsigned int h[][256], unsigned int x, unsigned int val) +static inline void hist_dec(unsigned int *h, unsigned int x, unsigned int val) { - h[x][val]--; + h[256 * x + val]--; }
-static inline void hist_sub(unsigned int *a, unsigned int *b) +static inline void hist_sub(unsigned int *a, unsigned int *b, unsigned int x) { int j; for (j = 0; j < 256; j++) - a[j] -= b[j]; + a[j] -= b[256 * x + j]; }
-static inline void hist_add(unsigned int *a, unsigned int *b) +static inline void hist_add(unsigned int *a, unsigned int *b, unsigned int x) { int j; for (j = 0; j < 256; j++) - a[j] += b[j]; + a[j] += b[256 * x + j]; }
#define HIST_INC hist_inc @@ -96,10 +88,20 @@ static int GP_FilterMedian_Raw(const GP_Context *src,
GP_DEBUG(1, "Median filter size %ux%u xmed=%u ymed=%u", w_src, h_src, 2 * xmed + 1, 2 * ymed + 1); + + /* The buffer is w + 2*xmed + 1 size because we read the last value but we don't use it */ + unsigned int size = (w_src + 2 * xmed + 1) * sizeof(int);
/* Create and initalize arrays for row of histograms */ - /* The buffer is w + 2*xmed + 1 size because we read the last value but we don't use it */ - HIST_INIT(w_src + 2 * xmed + 1); + GP_TempAllocCreate(temp, 3 * 256 * size); + + unsigned int *R = GP_TempAllocGet(temp, 256 * size); + unsigned int *G = GP_TempAllocGet(temp, 256 * size); + unsigned int *B = GP_TempAllocGet(temp, 256 * size); + + memset(R, 0, 256 * size); + memset(G, 0, 256 * size); + memset(B, 0, 256 * size);
/* Prefill row of histograms */ for (x = 0; x < (int)w_src + 2*xmed; x++) { @@ -126,9 +128,9 @@ static int GP_FilterMedian_Raw(const GP_Context *src, /* Compute first histogram */ for (i = 0; i <= 2*xmed; i++) { - hist_add(XR, R[i]); - hist_add(XG, G[i]); - hist_add(XB, B[i]); + hist_add(XR, R, i); + hist_add(XG, G, i); + hist_add(XB, B, i); } /* Generate row */ @@ -141,13 +143,13 @@ static int GP_FilterMedian_Raw(const GP_Context *src, GP_Pixel_CREATE_RGB888(r, g, b)); /* Recompute histograms */ - hist_sub(XR, R[x]); - hist_sub(XG, G[x]); - hist_sub(XB, B[x]); + hist_sub(XR, R, x); + hist_sub(XG, G, x); + hist_sub(XB, B, x);
- hist_add(XR, R[x + 2 * xmed + 1]); - hist_add(XG, G[x + 2 * xmed + 1]); - hist_add(XB, B[x + 2 * xmed + 1]); + hist_add(XR, R, (x + 2 * xmed + 1)); + hist_add(XG, G, (x + 2 * xmed + 1)); + hist_add(XB, B, (x + 2 * xmed + 1)); }
/* Recompute histograms, remove y - ymed pixel add y + ymed + 1 */ @@ -171,11 +173,12 @@ static int GP_FilterMedian_Raw(const GP_Context *src, } if (GP_ProgressCallbackReport(callback, y, h_src, w_src)) { - // GP_TempAllocFree(temp); + GP_TempAllocFree(temp); return 1; } }
+ GP_TempAllocFree(temp); GP_ProgressCallbackDone(callback);
return 0;
-----------------------------------------------------------------------
Summary of changes: libs/filters/GP_Median.c | 59 ++++++++++++++++++++++++--------------------- 1 files changed, 31 insertions(+), 28 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.