From patchwork Wed Mar 6 00:53:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 46828 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:d90e:b0:19e:cdac:8cce with SMTP id jd14csp96081pzb; Tue, 5 Mar 2024 17:08:51 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCXigTORKCnBLpSE7UIdGJul4kOrahFbRI1QFX7NyFMJq5wAcT+9rdgnZa/sZfrjPQzkFNLVfZeJbmilF5ilD6omtSgEaiUt9+Tobw== X-Google-Smtp-Source: AGHT+IFx1qNNXAXVMqQyiAlUYTWOs735Jt0JsBcjoJrDE1Yx40GyOot2ljRTDu3xg7bJyx5oRg4D X-Received: by 2002:a50:c90d:0:b0:564:5150:76a2 with SMTP id o13-20020a50c90d000000b00564515076a2mr9499415edh.4.1709687330720; Tue, 05 Mar 2024 17:08:50 -0800 (PST) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id f4-20020a50d544000000b005673b8a79c9si2791073edj.394.2024.03.05.17.08.48; Tue, 05 Mar 2024 17:08:50 -0800 (PST) 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=lGGH3fMM; 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 6C87768C9EE; Wed, 6 Mar 2024 03:08:45 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04olkn2108.outbound.protection.outlook.com [40.92.73.108]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id EF98A68C7F2 for ; Wed, 6 Mar 2024 03:08:38 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BxUAeNUV2j4sB/qnxyIMAqn5UD5LaTYferB6ElKvS+HzwBshjU4Cpg2XBkx+efvmBaBHkOrFt8XLOeUPnPTnUgUfr9LSVG5/B9KkA0zleNmSbwK8QIAbL+ori5EwYuWXISsiyXdfZSPjWDz0oLBScJSDaDeH7rkDhFym7O3A6XEAgy9SwSQGYRDxh1DuE+hmyYxTHa8FuBncZa/7uc42zrZYOpMXE+PJsyka8tf5gjFLD2c4lfNsalefM/pPyLENalDKHrg+yR8GNufR1kPMOkfchzVvBkfJI+gMnzpg+Iqbha0dlJq5QPGemLqaN/Ibyu3m4ZHEMDctuGzJmWoKhg== 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=hl3YpkRgm2qG3PflCC8xpYpatCzUjgIXKvX2MxnvObE=; b=JWowYvXAXwLnB4noTaUlBnm3hlMeOWz+PIxr0fa6JkWe0gWe5yguKU4O5vtwWs1G0DRNxxVog5pvfMwxco0qlzTg34LBDtWkmgyANqyltb5OFpFfkmTQw6gtUfvi5YMuea6pD5JGGsR/L5sNt/rnEb1D6usn8VgBvCsX6Wt6F3pVedebV3dAQLwG9OKgr0FmomyF27aIFaBcCPqu+APx+dcKEe7emvRCdt3tBUrmeE3Ov78i867CFXnuhsYerehZ2Wb8R41TABSXLx3GNsTixxU0ri3dCtDVTxiyCjnLVKzwNp9DWswA/4LTMKdjFDlrCG9044f6P7M7NGImn0RBxw== 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=hl3YpkRgm2qG3PflCC8xpYpatCzUjgIXKvX2MxnvObE=; b=lGGH3fMMJKLGVO2Mhodafre//QJj93CJKiDtgBAXdTAfAE89j7sYyqc+4LRAXhcKeVlZH+U11PejCUVmIo/J0sb0w8q1QJ5DpgRhqQOtf9D4afayZ+XnycFuVhNL0/fZWogIUr/7Wc2k6PmHbIIr7YGglMS7h+V1OvHfY/h5DFhbW4GVLN/NeLXF41DS8EgzSsBrSSwm2Pz3QsScYNjpc6xuecUylKd0gFrxSV+K8YYrFjE30i7vmbTo3zh7FvgTpc1I98jMrxkkaO6K/72KZ0PHEGKxYwUxmwV4Yzz4T4zv+Y1AVUY7Ftz5w+pW8kLKBodLmnzukqGWDe+8ja+aFA== Received: from AS8P250MB0744.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:541::14) by DU2P250MB0028.EURP250.PROD.OUTLOOK.COM (2603:10a6:10:23b::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7339.39; Wed, 6 Mar 2024 00:53:57 +0000 Received: from AS8P250MB0744.EURP250.PROD.OUTLOOK.COM ([fe80::65aa:deb0:a18e:d48d]) by AS8P250MB0744.EURP250.PROD.OUTLOOK.COM ([fe80::65aa:deb0:a18e:d48d%5]) with mapi id 15.20.7316.023; Wed, 6 Mar 2024 00:53:57 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Wed, 6 Mar 2024 01:53:49 +0100 Message-ID: X-Mailer: git-send-email 2.40.1 X-TMN: [D3ULOBxVGlTp4mBWcAu8Fd2myQFlqgTdjXjUVoV7oTY=] X-ClientProxiedBy: ZR0P278CA0188.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:44::20) To AS8P250MB0744.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:541::14) X-Microsoft-Original-Message-ID: <20240306005349.3123418-1-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8P250MB0744:EE_|DU2P250MB0028:EE_ X-MS-Office365-Filtering-Correlation-Id: 3a3aebd4-6ed1-4bd6-25b4-08dc3d77e730 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: FoPqe3VI67sgOhytQsjVkbKcTGSFEIaxhlEemq9i94vGMUtKXE0305PPdWxwRDNPgFRKKk5J4SLw8D7RRrOGi8SZNAiyj0JWQn490sP6/vhAIZ58bViBMVCRwkjlbZQxmgg/Kuvh6LMMBQ4AdTjPXt796725dlbgJvciyoqKtSiSjs5BxHLfvfZ09Mm9kJDkUqlx5PJi9DBQQd1uxRF4lS66D3YT6e9/VQNrxXl2DaXWwynHWfBz1cvJ6oRSKTNZEZWVDBpWszoo/0RsX9zeyE0467ypoyJ6MojSbELyb8YG+QFEgiQ6mYGnd7yXdUKzITtzM+KPO52UthdOiJmKIKJDFuGZTgDo0OgbmLZwxMC22YcK2BybMpd9U4oPUxg7i1JF4/NQ5POHjCwLN2YL1fUtmzZIRbkZcbi6eZ11PX6zlOwvEwKJRCuEizHT3e7XPVBE6vPiZwsXIPQdfIuyqm96uCD68B360qomPWtVdKH17iDp7cOuuyw19aYqk0jfTRXFYl8AWeykcoXAYUd6i+gRgrgKFYbWwc7YmoytboK2tDPZ0d8k5VRj0pdBW76royuca2V4y6x6pXt12ZiMzUUoPAuzJZVRqPjKDNcYH417fYBmLzhhSsL0xsZoIqpx X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-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IKFUkIjsNXY7zmsdGL7l6GKM01S9AVCvL2aqGwmSzVaOq584lo6aVqIeOvbDSosNILzu8WtWtLXchA7Bp5dHAD6NfwOL5OTjd9vm5b8GhZI+s2ejQFdnpLp2svYmSrtIXf8qkFR1VOBYB6XjIZY0ITr9K5CD01vm+sgTVAnHP1xskck03AklHH+XEgeTvZAVu9NmKNQ8Ig/flF9El9BjKs3Dtt5s4366ocXh+QiWyDJwxuliRgg== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3a3aebd4-6ed1-4bd6-25b4-08dc3d77e730 X-MS-Exchange-CrossTenant-AuthSource: AS8P250MB0744.EURP250.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Mar 2024 00:53:57.0624 (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: DU2P250MB0028 Subject: [FFmpeg-devel] [PATCH] avcodec/xbmenc: Avoid snprintf() for data->hex conversion 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: 6ufX0EqBAZWp Use a small LUT instead. Improves performance. Signed-off-by: Andreas Rheinhardt --- libavcodec/xbmenc.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/libavcodec/xbmenc.c b/libavcodec/xbmenc.c index cd8b73afa3..5231d4691d 100644 --- a/libavcodec/xbmenc.c +++ b/libavcodec/xbmenc.c @@ -20,11 +20,9 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "libavutil/reverse.h" #include "avcodec.h" #include "codec_internal.h" #include "encode.h" -#include "mathops.h" #define ANSI_MIN_READLINE 509 @@ -57,14 +55,25 @@ static int xbm_encode_frame(AVCodecContext *avctx, AVPacket *pkt, buf += snprintf(buf, 39, "static unsigned char image_bits[] = {\n"); for (i = 0, l = lineout; i < avctx->height; i++) { for (j = 0; j < linesize; j++) { - buf += snprintf(buf, 6, " 0x%02X", ff_reverse[*ptr++]); + // 0..15 bitreversed as chars + static const char lut[] = { + '0', '8', '4', 'C', '2', 'A', '6', 'E', + '1', '9', '5', 'D', '3', 'B', '7', 'F' + }; + buf[0] = ' '; + buf[1] = '0'; + buf[2] = 'x'; + buf[3] = lut[*ptr & 0xF]; + buf[4] = lut[*ptr >> 4]; + buf += 5; + ptr++; if (--commas <= 0) { - buf += snprintf(buf, 2, "\n"); + *buf++ = '\n'; break; } - buf += snprintf(buf, 2, ","); + *buf++ = ','; if (--l <= 0) { - buf += snprintf(buf, 2, "\n"); + *buf++ = '\n'; l = lineout; } }