AMD General
>From 6ba7556b992630bf0bcc76f3f1f80b8e3cea9eb1 Mon Sep 17 00:00:00 2001
From: Dong Nguyen <[email protected]>
Date: Tue, 13 Oct 2026 10:39:40 -0400
Subject: [PATCH] avcodec/d3d12va: set InterlaceType for field-coded decoders
D3D12_VIDEO_DECODE_CONFIGURATION.InterlaceType was never set,
defaulting to NONE (progressive-only). This caused green cell
artifacts when decoding interlaced H.264 content via D3D12VA.
Set InterlaceType to FIELD_BASED for H.264, MPEG-2, and VC-1
decoders. HEVC is left unchanged as it has no field coding.
Tested with interlaced H.264 on AMD RX 7800 XT - D3D12 output
is now byte-identical to D3D11.
________________________________
libavcodec/d3d12va_decode.c | 3 +++
libavcodec/d3d12va_h264.c | 1 +
libavcodec/d3d12va_mpeg2.c | 1 +
libavcodec/d3d12va_vc1.c | 2 ++
4 files changed, 7 insertions(+)
diff --git a/libavcodec/d3d12va_decode.c b/libavcodec/d3d12va_decode.c
index 39feb3a623..61694fa987 100644
--- a/libavcodec/d3d12va_decode.c
+++ b/libavcodec/d3d12va_decode.c
@@ -608,6 +608,9 @@ int ff_d3d12va_common_end_frame(AVCodecContext avctx,
AVFrame frame,
.pOutputTexture2D = output_resource,
};
*
/* Subresource index 0 is correct: FFmpeg allocates each D3D12 frame as a
*
* single-array-slice texture with both fields interleaved (same as D3D11VA).
*
* Field selection is communicated through DXVA picture parameters. /
*
memset(ctx->ref_subresources, 0, sizeof(UINT) * ctx->max_num_ref);
input_args.ReferenceFrames.NumTexture2Ds = ctx->max_num_ref;
input_args.ReferenceFrames.pSubresources = ctx->ref_subresources;
*
diff --git a/libavcodec/d3d12va_h264.c b/libavcodec/d3d12va_h264.c
index a3031f67b3..16ddef7e67 100644
--- a/libavcodec/d3d12va_h264.c
+++ b/libavcodec/d3d12va_h264.c
@@ -185,6 +185,7 @@ static av_cold int d3d12va_h264_decode_init(AVCodecContext
avctx)
*
DXVA_PicParams_H264 pp;
ctx->cfg.DecodeProfile = D3D12_VIDEO_DECODE_PROFILE_H264;
*
ctx->cfg.InterlaceType = D3D12_VIDEO_FRAME_CODED_INTERLACE_TYPE_FIELD_BASED;
ctx->max_num_ref = FF_ARRAY_ELEMS(pp.RefFrameList) + 1;
diff --git a/libavcodec/d3d12va_mpeg2.c b/libavcodec/d3d12va_mpeg2.c
index cceca682c7..867819586b 100644
--- a/libavcodec/d3d12va_mpeg2.c
+++ b/libavcodec/d3d12va_mpeg2.c
@@ -159,6 +159,7 @@ static av_cold int d3d12va_mpeg2_decode_init(AVCodecContext
avctx)
D3D12VADecodeContext ctx = D3D12VA_DECODE_CONTEXT(avctx);
ctx->cfg.DecodeProfile = D3D12_VIDEO_DECODE_PROFILE_MPEG2;
*
ctx->cfg.InterlaceType = D3D12_VIDEO_FRAME_CODED_INTERLACE_TYPE_FIELD_BASED;
ctx->max_num_ref = 3;
diff --git a/libavcodec/d3d12va_vc1.c b/libavcodec/d3d12va_vc1.c
index 53fc3955c3..9540d5680d 100644
--- a/libavcodec/d3d12va_vc1.c
+++ b/libavcodec/d3d12va_vc1.c
@@ -173,12 +173,14 @@ static av_cold int d3d12va_vc1_decode_init(AVCodecContext
avctx)
int ret;
D3D12VADecodeContext ctx = D3D12VA_DECODE_CONTEXT(avctx);
ctx->cfg.DecodeProfile = D3D12_VIDEO_DECODE_PROFILE_VC1_D2010;
*
ctx->cfg.InterlaceType = D3D12_VIDEO_FRAME_CODED_INTERLACE_TYPE_FIELD_BASED;
ctx->max_num_ref = 3;
ret = ff_d3d12va_decode_init(avctx);
if (ret < 0) {
ctx->cfg.DecodeProfile = D3D12_VIDEO_DECODE_PROFILE_VC1;
*
ctx->cfg.InterlaceType = D3D12_VIDEO_FRAME_CODED_INTERLACE_TYPE_FIELD_BASED;
*
ret = ff_d3d12va_decode_init(avctx);
}
--
2.54.0
_______________________________________________
ffmpeg-devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]