[vlc-devel] [PATCH 17/26] dxva2: use the decoder device to init the D3D9 device

Steve Lhomme robux4 at ycbcr.xyz
Fri Sep 20 16:28:47 CEST 2019


rather than the picture_sys
---
 modules/codec/avcodec/dxva2.c | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/modules/codec/avcodec/dxva2.c b/modules/codec/avcodec/dxva2.c
index 94a9b09f194..a5d379f1515 100644
--- a/modules/codec/avcodec/dxva2.c
+++ b/modules/codec/avcodec/dxva2.c
@@ -257,25 +257,25 @@ static int Open(vlc_va_t *va, AVCodecContext *ctx, enum PixelFormat pix_fmt,
     if (unlikely(sys == NULL))
         return VLC_ENOMEM;
     /* Load dll*/
-    picture_sys_d3d9_t *p_sys = picsys;
-    if (p_sys!=NULL && p_sys->surface!=NULL)
+    d3d9_decoder_device_t *d3d9_decoder = GetD3D9OpaqueDevice( dec_device );
+    if ( d3d9_decoder != NULL )
     {
-        IDirect3DDevice9 *device;
-        if ( FAILED(IDirect3DSurface9_GetDevice( p_sys->surface, &device )) )
+        D3D9_CloneExternal(&sys->hd3d, d3d9_decoder->device);
+        HRESULT hr = D3D9_CreateDevice(va, &sys->hd3d, d3d9_decoder->adapter, &sys->d3d_dev);
+        if ( FAILED(hr) )
         {
+            D3D9_Destroy(&sys->hd3d);
             free( sys );
             goto error;
         }
-        if ( D3D9_CreateExternal(&sys->hd3d, device) != VLC_SUCCESS ||
-             FAILED(D3D9_CreateDeviceExternal( device, &sys->hd3d, &sys->d3d_dev)) )
+        if (picsys != NULL)
         {
-            IDirect3DDevice9_Release(device);
-            free( sys );
-            goto error;
+            picture_sys_d3d9_t *p_sys = picsys;
+            /* TODO this will go away in push, we decide the decoding format */
+            D3DSURFACE_DESC src;
+            if (SUCCEEDED(IDirect3DSurface9_GetDesc(p_sys->surface, &src)))
+                sys->render = src.Format;
         }
-        D3DSURFACE_DESC src;
-        if (SUCCEEDED(IDirect3DSurface9_GetDesc(p_sys->surface, &src)))
-            sys->render = src.Format;
     }
     else if (D3D9_Create(va, &sys->hd3d) != VLC_SUCCESS) {
         msg_Warn(va, "cannot load d3d9.dll");
-- 
2.17.1



More information about the vlc-devel mailing list