[FFmpeg-devel] [PATCH 3/4] avcodec/mpeg12enc: Use av_rescale() in vbv_buffer_size computation
Michael Niedermayer
michael at niedermayer.cc
Thu Jun 20 22:35:03 EEST 2024
Fixes: signed integer overflow: 20 * 2314885530818453759 cannot be represented in type 'long'
Fixes: 69098/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MPEG2VIDEO_fuzzer-6107989688778752
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
---
libavcodec/mpeg12enc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libavcodec/mpeg12enc.c b/libavcodec/mpeg12enc.c
index 140fda4bc23..f22ca8a19f7 100644
--- a/libavcodec/mpeg12enc.c
+++ b/libavcodec/mpeg12enc.c
@@ -332,7 +332,7 @@ static void mpeg1_encode_sequence_header(MpegEncContext *s)
else
/* VBV calculation: Scaled so that a VCD has the proper
* VBV size of 40 kilobytes */
- vbv_buffer_size = ((20 * s->bit_rate) / (1151929 / 2)) * 8 * 1024;
+ vbv_buffer_size = av_rescale_rnd(s->bit_rate, 20, 1151929 / 2, AV_ROUND_ZERO) * 8 * 1024;
vbv_buffer_size = (vbv_buffer_size + 16383) / 16384;
put_sbits(&s->pb, 18, v);
--
2.45.2
More information about the ffmpeg-devel
mailing list