This is an automated email from the git hooks/post-receive script.

Git pushed a commit to branch master
in repository ffmpeg.

commit dde2f1b0778b3dabc91b31843cc95a03f54ad2b2
Author:     Michael Niedermayer <[email protected]>
AuthorDate: Sat Oct 10 17:57:35 2026 +0200
Commit:     michaelni <[email protected]>
CommitDate: Mon Oct 12 23:55:55 2026 +0000

    avcodec/ratecontrol: keep the wanted bits inside the int64 range in both 
directions
    
    Signed integer overflow Replicated through Modified FFmpeg (fuzzer harness 
built with --disable-asm) with UBSAN
    
    Fixes: signed integer overflow: 167640 - -9223372036854775808 cannot be 
represented in type 'int64_t'
    Fixes: 9.22337e+18 is outside the range of representable values of type 
'long'
    Fixes: 
565995849/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SNOW_fuzzer-5651323392163840
    Fixes: tYZSxpyV9Sjx
    Regression since: 7147c3c911f4ebf5bd1c21444423d8f78c6541ea
    
    Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
    Signed-off-by: Michael Niedermayer <[email protected]>
---
 libavcodec/ratecontrol.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/libavcodec/ratecontrol.c b/libavcodec/ratecontrol.c
index a3ada799b5..397a235821 100644
--- a/libavcodec/ratecontrol.c
+++ b/libavcodec/ratecontrol.c
@@ -971,14 +971,14 @@ float ff_rate_estimate_qscale(MPVMainEncContext *const m, 
int dry_run)
             wanted_bits_double = m->bit_rate * (double)picture_number / fps;
         else
             wanted_bits_double = m->bit_rate * (double)dts_pic->f->pts / fps;
-        if (wanted_bits_double > INT64_MAX) {
+        if (wanted_bits_double >= 0x1p63) {
             av_log(s->c.avctx, AV_LOG_WARNING, "Bits exceed 64bit range\n");
             wanted_bits = INT64_MAX;
         } else
-            wanted_bits = (int64_t)wanted_bits_double;
+            wanted_bits = FFMAX(wanted_bits_double, INT64_MIN);
     }
 
-    diff = m->total_bits - wanted_bits;
+    diff = (double)m->total_bits - wanted_bits;
     br_compensation = (a->bit_rate_tolerance - diff) / a->bit_rate_tolerance;
     if (br_compensation <= 0.0)
         br_compensation = 0.001;

-- 
To stop receiving notification emails like this one, please contact
[email protected].
_______________________________________________
ffmpeg-cvslog mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to