diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2007-05-20 01:35:15 +0000 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2007-05-20 01:35:15 +0000 |
commit | 64be2e60ef7b7b7f0da9b4a0921e4cfdf8f87da2 (patch) | |
tree | 35ce5140ca242678d61454c3f85639d113053d0f | |
parent | cb590b4842bdb7145b4880b0671f98c60175900c (diff) | |
download | ffmpeg-64be2e60ef7b7b7f0da9b4a0921e4cfdf8f87da2.tar.gz |
sanity checks for bitrate tolerance and buffer size (= fail if a single frame at the
requested bitrate would be bigger than the buffer size)
Originally committed as revision 9077 to svn://svn.ffmpeg.org/ffmpeg/trunk
-rw-r--r-- | libavcodec/mpegvideo.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c index 28b84e3d57..8f07b6196d 100644 --- a/libavcodec/mpegvideo.c +++ b/libavcodec/mpegvideo.c @@ -1029,6 +1029,16 @@ int MPV_encode_init(AVCodecContext *avctx) return -1; } + if(avctx->rc_buffer_size && avctx->bit_rate*av_q2d(avctx->time_base) > avctx->rc_buffer_size){ + av_log(avctx, AV_LOG_INFO, "VBV buffer too small for bitrate\n"); + return -1; + } + + if(avctx->bit_rate*av_q2d(avctx->time_base) > avctx->bit_rate_tolerance){ + av_log(avctx, AV_LOG_INFO, "bitrate tolerance too small for bitrate\n"); + return -1; + } + if( s->avctx->rc_max_rate && s->avctx->rc_min_rate == s->avctx->rc_max_rate && (s->codec_id == CODEC_ID_MPEG1VIDEO || s->codec_id == CODEC_ID_MPEG2VIDEO) && 90000LL * (avctx->rc_buffer_size-1) > s->avctx->rc_max_rate*0xFFFFLL){ |