From patchwork Sun Oct 23 19:36:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 38926 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:4a86:b0:9d:28a3:170e with SMTP id fn6csp1860043pzb; Sun, 23 Oct 2022 12:37:26 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7JUCH7NWLEijTTjM/Pxse2EMi9rF8UagYezNxapbw9xyCRxgaVEDiGdBTkEuI46GyWPsHJ X-Received: by 2002:a17:907:2da6:b0:78d:3cf1:9132 with SMTP id gt38-20020a1709072da600b0078d3cf19132mr24553644ejc.299.1666553846126; Sun, 23 Oct 2022 12:37:26 -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 d26-20020aa7d69a000000b0046157981475si5756794edr.474.2022.10.23.12.37.25; Sun, 23 Oct 2022 12:37:26 -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="RDAsmY/v"; 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 A55E768BD48; Sun, 23 Oct 2022 22:36:34 +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-db5eur02olkn2056.outbound.protection.outlook.com [40.92.50.56]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 14BD568BCDC for ; Sun, 23 Oct 2022 22:36:25 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=He5EJ45foErZCgQVzy4F57b589bgGrQliqCThFFzQ840/vTBx42GQ9Wtgyu37mZpTktTWl36UYTVj+TQtuHosKcswfZXErShfMrXU7zMQ1tHTFy5Ixywh/OYIml5nS702hzKbzXJGkIyqOt5La4djM5j60cWQBQ2eLPBkTY8rhd8EasYVt68NoJfV6sgsnrbPzaLhGxKmyFWrum64sUl4yIstZnZkzuf5JQErdlP19VXF8H2O0jblJ1vNRzl304xC3ycYMgEeWJHSClQQun5RwwxS4vExkiJwSeQBOoVhKyB9wlI0G8OPxUzQSoawZXgXzBbXduWFubTVXioqHOsWw== 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=09cWQOaxYoKKxtIQRbjahBXA7JoP5P1qFYGCvj1zXrs=; b=nW2PkNvR0juje+Oig5dZtywo+7GwpBmWY7WfgJgs90+xTopmOsZXWHt1SDYFhL0wZNV/XZSOi7K3fJ8jMogPGAdgmqPp1aKJwYsRCMI+bxaZudBSLVFVpTers1qPNjYznfFFlOALmYRX9SLx0QUkXFCPktku6yjZ/gUUmn5yf+zzJ5gONlFw256WK0LRRv8mwOyHLeW8zRfWv7Gn3JTf0su4X6qz3qU0qhUrT+ZovSLj+3OB8S8zykAQdMIE/1YpfvpS/g3LiPIOfYVk534QNFBNT7Hzayq53rMgfCfaH7mehHc1jhKp/5v1hzTSL2VQw3ewI+iWlq23TSRQDAuisg== 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=09cWQOaxYoKKxtIQRbjahBXA7JoP5P1qFYGCvj1zXrs=; b=RDAsmY/vjkbw846bRswBG5SMuBEHjVTHzcjoarIqpDrJ27yGDnr6bytDILFLI0B89/E+53s7F60ivnH/bxmGInDG1kpisGhK9GvuhUtZf4DmhvjDuFFASAZrIDDDiAPrKadiW99j+3PhLHdMCBibapThd+y7O22otinakajTAASk/RwmssTeYWI7QPA50nHxfgQtKpcqGy1XK7v+tyUAeNF5SBT9T7RuJhin6GVsCiLbvwLjurbMYZv/gdNwAxkXPlp9dnp1FOy6P/Obfr+nYhDqbyvDhYKZoCa1c6/RDT1KGawBiIb6HxO9oqTA5rn8rhZ84s3blDs534pwx4OUoA== 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:16 +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:16 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Sun, 23 Oct 2022 21:36:00 +0200 Message-ID: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: X-TMN: [zhrt7Jsc1yZ/UL1lbCbFUuHlKVZBhUbaBBzYAD0BmTg=] 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-6-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: ff03901a-fd6c-4e7e-6314-08dab52dda3c X-MS-Exchange-SLBlob-MailProps: AZnQBsB9XmqH3kRfXJefTqIxzT/YbMNW5AUKDvh7lgh8dYE8WV2Jl0pFeoC+T+gskA3mB6SZL3YMPt8iU2Rsb10PRyt7eBe+Hp8pKO2L6/Y+kOr55mIEf8ADEEw88HJgnCKbzCulODjy35rDpW2w2+nIZx6/p4Ontws/Ov3GFHfolgqMJjcVcGyi0c0naqfRlPETjOs96SXDv5KCAGOYpZ2bXbASviCMLJ1WMPavBiuuvxmfkz7nTyYV6H5SRN98TIAND7jV9GurPP/dj14L8M3Zl0a/Q4H+6LxqoV+XATMaTvT57/TTQ5YgEdtjey0pdESDVSHEsWGef87mRy5zhj1xFrS5URhgypnxB2bToNirmknfeVzkUkEaT6/OvfjrUDNs9dGJ+vn/4CFlK3Kh7QMAfBHkOHZqe17l02PJh0qYlGtdGWxqjsgCsP1F8SBwOzSWRvvgcJdyFfTbaXXR3Vjxq7dJmazXKa3lHKjdOd5E0ANQtF/7Ib7HaiJSKn5OIh/JZV7psxqnsGIwCH/NBxPW//6xkKo6J53CmiV7JqAyQ8Qoquy+TDZnYE9lLIoNxVW/YMNCiF6heD+m9qrhvNy7hchKpwjKIBuW8qJGDjuOzoB3EuPvmckuZlu4WHVLvyTjley3tOzhUwoLt54Ch8CxOfndYfyiOJ/c2+tNpDMTNMRv1l0sI2+uOPsZva1aG/wkRlaqNIntQ3TgqxI9+bJ3hn8GRB3tXZObpJkA2/E0kM1Q8BX2CpRKxilDrJyJR1zYzgKy0fQ= X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: cOASw9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Jr78slk8HCmdeBvkzqM9LfmQC7D4ifbeyM7i3M/Wk3WAImMNrHvn9KrsICM6O4Bit4xoPVCJMWKHpjAyeK3rJCwOiysbHI7thmv0HvXNxEtRgatgPQE4gIrSGgJBgx5rRiUnIEjQN48wR55LLDroK92MBDBmlh57FdZj79sJy96lj+yQip18+hhPP9gmSs8q7AFLj0N0U5w3cZufntvzKpaVfnsSwe/fSve1rBpHiyay5VM8uycWEtpssXUcUWzcnOdFaGDHrIquqTFzpM9dzDsiHXgZTIgVjiILPoL5a5oJGVvadWIO2znnKVjftY9aJjPkyexXWLG7Z84C6DodDWGb36fUvMiRWlgcAJMD/sWqfb4NuXi8g3lCzbB32/FM9J1HahQopWd4EW3A9YDcUlbf1VdBPcPL9tdH+VdBGk11nXqarLBRSPsjzW2IuEAI2biCrEyoIzyKG6N1QnayawcnvrYzZvSSXtTPLzZXuosb0FHFWZipjFe+0Fdt0TPjzPx5kMzOpXraYvxBu020XnKJBqPGE8+JXS0BK8gEY7wMqmZZE6GRjzs9tRl6ejNQDezhus/140zy/3WAEV9nUpIGI3dsVdG+/0msbB77EWfGOtHJysvfIY2F81HNWVaxP4sxskWTRik2g/j2fpMCuJYuJH9Sz8J3Jjxc9saWzMZ22c8qGSkd54WBmuImHU1M1yyD0EkrOW7AH4hsHbj2YaZDP4rdOiY/syGBTzDph8e7UEEa2zADnybNK8mMtjpxk9W0JKqW5cOCC05oY24G1pu66p4h6dAaiMyurez+lkAFQ8l2IP2Vke+PI/R7cbDqbRfON+2Svi8isrluZWlnWBIL5Arl2Tw2cQvFyAM1U7ds5X1S6xyfZC6BC19f/WdQ80JUKP18SiqTfmrLs3C3ZiyuXfCTImnyPQczHNETtl6gSsY53KwPrjxL+eMKyjv0uoo66XqJsV2UYwmKfu7ljOub/ezMzgbyaPsUAUtybwBkJ3v0dqfVHzb85w9orEgCG+QFW3Ntxv+rRBrTZTlZ X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: ff03901a-fd6c-4e7e-6314-08dab52dda3c 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:16.7767 (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 07/17] avcodec/mpeg12enc: Pass tables explicitly in ff_mpeg1_init_uni_ac_vlc 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: c59byplBa5F2 This will allow to remove ff_rl_mpeg2 soon and remove all uses of RLTable in MPEG-1/2/SpeedHQ later. Signed-off-by: Andreas Rheinhardt --- libavcodec/mpeg12enc.c | 19 ++++++++++++------- libavcodec/mpeg12vlc.h | 3 ++- libavcodec/speedhqenc.c | 3 ++- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/libavcodec/mpeg12enc.c b/libavcodec/mpeg12enc.c index 5d991ac99e..e0775d6b96 100644 --- a/libavcodec/mpeg12enc.c +++ b/libavcodec/mpeg12enc.c @@ -94,7 +94,10 @@ typedef struct MPEG12EncContext { #define A53_MAX_CC_COUNT 0x1f #endif /* CONFIG_MPEG1VIDEO_ENCODER || CONFIG_MPEG2VIDEO_ENCODER */ -av_cold void ff_mpeg1_init_uni_ac_vlc(const RLTable *rl, uint8_t *uni_ac_vlc_len) +av_cold void ff_mpeg1_init_uni_ac_vlc(const int8_t max_level[], + const uint8_t index_run[], + const uint16_t table_vlc[][2], + uint8_t uni_ac_vlc_len[]) { int i; @@ -107,16 +110,16 @@ av_cold void ff_mpeg1_init_uni_ac_vlc(const RLTable *rl, uint8_t *uni_ac_vlc_len int len, code; int alevel = FFABS(level); - if (alevel > rl->max_level[0][run]) + if (alevel > max_level[run]) code = 111; /* rl->n */ else - code = rl->index_run[0][run] + alevel - 1; + code = index_run[run] + alevel - 1; if (code < 111) { /* rl->n */ /* length of VLC and sign */ - len = rl->table_vlc[code][1] + 1; + len = table_vlc[code][1] + 1; } else { - len = rl->table_vlc[111 /* rl->n */][1] + 6; + len = table_vlc[MPEG12_RL_NB_ELEMS][1] + 6; if (alevel < 128) len += 8; @@ -1078,8 +1081,10 @@ static av_cold void mpeg12_encode_init_static(void) ff_rl_init(&ff_rl_mpeg1, mpeg12_static_rl_table_store[0]); ff_rl_init(&ff_rl_mpeg2, mpeg12_static_rl_table_store[1]); - ff_mpeg1_init_uni_ac_vlc(&ff_rl_mpeg1, uni_mpeg1_ac_vlc_len); - ff_mpeg1_init_uni_ac_vlc(&ff_rl_mpeg2, uni_mpeg2_ac_vlc_len); + ff_mpeg1_init_uni_ac_vlc(ff_rl_mpeg1.max_level[0], ff_rl_mpeg1.index_run[0], + ff_mpeg1_vlc_table, uni_mpeg1_ac_vlc_len); + ff_mpeg1_init_uni_ac_vlc(ff_rl_mpeg2.max_level[0], ff_rl_mpeg2.index_run[0], + ff_mpeg2_vlc_table, uni_mpeg2_ac_vlc_len); /* build unified dc encoding tables */ for (int i = -255; i < 256; i++) { diff --git a/libavcodec/mpeg12vlc.h b/libavcodec/mpeg12vlc.h index c810697370..5a04834bee 100644 --- a/libavcodec/mpeg12vlc.h +++ b/libavcodec/mpeg12vlc.h @@ -67,6 +67,7 @@ extern RL_VLC_ELEM ff_mpeg2_rl_vlc[]; void ff_init_2d_vlc_rl(const RLTable *rl, RL_VLC_ELEM rl_vlc[], unsigned static_size, int flags); -void ff_mpeg1_init_uni_ac_vlc(const RLTable *rl, uint8_t *uni_ac_vlc_len); +void ff_mpeg1_init_uni_ac_vlc(const int8_t max_level[], const uint8_t index_run[], + const uint16_t table_vlc[][2], uint8_t uni_ac_vlc_len[]); #endif /* AVCODEC_MPEG12VLC_H */ diff --git a/libavcodec/speedhqenc.c b/libavcodec/speedhqenc.c index 58b5e858a8..44ee62b9c2 100644 --- a/libavcodec/speedhqenc.c +++ b/libavcodec/speedhqenc.c @@ -88,7 +88,8 @@ static av_cold void speedhq_init_static_data(void) speedhq_chr_dc_uni[i + 255] = bits + (code << 8); } - ff_mpeg1_init_uni_ac_vlc(&ff_rl_speedhq, uni_speedhq_ac_vlc_len); + ff_mpeg1_init_uni_ac_vlc(ff_rl_speedhq.max_level[0], ff_rl_speedhq.index_run[0], + ff_speedhq_vlc_table, uni_speedhq_ac_vlc_len); } av_cold int ff_speedhq_encode_init(MpegEncContext *s)