一、 x264运动估计中宏块的位移cost计算:
/* lambda = pow(2,qp/6-2) */
const byte x264_lambda_tab[52] =
{
1, 1, 1, 1, 1, 1, 1, 1, /* 0-7 */
1, 1, 1, 1, /* 8-11 */
1, 1, 1, 1, 2, 2, 2, 2, /* 12-19 */
3, 3, 3, 4, 4, 4, 5, 6, /* 20-27 */
6, 7, 8, 9,10,11,13,14, /* 28-35 */
16,18,20,23,25,29,32,36, /* 36-43 */
40,45,51,57,64,72,81,91 /* 44-51 */
};
/*根据量化参数得到i_lambda的值*/
int i_qpm = 10; /*取值0 - 51; 每个宏块的qpm都是变化的,在函数x264_ratecontrol_mb中改变qpm值*/
int i_lambda = x264_lambda_tab[i_qpm];
/*计算i_lambda时所有位移的cost值*/
short *cost_mv[92];
malloc(cost_mv[i_lambda], (4*4*2048 + 1) * sizeof(short) );
cost_mv[i_lambda] += 2*4*2048;
for( i = 0; i <= 2*4*2048; i++ )
{
cost_mv[i_lambda][-i] = cost_mv[i_lambda][i]
= (short)( i_lambda * (log2f((float)( i+1 ))*