From 4342f3eba7ba3c116b01eface4a1757fbe30a9f8 Mon Sep 17 00:00:00 2001 From: Brian Popow Date: Fri, 28 Feb 2020 17:42:06 +0100 Subject: [PATCH] Additional webp lossy tests --- .../Formats/WebP/WebPDecoderTests.cs | 63 +++++++++++++------ tests/ImageSharp.Tests/TestImages.cs | 46 ++++++++------ tests/Images/Input/WebP/bike_lossy.webp | 4 +- .../Input/WebP/bike_lossy_complex_filter.webp | 3 + 4 files changed, 77 insertions(+), 39 deletions(-) create mode 100644 tests/Images/Input/WebP/bike_lossy_complex_filter.webp diff --git a/tests/ImageSharp.Tests/Formats/WebP/WebPDecoderTests.cs b/tests/ImageSharp.Tests/Formats/WebP/WebPDecoderTests.cs index 77768639cb..8538071a0f 100644 --- a/tests/ImageSharp.Tests/Formats/WebP/WebPDecoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/WebP/WebPDecoderTests.cs @@ -23,8 +23,8 @@ namespace SixLabors.ImageSharp.Tests.Formats.WebP [Theory] [InlineData(Lossless.Lossless1, 1000, 307, 24)] [InlineData(Lossless.Lossless2, 1000, 307, 24)] - [InlineData(Lossy.Alpha.LossyAlpha1, 1000, 307, 32)] - [InlineData(Lossy.Alpha.LossyAlpha2, 1000, 307, 32)] + [InlineData(Lossy.Alpha1, 1000, 307, 32)] + [InlineData(Lossy.Alpha2, 1000, 307, 32)] public void Identify_DetectsCorrectDimensions( string imagePath, int expectedWidth, @@ -44,17 +44,16 @@ namespace SixLabors.ImageSharp.Tests.Formats.WebP [Theory] [WithFile(Lossy.Bike, PixelTypes.Rgba32)] - [WithFile(Lossy.LenaIccp, PixelTypes.Rgba32)] - [WithFile(Lossy.Lossy01, PixelTypes.Rgba32)] - [WithFile(Lossy.Lossy02, PixelTypes.Rgba32)] - [WithFile(Lossy.Lossy03, PixelTypes.Rgba32)] - [WithFile(Lossy.Lossy04, PixelTypes.Rgba32)] - [WithFile(Lossy.Lossy05, PixelTypes.Rgba32)] - [WithFile(Lossy.Lossy06, PixelTypes.Rgba32)] - [WithFile(Lossy.Lossy07, PixelTypes.Rgba32)] - [WithFile(Lossy.Lossy08, PixelTypes.Rgba32)] - [WithFile(Lossy.Lossy09, PixelTypes.Rgba32)] - public void WebpDecoder_CanDecode_Lossy(TestImageProvider provider) + [WithFile(Lossy.NoFilter01, PixelTypes.Rgba32)] + [WithFile(Lossy.NoFilter02, PixelTypes.Rgba32)] + [WithFile(Lossy.NoFilter03, PixelTypes.Rgba32)] + [WithFile(Lossy.NoFilter04, PixelTypes.Rgba32)] + [WithFile(Lossy.NoFilter05, PixelTypes.Rgba32)] + [WithFile(Lossy.NoFilter06, PixelTypes.Rgba32)] + [WithFile(Lossy.NoFilter07, PixelTypes.Rgba32)] + [WithFile(Lossy.NoFilter08, PixelTypes.Rgba32)] + [WithFile(Lossy.NoFilter09, PixelTypes.Rgba32)] + public void WebpDecoder_CanDecode_Lossy_WithoutFilter(TestImageProvider provider) where TPixel : struct, IPixel { using (Image image = provider.GetImage(WebpDecoder)) @@ -65,11 +64,39 @@ namespace SixLabors.ImageSharp.Tests.Formats.WebP } [Theory] - [WithFile(Lossy.Alpha.LossyAlpha1, PixelTypes.Rgba32)] - [WithFile(Lossy.Alpha.LossyAlpha2, PixelTypes.Rgba32)] - [WithFile(Lossy.Alpha.LossyAlpha3, PixelTypes.Rgba32)] - [WithFile(Lossy.Alpha.LossyAlpha4, PixelTypes.Rgba32)] - [WithFile(Lossy.Alpha.LossyAlphaNoCompression, PixelTypes.Rgba32)] + [WithFile(Lossy.SimpleFilter01, PixelTypes.Rgba32)] + [WithFile(Lossy.SimpleFilter02, PixelTypes.Rgba32)] + public void WebpDecoder_CanDecode_Lossy_WithSimpleFilter(TestImageProvider provider) + where TPixel : struct, IPixel + { + using (Image image = provider.GetImage(WebpDecoder)) + { + image.DebugSave(provider); + image.CompareToOriginal(provider, ReferenceDecoder); + } + } + + [Theory] + [WithFile(Lossy.IccpComplexFilter, PixelTypes.Rgba32)] + [WithFile(Lossy.VeryShort, PixelTypes.Rgba32)] + [WithFile(Lossy.BikeComplexFilter, PixelTypes.Rgba32)] + [WithFile(Lossy.ComplexFilter01, PixelTypes.Rgba32)] + public void WebpDecoder_CanDecode_Lossy_WithComplexFilter(TestImageProvider provider) + where TPixel : struct, IPixel + { + using (Image image = provider.GetImage(WebpDecoder)) + { + image.DebugSave(provider); + image.CompareToOriginal(provider, ReferenceDecoder); + } + } + + [Theory] + [WithFile(Lossy.Alpha1, PixelTypes.Rgba32)] + [WithFile(Lossy.Alpha2, PixelTypes.Rgba32)] + [WithFile(Lossy.Alpha3, PixelTypes.Rgba32)] + [WithFile(Lossy.Alpha4, PixelTypes.Rgba32)] + [WithFile(Lossy.AlphaNoCompression, PixelTypes.Rgba32)] public void WebpDecoder_CanDecode_Lossy_WithAlpha(TestImageProvider provider) where TPixel : struct, IPixel { diff --git a/tests/ImageSharp.Tests/TestImages.cs b/tests/ImageSharp.Tests/TestImages.cs index 28613b5c81..c15a5ab811 100644 --- a/tests/ImageSharp.Tests/TestImages.cs +++ b/tests/ImageSharp.Tests/TestImages.cs @@ -428,27 +428,35 @@ namespace SixLabors.ImageSharp.Tests public static class Lossy { + // Lossy images without macroblock filtering. public const string Bike = "WebP/bike_lossy.webp"; - public const string LenaIccp = "WebP/lossy_iccp.webp"; + public const string NoFilter01 = "WebP/vp80-01-intra-1400.webp"; + public const string NoFilter02 = "WebP/vp80-00-comprehensive-010.webp"; + public const string NoFilter03 = "WebP/vp80-00-comprehensive-005.webp"; + public const string NoFilter04 = "WebP/vp80-01-intra-1417.webp"; + public const string NoFilter05 = "WebP/vp80-02-inter-1402.webp"; + public const string NoFilter06 = "WebP/vp80-03-segmentation-1401.webp"; + public const string NoFilter07 = "WebP/vp80-03-segmentation-1403.webp"; + public const string NoFilter08 = "WebP/vp80-03-segmentation-1407.webp"; + public const string NoFilter09 = "WebP/test.webp"; + + // Lossy images with a simple filter. + public const string SimpleFilter01 = "WebP/segment01.webp"; + public const string SimpleFilter02 = "WebP/segment02.webp"; + + // Losyy images with a complex filter. + public const string IccpComplexFilter = "WebP/lossy_iccp.webp"; public const string VeryShort = "WebP/very_short.webp"; - public const string Lossy01 = "WebP/vp80-01-intra-1400.webp"; - public const string Lossy02 = "WebP/vp80-00-comprehensive-010.webp"; - public const string Lossy03 = "WebP/vp80-01-intra-1417.webp"; - public const string Lossy04 = "WebP/vp80-02-inter-1402.webp"; - public const string Lossy05 = "WebP/vp80-03-segmentation-1401.webp"; - public const string Lossy06 = "WebP/vp80-02-inter-1418.webp"; - public const string Lossy07 = "WebP/vp80-03-segmentation-1403.webp"; - public const string Lossy08 = "WebP/vp80-03-segmentation-1407.webp"; - public const string Lossy09 = "WebP/test.webp"; - - public static class Alpha - { - public const string LossyAlpha1 = "WebP/lossy_alpha1.webp"; - public const string LossyAlpha2 = "WebP/lossy_alpha2.webp"; - public const string LossyAlpha3 = "WebP/lossy_alpha3.webp"; - public const string LossyAlpha4 = "WebP/lossy_alpha4.webp"; - public const string LossyAlphaNoCompression = "WebP/alpha_no_compression.webp"; - } + public const string BikeComplexFilter = "WebP/bike_lossy_complex_filter.webp"; + public const string ComplexFilter01 = "WebP/vp80-02-inter-1418.webp"; + public const string ComplexFilter02 = "WebP/vp80-02-inter-1418.webp"; + + // Lossy images with an alpha channel. + public const string Alpha1 = "WebP/lossy_alpha1.webp"; + public const string Alpha2 = "WebP/lossy_alpha2.webp"; + public const string Alpha3 = "WebP/lossy_alpha3.webp"; + public const string Alpha4 = "WebP/lossy_alpha4.webp"; + public const string AlphaNoCompression = "WebP/alpha_no_compression.webp"; } public static readonly string[] All = diff --git a/tests/Images/Input/WebP/bike_lossy.webp b/tests/Images/Input/WebP/bike_lossy.webp index 73eabf3635..a9e2fc6a8f 100644 --- a/tests/Images/Input/WebP/bike_lossy.webp +++ b/tests/Images/Input/WebP/bike_lossy.webp @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:21612476f2d7668f773ce286af1a2a4c33da8718352c5a5c1dd839a4643de823 -size 9396 +oid sha256:9f93883b8ba4ebc9c048c598b9294736baddfa756c4884e85f0d3b8e7f9d996c +size 39244 diff --git a/tests/Images/Input/WebP/bike_lossy_complex_filter.webp b/tests/Images/Input/WebP/bike_lossy_complex_filter.webp new file mode 100644 index 0000000000..73eabf3635 --- /dev/null +++ b/tests/Images/Input/WebP/bike_lossy_complex_filter.webp @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:21612476f2d7668f773ce286af1a2a4c33da8718352c5a5c1dd839a4643de823 +size 9396