From patchwork Mon Jan 30 18:39:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul B Mahol X-Patchwork-Id: 40181 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:3ca3:b0:b9:1511:ac2c with SMTP id b35csp3629397pzj; Mon, 30 Jan 2023 10:39:37 -0800 (PST) X-Google-Smtp-Source: AMrXdXtS8GyUA0DzRut1inmemY/diSmbr8Aa80HY9zJljcEg4hawBYkJru2I5tz1TRAl8xYl6oYs X-Received: by 2002:a05:6402:5023:b0:49e:9651:d180 with SMTP id p35-20020a056402502300b0049e9651d180mr49332783eda.18.1675103977199; Mon, 30 Jan 2023 10:39:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675103977; cv=none; d=google.com; s=arc-20160816; b=hqesW9yvrN8XsacMJL5swbx/50nvQ68o3L0RwDwe9nUglwYiTSNiX0U589JekF/QhG uUgOUTARXbMwk5L3ofQr2baWw3RGSWpW8JzuCRP3fHVUViu9wN70D0G7hQ1PInXxUAFo 8dD+PGx8f9QOfnTMhZ2UqcnYQPuSU5deEKqqFMT++xSQm47rbkGCZry+QNGayhPStMGH OBICpjeP2XmC+ecl8OYQun+9e2rPPR9F4bgrF+4wNd0NqEKmWJeeqswxcUgjl8QSZs8l h2yvhGaO5KZbZOVf0NYKQXADnxRszcxBXLaXYUw0fbEE1tVhnMhNnsPYCLPjemkX4YwH wwKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:subject:to :message-id:date:from:mime-version:dkim-signature:delivered-to; bh=aiMHII21RqTdTtedBV+poDcm1G4toa8CfoKZXktWk7c=; b=Dk8WeCKLeWwa4NJ6nokRqSu+jdO3C1YSQqF/r7iaFQp96i3xz7mEJermQUmhADI1Au lDbvnfqiNRRCttiFPtYoYZ+1OdhxtMCtq+s8xkfS6/dbkpiyyCPAVS0XkQw4FJ/x0/lG 6q6oPNBsuYuKqCQpobi+spCsz5qFDQhrZiHJwS9DsDUNtNg0fRKP4hjOuxE3Niptr/XG hr7mFToXcSyzY19Bmov7KekUYlzuJaq/2dUDv42sqHo0ZmjDFq/qq1QyvNkcdUveToSf 0OAtJoewHDZb5PZtWUWJhe0rbtyuA6J8qoQK/zRgg7BMco7YwTG1pMF2KyZiIU0MFttG 5yQw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=Udzanmoe; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id wl8-20020a170907310800b008889c61b770si3330615ejb.785.2023.01.30.10.39.36; Mon, 30 Jan 2023 10:39:37 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=Udzanmoe; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id C53AF68B59C; Mon, 30 Jan 2023 20:39:33 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-ua1-f53.google.com (mail-ua1-f53.google.com [209.85.222.53]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 0891C68B59C for ; Mon, 30 Jan 2023 20:39:27 +0200 (EET) Received: by mail-ua1-f53.google.com with SMTP id q19so2514437uac.10 for ; Mon, 30 Jan 2023 10:39:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=Bxy+P4LMpGs4YW2CE31tQf4H8D1PlvRkWtT/h4S0pAU=; b=UdzanmoeKlJgNnbZNaRmb5BsFEQXeZ4hEWheEcZ9xpvjylAFn0068/k51VLkmgn+Bl ceKRVyBlI7ffn53DN66A/lLumewaZIq8ZI4f3tp5uNZmt/gQpl1elz0plWGpfdYBKEXS J8kKtXxKx6VEmb2E7p3nmiqVnzOHQ5bZRExdpKSRN44jLHMloGWAuUFigoQJrJcTHr5l hNiM56oDrh/4NoKNkZvbnByPWeioxWVYxpTE7JpgZZsF//osMTGkE1HN0lFsvQjNPZ+1 WQ0gZLjiqBVTAMZf2dTQ8J3e99VXyqIK+nHZcZBY7YVeiwh3/pYkrhQQlfS28/4kIzAL S+lg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=Bxy+P4LMpGs4YW2CE31tQf4H8D1PlvRkWtT/h4S0pAU=; b=Wa1IFtEBISkLs/CuUn7wR9M1c6s1hf83Ok2VbIoztm6JLjHkQ58QZNlnWVlTyWeX6U pV+lAY2DiKlTtmsygxn6Tv8Vyl617nmXcMmzFsokfenMOs9t6fRbu3cjgGTEMyj05jRm 1eAq4wbQFKYpJ+E1xOFbl1ZO+S5odsEr6p3GRS4xvQw8WIV91hrBDJ9Y9F7ZMwUUKVvN 2BCUiMe1DfhPW4eEeWNl0oaqn/vQiKOwq4lk0rEklVt2CdLlgakviwa5earNzdwfCHom kYsD/lkR+y99ral0LHmLiBDL9TDTvjr/dKN/gzfUekSzRvIrJBzQr6x0T6BPXsVpvE1n OiVA== X-Gm-Message-State: AO0yUKW/MSbbxar8Wq91G/F7rzT98sPj63JrIojJ8peamsiNggNyCfJ3 LXgpKkqRiz/qs1nVSsiUrKwfLbKNgouyhIEy8Nqws37s X-Received: by 2002:ab0:49a6:0:b0:65a:b2d3:3bb2 with SMTP id e35-20020ab049a6000000b0065ab2d33bb2mr2006226uad.47.1675103965621; Mon, 30 Jan 2023 10:39:25 -0800 (PST) MIME-Version: 1.0 Received: by 2002:a05:612c:2428:b0:32a:5eaa:92e4 with HTTP; Mon, 30 Jan 2023 10:39:24 -0800 (PST) From: Paul B Mahol Date: Mon, 30 Jan 2023 19:39:24 +0100 Message-ID: To: FFmpeg development discussions and patches Subject: [FFmpeg-devel] [PATCH] avcodec/mlpdec: parse and use substream_info bits X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: 1bfBmstcHP07 Patch attached. Fixes relative recent thd regression. From 1715a7f4b0487c9ecebfedfc796377022a85baec Mon Sep 17 00:00:00 2001 From: Paul B Mahol 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 --- 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