mirror of https://github.com/SixLabors/ImageSharp
committed by
GitHub
101 changed files with 1069 additions and 1088 deletions
@ -1,7 +1,10 @@ |
|||
// Copyright (c) Six Labors and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
|
|||
using SixLabors.ImageSharp.Memory; |
|||
using SixLabors.Primitives; |
|||
|
|||
namespace SixLabors.ImageSharp.Formats.Jpeg.Common.Decoder |
|||
namespace SixLabors.ImageSharp.Formats.Jpeg.Components.Decoder |
|||
{ |
|||
/// <summary>
|
|||
/// Common interface to represent raw Jpeg components.
|
|||
@ -1,13 +1,16 @@ |
|||
// Copyright (c) Six Labors and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
|
|||
using SixLabors.Primitives; |
|||
|
|||
namespace SixLabors.ImageSharp.Formats.Jpeg.Common.Decoder |
|||
namespace SixLabors.ImageSharp.Formats.Jpeg.Components.Decoder |
|||
{ |
|||
/// <inheritdoc />
|
|||
/// <summary>
|
|||
/// Represents decompressed, unprocessed jpeg data with spectral space <see cref="T:SixLabors.ImageSharp.Formats.Jpeg.Common.Decoder.IJpegComponent" />-s.
|
|||
/// Represents decompressed, unprocessed jpeg data with spectral space <see cref="IJpegComponent" />-s.
|
|||
/// </summary>
|
|||
internal interface IRawJpegData : IDisposable |
|||
{ |
|||
@ -1,4 +1,7 @@ |
|||
namespace SixLabors.ImageSharp.Formats.Jpeg.Common.Decoder |
|||
// Copyright (c) Six Labors and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
|
|||
namespace SixLabors.ImageSharp.Formats.Jpeg.Components.Decoder |
|||
{ |
|||
/// <summary>
|
|||
/// Identifies the colorspace of a Jpeg image
|
|||
@ -1,8 +1,12 @@ |
|||
// Copyright (c) Six Labors and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
|
|||
using System; |
|||
|
|||
using SixLabors.ImageSharp.Memory; |
|||
using SixLabors.Primitives; |
|||
|
|||
namespace SixLabors.ImageSharp.Formats.Jpeg.Common.Decoder |
|||
namespace SixLabors.ImageSharp.Formats.Jpeg.Components.Decoder |
|||
{ |
|||
/// <summary>
|
|||
/// Encapsulates postprocessing data for one component for <see cref="JpegImagePostProcessor"/>.
|
|||
@ -1,18 +1,16 @@ |
|||
// Copyright (c) Six Labors and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
|
|||
using Block8x8F = SixLabors.ImageSharp.Formats.Jpeg.Common.Block8x8F; |
|||
|
|||
namespace SixLabors.ImageSharp.Formats.Jpeg.GolangPort.Components |
|||
namespace SixLabors.ImageSharp.Formats.Jpeg.Components.Encoder |
|||
{ |
|||
/// <summary>
|
|||
/// Poor man's stackalloc: Contains a value-type <see cref="float"/> buffer sized for 4 <see cref="Common.Block8x8F"/> instances.
|
|||
/// Poor man's stackalloc: Contains a value-type <see cref="float"/> buffer sized for 4 <see cref="Block8x8F"/> instances.
|
|||
/// Useful for decoder/encoder operations allocating a block for each Jpeg component.
|
|||
/// </summary>
|
|||
internal unsafe struct BlockQuad |
|||
{ |
|||
/// <summary>
|
|||
/// The value-type <see cref="float"/> buffer sized for 4 <see cref="Common.Block8x8F"/> instances.
|
|||
/// The value-type <see cref="float"/> buffer sized for 4 <see cref="Block8x8F"/> instances.
|
|||
/// </summary>
|
|||
public fixed float Data[4 * Block8x8F.Size]; |
|||
} |
|||
@ -1,7 +1,7 @@ |
|||
// Copyright (c) Six Labors and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
|
|||
namespace SixLabors.ImageSharp.Formats.Jpeg.GolangPort.Components.Encoder |
|||
namespace SixLabors.ImageSharp.Formats.Jpeg.Components.Encoder |
|||
{ |
|||
/// <summary>
|
|||
/// Enumerates the Huffman tables
|
|||
@ -1,7 +1,7 @@ |
|||
// Copyright (c) Six Labors and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
|
|||
namespace SixLabors.ImageSharp.Formats.Jpeg.GolangPort.Components.Encoder |
|||
namespace SixLabors.ImageSharp.Formats.Jpeg.Components.Encoder |
|||
{ |
|||
/// <summary>
|
|||
/// A compiled look-up table representation of a huffmanSpec.
|
|||
@ -1,7 +1,7 @@ |
|||
// Copyright (c) Six Labors and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
|
|||
namespace SixLabors.ImageSharp.Formats.Jpeg.GolangPort.Components.Encoder |
|||
namespace SixLabors.ImageSharp.Formats.Jpeg.Components.Encoder |
|||
{ |
|||
/// <summary>
|
|||
/// The Huffman encoding specifications.
|
|||
@ -1,7 +1,7 @@ |
|||
// Copyright (c) Six Labors and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
|
|||
namespace SixLabors.ImageSharp.Formats.Jpeg.GolangPort.Components.Encoder |
|||
namespace SixLabors.ImageSharp.Formats.Jpeg.Components.Encoder |
|||
{ |
|||
/// <summary>
|
|||
/// Enumerates the quantization tables
|
|||
@ -1,10 +1,10 @@ |
|||
using System; |
|||
using System.Runtime.CompilerServices; |
|||
|
|||
using SixLabors.ImageSharp.Advanced; |
|||
using SixLabors.ImageSharp.Formats.Jpeg.Common; |
|||
using SixLabors.ImageSharp.PixelFormats; |
|||
|
|||
namespace SixLabors.ImageSharp.Formats.Jpeg.GolangPort.Components.Encoder |
|||
namespace SixLabors.ImageSharp.Formats.Jpeg.Components.Encoder |
|||
{ |
|||
/// <summary>
|
|||
/// On-stack worker struct to efficiently encapsulate the TPixel -> Rgb24 -> YCbCr conversion chain of 8x8 pixel blocks.
|
|||
@ -1,11 +1,8 @@ |
|||
// Copyright (c) Six Labors and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
|
|||
using System.Numerics; |
|||
using System.Runtime.CompilerServices; |
|||
|
|||
// <auto-generated />
|
|||
namespace SixLabors.ImageSharp.Formats.Jpeg.Common |
|||
namespace SixLabors.ImageSharp.Formats.Jpeg.Components |
|||
{ |
|||
internal unsafe partial struct GenericBlock8x8<T> |
|||
{ |
|||
@ -1,10 +1,11 @@ |
|||
// Copyright (c) Six Labors and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
|
|||
using System; |
|||
using System.Runtime.CompilerServices; |
|||
using System.Runtime.InteropServices; |
|||
|
|||
namespace SixLabors.ImageSharp.Formats.Jpeg.Common |
|||
namespace SixLabors.ImageSharp.Formats.Jpeg.Components |
|||
{ |
|||
/// <summary>
|
|||
/// Holds the Jpeg UnZig array in a value/stack type.
|
|||
@ -1,189 +0,0 @@ |
|||
// Copyright (c) Six Labors and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
|
|||
using System.Collections.Generic; |
|||
|
|||
namespace SixLabors.ImageSharp.Formats.Jpeg.GolangPort |
|||
{ |
|||
/// <summary>
|
|||
/// Defines jpeg constants defined in the specification.
|
|||
/// </summary>
|
|||
internal static class OrigJpegConstants |
|||
{ |
|||
/// <summary>
|
|||
/// The maximum allowable length in each dimension of a jpeg image.
|
|||
/// </summary>
|
|||
public const ushort MaxLength = 65535; |
|||
|
|||
/// <summary>
|
|||
/// The list of mimetypes that equate to a jpeg.
|
|||
/// </summary>
|
|||
public static readonly IEnumerable<string> MimeTypes = new[] { "image/jpeg", "image/pjpeg" }; |
|||
|
|||
/// <summary>
|
|||
/// The list of file extensions that equate to a jpeg.
|
|||
/// </summary>
|
|||
public static readonly IEnumerable<string> FileExtensions = new[] { "jpg", "jpeg", "jfif" }; |
|||
|
|||
/// <summary>
|
|||
/// Describes common Jpeg markers
|
|||
/// </summary>
|
|||
internal static class Markers |
|||
{ |
|||
/// <summary>
|
|||
/// Marker prefix. Next byte is a marker.
|
|||
/// </summary>
|
|||
public const byte XFF = 0xff; |
|||
|
|||
/// <summary>
|
|||
/// Same as <see cref="XFF"/> but of type <see cref="int"/>
|
|||
/// </summary>
|
|||
public const int XFFInt = XFF; |
|||
|
|||
/// <summary>
|
|||
/// Start of Image
|
|||
/// </summary>
|
|||
public const byte SOI = 0xd8; |
|||
|
|||
/// <summary>
|
|||
/// Start of Frame (baseline DCT)
|
|||
/// <remarks>
|
|||
/// Indicates that this is a baseline DCT-based JPEG, and specifies the width, height, number of components,
|
|||
/// and component subsampling (e.g., 4:2:0).
|
|||
/// </remarks>
|
|||
/// </summary>
|
|||
public const byte SOF0 = 0xc0; |
|||
|
|||
/// <summary>
|
|||
/// Start Of Frame (Extended Sequential DCT)
|
|||
/// <remarks>
|
|||
/// Indicates that this is a progressive DCT-based JPEG, and specifies the width, height, number of components,
|
|||
/// and component subsampling (e.g., 4:2:0).
|
|||
/// </remarks>
|
|||
/// </summary>
|
|||
public const byte SOF1 = 0xc1; |
|||
|
|||
/// <summary>
|
|||
/// Start Of Frame (progressive DCT)
|
|||
/// <remarks>
|
|||
/// Indicates that this is a progressive DCT-based JPEG, and specifies the width, height, number of components,
|
|||
/// and component subsampling (e.g., 4:2:0).
|
|||
/// </remarks>
|
|||
/// </summary>
|
|||
public const byte SOF2 = 0xc2; |
|||
|
|||
/// <summary>
|
|||
/// Define Huffman Table(s)
|
|||
/// <remarks>
|
|||
/// Specifies one or more Huffman tables.
|
|||
/// </remarks>
|
|||
/// </summary>
|
|||
public const byte DHT = 0xc4; |
|||
|
|||
/// <summary>
|
|||
/// Define Quantization Table(s)
|
|||
/// <remarks>
|
|||
/// Specifies one or more quantization tables.
|
|||
/// </remarks>
|
|||
/// </summary>
|
|||
public const byte DQT = 0xdb; |
|||
|
|||
/// <summary>
|
|||
/// Define Restart Interval
|
|||
/// <remarks>
|
|||
/// Specifies the interval between RSTn markers, in macroblocks. This marker is followed by two bytes
|
|||
/// indicating the fixed size so it can be treated like any other variable size segment.
|
|||
/// </remarks>
|
|||
/// </summary>
|
|||
public const byte DRI = 0xdd; |
|||
|
|||
/// <summary>
|
|||
/// Define First Restart
|
|||
/// <remarks>
|
|||
/// Inserted every r macroblocks, where r is the restart interval set by a DRI marker.
|
|||
/// Not used if there was no DRI marker. The low three bits of the marker code cycle in value from 0 to 7.
|
|||
/// </remarks>
|
|||
/// </summary>
|
|||
public const byte RST0 = 0xd0; |
|||
|
|||
/// <summary>
|
|||
/// Define Eigth Restart
|
|||
/// <remarks>
|
|||
/// Inserted every r macroblocks, where r is the restart interval set by a DRI marker.
|
|||
/// Not used if there was no DRI marker. The low three bits of the marker code cycle in value from 0 to 7.
|
|||
/// </remarks>
|
|||
/// </summary>
|
|||
public const byte RST7 = 0xd7; |
|||
|
|||
/// <summary>
|
|||
/// Start of Scan
|
|||
/// <remarks>
|
|||
/// Begins a top-to-bottom scan of the image. In baseline DCT JPEG images, there is generally a single scan.
|
|||
/// Progressive DCT JPEG images usually contain multiple scans. This marker specifies which slice of data it
|
|||
/// will contain, and is immediately followed by entropy-coded data.
|
|||
/// </remarks>
|
|||
/// </summary>
|
|||
public const byte SOS = 0xda; |
|||
|
|||
/// <summary>
|
|||
/// Comment
|
|||
/// <remarks>
|
|||
/// Contains a text comment.
|
|||
/// </remarks>
|
|||
/// </summary>
|
|||
public const byte COM = 0xfe; |
|||
|
|||
/// <summary>
|
|||
/// End of Image
|
|||
/// </summary>
|
|||
public const byte EOI = 0xd9; |
|||
|
|||
/// <summary>
|
|||
/// Application specific marker for marking the jpeg format.
|
|||
/// <see href="http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/JPEG.html"/>
|
|||
/// </summary>
|
|||
public const byte APP0 = 0xe0; |
|||
|
|||
/// <summary>
|
|||
/// Application specific marker for marking where to store metadata.
|
|||
/// </summary>
|
|||
public const byte APP1 = 0xe1; |
|||
|
|||
/// <summary>
|
|||
/// Application specific marker for marking where to store ICC profile information.
|
|||
/// </summary>
|
|||
public const byte APP2 = 0xe2; |
|||
|
|||
/// <summary>
|
|||
/// Application specific marker used by Adobe for storing encoding information for DCT filters.
|
|||
/// </summary>
|
|||
public const byte APP14 = 0xee; |
|||
|
|||
/// <summary>
|
|||
/// Application specific marker used by GraphicConverter to store JPEG quality.
|
|||
/// </summary>
|
|||
public const byte APP15 = 0xef; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Describes Adobe specific markers <see href="http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/JPEG.html#Adobe"/>
|
|||
/// </summary>
|
|||
internal static class Adobe |
|||
{ |
|||
/// <summary>
|
|||
/// The color transform is unknown.(RGB or CMYK)
|
|||
/// </summary>
|
|||
public const int ColorTransformUnknown = 0; |
|||
|
|||
/// <summary>
|
|||
/// The color transform is YCbCr (luminance, red chroma, blue chroma)
|
|||
/// </summary>
|
|||
public const int ColorTransformYCbCr = 1; |
|||
|
|||
/// <summary>
|
|||
/// The color transform is YCCK (luminance, red chroma, blue chroma, keyline)
|
|||
/// </summary>
|
|||
public const int ColorTransformYcck = 2; |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,89 @@ |
|||
// Copyright (c) Six Labors and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
|
|||
using System; |
|||
using SixLabors.ImageSharp.Memory; |
|||
using SixLabors.ImageSharp.PixelFormats; |
|||
using Xunit; |
|||
// ReSharper disable InconsistentNaming
|
|||
|
|||
namespace SixLabors.ImageSharp.Tests.Formats.Jpg |
|||
{ |
|||
public partial class JpegDecoderTests |
|||
{ |
|||
[Theory] |
|||
[WithFileCollection(nameof(BaselineTestJpegs), PixelTypes.Rgba32)] |
|||
public void DecodeBaselineJpeg_Orig<TPixel>(TestImageProvider<TPixel> provider) |
|||
where TPixel : struct, IPixel<TPixel> |
|||
{ |
|||
if (SkipTest(provider)) |
|||
{ |
|||
return; |
|||
} |
|||
|
|||
// For 32 bit test enviroments:
|
|||
provider.Configuration.MemoryManager = ArrayPoolMemoryManager.CreateWithModeratePooling(); |
|||
|
|||
using (Image<TPixel> image = provider.GetImage(GolangJpegDecoder)) |
|||
{ |
|||
image.DebugSave(provider); |
|||
provider.Utility.TestName = DecodeBaselineJpegOutputName; |
|||
image.CompareToReferenceOutput( |
|||
this.GetImageComparer(provider), |
|||
provider, |
|||
appendPixelTypeToFileName: false); |
|||
} |
|||
|
|||
provider.Configuration.MemoryManager.ReleaseRetainedResources(); |
|||
} |
|||
|
|||
[Theory] |
|||
[WithFileCollection(nameof(BaselineTestJpegs), PixelTypes.Rgba32)] |
|||
public void DecodeBaselineJpeg_PdfJs<TPixel>(TestImageProvider<TPixel> provider) |
|||
where TPixel : struct, IPixel<TPixel> |
|||
{ |
|||
if (TestEnvironment.RunsOnCI && !TestEnvironment.Is64BitProcess) |
|||
{ |
|||
// skipping to avoid OutOfMemoryException on CI
|
|||
return; |
|||
} |
|||
|
|||
using (Image<TPixel> image = provider.GetImage(PdfJsJpegDecoder)) |
|||
{ |
|||
image.DebugSave(provider); |
|||
|
|||
provider.Utility.TestName = DecodeBaselineJpegOutputName; |
|||
image.CompareToReferenceOutput( |
|||
this.GetImageComparer(provider), |
|||
provider, |
|||
appendPixelTypeToFileName: false); |
|||
} |
|||
} |
|||
|
|||
[Theory] |
|||
[WithFile(TestImages.Jpeg.Issues.CriticalEOF214, PixelTypes.Rgba32)] |
|||
public void DecodeBaselineJpeg_CriticalEOF_ShouldThrow_Golang<TPixel>(TestImageProvider<TPixel> provider) |
|||
where TPixel : struct, IPixel<TPixel> |
|||
{ |
|||
// TODO: We need a public ImageDecoderException class in ImageSharp!
|
|||
Assert.ThrowsAny<Exception>(() => provider.GetImage(GolangJpegDecoder)); |
|||
} |
|||
|
|||
[Theory] |
|||
[WithFile(TestImages.Jpeg.Issues.CriticalEOF214, PixelTypes.Rgba32)] |
|||
public void DecodeBaselineJpeg_CriticalEOF_ShouldThrow_PdfJs<TPixel>(TestImageProvider<TPixel> provider) |
|||
where TPixel : struct, IPixel<TPixel> |
|||
{ |
|||
// TODO: We need a public ImageDecoderException class in ImageSharp!
|
|||
Assert.ThrowsAny<Exception>(() => provider.GetImage(PdfJsJpegDecoder)); |
|||
} |
|||
|
|||
[Theory(Skip = "Debug only, enable manually!")] |
|||
[WithFileCollection(nameof(BaselineTestJpegs), PixelTypes.Rgba32)] |
|||
public void CompareJpegDecoders_Baseline<TPixel>(TestImageProvider<TPixel> provider) |
|||
where TPixel : struct, IPixel<TPixel> |
|||
{ |
|||
this.CompareJpegDecodersImpl(provider, DecodeBaselineJpegOutputName); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,72 @@ |
|||
// Copyright (c) Six Labors and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
|
|||
using System.Collections.Generic; |
|||
|
|||
namespace SixLabors.ImageSharp.Tests.Formats.Jpg |
|||
{ |
|||
public partial class JpegDecoderTests |
|||
{ |
|||
public static string[] BaselineTestJpegs = |
|||
{ |
|||
TestImages.Jpeg.Baseline.Calliphora, |
|||
TestImages.Jpeg.Baseline.Cmyk, TestImages.Jpeg.Baseline.Ycck, |
|||
TestImages.Jpeg.Baseline.Jpeg400, |
|||
TestImages.Jpeg.Baseline.Testorig420, |
|||
|
|||
// BUG: The following image has a high difference compared to the expected output:
|
|||
// TestImages.Jpeg.Baseline.Jpeg420Small,
|
|||
|
|||
TestImages.Jpeg.Baseline.Jpeg444, |
|||
TestImages.Jpeg.Baseline.Bad.BadEOF, |
|||
TestImages.Jpeg.Issues.MultiHuffmanBaseline394, |
|||
TestImages.Jpeg.Baseline.MultiScanBaselineCMYK, |
|||
TestImages.Jpeg.Baseline.Bad.BadRST |
|||
}; |
|||
|
|||
public static string[] ProgressiveTestJpegs = |
|||
{ |
|||
TestImages.Jpeg.Progressive.Fb, |
|||
TestImages.Jpeg.Progressive.Progress, |
|||
TestImages.Jpeg.Progressive.Festzug, |
|||
TestImages.Jpeg.Progressive.Bad.BadEOF, |
|||
TestImages.Jpeg.Issues.BadCoeffsProgressive178, |
|||
TestImages.Jpeg.Issues.MissingFF00ProgressiveGirl159, |
|||
TestImages.Jpeg.Issues.MissingFF00ProgressiveBedroom159, |
|||
TestImages.Jpeg.Issues.BadZigZagProgressive385, |
|||
TestImages.Jpeg.Progressive.Bad.ExifUndefType, |
|||
TestImages.Jpeg.Issues.NoEoiProgressive517, |
|||
TestImages.Jpeg.Issues.BadRstProgressive518, |
|||
TestImages.Jpeg.Issues.MissingFF00ProgressiveBedroom159, |
|||
}; |
|||
|
|||
/// <summary>
|
|||
/// Golang decoder is unable to decode these
|
|||
/// </summary>
|
|||
public static string[] PdfJsOnly = |
|||
{ |
|||
TestImages.Jpeg.Issues.NoEoiProgressive517, TestImages.Jpeg.Issues.BadRstProgressive518, |
|||
TestImages.Jpeg.Issues.MissingFF00ProgressiveBedroom159 |
|||
}; |
|||
|
|||
private static readonly Dictionary<string, float> CustomToleranceValues = |
|||
new Dictionary<string, float> |
|||
{ |
|||
// Baseline:
|
|||
[TestImages.Jpeg.Baseline.Calliphora] = 0.00002f / 100, |
|||
[TestImages.Jpeg.Baseline.Bad.BadEOF] = 0.38f / 100, |
|||
[TestImages.Jpeg.Baseline.Testorig420] = 0.38f / 100, |
|||
[TestImages.Jpeg.Baseline.Bad.BadRST] = 0.0589f / 100, |
|||
|
|||
// Progressive:
|
|||
[TestImages.Jpeg.Issues.MissingFF00ProgressiveGirl159] = 0.34f / 100, |
|||
[TestImages.Jpeg.Issues.BadCoeffsProgressive178] = 0.38f / 100, |
|||
[TestImages.Jpeg.Progressive.Bad.BadEOF] = 0.3f / 100, |
|||
[TestImages.Jpeg.Progressive.Festzug] = 0.02f / 100, |
|||
[TestImages.Jpeg.Progressive.Fb] = 0.16f / 100, |
|||
[TestImages.Jpeg.Progressive.Progress] = 0.31f / 100, |
|||
[TestImages.Jpeg.Issues.BadZigZagProgressive385] = 0.23f / 100, |
|||
[TestImages.Jpeg.Progressive.Bad.ExifUndefType] = 0.011f / 100, |
|||
}; |
|||
} |
|||
} |
|||
@ -0,0 +1,81 @@ |
|||
// Copyright (c) Six Labors and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
|
|||
using System.Linq; |
|||
using SixLabors.ImageSharp.Memory; |
|||
using SixLabors.ImageSharp.PixelFormats; |
|||
using Xunit; |
|||
// ReSharper disable InconsistentNaming
|
|||
|
|||
namespace SixLabors.ImageSharp.Tests.Formats.Jpg |
|||
{ |
|||
public partial class JpegDecoderTests |
|||
{ |
|||
public const string DecodeProgressiveJpegOutputName = "DecodeProgressiveJpeg"; |
|||
|
|||
[Theory] |
|||
[WithFileCollection(nameof(ProgressiveTestJpegs), PixelTypes.Rgba32)] |
|||
public void DecodeProgressiveJpeg_Orig<TPixel>(TestImageProvider<TPixel> provider) |
|||
where TPixel : struct, IPixel<TPixel> |
|||
{ |
|||
if (TestEnvironment.RunsOnCI && !TestEnvironment.Is64BitProcess) |
|||
{ |
|||
// skipping to avoid OutOfMemoryException on CI
|
|||
return; |
|||
} |
|||
|
|||
// Golang decoder is unable to decode these:
|
|||
if (PdfJsOnly.Any(fn => fn.Contains(provider.SourceFileOrDescription))) |
|||
{ |
|||
return; |
|||
} |
|||
|
|||
// For 32 bit test enviroments:
|
|||
provider.Configuration.MemoryManager = ArrayPoolMemoryManager.CreateWithModeratePooling(); |
|||
|
|||
using (Image<TPixel> image = provider.GetImage(GolangJpegDecoder)) |
|||
{ |
|||
image.DebugSave(provider); |
|||
|
|||
provider.Utility.TestName = DecodeProgressiveJpegOutputName; |
|||
image.CompareToReferenceOutput( |
|||
this.GetImageComparer(provider), |
|||
provider, |
|||
appendPixelTypeToFileName: false); |
|||
} |
|||
|
|||
provider.Configuration.MemoryManager.ReleaseRetainedResources(); |
|||
} |
|||
|
|||
[Theory] |
|||
[WithFileCollection(nameof(ProgressiveTestJpegs), PixelTypes.Rgba32)] |
|||
public void DecodeProgressiveJpeg_PdfJs<TPixel>(TestImageProvider<TPixel> provider) |
|||
where TPixel : struct, IPixel<TPixel> |
|||
{ |
|||
if (SkipTest(provider)) |
|||
{ |
|||
// skipping to avoid OutOfMemoryException on CI
|
|||
return; |
|||
} |
|||
|
|||
using (Image<TPixel> image = provider.GetImage(PdfJsJpegDecoder)) |
|||
{ |
|||
image.DebugSave(provider); |
|||
|
|||
provider.Utility.TestName = DecodeProgressiveJpegOutputName; |
|||
image.CompareToReferenceOutput( |
|||
this.GetImageComparer(provider), |
|||
provider, |
|||
appendPixelTypeToFileName: false); |
|||
} |
|||
} |
|||
|
|||
[Theory(Skip = "Debug only, enable manually!")] |
|||
[WithFileCollection(nameof(ProgressiveTestJpegs), PixelTypes.Rgba32)] |
|||
public void CompareJpegDecoders_Progressive<TPixel>(TestImageProvider<TPixel> provider) |
|||
where TPixel : struct, IPixel<TPixel> |
|||
{ |
|||
this.CompareJpegDecodersImpl(provider, DecodeProgressiveJpegOutputName); |
|||
} |
|||
} |
|||
} |
|||
@ -1 +1 @@ |
|||
Subproject commit 8ab54f8003aff94b3a9662b0be46b0062cad6b74 |
|||
Subproject commit 8cff7b09d4a3b8d975a35cf04885264e5765e108 |
|||
|
After Width: | Height: | Size: 330 KiB |
|
Before Width: | Height: | Size: 2.1 MiB After Width: | Height: | Size: 2.1 MiB |
Some files were not shown because too many files changed in this diff
Loading…
Reference in new issue