From 416b7a6b95bd179486d410751dd4ff4fe48b8959 Mon Sep 17 00:00:00 2001 From: Pascal Massimino Date: Mon, 16 May 2011 17:11:32 -0700 Subject: [PATCH] raise the fixed-point precision for the rescaler for super-large upscaling factor (32x and up), 20bits was not enough. Change-Id: I7b0d1975d0609948d464cfc3aeff1a70df16dc57 --- src/enc/picture.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/enc/picture.c b/src/enc/picture.c index a3323d2b..daf61919 100644 --- a/src/enc/picture.c +++ b/src/enc/picture.c @@ -222,7 +222,7 @@ int WebPPictureCrop(WebPPicture* const pic, //----------------------------------------------------------------------------- // Simple picture rescaler -#define RFIX 20 +#define RFIX 30 #define MULT(x,y) (((int64_t)(x) * (y) + (1 << (RFIX - 1))) >> RFIX) static inline void ImportRow(const uint8_t* src, int src_width, int32_t* frow, int32_t* irow, int dst_width) { @@ -264,7 +264,7 @@ static inline void ImportRow(const uint8_t* src, int src_width, } static void ExportRow(int32_t* frow, int32_t* irow, uint8_t* dst, int dst_width, - const int yscale, const int fxy_scale) { + const int yscale, const int64_t fxy_scale) { int x_out; for (x_out = 0; x_out < dst_width; ++x_out) { const int frac = MULT(frow[x_out], yscale); @@ -281,7 +281,7 @@ static void RescalePlane(const uint8_t* src, int32_t* const work) { const int x_expand = (src_width < dst_width); const int fy_scale = (1 << RFIX) / dst_height; - const int fxy_scale = x_expand ? + const int64_t fxy_scale = x_expand ? ((int64_t)dst_height << RFIX) / (dst_width * src_height) : ((int64_t)dst_height << RFIX) / (src_width * src_height); int y_accum = src_height;