diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2008-07-26 02:27:14 +0000 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2008-07-26 02:27:14 +0000 |
commit | 0af6967ee747346bbb89b819b30dea11b498d1dd (patch) | |
tree | 2c4595739a6aac281f52256f6e632d927d99a01e /libavcodec | |
parent | 385c820b4a1bff625936ec66be9c151ea2f9718b (diff) | |
download | ffmpeg-0af6967ee747346bbb89b819b30dea11b498d1dd.tar.gz |
chroma_format_idc=0 aka grayscale support.
Can be disabled by removing #define ALLOW_NOCHROMA in case the extra if()
slow the code down measurably.
Fixes at least
FRExt/HPCAMOLQ_BRCM_B.264
FRExt/HPCVMOLQ_BRCM_B.264
Originally committed as revision 14407 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec')
-rw-r--r-- | libavcodec/h264.c | 29 | ||||
-rw-r--r-- | libavcodec/h264.h | 9 | ||||
-rw-r--r-- | libavcodec/h264data.h | 8 |
3 files changed, 41 insertions, 5 deletions
diff --git a/libavcodec/h264.c b/libavcodec/h264.c index c3def672ea..287b9afd10 100644 --- a/libavcodec/h264.c +++ b/libavcodec/h264.c @@ -3079,6 +3079,7 @@ static int pred_weight_table(H264Context *h){ h->luma_offset[list][i]= 0; } + if(CHROMA){ chroma_weight_flag= get_bits1(&s->gb); if(chroma_weight_flag){ int j; @@ -3096,6 +3097,7 @@ static int pred_weight_table(H264Context *h){ h->chroma_offset[list][i][j]= 0; } } + } } if(h->slice_type_nos != FF_B_TYPE) break; } @@ -4438,6 +4440,7 @@ decode_intra_mb: h->mb[index + (x&3) + 16*((x>>2)&1) + 64*(x>>3)]= get_bits(&s->gb, 8); } } + if(CHROMA){ for(y=0; y<8; y++){ const int index= 256 + 4*(y&3) + 32*(y>>2); for(x=0; x<8; x++){ @@ -4452,6 +4455,7 @@ decode_intra_mb: h->mb[index + (x&3) + 16*(x>>2)]= get_bits(&s->gb, 8); } } + } // In deblocking, the quantizer is 0 s->current_picture.qscale_table[mb_xy]= 0; @@ -4503,11 +4507,12 @@ decode_intra_mb: if(h->intra16x16_pred_mode < 0) return -1; } - + if(CHROMA){ pred_mode= check_intra_pred_mode(h, get_ue_golomb(&s->gb)); if(pred_mode < 0) return -1; h->chroma_pred_mode= pred_mode; + } }else if(partition_count==4){ int i, j, sub_partition_count[4], list, ref[2][4]; @@ -4713,10 +4718,15 @@ decode_intra_mb: return -1; } + if(CHROMA){ if(IS_INTRA4x4(mb_type)) cbp= golomb_to_intra4x4_cbp[cbp]; else cbp= golomb_to_inter_cbp[cbp]; + }else{ + if(IS_INTRA4x4(mb_type)) cbp= golomb_to_intra4x4_cbp_gray[cbp]; + else cbp= golomb_to_inter_cbp_gray[cbp]; + } } h->cbp = cbp; @@ -5578,6 +5588,7 @@ decode_intra_mb: h->mb[index + (x&3) + 16*((x>>2)&1) + 64*(x>>3)]= *ptr++; } } + if(CHROMA){ for(y=0; y<8; y++){ const int index= 256 + 4*(y&3) + 32*(y>>2); for(x=0; x<8; x++){ @@ -5592,6 +5603,7 @@ decode_intra_mb: h->mb[index + (x&3) + 16*(x>>2)]= *ptr++; } } + } ff_init_cabac_decoder(&h->cabac, ptr, h->cabac.bytestream_end - ptr); @@ -5638,12 +5650,14 @@ decode_intra_mb: h->intra16x16_pred_mode= check_intra_pred_mode( h, h->intra16x16_pred_mode ); if( h->intra16x16_pred_mode < 0 ) return -1; } + if(CHROMA){ h->chroma_pred_mode_table[mb_xy] = pred_mode = decode_cabac_mb_chroma_pre_mode( h ); pred_mode= check_intra_pred_mode( h, pred_mode ); if( pred_mode < 0 ) return -1; h->chroma_pred_mode= pred_mode; + } } else if( partition_count == 4 ) { int i, j, sub_partition_count[4], list, ref[2][4]; @@ -5845,6 +5859,7 @@ decode_intra_mb: if( !IS_INTRA16x16( mb_type ) ) { cbp = decode_cabac_mb_cbp_luma( h ); + if(CHROMA) cbp |= decode_cabac_mb_cbp_chroma( h ) << 4; } @@ -7130,14 +7145,17 @@ static inline int decode_seq_parameter_set(H264Context *h){ sps->level_idc= level_idc; if(sps->profile_idc >= 100){ //high profile - if(get_ue_golomb(&s->gb) == 3) //chroma_format_idc + sps->chroma_format_idc= get_ue_golomb(&s->gb); + if(sps->chroma_format_idc == 3) get_bits1(&s->gb); //residual_color_transform_flag get_ue_golomb(&s->gb); //bit_depth_luma_minus8 get_ue_golomb(&s->gb); //bit_depth_chroma_minus8 sps->transform_bypass = get_bits1(&s->gb); decode_scaling_matrices(h, sps, NULL, 1, sps->scaling_matrix4, sps->scaling_matrix8); - }else + }else{ sps->scaling_matrix_present = 0; + sps->chroma_format_idc= 1; + } sps->log2_max_frame_num= get_ue_golomb(&s->gb) + 4; sps->poc_type= get_ue_golomb(&s->gb); @@ -7219,7 +7237,7 @@ static inline int decode_seq_parameter_set(H264Context *h){ decode_vui_parameters(h, sps); if(s->avctx->debug&FF_DEBUG_PICT_INFO){ - av_log(h->s.avctx, AV_LOG_DEBUG, "sps:%u profile:%d/%d poc:%d ref:%d %dx%d %s %s crop:%d/%d/%d/%d %s\n", + av_log(h->s.avctx, AV_LOG_DEBUG, "sps:%u profile:%d/%d poc:%d ref:%d %dx%d %s %s crop:%d/%d/%d/%d %s %s\n", sps_id, sps->profile_idc, sps->level_idc, sps->poc_type, sps->ref_frame_count, @@ -7228,7 +7246,8 @@ static inline int decode_seq_parameter_set(H264Context *h){ sps->direct_8x8_inference_flag ? "8B8" : "", sps->crop_left, sps->crop_right, sps->crop_top, sps->crop_bottom, - sps->vui_parameters_present_flag ? "VUI" : "" + sps->vui_parameters_present_flag ? "VUI" : "", + ((const char*[]){"Gray","420","422","444"})[sps->chroma_format_idc] ); } return 0; diff --git a/libavcodec/h264.h b/libavcodec/h264.h index 889c94c6bc..93e7856f62 100644 --- a/libavcodec/h264.h +++ b/libavcodec/h264.h @@ -57,6 +57,8 @@ * of progressive decoding by about 2%. */ #define ALLOW_INTERLACE +#define ALLOW_NOCHROMA + #ifdef ALLOW_INTERLACE #define MB_MBAFF h->mb_mbaff #define MB_FIELD h->mb_field_decoding_flag @@ -72,6 +74,12 @@ #endif #define FIELD_OR_MBAFF_PICTURE (FRAME_MBAFF || FIELD_PICTURE) +#ifdef ALLOW_NOCHROMA +#define CHROMA h->sps.chroma_format_idc +#else +#define CHROMA 1 +#endif + #ifndef ENABLE_H264_ENCODER #define ENABLE_H264_ENCODER 0 #endif @@ -83,6 +91,7 @@ typedef struct SPS{ int profile_idc; int level_idc; + int chroma_format_idc; int transform_bypass; ///< qpprime_y_zero_transform_bypass_flag int log2_max_frame_num; ///< log2_max_frame_num_minus4 + 4 int poc_type; ///< pic_order_cnt_type diff --git a/libavcodec/h264data.h b/libavcodec/h264data.h index 237e3f8709..32cbcbf051 100644 --- a/libavcodec/h264data.h +++ b/libavcodec/h264data.h @@ -112,6 +112,14 @@ static const uint8_t inter_cbp_to_golomb[48]={ 6, 24, 25, 20, 26, 21, 46, 28, 27, 47, 22, 29, 23, 30, 31, 12 }; +static const uint8_t golomb_to_inter_cbp_gray[16]={ + 0, 1, 2, 4, 8, 3, 5,10,12,15, 7,11,13,14, 6, 9, +}; + +static const uint8_t golomb_to_intra4x4_cbp_gray[16]={ +15, 0, 7,11,13,14, 3, 5,10,12, 1, 2, 4, 8, 6, 9, +}; + static const uint8_t chroma_dc_coeff_token_len[4*5]={ 2, 0, 0, 0, 6, 1, 0, 0, |