[PR] avcodec/dxva2: add AV1 Profile 2 support (PR #23553)

Kacper Michajłow via ffmpeg-devel <[email protected]>
Newsgroups gmane.comp.video.ffmpeg.devel
Message-ID <178212684452.59.10274881266078453205@29965ddac10e>
PR #23553 opened by Kacper Michajłow (kasper93)
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/23553
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/23553.patch


From 4090717e0c80cf521d3aee09ab16ef0692fa5dc0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Kacper=20Michaj=C5=82ow?= <[email protected]>
Date: Mon, 22 Jun 2026 13:08:37 +0200
Subject: [PATCH 1/3] avcodec/dxva2: map 4:2:0 12-bit to P012 surfaces
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Select P012 as the D3D11VA/DXVA2 frames sw_format for YUV420P12 content
and map it to DXGI_FORMAT_P016, so 12-bit 4:2:0 hardware decoding can
allocate a usable surface.

Signed-off-by: Kacper Michajłow <[email protected]>
---
 libavcodec/dxva2.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/libavcodec/dxva2.c b/libavcodec/dxva2.c
index a282e6c0c7..da9b0bc834 100644
--- a/libavcodec/dxva2.c
+++ b/libavcodec/dxva2.c
@@ -458,6 +458,7 @@ static DXGI_FORMAT d3d11va_map_sw_to_hw_format(enum AVPixelFormat pix_fmt)
     switch (pix_fmt) {
     case AV_PIX_FMT_NV12:       return DXGI_FORMAT_NV12;
     case AV_PIX_FMT_P010:       return DXGI_FORMAT_P010;
+    case AV_PIX_FMT_P012:       return DXGI_FORMAT_P016;
     case AV_PIX_FMT_YUV420P:    return DXGI_FORMAT_420_OPAQUE;
     default:                    return DXGI_FORMAT_UNKNOWN;
     }
@@ -627,8 +628,11 @@ int ff_dxva2_common_frame_params(AVCodecContext *avctx,
     else
         num_surfaces += 2;
 
-    frames_ctx->sw_format = avctx->sw_pix_fmt == AV_PIX_FMT_YUV420P10 ?
-                            AV_PIX_FMT_P010 : AV_PIX_FMT_NV12;
+    switch (avctx->sw_pix_fmt) {
+    case AV_PIX_FMT_YUV420P10: frames_ctx->sw_format = AV_PIX_FMT_P010; break;
+    case AV_PIX_FMT_YUV420P12: frames_ctx->sw_format = AV_PIX_FMT_P012; break;
+    default:                   frames_ctx->sw_format = AV_PIX_FMT_NV12; break;
+    }
     frames_ctx->width = FFALIGN(avctx->coded_width, surface_alignment);
     frames_ctx->height = FFALIGN(avctx->coded_height, surface_alignment);
     frames_ctx->initial_pool_size = num_surfaces;
-- 
2.52.0


From e3d71739ce3a52e9c7771406b4372790e19d7dc6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Kacper=20Michaj=C5=82ow?= <[email protected]>
Date: Mon, 22 Jun 2026 13:08:50 +0200
Subject: [PATCH 2/3] avcodec/dxva2: add AV1 Profile 2 decoder GUIDs
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Add the AV1 Professional (Profile 2) decoder GUIDs, including the
dedicated 12-bit 4:2:0 mode, so D3D11VA/DXVA2 can match a decoder for
Profile 2 streams.

Signed-off-by: Kacper Michajłow <[email protected]>
---
 libavcodec/dxva2.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/libavcodec/dxva2.c b/libavcodec/dxva2.c
index da9b0bc834..8f09fb6c44 100644
--- a/libavcodec/dxva2.c
+++ b/libavcodec/dxva2.c
@@ -47,6 +47,9 @@ DEFINE_GUID(ff_DXVA2_ModeHEVC_VLD_Main10,0x107af0e0, 0xef1a,0x4d19,0xab,0xa8,0x6
 DEFINE_GUID(ff_DXVA2_ModeVP9_VLD_Profile0,0x463707f8,0xa1d0,0x4585,0x87,0x6d,0x83,0xaa,0x6d,0x60,0xb8,0x9e);
 DEFINE_GUID(ff_DXVA2_ModeVP9_VLD_10bit_Profile2,0xa4c749ef,0x6ecf,0x48aa,0x84,0x48,0x50,0xa7,0xa1,0x16,0x5f,0xf7);
 DEFINE_GUID(ff_DXVA2_ModeAV1_VLD_Profile0,0xb8be4ccb,0xcf53,0x46ba,0x8d,0x59,0xd6,0xb8,0xa6,0xda,0x5d,0x2a);
+DEFINE_GUID(ff_DXVA2_ModeAV1_VLD_Profile2,0x0c5f2aa1,0xe541,0x4089,0xbb,0x7b,0x98,0x11,0x0a,0x19,0xd7,0xc8);
+DEFINE_GUID(ff_DXVA2_ModeAV1_VLD_12bit_Profile2,0x17127009,0xa00f,0x4ce1,0x99,0x4e,0xbf,0x40,0x81,0xf6,0xf3,0xf0);
+DEFINE_GUID(ff_DXVA2_ModeAV1_VLD_12bit_Profile2_420,0x2d80bed6,0x9cac,0x4835,0x9e,0x91,0x32,0x7b,0xbc,0x4f,0x9e,0xe8);
 DEFINE_GUID(ff_DXVA2_NoEncrypt,          0x1b81beD0, 0xa0c7,0x11d3,0xb9,0x84,0x00,0xc0,0x4f,0x2e,0x73,0xc5);
 DEFINE_GUID(ff_GUID_NULL,                0x00000000, 0x0000,0x0000,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00);
 DEFINE_GUID(ff_IID_IDirectXVideoDecoderService, 0xfc51a551,0xd5e7,0x11d9,0xaf,0x55,0x00,0x05,0x4e,0x43,0xff,0x02);
@@ -76,6 +79,8 @@ static const int prof_vp9_profile2[] = {AV_PROFILE_VP9_2,
                                         AV_PROFILE_UNKNOWN};
 static const int prof_av1_profile0[] = {AV_PROFILE_AV1_MAIN,
                                         AV_PROFILE_UNKNOWN};
+static const int prof_av1_profile2[] = {AV_PROFILE_AV1_PROFESSIONAL,
+                                        AV_PROFILE_UNKNOWN};
 
 static const dxva_mode dxva_modes[] = {
     /* MPEG-2 */
@@ -103,7 +108,10 @@ static const dxva_mode dxva_modes[] = {
     { &ff_DXVA2_ModeVP9_VLD_10bit_Profile2, AV_CODEC_ID_VP9, prof_vp9_profile2 },
 
     /* AV1 */
-    { &ff_DXVA2_ModeAV1_VLD_Profile0,       AV_CODEC_ID_AV1, prof_av1_profile0 },
+    { &ff_DXVA2_ModeAV1_VLD_Profile0,            AV_CODEC_ID_AV1, prof_av1_profile0 },
+    { &ff_DXVA2_ModeAV1_VLD_12bit_Profile2_420,  AV_CODEC_ID_AV1, prof_av1_profile2 },
+    { &ff_DXVA2_ModeAV1_VLD_12bit_Profile2,      AV_CODEC_ID_AV1, prof_av1_profile2 },
+    { &ff_DXVA2_ModeAV1_VLD_Profile2,            AV_CODEC_ID_AV1, prof_av1_profile2 },
 
     { NULL,                          0 },
 };
-- 
2.52.0


From 78e0dc8e740474a15cb99fa4d870ac6b92bb3f9d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Kacper=20Michaj=C5=82ow?= <[email protected]>
Date: Mon, 22 Jun 2026 13:08:51 +0200
Subject: [PATCH 3/3] avcodec/av1dec: allow D3D11VA for 12-bit 4:2:0
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Offer the D3D11VA hwaccel pixel formats for YUV420P12 (AV1 Profile 2),
enabling hardware decoding of 12-bit 4:2:0 streams on capable devices.

Signed-off-by: Kacper Michajłow <[email protected]>
---
 libavcodec/av1dec.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/libavcodec/av1dec.c b/libavcodec/av1dec.c
index 424bbfc431..6bbc34d4bc 100644
--- a/libavcodec/av1dec.c
+++ b/libavcodec/av1dec.c
@@ -608,6 +608,10 @@ static int get_pixel_format(AVCodecContext *avctx)
 #endif
         break;
     case AV_PIX_FMT_YUV420P12:
+#if CONFIG_AV1_D3D11VA_HWACCEL
+        *fmtp++ = AV_PIX_FMT_D3D11VA_VLD;
+        *fmtp++ = AV_PIX_FMT_D3D11;
+#endif
 #if CONFIG_AV1_VULKAN_HWACCEL
         *fmtp++ = AV_PIX_FMT_VULKAN;
 #endif
-- 
2.52.0

_______________________________________________
ffmpeg-devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.