summaryrefslogtreecommitdiffstats
path: root/audio
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-02-09 15:15:32 +0100
committerwm4 <wm4@nowhere>2013-02-10 17:25:57 +0100
commitdd61fac9438a0ba83513c9346debf73e7f9d2b4d (patch)
tree7f8bbec5071f303c2b2eae182f2b67a3a110d84c /audio
parenta0987186b91680df473a7273a1eec130d0dd1a60 (diff)
downloadmpv-dd61fac9438a0ba83513c9346debf73e7f9d2b4d.tar.bz2
mpv-dd61fac9438a0ba83513c9346debf73e7f9d2b4d.tar.xz
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.
Diffstat (limited to 'audio')
-rw-r--r--audio/decode/ad_lavc.c42
1 files changed, 18 insertions, 24 deletions
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,