[vlc-devel] [PATCH 07/26] transcode: use sout_EncoderOpen instead of locally opening the module
Steve Lhomme
robux4 at ycbcr.xyz
Mon Jan 18 08:32:46 UTC 2021
---
modules/stream_out/transcode/encoder/audio.c | 13 +++++--------
modules/stream_out/transcode/encoder/spu.c | 5 +----
modules/stream_out/transcode/encoder/video.c | 13 ++++++-------
3 files changed, 12 insertions(+), 19 deletions(-)
diff --git a/modules/stream_out/transcode/encoder/audio.c b/modules/stream_out/transcode/encoder/audio.c
index ea59256e145..704f83a0278 100644
--- a/modules/stream_out/transcode/encoder/audio.c
+++ b/modules/stream_out/transcode/encoder/audio.c
@@ -62,10 +62,7 @@ int transcode_encoder_audio_open( transcode_encoder_t *p_enc,
p_enc->p_encoder->p_cfg = p_cfg->p_config_chain;
p_enc->p_encoder->fmt_out.i_codec = p_cfg->i_codec;
- p_enc->p_encoder->p_module = module_need( p_enc->p_encoder, "audio encoder",
- p_cfg->psz_name, true );
-
- if( p_enc->p_encoder->p_module )
+ if( sout_EncoderOpen(p_enc->p_encoder, p_cfg->psz_name, true) == VLC_SUCCESS )
{
p_enc->p_encoder->fmt_out.i_codec =
vlc_fourcc_GetCodec( AUDIO_ES, p_enc->p_encoder->fmt_out.i_codec );
@@ -169,8 +166,8 @@ int transcode_encoder_audio_test( encoder_t *p_encoder,
p_afmt_out->i_physical_channels = AOUT_CHANS_STEREO;
}
- module_t *p_module = module_need( p_encoder, "audio encoder", p_cfg->psz_name, true );
- if( !p_module )
+ int ret = sout_EncoderOpen(p_encoder, p_cfg->psz_name, true);
+ if( ret != VLC_SUCCESS )
{
msg_Err( p_encoder, "cannot find audio encoder (module:%s fourcc:%4.4s). "
"Take a look few lines earlier to see possible reason.",
@@ -181,7 +178,7 @@ int transcode_encoder_audio_test( encoder_t *p_encoder,
{
/* Close the encoder.
* We'll open it only when we have the first frame. */
- module_unneed( p_encoder, p_module );
+ module_unneed( p_encoder, p_encoder->p_module );
}
p_encoder->fmt_in.audio.i_format = p_encoder->fmt_in.i_codec;
@@ -194,7 +191,7 @@ int transcode_encoder_audio_test( encoder_t *p_encoder,
vlc_object_delete(p_encoder);
- return p_module != NULL ? VLC_SUCCESS : VLC_EGENERIC;
+ return ret;
}
block_t * transcode_encoder_audio_encode( transcode_encoder_t *p_enc, block_t *p_block )
diff --git a/modules/stream_out/transcode/encoder/spu.c b/modules/stream_out/transcode/encoder/spu.c
index 5724e19cf78..be203186c53 100644
--- a/modules/stream_out/transcode/encoder/spu.c
+++ b/modules/stream_out/transcode/encoder/spu.c
@@ -41,10 +41,7 @@ int transcode_encoder_spu_open( transcode_encoder_t *p_enc,
p_enc->p_encoder->p_cfg = p_cfg->p_config_chain;
p_enc->p_encoder->fmt_out.i_codec = p_cfg->i_codec;
- p_enc->p_encoder->p_module = module_need( p_enc->p_encoder, "spu encoder",
- p_cfg->psz_name, true );
-
- return ( p_enc->p_encoder->p_module ) ? VLC_SUCCESS: VLC_EGENERIC;
+ return sout_EncoderOpen(p_enc->p_encoder, p_cfg->psz_name, true);
}
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 d34a0c1bdbc..ae5982cfcc2 100644
--- a/modules/stream_out/transcode/encoder/video.c
+++ b/modules/stream_out/transcode/encoder/video.c
@@ -325,8 +325,8 @@ 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;
- module_t *p_module = module_need( p_encoder, "video encoder", p_cfg->psz_name, true );
- if( !p_module )
+ int ret = sout_EncoderOpen(p_encoder, p_cfg->psz_name, true);
+ if( ret != VLC_SUCCESS )
{
msg_Err( p_encoder, "cannot find video encoder (module:%s fourcc:%4.4s). "
"Take a look few lines earlier to see possible reason.",
@@ -337,7 +337,8 @@ int transcode_encoder_video_test( encoder_t *p_encoder,
{
/* Close the encoder.
* We'll open it only when we have the first frame. */
- module_unneed( p_encoder, p_module );
+ module_unneed( p_encoder, p_encoder->p_module );
+ p_encoder->p_module = NULL;
}
if( likely(!p_encoder->fmt_in.video.i_chroma) ) /* always missing, and required by filter chain */
@@ -352,7 +353,7 @@ int transcode_encoder_video_test( encoder_t *p_encoder,
vlc_object_delete(p_encoder);
- return p_module != NULL ? VLC_SUCCESS : VLC_EGENERIC;
+ return ret;
}
static void* EncoderThread( void *obj )
@@ -455,9 +456,7 @@ int transcode_encoder_video_open( transcode_encoder_t *p_enc,
p_enc->p_encoder->i_threads = p_cfg->video.threads.i_count;
p_enc->p_encoder->p_cfg = p_cfg->p_config_chain;
- p_enc->p_encoder->p_module =
- module_need( p_enc->p_encoder, "video encoder", p_cfg->psz_name, true );
- if( !p_enc->p_encoder->p_module )
+ if( sout_EncoderOpen(p_enc->p_encoder, p_cfg->psz_name, true) != VLC_SUCCESS )
return VLC_EGENERIC;
p_enc->p_encoder->fmt_in.video.i_chroma = p_enc->p_encoder->fmt_in.i_codec;
--
2.29.2
More information about the vlc-devel
mailing list