[vlc-devel] [PATCH 06/18] decoder: add the possibility to have a custom fmt_out setup to load a decoder
Steve Lhomme
robux4 at videolabs.io
Mon Jul 17 16:33:12 CEST 2017
By default it is a blank fmt_out with just the category set.
---
include/vlc_codec.h | 7 ++++++-
src/input/decoder.c | 11 +++++++----
src/misc/image.c | 3 +--
3 files changed, 14 insertions(+), 7 deletions(-)
diff --git a/include/vlc_codec.h b/include/vlc_codec.h
index 76a86767f1..eacb57f5e0 100644
--- a/include/vlc_codec.h
+++ b/include/vlc_codec.h
@@ -30,6 +30,7 @@
#include <vlc_es.h>
#include <vlc_picture.h>
#include <vlc_subpicture.h>
+#include <vlc_modules.h>
/**
* \defgroup codec Codec
@@ -411,8 +412,12 @@ VLC_API int decoder_GetDisplayRate( decoder_t * ) VLC_USED;
/**
* This function loads a decoder module matching the fmt_in of the decoder object.
+ *
+ * The probe is responsible for setting up the decoder fmt_out before/after
+ * loading a module. By default it initializes a blank fmt_out with just
+ * the category and cleans it up on module loading error.
*/
-VLC_API module_t *decoder_LoadModule( decoder_t * ) VLC_USED;
+VLC_API module_t *decoder_LoadModule( decoder_t *, vlc_activate_t probe ) VLC_USED;
/** @} */
/** @} */
diff --git a/src/input/decoder.c b/src/input/decoder.c
index f9b50f876b..336259078d 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 )
+module_t *decoder_LoadModule( decoder_t *p_dec, vlc_activate_t probe )
{
const char caps[ES_CATEGORY_COUNT][16] = {
[VIDEO_ES] = "video decoder",
@@ -195,7 +195,10 @@ module_t *decoder_LoadModule( decoder_t *p_dec )
return NULL; /* no decoder for this type */
}
- return module_need( p_dec, caps[p_dec->fmt_in.i_cat], "$codec", false);
+ 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 );
}
/**
@@ -213,15 +216,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 )
{
- p_dec->p_module = decoder_LoadModule( p_dec );
+ p_dec->p_module = decoder_LoadModule( p_dec, NULL );
}
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/misc/image.c b/src/misc/image.c
index 303f00916a..20b8a4eefc 100644
--- a/src/misc/image.c
+++ b/src/misc/image.c
@@ -647,7 +647,6 @@ static decoder_t *CreateDecoder( vlc_object_t *p_this, video_format_t *fmt )
p_dec->p_module = NULL;
es_format_Init( &p_dec->fmt_in, VIDEO_ES, fmt->i_chroma );
- es_format_Init( &p_dec->fmt_out, VIDEO_ES, 0 );
p_dec->fmt_in.video = *fmt;
p_dec->b_frame_drop_allowed = false;
@@ -655,7 +654,7 @@ static decoder_t *CreateDecoder( vlc_object_t *p_this, video_format_t *fmt )
p_dec->pf_vout_buffer_new = video_new_buffer;
/* Find a suitable decoder module */
- p_dec->p_module = decoder_LoadModule( p_dec );
+ p_dec->p_module = decoder_LoadModule( p_dec, NULL );
if( !p_dec->p_module )
{
msg_Err( p_dec, "no suitable decoder module for fourcc `%4.4s'. "
--
2.12.1
More information about the vlc-devel
mailing list