Fix broken vbv_buffer_init handling in libx264.c
authorJason Garrett-Glaser <jason@x264.com>
Sun, 6 Feb 2011 13:10:15 +0000 (05:10 -0800)
committerJason Garrett-Glaser <jason@x264.com>
Tue, 8 Feb 2011 23:59:27 +0000 (15:59 -0800)
Due to being pants-on-head retarded, libavcodec defaults this to zero, which
results in broken output.  This didn't affect ffmpeg.c, which sets it itself,
but caused problems for other calling apps using VBV.

libavcodec/libx264.c

index 84ecb2a..185287c 100644 (file)
@@ -277,12 +277,11 @@ static av_cold int X264_init(AVCodecContext *avctx)
     if (avctx->level > 0)
         x4->params.i_level_idc = avctx->level;
 
-    if ((avctx->rc_buffer_size != 0) &&
+    if (avctx->rc_buffer_size && avctx->rc_initial_buffer_occupancy &&
         (avctx->rc_initial_buffer_occupancy <= avctx->rc_buffer_size)) {
         x4->params.rc.f_vbv_buffer_init =
             (float)avctx->rc_initial_buffer_occupancy / avctx->rc_buffer_size;
-    } else
-        x4->params.rc.f_vbv_buffer_init = 0.9;
+    }
 
     x4->params.rc.b_mb_tree               = !!(avctx->flags2 & CODEC_FLAG2_MBTREE);
     x4->params.rc.f_ip_factor             = 1 / fabs(avctx->i_quant_factor);