1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-11-26 19:01:44 +02:00

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>
This commit is contained in:
Michael Niedermayer 2021-05-30 18:38:23 +02:00
parent 48bbeac259
commit 245017ec8a

View File

@ -463,9 +463,13 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx)
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 (avctx->rc_max_rate &&