From patchwork Thu Mar 28 23:10:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 47621 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:9f96:b0:1a3:b6bb:3029 with SMTP id mm22csp1667651pzb; Thu, 28 Mar 2024 16:12:12 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUej0t7RYtY+LtKzAvVuOTIdKJqa2APRn9zrJkNVsGx7nIef7T6N2DYv8AzOg/Esh9kuYShEnv5Ol5x66nciDZPBzMQL5g1j2/CLw== X-Google-Smtp-Source: AGHT+IEXgcSs4FzL/CvpFEXAhN79R0lNJa298yfcDmfHuKfznoH/29d7Su5RQMjq7UOh6ohVDl5t X-Received: by 2002:a05:651c:1032:b0:2d6:87d7:601 with SMTP id w18-20020a05651c103200b002d687d70601mr485542ljm.9.1711667531936; Thu, 28 Mar 2024 16:12:11 -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 cf13-20020a170906b2cd00b00a4e157285a1si1126098ejb.481.2024.03.28.16.12.11; Thu, 28 Mar 2024 16:12:11 -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=Kxpik7NG; 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 1BA7E68D773; Fri, 29 Mar 2024 01:11:27 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05olkn2063.outbound.protection.outlook.com [40.92.90.63]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 9815E68D74F for ; Fri, 29 Mar 2024 01:11:20 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TqTyMmrWE2dYCnHCf1uVcHrOFRnbwJJEp/sF7baoSeq4TmhNMeOykN8YHYQPXxofUAOcIvjLRisOMkUDC4Uw/iDYHn6SpjVFlcThtWH2Q8z9LYJlzvV/8y0Oe8E8za0f1KGqYI2tAXJuYCQ3uGxiVHdOitzbR7kGQU9w/e4OcxS6BL2NpbG7A2ZzdKWQzogj3wYo4zHW6enIIRNzQ8LEyA2UKhllfpASzqk54atZdf8rUQwXWQhYwYOZUrkiahSgMs92l6ROsVJ7s2h8wmSvdRirFknPBH2ZCoUqAuuCVq5eY99pOrz7m8ruMKxoc5h68egXK0nbnrjFtELJhkezNQ== 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=vH0ED+5wHy6RRQQ0Maoslz3xJ+NHsUZhe+wwoadeJ9g=; b=XaKiK38gu8LirWQ6EfyziXQpc2qMBjAqrQDujrptjv8E/XaTx/QaWugp+ekIQC1fw//oTe5ct41TarlBmHHY7Vjas/0b6m57B+0HcDyzqdHS+qyTujgeUhwXrmD6QxRt22C3idWWk9Uv9NjaWYRc9d/EYJ7lA9I3IEzU5KV1Zcfe4PZ2gRPdlzBr/Cv8LYkO7arTgYrfS/ZQOmhfkK/E+oksSKJwlc45ROTahD/BZwwl4sZ7WuodQmqYb8MQJsWU68/py8GNQLNdjPRC+w+8qXFWIVJXHKw7fnO4j268fs+M8OAylGTjQndtPACrQZJ4rLtWiO/PAFoZWWRtzDaAmg== 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=vH0ED+5wHy6RRQQ0Maoslz3xJ+NHsUZhe+wwoadeJ9g=; b=Kxpik7NGKpOclqrY7yNx9upxHAtGDK+8fQuMgSWHnYRS9I6NscFgtZfqstC3obvpP60rHZ/DW5NJ6QiS7+Ik9Ev3ZlTYPUhX/+yrMbzzvgRuxuOoOSKwr7G2IHqH0R15UrqtGKPbssu+QCMu0FuYlhG0WtPkARnwLyRec+vN/WZMgYDtc4YMS9hH+GCZWbuUu+2xUoxkHpAhE0bXZPF0CpM6V1sr4VcXhivKZbqAXKzF/tFdnGjpB6FihINEWqNoh0of7lACMlUXF+VvpwvGyEW6QPJBZ2YfYh6l542mYD6WIHv7nRA0lwZCsa/skG1kRz+bob+Y7AYvCLzKK4JWrA== Received: from AS8P250MB0744.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:541::14) by AS1P250MB0553.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:4af::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.31; Thu, 28 Mar 2024 23:11:16 +0000 Received: from AS8P250MB0744.EURP250.PROD.OUTLOOK.COM ([fe80::1f29:8206:b8c3:45bb]) by AS8P250MB0744.EURP250.PROD.OUTLOOK.COM ([fe80::1f29:8206:b8c3:45bb%3]) with mapi id 15.20.7409.039; Thu, 28 Mar 2024 23:11:16 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Fri, 29 Mar 2024 00:10:38 +0100 Message-ID: X-Mailer: git-send-email 2.40.1 In-Reply-To: References: X-TMN: [pye1918dCPlHfbVSeVY35nZbNASUlq7MC2mdrLHk+gg=] X-ClientProxiedBy: ZR0P278CA0093.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:23::8) To AS8P250MB0744.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:541::14) X-Microsoft-Original-Message-ID: <20240328231047.2202386-8-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8P250MB0744:EE_|AS1P250MB0553:EE_ X-MS-Office365-Filtering-Correlation-Id: 5edcbc0a-ff91-4871-6cee-08dc4f7c5ec4 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: oeelsUy8dBXQK1Y5U/zKEANwkRVtT+cKRmPS/yo9+Fi9kt33vBWbGwt1wWb/9zcdrlFSfLfcUD33rNrwIVa22+JrfbCV0mHuKmQXLeZ/0ZGwIWwdTAbIW0tsxonXXVhA/noq16U+AAmofywl1dH716UW3PfGSu7bMlRPZoDb/y6WPeo6A5F/uTdYsZgTCsR261LPAQjv1RH633Wd/6DTOeCK3bfyr0xoNxGP31L9vvLTR/d0EwyuikQRsCpu1Mn4myJIDnJ2hYr5jHJp9JxNoBHrWx9AvHVSxSLTJEA41gxF2Jtko6xvfptSvQ899xbXkhWN639EAhp2LIeiAcPkCoV9oGblGteEXC9iFf1P2IHgY5xVzc087Sqq5TbHBvLs0X7QSwGl3x1X4uWMYS/75EUnoJIrO9lwcNDUzPl92LlyGuPvGZNZVBLwZsQbAj3z/qP2HZZfy7bDZd5BKm402PSBrFeRZ/nh+ZU/2ChOCz+iFeWBVtuaZNodEbKdhJHILjc1F4Fuus/xNTMyVrK/0Q4vJI7IAxMoqeVqYpvyvlK8PoUS9+mCXtaz7NofY6q8B6HtSb/nzX92A+FwntNTF+Eo+7AjvB0//q2ZSMciAfK6Zz8JkCtXyWGMU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9cjwLiBGPpHQH5of71HI2arYA6xfTq5sUQ3T3MsVaz6AGD5uMWfNBJbnMafzc+B7LlgubsM+R0u8uuTCQqWw500jlufmSqTo3JRQ3KiNPEUiLzMbsVt6Xfhvf+Afk6MMCB9MxQ9tN5JuITE6UtxO/AZGfIE5+QpklwNIVv8+8YXwbCmAXg8Z0nv5sYZoMgS7ixeFaexmr8r7C1/SGLMkoA9ZjxP1MrdxVVBTZ8lx3a7bN3UkzH3D98NNuBEMtu9YoG6UVCWHf+2/PpNBM+bx4HGNvaJzfwSzi7PMTS3zCGQ== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5edcbc0a-ff91-4871-6cee-08dc4f7c5ec4 X-MS-Exchange-CrossTenant-AuthSource: AS8P250MB0744.EURP250.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Mar 2024 23:11:16.6066 (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: AS1P250MB0553 Subject: [FFmpeg-devel] [PATCH 09/18] swscale/swscale_internal: Hoist branch out of loop 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: 8uz4K+aTJiI1 Signed-off-by: Andreas Rheinhardt --- I wonder whether one can use aligned writes here? libswscale/swscale_internal.h | 34 ++++++++++------------------------ 1 file changed, 10 insertions(+), 24 deletions(-) diff --git a/libswscale/swscale_internal.h b/libswscale/swscale_internal.h index 2f6cc70946..d7faa5e165 100644 --- a/libswscale/swscale_internal.h +++ b/libswscale/swscale_internal.h @@ -1021,28 +1021,20 @@ int ff_sws_alphablendaway(SwsContext *c, const uint8_t *src[], static inline void fillPlane16(uint8_t *plane, int stride, int width, int height, int y, int alpha, int bits, const int big_endian) { - int i, j; uint8_t *ptr = plane + stride * y; int v = alpha ? 0xFFFF>>(16-bits) : (1<<(bits-1)); - for (i = 0; i < height; i++) { -#define FILL(wfunc) \ - for (j = 0; j < width; j++) {\ - wfunc(ptr+2*j, v);\ - } - if (big_endian) { - FILL(AV_WB16); - } else { - FILL(AV_WL16); - } + if (big_endian != HAVE_BIGENDIAN) + v = av_bswap16(v); + for (int i = 0; i < height; i++) { + for (int j = 0; j < width; j++) + AV_WN16(ptr + 2 * j, v); ptr += stride; } -#undef FILL } static inline void fillPlane32(uint8_t *plane, int stride, int width, int height, int y, int alpha, int bits, const int big_endian, int is_float) { - int i, j; uint8_t *ptr = plane + stride * y; uint32_t v; uint32_t onef32 = 0x3f800000; @@ -1050,20 +1042,14 @@ static inline void fillPlane32(uint8_t *plane, int stride, int width, int height v = alpha ? onef32 : 0; else v = alpha ? 0xFFFFFFFF>>(32-bits) : (1<<(bits-1)); + if (big_endian != HAVE_BIGENDIAN) + v = av_bswap32(v); - for (i = 0; i < height; i++) { -#define FILL(wfunc) \ - for (j = 0; j < width; j++) {\ - wfunc(ptr+4*j, v);\ - } - if (big_endian) { - FILL(AV_WB32); - } else { - FILL(AV_WL32); - } + for (int i = 0; i < height; i++) { + for (int j = 0; j < width; j++) + AV_WN32(ptr + 4 * j, v); ptr += stride; } -#undef FILL }