PR #25405 opened by michaelni
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/25405
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/25405.patch

The per slice sum of residual magnitudes exceeds INT_MAX for noisy
32bit float slices.

Fixes: signed integer overflow: 2147482002 + 34432 cannot be represented in 
type 'int'



>From 3d348e2d4f18775ecbff36f5c5cec93ac9479afe Mon Sep 17 00:00:00 2001
From: Michael Niedermayer <[email protected]>
Date: Sat, 24 Oct 2026 03:10:38 +0200
Subject: [PATCH] avcodec/ffv1enc: accumulate the RCT coefficient statistics in
 64bit

The per slice sum of residual magnitudes exceeds INT_MAX for noisy
32bit float slices.

Fixes: signed integer overflow: 2147482002 + 34432 cannot be represented in 
type 'int'
---
 libavcodec/ffv1enc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavcodec/ffv1enc.c b/libavcodec/ffv1enc.c
index 1d18f10f05f..21faa6551b3 100644
--- a/libavcodec/ffv1enc.c
+++ b/libavcodec/ffv1enc.c
@@ -1172,7 +1172,7 @@ static void choose_rct_params(const FFV1Context *f, 
FFV1SliceContext *sc,
         {1, 0}, //  R + 3G
     };
 
-    int stat[NB_Y_COEFF] = {0};
+    int64_t stat[NB_Y_COEFF] = {0};
     int x, y, i, p, best;
     int16_t *sample[3];
     int lbd = f->bits_per_raw_sample <= 8;
@@ -1252,7 +1252,7 @@ static void choose_rct_params_bayer(const FFV1Context *f, 
FFV1SliceContext *sc,
         { 0, 0 }, { 1, 1 }, { 2, 2 }, { 0, 2 }, { 2, 0 }, { 4, 0 }, { 0, 4 }, 
{ 0, 3 },
         { 3, 0 }, { 3, 1 }, { 1, 3 }, { 1, 2 }, { 2, 1 }, { 0, 1 }, { 1, 0 },
     };
-    int stat[NB_Y_COEFF] = {0};
+    int64_t stat[NB_Y_COEFF] = {0};
     int16_t *sample[3];
     int i, best;
 
-- 
2.54.0

_______________________________________________
ffmpeg-devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to