diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2012-10-24 00:03:06 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2012-10-24 00:40:18 +0200 |
commit | 1856162caa912a4a845b7caff51c9e2dff3d39d9 (patch) | |
tree | ed8eb44f8c9fd4f174e9f8f741cad5cb94d37944 | |
parent | 33c4535db73595612cddcc6f7df67d07713f228d (diff) | |
download | ffmpeg-1856162caa912a4a845b7caff51c9e2dff3d39d9.tar.gz |
mpegvideo enc: choose VBV buffer size for mpeg1/2 when none is specified instead of failing
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r-- | libavcodec/mpegvideo_enc.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c index d77707215a..00b0d03e5f 100644 --- a/libavcodec/mpegvideo_enc.c +++ b/libavcodec/mpegvideo_enc.c @@ -403,6 +403,18 @@ av_cold int ff_MPV_encode_init(AVCodecContext *avctx) s->loop_filter = !!(s->flags & CODEC_FLAG_LOOP_FILTER); + if (avctx->rc_max_rate && !avctx->rc_buffer_size) { + switch(avctx->codec_id) { + case AV_CODEC_ID_MPEG1VIDEO: + case AV_CODEC_ID_MPEG2VIDEO: + avctx->rc_buffer_size = FFMAX(avctx->rc_max_rate, 15000000) * 112L / 15000000 * 16384; + break; + } + if (avctx->rc_buffer_size) { + av_log(avctx, AV_LOG_INFO, "Automatically choosing VBV buffer size of %d kbyte\n", avctx->rc_buffer_size/8192); + } + } + if ((!avctx->rc_max_rate) != (!avctx->rc_buffer_size)) { av_log(avctx, AV_LOG_ERROR, "Either both buffer size and max rate or neither must be specified\n"); if (avctx->rc_max_rate && !avctx->rc_buffer_size) |