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

avcodec: use avcodec_is_open() instead of custom flag

parent 41f17efe
......@@ -219,7 +219,6 @@ int InitAudioDec( decoder_t *p_dec, AVCodecContext *p_context,
p_context->refcounted_frames = true;
p_sys->p_context = p_context;
p_sys->p_codec = p_codec;
p_sys->b_delayed_open = true;
// Initialize decoder extradata
InitDecoderConfig( p_dec, p_context);
......@@ -280,13 +279,14 @@ static int DecodeBlock( decoder_t *p_dec, block_t **pp_block )
block_t *p_block = NULL;
bool b_error = false;
if( !ctx->extradata_size && p_dec->fmt_in.i_extra && p_sys->b_delayed_open)
if( !ctx->extradata_size && p_dec->fmt_in.i_extra
&& !avcodec_is_open( ctx ) )
{
InitDecoderConfig( p_dec, ctx );
OpenAudioCodec( p_dec );
}
if( p_sys->b_delayed_open )
if( !avcodec_is_open( ctx ) )
{
if( pp_block )
p_block = *pp_block;
......
......@@ -388,7 +388,6 @@ int ffmpeg_OpenCodec( decoder_t *p_dec )
}
msg_Dbg( p_dec, "codec (%s) started", p_sys->p_codec->name );
p_sys->b_delayed_open = false;
return VLC_SUCCESS;
}
......@@ -396,7 +395,7 @@ void ffmpeg_CloseCodec( decoder_t *p_dec )
{
decoder_sys_t *p_sys = p_dec->p_sys;
if( p_sys->b_delayed_open )
if( !avcodec_is_open( p_sys->p_context ) )
return;
vlc_avcodec_lock();
......
......@@ -235,8 +235,7 @@ void ffmpeg_CloseCodec( decoder_t *p_dec );
#define AVCODEC_COMMON_MEMBERS \
AVCodecContext *p_context; \
const AVCodec *p_codec; \
bool b_delayed_open;
const AVCodec *p_codec;
#ifndef AV_VERSION_INT
# define AV_VERSION_INT(a, b, c) ((a)<<16 | (b)<<8 | (c))
......
......@@ -74,7 +74,6 @@ int InitSubtitleDec(decoder_t *dec, AVCodecContext *context,
sys->p_context = context;
sys->p_codec = codec;
sys->b_delayed_open = false;
sys->b_need_ephemer = codec->id == AV_CODEC_ID_HDMV_PGS_SUBTITLE;
/* */
......
......@@ -443,7 +443,6 @@ int InitVideoDec( decoder_t *p_dec, AVCodecContext *p_context,
p_sys->p_context = p_context;
p_sys->p_codec = p_codec;
p_sys->b_delayed_open = true;
p_sys->p_va = NULL;
vlc_sem_init( &p_sys->sem_mt, 0 );
......@@ -868,7 +867,7 @@ static picture_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block, bool *error
if( !p_context->extradata_size && p_dec->fmt_in.i_extra )
{
ffmpeg_InitCodec( p_dec );
if( p_sys->b_delayed_open )
if( !avcodec_is_open( p_context ) )
OpenVideoCodec( p_dec );
}
......@@ -876,7 +875,7 @@ static picture_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block, bool *error
if(!p_block && !(p_sys->p_codec->capabilities & AV_CODEC_CAP_DELAY) )
return NULL;
if( p_sys->b_delayed_open )
if( !avcodec_is_open( p_context ) )
{
if( p_block )
block_Release( p_block );
......
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