[vlc-devel] [PATCH v1 07/33] filter: allow using filters with a sink callback to filter into a single picture

Steve Lhomme robux4 at ycbcr.xyz
Fri Sep 25 16:46:43 CEST 2020


If a filter sending pictures to a sink send more than one picture to a sink,
the code will assert. It means filter_FilterSingle was used with a filter that
sends more than one picture. So filter_FilterSingle() should only be used with
safe filters, ie not user defined ones bu mostly converters. This is already
the case.
---
 include/vlc_filter.h | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/include/vlc_filter.h b/include/vlc_filter.h
index 9f8da434fd4..e660e8c6d18 100644
--- a/include/vlc_filter.h
+++ b/include/vlc_filter.h
@@ -219,8 +219,23 @@ static inline picture_t *filter_NewPicture( filter_t *p_filter )
     return pic;
 }
 
+static inline int GetSingleResult(struct vlc_video_sink *sink, picture_t *output)
+{
+    picture_t **single_output = (picture_t **)sink->sys;
+    vlc_assert(*single_output == NULL); // called filter_FilterSingle on wrong filter
+    *single_output = output;
+    return VLC_SUCCESS;
+}
+
 static inline picture_t *filter_FilterSingle( filter_t *p_filter, picture_t *pic )
 {
+    if ( p_filter->pf_video_filter_into != NULL )
+    {
+        picture_t *result = NULL;
+        struct vlc_video_sink sink = { &result, GetSingleResult };
+        p_filter->pf_video_filter_into( p_filter, pic, &sink );
+        return result;
+    }
     return p_filter->pf_video_filter( p_filter, pic );
 }
 
-- 
2.26.2



More information about the vlc-devel mailing list