mirror of
https://github.com/webmproject/libwebp.git
synced 2025-07-13 14:34:33 +02:00
fix rescaling bug (uninitialized read, see bug #254).
the x_add/x_sub increments were wrong for u/v in the upscaling case. They shouldn't be left to the caller's discretion, but set up by WebPRescalerInit to their exact necessary values. -> Cleaned-up WebPRescalerInit() param list. -> added safety asserts -> removed the mips32/mips_r2 variant of "ImportRow" which were buggy prior Change-Id: I347c75804d835811e7025de92a0758d7929dfc09
This commit is contained in:
@ -19,9 +19,11 @@
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
void WebPRescalerInit(WebPRescaler* const wrk, int src_width, int src_height,
|
||||
uint8_t* const dst, int dst_width, int dst_height,
|
||||
int dst_stride, int num_channels, int x_add, int x_sub,
|
||||
int y_add, int y_sub, int32_t* const work) {
|
||||
uint8_t* const dst,
|
||||
int dst_width, int dst_height, int dst_stride,
|
||||
int num_channels, int32_t* const work) {
|
||||
const int x_add = src_width, x_sub = dst_width;
|
||||
const int y_add = src_height, y_sub = dst_height;
|
||||
wrk->x_expand = (src_width < dst_width);
|
||||
wrk->src_width = src_width;
|
||||
wrk->src_height = src_height;
|
||||
@ -36,11 +38,12 @@ void WebPRescalerInit(WebPRescaler* const wrk, int src_width, int src_height,
|
||||
wrk->y_accum = y_add;
|
||||
wrk->y_add = y_add;
|
||||
wrk->y_sub = y_sub;
|
||||
wrk->fx_scale = (1 << WEBP_RESCALER_RFIX) / x_sub;
|
||||
wrk->fy_scale = (1 << WEBP_RESCALER_RFIX) / y_sub;
|
||||
wrk->fxy_scale = wrk->x_expand ?
|
||||
((int64_t)dst_height << WEBP_RESCALER_RFIX) / (x_sub * src_height) :
|
||||
((int64_t)dst_height << WEBP_RESCALER_RFIX) / (x_add * src_height);
|
||||
if (!wrk->x_expand) { // fx_scale is not used otherwise
|
||||
wrk->fx_scale = (1 << WEBP_RESCALER_RFIX) / wrk->x_sub;
|
||||
}
|
||||
wrk->fy_scale = (1 << WEBP_RESCALER_RFIX) / wrk->y_sub;
|
||||
wrk->fxy_scale =
|
||||
((int64_t)dst_height << WEBP_RESCALER_RFIX) / (wrk->x_add * src_height);
|
||||
wrk->irow = work;
|
||||
wrk->frow = work + num_channels * dst_width;
|
||||
|
||||
|
@ -46,8 +46,6 @@ void WebPRescalerInit(WebPRescaler* const rescaler,
|
||||
uint8_t* const dst,
|
||||
int dst_width, int dst_height, int dst_stride,
|
||||
int num_channels,
|
||||
int x_add, int x_sub,
|
||||
int y_add, int y_sub,
|
||||
int32_t* const work);
|
||||
|
||||
// Returns the number of input lines needed next to produce one output line,
|
||||
|
Reference in New Issue
Block a user