From patchwork Sun Oct 23 19:35:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 38923 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:4a86:b0:9d:28a3:170e with SMTP id fn6csp1859901pzb; Sun, 23 Oct 2022 12:36:52 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6o1q8pnxzUl3wZWCBj+9F7LlMBJXqR1YaYS5I1eHPKfb6ViWBwJWn6Wslerlf5Z1ooZEl8 X-Received: by 2002:a05:6402:1906:b0:45d:db20:7709 with SMTP id e6-20020a056402190600b0045ddb207709mr26927807edz.406.1666553811856; Sun, 23 Oct 2022 12:36:51 -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 gm1-20020a1709073d0100b0073da19d0cdasi13637555ejc.973.2022.10.23.12.36.51; Sun, 23 Oct 2022 12:36:51 -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=guXFAbyG; 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 6986368BD19; Sun, 23 Oct 2022 22:36:30 +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-db5eur02olkn2032.outbound.protection.outlook.com [40.92.50.32]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 3F6D668BCCE for ; Sun, 23 Oct 2022 22:36:24 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ItB2LVa2tAjCIxfSItJiLHuxcy14OpHNkQWbj++4iI6KPHz615iQ0bk4RXasUWJKOTuzv+UtVQFSVde+6zHSc5HyEYJ/JkmusDJWIz4vHkHbIDgm+5eQCEqEfciGf04N6MfsML8wW54OWuem8zJ97zAz+pgR/N1JhfiKL4AVP/yRaE2P5lrIB4QL7aq3OWGvyUE4K4IxyYyW0gJBppezw9n4mDQQ1BudnX7TloRihWfLW/G6iL1ipZPK9VPwuNeT9gcg+qssCAH5NaqUiC+DNboVEVL7oakunnCc6kS8A1uuffQ3+a53iu0c9vC/yrZlizfC61+9CODcNquApjjadQ== 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=i0JSk8D6dwXokHOPvjqWTxhbCB2SoaSe8a7qIZTCsLs=; b=Iperll+3I94XYdmaVZC4HrSn94kwd0JML5kCzJ0TDaJCAShWM0ttckf4ZMArvuKAjPljsCOQk48Ce0UTr2u8VuqMJ7TXdpcpQ1QD2LIf8B0pDYkikgbOJkeaxLypYV4mQLTjDQd26m0P/WT1SnZwOvtw4/1T372iS3Vyz2d06cI8wvjAHD937qfrKVx53A0VjF9nhooFDsTYoUwDSgLiXnU+exKdOILul5aCqiiKZhRwQX1MBwy7BewGJ/8Zkivrd4kJtP2DQpWpkpQHubfD46cVydpm3oSKCB2h7FSdS/XSxZUBU81dZ9l5YzKT/9nRaOe1sbPxqPlVZnHsHE8iMg== 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=i0JSk8D6dwXokHOPvjqWTxhbCB2SoaSe8a7qIZTCsLs=; b=guXFAbyGCiD5CnMk/A7rZW3jXBm+wvWiG1CqnLbwS/6yt9CDhcEDf6mV7HpzjjDutM7iuQjerRpaGQSemyR5TMShuLf/GrByHj2C0NwctINO8YZmeKCli1J8HbMN1zJ3z2+vG3ZMtSg3UHQmxawDxeB0rUs7k96Ha3W4I/Ydf+/v5KccPX7b4YMVajC4yoLkUUTbMNG8nEXHu3O2SLYXyKFq+JEKEaLWhY5lf/a8bRERH1jWDRYV4b5NYhpplMIb8avcAcZ1JmG/gCNDFfeZ8QW9tqul84PJ2+kgwPiZZaSlx7k4lo84s3JEJoVkXGEfd8L4QLNpaUNh3qTHf58KUw== Received: from AS8P250MB0744.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:541::14) by GV2P250MB0825.EURP250.PROD.OUTLOOK.COM (2603:10a6:150:aa::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5746.23; Sun, 23 Oct 2022 19:36:15 +0000 Received: from AS8P250MB0744.EURP250.PROD.OUTLOOK.COM ([fe80::f9d7:680f:70c4:44fe]) by AS8P250MB0744.EURP250.PROD.OUTLOOK.COM ([fe80::f9d7:680f:70c4:44fe%7]) with mapi id 15.20.5709.015; Sun, 23 Oct 2022 19:36:15 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Sun, 23 Oct 2022 21:35:59 +0200 Message-ID: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: X-TMN: [Vu5H2cCV7TLYtFvqyPx0IcxCGTc2AzGVfi11vPic9iM=] X-ClientProxiedBy: FR3P281CA0032.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:1c::13) To AS8P250MB0744.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:541::14) X-Microsoft-Original-Message-ID: <20221023193610.674990-5-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8P250MB0744:EE_|GV2P250MB0825:EE_ X-MS-Office365-Filtering-Correlation-Id: 60e058f3-e896-4888-c3b5-08dab52dd9a8 X-MS-Exchange-SLBlob-MailProps: AZnQBsB9XmqH3kRfXJefTqIxzT/YbMNWuQRxhCEr/lRitinAQLkPPenG+QbZNnzCCgBZMAuTy2MSY9UAdpop3Xcf2DItg/TYXX88XgC03DJNUMXf5KICkra4sfgssBTOX2WbAVQkjyR/Q+cTwxsg5JbfFXgfHPntCGocRDMH3z41xVCwYcyTFec0pTpvjMTUZBFnj9t/bKWbojVdlowfomZ/j8TCcQGAa+PFmb+FlazBr2FtxAF7Xr7+ccpWGBWp9rTkSyhR7A+lIuFIbey1Q4ioBH2HxCXt17MmqQQ7T2z5vr4wHFYQUNkt1rZxWHq7+2gPgqVsVnNPhajb6TVv7sde8hJeT80MDqURYfIrpvEcxUU4n++VxaLs1w7RrvzHBOimTkg11Thy2gdaGDmnj0G5qMwvnv5maKDvnXdjbHQwpEBGtrgCSGCve+B1V6sgjfe89o8wxE3ujuqFY/VDhMX+6muRc2bzq8PUwm/EcwWZVPsvpcqFndfkzPUaaTzXoZEiiY3hQIdGStovmpIt5J/dXYzjcrjwYLjJUKPds18KckhAJZH45w5xr1JlhV+oG/HaJECWFTu8+iP3OFotczEE3FRYeXdaiQNnJYDh0jul2hUzF9Mqbh/PhCyDUDhJuNC1N7Sytc7wfmnMPwyxJCzQSRE9UwxV3dlLUOjkEln5Xs2XI2+mUAw3QwfrnvP2PvYJwZ5QAs8PH6uHNIFUVFzTx54HdzMOxaJEZ6V0vMTY2oYW3ffaUyuAAS53TYkBZjIwUYTkmLQ= X-Microsoft-Antispam: BCL:0; X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Network-Message-Id: 60e058f3-e896-4888-c3b5-08dab52dd9a8 X-MS-Exchange-CrossTenant-AuthSource: AS8P250MB0744.EURP250.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Oct 2022 19:36:15.7780 (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: GV2P250MB0825 Subject: [FFmpeg-devel] [PATCH 06/17] avcodec/speedhqenc: Avoid unnecessary indirection 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: eZwe9h4fnkvM Signed-off-by: Andreas Rheinhardt --- libavcodec/speedhq.c | 4 ++-- libavcodec/speedhq.h | 7 +++++++ libavcodec/speedhqenc.c | 8 ++++---- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/libavcodec/speedhq.c b/libavcodec/speedhq.c index ee37573789..2d6e8ca949 100644 --- a/libavcodec/speedhq.c +++ b/libavcodec/speedhq.c @@ -24,7 +24,7 @@ #include "speedhq.h" /* AC codes: Very similar but not identical to MPEG-2. */ -static const uint16_t speedhq_vlc[123][2] = { +const uint16_t ff_speedhq_vlc_table[SPEEDHQ_RL_NB_ELEMS + 2][2] = { {0x0001, 2}, {0x0003, 3}, {0x000E, 4}, {0x0007, 5}, {0x0017, 5}, {0x0028, 6}, {0x0008, 6}, {0x006F, 7}, {0x001F, 7}, {0x00C4, 8}, {0x0044, 8}, {0x005F, 8}, @@ -101,7 +101,7 @@ static const uint8_t speedhq_run[121] = { RLTable ff_rl_speedhq = { 121, 121, - speedhq_vlc, + ff_speedhq_vlc_table, speedhq_run, speedhq_level, }; diff --git a/libavcodec/speedhq.h b/libavcodec/speedhq.h index 94879eda65..78f11ac6ab 100644 --- a/libavcodec/speedhq.h +++ b/libavcodec/speedhq.h @@ -21,9 +21,16 @@ #ifndef AVCODEC_SPEEDHQ_H #define AVCODEC_SPEEDHQ_H +#include #include "rl.h" #include "libavutil/attributes_internal.h" +#define SPEEDHQ_RL_NB_ELEMS 121 + +FF_VISIBILITY_PUSH_HIDDEN +extern const uint16_t ff_speedhq_vlc_table[SPEEDHQ_RL_NB_ELEMS + 2][2]; + extern RLTable attribute_visibility_hidden ff_rl_speedhq; +FF_VISIBILITY_POP_HIDDEN #endif /* AVCODEC_SPEEDHQ_H */ diff --git a/libavcodec/speedhqenc.c b/libavcodec/speedhqenc.c index 6cf40aac2d..58b5e858a8 100644 --- a/libavcodec/speedhqenc.c +++ b/libavcodec/speedhqenc.c @@ -222,11 +222,11 @@ static void encode_block(MpegEncContext *s, int16_t *block, int n) if (alevel <= ff_rl_speedhq.max_level[0][run]) { code = ff_rl_speedhq.index_run[0][run] + alevel - 1; /* store the VLC & sign at once */ - put_bits_le(&s->pb, ff_rl_speedhq.table_vlc[code][1] + 1, - ff_rl_speedhq.table_vlc[code][0] + (sign << ff_rl_speedhq.table_vlc[code][1])); + put_bits_le(&s->pb, ff_speedhq_vlc_table[code][1] + 1, + ff_speedhq_vlc_table[code][0] | (sign << ff_speedhq_vlc_table[code][1])); } else { /* escape seems to be pretty rare <5% so I do not optimize it; - * the values correspond to ff_rl_speedhq.table_vlc[121] */ + * the values correspond to ff_speedhq_vlc_table[121] */ put_bits_le(&s->pb, 6, 32); /* escape: only clip in this case */ put_bits_le(&s->pb, 6, run); @@ -235,7 +235,7 @@ static void encode_block(MpegEncContext *s, int16_t *block, int n) last_non_zero = i; } } - /* end of block; the values correspond to ff_rl_speedhq.table_vlc[122] */ + /* end of block; the values correspond to ff_speedhq_vlc_table[122] */ put_bits_le(&s->pb, 4, 6); }