Mercurial > libavcodec.hg
comparison h264.c @ 8362:156137b60026 libavcodec
Split filter_mb_dir() out of filter_mb().
1% overall decoding speed up for cathedral-beta2-400extra-crop-avc.mp4
no speed change for Aladin.mpg
Benchmarks done on Pentium dual
author | michael |
---|---|
date | Wed, 17 Dec 2008 02:35:14 +0000 |
parents | 1ef90fd7706a |
children | 7c36f4ce172c |
comparison
equal
deleted
inserted
replaced
8361:c34d5e164b22 | 8362:156137b60026 |
---|---|
6239 } | 6239 } |
6240 #undef FILTER | 6240 #undef FILTER |
6241 } | 6241 } |
6242 } | 6242 } |
6243 | 6243 |
6244 | |
6245 static void av_always_inline filter_mb_dir(H264Context *h, int mb_x, int mb_y, uint8_t *img_y, uint8_t *img_cb, uint8_t *img_cr, unsigned int linesize, unsigned int uvlinesize, int mb_xy, int mb_type, int mvy_limit, int first_vertical_edge_done, int dir) { | |
6246 MpegEncContext * const s = &h->s; | |
6247 int edge; | |
6248 const int mbm_xy = dir == 0 ? mb_xy -1 : h->top_mb_xy; | |
6249 const int mbm_type = s->current_picture.mb_type[mbm_xy]; | |
6250 int (*ref2frm) [64] = h->ref2frm[ h->slice_num &(MAX_SLICES-1) ][0] + (MB_MBAFF ? 20 : 2); | |
6251 int (*ref2frmm)[64] = h->ref2frm[ h->slice_table[mbm_xy]&(MAX_SLICES-1) ][0] + (MB_MBAFF ? 20 : 2); | |
6252 int start = h->slice_table[mbm_xy] == 0xFFFF ? 1 : 0; | |
6253 | |
6254 const int edges = (mb_type & (MB_TYPE_16x16|MB_TYPE_SKIP)) | |
6255 == (MB_TYPE_16x16|MB_TYPE_SKIP) ? 1 : 4; | |
6256 // how often to recheck mv-based bS when iterating between edges | |
6257 const int mask_edge = (mb_type & (MB_TYPE_16x16 | (MB_TYPE_16x8 << dir))) ? 3 : | |
6258 (mb_type & (MB_TYPE_8x16 >> dir)) ? 1 : 0; | |
6259 // how often to recheck mv-based bS when iterating along each edge | |
6260 const int mask_par0 = mb_type & (MB_TYPE_16x16 | (MB_TYPE_8x16 >> dir)); | |
6261 | |
6262 if (first_vertical_edge_done) { | |
6263 start = 1; | |
6264 } | |
6265 | |
6266 if (h->deblocking_filter==2 && h->slice_table[mbm_xy] != h->slice_table[mb_xy]) | |
6267 start = 1; | |
6268 | |
6269 if (FRAME_MBAFF && (dir == 1) && ((mb_y&1) == 0) && start == 0 | |
6270 && !IS_INTERLACED(mb_type) | |
6271 && IS_INTERLACED(mbm_type) | |
6272 ) { | |
6273 // This is a special case in the norm where the filtering must | |
6274 // be done twice (one each of the field) even if we are in a | |
6275 // frame macroblock. | |
6276 // | |
6277 static const int nnz_idx[4] = {4,5,6,3}; | |
6278 unsigned int tmp_linesize = 2 * linesize; | |
6279 unsigned int tmp_uvlinesize = 2 * uvlinesize; | |
6280 int mbn_xy = mb_xy - 2 * s->mb_stride; | |
6281 int qp; | |
6282 int i, j; | |
6283 int16_t bS[4]; | |
6284 | |
6285 for(j=0; j<2; j++, mbn_xy += s->mb_stride){ | |
6286 if( IS_INTRA(mb_type) || | |
6287 IS_INTRA(s->current_picture.mb_type[mbn_xy]) ) { | |
6288 bS[0] = bS[1] = bS[2] = bS[3] = 3; | |
6289 } else { | |
6290 const uint8_t *mbn_nnz = h->non_zero_count[mbn_xy]; | |
6291 for( i = 0; i < 4; i++ ) { | |
6292 if( h->non_zero_count_cache[scan8[0]+i] != 0 || | |
6293 mbn_nnz[nnz_idx[i]] != 0 ) | |
6294 bS[i] = 2; | |
6295 else | |
6296 bS[i] = 1; | |
6297 } | |
6298 } | |
6299 // Do not use s->qscale as luma quantizer because it has not the same | |
6300 // value in IPCM macroblocks. | |
6301 qp = ( s->current_picture.qscale_table[mb_xy] + s->current_picture.qscale_table[mbn_xy] + 1 ) >> 1; | |
6302 tprintf(s->avctx, "filter mb:%d/%d dir:%d edge:%d, QPy:%d ls:%d uvls:%d", mb_x, mb_y, dir, edge, qp, tmp_linesize, tmp_uvlinesize); | |
6303 { int i; for (i = 0; i < 4; i++) tprintf(s->avctx, " bS[%d]:%d", i, bS[i]); tprintf(s->avctx, "\n"); } | |
6304 filter_mb_edgeh( h, &img_y[j*linesize], tmp_linesize, bS, qp ); | |
6305 filter_mb_edgech( h, &img_cb[j*uvlinesize], tmp_uvlinesize, bS, | |
6306 ( h->chroma_qp[0] + get_chroma_qp( h, 0, s->current_picture.qscale_table[mbn_xy] ) + 1 ) >> 1); | |
6307 filter_mb_edgech( h, &img_cr[j*uvlinesize], tmp_uvlinesize, bS, | |
6308 ( h->chroma_qp[1] + get_chroma_qp( h, 1, s->current_picture.qscale_table[mbn_xy] ) + 1 ) >> 1); | |
6309 } | |
6310 | |
6311 start = 1; | |
6312 } | |
6313 | |
6314 /* Calculate bS */ | |
6315 for( edge = start; edge < edges; edge++ ) { | |
6316 /* mbn_xy: neighbor macroblock */ | |
6317 const int mbn_xy = edge > 0 ? mb_xy : mbm_xy; | |
6318 const int mbn_type = s->current_picture.mb_type[mbn_xy]; | |
6319 int (*ref2frmn)[64] = edge > 0 ? ref2frm : ref2frmm; | |
6320 int16_t bS[4]; | |
6321 int qp; | |
6322 | |
6323 if( (edge&1) && IS_8x8DCT(mb_type) ) | |
6324 continue; | |
6325 | |
6326 if( IS_INTRA(mb_type) || | |
6327 IS_INTRA(mbn_type) ) { | |
6328 int value; | |
6329 if (edge == 0) { | |
6330 if ( (!IS_INTERLACED(mb_type) && !IS_INTERLACED(mbm_type)) | |
6331 || ((FRAME_MBAFF || (s->picture_structure != PICT_FRAME)) && (dir == 0)) | |
6332 ) { | |
6333 value = 4; | |
6334 } else { | |
6335 value = 3; | |
6336 } | |
6337 } else { | |
6338 value = 3; | |
6339 } | |
6340 bS[0] = bS[1] = bS[2] = bS[3] = value; | |
6341 } else { | |
6342 int i, l; | |
6343 int mv_done; | |
6344 | |
6345 if( edge & mask_edge ) { | |
6346 bS[0] = bS[1] = bS[2] = bS[3] = 0; | |
6347 mv_done = 1; | |
6348 } | |
6349 else if( FRAME_MBAFF && IS_INTERLACED(mb_type ^ mbn_type)) { | |
6350 bS[0] = bS[1] = bS[2] = bS[3] = 1; | |
6351 mv_done = 1; | |
6352 } | |
6353 else if( mask_par0 && (edge || (mbn_type & (MB_TYPE_16x16 | (MB_TYPE_8x16 >> dir)))) ) { | |
6354 int b_idx= 8 + 4 + edge * (dir ? 8:1); | |
6355 int bn_idx= b_idx - (dir ? 8:1); | |
6356 int v = 0; | |
6357 | |
6358 for( l = 0; !v && l < 1 + (h->slice_type_nos == FF_B_TYPE); l++ ) { | |
6359 v |= ref2frm[l][h->ref_cache[l][b_idx]] != ref2frmn[l][h->ref_cache[l][bn_idx]] || | |
6360 FFABS( h->mv_cache[l][b_idx][0] - h->mv_cache[l][bn_idx][0] ) >= 4 || | |
6361 FFABS( h->mv_cache[l][b_idx][1] - h->mv_cache[l][bn_idx][1] ) >= mvy_limit; | |
6362 } | |
6363 | |
6364 if(h->slice_type_nos == FF_B_TYPE && v){ | |
6365 v=0; | |
6366 for( l = 0; !v && l < 2; l++ ) { | |
6367 int ln= 1-l; | |
6368 v |= ref2frm[l][h->ref_cache[l][b_idx]] != ref2frmn[ln][h->ref_cache[ln][bn_idx]] || | |
6369 FFABS( h->mv_cache[l][b_idx][0] - h->mv_cache[ln][bn_idx][0] ) >= 4 || | |
6370 FFABS( h->mv_cache[l][b_idx][1] - h->mv_cache[ln][bn_idx][1] ) >= mvy_limit; | |
6371 } | |
6372 } | |
6373 | |
6374 bS[0] = bS[1] = bS[2] = bS[3] = v; | |
6375 mv_done = 1; | |
6376 } | |
6377 else | |
6378 mv_done = 0; | |
6379 | |
6380 for( i = 0; i < 4; i++ ) { | |
6381 int x = dir == 0 ? edge : i; | |
6382 int y = dir == 0 ? i : edge; | |
6383 int b_idx= 8 + 4 + x + 8*y; | |
6384 int bn_idx= b_idx - (dir ? 8:1); | |
6385 | |
6386 if( h->non_zero_count_cache[b_idx] != 0 || | |
6387 h->non_zero_count_cache[bn_idx] != 0 ) { | |
6388 bS[i] = 2; | |
6389 } | |
6390 else if(!mv_done) | |
6391 { | |
6392 bS[i] = 0; | |
6393 for( l = 0; l < 1 + (h->slice_type_nos == FF_B_TYPE); l++ ) { | |
6394 if( ref2frm[l][h->ref_cache[l][b_idx]] != ref2frmn[l][h->ref_cache[l][bn_idx]] || | |
6395 FFABS( h->mv_cache[l][b_idx][0] - h->mv_cache[l][bn_idx][0] ) >= 4 || | |
6396 FFABS( h->mv_cache[l][b_idx][1] - h->mv_cache[l][bn_idx][1] ) >= mvy_limit ) { | |
6397 bS[i] = 1; | |
6398 break; | |
6399 } | |
6400 } | |
6401 | |
6402 if(h->slice_type_nos == FF_B_TYPE && bS[i]){ | |
6403 bS[i] = 0; | |
6404 for( l = 0; l < 2; l++ ) { | |
6405 int ln= 1-l; | |
6406 if( ref2frm[l][h->ref_cache[l][b_idx]] != ref2frmn[ln][h->ref_cache[ln][bn_idx]] || | |
6407 FFABS( h->mv_cache[l][b_idx][0] - h->mv_cache[ln][bn_idx][0] ) >= 4 || | |
6408 FFABS( h->mv_cache[l][b_idx][1] - h->mv_cache[ln][bn_idx][1] ) >= mvy_limit ) { | |
6409 bS[i] = 1; | |
6410 break; | |
6411 } | |
6412 } | |
6413 } | |
6414 } | |
6415 } | |
6416 | |
6417 if(bS[0]+bS[1]+bS[2]+bS[3] == 0) | |
6418 continue; | |
6419 } | |
6420 | |
6421 /* Filter edge */ | |
6422 // Do not use s->qscale as luma quantizer because it has not the same | |
6423 // value in IPCM macroblocks. | |
6424 qp = ( s->current_picture.qscale_table[mb_xy] + s->current_picture.qscale_table[mbn_xy] + 1 ) >> 1; | |
6425 //tprintf(s->avctx, "filter mb:%d/%d dir:%d edge:%d, QPy:%d, QPc:%d, QPcn:%d\n", mb_x, mb_y, dir, edge, qp, h->chroma_qp, s->current_picture.qscale_table[mbn_xy]); | |
6426 tprintf(s->avctx, "filter mb:%d/%d dir:%d edge:%d, QPy:%d ls:%d uvls:%d", mb_x, mb_y, dir, edge, qp, linesize, uvlinesize); | |
6427 { int i; for (i = 0; i < 4; i++) tprintf(s->avctx, " bS[%d]:%d", i, bS[i]); tprintf(s->avctx, "\n"); } | |
6428 if( dir == 0 ) { | |
6429 filter_mb_edgev( h, &img_y[4*edge], linesize, bS, qp ); | |
6430 if( (edge&1) == 0 ) { | |
6431 filter_mb_edgecv( h, &img_cb[2*edge], uvlinesize, bS, | |
6432 ( h->chroma_qp[0] + get_chroma_qp( h, 0, s->current_picture.qscale_table[mbn_xy] ) + 1 ) >> 1); | |
6433 filter_mb_edgecv( h, &img_cr[2*edge], uvlinesize, bS, | |
6434 ( h->chroma_qp[1] + get_chroma_qp( h, 1, s->current_picture.qscale_table[mbn_xy] ) + 1 ) >> 1); | |
6435 } | |
6436 } else { | |
6437 filter_mb_edgeh( h, &img_y[4*edge*linesize], linesize, bS, qp ); | |
6438 if( (edge&1) == 0 ) { | |
6439 filter_mb_edgech( h, &img_cb[2*edge*uvlinesize], uvlinesize, bS, | |
6440 ( h->chroma_qp[0] + get_chroma_qp( h, 0, s->current_picture.qscale_table[mbn_xy] ) + 1 ) >> 1); | |
6441 filter_mb_edgech( h, &img_cr[2*edge*uvlinesize], uvlinesize, bS, | |
6442 ( h->chroma_qp[1] + get_chroma_qp( h, 1, s->current_picture.qscale_table[mbn_xy] ) + 1 ) >> 1); | |
6443 } | |
6444 } | |
6445 } | |
6446 } | |
6447 | |
6244 static void filter_mb( H264Context *h, int mb_x, int mb_y, uint8_t *img_y, uint8_t *img_cb, uint8_t *img_cr, unsigned int linesize, unsigned int uvlinesize) { | 6448 static void filter_mb( H264Context *h, int mb_x, int mb_y, uint8_t *img_y, uint8_t *img_cb, uint8_t *img_cr, unsigned int linesize, unsigned int uvlinesize) { |
6245 MpegEncContext * const s = &h->s; | 6449 MpegEncContext * const s = &h->s; |
6246 const int mb_xy= mb_x + mb_y*s->mb_stride; | 6450 const int mb_xy= mb_x + mb_y*s->mb_stride; |
6247 const int mb_type = s->current_picture.mb_type[mb_xy]; | 6451 const int mb_type = s->current_picture.mb_type[mb_xy]; |
6248 const int mvy_limit = IS_INTERLACED(mb_type) ? 2 : 4; | 6452 const int mvy_limit = IS_INTERLACED(mb_type) ? 2 : 4; |
6356 { int i; for (i = 0; i < 8; i++) tprintf(s->avctx, " bS[%d]:%d", i, bS[i]); tprintf(s->avctx, "\n"); } | 6560 { int i; for (i = 0; i < 8; i++) tprintf(s->avctx, " bS[%d]:%d", i, bS[i]); tprintf(s->avctx, "\n"); } |
6357 filter_mb_mbaff_edgev ( h, &img_y [0], linesize, bS, qp ); | 6561 filter_mb_mbaff_edgev ( h, &img_y [0], linesize, bS, qp ); |
6358 filter_mb_mbaff_edgecv( h, &img_cb[0], uvlinesize, bS, bqp ); | 6562 filter_mb_mbaff_edgecv( h, &img_cb[0], uvlinesize, bS, bqp ); |
6359 filter_mb_mbaff_edgecv( h, &img_cr[0], uvlinesize, bS, rqp ); | 6563 filter_mb_mbaff_edgecv( h, &img_cr[0], uvlinesize, bS, rqp ); |
6360 } | 6564 } |
6361 /* dir : 0 -> vertical edge, 1 -> horizontal edge */ | 6565 |
6566 #ifdef CONFIG_SMALL | |
6362 for( dir = 0; dir < 2; dir++ ) | 6567 for( dir = 0; dir < 2; dir++ ) |
6363 { | 6568 filter_mb_dir(h, mb_x, mb_y, img_y, img_cb, img_cr, linesize, uvlinesize, mb_xy, mb_type, mvy_limit, dir ? 0 : first_vertical_edge_done, dir); |
6364 int edge; | 6569 #else |
6365 const int mbm_xy = dir == 0 ? mb_xy -1 : h->top_mb_xy; | 6570 filter_mb_dir(h, mb_x, mb_y, img_y, img_cb, img_cr, linesize, uvlinesize, mb_xy, mb_type, mvy_limit, first_vertical_edge_done, 0); |
6366 const int mbm_type = s->current_picture.mb_type[mbm_xy]; | 6571 filter_mb_dir(h, mb_x, mb_y, img_y, img_cb, img_cr, linesize, uvlinesize, mb_xy, mb_type, mvy_limit, 0, 1); |
6367 int (*ref2frm) [64] = h->ref2frm[ h->slice_num &(MAX_SLICES-1) ][0] + (MB_MBAFF ? 20 : 2); | 6572 #endif |
6368 int (*ref2frmm)[64] = h->ref2frm[ h->slice_table[mbm_xy]&(MAX_SLICES-1) ][0] + (MB_MBAFF ? 20 : 2); | |
6369 int start = h->slice_table[mbm_xy] == 0xFFFF ? 1 : 0; | |
6370 | |
6371 const int edges = (mb_type & (MB_TYPE_16x16|MB_TYPE_SKIP)) | |
6372 == (MB_TYPE_16x16|MB_TYPE_SKIP) ? 1 : 4; | |
6373 // how often to recheck mv-based bS when iterating between edges | |
6374 const int mask_edge = (mb_type & (MB_TYPE_16x16 | (MB_TYPE_16x8 << dir))) ? 3 : | |
6375 (mb_type & (MB_TYPE_8x16 >> dir)) ? 1 : 0; | |
6376 // how often to recheck mv-based bS when iterating along each edge | |
6377 const int mask_par0 = mb_type & (MB_TYPE_16x16 | (MB_TYPE_8x16 >> dir)); | |
6378 | |
6379 if (first_vertical_edge_done) { | |
6380 start = 1; | |
6381 first_vertical_edge_done = 0; | |
6382 } | |
6383 | |
6384 if (h->deblocking_filter==2 && h->slice_table[mbm_xy] != h->slice_table[mb_xy]) | |
6385 start = 1; | |
6386 | |
6387 if (FRAME_MBAFF && (dir == 1) && ((mb_y&1) == 0) && start == 0 | |
6388 && !IS_INTERLACED(mb_type) | |
6389 && IS_INTERLACED(mbm_type) | |
6390 ) { | |
6391 // This is a special case in the norm where the filtering must | |
6392 // be done twice (one each of the field) even if we are in a | |
6393 // frame macroblock. | |
6394 // | |
6395 static const int nnz_idx[4] = {4,5,6,3}; | |
6396 unsigned int tmp_linesize = 2 * linesize; | |
6397 unsigned int tmp_uvlinesize = 2 * uvlinesize; | |
6398 int mbn_xy = mb_xy - 2 * s->mb_stride; | |
6399 int qp; | |
6400 int i, j; | |
6401 int16_t bS[4]; | |
6402 | |
6403 for(j=0; j<2; j++, mbn_xy += s->mb_stride){ | |
6404 if( IS_INTRA(mb_type) || | |
6405 IS_INTRA(s->current_picture.mb_type[mbn_xy]) ) { | |
6406 bS[0] = bS[1] = bS[2] = bS[3] = 3; | |
6407 } else { | |
6408 const uint8_t *mbn_nnz = h->non_zero_count[mbn_xy]; | |
6409 for( i = 0; i < 4; i++ ) { | |
6410 if( h->non_zero_count_cache[scan8[0]+i] != 0 || | |
6411 mbn_nnz[nnz_idx[i]] != 0 ) | |
6412 bS[i] = 2; | |
6413 else | |
6414 bS[i] = 1; | |
6415 } | |
6416 } | |
6417 // Do not use s->qscale as luma quantizer because it has not the same | |
6418 // value in IPCM macroblocks. | |
6419 qp = ( s->current_picture.qscale_table[mb_xy] + s->current_picture.qscale_table[mbn_xy] + 1 ) >> 1; | |
6420 tprintf(s->avctx, "filter mb:%d/%d dir:%d edge:%d, QPy:%d ls:%d uvls:%d", mb_x, mb_y, dir, edge, qp, tmp_linesize, tmp_uvlinesize); | |
6421 { int i; for (i = 0; i < 4; i++) tprintf(s->avctx, " bS[%d]:%d", i, bS[i]); tprintf(s->avctx, "\n"); } | |
6422 filter_mb_edgeh( h, &img_y[j*linesize], tmp_linesize, bS, qp ); | |
6423 filter_mb_edgech( h, &img_cb[j*uvlinesize], tmp_uvlinesize, bS, | |
6424 ( h->chroma_qp[0] + get_chroma_qp( h, 0, s->current_picture.qscale_table[mbn_xy] ) + 1 ) >> 1); | |
6425 filter_mb_edgech( h, &img_cr[j*uvlinesize], tmp_uvlinesize, bS, | |
6426 ( h->chroma_qp[1] + get_chroma_qp( h, 1, s->current_picture.qscale_table[mbn_xy] ) + 1 ) >> 1); | |
6427 } | |
6428 | |
6429 start = 1; | |
6430 } | |
6431 | |
6432 /* Calculate bS */ | |
6433 for( edge = start; edge < edges; edge++ ) { | |
6434 /* mbn_xy: neighbor macroblock */ | |
6435 const int mbn_xy = edge > 0 ? mb_xy : mbm_xy; | |
6436 const int mbn_type = s->current_picture.mb_type[mbn_xy]; | |
6437 int (*ref2frmn)[64] = edge > 0 ? ref2frm : ref2frmm; | |
6438 int16_t bS[4]; | |
6439 int qp; | |
6440 | |
6441 if( (edge&1) && IS_8x8DCT(mb_type) ) | |
6442 continue; | |
6443 | |
6444 if( IS_INTRA(mb_type) || | |
6445 IS_INTRA(mbn_type) ) { | |
6446 int value; | |
6447 if (edge == 0) { | |
6448 if ( (!IS_INTERLACED(mb_type) && !IS_INTERLACED(mbm_type)) | |
6449 || ((FRAME_MBAFF || (s->picture_structure != PICT_FRAME)) && (dir == 0)) | |
6450 ) { | |
6451 value = 4; | |
6452 } else { | |
6453 value = 3; | |
6454 } | |
6455 } else { | |
6456 value = 3; | |
6457 } | |
6458 bS[0] = bS[1] = bS[2] = bS[3] = value; | |
6459 } else { | |
6460 int i, l; | |
6461 int mv_done; | |
6462 | |
6463 if( edge & mask_edge ) { | |
6464 bS[0] = bS[1] = bS[2] = bS[3] = 0; | |
6465 mv_done = 1; | |
6466 } | |
6467 else if( FRAME_MBAFF && IS_INTERLACED(mb_type ^ mbn_type)) { | |
6468 bS[0] = bS[1] = bS[2] = bS[3] = 1; | |
6469 mv_done = 1; | |
6470 } | |
6471 else if( mask_par0 && (edge || (mbn_type & (MB_TYPE_16x16 | (MB_TYPE_8x16 >> dir)))) ) { | |
6472 int b_idx= 8 + 4 + edge * (dir ? 8:1); | |
6473 int bn_idx= b_idx - (dir ? 8:1); | |
6474 int v = 0; | |
6475 | |
6476 for( l = 0; !v && l < 1 + (h->slice_type_nos == FF_B_TYPE); l++ ) { | |
6477 v |= ref2frm[l][h->ref_cache[l][b_idx]] != ref2frmn[l][h->ref_cache[l][bn_idx]] || | |
6478 FFABS( h->mv_cache[l][b_idx][0] - h->mv_cache[l][bn_idx][0] ) >= 4 || | |
6479 FFABS( h->mv_cache[l][b_idx][1] - h->mv_cache[l][bn_idx][1] ) >= mvy_limit; | |
6480 } | |
6481 | |
6482 if(h->slice_type_nos == FF_B_TYPE && v){ | |
6483 v=0; | |
6484 for( l = 0; !v && l < 2; l++ ) { | |
6485 int ln= 1-l; | |
6486 v |= ref2frm[l][h->ref_cache[l][b_idx]] != ref2frmn[ln][h->ref_cache[ln][bn_idx]] || | |
6487 FFABS( h->mv_cache[l][b_idx][0] - h->mv_cache[ln][bn_idx][0] ) >= 4 || | |
6488 FFABS( h->mv_cache[l][b_idx][1] - h->mv_cache[ln][bn_idx][1] ) >= mvy_limit; | |
6489 } | |
6490 } | |
6491 | |
6492 bS[0] = bS[1] = bS[2] = bS[3] = v; | |
6493 mv_done = 1; | |
6494 } | |
6495 else | |
6496 mv_done = 0; | |
6497 | |
6498 for( i = 0; i < 4; i++ ) { | |
6499 int x = dir == 0 ? edge : i; | |
6500 int y = dir == 0 ? i : edge; | |
6501 int b_idx= 8 + 4 + x + 8*y; | |
6502 int bn_idx= b_idx - (dir ? 8:1); | |
6503 | |
6504 if( h->non_zero_count_cache[b_idx] != 0 || | |
6505 h->non_zero_count_cache[bn_idx] != 0 ) { | |
6506 bS[i] = 2; | |
6507 } | |
6508 else if(!mv_done) | |
6509 { | |
6510 bS[i] = 0; | |
6511 for( l = 0; l < 1 + (h->slice_type_nos == FF_B_TYPE); l++ ) { | |
6512 if( ref2frm[l][h->ref_cache[l][b_idx]] != ref2frmn[l][h->ref_cache[l][bn_idx]] || | |
6513 FFABS( h->mv_cache[l][b_idx][0] - h->mv_cache[l][bn_idx][0] ) >= 4 || | |
6514 FFABS( h->mv_cache[l][b_idx][1] - h->mv_cache[l][bn_idx][1] ) >= mvy_limit ) { | |
6515 bS[i] = 1; | |
6516 break; | |
6517 } | |
6518 } | |
6519 | |
6520 if(h->slice_type_nos == FF_B_TYPE && bS[i]){ | |
6521 bS[i] = 0; | |
6522 for( l = 0; l < 2; l++ ) { | |
6523 int ln= 1-l; | |
6524 if( ref2frm[l][h->ref_cache[l][b_idx]] != ref2frmn[ln][h->ref_cache[ln][bn_idx]] || | |
6525 FFABS( h->mv_cache[l][b_idx][0] - h->mv_cache[ln][bn_idx][0] ) >= 4 || | |
6526 FFABS( h->mv_cache[l][b_idx][1] - h->mv_cache[ln][bn_idx][1] ) >= mvy_limit ) { | |
6527 bS[i] = 1; | |
6528 break; | |
6529 } | |
6530 } | |
6531 } | |
6532 } | |
6533 } | |
6534 | |
6535 if(bS[0]+bS[1]+bS[2]+bS[3] == 0) | |
6536 continue; | |
6537 } | |
6538 | |
6539 /* Filter edge */ | |
6540 // Do not use s->qscale as luma quantizer because it has not the same | |
6541 // value in IPCM macroblocks. | |
6542 qp = ( s->current_picture.qscale_table[mb_xy] + s->current_picture.qscale_table[mbn_xy] + 1 ) >> 1; | |
6543 //tprintf(s->avctx, "filter mb:%d/%d dir:%d edge:%d, QPy:%d, QPc:%d, QPcn:%d\n", mb_x, mb_y, dir, edge, qp, h->chroma_qp, s->current_picture.qscale_table[mbn_xy]); | |
6544 tprintf(s->avctx, "filter mb:%d/%d dir:%d edge:%d, QPy:%d ls:%d uvls:%d", mb_x, mb_y, dir, edge, qp, linesize, uvlinesize); | |
6545 { int i; for (i = 0; i < 4; i++) tprintf(s->avctx, " bS[%d]:%d", i, bS[i]); tprintf(s->avctx, "\n"); } | |
6546 if( dir == 0 ) { | |
6547 filter_mb_edgev( h, &img_y[4*edge], linesize, bS, qp ); | |
6548 if( (edge&1) == 0 ) { | |
6549 filter_mb_edgecv( h, &img_cb[2*edge], uvlinesize, bS, | |
6550 ( h->chroma_qp[0] + get_chroma_qp( h, 0, s->current_picture.qscale_table[mbn_xy] ) + 1 ) >> 1); | |
6551 filter_mb_edgecv( h, &img_cr[2*edge], uvlinesize, bS, | |
6552 ( h->chroma_qp[1] + get_chroma_qp( h, 1, s->current_picture.qscale_table[mbn_xy] ) + 1 ) >> 1); | |
6553 } | |
6554 } else { | |
6555 filter_mb_edgeh( h, &img_y[4*edge*linesize], linesize, bS, qp ); | |
6556 if( (edge&1) == 0 ) { | |
6557 filter_mb_edgech( h, &img_cb[2*edge*uvlinesize], uvlinesize, bS, | |
6558 ( h->chroma_qp[0] + get_chroma_qp( h, 0, s->current_picture.qscale_table[mbn_xy] ) + 1 ) >> 1); | |
6559 filter_mb_edgech( h, &img_cr[2*edge*uvlinesize], uvlinesize, bS, | |
6560 ( h->chroma_qp[1] + get_chroma_qp( h, 1, s->current_picture.qscale_table[mbn_xy] ) + 1 ) >> 1); | |
6561 } | |
6562 } | |
6563 } | |
6564 } | |
6565 } | 6573 } |
6566 | 6574 |
6567 static int decode_slice(struct AVCodecContext *avctx, void *arg){ | 6575 static int decode_slice(struct AVCodecContext *avctx, void *arg){ |
6568 H264Context *h = *(void**)arg; | 6576 H264Context *h = *(void**)arg; |
6569 MpegEncContext * const s = &h->s; | 6577 MpegEncContext * const s = &h->s; |