[vlc-devel] [PATCH 19/19] filter_chain: rework filter_chain_VideoDrain()

Steve Lhomme robux4 at ycbcr.xyz
Tue Oct 13 15:52:02 CEST 2020


>From the last filter in the chain to the first we:

- drain to get a picture
- if there is a picture we use it to filter it
- if we have a picture from running all the filters, we return it
- otherwise we

Remove unused FilterChainVideoFilter.
---
 src/misc/filter_chain.c | 42 +++++++++++++++++------------------------
 1 file changed, 17 insertions(+), 25 deletions(-)

diff --git a/src/misc/filter_chain.c b/src/misc/filter_chain.c
index 2cafacfe090..5c83468c4c9 100644
--- a/src/misc/filter_chain.c
+++ b/src/misc/filter_chain.c
@@ -426,24 +426,6 @@ vlc_video_context *filter_chain_GetVideoCtxOut(const filter_chain_t *p_chain)
     return p_chain->vctx_in;
 }
 
-static picture_t *FilterChainVideoFilter( chained_filter_t *f, picture_t *p_pic )
-{
-    for( ; f != NULL; f = f->next )
-    {
-        filter_t *p_filter = &f->filter;
-        p_pic = p_filter->ops->filter_video( p_filter, p_pic );
-        if( !p_pic )
-            break;
-        if( !vlc_picture_chain_IsEmpty( &f->pending ) )
-        {
-            msg_Warn( p_filter, "dropping pictures" );
-            FilterDeletePictures( &f->pending );
-        }
-        f->pending = picture_GetAndResetChain( p_pic );
-    }
-    return p_pic;
-}
-
 static picture_t *filter_chained( chained_filter_t *f, picture_t *p_pic )
 {
     for( ; f != NULL; f = f->next )
@@ -462,16 +444,26 @@ picture_t *filter_chain_VideoFilter( filter_chain_t *p_chain, picture_t *p_pic )
 
 picture_t *filter_chain_VideoDrain(filter_chain_t *p_chain)
 {
-    picture_t *p_pic;
-    for( chained_filter_t *b = p_chain->last; b != NULL; b = b->prev )
+    for( chained_filter_t *b = p_chain->last; b != NULL; )
     {
-        if( vlc_picture_chain_IsEmpty( &b->pending ) )
+        picture_t *p_pic = filter_DrainVideo( &b->filter );
+        if ( p_pic )
+        {
+            // we have a picture, feed it down the chain
+            p_pic = filter_chained( b->next, p_pic );
+
+            if ( p_pic )
+                // all filters produced a picture, we can return it
+                return p_pic;
+
+            // b drains picture, keep draining pictures until it's dry
+            // we assume the next filters won't produce a picture since
+            // they didn't produce one with a regular picture
             continue;
-        p_pic = vlc_picture_chain_PopFront( &b->pending );
+        }
 
-        p_pic = FilterChainVideoFilter( b->next, p_pic );
-        if( p_pic )
-            return p_pic;
+        // we don't have a picture from b, drain from further up in the chain
+        b = b->prev;
     }
     return NULL;
 }
-- 
2.26.2



More information about the vlc-devel mailing list