]> granicus.if.org Git - libx264/commitdiff
Improve CRF initial QP selection, fix get_qscale bug
authorFiona Glaser <fiona@x264.com>
Sat, 17 Oct 2009 10:04:56 +0000 (03:04 -0700)
committerFiona Glaser <fiona@x264.com>
Mon, 19 Oct 2009 09:29:17 +0000 (02:29 -0700)
If qcomp=1 (as in mb-tree), we don't need ABR_INIT_QP.
get_qscale could give slightly weird results with still images

encoder/ratecontrol.c

index 360c2065e631dbbf90d850b2d67345ea43fa9f91..f98790652c246ed79756f23b890d744394f266e0 100644 (file)
@@ -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);