From patchwork Sat Mar 30 03:39:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 47669 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:9f96:b0:1a3:b6bb:3029 with SMTP id mm22csp2325152pzb; Fri, 29 Mar 2024 20:39:37 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVbUBUIMP5FMv5huBy/kdlgc8oeWORgMKK2ECmp8JD8VBpFeGXo5qd5wG+DiAcNiV5D4iBw6gBdJdRD2nYgGIx8qA2gcJ23lSXnyg== X-Google-Smtp-Source: AGHT+IFVWZh0+u+guSdwVDhNJMdRMUerMl5AQ83l40yXQ3jNvGO7yZMN8BLEN4VbL1A36uEPAW24 X-Received: by 2002:a05:6402:268c:b0:56b:b8c8:53e4 with SMTP id w12-20020a056402268c00b0056bb8c853e4mr2526345edd.4.1711769976915; Fri, 29 Mar 2024 20:39:36 -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 r16-20020a50c010000000b0056bd7f3fcf3si2301719edb.624.2024.03.29.20.39.36; Fri, 29 Mar 2024 20:39:36 -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=fVatjKXH; 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 2F29168D430; Sat, 30 Mar 2024 05:39:33 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05olkn2102.outbound.protection.outlook.com [40.92.91.102]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 18A1168C273 for ; Sat, 30 Mar 2024 05:39:30 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aSKWlyKRxponCbVBNZLgG34hXcqe7ieh+wdRwjOcKF4Ub5+QnB4kDSrnNQp+YQgnEkQ+uwduShHBnlMPDPHFxoKKSPEJN3b4WzDkP3M30/EByHTFaouvhI68zViB2/xbL9PzeWoFEtrPHoZGbaqtjDsHqPRyrHu7p9bu+/btgbYHucve9RBLeTYrbPPhZ/lnnbERMEoOWQDXpNJHRScSGuw0GmezfB8a1dTKCQsNFhXu5oS8QMnEMVw2OINgfn67uZK/t7Ij8FUlJZQCKbEKXWubnYUZm1zjs2+wKOGITK+mLJYBrKc4Cdgxlauw+S6/N+SWL27iK65WbDMQT7tvpw== 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=9BdkfR1UCUURX3ODA1Qclx0mi+6Fx1Ow/XGaYS535Po=; b=h8MzKu0ZgVfgifKh0Z0VBe4qa3iYlwkv9128xEkBL02qR1MnUVxYmmwew1DDJFqgzN/lyZQ0ujseNXs7fj4awLgDw9cMpcn34HZAerl9UtURiYe1dF8Ikn0d6RjD+chUf/EgRh9u26smduGQ6WRYNdhq6pLBX4UJXCV22ZDtHAwaFWqOLEBafGZZyZwZqNnhnrldRh48F2NmA6+jJ0OnWAnfSYyy9UJ7SJjHMcQQnziJS1kLCfFPauwbLwcSPv6YHHk+ud3cICNROEJILUzEPdvez2sKmtMzkuStOTsYg6mZqTLbSPZmE1u/NFUHsfSXBNBdlHr8BE/1aHQZPjN0fQ== 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=9BdkfR1UCUURX3ODA1Qclx0mi+6Fx1Ow/XGaYS535Po=; b=fVatjKXH2nXeXg/E7wmb7eSOaJFNqEqeF3izLZeaMmu4rTelsa9gLlHXTBSWJKPne6V3p2iVULfyV4JKpJnnwIko7/v8m3jMSGlwtm0Vh7oO1F3VhXJxWcvxivh2EGbba2e64iGll+ZXC2M0bYw0F/n+dljmct64JyKndvriggtLMIWJIHJ5/CW4sPUjjRZPlBbfOCJKvRt5VJToim/P0iNpT9OQ7A75cbQ9YsCZLzhSoVqWbWLHHLJC3D4mWkPx736aiaaiHAim9lPdJyw9pr4MdB3BT2liFHiiwg/Zbe/dUGOzTd+YczfDjLnmO8qqkuK27DB9E0RmpA39bGpJfg== Received: from GV1P250MB0737.EURP250.PROD.OUTLOOK.COM (2603:10a6:150:8e::17) by AS1P250MB0477.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:4a6::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.40; Sat, 30 Mar 2024 03:39:29 +0000 Received: from GV1P250MB0737.EURP250.PROD.OUTLOOK.COM ([fe80::4a3b:cf76:cddc:c68d]) by GV1P250MB0737.EURP250.PROD.OUTLOOK.COM ([fe80::4a3b:cf76:cddc:c68d%4]) with mapi id 15.20.7409.039; Sat, 30 Mar 2024 03:39:29 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Sat, 30 Mar 2024 04:39:20 +0100 Message-ID: X-Mailer: git-send-email 2.40.1 In-Reply-To: References: X-TMN: [3F0Md7x25Q/L/03F/DORuEevjcDi9pJh] X-ClientProxiedBy: ZR0P278CA0095.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:23::10) To GV1P250MB0737.EURP250.PROD.OUTLOOK.COM (2603:10a6:150:8e::17) X-Microsoft-Original-Message-ID: <20240330033920.2721221-1-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: GV1P250MB0737:EE_|AS1P250MB0477:EE_ X-MS-Office365-Filtering-Correlation-Id: 23bd8c40-928d-4777-5393-08dc506b0119 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 1reZ4QFGrfkd7otl9AiZr/M0FydZXHKLTAHO8y996+hE+2+CDdm+R0MU6jghdtQDW5YkI0El5xkOjl7VN0SZSYuwDo7+QnVS66ixWg5lBnuyy00hFjCaNaIMpd46LvHBpfL+H+Jcigca+IecBypF0UcBfRQMQgdXUoVPKbccTBCr0WKrcKj+ODpczM5krhLMXkPtQ1PVc7WBpQ/HfVHKQ0RPxnZN+yugr1wYNl5YCzULp2Z4a9UxjNqoGGyjD5RNLk5EZ0k1dZNWn1jKw4hBb2eAR9Z1qvvku13QeddAN/vEU85IllpZFmpdA3WUsCfuVaq19YYfU7BI7yK3qeSZTAHSDbS7HMwnsp8iwVdISNJW6xf0O9h/no3EQTdXbKgISOd3YMZTeMlceYpOOpR3SAHvhZxp4hA6SfYOgS70aU2LXHajvGERonknr6z48OK4UwVz+5he3/tm2qZzesQ1FzE4vlk/CJZm3f/OEJnPL2nzRfr+sPbjKLLgRYfqctZORGF3iN5mfw+8Xf3CEshTN8Bx7nQqnuAlyuG8KKfdHvmOp38VBf7ewe9Lf0j3xhAL01CedgQrrTKaBw3NQY80JvVohEECqmXhtnSoj9WaZBxvTmsF3txzX3sXzFaAz76H X-MS-Exchange-AntiSpam-MessageData-ChunkCount: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BxPnkhBRzaHoH+leSTzlXOeLyLQbFveXu6wzHuUN31WGh4fskydJ2p06KE63qbH+0SEqzzgbpsw/AHNOl/cOwbc7rk1QblTI2EVHcrmhz57o4mc4JrYhYnV7kVvzcVlxeI2nb/3JtzATu4ImHco5wmwiPcnJxOm/pzjeXwWnhufhYKIooWfJUZtFkS9ExvqVcjN9oZZkTDOBXMgd2cXq9sSnfCP2AFWZtdIQsJmGpUjTenmN2GM/pnAsA6Z1mYbCY1YHk9g== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 23bd8c40-928d-4777-5393-08dc506b0119 X-MS-Exchange-CrossTenant-AuthSource: GV1P250MB0737.EURP250.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Mar 2024 03:39:29.1901 (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: AS1P250MB0477 Subject: [FFmpeg-devel] [PATCH v2 12/12] avcodec/vlc: Use union of uint8_t and uint16_t in VLC_MULTI_ELEM 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: 78C8Zk48zgH/ It is more natural and simplifies writing these arrays. Signed-off-by: Andreas Rheinhardt --- libavcodec/bitstream_template.h | 2 +- libavcodec/vlc.c | 10 +++++----- libavcodec/vlc.h | 5 ++++- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/libavcodec/bitstream_template.h b/libavcodec/bitstream_template.h index c8e4a5131e..bbb8dfa555 100644 --- a/libavcodec/bitstream_template.h +++ b/libavcodec/bitstream_template.h @@ -542,7 +542,7 @@ static inline int BS_FUNC(read_vlc_multi)(BSCTX *bc, uint8_t dst[8], unsigned idx = BS_FUNC(peek)(bc, bits); int ret, nb_bits, code, n = Jtable[idx].len; if (Jtable[idx].num) { - AV_COPY64U(dst, Jtable[idx].val); + AV_COPY64U(dst, Jtable[idx].val8); ret = Jtable[idx].num; } else { code = table[idx].sym; diff --git a/libavcodec/vlc.c b/libavcodec/vlc.c index e01cc41689..ee09d96fd6 100644 --- a/libavcodec/vlc.c +++ b/libavcodec/vlc.c @@ -440,8 +440,8 @@ static void add_level(VLC_MULTI_ELEM *table, const int is16bit, code = curcode + (buf[t].code >> curlen); newlimit = curlimit - l; l += curlen; - if (is16bit) AV_WN16(info.val+2*curlevel, sym); - else info.val[curlevel] = sym&0xFF; + if (is16bit) info.val16[curlevel] = sym; + else info.val8[curlevel] = sym&0xFF; if (curlevel) { // let's not add single entries uint32_t val = code >> (32 - numbits); @@ -468,7 +468,7 @@ static int vlc_multi_gen(VLC_MULTI_ELEM *table, const VLC *single, { int minbits, maxbits, max; unsigned count[VLC_MULTI_MAX_SYMBOLS-1] = { 0, }; - VLC_MULTI_ELEM info = { { 0, }, 0, 0, }; + VLC_MULTI_ELEM info = { 0 }; int count0 = 0; for (int j = 0; j < 1<table[j].len; table[j].num = single->table[j].len > 0 ? 1 : 0; if (is16bit) - AV_WN16(table[j].val, single->table[j].sym); + table[j].val16[0] = single->table[j].sym; else - table[j].val[0] = single->table[j].sym; + table[j].val8[0] = single->table[j].sym; } add_level(table, is16bit, nb_codes, numbits, buf, diff --git a/libavcodec/vlc.h b/libavcodec/vlc.h index 0cc106c499..bf7b0e65b4 100644 --- a/libavcodec/vlc.h +++ b/libavcodec/vlc.h @@ -40,7 +40,10 @@ typedef struct VLC { } VLC; typedef struct VLC_MULTI_ELEM { - uint8_t val[VLC_MULTI_MAX_SYMBOLS]; + union { + uint8_t val8[VLC_MULTI_MAX_SYMBOLS]; + uint16_t val16[VLC_MULTI_MAX_SYMBOLS / 2]; + }; int8_t len; // -31,32 uint8_t num; } VLC_MULTI_ELEM;