aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2021-05-30 18:38:23 +0200
committerMichael Niedermayer <michael@niedermayer.cc>2021-10-06 13:59:34 +0200
commit10226f869e9bb83d26f6c8ff790e3815a20d49c7 (patch)
tree9ddc191ca6e48c57fd835976239b1bb425cc5334 /libavcodec
parent29f073ca464e202c4621828ce925072757769eab (diff)
downloadffmpeg-10226f869e9bb83d26f6c8ff790e3815a20d49c7.tar.gz
avcodec/mpegvideo_enc: Limit bitrate tolerance to the representable
Fixes: error: 1.66789e+11 is outside the range of representable values of type 'int' Fixes: Ticket8201 Signed-off-by: Michael Niedermayer <michael@niedermayer.cc> (cherry picked from commit 245017ec8a87d6e4c764d06afeca37100b980d85) Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/mpegvideo_enc.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index ae3b131229..8cc4ce8f2e 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -492,9 +492,13 @@ FF_ENABLE_DEPRECATION_WARNINGS
if (!s->fixed_qscale &&
avctx->bit_rate * av_q2d(avctx->time_base) >
avctx->bit_rate_tolerance) {
+ double nbt = avctx->bit_rate * av_q2d(avctx->time_base) * 5;
av_log(avctx, AV_LOG_WARNING,
"bitrate tolerance %d too small for bitrate %"PRId64", overriding\n", avctx->bit_rate_tolerance, avctx->bit_rate);
- avctx->bit_rate_tolerance = 5 * avctx->bit_rate * av_q2d(avctx->time_base);
+ if (nbt <= INT_MAX) {
+ avctx->bit_rate_tolerance = nbt;
+ } else
+ avctx->bit_rate_tolerance = INT_MAX;
}
if (s->avctx->rc_max_rate &&