From: Fiona Glaser Date: Sat, 17 Oct 2009 10:04:56 +0000 (-0700) Subject: Improve CRF initial QP selection, fix get_qscale bug X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=318298e9e1c742fb1453ce8ae6574eaed7487e65;p=libx264 Improve CRF initial QP selection, fix get_qscale bug If qcomp=1 (as in mb-tree), we don't need ABR_INIT_QP. get_qscale could give slightly weird results with still images --- diff --git a/encoder/ratecontrol.c b/encoder/ratecontrol.c index 360c2065..f9879065 100644 --- a/encoder/ratecontrol.c +++ b/encoder/ratecontrol.c @@ -1359,7 +1359,7 @@ static double get_qscale(x264_t *h, ratecontrol_entry_t *rce, double rate_factor // avoid NaN's in the rc_eq if(!isfinite(q) || rce->tex_bits + rce->mv_bits == 0) - q = rcc->last_qscale; + q = rcc->last_qscale_for[rce->pict_type]; else { rcc->last_rceq = q; @@ -1848,7 +1848,7 @@ static float rate_estimate_qscale( x264_t *h ) q = x264_clip3f(q, lmin, lmax); } - else if( h->param.rc.i_rc_method == X264_RC_CRF ) + else if( h->param.rc.i_rc_method == X264_RC_CRF && rcc->qcompress != 1 ) { q = qp2qscale( ABR_INIT_QP ) / fabs( h->param.rc.f_ip_factor ); } @@ -1862,7 +1862,7 @@ static float rate_estimate_qscale( x264_t *h ) rcc->last_qscale = q; if( !(rcc->b_2pass && !rcc->b_vbv) && h->fenc->i_frame == 0 ) - rcc->last_qscale_for[SLICE_TYPE_P] = q; + rcc->last_qscale_for[SLICE_TYPE_P] = q * fabs( h->param.rc.f_ip_factor ); if( rcc->b_2pass && rcc->b_vbv ) rcc->frame_size_planned = qscale2bits(&rce, q);