Mercurial > libavcodec.hg
comparison h264.c @ 7332:b1003e468c3d libavcodec
Fix used references indexes in the loop filter.
Disable filter_mb_fast() as it optimized the incorrect code.
Fixes at least:
BA3_SVA_C.264
CABA3_SVA_B.264
CABACI3_Sony_B.jsv
CAFI1_SVA_C.264
camp_mot_frm0_full.26l
CAWP5_TOSHIBA_E.264
CVFI2_SVA_C.264
CVSE3_Sony_H.jsv
CVWP2_TOSHIBA_E.264
CVWP5_TOSHIBA_E.264
SL1_SVA_B.264
author | michael |
---|---|
date | Sun, 20 Jul 2008 18:06:41 +0000 |
parents | 483421b11d98 |
children | aaf3e396f094 |
comparison
equal
deleted
inserted
replaced
7331:cb07584c262b | 7332:b1003e468c3d |
---|---|
3871 MpegEncContext * const s0 = &h0->s; | 3871 MpegEncContext * const s0 = &h0->s; |
3872 unsigned int first_mb_in_slice; | 3872 unsigned int first_mb_in_slice; |
3873 unsigned int pps_id; | 3873 unsigned int pps_id; |
3874 int num_ref_idx_active_override_flag; | 3874 int num_ref_idx_active_override_flag; |
3875 static const uint8_t slice_type_map[5]= {FF_P_TYPE, FF_B_TYPE, FF_I_TYPE, FF_SP_TYPE, FF_SI_TYPE}; | 3875 static const uint8_t slice_type_map[5]= {FF_P_TYPE, FF_B_TYPE, FF_I_TYPE, FF_SP_TYPE, FF_SI_TYPE}; |
3876 unsigned int slice_type, tmp, i; | 3876 unsigned int slice_type, tmp, i, j; |
3877 int default_ref_list_done = 0; | 3877 int default_ref_list_done = 0; |
3878 int last_pic_structure; | 3878 int last_pic_structure; |
3879 | 3879 |
3880 s->dropable= h->nal_ref_idc == 0; | 3880 s->dropable= h->nal_ref_idc == 0; |
3881 | 3881 |
4161 if(h->nal_ref_idc) | 4161 if(h->nal_ref_idc) |
4162 decode_ref_pic_marking(h0, &s->gb); | 4162 decode_ref_pic_marking(h0, &s->gb); |
4163 | 4163 |
4164 if(FRAME_MBAFF) | 4164 if(FRAME_MBAFF) |
4165 fill_mbaff_ref_list(h); | 4165 fill_mbaff_ref_list(h); |
4166 | |
4167 h->ref2frm[1][0]= h->ref2frm[1][1]= -1; | |
4168 for(j=0; j<2; j++){ | |
4169 h->ref2frm[j][ 0]= | |
4170 h->ref2frm[j][ 1]= -1; | |
4171 for(i=0; i<48; i++) | |
4172 h->ref2frm[j][i+2]= 4*h->ref_list[j][i].frame_num | |
4173 +(h->ref_list[j][i].reference&3); | |
4174 } | |
4166 | 4175 |
4167 if( h->slice_type != FF_I_TYPE && h->slice_type != FF_SI_TYPE && h->pps.cabac ){ | 4176 if( h->slice_type != FF_I_TYPE && h->slice_type != FF_SI_TYPE && h->pps.cabac ){ |
4168 tmp = get_ue_golomb(&s->gb); | 4177 tmp = get_ue_golomb(&s->gb); |
4169 if(tmp > 2){ | 4178 if(tmp > 2){ |
4170 av_log(s->avctx, AV_LOG_ERROR, "cabac_init_idc overflow\n"); | 4179 av_log(s->avctx, AV_LOG_ERROR, "cabac_init_idc overflow\n"); |
6426 int qp, qp0, qp1, qpc, qpc0, qpc1, qp_thresh; | 6435 int qp, qp0, qp1, qpc, qpc0, qpc1, qp_thresh; |
6427 | 6436 |
6428 mb_xy = h->mb_xy; | 6437 mb_xy = h->mb_xy; |
6429 | 6438 |
6430 if(mb_x==0 || mb_y==mb_y_firstrow || !s->dsp.h264_loop_filter_strength || h->pps.chroma_qp_diff || | 6439 if(mb_x==0 || mb_y==mb_y_firstrow || !s->dsp.h264_loop_filter_strength || h->pps.chroma_qp_diff || |
6440 1 || | |
6431 (h->deblocking_filter == 2 && (h->slice_table[mb_xy] != h->slice_table[h->top_mb_xy] || | 6441 (h->deblocking_filter == 2 && (h->slice_table[mb_xy] != h->slice_table[h->top_mb_xy] || |
6432 h->slice_table[mb_xy] != h->slice_table[mb_xy - 1]))) { | 6442 h->slice_table[mb_xy] != h->slice_table[mb_xy - 1]))) { |
6433 filter_mb(h, mb_x, mb_y, img_y, img_cb, img_cr, linesize, uvlinesize); | 6443 filter_mb(h, mb_x, mb_y, img_y, img_cb, img_cr, linesize, uvlinesize); |
6434 return; | 6444 return; |
6435 } | 6445 } |
6537 const int mb_xy= mb_x + mb_y*s->mb_stride; | 6547 const int mb_xy= mb_x + mb_y*s->mb_stride; |
6538 const int mb_type = s->current_picture.mb_type[mb_xy]; | 6548 const int mb_type = s->current_picture.mb_type[mb_xy]; |
6539 const int mvy_limit = IS_INTERLACED(mb_type) ? 2 : 4; | 6549 const int mvy_limit = IS_INTERLACED(mb_type) ? 2 : 4; |
6540 int first_vertical_edge_done = 0; | 6550 int first_vertical_edge_done = 0; |
6541 int dir; | 6551 int dir; |
6542 /* FIXME: A given frame may occupy more than one position in | |
6543 * the reference list. So ref2frm should be populated with | |
6544 * frame numbers, not indexes. */ | |
6545 static const int ref2frm[34] = {-1,-1,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15, | |
6546 16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31}; | |
6547 | 6552 |
6548 //for sufficiently low qp, filtering wouldn't do anything | 6553 //for sufficiently low qp, filtering wouldn't do anything |
6549 //this is a conservative estimate: could also check beta_offset and more accurate chroma_qp | 6554 //this is a conservative estimate: could also check beta_offset and more accurate chroma_qp |
6550 if(!FRAME_MBAFF){ | 6555 if(!FRAME_MBAFF){ |
6551 int qp_thresh = 15 - h->slice_alpha_c0_offset - FFMAX3(0, h->pps.chroma_qp_index_offset[0], h->pps.chroma_qp_index_offset[1]); | 6556 int qp_thresh = 15 - h->slice_alpha_c0_offset - FFMAX3(0, h->pps.chroma_qp_index_offset[0], h->pps.chroma_qp_index_offset[1]); |
6724 } | 6729 } |
6725 else if( mask_par0 && (edge || (mbn_type & (MB_TYPE_16x16 | (MB_TYPE_8x16 >> dir)))) ) { | 6730 else if( mask_par0 && (edge || (mbn_type & (MB_TYPE_16x16 | (MB_TYPE_8x16 >> dir)))) ) { |
6726 int b_idx= 8 + 4 + edge * (dir ? 8:1); | 6731 int b_idx= 8 + 4 + edge * (dir ? 8:1); |
6727 int bn_idx= b_idx - (dir ? 8:1); | 6732 int bn_idx= b_idx - (dir ? 8:1); |
6728 int v = 0; | 6733 int v = 0; |
6734 int xn= (h->ref_cache[0][ b_idx] ^ h->ref_cache[0][bn_idx]) < 0; | |
6735 | |
6729 for( l = 0; !v && l < 1 + (h->slice_type == FF_B_TYPE); l++ ) { | 6736 for( l = 0; !v && l < 1 + (h->slice_type == FF_B_TYPE); l++ ) { |
6730 v |= ref2frm[h->ref_cache[l][b_idx]+2] != ref2frm[h->ref_cache[l][bn_idx]+2] || | 6737 int ln= l^xn; |
6731 FFABS( h->mv_cache[l][b_idx][0] - h->mv_cache[l][bn_idx][0] ) >= 4 || | 6738 v |= h->ref2frm[l][h->ref_cache[l][b_idx]+2] != h->ref2frm[ln][h->ref_cache[ln][bn_idx]+2] || |
6732 FFABS( h->mv_cache[l][b_idx][1] - h->mv_cache[l][bn_idx][1] ) >= mvy_limit; | 6739 FFABS( h->mv_cache[l][b_idx][0] - h->mv_cache[ln][bn_idx][0] ) >= 4 || |
6740 FFABS( h->mv_cache[l][b_idx][1] - h->mv_cache[ln][bn_idx][1] ) >= mvy_limit; | |
6733 } | 6741 } |
6734 bS[0] = bS[1] = bS[2] = bS[3] = v; | 6742 bS[0] = bS[1] = bS[2] = bS[3] = v; |
6735 mv_done = 1; | 6743 mv_done = 1; |
6736 } | 6744 } |
6737 else | 6745 else |
6747 h->non_zero_count_cache[bn_idx] != 0 ) { | 6755 h->non_zero_count_cache[bn_idx] != 0 ) { |
6748 bS[i] = 2; | 6756 bS[i] = 2; |
6749 } | 6757 } |
6750 else if(!mv_done) | 6758 else if(!mv_done) |
6751 { | 6759 { |
6760 int xn= (h->ref_cache[0][ b_idx] ^ h->ref_cache[0][bn_idx]) < 0; | |
6752 bS[i] = 0; | 6761 bS[i] = 0; |
6753 for( l = 0; l < 1 + (h->slice_type == FF_B_TYPE); l++ ) { | 6762 for( l = 0; l < 1 + (h->slice_type == FF_B_TYPE); l++ ) { |
6754 if( ref2frm[h->ref_cache[l][b_idx]+2] != ref2frm[h->ref_cache[l][bn_idx]+2] || | 6763 int ln= l^xn; |
6755 FFABS( h->mv_cache[l][b_idx][0] - h->mv_cache[l][bn_idx][0] ) >= 4 || | 6764 if( h->ref2frm[l][h->ref_cache[l][b_idx]+2] != h->ref2frm[ln][h->ref_cache[ln][bn_idx]+2] || |
6756 FFABS( h->mv_cache[l][b_idx][1] - h->mv_cache[l][bn_idx][1] ) >= mvy_limit ) { | 6765 FFABS( h->mv_cache[l][b_idx][0] - h->mv_cache[ln][bn_idx][0] ) >= 4 || |
6766 FFABS( h->mv_cache[l][b_idx][1] - h->mv_cache[ln][bn_idx][1] ) >= mvy_limit ) { | |
6757 bS[i] = 1; | 6767 bS[i] = 1; |
6758 break; | 6768 break; |
6759 } | 6769 } |
6760 } | 6770 } |
6761 } | 6771 } |