From 48c2e9d67d36af8aff354b18ab2ddda26abca117 Mon Sep 17 00:00:00 2001 From: wm4 Date: Mon, 26 Oct 2015 15:54:00 +0100 Subject: audio: use AVFrames with more than 8 channels correctly Requires messy dealing with the extended_ fields. Don't bother with af_lavfi and ao_lavc for now. There are probably no valid use-cases for these. --- audio/audio.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'audio/audio.c') diff --git a/audio/audio.c b/audio/audio.c index 4b12992879..c4ad4021b5 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -323,21 +323,23 @@ struct mp_audio *mp_audio_from_avframe(struct AVFrame *avframe) } // If we can't handle the format (e.g. too many channels), bail out. - if (!mp_audio_config_valid(new) || avframe->nb_extended_buf) + if (!mp_audio_config_valid(new)) goto fail; - for (int n = 0; n < AV_NUM_DATA_POINTERS; n++) { - if (!avframe->buf[n]) + for (int n = 0; n < AV_NUM_DATA_POINTERS + avframe->nb_extended_buf; n++) { + AVBufferRef *buf = n < AV_NUM_DATA_POINTERS ? avframe->buf[n] + : avframe->extended_buf[n - AV_NUM_DATA_POINTERS]; + if (!buf) break; if (n >= MP_NUM_CHANNELS) goto fail; - new->allocated[n] = av_buffer_ref(avframe->buf[n]); + new->allocated[n] = av_buffer_ref(buf); if (!new->allocated[n]) goto fail; } for (int n = 0; n < new->num_planes; n++) - new->planes[n] = avframe->data[n]; + new->planes[n] = avframe->extended_data[n]; new->samples = avframe->nb_samples; return new; -- cgit v1.2.3