comparison h264.c @ 7340:ef40221c1452 libavcodec

SI/SP slice support. (not bitexact) SI untested as I did not find any samples.
author michael
date Mon, 21 Jul 2008 18:44:57 +0000
parents 7d5cc12d8fe2
children b75aa0197be4
comparison
equal deleted inserted replaced
7339:7d5cc12d8fe2 7340:ef40221c1452
4214 h->slice_beta_offset = get_se_golomb(&s->gb) << 1; 4214 h->slice_beta_offset = get_se_golomb(&s->gb) << 1;
4215 } 4215 }
4216 } 4216 }
4217 4217
4218 if( s->avctx->skip_loop_filter >= AVDISCARD_ALL 4218 if( s->avctx->skip_loop_filter >= AVDISCARD_ALL
4219 ||(s->avctx->skip_loop_filter >= AVDISCARD_NONKEY && h->slice_type != FF_I_TYPE) 4219 ||(s->avctx->skip_loop_filter >= AVDISCARD_NONKEY && h->slice_type_nos != FF_I_TYPE)
4220 ||(s->avctx->skip_loop_filter >= AVDISCARD_BIDIR && h->slice_type == FF_B_TYPE) 4220 ||(s->avctx->skip_loop_filter >= AVDISCARD_BIDIR && h->slice_type == FF_B_TYPE)
4221 ||(s->avctx->skip_loop_filter >= AVDISCARD_NONREF && h->nal_ref_idc == 0)) 4221 ||(s->avctx->skip_loop_filter >= AVDISCARD_NONREF && h->nal_ref_idc == 0))
4222 h->deblocking_filter= 0; 4222 h->deblocking_filter= 0;
4223 4223
4224 if(h->deblocking_filter == 1 && h0->max_contexts > 1) { 4224 if(h->deblocking_filter == 1 && h0->max_contexts > 1) {
4552 mb_type= b_mb_type_info[mb_type].type; 4552 mb_type= b_mb_type_info[mb_type].type;
4553 }else{ 4553 }else{
4554 mb_type -= 23; 4554 mb_type -= 23;
4555 goto decode_intra_mb; 4555 goto decode_intra_mb;
4556 } 4556 }
4557 }else if(h->slice_type == FF_P_TYPE /*|| h->slice_type == FF_SP_TYPE */){ 4557 }else if(h->slice_type_nos == FF_P_TYPE){
4558 if(mb_type < 5){ 4558 if(mb_type < 5){
4559 partition_count= p_mb_type_info[mb_type].partition_count; 4559 partition_count= p_mb_type_info[mb_type].partition_count;
4560 mb_type= p_mb_type_info[mb_type].type; 4560 mb_type= p_mb_type_info[mb_type].type;
4561 }else{ 4561 }else{
4562 mb_type -= 5; 4562 mb_type -= 5;
4563 goto decode_intra_mb; 4563 goto decode_intra_mb;
4564 } 4564 }
4565 }else{ 4565 }else{
4566 assert(h->slice_type == FF_I_TYPE); 4566 assert(h->slice_type_nos == FF_I_TYPE);
4567 if(h->slice_type == FF_SI_TYPE && mb_type)
4568 mb_type--;
4567 decode_intra_mb: 4569 decode_intra_mb:
4568 if(mb_type > 25){ 4570 if(mb_type > 25){
4569 av_log(h->s.avctx, AV_LOG_ERROR, "mb_type %d in %c slice too large at %d %d\n", mb_type, av_get_pict_type_char(h->slice_type), s->mb_x, s->mb_y); 4571 av_log(h->s.avctx, AV_LOG_ERROR, "mb_type %d in %c slice too large at %d %d\n", mb_type, av_get_pict_type_char(h->slice_type), s->mb_x, s->mb_y);
4570 return -1; 4572 return -1;
4571 } 4573 }
5057 } 5059 }
5058 5060
5059 static int decode_cabac_mb_type( H264Context *h ) { 5061 static int decode_cabac_mb_type( H264Context *h ) {
5060 MpegEncContext * const s = &h->s; 5062 MpegEncContext * const s = &h->s;
5061 5063
5062 if( h->slice_type == FF_I_TYPE ) { 5064 if( h->slice_type_nos == FF_I_TYPE ) {
5063 return decode_cabac_intra_mb_type(h, 3, 1); 5065 return decode_cabac_intra_mb_type(h, 3, 1);
5064 } else if( h->slice_type == FF_P_TYPE ) { 5066 } else if( h->slice_type_nos == FF_P_TYPE ) {
5065 if( get_cabac_noinline( &h->cabac, &h->cabac_state[14] ) == 0 ) { 5067 if( get_cabac_noinline( &h->cabac, &h->cabac_state[14] ) == 0 ) {
5066 /* P-type */ 5068 /* P-type */
5067 if( get_cabac_noinline( &h->cabac, &h->cabac_state[15] ) == 0 ) { 5069 if( get_cabac_noinline( &h->cabac, &h->cabac_state[15] ) == 0 ) {
5068 /* P_L0_D16x16, P_8x8 */ 5070 /* P_L0_D16x16, P_8x8 */
5069 return 3 * get_cabac_noinline( &h->cabac, &h->cabac_state[16] ); 5071 return 3 * get_cabac_noinline( &h->cabac, &h->cabac_state[16] );
5688 mb_type= b_mb_type_info[mb_type].type; 5690 mb_type= b_mb_type_info[mb_type].type;
5689 }else{ 5691 }else{
5690 mb_type -= 23; 5692 mb_type -= 23;
5691 goto decode_intra_mb; 5693 goto decode_intra_mb;
5692 } 5694 }
5693 } else if( h->slice_type == FF_P_TYPE ) { 5695 } else if( h->slice_type_nos == FF_P_TYPE ) {
5694 if( mb_type < 5) { 5696 if( mb_type < 5) {
5695 partition_count= p_mb_type_info[mb_type].partition_count; 5697 partition_count= p_mb_type_info[mb_type].partition_count;
5696 mb_type= p_mb_type_info[mb_type].type; 5698 mb_type= p_mb_type_info[mb_type].type;
5697 } else { 5699 } else {
5698 mb_type -= 5; 5700 mb_type -= 5;
5699 goto decode_intra_mb; 5701 goto decode_intra_mb;
5700 } 5702 }
5701 } else { 5703 } else {
5702 assert(h->slice_type == FF_I_TYPE); 5704 if(h->slice_type == FF_SI_TYPE && mb_type)
5705 mb_type--;
5706 assert(h->slice_type_nos == FF_I_TYPE);
5703 decode_intra_mb: 5707 decode_intra_mb:
5704 partition_count = 0; 5708 partition_count = 0;
5705 cbp= i_mb_type_info[mb_type].cbp; 5709 cbp= i_mb_type_info[mb_type].cbp;
5706 h->intra16x16_pred_mode= i_mb_type_info[mb_type].pred_mode; 5710 h->intra16x16_pred_mode= i_mb_type_info[mb_type].pred_mode;
5707 mb_type= i_mb_type_info[mb_type].type; 5711 mb_type= i_mb_type_info[mb_type].type;
6818 s->gb.buffer + get_bits_count(&s->gb)/8, 6822 s->gb.buffer + get_bits_count(&s->gb)/8,
6819 ( s->gb.size_in_bits - get_bits_count(&s->gb) + 7)/8); 6823 ( s->gb.size_in_bits - get_bits_count(&s->gb) + 7)/8);
6820 /* calculate pre-state */ 6824 /* calculate pre-state */
6821 for( i= 0; i < 460; i++ ) { 6825 for( i= 0; i < 460; i++ ) {
6822 int pre; 6826 int pre;
6823 if( h->slice_type == FF_I_TYPE ) 6827 if( h->slice_type_nos == FF_I_TYPE )
6824 pre = av_clip( ((cabac_context_init_I[i][0] * s->qscale) >>4 ) + cabac_context_init_I[i][1], 1, 126 ); 6828 pre = av_clip( ((cabac_context_init_I[i][0] * s->qscale) >>4 ) + cabac_context_init_I[i][1], 1, 126 );
6825 else 6829 else
6826 pre = av_clip( ((cabac_context_init_PB[h->cabac_init_idc][i][0] * s->qscale) >>4 ) + cabac_context_init_PB[h->cabac_init_idc][i][1], 1, 126 ); 6830 pre = av_clip( ((cabac_context_init_PB[h->cabac_init_idc][i][0] * s->qscale) >>4 ) + cabac_context_init_PB[h->cabac_init_idc][i][1], 1, 126 );
6827 6831
6828 if( pre <= 63 ) 6832 if( pre <= 63 )
7585 7589
7586 s->current_picture_ptr->key_frame|= (hx->nal_unit_type == NAL_IDR_SLICE); 7590 s->current_picture_ptr->key_frame|= (hx->nal_unit_type == NAL_IDR_SLICE);
7587 if(hx->redundant_pic_count==0 && hx->s.hurry_up < 5 7591 if(hx->redundant_pic_count==0 && hx->s.hurry_up < 5
7588 && (avctx->skip_frame < AVDISCARD_NONREF || hx->nal_ref_idc) 7592 && (avctx->skip_frame < AVDISCARD_NONREF || hx->nal_ref_idc)
7589 && (avctx->skip_frame < AVDISCARD_BIDIR || hx->slice_type!=FF_B_TYPE) 7593 && (avctx->skip_frame < AVDISCARD_BIDIR || hx->slice_type!=FF_B_TYPE)
7590 && (avctx->skip_frame < AVDISCARD_NONKEY || hx->slice_type==FF_I_TYPE) 7594 && (avctx->skip_frame < AVDISCARD_NONKEY || hx->slice_type_nos==FF_I_TYPE)
7591 && avctx->skip_frame < AVDISCARD_ALL) 7595 && avctx->skip_frame < AVDISCARD_ALL)
7592 context_count++; 7596 context_count++;
7593 break; 7597 break;
7594 case NAL_DPA: 7598 case NAL_DPA:
7595 init_get_bits(&hx->s.gb, ptr, bit_length); 7599 init_get_bits(&hx->s.gb, ptr, bit_length);
7610 if(hx->redundant_pic_count==0 && hx->intra_gb_ptr && hx->s.data_partitioning 7614 if(hx->redundant_pic_count==0 && hx->intra_gb_ptr && hx->s.data_partitioning
7611 && s->context_initialized 7615 && s->context_initialized
7612 && s->hurry_up < 5 7616 && s->hurry_up < 5
7613 && (avctx->skip_frame < AVDISCARD_NONREF || hx->nal_ref_idc) 7617 && (avctx->skip_frame < AVDISCARD_NONREF || hx->nal_ref_idc)
7614 && (avctx->skip_frame < AVDISCARD_BIDIR || hx->slice_type!=FF_B_TYPE) 7618 && (avctx->skip_frame < AVDISCARD_BIDIR || hx->slice_type!=FF_B_TYPE)
7615 && (avctx->skip_frame < AVDISCARD_NONKEY || hx->slice_type==FF_I_TYPE) 7619 && (avctx->skip_frame < AVDISCARD_NONKEY || hx->slice_type_nos==FF_I_TYPE)
7616 && avctx->skip_frame < AVDISCARD_ALL) 7620 && avctx->skip_frame < AVDISCARD_ALL)
7617 context_count++; 7621 context_count++;
7618 break; 7622 break;
7619 case NAL_SEI: 7623 case NAL_SEI:
7620 init_get_bits(&s->gb, ptr, bit_length); 7624 init_get_bits(&s->gb, ptr, bit_length);