This is an automated email from the git hooks/post-receive script.

Git pushed a commit to branch master
in repository ffmpeg.

commit fe953596e9f53e3d61c465bce7a29834cae3375b
Author:     Kacper Michajłow <[email protected]>
AuthorDate: Mon Jun 22 20:57:59 2026 +0200
Commit:     Kacper Michajłow <[email protected]>
CommitDate: Tue Jul 28 08:39:15 2026 +0000

    avcodec/d3d12va: add AV1 Profile 2 support
    
    Accept the AV1 Professional profile in the D3D12VA hwaccel and select the
    matching decode profile GUID, offer D3D12 for YUV420P12 in the decoder,
    map the frames context to P012, and add P016 (12-bit) support to the
    d3d12va hwcontext.
    
    Signed-off-by: Kacper Michajłow <[email protected]>
---
 libavcodec/av1dec.c           |  3 +++
 libavcodec/d3d12va_av1.c      | 14 +++++++++++---
 libavcodec/d3d12va_decode.c   |  6 +++++-
 libavutil/hwcontext_d3d12va.c |  9 +++++----
 4 files changed, 24 insertions(+), 8 deletions(-)

diff --git a/libavcodec/av1dec.c b/libavcodec/av1dec.c
index 4f73fcc1fc..e08dbddc48 100644
--- a/libavcodec/av1dec.c
+++ b/libavcodec/av1dec.c
@@ -619,6 +619,9 @@ static int get_pixel_format(AVCodecContext *avctx)
         *fmtp++ = AV_PIX_FMT_D3D11VA_VLD;
         *fmtp++ = AV_PIX_FMT_D3D11;
 #endif
+#if CONFIG_AV1_D3D12VA_HWACCEL
+        *fmtp++ = AV_PIX_FMT_D3D12;
+#endif
 #if CONFIG_AV1_VULKAN_HWACCEL
         *fmtp++ = AV_PIX_FMT_VULKAN;
 #endif
diff --git a/libavcodec/d3d12va_av1.c b/libavcodec/d3d12va_av1.c
index bcf28ed590..83222d6770 100644
--- a/libavcodec/d3d12va_av1.c
+++ b/libavcodec/d3d12va_av1.c
@@ -174,10 +174,18 @@ static av_cold int d3d12va_av1_decode_init(AVCodecContext 
*avctx)
 
     int ret;
 
-    if (avctx->profile != AV_PROFILE_AV1_MAIN)
+    switch (avctx->profile) {
+    case AV_PROFILE_AV1_MAIN:
+        ctx->cfg.DecodeProfile = D3D12_VIDEO_DECODE_PROFILE_AV1_PROFILE0;
+        break;
+    case AV_PROFILE_AV1_PROFESSIONAL:
+        ctx->cfg.DecodeProfile = avctx->sw_pix_fmt == AV_PIX_FMT_YUV420P12 ?
+                                 
D3D12_VIDEO_DECODE_PROFILE_AV1_12BIT_PROFILE2_420 :
+                                 D3D12_VIDEO_DECODE_PROFILE_AV1_PROFILE2;
+        break;
+    default:
         return AVERROR(EINVAL);
-
-    ctx->cfg.DecodeProfile = D3D12_VIDEO_DECODE_PROFILE_AV1_PROFILE0;
+    }
 
     ctx->max_num_ref = FF_ARRAY_ELEMS(pp.RefFrameMapTextureIndex) + 1;
 
diff --git a/libavcodec/d3d12va_decode.c b/libavcodec/d3d12va_decode.c
index 1b83b2d905..3a461c7fe0 100644
--- a/libavcodec/d3d12va_decode.c
+++ b/libavcodec/d3d12va_decode.c
@@ -391,7 +391,11 @@ int ff_d3d12va_common_frame_params(AVCodecContext *avctx, 
AVBufferRef *hw_frames
     AVHWFramesContext *frames_ctx = (AVHWFramesContext *)hw_frames_ctx->data;
 
     frames_ctx->format    = AV_PIX_FMT_D3D12;
-    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     = avctx->width;
     frames_ctx->height    = avctx->height;
 
diff --git a/libavutil/hwcontext_d3d12va.c b/libavutil/hwcontext_d3d12va.c
index 164f15a285..4f2a7393a0 100644
--- a/libavutil/hwcontext_d3d12va.c
+++ b/libavutil/hwcontext_d3d12va.c
@@ -70,6 +70,7 @@ static const struct {
 } supported_formats[] = {
     { DXGI_FORMAT_NV12, AV_PIX_FMT_NV12 },
     { DXGI_FORMAT_P010, AV_PIX_FMT_P010 },
+    { DXGI_FORMAT_P016, AV_PIX_FMT_P012 },
 };
 
 static void d3d12va_default_lock(void *ctx)
@@ -144,7 +145,7 @@ static int d3d12va_create_helper_objects(AVHWFramesContext 
*ctx)
         .NodeMask = 0,
     };
 
-    s->luma_component_size = FFALIGN(ctx->width * (frames_hwctx->format == 
DXGI_FORMAT_P010 ? 2 : 1),
+    s->luma_component_size = FFALIGN(ctx->width * (frames_hwctx->format != 
DXGI_FORMAT_NV12 ? 2 : 1),
                                      D3D12_TEXTURE_DATA_PITCH_ALIGNMENT) * 
ctx->height;
 
     DX_CHECK(ID3D12Device_CreateFence(device_hwctx->device, 0, 
D3D12_FENCE_FLAG_NONE,
@@ -490,7 +491,7 @@ static int d3d12va_transfer_data(AVHWFramesContext *ctx, 
AVFrame *dst,
     }
 
     for (int i = 0; i < 4; i++)
-        linesizes[i] = FFALIGN(frame->width * (frames_hwctx->format == 
DXGI_FORMAT_P010 ? 2 : 1),
+        linesizes[i] = FFALIGN(frame->width * (frames_hwctx->format != 
DXGI_FORMAT_NV12 ? 2 : 1),
                                D3D12_TEXTURE_DATA_PITCH_ALIGNMENT);
 
     staging_y_location = (D3D12_TEXTURE_COPY_LOCATION) {
@@ -498,7 +499,7 @@ static int d3d12va_transfer_data(AVHWFramesContext *ctx, 
AVFrame *dst,
         .PlacedFootprint = {
             .Offset = 0,
             .Footprint = {
-                .Format   = frames_hwctx->format == DXGI_FORMAT_P010 ?
+                .Format   = frames_hwctx->format != DXGI_FORMAT_NV12 ?
                                                     DXGI_FORMAT_R16_UNORM : 
DXGI_FORMAT_R8_UNORM,
                 .Width    = ctx->width,
                 .Height   = ctx->height,
@@ -513,7 +514,7 @@ static int d3d12va_transfer_data(AVHWFramesContext *ctx, 
AVFrame *dst,
         .PlacedFootprint = {
             .Offset = s->luma_component_size,
             .Footprint = {
-                .Format   = frames_hwctx->format == DXGI_FORMAT_P010 ?
+                .Format   = frames_hwctx->format != DXGI_FORMAT_NV12 ?
                                                     DXGI_FORMAT_R16G16_UNORM : 
DXGI_FORMAT_R8G8_UNORM,
                 .Width    = ctx->width  >> 1,
                 .Height   = ctx->height >> 1,

_______________________________________________
ffmpeg-cvslog mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to