[vlc-commits] filters: use macro to set the typed Open callback for deinterlacers

Steve Lhomme git at videolan.org
Tue Oct 13 11:07:05 CEST 2020


vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Thu Oct  8 14:35:03 2020 +0200| [1c87e2904259201f0c0b08c44a30e38003c36848] | committer: Steve Lhomme

filters: use macro to set the typed Open callback for deinterlacers

All deinterlacers have a priority of 0 since they are each specific to an input
chroma/video context.

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

 include/vlc_filter.h                           | 12 ++++++++++++
 modules/hw/d3d11/d3d11_deinterlace.c           |  3 +--
 modules/hw/d3d11/d3d11_filters.c               |  3 +--
 modules/hw/d3d11/d3d11_filters.h               |  2 +-
 modules/hw/d3d9/d3d9_filters.c                 |  3 +--
 modules/hw/d3d9/d3d9_filters.h                 |  2 +-
 modules/hw/d3d9/dxva2_deinterlace.c            |  3 +--
 modules/hw/mmal/deinterlace.c                  |  9 +++------
 modules/hw/vaapi/filters.c                     |  6 ++----
 modules/hw/vdpau/deinterlace.c                 |  8 ++------
 modules/video_filter/deinterlace/deinterlace.c | 11 ++++-------
 11 files changed, 29 insertions(+), 33 deletions(-)

diff --git a/include/vlc_filter.h b/include/vlc_filter.h
index 1f130bcb7a..4497435420 100644
--- a/include/vlc_filter.h
+++ b/include/vlc_filter.h
@@ -140,6 +140,18 @@ struct vlc_filter_operations
     void (*close)(filter_t *);
 };
 
