[FFmpeg-cvslog] mpegvideo enc: choose VBV buffer size for mpeg4 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:38:56 2012 +0200| [9d9d16b33f73e93309932323134ead3573fbd79a] | committer: Michael Niedermayer

mpegvideo enc: choose VBV buffer size for mpeg4 when none is specified instead of failing

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

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

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

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

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



More information about the ffmpeg-cvslog mailing list