comparison h264.c @ 2597:b5b09255f7c3 libavcodec

CABAC support for MBAFF I frames patch by (Lo«Ác Le Loarer < lll+ffmpeg m4x org) This patch corrects the support for I slice in CABAC and MBAFF mode. This decodes correctly 6 more frames of the conformance suite.
author michael
date Tue, 05 Apr 2005 18:29:26 +0000
parents 5357b214eda0
children aaf8e94bce00
comparison
equal deleted inserted replaced
2596:3e90a8cfddc6 2597:b5b09255f7c3
4656 uint8_t *state= &h->cabac_state[ctx_base]; 4656 uint8_t *state= &h->cabac_state[ctx_base];
4657 int mb_type; 4657 int mb_type;
4658 4658
4659 if(intra_slice){ 4659 if(intra_slice){
4660 MpegEncContext * const s = &h->s; 4660 MpegEncContext * const s = &h->s;
4661 const int mb_xy= s->mb_x + s->mb_y*s->mb_stride; 4661 const int mba_xy = h->left_mb_xy[0];
4662 const int mba_xy = mb_xy - 1; 4662 const int mbb_xy = h->top_mb_xy;
4663 const int mbb_xy = mb_xy - s->mb_stride;
4664 int ctx=0; 4663 int ctx=0;
4665 if( h->slice_table[mba_xy] == h->slice_num && !IS_INTRA4x4( s->current_picture.mb_type[mba_xy] ) ) 4664 if( h->slice_table[mba_xy] == h->slice_num && !IS_INTRA4x4( s->current_picture.mb_type[mba_xy] ) )
4666 ctx++; 4665 ctx++;
4667 if( h->slice_table[mbb_xy] == h->slice_num && !IS_INTRA4x4( s->current_picture.mb_type[mbb_xy] ) ) 4666 if( h->slice_table[mbb_xy] == h->slice_num && !IS_INTRA4x4( s->current_picture.mb_type[mbb_xy] ) )
4668 ctx++; 4667 ctx++;
4715 } 4714 }
4716 } else { 4715 } else {
4717 return decode_cabac_intra_mb_type(h, 17, 0) + 5; 4716 return decode_cabac_intra_mb_type(h, 17, 0) + 5;
4718 } 4717 }
4719 } else if( h->slice_type == B_TYPE ) { 4718 } else if( h->slice_type == B_TYPE ) {
4720 const int mb_xy= s->mb_x + s->mb_y*s->mb_stride; 4719 const int mba_xy = h->left_mb_xy[0];
4721 const int mba_xy = mb_xy - 1; 4720 const int mbb_xy = h->top_mb_xy;
4722 const int mbb_xy = mb_xy - s->mb_stride;
4723 int ctx = 0; 4721 int ctx = 0;
4724 int bits; 4722 int bits;
4725 4723
4726 if( h->slice_table[mba_xy] == h->slice_num && !IS_SKIP( s->current_picture.mb_type[mba_xy] ) 4724 if( h->slice_table[mba_xy] == h->slice_num && !IS_SKIP( s->current_picture.mb_type[mba_xy] )
4727 && !IS_DIRECT( s->current_picture.mb_type[mba_xy] ) ) 4725 && !IS_DIRECT( s->current_picture.mb_type[mba_xy] ) )
5150 } 5148 }
5151 } 5149 }
5152 return 0; 5150 return 0;
5153 } 5151 }
5154 5152
5153 void inline compute_mb_neighboors(H264Context *h)
5154 {
5155 MpegEncContext * const s = &h->s;
5156 const int mb_xy = s->mb_x + s->mb_y*s->mb_stride;
5157 h->top_mb_xy = mb_xy - s->mb_stride;
5158 h->left_mb_xy[0] = mb_xy - 1;
5159 if(h->mb_aff_frame){
5160 const int pair_xy = s->mb_x + (s->mb_y & ~1)*s->mb_stride;
5161 const int top_pair_xy = pair_xy - s->mb_stride;
5162 const int top_mb_frame_flag = !IS_INTERLACED(s->current_picture.mb_type[top_pair_xy]);
5163 const int left_mb_frame_flag = !IS_INTERLACED(s->current_picture.mb_type[pair_xy-1]);
5164 const int curr_mb_frame_flag = !h->mb_field_decoding_flag;
5165 const int bottom = (s->mb_y & 1);
5166 if (bottom
5167 ? !curr_mb_frame_flag // bottom macroblock
5168 : (!curr_mb_frame_flag && !top_mb_frame_flag) // top macroblock
5169 ) {
5170 h->top_mb_xy -= s->mb_stride;
5171 }
5172 if (left_mb_frame_flag != curr_mb_frame_flag) {
5173 h->left_mb_xy[0] = pair_xy - 1;
5174 }
5175 }
5176 return;
5177 }
5178
5155 /** 5179 /**
5156 * decodes a macroblock 5180 * decodes a macroblock
5157 * @returns 0 if ok, AC_ERROR / DC_ERROR / MV_ERROR if an error is noticed 5181 * @returns 0 if ok, AC_ERROR / DC_ERROR / MV_ERROR if an error is noticed
5158 */ 5182 */
5159 static int decode_mb_cabac(H264Context *h) { 5183 static int decode_mb_cabac(H264Context *h) {
5183 }else 5207 }else
5184 h->mb_field_decoding_flag= (s->picture_structure!=PICT_FRAME); 5208 h->mb_field_decoding_flag= (s->picture_structure!=PICT_FRAME);
5185 5209
5186 h->prev_mb_skiped = 0; 5210 h->prev_mb_skiped = 0;
5187 5211
5212 compute_mb_neighboors(h);
5188 if( ( mb_type = decode_cabac_mb_type( h ) ) < 0 ) { 5213 if( ( mb_type = decode_cabac_mb_type( h ) ) < 0 ) {
5189 av_log( h->s.avctx, AV_LOG_ERROR, "decode_cabac_mb_type failed\n" ); 5214 av_log( h->s.avctx, AV_LOG_ERROR, "decode_cabac_mb_type failed\n" );
5190 return -1; 5215 return -1;
5191 } 5216 }
5192 5217