aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2012-10-24 00:38:56 +0200
committerMichael Niedermayer <michaelni@gmx.at>2012-10-24 00:40:18 +0200
commit3556e7ce737edade8c5e628a19e2b5da0809928d (patch)
tree8ff22f0f9302dc52720b20327269d1d871f2c679
parent1856162caa912a4a845b7caff51c9e2dff3d39d9 (diff)
downloadffmpeg-3556e7ce737edade8c5e628a19e2b5da0809928d.tar.gz
mpegvideo enc: choose VBV buffer size for mpeg4 when none is specified instead of failing
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r--libavcodec/mpegvideo_enc.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index 00b0d03e5f..256b8d4e4d 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -409,6 +409,20 @@ av_cold int ff_MPV_encode_init(AVCodecContext *avctx)
case AV_CODEC_ID_MPEG2VIDEO:
avctx->rc_buffer_size = FFMAX(avctx->rc_max_rate, 15000000) * 112L / 15000000 * 16384;
break;
+ case AV_CODEC_ID_MPEG4:
+ case AV_CODEC_ID_MSMPEG4V1:
+ case AV_CODEC_ID_MSMPEG4V2:
+ case AV_CODEC_ID_MSMPEG4V3:
+ if (avctx->rc_max_rate >= 15000000) {
+ avctx->rc_buffer_size = 320 + (avctx->rc_max_rate - 15000000L) * (760-320) / (38400000 - 15000000);
+ } else if(avctx->rc_max_rate >= 2000000) {
+ avctx->rc_buffer_size = 80 + (avctx->rc_max_rate - 2000000L) * (320- 80) / (15000000 - 2000000);
+ } else if(avctx->rc_max_rate >= 384000) {
+ avctx->rc_buffer_size = 40 + (avctx->rc_max_rate - 384000L) * ( 80- 40) / ( 2000000 - 384000);
+ } else
+ avctx->rc_buffer_size = 40;
+ avctx->rc_buffer_size *= 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);