[x264-devel] Question about MV initial cost calculation
Shen Sha
asic_soc at 163.com
Wed Nov 17 10:37:22 CET 2010
Dear experts,
I'm reading the motion estimation realed x264 code now. I know that when performing mode decision, cost for all possible partition/mv should be calculated. I see the following code in file "Analyse.c", which is obviously doing some initialization for the MV cost calculation.
int x264_analyse_init_costs( x264_t *h, int qp )
{
int lambda = x264_lambda_tab[qp];
if( h->cost_mv[lambda] )
return 0;
/* factor of 4 from qpel, 2 from sign, and 2 because mv can be opposite from mvp */
CHECKED_MALLOC( h->cost_mv[lambda], (4*4*2048 + 1) * sizeof(uint16_t) );
h->cost_mv[lambda] += 2*4*2048;
for( int i = 0; i <= 2*4*2048; i++ )
{
h->cost_mv[lambda][-i] =
h->cost_mv[lambda][i] = lambda * (log2f(i+1)*2 + 0.718f + !!i) + .5f;
}
........
}
I have the following question about the equation "h->cost_mv[lambda][i] = lambda * (log2f(i+1)*2 + 0.718f + !!i) + .5f;
" used above:
(1) why the value 0.718 used in the above calculation? Is there any papers/documents which introduce why this number is chosen?
(2) why the log2f(i+1)*2 is used instead of just log2f(i+1)? In my opinion, the bit lenght of mv is log2f(i+1), why here this bit length is doubled?
Thanks a lot for your kindly help.
Sha
More information about the x264-devel
mailing list