diff --git a/src/ImageSharp.Formats.Jpeg/Components/Decoder/JpegScanDecoder.ComputationData.cs b/src/ImageSharp.Formats.Jpeg/Components/Decoder/JpegScanDecoder.ComputationData.cs new file mode 100644 index 000000000..ef04bf418 --- /dev/null +++ b/src/ImageSharp.Formats.Jpeg/Components/Decoder/JpegScanDecoder.ComputationData.cs @@ -0,0 +1,68 @@ +// +// Copyright (c) James Jackson-South and contributors. +// Licensed under the Apache License, Version 2.0. +// + +namespace ImageSharp.Formats.Jpg +{ + using System.Runtime.InteropServices; + + /// + /// Conains the definition of + /// + internal unsafe partial struct JpegScanDecoder + { + /// + /// Holds the "large" data blocks needed for computations + /// + [StructLayout(LayoutKind.Sequential)] + public struct ComputationData + { + /// + /// The main input/working block + /// + public Block8x8F Block; + + /// + /// Temporal block 1 to store intermediate and/or final computation results + /// + public Block8x8F Temp1; + + /// + /// Temporal block 2 to store intermediate and/or final computation results + /// + public Block8x8F Temp2; + + /// + /// The quantization table as + /// + public Block8x8F QuantiazationTable; + + /// + /// The jpeg unzig data + /// + public UnzigData Unzig; + + /// + /// The no-idea-what's this data + /// + public fixed byte ScanData[3 * JpegDecoderCore.MaxComponents]; + + /// + /// The DC component values + /// + public fixed int Dc[JpegDecoderCore.MaxComponents]; + + /// + /// Creates and initializes a new instance + /// + /// The + public static ComputationData Create() + { + ComputationData data = default(ComputationData); + data.Unzig = UnzigData.Create(); + return data; + } + } + } +} \ No newline at end of file diff --git a/src/ImageSharp.Formats.Jpeg/Components/Decoder/JpegScanDecoder.DataPointers.cs b/src/ImageSharp.Formats.Jpeg/Components/Decoder/JpegScanDecoder.DataPointers.cs new file mode 100644 index 000000000..b76ad59bb --- /dev/null +++ b/src/ImageSharp.Formats.Jpeg/Components/Decoder/JpegScanDecoder.DataPointers.cs @@ -0,0 +1,69 @@ +// +// Copyright (c) James Jackson-South and contributors. +// Licensed under the Apache License, Version 2.0. +// + +namespace ImageSharp.Formats.Jpg +{ + /// + /// Conains the definition of + /// + internal unsafe partial struct JpegScanDecoder + { + /// + /// Contains pointers to the memory regions of so they can be easily passed around to pointer based utility methods of + /// + public struct DataPointers + { + /// + /// Pointer to + /// + public Block8x8F* Block; + + /// + /// Pointer to + /// + public Block8x8F* Temp1; + + /// + /// Pointer to + /// + public Block8x8F* Temp2; + + /// + /// Pointer to + /// + public Block8x8F* QuantiazationTable; + + /// + /// Pointer to as int* + /// + public int* Unzig; + + /// + /// Pointer to as Scan* + /// + public ComponentScan* ComponentScan; + + /// + /// Pointer to + /// + public int* Dc; + + /// + /// Initializes a new instance of the struct. + /// + /// The pointer pointing to + public DataPointers(ComputationData* basePtr) + { + this.Block = &basePtr->Block; + this.Temp1 = &basePtr->Temp1; + this.Temp2 = &basePtr->Temp2; + this.QuantiazationTable = &basePtr->QuantiazationTable; + this.Unzig = basePtr->Unzig.Data; + this.ComponentScan = (ComponentScan*)basePtr->ScanData; + this.Dc = basePtr->Dc; + } + } + } +} \ No newline at end of file diff --git a/src/ImageSharp.Formats.Jpeg/Components/Decoder/JpegScanDecoder.cs b/src/ImageSharp.Formats.Jpeg/Components/Decoder/JpegScanDecoder.cs index 0d588cdda..9fef5010d 100644 --- a/src/ImageSharp.Formats.Jpeg/Components/Decoder/JpegScanDecoder.cs +++ b/src/ImageSharp.Formats.Jpeg/Components/Decoder/JpegScanDecoder.cs @@ -8,13 +8,12 @@ namespace ImageSharp.Formats.Jpg { using System; using System.Runtime.CompilerServices; - using System.Runtime.InteropServices; /// /// Encapsulates the impementation of Jpeg SOS decoder. /// See JpegScanDecoder.md! /// - internal unsafe struct JpegScanDecoder + internal unsafe partial struct JpegScanDecoder { /// /// The AC table index @@ -411,6 +410,11 @@ namespace ImageSharp.Formats.Jpg destArea.LoadColorsFrom(this.pointers.Temp1, this.pointers.Temp2); } + /// + /// Gets the block index used to retieve blocks from in + /// + /// The instance + /// The index private int GetBlockIndex(JpegDecoderCore decoder) { return ((this.@by * decoder.MCUCountX) * this.hi) + this.bx; @@ -623,114 +627,5 @@ namespace ImageSharp.Formats.Jpg return zig; } - - /// - /// Holds the "large" data blocks needed for computations - /// - [StructLayout(LayoutKind.Sequential)] - public struct ComputationData - { - /// - /// The main input block - /// - public Block8x8F Block; - - /// - /// Temporal block 1 to store intermediate and/or final computation results - /// - public Block8x8F Temp1; - - /// - /// Temporal block 2 to store intermediate and/or final computation results - /// - public Block8x8F Temp2; - - /// - /// The quantization table as - /// - public Block8x8F QuantiazationTable; - - /// - /// The jpeg unzig data - /// - public UnzigData Unzig; - - /// - /// The no-idea-what's this data - /// - public fixed byte ScanData[3 * JpegDecoderCore.MaxComponents]; - - /// - /// The DC component values - /// - public fixed int Dc[JpegDecoderCore.MaxComponents]; - - /// - /// Creates and initializes a new instance - /// - /// The - public static ComputationData Create() - { - ComputationData data = default(ComputationData); - data.Unzig = UnzigData.Create(); - return data; - } - } - - /// - /// Contains pointers to the memory regions of so they can be easily passed around to pointer based utility methods of - /// - public struct DataPointers - { - /// - /// Pointer to - /// - public Block8x8F* Block; - - /// - /// Pointer to - /// - public Block8x8F* Temp1; - - /// - /// Pointer to - /// - public Block8x8F* Temp2; - - /// - /// Pointer to - /// - public Block8x8F* QuantiazationTable; - - /// - /// Pointer to as int* - /// - public int* Unzig; - - /// - /// Pointer to as Scan* - /// - public ComponentScan* ComponentScan; - - /// - /// Pointer to - /// - public int* Dc; - - /// - /// Initializes a new instance of the struct. - /// - /// The pointer pointing to - public DataPointers(ComputationData* basePtr) - { - this.Block = &basePtr->Block; - this.Temp1 = &basePtr->Temp1; - this.Temp2 = &basePtr->Temp2; - this.QuantiazationTable = &basePtr->QuantiazationTable; - this.Unzig = basePtr->Unzig.Data; - this.ComponentScan = (ComponentScan*)basePtr->ScanData; - this.Dc = basePtr->Dc; - } - } } } \ No newline at end of file