[vlc-devel] [PATCH 2/2] filter_chain: set NULL on AppendConverter output when value is implied by previous call

Steve Lhomme robux4 at ycbcr.xyz
Fri Nov 15 10:22:22 CET 2019


Either because Reset() set the same input value or the we're using the same
value set by the previous AppendXXX().

I transcode we init the test chain to the output we really want rather than one
we're never going to use.
---
 include/vlc_filter.h                 | 2 +-
 modules/stream_out/sdi/SDIStream.cpp | 2 +-
 modules/stream_out/transcode/video.c | 6 +++---
 modules/video_chroma/chain.c         | 4 ++--
 src/video_output/display.c           | 2 +-
 src/video_output/video_output.c      | 2 +-
 6 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/include/vlc_filter.h b/include/vlc_filter.h
index 9a8331aee97..244d03becae 100644
--- a/include/vlc_filter.h
+++ b/include/vlc_filter.h
@@ -380,7 +380,7 @@ VLC_API filter_t *filter_chain_AppendFilter(filter_chain_t *chain,
  * Append a conversion to the chain.
  *
  * \param chain filter chain to append a filter to
- * \param fmt_out filter output format
+ * \param fmt_out forced output format or NULL for the default chain output
  * \retval 0 on success
  * \retval -1 on failure
  */
diff --git a/modules/stream_out/sdi/SDIStream.cpp b/modules/stream_out/sdi/SDIStream.cpp
index 344eb83211b..4c445e5d79c 100644
--- a/modules/stream_out/sdi/SDIStream.cpp
+++ b/modules/stream_out/sdi/SDIStream.cpp
@@ -517,7 +517,7 @@ filter_chain_t * VideoDecodedStream::VideoFilterCreate(const es_format_t *p_srcf
 
     if(p_srcfmt->video.i_chroma != requestedoutput.video.i_chroma)
     {
-        if(filter_chain_AppendConverter(p_chain, &requestedoutput) != VLC_SUCCESS)
+        if(filter_chain_AppendConverter(p_chain, NULL) != VLC_SUCCESS)
         {
             filter_chain_Delete(p_chain);
             return NULL;
diff --git a/modules/stream_out/transcode/video.c b/modules/stream_out/transcode/video.c
index b1754ca23ac..1503808411c 100644
--- a/modules/stream_out/transcode/video.c
+++ b/modules/stream_out/transcode/video.c
@@ -99,9 +99,9 @@ static int video_update_format_decoder( decoder_t *p_dec, vlc_video_context *vct
     msg_Dbg( p_obj, "Checking if filter chain %4.4s -> %4.4s is possible",
                  (char *)&p_dec->fmt_out.i_codec, (char*)&p_enc_in->i_codec );
     test_chain = filter_chain_NewVideo( p_obj, false, NULL );
-    filter_chain_Reset( test_chain, &p_dec->fmt_out, &p_dec->fmt_out );
+    filter_chain_Reset( test_chain, &p_dec->fmt_out, p_enc_in );
 
-    int chain_works = filter_chain_AppendConverter( test_chain, p_enc_in );
+    int chain_works = filter_chain_AppendConverter( test_chain, NULL );
     filter_chain_Delete( test_chain );
 
     msg_Dbg( p_obj, "Filter chain testing done, input chroma %4.4s seems to be %s for transcode",
@@ -289,7 +289,7 @@ static int transcode_video_set_conversions( sout_stream_t *p_stream,
             return VLC_EGENERIC;
         filter_chain_Reset( *pp_chain, *pp_src, p_tmpdst );
 
-        if( filter_chain_AppendConverter( *pp_chain, p_tmpdst ) != VLC_SUCCESS )
+        if( filter_chain_AppendConverter( *pp_chain, NULL ) != VLC_SUCCESS )
             return VLC_EGENERIC;
 
         *pp_src = filter_chain_GetFmtOut( *pp_chain );
diff --git a/modules/video_chroma/chain.c b/modules/video_chroma/chain.c
index c4364e8ab7e..a1ff31c1ab9 100644
--- a/modules/video_chroma/chain.c
+++ b/modules/video_chroma/chain.c
@@ -447,7 +447,7 @@ static int CreateChain( filter_t *p_filter, const es_format_t *p_fmt_mid )
     }
     else
     {
-        if( filter_chain_AppendConverter( p_sys->p_chain, &p_filter->fmt_out ) )
+        if( filter_chain_AppendConverter( p_sys->p_chain, NULL) )
             goto error;
     }
     return VLC_SUCCESS;
@@ -481,7 +481,7 @@ static int CreateResizeChromaChain( filter_t *p_filter, const es_format_t *p_fmt
         es_format_Clean( &fmt_out );
     }
     else
-        i_ret = filter_chain_AppendConverter( p_sys->p_chain, &p_filter->fmt_out );
+        i_ret = filter_chain_AppendConverter( p_sys->p_chain, NULL );
 
     if( i_ret != VLC_SUCCESS )
         filter_chain_Clear( p_sys->p_chain );
diff --git a/src/video_output/display.c b/src/video_output/display.c
index eaaa4c3246c..bce7f56ba49 100644
--- a/src/video_output/display.c
+++ b/src/video_output/display.c
@@ -338,7 +338,7 @@ static int VoutDisplayCreateRender(vout_display_t *vd)
         es_format_InitFromVideo(&dst, i == 0 ? &v_dst : &v_dst_cmp);
 
         filter_chain_Reset(osys->converters, &src, &dst);
-        ret = filter_chain_AppendConverter(osys->converters, &dst);
+        ret = filter_chain_AppendConverter(osys->converters, NULL);
         es_format_Clean(&dst);
         if (ret == 0)
             break;
diff --git a/src/video_output/video_output.c b/src/video_output/video_output.c
index 0bbf45a7658..7409002735c 100644
--- a/src/video_output/video_output.c
+++ b/src/video_output/video_output.c
@@ -979,7 +979,7 @@ static picture_t *ConvertRGB32AndBlend(vout_thread_t *vout, picture_t *pic,
 
     filter_chain_Reset(filterc, &src, &dst);
 
-    if (filter_chain_AppendConverter(filterc, &dst) != 0)
+    if (filter_chain_AppendConverter(filterc, NULL) != 0)
     {
         filter_chain_Delete(filterc);
         return NULL;
-- 
2.17.1



More information about the vlc-devel mailing list