[vlc-commits] d3d11: use a close callback for locally defined operations

Steve Lhomme git at videolan.org
Mon Oct 12 15:55:51 CEST 2020


vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Tue Oct  6 10:58:55 2020 +0200| [f52184c73c6c7845590d3d843fe86f9ebd408bc7] | committer: Steve Lhomme

d3d11: use a close callback for locally defined operations

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

 modules/hw/d3d11/d3d11_deinterlace.c | 21 ++++++++++-----------
 modules/hw/d3d11/d3d11_filters.c     |  4 ++--
 modules/hw/d3d11/d3d11_filters.h     |  2 --
 modules/hw/d3d11/d3d11_surface.c     | 23 +++++++++++------------
 4 files changed, 23 insertions(+), 27 deletions(-)

diff --git a/modules/hw/d3d11/d3d11_deinterlace.c b/modules/hw/d3d11/d3d11_deinterlace.c
index 3eb8e9bf08..feaea04507 100644
--- a/modules/hw/d3d11/d3d11_deinterlace.c
+++ b/modules/hw/d3d11/d3d11_deinterlace.c
@@ -232,8 +232,17 @@ picture_t *AllocPicture( filter_t *p_filter )
     return pic;
 }
 
+static void D3D11CloseDeinterlace(filter_t *filter)
+{
+    filter_sys_t *sys = filter->p_sys;
+    D3D11_ReleaseProcessor( &sys->d3d_proc );
+    vlc_video_context_Release(filter->vctx_out);
+
+    free(sys);
+}
+
 static const struct vlc_filter_operations filter_ops = {
-    .filter_video = Deinterlace, .flush = Flush,
+    .filter_video = Deinterlace, .flush = Flush, .close = D3D11CloseDeinterlace,
 };
 
 int D3D11OpenDeinterlace(vlc_object_t *obj)
@@ -366,13 +375,3 @@ error:
     return VLC_EGENERIC;
 }
 
-void D3D11CloseDeinterlace(vlc_object_t *obj)
-{
-    filter_t *filter = (filter_t *)obj;
-    filter_sys_t *sys = filter->p_sys;
-    D3D11_ReleaseProcessor( &sys->d3d_proc );
-    vlc_video_context_Release(filter->vctx_out);
-
-    free(sys);
-}
-
diff --git a/modules/hw/d3d11/d3d11_filters.c b/modules/hw/d3d11/d3d11_filters.c
index 36e3351543..a8f59e5d4b 100644
--- a/modules/hw/d3d11/d3d11_filters.c
+++ b/modules/hw/d3d11/d3d11_filters.c
@@ -594,7 +594,7 @@ vlc_module_begin()
 
     add_submodule()
     set_description(N_("Direct3D11 deinterlace filter"))
-    set_callbacks( D3D11OpenDeinterlace, D3D11CloseDeinterlace )
+    set_callback( D3D11OpenDeinterlace )
     add_shortcut ("deinterlace")
 
     add_submodule()
@@ -602,7 +602,7 @@ vlc_module_begin()
     set_callbacks( D3D11OpenConverter, D3D11CloseConverter )
 
     add_submodule()
-    set_callbacks( D3D11OpenCPUConverter, D3D11CloseCPUConverter )
+    set_callback( D3D11OpenCPUConverter )
     set_capability( "video converter", 10 )
 
     add_submodule()
diff --git a/modules/hw/d3d11/d3d11_filters.h b/modules/hw/d3d11/d3d11_filters.h
index 71a8dcd178..555d2b6ba3 100644
--- a/modules/hw/d3d11/d3d11_filters.h
+++ b/modules/hw/d3d11/d3d11_filters.h
@@ -29,11 +29,9 @@
 #include "../../video_chroma/d3d11_fmt.h"
 
 int  D3D11OpenDeinterlace(vlc_object_t *);
-void D3D11CloseDeinterlace(vlc_object_t *);
 int  D3D11OpenConverter(vlc_object_t *);
 void D3D11CloseConverter(vlc_object_t *);
 int  D3D11OpenCPUConverter(vlc_object_t *);
-void D3D11CloseCPUConverter(vlc_object_t *);
 
 int  D3D11OpenDecoderDeviceW8(vlc_decoder_device *, vout_window_t *);
 int  D3D11OpenDecoderDeviceAny(vlc_decoder_device *, vout_window_t *);
diff --git a/modules/hw/d3d11/d3d11_surface.c b/modules/hw/d3d11/d3d11_surface.c
index 44a3c87ac6..fe20618a69 100644
--- a/modules/hw/d3d11/d3d11_surface.c
+++ b/modules/hw/d3d11/d3d11_surface.c
@@ -664,8 +664,18 @@ static picture_t *NV12_D3D11_Filter( filter_t *p_filter, picture_t *p_pic )
     return p_outpic;
 }
 
+static void D3D11CloseCPUConverter( filter_t *p_filter )
+{
+    filter_sys_t *p_sys = p_filter->p_sys;
+    if (p_sys->filter)
+        DeleteFilter(p_sys->filter);
+    if (p_sys->staging_pic)
+        picture_Release(p_sys->staging_pic);
+    vlc_video_context_Release(p_filter->vctx_out);
+}
+
 static const struct vlc_filter_operations NV12_D3D11_ops = {
-    .filter_video = NV12_D3D11_Filter,
+    .filter_video = NV12_D3D11_Filter, .close = D3D11CloseCPUConverter,
 };
 
 int D3D11OpenConverter( vlc_object_t *obj )
@@ -849,14 +859,3 @@ void D3D11CloseConverter( vlc_object_t *obj )
     if (p_sys->staging)
         ID3D11Texture2D_Release(p_sys->staging);
 }
-
-void D3D11CloseCPUConverter( vlc_object_t *obj )
-{
-    filter_t *p_filter = (filter_t *)obj;
-    filter_sys_t *p_sys = p_filter->p_sys;
-    if (p_sys->filter)
-        DeleteFilter(p_sys->filter);
-    if (p_sys->staging_pic)
-        picture_Release(p_sys->staging_pic);
-    vlc_video_context_Release(p_filter->vctx_out);
-}



More information about the vlc-commits mailing list