[vlc-devel] [PATCH 03/15] filter: allow the owner not to provide a buffer callback

Steve Lhomme robux4 at ycbcr.xyz
Fri Jul 19 15:32:07 CEST 2019


In this case we just allocate a picture from the filter output format.
---
 include/vlc_filter.h    |  7 ++++++-
 src/misc/filter_chain.c | 10 ++++------
 2 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/include/vlc_filter.h b/include/vlc_filter.h
index 5c2a82ed1d..849ba67851 100644
--- a/include/vlc_filter.h
+++ b/include/vlc_filter.h
@@ -26,6 +26,7 @@
 #define VLC_FILTER_H 1
 
 #include <vlc_es.h>
+#include <vlc_picture.h>
 
 /**
  * \defgroup filter Filters
@@ -160,7 +161,11 @@ struct filter_t
  */
 static inline picture_t *filter_NewPicture( filter_t *p_filter )
 {
-    picture_t *pic = p_filter->owner.video->buffer_new( p_filter, p_filter->owner.sys );
+    picture_t *pic;
+    if ( p_filter->owner.video == NULL || p_filter->owner.video->buffer_new == NULL)
+        pic = picture_NewFromFormat( &p_filter->fmt_out.video );
+    else
+        pic = p_filter->owner.video->buffer_new( p_filter, p_filter->owner.sys );
     if( pic == NULL )
         msg_Warn( p_filter, "can't get output picture" );
     return pic;
diff --git a/src/misc/filter_chain.c b/src/misc/filter_chain.c
index 7070ce9f8c..8069a3e6dd 100644
--- a/src/misc/filter_chain.c
+++ b/src/misc/filter_chain.c
@@ -110,19 +110,17 @@ filter_chain_t *filter_chain_NewSPU( vlc_object_t *obj, const char *cap )
 /** Chained filter picture allocator function */
 static picture_t *filter_chain_VideoBufferNew( filter_t *filter, void *sys )
 {
-    if( chained(filter)->next != NULL )
+    filter_chain_t *chain = sys;
+    if( chained(filter)->next != NULL ||
+        chain->owner.video == NULL || chain->owner.video->buffer_new == NULL )
     {
         picture_t *pic = picture_NewFromFormat( &filter->fmt_out.video );
         if( pic == NULL )
             msg_Err( filter, "Failed to allocate picture" );
         return pic;
     }
-    else
-    {
-        filter_chain_t *chain = sys;
 
-        return chain->owner.video->buffer_new( filter, chain->owner.sys );
-    }
+    return chain->owner.video->buffer_new( filter, chain->owner.sys );
 }
 
 static const struct filter_video_callbacks filter_chain_video_cbs =
-- 
2.17.1



More information about the vlc-devel mailing list