Commit 79eed1a3 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

avcodec: split decoder in submodules per ES type

parent 025fde2a
......@@ -196,8 +196,9 @@ static block_t *vlc_av_frame_Wrap(AVFrame *frame)
* This function is called when the thread ends after a successful
* initialization.
*****************************************************************************/
void EndAudioDec( decoder_t *p_dec )
void EndAudioDec( vlc_object_t *obj )
{
decoder_t *p_dec = (decoder_t *)obj;
decoder_sys_t *sys = p_dec->p_sys;
AVCodecContext *ctx = sys->p_context;
......@@ -210,8 +211,12 @@ void EndAudioDec( decoder_t *p_dec )
*****************************************************************************
* The avcodec codec will be opened, some memory allocated.
*****************************************************************************/
int InitAudioDec( decoder_t *p_dec )
int InitAudioDec( vlc_object_t *obj )
{
decoder_t *p_dec = (decoder_t *)obj;
if( p_dec->fmt_in.i_cat != AUDIO_ES )
return VLC_EGENERIC;
const AVCodec *codec;
AVCodecContext *avctx = ffmpeg_AllocContext( p_dec, &codec );
if( avctx == NULL )
......
......@@ -45,9 +45,6 @@
/****************************************************************************
* Local prototypes
****************************************************************************/
static int OpenDecoder( vlc_object_t * );
static void CloseDecoder( vlc_object_t * );
static const int nloopf_list[] = { 0, 1, 2, 3, 4 };
static const char *const nloopf_list_text[] =
{ N_("None"), N_("Non-ref"), N_("Bidir"), N_("Non-key"), N_("All") };
......@@ -73,16 +70,26 @@ static const char *const enc_hq_list_text[] = {
vlc_module_begin ()
set_shortname( "FFmpeg")
add_shortcut( "ffmpeg" )
set_category( CAT_INPUT )
set_subcategory( SUBCAT_INPUT_VCODEC )
/* decoder main module */
set_description( N_("FFmpeg audio/video decoder") )
set_help( MODULE_DESCRIPTION )
set_capability( "decoder", 70 )
set_section( N_("Decoding") , NULL )
set_callbacks( OpenDecoder, CloseDecoder )
add_shortcut("ffmpeg")
set_capability("decoder", 70)
set_callbacks(InitVideoDec, EndVideoDec)
add_submodule()
add_shortcut("ffmpeg")
set_capability("decoder", 70)
set_callbacks(InitAudioDec, EndAudioDec)
add_submodule()
add_shortcut("ffmpeg")
set_capability("decoder", 70)
set_callbacks(InitSubtitleDec, EndSubtitleDec)
add_obsolete_bool( "ffmpeg-dr" ) /* removed since 2.1.0 */
add_bool( "avcodec-dr", true, DR_TEXT, DR_TEXT, true )
......@@ -288,55 +295,6 @@ AVCodecContext *ffmpeg_AllocContext( decoder_t *p_dec,
return avctx;
}
/*****************************************************************************
* OpenDecoder: probe the decoder and return score
*****************************************************************************/
static int OpenDecoder( vlc_object_t *p_this )
{
decoder_t *p_dec = (decoder_t *)p_this;
int ret;
switch( p_dec->fmt_in.i_cat )
{
case VIDEO_ES:
ret = InitVideoDec( p_dec );
break;
case AUDIO_ES:
ret = InitAudioDec( p_dec );
break;
case SPU_ES:
ret = InitSubtitleDec( p_dec );
break;
default:
vlc_assert_unreachable();
}
return ret;
}
/*****************************************************************************
* CloseDecoder: decoder destruction
*****************************************************************************/
static void CloseDecoder( vlc_object_t *p_this )
{
decoder_t *p_dec = (decoder_t *)p_this;
switch( p_dec->fmt_out.i_cat )
{
case VIDEO_ES:
EndVideoDec( p_dec );
break;
case AUDIO_ES:
EndAudioDec( p_dec );
break;
case SPU_ES:
EndSubtitleDec( p_dec );
break;
default:
vlc_assert_unreachable();
}
}
/*****************************************************************************
* ffmpeg_OpenCodec:
*****************************************************************************/
......
......@@ -35,16 +35,16 @@ int OpenEncoder ( vlc_object_t * );
void CloseEncoder( vlc_object_t * );
/* Video Decoder */
int InitVideoDec( decoder_t * );
void EndVideoDec( decoder_t *p_dec );
int InitVideoDec( vlc_object_t * );
void EndVideoDec( vlc_object_t * );
/* Audio Decoder */
int InitAudioDec( decoder_t * );
void EndAudioDec( decoder_t *p_dec );
int InitAudioDec( vlc_object_t * );
void EndAudioDec( vlc_object_t * );
/* Subtitle Decoder */
int InitSubtitleDec( decoder_t * );
void EndSubtitleDec( decoder_t * );
int InitSubtitleDec( vlc_object_t * );
void EndSubtitleDec( vlc_object_t * );
/* Initialize decoder */
AVCodecContext *ffmpeg_AllocContext( decoder_t *, const AVCodec ** );
......
......@@ -52,8 +52,12 @@ static void Flush(decoder_t *);
/**
* Initialize subtitle decoder
*/
int InitSubtitleDec(decoder_t *dec)
int InitSubtitleDec(vlc_object_t *obj)
{
decoder_t *dec = (decoder_t *)obj;
if (dec->fmt_in.i_cat != SPU_ES)
return VLC_EGENERIC;
const AVCodec *codec;
AVCodecContext *context = ffmpeg_AllocContext(dec, &codec);
if (context == NULL)
......@@ -128,8 +132,9 @@ int InitSubtitleDec(decoder_t *dec)
return VLC_SUCCESS;
}
void EndSubtitleDec(decoder_t *dec)
void EndSubtitleDec(vlc_object_t *obj)
{
decoder_t *dec = (decoder_t *)obj;
decoder_sys_t *sys = dec->p_sys;
AVCodecContext *ctx = sys->p_context;
......
......@@ -434,8 +434,12 @@ static int OpenVideoCodec( decoder_t *p_dec )
* the ffmpeg codec will be opened, some memory allocated. The vout is not yet
* opened (done after the first decoded frame).
*****************************************************************************/
int InitVideoDec( decoder_t *p_dec )
int InitVideoDec( vlc_object_t *obj )
{
decoder_t *p_dec = (decoder_t *)obj;
if( p_dec->fmt_in.i_cat != VIDEO_ES )
return VLC_EGENERIC;
const AVCodec *p_codec;
AVCodecContext *p_context = ffmpeg_AllocContext( p_dec, &p_codec );
if( p_context == NULL )
......@@ -1219,8 +1223,9 @@ static int DecodeVideo( decoder_t *p_dec, block_t *p_block )
* This function is called when the thread ends after a successful
* initialization.
*****************************************************************************/
void EndVideoDec( decoder_t *p_dec )
void EndVideoDec( vlc_object_t *obj )
{
decoder_t *p_dec = (decoder_t *)obj;
decoder_sys_t *p_sys = p_dec->p_sys;
AVCodecContext *ctx = p_sys->p_context;
void *hwaccel_context;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment