[vlc-commits] hw:d3d9: use d3d9_device_t instead of IDirect3DDevice9

Steve Lhomme git at videolan.org
Thu Nov 23 10:17:02 CET 2017


vlc | branch: master | Steve Lhomme <robUx4 at videolabs.io> | Wed Nov 22 18:18:34 2017 +0100| [00022da0e2544b72ba92597e49054ec0eb7575fe] | committer: Jean-Baptiste Kempf

hw:d3d9: use d3d9_device_t instead of IDirect3DDevice9

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=00022da0e2544b72ba92597e49054ec0eb7575fe
---

 modules/hw/d3d9/d3d9_filters.c      | 22 +++++++++++-----------
 modules/hw/d3d9/dxa9.c              | 27 +++++++++++++--------------
 modules/hw/d3d9/dxva2_deinterlace.c | 21 ++++++++++-----------
 3 files changed, 34 insertions(+), 36 deletions(-)

diff --git a/modules/hw/d3d9/d3d9_filters.c b/modules/hw/d3d9/d3d9_filters.c
index 9153b931b6..d0212718eb 100644
--- a/modules/hw/d3d9/d3d9_filters.c
+++ b/modules/hw/d3d9/d3d9_filters.c
@@ -55,7 +55,7 @@ struct filter_sys_t
     HINSTANCE                      hdecoder_dll;
     /* keep a reference in case the vout is released first */
     HINSTANCE                      d3d9_dll;
-    IDirect3DDevice9               *d3ddev;
+    d3d9_device_t                  d3d_dev;
     IDirectXVideoProcessor         *processor;
     IDirect3DSurface9              *hw_surface;
 
@@ -147,7 +147,7 @@ static picture_t *Filter(filter_t *p_filter, picture_t *p_pic)
                                                  &params,
                                                  &sample,
                                                  1, NULL );
-    hr = IDirect3DDevice9_StretchRect( p_sys->d3ddev,
+    hr = IDirect3DDevice9_StretchRect( p_sys->d3d_dev.dev,
                                        p_sys->hw_surface, NULL,
                                        p_outpic->p_sys->surface, NULL,
                                        D3DTEXF_NONE);
@@ -236,6 +236,10 @@ static int D3D9OpenAdjust(vlc_object_t *obj)
     if (!video_format_IsSimilar(&filter->fmt_in.video, &filter->fmt_out.video))
         return VLC_EGENERIC;
 
+    sys = calloc(1, sizeof (*sys));
+    if (unlikely(sys == NULL))
+        return VLC_ENOMEM;
+
     d3d9_dll = LoadLibrary(TEXT("D3D9.DLL"));
     if (!d3d9_dll)
         goto error;
@@ -254,10 +258,6 @@ static int D3D9OpenAdjust(vlc_object_t *obj)
         goto error;
     }
 
-    sys = calloc(1, sizeof (*sys));
-    if (unlikely(sys == NULL))
-        goto error;
-
     HRESULT (WINAPI *CreateVideoService)(IDirect3DDevice9 *,
                                          REFIID riid,
                                          void **ppService);
@@ -266,7 +266,7 @@ static int D3D9OpenAdjust(vlc_object_t *obj)
     if (CreateVideoService == NULL)
         goto error;
 
-    hr = IDirect3DSurface9_GetDevice( dst->p_sys->surface, &sys->d3ddev );
+    hr = IDirect3DSurface9_GetDevice( dst->p_sys->surface, &sys->d3d_dev.dev );
     if (FAILED(hr))
         goto error;
 
@@ -275,7 +275,7 @@ static int D3D9OpenAdjust(vlc_object_t *obj)
     if (unlikely(FAILED(hr)))
         goto error;
 
