comparison h264.c @ 3651:2265410d1d74 libavcodec

slightly faster deblock
author lorenm
date Tue, 29 Aug 2006 03:07:58 +0000
parents 47821be55b6c
children 1843a85123b7
comparison
equal deleted inserted replaced
3650:a74c0aaf9832 3651:2265410d1d74
369 uint8_t cabac_state[460]; 369 uint8_t cabac_state[460];
370 int cabac_init_idc; 370 int cabac_init_idc;
371 371
372 /* 0x100 -> non null luma_dc, 0x80/0x40 -> non null chroma_dc (cb/cr), 0x?0 -> chroma_cbp(0,1,2), 0x0? luma_cbp */ 372 /* 0x100 -> non null luma_dc, 0x80/0x40 -> non null chroma_dc (cb/cr), 0x?0 -> chroma_cbp(0,1,2), 0x0? luma_cbp */
373 uint16_t *cbp_table; 373 uint16_t *cbp_table;
374 int cbp;
374 int top_cbp; 375 int top_cbp;
375 int left_cbp; 376 int left_cbp;
376 /* chroma_pred_mode for i4x4 or i16x16, else 0 */ 377 /* chroma_pred_mode for i4x4 or i16x16, else 0 */
377 uint8_t *chroma_pred_mode_table; 378 uint8_t *chroma_pred_mode_table;
378 int last_qscale_diff; 379 int last_qscale_diff;
5477 if(IS_INTRA4x4(mb_type)) 5478 if(IS_INTRA4x4(mb_type))
5478 cbp= golomb_to_intra4x4_cbp[cbp]; 5479 cbp= golomb_to_intra4x4_cbp[cbp];
5479 else 5480 else
5480 cbp= golomb_to_inter_cbp[cbp]; 5481 cbp= golomb_to_inter_cbp[cbp];
5481 } 5482 }
5483 h->cbp = cbp;
5482 5484
5483 if(dct8x8_allowed && (cbp&15) && !IS_INTRA(mb_type)){ 5485 if(dct8x8_allowed && (cbp&15) && !IS_INTRA(mb_type)){
5484 if(get_bits1(&s->gb)) 5486 if(get_bits1(&s->gb))
5485 mb_type |= MB_TYPE_8x8DCT; 5487 mb_type |= MB_TYPE_8x8DCT;
5486 } 5488 }
6579 if( !IS_INTRA16x16( mb_type ) ) { 6581 if( !IS_INTRA16x16( mb_type ) ) {
6580 cbp = decode_cabac_mb_cbp_luma( h ); 6582 cbp = decode_cabac_mb_cbp_luma( h );
6581 cbp |= decode_cabac_mb_cbp_chroma( h ) << 4; 6583 cbp |= decode_cabac_mb_cbp_chroma( h ) << 4;
6582 } 6584 }
6583 6585
6584 h->cbp_table[mb_xy] = cbp; 6586 h->cbp_table[mb_xy] = h->cbp = cbp;
6585 6587
6586 if( dct8x8_allowed && (cbp&15) && !IS_INTRA( mb_type ) ) { 6588 if( dct8x8_allowed && (cbp&15) && !IS_INTRA( mb_type ) ) {
6587 if( decode_cabac_mb_transform_size( h ) ) 6589 if( decode_cabac_mb_transform_size( h ) )
6588 mb_type |= MB_TYPE_8x8DCT; 6590 mb_type |= MB_TYPE_8x8DCT;
6589 } 6591 }
7018 qpc = get_chroma_qp( h->pps.chroma_qp_index_offset, qp ); 7020 qpc = get_chroma_qp( h->pps.chroma_qp_index_offset, qp );
7019 qpc0 = get_chroma_qp( h->pps.chroma_qp_index_offset, qp0 ); 7021 qpc0 = get_chroma_qp( h->pps.chroma_qp_index_offset, qp0 );
7020 qpc1 = get_chroma_qp( h->pps.chroma_qp_index_offset, qp1 ); 7022 qpc1 = get_chroma_qp( h->pps.chroma_qp_index_offset, qp1 );
7021 qp0 = (qp + qp0 + 1) >> 1; 7023 qp0 = (qp + qp0 + 1) >> 1;
7022 qp1 = (qp + qp1 + 1) >> 1; 7024 qp1 = (qp + qp1 + 1) >> 1;
7023 qp_thresh = 15 - h->slice_alpha_c0_offset - FFMAX(0, h->pps.chroma_qp_index_offset);
7024 if(qp <= qp_thresh && qp0 <= qp_thresh && qp1 <= qp_thresh)
7025 return;
7026 qpc0 = (qpc + qpc0 + 1) >> 1; 7025 qpc0 = (qpc + qpc0 + 1) >> 1;
7027 qpc1 = (qpc + qpc1 + 1) >> 1; 7026 qpc1 = (qpc + qpc1 + 1) >> 1;
7027 qp_thresh = 15 - h->slice_alpha_c0_offset;
7028 if(qp <= qp_thresh && qp0 <= qp_thresh && qp1 <= qp_thresh &&
7029 qpc <= qp_thresh && qpc0 <= qp_thresh && qpc1 <= qp_thresh)
7030 return;
7028 7031
7029 if( IS_INTRA(mb_type) ) { 7032 if( IS_INTRA(mb_type) ) {
7030 int16_t bS4[4] = {4,4,4,4}; 7033 int16_t bS4[4] = {4,4,4,4};
7031 int16_t bS3[4] = {3,3,3,3}; 7034 int16_t bS3[4] = {3,3,3,3};
7032 if( IS_8x8DCT(mb_type) ) { 7035 if( IS_8x8DCT(mb_type) ) {
7054 filter_mb_edgech( h, &img_cr[2*2*uvlinesize], uvlinesize, bS3, qpc ); 7057 filter_mb_edgech( h, &img_cr[2*2*uvlinesize], uvlinesize, bS3, qpc );
7055 return; 7058 return;
7056 } else { 7059 } else {
7057 DECLARE_ALIGNED_8(int16_t, bS[2][4][4]); 7060 DECLARE_ALIGNED_8(int16_t, bS[2][4][4]);
7058 uint64_t (*bSv)[4] = (uint64_t(*)[4])bS; 7061 uint64_t (*bSv)[4] = (uint64_t(*)[4])bS;
7059 int edges = (mb_type & (MB_TYPE_16x16|MB_TYPE_SKIP)) 7062 int edges;
7060 == (MB_TYPE_16x16|MB_TYPE_SKIP) ? 1 : 4; 7063 if( IS_8x8DCT(mb_type) && (h->cbp&7) == 7 ) {
7061 int mask_edge1 = (mb_type & (MB_TYPE_16x16 | MB_TYPE_8x16)) ? 3 : 7064 edges = 4;
7062 (mb_type & MB_TYPE_16x8) ? 1 : 0; 7065 bSv[0][0] = bSv[0][2] = bSv[1][0] = bSv[1][2] = 0x0002000200020002ULL;
7063 int mask_edge0 = (mb_type & (MB_TYPE_16x16 | MB_TYPE_8x16)) 7066 } else {
7064 && (s->current_picture.mb_type[mb_xy-1] & (MB_TYPE_16x16 | MB_TYPE_8x16)) 7067 int mask_edge1 = (mb_type & (MB_TYPE_16x16 | MB_TYPE_8x16)) ? 3 :
7065 ? 3 : 0; 7068 (mb_type & MB_TYPE_16x8) ? 1 : 0;
7066 int step = IS_8x8DCT(mb_type) ? 2 : 1; 7069 int mask_edge0 = (mb_type & (MB_TYPE_16x16 | MB_TYPE_8x16))
7067 s->dsp.h264_loop_filter_strength( bS, h->non_zero_count_cache, h->ref_cache, h->mv_cache, 7070 && (s->current_picture.mb_type[mb_xy-1] & (MB_TYPE_16x16 | MB_TYPE_8x16))
7068 (h->slice_type == B_TYPE), edges, step, mask_edge0, mask_edge1 ); 7071 ? 3 : 0;
7072 int step = IS_8x8DCT(mb_type) ? 2 : 1;
7073 edges = (mb_type & MB_TYPE_16x16) && !(h->cbp & 15) ? 1 : 4;
7074 s->dsp.h264_loop_filter_strength( bS, h->non_zero_count_cache, h->ref_cache, h->mv_cache,
7075 (h->slice_type == B_TYPE), edges, step, mask_edge0, mask_edge1 );
7076 }
7069 if( IS_INTRA(s->current_picture.mb_type[mb_xy-1]) ) 7077 if( IS_INTRA(s->current_picture.mb_type[mb_xy-1]) )
7070 bSv[0][0] = 0x0004000400040004ULL; 7078 bSv[0][0] = 0x0004000400040004ULL;
7071 if( IS_INTRA(s->current_picture.mb_type[h->top_mb_xy]) ) 7079 if( IS_INTRA(s->current_picture.mb_type[h->top_mb_xy]) )
7072 bSv[1][0] = 0x0004000400040004ULL; 7080 bSv[1][0] = 0x0004000400040004ULL;
7073 7081