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 daafd38370880ea9d6ab72cc60735a1613c8820f (commit) from bc90b8ca4857bb02db99601f3022907a08d7719d (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/daafd38370880ea9d6ab72cc60735a1613c88...
commit daafd38370880ea9d6ab72cc60735a1613c8820f Author: Cyril Hrubis metan@ucw.cz Date: Sun Aug 18 23:33:33 2013 +0200
filters: Templatize linear convolutions.
Signed-off-by: Cyril Hrubis metan@ucw.cz
diff --git a/libs/filters/GP_LinearConvolution.c b/libs/filters/GP_LinearConvolution.c new file mode 100644 index 0000000..8709407 --- /dev/null +++ b/libs/filters/GP_LinearConvolution.c @@ -0,0 +1,97 @@ +/***************************************************************************** + * This file is part of gfxprim library. * + * * + * Gfxprim is free software; you can redistribute it and/or * + * modify it under the terms of the GNU Lesser General Public * + * License as published by the Free Software Foundation; either * + * version 2.1 of the License, or (at your option) any later version. * + * * + * Gfxprim is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * + * Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public * + * License along with gfxprim; if not, write to the Free Software * + * Foundation, Inc., 51 Franklin Street, Fifth Floor, * + * Boston, MA 02110-1301 USA * + * * + * Copyright (C) 2009-2013 Cyril Hrubis metan@ucw.cz * + * * + *****************************************************************************/ + +#include "core/GP_Context.h" +#include "core/GP_Debug.h" + +#include "GP_Linear.h" + +static int h_callback(GP_ProgressCallback *self) +{ + GP_ProgressCallback *callback = self->priv; + + callback->percentage = self->percentage / 2; + return callback->callback(callback); +} + +static int v_callback(GP_ProgressCallback *self) +{ + GP_ProgressCallback *callback = self->priv; + + callback->percentage = self->percentage / 2 + 50; + return callback->callback(callback); +} + +int GP_FilterVHLinearConvolution_Raw(const GP_Context *src, + GP_Coord x_src, GP_Coord y_src, + GP_Size w_src, GP_Size h_src, + GP_Context *dst, + GP_Coord x_dst, GP_Coord y_dst, + float hkernel[], uint32_t kw, float hkern_div, + float vkernel[], uint32_t kh, float vkern_div, + GP_ProgressCallback *callback) +{ + GP_ProgressCallback *new_callback; + + GP_ProgressCallback conv_callback = { + .callback = h_callback, + .priv = callback, + }; + + return 0; + new_callback = callback ? &conv_callback : NULL; + + if (GP_FilterVLinearConvolution_Raw(src, x_src, y_src, w_src, h_src, + dst, x_dst, y_dst, + hkernel, kw, hkern_div, + new_callback)) + return 1; + + conv_callback.callback = v_callback; + + if (GP_FilterHLinearConvolution_Raw(dst, x_src, y_src, w_src, h_src, + dst, x_dst, y_dst, + vkernel, kh, vkern_div, + new_callback)) + return 1; + + GP_ProgressCallbackDone(callback); + return 0; +} + +void GP_FilterKernelPrint_Raw(float kernel[], int kw, int kh, float kern_div) +{ + int i, j; + + for (i = 0; i < kw; i++) { + + if (i == kw/2) + printf("% 8.2f * | ", 1/kern_div); + else + printf(" | "); + + for (j = 0; j < kh; j++) + printf("% 8.2f ", kernel[j + i * kw]); + + printf("|n"); + } +} diff --git a/libs/filters/GP_Linear.c b/libs/filters/GP_LinearConvolution.gen.c.t similarity index 52% rename from libs/filters/GP_Linear.c rename to libs/filters/GP_LinearConvolution.gen.c.t index 5956b09..2a7337c 100644 --- a/libs/filters/GP_Linear.c +++ b/libs/filters/GP_LinearConvolution.gen.c.t @@ -16,24 +16,32 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, * * Boston, MA 02110-1301 USA * * * - * Copyright (C) 2009-2012 Cyril Hrubis metan@ucw.cz * + * Copyright (C) 2009-2013 Cyril Hrubis metan@ucw.cz * * * *****************************************************************************/
+%% extends "filter.c.t" + +{% block descr %}Linear Convolution{% endblock %} + +%% block body + #include <errno.h>
#include "core/GP_Context.h" #include "core/GP_GetPutPixel.h" #include "core/GP_TempAlloc.h" #include "core/GP_Clamp.h" - #include "core/GP_Debug.h"
#include "GP_Linear.h"
#define MUL 1024
-int GP_FilterHLinearConvolution_Raw(const GP_Context *src, +%% for pt in pixeltypes +%% if not pt.is_unknown() and not pt.is_palette() + +static int h_lin_conv_{{ pt.name }}(const GP_Context *src, GP_Coord x_src, GP_Coord y_src, GP_Size w_src, GP_Size h_src, GP_Context *dst, @@ -50,51 +58,44 @@ int GP_FilterHLinearConvolution_Raw(const GP_Context *src, "offset %ix%i rectangle %ux%u", kw, x_src, y_src, w_src, h_src);
- /* Not yet implemented */ - if (src->pixel_type != GP_PIXEL_RGB888) { - errno = ENOSYS; - return 1; - } - for (i = 0; i < kw; i++) ikernel[i] = kernel[i] * MUL + 0.5;
ikern_div = kern_div * MUL + 0.5;
/* Create temporary buffers */ - GP_TempAllocCreate(temp, 3 * size * sizeof(int)); + GP_TempAllocCreate(temp, {{ len(pt.chanslist) }} * size * sizeof(int));
- int *R = GP_TempAllocGet(temp, size * sizeof(int)); - int *G = GP_TempAllocGet(temp, size * sizeof(int)); - int *B = GP_TempAllocGet(temp, size * sizeof(int)); + %% for c in pt.chanslist + int *{{ c.name }} = GP_TempAllocGet(temp, size * sizeof(int)); + %% endfor
/* Do horizontal linear convolution */ for (y = 0; y < (GP_Coord)h_src; y++) { int yi = GP_MIN(y_src + y, (int)src->h - 1);
/* Fetch the whole row */ - GP_Pixel pix = GP_GetPixel_Raw_24BPP(src, 0, yi); + GP_Pixel pix = GP_GetPixel_Raw_{{ pt.pixelsize.suffix }}(src, 0, yi);
int xi = x_src - kw/2; i = 0;
/* Copy border pixel until the source image starts */ while (xi <= 0 && i < size) { - 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 c in pt.chanslist + {{ c.name }}[i] = GP_Pixel_GET_{{ c.name }}_{{ pt.name }}(pix); + %% endfor i++; xi++; }
/* Use as much source image pixels as possible */ while (xi < (int)src->w && i < size) { - pix = GP_GetPixel_Raw_24BPP(src, xi, yi); + pix = GP_GetPixel_Raw_{{ pt.pixelsize.suffix }}(src, xi, yi);
- 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 c in pt.chanslist + {{ c.name }}[i] = GP_Pixel_GET_{{ c.name }}_{{ pt.name }}(pix); + %% endfor
i++; xi++; @@ -102,36 +103,40 @@ int GP_FilterHLinearConvolution_Raw(const GP_Context *src,
/* Copy the rest the border pixel when we are out again */ while (i < size) { - 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 c in pt.chanslist + {{ c.name }}[i] = GP_Pixel_GET_{{ c.name }}_{{ pt.name }}(pix); + %% endfor
i++; }
for (x = 0; x < (GP_Coord)w_src; x++) { - int32_t r = MUL/2, g = MUL/2, b = MUL/2; - int *pR = R + x, *pG = G + x, *pB = B + x; + %% for c in pt.chanslist + int32_t {{ c.name }}_sum = MUL/2; + int *p{{ c.name }} = {{ c.name }} + x; + %% endfor
/* count the pixel value from neighbours weighted by kernel */ for (i = 0; i < kw; i++) { - r += (*pR++) * ikernel[i]; - g += (*pG++) * ikernel[i]; - b += (*pB++) * ikernel[i]; + %% for c in pt.chanslist + {{ c.name }}_sum += (*p{{ c.name }}++) * ikernel[i]; + %% endfor }
/* divide the result */ - r /= ikern_div; - g /= ikern_div; - b /= ikern_div; + %% for c in pt.chanslist + {{ c.name }}_sum /= ikern_div; + %% endfor
/* and clamp just to be extra sure */ - r = GP_CLAMP(r, 0, 255); - g = GP_CLAMP(g, 0, 255); - b = GP_CLAMP(b, 0, 255); - - GP_PutPixel_Raw_24BPP(dst, x_dst + x, y_dst + y, - GP_Pixel_CREATE_RGB888(r, g, b)); + %% for c in pt.chanslist + {{ c.name }}_sum = GP_CLAMP({{ c.name }}_sum, 0, {{ c.max }}); + %% endfor + + GP_PutPixel_Raw_{{ pt.pixelsize.suffix }}(dst, x_dst + x, y_dst + y, + GP_Pixel_CREATE_{{ pt.name }}( + {{ expand_chanslist(pt, "", "_sum") }} + )); }
if (GP_ProgressCallbackReport(callback, y, h_src, w_src)) { @@ -146,7 +151,38 @@ int GP_FilterHLinearConvolution_Raw(const GP_Context *src, return 0; }
-int GP_FilterVLinearConvolution_Raw(const GP_Context *src, +%% endif +%% endfor + + +int GP_FilterHLinearConvolution_Raw(const GP_Context *src, + GP_Coord x_src, GP_Coord y_src, + GP_Size w_src, GP_Size h_src, + GP_Context *dst, + GP_Coord x_dst, GP_Coord y_dst, + float kernel[], uint32_t kw, float kern_div, + GP_ProgressCallback *callback) +{ + switch (src->pixel_type) { + %% for pt in pixeltypes + %% if not pt.is_unknown() and not pt.is_palette() + case GP_PIXEL_{{ pt.name }}: + return h_lin_conv_{{ pt.name }}(src, x_src, y_src, w_src, h_src, + dst, x_dst, y_dst, + kernel, kw, kern_div, callback); + break; + %% endif + %% endfor + default: + errno = EINVAL; + return -1; + } +} + +%% for pt in pixeltypes +%% if not pt.is_unknown() and not pt.is_palette() + +static int v_lin_conv_{{ pt.name }}(const GP_Context *src, GP_Coord x_src, GP_Coord y_src, GP_Size w_src, GP_Size h_src, GP_Context *dst, @@ -162,40 +198,30 @@ int GP_FilterVLinearConvolution_Raw(const GP_Context *src, for (i = 0; i < kh; i++) ikernel[i] = kernel[i] * MUL + 0.5;
- GP_DEBUG(1, "Vertical linear convolution kernel width %u " - "offset %ix%i rectangle %ux%u", - kh, x_src, y_src, w_src, h_src); - - /* Not yet implemented */ - if (src->pixel_type != GP_PIXEL_RGB888) { - errno = ENOSYS; - return 1; - } - ikern_div = kern_div * MUL + 0.5;
/* Create temporary buffers */ - GP_TempAllocCreate(temp, 3 * size * sizeof(int)); + GP_TempAllocCreate(temp, {{ len(pt.chanslist) }} * size * sizeof(int));
- int *R = GP_TempAllocGet(temp, size * sizeof(int)); - int *G = GP_TempAllocGet(temp, size * sizeof(int)); - int *B = GP_TempAllocGet(temp, size * sizeof(int)); + %% for c in pt.chanslist + int *{{ c.name }} = GP_TempAllocGet(temp, size * sizeof(int)); + %% endfor
/* Do vertical linear convolution */ for (x = 0; x < (GP_Coord)w_src; x++) { int xi = GP_MIN(x_src + x, (int)src->w - 1);
/* Fetch the whole row */ - GP_Pixel pix = GP_GetPixel_Raw_24BPP(src, xi, 0); + GP_Pixel pix = GP_GetPixel_Raw_{{ pt.pixelsize.suffix }}(src, xi, 0);
int yi = y_src - kh/2; i = 0;
/* Copy border pixel until the source image starts */ while (yi <= 0 && i < size) { - 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 c in pt.chanslist + {{ c.name }}[i] = GP_Pixel_GET_{{ c.name }}_{{ pt.name }}(pix); + %% endfor
i++; yi++; @@ -203,11 +229,11 @@ int GP_FilterVLinearConvolution_Raw(const GP_Context *src,
/* Use as much source image pixels as possible */ while (yi < (int)src->h && i < size) { - pix = GP_GetPixel_Raw_24BPP(src, xi, yi); + pix = GP_GetPixel_Raw_{{ pt.pixelsize.suffix }}(src, xi, yi);
- 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 c in pt.chanslist + {{ c.name }}[i] = GP_Pixel_GET_{{ c.name }}_{{ pt.name }}(pix); + %% endfor
i++; yi++; @@ -215,36 +241,40 @@ int GP_FilterVLinearConvolution_Raw(const GP_Context *src,
/* Copy the rest the border pixel when we are out again */ while (i < size) { - 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 c in pt.chanslist + {{ c.name }}[i] = GP_Pixel_GET_{{ c.name }}_{{ pt.name }}(pix); + %% endfor
i++; }
for (y = 0; y < (GP_Coord)h_src; y++) { - int32_t r = MUL/2, g = MUL/2, b = MUL/2; - int *pR = R + y, *pG = G + y, *pB = B + y; + %% for c in pt.chanslist + int32_t {{ c.name }}_sum = MUL/2; + int *p{{ c.name }} = {{ c.name }} + y; + %% endfor
/* count the pixel value from neighbours weighted by kernel */ for (i = 0; i < kh; i++) { - r += (*pR++) * ikernel[i]; - g += (*pG++) * ikernel[i]; - b += (*pB++) * ikernel[i]; + %% for c in pt.chanslist + {{ c.name }}_sum += (*p{{ c.name }}++) * ikernel[i]; + %% endfor }
/* divide the result */ - r /= ikern_div; - g /= ikern_div; - b /= ikern_div; + %% for c in pt.chanslist + {{ c.name }}_sum /= ikern_div; + %% endfor
/* and clamp just to be extra sure */ - r = GP_CLAMP(r, 0, 255); - g = GP_CLAMP(g, 0, 255); - b = GP_CLAMP(b, 0, 255); - - GP_PutPixel_Raw_24BPP(dst, x_dst + x, y_dst + y, - GP_Pixel_CREATE_RGB888(r, g, b)); + %% for c in pt.chanslist + {{ c.name }}_sum = GP_CLAMP({{ c.name }}_sum, 0, {{ c.max }}); + %% endfor + + GP_PutPixel_Raw_{{ pt.pixelsize.suffix }}(dst, x_dst + x, y_dst + y, + GP_Pixel_CREATE_{{ pt.name }}( + {{ expand_chanslist(pt, "", "_sum") }} + )); }
if (GP_ProgressCallbackReport(callback, x, w_src, h_src)) { @@ -259,81 +289,56 @@ int GP_FilterVLinearConvolution_Raw(const GP_Context *src, return 0; }
-static int h_callback(GP_ProgressCallback *self) -{ - GP_ProgressCallback *callback = self->priv; +%% endif +%% endfor
- callback->percentage = self->percentage / 2; - return callback->callback(callback); -} - -static int v_callback(GP_ProgressCallback *self) +int GP_FilterVLinearConvolution_Raw(const GP_Context *src, + GP_Coord x_src, GP_Coord y_src, + GP_Size w_src, GP_Size h_src, + GP_Context *dst, + GP_Coord x_dst, GP_Coord y_dst, + float kernel[], uint32_t kh, float kern_div, + GP_ProgressCallback *callback) { - GP_ProgressCallback *callback = self->priv; + GP_DEBUG(1, "Vertical linear convolution kernel width %u " + "offset %ix%i rectangle %ux%u", + kh, x_src, y_src, w_src, h_src);
- callback->percentage = self->percentage / 2 + 50; - return callback->callback(callback); + switch (src->pixel_type) { + %% for pt in pixeltypes + %% if not pt.is_unknown() and not pt.is_palette() + case GP_PIXEL_{{ pt.name }}: + return v_lin_conv_{{ pt.name }}(src, x_src, y_src, w_src, h_src, + dst, x_dst, y_dst, + kernel, kh, kern_div, callback); + break; + %% endif + %% endfor + default: + errno = EINVAL; + return -1; + } }
-int GP_FilterVHLinearConvolution_Raw(const GP_Context *src, - GP_Coord x_src, GP_Coord y_src, - GP_Size w_src, GP_Size h_src, - GP_Context *dst, - GP_Coord x_dst, GP_Coord y_dst, - float hkernel[], uint32_t kw, float hkern_div, - float vkernel[], uint32_t kh, float vkern_div, - GP_ProgressCallback *callback) -{ - GP_ProgressCallback *new_callback; - - GP_ProgressCallback conv_callback = { - .callback = h_callback, - .priv = callback, - }; - - new_callback = callback ? &conv_callback : NULL; - - if (GP_FilterVLinearConvolution_Raw(src, x_src, y_src, w_src, h_src, - dst, x_dst, y_dst, - hkernel, kw, hkern_div, - new_callback)) - return 1; - - conv_callback.callback = v_callback; - - if (GP_FilterHLinearConvolution_Raw(dst, x_src, y_src, w_src, h_src, - dst, x_dst, y_dst, - vkernel, kh, vkern_div, - new_callback)) - return 1; +%% for pt in pixeltypes +%% if not pt.is_unknown() and not pt.is_palette()
- GP_ProgressCallbackDone(callback); - return 0; -} - -int GP_FilterLinearConvolution_Raw(const GP_Context *src, - GP_Coord x_src, GP_Coord y_src, - GP_Size w_src, GP_Size h_src, - GP_Context *dst, - GP_Coord x_dst, GP_Coord y_dst, - float kernel[], uint32_t kw, uint32_t kh, - float kern_div, GP_ProgressCallback *callback) +static int lin_conv_{{ pt.name }}(const GP_Context *src, + GP_Coord x_src, GP_Coord y_src, + GP_Size w_src, GP_Size h_src, + GP_Context *dst, + GP_Coord x_dst, GP_Coord y_dst, + float kernel[], uint32_t kw, uint32_t kh, + float kern_div, GP_ProgressCallback *callback) { GP_Coord x, y; unsigned int i, j;
- GP_DEBUG(1, "Linear convolution kernel %ix%i rectangle %ux%u", - kw, kh, w_src, h_src); - - /* Not yet implemented */ - if (src->pixel_type != GP_PIXEL_RGB888) { - errno = ENOSYS; - return 1; - } - /* Do linear convolution */ for (y = 0; y < (GP_Coord)h_src; y++) { - uint32_t R[kw][kh], G[kw][kh], B[kw][kh]; + %% for c in pt.chanslist + uint32_t {{ c.name }}[kw][kh]; + %% endfor GP_Pixel pix;
/* Prefill the buffer on the start */ @@ -345,18 +350,20 @@ int GP_FilterLinearConvolution_Raw(const GP_Context *src, xi = GP_CLAMP(xi, 0, (int)src->w - 1); yi = GP_CLAMP(yi, 0, (int)src->h - 1);
- pix = GP_GetPixel_Raw_24BPP(src, xi, yi); + pix = GP_GetPixel_Raw_{{ pt.pixelsize.suffix }}(src, xi, yi);
- R[i][j] = GP_Pixel_GET_R_RGB888(pix); - G[i][j] = GP_Pixel_GET_G_RGB888(pix); - B[i][j] = GP_Pixel_GET_B_RGB888(pix); + %% for c in pt.chanslist + {{ c.name }}[i][j] = GP_Pixel_GET_{{ c.name }}_{{ pt.name }}(pix); + %% endfor } }
int idx = kw - 1;
for (x = 0; x < (GP_Coord)w_src; x++) { - float r = 0, g = 0, b = 0; + %% for c in pt.chanslist + float {{ c.name }}_sum = 0; + %% endfor
for (j = 0; j < kh; j++) { int xi = x_src + x + kw/2; @@ -365,11 +372,11 @@ int GP_FilterLinearConvolution_Raw(const GP_Context *src, xi = GP_CLAMP(xi, 0, (int)src->w - 1); yi = GP_CLAMP(yi, 0, (int)src->h - 1);
- pix = GP_GetPixel_Raw_24BPP(src, xi, yi); + pix = GP_GetPixel_Raw_{{ pt.pixelsize.suffix }}(src, xi, yi);
- R[idx][j] = GP_Pixel_GET_R_RGB888(pix); - G[idx][j] = GP_Pixel_GET_G_RGB888(pix); - B[idx][j] = GP_Pixel_GET_B_RGB888(pix); + %% for c in pt.chanslist + {{ c.name }}[idx][j] = GP_Pixel_GET_{{ c.name }}_{{ pt.name }}(pix); + %% endfor }
/* Count the pixel value from neighbours weighted by kernel */ @@ -382,25 +389,25 @@ int GP_FilterLinearConvolution_Raw(const GP_Context *src, k = i - idx - 1;
for (j = 0; j < kh; j++) { - r += R[i][j] * kernel[k + j * kw]; - g += G[i][j] * kernel[k + j * kw]; - b += B[i][j] * kernel[k + j * kw]; + %% for c in pt.chanslist + {{ c.name }}_sum += {{ c.name }}[i][j] * kernel[k + j * kw]; + %% endfor } }
/* divide the result */ - r /= kern_div; - g /= kern_div; - b /= kern_div; + %% for c in pt.chanslist + {{ c.name }}_sum /= kern_div; + %% endfor
/* and clamp just to be extra sure */ - r = GP_CLAMP((int)r, 0, 255); - g = GP_CLAMP((int)g, 0, 255); - b = GP_CLAMP((int)b, 0, 255); + %% for c in pt.chanslist + int {{ c.name }}_res = GP_CLAMP((int){{ c.name }}_sum, 0, {{ c.max }}); + %% endfor
- pix = GP_Pixel_CREATE_RGB888((uint32_t)r, (uint32_t)g, (uint32_t)b); + pix = GP_Pixel_CREATE_{{ pt.name }}({{ expand_chanslist(pt, "", "_res") }});
- GP_PutPixel_Raw_24BPP(dst, x_dst + x, y_dst + y, pix); + GP_PutPixel_Raw_{{ pt.pixelsize.suffix }}(dst, x_dst + x, y_dst + y, pix);
idx++;
@@ -416,20 +423,34 @@ int GP_FilterLinearConvolution_Raw(const GP_Context *src, return 0; }
-void GP_FilterKernelPrint_Raw(float kernel[], int kw, int kh, float kern_div) -{ - int i, j; - - for (i = 0; i < kw; i++) { +%% endif +%% endfor
- if (i == kw/2) - printf("% 8.2f * | ", 1/kern_div); - else - printf(" | "); - - for (j = 0; j < kh; j++) - printf("% 8.2f ", kernel[j + i * kw]); +int GP_FilterLinearConvolution_Raw(const GP_Context *src, + GP_Coord x_src, GP_Coord y_src, + GP_Size w_src, GP_Size h_src, + GP_Context *dst, + GP_Coord x_dst, GP_Coord y_dst, + float kernel[], uint32_t kw, uint32_t kh, + float kern_div, GP_ProgressCallback *callback) +{ + GP_DEBUG(1, "Linear convolution kernel %ix%i rectangle %ux%u", + kw, kh, w_src, h_src);
- printf("|n"); + switch (src->pixel_type) { + %% for pt in pixeltypes + %% if not pt.is_unknown() and not pt.is_palette() + case GP_PIXEL_{{ pt.name }}: + return lin_conv_{{ pt.name }}(src, x_src, y_src, w_src, h_src, + dst, x_dst, y_dst, + kernel, kw, kh, kern_div, callback); + break; + %% endif + %% endfor + default: + errno = EINVAL; + return -1; } } + +%% endblock body diff --git a/libs/filters/Makefile b/libs/filters/Makefile index e331b59..05a310e 100644 --- a/libs/filters/Makefile +++ b/libs/filters/Makefile @@ -13,7 +13,8 @@ RESAMPLING_FILTERS=GP_ResizeNN.gen.c GP_Cubic.gen.c GP_ResizeCubic.gen.c GP_ResizeLinear.gen.c
GENSOURCES=GP_MirrorV.gen.c GP_Rotate.gen.c GP_FloydSteinberg.gen.c GP_HilbertPeano.gen.c- $(POINT_FILTERS) $(ARITHMETIC_FILTERS) $(STATS_FILTERS) $(RESAMPLING_FILTERS) + $(POINT_FILTERS) $(ARITHMETIC_FILTERS) $(STATS_FILTERS) $(RESAMPLING_FILTERS)+ GP_LinearConvolution.gen.c
CSOURCES=$(filter-out $(wildcard *.gen.c),$(wildcard *.c)) LIBNAME=filters
-----------------------------------------------------------------------
Summary of changes: libs/filters/GP_LinearConvolution.c | 97 +++++ .../{GP_Linear.c => GP_LinearConvolution.gen.c.t} | 371 +++++++++++--------- libs/filters/Makefile | 3 +- 3 files changed, 295 insertions(+), 176 deletions(-) create mode 100644 libs/filters/GP_LinearConvolution.c rename libs/filters/{GP_Linear.c => GP_LinearConvolution.gen.c.t} (52%)
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.