diff options
author | Paul B Mahol <onemda@gmail.com> | 2022-09-17 14:08:58 +0200 |
---|---|---|
committer | Paul B Mahol <onemda@gmail.com> | 2022-09-18 15:13:36 +0200 |
commit | adaa06581c5444c94eef72d61b8166f096e2687a (patch) | |
tree | 3f88533a3b92b1fa8c624bd6597e5270cf298118 | |
parent | ed83a3a5bddf4c209157dc9f041eda0721b4c3e0 (diff) | |
download | ffmpeg-adaa06581c5444c94eef72d61b8166f096e2687a.tar.gz |
avcodec/mlpdec: relax channels checking
Internal TrueHD decoder channel rematrix can mix 2 stereo substreams
into single mono stream.
Fixes #1726
-rw-r--r-- | libavcodec/mlpdec.c | 23 |
1 files changed, 1 insertions, 22 deletions
diff --git a/libavcodec/mlpdec.c b/libavcodec/mlpdec.c index bb72134b09..092344b69a 100644 --- a/libavcodec/mlpdec.c +++ b/libavcodec/mlpdec.c @@ -425,6 +425,7 @@ static int read_major_sync(MLPDecodeContext *m, GetBitContext *gb) mh.stream_type); return AVERROR_PATCHWELCOME; } + m->substream[1].mask = mh.channel_layout_thd_stream1; if (mh.channels_thd_stream1 == 2 && mh.channels_thd_stream2 == 2 && m->avctx->ch_layout.nb_channels == 2) @@ -438,16 +439,6 @@ static int read_major_sync(MLPDecodeContext *m, GetBitContext *gb) 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 (m->avctx->ch_layout.nb_channels <= 2 && - m->substream[substr].mask == AV_CH_LAYOUT_MONO && m->max_decoded_substream == 1) { - av_log(m->avctx, AV_LOG_DEBUG, "Mono stream with 2 substreams, ignoring 2nd\n"); - m->max_decoded_substream = 0; - if (m->avctx->ch_layout.nb_channels == 2) { - av_channel_layout_uninit(&m->avctx->ch_layout); - m->avctx->ch_layout = (AVChannelLayout)AV_CHANNEL_LAYOUT_STEREO; - } - } } m->needs_reordering = mh.channel_arrangement >= 18 && mh.channel_arrangement <= 20; @@ -541,12 +532,6 @@ static int read_restart_header(MLPDecodeContext *m, GetBitContext *gbp, return AVERROR_INVALIDDATA; } - if (max_channel != max_matrix_channel) { - av_log(m->avctx, AV_LOG_ERROR, - "Max channel must be equal max matrix channel.\n"); - return AVERROR_INVALIDDATA; - } - /* This should happen for TrueHD streams with >6 channels and MLP's noise * type. It is not yet known if this is allowed. */ if (max_channel > MAX_MATRIX_CHANNEL_MLP && !noise_type) { @@ -557,12 +542,6 @@ static int read_restart_header(MLPDecodeContext *m, GetBitContext *gbp, return AVERROR_PATCHWELCOME; } - if (min_channel > max_channel) { - av_log(m->avctx, AV_LOG_ERROR, - "Substream min channel cannot be greater than max channel.\n"); - return AVERROR_INVALIDDATA; - } - s->min_channel = min_channel; s->max_channel = max_channel; s->coded_channels = ((1LL << (max_channel - min_channel + 1)) - 1) << min_channel; |