Commit 8dc541c6 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

avcodec: pass explicit parameters to ffmpeg_OpenCodec()

This avoids relying on p_sys.
parent 2b8f8d1c
......@@ -148,7 +148,7 @@ static int OpenAudioCodec( decoder_t *p_dec )
ctx->sample_rate > 0)
ctx->bits_per_coded_sample = ctx->bit_rate / ctx->sample_rate;
return ffmpeg_OpenCodec( p_dec );
return ffmpeg_OpenCodec( p_dec, ctx, codec );
}
/**
......
......@@ -354,9 +354,9 @@ static void CloseDecoder( vlc_object_t *p_this )
/*****************************************************************************
* ffmpeg_OpenCodec:
*****************************************************************************/
int ffmpeg_OpenCodec( decoder_t *p_dec )
int ffmpeg_OpenCodec( decoder_t *p_dec, AVCodecContext *ctx,
const AVCodec *codec )
{
decoder_sys_t *p_sys = p_dec->p_sys;
char *psz_opts = var_InheritString( p_dec, "avcodec-options" );
AVDictionary *options = NULL;
int ret;
......@@ -367,7 +367,7 @@ int ffmpeg_OpenCodec( decoder_t *p_dec )
}
vlc_avcodec_lock();
ret = avcodec_open2( p_sys->p_context, p_sys->p_codec, options ? &options : NULL );
ret = avcodec_open2( ctx, codec, options ? &options : NULL );
vlc_avcodec_unlock();
AVDictionaryEntry *t = NULL;
......@@ -378,10 +378,10 @@ int ffmpeg_OpenCodec( decoder_t *p_dec )
if( ret < 0 )
{
msg_Err( p_dec, "cannot start codec (%s)", p_sys->p_codec->name );
msg_Err( p_dec, "cannot start codec (%s)", codec->name );
return VLC_EGENERIC;
}
msg_Dbg( p_dec, "codec (%s) started", p_sys->p_codec->name );
msg_Dbg( p_dec, "codec (%s) started", codec->name );
return VLC_SUCCESS;
}
......@@ -47,7 +47,7 @@ int InitSubtitleDec( decoder_t *, AVCodecContext *, const AVCodec * );
void EndSubtitleDec( decoder_t * );
/* Initialize decoder */
int ffmpeg_OpenCodec( decoder_t *p_dec );
int ffmpeg_OpenCodec( decoder_t *p_dec, AVCodecContext *, const AVCodec * );
/*****************************************************************************
* Module descriptor help strings
......
......@@ -400,7 +400,7 @@ static int OpenVideoCodec( decoder_t *p_dec )
cc_Init( &p_sys->cc );
post_mt( p_sys );
ret = ffmpeg_OpenCodec( p_dec );
ret = ffmpeg_OpenCodec( p_dec, ctx, codec );
wait_mt( p_sys );
if( ret < 0 )
return ret;
......
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