From: Anton Mitrofanov Date: Sun, 29 Aug 2010 12:35:32 +0000 (+0400) Subject: Fix bug in 2pass if the first P-frames are all skip X-Git-Url: http://www.zmx.ovh/git.videolan.org/?a=commitdiff_plain;h=5978cbc53dec1e7023b2ba9c9f9ce6ed24ffc68b;p=x264.git Fix bug in 2pass if the first P-frames are all skip last_qscale_for was read before being initialized in this case, resulting in the value from the previous iteration being used instead. --- diff --git a/encoder/ratecontrol.c b/encoder/ratecontrol.c index d9d118a1..cf51f373 100644 --- a/encoder/ratecontrol.c +++ b/encoder/ratecontrol.c @@ -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++ ) {