[vlc-commits] transcode: create the test encoder outside of the test function
Steve Lhomme
git at videolan.org
Wed Jan 8 12:47:24 CET 2020
vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Tue Aug 20 08:20:53 2019 +0200| [a9f29faf8d00fa53edf543e41813e34fc58810cc] | committer: Steve Lhomme
transcode: create the test encoder outside of the test function
This allows adding extra values not known to the encoder itself.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=a9f29faf8d00fa53edf543e41813e34fc58810cc
---
modules/stream_out/transcode/audio.c | 2 +-
modules/stream_out/transcode/encoder/audio.c | 8 ++------
modules/stream_out/transcode/encoder/encoder.c | 9 ++++++---
modules/stream_out/transcode/encoder/encoder.h | 2 +-
modules/stream_out/transcode/encoder/encoder_priv.h | 4 ++--
modules/stream_out/transcode/encoder/video.c | 8 ++------
modules/stream_out/transcode/video.c | 2 +-
7 files changed, 15 insertions(+), 20 deletions(-)
diff --git a/modules/stream_out/transcode/audio.c b/modules/stream_out/transcode/audio.c
index 1a8c6ddf8c..79a2a1af4e 100644
--- a/modules/stream_out/transcode/audio.c
+++ b/modules/stream_out/transcode/audio.c
@@ -165,7 +165,7 @@ int transcode_audio_init( sout_stream_t *p_stream, const es_format_t *p_fmt,
* This should be enough to initialize the encoder for the first time (it
* will be reloaded when all informations from the decoder are available).
* */
- if( transcode_encoder_test( VLC_OBJECT(p_stream),
+ if( transcode_encoder_test( sout_EncoderCreate(p_stream, sizeof(encoder_t)),
id->p_enccfg,
&id->decoder_out,
id->p_decoder->fmt_out.i_codec,
diff --git a/modules/stream_out/transcode/encoder/audio.c b/modules/stream_out/transcode/encoder/audio.c
index 5286ad5b21..2aa0c78859 100644
--- a/modules/stream_out/transcode/encoder/audio.c
+++ b/modules/stream_out/transcode/encoder/audio.c
@@ -139,16 +139,12 @@ int transcode_encoder_audio_configure( const transcode_encoder_config_t *p_cfg,
return encoder_audio_configure( p_cfg, p_dec_out, p_enc->p_encoder, b_keep_fmtin );
}
-int transcode_encoder_audio_test( vlc_object_t *p_obj,
+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 )
{
- encoder_t *p_encoder = sout_EncoderCreate( p_obj, sizeof(encoder_t) );
- if( !p_encoder )
- return VLC_EGENERIC;
-
p_encoder->p_cfg = p_cfg->p_config_chain;
es_format_Init( &p_encoder->fmt_in, AUDIO_ES, i_codec_in );
@@ -176,7 +172,7 @@ int transcode_encoder_audio_test( vlc_object_t *p_obj,
module_t *p_module = module_need( p_encoder, "encoder", p_cfg->psz_name, true );
if( !p_module )
{
- msg_Err( p_obj, "cannot find audio encoder (module:%s fourcc:%4.4s). "
+ msg_Err( p_encoder, "cannot find audio encoder (module:%s fourcc:%4.4s). "
"Take a look few lines earlier to see possible reason.",
p_cfg->psz_name ? p_cfg->psz_name : "any",
(char *)&p_cfg->i_codec );
diff --git a/modules/stream_out/transcode/encoder/encoder.c b/modules/stream_out/transcode/encoder/encoder.c
index 9d10dca3f1..e8ffb346ac 100644
--- a/modules/stream_out/transcode/encoder/encoder.c
+++ b/modules/stream_out/transcode/encoder/encoder.c
@@ -220,19 +220,22 @@ int transcode_encoder_drain( transcode_encoder_t *p_enc, block_t **out )
}
}
-int transcode_encoder_test( vlc_object_t *p_obj,
+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 )
{
case VIDEO_ES:
- return transcode_encoder_video_test( p_obj, p_cfg, p_dec_fmtin,
+ return transcode_encoder_video_test( p_encoder, p_cfg, p_dec_fmtin,
i_codec_in, p_enc_wanted_in );
case AUDIO_ES:
- return transcode_encoder_audio_test( p_obj, p_cfg, p_dec_fmtin,
+ return transcode_encoder_audio_test( p_encoder, p_cfg, p_dec_fmtin,
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 d3997395a9..6b5581571c 100644
--- a/modules/stream_out/transcode/encoder/encoder.h
+++ b/modules/stream_out/transcode/encoder/encoder.h
@@ -78,7 +78,7 @@ bool transcode_encoder_opened( const transcode_encoder_t * );
int transcode_encoder_open( transcode_encoder_t *, const transcode_encoder_config_t * );
int transcode_encoder_drain( transcode_encoder_t *, block_t ** );
-int transcode_encoder_test( vlc_object_t *p_obj,
+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,
diff --git a/modules/stream_out/transcode/encoder/encoder_priv.h b/modules/stream_out/transcode/encoder/encoder_priv.h
index 2875ae71a4..7da2b02670 100644
--- a/modules/stream_out/transcode/encoder/encoder_priv.h
+++ b/modules/stream_out/transcode/encoder/encoder_priv.h
@@ -49,13 +49,13 @@ block_t * transcode_encoder_spu_encode( transcode_encoder_t *p_enc, subpicture_t
int transcode_encoder_audio_drain( transcode_encoder_t *p_enc, block_t **out );
int transcode_encoder_video_drain( transcode_encoder_t *p_enc, block_t **out );
-int transcode_encoder_video_test( 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 );
-int transcode_encoder_audio_test( vlc_object_t *p_obj,
+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,
diff --git a/modules/stream_out/transcode/encoder/video.c b/modules/stream_out/transcode/encoder/video.c
index c3f6b9ad7b..0e20f43017 100644
--- a/modules/stream_out/transcode/encoder/video.c
+++ b/modules/stream_out/transcode/encoder/video.c
@@ -283,16 +283,12 @@ void transcode_encoder_video_configure( vlc_object_t *p_obj,
(const char *)&p_enc_in->i_chroma);
}
-int transcode_encoder_video_test( 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 )
{
- encoder_t *p_encoder = sout_EncoderCreate( p_obj, sizeof(encoder_t) );
- if( !p_encoder )
- return VLC_EGENERIC;
-
p_encoder->i_threads = p_cfg->video.threads.i_count;
p_encoder->p_cfg = p_cfg->p_config_chain;
@@ -324,7 +320,7 @@ int transcode_encoder_video_test( vlc_object_t *p_obj,
module_t *p_module = module_need( p_encoder, "encoder", p_cfg->psz_name, true );
if( !p_module )
{
- msg_Err( p_obj, "cannot find video encoder (module:%s fourcc:%4.4s). "
+ msg_Err( p_encoder, "cannot find video encoder (module:%s fourcc:%4.4s). "
"Take a look few lines earlier to see possible reason.",
p_cfg->psz_name ? p_cfg->psz_name : "any",
(char *)&p_cfg->i_codec );
diff --git a/modules/stream_out/transcode/video.c b/modules/stream_out/transcode/video.c
index 8d47662c72..efcde3b8cd 100644
--- a/modules/stream_out/transcode/video.c
+++ b/modules/stream_out/transcode/video.c
@@ -220,7 +220,7 @@ int transcode_video_init( sout_stream_t *p_stream, const es_format_t *p_fmt,
es_format_t encoder_tested_fmt_in;
es_format_Init( &encoder_tested_fmt_in, id->decoder_out.i_cat, 0 );
- if( transcode_encoder_test( VLC_OBJECT(p_stream),
+ if( transcode_encoder_test( sout_EncoderCreate(p_stream, sizeof(struct encoder_t)),
id->p_enccfg,
&id->p_decoder->fmt_in,
id->p_decoder->fmt_out.i_codec,
More information about the vlc-commits
mailing list