[vlc-devel] [PATCH 7/7] filters: use macro to set the typed Open callback for video blending filters

Steve Lhomme robux4 at ycbcr.xyz
Mon Oct 12 15:59:15 CEST 2020


---
 include/vlc_filter.h           | 11 ++++++++++-
 modules/video_filter/blend.cpp |  8 +++-----
 2 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/include/vlc_filter.h b/include/vlc_filter.h
index d9eb54e72e2..9d5e3541a44 100644
--- a/include/vlc_filter.h
+++ b/include/vlc_filter.h
@@ -90,7 +90,7 @@ struct vlc_filter_operations
         /** Filter an audio block (audio filter) */
         block_t * (*filter_audio)(filter_t *, block_t *);
 
-        /** Blend a subpicture onto a picture (blend) */
+        /** Blend a subpicture onto a picture (video blending) */
         void (*blend_video)(filter_t *,  picture_t *, const picture_t *,
                             int, int, int);
 
@@ -146,6 +146,7 @@ typedef int (*vlc_video_filter_open)(filter_t *);
 typedef int (*vlc_video_text_renderer_open)(filter_t *);
 typedef int (*vlc_video_sub_filter_open)(filter_t *);
 typedef int (*vlc_video_sub_source_open)(filter_t *);
+typedef int (*vlc_video_blending_open)(filter_t *);
 
 
 #define set_deinterlace_callback( activate )     \
@@ -197,6 +198,14 @@ typedef int (*vlc_video_sub_source_open)(filter_t *);
     }                                                      \
     set_capability( "sub source", priority )
 
+#define set_callback_video_blending( activate, priority )  \
+    {                                                      \
+        vlc_video_blending_open open__ = activate;         \
+        (void) open__;                                     \
+        set_callback(activate)                             \
+    }                                                      \
+    set_capability( "video blending", priority )
+
 /** 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/video_filter/blend.cpp b/modules/video_filter/blend.cpp
index dd5860022b7..c2fd6d21cf8 100644
--- a/modules/video_filter/blend.cpp
+++ b/modules/video_filter/blend.cpp
@@ -36,13 +36,12 @@
 /*****************************************************************************
  * Module descriptor
  *****************************************************************************/
-static int  Open (vlc_object_t *);
+static int  Open (filter_t *);
 static void Close(filter_t *);
 
 vlc_module_begin()
     set_description(N_("Video pictures blending"))
-    set_capability("video blending", 100)
-    set_callback(Open)
+    set_callback_video_blending(Open, 100)
 vlc_module_end()
 
 static inline unsigned div255(unsigned v)
@@ -689,9 +688,8 @@ static const struct FilterOperationInitializer {
     };
 } filter_ops;
 
-static int Open(vlc_object_t *object)
+static int Open(filter_t *filter)
 {
-    filter_t *filter = (filter_t *)object;
     const vlc_fourcc_t src = filter->fmt_in.video.i_chroma;
     const vlc_fourcc_t dst = filter->fmt_out.video.i_chroma;
 
-- 
2.26.2



More information about the vlc-devel mailing list