-    hr = CreateVideoService( sys->d3ddev, &IID_IDirectXVideoProcessorService,
+    hr = CreateVideoService( sys->d3d_dev.dev, &IID_IDirectXVideoProcessorService,
                             (void**)&processor);
     if (FAILED(hr))
         goto error;
@@ -413,8 +413,8 @@ error:
         IDirectXVideoProcessor_Release( sys->processor );
     if (processor)
         IDirectXVideoProcessorService_Release(processor);
-    if (sys && sys->d3ddev)
-        IDirect3DDevice9_Release( sys->d3ddev );
+    if (sys)
+        D3D9_ReleaseDevice( &sys->d3d_dev );
     if (hdecoder_dll)
         FreeLibrary(hdecoder_dll);
     if (d3d9_dll)
@@ -433,7 +433,7 @@ static void D3D9CloseAdjust(vlc_object_t *obj)
 
     IDirect3DSurface9_Release( sys->hw_surface );
     IDirectXVideoProcessor_Release( sys->processor );
-    IDirect3DDevice9_Release( sys->d3ddev );
+    D3D9_ReleaseDevice( &sys->d3d_dev );
     FreeLibrary( sys->hdecoder_dll );
     FreeLibrary( sys->d3d9_dll );
 
diff --git a/modules/hw/d3d9/dxa9.c b/modules/hw/d3d9/dxa9.c
index d6624a7f5a..6815db2a93 100644
--- a/modules/hw/d3d9/dxa9.c
+++ b/modules/hw/d3d9/dxa9.c
@@ -47,7 +47,7 @@ struct filter_sys_t {
     copy_cache_t      cache;
 
     /* CPU to GPU */
-    IDirect3DDevice9  *d3ddev;
+    d3d9_device_t     d3d_dev;
     filter_t          *filter;
     picture_t         *staging;
 
@@ -265,7 +265,7 @@ static void YV12_D3D9(filter_t *p_filter, picture_t *src, picture_t *dst)
     RECT visibleSource = {
         .right = dst->format.i_width, .bottom = dst->format.i_height,
     };
-    IDirect3DDevice9_StretchRect( sys->d3ddev,
+    IDirect3DDevice9_StretchRect( sys->d3d_dev.dev,
                                   sys->staging->p_sys->surface, &visibleSource,
                                   dst->p_sys->surface, &visibleSource,
                                   D3DTEXF_NONE );
@@ -342,7 +342,6 @@ int D3D9OpenCPUConverter( vlc_object_t *obj )
     filter_t *p_filter = (filter_t *)obj;
     int err = VLC_EGENERIC;
     LPDIRECT3DSURFACE9 texture = NULL;
-    IDirect3DDevice9  *d3ddev = NULL;
     filter_t *p_cpu_filter = NULL;
     picture_t *p_dst = NULL;
     HINSTANCE hd3d_dll = NULL;
@@ -364,6 +363,12 @@ int D3D9OpenCPUConverter( vlc_object_t *obj )
         return VLC_EGENERIC;
     }
 
+    filter_sys_t *p_sys = calloc(1, sizeof(filter_sys_t));
+    if (!p_sys) {
+         err = VLC_ENOMEM;
+         goto done;
+    }
+
     picture_t *peek = filter_NewPicture(p_filter);
     if (peek == NULL)
         return VLC_EGENERIC;
@@ -401,8 +406,8 @@ int D3D9OpenCPUConverter( vlc_object_t *obj )
         }
         picture_Setup(p_dst, &p_dst->format);
 
-        IDirect3DSurface9_GetDevice(peek->p_sys->surface, &d3ddev);
-        HRESULT hr = IDirect3DDevice9_CreateOffscreenPlainSurface(d3ddev,
+        IDirect3DSurface9_GetDevice(peek->p_sys->surface, &p_sys->d3d_dev.dev);
+        HRESULT hr = IDirect3DDevice9_CreateOffscreenPlainSurface(p_sys->d3d_dev.dev,
                                                           p_dst->format.i_width,
                                                           p_dst->format.i_height,
                                                           texDesc.Format,
@@ -427,12 +432,6 @@ int D3D9OpenCPUConverter( vlc_object_t *obj )
         goto done;
     }
 
-    filter_sys_t *p_sys = calloc(1, sizeof(filter_sys_t));
-    if (!p_sys) {
-         err = VLC_ENOMEM;
-         goto done;
-    }
-    p_sys->d3ddev    = d3ddev;
     p_sys->filter    = p_cpu_filter;
     p_sys->staging   = p_dst;
     p_sys->hd3d_dll = hd3d_dll;
@@ -444,14 +443,14 @@ done:
     picture_Release(peek);
     if (err != VLC_SUCCESS)
     {
-        if (d3ddev)
-            IDirect3DDevice9_Release(d3ddev);
         if (p_cpu_filter)
             DeleteFilter( p_cpu_filter );
         if (texture)
             IDirect3DSurface9_Release(texture);
+        D3D9_ReleaseDevice(&p_sys->d3d_dev);
         if (hd3d_dll)
             FreeLibrary(hd3d_dll);
+        free(p_sys);
     }
     return err;
 }
@@ -471,7 +470,7 @@ void D3D9CloseCPUConverter( vlc_object_t *obj )
     filter_sys_t *p_sys = (filter_sys_t*) p_filter->p_sys;
     DeleteFilter(p_sys->filter);
     picture_Release(p_sys->staging);
-    IDirect3DDevice9_Release(p_sys->d3ddev);
+    D3D9_ReleaseDevice(&p_sys->d3d_dev);
     FreeLibrary(p_sys->hd3d_dll);
     free( p_sys );
     p_filter->p_sys = NULL;
diff --git a/modules/hw/d3d9/dxva2_deinterlace.c b/modules/hw/d3d9/dxva2_deinterlace.c
index 4afd34fbe1..27f6fdb0d8 100644
--- a/modules/hw/d3d9/dxva2_deinterlace.c
+++ b/modules/hw/d3d9/dxva2_deinterlace.c
@@ -45,7 +45,7 @@ struct filter_sys_t
     HINSTANCE                      hdecoder_dll;
     /* keep a reference in case the vout is released first */
     HINSTANCE                      d3d9_dll;
-    IDirect3DDevice9               *d3ddev;
+    d3d9_device_t                  d3d_dev;
     IDirectXVideoProcessor         *processor;
     IDirect3DSurface9              *hw_surface;
 
@@ -193,7 +193,7 @@ static int RenderPic( filter_t *filter, picture_t *p_outpic, picture_t *src,
     if (FAILED(hr))
         return VLC_EGENERIC;
 
-    hr = IDirect3DDevice9_StretchRect( sys->d3ddev,
+    hr = IDirect3DDevice9_StretchRect( sys->d3d_dev.dev,
                                        sys->hw_surface, NULL,
                                        p_outpic->p_sys->surface, NULL,
                                        D3DTEXF_NONE);
@@ -293,6 +293,10 @@ int D3D9OpenDeinterlace(vlc_object_t *obj)
     if (!hdecoder_dll)
         goto error;
 
+    sys = calloc(1, sizeof (*sys));
+    if (unlikely(sys == NULL))
+        goto error;
+
     dst = filter_NewPicture(filter);
     if (dst == NULL)
         goto error;
@@ -303,10 +307,6 @@ int D3D9OpenDeinterlace(vlc_object_t *obj)
         goto error;
     }
 
-    sys = calloc(1, sizeof (*sys));
-    if (unlikely(sys == NULL))
-        goto error;
-
     HRESULT (WINAPI *CreateVideoService)(IDirect3DDevice9 *,
                                          REFIID riid,
                                          void **ppService);
@@ -315,7 +315,7 @@ int D3D9OpenDeinterlace(vlc_object_t *obj)
     if (CreateVideoService == NULL)
         goto error;
 
-    hr = IDirect3DSurface9_GetDevice( dst->p_sys->surface, &sys->d3ddev );
+    hr = IDirect3DSurface9_GetDevice( dst->p_sys->surface, &sys->d3d_dev.dev );
     if (FAILED(hr))
         goto error;
 
@@ -324,7 +324,7 @@ int D3D9OpenDeinterlace(vlc_object_t *obj)
     if (unlikely(FAILED(hr)))
         goto error;
 
-    hr = CreateVideoService( sys->d3ddev, &IID_IDirectXVideoProcessorService,
+    hr = CreateVideoService( sys->d3d_dev.dev, &IID_IDirectXVideoProcessorService,
                             (void**)&processor);
     if (FAILED(hr))
         goto error;
@@ -480,8 +480,7 @@ error:
         IDirectXVideoProcessor_Release( sys->processor );
     if (processor)
         IDirectXVideoProcessorService_Release(processor);
-    if (sys && sys->d3ddev)
-        IDirect3DDevice9_Release( sys->d3ddev );
+    D3D9_ReleaseDevice( &sys->d3d_dev );
     if (hdecoder_dll)
         FreeLibrary(hdecoder_dll);
     if (d3d9_dll)
@@ -500,7 +499,7 @@ void D3D9CloseDeinterlace(vlc_object_t *obj)
 
     IDirect3DSurface9_Release( sys->hw_surface );
     IDirectXVideoProcessor_Release( sys->processor );
-    IDirect3DDevice9_Release( sys->d3ddev );
+    D3D9_ReleaseDevice( &sys->d3d_dev );
     FreeLibrary( sys->hdecoder_dll );
     FreeLibrary( sys->d3d9_dll );
 



More information about the vlc-commits mailing list