gpt-3.5-turbo-0301· OpenAI
WildChat-4.8M (AI2)
解析x264中的下面函数,每行代码做注释 static int initcosts( x264t h, float logs, int qp ) { if(…
- User
解析x264中的下面函数,每行代码做注释 static int init_costs( x264_t *h, float *logs, int qp ) { if( h->cost_mv[qp] ) return 0;
codeint mv_range = h->param.analyse.i_mv_range; int lambda = x264_lambda_tab[qp]; /* factor of 4 from qpel, 2 from sign, and 2 because mv can be opposite from mvp */ CHECKED_MALLOC( h->cost_mv[qp], (4*4*mv_range + 1) * sizeof(uint16_t) ); h->cost_mv[qp] += 2*4*mv_range; for( int i = 0; i <= 2*4*mv_range; i++ ) { h->cost_mv[qp][-i] = h->cost_mv[qp][i] = X264_MIN( (int)(lambda * logs[i] + .5f), UINT16_MAX ); } for( int i = 0; i < 3; i++ ) for( int j = 0; j < 33; j++ ) h->cost_table->ref[qp][i][j] = i ? X264_MIN( lambda * bs_size_te( i, j ), UINT16_MAX ) : 0; if( h->param.analyse.i_me_method >= X264_ME_ESA && !h->cost_mv_fpel[qp][0] ) { for( int j = 0; j < 4; j++ ) { CHECKED_MALLOC( h->cost_mv_fpel[qp][j], (4*mv_range + 1) * sizeof(uint16_t) ); h->cost_mv_fpel[qp][j] += 2*mv_range; for( int i = -2*mv_range; i < 2*mv_range; i++ ) h->cost_mv_fpel[qp][j][i] = h->cost_mv[qp][i*4+j]; } } uint16_t *cost_i4x4_mode = h->cost_table->i4x4_mode[qp]; for( int i = 0; i < 17; i++ ) cost_i4x4_mode[i] = 3*lambda*(i!=8); return 0;fail: return -1; }
- Assistant
/初始化costs数组/ static int init_costs( x264_t *h, float *logs, int qp ) { /如果该qp的cost_mv数组已被初始化,则直接返回,不必重新初始化/ if( h->cost_mv[qp] ) return 0;
code