summaryrefslogtreecommitdiff
path: root/libavcodec/dxva2_h264.c
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2016-03-22 13:31:21 +0100
committerAnton Khirnov <anton@khirnov.net>2016-04-24 10:06:23 +0200
commit3176217c60ca7828712985092d9102d331ea4f3d (patch)
tree1124709788c4b1b3ec4da9cd8e204cc63039cc8f /libavcodec/dxva2_h264.c
parent44d16df413878588659dd8901bba016b5a869fd1 (diff)
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/dxva2_h264.c')
-rw-r--r--libavcodec/dxva2_h264.c80
1 files changed, 41 insertions, 39 deletions
diff --git a/libavcodec/dxva2_h264.c b/libavcodec/dxva2_h264.c
index 2d6fa79152..cd13486b7d 100644
--- a/libavcodec/dxva2_h264.c
+++ b/libavcodec/dxva2_h264.c
@@ -50,6 +50,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));
@@ -94,30 +96,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 Libav) */
(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)
@@ -133,28 +135,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 Libav */
//pp->SliceGroupMap[810]; /* XXX not implemented by Libav */
@@ -167,20 +169,20 @@ static void fill_scaling_lists(const AVCodecContext *avctx, AVDXVAContext *ctx,
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]];
}
}
}
@@ -280,11 +282,11 @@ static void fill_slice_long(AVCodecContext *avctx, DXVA_Slice_H264_Long *slice,
}
}
slice->slice_qs_delta = 0; /* XXX not implemented by Libav */
- 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