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

Git pushed a commit to branch master
in repository ffmpeg.

commit a15481190f5884a802b0ce3ff96898492c773234
Author:     Kacper Michajłow <[email protected]>
AuthorDate: Tue Sep 22 11:39:11 2026 +0200
Commit:     Kacper Michajłow <[email protected]>
CommitDate: Tue Sep 22 21:07:52 2026 +0000

    avcodec/dxva2: derive the DXVA2 decoder format from the frames context
    
    dxva2_create_decoder picked the D3D9 surface format from sw_pix_fmt with
    a hardcoded choice between NV12 and P010, while the surfaces it decodes
    into come from the frames context, whose format is chosen separately in
    ff_dxva2_common_frame_params. Map frames_ctx->sw_format to the D3DFORMAT
    instead, like the D3D11 path already does, so the two cannot drift
    apart.
    
    DXVA2 is only offered for 4:2:0 8-bit and 10-bit streams, so this code
    path only ever sees NV12 and P010. But it's nicer to be explicit here,
    and return D3DFMT_UNKNOWN for any unexpected format, if ever added.
    
    Signed-off-by: Kacper Michajłow <[email protected]>
---
 libavcodec/dxva2.c | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/libavcodec/dxva2.c b/libavcodec/dxva2.c
index c761f8eebb..ead5eabb47 100644
--- a/libavcodec/dxva2.c
+++ b/libavcodec/dxva2.c
@@ -352,22 +352,30 @@ static int dxva2_get_decoder_configuration(AVCodecContext 
*avctx, const GUID *de
     return ret;
 }
 
+static D3DFORMAT dxva2_map_sw_to_hw_format(enum AVPixelFormat pix_fmt)
+{
+    switch (pix_fmt) {
+    case AV_PIX_FMT_NV12:       return MKTAG('N', 'V', '1', '2');
+    case AV_PIX_FMT_P010:       return MKTAG('P', '0', '1', '0');
+    default:                    return D3DFMT_UNKNOWN;
+    }
+}
+
 static int dxva2_create_decoder(AVCodecContext *avctx)
 {
     FFDXVASharedContext *sctx = DXVA_SHARED_CONTEXT(avctx);
     GUID *guid_list;
     unsigned guid_count;
     GUID device_guid;
-    D3DFORMAT surface_format = avctx->sw_pix_fmt == AV_PIX_FMT_YUV420P10 ?
-                               MKTAG('P', '0', '1', '0') : MKTAG('N', 'V', 
'1', '2');
+    AVHWFramesContext *frames_ctx = 
(AVHWFramesContext*)avctx->hw_frames_ctx->data;
+    AVDXVA2FramesContext *frames_hwctx = frames_ctx->hwctx;
+    AVDXVA2DeviceContext *device_hwctx = frames_ctx->device_ctx->hwctx;
+    D3DFORMAT surface_format = 
dxva2_map_sw_to_hw_format(frames_ctx->sw_format);
     DXVA2_VideoDesc desc = { 0 };
     DXVA2_ConfigPictureDecode config;
     HRESULT hr;
     int ret;
     HANDLE device_handle;
-    AVHWFramesContext *frames_ctx = 
(AVHWFramesContext*)avctx->hw_frames_ctx->data;
-    AVDXVA2FramesContext *frames_hwctx = frames_ctx->hwctx;
-    AVDXVA2DeviceContext *device_hwctx = frames_ctx->device_ctx->hwctx;
 
     hr = IDirect3DDeviceManager9_OpenDeviceHandle(device_hwctx->devmgr,
                                                   &device_handle);

-- 
To stop receiving notification emails like this one, please contact
[email protected].
_______________________________________________
ffmpeg-cvslog mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to