summaryrefslogtreecommitdiffstats
path: root/audio/decode/ad_lavc.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-11-27 00:11:35 +0100
committerwm4 <wm4@nowhere>2013-11-27 00:16:05 +0100
commitaddfcf9ce339f487c94c36f6e72fc7e736586015 (patch)
tree0aa3a9b83ca5f203737573d12b4afb017fdb43a5 /audio/decode/ad_lavc.c
parentce1a511e221b032acc863d86b8d5b1644af00445 (diff)
downloadmpv-addfcf9ce339f487c94c36f6e72fc7e736586015.tar.bz2
mpv-addfcf9ce339f487c94c36f6e72fc7e736586015.tar.xz
audio: better rejection of invalid formats
This includes the case when lavc decodes audio with more than 8 channels, which our audio chain currently does not support. the changes in ad_lavc.c are just simplifications. The code tried to avoid overriding global parameters if it found something invalid, but that is not needed anymore.
Diffstat (limited to 'audio/decode/ad_lavc.c')
-rw-r--r--audio/decode/ad_lavc.c16
1 files changed, 7 insertions, 9 deletions
diff --git a/audio/decode/ad_lavc.c b/audio/decode/ad_lavc.c
index 0f442cef52..45e06c8b3d 100644
--- a/audio/decode/ad_lavc.c
+++ b/audio/decode/ad_lavc.c
@@ -134,15 +134,15 @@ static int setup_format(struct dec_audio *da)
AVCodecContext *lavc_context = priv->avctx;
struct sh_audio *sh_audio = da->header->audio;
- int sample_format = af_from_avformat(lavc_context->sample_fmt);
- if (!sample_format)
- return -1;
+ // Note: invalid parameters are rejected by dec_audio.c
+
+ mp_audio_set_format(&da->decoded, af_from_avformat(lavc_context->sample_fmt));
- int samplerate = lavc_context->sample_rate;
- if (!samplerate && sh_audio->wf) {
+ da->decoded.rate = lavc_context->sample_rate;
+ if (!da->decoded.rate && sh_audio->wf) {
// If not set, try container samplerate.
// (Maybe this can't happen, and it's an artifact from the past.)
- samplerate = sh_audio->wf->nSamplesPerSec;
+ da->decoded.rate = sh_audio->wf->nSamplesPerSec;
mp_tmsg(MSGT_DECAUDIO, MSGL_WARN, "ad_lavc: using container rate.\n");
}
@@ -155,10 +155,8 @@ static int setup_format(struct dec_audio *da)
if (lavc_chmap.num == sh_audio->channels.num)
lavc_chmap = sh_audio->channels;
}
-
mp_audio_set_channels(&da->decoded, &lavc_chmap);
- mp_audio_set_format(&da->decoded, sample_format);
- da->decoded.rate = samplerate;
+
return 0;
}