d3d12: Clean up H264 video decode interlaced code path

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27213>
This commit is contained in:
Sil Vilerino
2024-01-23 08:26:43 -05:00
committed by Marge Bot
parent d9477f994a
commit 04ebb79b9e
10 changed files with 17 additions and 24 deletions

View File

@@ -345,7 +345,7 @@ d3d12_video_decoder_decode_bitstream(struct pipe_video_codec *codec,
if (pD3D12Dec->m_d3d12DecProfileType == d3d12_video_decode_profile_type_h264) {
struct pipe_h264_picture_desc *h264 = (pipe_h264_picture_desc*) picture;
target->interlaced = !h264->pps->sps->frame_mbs_only_flag && (h264->field_pic_flag || /* PAFF */ h264->pps->sps->mb_adaptive_frame_field_flag); /* MBAFF */
target->interlaced = !h264->pps->sps->frame_mbs_only_flag;
}
}
@@ -1128,15 +1128,13 @@ d3d12_video_decoder_reconfigure_dpb(struct d3d12_video_decoder *pD3D12Dec,
uint32_t width;
uint32_t height;
uint16_t maxDPB;
bool isInterlaced;
d3d12_video_decoder_get_frame_info(pD3D12Dec, &width, &height, &maxDPB, isInterlaced);
d3d12_video_decoder_get_frame_info(pD3D12Dec, &width, &height, &maxDPB);
ID3D12Resource *pPipeD3D12DstResource = d3d12_resource_resource(pD3D12VideoBuffer->texture);
D3D12_RESOURCE_DESC outputResourceDesc = GetDesc(pPipeD3D12DstResource);
assert(pD3D12VideoBuffer->base.interlaced == isInterlaced);
D3D12_VIDEO_FRAME_CODED_INTERLACE_TYPE interlaceTypeRequested =
isInterlaced ? D3D12_VIDEO_FRAME_CODED_INTERLACE_TYPE_FIELD_BASED : D3D12_VIDEO_FRAME_CODED_INTERLACE_TYPE_NONE;
pD3D12VideoBuffer->base.interlaced ? D3D12_VIDEO_FRAME_CODED_INTERLACE_TYPE_FIELD_BASED : D3D12_VIDEO_FRAME_CODED_INTERLACE_TYPE_NONE;
if ((pD3D12Dec->m_decodeFormat != outputResourceDesc.Format) ||
(pD3D12Dec->m_decoderDesc.Configuration.InterlaceType != interlaceTypeRequested)) {
// Copy current pD3D12Dec->m_decoderDesc, modify decodeprofile and re-create decoder.
@@ -1254,37 +1252,36 @@ d3d12_video_decoder_refresh_dpb_active_references(struct d3d12_video_decoder *pD
void
d3d12_video_decoder_get_frame_info(
struct d3d12_video_decoder *pD3D12Dec, uint32_t *pWidth, uint32_t *pHeight, uint16_t *pMaxDPB, bool &isInterlaced)
struct d3d12_video_decoder *pD3D12Dec, uint32_t *pWidth, uint32_t *pHeight, uint16_t *pMaxDPB)
{
*pWidth = 0;
*pHeight = 0;
*pMaxDPB = 0;
isInterlaced = false;
#if D3D12_VIDEO_ANY_DECODER_ENABLED
switch (pD3D12Dec->m_d3d12DecProfileType) {
#if VIDEO_CODEC_H264DEC
case d3d12_video_decode_profile_type_h264:
{
d3d12_video_decoder_get_frame_info_h264(pD3D12Dec, pWidth, pHeight, pMaxDPB, isInterlaced);
d3d12_video_decoder_get_frame_info_h264(pD3D12Dec, pWidth, pHeight, pMaxDPB);
} break;
#endif
#if VIDEO_CODEC_H265DEC
case d3d12_video_decode_profile_type_hevc:
{
d3d12_video_decoder_get_frame_info_hevc(pD3D12Dec, pWidth, pHeight, pMaxDPB, isInterlaced);
d3d12_video_decoder_get_frame_info_hevc(pD3D12Dec, pWidth, pHeight, pMaxDPB);
} break;
#endif
#if VIDEO_CODEC_AV1DEC
case d3d12_video_decode_profile_type_av1:
{
d3d12_video_decoder_get_frame_info_av1(pD3D12Dec, pWidth, pHeight, pMaxDPB, isInterlaced);
d3d12_video_decoder_get_frame_info_av1(pD3D12Dec, pWidth, pHeight, pMaxDPB);
} break;
#endif
#if VIDEO_CODEC_VP9DEC
case d3d12_video_decode_profile_type_vp9:
{
d3d12_video_decoder_get_frame_info_vp9(pD3D12Dec, pWidth, pHeight, pMaxDPB, &isInterlaced);
d3d12_video_decoder_get_frame_info_vp9(pD3D12Dec, pWidth, pHeight, pMaxDPB);
} break;
#endif
default:

View File

@@ -240,7 +240,7 @@ d3d12_video_decoder_reconfigure_dpb(struct d3d12_video_decoder *
const d3d12_video_decode_output_conversion_arguments &conversionArguments);
void
d3d12_video_decoder_get_frame_info(
struct d3d12_video_decoder *pD3D12Dec, uint32_t *pWidth, uint32_t *pHeight, uint16_t *pMaxDPB, bool &isInterlaced);
struct d3d12_video_decoder *pD3D12Dec, uint32_t *pWidth, uint32_t *pHeight, uint16_t *pMaxDPB);
void
d3d12_video_decoder_store_converted_dxva_picparams_from_pipe_input(struct d3d12_video_decoder *codec,
struct pipe_picture_desc * picture,

View File

@@ -57,7 +57,7 @@ d3d12_video_decoder_refresh_dpb_active_references_av1(struct d3d12_video_decoder
void
d3d12_video_decoder_get_frame_info_av1(
struct d3d12_video_decoder *pD3D12Dec, uint32_t *pWidth, uint32_t *pHeight, uint16_t *pMaxDPB, bool &isInterlaced)
struct d3d12_video_decoder *pD3D12Dec, uint32_t *pWidth, uint32_t *pHeight, uint16_t *pMaxDPB)
{
auto pPicParams = d3d12_video_decoder_get_current_dxva_picparams<DXVA_PicParams_AV1>(pD3D12Dec);
/* width, height
@@ -75,7 +75,6 @@ d3d12_video_decoder_get_frame_info_av1(
Each frame may pick up to 7 reference frames (frame_refs[]) from the pool to use for inter prediction of the current frame.
*/
*pMaxDPB = 8 + 1 /*current picture*/;
isInterlaced = false;
}
void

View File

@@ -334,7 +334,7 @@ d3d12_video_decoder_refresh_dpb_active_references_av1(struct d3d12_video_decoder
void
d3d12_video_decoder_get_frame_info_av1(
struct d3d12_video_decoder *pD3D12Dec, uint32_t *pWidth, uint32_t *pHeight, uint16_t *pMaxDPB, bool &isInterlaced);
struct d3d12_video_decoder *pD3D12Dec, uint32_t *pWidth, uint32_t *pHeight, uint16_t *pMaxDPB);
DXVA_PicParams_AV1
d3d12_video_decoder_dxva_picparams_from_pipe_picparams_av1(

View File

@@ -72,7 +72,7 @@ d3d12_video_decoder_refresh_dpb_active_references_h264(struct d3d12_video_decode
void
d3d12_video_decoder_get_frame_info_h264(
struct d3d12_video_decoder *pD3D12Dec, uint32_t *pWidth, uint32_t *pHeight, uint16_t *pMaxDPB, bool &isInterlaced)
struct d3d12_video_decoder *pD3D12Dec, uint32_t *pWidth, uint32_t *pHeight, uint16_t *pMaxDPB)
{
auto pPicParams = d3d12_video_decoder_get_current_dxva_picparams<DXVA_PicParams_H264>(pD3D12Dec);
// wFrameWidthInMbsMinus1 Width of the frame containing this picture, in units of macroblocks, minus 1. (The width in
@@ -85,7 +85,6 @@ d3d12_video_decoder_get_frame_info_h264(
*pHeight = (2 - pPicParams->frame_mbs_only_flag) * *pHeight;
*pHeight = *pHeight * 16;
*pMaxDPB = pPicParams->num_ref_frames + 1;
isInterlaced = !pPicParams->frame_mbs_only_flag;
}
///

View File

@@ -203,7 +203,7 @@ d3d12_video_decoder_dxva_picparams_from_pipe_picparams_h264(uint32_t
pipe_h264_picture_desc *pipeDesc);
void
d3d12_video_decoder_get_frame_info_h264(
struct d3d12_video_decoder *pD3D12Dec, uint32_t *pWidth, uint32_t *pHeight, uint16_t *pMaxDPB, bool &isInterlaced);
struct d3d12_video_decoder *pD3D12Dec, uint32_t *pWidth, uint32_t *pHeight, uint16_t *pMaxDPB);
void
d3d12_video_decoder_prepare_current_frame_references_h264(struct d3d12_video_decoder *pD3D12Dec,
ID3D12Resource * pTexture2D,

View File

@@ -75,14 +75,13 @@ LengthFromMinCb(int length, int cbsize)
void
d3d12_video_decoder_get_frame_info_hevc(
struct d3d12_video_decoder *pD3D12Dec, uint32_t *pWidth, uint32_t *pHeight, uint16_t *pMaxDPB, bool &isInterlaced)
struct d3d12_video_decoder *pD3D12Dec, uint32_t *pWidth, uint32_t *pHeight, uint16_t *pMaxDPB)
{
auto pPicParams = d3d12_video_decoder_get_current_dxva_picparams<DXVA_PicParams_HEVC>(pD3D12Dec);
UINT log2_min_luma_coding_block_size = pPicParams->log2_min_luma_coding_block_size_minus3 + 3;
*pWidth = LengthFromMinCb(pPicParams->PicWidthInMinCbsY, log2_min_luma_coding_block_size);
*pHeight = LengthFromMinCb(pPicParams->PicHeightInMinCbsY, log2_min_luma_coding_block_size);
*pMaxDPB = pPicParams->sps_max_dec_pic_buffering_minus1 + 1;
isInterlaced = false;
}
///

View File

@@ -216,7 +216,7 @@ d3d12_video_decoder_dxva_picparams_from_pipe_picparams_hevc(struct d3d12_video_d
pipe_h265_picture_desc * pipeDesc);
void
d3d12_video_decoder_get_frame_info_hevc(
struct d3d12_video_decoder *pD3D12Dec, uint32_t *pWidth, uint32_t *pHeight, uint16_t *pMaxDPB, bool &isInterlaced);
struct d3d12_video_decoder *pD3D12Dec, uint32_t *pWidth, uint32_t *pHeight, uint16_t *pMaxDPB);
void
d3d12_video_decoder_prepare_current_frame_references_hevc(struct d3d12_video_decoder *pD3D12Dec,
ID3D12Resource * pTexture2D,

View File

@@ -62,7 +62,7 @@ d3d12_video_decoder_refresh_dpb_active_references_vp9(struct d3d12_video_decoder
void
d3d12_video_decoder_get_frame_info_vp9(
struct d3d12_video_decoder *pD3D12Dec, uint32_t *pWidth, uint32_t *pHeight, uint16_t *pMaxDPB, bool *pIsInterlaced)
struct d3d12_video_decoder *pD3D12Dec, uint32_t *pWidth, uint32_t *pHeight, uint16_t *pMaxDPB)
{
auto pPicParams = d3d12_video_decoder_get_current_dxva_picparams<DXVA_PicParams_VP9>(pD3D12Dec);
*pWidth = pPicParams->width;
@@ -74,7 +74,6 @@ d3d12_video_decoder_get_frame_info_vp9(
Golden, and AltRef) of the current frame.
*/
*pMaxDPB = 8 + 1 /*current picture*/;
*pIsInterlaced = false;
}
void

View File

@@ -140,7 +140,7 @@ d3d12_video_decoder_refresh_dpb_active_references_vp9(struct d3d12_video_decoder
void
d3d12_video_decoder_get_frame_info_vp9(
struct d3d12_video_decoder *pD3D12Dec, uint32_t *pWidth, uint32_t *pHeight, uint16_t *pMaxDPB, bool *pIsInterlaced);
struct d3d12_video_decoder *pD3D12Dec, uint32_t *pWidth, uint32_t *pHeight, uint16_t *pMaxDPB);
DXVA_PicParams_VP9
d3d12_video_decoder_dxva_picparams_from_pipe_picparams_vp9(