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 1d97b3f64cb80fea14245d253f6c7db64b8495b2 (commit) from f6d646faac5ebf7a3f0831af73a79709fae9d36a (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/1d97b3f64cb80fea14245d253f6c7db64b849...
commit 1d97b3f64cb80fea14245d253f6c7db64b8495b2 Author: Cyril Hrubis metan@ucw.cz Date: Sun Jan 22 14:27:52 2012 +0100
filters: Bicubic interpolate first on x
* That way we are using the caches better.
diff --git a/libs/filters/GP_Resize.c b/libs/filters/GP_Resize.c index 05f2c3d..7b26eaa 100644 --- a/libs/filters/GP_Resize.c +++ b/libs/filters/GP_Resize.c @@ -366,6 +366,136 @@ int GP_FilterInterpolate_CubicInt(const GP_Context *src, GP_Context *dst, return 0; }
+int GP_FilterInterpolate_CubicInt2(const GP_Context *src, GP_Context *dst, + GP_ProgressCallback *callback) +{ + int32_t col_r[src->w], col_g[src->w], col_b[src->w]; + uint32_t i, j; + + GP_DEBUG(1, "Scaling image %ux%u -> %ux%u %2.2f %2.2f", + src->w, src->h, dst->w, dst->h, + 1.00 * dst->w / src->w, 1.00 * dst->h / src->h); + + for (i = 0; i < dst->h; i++) { + float y = (1.00 * i / dst->h) * src->h; + int32_t cvy[4]; + int yi = y - 1; + + if (yi < 0) + yi = 0; + + if (yi > (int)src->h - 4) + yi = src->h - 4; + + cvy[0] = cubic(yi - y) * MUL + 0.5; + cvy[1] = cubic(yi + 1 - y) * MUL + 0.5; + cvy[2] = cubic(yi + 2 - y) * MUL + 0.5; + cvy[3] = cubic(yi + 3 - y) * MUL + 0.5; + + /* Generate interpolated row */ + for (j = 0; j < src->w; j++) { + int32_t rv[4], gv[4], bv[4]; + GP_Pixel pix[4]; + + pix[0] = GP_GetPixel_Raw_24BPP(src, j, yi); + pix[1] = GP_GetPixel_Raw_24BPP(src, j, yi + 1); + pix[2] = GP_GetPixel_Raw_24BPP(src, j, yi + 2); + pix[3] = GP_GetPixel_Raw_24BPP(src, j, yi + 3); + + rv[0] = GP_Pixel_GET_R_RGB888(pix[0]); + rv[1] = GP_Pixel_GET_R_RGB888(pix[1]); + rv[2] = GP_Pixel_GET_R_RGB888(pix[2]); + rv[3] = GP_Pixel_GET_R_RGB888(pix[3]); + + gv[0] = GP_Pixel_GET_G_RGB888(pix[0]); + gv[1] = GP_Pixel_GET_G_RGB888(pix[1]); + gv[2] = GP_Pixel_GET_G_RGB888(pix[2]); + gv[3] = GP_Pixel_GET_G_RGB888(pix[3]); + + bv[0] = GP_Pixel_GET_B_RGB888(pix[0]); + bv[1] = GP_Pixel_GET_B_RGB888(pix[1]); + bv[2] = GP_Pixel_GET_B_RGB888(pix[2]); + bv[3] = GP_Pixel_GET_B_RGB888(pix[3]); + + MUL_I(rv, cvy); + MUL_I(gv, cvy); + MUL_I(bv, cvy); + + col_r[j] = SUM_I(rv); + col_g[j] = SUM_I(gv); + col_b[j] = SUM_I(bv); + } + + /* now interpolate column for new image */ + for (j = 0; j < dst->w; j++) { + float x = (1.00 * j / dst->w) * src->w; + int32_t cvx[4], rv[4], gv[4], bv[4]; + int32_t r, g, b; + int xi = x - 1; + + if (xi < 0) + xi = 0; + + if (xi > (int)src->w - 4) + xi = src->w - 4; + + cvx[0] = cubic(xi - x) * MUL + 0.5; + cvx[1] = cubic(xi + 1 - x) * MUL + 0.5; + cvx[2] = cubic(xi + 2 - x) * MUL + 0.5; + cvx[3] = cubic(xi + 3 - x) * MUL + 0.5; + + rv[0] = col_r[xi]; + rv[1] = col_r[xi + 1]; + rv[2] = col_r[xi + 2]; + rv[3] = col_r[xi + 3]; + + gv[0] = col_g[xi]; + gv[1] = col_g[xi + 1]; + gv[2] = col_g[xi + 2]; + gv[3] = col_g[xi + 3]; + + bv[0] = col_b[xi]; + bv[1] = col_b[xi + 1]; + bv[2] = col_b[xi + 2]; + bv[3] = col_b[xi + 3]; + + MUL_I(rv, cvx); + MUL_I(gv, cvx); + MUL_I(bv, cvx); + + r = (SUM_I(rv) + MUL*MUL/2) / MUL / MUL; + g = (SUM_I(gv) + MUL*MUL/2) / MUL / MUL; + b = (SUM_I(bv) + MUL*MUL/2) / MUL / MUL; + + 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; + + GP_Pixel pix = GP_Pixel_CREATE_RGB888((uint8_t)r, (uint8_t)g, (uint8_t)b); + GP_PutPixel_Raw_24BPP(dst, j, i, pix); + } + + if (GP_ProgressCallbackReport(callback, i, dst->h, dst->w)) + return 1; + } + + GP_ProgressCallbackDone(callback); + return 0; +}
int GP_FilterResize_Raw(const GP_Context *src, GP_Context *dst, GP_InterpolationType type, @@ -377,7 +507,7 @@ int GP_FilterResize_Raw(const GP_Context *src, GP_Context *dst, case GP_INTERP_CUBIC: return GP_FilterInterpolate_Cubic(src, dst, callback); case GP_INTERP_CUBIC_INT: - return GP_FilterInterpolate_CubicInt(src, dst, callback); + return GP_FilterInterpolate_CubicInt2(src, dst, callback); }
return 1;
-----------------------------------------------------------------------
Summary of changes: libs/filters/GP_Resize.c | 132 +++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 131 insertions(+), 1 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.