Skip to content

Commit

Permalink
Merge pull request #2618 from SixLabors/js/fix-sse3-paeth
Browse files Browse the repository at this point in the history
Fix Paeth Filter decode on platforms that do not support Ssse3
  • Loading branch information
JimBobSquarePants authored Dec 12, 2023
2 parents ad1b0e6 + 9672d48 commit 4b162db
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/ImageSharp/Formats/Png/Filters/PaethFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ public static void Decode(Span<byte> scanline, Span<byte> previousScanline, int
// row: a d
// The Paeth function predicts d to be whichever of a, b, or c is nearest to
// p = a + b - c.
if (Sse2.IsSupported && bytesPerPixel is 4)
if (Ssse3.IsSupported && bytesPerPixel is 4)
{
DecodeSse3(scanline, previousScanline);
DecodeSsse3(scanline, previousScanline);
}
else if (AdvSimd.Arm64.IsSupported && bytesPerPixel is 4)
{
Expand All @@ -50,7 +50,7 @@ public static void Decode(Span<byte> scanline, Span<byte> previousScanline, int
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static void DecodeSse3(Span<byte> scanline, Span<byte> previousScanline)
private static void DecodeSsse3(Span<byte> scanline, Span<byte> previousScanline)
{
ref byte scanBaseRef = ref MemoryMarshal.GetReference(scanline);
ref byte prevBaseRef = ref MemoryMarshal.GetReference(previousScanline);
Expand Down
3 changes: 3 additions & 0 deletions tests/ImageSharp.Tests/Formats/Png/PngDecoderFilterTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,9 @@ private static void RunPaethFilterTest()
[Fact]
public void PaethFilter_WithHardwareIntrinsics_Works() => FeatureTestRunner.RunWithHwIntrinsicsFeature(RunPaethFilterTest, HwIntrinsics.AllowAll);

[Fact]
public void PaethFilter_WithoutSsse3_Works() => FeatureTestRunner.RunWithHwIntrinsicsFeature(RunPaethFilterTest, HwIntrinsics.DisableSSSE3);

[Fact]
public void PaethFilter_WithoutHardwareIntrinsics_Works() => FeatureTestRunner.RunWithHwIntrinsicsFeature(RunPaethFilterTest, HwIntrinsics.DisableHWIntrinsic);
}

0 comments on commit 4b162db

Please sign in to comment.