两个RC结构的比较:
1 x264_t-->x264_ratecontrol_t:
structx264_ratecontrol_t
{
/*constants */
intb_abr;
intb_2pass;
intb_vbv;
intb_vbv_min_rate;
doublefps;
doublebitrate;
doublerate_tolerance;
doubleqcompress;
intnmb;/* number of macroblocksin a frame */
intqp_constant[3];
/*current frame */
ratecontrol_entry_t*rce;
intqp;/* qpfor current frame */
floatqpm;/* qpfor currentmacroblock:precise float for AQ */
floatqpa_rc;/* average of macroblocks'qpbeforeaq*/
floatqpa_rc_prev;
intqpa_aq; /* average of macroblocks'qpafteraq*/
intqpa_aq_prev;
floatqp_novbv;/* QP for the current frame if1-pass VBV was disabled. */
/*VBV stuff */
doublebuffer_size;
int64_tbuffer_fill_final;
doublebuffer_fill;/* planned buffer, if allin-progress frames hit their bit budget */
doublebuffer_rate;/* # of bits added tobuffer_fill after each frame */
doublevbv_max_rate;/* # of bits added to buffer_fillper second */
predictor_t*pred;/* predict frame size from satd*/
intsingle_frame_vbv;
doublerate_factor_max_increment;/* Don't allow RF above (CRF + thisvalue). */
/*ABR stuff */
intlast_satd;
doublelast_rceq;
doublecplxr_sum;/* sum of bits*qscale/rceq*/
doubleexpected_bits_sum;/* sum of qscale2bits after rceq,ratefactor,and overflow, only includes finished frames */
int64_tfiller_bits_sum;/* sum in bits of finished frames'filler data */
doublewanted_bits_window;/* target bitrate* window */
doublecbr_decay;
doubleshort_term_cplxsum;
doubleshort_term_cplxcount;
doublerate_factor_constant;
doubleip_offset;
doublepb_offset;
/*2pass stuff */
FILE*p_stat_file_out;
char*psz_stat_file_tmpname;
FILE*p_mbtree_stat_file_out;
char*psz_mbtree_stat_file_tmpname;
char*psz_mbtree_stat_file_name;
FILE*p_mbtree_stat_file_in;
intnum_entries;/* number ofratecontrol_entry_ts */
ratecontrol_entry_t*entry;/*FIXME:copy needed data and free this onceinitis done */
doublelast_qscale;
doublelast_qscale_for[3];/* last qscalefor a specificpicttype, used for max_diff &ipbfactor stuff */
intlast_non_b_pict_type;
doubleaccum_p_qp;/* for determining I-framequant*/
doubleaccum_p_norm;
doublelast_accum_p_norm;
doublelmin[3];/* minqscaleby frame type */
doublelmax[3];
doublelstep;/* max change (multiply) inqscaleper frame */
struct
{
uint16_t*qp_buffer[2];/* Global buffers for converting MB-treequantizer data. */
intqpbuf_pos;/* In order to handle pyramidreordering, QP buffer acts as a stack.
*This value is the current position (0 or 1). */
intsrc_mb_count;
/*Forrescaling*/
intrescale_enabled;
float*scale_buffer[2];/* Intermediate buffers */
intfiltersize[2];/* filter size (H/V) */
float*coeffs[2];
int*pos[2];
intsrcdim[2];/* Source dimensions (W/H) */
}mbtree;
/*MBRC stuff */
floatframe_size_estimated;/* Access to this variable must beatomic: double is
*not atomic on all arches we care about */
doubleframe_size_maximum;/* Maximum frame size due to MinCR */
doubleframe_size_planned;
doubleslice_size_planned;
predictor_t(*row_pred)[2];
predictor_trow_preds[3][2];
predictor_t*pred_b_from_p;/* predict B-frame size from P-framesatd*/
intbframes;/* # consecutive B-framesbefore this P-frame */
intbframe_bits;/* total cost of those frames*/
inti_zones;
x264_zone_t*zones;
x264_zone_t*prev_zone;
/*hrdstuff */
intinitial_cpb_removal_delay;
intinitial_cpb_removal_delay_offset;
doublenrt_first_access_unit;/* nominal removal time */
doubleprevious_cpb_final_arrival_time;
uint64_thrd_multiply_denom;
};
2 x264_t-->x264_param_t-->rc
/*Rate control parameters */
struct
{
inti_rc_method;/* X264_RC_* */
inti_qp_constant;/* 0 to (51 + 6*(x264_bit_depth-8)).0=lossless*/
inti_qp_min; /* minallowed QP value */
inti_qp_max; /* max allowed QP value */
inti_qp_step; /* max QP step between frames */
inti_bitrate;
floatf_rf_constant;/* 1pass VBR, nominal QP */
floatf_rf_constant_max;/* In CRF mode, maximum CRF as causedby VBV */
floatf_rate_tolerance;
inti_vbv_max_bitrate;
inti_vbv_buffer_size;
floatf_vbv_buffer_init;/* <=1: fraction of buffer_size. >1:kbit*/
floatf_ip_factor;
floatf_pb_factor;
inti_aq_mode; /* psyadaptive QP. (X264_AQ_*) */
floatf_aq_strength;
intb_mb_tree; /* Macroblock-treeratecontrol.*/
inti_lookahead;
/*2pass */
intb_stat_write;/* Enable statwriting in psz_stat_out */
char *psz_stat_out;
intb_stat_read;/* Read statfrom psz_stat_in and use it */
char *psz_stat_in;
/*2passparams(same asffmpegones) */
floatf_qcompress;/* 0.0 => cbr,1.0 => constantqp*/
floatf_qblur; /* temporally blur quants*/
floatf_complexity_blur;/* temporally blur complexity */
x264_zone_t*zones;/* ratecontroloverrides */
inti_zones; /* number of zone_t's */
char *psz_zones;/* alternate method of specifyingzones */
}rc;