From 210e844def9d2c5a1e3840b8c5ad9c094b74a871 Mon Sep 17 00:00:00 2001 From: Paul B Mahol Date: Wed, 25 Oct 2023 12:43:13 +0200 Subject: [PATCH] avcodec/mlpdec: support for truehd with channels not representable with 5bit field in second stream Fixes decoding for 4.0/4.1 layouts. --- libavcodec/mlpdec.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libavcodec/mlpdec.c b/libavcodec/mlpdec.c index 11b5d2fe98..f1524b95a6 100644 --- a/libavcodec/mlpdec.c +++ b/libavcodec/mlpdec.c @@ -452,7 +452,10 @@ static int read_major_sync(MLPDecodeContext *m, GetBitContext *gb) else m->substream[2].mask = mh.channel_layout_thd_stream1; if (m->avctx->ch_layout.nb_channels > 2) - m->substream[mh.num_substreams > 1].mask = mh.channel_layout_thd_stream1; + if (mh.num_substreams > 2) + m->substream[1].mask = mh.channel_layout_thd_stream1; + else + m->substream[mh.num_substreams > 1].mask = mh.channel_layout_thd_stream2; } m->needs_reordering = mh.channel_arrangement >= 18 && mh.channel_arrangement <= 20;