diff options
author | Anton Khirnov <anton@khirnov.net> | 2016-03-22 13:31:21 +0100 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2016-04-24 10:06:23 +0200 |
commit | 3176217c60ca7828712985092d9102d331ea4f3d (patch) | |
tree | 1124709788c4b1b3ec4da9cd8e204cc63039cc8f /libavcodec/vaapi_h264.c | |
parent | 44d16df413878588659dd8901bba016b5a869fd1 (diff) | |
download | ffmpeg-3176217c60ca7828712985092d9102d331ea4f3d.tar.gz |
h264: decouple h264_ps from the h264 decoder
Make the SPS/PPS parsing independent of the H264Context, to allow
decoupling the parser from the decoder. The change is modelled after the
one done earlier for HEVC.
Move the dequant buffers to the PPS to avoid complex checks whether they
changed and an expensive copy for frame threads.
Diffstat (limited to 'libavcodec/vaapi_h264.c')
-rw-r--r-- | libavcodec/vaapi_h264.c | 66 |
1 files changed, 34 insertions, 32 deletions
diff --git a/libavcodec/vaapi_h264.c b/libavcodec/vaapi_h264.c index 2e2626edc5..9c17ac1374 100644 --- a/libavcodec/vaapi_h264.c +++ b/libavcodec/vaapi_h264.c @@ -227,6 +227,8 @@ static int vaapi_h264_start_frame(AVCodecContext *avctx, { H264Context * const h = avctx->priv_data; struct vaapi_context * const vactx = avctx->hwaccel_context; + const PPS *pps = h->ps.pps; + const SPS *sps = h->ps.sps; VAPictureParameterBufferH264 *pic_param; VAIQMatrixBufferH264 *iq_matrix; @@ -243,38 +245,38 @@ static int vaapi_h264_start_frame(AVCodecContext *avctx, return -1; pic_param->picture_width_in_mbs_minus1 = h->mb_width - 1; pic_param->picture_height_in_mbs_minus1 = h->mb_height - 1; - pic_param->bit_depth_luma_minus8 = h->sps.bit_depth_luma - 8; - pic_param->bit_depth_chroma_minus8 = h->sps.bit_depth_chroma - 8; - pic_param->num_ref_frames = h->sps.ref_frame_count; + pic_param->bit_depth_luma_minus8 = sps->bit_depth_luma - 8; + pic_param->bit_depth_chroma_minus8 = sps->bit_depth_chroma - 8; + pic_param->num_ref_frames = sps->ref_frame_count; pic_param->seq_fields.value = 0; /* reset all bits */ - pic_param->seq_fields.bits.chroma_format_idc = h->sps.chroma_format_idc; - pic_param->seq_fields.bits.residual_colour_transform_flag = h->sps.residual_color_transform_flag; /* XXX: only for 4:4:4 high profile? */ - pic_param->seq_fields.bits.gaps_in_frame_num_value_allowed_flag = h->sps.gaps_in_frame_num_allowed_flag; - pic_param->seq_fields.bits.frame_mbs_only_flag = h->sps.frame_mbs_only_flag; - pic_param->seq_fields.bits.mb_adaptive_frame_field_flag = h->sps.mb_aff; - pic_param->seq_fields.bits.direct_8x8_inference_flag = h->sps.direct_8x8_inference_flag; - pic_param->seq_fields.bits.MinLumaBiPredSize8x8 = h->sps.level_idc >= 31; /* A.3.3.2 */ - pic_param->seq_fields.bits.log2_max_frame_num_minus4 = h->sps.log2_max_frame_num - 4; - pic_param->seq_fields.bits.pic_order_cnt_type = h->sps.poc_type; - pic_param->seq_fields.bits.log2_max_pic_order_cnt_lsb_minus4 = h->sps.log2_max_poc_lsb - 4; - pic_param->seq_fields.bits.delta_pic_order_always_zero_flag = h->sps.delta_pic_order_always_zero_flag; - pic_param->num_slice_groups_minus1 = h->pps.slice_group_count - 1; - pic_param->slice_group_map_type = h->pps.mb_slice_group_map_type; + pic_param->seq_fields.bits.chroma_format_idc = sps->chroma_format_idc; + pic_param->seq_fields.bits.residual_colour_transform_flag = sps->residual_color_transform_flag; /* XXX: only for 4:4:4 high profile? */ + pic_param->seq_fields.bits.gaps_in_frame_num_value_allowed_flag = sps->gaps_in_frame_num_allowed_flag; + pic_param->seq_fields.bits.frame_mbs_only_flag = sps->frame_mbs_only_flag; + pic_param->seq_fields.bits.mb_adaptive_frame_field_flag = sps->mb_aff; + pic_param->seq_fields.bits.direct_8x8_inference_flag = sps->direct_8x8_inference_flag; + pic_param->seq_fields.bits.MinLumaBiPredSize8x8 = sps->level_idc >= 31; /* A.3.3.2 */ + pic_param->seq_fields.bits.log2_max_frame_num_minus4 = sps->log2_max_frame_num - 4; + pic_param->seq_fields.bits.pic_order_cnt_type = sps->poc_type; + pic_param->seq_fields.bits.log2_max_pic_order_cnt_lsb_minus4 = sps->log2_max_poc_lsb - 4; + pic_param->seq_fields.bits.delta_pic_order_always_zero_flag = sps->delta_pic_order_always_zero_flag; + pic_param->num_slice_groups_minus1 = pps->slice_group_count - 1; + pic_param->slice_group_map_type = pps->mb_slice_group_map_type; pic_param->slice_group_change_rate_minus1 = 0; /* XXX: unimplemented in Libav */ - pic_param->pic_init_qp_minus26 = h->pps.init_qp - 26; - pic_param->pic_init_qs_minus26 = h->pps.init_qs - 26; - pic_param->chroma_qp_index_offset = h->pps.chroma_qp_index_offset[0]; - pic_param->second_chroma_qp_index_offset = h->pps.chroma_qp_index_offset[1]; + pic_param->pic_init_qp_minus26 = pps->init_qp - 26; + pic_param->pic_init_qs_minus26 = pps->init_qs - 26; + pic_param->chroma_qp_index_offset = pps->chroma_qp_index_offset[0]; + pic_param->second_chroma_qp_index_offset = pps->chroma_qp_index_offset[1]; pic_param->pic_fields.value = 0; /* reset all bits */ - pic_param->pic_fields.bits.entropy_coding_mode_flag = h->pps.cabac; - pic_param->pic_fields.bits.weighted_pred_flag = h->pps.weighted_pred; - pic_param->pic_fields.bits.weighted_bipred_idc = h->pps.weighted_bipred_idc; - pic_param->pic_fields.bits.transform_8x8_mode_flag = h->pps.transform_8x8_mode; + pic_param->pic_fields.bits.entropy_coding_mode_flag = pps->cabac; + pic_param->pic_fields.bits.weighted_pred_flag = pps->weighted_pred; + pic_param->pic_fields.bits.weighted_bipred_idc = pps->weighted_bipred_idc; + pic_param->pic_fields.bits.transform_8x8_mode_flag = pps->transform_8x8_mode; pic_param->pic_fields.bits.field_pic_flag = h->picture_structure != PICT_FRAME; - pic_param->pic_fields.bits.constrained_intra_pred_flag = h->pps.constrained_intra_pred; - pic_param->pic_fields.bits.pic_order_present_flag = h->pps.pic_order_present; - pic_param->pic_fields.bits.deblocking_filter_control_present_flag = h->pps.deblocking_filter_parameters_present; - pic_param->pic_fields.bits.redundant_pic_cnt_present_flag = h->pps.redundant_pic_cnt_present; + pic_param->pic_fields.bits.constrained_intra_pred_flag = pps->constrained_intra_pred; + pic_param->pic_fields.bits.pic_order_present_flag = pps->pic_order_present; + pic_param->pic_fields.bits.deblocking_filter_control_present_flag = pps->deblocking_filter_parameters_present; + pic_param->pic_fields.bits.redundant_pic_cnt_present_flag = pps->redundant_pic_cnt_present; pic_param->pic_fields.bits.reference_pic_flag = h->nal_ref_idc != 0; pic_param->frame_num = h->frame_num; @@ -282,9 +284,9 @@ static int vaapi_h264_start_frame(AVCodecContext *avctx, iq_matrix = ff_vaapi_alloc_iq_matrix(vactx, sizeof(VAIQMatrixBufferH264)); if (!iq_matrix) return -1; - memcpy(iq_matrix->ScalingList4x4, h->pps.scaling_matrix4, sizeof(iq_matrix->ScalingList4x4)); - memcpy(iq_matrix->ScalingList8x8[0], h->pps.scaling_matrix8[0], sizeof(iq_matrix->ScalingList8x8[0])); - memcpy(iq_matrix->ScalingList8x8[1], h->pps.scaling_matrix8[3], sizeof(iq_matrix->ScalingList8x8[0])); + memcpy(iq_matrix->ScalingList4x4, pps->scaling_matrix4, sizeof(iq_matrix->ScalingList4x4)); + memcpy(iq_matrix->ScalingList8x8[0], pps->scaling_matrix8[0], sizeof(iq_matrix->ScalingList8x8[0])); + memcpy(iq_matrix->ScalingList8x8[1], pps->scaling_matrix8[3], sizeof(iq_matrix->ScalingList8x8[0])); return 0; } @@ -335,7 +337,7 @@ static int vaapi_h264_decode_slice(AVCodecContext *avctx, slice_param->num_ref_idx_l0_active_minus1 = sl->list_count > 0 ? sl->ref_count[0] - 1 : 0; slice_param->num_ref_idx_l1_active_minus1 = sl->list_count > 1 ? sl->ref_count[1] - 1 : 0; slice_param->cabac_init_idc = sl->cabac_init_idc; - slice_param->slice_qp_delta = sl->qscale - h->pps.init_qp; + slice_param->slice_qp_delta = sl->qscale - h->ps.pps->init_qp; slice_param->disable_deblocking_filter_idc = sl->deblocking_filter < 2 ? !sl->deblocking_filter : sl->deblocking_filter; slice_param->slice_alpha_c0_offset_div2 = sl->slice_alpha_c0_offset / 2; slice_param->slice_beta_offset_div2 = sl->slice_beta_offset / 2; |