Browse Source

Fixed wrong division hack

The numerator can be negative, thus the bit-hack yields wrong results.
pull/2413/head
Günther Foidl 3 years ago
parent
commit
b69495666b
  1. 2
      src/ImageSharp/Formats/Webp/Lossless/LosslessUtils.cs

2
src/ImageSharp/Formats/Webp/Lossless/LosslessUtils.cs

@ -1456,7 +1456,7 @@ internal static unsafe class LosslessUtils
}
[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));

Loading…
Cancel
Save