From a3dddea9b5d0d445c24c756a406713686abf1257 Mon Sep 17 00:00:00 2001 From: Vincent Rabaud Date: Mon, 24 Nov 2025 16:17:58 +0100 Subject: [PATCH] Prevent some overflow during MBAnalyze kThreshold * m2 can be 17 * (16*(16*255)^2) in the worst case. Change-Id: Id9d82a7f2f933273bb04e7df37aaf724b3a69f43 --- src/enc/analysis_enc.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/enc/analysis_enc.c b/src/enc/analysis_enc.c index aebdccab..e06a3682 100644 --- a/src/enc/analysis_enc.c +++ b/src/enc/analysis_enc.c @@ -261,9 +261,10 @@ static int FastMBAnalyze(VP8EncIterator* const it) { // Empirical cut-off value, should be around 16 (~=block size). We use the // [8-17] range and favor intra4 at high quality, intra16 for low quality. const int q = (int)it->enc->config->quality; - const uint32_t kThreshold = 8 + (17 - 8) * q / 100; + const uint64_t kThreshold = 8 + (17 - 8) * q / 100; int k; - uint32_t dc[16], m, m2; + uint32_t dc[16]; + uint64_t m, m2; for (k = 0; k < 16; k += 4) { VP8Mean16x4(it->yuv_in + Y_OFF_ENC + k * BPS, &dc[k]); }