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 0192d34fbb5325dc78143d0bb8438c6d2613aadd (commit) via aba01e605969e8c5c6bfaee0759d1035522d47ef (commit) from f0637e601e591b56c6b074a6ca7e51af29eb182d (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/0192d34fbb5325dc78143d0bb8438c6d2613a...
commit 0192d34fbb5325dc78143d0bb8438c6d2613aadd Author: Cyril Hrubis metan@ucw.cz Date: Sun May 25 22:06:06 2014 +0200
filters: ResizeLinearLF: Improve precision
Improves precision which fixes artefacts when downscaling from big image to small image or with close to 1:1 ratio.
Signed-off-by: Cyril Hrubis metan@ucw.cz
diff --git a/libs/filters/GP_ResizeLinear.gen.c.t b/libs/filters/GP_ResizeLinear.gen.c.t index d0169df5..d7b57a06 100644 --- a/libs/filters/GP_ResizeLinear.gen.c.t +++ b/libs/filters/GP_ResizeLinear.gen.c.t @@ -50,17 +50,20 @@ for (x = 0; x < dst->w; x++) { /* Get first left pixel */ %% for c in pt.chanslist - {{ c.name }}_res[x] += {{ c.name }}[xmap[x]] * (MULT - xoff[x]) * {{ mult }} / MULT; + uint32_t {{ c.name }}_tmp = {{ c.name }}[xmap[x]] * (MULT - xoff[x]) / DIV; %% endfor /* Sum middle pixels */ for (j = xmap[x]+1; j < xmap[x+1]; j++) { %% for c in pt.chanslist - {{ c.name }}_res[x] += {{ c.name }}[j] * {{ mult }}; + {{ c.name }}_tmp += {{ c.name }}[j] * MULT / DIV; %% endfor } /* Add last right pixel */ %% for c in pt.chanslist - {{ c.name }}_res[x] += {{ c.name }}[xmap[x+1]] * xoff[x+1] * {{ mult }} / MULT; + {{ c.name }}_tmp += {{ c.name }}[xmap[x+1]] * xoff[x+1] / DIV; +%% endfor +%% for c in pt.chanslist + {{ c.name }}_res[x] += {{ c.name }}_tmp * {{ mult }} / DIV; %% endfor } %% endmacro @@ -73,8 +76,8 @@ static int resize_lin_lf_{{ pt.name }}(const GP_Context *src, GP_Context *dst, { uint32_t xmap[dst->w + 1]; uint32_t ymap[dst->h + 1]; - uint16_t xoff[dst->w + 1]; - uint16_t yoff[dst->h + 1]; + uint32_t xoff[dst->w + 1]; + uint32_t yoff[dst->h + 1]; %% for c in pt.chanslist uint32_t {{ c.name }}[src->w]; %% endfor @@ -82,23 +85,26 @@ static int resize_lin_lf_{{ pt.name }}(const GP_Context *src, GP_Context *dst, uint32_t i, j; {# Reduce fixed point bits for > 8 bits per channel (fixed 16 bit Grayscale) #} %% if pt.chanslist[0].size > 8 - const int MULT=256; + const int MULT=1<<10; + const int DIV=1<<6; %% else - const int MULT=1024; + const int MULT=1<<14; + const int DIV=1<<9; %% endif + /* Pre-compute mapping for interpolation */ for (i = 0; i <= dst->w; i++) { - xmap[i] = (i * src->w) / dst->w; - xoff[i] = (MULT * (i * src->w))/dst->w - MULT * xmap[i]; + xmap[i] = ((uint64_t)i * src->w) / dst->w; + xoff[i] = ((uint64_t)MULT * (i * src->w))/dst->w - MULT * xmap[i]; }
for (i = 0; i <= dst->h; i++) { - ymap[i] = (i * src->h) / dst->h; - yoff[i] = (MULT * (i * src->h))/dst->h - MULT * ymap[i]; + ymap[i] = ((uint64_t)i * src->h) / dst->h; + yoff[i] = ((uint64_t)MULT * (i * src->h))/dst->h - MULT * ymap[i]; }
/* Compute pixel area for the final normalization */ - uint32_t div = (xmap[1] * MULT + xoff[1]) * (ymap[1] * MULT + yoff[1]) / MULT; + uint32_t div = (((uint64_t)(xmap[1] * MULT + xoff[1]) * ((uint64_t)ymap[1] * MULT + yoff[1]) + DIV/2) / DIV + DIV/2)/DIV;
/* Prefetch first row */ {{ fetch_rows(pt, 0) }}
http://repo.or.cz/w/gfxprim.git/commit/aba01e605969e8c5c6bfaee0759d1035522d4...
commit aba01e605969e8c5c6bfaee0759d1035522d47ef Author: Cyril Hrubis metan@ucw.cz Date: Sun May 25 16:21:51 2014 +0200
filters: ResizeLinearLF: More work
Removes useless if in inner cycle which brings another 10% speedup.
Do not fetch border rows twice about 20% speedup.
Get rid of the C macro, use jinja macro.
Signed-off-by: Cyril Hrubis metan@ucw.cz
diff --git a/libs/filters/GP_ResizeLinear.gen.c.t b/libs/filters/GP_ResizeLinear.gen.c.t index a7887907..d0169df5 100644 --- a/libs/filters/GP_ResizeLinear.gen.c.t +++ b/libs/filters/GP_ResizeLinear.gen.c.t @@ -37,28 +37,33 @@
#include "GP_Resize.h"
-%%- macro fetch_row(pt, src, y, suff) - { - unsigned int x; - +%%- macro fetch_rows(pt, y) for (x = 0; x < src->w; x++) { - GP_Pixel pix = GP_GetPixel_Raw_{{ pt.pixelsize.suffix }}({{ src }}, x, {{ y }}); + GP_Pixel pix = GP_GetPixel_Raw_{{ pt.pixelsize.suffix }}(src, x, {{ y }}); %% for c in pt.chanslist - {{ c.name }}{{ suff }}[x] = GP_Pixel_GET_{{ c.name }}_{{ pt.name }}(pix); + {{ c.name }}[x] = GP_Pixel_GET_{{ c.name }}_{{ pt.name }}(pix); %% endfor } - } %% endmacro
-#define SUM(COL, COLD, MUL) - COLD[x] += (COL[xmap[x]] * (MULT - xoff[x]) * (MUL)) / MULT;-- for (j = xmap[x]+1; j < xmap[x+1]; j++) { - COLD[x] += (COL[j] * (MUL)); - } -- if (xoff[x+1]) - COLD[x] += (COL[xmap[x+1]] * xoff[x+1] * (MUL)) / MULT; +%%- macro sum_rows(pt, mult) + for (x = 0; x < dst->w; x++) { + /* Get first left pixel */ +%% for c in pt.chanslist + {{ c.name }}_res[x] += {{ c.name }}[xmap[x]] * (MULT - xoff[x]) * {{ mult }} / MULT; +%% endfor + /* Sum middle pixels */ + for (j = xmap[x]+1; j < xmap[x+1]; j++) { +%% for c in pt.chanslist + {{ c.name }}_res[x] += {{ c.name }}[j] * {{ mult }}; +%% endfor + } + /* Add last right pixel */ +%% for c in pt.chanslist + {{ c.name }}_res[x] += {{ c.name }}[xmap[x+1]] * xoff[x+1] * {{ mult }} / MULT; +%% endfor + } +%% endmacro
%% for pt in pixeltypes %% if not pt.is_unknown() and not pt.is_palette() @@ -70,6 +75,9 @@ static int resize_lin_lf_{{ pt.name }}(const GP_Context *src, GP_Context *dst, uint32_t ymap[dst->h + 1]; uint16_t xoff[dst->w + 1]; uint16_t yoff[dst->h + 1]; +%% for c in pt.chanslist + uint32_t {{ c.name }}[src->w]; +%% endfor uint32_t x, y; uint32_t i, j; {# Reduce fixed point bits for > 8 bits per channel (fixed 16 bit Grayscale) #} @@ -92,10 +100,12 @@ static int resize_lin_lf_{{ pt.name }}(const GP_Context *src, GP_Context *dst, /* Compute pixel area for the final normalization */ uint32_t div = (xmap[1] * MULT + xoff[1]) * (ymap[1] * MULT + yoff[1]) / MULT;
+ /* Prefetch first row */ + {{ fetch_rows(pt, 0) }} + for (y = 0; y < dst->h; y++) { %% for c in pt.chanslist - uint32_t {{ c.name }}[src->w]; - uint32_t {{ c.name }}_res[src->w]; + uint32_t {{ c.name }}_res[dst->w]; %% endfor
%% for c in pt.chanslist @@ -103,31 +113,18 @@ static int resize_lin_lf_{{ pt.name }}(const GP_Context *src, GP_Context *dst, %% endfor
/* Sum first row */ - {{ fetch_row(pt, 'src', 'ymap[y]', '') }} - for (x = 0; x < dst->w; x++) { -%% for c in pt.chanslist - SUM({{ c.name }}, {{ c.name }}_res, MULT-yoff[y]); -%% endfor - } + {{ sum_rows(pt, '(MULT-yoff[y])') }}
/* Sum middle */ for (i = ymap[y]+1; i < ymap[y+1]; i++) { - {{ fetch_row(pt, 'src', 'i', '') }} - for (x = 0; x < dst->w; x++) { -%% for c in pt.chanslist - SUM({{ c.name }}, {{ c.name }}_res, MULT); -%% endfor - } + {{ fetch_rows(pt, 'i') }} + {{ sum_rows(pt, 'MULT') }} }
/* Sum last row */ if (yoff[y+1]) { - {{ fetch_row(pt, 'src', 'ymap[y+1]', '') }} - for (x = 0; x < dst->w; x++) { -%% for c in pt.chanslist - SUM({{ c.name }}, {{ c.name }}_res, yoff[y+1]); -%% endfor - } + {{ fetch_rows(pt, 'ymap[y+1]') }} + {{ sum_rows(pt, 'yoff[y+1]') }} }
for (x = 0; x < dst->w; x++) {
-----------------------------------------------------------------------
Summary of changes: libs/filters/GP_ResizeLinear.gen.c.t | 93 +++++++++++++++++---------------- 1 files changed, 48 insertions(+), 45 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.