Mercurial > libavcodec.hg
changeset 5047:460a12052adf libavcodec
sanity checks for bitrate tolerance and buffer size (= fail if a single frame at the
requested bitrate would be bigger than the buffer size)
author | michael |
---|---|
date | Sun, 20 May 2007 01:35:15 +0000 |
parents | da1ca444ff51 |
children | 59f2f619f4a2 |
files | mpegvideo.c |
diffstat | 1 files changed, 10 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/mpegvideo.c Sun May 20 01:05:34 2007 +0000 +++ b/mpegvideo.c Sun May 20 01:35:15 2007 +0000 @@ -1029,6 +1029,16 @@ 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){