From patchwork Tue Sep 26 22:17:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 43966 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:2a18:b0:15d:8365:d4b8 with SMTP id e24csp2211665pzh; Tue, 26 Sep 2023 15:24:26 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFn1mZPDF6/9NanrH+H69Nz4pkqVoEVZzFMrqIdKeVx6MjDxpTDe1ZhkPZS2mXNUJ6cWxu+ X-Received: by 2002:a17:906:1096:b0:9a1:c370:1af2 with SMTP id u22-20020a170906109600b009a1c3701af2mr68749eju.3.1695767065958; Tue, 26 Sep 2023 15:24:25 -0700 (PDT) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id n2-20020a170906840200b009925144d755si12335134ejx.461.2023.09.26.15.24.25; Tue, 26 Sep 2023 15:24:25 -0700 (PDT) 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=@outlook.com header.s=selector1 header.b=XEsKFx74; arc=fail (body hash mismatch); 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=outlook.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 56F0868CBB8; Wed, 27 Sep 2023 01:22:42 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR02-DB5-obe.outbound.protection.outlook.com (mail-db5eur02olkn2061.outbound.protection.outlook.com [40.92.50.61]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 9A03468CB43 for ; Wed, 27 Sep 2023 01:22:40 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NPYpoPp2hwQFufocEFimsWnbTvEzo+729qtRzirkPCL/tIpsQHO6mYZgnstCOJsGp63tXSLA57J87iw4NhSZRndMb/d1WMrfW/3+Wz96IQ5HJ9G5yfyK8uENhgf/z6diZnW3sV6kbI/QrIqRgiuzlXkkwlOSuhUvv9JIY7LjcovD3e0aMH7vqSG9EfU9cMbKoTSkU6qul4grSPF6MXnoR1rLfDTAAA/SOo1KldbDORe2boq5VXy++1ReRD2Fg4EDk864KMFKyLbkurjRycbIzhNLiBQURer2ucvte6/wasYKA4GB/Bfz6FWY4IMeo72+huv1VJx820Jm+0fIn5mpqg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=IFWmpTBactP0yLlxHwd3tUK6MkoLpAoAyMUFrwBLxJg=; b=SjHcKv04+IAXx6XuGUnMy77KWZ4vTw8JDpKnvQk5AwFIKMjli4otNh+kwOX0ypzg1PPQh5zkvJvFThJVkOIfM9EhKfG/q3IztYEqeVt9Y2lDqUxEqEIZmYDnQeMKlvWSjjqwYxX79vaZPSvf2AEZdw//JjMgTgFmH7tDsyI27gsF3C03/sn5BE0WZoGSZlypzXUL17cRb3nSZLZjcVPk06Rq55E025Gyy8mKrIFTOVZRko3X6gIgGUtB1bJT8rICPF+71v8TP68UIdmXo8JKF6IXUBW+xyiFOlruv0ODPQR2B9wKAesoBkPspcCN+gWt1ldJwz5q2BthlvYTVJf6Zg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=IFWmpTBactP0yLlxHwd3tUK6MkoLpAoAyMUFrwBLxJg=; b=XEsKFx74In1AZ4PFkXXTkdXDD3J6SM6QTihqvcWPQYHYB01phDdjPR2MPrjqH+9U+Idkm9WQcZ5x9izcJbpmTiYQslk8IHw/FNOSSQalsHFkEadB+/wmZHkr5ZOrkKJd6XpaxuOo6mugQaCIXTGq7rJEfJYQk47ENqKdG/IU6YLJw7aX5oVQZBf10DmNJ4/3Y7gyVbGSjIOoRYJMWoAfparnZxuAFKzclvyg7gEe/8Er3Cl8qJqyFlu66YZ210IqbPsXAwjQDDvu6hLWTWgiLX0F91cJwH5vlH+M4kLP2MVJWiwZINw90AA/cAxdex6V3obMjmOq7jhwGmMymZvxKQ== Received: from GV1P250MB0737.EURP250.PROD.OUTLOOK.COM (2603:10a6:150:8e::17) by AM8P250MB0160.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:323::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6813.28; Tue, 26 Sep 2023 22:22:39 +0000 Received: from GV1P250MB0737.EURP250.PROD.OUTLOOK.COM ([fe80::9d42:7b4f:71ef:c76a]) by GV1P250MB0737.EURP250.PROD.OUTLOOK.COM ([fe80::9d42:7b4f:71ef:c76a%3]) with mapi id 15.20.6813.027; Tue, 26 Sep 2023 22:22:39 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Wed, 27 Sep 2023 00:17:26 +0200 Message-ID: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: X-TMN: [MP4FRElBvJZ8Bvga7BRVi9tdBKZw7yeh] X-ClientProxiedBy: FR3P281CA0019.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:1c::6) To GV1P250MB0737.EURP250.PROD.OUTLOOK.COM (2603:10a6:150:8e::17) X-Microsoft-Original-Message-ID: <20230926221732.3711507-54-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: GV1P250MB0737:EE_|AM8P250MB0160:EE_ X-MS-Office365-Filtering-Correlation-Id: 953cb78c-525e-4f51-bb02-08dbbedf17c4 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: jqsUFmWajgSc8OTv/i5aE1NuJfpTDq7Sjl4LJEL7eH6F37OZjZ0F1v/8+JFodMnbOUmv+T/piq3Q6pX0J9AYtKo6pGdJm4wfPXUv/oNy/O+S/Mo55ua8wuW0A+nhW4X2eYJd/xLP+XencNJS+DYqB6ORdnAd6KthEceE3LzA1esOM3CL5jwRhCoNpdHQYcHT2a1RCsKvMPRoTtUg19IYUJN26tGvl3RWMmRA8gYdoe17fcRo6+YfNtzZn1xJSNiJ46st+W9algM0PkfOjasoXTesJfSBUwRtK63OFC+Yf4vJ6WCbU/XS0EunLx0ZCoUAvvd2YF3bsR5tJUo7wKelPUFhx33sefvqki/X87O8HW8rEah19jnOXrcJYzV6D7LQmDweVSM6tVL2BGQzjsVY3NDZLP4REbHBs+msGC7AdTx42OWuTRfAtdO8glMU/VM20c07yz8a9Zqf8DWZnshaFZ80vD2KJLLlvN/VSA2lrmbw5okxzyVO6ptQeMBzyoIBIT5z60e6DCUqyuJsSziCQOWGmryiHE/TcN9RSmcWJDbx+4UnpqUz4rU2RI4mPkz7PI6UkY3U5X1WeYL2dPwmoXWPIuhS1qAQBfrH72Zk+cJOZiNGisGcz+wmGhWwuyfa X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Fid5gISje3gom1IZoc1IjpSIaRYb3f6s/Ne5/wnLXznvF+HzLt4IWlj7nHrh4zajfmhO6uHLTNveC27UtTXdpvhLcj4OgA6jyXPJi1JMZGJ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MSa6umViTdIdoDLooEwZ/WlLjydaPwWQjdTYwnZCrSaFd710QO3AkAV8Ma4d3UFwrnBfcFZt6CC+EIj6sdEw X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 953cb78c-525e-4f51-bb02-08dbbedf17c4 X-MS-Exchange-CrossTenant-AuthSource: GV1P250MB0737.EURP250.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Sep 2023 22:22:39.1409 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8P250MB0160 Subject: [FFmpeg-devel] [PATCH 55/61] avcodec/aacps_common: Combine huffman tabels 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 Cc: Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: jmcxnRB7uSx3 This allows to avoid the relocations inherent in an array to individual tables; it also reduces padding. Signed-off-by: Andreas Rheinhardt --- libavcodec/aacps_common.c | 27 +++++---------------------- libavcodec/aacpsdata.c | 31 +++---------------------------- 2 files changed, 8 insertions(+), 50 deletions(-) diff --git a/libavcodec/aacps_common.c b/libavcodec/aacps_common.c index 653fc38da3..7a83cbd7d6 100644 --- a/libavcodec/aacps_common.c +++ b/libavcodec/aacps_common.c @@ -288,36 +288,19 @@ err: return bits_left; } -#define PS_VLC_ROW(name) \ - { name ## _tab, FF_ARRAY_ELEMS(name ## _tab) } - av_cold void ff_ps_init_common(void) { static VLCElem vlc_buf[(1544 + 832 + 1024 + 1036) + (544 + 544) + (32 + 32 + 32 + 32)]; VLCInitState state = VLC_INIT_STATE(vlc_buf); - // Syntax initialization - static const struct { - const uint8_t (*vlc_tab)[2]; - const unsigned int table_elems; - } ps_tmp[] = { - PS_VLC_ROW(huff_iid_df1), - PS_VLC_ROW(huff_iid_dt1), - PS_VLC_ROW(huff_iid_df0), - PS_VLC_ROW(huff_iid_dt0), - PS_VLC_ROW(huff_icc_df), - PS_VLC_ROW(huff_icc_dt), - PS_VLC_ROW(huff_ipd_df), - PS_VLC_ROW(huff_ipd_dt), - PS_VLC_ROW(huff_opd_df), - PS_VLC_ROW(huff_opd_dt), - }; + const uint8_t (*tab)[2] = aacps_huff_tabs; for (int i = 0; i < FF_ARRAY_ELEMS(vlc_ps); i++) { vlc_ps[i] = - ff_vlc_init_tables_from_lengths(&state, i <= 5 ? 9 : 5, ps_tmp[i].table_elems, - &ps_tmp[i].vlc_tab[0][1], 2, - &ps_tmp[i].vlc_tab[0][0], 2, 1, + ff_vlc_init_tables_from_lengths(&state, i <= 5 ? 9 : 5, huff_sizes[i], + &tab[0][1], 2, + &tab[0][0], 2, 1, 0, 0); + tab += huff_sizes[i]; } } diff --git a/libavcodec/aacpsdata.c b/libavcodec/aacpsdata.c index 8241346b0d..6885b386c0 100644 --- a/libavcodec/aacpsdata.c +++ b/libavcodec/aacpsdata.c @@ -21,7 +21,9 @@ #include -static const uint8_t huff_iid_df1_tab[][2] = { +static const uint8_t huff_sizes[] = { 61, 61, 29, 29, 15, 15, 8, 8, 8, 8 }; + +static const uint8_t aacps_huff_tabs[][2] = { /* huff_iid_df1 - 61 entries */ { 28, 4 }, { 32, 4 }, { 29, 3 }, { 31, 3 }, { 27, 5 }, { 33, 5 }, { 26, 6 }, { 34, 6 }, { 25, 7 }, { 35, 7 }, @@ -36,9 +38,6 @@ static const uint8_t huff_iid_df1_tab[][2] = { { 57, 18 }, { 58, 18 }, { 0, 18 }, { 1, 18 }, { 10, 18 }, { 50, 18 }, { 14, 16 }, { 46, 16 }, { 20, 12 }, { 23, 10 }, { 30, 1 }, -}; - -static const uint8_t huff_iid_dt1_tab[][2] = { /* huff_iid_dt1 - 61 entries */ { 31, 2 }, { 26, 7 }, { 34, 7 }, { 27, 6 }, { 33, 6 }, { 35, 8 }, { 24, 9 }, { 36, 9 }, { 39, 11 }, { 41, 12 }, @@ -53,9 +52,6 @@ static const uint8_t huff_iid_dt1_tab[][2] = { { 14, 15 }, { 46, 15 }, { 50, 16 }, { 51, 16 }, { 19, 13 }, { 21, 12 }, { 25, 9 }, { 28, 5 }, { 32, 5 }, { 29, 3 }, { 30, 1 }, -}; - -static const uint8_t huff_iid_df0_tab[][2] = { /* huff_iid_df0 - 29 entries */ { 14, 1 }, { 15, 3 }, { 13, 3 }, { 16, 4 }, { 12, 4 }, { 17, 5 }, { 11, 5 }, { 10, 6 }, { 18, 6 }, { 19, 6 }, @@ -63,9 +59,6 @@ static const uint8_t huff_iid_df0_tab[][2] = { { 22, 13 }, { 6, 13 }, { 23, 14 }, { 24, 14 }, { 5, 15 }, { 25, 15 }, { 4, 16 }, { 3, 17 }, { 0, 17 }, { 1, 17 }, { 2, 17 }, { 26, 17 }, { 27, 18 }, { 28, 18 }, -}; - -static const uint8_t huff_iid_dt0_tab[][2] = { /* huff_iid_dt0 - 29 entries */ { 14, 1 }, { 13, 2 }, { 15, 3 }, { 12, 4 }, { 16, 5 }, { 11, 6 }, { 17, 7 }, { 10, 8 }, { 18, 9 }, { 9, 10 }, @@ -73,41 +66,23 @@ static const uint8_t huff_iid_dt0_tab[][2] = { { 22, 17 }, { 6, 17 }, { 23, 19 }, { 0, 19 }, { 1, 19 }, { 2, 19 }, { 3, 20 }, { 4, 20 }, { 5, 20 }, { 24, 20 }, { 25, 20 }, { 26, 20 }, { 27, 20 }, { 28, 20 }, -}; - -static const uint8_t huff_icc_df_tab[][2] = { /* huff_icc_df - 15 entries */ { 7, 1 }, { 8, 2 }, { 6, 3 }, { 9, 4 }, { 5, 5 }, { 10, 6 }, { 4, 7 }, { 11, 8 }, { 12, 9 }, { 3, 10 }, { 13, 11 }, { 2, 12 }, { 14, 13 }, { 1, 14 }, { 0, 14 }, -}; - -static const uint8_t huff_icc_dt_tab[][2] = { /* huff_icc_dt - 15 entries */ { 7, 1 }, { 8, 2 }, { 6, 3 }, { 9, 4 }, { 5, 5 }, { 10, 6 }, { 4, 7 }, { 11, 8 }, { 3, 9 }, { 12, 10 }, { 2, 11 }, { 13, 12 }, { 1, 13 }, { 0, 14 }, { 14, 14 }, -}; - -static const uint8_t huff_ipd_df_tab[][2] = { /* huff_ipd_df - 8 entries */ { 1, 3 }, { 4, 4 }, { 5, 4 }, { 3, 4 }, { 6, 4 }, { 2, 4 }, { 7, 4 }, { 0, 1 }, -}; - -static const uint8_t huff_ipd_dt_tab[][2] = { /* huff_ipd_dt - 8 entries */ { 5, 4 }, { 4, 5 }, { 3, 5 }, { 2, 4 }, { 6, 4 }, { 1, 3 }, { 7, 3 }, { 0, 1 }, -}; - -static const uint8_t huff_opd_df_tab[][2] = { /* huff_opd_df - 8 entries */ { 7, 3 }, { 1, 3 }, { 3, 4 }, { 6, 4 }, { 2, 4 }, { 5, 5 }, { 4, 5 }, { 0, 1 }, -}; - -static const uint8_t huff_opd_dt_tab[][2] = { /* huff_opd_dt - 8 entries */ { 5, 4 }, { 2, 4 }, { 6, 4 }, { 4, 5 }, { 3, 5 }, { 1, 3 }, { 7, 3 }, { 0, 1 },