[vlc-commits] video_filters: use a typed close callback in the operations structure

Steve Lhomme git at videolan.org
Mon Oct 12 15:56:07 CEST 2020


vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Thu Jan  1 01:00:00 1970 +0100| [f0f50648126077de7280b4e5197e4a6ea2689567] | committer: Steve Lhomme

video_filters: use a typed close callback in the operations structure

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

 modules/hw/d3d11/d3d11_filters.c        | 59 ++++++++++++++--------------
 modules/hw/d3d9/d3d9_filters.c          | 29 +++++++-------
 modules/hw/vaapi/chroma.c               |  7 ++--
 modules/hw/vaapi/filters.c              | 69 ++++++++++++++++-----------------
 modules/hw/vaapi/filters.h              |  2 +-
 modules/hw/vdpau/adjust.c               | 31 +++++++--------
 modules/hw/vdpau/sharpen.c              | 19 +++++----
 modules/spu/audiobargraph_v.c           |  9 ++++-
 modules/spu/logo.c                      |  8 +++-
 modules/video_chroma/chain.c            | 11 +++---
 modules/video_chroma/cvpx.c             | 30 +++++++-------
 modules/video_chroma/swscale.c          |  9 ++---
 modules/video_filter/adjust.c           | 11 +++---
 modules/video_filter/alphamask.c        |  9 ++---
 modules/video_filter/antiflicker.c      |  9 ++---
 modules/video_filter/ball.c             |  9 ++---
 modules/video_filter/blendbench.c       |  9 ++---
 modules/video_filter/bluescreen.c       |  9 ++---
 modules/video_filter/canvas.c           |  9 ++---
 modules/video_filter/ci_filters.m       | 50 ++++++++++++------------
 modules/video_filter/colorthres.c       | 10 ++---
 modules/video_filter/edgedetection.c    |  9 ++---
 modules/video_filter/erase.c            |  9 ++---
 modules/video_filter/extract.c          |  9 ++---
 modules/video_filter/freeze.c           |  8 ++--
 modules/video_filter/gaussianblur.c     |  9 ++---
 modules/video_filter/gradfun.c          |  9 ++---
 modules/video_filter/gradient.c         |  9 ++---
 modules/video_filter/grain.c            |  9 ++---
 modules/video_filter/hqdn3d.c           |  9 ++---
 modules/video_filter/magnify.c          |  8 ++--
 modules/video_filter/mirror.c           |  9 ++---
 modules/video_filter/motionblur.c       |  9 ++---
 modules/video_filter/motiondetect.c     |  9 ++---
 modules/video_filter/oldmovie.c         |  9 ++---
 modules/video_filter/opencv_example.cpp |  8 ++--
 modules/video_filter/opencv_wrapper.c   |  9 ++---
 modules/video_filter/posterize.c        |  9 ++---
 modules/video_filter/postproc.c         |  9 ++---
 modules/video_filter/psychedelic.c      |  9 ++---
 modules/video_filter/puzzle.c           |  8 ++--
 modules/video_filter/rotate.c           | 11 +++---
 modules/video_filter/scene.c            |  9 ++---
 modules/video_filter/sepia.c            | 10 ++---
 modules/video_filter/sharpen.c          |  9 ++---
 modules/video_filter/vhs.c              |  9 ++---
 46 files changed, 301 insertions(+), 331 deletions(-)

diff --git a/modules/hw/d3d11/d3d11_filters.c b/modules/hw/d3d11/d3d11_filters.c
index abd43d7ae1..a887fc131a 100644
--- a/modules/hw/d3d11/d3d11_filters.c
+++ b/modules/hw/d3d11/d3d11_filters.c
@@ -335,8 +335,35 @@ static int AdjustCallback( vlc_object_t *p_this, char const *psz_var,
     return VLC_SUCCESS;
 }
 
+static void D3D11CloseAdjust(filter_t *filter)
+{
+    filter_sys_t *sys = filter->p_sys;
+
+    var_DelCallback( filter, "contrast",   AdjustCallback, sys );
+    var_DelCallback( filter, "brightness", AdjustCallback, sys );
+    var_DelCallback( filter, "hue",        AdjustCallback, sys );
+    var_DelCallback( filter, "saturation", AdjustCallback, sys );
+    var_DelCallback( filter, "gamma",      AdjustCallback, sys );
+    var_DelCallback( filter, "brightness-threshold",
+                                             AdjustCallback, sys );
+
+    for (int i=0; i<PROCESSOR_SLICES; i++)
+    {
+        if (sys->procInput[i])
+            ID3D11VideoProcessorInputView_Release(sys->procInput[i]);
+        if (sys->procOutput[i])
+            ID3D11VideoProcessorOutputView_Release(sys->procOutput[i]);
+    }
+    ID3D11Texture2D_Release(sys->out[0].texture);
+    ID3D11Texture2D_Release(sys->out[1].texture);
+    D3D11_ReleaseProcessor( &sys->d3d_proc );
+    vlc_video_context_Release(filter->vctx_out);
+
+    free(sys);
+}
+
 static const struct vlc_filter_operations filter_ops = {
-    .filter_video = Filter,
+    .filter_video = Filter, .close = D3D11CloseAdjust,
 };
 
 static int D3D11OpenAdjust(vlc_object_t *obj)
@@ -537,40 +564,12 @@ error:
     return VLC_EGENERIC;
 }
 
-static void D3D11CloseAdjust(vlc_object_t *obj)
-{
-    filter_t *filter = (filter_t *)obj;
-    filter_sys_t *sys = filter->p_sys;
-
-    var_DelCallback( filter, "contrast",   AdjustCallback, sys );
-    var_DelCallback( filter, "brightness", AdjustCallback, sys );
-    var_DelCallback( filter, "hue",        AdjustCallback, sys );
-    var_DelCallback( filter, "saturation", AdjustCallback, sys );
-    var_DelCallback( filter, "gamma",      AdjustCallback, sys );
-    var_DelCallback( filter, "brightness-threshold",
-                                             AdjustCallback, sys );
-
-    for (int i=0; i<PROCESSOR_SLICES; i++)
-    {
-        if (sys->procInput[i])
-            ID3D11VideoProcessorInputView_Release(sys->procInput[i]);
-        if (sys->procOutput[i])
-            ID3D11VideoProcessorOutputView_Release(sys->procOutput[i]);
-    }
-    ID3D11Texture2D_Release(sys->out[0].texture);
-    ID3D11Texture2D_Release(sys->out[1].texture);
-    D3D11_ReleaseProcessor( &sys->d3d_proc );
-    vlc_video_context_Release(filter->vctx_out);
-
-    free(sys);
-}
-
 vlc_module_begin()
     set_description(N_("Direct3D11 adjust filter"))
     set_capability("video filter", 0)
     set_category( CAT_VIDEO )
     set_subcategory( SUBCAT_VIDEO_VFILTER )
-    set_callbacks(D3D11OpenAdjust, D3D11CloseAdjust)
+    set_callback(D3D11OpenAdjust)
     add_shortcut( "adjust" )
 
     add_float_with_range( "contrast", 1.0, 0.0, 2.0,
diff --git a/modules/hw/d3d9/d3d9_filters.c b/modules/hw/d3d9/d3d9_filters.c
index 7c36d3e3ad..8f211a3e2c 100644
--- a/modules/hw/d3d9/d3d9_filters.c
+++ b/modules/hw/d3d9/d3d9_filters.c
@@ -259,8 +259,20 @@ static int AdjustCallback( vlc_object_t *p_this, char const *psz_var,
     return VLC_SUCCESS;
 }
 
+static void D3D9CloseAdjust(filter_t *filter)
+{
+    filter_sys_t *sys = filter->p_sys;
+
+    IDirect3DSurface9_Release( sys->hw_surface );
+    IDirectXVideoProcessor_Release( sys->processor );
+    FreeLibrary( sys->hdecoder_dll );
+    vlc_video_context_Release(filter->vctx_out);
+
+    free(sys);
+}
+
 static const struct vlc_filter_operations filter_ops = {
-    .filter_video = Filter,
+    .filter_video = Filter, .close = D3D9CloseAdjust,
 };
 
 static int D3D9OpenAdjust(vlc_object_t *obj)
@@ -472,25 +484,12 @@ error:
     return VLC_EGENERIC;
 }
 
-static void D3D9CloseAdjust(vlc_object_t *obj)
-{
-    filter_t *filter = (filter_t *)obj;
-    filter_sys_t *sys = filter->p_sys;
-
-    IDirect3DSurface9_Release( sys->hw_surface );
-    IDirectXVideoProcessor_Release( sys->processor );
-    FreeLibrary( sys->hdecoder_dll );
-    vlc_video_context_Release(filter->vctx_out);
-
-    free(sys);
-}
-
 vlc_module_begin()
     set_description(N_("Direct3D9 adjust filter"))
     set_capability("video filter", 0)
     set_category(CAT_VIDEO)
     set_subcategory(SUBCAT_VIDEO_VFILTER)
-    set_callbacks(D3D9OpenAdjust, D3D9CloseAdjust)
+    set_callback(D3D9OpenAdjust)
     add_shortcut( "adjust" )
 
     add_float_with_range( "contrast", 1.0, 0.0, 2.0,
diff --git a/modules/hw/vaapi/chroma.c b/modules/hw/vaapi/chroma.c
index 7ea95254d4..dfd573ef1e 100644
--- a/modules/hw/vaapi/chroma.c
+++ b/modules/hw/vaapi/chroma.c
@@ -317,11 +317,11 @@ static int CheckFmt(const video_format_t *in, const video_format_t *out,
 }
 
 static const struct vlc_filter_operations filter_upload_ops = {
-    .filter_video = UploadSurface,
+    .filter_video = UploadSurface,   .close = vlc_vaapi_CloseChroma,
 };
 
 static const struct vlc_filter_operations filter_download_ops = {
-    .filter_video = DownloadSurface,
+    .filter_video = DownloadSurface, .close = vlc_vaapi_CloseChroma,
 };
 
 int
@@ -413,9 +413,8 @@ vlc_vaapi_OpenChroma(vlc_object_t *obj)
 }
 
 void
-vlc_vaapi_CloseChroma(vlc_object_t *obj)
+vlc_vaapi_CloseChroma(filter_t *filter)
 {
-    filter_t *filter = (filter_t *)obj;
     filter_sys_t *const filter_sys = filter->p_sys;
 
     if (filter_sys->dest_pics)
diff --git a/modules/hw/vaapi/filters.c b/modules/hw/vaapi/filters.c
index 8337081f42..f75ca6d330 100644
--- a/modules/hw/vaapi/filters.c
+++ b/modules/hw/vaapi/filters.c
@@ -567,8 +567,23 @@ OpenAdjust_InitFilterParams(filter_t * filter, void * p_data,
     return VLC_SUCCESS;
 }
 
+static void
+CloseAdjust(filter_t *filter)
+{
+    filter_sys_t *const filter_sys = filter->p_sys;
+
+    for (unsigned int i = 0; i < NUM_ADJUST_MODES; ++i)
+    {
+        var_DelCallback(filter, adjust_params_names[i],
+                        FilterCallback, filter_sys->p_data);
+        var_Destroy(filter, adjust_params_names[i]);
+    }
+    free(filter_sys->p_data);
+    Close(filter, filter_sys);
+}
+
 static const struct vlc_filter_operations Adjust_ops = {
-    .filter_video = Adjust,
+    .filter_video = Adjust, .close = CloseAdjust,
 };
 
 static int
@@ -602,22 +617,6 @@ error:
     return VLC_EGENERIC;
 }
 
