Prevent some overflow during MBAnalyze

kThreshold * m2 can be 17 * (16*(16*255)^2) in the worst case.

Change-Id: Id9d82a7f2f933273bb04e7df37aaf724b3a69f43
This commit is contained in:
Vincent Rabaud
2025-11-24 16:17:58 +01:00
parent 5465220b03
commit a3dddea9b5

View File

@@ -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]);
}