[vlc-devel] [PATCH 04/18] decoder: add a function to create a decoder module
Steve Lhomme
robux4 at videolabs.io
Mon Jul 17 16:33:10 CEST 2017
And add a sanity check for the ES category.
---
include/vlc_codec.h | 5 +++++
src/input/decoder.c | 17 ++++-------------
src/libvlccore.sym | 1 +
3 files changed, 10 insertions(+), 13 deletions(-)
diff --git a/include/vlc_codec.h b/include/vlc_codec.h
index c62ccd0e94..76a86767f1 100644
--- a/include/vlc_codec.h
+++ b/include/vlc_codec.h
@@ -409,6 +409,11 @@ VLC_API mtime_t decoder_GetDisplayDate( decoder_t *, mtime_t ) VLC_USED;
*/
VLC_API int decoder_GetDisplayRate( decoder_t * ) VLC_USED;
+/**
+ * This function loads a decoder module matching the fmt_in of the decoder object.
+ */
+VLC_API module_t *decoder_LoadModule( decoder_t * ) VLC_USED;
+
/** @} */
/** @} */
#endif /* _VLC_CODEC_H */
diff --git a/src/input/decoder.c b/src/input/decoder.c
index 63edadf994..f9b50f876b 100644
--- a/src/input/decoder.c
+++ b/src/input/decoder.c
@@ -177,7 +177,7 @@ int PacketizerLoader(void *func, va_list ap)
return res;
}
-module_t *decoder_LoadModule( decoder_t *p_dec, vlc_activate_t probe )
+module_t *decoder_LoadModule( decoder_t *p_dec )
{
const char caps[ES_CATEGORY_COUNT][16] = {
[VIDEO_ES] = "video decoder",
@@ -195,10 +195,7 @@ module_t *decoder_LoadModule( decoder_t *p_dec, vlc_activate_t probe )
return NULL; /* no decoder for this type */
}
- if ( probe == NULL )
- es_format_Init( &p_dec->fmt_out, p_dec->fmt_in.i_cat, 0 );
- return vlc_module_load( p_dec, caps[p_dec->fmt_in.i_cat], "$codec",
- false, probe ? probe : DecoderLoader, p_dec );
+ return module_need( p_dec, caps[p_dec->fmt_in.i_cat], "$codec", false);
}
/**
@@ -216,21 +213,15 @@ static int LoadDecoder( decoder_t *p_dec, bool b_packetizer,
p_dec->pf_flush = NULL;
es_format_Copy( &p_dec->fmt_in, p_fmt );
+ es_format_Init( &p_dec->fmt_out, p_fmt->i_cat, 0 );
/* Find a suitable decoder/packetizer module */
if( !b_packetizer )
{
- const char caps[ES_CATEGORY_COUNT][16] = {
- [VIDEO_ES] = "video decoder",
- [AUDIO_ES] = "audio decoder",
- [SPU_ES] = "spu decoder",
- };
- p_dec->p_module = module_need( p_dec, caps[p_dec->fmt_in.i_cat],
- "$codec", false );
+ p_dec->p_module = decoder_LoadModule( p_dec );
}
else
{
- es_format_Init( &p_dec->fmt_out, p_fmt->i_cat, 0 );
p_dec->fmt_out.b_packetized = true;
p_dec->p_module = vlc_module_load( p_dec, "packetizer", "$packetizer",
false, PacketizerLoader, p_dec );
diff --git a/src/libvlccore.sym b/src/libvlccore.sym
index 93c56d3749..393e6c055d 100644
--- a/src/libvlccore.sym
+++ b/src/libvlccore.sym
@@ -82,6 +82,7 @@ decoder_GetDisplayRate
decoder_GetInputAttachments
decoder_NewAudioBuffer
decoder_NewSubpicture
+decoder_LoadModule
demux_Delete
demux_PacketizerDestroy
demux_PacketizerNew
--
2.12.1
More information about the vlc-devel
mailing list