[vlc-devel] [PATCH 26/31] d3d11va: create a video context for the VA

Steve Lhomme robux4 at ycbcr.xyz
Fri Jul 5 16:20:05 CEST 2019


---
 modules/codec/avcodec/d3d11va.c | 44 +++++++++++++++++++--------------
 1 file changed, 26 insertions(+), 18 deletions(-)

diff --git a/modules/codec/avcodec/d3d11va.c b/modules/codec/avcodec/d3d11va.c
index 3ee0c5d1b7..0c3b0d373d 100644
--- a/modules/codec/avcodec/d3d11va.c
+++ b/modules/codec/avcodec/d3d11va.c
@@ -369,26 +369,34 @@ static int Open(vlc_va_t *va, AVCodecContext *ctx, enum PixelFormat pix_fmt,
         {
             if (sys->d3d_dev.context_mutex == INVALID_HANDLE_VALUE)
                 msg_Warn(va, "No mutex found to lock the decoder");
-            void *d3dvidctx = NULL;
-            hr = ID3D11DeviceContext_QueryInterface(sys->d3d_dev.d3dcontext, &IID_ID3D11VideoContext, &d3dvidctx);
-            if (FAILED(hr)) {
-               msg_Err(va, "Could not Query ID3D11VideoContext Interface from the picture. (hr=0x%lX)", hr);
-               D3D11_ReleaseDevice(&sys->d3d_dev);
-            } else {
-                sys->d3dvidctx = d3dvidctx;
 
-                if (p_sys != NULL)
-                {
-                    /* TODO this will go away in push, we decide the decoding format */
-                    assert(p_sys->texture[KNOWN_DXGI_INDEX] != NULL);
-                    D3D11_TEXTURE2D_DESC dstDesc;
-                    ID3D11Texture2D_GetDesc( p_sys->texture[KNOWN_DXGI_INDEX], &dstDesc);
-                    sys->render = dstDesc.Format;
-                    if (dstDesc.BindFlags & D3D11_BIND_DECODER)
+            vlc_video_context *vctx = vlc_video_context_Create( dec_device, NULL, NULL );
+            if (likely(vctx != NULL))
+            {
+                void *d3dvidctx = NULL;
+                hr = ID3D11DeviceContext_QueryInterface(sys->d3d_dev.d3dcontext, &IID_ID3D11VideoContext, &d3dvidctx);
+                if (FAILED(hr)) {
+                    msg_Err(va, "Could not Query ID3D11VideoContext Interface from the picture. (hr=0x%lX)", hr);
+                    D3D11_ReleaseDevice(&sys->d3d_dev);
+                    vlc_video_context_Release( vctx );
+                } else {
+                    sys->d3dvidctx = d3dvidctx;
+
+                    *vctx_out = vctx;
+
+                    if (p_sys != NULL)
                     {
-                        va->sys->textureWidth = dstDesc.Width;
-                        va->sys->textureHeight = dstDesc.Height;
-                        va->sys->totalTextureSlices = dstDesc.ArraySize;
+                        /* TODO this will go away in push, we decide the decoding format */
+                        assert(p_sys->texture[KNOWN_DXGI_INDEX] != NULL);
+                        D3D11_TEXTURE2D_DESC dstDesc;
+                        ID3D11Texture2D_GetDesc( p_sys->texture[KNOWN_DXGI_INDEX], &dstDesc);
+                        sys->render = dstDesc.Format;
+                        if (dstDesc.BindFlags & D3D11_BIND_DECODER)
+                        {
+                            va->sys->textureWidth = dstDesc.Width;
+                            va->sys->textureHeight = dstDesc.Height;
+                            va->sys->totalTextureSlices = dstDesc.ArraySize;
+                        }
                     }
                 }
             }
-- 
2.17.1



More information about the vlc-devel mailing list