From patchwork Fri Mar 29 03:24:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 47637 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:9f96:b0:1a3:b6bb:3029 with SMTP id mm22csp1754886pzb; Thu, 28 Mar 2024 20:24:58 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVEpvjcwuYcYRrhOBY5uDQUPr9LS2zYguhjHxJjUyKL8vmR59aw/3er/l6vcrB4KMVbTpg+5OE4I3OXVV7R7PP9Dzd64DBC39TxKA== X-Google-Smtp-Source: AGHT+IFweEYi3W2P1vY3IPKDLgpShjfv00LXUVNiFSDlRXYETK3DVmZJUAJqfUdZgN5UVIO2KOEt X-Received: by 2002:a17:906:2b09:b0:a4a:20df:e032 with SMTP id a9-20020a1709062b0900b00a4a20dfe032mr633944ejg.66.1711682698559; Thu, 28 Mar 2024 20:24:58 -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 r13-20020a170906a20d00b00a46a90e7afesi1309047ejy.96.2024.03.28.20.24.58; Thu, 28 Mar 2024 20:24:58 -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=DIUH9HZp; 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 6C71168D742; Fri, 29 Mar 2024 05:24:52 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR02-DB5-obe.outbound.protection.outlook.com (mail-db5eur02olkn2037.outbound.protection.outlook.com [40.92.50.37]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 8C43568D66C for ; Fri, 29 Mar 2024 05:24:45 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RvrRUn4rv1WRUxOKbljKUsDzKeJb7NrmrIo9qbEvj0UZsHAOVPKNe5uM5CciBHadolPW+yHZ6z8nTToDGprcvAxiqwTDGjbFKoPrSwWuJo/myyrFfZoWQHw2FY99IHo2KFF09ICK439Av1AfrgDWVIQap6W76/kTz9RNJ+p6Jq1aXKTwdUI/ae5e5vY4nm1wXfwj5faa6Un/y7/yB5PDSvQeZf0jWGH1cEUIjE56wrYD5HCBM7/y1eKSeHzGWRSzG83dlxHGo4Y6k/fIXk2jBVazRuPmmdCbaQjiWi9auVwMlMxJLw7cy2ExSezofNHG9kvwRGTu352q9NB8hIQglQ== 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=GGFPXxR2SOAG8LqVAp2pSWoRBoJa1o1dJWHuZIo/tRk=; b=WiCBuMkjc149U+L7Ys3RkFCj9eV2ZNGS5HaHnstTc6YJjya+tBOmy/Ut84nr0M2rYQQn2yULmTsg3roUxtcfR1iu1vkoyxI0qlE9XQfYMzCjMn2xu3dDuApsb1Eo6ygtaSh1cyNaqPk5k1bKQBkNY31QT2Ek7fbWP2dVhppHAz4OD9QCVJrrylAWtVx9A8FBPDWxMACHarwwLth6r+74+0wj/XIdJWS1z3JbsnE0Amu5nvfv1zsz0VYzXxIh9v7j+BKGj+ogHV9rbjYox4VxVDfmWtvTtX9cyUk4MJ6qSTolOLLwQlVhRn+gPIXcAIpFabhnsvGbo6GYH314tjNp1Q== 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=GGFPXxR2SOAG8LqVAp2pSWoRBoJa1o1dJWHuZIo/tRk=; b=DIUH9HZp+m46rlYK2L9rC4yMJ1qSI4oH94VnM4ZCLJuo4T2EL0heeAgzv+ghJ3SfzDxXbg97NuRJGnaoEfM6eI8MrFIQZ0FTVJqxdK2FOCv90SMpiI+S1AwSuoQCV58gulYgMhtzRpw1gf8Q4vdm7V97N+OCW25AdPaD+6SHqSVUhZRsidIHMAd5m2VdBzoWGueQVIjZpZFOD2J8hDikF+G5Tmdw9CJ8Ie2l7pjZseZdbWfh079m/EqCAsVG7EaNUWT03awyIVAb2N4l16pr9SlFbveeKfZPZ8Faq+BwAtRGJ6A2h18+okdSE0Zo69+16gpI8xh7nIQfTWnL66PL0Q== Received: from GV1P250MB0737.EURP250.PROD.OUTLOOK.COM (2603:10a6:150:8e::17) by PR3P250MB0116.EURP250.PROD.OUTLOOK.COM (2603:10a6:102:173::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.39; Fri, 29 Mar 2024 03:24:39 +0000 Received: from GV1P250MB0737.EURP250.PROD.OUTLOOK.COM ([fe80::4a3b:cf76:cddc:c68d]) by GV1P250MB0737.EURP250.PROD.OUTLOOK.COM ([fe80::4a3b:cf76:cddc:c68d%4]) with mapi id 15.20.7409.039; Fri, 29 Mar 2024 03:24:39 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Fri, 29 Mar 2024 04:24:27 +0100 Message-ID: X-Mailer: git-send-email 2.40.1 In-Reply-To: References: X-TMN: [skJXWpXBbZqUymF4rmBjyDwxhOcjZs0We2S6kt3rH/U=] X-ClientProxiedBy: FR0P281CA0061.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:49::16) To GV1P250MB0737.EURP250.PROD.OUTLOOK.COM (2603:10a6:150:8e::17) X-Microsoft-Original-Message-ID: <20240329032429.2305146-2-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: GV1P250MB0737:EE_|PR3P250MB0116:EE_ X-MS-Office365-Filtering-Correlation-Id: b08e0fd4-6acc-4408-28c2-08dc4f9fc3ca X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: /zTVgZiF6Nbxblewnr1eJsBtUl7T9ApRunzvt47ONGf9NWoUJYosS74fVW/e67BTuxDRvQpd7xG9RWW6NVnq7I8IKbhtBhxyLGDCBlZ59SXzz3wDFLIWC1tZD9Hb1Dizk8EuqTonEDLDuv+gNjbWjB+kMXP4H0Ry2MdIU4PeRYZdoAcJjSKLoabpwzMYMYKeMF3SpkQvpef21RC/G21IDFfQtH2MZrXvJGz7p5dX7LIEN5rZeNHp56G2uoRWwFB+1xoe1huMCnPM8Lhi/HSf1U4fvel0XYZFqFKzasN2hZ4o3Ns5qr1iEzOIOeFpEsa4f4W6BYsnvrFsZPGP7AsrYbCZ2cs2rM3X3rHu5fCPqypXfetfxYHMkZ690YTrP6/zKroW3iyZFlx0/d8gLt0aV2X9HvcqSgNklIjRmuPWVY9g/TzZkfYPPdE688u8iDBLD1SNpumN47wkUpmRDnAPCsM8Vvgf3laMjKEeSUwMn062bf6ccaicSbOYTMVi4H0pfu/PnrgwG/LSTJ0U7ZHxPeRNX+C9gI+Lob/8As8+PO1gXSy890xzP6A34vAEZfbUOH6awB1FrZ2H/txOgKCEbyv039kHbzXrDdB7VLkweWZlqZJPeRfUNoMq3qyoS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iWI15zAvOcfCuNaGoWykugmuWXW2+5pJAFwr6Be/aOBkxtb/c+I0QKHdxApClp9nRhmFtW/hsDjmC/bBYT2/Ys8N9F0iWVXDzkEAZSLGF/k6nPx+rA2kjtbMXI45Z0XHJH6/uPv/Au6zZ5I16mLB1wY/YryUv8MbYk4usfpz+tM8pdHefs3sLEYg8TRJrrtRnMihuskCVsU1rdrgjq7s4YaykBCrH8ynW/YDzbY6Q+fZGwJito1nKg4n7rMI1/3Z5hig5oC4Q5FMxB9mWn0+beTnOA== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: b08e0fd4-6acc-4408-28c2-08dc4f9fc3ca X-MS-Exchange-CrossTenant-AuthSource: GV1P250MB0737.EURP250.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Mar 2024 03:24:38.4849 (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: PR3P250MB0116 Subject: [FFmpeg-devel] [PATCH 3/5] avcodec/pngdsp: Fix unaligned accesses, effective type violations 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: rhxp2sOhj1Lc Affected the lscr fate-test (only visible on x86 if the SSE2 is disabled). Signed-off-by: Andreas Rheinhardt --- libavcodec/pngdsp.c | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/libavcodec/pngdsp.c b/libavcodec/pngdsp.c index 65916b1386..50ee96a684 100644 --- a/libavcodec/pngdsp.c +++ b/libavcodec/pngdsp.c @@ -21,20 +21,33 @@ #include "config.h" #include "libavutil/attributes.h" +#include "libavutil/intreadwrite.h" +#include "libavutil/macros.h" #include "png.h" #include "pngdsp.h" +#if HAVE_FAST_64BIT +#define BITS 64 +typedef uint64_t uint_native; +#else +#define BITS 32 +typedef uint32_t uint_native; +#endif +#define RN AV_JOIN(AV_RN, BITS) +#define RNA AV_JOIN(AV_JOIN(AV_RN, BITS), A) +#define WN AV_JOIN(AV_WN, BITS) + // 0x7f7f7f7f or 0x7f7f7f7f7f7f7f7f or whatever, depending on the cpu's native arithmetic size -#define pb_7f (~0UL / 255 * 0x7f) -#define pb_80 (~0UL / 255 * 0x80) +#define pb_7f (~(uint_native)0 / 255 * 0x7f) +#define pb_80 (~(uint_native)0 / 255 * 0x80) static void add_bytes_l2_c(uint8_t *dst, uint8_t *src1, uint8_t *src2, int w) { long i; - for (i = 0; i <= w - (int) sizeof(long); i += sizeof(long)) { - long a = *(long *)(src1 + i); - long b = *(long *)(src2 + i); - *(long *)(dst + i) = ((a & pb_7f) + (b & pb_7f)) ^ ((a ^ b) & pb_80); + for (i = 0; i <= w - (int) sizeof(uint_native); i += sizeof(uint_native)) { + uint_native a = RNA(src1 + i); + uint_native b = RN (src2 + i); + WN(dst + i, ((a & pb_7f) + (b & pb_7f)) ^ ((a ^ b) & pb_80)); } for (; i < w; i++) dst[i] = src1[i] + src2[i];