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 bccb0491d955bfbd1c0cb8d9ca7add8c886c50fe (commit) via 6f7a48cf329d250dea4f2c4a34cf9f0e84c78c39 (commit) via 76102f7788b5e16a479e7b3543dbac60b60eae0b (commit) via b369dc80bc0313dd846091ab433f265af1b2b081 (commit) from 2f32bbb6ab45e8648e9f1023b1ed7ca167f1a4a1 (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/bccb0491d955bfbd1c0cb8d9ca7add8c886c5...
commit bccb0491d955bfbd1c0cb8d9ca7add8c886c50fe Author: Cyril Hrubis metan@ucw.cz Date: Sat Jan 21 21:39:59 2012 +0100
filters: blur fix includes.
diff --git a/libs/filters/GP_Linear.c b/libs/filters/GP_Linear.c index 2d2970d..06145f6 100644 --- a/libs/filters/GP_Linear.c +++ b/libs/filters/GP_Linear.c @@ -22,10 +22,10 @@
#include <math.h>
-#include <GP_Context.h> -#include <GP_GetPutPixel.h> +#include <core/GP_Context.h> +#include <core/GP_GetPutPixel.h>
-#include <GP_Debug.h> +#include <core/GP_Debug.h>
#include <GP_Linear.h>
http://repo.or.cz/w/gfxprim.git/commit/6f7a48cf329d250dea4f2c4a34cf9f0e84c78...
commit 6f7a48cf329d250dea4f2c4a34cf9f0e84c78c39 Author: Cyril Hrubis metan@ucw.cz Date: Sat Jan 21 21:15:01 2012 +0100
demos: fbshow do low pass filter only when rat < 1
diff --git a/demos/fbshow/fbshow.c b/demos/fbshow/fbshow.c index 6c38216..f7ab61f 100644 --- a/demos/fbshow/fbshow.c +++ b/demos/fbshow/fbshow.c @@ -188,11 +188,13 @@ static void *image_loader(void *ptr) GP_Context *ret;
- timer_start("blur"); - callback.priv = "Blurring Image"; - if (GP_FilterGaussianBlur(img, img, 0.5/rat, 0.5/rat, &callback) == NULL) - return NULL; - timer_stop(); + if (rat < 1) { + timer_start("blur"); + callback.priv = "Blurring Image"; + if (GP_FilterGaussianBlur(img, img, 0.5/rat, 0.5/rat, &callback) == NULL) + return NULL; + timer_stop(); + }
callback.priv = "Resampling Image"; ret = GP_FilterResize(img, NULL, GP_INTERP_CUBIC_INT, img->w * rat, img->h * rat, &callback);
http://repo.or.cz/w/gfxprim.git/commit/76102f7788b5e16a479e7b3543dbac60b60ea...
commit 76102f7788b5e16a479e7b3543dbac60b60eae0b Author: Cyril Hrubis metan@ucw.cz Date: Sat Jan 21 20:11:29 2012 +0100
demos: fbshow implement thread time counter.
diff --git a/demos/fbshow/fbshow.c b/demos/fbshow/fbshow.c index c7363fd..6c38216 100644 --- a/demos/fbshow/fbshow.c +++ b/demos/fbshow/fbshow.c @@ -106,6 +106,36 @@ static const char *img_name(const char *img_path) return NULL; }
+#include <time.h> + +static struct timespec t_start; +static struct timespec t_stop; +static const char *t_name; + +static void timer_start(const char *name) +{ + t_name = name; + clock_gettime(CLOCK_THREAD_CPUTIME_ID, &t_start); +} + +static void timer_stop(void) +{ + clock_gettime(CLOCK_THREAD_CPUTIME_ID, &t_stop); + + int sec; + int nsec; + + if (t_stop.tv_nsec < t_start.tv_nsec) { + sec = t_stop.tv_sec - t_start.tv_sec - 1; + nsec = t_stop.tv_nsec + 1000000000 - t_start.tv_nsec; + } else { + sec = t_stop.tv_sec - t_start.tv_sec; + nsec = t_stop.tv_nsec - t_start.tv_nsec; + } + + printf("TIMER '%s' %i.%09i secn", t_name, sec, nsec); +} + static void *image_loader(void *ptr) { struct loader_params *params = ptr; @@ -158,10 +188,12 @@ static void *image_loader(void *ptr) GP_Context *ret;
+ timer_start("blur"); callback.priv = "Blurring Image"; if (GP_FilterGaussianBlur(img, img, 0.5/rat, 0.5/rat, &callback) == NULL) return NULL; - + timer_stop(); + callback.priv = "Resampling Image"; ret = GP_FilterResize(img, NULL, GP_INTERP_CUBIC_INT, img->w * rat, img->h * rat, &callback); GP_ContextFree(img);
http://repo.or.cz/w/gfxprim.git/commit/b369dc80bc0313dd846091ab433f265af1b2b...
commit b369dc80bc0313dd846091ab433f265af1b2b081 Author: Cyril Hrubis metan@ucw.cz Date: Sat Jan 21 19:32:05 2012 +0100
filters: Speed up the blur filter.
diff --git a/libs/filters/GP_Linear.c b/libs/filters/GP_Linear.c index da15f11..2d2970d 100644 --- a/libs/filters/GP_Linear.c +++ b/libs/filters/GP_Linear.c @@ -144,6 +144,7 @@ int GP_FilterHLinearConvolution_Raw(const GP_Context *src, GP_Context *dst, float kernel_sum = 0; GP_Coord x, y; uint32_t i; + GP_Pixel pix;
GP_DEBUG(1, "Horizontal linear convolution kernel width %i image %ux%u", kw, src->w, src->h); @@ -154,7 +155,6 @@ int GP_FilterHLinearConvolution_Raw(const GP_Context *src, GP_Context *dst,
/* do linear convolution */ for (y = 0; y < (GP_Coord)dst->h; y++) { - GP_Pixel pix; uint32_t R[kw], G[kw], B[kw];
/* prefill the buffer on the start */ @@ -346,6 +346,13 @@ int GP_FilterVLinearConvolution_Raw(const GP_Context *src, GP_Context *dst,
#define MUL 1024
+#define CLAMP(val) do { + if (val > 255) + val = 255; + if (val < 0) + val = 0; +} while (0) + int GP_FilterHLinearConvolutionInt_Raw(const GP_Context *src, GP_Context *dst, float kernel[], uint32_t kw, GP_ProgressCallback *callback) @@ -353,8 +360,9 @@ int GP_FilterHLinearConvolutionInt_Raw(const GP_Context *src, GP_Context *dst, int32_t kernel_sum = 0; GP_Coord x, y; uint32_t i; - int ikernel[kw]; - + int32_t ikernel[kw]; + uint32_t size = dst->w + kw; + for (i = 0; i < kw; i++) ikernel[i] = kernel[i] * MUL + 0.5;
@@ -367,16 +375,19 @@ int GP_FilterHLinearConvolutionInt_Raw(const GP_Context *src, GP_Context *dst,
/* do linear convolution */ for (y = 0; y < (GP_Coord)dst->h; y++) { - GP_Pixel pix; - uint32_t R[kw], G[kw], B[kw]; + uint8_t R[size], G[size], B[size];
- /* prefill the buffer on the start */ - for (i = 0; i < kw - 1; i++) { + /* Fetch the whole row */ + for (i = 0; i < size; i++) { + GP_Pixel pix; int cx = i - kw/2;
if (cx < 0) cx = 0; - + + if (cx >= (int)src->w) + cx = src->w - 1; + pix = GP_GetPixel_Raw_24BPP(src, cx, y);
R[i] = GP_Pixel_GET_R_RGB888(pix); @@ -384,63 +395,28 @@ int GP_FilterHLinearConvolutionInt_Raw(const GP_Context *src, GP_Context *dst, B[i] = GP_Pixel_GET_B_RGB888(pix); }
- int idx = kw - 1; - for (x = 0; x < (GP_Coord)dst->w; x++) { - float r = 0, g = 0, b = 0; - - int cx = x + kw/2; - - if (cx >= (int)src->w) - cx = src->w - 1; - - pix = GP_GetPixel_Raw_24BPP(src, cx, y); + int32_t r = 0, g = 0, b = 0;
- R[idx] = GP_Pixel_GET_R_RGB888(pix); - G[idx] = GP_Pixel_GET_G_RGB888(pix); - B[idx] = GP_Pixel_GET_B_RGB888(pix); - /* count the pixel value from neighbours weighted by kernel */ for (i = 0; i < kw; i++) { - int k; - - if ((int)i < idx + 1) - k = kw - idx - 1 + i; - else - k = i - idx - 1; - - r += R[i] * ikernel[k]; - g += G[i] * ikernel[k]; - b += B[i] * ikernel[k]; + r += R[i + x] * ikernel[i]; + g += G[i + x] * ikernel[i]; + b += B[i + x] * ikernel[i]; } - + /* normalize the result */ - r /= kernel_sum; - g /= kernel_sum; - b /= kernel_sum; + r = (r + MUL/2) / kernel_sum; + g = (g + MUL/2) / kernel_sum; + b = (b + MUL/2) / kernel_sum; /* and clamp just to be extra sure */ - if (r > 255) - r = 255; - if (r < 0) - r = 0; - if (g > 255) - g = 255; - if (g < 0) - g = 0; - if (b > 255) - b = 255; - if (b < 0) - b = 0; + CLAMP(r); + CLAMP(g); + CLAMP(b);
- pix = GP_Pixel_CREATE_RGB888((uint32_t)r, (uint32_t)g, (uint32_t)b); - - GP_PutPixel_Raw_24BPP(dst, x, y, pix); - - idx++; - - if (idx >= (int)kw) - idx = 0; + GP_PutPixel_Raw_24BPP(dst, x, y, + GP_Pixel_CREATE_RGB888(r, g, b)); } if (GP_ProgressCallbackReport(callback, y, dst->h, dst->w)) @@ -459,6 +435,7 @@ int GP_FilterVLinearConvolutionInt_Raw(const GP_Context *src, GP_Context *dst, GP_Coord x, y; uint32_t i; int32_t ikernel[kh]; + uint32_t size = dst->h + kh;
for (i = 0; i < kh; i++) ikernel[i] = kernel[i] * MUL + 0.5; @@ -472,16 +449,20 @@ int GP_FilterVLinearConvolutionInt_Raw(const GP_Context *src, GP_Context *dst,
/* do linear convolution */ for (x = 0; x < (GP_Coord)dst->w; x++) { - GP_Pixel pix; - uint32_t R[kh], G[kh], B[kh]; + uint8_t R[size], G[size], B[size];
- /* prefill the buffer on the start */ - for (i = 0; i < kh - 1; i++) { + /* Fetch the whole column */ + for (i = 0; i < size; i++) { + GP_Pixel pix; + int cy = i - kh/2;
if (cy < 0) cy = 0; + if (cy >= (int)src->h) + cy = src->h - 1; + pix = GP_GetPixel_Raw_24BPP(src, x, cy);
R[i] = GP_Pixel_GET_R_RGB888(pix); @@ -489,63 +470,28 @@ int GP_FilterVLinearConvolutionInt_Raw(const GP_Context *src, GP_Context *dst, B[i] = GP_Pixel_GET_B_RGB888(pix); }
- int idx = kh - 1; - for (y = 0; y < (GP_Coord)dst->h; y++) { int32_t r = 0, g = 0, b = 0; - - int cy = y + kh/2; - - if (cy >= (int)src->h) - cy = src->h - 1; - - pix = GP_GetPixel_Raw_24BPP(src, x, cy); - - R[idx] = GP_Pixel_GET_R_RGB888(pix); - G[idx] = GP_Pixel_GET_G_RGB888(pix); - B[idx] = GP_Pixel_GET_B_RGB888(pix); /* count the pixel value from neighbours weighted by kernel */ for (i = 0; i < kh; i++) { - int k; - - if ((int)i < idx + 1) - k = kh - idx - 1 + i; - else - k = i - idx - 1; - - r += R[i] * ikernel[k]; - g += G[i] * ikernel[k]; - b += B[i] * ikernel[k]; + r += R[y + i] * ikernel[i]; + g += G[y + i] * ikernel[i]; + b += B[y + i] * ikernel[i]; }
/* normalize the result */ - r /= kernel_sum; - g /= kernel_sum; - b /= kernel_sum; + r = (r + MUL/2) / kernel_sum; + g = (g + MUL/2) / kernel_sum; + b = (b + MUL/2) / kernel_sum; /* and clamp just to be extra sure */ - if (r > 255) - r = 255; - if (r < 0) - r = 0; - if (g > 255) - g = 255; - if (g < 0) - g = 0; - if (b > 255) - b = 255; - if (b < 0) - b = 0; - - pix = GP_Pixel_CREATE_RGB888((uint32_t)r, (uint32_t)g, (uint32_t)b); + CLAMP(r); + CLAMP(g); + CLAMP(b);
- GP_PutPixel_Raw_24BPP(dst, x, y, pix); - - idx++; - - if (idx >= (int)kh) - idx = 0; + GP_PutPixel_Raw_24BPP(dst, x, y, + GP_Pixel_CREATE_RGB888(r, g, b)); } if (GP_ProgressCallbackReport(callback, x, dst->w, dst->h))
-----------------------------------------------------------------------
Summary of changes: demos/fbshow/fbshow.c | 42 +++++++++++- libs/filters/GP_Linear.c | 164 +++++++++++++++------------------------------ 2 files changed, 93 insertions(+), 113 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.