[vlc-devel] [PATCH v2 04/26] d3d11: use a close callback for locally defined operations

Steve Lhomme robux4 at ycbcr.xyz
Fri Oct 9 15:04:00 CEST 2020


---
 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 3eb8e9bf081..feaea04507a 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 36e3351543e..a8f59e5d4b9 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 71a8dcd178c..555d2b6ba3a 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 44a3c87ac6c..fe20618a696 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);
-}
-- 
2.26.2



More information about the vlc-devel mailing list