From patchwork Sun Oct 23 19:35:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 38921 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:4a86:b0:9d:28a3:170e with SMTP id fn6csp1859816pzb; Sun, 23 Oct 2022 12:36:33 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6GQAgnDJX5V7jyirWKyUqAqvvCKBGTNTtBJ6CLUH1GoRo7/SQVKD8vN6EuZ8F7cfog58Yf X-Received: by 2002:a17:907:94c6:b0:796:f9ed:ceb3 with SMTP id dn6-20020a17090794c600b00796f9edceb3mr17429183ejc.197.1666553793065; Sun, 23 Oct 2022 12:36:33 -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 nb3-20020a1709071c8300b007a7fc67c880si1107735ejc.71.2022.10.23.12.36.32; Sun, 23 Oct 2022 12:36:33 -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=lm97euvr; 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 5B58468BCBB; Sun, 23 Oct 2022 22:36:25 +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 116F168BCA4 for ; Sun, 23 Oct 2022 22:36:19 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=S7M/YABK5E2KB4Rq0nK7CSQm73pTlE4aC0DrNysBNTMmglg6giumnPtydT5SnkoWixMNyJNFvfCEsyM9KJxBQN9HGU4XmeWHHOU80bMVTYxTCmuloL3XU/roAoyQ0cAp1dsDJPpCheO5roQMvWQHDMb/W5V2vXVo3hmmZODTz/F2+il4PtfSBPx+To5yP12ytdwrULiBGC8NOQBs5xCxupDddUsWDIpgW33GTw9ULTOhrdil61kPizGQK0tMN21jSuCQU3C/TOFLC4CKoPbpwtS1oWL2GhOUma8RyYqLfjLfgG0EinzNXmtTCsJTI7EtngMJkIytmD4yofPMfHH5PQ== 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=AfUfaxdHq/PfQUWPp71PuLgSt2LfsawPj37R9S3a0nE=; b=G6oUKpBLKp/pAp/MuE3wLMMwoW1qlxPJlTd8IsJkbF2CzcnZt+5mdfWGpA0ni8RMjvdXnTCchOW/cEMjnusV2Od1m0BnnemgJnCmkueKqpsZq6pUlElk+Tx2ewH44Jxce7Hs+/Pd+girx5PPnBrxkFd9AJGyCUpP2KZph9Iu8Kvm//MEt8PGu7ZSkhZVz3s9BeRAmb2otkdVJfLiaEUQPOc4topLmwZL8uyEb/xHaudL3bIKSealHwUfY2F3XSnI1TeL8eYFWfkffIliIIiP1erQoNJwxm2kUsjY+8HECQpW/nPFemvXz23Cr8yjpXoV4VjH6ZHgShxPedIm7TdkvQ== 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=AfUfaxdHq/PfQUWPp71PuLgSt2LfsawPj37R9S3a0nE=; b=lm97euvrPSgdRsZTwq5fL0uP+9FB9hMS+sDQUNNCuwuezb11IoQ0BIQ2FynTN0LNgkEdrT4dSdmeVrlRDQJHoKawxm2P/YXdf8Mw/Eq+bZkrIw6yGllfiEU81vMW3mmFso4qM50LTFOJK0BMTmZEesYDXQFwBGZJkWcDUcMWrSM5qWSdItaNByJ2hUAyR6GBxPwCBsOYUkUCU3gz0qEV/6CdeEzCq2EiyvFRq4XAp2OK7PT6ii5ZOQ6iS7TqQz/HFrrHdQ84ORUVEdl2bWTWnvTCv80aXMvYaQPMIOleQHFOoZGrCHH10z8ntc12l0zw5ZvqubBqDx9UFNo6btdhhw== 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:14 +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:14 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Sun, 23 Oct 2022 21:35:58 +0200 Message-ID: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: X-TMN: [EbGgNYBHA+di2zvnZtFepdaW3+TdtYk3Okkcj/lzip8=] 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-4-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: 6584ceb0-f0a1-4b87-a11e-08dab52dd90d X-MS-Exchange-SLBlob-MailProps: AZnQBsB9XmqH3kRfXJefTqIxzT/YbMNWuQRxhCEr/lRitinAQLkPPQP9WiNgrgow0G3W0sjVSsheRmky1F5nY50qkr1iirKlY9xWySuxn+w17a4FEDd6+7eF3fhGaxyOtjzC35X0m0RnB1Tkt0o02/gDg4s0/RkuUjJXmKJdDJx033ru5swColpcl/2PhV/KvbZaEdvgrIVaR2sMislL+nEZXF94xAP7cT2bCXwSd3Me9B7u4g7MIqmkiQIOXLC6V0irobe8Vdy7QLgrnhZTO63MX8aUEj02Hp9YBEfQsp+Q2GKcx1Bo6dWcmkWWXhxlVHouJtw+Dzc/VjSYmN30e0NYH5naadcKEBv2XEG4LiwbKrceL7LsqFE2IWHJ6uBYyK43R1SO3t4zlQJ9Ra3p34sBkkbIjwuCCmorq1JACC4eLqsQheNRa692dqJaLLXVjyjhloYpL2nk/hESR4oOnfBpO8QuY6awNMcKu25Ju/i0Xs9FGkcVmbfnbHnux/Od0MqWmvBI5k0XY67KL2vCd0v1Wa8C0sFwKR++vb4YrrAL/G/bapYqZT47uujMramJgQ7nHO8M+b4RjGZYRTY3En6OCu54T3H2VunUDadwDUWNzOAH5f6qTllrZ/5p4j4ACNu32w9F88dkYcMuWA/tB9HelXAS5LNQ5/P0FsB8dgvcNPlyEeVR3QH4KYTVxTAywWcdOfYSbzU671SEaKOeQwUfV6xTFhAE6Z076z597+A8HgHAflQsOgTujG+0n2kPEBSQ2fU23XE= X-Microsoft-Antispam: BCL:0; X-Microsoft-Ant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dL0LAAa7A1yQ5FfP6fRY2JXBXHrBkC7eo839U2EQVp6QOG15aL33rAT08b+W7b37lWYgc89kNwYGNxY/nQTuAO7guLEdeRC5EtU2LrwUj0S2q1EK3BqljOiIw3Q3gUjVoM8LbDBjkxRSpbyUISthHoGpQlEFTv2vDhNSJS03JBCwZYV3eDcRAcIEcCNE9uiYwL+kQ+JHMUgiRF0oqTtNKdA8LcgasepREIXnLOsGEvSH0OUJ0gyG/h/lvzAhacDcLqiat4ec0VyVneiFpRJCmFYEakctWK51nJFYGEz3DWDxIjgnoWJJXvh6MysLm7MnCmteh1dmLGCkiD/e/1RswtUGhjd2EVbGS2Fvf6djT7xEZSm6EvpwxrPCTlUIftB/4obSIrLAgFqg4OK/OdK/VC0gGSQyER83sYAoY76IOuUyKaal5Jy4KbHIUgJsflEGiBUMwLPFMA+f8i6fT4RtjpvD0iXbb+OXwfvPM7fowJ0zYCjEe1nSZOLmAs5sXceiw23onJDhwmE671LwXF/RE44JdXKiTn+NwyoO/T3vBby6rAnK/zzcKLBqo684OiwwvgVwheGfjiyAbmjMSmWQNEhIbuDY1da2zWVTcTymKSDPTNzlrnOAhxv54yBu9DAk98SFIHP39JAUxp018IV+DYCN2N9TNh55cVLQz+SPXhulIK3P8hjkuSEcwuQOUDqWQTiyrxZX9e259YeV7pW/gVX9L8xlovT7BIEBX+JuefGeMePg7deWQOc9UTQvPkDXRccyq80MQ0mJedl2lI1tG1dRPdWThsE3/wu75eGKax873JeonW4xbB8sIQmjeccVLdSFIwX6BPhJhSThpPXYQxT0dQr1DQjkmRYKIKu1JrWRrSREddjL+1LHs1VojMSdCYpV1cJKPn7am/ieT+z3BPA1OX6UbDIB/DIbklWlZZmSnmxQcr6T+/AuP77SWgGltSG+0UT8E4JVlMK39xXLhJ6slvXKJKV6YxX/KT+1RKrbDlGMtY+URo= X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6584ceb0-f0a1-4b87-a11e-08dab52dd90d 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:14.7925 (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 05/17] avcodec/mpeg12enc: 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: /1q8oh1Sq+6T Signed-off-by: Andreas Rheinhardt --- libavcodec/mpeg12data.c | 8 ++++---- libavcodec/mpeg12enc.c | 4 ++-- libavcodec/mpeg12vlc.h | 5 +++++ 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/libavcodec/mpeg12data.c b/libavcodec/mpeg12data.c index e301310b9f..398f70dd8a 100644 --- a/libavcodec/mpeg12data.c +++ b/libavcodec/mpeg12data.c @@ -64,7 +64,7 @@ const unsigned char ff_mpeg12_vlc_dc_chroma_bits[12] = { 2, 2, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, }; -static const uint16_t mpeg1_vlc[113][2] = { +const uint16_t ff_mpeg1_vlc_table[MPEG12_RL_NB_ELEMS + 2][2] = { { 0x3, 2 }, { 0x4, 4 }, { 0x5, 5 }, { 0x6, 7 }, { 0x26, 8 }, { 0x21, 8 }, { 0xa, 10 }, { 0x1d, 12 }, { 0x18, 12 }, { 0x13, 12 }, { 0x10, 12 }, { 0x1a, 13 }, @@ -97,7 +97,7 @@ static const uint16_t mpeg1_vlc[113][2] = { { 0x2, 2 }, /* EOB */ }; -static const uint16_t mpeg2_vlc[113][2] = { +const uint16_t ff_mpeg2_vlc_table[MPEG12_RL_NB_ELEMS + 2][2] = { {0x02, 2}, {0x06, 3}, {0x07, 4}, {0x1c, 5}, {0x1d, 5}, {0x05, 6}, {0x04, 6}, {0x7b, 7}, {0x7c, 7}, {0x23, 8}, {0x22, 8}, {0xfa, 8}, @@ -167,7 +167,7 @@ static const int8_t mpeg1_run[111] = { RLTable ff_rl_mpeg1 = { 111, 111, - mpeg1_vlc, + ff_mpeg1_vlc_table, mpeg1_run, mpeg1_level, }; @@ -175,7 +175,7 @@ RLTable ff_rl_mpeg1 = { RLTable ff_rl_mpeg2 = { 111, 111, - mpeg2_vlc, + ff_mpeg2_vlc_table, mpeg1_run, mpeg1_level, }; diff --git a/libavcodec/mpeg12enc.c b/libavcodec/mpeg12enc.c index c3df924b64..5d991ac99e 100644 --- a/libavcodec/mpeg12enc.c +++ b/libavcodec/mpeg12enc.c @@ -709,7 +709,7 @@ static void mpeg1_encode_block(MpegEncContext *s, int16_t *block, int n) { int alevel, level, last_non_zero, dc, diff, i, j, run, last_index, sign; int code, component; - const uint16_t (*table_vlc)[2] = ff_rl_mpeg1.table_vlc; + const uint16_t (*table_vlc)[2] = ff_mpeg1_vlc_table; last_index = s->block_last_index[n]; @@ -722,7 +722,7 @@ static void mpeg1_encode_block(MpegEncContext *s, int16_t *block, int n) s->last_dc[component] = dc; i = 1; if (s->intra_vlc_format) - table_vlc = ff_rl_mpeg2.table_vlc; + table_vlc = ff_mpeg2_vlc_table; } else { /* encode the first coefficient: needs to be done here because * it is handled slightly differently */ diff --git a/libavcodec/mpeg12vlc.h b/libavcodec/mpeg12vlc.h index d0083f1124..c810697370 100644 --- a/libavcodec/mpeg12vlc.h +++ b/libavcodec/mpeg12vlc.h @@ -53,9 +53,14 @@ void ff_mpeg12_init_vlcs(void); #define INIT_2D_VLC_RL(rl, rl_vlc, flags)\ ff_init_2d_vlc_rl(&rl, rl_vlc, FF_ARRAY_ELEMS(rl_vlc), flags) +#define MPEG12_RL_NB_ELEMS 111 + extern RLTable ff_rl_mpeg1; extern RLTable ff_rl_mpeg2; +extern const uint16_t ff_mpeg1_vlc_table[MPEG12_RL_NB_ELEMS + 2][2]; +extern const uint16_t ff_mpeg2_vlc_table[MPEG12_RL_NB_ELEMS + 2][2]; + extern RL_VLC_ELEM ff_mpeg1_rl_vlc[]; extern RL_VLC_ELEM ff_mpeg2_rl_vlc[];