-static void
-CloseAdjust(vlc_object_t * obj)
-{
-    filter_t *const     filter = (filter_t *)obj;
-    filter_sys_t *const filter_sys = filter->p_sys;
-
-    for (unsigned int i = 0; i < NUM_ADJUST_MODES; ++i)
-    {
-        var_DelCallback(obj, adjust_params_names[i],
-                        FilterCallback, filter_sys->p_data);
-        var_Destroy(obj, adjust_params_names[i]);
-    }
-    free(filter_sys->p_data);
-    Close(filter, filter_sys);
-}
-
 /***************************
  * Basic filters functions *
  ***************************/
@@ -688,8 +687,20 @@ OpenBasicFilter_InitFilterParams(filter_t * filter, void * p_data,
     return VLC_SUCCESS;
 }
 
+static void
+CloseBasicFilter(filter_t *filter)
+{
+    filter_sys_t *const                 filter_sys = filter->p_sys;
+    struct basic_filter_data *const     p_data = filter_sys->p_data;
+
+    var_DelCallback(filter, p_data->sigma.psz_name, FilterCallback, p_data);
+    var_Destroy(filter, p_data->sigma.psz_name);
+    free(p_data);
+    Close(filter, filter_sys);
+}
+
 static const struct vlc_filter_operations BasicFilter_ops = {
-    .filter_video = BasicFilter,
+    .filter_video = BasicFilter, .close = CloseBasicFilter
 };
 
 static int
@@ -740,19 +751,6 @@ OpenSharpenFilter(vlc_object_t * obj)
                            &vlc_sharpen_sigma_range);
 }
 
-static void
-CloseBasicFilter(vlc_object_t * obj)
-{
-    filter_t *const                     filter = (filter_t *)obj;
-    filter_sys_t *const                 filter_sys = filter->p_sys;
-    struct basic_filter_data *const     p_data = filter_sys->p_data;
-
-    var_DelCallback(obj, p_data->sigma.psz_name, FilterCallback, p_data);
-    var_Destroy(obj, p_data->sigma.psz_name);
-    free(p_data);
-    Close(filter, filter_sys);
-}
-
 /*************************
  * Deinterlace functions *
  *************************/
@@ -1144,7 +1142,7 @@ vlc_module_begin()
     set_capability("video filter", 0)
 
     add_submodule()
-    set_callbacks(OpenAdjust, CloseAdjust)
+    set_callback(OpenAdjust)
     add_shortcut("adjust")
 
     add_submodule()
@@ -1152,7 +1150,7 @@ vlc_module_begin()
     add_shortcut("deinterlace")
 
     add_submodule()
-    set_callbacks(OpenDenoiseFilter, CloseBasicFilter)
+    set_callback(OpenDenoiseFilter)
     add_float_with_range("denoise-sigma", 1.f, .0f, .0f,
                          "Denoise strength (0-2)",
                          "Set the Denoise strength, between 0 and 2. "
@@ -1161,10 +1159,9 @@ vlc_module_begin()
     add_shortcut("denoise")
 
     add_submodule()
-    set_callbacks(OpenSharpenFilter, CloseBasicFilter)
+    set_callback(OpenSharpenFilter)
     add_shortcut("sharpen")
 
     add_submodule()
-    set_capability("video converter", 10)
-    set_callbacks(vlc_vaapi_OpenChroma, vlc_vaapi_CloseChroma)
+    set_video_converter_callback(vlc_vaapi_OpenChroma, 10)
 vlc_module_end()
diff --git a/modules/hw/vaapi/filters.h b/modules/hw/vaapi/filters.h
index aafb1383f4..83a51811cf 100644
--- a/modules/hw/vaapi/filters.h
+++ b/modules/hw/vaapi/filters.h
@@ -29,6 +29,6 @@
 
 /* chroma filters callbacks */
 int  vlc_vaapi_OpenChroma(vlc_object_t *obj);
-void vlc_vaapi_CloseChroma(vlc_object_t *obj);
+void vlc_vaapi_CloseChroma(filter_t *);
 
 #endif /* VLC_VAAPI_FILTERS_H */
diff --git a/modules/hw/vdpau/adjust.c b/modules/hw/vdpau/adjust.c
index 3a4d5a5387..7552bfc4e3 100644
--- a/modules/hw/vdpau/adjust.c
+++ b/modules/hw/vdpau/adjust.c
@@ -135,12 +135,25 @@ static picture_t *Adjust(filter_t *filter, picture_t *pic)
     return pic;
 }
 
+static void Close(filter_t *filter)
+{
+    filter_sys_t *sys = filter->p_sys;
+
+    var_DelCallback(filter, "hue", HueCallback, &sys->hue);
+    var_DelCallback(filter, "saturation", SaturationCallback,
+                    &sys->saturation);
+    var_DelCallback(filter, "contrast", ContrastCallback, &sys->contrast);
+    var_DelCallback(filter, "brightness", BrightnessCallback,
+                    &sys->brightness);
+    free(sys);
+}
+
 static const char *const options[] = {
     "brightness", "contrast", "saturation", "hue", NULL
 };
 
 static const struct vlc_filter_operations filter_ops = {
-    .filter_video = Adjust,
+    .filter_video = Adjust, .close = Close,
 };
 
 static int Open(vlc_object_t *obj)
@@ -190,25 +203,11 @@ static int Open(vlc_object_t *obj)
     return VLC_SUCCESS;
 }
 
-static void Close(vlc_object_t *obj)
-{
-    filter_t *filter = (filter_t *)obj;
-    filter_sys_t *sys = filter->p_sys;
-
-    var_DelCallback(filter, "hue", HueCallback, &sys->hue);
-    var_DelCallback(filter, "saturation", SaturationCallback,
-                    &sys->saturation);
-    var_DelCallback(filter, "contrast", ContrastCallback, &sys->contrast);
-    var_DelCallback(filter, "brightness", BrightnessCallback,
-                    &sys->brightness);
-    free(sys);
-}
-
 vlc_module_begin()
     set_description(N_("VDPAU adjust video filter"))
     set_category(CAT_VIDEO)
     set_subcategory(SUBCAT_VIDEO_VFILTER)
     set_capability("video filter", 0)
     add_shortcut("adjust")
-    set_callbacks(Open, Close)
+    set_callback(Open)
 vlc_module_end()
diff --git a/modules/hw/vdpau/sharpen.c b/modules/hw/vdpau/sharpen.c
index 718eedddb1..e02efd86ca 100644
--- a/modules/hw/vdpau/sharpen.c
+++ b/modules/hw/vdpau/sharpen.c
@@ -77,10 +77,18 @@ static picture_t *Sharpen(filter_t *filter, picture_t *pic)
     return pic;
 }
 
+static void Close(filter_t *filter)
+{
+    filter_sys_t *sys = filter->p_sys;
+
+    var_DelCallback(filter, "sharpen-sigma", SharpenCallback, sys);
+    free(sys);
+}
+
 static const char *const options[] = { "sigma", NULL };
 
 static const struct vlc_filter_operations filter_ops = {
-    .filter_video = Sharpen,
+    .filter_video = Sharpen, .close = Close,
 };
 
 static int Open(vlc_object_t *obj)
@@ -142,15 +150,6 @@ static int Open(vlc_object_t *obj)
     return VLC_SUCCESS;
 }
 
-static void Close(vlc_object_t *obj)
-{
-    filter_t *filter = (filter_t *)obj;
-    filter_sys_t *sys = filter->p_sys;
-
-    var_DelCallback(filter, "sharpen-sigma", SharpenCallback, sys);
-    free(sys);
-}
-
 vlc_module_begin()
     set_description(N_("VDPAU sharpen video filter"))
     set_category(CAT_VIDEO)
diff --git a/modules/spu/audiobargraph_v.c b/modules/spu/audiobargraph_v.c
index 9fdc78c7e4..1f7225bbe8 100644
--- a/modules/spu/audiobargraph_v.c
+++ b/modules/spu/audiobargraph_v.c
@@ -94,7 +94,7 @@ vlc_module_begin ()
     /* video output filter submodule */
     add_submodule ()
     set_capability("video filter", 0)
-    set_callbacks(OpenVideo, Close)
+    set_callback(OpenVideo)
     set_description(N_("Audio Bar Graph Video sub source"))
     add_shortcut("audiobargraph_v")
 vlc_module_end ()
@@ -491,8 +491,13 @@ static const struct vlc_filter_operations filter_sub_ops = {
     .source_sub = FilterSub,
 };
 
+static void CloseVideo( filter_t *p_filter )
+{
+    Close( VLC_OBJECT(p_filter) );
+}
+
 static const struct vlc_filter_operations filter_video_ops = {
-    .filter_video = FilterVideo,
+    .filter_video = FilterVideo, .close = CloseVideo,
 };
 
 /**
diff --git a/modules/spu/logo.c b/modules/spu/logo.c
index 9a713cb240..f4b3d23ab2 100644
--- a/modules/spu/logo.c
+++ b/modules/spu/logo.c
@@ -107,7 +107,7 @@ vlc_module_begin ()
     /* video output filter submodule */
     add_submodule ()
     set_capability( "video filter", 0 )
-    set_callbacks( OpenVideo, Close )
+    set_callback( OpenVideo )
     set_description( N_("Logo video filter") )
     add_shortcut( "logo" )
 vlc_module_end ()
@@ -219,9 +219,15 @@ static const struct vlc_filter_operations filter_sub_ops = {
     .source_sub = FilterSub,
 };
 
+static void CloseVideo( filter_t *p_filter )
+{
+    Close( VLC_OBJECT(p_filter) );
+}
+
 static const struct vlc_filter_operations filter_video_ops = {
     .filter_video = FilterVideo,
     .video_mouse = Mouse,
+    .close = CloseVideo,
 };
 
 /**
diff --git a/modules/video_chroma/chain.c b/modules/video_chroma/chain.c
index 630526016d..f303b98795 100644
--- a/modules/video_chroma/chain.c
+++ b/modules/video_chroma/chain.c
@@ -39,15 +39,15 @@
  *****************************************************************************/
 static int       ActivateConverter  ( vlc_object_t * );
 static int       ActivateFilter     ( vlc_object_t * );
-static void      Destroy            ( vlc_object_t * );
+static void      Destroy            ( filter_t * );
 
 vlc_module_begin ()
     set_description( N_("Video filtering using a chain of video filter modules") )
     set_capability( "video converter", 1 )
-    set_callbacks( ActivateConverter, Destroy )
+    set_callback( ActivateConverter )
     add_submodule ()
         set_capability( "video filter", 0 )