+typedef int (*vlc_open_deinterlace)(filter_t *);
+
+
+#define set_deinterlace_callback( activate )     \
+    {                                            \
+        vlc_open_deinterlace open__ = activate;  \
+        (void) open__;                           \
+        set_callback(activate)                   \
+    }                                            \
+    set_capability( "video filter", 0 )          \
+    add_shortcut( "deinterlace" )
+
 /** Structure describing a filter
  * @warning BIG FAT WARNING : the code relies on the first 4 members of
  * filter_t and decoder_t to be the same, so if you have anything to add,
diff --git a/modules/hw/d3d11/d3d11_deinterlace.c b/modules/hw/d3d11/d3d11_deinterlace.c
index feaea04507..d37b3c8e05 100644
--- a/modules/hw/d3d11/d3d11_deinterlace.c
+++ b/modules/hw/d3d11/d3d11_deinterlace.c
@@ -245,9 +245,8 @@ static const struct vlc_filter_operations filter_ops = {
     .filter_video = Deinterlace, .flush = Flush, .close = D3D11CloseDeinterlace,
 };
 
-int D3D11OpenDeinterlace(vlc_object_t *obj)
+int D3D11OpenDeinterlace(filter_t *filter)
 {
-    filter_t *filter = (filter_t *)obj;
     HRESULT hr;
 
     if (!is_d3d11_opaque(filter->fmt_in.video.i_chroma))
diff --git a/modules/hw/d3d11/d3d11_filters.c b/modules/hw/d3d11/d3d11_filters.c
index a887fc131a..53070a76bc 100644
--- a/modules/hw/d3d11/d3d11_filters.c
+++ b/modules/hw/d3d11/d3d11_filters.c
@@ -593,8 +593,7 @@ vlc_module_begin()
 
     add_submodule()
     set_description(N_("Direct3D11 deinterlace filter"))
-    set_callback( D3D11OpenDeinterlace )
-    add_shortcut ("deinterlace")
+    set_deinterlace_callback( D3D11OpenDeinterlace )
 
     add_submodule()
     set_capability( "video converter", 10 )
diff --git a/modules/hw/d3d11/d3d11_filters.h b/modules/hw/d3d11/d3d11_filters.h
index fbc1e2fd6a..411afda4b9 100644
--- a/modules/hw/d3d11/d3d11_filters.h
+++ b/modules/hw/d3d11/d3d11_filters.h
@@ -28,7 +28,7 @@
 
 #include "../../video_chroma/d3d11_fmt.h"
 
-int  D3D11OpenDeinterlace(vlc_object_t *);
+int  D3D11OpenDeinterlace(filter_t *);
 int  D3D11OpenConverter(vlc_object_t *);
 int  D3D11OpenCPUConverter(vlc_object_t *);
 
diff --git a/modules/hw/d3d9/d3d9_filters.c b/modules/hw/d3d9/d3d9_filters.c
index 8f211a3e2c..deb6b06744 100644
--- a/modules/hw/d3d9/d3d9_filters.c
+++ b/modules/hw/d3d9/d3d9_filters.c
@@ -513,8 +513,7 @@ vlc_module_begin()
 
     add_submodule()
     set_description(N_("Direct3D9 deinterlace filter"))
-    set_callback( D3D9OpenDeinterlace )
-    add_shortcut ("deinterlace")
+    set_deinterlace_callback( D3D9OpenDeinterlace )
 
     add_submodule()
     set_capability( "video converter", 10 )
diff --git a/modules/hw/d3d9/d3d9_filters.h b/modules/hw/d3d9/d3d9_filters.h
index c098e07a1b..219b079bbc 100644
--- a/modules/hw/d3d9/d3d9_filters.h
+++ b/modules/hw/d3d9/d3d9_filters.h
@@ -28,7 +28,7 @@
 
 #include "../../video_chroma/d3d9_fmt.h"
 
-int  D3D9OpenDeinterlace(vlc_object_t *);
+int  D3D9OpenDeinterlace(filter_t *);
 int  D3D9OpenConverter(vlc_object_t *);
 int  D3D9OpenCPUConverter(vlc_object_t *);
 
diff --git a/modules/hw/d3d9/dxva2_deinterlace.c b/modules/hw/d3d9/dxva2_deinterlace.c
index a520fb3bbc..4e28f52c81 100644
--- a/modules/hw/d3d9/dxva2_deinterlace.c
+++ b/modules/hw/d3d9/dxva2_deinterlace.c
@@ -338,9 +338,8 @@ static const struct vlc_filter_operations filter_ops = {
     .filter_video = Deinterlace, .flush = Flush, .close = D3D9CloseDeinterlace,
 };
 
-int D3D9OpenDeinterlace(vlc_object_t *obj)
+int D3D9OpenDeinterlace(filter_t *filter)
 {
-    filter_t *filter = (filter_t *)obj;
     filter_sys_t *sys;
     HINSTANCE hdecoder_dll = NULL;
     HRESULT hr;
diff --git a/modules/hw/mmal/deinterlace.c b/modules/hw/mmal/deinterlace.c
index 45df307ee6..e70def780b 100644
--- a/modules/hw/mmal/deinterlace.c
+++ b/modules/hw/mmal/deinterlace.c
@@ -60,16 +60,14 @@
 #define MMAL_DEINTERLACE_FULL_RATE_TEXT N_("Full output framerate")
 #define MMAL_DEINTERLACE_FULL_RATE_LONGTEXT N_("Full output framerate. 1 output frame for each interlaced field input")
 
-static int OpenMmalDeinterlace(vlc_object_t *);
+static int OpenMmalDeinterlace(filter_t *);
 
 vlc_module_begin()
     set_shortname(N_("MMAL deinterlace"))
     set_description(N_("MMAL-based deinterlace filter plugin"))
-    set_capability("video filter", 900)
     set_category(CAT_VIDEO)
     set_subcategory(SUBCAT_VIDEO_VFILTER)
-    set_callback(OpenMmalDeinterlace)
-    add_shortcut("deinterlace")
+    set_deinterlace_callback(OpenMmalDeinterlace)
     add_bool(MMAL_DEINTERLACE_NO_QPU, false, MMAL_DEINTERLACE_NO_QPU_TEXT,
                     MMAL_DEINTERLACE_NO_QPU_LONGTEXT, true);
     add_bool(MMAL_DEINTERLACE_ADV, false, MMAL_DEINTERLACE_ADV_TEXT,
@@ -418,9 +416,8 @@ static const struct vlc_filter_operations filter_pass_ops = {
     .filter_video = pass_deinterlace, .close = CloseMmalDeinterlace,
 };
 
-static int OpenMmalDeinterlace(vlc_object_t *p_this)
+static int OpenMmalDeinterlace(filter_t *filter)
 {
-    filter_t *filter = (filter_t*)p_this;
     int32_t frame_duration = filter->fmt_in.video.i_frame_rate != 0 ?
             CLOCK_FREQ * filter->fmt_in.video.i_frame_rate_base /
             filter->fmt_in.video.i_frame_rate : 0;
diff --git a/modules/hw/vaapi/filters.c b/modules/hw/vaapi/filters.c
index e9a7768cf8..de79b4b663 100644
--- a/modules/hw/vaapi/filters.c
+++ b/modules/hw/vaapi/filters.c
@@ -1096,10 +1096,9 @@ static const struct vlc_filter_operations Deinterlace_ops = {
 };
 
 static int
-OpenDeinterlace(vlc_object_t * obj)
+OpenDeinterlace(filter_t *filter)
 {
     VAProcPipelineCaps          pipeline_caps;
-    filter_t *const             filter = (filter_t *)obj;
     struct deint_data *const    p_data = calloc(1, sizeof(*p_data));
     if (!p_data)
         return VLC_ENOMEM;
@@ -1146,8 +1145,7 @@ vlc_module_begin()
     add_shortcut("adjust")
 
     add_submodule()
-    set_callback(OpenDeinterlace)
-    add_shortcut("deinterlace")
+    set_deinterlace_callback(OpenDeinterlace)
 
     add_submodule()
     set_callback(OpenDenoiseFilter)
diff --git a/modules/hw/vdpau/deinterlace.c b/modules/hw/vdpau/deinterlace.c
index f14ed515a0..c2c4f85083 100644
--- a/modules/hw/vdpau/deinterlace.c
+++ b/modules/hw/vdpau/deinterlace.c
@@ -106,10 +106,8 @@ static const struct vlc_filter_operations filter_ops = {
     .filter_video = Deinterlace, .close = Close,
 };
 
-static int Open(vlc_object_t *obj)
+static int Open(filter_t *filter)
 {
-    filter_t *filter = (filter_t *)obj;
-
     if ( filter->vctx_in == NULL ||
          vlc_video_context_GetType(filter->vctx_in) != VLC_VIDEO_CONTEXT_VDPAU )
         return VLC_EGENERIC;
@@ -138,9 +136,7 @@ static int Open(vlc_object_t *obj)
 
 vlc_module_begin()
     set_description(N_("VDPAU deinterlacing filter"))
-    set_capability("video filter", 0)
     set_category(CAT_VIDEO)
     set_subcategory(SUBCAT_VIDEO_VFILTER)
-    set_callback(Open)
-    add_shortcut ("deinterlace")
+    set_deinterlace_callback(Open)
 vlc_module_end()
diff --git a/modules/video_filter/deinterlace/deinterlace.c b/modules/video_filter/deinterlace/deinterlace.c
index 4822377e2c..62bd077c0a 100644
--- a/modules/video_filter/deinterlace/deinterlace.c
+++ b/modules/video_filter/deinterlace/deinterlace.c
@@ -106,7 +106,7 @@ static picture_t *Deinterlace( filter_t *p_filter, picture_t *p_pic );
  * Open() is atomic: if an error occurs, the state of p_this
  * is left as it was before the call to this function.
  *
- * @param p_this The filter instance as vlc_object_t.
+ * @param p_filter The filter instance.
  * @return VLC error code
  * @retval VLC_SUCCESS All ok, filter set up and started.
  * @retval VLC_ENOMEM Memory allocation error, initialization aborted.
@@ -114,7 +114,7 @@ static picture_t *Deinterlace( filter_t *p_filter, picture_t *p_pic );
  * @see IsChromaSupported()
  * @see SetFilterMethod()
  */
