[vlc-devel] [PATCH 2/6] transcode: use the final converter to apply the scaling

Steve Lhomme robux4 at ycbcr.xyz
Thu Jan 14 13:54:24 UTC 2021


df0a715f3ffda6e7fb00b9ae6b70b438044db821 assumed the converter would do the
scaling, in addition to codec/chroma converters and orientation. But the code
to do it properly was missing.

We do not update the encoder source format anymore when the static/user filters
are added. The encoder should still encode at the size requested, regardless of
the extra filters. It may however use a different input codec/chroma if this
one wasn't forced.

The converter is always adapting between the decoder output (with the video
context in the picture) and the encoder input.

Fixes #25362
---
 modules/stream_out/transcode/video.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/modules/stream_out/transcode/video.c b/modules/stream_out/transcode/video.c
index db9998630a6..1eb26cc292f 100644
--- a/modules/stream_out/transcode/video.c
+++ b/modules/stream_out/transcode/video.c
@@ -524,10 +524,12 @@ int transcode_video_process( sout_stream_t *p_stream, sout_stream_id_sys_t *id,
             /* The fmt_in may have been overriden by the encoder. */
             const es_format_t *encoder_fmt_in = transcode_encoder_format_in( id->encoder );
 
-            /* In case the encoder wasn't open yet, check if we need to add
-             * a converter between last user filter and encoder. */
-            if( !is_encoder_open &&
-                filter_fmt_out.i_codec != encoder_fmt_in->i_codec )
+            /* check if we need to add a converter between last user filter and encoder. */
+            if( filter_fmt_out.i_codec != encoder_fmt_in->i_codec ||
+                id->decoder_out.video.i_width  != encoder_fmt_in->video.i_width ||
+                id->decoder_out.video.i_height != encoder_fmt_in->video.i_height ||
+                id->decoder_out.video.i_visible_width  != encoder_fmt_in->video.i_visible_width ||
+                id->decoder_out.video.i_visible_height != encoder_fmt_in->video.i_visible_height )
             {
                 if ( !id->p_final_conv_static )
                     id->p_final_conv_static =
@@ -544,9 +546,8 @@ int transcode_video_process( sout_stream_t *p_stream, sout_stream_id_sys_t *id,
                 }
 
                 filter_chain_Reset( id->p_final_conv_static,
-                                    p_fmt_filtered,
-                                    //encoder_vctx_in,
-                                    NULL,
+                                    &id->decoder_out,
+                                    picture_GetVideoContext(p_pic),
                                     encoder_fmt_in );
                 filter_chain_AppendConverter( id->p_final_conv_static, NULL );
             }
-- 
2.29.2



More information about the vlc-devel mailing list