lavc: set the default rc_initial_buffer_occupancy
authorLuca Barbato <lu_zero@gentoo.org>
Mon, 14 Jan 2013 04:32:38 +0000 (05:32 +0100)
committerLuca Barbato <lu_zero@gentoo.org>
Tue, 15 Jan 2013 07:58:51 +0000 (08:58 +0100)
rc_buffer_size is not set before.

Solve the initial the rate control underflow issue reported in
bug 222.

CC: libav-stable@libav.org
Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
avconv_opt.c
libavcodec/utils.c

index ce32df6..e67abef 100644 (file)
@@ -950,8 +950,6 @@ static OutputStream *new_video_stream(OptionsContext *o, AVFormatContext *oc)
             if (p) p++;
         }
         video_enc->rc_override_count = i;
-        if (!video_enc->rc_initial_buffer_occupancy)
-            video_enc->rc_initial_buffer_occupancy = video_enc->rc_buffer_size * 3 / 4;
         video_enc->intra_dc_precision = intra_dc_precision - 8;
 
         /* two pass mode */
index 23f2ac4..19c8a99 100644 (file)
@@ -824,6 +824,9 @@ int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *code
         } else if (avctx->channel_layout) {
             avctx->channels = av_get_channel_layout_nb_channels(avctx->channel_layout);
         }
+
+        if (!avctx->rc_initial_buffer_occupancy)
+            avctx->rc_initial_buffer_occupancy = avctx->rc_buffer_size * 3 / 4;
     }
 
     if (avctx->codec->init && !(avctx->active_thread_type & FF_THREAD_FRAME)) {