[vlc-devel] [PATCH 17/19] transcode: video: drain all filter chains sequentially until they're dry

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


Loop while there are pictures to encode.

- Start by filtering the first picture through each filter chain, and encode
the result.
- Then drain the first (non-null) filter chain and pass the result through
the other filter chain, and encode the result.
- Then drain the second (non-null) filter chain and pass the result through
the other filter chain, and encode the result.
- And so on, until there is no more filtered pictures to encode.
---
 modules/stream_out/transcode/video.c | 24 ++++++++++--------------
 1 file changed, 10 insertions(+), 14 deletions(-)

diff --git a/modules/stream_out/transcode/video.c b/modules/stream_out/transcode/video.c
index 147db4086e6..e15e8b34c19 100644
--- a/modules/stream_out/transcode/video.c
+++ b/modules/stream_out/transcode/video.c
@@ -573,23 +573,19 @@ int transcode_video_process( sout_stream_t *p_stream, sout_stream_id_sys_t *id,
          * and then with NULL as many times as we need until they
          * stop outputting frames.
          */
-        for ( picture_t *p_in = p_pic; ; p_in = NULL /* drain second time */ )
+        for ( picture_t *p_in = p_pic; ; p_in = NULL /* keep draining */ )
         {
-            /* Run filter chain */
-            if( id->p_f_chain )
-                p_in = filter_chain_VideoFilter( id->p_f_chain, p_in );
-
-            if( !p_in )
-                break;
-
-            /* Run user specified filter chain */
-            filter_chain_t * secondary_chains[] = { id->p_uf_chain,
-                                                    id->p_final_conv_static };
-            for( size_t i=0; p_in && i<ARRAY_SIZE(secondary_chains); i++ )
+            filter_chain_t * chains[] = { id->p_f_chain,
+                                          id->p_uf_chain,
+                                          id->p_final_conv_static };
+            for( size_t i=0; i<ARRAY_SIZE(chains); i++ )
             {
-                if( !secondary_chains[i] )
+                if( !chains[i] )
                     continue;
-                p_in = filter_chain_VideoFilter( secondary_chains[i], p_in );
+                if ( p_in )
+                    p_in = filter_chain_VideoFilter( chains[i], p_in );
+                else
+                    p_in = filter_chain_VideoDrain( chains[i] );
             }
 
             if( !p_in )
-- 
2.26.2



More information about the vlc-devel mailing list