]> git.sesse.net Git - x264/commitdiff
Fix bug in 2pass if the first P-frames are all skip
authorAnton Mitrofanov <BugMaster@narod.ru>
Sun, 29 Aug 2010 12:35:32 +0000 (16:35 +0400)
committerFiona Glaser <fiona@x264.com>
Sun, 29 Aug 2010 13:05:51 +0000 (09:05 -0400)
last_qscale_for was read before being initialized in this case, resulting
in the value from the previous iteration being used instead.

encoder/ratecontrol.c

index c76b681d6d8541fdb25e59e5ddef5f349ae107a5..5827d21311cfd4d62d84cbb57ccf57d5e91a0331 100644 (file)
@@ -2518,6 +2518,7 @@ static int init_pass2( x264_t *h )
     const int filter_size = (int)(qblur*4) | 1;
     double expected_bits;
     double *qscale, *blurred_qscale;
+    double base_cplx = h->mb.i_mb_count * (h->param.i_bframe ? 120 : 80);
 
     /* find total/average complexity & const_bits */
     for( int i = 0; i < rcc->num_entries; i++ )
@@ -2602,6 +2603,10 @@ static int init_pass2( x264_t *h )
         rcc->last_accum_p_norm = 1;
         rcc->accum_p_norm = 0;
 
+        rcc->last_qscale_for[0] =
+        rcc->last_qscale_for[1] =
+        rcc->last_qscale_for[2] = pow( base_cplx, 1 - rcc->qcompress ) / rate_factor;
+
         /* find qscale */
         for( int i = 0; i < rcc->num_entries; i++ )
         {