1、static float rate_estimate_qscale( x264_t *h )
{
...
//估计模糊复杂度
rcc->last_satd = x264_stack_align( x264_rc_analyse_slice, h );
rcc->short_term_cplxsum *= 0.5;
rcc->short_term_cplxcount *= 0.5;
rcc->short_term_cplxsum += rcc->last_satd;
rcc->short_term_cplxcount ++;
rce.tex_bits = rcc->last_satd;
rce.blurred_complexity = rcc->short_term_cplxsum / rcc->short_term_cplxcount;
}
2、static double get_qscale(...)
{
....
q = pow( rce->blurred_complexity, 1 - h->param.rc.f_qcompress );//按模糊复杂度采用指数估计一次模型的拉格朗日线性因子
....
}
3、按一阶模型的satd估计的分配bits做vbv限制,修正线性因子
clip_qscale(){
....
predict_size( &rcc->pred[h->sh.i_type], q, rcc->last_satd );//按一阶模型从satd获得预测分配bits
....
}
4.x264_ratecontrol_end中按一阶模型估计已编码数据的模糊总复杂度
rc->cplxr_sum 及期望分配bits值rc->wanted_bits_window,这两个值的比值用在指数决策拉格朗日因子中
5、按实际发生bits及QP按一阶模型修正总bits
update_vbv{
update_predictor( &rct->pred[h->sh.i_type], qp2qscale(rcc->qpa_rc), rcc->last_satd, bits );
}