[FFmpeg-cvslog] mpegvideo enc: choose VBV buffer size for mpeg1/ 2 when none is specified instead of failing

Michael Niedermayer git at videolan.org
Mon Dec 3 20:33:42 CET 2012


ffmpeg | branch: release/1.0 | Michael Niedermayer <michaelni at gmx.at> | Wed Oct 24 00:03:06 2012 +0200| [8b170ee5d874199e2462de542c3c2490fdfc3cae] | committer: Michael Niedermayer

mpegvideo enc: choose VBV buffer size for mpeg1/2 when none is specified instead of failing

Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
(cherry picked from commit 1856162caa912a4a845b7caff51c9e2dff3d39d9)

Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=8b170ee5d874199e2462de542c3c2490fdfc3cae
---

 libavcodec/mpegvideo_enc.c |   12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index 4322d65..4faf469 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -402,6 +402,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)



More information about the ffmpeg-cvslog mailing list