Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: Paul B Mahol <onemda@gmail.com>
To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
Subject: [FFmpeg-devel] [PATCH] avcodec/mlpdec: relax channel checking
Date: Sat, 17 Sep 2022 14:10:18 +0200
Message-ID: <CAPYw7P7uOBbkFszyG52z+QUWxQ_FZEe3kOWevhvhJuAFQ64T7Q@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 16 bytes --]

Patch attached.

[-- Attachment #2: 0001-avcodec-mlpdec-relax-channels-checking.patch --]
[-- Type: text/x-patch, Size: 2976 bytes --]

From 5be1fbb848b50e02d302873653e94ed77dea861c Mon Sep 17 00:00:00 2001
From: Paul B Mahol <onemda@gmail.com>
Date: Sat, 17 Sep 2022 14:08:58 +0200
Subject: [PATCH] avcodec/mlpdec: relax channels checking

Internal TrueHD decoder channel rematrix can mix 2 stereo substreams
into single mono stream.

Fixes #1726

Signed-off-by: Paul B Mahol <onemda@gmail.com>
---
 libavcodec/mlpdec.c | 23 +----------------------
 1 file changed, 1 insertion(+), 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;
-- 
2.37.2


[-- Attachment #3: Type: text/plain, Size: 251 bytes --]

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

                 reply	other threads:[~2022-09-17 12:10 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAPYw7P7uOBbkFszyG52z+QUWxQ_FZEe3kOWevhvhJuAFQ64T7Q@mail.gmail.com \
    --to=onemda@gmail.com \
    --cc=ffmpeg-devel@ffmpeg.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git