From d610c59d5c4c7205c06cf8360d212064a9dd30b7 Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Fri, 11 May 2018 15:16:02 +1000 Subject: [PATCH] Rename Golang decoder components --- .../GolangPort/Components/Decoder/Bits.cs | 36 +++++----- .../GolangPort/Components/Decoder/Bytes.cs | 54 +++++++-------- .../Components/Decoder/DecoderThrowHelper.cs | 28 ++++---- .../{OrigComponent.cs => GolangComponent.cs} | 6 +- ...omponentScan.cs => GolangComponentScan.cs} | 2 +- ...ErrorCode.cs => GolangDecoderErrorCode.cs} | 2 +- ...rigHuffmanTree.cs => GolangHuffmanTree.cs} | 12 ++-- ... GolangJpegScanDecoder.ComputationData.cs} | 4 +- ... => GolangJpegScanDecoder.DataPointers.cs} | 6 +- ...canDecoder.cs => GolangJpegScanDecoder.cs} | 34 +++++----- .../Components/Decoder/InputProcessor.cs | 68 +++++++++---------- .../Jpeg/GolangPort/GolangJpegDecoderCore.cs | 26 +++---- .../Jpeg/GolangPort/JpegEncoderCore.cs | 5 -- .../Formats/Jpg/ParseStreamTests.cs | 14 ++-- .../Jpg/Utils/LibJpegTools.ComponentData.cs | 2 +- .../Jpg/Utils/LibJpegTools.SpectralData.cs | 2 +- 16 files changed, 146 insertions(+), 155 deletions(-) rename src/ImageSharp/Formats/Jpeg/GolangPort/Components/Decoder/{OrigComponent.cs => GolangComponent.cs} (98%) rename src/ImageSharp/Formats/Jpeg/GolangPort/Components/Decoder/{OrigComponentScan.cs => GolangComponentScan.cs} (94%) rename src/ImageSharp/Formats/Jpeg/GolangPort/Components/Decoder/{OrigDecoderErrorCode.cs => GolangDecoderErrorCode.cs} (93%) rename src/ImageSharp/Formats/Jpeg/GolangPort/Components/Decoder/{OrigHuffmanTree.cs => GolangHuffmanTree.cs} (95%) rename src/ImageSharp/Formats/Jpeg/GolangPort/Components/Decoder/{OrigJpegScanDecoder.ComputationData.cs => GolangJpegScanDecoder.ComputationData.cs} (91%) rename src/ImageSharp/Formats/Jpeg/GolangPort/Components/Decoder/{OrigJpegScanDecoder.DataPointers.cs => GolangJpegScanDecoder.DataPointers.cs} (89%) rename src/ImageSharp/Formats/Jpeg/GolangPort/Components/Decoder/{OrigJpegScanDecoder.cs => GolangJpegScanDecoder.cs} (94%) diff --git a/src/ImageSharp/Formats/Jpeg/GolangPort/Components/Decoder/Bits.cs b/src/ImageSharp/Formats/Jpeg/GolangPort/Components/Decoder/Bits.cs index 05bde78e65..353eb01fe2 100644 --- a/src/ImageSharp/Formats/Jpeg/GolangPort/Components/Decoder/Bits.cs +++ b/src/ImageSharp/Formats/Jpeg/GolangPort/Components/Decoder/Bits.cs @@ -38,7 +38,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.GolangPort.Components.Decoder [MethodImpl(MethodImplOptions.AggressiveInlining)] public void EnsureNBits(int n, ref InputProcessor inputProcessor) { - OrigDecoderErrorCode errorCode = this.EnsureNBitsUnsafe(n, ref inputProcessor); + GolangDecoderErrorCode errorCode = this.EnsureNBitsUnsafe(n, ref inputProcessor); errorCode.EnsureNoError(); } @@ -46,17 +46,17 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.GolangPort.Components.Decoder /// Reads bytes from the byte buffer to ensure that bits.UnreadBits is at /// least n. For best performance (avoiding function calls inside hot loops), /// the caller is the one responsible for first checking that bits.UnreadBits < n. - /// This method does not throw. Returns instead. + /// This method does not throw. Returns instead. /// /// The number of bits to ensure. /// The /// Error code - public OrigDecoderErrorCode EnsureNBitsUnsafe(int n, ref InputProcessor inputProcessor) + public GolangDecoderErrorCode EnsureNBitsUnsafe(int n, ref InputProcessor inputProcessor) { while (true) { - OrigDecoderErrorCode errorCode = this.EnsureBitsStepImpl(ref inputProcessor); - if (errorCode != OrigDecoderErrorCode.NoError || this.UnreadBits >= n) + GolangDecoderErrorCode errorCode = this.EnsureBitsStepImpl(ref inputProcessor); + if (errorCode != GolangDecoderErrorCode.NoError || this.UnreadBits >= n) { return errorCode; } @@ -67,8 +67,8 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.GolangPort.Components.Decoder /// Unrolled version of for n==8 /// /// The - /// A - public OrigDecoderErrorCode Ensure8BitsUnsafe(ref InputProcessor inputProcessor) + /// A + public GolangDecoderErrorCode Ensure8BitsUnsafe(ref InputProcessor inputProcessor) { return this.EnsureBitsStepImpl(ref inputProcessor); } @@ -77,8 +77,8 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.GolangPort.Components.Decoder /// Unrolled version of for n==1 /// /// The - /// A - public OrigDecoderErrorCode Ensure1BitUnsafe(ref InputProcessor inputProcessor) + /// A + public GolangDecoderErrorCode Ensure1BitUnsafe(ref InputProcessor inputProcessor) { return this.EnsureBitsStepImpl(ref inputProcessor); } @@ -92,7 +92,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.GolangPort.Components.Decoder [MethodImpl(MethodImplOptions.AggressiveInlining)] public int ReceiveExtend(int t, ref InputProcessor inputProcessor) { - OrigDecoderErrorCode errorCode = this.ReceiveExtendUnsafe(t, ref inputProcessor, out int x); + GolangDecoderErrorCode errorCode = this.ReceiveExtendUnsafe(t, ref inputProcessor, out int x); errorCode.EnsureNoError(); return x; } @@ -103,13 +103,13 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.GolangPort.Components.Decoder /// Byte /// The /// Read bits value - /// The - public OrigDecoderErrorCode ReceiveExtendUnsafe(int t, ref InputProcessor inputProcessor, out int x) + /// The + public GolangDecoderErrorCode ReceiveExtendUnsafe(int t, ref InputProcessor inputProcessor, out int x) { if (this.UnreadBits < t) { - OrigDecoderErrorCode errorCode = this.EnsureNBitsUnsafe(t, ref inputProcessor); - if (errorCode != OrigDecoderErrorCode.NoError) + GolangDecoderErrorCode errorCode = this.EnsureNBitsUnsafe(t, ref inputProcessor); + if (errorCode != GolangDecoderErrorCode.NoError) { x = int.MaxValue; return errorCode; @@ -126,14 +126,14 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.GolangPort.Components.Decoder x += ((-1) << t) + 1; } - return OrigDecoderErrorCode.NoError; + return GolangDecoderErrorCode.NoError; } - private OrigDecoderErrorCode EnsureBitsStepImpl(ref InputProcessor inputProcessor) + private GolangDecoderErrorCode EnsureBitsStepImpl(ref InputProcessor inputProcessor) { - OrigDecoderErrorCode errorCode = inputProcessor.Bytes.ReadByteStuffedByteUnsafe(inputProcessor.InputStream, out int c); + GolangDecoderErrorCode errorCode = inputProcessor.Bytes.ReadByteStuffedByteUnsafe(inputProcessor.InputStream, out int c); - if (errorCode != OrigDecoderErrorCode.NoError) + if (errorCode != GolangDecoderErrorCode.NoError) { return errorCode; } diff --git a/src/ImageSharp/Formats/Jpeg/GolangPort/Components/Decoder/Bytes.cs b/src/ImageSharp/Formats/Jpeg/GolangPort/Components/Decoder/Bytes.cs index 467b9b46a3..aaaa10a160 100644 --- a/src/ImageSharp/Formats/Jpeg/GolangPort/Components/Decoder/Bytes.cs +++ b/src/ImageSharp/Formats/Jpeg/GolangPort/Components/Decoder/Bytes.cs @@ -79,8 +79,8 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.GolangPort.Components.Decoder /// /// Input stream /// The result byte as - /// The - public OrigDecoderErrorCode ReadByteStuffedByteUnsafe(Stream inputStream, out int x) + /// The + public GolangDecoderErrorCode ReadByteStuffedByteUnsafe(Stream inputStream, out int x) { // Take the fast path if bytes.buf contains at least two bytes. if (this.I + 2 <= this.J) @@ -90,48 +90,48 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.GolangPort.Components.Decoder this.UnreadableBytes = 1; if (x != JpegConstants.Markers.XFFInt) { - return OrigDecoderErrorCode.NoError; + return GolangDecoderErrorCode.NoError; } if (this.BufferAsInt[this.I] != 0x00) { - return OrigDecoderErrorCode.MissingFF00; + return GolangDecoderErrorCode.MissingFF00; } this.I++; this.UnreadableBytes = 2; x = JpegConstants.Markers.XFF; - return OrigDecoderErrorCode.NoError; + return GolangDecoderErrorCode.NoError; } this.UnreadableBytes = 0; - OrigDecoderErrorCode errorCode = this.ReadByteAsIntUnsafe(inputStream, out x); + GolangDecoderErrorCode errorCode = this.ReadByteAsIntUnsafe(inputStream, out x); this.UnreadableBytes = 1; - if (errorCode != OrigDecoderErrorCode.NoError) + if (errorCode != GolangDecoderErrorCode.NoError) { return errorCode; } if (x != JpegConstants.Markers.XFF) { - return OrigDecoderErrorCode.NoError; + return GolangDecoderErrorCode.NoError; } errorCode = this.ReadByteAsIntUnsafe(inputStream, out x); this.UnreadableBytes = 2; - if (errorCode != OrigDecoderErrorCode.NoError) + if (errorCode != GolangDecoderErrorCode.NoError) { return errorCode; } if (x != 0x00) { - return OrigDecoderErrorCode.MissingFF00; + return GolangDecoderErrorCode.MissingFF00; } x = JpegConstants.Markers.XFF; - return OrigDecoderErrorCode.NoError; + return GolangDecoderErrorCode.NoError; } /// @@ -142,25 +142,25 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.GolangPort.Components.Decoder [MethodImpl(MethodImplOptions.AggressiveInlining)] public byte ReadByte(Stream inputStream) { - OrigDecoderErrorCode errorCode = this.ReadByteUnsafe(inputStream, out byte result); + GolangDecoderErrorCode errorCode = this.ReadByteUnsafe(inputStream, out byte result); errorCode.EnsureNoError(); return result; } /// /// Extracts the next byte, whether buffered or not buffered into the result out parameter. It does not care about byte stuffing. - /// This method does not throw on format error, it returns a instead. + /// This method does not throw on format error, it returns a instead. /// /// Input stream /// The result as out parameter - /// The - public OrigDecoderErrorCode ReadByteUnsafe(Stream inputStream, out byte result) + /// The + public GolangDecoderErrorCode ReadByteUnsafe(Stream inputStream, out byte result) { - OrigDecoderErrorCode errorCode = OrigDecoderErrorCode.NoError; + GolangDecoderErrorCode errorCode = GolangDecoderErrorCode.NoError; while (this.I == this.J) { errorCode = this.FillUnsafe(inputStream); - if (errorCode != OrigDecoderErrorCode.NoError) + if (errorCode != GolangDecoderErrorCode.NoError) { result = 0; return errorCode; @@ -178,15 +178,15 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.GolangPort.Components.Decoder /// /// The input stream /// The result - /// A + /// A [MethodImpl(MethodImplOptions.AggressiveInlining)] - public OrigDecoderErrorCode ReadByteAsIntUnsafe(Stream inputStream, out int result) + public GolangDecoderErrorCode ReadByteAsIntUnsafe(Stream inputStream, out int result) { - OrigDecoderErrorCode errorCode = OrigDecoderErrorCode.NoError; + GolangDecoderErrorCode errorCode = GolangDecoderErrorCode.NoError; while (this.I == this.J) { errorCode = this.FillUnsafe(inputStream); - if (errorCode != OrigDecoderErrorCode.NoError) + if (errorCode != GolangDecoderErrorCode.NoError) { result = 0; return errorCode; @@ -208,18 +208,18 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.GolangPort.Components.Decoder [MethodImpl(MethodImplOptions.AggressiveInlining)] public void Fill(Stream inputStream) { - OrigDecoderErrorCode errorCode = this.FillUnsafe(inputStream); + GolangDecoderErrorCode errorCode = this.FillUnsafe(inputStream); errorCode.EnsureNoError(); } /// /// Fills up the bytes buffer from the underlying stream. /// It should only be called when there are no unread bytes in bytes. - /// This method does not throw , returns a instead! + /// This method does not throw , returns a instead! /// /// Input stream - /// The - public OrigDecoderErrorCode FillUnsafe(Stream inputStream) + /// The + public GolangDecoderErrorCode FillUnsafe(Stream inputStream) { if (this.I != this.J) { @@ -241,7 +241,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.GolangPort.Components.Decoder int n = inputStream.Read(this.Buffer, this.J, this.Buffer.Length - this.J); if (n == 0) { - return OrigDecoderErrorCode.UnexpectedEndOfStream; + return GolangDecoderErrorCode.UnexpectedEndOfStream; } this.J += n; @@ -251,7 +251,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.GolangPort.Components.Decoder this.BufferAsInt[i] = this.Buffer[i]; } - return OrigDecoderErrorCode.NoError; + return GolangDecoderErrorCode.NoError; } } } \ No newline at end of file diff --git a/src/ImageSharp/Formats/Jpeg/GolangPort/Components/Decoder/DecoderThrowHelper.cs b/src/ImageSharp/Formats/Jpeg/GolangPort/Components/Decoder/DecoderThrowHelper.cs index 904ce00dde..2b2bc61ba8 100644 --- a/src/ImageSharp/Formats/Jpeg/GolangPort/Components/Decoder/DecoderThrowHelper.cs +++ b/src/ImageSharp/Formats/Jpeg/GolangPort/Components/Decoder/DecoderThrowHelper.cs @@ -12,22 +12,22 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.GolangPort.Components.Decoder internal static class DecoderThrowHelper { /// - /// Throws an exception that belongs to the given + /// Throws an exception that belongs to the given /// - /// The + /// The [MethodImpl(MethodImplOptions.NoInlining)] - public static void ThrowExceptionForErrorCode(this OrigDecoderErrorCode errorCode) + public static void ThrowExceptionForErrorCode(this GolangDecoderErrorCode errorCode) { // REMARK: If this method throws for an image that is expected to be decodable, // consider using the ***Unsafe variant of the parsing method that asks for ThrowExceptionForErrorCode() // then verify the error code + implement fallback logic manually! switch (errorCode) { - case OrigDecoderErrorCode.NoError: + case GolangDecoderErrorCode.NoError: throw new ArgumentException("ThrowExceptionForErrorCode() called with NoError!", nameof(errorCode)); - case OrigDecoderErrorCode.MissingFF00: + case GolangDecoderErrorCode.MissingFF00: throw new MissingFF00Exception(); - case OrigDecoderErrorCode.UnexpectedEndOfStream: + case GolangDecoderErrorCode.UnexpectedEndOfStream: throw new EOFException(); default: throw new ArgumentOutOfRangeException(nameof(errorCode), errorCode, null); @@ -35,26 +35,26 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.GolangPort.Components.Decoder } /// - /// Throws an exception if the given defines an error. + /// Throws an exception if the given defines an error. /// - /// The + /// The [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void EnsureNoError(this OrigDecoderErrorCode errorCode) + public static void EnsureNoError(this GolangDecoderErrorCode errorCode) { - if (errorCode != OrigDecoderErrorCode.NoError) + if (errorCode != GolangDecoderErrorCode.NoError) { ThrowExceptionForErrorCode(errorCode); } } /// - /// Throws an exception if the given is . + /// Throws an exception if the given is . /// - /// The + /// The [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void EnsureNoEOF(this OrigDecoderErrorCode errorCode) + public static void EnsureNoEOF(this GolangDecoderErrorCode errorCode) { - if (errorCode == OrigDecoderErrorCode.UnexpectedEndOfStream) + if (errorCode == GolangDecoderErrorCode.UnexpectedEndOfStream) { errorCode.ThrowExceptionForErrorCode(); } diff --git a/src/ImageSharp/Formats/Jpeg/GolangPort/Components/Decoder/OrigComponent.cs b/src/ImageSharp/Formats/Jpeg/GolangPort/Components/Decoder/GolangComponent.cs similarity index 98% rename from src/ImageSharp/Formats/Jpeg/GolangPort/Components/Decoder/OrigComponent.cs rename to src/ImageSharp/Formats/Jpeg/GolangPort/Components/Decoder/GolangComponent.cs index 1317af3943..ec8d96db90 100644 --- a/src/ImageSharp/Formats/Jpeg/GolangPort/Components/Decoder/OrigComponent.cs +++ b/src/ImageSharp/Formats/Jpeg/GolangPort/Components/Decoder/GolangComponent.cs @@ -14,9 +14,9 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.GolangPort.Components.Decoder /// /// Represents a single color component /// - internal class OrigComponent : IDisposable, IJpegComponent + internal class GolangComponent : IDisposable, IJpegComponent { - public OrigComponent(byte identifier, int index) + public GolangComponent(byte identifier, int index) { this.Identifier = identifier; this.Index = index; @@ -76,7 +76,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.GolangPort.Components.Decoder } else { - OrigComponent c0 = decoder.Components[0]; + GolangComponent c0 = decoder.Components[0]; this.SubSamplingDivisors = c0.SamplingFactors.DivideBy(this.SamplingFactors); } diff --git a/src/ImageSharp/Formats/Jpeg/GolangPort/Components/Decoder/OrigComponentScan.cs b/src/ImageSharp/Formats/Jpeg/GolangPort/Components/Decoder/GolangComponentScan.cs similarity index 94% rename from src/ImageSharp/Formats/Jpeg/GolangPort/Components/Decoder/OrigComponentScan.cs rename to src/ImageSharp/Formats/Jpeg/GolangPort/Components/Decoder/GolangComponentScan.cs index 0d98044045..6752768ffa 100644 --- a/src/ImageSharp/Formats/Jpeg/GolangPort/Components/Decoder/OrigComponentScan.cs +++ b/src/ImageSharp/Formats/Jpeg/GolangPort/Components/Decoder/GolangComponentScan.cs @@ -9,7 +9,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.GolangPort.Components.Decoder /// Represents a component scan /// [StructLayout(LayoutKind.Sequential)] - internal struct OrigComponentScan + internal struct GolangComponentScan { /// /// Gets or sets the component index. diff --git a/src/ImageSharp/Formats/Jpeg/GolangPort/Components/Decoder/OrigDecoderErrorCode.cs b/src/ImageSharp/Formats/Jpeg/GolangPort/Components/Decoder/GolangDecoderErrorCode.cs similarity index 93% rename from src/ImageSharp/Formats/Jpeg/GolangPort/Components/Decoder/OrigDecoderErrorCode.cs rename to src/ImageSharp/Formats/Jpeg/GolangPort/Components/Decoder/GolangDecoderErrorCode.cs index 02a8ea55e0..fa3364527c 100644 --- a/src/ImageSharp/Formats/Jpeg/GolangPort/Components/Decoder/OrigDecoderErrorCode.cs +++ b/src/ImageSharp/Formats/Jpeg/GolangPort/Components/Decoder/GolangDecoderErrorCode.cs @@ -6,7 +6,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.GolangPort.Components.Decoder /// /// Represents "recoverable" decoder errors. /// - internal enum OrigDecoderErrorCode + internal enum GolangDecoderErrorCode { /// /// NoError diff --git a/src/ImageSharp/Formats/Jpeg/GolangPort/Components/Decoder/OrigHuffmanTree.cs b/src/ImageSharp/Formats/Jpeg/GolangPort/Components/Decoder/GolangHuffmanTree.cs similarity index 95% rename from src/ImageSharp/Formats/Jpeg/GolangPort/Components/Decoder/OrigHuffmanTree.cs rename to src/ImageSharp/Formats/Jpeg/GolangPort/Components/Decoder/GolangHuffmanTree.cs index dbc7bb0f7f..dccce2aaa8 100644 --- a/src/ImageSharp/Formats/Jpeg/GolangPort/Components/Decoder/OrigHuffmanTree.cs +++ b/src/ImageSharp/Formats/Jpeg/GolangPort/Components/Decoder/GolangHuffmanTree.cs @@ -1,8 +1,6 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using System; -using System.Buffers; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; @@ -12,7 +10,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.GolangPort.Components.Decoder /// Represents a Huffman tree /// [StructLayout(LayoutKind.Sequential)] - internal unsafe struct OrigHuffmanTree + internal unsafe struct GolangHuffmanTree { /// /// The index of the AC table row @@ -95,12 +93,12 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.GolangPort.Components.Decoder public FixedInt32Buffer16 Indices; /// - /// Creates and initializes an array of instances of size + /// Creates and initializes an array of instances of size /// - /// An array of instances representing the Huffman tables - public static OrigHuffmanTree[] CreateHuffmanTrees() + /// An array of instances representing the Huffman tables + public static GolangHuffmanTree[] CreateHuffmanTrees() { - return new OrigHuffmanTree[NumberOfTrees]; + return new GolangHuffmanTree[NumberOfTrees]; } /// diff --git a/src/ImageSharp/Formats/Jpeg/GolangPort/Components/Decoder/OrigJpegScanDecoder.ComputationData.cs b/src/ImageSharp/Formats/Jpeg/GolangPort/Components/Decoder/GolangJpegScanDecoder.ComputationData.cs similarity index 91% rename from src/ImageSharp/Formats/Jpeg/GolangPort/Components/Decoder/OrigJpegScanDecoder.ComputationData.cs rename to src/ImageSharp/Formats/Jpeg/GolangPort/Components/Decoder/GolangJpegScanDecoder.ComputationData.cs index 41845ff720..f912cfccdc 100644 --- a/src/ImageSharp/Formats/Jpeg/GolangPort/Components/Decoder/OrigJpegScanDecoder.ComputationData.cs +++ b/src/ImageSharp/Formats/Jpeg/GolangPort/Components/Decoder/GolangJpegScanDecoder.ComputationData.cs @@ -9,7 +9,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.GolangPort.Components.Decoder /// /// Conains the definition of /// - internal unsafe partial struct OrigJpegScanDecoder + internal unsafe partial struct GolangJpegScanDecoder { /// /// Holds the "large" data blocks needed for computations. @@ -28,7 +28,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.GolangPort.Components.Decoder public ZigZag Unzig; /// - /// The buffer storing the -s for each component + /// The buffer storing the -s for each component /// public fixed byte ScanData[3 * GolangJpegDecoderCore.MaxComponents]; diff --git a/src/ImageSharp/Formats/Jpeg/GolangPort/Components/Decoder/OrigJpegScanDecoder.DataPointers.cs b/src/ImageSharp/Formats/Jpeg/GolangPort/Components/Decoder/GolangJpegScanDecoder.DataPointers.cs similarity index 89% rename from src/ImageSharp/Formats/Jpeg/GolangPort/Components/Decoder/OrigJpegScanDecoder.DataPointers.cs rename to src/ImageSharp/Formats/Jpeg/GolangPort/Components/Decoder/GolangJpegScanDecoder.DataPointers.cs index 0207280e3e..87a35a49f3 100644 --- a/src/ImageSharp/Formats/Jpeg/GolangPort/Components/Decoder/OrigJpegScanDecoder.DataPointers.cs +++ b/src/ImageSharp/Formats/Jpeg/GolangPort/Components/Decoder/GolangJpegScanDecoder.DataPointers.cs @@ -8,7 +8,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.GolangPort.Components.Decoder /// /// Conains the definition of /// - internal unsafe partial struct OrigJpegScanDecoder + internal unsafe partial struct GolangJpegScanDecoder { /// /// Contains pointers to the memory regions of so they can be easily passed around to pointer based utility methods of @@ -28,7 +28,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.GolangPort.Components.Decoder /// /// Pointer to as Scan* /// - public OrigComponentScan* ComponentScan; + public GolangComponentScan* ComponentScan; /// /// Pointer to @@ -43,7 +43,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.GolangPort.Components.Decoder { this.Block = &basePtr->Block; this.Unzig = basePtr->Unzig.Data; - this.ComponentScan = (OrigComponentScan*)basePtr->ScanData; + this.ComponentScan = (GolangComponentScan*)basePtr->ScanData; this.Dc = basePtr->Dc; } } diff --git a/src/ImageSharp/Formats/Jpeg/GolangPort/Components/Decoder/OrigJpegScanDecoder.cs b/src/ImageSharp/Formats/Jpeg/GolangPort/Components/Decoder/GolangJpegScanDecoder.cs similarity index 94% rename from src/ImageSharp/Formats/Jpeg/GolangPort/Components/Decoder/OrigJpegScanDecoder.cs rename to src/ImageSharp/Formats/Jpeg/GolangPort/Components/Decoder/GolangJpegScanDecoder.cs index 052635a313..156ccdd63e 100644 --- a/src/ImageSharp/Formats/Jpeg/GolangPort/Components/Decoder/OrigJpegScanDecoder.cs +++ b/src/ImageSharp/Formats/Jpeg/GolangPort/Components/Decoder/GolangJpegScanDecoder.cs @@ -4,8 +4,6 @@ using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using SixLabors.ImageSharp.Formats.Jpeg.Common; -using SixLabors.ImageSharp.Formats.Jpeg.Common.Decoder; -using SixLabors.ImageSharp.Memory; // ReSharper disable InconsistentNaming namespace SixLabors.ImageSharp.Formats.Jpeg.GolangPort.Components.Decoder @@ -29,7 +27,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.GolangPort.Components.Decoder /// For baseline JPEGs, these parameters are hard-coded to 0/63/0/0. /// [StructLayout(LayoutKind.Sequential)] - internal unsafe partial struct OrigJpegScanDecoder + internal unsafe partial struct GolangJpegScanDecoder { // The JpegScanDecoder members should be ordered in a way that results in optimal memory layout. #pragma warning disable SA1202 // ElementsMustBeOrderedByAccess @@ -110,12 +108,12 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.GolangPort.Components.Decoder private byte expectedRst; /// - /// Initializes a default-constructed instance for reading data from -s stream. + /// Initializes a default-constructed instance for reading data from -s stream. /// - /// Pointer to on the stack + /// Pointer to on the stack /// The instance /// The remaining bytes in the segment block. - public static void InitStreamReading(OrigJpegScanDecoder* p, GolangJpegDecoderCore decoder, int remaining) + public static void InitStreamReading(GolangJpegScanDecoder* p, GolangJpegDecoderCore decoder, int remaining) { p->data = ComputationData.Create(); p->pointers = new DataPointers(&p->data); @@ -124,7 +122,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.GolangPort.Components.Decoder /// /// Read Huffman data from Jpeg scans in , - /// and decode it as into . + /// and decode it as into . /// /// The blocks are traversed one MCU at a time. For 4:2:0 chroma /// subsampling, there are four Y 8x8 blocks in every 16x16 MCU. @@ -182,7 +180,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.GolangPort.Components.Decoder for (int scanIndex = 0; scanIndex < this.componentScanCount; scanIndex++) { this.ComponentIndex = this.pointers.ComponentScan[scanIndex].ComponentIndex; - OrigComponent component = decoder.Components[this.ComponentIndex]; + GolangComponent component = decoder.Components[this.ComponentIndex]; this.hi = component.HorizontalSamplingFactor; int vi = component.VerticalSamplingFactor; @@ -285,7 +283,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.GolangPort.Components.Decoder /// private void ResetDcValues() { - Unsafe.InitBlock(this.pointers.Dc, default(byte), sizeof(int) * GolangJpegDecoderCore.MaxComponents); + Unsafe.InitBlock(this.pointers.Dc, default, sizeof(int) * GolangJpegDecoderCore.MaxComponents); } /// @@ -363,7 +361,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.GolangPort.Components.Decoder private void DecodeBlock(GolangJpegDecoderCore decoder, int scanIndex) { Block8x8* b = this.pointers.Block; - int huffmannIdx = (OrigHuffmanTree.AcTableIndex * OrigHuffmanTree.ThRowSize) + this.pointers.ComponentScan[scanIndex].AcTableSelector; + int huffmannIdx = (GolangHuffmanTree.AcTableIndex * GolangHuffmanTree.ThRowSize) + this.pointers.ComponentScan[scanIndex].AcTableSelector; if (this.ah != 0) { this.Refine(ref decoder.InputProcessor, ref decoder.HuffmanTrees[huffmannIdx], 1 << this.al); @@ -377,7 +375,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.GolangPort.Components.Decoder zig++; // Decode the DC coefficient, as specified in section F.2.2.1. - int huffmanIndex = (OrigHuffmanTree.DcTableIndex * OrigHuffmanTree.ThRowSize) + this.pointers.ComponentScan[scanIndex].DcTableSelector; + int huffmanIndex = (GolangHuffmanTree.DcTableIndex * GolangHuffmanTree.ThRowSize) + this.pointers.ComponentScan[scanIndex].DcTableSelector; decoder.InputProcessor.DecodeHuffmanUnsafe( ref decoder.HuffmanTrees[huffmanIndex], out int value); @@ -467,7 +465,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.GolangPort.Components.Decoder private void DecodeEobRun(int count, ref InputProcessor processor) { processor.DecodeBitsUnsafe(count, out int bitsResult); - if (processor.LastErrorCode != OrigDecoderErrorCode.NoError) + if (processor.LastErrorCode != GolangDecoderErrorCode.NoError) { return; } @@ -475,7 +473,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.GolangPort.Components.Decoder this.eobRun |= bitsResult; } - private void InitComponentScan(GolangJpegDecoderCore decoder, int i, ref OrigComponentScan currentComponentScan, ref int totalHv) + private void InitComponentScan(GolangJpegDecoderCore decoder, int i, ref GolangComponentScan currentComponentScan, ref int totalHv) { // Component selector. int cs = decoder.Temp[1 + (2 * i)]; @@ -502,9 +500,9 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.GolangPort.Components.Decoder private void ProcessComponentImpl( GolangJpegDecoderCore decoder, int i, - ref OrigComponentScan currentComponentScan, + ref GolangComponentScan currentComponentScan, ref int totalHv, - OrigComponent currentComponent) + GolangComponent currentComponent) { // Section B.2.3 states that "the value of Cs_j shall be different from // the values of Cs_1 through Cs_(j-1)". Since we have previously @@ -522,13 +520,13 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.GolangPort.Components.Decoder totalHv += currentComponent.HorizontalSamplingFactor * currentComponent.VerticalSamplingFactor; currentComponentScan.DcTableSelector = (byte)(decoder.Temp[2 + (2 * i)] >> 4); - if (currentComponentScan.DcTableSelector > OrigHuffmanTree.MaxTh) + if (currentComponentScan.DcTableSelector > GolangHuffmanTree.MaxTh) { throw new ImageFormatException("Bad DC table selector value"); } currentComponentScan.AcTableSelector = (byte)(decoder.Temp[2 + (2 * i)] & 0x0f); - if (currentComponentScan.AcTableSelector > OrigHuffmanTree.MaxTh) + if (currentComponentScan.AcTableSelector > GolangHuffmanTree.MaxTh) { throw new ImageFormatException("Bad AC table selector value"); } @@ -540,7 +538,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.GolangPort.Components.Decoder /// The instance /// The Huffman tree /// The low transform offset - private void Refine(ref InputProcessor bp, ref OrigHuffmanTree h, int delta) + private void Refine(ref InputProcessor bp, ref GolangHuffmanTree h, int delta) { Block8x8* b = this.pointers.Block; diff --git a/src/ImageSharp/Formats/Jpeg/GolangPort/Components/Decoder/InputProcessor.cs b/src/ImageSharp/Formats/Jpeg/GolangPort/Components/Decoder/InputProcessor.cs index 8932248e4b..8019de2f28 100644 --- a/src/ImageSharp/Formats/Jpeg/GolangPort/Components/Decoder/InputProcessor.cs +++ b/src/ImageSharp/Formats/Jpeg/GolangPort/Components/Decoder/InputProcessor.cs @@ -34,7 +34,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.GolangPort.Components.Decoder this.Bytes = Bytes.Create(); this.InputStream = inputStream; this.Temp = temp; - this.LastErrorCode = OrigDecoderErrorCode.NoError; + this.LastErrorCode = GolangDecoderErrorCode.NoError; } /// @@ -50,13 +50,13 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.GolangPort.Components.Decoder /// /// Gets a value indicating whether an unexpected EOF reached in . /// - public bool ReachedEOF => this.LastErrorCode == OrigDecoderErrorCode.UnexpectedEndOfStream; + public bool ReachedEOF => this.LastErrorCode == GolangDecoderErrorCode.UnexpectedEndOfStream; - public bool HasError => this.LastErrorCode != OrigDecoderErrorCode.NoError; + public bool HasError => this.LastErrorCode != GolangDecoderErrorCode.NoError; - public OrigDecoderErrorCode LastErrorCode { get; private set; } + public GolangDecoderErrorCode LastErrorCode { get; private set; } - public void ResetErrorState() => this.LastErrorCode = OrigDecoderErrorCode.NoError; + public void ResetErrorState() => this.LastErrorCode = GolangDecoderErrorCode.NoError; /// /// If errorCode indicates unexpected EOF, sets to true and returns false. @@ -65,7 +65,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.GolangPort.Components.Decoder /// A indicating whether EOF reached public bool CheckEOFEnsureNoError() { - if (this.LastErrorCode == OrigDecoderErrorCode.UnexpectedEndOfStream) + if (this.LastErrorCode == GolangDecoderErrorCode.UnexpectedEndOfStream) { return false; } @@ -81,7 +81,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.GolangPort.Components.Decoder /// A indicating whether EOF reached public bool CheckEOF() { - if (this.LastErrorCode == OrigDecoderErrorCode.UnexpectedEndOfStream) + if (this.LastErrorCode == GolangDecoderErrorCode.UnexpectedEndOfStream) { return false; } @@ -106,7 +106,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.GolangPort.Components.Decoder } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public OrigDecoderErrorCode ReadByteUnsafe(out byte result) + public GolangDecoderErrorCode ReadByteUnsafe(out byte result) { this.LastErrorCode = this.Bytes.ReadByteUnsafe(this.InputStream, out result); return this.LastErrorCode; @@ -117,13 +117,13 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.GolangPort.Components.Decoder /// TODO: This method (and also the usages) could be optimized by batching! /// /// The decoded bit as a - /// The - public OrigDecoderErrorCode DecodeBitUnsafe(out bool result) + /// The + public GolangDecoderErrorCode DecodeBitUnsafe(out bool result) { if (this.Bits.UnreadBits == 0) { this.LastErrorCode = this.Bits.Ensure1BitUnsafe(ref this); - if (this.LastErrorCode != OrigDecoderErrorCode.NoError) + if (this.LastErrorCode != GolangDecoderErrorCode.NoError) { result = false; return this.LastErrorCode; @@ -133,7 +133,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.GolangPort.Components.Decoder result = (this.Bits.Accumulator & this.Bits.Mask) != 0; this.Bits.UnreadBits--; this.Bits.Mask >>= 1; - return this.LastErrorCode = OrigDecoderErrorCode.NoError; + return this.LastErrorCode = GolangDecoderErrorCode.NoError; } /// @@ -143,8 +143,8 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.GolangPort.Components.Decoder /// The data to write to. /// The offset in the source buffer /// The number of bytes to read - /// The - public OrigDecoderErrorCode ReadFullUnsafe(byte[] data, int offset, int length) + /// The + public GolangDecoderErrorCode ReadFullUnsafe(byte[] data, int offset, int length) { // Unread the overshot bytes, if any. if (this.Bytes.UnreadableBytes != 0) @@ -157,8 +157,8 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.GolangPort.Components.Decoder this.Bytes.UnreadableBytes = 0; } - this.LastErrorCode = OrigDecoderErrorCode.NoError; - while (length > 0 && this.LastErrorCode == OrigDecoderErrorCode.NoError) + this.LastErrorCode = GolangDecoderErrorCode.NoError; + while (length > 0 && this.LastErrorCode == GolangDecoderErrorCode.NoError) { if (this.Bytes.J - this.Bytes.I >= length) { @@ -185,13 +185,13 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.GolangPort.Components.Decoder /// /// The number of bits to decode. /// The result - /// The - public OrigDecoderErrorCode DecodeBitsUnsafe(int count, out int result) + /// The + public GolangDecoderErrorCode DecodeBitsUnsafe(int count, out int result) { if (this.Bits.UnreadBits < count) { this.LastErrorCode = this.Bits.EnsureNBitsUnsafe(count, ref this); - if (this.LastErrorCode != OrigDecoderErrorCode.NoError) + if (this.LastErrorCode != GolangDecoderErrorCode.NoError) { result = 0; return this.LastErrorCode; @@ -202,7 +202,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.GolangPort.Components.Decoder result = result & ((1 << count) - 1); this.Bits.UnreadBits -= count; this.Bits.Mask >>= count; - return this.LastErrorCode = OrigDecoderErrorCode.NoError; + return this.LastErrorCode = GolangDecoderErrorCode.NoError; } /// @@ -210,8 +210,8 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.GolangPort.Components.Decoder /// /// The huffman value /// The decoded - /// The - public OrigDecoderErrorCode DecodeHuffmanUnsafe(ref OrigHuffmanTree huffmanTree, out int result) + /// The + public GolangDecoderErrorCode DecodeHuffmanUnsafe(ref GolangHuffmanTree huffmanTree, out int result) { result = 0; @@ -224,9 +224,9 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.GolangPort.Components.Decoder { this.LastErrorCode = this.Bits.Ensure8BitsUnsafe(ref this); - if (this.LastErrorCode == OrigDecoderErrorCode.NoError) + if (this.LastErrorCode == GolangDecoderErrorCode.NoError) { - int lutIndex = (this.Bits.Accumulator >> (this.Bits.UnreadBits - OrigHuffmanTree.LutSizeLog2)) & 0xFF; + int lutIndex = (this.Bits.Accumulator >> (this.Bits.UnreadBits - GolangHuffmanTree.LutSizeLog2)) & 0xFF; int v = huffmanTree.Lut[lutIndex]; if (v != 0) @@ -246,7 +246,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.GolangPort.Components.Decoder } int code = 0; - for (int i = 0; i < OrigHuffmanTree.MaxCodeLength; i++) + for (int i = 0; i < GolangHuffmanTree.MaxCodeLength; i++) { if (this.Bits.UnreadBits == 0) { @@ -269,7 +269,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.GolangPort.Components.Decoder if (code <= huffmanTree.MaxCodes[i]) { result = huffmanTree.GetValue(code, i); - return this.LastErrorCode = OrigDecoderErrorCode.NoError; + return this.LastErrorCode = GolangDecoderErrorCode.NoError; } code <<= 1; @@ -279,7 +279,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.GolangPort.Components.Decoder DecoderThrowHelper.ThrowImageFormatException.BadHuffmanCode(); // DUMMY RETURN! C# doesn't know we have thrown an exception! - return OrigDecoderErrorCode.NoError; + return GolangDecoderErrorCode.NoError; } /// @@ -295,11 +295,11 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.GolangPort.Components.Decoder /// /// Skips the next n bytes. - /// Does not throw, returns instead! + /// Does not throw, returns instead! /// /// The number of bytes to ignore. - /// The - public OrigDecoderErrorCode SkipUnsafe(int count) + /// The + public GolangDecoderErrorCode SkipUnsafe(int count) { // Unread the overshot bytes, if any. if (this.Bytes.UnreadableBytes != 0) @@ -328,13 +328,13 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.GolangPort.Components.Decoder } this.LastErrorCode = this.Bytes.FillUnsafe(this.InputStream); - if (this.LastErrorCode != OrigDecoderErrorCode.NoError) + if (this.LastErrorCode != GolangDecoderErrorCode.NoError) { return this.LastErrorCode; } } - return this.LastErrorCode = OrigDecoderErrorCode.NoError; + return this.LastErrorCode = GolangDecoderErrorCode.NoError; } /// @@ -374,8 +374,8 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.GolangPort.Components.Decoder /// /// Byte /// Read bits value - /// The - public OrigDecoderErrorCode ReceiveExtendUnsafe(int t, out int x) + /// The + public GolangDecoderErrorCode ReceiveExtendUnsafe(int t, out int x) { this.LastErrorCode = this.Bits.ReceiveExtendUnsafe(t, ref this, out x); return this.LastErrorCode; diff --git a/src/ImageSharp/Formats/Jpeg/GolangPort/GolangJpegDecoderCore.cs b/src/ImageSharp/Formats/Jpeg/GolangPort/GolangJpegDecoderCore.cs index 688e0afbf3..4f95240705 100644 --- a/src/ImageSharp/Formats/Jpeg/GolangPort/GolangJpegDecoderCore.cs +++ b/src/ImageSharp/Formats/Jpeg/GolangPort/GolangJpegDecoderCore.cs @@ -96,12 +96,12 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.GolangPort /// /// Gets the component array /// - public OrigComponent[] Components { get; private set; } + public GolangComponent[] Components { get; private set; } /// /// Gets the huffman trees /// - public OrigHuffmanTree[] HuffmanTrees { get; private set; } + public GolangHuffmanTree[] HuffmanTrees { get; private set; } /// public Block8x8F[] QuantizationTables { get; private set; } @@ -209,7 +209,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.GolangPort { if (this.Components != null) { - foreach (OrigComponent component in this.Components) + foreach (GolangComponent component in this.Components) { component?.Dispose(); } @@ -219,7 +219,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.GolangPort } /// - /// Read metadata from stream and read the blocks in the scans into . + /// Read metadata from stream and read the blocks in the scans into . /// /// The stream /// Whether to decode metadata only. @@ -231,7 +231,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.GolangPort if (!metadataOnly) { - this.HuffmanTrees = OrigHuffmanTree.CreateHuffmanTrees(); + this.HuffmanTrees = GolangHuffmanTree.CreateHuffmanTrees(); this.QuantizationTables = new Block8x8F[MaxTq + 1]; } @@ -680,12 +680,12 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.GolangPort if (!metadataOnly) { - this.Components = new OrigComponent[this.ComponentCount]; + this.Components = new GolangComponent[this.ComponentCount]; for (int i = 0; i < this.ComponentCount; i++) { byte componentIdentifier = this.Temp[6 + (3 * i)]; - var component = new OrigComponent(componentIdentifier, i); + var component = new GolangComponent(componentIdentifier, i); component.InitializeCoreData(this); this.Components[i] = component; } @@ -697,7 +697,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.GolangPort this.ColorSpace = this.DeduceJpegColorSpace(); - foreach (OrigComponent component in this.Components) + foreach (GolangComponent component in this.Components) { component.InitializeDerivedData(this.configuration.MemoryManager, this); } @@ -721,18 +721,18 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.GolangPort this.InputProcessor.ReadFull(this.Temp, 0, 17); int tc = this.Temp[0] >> 4; - if (tc > OrigHuffmanTree.MaxTc) + if (tc > GolangHuffmanTree.MaxTc) { throw new ImageFormatException("Bad Tc value"); } int th = this.Temp[0] & 0x0f; - if (th > OrigHuffmanTree.MaxTh) + if (th > GolangHuffmanTree.MaxTh) { throw new ImageFormatException("Bad Th value"); } - int huffTreeIndex = (tc * OrigHuffmanTree.ThRowSize) + th; + int huffTreeIndex = (tc * GolangHuffmanTree.ThRowSize) + th; this.HuffmanTrees[huffTreeIndex].ProcessDefineHuffmanTablesMarkerLoop( ref this.InputProcessor, this.Temp, @@ -766,8 +766,8 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.GolangPort /// private void ProcessStartOfScanMarker(int remaining) { - var scan = default(OrigJpegScanDecoder); - OrigJpegScanDecoder.InitStreamReading(&scan, this, remaining); + var scan = default(GolangJpegScanDecoder); + GolangJpegScanDecoder.InitStreamReading(&scan, this, remaining); this.InputProcessor.Bits = default(Bits); scan.DecodeBlocks(this); } diff --git a/src/ImageSharp/Formats/Jpeg/GolangPort/JpegEncoderCore.cs b/src/ImageSharp/Formats/Jpeg/GolangPort/JpegEncoderCore.cs index 7d8a4bb5cb..df51e893d9 100644 --- a/src/ImageSharp/Formats/Jpeg/GolangPort/JpegEncoderCore.cs +++ b/src/ImageSharp/Formats/Jpeg/GolangPort/JpegEncoderCore.cs @@ -101,11 +101,6 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.GolangPort } }; - /// - /// Lookup tables for converting Rgb to YCbCr - /// - private static RgbToYCbCrTables rgbToYCbCrTables = RgbToYCbCrTables.Create(); - /// /// A scratch buffer to reduce allocations. /// diff --git a/tests/ImageSharp.Tests/Formats/Jpg/ParseStreamTests.cs b/tests/ImageSharp.Tests/Formats/Jpg/ParseStreamTests.cs index f5ca5076ae..270f313a61 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/ParseStreamTests.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/ParseStreamTests.cs @@ -52,7 +52,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg Assert.Equal(expectedSizeInBlocks, decoder.ImageSizeInMCU); var uniform1 = new Size(1, 1); - OrigComponent c0 = decoder.Components[0]; + GolangComponent c0 = decoder.Components[0]; VerifyJpeg.VerifyComponent(c0, expectedSizeInBlocks, uniform1, uniform1); } } @@ -72,8 +72,8 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg { sb.AppendLine(imageFile); sb.AppendLine($"Size:{decoder.ImageSizeInPixels} MCU:{decoder.ImageSizeInMCU}"); - OrigComponent c0 = decoder.Components[0]; - OrigComponent c1 = decoder.Components[1]; + GolangComponent c0 = decoder.Components[0]; + GolangComponent c1 = decoder.Components[1]; sb.AppendLine($"Luma: SAMP: {c0.SamplingFactors} BLOCKS: {c0.SizeInBlocks}"); sb.AppendLine($"Chroma: {c1.SamplingFactors} BLOCKS: {c1.SizeInBlocks}"); @@ -108,9 +108,9 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg Assert.Equal(componentCount, decoder.ComponentCount); Assert.Equal(componentCount, decoder.Components.Length); - OrigComponent c0 = decoder.Components[0]; - OrigComponent c1 = decoder.Components[1]; - OrigComponent c2 = decoder.Components[2]; + GolangComponent c0 = decoder.Components[0]; + GolangComponent c1 = decoder.Components[1]; + GolangComponent c2 = decoder.Components[2]; var uniform1 = new Size(1, 1); @@ -126,7 +126,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg if (componentCount == 4) { - OrigComponent c3 = decoder.Components[2]; + GolangComponent c3 = decoder.Components[2]; VerifyJpeg.VerifyComponent(c3, expectedLumaSizeInBlocks, fLuma, uniform1); } } diff --git a/tests/ImageSharp.Tests/Formats/Jpg/Utils/LibJpegTools.ComponentData.cs b/tests/ImageSharp.Tests/Formats/Jpg/Utils/LibJpegTools.ComponentData.cs index 45df1d0fc4..9569b47655 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/Utils/LibJpegTools.ComponentData.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/Utils/LibJpegTools.ComponentData.cs @@ -77,7 +77,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils return result; } - public static ComponentData Load(OrigComponent c) + public static ComponentData Load(GolangComponent c) { var result = new ComponentData( c.SizeInBlocks.Width, diff --git a/tests/ImageSharp.Tests/Formats/Jpg/Utils/LibJpegTools.SpectralData.cs b/tests/ImageSharp.Tests/Formats/Jpg/Utils/LibJpegTools.SpectralData.cs index 8aa10a96c3..4285950f8e 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/Utils/LibJpegTools.SpectralData.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/Utils/LibJpegTools.SpectralData.cs @@ -39,7 +39,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils public static SpectralData LoadFromImageSharpDecoder(GolangJpegDecoderCore decoder) { - OrigComponent[] srcComponents = decoder.Components; + GolangComponent[] srcComponents = decoder.Components; LibJpegTools.ComponentData[] destComponents = srcComponents.Select(LibJpegTools.ComponentData.Load).ToArray(); return new SpectralData(destComponents);