-static int Open( vlc_object_t *p_this );
+static int Open( filter_t *p_filter );
 
 /**
  * Resets the filter state, including resetting all algorithm-specific state
@@ -290,7 +290,6 @@ static int Mouse( filter_t *p_filter,
 vlc_module_begin ()
     set_description( N_("Deinterlacing video filter") )
     set_shortname( N_("Deinterlace" ))
-    set_capability( "video filter", 0 )
     set_category( CAT_VIDEO )
     set_subcategory( SUBCAT_VIDEO_VFILTER )
 
@@ -306,8 +305,7 @@ vlc_module_begin ()
                 PHOSPHOR_DIMMER_LONGTEXT, true )
         change_integer_list( phosphor_dimmer_list, phosphor_dimmer_list_text )
         change_safe ()
-    add_shortcut( "deinterlace" )
-    set_callback( Open )
+    set_deinterlace_callback( Open )
 vlc_module_end ()
 
 /*****************************************************************************
@@ -497,9 +495,8 @@ static const struct vlc_filter_operations filter_ops = {
  * Open
  *****************************************************************************/
 
-int Open( vlc_object_t *p_this )
+int Open( filter_t *p_filter )
 {
-    filter_t *p_filter = (filter_t*)p_this;
     filter_sys_t *p_sys;
 
     const vlc_fourcc_t fourcc = p_filter->fmt_in.video.i_chroma;



More information about the vlc-commits mailing list