[vlc-devel] [PATCH 19/26] sout:encoder: pass the config_chain_t to sout_EncoderOpen
Steve Lhomme
robux4 at ycbcr.xyz
Mon Jan 18 08:32:58 UTC 2021
Encoders usually have encoding parameters that are used during the Open, so
explicitly pass the value on Open.
The encoder_t::p_cfg is set to const as the encoder is not supposed to modify
the config.
The image encoder doesn't provide any encoder parameters.
---
include/vlc_codec.h | 2 +-
include/vlc_sout.h | 3 ++-
modules/stream_out/transcode/encoder/audio.c | 7 ++-----
modules/stream_out/transcode/encoder/spu.c | 3 +--
modules/stream_out/transcode/encoder/video.c | 7 +++----
src/misc/image.c | 2 +-
src/missing.c | 4 +++-
src/stream_output/stream_output.c | 4 +++-
8 files changed, 16 insertions(+), 16 deletions(-)
diff --git a/include/vlc_codec.h b/include/vlc_codec.h
index c18bfd3d774..68dade50c8c 100644
--- a/include/vlc_codec.h
+++ b/include/vlc_codec.h
@@ -266,7 +266,7 @@ struct encoder_t
int i_tolerance; /* Bitrate tolerance */
/* Encoder config */
- config_chain_t *p_cfg;
+ const config_chain_t *p_cfg;
/* Private structure for the owner of the encoder */
const struct encoder_owner_callbacks *cbs;
diff --git a/include/vlc_sout.h b/include/vlc_sout.h
index 2f5eb6a3a73..2bbc1b27b37 100644
--- a/include/vlc_sout.h
+++ b/include/vlc_sout.h
@@ -230,7 +230,8 @@ static inline bool sout_StreamIsSynchronous(sout_stream_t *s)
VLC_API encoder_t * sout_EncoderCreate( vlc_object_t *, size_t, const es_format_t *fmt_in );
#define sout_EncoderCreate(o,a,b) sout_EncoderCreate(VLC_OBJECT(o),a,b)
-VLC_API int sout_EncoderOpen(encoder_t *, const char *name, bool strict);
+VLC_API int sout_EncoderOpen(encoder_t *, const char *name, bool strict,
+ const config_chain_t *);
VLC_API void sout_EncoderDelete(encoder_t *);
/****************************************************************************
diff --git a/modules/stream_out/transcode/encoder/audio.c b/modules/stream_out/transcode/encoder/audio.c
index 46f12c001c2..e56806da723 100644
--- a/modules/stream_out/transcode/encoder/audio.c
+++ b/modules/stream_out/transcode/encoder/audio.c
@@ -59,10 +59,9 @@ static const int pi_channels_maps[9] =
int transcode_encoder_audio_open( transcode_encoder_t *p_enc,
const transcode_encoder_config_t *p_cfg )
{
- p_enc->p_encoder->p_cfg = p_cfg->p_config_chain;
p_enc->p_encoder->fmt_out.i_codec = p_cfg->i_codec;
- return sout_EncoderOpen(p_enc->p_encoder, p_cfg->psz_name, true);
+ return sout_EncoderOpen(p_enc->p_encoder, p_cfg->psz_name, true, p_cfg->p_config_chain);
}
static int encoder_audio_configure( const transcode_encoder_config_t *p_cfg,
@@ -135,8 +134,6 @@ int transcode_encoder_audio_test( encoder_t *p_encoder,
vlc_fourcc_t i_codec_in,
es_format_t *p_enc_wanted_in )
{
- p_encoder->p_cfg = p_cfg->p_config_chain;
-
p_encoder->fmt_in.i_codec = i_codec_in;
es_format_Init( &p_encoder->fmt_out, AUDIO_ES, p_cfg->i_codec );
@@ -156,7 +153,7 @@ int transcode_encoder_audio_test( encoder_t *p_encoder,
p_afmt_out->i_physical_channels = AOUT_CHANS_STEREO;
}
- int ret = sout_EncoderOpen(p_encoder, p_cfg->psz_name, true);
+ int ret = sout_EncoderOpen(p_encoder, p_cfg->psz_name, true, p_cfg->p_config_chain);
if( ret != VLC_SUCCESS )
{
msg_Err( p_encoder, "cannot find audio encoder (module:%s fourcc:%4.4s). "
diff --git a/modules/stream_out/transcode/encoder/spu.c b/modules/stream_out/transcode/encoder/spu.c
index be203186c53..d7d8af87f4b 100644
--- a/modules/stream_out/transcode/encoder/spu.c
+++ b/modules/stream_out/transcode/encoder/spu.c
@@ -38,10 +38,9 @@
int transcode_encoder_spu_open( transcode_encoder_t *p_enc,
const transcode_encoder_config_t *p_cfg )
{
- p_enc->p_encoder->p_cfg = p_cfg->p_config_chain;
p_enc->p_encoder->fmt_out.i_codec = p_cfg->i_codec;
- return sout_EncoderOpen(p_enc->p_encoder, p_cfg->psz_name, true);
+ return sout_EncoderOpen(p_enc->p_encoder, p_cfg->psz_name, true, p_cfg->p_config_chain);
}
block_t * transcode_encoder_spu_encode( transcode_encoder_t *p_enc, subpicture_t *p_spu )
diff --git a/modules/stream_out/transcode/encoder/video.c b/modules/stream_out/transcode/encoder/video.c
index 80f97829ae3..4f79d867e3f 100644
--- a/modules/stream_out/transcode/encoder/video.c
+++ b/modules/stream_out/transcode/encoder/video.c
@@ -301,7 +301,6 @@ int transcode_encoder_video_test( encoder_t *p_encoder,
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;
p_encoder->fmt_in.i_codec = i_codec_in;
es_format_Init( &p_encoder->fmt_out, VIDEO_ES, p_cfg->i_codec );
@@ -323,7 +322,7 @@ int transcode_encoder_video_test( encoder_t *p_encoder,
p_vfmt_out->i_width = p_vfmt_in->i_width & ~1;
p_vfmt_out->i_height = p_vfmt_in->i_height & ~1;
- int ret = sout_EncoderOpen(p_encoder, p_cfg->psz_name, true);
+ int ret = sout_EncoderOpen(p_encoder, p_cfg->psz_name, true, p_cfg->p_config_chain);
if( ret != VLC_SUCCESS )
{
msg_Err( p_encoder, "cannot find video encoder (module:%s fourcc:%4.4s). "
@@ -440,9 +439,9 @@ int transcode_encoder_video_open( transcode_encoder_t *p_enc,
const transcode_encoder_config_t *p_cfg )
{
p_enc->p_encoder->i_threads = p_cfg->video.threads.i_count;
- p_enc->p_encoder->p_cfg = p_cfg->p_config_chain;
- if( sout_EncoderOpen(p_enc->p_encoder, p_cfg->psz_name, true) != VLC_SUCCESS )
+ if( sout_EncoderOpen(p_enc->p_encoder, p_cfg->psz_name, true, p_cfg->p_config_chain)
+ != VLC_SUCCESS )
return VLC_EGENERIC;
/* */
diff --git a/src/misc/image.c b/src/misc/image.c
index 2414778cbc0..92c5b436101 100644
--- a/src/misc/image.c
+++ b/src/misc/image.c
@@ -743,7 +743,7 @@ static encoder_t *CreateEncoder( vlc_object_t *p_this, const video_format_t *fmt
p_enc->fmt_out.video.i_height = p_enc->fmt_in.video.i_height;
/* Find a suitable decoder module */
- if( sout_EncoderOpen(p_enc, NULL, false) != VLC_SUCCESS )
+ if( sout_EncoderOpen(p_enc, NULL, false, NULL) != VLC_SUCCESS )
{
msg_Err( p_enc, "no suitable encoder module for fourcc `%4.4s'.\n"
"VLC probably does not support this image format.",
diff --git a/src/missing.c b/src/missing.c
index f1a6b243cf4..2180d240b41 100644
--- a/src/missing.c
+++ b/src/missing.c
@@ -107,9 +107,11 @@ encoder_t *sout_EncoderCreate( vlc_object_t *p_this, size_t owner_size,
return NULL;
}
-int sout_EncoderOpen( encoder_t *p_encoder, const char *name, bool strict )
+int sout_EncoderOpen( encoder_t *p_encoder, const char *name, bool strict,
+ const config_chain_t *config )
{
VLC_UNUSED (p_encoder); VLC_UNUSED (name); VLC_UNUSED (strict);
+ VLC_UNUSED (config);
vlc_assert_unreachable ();
}
diff --git a/src/stream_output/stream_output.c b/src/stream_output/stream_output.c
index 19128cb0fa8..8eceeb04aad 100644
--- a/src/stream_output/stream_output.c
+++ b/src/stream_output/stream_output.c
@@ -1079,7 +1079,8 @@ static int encoder_start_spu(void *func, bool forced, va_list ap)
return ret;
}
-int sout_EncoderOpen(encoder_t *p_encoder, const char *name, bool strict)
+int sout_EncoderOpen(encoder_t *p_encoder, const char *name, bool strict,
+ const config_chain_t *p_cfg)
{
static const vlc_activate_t activates[ES_CATEGORY_COUNT] = {
[VIDEO_ES] = encoder_start_video,
@@ -1087,6 +1088,7 @@ int sout_EncoderOpen(encoder_t *p_encoder, const char *name, bool strict)
[SPU_ES] = encoder_start_spu,
};
+ p_encoder->p_cfg = p_cfg;
p_encoder->p_module =
vlc_module_load(p_encoder, encoder_caps[p_encoder->fmt_in.i_cat], name,
strict, activates[p_encoder->fmt_in.i_cat],
--
2.29.2
More information about the vlc-devel
mailing list