From b69495666b035c392c553497c95a5355e5a45231 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=BCnther=20Foidl?= Date: Fri, 24 Mar 2023 20:23:31 +0100 Subject: [PATCH] Fixed wrong division hack The numerator can be negative, thus the bit-hack yields wrong results. --- src/ImageSharp/Formats/Webp/Lossless/LosslessUtils.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ImageSharp/Formats/Webp/Lossless/LosslessUtils.cs b/src/ImageSharp/Formats/Webp/Lossless/LosslessUtils.cs index 05b6001c91..8d64a09dfb 100644 --- a/src/ImageSharp/Formats/Webp/Lossless/LosslessUtils.cs +++ b/src/ImageSharp/Formats/Webp/Lossless/LosslessUtils.cs @@ -1456,7 +1456,7 @@ private static uint ClampedAddSubtractHalf(uint c0, uint c1, uint c2) } [MethodImpl(InliningOptions.ShortMethod)] - private static int AddSubtractComponentHalf(int a, int b) => (int)Clip255((uint)(a + ((a - b) >> 1))); // >> 1 is bit-hack for / 2 + private static int AddSubtractComponentHalf(int a, int b) => (int)Clip255((uint)(a + ((a - b) / 2))); [MethodImpl(InliningOptions.ShortMethod)] private static int AddSubtractComponentFull(int a, int b, int c) => (int)Clip255((uint)(a + b - c));