-
-
Notifications
You must be signed in to change notification settings - Fork 893
PNG: Add SSE/AVX version of Sub, Up, Average and Paethfilters #2028
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’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 11 commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
747422c
Add Sse2 version of Average png filter
brianpopow 7152088
No need for the scratch buffer for 4 bytes per pixel
brianpopow 18548f7
Dont use intrinsics for 3 bytes per pixel
brianpopow 9eb71a2
Add average filter tests
brianpopow a921c57
Add benchmark file for average filter with 4bpp
brianpopow 3ab1ba6
Use DisableHWIntrinsic in average filter test
brianpopow 9f3c466
Merge branch 'main' into bp/pngavgsse2
brianpopow 9f32255
Rename average filter tests
brianpopow 4f6b807
Fix average test data
brianpopow c01001f
Add comment about pixel layout
brianpopow e1f96f2
Additional png decoder tests for average filter
brianpopow 8716c51
Add SSE2 version of up filter
brianpopow 0c8dbea
Add Avx version of up filter
brianpopow 849e866
Add SSE2 version of sub filter
brianpopow 670105f
Apply suggestions from code review
brianpopow 04219b5
Use nint for offset
brianpopow 8432b9f
Use nint for offset
brianpopow 06843f2
Add SSE version of paeth filter
brianpopow d9fddd5
Merge branch 'bp/pngupfilter' into bp/pngavgsse2
brianpopow 88b75da
Add tests for png filters with and without intrinsics
brianpopow 26a742e
Additional tests for decoding png's with filter
brianpopow bdbb9d2
Merge branch 'main' into bp/pngavgsse2
brianpopow fe06e38
Merge branch 'main' into bp/pngavgsse2
JimBobSquarePants File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
tests/ImageSharp.Tests/Formats/Png/PngDecoderFilterTests.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| // Copyright (c) Six Labors. | ||
| // Licensed under the Apache License, Version 2.0. | ||
|
|
||
| using SixLabors.ImageSharp.Formats.Png.Filters; | ||
| using SixLabors.ImageSharp.Tests.TestUtilities; | ||
| using Xunit; | ||
|
|
||
| namespace SixLabors.ImageSharp.Tests.Formats.Png | ||
| { | ||
| [Trait("Format", "Png")] | ||
| public class PngDecoderFilterTests | ||
| { | ||
| private static void RunAverageFilterTest() | ||
| { | ||
| // arrange | ||
| byte[] scanline = | ||
| { | ||
| 3, 39, 39, 39, 0, 4, 4, 4, 0, 1, 1, 1, 0, 1, 1, 1, 0, 2, 2, 2, 0, 2, 2, 2, 0, 2, 2, 2, 0, 4, 4, 4, | ||
| 0, 2, 2, 2, 0, 3, 3, 3, 0, 1, 1, 1, 0, 3, 3, 3, 0, 3, 3, 3, 0, 1, 1, 1, 0, 3, 3, 3, 0, 2, 2, 2, 0, | ||
| 1, 1, 1, 0, 3, 3, 3, 0, 1, 1, 1, 0, 3, 3, 3, 0, 1, 1, 1, 0, 3, 3, 3, 0, 3, 3, 3, 0, 254, 254, 254, | ||
| 0, 6, 6, 6, 14, 71, 71, 71, 157, 254, 254, 254, 28, 251, 251, 251, 0, 4, 4, 4, 0, 2, 2, 2, 0, 11, | ||
| 11, 11, 0, 226, 226, 226, 0, 255, 128, 234 | ||
| }; | ||
|
|
||
| byte[] previousScanline = | ||
| { | ||
| 3, 74, 74, 74, 0, 73, 73, 73, 0, 73, 73, 73, 0, 74, 74, 74, 0, 74, 74, 74, 0, 73, 73, 73, 0, 72, 72, | ||
| 72, 0, 72, 72, 72, 0, 73, 73, 73, 0, 74, 74, 74, 0, 73, 73, 73, 0, 72, 72, 72, 0, 72, 72, 72, 0, 74, | ||
| 74, 74, 0, 72, 72, 72, 0, 73, 73, 73, 0, 75, 75, 75, 0, 73, 73, 73, 0, 74, 74, 74, 0, 72, 72, 72, 0, | ||
| 73, 73, 73, 0, 73, 73, 73, 0, 72, 72, 72, 0, 74, 74, 74, 0, 61, 61, 61, 0, 101, 101, 101, 78, 197, | ||
| 197, 197, 251, 152, 152, 152, 255, 155, 155, 155, 255, 162, 162, 162, 255, 175, 175, 175, 255, 160, | ||
| 160, 160, 255, 139, 128, 134 | ||
| }; | ||
|
|
||
| byte[] expected = | ||
| { | ||
| 3, 76, 76, 76, 0, 78, 78, 78, 0, 76, 76, 76, 0, 76, 76, 76, 0, 77, 77, 77, 0, 77, 77, 77, 0, 76, 76, | ||
| 76, 0, 78, 78, 78, 0, 77, 77, 77, 0, 78, 78, 78, 0, 76, 76, 76, 0, 77, 77, 77, 0, 77, 77, 77, 0, 76, | ||
| 76, 76, 0, 77, 77, 77, 0, 77, 77, 77, 0, 77, 77, 77, 0, 78, 78, 78, 0, 77, 77, 77, 0, 77, 77, 77, 0, | ||
| 76, 76, 76, 0, 77, 77, 77, 0, 77, 77, 77, 0, 73, 73, 73, 0, 73, 73, 73, 14, 158, 158, 158, 203, 175, | ||
| 175, 175, 255, 158, 158, 158, 255, 160, 160, 160, 255, 163, 163, 163, 255, 180, 180, 180, 255, 140, | ||
| 140, 140, 255, 138, 6, 115 | ||
| }; | ||
|
|
||
| // act | ||
| AverageFilter.Decode(scanline, previousScanline, 4); | ||
|
|
||
| // assert | ||
| Assert.Equal(scanline, expected); | ||
| } | ||
|
|
||
| [Fact] | ||
| public void AverageFilter_Works() => RunAverageFilterTest(); | ||
|
|
||
| #if SUPPORTS_RUNTIME_INTRINSICS | ||
| [Fact] | ||
| public void AverageFilter_WithHardwareIntrinsics_Works() => FeatureTestRunner.RunWithHwIntrinsicsFeature(RunAverageFilterTest, HwIntrinsics.AllowAll); | ||
|
|
||
| [Fact] | ||
| public void AverageFilter_WithoutHardwareIntrinsics_Works() => FeatureTestRunner.RunWithHwIntrinsicsFeature(RunAverageFilterTest, HwIntrinsics.DisableHWIntrinsic); | ||
| #endif | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.