[vlc-devel] [PATCH 15/26] transcode: use sout_EncoderDelete instead of custom calls
Steve Lhomme
robux4 at ycbcr.xyz
Mon Jan 18 08:32:54 UTC 2021
---
modules/stream_out/transcode/encoder/audio.c | 16 +++-------------
modules/stream_out/transcode/encoder/encoder.c | 12 ++++--------
modules/stream_out/transcode/encoder/video.c | 13 ++-----------
3 files changed, 9 insertions(+), 32 deletions(-)
diff --git a/modules/stream_out/transcode/encoder/audio.c b/modules/stream_out/transcode/encoder/audio.c
index 1158095b3b5..6a37b0e37a8 100644
--- a/modules/stream_out/transcode/encoder/audio.c
+++ b/modules/stream_out/transcode/encoder/audio.c
@@ -146,9 +146,7 @@ int transcode_encoder_audio_test( encoder_t *p_encoder,
if( encoder_audio_configure( p_cfg, &p_dec_out->audio, p_encoder, false ) )
{
- es_format_Clean( &p_encoder->fmt_in );
- es_format_Clean( &p_encoder->fmt_out );
- vlc_object_delete(p_encoder);
+ sout_EncoderDelete( p_encoder );
return VLC_EGENERIC;
}
@@ -168,22 +166,14 @@ int transcode_encoder_audio_test( encoder_t *p_encoder,
p_cfg->psz_name ? p_cfg->psz_name : "any",
(char *)&p_cfg->i_codec );
}
- else
- {
- /* Close the encoder.
- * We'll open it only when we have the first frame. */
- module_unneed( p_encoder, p_encoder->p_module );
- }
p_encoder->fmt_in.audio.i_format = p_encoder->fmt_in.i_codec;
/* copy our requested format */
es_format_Copy( p_enc_wanted_in, &p_encoder->fmt_in );
- es_format_Clean( &p_encoder->fmt_in );
- es_format_Clean( &p_encoder->fmt_out );
-
- vlc_object_delete(p_encoder);
+ /* Close the encoder. We'll open it only when we have the first frame. */
+ sout_EncoderDelete( p_encoder );
return ret;
}
diff --git a/modules/stream_out/transcode/encoder/encoder.c b/modules/stream_out/transcode/encoder/encoder.c
index 6958a8dc724..7ca60b8bacf 100644
--- a/modules/stream_out/transcode/encoder/encoder.c
+++ b/modules/stream_out/transcode/encoder/encoder.c
@@ -51,9 +51,7 @@ void transcode_encoder_delete( transcode_encoder_t *p_enc )
block_ChainRelease( p_enc->p_buffers );
picture_fifo_Delete( p_enc->pp_pics );
}
- es_format_Clean( &p_enc->p_encoder->fmt_in );
- es_format_Clean( &p_enc->p_encoder->fmt_out );
- vlc_object_delete(p_enc->p_encoder);
+ sout_EncoderDelete( p_enc->p_encoder );
}
free( p_enc );
}
@@ -75,9 +73,9 @@ transcode_encoder_t * transcode_encoder_new( encoder_t *p_encoder,
}
transcode_encoder_t *p_enc = calloc( 1, sizeof(*p_enc) );
- if( !p_enc )
+ if( unlikely(!p_enc) )
{
- vlc_object_delete(p_encoder);
+ sout_EncoderDelete(p_encoder);
return NULL;
}
@@ -99,9 +97,7 @@ transcode_encoder_t * transcode_encoder_new( encoder_t *p_encoder,
p_enc->pp_pics = picture_fifo_New();
if( !p_enc->pp_pics )
{
- es_format_Clean( &p_enc->p_encoder->fmt_in );
- es_format_Clean( &p_enc->p_encoder->fmt_out );
- vlc_object_delete(p_enc->p_encoder);
+ sout_EncoderDelete( p_enc->p_encoder );
free( p_enc );
return NULL;
}
diff --git a/modules/stream_out/transcode/encoder/video.c b/modules/stream_out/transcode/encoder/video.c
index e396ff5d9b7..68e10ec8bac 100644
--- a/modules/stream_out/transcode/encoder/video.c
+++ b/modules/stream_out/transcode/encoder/video.c
@@ -333,22 +333,13 @@ int transcode_encoder_video_test( encoder_t *p_encoder,
p_cfg->psz_name ? p_cfg->psz_name : "any",
(char *)&p_cfg->i_codec );
}
- else
- {
- /* Close the encoder.
- * We'll open it only when we have the first frame. */
- module_unneed( p_encoder, p_encoder->p_module );
- p_encoder->p_module = NULL;
- }
/* output our requested format */
es_format_Copy( p_enc_wanted_in, &p_encoder->fmt_in );
video_format_FixRgb( &p_enc_wanted_in->video ); /* set masks when RGB */
- es_format_Clean( &p_encoder->fmt_in );
- es_format_Clean( &p_encoder->fmt_out );
-
- vlc_object_delete(p_encoder);
+ /* Close the encoder. We'll open it only when we have the first frame. */
+ sout_EncoderDelete( p_encoder );
return ret;
}
--
2.29.2
More information about the vlc-devel
mailing list