Mercurial > libavcodec.hg
comparison h264.c @ 8735:5d7ebbb7e91b libavcodec
Add fields to H264Context and SPS for upcoming VA API support.
Patch by Gwenole Beauchesne gbeauchesne A splitted-desktop dotcom
author | cehoyos |
---|---|
date | Tue, 03 Feb 2009 20:49:02 +0000 |
parents | 0d2190f5ae78 |
children | ecabe55b66bb |
comparison
equal
deleted
inserted
replaced
8734:bb969c77ad18 | 8735:5d7ebbb7e91b |
---|---|
2994 h->chroma_log2_weight_denom= get_ue_golomb(&s->gb); | 2994 h->chroma_log2_weight_denom= get_ue_golomb(&s->gb); |
2995 luma_def = 1<<h->luma_log2_weight_denom; | 2995 luma_def = 1<<h->luma_log2_weight_denom; |
2996 chroma_def = 1<<h->chroma_log2_weight_denom; | 2996 chroma_def = 1<<h->chroma_log2_weight_denom; |
2997 | 2997 |
2998 for(list=0; list<2; list++){ | 2998 for(list=0; list<2; list++){ |
2999 h->luma_weight_flag[list] = 0; | |
3000 h->chroma_weight_flag[list] = 0; | |
2999 for(i=0; i<h->ref_count[list]; i++){ | 3001 for(i=0; i<h->ref_count[list]; i++){ |
3000 int luma_weight_flag, chroma_weight_flag; | 3002 int luma_weight_flag, chroma_weight_flag; |
3001 | 3003 |
3002 luma_weight_flag= get_bits1(&s->gb); | 3004 luma_weight_flag= get_bits1(&s->gb); |
3003 if(luma_weight_flag){ | 3005 if(luma_weight_flag){ |
3004 h->luma_weight[list][i]= get_se_golomb(&s->gb); | 3006 h->luma_weight[list][i]= get_se_golomb(&s->gb); |
3005 h->luma_offset[list][i]= get_se_golomb(&s->gb); | 3007 h->luma_offset[list][i]= get_se_golomb(&s->gb); |
3006 if( h->luma_weight[list][i] != luma_def | 3008 if( h->luma_weight[list][i] != luma_def |
3007 || h->luma_offset[list][i] != 0) | 3009 || h->luma_offset[list][i] != 0) { |
3008 h->use_weight= 1; | 3010 h->use_weight= 1; |
3011 h->luma_weight_flag[list]= 1; | |
3012 } | |
3009 }else{ | 3013 }else{ |
3010 h->luma_weight[list][i]= luma_def; | 3014 h->luma_weight[list][i]= luma_def; |
3011 h->luma_offset[list][i]= 0; | 3015 h->luma_offset[list][i]= 0; |
3012 } | 3016 } |
3013 | 3017 |
3017 int j; | 3021 int j; |
3018 for(j=0; j<2; j++){ | 3022 for(j=0; j<2; j++){ |
3019 h->chroma_weight[list][i][j]= get_se_golomb(&s->gb); | 3023 h->chroma_weight[list][i][j]= get_se_golomb(&s->gb); |
3020 h->chroma_offset[list][i][j]= get_se_golomb(&s->gb); | 3024 h->chroma_offset[list][i][j]= get_se_golomb(&s->gb); |
3021 if( h->chroma_weight[list][i][j] != chroma_def | 3025 if( h->chroma_weight[list][i][j] != chroma_def |
3022 || h->chroma_offset[list][i][j] != 0) | 3026 || h->chroma_offset[list][i][j] != 0) { |
3023 h->use_weight_chroma= 1; | 3027 h->use_weight_chroma= 1; |
3028 h->chroma_weight_flag[list]= 1; | |
3029 } | |
3024 } | 3030 } |
3025 }else{ | 3031 }else{ |
3026 int j; | 3032 int j; |
3027 for(j=0; j<2; j++){ | 3033 for(j=0; j<2; j++){ |
3028 h->chroma_weight[list][i][j]= chroma_def; | 3034 h->chroma_weight[list][i][j]= chroma_def; |
3037 return 0; | 3043 return 0; |
3038 } | 3044 } |
3039 | 3045 |
3040 static void implicit_weight_table(H264Context *h){ | 3046 static void implicit_weight_table(H264Context *h){ |
3041 MpegEncContext * const s = &h->s; | 3047 MpegEncContext * const s = &h->s; |
3042 int ref0, ref1; | 3048 int ref0, ref1, i; |
3043 int cur_poc = s->current_picture_ptr->poc; | 3049 int cur_poc = s->current_picture_ptr->poc; |
3044 | 3050 |
3045 if( h->ref_count[0] == 1 && h->ref_count[1] == 1 | 3051 if( h->ref_count[0] == 1 && h->ref_count[1] == 1 |
3046 && h->ref_list[0][0].poc + h->ref_list[1][0].poc == 2*cur_poc){ | 3052 && h->ref_list[0][0].poc + h->ref_list[1][0].poc == 2*cur_poc){ |
3047 h->use_weight= 0; | 3053 h->use_weight= 0; |
3051 | 3057 |
3052 h->use_weight= 2; | 3058 h->use_weight= 2; |
3053 h->use_weight_chroma= 2; | 3059 h->use_weight_chroma= 2; |
3054 h->luma_log2_weight_denom= 5; | 3060 h->luma_log2_weight_denom= 5; |
3055 h->chroma_log2_weight_denom= 5; | 3061 h->chroma_log2_weight_denom= 5; |
3062 for (i = 0; i < 2; i++) { | |
3063 h->luma_weight_flag[i] = 0; | |
3064 h->chroma_weight_flag[i] = 0; | |
3065 } | |
3056 | 3066 |
3057 for(ref0=0; ref0 < h->ref_count[0]; ref0++){ | 3067 for(ref0=0; ref0 < h->ref_count[0]; ref0++){ |
3058 int poc0 = h->ref_list[0][ref0].poc; | 3068 int poc0 = h->ref_list[0][ref0].poc; |
3059 for(ref1=0; ref1 < h->ref_count[1]; ref1++){ | 3069 for(ref1=0; ref1 < h->ref_count[1]; ref1++){ |
3060 int poc1 = h->ref_list[1][ref1].poc; | 3070 int poc1 = h->ref_list[1][ref1].poc; |
3936 if( (h->pps.weighted_pred && h->slice_type_nos == FF_P_TYPE ) | 3946 if( (h->pps.weighted_pred && h->slice_type_nos == FF_P_TYPE ) |
3937 || (h->pps.weighted_bipred_idc==1 && h->slice_type_nos== FF_B_TYPE ) ) | 3947 || (h->pps.weighted_bipred_idc==1 && h->slice_type_nos== FF_B_TYPE ) ) |
3938 pred_weight_table(h); | 3948 pred_weight_table(h); |
3939 else if(h->pps.weighted_bipred_idc==2 && h->slice_type_nos== FF_B_TYPE) | 3949 else if(h->pps.weighted_bipred_idc==2 && h->slice_type_nos== FF_B_TYPE) |
3940 implicit_weight_table(h); | 3950 implicit_weight_table(h); |
3941 else | 3951 else { |
3942 h->use_weight = 0; | 3952 h->use_weight = 0; |
3953 for (i = 0; i < 2; i++) { | |
3954 h->luma_weight_flag[i] = 0; | |
3955 h->chroma_weight_flag[i] = 0; | |
3956 } | |
3957 } | |
3943 | 3958 |
3944 if(h->nal_ref_idc) | 3959 if(h->nal_ref_idc) |
3945 decode_ref_pic_marking(h0, &s->gb); | 3960 decode_ref_pic_marking(h0, &s->gb); |
3946 | 3961 |
3947 if(FRAME_MBAFF) | 3962 if(FRAME_MBAFF) |
7053 sps->scaling_matrix_present = 0; | 7068 sps->scaling_matrix_present = 0; |
7054 | 7069 |
7055 if(sps->profile_idc >= 100){ //high profile | 7070 if(sps->profile_idc >= 100){ //high profile |
7056 sps->chroma_format_idc= get_ue_golomb_31(&s->gb); | 7071 sps->chroma_format_idc= get_ue_golomb_31(&s->gb); |
7057 if(sps->chroma_format_idc == 3) | 7072 if(sps->chroma_format_idc == 3) |
7058 get_bits1(&s->gb); //residual_color_transform_flag | 7073 sps->residual_color_transform_flag = get_bits1(&s->gb); |
7059 get_ue_golomb(&s->gb); //bit_depth_luma_minus8 | 7074 sps->bit_depth_luma = get_ue_golomb(&s->gb) + 8; |
7060 get_ue_golomb(&s->gb); //bit_depth_chroma_minus8 | 7075 sps->bit_depth_chroma = get_ue_golomb(&s->gb) + 8; |
7061 sps->transform_bypass = get_bits1(&s->gb); | 7076 sps->transform_bypass = get_bits1(&s->gb); |
7062 decode_scaling_matrices(h, sps, NULL, 1, sps->scaling_matrix4, sps->scaling_matrix8); | 7077 decode_scaling_matrices(h, sps, NULL, 1, sps->scaling_matrix4, sps->scaling_matrix8); |
7063 }else{ | 7078 }else{ |
7064 sps->chroma_format_idc= 1; | 7079 sps->chroma_format_idc= 1; |
7065 } | 7080 } |