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 47b078113632ec8cf3e760af0dce2e0bf0c01c92 (commit) via 7850ea0241dc2bef8cd4d45d3c22697206788cc9 (commit) from d093866437ca8adc100d6bc2a40011a26c26e813 (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/47b078113632ec8cf3e760af0dce2e0bf0c01...
commit 47b078113632ec8cf3e760af0dce2e0bf0c01c92 Merge: 7850ea0 d093866 Author: Cyril Hrubis metan@ucw.cz Date: Sat Jan 21 23:17:46 2012 +0100
Merge ssh://repo.or.cz/srv/git/gfxprim
http://repo.or.cz/w/gfxprim.git/commit/7850ea0241dc2bef8cd4d45d3c22697206788...
commit 7850ea0241dc2bef8cd4d45d3c22697206788cc9 Author: Cyril Hrubis metan@ucw.cz Date: Sat Jan 21 23:17:03 2012 +0100
filters: Some more fixes for blur.
diff --git a/libs/filters/GP_Linear.c b/libs/filters/GP_Linear.c index 06145f6..7101472 100644 --- a/libs/filters/GP_Linear.c +++ b/libs/filters/GP_Linear.c @@ -90,7 +90,7 @@ int GP_FilterGaussianBlur_Raw(const GP_Context *src, GP_Context *dst, float kernel_x[size_x]; gaussian_kernel_init(sigma_x, kernel_x); - if (GP_FilterHLinearConvolutionInt_Raw(src, dst, kernel_x, size_x, + if (GP_FilterHLinearConvolution_Raw(src, dst, kernel_x, size_x, new_callback)) return 1; } @@ -103,7 +103,7 @@ int GP_FilterGaussianBlur_Raw(const GP_Context *src, GP_Context *dst, float kernel_y[size_y]; gaussian_kernel_init(sigma_y, kernel_y); - if (GP_FilterVLinearConvolutionInt_Raw(dst, dst, kernel_y, size_y, + if (GP_FilterVLinearConvolution_Raw(dst, dst, kernel_y, size_y, new_callback)) return 1; } @@ -137,213 +137,6 @@ GP_Context *GP_FilterGaussianBlur(const GP_Context *src, GP_Context *dst, return dst; }
-int GP_FilterHLinearConvolution_Raw(const GP_Context *src, GP_Context *dst, - float kernel[], uint32_t kw, - GP_ProgressCallback *callback) -{ - 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); - - /* count kernel sum for normalization */ - for (i = 0; i < kw; i++) - kernel_sum += kernel[i]; - - /* do linear convolution */ - for (y = 0; y < (GP_Coord)dst->h; y++) { - uint32_t R[kw], G[kw], B[kw]; - - /* prefill the buffer on the start */ - for (i = 0; i < kw - 1; i++) { - int cx = i - kw/2; - - if (cx < 0) - cx = 0; - - pix = GP_GetPixel_Raw_24BPP(src, cx, y); - - R[i] = GP_Pixel_GET_R_RGB888(pix); - G[i] = GP_Pixel_GET_G_RGB888(pix); - 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); - - 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] * kernel[k]; - g += G[i] * kernel[k]; - b += B[i] * kernel[k]; - } - - /* normalize the result */ - r /= kernel_sum; - g /= kernel_sum; - b /= 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); - - GP_PutPixel_Raw_24BPP(dst, x, y, pix); - - idx++; - - if (idx >= (int)kw) - idx = 0; - } - - if (GP_ProgressCallbackReport(callback, y, dst->h, dst->w)) - return 1; - } - - GP_ProgressCallbackDone(callback); - return 0; -} - -/* - * Special case for vertical only kernel (10-30% faster). - * - * Can be used in-place. - */ -int GP_FilterVLinearConvolution_Raw(const GP_Context *src, GP_Context *dst, - float kernel[], uint32_t kh, - GP_ProgressCallback *callback) -{ - float kernel_sum = 0; - GP_Coord x, y; - uint32_t i; - - GP_DEBUG(1, "Vertical linear convolution kernel width %i image %ux%u", - kh, src->w, src->h); - - /* count kernel sum for normalization */ - for (i = 0; i < kh; i++) - kernel_sum += kernel[i]; - - /* do linear convolution */ - for (x = 0; x < (GP_Coord)dst->w; x++) { - GP_Pixel pix; - uint32_t R[kh], G[kh], B[kh]; - - /* prefill the buffer on the start */ - for (i = 0; i < kh - 1; i++) { - int cy = i - kh/2; - - if (cy < 0) - cy = 0; - - pix = GP_GetPixel_Raw_24BPP(src, x, cy); - - R[i] = GP_Pixel_GET_R_RGB888(pix); - G[i] = GP_Pixel_GET_G_RGB888(pix); - B[i] = GP_Pixel_GET_B_RGB888(pix); - } - - int idx = kh - 1; - - for (y = 0; y < (GP_Coord)dst->h; y++) { - float 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] * kernel[k]; - g += G[i] * kernel[k]; - b += B[i] * kernel[k]; - } - - /* normalize the result */ - r /= kernel_sum; - g /= kernel_sum; - b /= 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); - - GP_PutPixel_Raw_24BPP(dst, x, y, pix); - - idx++; - - if (idx >= (int)kh) - idx = 0; - } - - if (GP_ProgressCallbackReport(callback, x, dst->w, dst->h)) - return 1; - } - - GP_ProgressCallbackDone(callback); - return 0; -} - #define MUL 1024
#define CLAMP(val) do { @@ -353,9 +146,9 @@ int GP_FilterVLinearConvolution_Raw(const GP_Context *src, GP_Context *dst, val = 0; } while (0)
-int GP_FilterHLinearConvolutionInt_Raw(const GP_Context *src, GP_Context *dst, - float kernel[], uint32_t kw, - GP_ProgressCallback *callback) +int GP_FilterHLinearConvolution_Raw(const GP_Context *src, GP_Context *dst, + float kernel[], uint32_t kw, + GP_ProgressCallback *callback) { int32_t kernel_sum = 0; GP_Coord x, y; @@ -378,25 +171,30 @@ int GP_FilterHLinearConvolutionInt_Raw(const GP_Context *src, GP_Context *dst, uint8_t R[size], G[size], B[size];
/* Fetch the whole row */ - for (i = 0; i < size; i++) { - GP_Pixel pix; - int cx = i - kw/2; + GP_Pixel pix = GP_GetPixel_Raw_24BPP(src, 0, y);
- if (cx < 0) - cx = 0; - - if (cx >= (int)src->w) - cx = src->w - 1; - - pix = GP_GetPixel_Raw_24BPP(src, cx, y); + for (i = 0; i < kw/2; i++) { + R[i] = GP_Pixel_GET_R_RGB888(pix); + G[i] = GP_Pixel_GET_G_RGB888(pix); + B[i] = GP_Pixel_GET_B_RGB888(pix); + } + + for (i = kw/2; i < src->w; i++) { + pix = GP_GetPixel_Raw_24BPP(src, i, y);
R[i] = GP_Pixel_GET_R_RGB888(pix); G[i] = GP_Pixel_GET_G_RGB888(pix); B[i] = GP_Pixel_GET_B_RGB888(pix); } + + for (i = src->w; i < size; i++) { + R[i] = GP_Pixel_GET_R_RGB888(pix); + G[i] = GP_Pixel_GET_G_RGB888(pix); + B[i] = GP_Pixel_GET_B_RGB888(pix); + }
for (x = 0; x < (GP_Coord)dst->w; x++) { - int32_t r = 0, g = 0, b = 0; + int32_t r = MUL/2, g = MUL/2, b = MUL/2;
/* count the pixel value from neighbours weighted by kernel */ for (i = 0; i < kw; i++) { @@ -406,9 +204,9 @@ int GP_FilterHLinearConvolutionInt_Raw(const GP_Context *src, GP_Context *dst, } /* normalize the result */ - r = (r + MUL/2) / kernel_sum; - g = (g + MUL/2) / kernel_sum; - b = (b + MUL/2) / kernel_sum; + r /= kernel_sum; + g /= kernel_sum; + b /= kernel_sum; /* and clamp just to be extra sure */ CLAMP(r); @@ -427,9 +225,9 @@ int GP_FilterHLinearConvolutionInt_Raw(const GP_Context *src, GP_Context *dst, return 0; }
-int GP_FilterVLinearConvolutionInt_Raw(const GP_Context *src, GP_Context *dst, - float kernel[], uint32_t kh, - GP_ProgressCallback *callback) +int GP_FilterVLinearConvolution_Raw(const GP_Context *src, GP_Context *dst, + float kernel[], uint32_t kh, + GP_ProgressCallback *callback) { int32_t kernel_sum = 0; GP_Coord x, y; @@ -452,26 +250,30 @@ int GP_FilterVLinearConvolutionInt_Raw(const GP_Context *src, GP_Context *dst, uint8_t R[size], G[size], B[size];
/* Fetch the whole column */ - for (i = 0; i < size; i++) { - GP_Pixel pix; - - int cy = i - kh/2; + GP_Pixel pix = GP_GetPixel_Raw_24BPP(src, x, 0);
- if (cy < 0) - cy = 0; + for (i = 0; i < kh/2; i++) { + R[i] = GP_Pixel_GET_R_RGB888(pix); + G[i] = GP_Pixel_GET_G_RGB888(pix); + B[i] = GP_Pixel_GET_B_RGB888(pix); + } - if (cy >= (int)src->h) - cy = src->h - 1; - - pix = GP_GetPixel_Raw_24BPP(src, x, cy); + for (i = kh/2; i < src->h; i++) { + pix = GP_GetPixel_Raw_24BPP(src, x, i);
R[i] = GP_Pixel_GET_R_RGB888(pix); G[i] = GP_Pixel_GET_G_RGB888(pix); B[i] = GP_Pixel_GET_B_RGB888(pix); } + + for (i = src->h; i < size; i++) { + R[i] = GP_Pixel_GET_R_RGB888(pix); + G[i] = GP_Pixel_GET_G_RGB888(pix); + B[i] = GP_Pixel_GET_B_RGB888(pix); + }
for (y = 0; y < (GP_Coord)dst->h; y++) { - int32_t r = 0, g = 0, b = 0; + int32_t r = MUL/2, g = MUL/2, b = MUL/2; /* count the pixel value from neighbours weighted by kernel */ for (i = 0; i < kh; i++) { @@ -481,9 +283,9 @@ int GP_FilterVLinearConvolutionInt_Raw(const GP_Context *src, GP_Context *dst, }
/* normalize the result */ - r = (r + MUL/2) / kernel_sum; - g = (g + MUL/2) / kernel_sum; - b = (b + MUL/2) / kernel_sum; + r /= kernel_sum; + g /= kernel_sum; + b /= kernel_sum; /* and clamp just to be extra sure */ CLAMP(r);
-----------------------------------------------------------------------
Summary of changes: libs/filters/GP_Linear.c | 288 +++++++-------------------------------------- 1 files changed, 45 insertions(+), 243 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.