Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Paeth Filter decode on platforms that do not support Ssse3 #2618

Merged
merged 1 commit into from
Dec 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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);
}