From: Laurent Aimar Date: Sun, 29 Aug 2004 11:32:34 +0000 (+0000) Subject: * ratecontrol: path by Loren Merritt. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8c6f6fa0db394e65fa9b4272deec859c9cb67aac;p=libx264 * ratecontrol: path by Loren Merritt. "Use average qp instead of last qp in the frame for 2pass rc. (Improves quality and rate accuracy if the first pass was cbr.)" git-svn-id: svn://svn.videolan.org/x264/trunk@45 df754926-b1dd-0310-bc7b-ec298dee348c --- diff --git a/encoder/ratecontrol.c b/encoder/ratecontrol.c index da8e3529..be4972fd 100644 --- a/encoder/ratecontrol.c +++ b/encoder/ratecontrol.c @@ -6,7 +6,7 @@ * * Authors: Måns Rullgård * 2 pass code: Michael Niedermayer - * Loren Merritt + * Loren Merritt * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -101,7 +101,7 @@ struct x264_ratecontrol_t double last_qscale; double last_qscale_for[5]; /* last qscale for a specific pict type, used for max_diff & ipb factor stuff */ int last_non_b_pict_type; - double lmin[5]; /* min qscale by frame type */ + double lmin[5]; /* min qscale by frame type */ double lmax[5]; double i_cplx_sum[5]; /* estimated total texture bits in intra MBs at qscale=1 */ double p_cplx_sum[5]; @@ -115,7 +115,7 @@ static float rate_estimate_qscale( x264_t *h, int pict_type ); /* Terminology: * qp = h.264's quantizer - * qscale = an arbitrary linear scale, mappable to qp + * qscale = linearized quantizer = Lagrange multiplier */ static inline double qp2qscale(double qp) { @@ -337,7 +337,6 @@ void x264_ratecontrol_start( x264_t *h, int i_slice_type ) rc->slice_type = i_slice_type; - /* Needed ? */ x264_cpu_restore( h->param.cpu ); if( h->param.rc.b_stat_read ) @@ -551,7 +550,7 @@ void x264_ratecontrol_end( x264_t *h, int bits ) fprintf( rc->p_stat_file_out, "in:%d out:%d type:%d q:%.3f itex:%d ptex:%d mv:%d misc:%d imb:%d pmb:%d smb:%d;\n", h->fenc->i_frame, h->i_frame-1, - rc->slice_type, (float)rc->qpm, + rc->slice_type, (float)rc->qpa, h->stat.frame.i_itex_bits, h->stat.frame.i_ptex_bits, h->stat.frame.i_hdr_bits, h->stat.frame.i_misc_bits, h->stat.frame.i_mb_count[I_4x4] + h->stat.frame.i_mb_count[I_16x16], @@ -611,10 +610,6 @@ static double get_qscale(x264_t *h, ratecontrol_entry_t *rce, double rate_factor //double q, avg_cplx; const int pict_type = rce->new_pict_type; - x264_cpu_restore( h->param.cpu ); - - //avg_cplx = (rcc->i_cplx_sum[pict_type] + rcc->p_cplx_sum[pict_type]) / rcc->frame_count[pict_type]; - double const_values[]={ rce->i_tex_bits * rce->qscale, rce->p_tex_bits * rce->qscale,