-        set_callbacks( ActivateFilter, Destroy )
+        set_callback( ActivateFilter )
 vlc_module_end ()
 
 /*****************************************************************************
@@ -155,7 +155,7 @@ static const struct filter_video_callbacks filter_video_chain_cbs =
 };
 
 static const struct vlc_filter_operations filter_ops = {
-    .filter_video = Chain, .flush = Flush,
+    .filter_video = Chain, .flush = Flush, .close = Destroy,
 };
 
 /*****************************************************************************
@@ -259,9 +259,8 @@ static int ActivateFilter( vlc_object_t *p_this )
     return i_ret;
 }
 
-static void Destroy( vlc_object_t *p_this )
+static void Destroy( filter_t *p_filter )
 {
-    filter_t *p_filter = (filter_t *)p_this;
     filter_sys_t *p_sys = p_filter->p_sys;
 
     if (p_sys->p_video_filter)
diff --git a/modules/video_chroma/cvpx.c b/modules/video_chroma/cvpx.c
index 062b1ef0f9..f6a929df43 100644
--- a/modules/video_chroma/cvpx.c
+++ b/modules/video_chroma/cvpx.c
@@ -38,14 +38,14 @@
 #include "../video_chroma/copy.h"
 
 static int Open(vlc_object_t *);
-static void Close(vlc_object_t *);
+static void Close(filter_t *);
 
 #if !TARGET_OS_IPHONE
 static int Open_CVPX_to_CVPX(vlc_object_t *);
-static void Close_CVPX_to_CVPX(vlc_object_t *);
+static void Close_CVPX_to_CVPX(filter_t *);
 
 static int Open_chain_CVPX(vlc_object_t *);
-static void Close_chain_CVPX(vlc_object_t *);
+static void Close_chain_CVPX(filter_t *);
 #endif
 
 typedef struct
@@ -67,16 +67,16 @@ typedef struct
 vlc_module_begin ()
     set_description("Conversions from/to CoreVideo buffers")
     set_capability("video converter", 10)
-    set_callbacks(Open, Close)
+    set_callback(Open)
 #if !TARGET_OS_IPHONE
     add_submodule()
     set_description("Conversions between CoreVideo buffers")
-    set_callbacks(Open_CVPX_to_CVPX, Close_CVPX_to_CVPX)
+    set_callback(Open_CVPX_to_CVPX)
     set_capability("video converter", 10)
 
     add_submodule()
     set_description("Fast CoreVideo resize+conversion")
-    set_callbacks(Open_chain_CVPX, Close_chain_CVPX)
+    set_callback(Open_chain_CVPX)
     set_capability("video converter", 11)
 #endif
 vlc_module_end ()
@@ -234,9 +234,8 @@ static picture_t *SW_TO_CVPX_Filter(filter_t *p_filter, picture_t *src)
     return dst;
 }
 
-static void Close(vlc_object_t *obj)
+static void Close(filter_t *p_filter)
 {
-    filter_t *p_filter = (filter_t *)obj;
     filter_sys_t *p_sys = p_filter->p_sys;
 
     if (p_sys->pool != NULL)
@@ -249,10 +248,10 @@ static void Close(vlc_object_t *obj)
 }
 
 static const struct vlc_filter_operations CVPX_TO_SW_ops = {
-    .filter_video = CVPX_TO_SW_Filter,
+    .filter_video = CVPX_TO_SW_Filter, .close = Close,
 };
 static const struct vlc_filter_operations SW_TO_CVPX_ops = {
-    .filter_video = SW_TO_CVPX_Filter,
+    .filter_video = SW_TO_CVPX_Filter, .close = Close,
 };
 
 static int Open(vlc_object_t *obj)
@@ -377,7 +376,7 @@ static int Open(vlc_object_t *obj)
     p_filter->fmt_out.i_codec = p_filter->fmt_out.video.i_chroma;
     return VLC_SUCCESS;
 error:
-    Close(obj);
+    Close(filter);
     p_filter->p_sys = NULL;
 
     assert(ret != VLC_SUCCESS);
@@ -440,7 +439,7 @@ static vlc_fourcc_t const supported_chromas[] = { VLC_CODEC_CVPX_BGRA,
                                                   VLC_CODEC_CVPX_UYVY };
 
 static const struct vlc_filter_operations filter_ops = {
-    .filter_video = Filter,
+    .filter_video = Filter, .close = Close_CVPX_to_CVPX,
 };
 
 static int
@@ -498,9 +497,8 @@ Open_CVPX_to_CVPX(vlc_object_t *obj)
 }
 
 static void
-Close_CVPX_to_CVPX(vlc_object_t *obj)
+Close_CVPX_to_CVPX(filter_t *filter)
 {
-    filter_t *filter = (filter_t *)obj;
     filter_sys_t *p_sys = filter->p_sys;
 
     VTPixelTransferSessionInvalidate(p_sys->vttransfer);
@@ -566,6 +564,7 @@ static const vlc_fourcc_t supported_sw_chromas[] = {
 
 static const struct vlc_filter_operations chain_CVPX_ops = {
     .filter_video = chain_CVPX_Filter, .flush = chain_CVPX_Flush,
+    .close = Close_chain_CVPX,
 };
 
 static int
@@ -686,9 +685,8 @@ error:
 }
 
 static void
-Close_chain_CVPX(vlc_object_t *obj)
+Close_chain_CVPX(filter_t *filter)
 {
-    filter_t *filter = (filter_t*)obj;
     filter_chain_t *chain = filter->p_sys;
     filter_chain_Delete(chain);
     var_Destroy(filter, "cvpx-chroma-chain");
diff --git a/modules/video_chroma/swscale.c b/modules/video_chroma/swscale.c
index b96dde00dc..6f623cde48 100644
--- a/modules/video_chroma/swscale.c
+++ b/modules/video_chroma/swscale.c
@@ -52,7 +52,7 @@
  * Module descriptor
  *****************************************************************************/
 static int  OpenScaler( vlc_object_t * );
-static void CloseScaler( vlc_object_t * );
+static void CloseScaler( filter_t * );
 
 #define SCALEMODE_TEXT N_("Scaling mode")
 #define SCALEMODE_LONGTEXT N_("Scaling mode to use.")
@@ -70,7 +70,7 @@ vlc_module_begin ()
     set_capability( "video converter", 150 )
     set_category( CAT_VIDEO )
     set_subcategory( SUBCAT_VIDEO_VFILTER )
-    set_callbacks( OpenScaler, CloseScaler )
+    set_callback( OpenScaler )
     add_integer( "swscale-mode", 2, SCALEMODE_TEXT, SCALEMODE_LONGTEXT, true )
         change_integer_list( pi_mode_values, ppsz_mode_descriptions )
 vlc_module_end ()
@@ -139,7 +139,7 @@ static int GetSwsCpuMask(void);
 #define OFFSET_A (3)
 
 static const struct vlc_filter_operations filter_ops = {
-    .filter_video = Filter,
+    .filter_video = Filter, .close = CloseScaler,
 };
 
 /*****************************************************************************
@@ -212,9 +212,8 @@ static int OpenScaler( vlc_object_t *p_this )
 /*****************************************************************************
  * CloseFilter: clean up the filter
  *****************************************************************************/
