From dd61fac9438a0ba83513c9346debf73e7f9d2b4d Mon Sep 17 00:00:00 2001 From: wm4 Date: Sat, 9 Feb 2013 15:15:32 +0100 Subject: demux_lavf, ad_lavc, vd_lavc: refactor, cleanup Rearrange some code to make it easier readable. Remove some dead code, and stop printing AVI headers in demux_lavf. (These are not actual AVI headers, just for internal use.) There should be no functional changes, other than reducing output in verbose mode. --- audio/decode/ad_lavc.c | 42 ++++++++++++++++++------------------------ 1 file changed, 18 insertions(+), 24 deletions(-) (limited to 'audio') diff --git a/audio/decode/ad_lavc.c b/audio/decode/ad_lavc.c index 26c02b3240..f6efde4437 100644 --- a/audio/decode/ad_lavc.c +++ b/audio/decode/ad_lavc.c @@ -181,6 +181,21 @@ static int setup_format(sh_audio_t *sh_audio, return 0; } +static void set_from_wf(AVCodecContext *avctx, WAVEFORMATEX *wf) +{ + avctx->channels = wf->nChannels; + avctx->sample_rate = wf->nSamplesPerSec; + avctx->bit_rate = wf->nAvgBytesPerSec * 8; + avctx->block_align = wf->nBlockAlign; + avctx->bits_per_coded_sample = wf->wBitsPerSample; + + if (wf->cbSize > 0) { + avctx->extradata = av_mallocz(wf->cbSize + FF_INPUT_BUFFER_PADDING_SIZE); + avctx->extradata_size = wf->cbSize; + memcpy(avctx->extradata, wf + 1, avctx->extradata_size); + } +} + static int init(sh_audio_t *sh_audio, const char *decoder) { struct MPOpts *opts = sh_audio->opts; @@ -212,13 +227,7 @@ static int init(sh_audio_t *sh_audio, const char *decoder) AV_OPT_SEARCH_CHILDREN); lavc_context->sample_rate = sh_audio->samplerate; lavc_context->bit_rate = sh_audio->i_bps * 8; - if (sh_audio->wf) { - lavc_context->channels = sh_audio->wf->nChannels; - lavc_context->sample_rate = sh_audio->wf->nSamplesPerSec; - lavc_context->bit_rate = sh_audio->wf->nAvgBytesPerSec * 8; - lavc_context->block_align = sh_audio->wf->nBlockAlign; - lavc_context->bits_per_coded_sample = sh_audio->wf->wBitsPerSample; - } + lavc_context->request_channels = opts->audio_output_channels; lavc_context->codec_tag = sh_audio->format; //FOURCC if (sh_audio->gsh->lavf_codec_tag) @@ -226,13 +235,8 @@ static int init(sh_audio_t *sh_audio, const char *decoder) lavc_context->codec_type = AVMEDIA_TYPE_AUDIO; lavc_context->codec_id = lavc_codec->id; // not sure if required, imho not --A'rpi - /* alloc extra data */ - if (sh_audio->wf && sh_audio->wf->cbSize > 0) { - lavc_context->extradata = av_mallocz(sh_audio->wf->cbSize + FF_INPUT_BUFFER_PADDING_SIZE); - lavc_context->extradata_size = sh_audio->wf->cbSize; - memcpy(lavc_context->extradata, sh_audio->wf + 1, - lavc_context->extradata_size); - } + if (sh_audio->wf) + set_from_wf(lavc_context, sh_audio->wf); // for QDM2 if (sh_audio->codecdata_len && sh_audio->codecdata && @@ -253,16 +257,6 @@ static int init(sh_audio_t *sh_audio, const char *decoder) mp_msg(MSGT_DECAUDIO, MSGL_V, "INFO: libavcodec \"%s\" init OK!\n", lavc_codec->name); - if (sh_audio->wf && sh_audio->format == 0x3343414D) { - // MACE 3:1 - sh_audio->ds->ss_div = 2 * 3; // 1 samples/packet - sh_audio->ds->ss_mul = 2 * sh_audio->wf->nChannels; // 1 byte*ch/packet - } else if (sh_audio->wf && sh_audio->format == 0x3643414D) { - // MACE 6:1 - sh_audio->ds->ss_div = 2 * 6; // 1 samples/packet - sh_audio->ds->ss_mul = 2 * sh_audio->wf->nChannels; // 1 byte*ch/packet - } - // Decode at least 1 byte: (to get header filled) for (int tries = 0;;) { int x = decode_audio(sh_audio, sh_audio->a_buffer, 1, -- cgit v1.2.3