diff options
author | Clément Bœsch <u@pkh.me> | 2016-06-12 13:24:27 +0200 |
---|---|---|
committer | Clément Bœsch <u@pkh.me> | 2016-06-12 13:26:52 +0200 |
commit | 1534ef87c74cc66a117bf61c467641c2129bc964 (patch) | |
tree | 68e36bf8432b8a5bd1cd9cc6187d874e0978b1a4 /libavcodec/vaapi_h264.c | |
parent | 1a57b464cf1687d4571a075c99b6ac36a60f4480 (diff) | |
parent | 3176217c60ca7828712985092d9102d331ea4f3d (diff) | |
download | ffmpeg-1534ef87c74cc66a117bf61c467641c2129bc964.tar.gz |
Merge commit '3176217c60ca7828712985092d9102d331ea4f3d'
* commit '3176217c60ca7828712985092d9102d331ea4f3d':
h264: decouple h264_ps from the h264 decoder
Main changes:
- a local GetBitContext is created for the various
ff_h264_decode_seq_parameter_set() attempts
- just like the old code, remove_sps() is adjusted so it doesn't remove
the pps.
Fixes decode with Ticket #631
http://ffmpeg.org/pipermail/ffmpeg-user/attachments/20111108/dae58f17/attachment.mp4
but see next point as well.
- ff_h264_update_thread_context() is updated to work even when SPS
isn't set as it breaks current skip_frame code. This makes sure we
can still decode the sample from ticket #631 without the need for
-flags2 +chunks. (Thanks to Michael)
- keep {sps,pps}_ref pointers that stay alive even when the active
pps/sps get removed from the available lists (patch by michaelni with
additionnal frees in ff_h264_free_context() from mateo)
- added a check on sps in avpriv_h264_has_num_reorder_frames() to fix
crashes with mpegts_with_dvbsubs.ts from Ticket #4074
http://samples.ffmpeg.org/ffmpeg-bugs/trac/ticket4074/mpegts_with_dvbsubs.ts
- in h264_parser.c:h264_parse(), after the ff_h264_decode_extradata() is
called, the pps and sps from the local parser context are updated with
the pps and sps from the used h264context. This fixes fate-flv-demux.
- in h264_slice.c, "PPS changed between slices" error is not triggered
anymore in one condition as it makes fate-h264-xavc-4389 fails with
THREADS=N (Thanks to Michael)
Merged-by: Clément Bœsch <clement@stupeflix.com>
Merged-by: Michael Niedermayer <michael@niedermayer.cc>
Merged-by: Matthieu Bouron <matthieu.bouron@stupeflix.com>
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 7470a1603c..9b13fa9877 100644 --- a/libavcodec/vaapi_h264.c +++ b/libavcodec/vaapi_h264.c @@ -228,6 +228,8 @@ static int vaapi_h264_start_frame(AVCodecContext *avctx, { H264Context * const h = avctx->priv_data; FFVAContext * const vactx = ff_vaapi_get_context(avctx); + const PPS *pps = h->ps.pps; + const SPS *sps = h->ps.sps; VAPictureParameterBufferH264 *pic_param; VAIQMatrixBufferH264 *iq_matrix; @@ -244,38 +246,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 FFmpeg */ - 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; @@ -283,9 +285,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; } @@ -337,7 +339,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; |