diff --git a/src/ImageSharp/Formats/Jpeg/Port/Components/Adobe.cs b/src/ImageSharp/Formats/Jpeg/PdfJsPort/Components/PdfJsAdobe.cs
similarity index 89%
rename from src/ImageSharp/Formats/Jpeg/Port/Components/Adobe.cs
rename to src/ImageSharp/Formats/Jpeg/PdfJsPort/Components/PdfJsAdobe.cs
index 6ef128ccb4..542272044b 100644
--- a/src/ImageSharp/Formats/Jpeg/Port/Components/Adobe.cs
+++ b/src/ImageSharp/Formats/Jpeg/PdfJsPort/Components/PdfJsAdobe.cs
@@ -4,14 +4,14 @@
//
// ReSharper disable InconsistentNaming
-namespace ImageSharp.Formats.Jpeg.Port.Components
+namespace ImageSharp.Formats.Jpeg.PdfJsPort.Components
{
using System;
///
/// Provides information about the Adobe marker segment
///
- internal struct Adobe : IEquatable
+ internal struct PdfJsAdobe : IEquatable
{
///
/// The DCT Encode Version
@@ -38,7 +38,7 @@ namespace ImageSharp.Formats.Jpeg.Port.Components
public byte ColorTransform;
///
- public bool Equals(Adobe other)
+ public bool Equals(PdfJsAdobe other)
{
return this.DCTEncodeVersion == other.DCTEncodeVersion
&& this.APP14Flags0 == other.APP14Flags0
@@ -54,7 +54,7 @@ namespace ImageSharp.Formats.Jpeg.Port.Components
return false;
}
- return obj is Adobe && this.Equals((Adobe)obj);
+ return obj is PdfJsAdobe && this.Equals((PdfJsAdobe)obj);
}
///
diff --git a/src/ImageSharp/Formats/Jpeg/Port/Components/Component.cs b/src/ImageSharp/Formats/Jpeg/PdfJsPort/Components/PdfJsComponent.cs
similarity index 90%
rename from src/ImageSharp/Formats/Jpeg/Port/Components/Component.cs
rename to src/ImageSharp/Formats/Jpeg/PdfJsPort/Components/PdfJsComponent.cs
index a21cb66207..12e11a86e7 100644
--- a/src/ImageSharp/Formats/Jpeg/Port/Components/Component.cs
+++ b/src/ImageSharp/Formats/Jpeg/PdfJsPort/Components/PdfJsComponent.cs
@@ -3,7 +3,7 @@
// Licensed under the Apache License, Version 2.0.
//
-namespace ImageSharp.Formats.Jpeg.Port.Components
+namespace ImageSharp.Formats.Jpeg.PdfJsPort.Components
{
using System;
using System.Numerics;
@@ -12,7 +12,7 @@ namespace ImageSharp.Formats.Jpeg.Port.Components
///
/// Represents a component block
///
- internal struct Component : IDisposable
+ internal struct PdfJsComponent : IDisposable
{
///
/// Gets or sets the output
diff --git a/src/ImageSharp/Formats/Jpeg/Port/Components/ComponentBlocks.cs b/src/ImageSharp/Formats/Jpeg/PdfJsPort/Components/PdfJsComponentBlocks.cs
similarity index 87%
rename from src/ImageSharp/Formats/Jpeg/Port/Components/ComponentBlocks.cs
rename to src/ImageSharp/Formats/Jpeg/PdfJsPort/Components/PdfJsComponentBlocks.cs
index a72835e757..a69f5a7664 100644
--- a/src/ImageSharp/Formats/Jpeg/Port/Components/ComponentBlocks.cs
+++ b/src/ImageSharp/Formats/Jpeg/PdfJsPort/Components/PdfJsComponentBlocks.cs
@@ -3,7 +3,7 @@
// Licensed under the Apache License, Version 2.0.
//
-namespace ImageSharp.Formats.Jpeg.Port.Components
+namespace ImageSharp.Formats.Jpeg.PdfJsPort.Components
{
using System;
@@ -15,7 +15,7 @@ namespace ImageSharp.Formats.Jpeg.Port.Components
///
/// Gets or sets the component blocks
///
- public Component[] Components { get; set; }
+ public PdfJsComponent[] Components { get; set; }
///
public void Dispose()
diff --git a/src/ImageSharp/Formats/Jpeg/Port/Components/FileMarker.cs b/src/ImageSharp/Formats/Jpeg/PdfJsPort/Components/PdfJsFileMarker.cs
similarity index 79%
rename from src/ImageSharp/Formats/Jpeg/Port/Components/FileMarker.cs
rename to src/ImageSharp/Formats/Jpeg/PdfJsPort/Components/PdfJsFileMarker.cs
index eaf3dafb95..5e2555a9b7 100644
--- a/src/ImageSharp/Formats/Jpeg/Port/Components/FileMarker.cs
+++ b/src/ImageSharp/Formats/Jpeg/PdfJsPort/Components/PdfJsFileMarker.cs
@@ -3,19 +3,19 @@
// Licensed under the Apache License, Version 2.0.
//
-namespace ImageSharp.Formats.Jpeg.Port.Components
+namespace ImageSharp.Formats.Jpeg.PdfJsPort.Components
{
///
/// Represents a jpeg file marker
///
- internal struct FileMarker
+ internal struct PdfJsFileMarker
{
///
- /// Initializes a new instance of the struct.
+ /// Initializes a new instance of the struct.
///
/// The marker
/// The position within the stream
- public FileMarker(ushort marker, long position)
+ public PdfJsFileMarker(ushort marker, long position)
{
this.Marker = marker;
this.Position = position;
@@ -23,12 +23,12 @@ namespace ImageSharp.Formats.Jpeg.Port.Components
}
///
- /// Initializes a new instance of the struct.
+ /// Initializes a new instance of the struct.
///
/// The marker
/// The position within the stream
/// Whether the current marker is invalid
- public FileMarker(ushort marker, long position, bool invalid)
+ public PdfJsFileMarker(ushort marker, long position, bool invalid)
{
this.Marker = marker;
this.Position = position;
diff --git a/src/ImageSharp/Formats/Jpeg/Port/Components/Frame.cs b/src/ImageSharp/Formats/Jpeg/PdfJsPort/Components/PdfJsFrame.cs
similarity index 93%
rename from src/ImageSharp/Formats/Jpeg/Port/Components/Frame.cs
rename to src/ImageSharp/Formats/Jpeg/PdfJsPort/Components/PdfJsFrame.cs
index 06b4bbc24f..ff25ee154a 100644
--- a/src/ImageSharp/Formats/Jpeg/Port/Components/Frame.cs
+++ b/src/ImageSharp/Formats/Jpeg/PdfJsPort/Components/PdfJsFrame.cs
@@ -3,14 +3,14 @@
// Licensed under the Apache License, Version 2.0.
//
-namespace ImageSharp.Formats.Jpeg.Port.Components
+namespace ImageSharp.Formats.Jpeg.PdfJsPort.Components
{
using System;
///
/// Represent a single jpeg frame
///
- internal sealed class Frame : IDisposable
+ internal sealed class PdfJsFrame : IDisposable
{
///
/// Gets or sets a value indicating whether the frame uses the extended specification
@@ -50,7 +50,7 @@ namespace ImageSharp.Formats.Jpeg.Port.Components
///
/// Gets or sets the frame component collection
///
- public FrameComponent[] Components { get; set; }
+ public PdfJsFrameComponent[] Components { get; set; }
///
/// Gets or sets the maximum horizontal sampling factor
diff --git a/src/ImageSharp/Formats/Jpeg/Port/Components/FrameComponent.cs b/src/ImageSharp/Formats/Jpeg/PdfJsPort/Components/PdfJsFrameComponent.cs
similarity index 94%
rename from src/ImageSharp/Formats/Jpeg/Port/Components/FrameComponent.cs
rename to src/ImageSharp/Formats/Jpeg/PdfJsPort/Components/PdfJsFrameComponent.cs
index b386a86f3c..b999d86f19 100644
--- a/src/ImageSharp/Formats/Jpeg/Port/Components/FrameComponent.cs
+++ b/src/ImageSharp/Formats/Jpeg/PdfJsPort/Components/PdfJsFrameComponent.cs
@@ -3,7 +3,7 @@
// Licensed under the Apache License, Version 2.0.
//
-namespace ImageSharp.Formats.Jpeg.Port.Components
+namespace ImageSharp.Formats.Jpeg.PdfJsPort.Components
{
using System;
@@ -12,7 +12,7 @@ namespace ImageSharp.Formats.Jpeg.Port.Components
///
/// Represents a single frame component
///
- internal struct FrameComponent : IDisposable
+ internal struct PdfJsFrameComponent : IDisposable
{
///
/// Gets or sets the component Id
diff --git a/src/ImageSharp/Formats/Jpeg/Port/Components/HuffmanTable.cs b/src/ImageSharp/Formats/Jpeg/PdfJsPort/Components/PdfJsHuffmanTable.cs
similarity index 96%
rename from src/ImageSharp/Formats/Jpeg/Port/Components/HuffmanTable.cs
rename to src/ImageSharp/Formats/Jpeg/PdfJsPort/Components/PdfJsHuffmanTable.cs
index 4c475450bd..745dc63619 100644
--- a/src/ImageSharp/Formats/Jpeg/Port/Components/HuffmanTable.cs
+++ b/src/ImageSharp/Formats/Jpeg/PdfJsPort/Components/PdfJsHuffmanTable.cs
@@ -3,7 +3,7 @@
// Licensed under the Apache License, Version 2.0.
//
-namespace ImageSharp.Formats.Jpeg.Port.Components
+namespace ImageSharp.Formats.Jpeg.PdfJsPort.Components
{
using System;
using System.Runtime.CompilerServices;
@@ -13,7 +13,7 @@ namespace ImageSharp.Formats.Jpeg.Port.Components
///
/// Represents a Huffman Table
///
- internal struct HuffmanTable : IDisposable
+ internal struct PdfJsHuffmanTable : IDisposable
{
private Buffer lookahead;
private Buffer valOffset;
@@ -21,11 +21,11 @@ namespace ImageSharp.Formats.Jpeg.Port.Components
private Buffer huffval;
///
- /// Initializes a new instance of the struct.
+ /// Initializes a new instance of the struct.
///
/// The code lengths
/// The huffman values
- public HuffmanTable(byte[] lengths, byte[] values)
+ public PdfJsHuffmanTable(byte[] lengths, byte[] values)
{
this.lookahead = Buffer.CreateClean(256);
this.valOffset = Buffer.CreateClean(18);
diff --git a/src/ImageSharp/Formats/Jpeg/Port/Components/HuffmanTables.cs b/src/ImageSharp/Formats/Jpeg/PdfJsPort/Components/PdfJsHuffmanTables.cs
similarity index 79%
rename from src/ImageSharp/Formats/Jpeg/Port/Components/HuffmanTables.cs
rename to src/ImageSharp/Formats/Jpeg/PdfJsPort/Components/PdfJsHuffmanTables.cs
index d076c0b038..5d00fe7f6f 100644
--- a/src/ImageSharp/Formats/Jpeg/Port/Components/HuffmanTables.cs
+++ b/src/ImageSharp/Formats/Jpeg/PdfJsPort/Components/PdfJsHuffmanTables.cs
@@ -3,7 +3,7 @@
// Licensed under the Apache License, Version 2.0.
//
-namespace ImageSharp.Formats.Jpeg.Port.Components
+namespace ImageSharp.Formats.Jpeg.PdfJsPort.Components
{
using System;
using System.Collections.Generic;
@@ -12,16 +12,16 @@ namespace ImageSharp.Formats.Jpeg.Port.Components
///
/// Defines a pair of huffman tables
///
- internal sealed class HuffmanTables : IDisposable
+ internal sealed class PdfJsHuffmanTables : IDisposable
{
- private readonly HuffmanTable[] tables = new HuffmanTable[4];
+ private readonly PdfJsHuffmanTable[] tables = new PdfJsHuffmanTable[4];
///
/// Gets or sets the table at the given index.
///
/// The index
/// The
- public ref HuffmanTable this[int index]
+ public ref PdfJsHuffmanTable this[int index]
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get
diff --git a/src/ImageSharp/Formats/Jpeg/Port/Components/IDCT.cs b/src/ImageSharp/Formats/Jpeg/PdfJsPort/Components/PdfJsIDCT.cs
similarity index 97%
rename from src/ImageSharp/Formats/Jpeg/Port/Components/IDCT.cs
rename to src/ImageSharp/Formats/Jpeg/PdfJsPort/Components/PdfJsIDCT.cs
index 064b3bea36..c509d43577 100644
--- a/src/ImageSharp/Formats/Jpeg/Port/Components/IDCT.cs
+++ b/src/ImageSharp/Formats/Jpeg/PdfJsPort/Components/PdfJsIDCT.cs
@@ -1,4 +1,4 @@
-namespace ImageSharp.Formats.Jpeg.Port.Components
+namespace ImageSharp.Formats.Jpeg.PdfJsPort.Components
{
using System;
using System.Runtime.CompilerServices;
@@ -8,7 +8,7 @@
///
/// Performs the inverse Descrete Cosine Transform on each frame component.
///
- internal static class IDCT
+ internal static class PdfJsIDCT
{
///
/// Precomputed values scaled up by 14 bits
@@ -61,7 +61,7 @@
private static readonly byte[] Limit = new byte[5 * (MaxJSample + 1)];
- static IDCT()
+ static PdfJsIDCT()
{
// Main part of range limit table: limit[x] = x
int i;
@@ -87,7 +87,7 @@
/// The block buffer offset
/// The computational buffer for holding temp values
/// The quantization table
- public static void QuantizeAndInverse(ref FrameComponent component, int blockBufferOffset, ref Span computationBuffer, ref Span quantizationTable)
+ public static void QuantizeAndInverse(ref PdfJsFrameComponent component, int blockBufferOffset, ref Span computationBuffer, ref Span quantizationTable)
{
Span blockData = component.BlockData.Slice(blockBufferOffset);
int v0, v1, v2, v3, v4, v5, v6, v7;
@@ -306,7 +306,7 @@
/// The block buffer offset
/// The computational buffer for holding temp values
/// The multiplier table
- public static void QuantizeAndInverseFast(ref FrameComponent component, int blockBufferOffset, ref Span computationBuffer, ref Span multiplierTable)
+ public static void QuantizeAndInverseFast(ref PdfJsFrameComponent component, int blockBufferOffset, ref Span computationBuffer, ref Span multiplierTable)
{
Span blockData = component.BlockData.Slice(blockBufferOffset);
int p0, p1, p2, p3, p4, p5, p6, p7;
diff --git a/src/ImageSharp/Formats/Jpeg/Port/Components/JFif.cs b/src/ImageSharp/Formats/Jpeg/PdfJsPort/Components/PdfJsJFif.cs
similarity index 90%
rename from src/ImageSharp/Formats/Jpeg/Port/Components/JFif.cs
rename to src/ImageSharp/Formats/Jpeg/PdfJsPort/Components/PdfJsJFif.cs
index 6baecdf682..3c7cba9892 100644
--- a/src/ImageSharp/Formats/Jpeg/Port/Components/JFif.cs
+++ b/src/ImageSharp/Formats/Jpeg/PdfJsPort/Components/PdfJsJFif.cs
@@ -3,7 +3,7 @@
// Licensed under the Apache License, Version 2.0.
//
-namespace ImageSharp.Formats.Jpeg.Port.Components
+namespace ImageSharp.Formats.Jpeg.PdfJsPort.Components
{
using System;
@@ -11,7 +11,7 @@ namespace ImageSharp.Formats.Jpeg.Port.Components
/// Provides information about the JFIF marker segment
/// TODO: Thumbnail?
///
- internal struct JFif : IEquatable
+ internal struct PdfJsJFif : IEquatable
{
///
/// The major version
@@ -42,7 +42,7 @@ namespace ImageSharp.Formats.Jpeg.Port.Components
public short YDensity;
///
- public bool Equals(JFif other)
+ public bool Equals(PdfJsJFif other)
{
return this.MajorVersion == other.MajorVersion
&& this.MinorVersion == other.MinorVersion
@@ -59,7 +59,7 @@ namespace ImageSharp.Formats.Jpeg.Port.Components
return false;
}
- return obj is JFif && this.Equals((JFif)obj);
+ return obj is PdfJsJFif && this.Equals((PdfJsJFif)obj);
}
///
diff --git a/src/ImageSharp/Formats/Jpeg/Port/Components/JpegPixelArea.cs b/src/ImageSharp/Formats/Jpeg/PdfJsPort/Components/PdfJsJpegPixelArea.cs
similarity index 93%
rename from src/ImageSharp/Formats/Jpeg/Port/Components/JpegPixelArea.cs
rename to src/ImageSharp/Formats/Jpeg/PdfJsPort/Components/PdfJsJpegPixelArea.cs
index e88e396170..e39564e9a0 100644
--- a/src/ImageSharp/Formats/Jpeg/Port/Components/JpegPixelArea.cs
+++ b/src/ImageSharp/Formats/Jpeg/PdfJsPort/Components/PdfJsJpegPixelArea.cs
@@ -3,7 +3,7 @@
// Licensed under the Apache License, Version 2.0.
//
-namespace ImageSharp.Formats.Jpeg.Port.Components
+namespace ImageSharp.Formats.Jpeg.PdfJsPort.Components
{
using System;
using System.Diagnostics;
@@ -14,7 +14,7 @@ namespace ImageSharp.Formats.Jpeg.Port.Components
///
/// Represents a section of the jpeg component data laid out in pixel order.
///
- internal struct JpegPixelArea : IDisposable
+ internal struct PdfJsJpegPixelArea : IDisposable
{
private readonly int imageWidth;
@@ -25,12 +25,12 @@ namespace ImageSharp.Formats.Jpeg.Port.Components
private int rowStride;
///
- /// Initializes a new instance of the struct.
+ /// Initializes a new instance of the struct.
///
/// The image width
/// The image height
/// The number of components
- public JpegPixelArea(int imageWidth, int imageHeight, int numberOfComponents)
+ public PdfJsJpegPixelArea(int imageWidth, int imageHeight, int numberOfComponents)
{
this.imageWidth = imageWidth;
this.imageHeight = imageHeight;
@@ -80,7 +80,7 @@ namespace ImageSharp.Formats.Jpeg.Port.Components
Span xScaleBlockOffsetSpan = xScaleBlockOffset;
for (int i = 0; i < numberOfComponents; i++)
{
- ref Component component = ref components.Components[i];
+ ref PdfJsComponent component = ref components.Components[i];
Vector2 componentScale = component.Scale * scale;
int offset = i;
Span output = component.Output;
diff --git a/src/ImageSharp/Formats/Jpeg/Port/Components/QuantizationTables.cs b/src/ImageSharp/Formats/Jpeg/PdfJsPort/Components/PdfJsQuantizationTables.cs
similarity index 93%
rename from src/ImageSharp/Formats/Jpeg/Port/Components/QuantizationTables.cs
rename to src/ImageSharp/Formats/Jpeg/PdfJsPort/Components/PdfJsQuantizationTables.cs
index 352dc43f23..996752ba33 100644
--- a/src/ImageSharp/Formats/Jpeg/Port/Components/QuantizationTables.cs
+++ b/src/ImageSharp/Formats/Jpeg/PdfJsPort/Components/PdfJsQuantizationTables.cs
@@ -3,7 +3,7 @@
// Licensed under the Apache License, Version 2.0.
//
-namespace ImageSharp.Formats.Jpeg.Port.Components
+namespace ImageSharp.Formats.Jpeg.PdfJsPort.Components
{
using System;
using System.Runtime.CompilerServices;
@@ -13,7 +13,7 @@ namespace ImageSharp.Formats.Jpeg.Port.Components
///
/// Contains the quantization tables.
///
- internal sealed class QuantizationTables : IDisposable
+ internal sealed class PdfJsQuantizationTables : IDisposable
{
///
/// Gets the ZigZag scan table
diff --git a/src/ImageSharp/Formats/Jpeg/Port/Components/ScanDecoder.cs b/src/ImageSharp/Formats/Jpeg/PdfJsPort/Components/PdfJsScanDecoder.cs
similarity index 84%
rename from src/ImageSharp/Formats/Jpeg/Port/Components/ScanDecoder.cs
rename to src/ImageSharp/Formats/Jpeg/PdfJsPort/Components/PdfJsScanDecoder.cs
index 8b711eaa89..c250db4c4a 100644
--- a/src/ImageSharp/Formats/Jpeg/Port/Components/ScanDecoder.cs
+++ b/src/ImageSharp/Formats/Jpeg/PdfJsPort/Components/PdfJsScanDecoder.cs
@@ -3,7 +3,7 @@
// Licensed under the Apache License, Version 2.0.
//
-namespace ImageSharp.Formats.Jpeg.Port.Components
+namespace ImageSharp.Formats.Jpeg.PdfJsPort.Components
{
using System;
#if DEBUG
@@ -15,7 +15,7 @@ namespace ImageSharp.Formats.Jpeg.Port.Components
///
/// Provides the means to decode a spectral scan
///
- internal struct ScanDecoder
+ internal struct PdfJsScanDecoder
{
private byte[] markerBuffer;
@@ -63,11 +63,11 @@ namespace ImageSharp.Formats.Jpeg.Port.Components
/// The successive approximation bit high end
/// The successive approximation bit low end
public void DecodeScan(
- Frame frame,
+ PdfJsFrame frame,
Stream stream,
- HuffmanTables dcHuffmanTables,
- HuffmanTables acHuffmanTables,
- FrameComponent[] components,
+ PdfJsHuffmanTables dcHuffmanTables,
+ PdfJsHuffmanTables acHuffmanTables,
+ PdfJsFrameComponent[] components,
int componentIndex,
int componentsLength,
ushort resetInterval,
@@ -98,14 +98,14 @@ namespace ImageSharp.Formats.Jpeg.Port.Components
mcuExpected = mcusPerLine * frame.McusPerColumn;
}
- FileMarker fileMarker;
+ PdfJsFileMarker fileMarker;
while (mcu < mcuExpected)
{
// Reset interval stuff
int mcuToRead = resetInterval != 0 ? Math.Min(mcuExpected - mcu, resetInterval) : mcuExpected;
for (int i = 0; i < components.Length; i++)
{
- ref FrameComponent c = ref components[i];
+ ref PdfJsFrameComponent c = ref components[i];
c.Pred = 0;
}
@@ -145,7 +145,7 @@ namespace ImageSharp.Formats.Jpeg.Port.Components
this.bitsCount = 0;
this.accumulator = 0;
this.bitsUnRead = 0;
- fileMarker = JpegDecoderCore.FindNextFileMarker(this.markerBuffer, stream);
+ fileMarker = PdfJsJpegDecoderCore.FindNextFileMarker(this.markerBuffer, stream);
// Some bad images seem to pad Scan blocks with e.g. zero bytes, skip past
// those to attempt to find a valid marker (fixes issue4090.pdf) in original code.
@@ -159,7 +159,7 @@ namespace ImageSharp.Formats.Jpeg.Port.Components
ushort marker = fileMarker.Marker;
// RSTn - We've alread read the bytes and altered the position so no need to skip
- if (marker >= JpegConstants.Markers.RST0 && marker <= JpegConstants.Markers.RST7)
+ if (marker >= PdfJsJpegConstants.Markers.RST0 && marker <= PdfJsJpegConstants.Markers.RST7)
{
continue;
}
@@ -173,7 +173,7 @@ namespace ImageSharp.Formats.Jpeg.Port.Components
}
}
- fileMarker = JpegDecoderCore.FindNextFileMarker(this.markerBuffer, stream);
+ fileMarker = PdfJsJpegDecoderCore.FindNextFileMarker(this.markerBuffer, stream);
// Some images include more Scan blocks than expected, skip past those and
// attempt to find the next valid marker (fixes issue8182.pdf) in original code.
@@ -192,16 +192,16 @@ namespace ImageSharp.Formats.Jpeg.Port.Components
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- private static int GetBlockBufferOffset(FrameComponent component, int row, int col)
+ private static int GetBlockBufferOffset(PdfJsFrameComponent component, int row, int col)
{
return 64 * (((component.BlocksPerLine + 1) * row) + col);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private void DecodeScanBaseline(
- HuffmanTables dcHuffmanTables,
- HuffmanTables acHuffmanTables,
- FrameComponent[] components,
+ PdfJsHuffmanTables dcHuffmanTables,
+ PdfJsHuffmanTables acHuffmanTables,
+ PdfJsFrameComponent[] components,
int componentsLength,
int mcusPerLine,
int mcuToRead,
@@ -210,9 +210,9 @@ namespace ImageSharp.Formats.Jpeg.Port.Components
{
if (componentsLength == 1)
{
- ref FrameComponent component = ref components[this.compIndex];
- ref HuffmanTable dcHuffmanTable = ref dcHuffmanTables[component.DCHuffmanTableId];
- ref HuffmanTable acHuffmanTable = ref acHuffmanTables[component.ACHuffmanTableId];
+ ref PdfJsFrameComponent component = ref components[this.compIndex];
+ ref PdfJsHuffmanTable dcHuffmanTable = ref dcHuffmanTables[component.DCHuffmanTableId];
+ ref PdfJsHuffmanTable acHuffmanTable = ref acHuffmanTables[component.ACHuffmanTableId];
for (int n = 0; n < mcuToRead; n++)
{
@@ -231,9 +231,9 @@ namespace ImageSharp.Formats.Jpeg.Port.Components
{
for (int i = 0; i < componentsLength; i++)
{
- ref FrameComponent component = ref components[i];
- ref HuffmanTable dcHuffmanTable = ref dcHuffmanTables[component.DCHuffmanTableId];
- ref HuffmanTable acHuffmanTable = ref acHuffmanTables[component.ACHuffmanTableId];
+ ref PdfJsFrameComponent component = ref components[i];
+ ref PdfJsHuffmanTable dcHuffmanTable = ref dcHuffmanTables[component.DCHuffmanTableId];
+ ref PdfJsHuffmanTable acHuffmanTable = ref acHuffmanTables[component.ACHuffmanTableId];
int h = component.HorizontalFactor;
int v = component.VerticalFactor;
@@ -258,8 +258,8 @@ namespace ImageSharp.Formats.Jpeg.Port.Components
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private void DecodeScanDCFirst(
- HuffmanTables dcHuffmanTables,
- FrameComponent[] components,
+ PdfJsHuffmanTables dcHuffmanTables,
+ PdfJsFrameComponent[] components,
int componentsLength,
int mcusPerLine,
int mcuToRead,
@@ -268,8 +268,8 @@ namespace ImageSharp.Formats.Jpeg.Port.Components
{
if (componentsLength == 1)
{
- ref FrameComponent component = ref components[this.compIndex];
- ref HuffmanTable dcHuffmanTable = ref dcHuffmanTables[component.DCHuffmanTableId];
+ ref PdfJsFrameComponent component = ref components[this.compIndex];
+ ref PdfJsHuffmanTable dcHuffmanTable = ref dcHuffmanTables[component.DCHuffmanTableId];
for (int n = 0; n < mcuToRead; n++)
{
@@ -288,8 +288,8 @@ namespace ImageSharp.Formats.Jpeg.Port.Components
{
for (int i = 0; i < componentsLength; i++)
{
- ref FrameComponent component = ref components[i];
- ref HuffmanTable dcHuffmanTable = ref dcHuffmanTables[component.DCHuffmanTableId];
+ ref PdfJsFrameComponent component = ref components[i];
+ ref PdfJsHuffmanTable dcHuffmanTable = ref dcHuffmanTables[component.DCHuffmanTableId];
int h = component.HorizontalFactor;
int v = component.VerticalFactor;
@@ -314,7 +314,7 @@ namespace ImageSharp.Formats.Jpeg.Port.Components
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private void DecodeScanDCSuccessive(
- FrameComponent[] components,
+ PdfJsFrameComponent[] components,
int componentsLength,
int mcusPerLine,
int mcuToRead,
@@ -323,7 +323,7 @@ namespace ImageSharp.Formats.Jpeg.Port.Components
{
if (componentsLength == 1)
{
- ref FrameComponent component = ref components[this.compIndex];
+ ref PdfJsFrameComponent component = ref components[this.compIndex];
for (int n = 0; n < mcuToRead; n++)
{
if (this.endOfStreamReached || this.unexpectedMarkerReached)
@@ -341,7 +341,7 @@ namespace ImageSharp.Formats.Jpeg.Port.Components
{
for (int i = 0; i < componentsLength; i++)
{
- ref FrameComponent component = ref components[i];
+ ref PdfJsFrameComponent component = ref components[i];
int h = component.HorizontalFactor;
int v = component.VerticalFactor;
for (int j = 0; j < v; j++)
@@ -365,8 +365,8 @@ namespace ImageSharp.Formats.Jpeg.Port.Components
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private void DecodeScanACFirst(
- HuffmanTables acHuffmanTables,
- FrameComponent[] components,
+ PdfJsHuffmanTables acHuffmanTables,
+ PdfJsFrameComponent[] components,
int componentsLength,
int mcusPerLine,
int mcuToRead,
@@ -375,8 +375,8 @@ namespace ImageSharp.Formats.Jpeg.Port.Components
{
if (componentsLength == 1)
{
- ref FrameComponent component = ref components[this.compIndex];
- ref HuffmanTable acHuffmanTable = ref acHuffmanTables[component.ACHuffmanTableId];
+ ref PdfJsFrameComponent component = ref components[this.compIndex];
+ ref PdfJsHuffmanTable acHuffmanTable = ref acHuffmanTables[component.ACHuffmanTableId];
for (int n = 0; n < mcuToRead; n++)
{
@@ -395,8 +395,8 @@ namespace ImageSharp.Formats.Jpeg.Port.Components
{
for (int i = 0; i < componentsLength; i++)
{
- ref FrameComponent component = ref components[i];
- ref HuffmanTable acHuffmanTable = ref acHuffmanTables[component.ACHuffmanTableId];
+ ref PdfJsFrameComponent component = ref components[i];
+ ref PdfJsHuffmanTable acHuffmanTable = ref acHuffmanTables[component.ACHuffmanTableId];
int h = component.HorizontalFactor;
int v = component.VerticalFactor;
@@ -421,8 +421,8 @@ namespace ImageSharp.Formats.Jpeg.Port.Components
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private void DecodeScanACSuccessive(
- HuffmanTables acHuffmanTables,
- FrameComponent[] components,
+ PdfJsHuffmanTables acHuffmanTables,
+ PdfJsFrameComponent[] components,
int componentsLength,
int mcusPerLine,
int mcuToRead,
@@ -431,8 +431,8 @@ namespace ImageSharp.Formats.Jpeg.Port.Components
{
if (componentsLength == 1)
{
- ref FrameComponent component = ref components[this.compIndex];
- ref HuffmanTable acHuffmanTable = ref acHuffmanTables[component.ACHuffmanTableId];
+ ref PdfJsFrameComponent component = ref components[this.compIndex];
+ ref PdfJsHuffmanTable acHuffmanTable = ref acHuffmanTables[component.ACHuffmanTableId];
for (int n = 0; n < mcuToRead; n++)
{
@@ -451,8 +451,8 @@ namespace ImageSharp.Formats.Jpeg.Port.Components
{
for (int i = 0; i < componentsLength; i++)
{
- ref FrameComponent component = ref components[i];
- ref HuffmanTable acHuffmanTable = ref acHuffmanTables[component.ACHuffmanTableId];
+ ref PdfJsFrameComponent component = ref components[i];
+ ref PdfJsHuffmanTable acHuffmanTable = ref acHuffmanTables[component.ACHuffmanTableId];
int h = component.HorizontalFactor;
int v = component.VerticalFactor;
@@ -476,7 +476,7 @@ namespace ImageSharp.Formats.Jpeg.Port.Components
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- private void DecodeBlockBaseline(ref HuffmanTable dcHuffmanTable, ref HuffmanTable acHuffmanTable, ref FrameComponent component, int mcu, Stream stream)
+ private void DecodeBlockBaseline(ref PdfJsHuffmanTable dcHuffmanTable, ref PdfJsHuffmanTable acHuffmanTable, ref PdfJsFrameComponent component, int mcu, Stream stream)
{
int blockRow = mcu / component.BlocksPerLine;
int blockCol = mcu % component.BlocksPerLine;
@@ -485,7 +485,7 @@ namespace ImageSharp.Formats.Jpeg.Port.Components
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- private void DecodeMcuBaseline(ref HuffmanTable dcHuffmanTable, ref HuffmanTable acHuffmanTable, ref FrameComponent component, int mcusPerLine, int mcu, int row, int col, Stream stream)
+ private void DecodeMcuBaseline(ref PdfJsHuffmanTable dcHuffmanTable, ref PdfJsHuffmanTable acHuffmanTable, ref PdfJsFrameComponent component, int mcusPerLine, int mcu, int row, int col, Stream stream)
{
int mcuRow = mcu / mcusPerLine;
int mcuCol = mcu % mcusPerLine;
@@ -496,7 +496,7 @@ namespace ImageSharp.Formats.Jpeg.Port.Components
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- private void DecodeBlockDCFirst(ref HuffmanTable dcHuffmanTable, ref FrameComponent component, int mcu, Stream stream)
+ private void DecodeBlockDCFirst(ref PdfJsHuffmanTable dcHuffmanTable, ref PdfJsFrameComponent component, int mcu, Stream stream)
{
int blockRow = mcu / component.BlocksPerLine;
int blockCol = mcu % component.BlocksPerLine;
@@ -505,7 +505,7 @@ namespace ImageSharp.Formats.Jpeg.Port.Components
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- private void DecodeMcuDCFirst(ref HuffmanTable dcHuffmanTable, ref FrameComponent component, int mcusPerLine, int mcu, int row, int col, Stream stream)
+ private void DecodeMcuDCFirst(ref PdfJsHuffmanTable dcHuffmanTable, ref PdfJsFrameComponent component, int mcusPerLine, int mcu, int row, int col, Stream stream)
{
int mcuRow = mcu / mcusPerLine;
int mcuCol = mcu % mcusPerLine;
@@ -516,7 +516,7 @@ namespace ImageSharp.Formats.Jpeg.Port.Components
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- private void DecodeBlockDCSuccessive(ref FrameComponent component, int mcu, Stream stream)
+ private void DecodeBlockDCSuccessive(ref PdfJsFrameComponent component, int mcu, Stream stream)
{
int blockRow = mcu / component.BlocksPerLine;
int blockCol = mcu % component.BlocksPerLine;
@@ -525,7 +525,7 @@ namespace ImageSharp.Formats.Jpeg.Port.Components
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- private void DecodeMcuDCSuccessive(ref FrameComponent component, int mcusPerLine, int mcu, int row, int col, Stream stream)
+ private void DecodeMcuDCSuccessive(ref PdfJsFrameComponent component, int mcusPerLine, int mcu, int row, int col, Stream stream)
{
int mcuRow = mcu / mcusPerLine;
int mcuCol = mcu % mcusPerLine;
@@ -536,7 +536,7 @@ namespace ImageSharp.Formats.Jpeg.Port.Components
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- private void DecodeBlockACFirst(ref HuffmanTable acHuffmanTable, ref FrameComponent component, int mcu, Stream stream)
+ private void DecodeBlockACFirst(ref PdfJsHuffmanTable acHuffmanTable, ref PdfJsFrameComponent component, int mcu, Stream stream)
{
int blockRow = mcu / component.BlocksPerLine;
int blockCol = mcu % component.BlocksPerLine;
@@ -545,7 +545,7 @@ namespace ImageSharp.Formats.Jpeg.Port.Components
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- private void DecodeMcuACFirst(ref HuffmanTable acHuffmanTable, ref FrameComponent component, int mcusPerLine, int mcu, int row, int col, Stream stream)
+ private void DecodeMcuACFirst(ref PdfJsHuffmanTable acHuffmanTable, ref PdfJsFrameComponent component, int mcusPerLine, int mcu, int row, int col, Stream stream)
{
int mcuRow = mcu / mcusPerLine;
int mcuCol = mcu % mcusPerLine;
@@ -556,7 +556,7 @@ namespace ImageSharp.Formats.Jpeg.Port.Components
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- private void DecodeBlockACSuccessive(ref HuffmanTable acHuffmanTable, ref FrameComponent component, int mcu, Stream stream)
+ private void DecodeBlockACSuccessive(ref PdfJsHuffmanTable acHuffmanTable, ref PdfJsFrameComponent component, int mcu, Stream stream)
{
int blockRow = mcu / component.BlocksPerLine;
int blockCol = mcu % component.BlocksPerLine;
@@ -565,7 +565,7 @@ namespace ImageSharp.Formats.Jpeg.Port.Components
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- private void DecodeMcuACSuccessive(ref HuffmanTable acHuffmanTable, ref FrameComponent component, int mcusPerLine, int mcu, int row, int col, Stream stream)
+ private void DecodeMcuACSuccessive(ref PdfJsHuffmanTable acHuffmanTable, ref PdfJsFrameComponent component, int mcusPerLine, int mcu, int row, int col, Stream stream)
{
int mcuRow = mcu / mcusPerLine;
int mcuCol = mcu % mcusPerLine;
@@ -593,7 +593,7 @@ namespace ImageSharp.Formats.Jpeg.Port.Components
this.endOfStreamReached = true;
}
- if (this.bitsData == JpegConstants.Markers.Prefix)
+ if (this.bitsData == PdfJsJpegConstants.Markers.Prefix)
{
int nextByte = stream.ReadByte();
if (nextByte != 0)
@@ -616,7 +616,7 @@ namespace ImageSharp.Formats.Jpeg.Port.Components
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- private short DecodeHuffman(ref HuffmanTable tree, Stream stream)
+ private short DecodeHuffman(ref PdfJsHuffmanTable tree, Stream stream)
{
short code = -1;
@@ -715,7 +715,7 @@ namespace ImageSharp.Formats.Jpeg.Port.Components
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- private void DecodeBaseline(ref FrameComponent component, int offset, ref HuffmanTable dcHuffmanTable, ref HuffmanTable acHuffmanTable, Stream stream)
+ private void DecodeBaseline(ref PdfJsFrameComponent component, int offset, ref PdfJsHuffmanTable dcHuffmanTable, ref PdfJsHuffmanTable acHuffmanTable, Stream stream)
{
int t = this.DecodeHuffman(ref dcHuffmanTable, stream);
if (this.endOfStreamReached || this.unexpectedMarkerReached)
@@ -756,7 +756,7 @@ namespace ImageSharp.Formats.Jpeg.Port.Components
break;
}
- byte z = QuantizationTables.DctZigZag[k];
+ byte z = PdfJsQuantizationTables.DctZigZag[k];
short re = (short)this.ReceiveAndExtend(s, stream);
component.BlockData[offset + z] = re;
k++;
@@ -764,7 +764,7 @@ namespace ImageSharp.Formats.Jpeg.Port.Components
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- private void DecodeDCFirst(ref FrameComponent component, int offset, ref HuffmanTable dcHuffmanTable, Stream stream)
+ private void DecodeDCFirst(ref PdfJsFrameComponent component, int offset, ref PdfJsHuffmanTable dcHuffmanTable, Stream stream)
{
int t = this.DecodeHuffman(ref dcHuffmanTable, stream);
if (this.endOfStreamReached || this.unexpectedMarkerReached)
@@ -777,7 +777,7 @@ namespace ImageSharp.Formats.Jpeg.Port.Components
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- private void DecodeDCSuccessive(ref FrameComponent component, int offset, Stream stream)
+ private void DecodeDCSuccessive(ref PdfJsFrameComponent component, int offset, Stream stream)
{
int bit = this.ReadBit(stream);
if (this.endOfStreamReached || this.unexpectedMarkerReached)
@@ -789,7 +789,7 @@ namespace ImageSharp.Formats.Jpeg.Port.Components
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- private void DecodeACFirst(ref FrameComponent component, int offset, ref HuffmanTable acHuffmanTable, Stream stream)
+ private void DecodeACFirst(ref PdfJsFrameComponent component, int offset, ref PdfJsHuffmanTable acHuffmanTable, Stream stream)
{
if (this.eobrun > 0)
{
@@ -824,14 +824,14 @@ namespace ImageSharp.Formats.Jpeg.Port.Components
}
k += r;
- byte z = QuantizationTables.DctZigZag[k];
+ byte z = PdfJsQuantizationTables.DctZigZag[k];
componentBlockDataSpan[offset + z] = (short)(this.ReceiveAndExtend(s, stream) * (1 << this.successiveState));
k++;
}
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- private void DecodeACSuccessive(ref FrameComponent component, int offset, ref HuffmanTable acHuffmanTable, Stream stream)
+ private void DecodeACSuccessive(ref PdfJsFrameComponent component, int offset, ref PdfJsHuffmanTable acHuffmanTable, Stream stream)
{
int k = this.specStart;
int e = this.specEnd;
@@ -839,7 +839,7 @@ namespace ImageSharp.Formats.Jpeg.Port.Components
Span componentBlockDataSpan = component.BlockData.Span;
while (k <= e)
{
- byte z = QuantizationTables.DctZigZag[k];
+ byte z = PdfJsQuantizationTables.DctZigZag[k];
switch (this.successiveACState)
{
case 0: // Initial state
diff --git a/src/ImageSharp/Formats/Jpeg/Port/Components/YCbCrToRgbTables.cs b/src/ImageSharp/Formats/Jpeg/PdfJsPort/Components/PdfJsYCbCrToRgbTables.cs
similarity index 97%
rename from src/ImageSharp/Formats/Jpeg/Port/Components/YCbCrToRgbTables.cs
rename to src/ImageSharp/Formats/Jpeg/PdfJsPort/Components/PdfJsYCbCrToRgbTables.cs
index 02397e1d77..07c8f9830b 100644
--- a/src/ImageSharp/Formats/Jpeg/Port/Components/YCbCrToRgbTables.cs
+++ b/src/ImageSharp/Formats/Jpeg/PdfJsPort/Components/PdfJsYCbCrToRgbTables.cs
@@ -1,4 +1,4 @@
-namespace ImageSharp.Formats.Jpeg.Port.Components
+namespace ImageSharp.Formats.Jpeg.PdfJsPort.Components
{
using System.Runtime.CompilerServices;
using ImageSharp.PixelFormats;
@@ -7,7 +7,7 @@
/// Provides 8-bit lookup tables for converting from YCbCr to Rgb colorspace.
/// Methods to build the tables are based on libjpeg implementation.
///
- internal struct YCbCrToRgbTables
+ internal struct PdfJsYCbCrToRgbTables
{
///
/// The red red-chrominance table
diff --git a/src/ImageSharp/Formats/Jpeg/Port/JpegConstants.cs b/src/ImageSharp/Formats/Jpeg/PdfJsPort/PdfJsJpegConstants.cs
similarity index 99%
rename from src/ImageSharp/Formats/Jpeg/Port/JpegConstants.cs
rename to src/ImageSharp/Formats/Jpeg/PdfJsPort/PdfJsJpegConstants.cs
index a02e055917..8b3765e6cf 100644
--- a/src/ImageSharp/Formats/Jpeg/Port/JpegConstants.cs
+++ b/src/ImageSharp/Formats/Jpeg/PdfJsPort/PdfJsJpegConstants.cs
@@ -4,12 +4,12 @@
//
// ReSharper disable InconsistentNaming
-namespace ImageSharp.Formats.Jpeg.Port
+namespace ImageSharp.Formats.Jpeg.PdfJsPort
{
///
/// Contains jpeg constant values
///
- internal static class JpegConstants
+ internal static class PdfJsJpegConstants
{
///
/// Contains marker specific constants
diff --git a/src/ImageSharp/Formats/Jpeg/Port/JpegDecoderCore.cs b/src/ImageSharp/Formats/Jpeg/PdfJsPort/PdfJsJpegDecoderCore.cs
similarity index 80%
rename from src/ImageSharp/Formats/Jpeg/Port/JpegDecoderCore.cs
rename to src/ImageSharp/Formats/Jpeg/PdfJsPort/PdfJsJpegDecoderCore.cs
index 6b499a5fdc..ef03818cc7 100644
--- a/src/ImageSharp/Formats/Jpeg/Port/JpegDecoderCore.cs
+++ b/src/ImageSharp/Formats/Jpeg/PdfJsPort/PdfJsJpegDecoderCore.cs
@@ -3,14 +3,15 @@
// Licensed under the Apache License, Version 2.0.
//
-namespace ImageSharp.Formats.Jpeg.Port
+namespace ImageSharp.Formats.Jpeg.PdfJsPort
{
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Runtime.CompilerServices;
- using ImageSharp.Formats.Jpeg.Port.Components;
+
+ using ImageSharp.Formats.Jpeg.PdfJsPort.Components;
using ImageSharp.Memory;
using ImageSharp.PixelFormats;
@@ -18,7 +19,7 @@ namespace ImageSharp.Formats.Jpeg.Port
/// Performs the jpeg decoding operation.
/// Ported from with additional fixes to handle common encoding errors
///
- internal sealed class JpegDecoderCore : IDisposable
+ internal sealed class PdfJsJpegDecoderCore : IDisposable
{
///
/// The global configuration
@@ -32,17 +33,17 @@ namespace ImageSharp.Formats.Jpeg.Port
private readonly byte[] markerBuffer = new byte[2];
- private QuantizationTables quantizationTables;
+ private PdfJsQuantizationTables quantizationTables;
- private HuffmanTables dcHuffmanTables;
+ private PdfJsHuffmanTables dcHuffmanTables;
- private HuffmanTables acHuffmanTables;
+ private PdfJsHuffmanTables acHuffmanTables;
- private Frame frame;
+ private PdfJsFrame frame;
private ComponentBlocks components;
- private JpegPixelArea pixelArea;
+ private PdfJsJpegPixelArea pixelArea;
private ushort resetInterval;
@@ -60,27 +61,27 @@ namespace ImageSharp.Formats.Jpeg.Port
///
/// Contains information about the JFIF marker
///
- private JFif jFif;
+ private PdfJsJFif jFif;
///
/// Contains information about the Adobe marker
///
- private Adobe adobe;
+ private PdfJsAdobe adobe;
///
- /// Initializes static members of the class.
+ /// Initializes static members of the class.
///
- static JpegDecoderCore()
+ static PdfJsJpegDecoderCore()
{
- YCbCrToRgbTables.Create();
+ PdfJsYCbCrToRgbTables.Create();
}
///
- /// Initializes a new instance of the class.
+ /// Initializes a new instance of the class.
///
/// The configuration.
/// The options.
- public JpegDecoderCore(Configuration configuration, IJpegDecoderOptions options)
+ public PdfJsJpegDecoderCore(Configuration configuration, IJpegDecoderOptions options)
{
this.configuration = configuration ?? Configuration.Default;
this.IgnoreMetadata = options.IgnoreMetadata;
@@ -101,35 +102,35 @@ namespace ImageSharp.Formats.Jpeg.Port
///
/// The buffer to read file markers to
/// The input stream
- /// The
- public static FileMarker FindNextFileMarker(byte[] marker, Stream stream)
+ /// The
+ public static PdfJsFileMarker FindNextFileMarker(byte[] marker, Stream stream)
{
int value = stream.Read(marker, 0, 2);
if (value == 0)
{
- return new FileMarker(JpegConstants.Markers.EOI, (int)stream.Length - 2);
+ return new PdfJsFileMarker(PdfJsJpegConstants.Markers.EOI, (int)stream.Length - 2);
}
- if (marker[0] == JpegConstants.Markers.Prefix)
+ if (marker[0] == PdfJsJpegConstants.Markers.Prefix)
{
// According to Section B.1.1.2:
// "Any marker may optionally be preceded by any number of fill bytes, which are bytes assigned code 0xFF."
- while (marker[1] == JpegConstants.Markers.Prefix)
+ while (marker[1] == PdfJsJpegConstants.Markers.Prefix)
{
int suffix = stream.ReadByte();
if (suffix == -1)
{
- return new FileMarker(JpegConstants.Markers.EOI, (int)stream.Length - 2);
+ return new PdfJsFileMarker(PdfJsJpegConstants.Markers.EOI, (int)stream.Length - 2);
}
marker[1] = (byte)value;
}
- return new FileMarker((ushort)((marker[0] << 8) | marker[1]), (int)(stream.Position - 2));
+ return new PdfJsFileMarker((ushort)((marker[0] << 8) | marker[1]), (int)(stream.Position - 2));
}
- return new FileMarker((ushort)((marker[0] << 8) | marker[1]), (int)(stream.Position - 2), true);
+ return new PdfJsFileMarker((ushort)((marker[0] << 8) | marker[1]), (int)(stream.Position - 2), true);
}
///
@@ -171,7 +172,7 @@ namespace ImageSharp.Formats.Jpeg.Port
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- private static int GetBlockBufferOffset(ref Component component, int row, int col)
+ private static int GetBlockBufferOffset(ref PdfJsComponent component, int row, int col)
{
return 64 * (((component.BlocksPerLine + 1) * row) + col);
}
@@ -185,79 +186,79 @@ namespace ImageSharp.Formats.Jpeg.Port
{
// TODO: metadata only logic
// Check for the Start Of Image marker.
- var fileMarker = new FileMarker(this.ReadUint16(), 0);
- if (fileMarker.Marker != JpegConstants.Markers.SOI)
+ var fileMarker = new PdfJsFileMarker(this.ReadUint16(), 0);
+ if (fileMarker.Marker != PdfJsJpegConstants.Markers.SOI)
{
throw new ImageFormatException("Missing SOI marker.");
}
ushort marker = this.ReadUint16();
- fileMarker = new FileMarker(marker, (int)this.InputStream.Position - 2);
+ fileMarker = new PdfJsFileMarker(marker, (int)this.InputStream.Position - 2);
- this.quantizationTables = new QuantizationTables();
- this.dcHuffmanTables = new HuffmanTables();
- this.acHuffmanTables = new HuffmanTables();
+ this.quantizationTables = new PdfJsQuantizationTables();
+ this.dcHuffmanTables = new PdfJsHuffmanTables();
+ this.acHuffmanTables = new PdfJsHuffmanTables();
- while (fileMarker.Marker != JpegConstants.Markers.EOI)
+ while (fileMarker.Marker != PdfJsJpegConstants.Markers.EOI)
{
// Get the marker length
int remaining = this.ReadUint16() - 2;
switch (fileMarker.Marker)
{
- case JpegConstants.Markers.APP0:
+ case PdfJsJpegConstants.Markers.APP0:
this.ProcessApplicationHeaderMarker(remaining);
break;
- case JpegConstants.Markers.APP1:
+ case PdfJsJpegConstants.Markers.APP1:
this.ProcessApp1Marker(remaining, metaData);
break;
- case JpegConstants.Markers.APP2:
+ case PdfJsJpegConstants.Markers.APP2:
this.ProcessApp2Marker(remaining, metaData);
break;
- case JpegConstants.Markers.APP3:
- case JpegConstants.Markers.APP4:
- case JpegConstants.Markers.APP5:
- case JpegConstants.Markers.APP6:
- case JpegConstants.Markers.APP7:
- case JpegConstants.Markers.APP8:
- case JpegConstants.Markers.APP9:
- case JpegConstants.Markers.APP10:
- case JpegConstants.Markers.APP11:
- case JpegConstants.Markers.APP12:
- case JpegConstants.Markers.APP13:
+ case PdfJsJpegConstants.Markers.APP3:
+ case PdfJsJpegConstants.Markers.APP4:
+ case PdfJsJpegConstants.Markers.APP5:
+ case PdfJsJpegConstants.Markers.APP6:
+ case PdfJsJpegConstants.Markers.APP7:
+ case PdfJsJpegConstants.Markers.APP8:
+ case PdfJsJpegConstants.Markers.APP9:
+ case PdfJsJpegConstants.Markers.APP10:
+ case PdfJsJpegConstants.Markers.APP11:
+ case PdfJsJpegConstants.Markers.APP12:
+ case PdfJsJpegConstants.Markers.APP13:
this.InputStream.Skip(remaining);
break;
- case JpegConstants.Markers.APP14:
+ case PdfJsJpegConstants.Markers.APP14:
this.ProcessApp14Marker(remaining);
break;
- case JpegConstants.Markers.APP15:
- case JpegConstants.Markers.COM:
+ case PdfJsJpegConstants.Markers.APP15:
+ case PdfJsJpegConstants.Markers.COM:
this.InputStream.Skip(remaining);
break;
- case JpegConstants.Markers.DQT:
+ case PdfJsJpegConstants.Markers.DQT:
this.ProcessDefineQuantizationTablesMarker(remaining);
break;
- case JpegConstants.Markers.SOF0:
- case JpegConstants.Markers.SOF1:
- case JpegConstants.Markers.SOF2:
+ case PdfJsJpegConstants.Markers.SOF0:
+ case PdfJsJpegConstants.Markers.SOF1:
+ case PdfJsJpegConstants.Markers.SOF2:
this.ProcessStartOfFrameMarker(remaining, fileMarker);
break;
- case JpegConstants.Markers.DHT:
+ case PdfJsJpegConstants.Markers.DHT:
this.ProcessDefineHuffmanTablesMarker(remaining);
break;
- case JpegConstants.Markers.DRI:
+ case PdfJsJpegConstants.Markers.DRI:
this.ProcessDefineRestartIntervalMarker(remaining);
break;
- case JpegConstants.Markers.SOS:
+ case PdfJsJpegConstants.Markers.SOS:
this.ProcessStartOfScanMarker();
break;
}
@@ -268,12 +269,12 @@ namespace ImageSharp.Formats.Jpeg.Port
this.imageWidth = this.frame.SamplesPerLine;
this.imageHeight = this.frame.Scanlines;
- this.components = new ComponentBlocks { Components = new Component[this.frame.ComponentCount] };
+ this.components = new ComponentBlocks { Components = new PdfJsComponent[this.frame.ComponentCount] };
for (int i = 0; i < this.components.Components.Length; i++)
{
ref var frameComponent = ref this.frame.Components[i];
- var component = new Component
+ var component = new PdfJsComponent
{
Scale = new System.Numerics.Vector2(
frameComponent.HorizontalFactor / (float)this.frame.MaxHorizontalFactor,
@@ -302,7 +303,7 @@ namespace ImageSharp.Formats.Jpeg.Port
throw new ImageFormatException($"Unsupported color mode. Max components 4; found {this.numberOfComponents}");
}
- this.pixelArea = new JpegPixelArea(image.Width, image.Height, this.numberOfComponents);
+ this.pixelArea = new PdfJsJpegPixelArea(image.Width, image.Height, this.numberOfComponents);
this.pixelArea.LinearizeBlockData(this.components, image.Width, image.Height);
if (this.numberOfComponents == 1)
@@ -313,11 +314,11 @@ namespace ImageSharp.Formats.Jpeg.Port
if (this.numberOfComponents == 3)
{
- if (this.adobe.Equals(default(Adobe)) || this.adobe.ColorTransform == JpegConstants.Markers.Adobe.ColorTransformYCbCr)
+ if (this.adobe.Equals(default(PdfJsAdobe)) || this.adobe.ColorTransform == PdfJsJpegConstants.Markers.Adobe.ColorTransformYCbCr)
{
this.FillYCbCrImage(image);
}
- else if (this.adobe.ColorTransform == JpegConstants.Markers.Adobe.ColorTransformUnknown)
+ else if (this.adobe.ColorTransform == PdfJsJpegConstants.Markers.Adobe.ColorTransformUnknown)
{
this.FillRgbImage(image);
}
@@ -325,7 +326,7 @@ namespace ImageSharp.Formats.Jpeg.Port
if (this.numberOfComponents == 4)
{
- if (this.adobe.ColorTransform == JpegConstants.Markers.Adobe.ColorTransformYcck)
+ if (this.adobe.ColorTransform == PdfJsJpegConstants.Markers.Adobe.ColorTransformYcck)
{
this.FillYcckImage(image);
}
@@ -380,15 +381,15 @@ namespace ImageSharp.Formats.Jpeg.Port
this.InputStream.Read(this.temp, 0, 13);
remaining -= 13;
- bool isJfif = this.temp[0] == JpegConstants.Markers.JFif.J &&
- this.temp[1] == JpegConstants.Markers.JFif.F &&
- this.temp[2] == JpegConstants.Markers.JFif.I &&
- this.temp[3] == JpegConstants.Markers.JFif.F &&
- this.temp[4] == JpegConstants.Markers.JFif.Null;
+ bool isJfif = this.temp[0] == PdfJsJpegConstants.Markers.JFif.J &&
+ this.temp[1] == PdfJsJpegConstants.Markers.JFif.F &&
+ this.temp[2] == PdfJsJpegConstants.Markers.JFif.I &&
+ this.temp[3] == PdfJsJpegConstants.Markers.JFif.F &&
+ this.temp[4] == PdfJsJpegConstants.Markers.JFif.Null;
if (isJfif)
{
- this.jFif = new JFif
+ this.jFif = new PdfJsJFif
{
MajorVersion = this.temp[5],
MinorVersion = this.temp[6],
@@ -422,12 +423,12 @@ namespace ImageSharp.Formats.Jpeg.Port
byte[] profile = new byte[remaining];
this.InputStream.Read(profile, 0, remaining);
- if (profile[0] == JpegConstants.Markers.Exif.E &&
- profile[1] == JpegConstants.Markers.Exif.X &&
- profile[2] == JpegConstants.Markers.Exif.I &&
- profile[3] == JpegConstants.Markers.Exif.F &&
- profile[4] == JpegConstants.Markers.Exif.Null &&
- profile[5] == JpegConstants.Markers.Exif.Null)
+ if (profile[0] == PdfJsJpegConstants.Markers.Exif.E &&
+ profile[1] == PdfJsJpegConstants.Markers.Exif.X &&
+ profile[2] == PdfJsJpegConstants.Markers.Exif.I &&
+ profile[3] == PdfJsJpegConstants.Markers.Exif.F &&
+ profile[4] == PdfJsJpegConstants.Markers.Exif.Null &&
+ profile[5] == PdfJsJpegConstants.Markers.Exif.Null)
{
this.isExif = true;
metadata.ExifProfile = new ExifProfile(profile);
@@ -453,18 +454,18 @@ namespace ImageSharp.Formats.Jpeg.Port
this.InputStream.Read(identifier, 0, Icclength);
remaining -= Icclength; // We have read it by this point
- if (identifier[0] == JpegConstants.Markers.ICC.I &&
- identifier[1] == JpegConstants.Markers.ICC.C &&
- identifier[2] == JpegConstants.Markers.ICC.C &&
- identifier[3] == JpegConstants.Markers.ICC.UnderScore &&
- identifier[4] == JpegConstants.Markers.ICC.P &&
- identifier[5] == JpegConstants.Markers.ICC.R &&
- identifier[6] == JpegConstants.Markers.ICC.O &&
- identifier[7] == JpegConstants.Markers.ICC.F &&
- identifier[8] == JpegConstants.Markers.ICC.I &&
- identifier[9] == JpegConstants.Markers.ICC.L &&
- identifier[10] == JpegConstants.Markers.ICC.E &&
- identifier[11] == JpegConstants.Markers.ICC.Null)
+ if (identifier[0] == PdfJsJpegConstants.Markers.ICC.I &&
+ identifier[1] == PdfJsJpegConstants.Markers.ICC.C &&
+ identifier[2] == PdfJsJpegConstants.Markers.ICC.C &&
+ identifier[3] == PdfJsJpegConstants.Markers.ICC.UnderScore &&
+ identifier[4] == PdfJsJpegConstants.Markers.ICC.P &&
+ identifier[5] == PdfJsJpegConstants.Markers.ICC.R &&
+ identifier[6] == PdfJsJpegConstants.Markers.ICC.O &&
+ identifier[7] == PdfJsJpegConstants.Markers.ICC.F &&
+ identifier[8] == PdfJsJpegConstants.Markers.ICC.I &&
+ identifier[9] == PdfJsJpegConstants.Markers.ICC.L &&
+ identifier[10] == PdfJsJpegConstants.Markers.ICC.E &&
+ identifier[11] == PdfJsJpegConstants.Markers.ICC.Null)
{
byte[] profile = new byte[remaining];
this.InputStream.Read(profile, 0, remaining);
@@ -502,15 +503,15 @@ namespace ImageSharp.Formats.Jpeg.Port
this.InputStream.Read(this.temp, 0, 12);
remaining -= 12;
- bool isAdobe = this.temp[0] == JpegConstants.Markers.Adobe.A &&
- this.temp[1] == JpegConstants.Markers.Adobe.D &&
- this.temp[2] == JpegConstants.Markers.Adobe.O &&
- this.temp[3] == JpegConstants.Markers.Adobe.B &&
- this.temp[4] == JpegConstants.Markers.Adobe.E;
+ bool isAdobe = this.temp[0] == PdfJsJpegConstants.Markers.Adobe.A &&
+ this.temp[1] == PdfJsJpegConstants.Markers.Adobe.D &&
+ this.temp[2] == PdfJsJpegConstants.Markers.Adobe.O &&
+ this.temp[3] == PdfJsJpegConstants.Markers.Adobe.B &&
+ this.temp[4] == PdfJsJpegConstants.Markers.Adobe.E;
if (isAdobe)
{
- this.adobe = new Adobe
+ this.adobe = new PdfJsAdobe
{
DCTEncodeVersion = (short)((this.temp[5] << 8) | this.temp[6]),
APP14Flags0 = (short)((this.temp[7] << 8) | this.temp[8]),
@@ -557,7 +558,7 @@ namespace ImageSharp.Formats.Jpeg.Port
Span tableSpan = this.quantizationTables.Tables.GetRowSpan(quantizationTableSpec & 15);
for (int j = 0; j < 64; j++)
{
- tableSpan[QuantizationTables.DctZigZag[j]] = this.temp[j];
+ tableSpan[PdfJsQuantizationTables.DctZigZag[j]] = this.temp[j];
}
}
@@ -577,7 +578,7 @@ namespace ImageSharp.Formats.Jpeg.Port
Span tableSpan = this.quantizationTables.Tables.GetRowSpan(quantizationTableSpec & 15);
for (int j = 0; j < 64; j++)
{
- tableSpan[QuantizationTables.DctZigZag[j]] = (short)((this.temp[2 * j] << 8) | this.temp[(2 * j) + 1]);
+ tableSpan[PdfJsQuantizationTables.DctZigZag[j]] = (short)((this.temp[2 * j] << 8) | this.temp[(2 * j) + 1]);
}
}
@@ -603,7 +604,7 @@ namespace ImageSharp.Formats.Jpeg.Port
///
/// The remaining bytes in the segment block.
/// The current frame marker.
- private void ProcessStartOfFrameMarker(int remaining, FileMarker frameMarker)
+ private void ProcessStartOfFrameMarker(int remaining, PdfJsFileMarker frameMarker)
{
if (this.frame != null)
{
@@ -612,10 +613,10 @@ namespace ImageSharp.Formats.Jpeg.Port
this.InputStream.Read(this.temp, 0, remaining);
- this.frame = new Frame
+ this.frame = new PdfJsFrame
{
- Extended = frameMarker.Marker == JpegConstants.Markers.SOF1,
- Progressive = frameMarker.Marker == JpegConstants.Markers.SOF2,
+ Extended = frameMarker.Marker == PdfJsJpegConstants.Markers.SOF1,
+ Progressive = frameMarker.Marker == PdfJsJpegConstants.Markers.SOF2,
Precision = this.temp[0],
Scanlines = (short)((this.temp[1] << 8) | this.temp[2]),
SamplesPerLine = (short)((this.temp[3] << 8) | this.temp[4]),
@@ -628,7 +629,7 @@ namespace ImageSharp.Formats.Jpeg.Port
// No need to pool this. They max out at 4
this.frame.ComponentIds = new byte[this.frame.ComponentCount];
- this.frame.Components = new FrameComponent[this.frame.ComponentCount];
+ this.frame.Components = new PdfJsFrameComponent[this.frame.ComponentCount];
for (int i = 0; i < this.frame.Components.Length; i++)
{
@@ -747,7 +748,7 @@ namespace ImageSharp.Formats.Jpeg.Port
throw new ImageFormatException("Unknown component selector");
}
- ref FrameComponent component = ref this.frame.Components[componentIndex];
+ ref PdfJsFrameComponent component = ref this.frame.Components[componentIndex];
int tableSpec = this.InputStream.ReadByte();
component.DCHuffmanTableId = tableSpec >> 4;
component.ACHuffmanTableId = tableSpec & 15;
@@ -758,7 +759,7 @@ namespace ImageSharp.Formats.Jpeg.Port
int spectralStart = this.temp[0];
int spectralEnd = this.temp[1];
int successiveApproximation = this.temp[2];
- var scanDecoder = default(ScanDecoder);
+ var scanDecoder = default(PdfJsScanDecoder);
scanDecoder.DecodeScan(
this.frame,
@@ -780,7 +781,7 @@ namespace ImageSharp.Formats.Jpeg.Port
///
/// The component
/// The frame component
- private void BuildComponentData(ref Component component, ref FrameComponent frameComponent)
+ private void BuildComponentData(ref PdfJsComponent component, ref PdfJsFrameComponent frameComponent)
{
int blocksPerLine = component.BlocksPerLine;
int blocksPerColumn = component.BlocksPerColumn;
@@ -798,7 +799,7 @@ namespace ImageSharp.Formats.Jpeg.Port
Span multiplierSpan = multiplicationBuffer;
for (int i = 0; i < 64; i++)
{
- multiplierSpan[i] = (short)IDCT.Descale(quantizationTable[i] * IDCT.Aanscales[i], 12);
+ multiplierSpan[i] = (short)PdfJsIDCT.Descale(quantizationTable[i] * PdfJsIDCT.Aanscales[i], 12);
}
for (int blockRow = 0; blockRow < blocksPerColumn; blockRow++)
@@ -806,7 +807,7 @@ namespace ImageSharp.Formats.Jpeg.Port
for (int blockCol = 0; blockCol < blocksPerLine; blockCol++)
{
int offset = GetBlockBufferOffset(ref component, blockRow, blockCol);
- IDCT.QuantizeAndInverseFast(ref frameComponent, offset, ref computationBufferSpan, ref multiplierSpan);
+ PdfJsIDCT.QuantizeAndInverseFast(ref frameComponent, offset, ref computationBufferSpan, ref multiplierSpan);
}
}
}
@@ -821,9 +822,9 @@ namespace ImageSharp.Formats.Jpeg.Port
/// The table index
/// The codelengths
/// The values
- private void BuildHuffmanTable(HuffmanTables tables, int index, byte[] codeLengths, byte[] values)
+ private void BuildHuffmanTable(PdfJsHuffmanTables tables, int index, byte[] codeLengths, byte[] values)
{
- tables[index] = new HuffmanTable(codeLengths, values);
+ tables[index] = new PdfJsHuffmanTable(codeLengths, values);
}
///
@@ -887,7 +888,7 @@ namespace ImageSharp.Formats.Jpeg.Port
ref byte cb = ref areaRowSpan[o + 1];
ref byte cr = ref areaRowSpan[o + 2];
ref TPixel pixel = ref imageRowSpan[x];
- YCbCrToRgbTables.PackYCbCr(ref pixel, yy, cb, cr);
+ PdfJsYCbCrToRgbTables.PackYCbCr(ref pixel, yy, cb, cr);
}
}
}
@@ -908,7 +909,7 @@ namespace ImageSharp.Formats.Jpeg.Port
ref byte k = ref areaRowSpan[o + 3];
ref TPixel pixel = ref imageRowSpan[x];
- YCbCrToRgbTables.PackYccK(ref pixel, yy, cb, cr, k);
+ PdfJsYCbCrToRgbTables.PackYccK(ref pixel, yy, cb, cr, k);
}
}
}
diff --git a/src/ImageSharp/ImageSharp.csproj b/src/ImageSharp/ImageSharp.csproj
index 8733131a74..280c79047a 100644
--- a/src/ImageSharp/ImageSharp.csproj
+++ b/src/ImageSharp/ImageSharp.csproj
@@ -104,4 +104,7 @@
PorterDuffFunctions.Generated.tt
+
+
+
\ No newline at end of file