Commit 62330410 authored by Jai Menon's avatar Jai Menon Committed by Jean-Baptiste Kempf

AVCodec : Set audio related parameters in ffmpeg_OpenCodec and use it for...

AVCodec : Set audio related parameters in ffmpeg_OpenCodec and use it for audio decoder initialization.
Signed-off-by: default avatarJean-Baptiste Kempf <jb@videolan.org>
parent 512acd87
...@@ -164,20 +164,8 @@ int InitAudioDec( decoder_t *p_dec, AVCodecContext *p_context, ...@@ -164,20 +164,8 @@ int InitAudioDec( decoder_t *p_dec, AVCodecContext *p_context,
// Initialize decoder extradata // Initialize decoder extradata
InitDecoderConfig( p_dec, p_context); InitDecoderConfig( p_dec, p_context);
/* ***** Fill p_context with init values ***** */
p_sys->p_context->sample_rate = p_dec->fmt_in.audio.i_rate;
p_sys->p_context->channels = p_dec->fmt_in.audio.i_channels;
p_sys->p_context->block_align = p_dec->fmt_in.audio.i_blockalign;
p_sys->p_context->bit_rate = p_dec->fmt_in.i_bitrate;
p_sys->p_context->bits_per_coded_sample = p_dec->fmt_in.audio.i_bitspersample;
/* ***** Open the codec ***** */ /* ***** Open the codec ***** */
int ret; if( ffmpeg_OpenCodec( p_dec ) < 0 )
vlc_avcodec_lock();
ret = avcodec_open( p_sys->p_context, p_sys->p_codec );
vlc_avcodec_unlock();
if( ret < 0 )
{ {
msg_Err( p_dec, "cannot open codec (%s)", p_sys->psz_namecodec ); msg_Err( p_dec, "cannot open codec (%s)", p_sys->psz_namecodec );
free( p_sys->p_context->extradata ); free( p_sys->p_context->extradata );
...@@ -185,8 +173,6 @@ int InitAudioDec( decoder_t *p_dec, AVCodecContext *p_context, ...@@ -185,8 +173,6 @@ int InitAudioDec( decoder_t *p_dec, AVCodecContext *p_context,
return VLC_EGENERIC; return VLC_EGENERIC;
} }
msg_Dbg( p_dec, "ffmpeg codec (%s) started", p_sys->psz_namecodec );
switch( i_codec_id ) switch( i_codec_id )
{ {
case CODEC_ID_WAVPACK: case CODEC_ID_WAVPACK:
......
...@@ -416,10 +416,21 @@ int ffmpeg_OpenCodec( decoder_t *p_dec ) ...@@ -416,10 +416,21 @@ int ffmpeg_OpenCodec( decoder_t *p_dec )
return 1; return 1;
} }
} }
p_sys->p_context->width = p_dec->fmt_in.video.i_width; if( p_dec->fmt_in.i_cat == VIDEO_ES )
p_sys->p_context->height = p_dec->fmt_in.video.i_height; {
p_sys->p_context->bits_per_coded_sample = p_dec->fmt_in.video.i_bits_per_pixel; p_sys->p_context->width = p_dec->fmt_in.video.i_width;
p_sys->p_context->height = p_dec->fmt_in.video.i_height;
p_sys->p_context->bits_per_coded_sample = p_dec->fmt_in.video.i_bits_per_pixel;
}
else if( p_dec->fmt_in.i_cat == AUDIO_ES )
{
p_sys->p_context->sample_rate = p_dec->fmt_in.audio.i_rate;
p_sys->p_context->channels = p_dec->fmt_in.audio.i_channels;
p_sys->p_context->block_align = p_dec->fmt_in.audio.i_blockalign;
p_sys->p_context->bit_rate = p_dec->fmt_in.i_bitrate;
p_sys->p_context->bits_per_coded_sample = p_dec->fmt_in.audio.i_bitspersample;
}
int ret; int ret;
vlc_avcodec_lock(); vlc_avcodec_lock();
ret = avcodec_open( p_sys->p_context, p_sys->p_codec ); ret = avcodec_open( p_sys->p_context, p_sys->p_codec );
...@@ -429,24 +440,27 @@ int ffmpeg_OpenCodec( decoder_t *p_dec ) ...@@ -429,24 +440,27 @@ int ffmpeg_OpenCodec( decoder_t *p_dec )
msg_Dbg( p_dec, "ffmpeg codec (%s) started", p_sys->psz_namecodec ); msg_Dbg( p_dec, "ffmpeg codec (%s) started", p_sys->psz_namecodec );
#ifdef HAVE_AVCODEC_MT #ifdef HAVE_AVCODEC_MT
switch( p_sys->p_context->active_thread_type ) if( p_dec->fmt_in.i_cat == VIDEO_ES )
{ {
case FF_THREAD_FRAME: switch( p_sys->p_context->active_thread_type )
msg_Dbg( p_dec, "using frame thread mode with %d threads", {
p_sys->p_context->thread_count ); case FF_THREAD_FRAME:
break; msg_Dbg( p_dec, "using frame thread mode with %d threads",
case FF_THREAD_SLICE: p_sys->p_context->thread_count );
msg_Dbg( p_dec, "using slice thread mode with %d threads", break;
p_sys->p_context->thread_count ); case FF_THREAD_SLICE:
break; msg_Dbg( p_dec, "using slice thread mode with %d threads",
case 0: p_sys->p_context->thread_count );
if( p_sys->p_context->thread_count > 1 ) break;
msg_Warn( p_dec, "failed to enable threaded decoding" ); case 0:
break; if( p_sys->p_context->thread_count > 1 )
default: msg_Warn( p_dec, "failed to enable threaded decoding" );
msg_Warn( p_dec, "using unknown thread mode with %d threads", break;
p_sys->p_context->thread_count ); default:
break; msg_Warn( p_dec, "using unknown thread mode with %d threads",
p_sys->p_context->thread_count );
break;
}
} }
#endif #endif
......
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