[vlc-devel] [PATCH 1/2] filter: declare the filter function called in video filter wrappers

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


By default it declares a static function. There are new variants for the rare
cases where the function is not static.

For now the function to call cannot return an error to match the existing usage.

Also declare the close function to make sure there's more warnings when it's
used with the wrong callback signature.
---
 include/vlc_filter.h            | 23 +++++++++++++++++++++--
 modules/video_chroma/i420_rgb.c | 18 +++++++++---------
 2 files changed, 30 insertions(+), 11 deletions(-)

diff --git a/include/vlc_filter.h b/include/vlc_filter.h
index 88df8ae5daa..1f130bcb7a1 100644
--- a/include/vlc_filter.h
+++ b/include/vlc_filter.h
@@ -354,7 +354,7 @@ VLC_API void filter_DeleteBlend( vlc_blender_t * );
  *
  * Currently used by the chroma video filters
  */
-#define VIDEO_FILTER_WRAPPER_CLOSE( name, close_cb )                    \
+#define VIDEO_FILTER_WRAPPER_CLOSE_FILT( name, close_cb )               \
     static picture_t *name ## _Filter ( filter_t *p_filter,             \
                                         picture_t *p_pic )              \
     {                                                                   \
@@ -371,7 +371,26 @@ VLC_API void filter_DeleteBlend( vlc_blender_t * );
         .filter_video = name ## _Filter, .close = close_cb,             \
     };
 
-#define VIDEO_FILTER_WRAPPER( name )   VIDEO_FILTER_WRAPPER_CLOSE( name, NULL )
+#define VIDEO_FILTER_WRAPPER_CLOSE( name, close_cb )                    \
+    static void name (filter_t *, picture_t *, picture_t *);            \
+    static void close_cb (filter_t *);                                  \
+    VIDEO_FILTER_WRAPPER_CLOSE_FILT( name, close_cb )
+
+#define VIDEO_FILTER_WRAPPER( name )                                    \
+    static void name (filter_t *, picture_t *, picture_t *);            \
+    VIDEO_FILTER_WRAPPER_CLOSE_FILT( name, NULL )
+
+/**
+ * Wrappers to use when the filter function is not a static function
+ */
+#define VIDEO_FILTER_WRAPPER_EXT( name )                                \
+    void name (filter_t *, picture_t *, picture_t *);                   \
+    VIDEO_FILTER_WRAPPER_CLOSE_FILT( name, NULL )
+
+#define VIDEO_FILTER_WRAPPER_CLOSE_EXT( name, close_cb )                \
+    void name (filter_t *, picture_t *, picture_t *);                   \
+    static void close_cb (filter_t *);                                  \
+    VIDEO_FILTER_WRAPPER_CLOSE_FILT( name, close_cb )
 
 /**
  * Filter chain management API
diff --git a/modules/video_chroma/i420_rgb.c b/modules/video_chroma/i420_rgb.c
index 4ea5e2cec8c..dc79754f6ad 100644
--- a/modules/video_chroma/i420_rgb.c
+++ b/modules/video_chroma/i420_rgb.c
@@ -78,16 +78,16 @@ vlc_module_begin ()
 vlc_module_end ()
 
 #ifndef PLAIN
-VIDEO_FILTER_WRAPPER_CLOSE( I420_R5G5B5, Deactivate )
-VIDEO_FILTER_WRAPPER_CLOSE( I420_R5G6B5, Deactivate )
-VIDEO_FILTER_WRAPPER_CLOSE( I420_A8R8G8B8, Deactivate )
-VIDEO_FILTER_WRAPPER_CLOSE( I420_R8G8B8A8, Deactivate )
-VIDEO_FILTER_WRAPPER_CLOSE( I420_B8G8R8A8, Deactivate )
-VIDEO_FILTER_WRAPPER_CLOSE( I420_A8B8G8R8, Deactivate )
+VIDEO_FILTER_WRAPPER_CLOSE_EXT( I420_R5G5B5, Deactivate )
+VIDEO_FILTER_WRAPPER_CLOSE_EXT( I420_R5G6B5, Deactivate )
+VIDEO_FILTER_WRAPPER_CLOSE_EXT( I420_A8R8G8B8, Deactivate )
+VIDEO_FILTER_WRAPPER_CLOSE_EXT( I420_R8G8B8A8, Deactivate )
+VIDEO_FILTER_WRAPPER_CLOSE_EXT( I420_B8G8R8A8, Deactivate )
+VIDEO_FILTER_WRAPPER_CLOSE_EXT( I420_A8B8G8R8, Deactivate )
 #else
-VIDEO_FILTER_WRAPPER_CLOSE( I420_RGB8, Deactivate )
-VIDEO_FILTER_WRAPPER_CLOSE( I420_RGB16, Deactivate )
-VIDEO_FILTER_WRAPPER_CLOSE( I420_RGB32, Deactivate )
+VIDEO_FILTER_WRAPPER_CLOSE_EXT( I420_RGB8, Deactivate )
+VIDEO_FILTER_WRAPPER_CLOSE_EXT( I420_RGB16, Deactivate )
+VIDEO_FILTER_WRAPPER_CLOSE_EXT( I420_RGB32, Deactivate )
 #endif
 
 /*****************************************************************************
-- 
2.26.2



More information about the vlc-devel mailing list