-static void CloseScaler( vlc_object_t *p_this )
+static void CloseScaler( filter_t *p_filter )
 {
-    filter_t *p_filter = (filter_t*)p_this;
     filter_sys_t *p_sys = p_filter->p_sys;
 
     Clean( p_filter );
diff --git a/modules/video_filter/adjust.c b/modules/video_filter/adjust.c
index 9ce531b1fa..8218ddcc48 100644
--- a/modules/video_filter/adjust.c
+++ b/modules/video_filter/adjust.c
@@ -45,7 +45,7 @@
  * Local prototypes
  *****************************************************************************/
 static int  Create    ( vlc_object_t * );
-static void Destroy   ( vlc_object_t * );
+static void Destroy   ( filter_t * );
 
 static void FilterPlanar( filter_t *, picture_t *, picture_t * );
 static picture_t *FilterPacked( filter_t *, picture_t * );
@@ -96,7 +96,7 @@ vlc_module_begin ()
         change_safe()
 
     add_shortcut( "adjust" )
-    set_callbacks( Create, Destroy )
+    set_callback( Create )
 vlc_module_end ()
 
 static const char *const ppsz_filter_options[] = {
@@ -141,11 +141,11 @@ static int BoolCallback( vlc_object_t *obj, char const *varname,
     return VLC_SUCCESS;
 }
 
-VIDEO_FILTER_WRAPPER( FilterPlanar )
+VIDEO_FILTER_WRAPPER_CLOSE( FilterPlanar, Destroy )
 
 static const struct vlc_filter_operations packed_filter_ops =
 {
-    .filter_video = FilterPacked,
+    .filter_video = FilterPacked, .close = Destroy,
 };
 
 /*****************************************************************************
@@ -231,9 +231,8 @@ static int Create( vlc_object_t *p_this )
 /*****************************************************************************
  * Destroy: destroy adjust video filter
  *****************************************************************************/
-static void Destroy( vlc_object_t *p_this )
+static void Destroy( filter_t *p_filter )
 {
-    filter_t *p_filter = (filter_t *)p_this;
     filter_sys_t *p_sys = p_filter->p_sys;
 
     var_DelCallback( p_filter, "contrast", FloatCallback, &p_sys->f_contrast );
diff --git a/modules/video_filter/alphamask.c b/modules/video_filter/alphamask.c
index 9b894f9f76..2793f634f5 100644
--- a/modules/video_filter/alphamask.c
+++ b/modules/video_filter/alphamask.c
@@ -49,7 +49,7 @@
  * Local prototypes
  *****************************************************************************/
 static int  Create      ( vlc_object_t * );
-static void Destroy     ( vlc_object_t * );
+static void Destroy     ( filter_t * );
 
 static picture_t *Filter( filter_t *, picture_t * );
 static void LoadMask( filter_t *, const char * );
@@ -67,7 +67,7 @@ vlc_module_begin ()
     set_subcategory( SUBCAT_VIDEO_VFILTER )
     set_capability( "video filter", 0 )
     add_shortcut( "alphamask", "mask" )
-    set_callbacks( Create, Destroy )
+    set_callback( Create )
 
     add_loadfile(CFG_PREFIX "mask", NULL, MASK_TEXT, MASK_LONGTEXT)
 vlc_module_end ()
@@ -84,7 +84,7 @@ typedef struct
 
 static const struct vlc_filter_operations filter_ops =
 {
-    .filter_video = Filter,
+    .filter_video = Filter, .close = Destroy,
 };
 
 static int Create( vlc_object_t *p_this )
@@ -132,9 +132,8 @@ static int Create( vlc_object_t *p_this )
     return VLC_SUCCESS;
 }
 
-static void Destroy( vlc_object_t *p_this )
+static void Destroy( filter_t *p_filter )
 {
-    filter_t *p_filter = (filter_t *)p_this;
     filter_sys_t *p_sys = p_filter->p_sys;
 
     var_DelCallback( p_filter, CFG_PREFIX "mask", MaskCallback,
diff --git a/modules/video_filter/antiflicker.c b/modules/video_filter/antiflicker.c
index f469e1d22a..b43cda21c2 100644
--- a/modules/video_filter/antiflicker.c
+++ b/modules/video_filter/antiflicker.c
@@ -46,8 +46,8 @@ static int AntiFlickerCallback( vlc_object_t *p_this, char const *psz_var,
                            void *p_data );
 
 static int  Create    ( vlc_object_t * );
-static void Destroy   ( vlc_object_t * );
-VIDEO_FILTER_WRAPPER( Filter )
+static void Destroy   ( filter_t * );
+VIDEO_FILTER_WRAPPER_CLOSE( Filter, Destroy )
 
 #define WINDOW_TEXT N_("Window size")
 #define WINDOW_LONGTEXT N_("Number of frames (0 to 100)")
@@ -78,7 +78,7 @@ vlc_module_begin ()
         SFTN_TEXT, SFTN_LONGTEXT, false )
 
     add_shortcut( "antiflicker" )
-    set_callbacks( Create, Destroy )
+    set_callback( Create )
 vlc_module_end ()
 
 /*****************************************************************************
@@ -158,9 +158,8 @@ static int Create( vlc_object_t *p_this )
  *****************************************************************************
  * Terminate an output method created by DistortCreateOutputMethod
  *****************************************************************************/
-static void Destroy( vlc_object_t *p_this )
+static void Destroy( filter_t *p_filter )
 {
-    filter_t *p_filter = (filter_t *)p_this;
     filter_sys_t *p_sys = p_filter->p_sys;
 
     var_DelCallback(p_filter,FILTER_PREFIX "window-size",
diff --git a/modules/video_filter/ball.c b/modules/video_filter/ball.c
index 3e5df31b24..a1429423a1 100644
--- a/modules/video_filter/ball.c
+++ b/modules/video_filter/ball.c
@@ -73,10 +73,10 @@ enum { RED, GREEN, BLUE, WHITE };
 typedef struct filter_sys_t filter_sys_t;
 
 static int  Create    ( vlc_object_t * );
-static void Destroy   ( vlc_object_t * );
+static void Destroy   ( filter_t * );
 
 static void Filter( filter_t *, picture_t *, picture_t * );
-VIDEO_FILTER_WRAPPER( Filter )
+VIDEO_FILTER_WRAPPER_CLOSE( Filter, Destroy )
 
 static void drawBall( filter_sys_t *p_sys, picture_t *p_outpic );
 static void drawPixelRGB24( filter_sys_t *p_sys, picture_t *p_outpic,
@@ -148,7 +148,7 @@ vlc_module_begin ()
               EDGE_VISIBLE_TEXT, EDGE_VISIBLE_LONGTEXT, true )
 
     add_shortcut( "ball" )
-    set_callbacks( Create, Destroy )
+    set_callback( Create )
 vlc_module_end ()
 
 static const char *const ppsz_filter_options[] = {
@@ -318,9 +318,8 @@ static int Create( vlc_object_t *p_this )
 *****************************************************************************
 * Terminate an output method created by DistortCreateOutputMethod
  *****************************************************************************/
-static void Destroy( vlc_object_t *p_this )
+static void Destroy( filter_t *p_filter)
 {
-    filter_t *p_filter = (filter_t *)p_this;
     filter_sys_t *p_sys = p_filter->p_sys;
 
     var_DelCallback( p_filter, FILTER_PREFIX "color",
diff --git a/modules/video_filter/blendbench.c b/modules/video_filter/blendbench.c
index 1787620447..0e432b1036 100644
--- a/modules/video_filter/blendbench.c
+++ b/modules/video_filter/blendbench.c
@@ -41,7 +41,7 @@
  * Local prototypes
  *****************************************************************************/
 static int Create( vlc_object_t * );
-static void Destroy( vlc_object_t * );
+static void Destroy( filter_t * );
 
 static picture_t *Filter( filter_t *, picture_t * );
 
@@ -95,7 +95,7 @@ vlc_module_begin ()
     add_string( CFG_PREFIX "blend-chroma", "YUVA", BLEND_CHROMA_TEXT,
               BLEND_CHROMA_LONGTEXT, false )
 
-    set_callbacks( Create, Destroy )
+    set_callback( Create )
 vlc_module_end ()
 
 static const char *const ppsz_filter_options[] = {
@@ -146,7 +146,7 @@ static int blendbench_LoadImage( vlc_object_t *p_this, picture_t **pp_pic,
 
 static const struct vlc_filter_operations filter_ops =
 {
-    .filter_video = Filter,
+    .filter_video = Filter, .close = Destroy,
 };
 
 /*****************************************************************************
@@ -218,9 +218,8 @@ static int Create( vlc_object_t *p_this )
 /*****************************************************************************
  * Destroy: destroy video thread output method
  *****************************************************************************/
-static void Destroy( vlc_object_t *p_this )
+static void Destroy( filter_t *p_filter )
 {
-    filter_t *p_filter = (filter_t *)p_this;
     filter_sys_t *p_sys = p_filter->p_sys;
 
     picture_Release( p_sys->p_base_image );
diff --git a/modules/video_filter/bluescreen.c b/modules/video_filter/bluescreen.c
index d624ddf2df..94807ce45c 100644
--- a/modules/video_filter/bluescreen.c
+++ b/modules/video_filter/bluescreen.c
@@ -64,7 +64,7 @@
  * Local prototypes
  *****************************************************************************/
 static int  Create      ( vlc_object_t * );
-static void Destroy     ( vlc_object_t * );
+static void Destroy     ( filter_t * );
 
 static picture_t *Filter( filter_t *, picture_t * );
 static int BluescreenCallback( vlc_object_t *, char const *,
@@ -81,7 +81,7 @@ vlc_module_begin ()
     set_subcategory( SUBCAT_VIDEO_VFILTER )
     set_capability( "video filter", 0 )
     add_shortcut( "bluescreen" )
-    set_callbacks( Create, Destroy )
+    set_callback( Create )
 
     add_integer_with_range( CFG_PREFIX "u", 120, 0, 255,
                             BLUESCREENU_TEXT, BLUESCREENU_LONGTEXT, false )
@@ -108,7 +108,7 @@ typedef struct
 
 static const struct vlc_filter_operations filter_ops =
 {
-    .filter_video = Filter,
+    .filter_video = Filter, .close = Destroy,
 };
 
 static int Create( vlc_object_t *p_this )
@@ -153,9 +153,8 @@ static int Create( vlc_object_t *p_this )
     return VLC_SUCCESS;
 }
 
-static void Destroy( vlc_object_t *p_this )
+static void Destroy( filter_t *p_filter )
 {
-    filter_t *p_filter = (filter_t *)p_this;
     filter_sys_t *p_sys = p_filter->p_sys;
 
     var_DelCallback( p_filter, CFG_PREFIX "u", BluescreenCallback, p_sys );
diff --git a/modules/video_filter/canvas.c b/modules/video_filter/canvas.c
index 18a0c065cd..c1afb71c76 100644
--- a/modules/video_filter/canvas.c
+++ b/modules/video_filter/canvas.c
@@ -39,7 +39,7 @@
  * Local and extern prototypes.
  *****************************************************************************/
 static int  Activate( vlc_object_t * );
-static void Destroy( vlc_object_t * );
+static void Destroy( filter_t * );
 static picture_t *Filter( filter_t *, picture_t * );
 static void Flush( filter_t * );
 
@@ -106,7 +106,7 @@ vlc_module_begin ()
     set_description( N_("Canvas video filter") )
     set_capability( "video filter", 0 )
     set_help( CANVAS_HELP )
-    set_callbacks( Activate, Destroy )
+    set_callback( Activate )
 
     set_category( CAT_VIDEO )
     set_subcategory( SUBCAT_VIDEO_VFILTER )
@@ -147,7 +147,7 @@ static const struct filter_video_callbacks canvas_cbs =
 
 static const struct vlc_filter_operations filter_ops =
 {
-    .filter_video = Filter, .flush = Flush,
+    .filter_video = Filter, .flush = Flush, .close = Destroy,
 };
 
 /*****************************************************************************
@@ -387,9 +387,8 @@ static int Activate( vlc_object_t *p_this )
 /*****************************************************************************
  *
  *****************************************************************************/
-static void Destroy( vlc_object_t *p_this )
+static void Destroy( filter_t *p_filter )
 {
-    filter_t *p_filter = (filter_t *)p_this;
     filter_sys_t *p_sys = p_filter->p_sys;
     filter_chain_Delete( p_sys->p_chain );
     free( p_sys );
diff --git a/modules/video_filter/ci_filters.m b/modules/video_filter/ci_filters.m
index 1b0d0f41b3..ee56ef33b3 100644
--- a/modules/video_filter/ci_filters.m
+++ b/modules/video_filter/ci_filters.m
@@ -572,10 +572,28 @@ CVPX_to_CVPX_converter_Create(filter_t *filter, bool to_rgba)
     return converter;
 }
 
+static void
+Close(filter_t *filter)
+{
+    filter_sys_t *p_sys = filter->p_sys;
+    struct ci_filters_ctx *ctx = p_sys->ctx;
+    enum filter_type filter_types[NUM_MAX_EQUIVALENT_VLC_FILTERS];
+
+    filter_desc_table_GetFilterTypes(p_sys->psz_filter, filter_types);
+    for (unsigned int i = 0;
+         i < NUM_MAX_EQUIVALENT_VLC_FILTERS && filter_types[i] != FILTER_NONE;
+         ++i)
+        filter_chain_RemoveFilter(&ctx->fchain, filter_types[i]);
+
+    vlc_video_context_Release(filter->vctx_out);
+    free(p_sys);
+}
+
 static const struct vlc_filter_operations filter_ops =
 {
     .filter_video = Filter,
     .video_mouse = Mouse,
+    .close = Close,
 };
 
 static int
@@ -740,24 +758,6 @@ OpenCustom(vlc_object_t *obj)
     return Open(obj, "custom");
 }
 
-static void
-Close(vlc_object_t *obj)
-{
-    filter_t *filter = (filter_t *)obj;
-    filter_sys_t *p_sys = filter->p_sys;
-    struct ci_filters_ctx *ctx = p_sys->ctx;
-    enum filter_type filter_types[NUM_MAX_EQUIVALENT_VLC_FILTERS];
-
-    filter_desc_table_GetFilterTypes(p_sys->psz_filter, filter_types);
-    for (unsigned int i = 0;
-         i < NUM_MAX_EQUIVALENT_VLC_FILTERS && filter_types[i] != FILTER_NONE;
-         ++i)
-        filter_chain_RemoveFilter(&ctx->fchain, filter_types[i]);
-
-    vlc_video_context_Release(filter->vctx_out);
-    free(p_sys);
-}
-
 #define CI_CUSTOM_FILTER_TEXT N_("Use a specific Core Image Filter")
 #define CI_CUSTOM_FILTER_LONGTEXT N_( \
     "Example: 'CICrystallize', 'CIBumpDistortion', 'CIThermal', 'CIComicEffect'")
@@ -769,31 +769,31 @@ vlc_module_begin()
     set_description(N_("Mac OS X hardware video filters"))
 
     add_submodule()
-    set_callbacks(OpenAdjust, Close)
+    set_callback(OpenAdjust)
     add_shortcut("adjust")
 
     add_submodule()
-    set_callbacks(OpenInvert, Close)
+    set_callback(OpenInvert)
     add_shortcut("invert")
 
     add_submodule()
-    set_callbacks(OpenPosterize, Close)
+    set_callback(OpenPosterize)
     add_shortcut("posterize")
 
     add_submodule()
-    set_callbacks(OpenSepia, Close)
+    set_callback(OpenSepia)
     add_shortcut("sepia")
 
     add_submodule()
-    set_callbacks(OpenSharpen, Close)
+    set_callback(OpenSharpen)
     add_shortcut("sharpen")
 
     add_submodule()
-    set_callbacks(OpenPsychedelic, Close)
+    set_callback(OpenPsychedelic)
     add_shortcut("psychedelic")
 
     add_submodule()
-    set_callbacks(OpenCustom, Close)
+    set_callback(OpenCustom)
     add_shortcut("ci")
     add_string("ci-filter", "CIComicEffect", CI_CUSTOM_FILTER_TEXT, CI_CUSTOM_FILTER_LONGTEXT, true);
 vlc_module_end()
diff --git a/modules/video_filter/colorthres.c b/modules/video_filter/colorthres.c
index 37f60196ff..90c5536cdc 100644
--- a/modules/video_filter/colorthres.c
+++ b/modules/video_filter/colorthres.c
@@ -43,11 +43,11 @@
  * Local prototypes
  *****************************************************************************/
 static int  Create    ( vlc_object_t * );
-static void Destroy   ( vlc_object_t * );
+static void Destroy   ( filter_t * );
 
 static void Filter( filter_t *, picture_t *, picture_t * );
 static picture_t *FilterPacked( filter_t *, picture_t * );
-VIDEO_FILTER_WRAPPER( Filter )
+VIDEO_FILTER_WRAPPER_CLOSE( Filter, Destroy )
 
 /*****************************************************************************
  * Module descriptor
@@ -79,7 +79,7 @@ vlc_module_begin ()
                  N_("Saturation threshold"), "", false )
     add_integer( CFG_PREFIX "similaritythres", 15,
                  N_("Similarity threshold"), "", false )
-    set_callbacks( Create, Destroy )
+    set_callback( Create )
 vlc_module_end ()
 
 static const char *const ppsz_filter_options[] = {
@@ -105,7 +105,7 @@ typedef struct
 
 static const struct vlc_filter_operations packed_filter_ops =
 {
-    .filter_video = FilterPacked,
+    .filter_video = FilterPacked, .close = Destroy,
 };
 
 /*****************************************************************************
@@ -166,7 +166,7 @@ static int Create( vlc_object_t *p_this )
  *****************************************************************************
  * Terminate an output method created by adjustCreateOutputMethod
  *****************************************************************************/
-static void Destroy( vlc_object_t *p_this )
+static void Destroy( filter_t *p_this )
 {
     filter_t *p_filter = (filter_t *)p_this;
     filter_sys_t *p_sys = p_filter->p_sys;
diff --git a/modules/video_filter/edgedetection.c b/modules/video_filter/edgedetection.c
index 70dd1a8291..cd68f46125 100644
--- a/modules/video_filter/edgedetection.c
+++ b/modules/video_filter/edgedetection.c
@@ -46,7 +46,7 @@
  * Local prototypes
  *****************************************************************************/
 static int Open( vlc_object_t * );
-static void Close( vlc_object_t * );
+static void Close( filter_t * );
 static picture_t *new_frame( filter_t * );
 static picture_t *Filter( filter_t *, picture_t * );
 static uint8_t sobel( const uint8_t *, const int, const int, int, int);
@@ -73,7 +73,7 @@ vlc_module_begin ()
     set_category( CAT_VIDEO )
     set_subcategory( SUBCAT_VIDEO_VFILTER )
     set_capability( "video filter", 0 )
-    set_callbacks( Open, Close )
+    set_callback( Open )
 
 vlc_module_end ()
 
@@ -90,7 +90,7 @@ static void Flush( filter_t *p_filter )
 
 static const struct vlc_filter_operations filter_ops =
 {
-    .filter_video = Filter, .flush = Flush,
+    .filter_video = Filter, .flush = Flush, .close = Close,
 };
 
 /*****************************************************************************
@@ -142,9 +142,8 @@ static int Open( vlc_object_t *p_this )
 /******************************************************************************
  * Closes the filter and cleans up all dynamically allocated data.
  ******************************************************************************/
-static void Close( vlc_object_t *p_this )
+static void Close( filter_t *p_filter )
 {
-    filter_t *p_filter = (filter_t *)p_this;
     filter_chain_Delete( (filter_chain_t *)p_filter->p_sys );
 }
 
diff --git a/modules/video_filter/erase.c b/modules/video_filter/erase.c
index 14567b46a0..83e0114d1b 100644
--- a/modules/video_filter/erase.c
+++ b/modules/video_filter/erase.c
@@ -40,13 +40,13 @@
  * Local prototypes
  *****************************************************************************/
 static int  Create    ( vlc_object_t * );
-static void Destroy   ( vlc_object_t * );
+static void Destroy   ( filter_t * );
 
 static void Filter( filter_t *, picture_t *, picture_t * );
 static void FilterErase( filter_t *, picture_t *, picture_t * );
 static int EraseCallback( vlc_object_t *, char const *,
                           vlc_value_t, vlc_value_t, void * );
-VIDEO_FILTER_WRAPPER( Filter )
+VIDEO_FILTER_WRAPPER_CLOSE( Filter, Destroy )
 
 /*****************************************************************************
  * Module descriptor
@@ -76,7 +76,7 @@ vlc_module_begin ()
     add_integer( CFG_PREFIX "y", 0, POSY_TEXT, POSY_LONGTEXT, false )
 
     add_shortcut( "erase" )
-    set_callbacks( Create, Destroy )
+    set_callback( Create )
 vlc_module_end ()
 
 static const char *const ppsz_filter_options[] = {
@@ -186,9 +186,8 @@ static int Create( vlc_object_t *p_this )
 /*****************************************************************************
  * Destroy
  *****************************************************************************/
-static void Destroy( vlc_object_t *p_this )
+static void Destroy( filter_t *p_filter )
 {
-    filter_t *p_filter = (filter_t *)p_this;
     filter_sys_t *p_sys = p_filter->p_sys;
     if( p_sys->p_mask )
         picture_Release( p_sys->p_mask );
diff --git a/modules/video_filter/extract.c b/modules/video_filter/extract.c
index 41a619bee9..8bf4fe13ae 100644
--- a/modules/video_filter/extract.c
+++ b/modules/video_filter/extract.c
@@ -40,12 +40,12 @@
  * Local prototypes
  *****************************************************************************/
 static int  Create      ( vlc_object_t * );
-static void Destroy     ( vlc_object_t * );
+static void Destroy     ( filter_t * );
 
 static void Filter( filter_t *, picture_t *, picture_t * );
 static int ExtractCallback( vlc_object_t *, char const *,
                             vlc_value_t, vlc_value_t, void * );
-VIDEO_FILTER_WRAPPER( Filter )
+VIDEO_FILTER_WRAPPER_CLOSE(Filter, Destroy)
 
 static void make_projection_matrix( filter_t *, int color, int *matrix );
 static void get_custom_from_yuv( picture_t *, picture_t *, int const, int const, int const, int const * );
@@ -75,7 +75,7 @@ vlc_module_begin ()
                             COMPONENT_TEXT, COMPONENT_LONGTEXT, false )
         change_integer_list( pi_component_values, ppsz_component_descriptions )
 
-    set_callbacks( Create, Destroy )
+    set_callback( Create )
 vlc_module_end ()
 
 static const char *const ppsz_filter_options[] = {
@@ -151,9 +151,8 @@ static int Create( vlc_object_t *p_this )
 /*****************************************************************************
  * Destroy
  *****************************************************************************/
-static void Destroy( vlc_object_t *p_this )
+static void Destroy( filter_t *p_filter )
 {
-    filter_t *p_filter = (filter_t *)p_this;
     filter_sys_t *p_sys = p_filter->p_sys;
 
     var_DelCallback( p_filter, FILTER_PREFIX "component", ExtractCallback,
diff --git a/modules/video_filter/freeze.c b/modules/video_filter/freeze.c
index 719a762619..c296923a3a 100644
--- a/modules/video_filter/freeze.c
+++ b/modules/video_filter/freeze.c
@@ -72,7 +72,7 @@ static void freeze_free_allocated_data( filter_t * );
 #define CFG_PREFIX "freeze-"
 
 static int  Open ( vlc_object_t * );
-static void Close( vlc_object_t * );
+static void Close( filter_t * );
 
 vlc_module_begin()
     set_description( N_("Freezing interactive video filter") )
@@ -81,7 +81,7 @@ vlc_module_begin()
     set_category(    CAT_VIDEO )
     set_subcategory( SUBCAT_VIDEO_VFILTER )
 
-    set_callbacks( Open, Close )
+    set_callback( Open )
 vlc_module_end()
 
 /*****************************************************************************
@@ -92,6 +92,7 @@ static const struct vlc_filter_operations filter_ops =
 {
     .filter_video = Filter,
     .video_mouse = freeze_mouse,
+    .close = Close,
 };
 
 /**
@@ -135,8 +136,7 @@ static int Open( vlc_object_t *p_this )
 /**
  * Close the filter
  */
-static void Close( vlc_object_t *p_this ) {
-    filter_t *p_filter  = (filter_t *)p_this;
+static void Close( filter_t *p_filter ) {
     filter_sys_t *p_sys = p_filter->p_sys;
 
     /* Free allocated memory */
diff --git a/modules/video_filter/gaussianblur.c b/modules/video_filter/gaussianblur.c
index ff6870609b..472b9304ba 100644
--- a/modules/video_filter/gaussianblur.c
+++ b/modules/video_filter/gaussianblur.c
@@ -39,7 +39,7 @@
  * Module descriptor
  *****************************************************************************/
 static int  Create    ( vlc_object_t * );
-static void Destroy   ( vlc_object_t * );
+static void Destroy   ( filter_t * );
 
 #define SIGMA_MIN (0.01)
 #define SIGMA_MAX (4096.0)
@@ -65,14 +65,14 @@ vlc_module_begin ()
                           SIGMA_TEXT, SIGMA_LONGTEXT,
                           false )
 
-    set_callbacks( Create, Destroy )
+    set_callback( Create )
 vlc_module_end ()
 
 /*****************************************************************************
  * Local prototypes
  *****************************************************************************/
 static void Filter( filter_t *, picture_t *, picture_t * );
-VIDEO_FILTER_WRAPPER( Filter )
+VIDEO_FILTER_WRAPPER_CLOSE(Filter, Destroy)
 
 static const char *const ppsz_filter_options[] = {
     "sigma", NULL
@@ -174,9 +174,8 @@ static int Create( vlc_object_t *p_this )
     return VLC_SUCCESS;
 }
 
-static void Destroy( vlc_object_t *p_this )
+static void Destroy( filter_t *p_filter )
 {
-    filter_t *p_filter = (filter_t *)p_this;
     filter_sys_t *p_sys = p_filter->p_sys;
 
     free( p_sys->pt_distribution );
diff --git a/modules/video_filter/gradfun.c b/modules/video_filter/gradfun.c
index 880769a209..4deb9f4bc0 100644
--- a/modules/video_filter/gradfun.c
+++ b/modules/video_filter/gradfun.c
@@ -40,7 +40,7 @@
  * Module descriptor
  *****************************************************************************/
 static int  Open (vlc_object_t *);
-static void Close(vlc_object_t *);
+static void Close(filter_t *);
 
 #define CFG_PREFIX "gradfun-"
 
@@ -66,7 +66,7 @@ vlc_module_begin()
     add_float_with_range(CFG_PREFIX "strength", 1.2, STRENGTH_MIN, STRENGTH_MAX,
                          STRENGTH_TEXT, STRENGTH_LONGTEXT, false)
 
-    set_callbacks(Open, Close)
+    set_callback(Open)
 vlc_module_end()
 
 /*****************************************************************************
@@ -100,7 +100,7 @@ vlc_module_end()
 
 static void Filter(filter_t *, picture_t *, picture_t *);
 static int Callback(vlc_object_t *, char const *, vlc_value_t, vlc_value_t, void *);
-VIDEO_FILTER_WRAPPER( Filter )
+VIDEO_FILTER_WRAPPER_CLOSE(Filter, Close)
 
 typedef struct
 {
@@ -162,9 +162,8 @@ static int Open(vlc_object_t *object)
     return VLC_SUCCESS;
 }
 
-static void Close(vlc_object_t *object)
+static void Close(filter_t *filter)
 {
-    filter_t     *filter = (filter_t *)object;
     filter_sys_t *sys = filter->p_sys;
 
     var_DelCallback(filter, CFG_PREFIX "radius",   Callback, NULL);
diff --git a/modules/video_filter/gradient.c b/modules/video_filter/gradient.c
index 7b433a6a50..62c2b81437 100644
--- a/modules/video_filter/gradient.c
+++ b/modules/video_filter/gradient.c
@@ -44,13 +44,13 @@ enum { GRADIENT, EDGE, HOUGH };
  * Local prototypes
  *****************************************************************************/
 static int  Create    ( vlc_object_t * );
-static void Destroy   ( vlc_object_t * );
+static void Destroy   ( filter_t * );
 
 static void Filter( filter_t *, picture_t *, picture_t * );
 static int GradientCallback( vlc_object_t *, char const *,
                              vlc_value_t, vlc_value_t,
                              void * );
-VIDEO_FILTER_WRAPPER( Filter )
+VIDEO_FILTER_WRAPPER_CLOSE(Filter, Destroy)
 
 static void FilterGradient( filter_t *, picture_t *, picture_t * );
 static void FilterEdge    ( filter_t *, picture_t *, picture_t * );
@@ -95,7 +95,7 @@ vlc_module_begin ()
                 CARTOON_TEXT, CARTOON_LONGTEXT, false )
 
     add_shortcut( "gradient" )
-    set_callbacks( Create, Destroy )
+    set_callback( Create )
 vlc_module_end ()
 
 static const char *const ppsz_filter_options[] = {
@@ -213,9 +213,8 @@ static int Create( vlc_object_t *p_this )
  *****************************************************************************
  * Terminate an output method created by DistortCreateOutputMethod
  *****************************************************************************/
-static void Destroy( vlc_object_t *p_this )
+static void Destroy( filter_t *p_filter )
 {
-    filter_t *p_filter = (filter_t *)p_this;
     filter_sys_t *p_sys = p_filter->p_sys;
 
     var_DelCallback( p_filter, FILTER_PREFIX "mode",
diff --git a/modules/video_filter/grain.c b/modules/video_filter/grain.c
index 3aaa89abde..7638c48910 100644
--- a/modules/video_filter/grain.c
+++ b/modules/video_filter/grain.c
@@ -41,9 +41,9 @@
  * Module descriptor
  *****************************************************************************/
 static int  Open (vlc_object_t *);
-static void Close(vlc_object_t *);
+static void Close(filter_t *);
 static void Filter(filter_t *filter, picture_t *src, picture_t *dst);
-VIDEO_FILTER_WRAPPER( Filter )
+VIDEO_FILTER_WRAPPER_CLOSE(Filter, Close)
 
 #define BANK_SIZE (64)
 
@@ -74,7 +74,7 @@ vlc_module_begin()
                            PERIOD_MIN_TEXT, PERIOD_MIN_LONGTEXT, false)
     add_integer_with_range(CFG_PREFIX "period-max", 3*PERIOD_MAX/4, PERIOD_MIN, PERIOD_MAX,
                            PERIOD_MAX_TEXT, PERIOD_MAX_LONGTEXT, false)
-    set_callbacks(Open, Close)
+    set_callback(Open)
 vlc_module_end()
 
 /*****************************************************************************
@@ -416,9 +416,8 @@ static int Open(vlc_object_t *object)
     return VLC_SUCCESS;
 }
 
-static void Close(vlc_object_t *object)
+static void Close(filter_t *filter)
 {
-    filter_t     *filter = (filter_t *)object;
     filter_sys_t *sys    = filter->p_sys;
 
     var_DelCallback(filter, CFG_PREFIX "variance", Callback, NULL);
diff --git a/modules/video_filter/hqdn3d.c b/modules/video_filter/hqdn3d.c
index 0dcbca718e..b1413a2ff7 100644
--- a/modules/video_filter/hqdn3d.c
+++ b/modules/video_filter/hqdn3d.c
@@ -41,7 +41,7 @@
  * Local protypes
  *****************************************************************************/
 static int  Open         (vlc_object_t *);
-static void Close        (vlc_object_t *);
+static void Close        (filter_t *);
 static picture_t *Filter (filter_t *, picture_t *);
 static int DenoiseCallback( vlc_object_t *p_this, char const *psz_var,
                             vlc_value_t oldval, vlc_value_t newval,
@@ -76,7 +76,7 @@ vlc_module_begin()
 
     add_shortcut("hqdn3d")
 
-    set_callbacks(Open, Close)
+    set_callback(Open)
 vlc_module_end()
 
 static const char *const filter_options[] = {
@@ -156,7 +156,7 @@ static int Open(vlc_object_t *this)
 
     static const struct vlc_filter_operations filter_ops =
     {
-        .filter_video = Filter,
+        .filter_video = Filter, .close = Close,
     };
 
     filter->p_sys = sys;
@@ -173,9 +173,8 @@ static int Open(vlc_object_t *this)
 /*****************************************************************************
  * Close
  *****************************************************************************/
-static void Close(vlc_object_t *this)
+static void Close(filter_t *filter)
 {
-    filter_t *filter = (filter_t *)this;
     filter_sys_t *sys = filter->p_sys;
     struct vf_priv_s *cfg = &sys->cfg;
 
diff --git a/modules/video_filter/magnify.c b/modules/video_filter/magnify.c
index b5d2fe042c..ebeaec5876 100644
--- a/modules/video_filter/magnify.c
+++ b/modules/video_filter/magnify.c
@@ -42,7 +42,7 @@
  * Module descriptor
  *****************************************************************************/
 static int  Create    ( vlc_object_t * );
-static void Destroy   ( vlc_object_t * );
+static void Destroy   ( filter_t * );
 
 vlc_module_begin ()
     set_description( N_("Magnify/Zoom interactive video filter") )
@@ -51,7 +51,7 @@ vlc_module_begin ()
     set_category( CAT_VIDEO )
     set_subcategory( SUBCAT_VIDEO_VFILTER )
 
-    set_callbacks( Create, Destroy )
+    set_callback( Create )
 vlc_module_end ()
 
 
@@ -133,6 +133,7 @@ static int Create( vlc_object_t *p_this )
     {
         .filter_video = Filter,
         .video_mouse = Mouse,
+        .close = Destroy,
     };
     p_filter->ops = &filter_ops;
     return VLC_SUCCESS;
@@ -141,9 +142,8 @@ static int Create( vlc_object_t *p_this )
 /*****************************************************************************
  * Destroy:
  *****************************************************************************/
-static void Destroy( vlc_object_t *p_this )
+static void Destroy( filter_t *p_filter )
 {
-    filter_t *p_filter = (filter_t *)p_this;
     filter_sys_t *p_sys = p_filter->p_sys;
 
     image_HandlerDelete( p_sys->p_image );
diff --git a/modules/video_filter/mirror.c b/modules/video_filter/mirror.c
index b92bde98ea..14ec5517d4 100644
--- a/modules/video_filter/mirror.c
+++ b/modules/video_filter/mirror.c
@@ -41,7 +41,7 @@
  * Local prototypes
  *****************************************************************************/
 static int  Create      ( vlc_object_t * );
-static void Destroy     ( vlc_object_t * );
+static void Destroy     ( filter_t * );
 
 static void Filter( filter_t *, picture_t *, picture_t * );
 static void VerticalMirror( picture_t *, picture_t *, int plane, bool );
@@ -52,7 +52,7 @@ static void RV24VerticalMirror( picture_t *, picture_t *, int plane, bool );
 static void RV32VerticalMirror( picture_t *, picture_t *, int plane, bool );
 
 static void YUV422Mirror2Pixels( uint8_t *, uint8_t *, bool );
-VIDEO_FILTER_WRAPPER( Filter )
+VIDEO_FILTER_WRAPPER_CLOSE(Filter, Destroy)
 
 static const char *const ppsz_filter_options[] = {
     "split", "direction", NULL
@@ -90,7 +90,7 @@ vlc_module_begin ()
     add_integer( CFG_PREFIX "direction", 0, DIRECTION_TEXT,
                 DIRECTION_LONGTEXT, false )
         change_integer_list( pi_direction_values, ppsz_direction_descriptions )
-    set_callbacks( Create, Destroy )
+    set_callback( Create )
 vlc_module_end ()
 
 /*****************************************************************************
@@ -166,9 +166,8 @@ static int Create( vlc_object_t *p_this )
  *****************************************************************************
  * Terminate an output method created by MirrorCreateOutputMethod
  *****************************************************************************/
-static void Destroy( vlc_object_t *p_this )
+static void Destroy( filter_t *p_filter )
 {
-    filter_t *p_filter = (filter_t *)p_this;
     filter_sys_t *p_sys = p_filter->p_sys;
 
     var_DelCallback( p_filter, CFG_PREFIX "split", FilterCallback, p_sys );
diff --git a/modules/video_filter/motionblur.c b/modules/video_filter/motionblur.c
index 1008596f84..c99d2495b6 100644
--- a/modules/video_filter/motionblur.c
+++ b/modules/video_filter/motionblur.c
@@ -43,12 +43,12 @@
 typedef struct filter_sys_t filter_sys_t;
 
 static int  Create       ( vlc_object_t * );
-static void Destroy      ( vlc_object_t * );
+static void Destroy      ( filter_t * );
 static void Filter ( filter_t *, picture_t *, picture_t * );
 static void RenderBlur   ( filter_sys_t *, picture_t *, picture_t * );
 static int MotionBlurCallback( vlc_object_t *, char const *,
                                vlc_value_t, vlc_value_t, void * );
-VIDEO_FILTER_WRAPPER( Filter )
+VIDEO_FILTER_WRAPPER_CLOSE(Filter, Destroy)
 
 /*****************************************************************************
  * Module descriptor
@@ -70,7 +70,7 @@ vlc_module_begin ()
 
     add_shortcut( "blur" )
 
-    set_callbacks( Create, Destroy )
+    set_callback( Create )
 vlc_module_end ()
 
 static const char *const ppsz_filter_options[] = {
@@ -130,9 +130,8 @@ static int Create( vlc_object_t *p_this )
 /*****************************************************************************
  * Destroy
  *****************************************************************************/
-static void Destroy( vlc_object_t *p_this )
+static void Destroy( filter_t *p_filter )
 {
-    filter_t *p_filter = (filter_t *)p_this;
     filter_sys_t *p_sys = p_filter->p_sys;
 
     var_DelCallback( p_filter, FILTER_PREFIX "factor",
diff --git a/modules/video_filter/motiondetect.c b/modules/video_filter/motiondetect.c
index c2c3796613..ce6d35396d 100644
--- a/modules/video_filter/motiondetect.c
+++ b/modules/video_filter/motiondetect.c
@@ -39,7 +39,7 @@
  * Module descriptor
  *****************************************************************************/
 static int  Create    ( vlc_object_t * );
-static void Destroy   ( vlc_object_t * );
+static void Destroy   ( filter_t * );
 
 #define FILTER_PREFIX "motiondetect-"
 
@@ -51,7 +51,7 @@ vlc_module_begin ()
     set_capability( "video filter", 0 )
 
     add_shortcut( "motion" )
-    set_callbacks( Create, Destroy )
+    set_callback( Create )
 vlc_module_end ()
 
 
@@ -118,7 +118,7 @@ static int Create( vlc_object_t *p_this )
     }
     static const struct vlc_filter_operations filter_ops =
     {
-        .filter_video = Filter, .flush = Flush,
+        .filter_video = Filter, .flush = Flush, .close = Destroy,
     };
     p_filter->ops = &filter_ops;
 
@@ -145,9 +145,8 @@ static int Create( vlc_object_t *p_this )
 /*****************************************************************************
  * Destroy
  *****************************************************************************/
-static void Destroy( vlc_object_t *p_this )
+static void Destroy( filter_t *p_filter )
 {
-    filter_t *p_filter = (filter_t *)p_this;
     filter_sys_t *p_sys = p_filter->p_sys;
 
     free( p_sys->p_buf2 );
diff --git a/modules/video_filter/oldmovie.c b/modules/video_filter/oldmovie.c
index dd2a701d8f..730fb7ef25 100644
--- a/modules/video_filter/oldmovie.c
+++ b/modules/video_filter/oldmovie.c
@@ -173,7 +173,7 @@ static int  oldmovie_sliding_offset_apply( filter_t *p_filter, picture_t *p_pic_
  *****************************************************************************/
 
 static int  Open ( vlc_object_t * );
-static void Close( vlc_object_t * );
+static void Close( filter_t * );
 
 vlc_module_begin()
     set_description( N_("Old movie effect video filter") )
@@ -182,7 +182,7 @@ vlc_module_begin()
     set_category( CAT_VIDEO )
     set_subcategory( SUBCAT_VIDEO_VFILTER )
 
-    set_callbacks( Open, Close )
+    set_callback( Open )
 vlc_module_end()
 
 /**
@@ -218,7 +218,7 @@ static int Open( vlc_object_t *p_this ) {
     /* init data */
     static const struct vlc_filter_operations filter_ops =
     {
-        .filter_video = Filter,
+        .filter_video = Filter, .close = Close,
     };
     p_filter->ops = &filter_ops;
     p_sys->i_start_time = p_sys->i_cur_time = p_sys->i_last_time = vlc_tick_now();
@@ -229,8 +229,7 @@ static int Open( vlc_object_t *p_this ) {
 /**
  * Close the filter
  */
-static void Close( vlc_object_t *p_this ) {
-    filter_t *p_filter  = (filter_t *)p_this;
+static void Close( filter_t *p_filter ) {
     filter_sys_t *p_sys = p_filter->p_sys;
 
     /* Free allocated memory */
diff --git a/modules/video_filter/opencv_example.cpp b/modules/video_filter/opencv_example.cpp
index ed4e8cba26..3a4a30e101 100644
--- a/modules/video_filter/opencv_example.cpp
+++ b/modules/video_filter/opencv_example.cpp
@@ -66,7 +66,7 @@ struct filter_sys_t
  * Local prototypes
  ****************************************************************************/
 static int  OpenFilter ( vlc_object_t * );
-static void CloseFilter( vlc_object_t * );
+static void CloseFilter( filter_t * );
 
 static picture_t *Filter( filter_t *, picture_t * );
 
@@ -81,7 +81,7 @@ vlc_module_begin ()
 
     set_category( CAT_VIDEO )
     set_subcategory( SUBCAT_VIDEO_VFILTER )
-    set_callbacks( OpenFilter, CloseFilter )
+    set_callback( OpenFilter )
 
     add_string( "opencv-haarcascade-file", "c:\\haarcascade_frontalface_alt.xml",
                           N_("Haar cascade filename"),
@@ -113,6 +113,7 @@ static int OpenFilter( vlc_object_t *p_this )
         FilterOperationInitializer()
         {
             ops.filter_video = Filter;
+            ops.close        = CloseFilter;
         };
     } filter_ops;
     p_filter->ops = &filter_ops.ops;
@@ -138,9 +139,8 @@ static int OpenFilter( vlc_object_t *p_this )
 /*****************************************************************************
  * CloseFilter: clean up the filter
  *****************************************************************************/
-static void CloseFilter( vlc_object_t *p_this )
+static void CloseFilter( filter_t *p_filter )
 {
-    filter_t *p_filter = (filter_t*)p_this;
     filter_sys_t *p_sys = static_cast<filter_sys_t *>(p_filter->p_sys);
 
     if( p_sys->p_cascade )
diff --git a/modules/video_filter/opencv_wrapper.c b/modules/video_filter/opencv_wrapper.c
index f4c8d770dd..0b6e77c630 100644
--- a/modules/video_filter/opencv_wrapper.c
+++ b/modules/video_filter/opencv_wrapper.c
@@ -46,7 +46,7 @@
  * Local prototypes
  *****************************************************************************/
 static int  Create    ( vlc_object_t * );
-static void Destroy   ( vlc_object_t * );
+static void Destroy   ( filter_t * );
 
 static picture_t* Filter( filter_t*, picture_t* );
 
@@ -72,7 +72,7 @@ vlc_module_begin ()
     set_subcategory( SUBCAT_VIDEO_VFILTER )
     set_capability( "video filter", 0 )
     add_shortcut( "opencv_wrapper" )
-    set_callbacks( Create, Destroy )
+    set_callback( Create )
     add_float_with_range( "opencv-scale", 1.0, 0.1, 2.0,
                           N_("Scale factor (0.1-2.0)"),
                           N_("Amount by which to scale the picture before sending it to the internal OpenCV filter"),
@@ -251,7 +251,7 @@ static int Create( vlc_object_t *p_this )
 
     static const struct vlc_filter_operations filter_ops =
     {
-        .filter_video = Filter,
+        .filter_video = Filter, .close = Destroy,
     };
     p_filter->ops = &filter_ops;
     p_filter->p_sys = p_sys;
@@ -264,9 +264,8 @@ static int Create( vlc_object_t *p_this )
  *****************************************************************************
  * Terminate an output method created by opencv_wrapperCreateOutputMethod
  *****************************************************************************/
-static void Destroy( vlc_object_t *p_this )
+static void Destroy( filter_t* p_filter )
 {
-    filter_t* p_filter = (filter_t*)p_this;
     filter_sys_t *p_sys = p_filter->p_sys;
     ReleaseImages( p_filter );
 
diff --git a/modules/video_filter/posterize.c b/modules/video_filter/posterize.c
index 5ffa53fe0a..0d97459314 100644
--- a/modules/video_filter/posterize.c
+++ b/modules/video_filter/posterize.c
@@ -41,7 +41,7 @@
  * Local prototypes
  *****************************************************************************/
 static int  Create      ( vlc_object_t * );
-static void Destroy     ( vlc_object_t * );
+static void Destroy     ( filter_t * );
 
 static void Filter( filter_t *, picture_t *, picture_t * );
 static void PlanarYUVPosterize( picture_t *, picture_t *, int);
@@ -49,7 +49,7 @@ static void PackedYUVPosterize( picture_t *, picture_t *, int);
 static void RVPosterize( picture_t *, picture_t *, bool, int );
 static void YuvPosterization( uint8_t *, uint8_t *, uint8_t *, uint8_t *,
                     uint8_t, uint8_t, uint8_t, uint8_t, int );
-VIDEO_FILTER_WRAPPER( Filter )
+VIDEO_FILTER_WRAPPER_CLOSE(Filter, Destroy)
 
 static const char *const ppsz_filter_options[] = {
     "level", NULL
@@ -74,7 +74,7 @@ vlc_module_begin ()
     add_integer_with_range( CFG_PREFIX "level", 6, 2, 256,
                            POSTERIZE_LEVEL_TEXT, POSTERIZE_LEVEL_LONGTEXT,
                            false )
-    set_callbacks( Create, Destroy )
+    set_callback( Create )
 vlc_module_end ()
 
 /*****************************************************************************
@@ -145,9 +145,8 @@ static int Create( vlc_object_t *p_this )
  *****************************************************************************
  * Terminate an output method created by PosterizeCreateOutputMethod
  *****************************************************************************/
-static void Destroy( vlc_object_t *p_this )
+static void Destroy( filter_t *p_filter )
 {
-    filter_t *p_filter = (filter_t *)p_this;
     filter_sys_t *p_sys = p_filter->p_sys;
 
     var_DelCallback( p_filter, CFG_PREFIX "level", FilterCallback, p_sys );
diff --git a/modules/video_filter/postproc.c b/modules/video_filter/postproc.c
index 452609da0b..0015598126 100644
--- a/modules/video_filter/postproc.c
+++ b/modules/video_filter/postproc.c
@@ -54,10 +54,10 @@
  * Local prototypes
  *****************************************************************************/
 static int OpenPostproc( vlc_object_t * );
-static void ClosePostproc( vlc_object_t * );
+static void ClosePostproc( filter_t * );
 
 static void PostprocPict( filter_t *, picture_t *, picture_t * );
-VIDEO_FILTER_WRAPPER( PostprocPict )
+VIDEO_FILTER_WRAPPER_CLOSE(PostprocPict, ClosePostproc)
 
 static int PPQCallback( vlc_object_t *, char const *,
                         vlc_value_t, vlc_value_t, void * );
@@ -88,7 +88,7 @@ vlc_module_begin ()
 
     set_capability( "video filter", 0 )
 
-    set_callbacks( OpenPostproc, ClosePostproc )
+    set_callback( OpenPostproc )
 
     add_integer_with_range( FILTER_PREFIX "q", PP_QUALITY_MAX, 0,
                             PP_QUALITY_MAX, Q_TEXT, Q_LONGTEXT, false )
@@ -261,9 +261,8 @@ static int OpenPostproc( vlc_object_t *p_this )
 /*****************************************************************************
  * ClosePostproc
  *****************************************************************************/
-static void ClosePostproc( vlc_object_t *p_this )
+static void ClosePostproc( filter_t *p_filter )
 {
-    filter_t *p_filter = (filter_t *)p_this;
     filter_sys_t *p_sys = p_filter->p_sys;
 
     /* delete the callback before destroying the mutex */
diff --git a/modules/video_filter/psychedelic.c b/modules/video_filter/psychedelic.c
index d4ec4afca1..0c0b010fa3 100644
--- a/modules/video_filter/psychedelic.c
+++ b/modules/video_filter/psychedelic.c
@@ -41,10 +41,10 @@
  * Local prototypes
  *****************************************************************************/
 static int  Create    ( vlc_object_t * );
-static void Destroy   ( vlc_object_t * );
+static void Destroy   ( filter_t * );
 
 static void Filter( filter_t *, picture_t *, picture_t * );
-VIDEO_FILTER_WRAPPER( Filter )
+VIDEO_FILTER_WRAPPER_CLOSE(Filter, Destroy)
 
 /*****************************************************************************
  * Module descriptor
@@ -57,7 +57,7 @@ vlc_module_begin ()
     set_subcategory( SUBCAT_VIDEO_VFILTER )
 
     add_shortcut( "psychedelic" )
-    set_callbacks( Create, Destroy )
+    set_callback( Create )
 vlc_module_end ()
 
 /*****************************************************************************
@@ -116,9 +116,8 @@ static int Create( vlc_object_t *p_this )
  *****************************************************************************
  * Terminate an output method created by DistortCreateOutputMethod
  *****************************************************************************/
-static void Destroy( vlc_object_t *p_this )
+static void Destroy( filter_t *p_filter )
 {
-    filter_t *p_filter = (filter_t *)p_this;
     filter_sys_t *p_sys = p_filter->p_sys;
 
     if( p_sys->p_image )
diff --git a/modules/video_filter/puzzle.c b/modules/video_filter/puzzle.c
index 80b5775c74..15f7a9e677 100644
--- a/modules/video_filter/puzzle.c
+++ b/modules/video_filter/puzzle.c
@@ -78,7 +78,7 @@ static const char *const ppsz_rotation_descriptions[] = { N_("0"), N_("0/180"),
 #define CFG_PREFIX "puzzle-"
 
 static int  Open ( vlc_object_t * );
-static void Close( vlc_object_t * );
+static void Close( filter_t * );
 
 vlc_module_begin()
     set_description( N_("Puzzle interactive game video filter") )
@@ -110,7 +110,7 @@ vlc_module_begin()
               MODE_TEXT, MODE_LONGTEXT, false )
         change_integer_list(pi_mode_values, ppsz_mode_descriptions )
 
-    set_callbacks( Open, Close )
+    set_callback( Open )
 vlc_module_end()
 
 /*****************************************************************************
@@ -206,6 +206,7 @@ static int Open( vlc_object_t *p_this )
     {
         .filter_video = Filter,
         .video_mouse = puzzle_mouse,
+        .close = Close,
     };
     p_filter->ops = &filter_ops;
 
@@ -215,8 +216,7 @@ static int Open( vlc_object_t *p_this )
 /**
  * Close the filter
  */
-static void Close( vlc_object_t *p_this ) {
-    filter_t *p_filter = (filter_t *)p_this;
+static void Close( filter_t *p_filter ) {
     filter_sys_t *p_sys = p_filter->p_sys;
 
     var_DelCallback( p_filter, CFG_PREFIX "rows",          puzzle_Callback, p_sys );
diff --git a/modules/video_filter/rotate.c b/modules/video_filter/rotate.c
index a2b56118b6..b810f9e0db 100644
--- a/modules/video_filter/rotate.c
+++ b/modules/video_filter/rotate.c
@@ -43,11 +43,11 @@
  * Local prototypes
  *****************************************************************************/
 static int  Create    ( vlc_object_t * );
-static void Destroy   ( vlc_object_t * );
+static void Destroy   ( filter_t * );
 
 static void Filter( filter_t *, picture_t *, picture_t * );
 static picture_t *FilterPacked( filter_t *, picture_t * );
-VIDEO_FILTER_WRAPPER( Filter )
+VIDEO_FILTER_WRAPPER_CLOSE(Filter, Destroy)
 
 static int RotateCallback( vlc_object_t *p_this, char const *psz_var,
                            vlc_value_t oldval, vlc_value_t newval,
@@ -76,7 +76,7 @@ vlc_module_begin ()
               MOTION_LONGTEXT, false )
 
     add_shortcut( "rotate" )
-    set_callbacks( Create, Destroy )
+    set_callback( Create )
 vlc_module_end ()
 
 static const char *const ppsz_filter_options[] = {
@@ -121,7 +121,7 @@ static void fetch_trigo( filter_sys_t *sys, int *i_sin, int *i_cos )
 
 static const struct vlc_filter_operations packed_filter_ops =
 {
-    .filter_video = FilterPacked,
+    .filter_video = FilterPacked, .close = Destroy,
 };
 
 /*****************************************************************************
@@ -188,9 +188,8 @@ static int Create( vlc_object_t *p_this )
 /*****************************************************************************
  * Destroy: destroy Distort filter
  *****************************************************************************/
-static void Destroy( vlc_object_t *p_this )
+static void Destroy( filter_t *p_filter )
 {
-    filter_t *p_filter = (filter_t *)p_this;
     filter_sys_t *p_sys = p_filter->p_sys;
 
     if( p_sys->p_motion != NULL )
diff --git a/modules/video_filter/scene.c b/modules/video_filter/scene.c
index f655cb4e7a..0de53fd1b2 100644
--- a/modules/video_filter/scene.c
+++ b/modules/video_filter/scene.c
@@ -45,7 +45,7 @@
  * Local prototypes
  *****************************************************************************/
 static int  Create      ( vlc_object_t * );
-static void Destroy     ( vlc_object_t * );
+static void Destroy     ( filter_t * );
 
 static picture_t *Filter( filter_t *, picture_t * );
 
@@ -116,7 +116,7 @@ vlc_module_begin ()
     add_integer_with_range( CFG_PREFIX "ratio", 50, 1, INT_MAX,
                             RATIO_TEXT, RATIO_LONGTEXT, false )
 
-    set_callbacks( Create, Destroy )
+    set_callback( Create )
 vlc_module_end ()
 
 static const char *const ppsz_vfilter_options[] = {
@@ -199,7 +199,7 @@ static int Create( vlc_object_t *p_this )
 
     static const struct vlc_filter_operations filter_ops =
     {
-        .filter_video = Filter,
+        .filter_video = Filter, .close = Destroy,
     };
     p_filter->ops = &filter_ops;
 
@@ -209,9 +209,8 @@ static int Create( vlc_object_t *p_this )
 /*****************************************************************************
  * Destroy: destroy video filter method
  *****************************************************************************/
-static void Destroy( vlc_object_t *p_this )
+static void Destroy( filter_t *p_filter )
 {
-    filter_t *p_filter = (filter_t *)p_this;
     filter_sys_t *p_sys = p_filter->p_sys;
 
     image_HandlerDelete( p_sys->p_image );
diff --git a/modules/video_filter/sepia.c b/modules/video_filter/sepia.c
index 8636400486..65f4079249 100644
--- a/modules/video_filter/sepia.c
+++ b/modules/video_filter/sepia.c
@@ -42,7 +42,7 @@
  * Local prototypes
  *****************************************************************************/
 static int  Create      ( vlc_object_t * );
-static void Destroy     ( vlc_object_t * );
+static void Destroy     ( filter_t * );
 
 static void RVSepia( picture_t *, picture_t *, int );
 static void PlanarI420Sepia( picture_t *, picture_t *, int);
@@ -51,7 +51,7 @@ static void Filter( filter_t *, picture_t *, picture_t * );
 static const char *const ppsz_filter_options[] = {
     "intensity", NULL
 };
-VIDEO_FILTER_WRAPPER( Filter )
+VIDEO_FILTER_WRAPPER_CLOSE(Filter, Destroy)
 
 /*****************************************************************************
  * Module descriptor
@@ -71,7 +71,7 @@ vlc_module_begin ()
     add_integer_with_range( CFG_PREFIX "intensity", 120, 0, 255,
                            SEPIA_INTENSITY_TEXT, SEPIA_INTENSITY_LONGTEXT,
                            false )
-    set_callbacks( Create, Destroy )
+    set_callback( Create )
 vlc_module_end ()
 
 /*****************************************************************************
@@ -154,10 +154,8 @@ static int Create( vlc_object_t *p_this )
  *****************************************************************************
  * Terminate an output method
  *****************************************************************************/
-static void Destroy( vlc_object_t *p_this )
+static void Destroy( filter_t *p_filter )
 {
-    filter_t *p_filter = (filter_t *)p_this;
-
     var_DelCallback( p_filter, CFG_PREFIX "intensity", FilterCallback, NULL );
 
     free( p_filter->p_sys );
diff --git a/modules/video_filter/sharpen.c b/modules/video_filter/sharpen.c
index 1933414d33..c8bc55622e 100644
--- a/modules/video_filter/sharpen.c
+++ b/modules/video_filter/sharpen.c
@@ -50,12 +50,12 @@
  * Local prototypes
  *****************************************************************************/
 static int  Create    ( vlc_object_t * );
-static void Destroy   ( vlc_object_t * );
+static void Destroy   ( filter_t * );
 
 static void Filter( filter_t *, picture_t *, picture_t * );
 static int SharpenCallback( vlc_object_t *, char const *,
                             vlc_value_t, vlc_value_t, void * );
-VIDEO_FILTER_WRAPPER( Filter )
+VIDEO_FILTER_WRAPPER_CLOSE(Filter, Destroy)
 
 #define SHARPEN_HELP N_("Augment contrast between contours.")
 #define FILTER_PREFIX "sharpen-"
@@ -74,7 +74,7 @@ vlc_module_begin ()
         SIG_TEXT, SIG_LONGTEXT, false )
     change_safe()
     add_shortcut( "sharpen" )
-    set_callbacks( Create, Destroy )
+    set_callback( Create )
 vlc_module_end ()
 
 static const char *const ppsz_filter_options[] = {
@@ -139,9 +139,8 @@ static int Create( vlc_object_t *p_this )
  *****************************************************************************
  * Terminate an output method created by SharpenCreateOutputMethod
  *****************************************************************************/
-static void Destroy( vlc_object_t *p_this )
+static void Destroy( filter_t *p_filter )
 {
-    filter_t *p_filter = (filter_t *)p_this;
     filter_sys_t *p_sys = p_filter->p_sys;
 
     var_DelCallback( p_filter, FILTER_PREFIX "sigma", SharpenCallback, p_sys );
diff --git a/modules/video_filter/vhs.c b/modules/video_filter/vhs.c
index 7c0a478b4a..001d47295a 100644
--- a/modules/video_filter/vhs.c
+++ b/modules/video_filter/vhs.c
@@ -99,7 +99,7 @@ static int  vhs_sliding_effect_apply( filter_t *, picture_t * );
  *****************************************************************************/
 
 static int  Open ( vlc_object_t * );
-static void Close( vlc_object_t * );
+static void Close( filter_t * );
 
 vlc_module_begin()
     set_description( N_("VHS movie effect video filter") )
@@ -108,7 +108,7 @@ vlc_module_begin()
     set_category( CAT_VIDEO )
     set_subcategory( SUBCAT_VIDEO_VFILTER )
 
-    set_callbacks( Open, Close )
+    set_callback( Open )
 vlc_module_end()
 
 /**
@@ -145,7 +145,7 @@ static int Open( vlc_object_t *p_this )
     /* init data */
     static const struct vlc_filter_operations filter_ops =
     {
-        .filter_video = Filter,
+        .filter_video = Filter, .close = Close,
     };
     p_filter->ops = &filter_ops;
     p_sys->i_start_time = p_sys->i_cur_time = p_sys->i_last_time = vlc_tick_now();
@@ -156,8 +156,7 @@ static int Open( vlc_object_t *p_this )
 /**
  * Close the filter
  */
-static void Close( vlc_object_t *p_this ) {
-    filter_t *p_filter = (filter_t*)p_this;
+static void Close( filter_t *p_filter ) {
     filter_sys_t *p_sys = p_filter->p_sys;
 
     /* Free allocated memory */



More information about the vlc-commits mailing list