[vlc-devel] [PATCH 09/15] filter_chain: rename some variables and add some comments

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


The local picture allocation is a hack for intermediate filters not using the
same video format as the output (often the case).
---
 src/misc/filter_chain.c | 20 +++++++++-----------
 1 file changed, 9 insertions(+), 11 deletions(-)

diff --git a/src/misc/filter_chain.c b/src/misc/filter_chain.c
index d18ddcbd46..839df34ceb 100644
--- a/src/misc/filter_chain.c
+++ b/src/misc/filter_chain.c
@@ -42,12 +42,6 @@ typedef struct chained_filter_t
     picture_t *pending;
 } chained_filter_t;
 
-/* Only use this with filter objects from _this_ C module */
-static inline chained_filter_t *chained(filter_t *filter)
-{
-    return container_of(filter, chained_filter_t, filter);
-}
-
 /* */
 struct filter_chain_t
 {
@@ -104,19 +98,23 @@ 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 )
+static picture_t *filter_chain_VideoBufferNew( filter_t *chained_filter, void *sys )
 {
     filter_chain_t *chain = sys;
-    if( chained(filter)->next != NULL ||
+    chained_filter_t *chained = container_of(chained_filter, chained_filter_t, filter);
+    if( chained->next != NULL ||
         chain->owner.video == NULL || chain->owner.video->buffer_new == NULL )
     {
-        picture_t *pic = picture_NewFromFormat( &filter->fmt_out.video );
+        // HACK as intermediate filters may not have the same video format as
+        // the last one handled by the owner
+        picture_t *pic = picture_NewFromFormat( &chained_filter->fmt_out.video );
         if( pic == NULL )
-            msg_Err( filter, "Failed to allocate picture" );
+            msg_Err( chained_filter, "Failed to allocate picture" );
         return pic;
     }
 
-    return chain->owner.video->buffer_new( filter, chain->owner.sys );
+    // the owner of the chain requires pictures to be grabbed from its callback
+    return chain->owner.video->buffer_new( chained_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