* [FFmpeg-devel] [PATCH] avcodec/mlpdec: parse and use substream_info bits
@ 2023-01-30 18:39 Paul B Mahol
2023-01-31 11:27 ` Andreas Rheinhardt
0 siblings, 1 reply; 4+ messages in thread
From: Paul B Mahol @ 2023-01-30 18:39 UTC (permalink / raw)
To: FFmpeg development discussions and patches
[-- Attachment #1: Type: text/plain, Size: 55 bytes --]
Patch attached.
Fixes relative recent thd regression.
[-- Attachment #2: 0001-avcodec-mlpdec-parse-and-use-substream-info-bits.patch --]
[-- Type: text/x-patch, Size: 3612 bytes --]
From 1715a7f4b0487c9ecebfedfc796377022a85baec Mon Sep 17 00:00:00 2001
From: Paul B Mahol <onemda@gmail.com>
Date: Mon, 30 Jan 2023 19:35:36 +0100
Subject: [PATCH] avcodec/mlpdec: parse and use substream info bits
Signed-off-by: Paul B Mahol <onemda@gmail.com>
---
libavcodec/mlp_parse.c | 6 +++++-
libavcodec/mlp_parse.h | 3 +++
libavcodec/mlpdec.c | 15 ++++++++++++++-
3 files changed, 22 insertions(+), 2 deletions(-)
diff --git a/libavcodec/mlp_parse.c b/libavcodec/mlp_parse.c
index 45715352c2..924c731439 100644
--- a/libavcodec/mlp_parse.c
+++ b/libavcodec/mlp_parse.c
@@ -159,7 +159,11 @@ int ff_mlp_read_major_sync(void *log, MLPHeaderInfo *mh, GetBitContext *gb)
mh->num_substreams = get_bits(gb, 4);
- skip_bits_long(gb, 4 + (header_size - 17) * 8);
+ skip_bits(gb, 2);
+ mh->extended_substream_info = get_bits(gb, 2);
+ mh->substream_info = get_bits(gb, 8);
+
+ skip_bits_long(gb, (header_size - 18) * 8);
return 0;
}
diff --git a/libavcodec/mlp_parse.h b/libavcodec/mlp_parse.h
index f0d7b41c11..fa6e3d52dc 100644
--- a/libavcodec/mlp_parse.h
+++ b/libavcodec/mlp_parse.h
@@ -58,6 +58,9 @@ typedef struct MLPHeaderInfo
int peak_bitrate; ///< Peak bitrate for VBR, actual bitrate (==peak) for CBR
int num_substreams; ///< Number of substreams within stream
+
+ int extended_substream_info; ///< Which substream of substreams carry 16-channel presentation
+ int substream_info; ///< Which substream of substreams carry 2/6/8-channel presentation
} MLPHeaderInfo;
static const uint8_t thd_chancount[13] = {
diff --git a/libavcodec/mlpdec.c b/libavcodec/mlpdec.c
index 5b14a3b03b..c7b2ca21a1 100644
--- a/libavcodec/mlpdec.c
+++ b/libavcodec/mlpdec.c
@@ -153,6 +153,12 @@ typedef struct MLPDecodeContext {
/// Number of substreams contained within this stream.
uint8_t num_substreams;
+ ///< Which substream of substreams carry 16-channel presentation
+ uint8_t extended_substream_info;
+
+ ///< Which substream of substreams carry 2/6/8-channel presentation
+ uint8_t substream_info;
+
/// Index of the last substream to decode - further substreams are skipped.
uint8_t max_decoded_substream;
@@ -384,6 +390,7 @@ static int read_major_sync(MLPDecodeContext *m, GetBitContext *gb)
m->access_unit_size_pow2 = mh.access_unit_size_pow2;
m->num_substreams = mh.num_substreams;
+ m->substream_info = mh.substream_info;
/* limit to decoding 3 substreams, as the 4th is used by Dolby Atmos for non-audio data */
m->max_decoded_substream = FFMIN(m->num_substreams - 1, 2);
@@ -1286,7 +1293,13 @@ static int read_access_unit(AVCodecContext *avctx, AVFrame *frame,
if (!s->restart_seen)
goto next_substr;
- if (substr > 0 && substr < m->max_decoded_substream &&
+ if (((avctx->ch_layout.nb_channels == 6 &&
+ ((m->substream_info >> 2) & 0x3) != 0x3) ||
+ (avctx->ch_layout.nb_channels == 8 &&
+ ((m->substream_info >> 4) & 0x7) != 0x7 &&
+ ((m->substream_info >> 4) & 0x7) != 0x6 &&
+ ((m->substream_info >> 4) & 0x7) != 0x3)) &&
+ substr > 0 && substr < m->max_decoded_substream &&
(s->min_channel <= m->substream[substr - 1].max_channel)) {
av_log(avctx, AV_LOG_DEBUG,
"Previous substream(%d) channels overlaps current substream(%d) channels, skipping.\n",
--
2.39.1
[-- 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".
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [FFmpeg-devel] [PATCH] avcodec/mlpdec: parse and use substream_info bits
2023-01-30 18:39 [FFmpeg-devel] [PATCH] avcodec/mlpdec: parse and use substream_info bits Paul B Mahol
@ 2023-01-31 11:27 ` Andreas Rheinhardt
2023-01-31 11:35 ` Paul B Mahol
0 siblings, 1 reply; 4+ messages in thread
From: Andreas Rheinhardt @ 2023-01-31 11:27 UTC (permalink / raw)
To: ffmpeg-devel
Paul B Mahol:
> + ///< Which substream of substreams carry 16-channel presentation
> + uint8_t extended_substream_info;
> +
> + ///< Which substream of substreams carry 2/6/8-channel presentation
> + uint8_t substream_info;
> +
Sure about the '<' in ///<? I thought this means that the comment
applies to the entity directly before the ///<.
- Andreas
_______________________________________________
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".
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [FFmpeg-devel] [PATCH] avcodec/mlpdec: parse and use substream_info bits
2023-01-31 11:27 ` Andreas Rheinhardt
@ 2023-01-31 11:35 ` Paul B Mahol
2023-01-31 15:04 ` Paul B Mahol
0 siblings, 1 reply; 4+ messages in thread
From: Paul B Mahol @ 2023-01-31 11:35 UTC (permalink / raw)
To: FFmpeg development discussions and patches
On 1/31/23, Andreas Rheinhardt <andreas.rheinhardt@outlook.com> wrote:
> Paul B Mahol:
>> + ///< Which substream of substreams carry 16-channel presentation
>> + uint8_t extended_substream_info;
>> +
>> + ///< Which substream of substreams carry 2/6/8-channel presentation
>> + uint8_t substream_info;
>> +
>
> Sure about the '<' in ///<? I thought this means that the comment
> applies to the entity directly before the ///<.
I copied from other lines.
>
> - Andreas
>
> _______________________________________________
> 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".
>
_______________________________________________
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".
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [FFmpeg-devel] [PATCH] avcodec/mlpdec: parse and use substream_info bits
2023-01-31 11:35 ` Paul B Mahol
@ 2023-01-31 15:04 ` Paul B Mahol
0 siblings, 0 replies; 4+ messages in thread
From: Paul B Mahol @ 2023-01-31 15:04 UTC (permalink / raw)
To: FFmpeg development discussions and patches
On 1/31/23, Paul B Mahol <onemda@gmail.com> wrote:
> On 1/31/23, Andreas Rheinhardt <andreas.rheinhardt@outlook.com> wrote:
>> Paul B Mahol:
>>> + ///< Which substream of substreams carry 16-channel presentation
>>> + uint8_t extended_substream_info;
>>> +
>>> + ///< Which substream of substreams carry 2/6/8-channel presentation
>>> + uint8_t substream_info;
>>> +
>>
>> Sure about the '<' in ///<? I thought this means that the comment
>> applies to the entity directly before the ///<.
>
> I copied from other lines.
Will apply with this fixed.
_______________________________________________
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".
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-01-31 15:05 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-30 18:39 [FFmpeg-devel] [PATCH] avcodec/mlpdec: parse and use substream_info bits Paul B Mahol
2023-01-31 11:27 ` Andreas Rheinhardt
2023-01-31 11:35 ` Paul B Mahol
2023-01-31 15:04 ` Paul B Mahol
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