diff options
author | Clément Bœsch <u@pkh.me> | 2016-06-12 14:24:27 +0300 |
---|---|---|
committer | Clément Bœsch <u@pkh.me> | 2016-06-12 14:26:52 +0300 |
commit | 1534ef87c74cc66a117bf61c467641c2129bc964 (patch) | |
tree | 68e36bf8432b8a5bd1cd9cc6187d874e0978b1a4 /libavcodec/dxva2_h264.c | |
parent | 1a57b464cf1687d4571a075c99b6ac36a60f4480 (diff) | |
parent | 3176217c60ca7828712985092d9102d331ea4f3d (diff) |
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/dxva2_h264.c')
-rw-r--r-- | libavcodec/dxva2_h264.c | 81 |
1 files changed, 42 insertions, 39 deletions
diff --git a/libavcodec/dxva2_h264.c b/libavcodec/dxva2_h264.c index bcba875b7c..bd1fa1ee71 100644 --- a/libavcodec/dxva2_h264.c +++ b/libavcodec/dxva2_h264.c @@ -52,6 +52,8 @@ static void fill_picture_parameters(const AVCodecContext *avctx, AVDXVAContext * DXVA_PicParams_H264 *pp) { const H264Picture *current_picture = h->cur_pic_ptr; + const SPS *sps = h->ps.sps; + const PPS *pps = h->ps.pps; int i, j; memset(pp, 0, sizeof(*pp)); @@ -96,30 +98,30 @@ static void fill_picture_parameters(const AVCodecContext *avctx, AVDXVAContext * pp->wFrameWidthInMbsMinus1 = h->mb_width - 1; pp->wFrameHeightInMbsMinus1 = h->mb_height - 1; - pp->num_ref_frames = h->sps.ref_frame_count; + pp->num_ref_frames = sps->ref_frame_count; pp->wBitFields = ((h->picture_structure != PICT_FRAME) << 0) | - ((h->sps.mb_aff && + ((sps->mb_aff && (h->picture_structure == PICT_FRAME)) << 1) | - (h->sps.residual_color_transform_flag << 2) | + (sps->residual_color_transform_flag << 2) | /* sp_for_switch_flag (not implemented by FFmpeg) */ (0 << 3) | - (h->sps.chroma_format_idc << 4) | + (sps->chroma_format_idc << 4) | ((h->nal_ref_idc != 0) << 6) | - (h->pps.constrained_intra_pred << 7) | - (h->pps.weighted_pred << 8) | - (h->pps.weighted_bipred_idc << 9) | + (pps->constrained_intra_pred << 7) | + (pps->weighted_pred << 8) | + (pps->weighted_bipred_idc << 9) | /* MbsConsecutiveFlag */ (1 << 11) | - (h->sps.frame_mbs_only_flag << 12) | - (h->pps.transform_8x8_mode << 13) | - ((h->sps.level_idc >= 31) << 14) | + (sps->frame_mbs_only_flag << 12) | + (pps->transform_8x8_mode << 13) | + ((sps->level_idc >= 31) << 14) | /* IntraPicFlag (Modified if we detect a non * intra slice in dxva2_h264_decode_slice) */ (1 << 15); - pp->bit_depth_luma_minus8 = h->sps.bit_depth_luma - 8; - pp->bit_depth_chroma_minus8 = h->sps.bit_depth_chroma - 8; + pp->bit_depth_luma_minus8 = sps->bit_depth_luma - 8; + pp->bit_depth_chroma_minus8 = sps->bit_depth_chroma - 8; if (DXVA_CONTEXT_WORKAROUND(avctx, ctx) & FF_DXVA2_WORKAROUND_SCALING_LIST_ZIGZAG) pp->Reserved16Bits = 0; else if (DXVA_CONTEXT_WORKAROUND(avctx, ctx) & FF_DXVA2_WORKAROUND_INTEL_CLEARVIDEO) @@ -135,28 +137,28 @@ static void fill_picture_parameters(const AVCodecContext *avctx, AVDXVAContext * if ((h->picture_structure & PICT_BOTTOM_FIELD) && current_picture->field_poc[1] != INT_MAX) pp->CurrFieldOrderCnt[1] = current_picture->field_poc[1]; - pp->pic_init_qs_minus26 = h->pps.init_qs - 26; - pp->chroma_qp_index_offset = h->pps.chroma_qp_index_offset[0]; - pp->second_chroma_qp_index_offset = h->pps.chroma_qp_index_offset[1]; + pp->pic_init_qs_minus26 = pps->init_qs - 26; + pp->chroma_qp_index_offset = pps->chroma_qp_index_offset[0]; + pp->second_chroma_qp_index_offset = pps->chroma_qp_index_offset[1]; pp->ContinuationFlag = 1; - pp->pic_init_qp_minus26 = h->pps.init_qp - 26; - pp->num_ref_idx_l0_active_minus1 = h->pps.ref_count[0] - 1; - pp->num_ref_idx_l1_active_minus1 = h->pps.ref_count[1] - 1; + pp->pic_init_qp_minus26 = pps->init_qp - 26; + pp->num_ref_idx_l0_active_minus1 = pps->ref_count[0] - 1; + pp->num_ref_idx_l1_active_minus1 = pps->ref_count[1] - 1; pp->Reserved8BitsA = 0; pp->frame_num = h->frame_num; - pp->log2_max_frame_num_minus4 = h->sps.log2_max_frame_num - 4; - pp->pic_order_cnt_type = h->sps.poc_type; - if (h->sps.poc_type == 0) - pp->log2_max_pic_order_cnt_lsb_minus4 = h->sps.log2_max_poc_lsb - 4; - else if (h->sps.poc_type == 1) - pp->delta_pic_order_always_zero_flag = h->sps.delta_pic_order_always_zero_flag; - pp->direct_8x8_inference_flag = h->sps.direct_8x8_inference_flag; - pp->entropy_coding_mode_flag = h->pps.cabac; - pp->pic_order_present_flag = h->pps.pic_order_present; - pp->num_slice_groups_minus1 = h->pps.slice_group_count - 1; - pp->slice_group_map_type = h->pps.mb_slice_group_map_type; - pp->deblocking_filter_control_present_flag = h->pps.deblocking_filter_parameters_present; - pp->redundant_pic_cnt_present_flag= h->pps.redundant_pic_cnt_present; + pp->log2_max_frame_num_minus4 = sps->log2_max_frame_num - 4; + pp->pic_order_cnt_type = sps->poc_type; + if (sps->poc_type == 0) + pp->log2_max_pic_order_cnt_lsb_minus4 = sps->log2_max_poc_lsb - 4; + else if (sps->poc_type == 1) + pp->delta_pic_order_always_zero_flag = sps->delta_pic_order_always_zero_flag; + pp->direct_8x8_inference_flag = sps->direct_8x8_inference_flag; + pp->entropy_coding_mode_flag = pps->cabac; + pp->pic_order_present_flag = pps->pic_order_present; + pp->num_slice_groups_minus1 = pps->slice_group_count - 1; + pp->slice_group_map_type = pps->mb_slice_group_map_type; + pp->deblocking_filter_control_present_flag = pps->deblocking_filter_parameters_present; + pp->redundant_pic_cnt_present_flag= pps->redundant_pic_cnt_present; pp->Reserved8BitsB = 0; pp->slice_group_change_rate_minus1= 0; /* XXX not implemented by FFmpeg */ //pp->SliceGroupMap[810]; /* XXX not implemented by FFmpeg */ @@ -164,25 +166,26 @@ static void fill_picture_parameters(const AVCodecContext *avctx, AVDXVAContext * static void fill_scaling_lists(const AVCodecContext *avctx, AVDXVAContext *ctx, const H264Context *h, DXVA_Qmatrix_H264 *qm) { + const PPS *pps = h->ps.pps; unsigned i, j; memset(qm, 0, sizeof(*qm)); if (DXVA_CONTEXT_WORKAROUND(avctx, ctx) & FF_DXVA2_WORKAROUND_SCALING_LIST_ZIGZAG) { for (i = 0; i < 6; i++) for (j = 0; j < 16; j++) - qm->bScalingLists4x4[i][j] = h->pps.scaling_matrix4[i][j]; + qm->bScalingLists4x4[i][j] = pps->scaling_matrix4[i][j]; for (i = 0; i < 64; i++) { - qm->bScalingLists8x8[0][i] = h->pps.scaling_matrix8[0][i]; - qm->bScalingLists8x8[1][i] = h->pps.scaling_matrix8[3][i]; + qm->bScalingLists8x8[0][i] = pps->scaling_matrix8[0][i]; + qm->bScalingLists8x8[1][i] = pps->scaling_matrix8[3][i]; } } else { for (i = 0; i < 6; i++) for (j = 0; j < 16; j++) - qm->bScalingLists4x4[i][j] = h->pps.scaling_matrix4[i][ff_zigzag_scan[j]]; + qm->bScalingLists4x4[i][j] = pps->scaling_matrix4[i][ff_zigzag_scan[j]]; for (i = 0; i < 64; i++) { - qm->bScalingLists8x8[0][i] = h->pps.scaling_matrix8[0][ff_zigzag_direct[i]]; - qm->bScalingLists8x8[1][i] = h->pps.scaling_matrix8[3][ff_zigzag_direct[i]]; + qm->bScalingLists8x8[0][i] = pps->scaling_matrix8[0][ff_zigzag_direct[i]]; + qm->bScalingLists8x8[1][i] = pps->scaling_matrix8[3][ff_zigzag_direct[i]]; } } } @@ -282,11 +285,11 @@ static void fill_slice_long(AVCodecContext *avctx, DXVA_Slice_H264_Long *slice, } } slice->slice_qs_delta = 0; /* XXX not implemented by FFmpeg */ - slice->slice_qp_delta = sl->qscale - h->pps.init_qp; + slice->slice_qp_delta = sl->qscale - h->ps.pps->init_qp; slice->redundant_pic_cnt = sl->redundant_pic_count; if (sl->slice_type == AV_PICTURE_TYPE_B) slice->direct_spatial_mv_pred_flag = sl->direct_spatial_mv_pred; - slice->cabac_init_idc = h->pps.cabac ? sl->cabac_init_idc : 0; + slice->cabac_init_idc = h->ps.pps->cabac ? sl->cabac_init_idc : 0; if (sl->deblocking_filter < 2) slice->disable_deblocking_filter_idc = 1 - sl->deblocking_filter; else |