[vlc-devel] [PATCH 18/26] transcode: simplify encoder test opening

Steve Lhomme robux4 at ycbcr.xyz
Mon Jan 18 08:32:57 UTC 2021


The input ES format is already set to the same value in encoder_t::fmt_in so
no need to pass it again in the test functions. Only the input i_codec value
may not be initialized to the value that was set in the test function.
---
 modules/stream_out/transcode/audio.c                | 1 -
 modules/stream_out/transcode/encoder/audio.c        | 6 ++----
 modules/stream_out/transcode/encoder/encoder.c      | 7 +++----
 modules/stream_out/transcode/encoder/encoder.h      | 1 -
 modules/stream_out/transcode/encoder/encoder_priv.h | 2 --
 modules/stream_out/transcode/encoder/video.c        | 6 ++----
 modules/stream_out/transcode/video.c                | 1 -
 7 files changed, 7 insertions(+), 17 deletions(-)

diff --git a/modules/stream_out/transcode/audio.c b/modules/stream_out/transcode/audio.c
index 538869471b3..899d650a3a5 100644
--- a/modules/stream_out/transcode/audio.c
+++ b/modules/stream_out/transcode/audio.c
@@ -168,7 +168,6 @@ int transcode_audio_init( sout_stream_t *p_stream, const es_format_t *p_fmt,
     if( transcode_encoder_test( sout_EncoderCreate(p_stream, sizeof(encoder_t),
                                                    &id->decoder_out),
                                 id->p_enccfg,
-                                &id->decoder_out,
                                 id->p_decoder->fmt_out.i_codec,
                                 &encoder_tested_fmt_in ) )
     {
diff --git a/modules/stream_out/transcode/encoder/audio.c b/modules/stream_out/transcode/encoder/audio.c
index 6a37b0e37a8..46f12c001c2 100644
--- a/modules/stream_out/transcode/encoder/audio.c
+++ b/modules/stream_out/transcode/encoder/audio.c
@@ -132,19 +132,17 @@ int transcode_encoder_audio_configure( const transcode_encoder_config_t *p_cfg,
 
 int transcode_encoder_audio_test( encoder_t *p_encoder,
                                   const transcode_encoder_config_t *p_cfg,
-                                  const es_format_t *p_dec_out,
                                   vlc_fourcc_t i_codec_in,
                                   es_format_t *p_enc_wanted_in )
 {
     p_encoder->p_cfg = p_cfg->p_config_chain;
 
-    es_format_Init( &p_encoder->fmt_in, AUDIO_ES, i_codec_in );
-    p_encoder->fmt_in.audio = p_dec_out->audio;
+    p_encoder->fmt_in.i_codec = i_codec_in;
     es_format_Init( &p_encoder->fmt_out, AUDIO_ES, p_cfg->i_codec );
 
     audio_format_t *p_afmt_out = &p_encoder->fmt_out.audio;
 
-    if( encoder_audio_configure( p_cfg, &p_dec_out->audio, p_encoder, false ) )
+    if( encoder_audio_configure( p_cfg, &p_encoder->fmt_in.audio, p_encoder, false ) )
     {
         sout_EncoderDelete( p_encoder );
         return VLC_EGENERIC;
diff --git a/modules/stream_out/transcode/encoder/encoder.c b/modules/stream_out/transcode/encoder/encoder.c
index a88277f24c4..1d953c0a578 100644
--- a/modules/stream_out/transcode/encoder/encoder.c
+++ b/modules/stream_out/transcode/encoder/encoder.c
@@ -217,20 +217,19 @@ int transcode_encoder_drain( transcode_encoder_t *p_enc, block_t **out )
 
 int transcode_encoder_test( encoder_t *p_encoder,
                             const transcode_encoder_config_t *p_cfg,
-                            const es_format_t *p_dec_fmtin,
                             vlc_fourcc_t i_codec_in,
                             es_format_t *p_enc_wanted_in )
 {
     if( !p_encoder )
         return VLC_EGENERIC;
 
-    switch ( p_dec_fmtin->i_cat )
+    switch ( p_encoder->fmt_in.i_cat )
     {
         case VIDEO_ES:
-            return transcode_encoder_video_test( p_encoder, p_cfg, p_dec_fmtin,
+            return transcode_encoder_video_test( p_encoder, p_cfg,
                                                  i_codec_in, p_enc_wanted_in );
         case AUDIO_ES:
-            return transcode_encoder_audio_test( p_encoder, p_cfg, p_dec_fmtin,
+            return transcode_encoder_audio_test( p_encoder, p_cfg,
                                                  i_codec_in, p_enc_wanted_in );
         default:
             return VLC_EGENERIC;
diff --git a/modules/stream_out/transcode/encoder/encoder.h b/modules/stream_out/transcode/encoder/encoder.h
index 22b1d7d1b2c..1b20fb9510e 100644
--- a/modules/stream_out/transcode/encoder/encoder.h
+++ b/modules/stream_out/transcode/encoder/encoder.h
@@ -81,7 +81,6 @@ int transcode_encoder_drain( transcode_encoder_t *, block_t ** );
 
 int transcode_encoder_test( encoder_t *p_encoder,
                             const transcode_encoder_config_t *p_cfg,
-                            const es_format_t *p_dec_fmtin,
                             vlc_fourcc_t i_codec_in,
                             es_format_t *p_enc_wanted_in );
 
diff --git a/modules/stream_out/transcode/encoder/encoder_priv.h b/modules/stream_out/transcode/encoder/encoder_priv.h
index 7da2b02670d..b5f9bf6d2e0 100644
--- a/modules/stream_out/transcode/encoder/encoder_priv.h
+++ b/modules/stream_out/transcode/encoder/encoder_priv.h
@@ -51,12 +51,10 @@ int transcode_encoder_video_drain( transcode_encoder_t *p_enc, block_t **out );
 
 int transcode_encoder_video_test( encoder_t *p_encoder,
                                   const transcode_encoder_config_t *p_cfg,
-                                  const es_format_t *p_dec_fmtin,
                                   vlc_fourcc_t i_codec_in,
                                   es_format_t *p_enc_wanted_in );
 
 int transcode_encoder_audio_test( encoder_t *p_encoder,
                                   const transcode_encoder_config_t *p_cfg,
-                                  const es_format_t *p_dec_out,
                                   vlc_fourcc_t i_codec_in,
                                   es_format_t *p_enc_wanted_in );
diff --git a/modules/stream_out/transcode/encoder/video.c b/modules/stream_out/transcode/encoder/video.c
index 68e10ec8bac..80f97829ae3 100644
--- a/modules/stream_out/transcode/encoder/video.c
+++ b/modules/stream_out/transcode/encoder/video.c
@@ -297,17 +297,15 @@ void transcode_encoder_video_configure( vlc_object_t *p_obj,
 
 int transcode_encoder_video_test( encoder_t *p_encoder,
                                   const transcode_encoder_config_t *p_cfg,
-                                  const es_format_t *p_dec_fmtin,
                                   vlc_fourcc_t i_codec_in,
                                   es_format_t *p_enc_wanted_in )
 {
     p_encoder->i_threads = p_cfg->video.threads.i_count;
     p_encoder->p_cfg = p_cfg->p_config_chain;
 
-    es_format_Init( &p_encoder->fmt_in, VIDEO_ES, i_codec_in );
+    p_encoder->fmt_in.i_codec = i_codec_in;
     es_format_Init( &p_encoder->fmt_out, VIDEO_ES, p_cfg->i_codec );
 
-    const video_format_t *p_dec_in = &p_dec_fmtin->video;
     video_format_t *p_vfmt_in = &p_encoder->fmt_in.video;
     video_format_t *p_vfmt_out = &p_encoder->fmt_out.video;
 
@@ -318,7 +316,7 @@ int transcode_encoder_video_test( encoder_t *p_encoder,
      * Just put sensible values so we can test an encoder is available. */
     /* Input */
     p_vfmt_in->i_chroma = i_codec_in;
-    transcode_video_size_config_apply(VLC_OBJECT(p_encoder), p_dec_in, p_cfg, p_vfmt_in);
+    transcode_video_size_config_apply(VLC_OBJECT(p_encoder), p_vfmt_in, p_cfg, p_vfmt_in);
     p_vfmt_in->i_frame_rate = ENC_FRAMERATE;
     p_vfmt_in->i_frame_rate_base = ENC_FRAMERATE_BASE;
 
diff --git a/modules/stream_out/transcode/video.c b/modules/stream_out/transcode/video.c
index ed84dfbb476..a434c759c30 100644
--- a/modules/stream_out/transcode/video.c
+++ b/modules/stream_out/transcode/video.c
@@ -233,7 +233,6 @@ int transcode_video_init( sout_stream_t *p_stream, const es_format_t *p_fmt,
 
     if( transcode_encoder_test( &p_enc_owner->enc,
                                 id->p_enccfg,
-                                &id->p_decoder->fmt_in,
                                 id->p_decoder->fmt_out.i_codec,
                                 &encoder_tested_fmt_in ) )
        goto error;
-- 
2.29.2



More information about the vlc-devel mailing list