Browse Source

Additional webp lossy tests

pull/1552/head
Brian Popow 6 years ago
parent
commit
4342f3eba7
  1. 63
      tests/ImageSharp.Tests/Formats/WebP/WebPDecoderTests.cs
  2. 46
      tests/ImageSharp.Tests/TestImages.cs
  3. 4
      tests/Images/Input/WebP/bike_lossy.webp
  4. 3
      tests/Images/Input/WebP/bike_lossy_complex_filter.webp

63
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<TPixel>(TestImageProvider<TPixel> 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<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : struct, IPixel<TPixel>
{
using (Image<TPixel> 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<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : struct, IPixel<TPixel>
{
using (Image<TPixel> 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<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : struct, IPixel<TPixel>
{
using (Image<TPixel> 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<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : struct, IPixel<TPixel>
{

46
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 =

4
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

3
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
Loading…
Cancel
Save