WebPRescalerInit: add missing int64_t promotion

large values of x_add and y_add may rollover an int causing a later
assertion to fail in WebPRescalerExportRow due to fxy_scale incorrectly
being set to 0.

fixes:
src/dsp/rescaler.c:178: void WebPRescalerExportRow(WebPRescaler *const):
Assertion `wrk->src_height == wrk->dst_height && wrk->x_add == 1'
failed.

Bug: chromium:1196480
Change-Id: I2c00f015d61a1257033d8edb1edd4d060d6878b7
This commit is contained in:
James Zern 2021-04-20 14:26:06 -07:00
parent b6cf52d5b8
commit 6a9916d734

View File

@ -51,8 +51,9 @@ void WebPRescalerInit(WebPRescaler* const wrk, int src_width, int src_height,
// This is WEBP_RESCALER_FRAC(dst_height, x_add * y_add) without the cast. // This is WEBP_RESCALER_FRAC(dst_height, x_add * y_add) without the cast.
// Its value is <= WEBP_RESCALER_ONE, because dst_height <= wrk->y_add, and // Its value is <= WEBP_RESCALER_ONE, because dst_height <= wrk->y_add, and
// wrk->x_add >= 1; // wrk->x_add >= 1;
const uint64_t ratio = const uint64_t num = (uint64_t)dst_height * WEBP_RESCALER_ONE;
(uint64_t)dst_height * WEBP_RESCALER_ONE / (wrk->x_add * wrk->y_add); const uint64_t den = (uint64_t)wrk->x_add * wrk->y_add;
const uint64_t ratio = num / den;
if (ratio != (uint32_t)ratio) { if (ratio != (uint32_t)ratio) {
// When ratio == WEBP_RESCALER_ONE, we can't represent the ratio with the // When ratio == WEBP_RESCALER_ONE, we can't represent the ratio with the
// current fixed-point precision. This happens when src_height == // current fixed-point precision. This happens when src_height ==