vlc | branch: master | Rémi Denis-Courmont <[email protected]> | Thu Sep 11 22:04:15 2014 +0300| [c779bd781c9484941139bcde0fb3cc741389c62f] | committer: Rémi Denis-Courmont
avcodec: move audio-specific code to audio.c > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=c779bd781c9484941139bcde0fb3cc741389c62f --- modules/codec/avcodec/audio.c | 38 ++++++++++++++++++++++++++++++++++---- modules/codec/avcodec/avcodec.c | 27 --------------------------- 2 files changed, 34 insertions(+), 31 deletions(-) diff --git a/modules/codec/avcodec/audio.c b/modules/codec/avcodec/audio.c index 254c06d..75957ac 100644 --- a/modules/codec/avcodec/audio.c +++ b/modules/codec/avcodec/audio.c @@ -115,6 +115,38 @@ static void InitDecoderConfig( decoder_t *p_dec, AVCodecContext *p_context ) } } +static int OpenAudioCodec( decoder_t *p_dec ) +{ + decoder_sys_t *p_sys = p_dec->p_sys; + + if( p_sys->p_context->extradata_size <= 0 ) + { + if( p_sys->i_codec_id == AV_CODEC_ID_VORBIS || + ( p_sys->i_codec_id == AV_CODEC_ID_AAC && + !p_dec->fmt_in.b_packetized ) ) + { + msg_Warn( p_dec, "waiting for extra data for codec %s", + p_sys->psz_namecodec ); + return 1; + } + } + + 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; + + if( p_sys->i_codec_id == AV_CODEC_ID_ADPCM_G726 && + p_sys->p_context->bit_rate > 0 && + p_sys->p_context->sample_rate > 0) + p_sys->p_context->bits_per_coded_sample = p_sys->p_context->bit_rate + / p_sys->p_context->sample_rate; + + return ffmpeg_OpenCodec( p_dec ); +} + /** * Allocates decoded audio buffer for libavcodec to use. */ @@ -231,9 +263,8 @@ int InitAudioDec( decoder_t *p_dec, AVCodecContext *p_context, InitDecoderConfig( p_dec, p_context); /* ***** Open the codec ***** */ - if( ffmpeg_OpenCodec( p_dec ) < 0 ) + if( OpenAudioCodec( p_dec ) < 0 ) { - msg_Err( p_dec, "cannot open codec (%s)", p_sys->psz_namecodec ); av_free( p_sys->p_context->extradata ); free( p_sys ); return VLC_EGENERIC; @@ -274,8 +305,7 @@ block_t * DecodeAudio ( decoder_t *p_dec, block_t **pp_block ) if( !ctx->extradata_size && p_dec->fmt_in.i_extra && p_sys->b_delayed_open) { InitDecoderConfig( p_dec, ctx ); - if( ffmpeg_OpenCodec( p_dec ) ) - msg_Err( p_dec, "Cannot open decoder %s", p_sys->psz_namecodec ); + OpenAudioCodec( p_dec ); } if( p_sys->b_delayed_open ) diff --git a/modules/codec/avcodec/avcodec.c b/modules/codec/avcodec/avcodec.c index fd43240..bc5ece0 100644 --- a/modules/codec/avcodec/avcodec.c +++ b/modules/codec/avcodec/avcodec.c @@ -368,33 +368,6 @@ static void CloseDecoder( vlc_object_t *p_this ) int ffmpeg_OpenCodec( decoder_t *p_dec ) { decoder_sys_t *p_sys = p_dec->p_sys; - - if( p_sys->p_context->extradata_size <= 0 ) - { - if( p_sys->i_codec_id == AV_CODEC_ID_VORBIS || - ( p_sys->i_codec_id == AV_CODEC_ID_AAC && - !p_dec->fmt_in.b_packetized ) ) - { - msg_Warn( p_dec, "waiting for extra data for codec %s", - p_sys->psz_namecodec ); - return 1; - } - } - 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; - if( p_sys->i_codec_id == AV_CODEC_ID_ADPCM_G726 && - p_sys->p_context->bit_rate > 0 && - p_sys->p_context->sample_rate > 0) - p_sys->p_context->bits_per_coded_sample = p_sys->p_context->bit_rate / - p_sys->p_context->sample_rate; - } - char *psz_opts = var_InheritString( p_dec, "avcodec-options" ); AVDictionary *options = NULL; int ret; _______________________________________________ vlc-commits mailing list [email protected] https://mailman.videolan.org/listinfo/vlc-commits
