Mercurial > libavcodec.hg
comparison h264.c @ 7338:b088035801d5 libavcodec
Simplify slice type checks.
author | michael |
---|---|
date | Mon, 21 Jul 2008 18:24:45 +0000 |
parents | 1328ffc5e0fd |
children | 7d5cc12d8fe2 |
comparison
equal
deleted
inserted
replaced
7337:1328ffc5e0fd | 7338:b088035801d5 |
---|---|
3029 MpegEncContext * const s = &h->s; | 3029 MpegEncContext * const s = &h->s; |
3030 int list, index, pic_structure; | 3030 int list, index, pic_structure; |
3031 | 3031 |
3032 print_short_term(h); | 3032 print_short_term(h); |
3033 print_long_term(h); | 3033 print_long_term(h); |
3034 if(h->slice_type==FF_I_TYPE || h->slice_type==FF_SI_TYPE) return 0; //FIXME move before func | 3034 if(h->slice_type_nos==FF_I_TYPE) return 0; //FIXME move before func |
3035 | 3035 |
3036 for(list=0; list<h->list_count; list++){ | 3036 for(list=0; list<h->list_count; list++){ |
3037 memcpy(h->ref_list[list], h->default_ref_list[list], sizeof(Picture)*h->ref_count[list]); | 3037 memcpy(h->ref_list[list], h->default_ref_list[list], sizeof(Picture)*h->ref_count[list]); |
3038 | 3038 |
3039 if(get_bits1(&s->gb)){ | 3039 if(get_bits1(&s->gb)){ |
3906 if (slice_type == FF_I_TYPE | 3906 if (slice_type == FF_I_TYPE |
3907 || (h0->current_slice != 0 && slice_type == h0->last_slice_type) ) { | 3907 || (h0->current_slice != 0 && slice_type == h0->last_slice_type) ) { |
3908 default_ref_list_done = 1; | 3908 default_ref_list_done = 1; |
3909 } | 3909 } |
3910 h->slice_type= slice_type; | 3910 h->slice_type= slice_type; |
3911 h->slice_type_nos= slice_type & 3; | |
3911 | 3912 |
3912 s->pict_type= h->slice_type; // to make a few old func happy, it's wrong though | 3913 s->pict_type= h->slice_type; // to make a few old func happy, it's wrong though |
3913 if (s->pict_type == FF_B_TYPE && s0->last_picture_ptr == NULL) { | 3914 if (s->pict_type == FF_B_TYPE && s0->last_picture_ptr == NULL) { |
3914 av_log(h->s.avctx, AV_LOG_ERROR, | 3915 av_log(h->s.avctx, AV_LOG_ERROR, |
3915 "B picture before any references, skipping\n"); | 3916 "B picture before any references, skipping\n"); |
4111 | 4112 |
4112 //set defaults, might be overriden a few line later | 4113 //set defaults, might be overriden a few line later |
4113 h->ref_count[0]= h->pps.ref_count[0]; | 4114 h->ref_count[0]= h->pps.ref_count[0]; |
4114 h->ref_count[1]= h->pps.ref_count[1]; | 4115 h->ref_count[1]= h->pps.ref_count[1]; |
4115 | 4116 |
4116 if(h->slice_type == FF_P_TYPE || h->slice_type == FF_SP_TYPE || h->slice_type == FF_B_TYPE){ | 4117 if(h->slice_type_nos != FF_I_TYPE){ |
4117 if(h->slice_type == FF_B_TYPE){ | 4118 if(h->slice_type == FF_B_TYPE){ |
4118 h->direct_spatial_mv_pred= get_bits1(&s->gb); | 4119 h->direct_spatial_mv_pred= get_bits1(&s->gb); |
4119 if(FIELD_PICTURE && h->direct_spatial_mv_pred) | 4120 if(FIELD_PICTURE && h->direct_spatial_mv_pred) |
4120 av_log(h->s.avctx, AV_LOG_ERROR, "PAFF + spatial direct mode is not implemented\n"); | 4121 av_log(h->s.avctx, AV_LOG_ERROR, "PAFF + spatial direct mode is not implemented\n"); |
4121 } | 4122 } |
4144 } | 4145 } |
4145 | 4146 |
4146 if(decode_ref_pic_list_reordering(h) < 0) | 4147 if(decode_ref_pic_list_reordering(h) < 0) |
4147 return -1; | 4148 return -1; |
4148 | 4149 |
4149 if( (h->pps.weighted_pred && (h->slice_type == FF_P_TYPE || h->slice_type == FF_SP_TYPE )) | 4150 if( (h->pps.weighted_pred && (h->slice_type_nos == FF_P_TYPE )) |
4150 || (h->pps.weighted_bipred_idc==1 && h->slice_type==FF_B_TYPE ) ) | 4151 || (h->pps.weighted_bipred_idc==1 && h->slice_type==FF_B_TYPE ) ) |
4151 pred_weight_table(h); | 4152 pred_weight_table(h); |
4152 else if(h->pps.weighted_bipred_idc==2 && h->slice_type==FF_B_TYPE) | 4153 else if(h->pps.weighted_bipred_idc==2 && h->slice_type==FF_B_TYPE) |
4153 implicit_weight_table(h); | 4154 implicit_weight_table(h); |
4154 else | 4155 else |
4167 for(i=0; i<48; i++) | 4168 for(i=0; i<48; i++) |
4168 h->ref2frm[j][i+2]= 4*h->ref_list[j][i].frame_num | 4169 h->ref2frm[j][i+2]= 4*h->ref_list[j][i].frame_num |
4169 +(h->ref_list[j][i].reference&3); | 4170 +(h->ref_list[j][i].reference&3); |
4170 } | 4171 } |
4171 | 4172 |
4172 if( h->slice_type != FF_I_TYPE && h->slice_type != FF_SI_TYPE && h->pps.cabac ){ | 4173 if( h->slice_type_nos != FF_I_TYPE && h->pps.cabac ){ |
4173 tmp = get_ue_golomb(&s->gb); | 4174 tmp = get_ue_golomb(&s->gb); |
4174 if(tmp > 2){ | 4175 if(tmp > 2){ |
4175 av_log(s->avctx, AV_LOG_ERROR, "cabac_init_idc overflow\n"); | 4176 av_log(s->avctx, AV_LOG_ERROR, "cabac_init_idc overflow\n"); |
4176 return -1; | 4177 return -1; |
4177 } | 4178 } |
4519 s->dsp.clear_blocks(h->mb); //FIXME avoid if already clear (move after skip handlong? | 4520 s->dsp.clear_blocks(h->mb); //FIXME avoid if already clear (move after skip handlong? |
4520 | 4521 |
4521 tprintf(s->avctx, "pic:%d mb:%d/%d\n", h->frame_num, s->mb_x, s->mb_y); | 4522 tprintf(s->avctx, "pic:%d mb:%d/%d\n", h->frame_num, s->mb_x, s->mb_y); |
4522 cbp = 0; /* avoid warning. FIXME: find a solution without slowing | 4523 cbp = 0; /* avoid warning. FIXME: find a solution without slowing |
4523 down the code */ | 4524 down the code */ |
4524 if(h->slice_type != FF_I_TYPE && h->slice_type != FF_SI_TYPE){ | 4525 if(h->slice_type_nos != FF_I_TYPE){ |
4525 if(s->mb_skip_run==-1) | 4526 if(s->mb_skip_run==-1) |
4526 s->mb_skip_run= get_ue_golomb(&s->gb); | 4527 s->mb_skip_run= get_ue_golomb(&s->gb); |
4527 | 4528 |
4528 if (s->mb_skip_run--) { | 4529 if (s->mb_skip_run--) { |
4529 if(FRAME_MBAFF && (s->mb_y&1) == 0){ | 4530 if(FRAME_MBAFF && (s->mb_y&1) == 0){ |
4685 h->ref_cache[1][scan8[4]] = | 4686 h->ref_cache[1][scan8[4]] = |
4686 h->ref_cache[0][scan8[12]] = | 4687 h->ref_cache[0][scan8[12]] = |
4687 h->ref_cache[1][scan8[12]] = PART_NOT_AVAILABLE; | 4688 h->ref_cache[1][scan8[12]] = PART_NOT_AVAILABLE; |
4688 } | 4689 } |
4689 }else{ | 4690 }else{ |
4690 assert(h->slice_type == FF_P_TYPE || h->slice_type == FF_SP_TYPE); //FIXME SP correct ? | 4691 assert(h->slice_type_nos == FF_P_TYPE); //FIXME SP correct ? |
4691 for(i=0; i<4; i++){ | 4692 for(i=0; i<4; i++){ |
4692 h->sub_mb_type[i]= get_ue_golomb(&s->gb); | 4693 h->sub_mb_type[i]= get_ue_golomb(&s->gb); |
4693 if(h->sub_mb_type[i] >=4){ | 4694 if(h->sub_mb_type[i] >=4){ |
4694 av_log(h->s.avctx, AV_LOG_ERROR, "P sub_mb_type %u out of range at %d %d\n", h->sub_mb_type[i], s->mb_x, s->mb_y); | 4695 av_log(h->s.avctx, AV_LOG_ERROR, "P sub_mb_type %u out of range at %d %d\n", h->sub_mb_type[i], s->mb_x, s->mb_y); |
4695 return -1; | 4696 return -1; |
5634 mb_xy = h->mb_xy = s->mb_x + s->mb_y*s->mb_stride; | 5635 mb_xy = h->mb_xy = s->mb_x + s->mb_y*s->mb_stride; |
5635 | 5636 |
5636 s->dsp.clear_blocks(h->mb); //FIXME avoid if already clear (move after skip handlong?) | 5637 s->dsp.clear_blocks(h->mb); //FIXME avoid if already clear (move after skip handlong?) |
5637 | 5638 |
5638 tprintf(s->avctx, "pic:%d mb:%d/%d\n", h->frame_num, s->mb_x, s->mb_y); | 5639 tprintf(s->avctx, "pic:%d mb:%d/%d\n", h->frame_num, s->mb_x, s->mb_y); |
5639 if( h->slice_type != FF_I_TYPE && h->slice_type != FF_SI_TYPE ) { | 5640 if( h->slice_type_nos != FF_I_TYPE ) { |
5640 int skip; | 5641 int skip; |
5641 /* a skipped mb needs the aff flag from the following mb */ | 5642 /* a skipped mb needs the aff flag from the following mb */ |
5642 if( FRAME_MBAFF && s->mb_x==0 && (s->mb_y&1)==0 ) | 5643 if( FRAME_MBAFF && s->mb_x==0 && (s->mb_y&1)==0 ) |
5643 predict_field_decoding_flag(h); | 5644 predict_field_decoding_flag(h); |
5644 if( FRAME_MBAFF && (s->mb_y&1)==1 && h->prev_mb_skipped ) | 5645 if( FRAME_MBAFF && (s->mb_y&1)==1 && h->prev_mb_skipped ) |