Fix float division by zero when encoding CRF+VBV
authorAnton Mitrofanov <BugMaster@narod.ru>
Mon, 25 Nov 2019 11:58:43 +0000 (14:58 +0300)
committerAnton Mitrofanov <BugMaster@narod.ru>
Tue, 26 Nov 2019 23:50:00 +0000 (02:50 +0300)
Bug report by Sam Panzer.

encoder/ratecontrol.c

index b8073614413af658032a6e96abc3085d374ef6b8..b0ee5c8ee3f5253401947640843bccc353038b5e 100644 (file)
@@ -713,8 +713,9 @@ void x264_ratecontrol_init_reconfigurable( x264_t *h, int b_init )
         rc->vbv_max_rate = vbv_max_bitrate;
         rc->buffer_size = vbv_buffer_size;
         rc->single_frame_vbv = rc->buffer_rate * 1.1 > rc->buffer_size;
-        rc->cbr_decay = 1.0 - rc->buffer_rate / rc->buffer_size
-                      * 0.5 * X264_MAX(0, 1.5 - rc->buffer_rate * rc->fps / rc->bitrate);
+        if( rc->b_abr && h->param.rc.i_rc_method == X264_RC_ABR )
+            rc->cbr_decay = 1.0 - rc->buffer_rate / rc->buffer_size
+                          * 0.5 * X264_MAX(0, 1.5 - rc->buffer_rate * rc->fps / rc->bitrate);
         if( h->param.rc.i_rc_method == X264_RC_CRF && h->param.rc.f_rf_constant_max )
         {
             rc->rate_factor_max_increment = h->param.rc.f_rf_constant_max - h->param.rc.f_rf_constant;