diff --git a/src/dsp/rescaler.c b/src/dsp/rescaler.c index 7bdae1a7..72ad04ca 100644 --- a/src/dsp/rescaler.c +++ b/src/dsp/rescaler.c @@ -110,7 +110,7 @@ void WebPRescalerExportRowExpandC(WebPRescaler* const wrk) { } } else { const uint32_t B = WEBP_RESCALER_FRAC(-wrk->y_accum, wrk->y_sub); - const uint32_t A = WEBP_RESCALER_ONE - B; + const uint32_t A = (uint32_t)(WEBP_RESCALER_ONE - B); for (x_out = 0; x_out < x_out_max; ++x_out) { const uint64_t I = (uint64_t)A * frow[x_out] + (uint64_t)B * irow[x_out]; diff --git a/src/dsp/rescaler_sse2.c b/src/dsp/rescaler_sse2.c index a0534cab..d0cfc7d0 100644 --- a/src/dsp/rescaler_sse2.c +++ b/src/dsp/rescaler_sse2.c @@ -105,7 +105,7 @@ static void RescalerExportRowExpandSSE2(WebPRescaler* const wrk) { } } else { const uint32_t B = WEBP_RESCALER_FRAC(-wrk->y_accum, wrk->y_sub); - const uint32_t A = WEBP_RESCALER_ONE - B; + const uint32_t A = (uint32_t)(WEBP_RESCALER_ONE - B); const __m128i mA = _mm_set_epi64x(A, A); const __m128i mB = _mm_set_epi64x(B, B); const __m128i rounder = _mm_set_epi64x(ROUNDER, ROUNDER); diff --git a/src/utils/rescaler.h b/src/utils/rescaler.h index 61405875..98b01a76 100644 --- a/src/utils/rescaler.h +++ b/src/utils/rescaler.h @@ -22,7 +22,8 @@ extern "C" { #define WEBP_RESCALER_RFIX 32 // fixed-point precision for multiplies #define WEBP_RESCALER_ONE (1ull << WEBP_RESCALER_RFIX) -#define WEBP_RESCALER_FRAC(x, y) (((uint64_t)(x) << WEBP_RESCALER_RFIX) / (y)) +#define WEBP_RESCALER_FRAC(x, y) \ + ((uint32_t)(((uint64_t)(x) << WEBP_RESCALER_RFIX) / (y))) // Structure used for on-the-fly rescaling typedef uint32_t rescaler_t; // type for side-buffer