From cfc39bec00c95ecc33545399af80313eb97f6a69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Ekstr=C3=B6m?= Date: Wed, 1 Jun 2022 23:58:17 +0300 Subject: [PATCH] demux_lavf: switch to AVChannelLayout when available --- demux/demux_lavf.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/demux/demux_lavf.c b/demux/demux_lavf.c index 03c0a1fa0d..0602f7c3d1 100644 --- a/demux/demux_lavf.c +++ b/demux/demux_lavf.c @@ -40,6 +40,8 @@ #include #endif +#include "audio/chmap_avchannel.h" + #include "common/msg.h" #include "common/tags.h" #include "common/av_common.h" @@ -658,10 +660,22 @@ static void handle_new_stream(demuxer_t *demuxer, int i) case AVMEDIA_TYPE_AUDIO: { sh = demux_alloc_sh_stream(STREAM_AUDIO); +#if !HAVE_AV_CHANNEL_LAYOUT // probably unneeded mp_chmap_set_unknown(&sh->codec->channels, codec->channels); if (codec->channel_layout) mp_chmap_from_lavc(&sh->codec->channels, codec->channel_layout); +#else + if (!mp_chmap_from_av_layout(&sh->codec->channels, &codec->ch_layout)) { + char layout[128] = {0}; + MP_WARN(demuxer, + "Failed to convert channel layout %s to mpv one!\n", + av_channel_layout_describe(&codec->ch_layout, + layout, 128) < 0 ? + "undefined" : layout); + } +#endif + sh->codec->samplerate = codec->sample_rate; sh->codec->bitrate = codec->bit_rate;