Commit 318298e9 authored by Fiona Glaser's avatar Fiona Glaser

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
parent d9e6b173
...@@ -1359,7 +1359,7 @@ static double get_qscale(x264_t *h, ratecontrol_entry_t *rce, double rate_factor ...@@ -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 // avoid NaN's in the rc_eq
if(!isfinite(q) || rce->tex_bits + rce->mv_bits == 0) if(!isfinite(q) || rce->tex_bits + rce->mv_bits == 0)
q = rcc->last_qscale; q = rcc->last_qscale_for[rce->pict_type];
else else
{ {
rcc->last_rceq = q; rcc->last_rceq = q;
...@@ -1848,7 +1848,7 @@ static float rate_estimate_qscale( x264_t *h ) ...@@ -1848,7 +1848,7 @@ static float rate_estimate_qscale( x264_t *h )
q = x264_clip3f(q, lmin, lmax); 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 ); q = qp2qscale( ABR_INIT_QP ) / fabs( h->param.rc.f_ip_factor );
} }
...@@ -1862,7 +1862,7 @@ static float rate_estimate_qscale( x264_t *h ) ...@@ -1862,7 +1862,7 @@ static float rate_estimate_qscale( x264_t *h )
rcc->last_qscale = q; rcc->last_qscale = q;
if( !(rcc->b_2pass && !rcc->b_vbv) && h->fenc->i_frame == 0 ) 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 ) if( rcc->b_2pass && rcc->b_vbv )
rcc->frame_size_planned = qscale2bits(&rce, q); rcc->frame_size_planned = qscale2bits(&rce, q);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment