Browse Source

prefixing GolangPort stuff with Old*** #Round1

pull/298/head
Anton Firszov 9 years ago
parent
commit
51b430b4f1
  1. 8
      src/ImageSharp/Formats/Jpeg/GolangPort/Components/Decoder/Bytes.cs
  2. 2
      src/ImageSharp/Formats/Jpeg/GolangPort/Components/Decoder/OldComponent.cs
  3. 2
      src/ImageSharp/Formats/Jpeg/GolangPort/Components/Decoder/OldComponentScan.cs
  4. 4
      src/ImageSharp/Formats/Jpeg/GolangPort/Components/Decoder/OldJpegScanDecoder.ComputationData.cs
  5. 6
      src/ImageSharp/Formats/Jpeg/GolangPort/Components/Decoder/OldJpegScanDecoder.DataPointers.cs
  6. 20
      src/ImageSharp/Formats/Jpeg/GolangPort/Components/Decoder/OldJpegScanDecoder.cs
  7. 50
      src/ImageSharp/Formats/Jpeg/GolangPort/JpegDecoderCore.cs
  8. 32
      src/ImageSharp/Formats/Jpeg/GolangPort/JpegEncoderCore.cs
  9. 2
      src/ImageSharp/Formats/Jpeg/GolangPort/OldJpegConstants.cs
  10. 2
      src/ImageSharp/Formats/Jpeg/GolangPort/Utils/OldJpegUtils.cs
  11. 4
      src/ImageSharp/Formats/Jpeg/JpegFormat.cs

8
src/ImageSharp/Formats/Jpeg/GolangPort/Components/Decoder/Bytes.cs

@ -95,7 +95,7 @@ namespace ImageSharp.Formats.Jpeg.GolangPort.Components.Decoder
x = this.BufferAsInt[this.I]; x = this.BufferAsInt[this.I];
this.I++; this.I++;
this.UnreadableBytes = 1; this.UnreadableBytes = 1;
if (x != JpegConstants.Markers.XFFInt) if (x != OldJpegConstants.Markers.XFFInt)
{ {
return DecoderErrorCode.NoError; return DecoderErrorCode.NoError;
} }
@ -107,7 +107,7 @@ namespace ImageSharp.Formats.Jpeg.GolangPort.Components.Decoder
this.I++; this.I++;
this.UnreadableBytes = 2; this.UnreadableBytes = 2;
x = JpegConstants.Markers.XFF; x = OldJpegConstants.Markers.XFF;
return DecoderErrorCode.NoError; return DecoderErrorCode.NoError;
} }
@ -120,7 +120,7 @@ namespace ImageSharp.Formats.Jpeg.GolangPort.Components.Decoder
return errorCode; return errorCode;
} }
if (x != JpegConstants.Markers.XFF) if (x != OldJpegConstants.Markers.XFF)
{ {
return DecoderErrorCode.NoError; return DecoderErrorCode.NoError;
} }
@ -137,7 +137,7 @@ namespace ImageSharp.Formats.Jpeg.GolangPort.Components.Decoder
return DecoderErrorCode.MissingFF00; return DecoderErrorCode.MissingFF00;
} }
x = JpegConstants.Markers.XFF; x = OldJpegConstants.Markers.XFF;
return DecoderErrorCode.NoError; return DecoderErrorCode.NoError;
} }

2
src/ImageSharp/Formats/Jpeg/GolangPort/Components/Decoder/Component.cs → src/ImageSharp/Formats/Jpeg/GolangPort/Components/Decoder/OldComponent.cs

@ -8,7 +8,7 @@ namespace ImageSharp.Formats.Jpeg.GolangPort.Components.Decoder
/// <summary> /// <summary>
/// Represents a single color component /// Represents a single color component
/// </summary> /// </summary>
internal struct Component internal struct OldComponent
{ {
/// <summary> /// <summary>
/// Gets or sets the horizontal sampling factor. /// Gets or sets the horizontal sampling factor.

2
src/ImageSharp/Formats/Jpeg/GolangPort/Components/Decoder/ComponentScan.cs → src/ImageSharp/Formats/Jpeg/GolangPort/Components/Decoder/OldComponentScan.cs

@ -11,7 +11,7 @@ namespace ImageSharp.Formats.Jpeg.GolangPort.Components.Decoder
/// Represents a component scan /// Represents a component scan
/// </summary> /// </summary>
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Sequential)]
internal struct ComponentScan internal struct OldComponentScan
{ {
/// <summary> /// <summary>
/// Gets or sets the component index. /// Gets or sets the component index.

4
src/ImageSharp/Formats/Jpeg/GolangPort/Components/Decoder/JpegScanDecoder.ComputationData.cs → src/ImageSharp/Formats/Jpeg/GolangPort/Components/Decoder/OldJpegScanDecoder.ComputationData.cs

@ -11,7 +11,7 @@ namespace ImageSharp.Formats.Jpeg.GolangPort.Components.Decoder
/// <content> /// <content>
/// Conains the definition of <see cref="ComputationData"/> /// Conains the definition of <see cref="ComputationData"/>
/// </content> /// </content>
internal unsafe partial struct JpegScanDecoder internal unsafe partial struct OldJpegScanDecoder
{ {
/// <summary> /// <summary>
/// Holds the "large" data blocks needed for computations. /// Holds the "large" data blocks needed for computations.
@ -30,7 +30,7 @@ namespace ImageSharp.Formats.Jpeg.GolangPort.Components.Decoder
public UnzigData Unzig; public UnzigData Unzig;
/// <summary> /// <summary>
/// The buffer storing the <see cref="ComponentScan"/>-s for each component /// The buffer storing the <see cref="OldComponentScan"/>-s for each component
/// </summary> /// </summary>
public fixed byte ScanData[3 * JpegDecoderCore.MaxComponents]; public fixed byte ScanData[3 * JpegDecoderCore.MaxComponents];

6
src/ImageSharp/Formats/Jpeg/GolangPort/Components/Decoder/JpegScanDecoder.DataPointers.cs → src/ImageSharp/Formats/Jpeg/GolangPort/Components/Decoder/OldJpegScanDecoder.DataPointers.cs

@ -10,7 +10,7 @@ namespace ImageSharp.Formats.Jpeg.GolangPort.Components.Decoder
/// <content> /// <content>
/// Conains the definition of <see cref="DataPointers"/> /// Conains the definition of <see cref="DataPointers"/>
/// </content> /// </content>
internal unsafe partial struct JpegScanDecoder internal unsafe partial struct OldJpegScanDecoder
{ {
/// <summary> /// <summary>
/// Contains pointers to the memory regions of <see cref="ComputationData"/> so they can be easily passed around to pointer based utility methods of <see cref="Block8x8F"/> /// Contains pointers to the memory regions of <see cref="ComputationData"/> so they can be easily passed around to pointer based utility methods of <see cref="Block8x8F"/>
@ -30,7 +30,7 @@ namespace ImageSharp.Formats.Jpeg.GolangPort.Components.Decoder
/// <summary> /// <summary>
/// Pointer to <see cref="ComputationData.ScanData"/> as Scan* /// Pointer to <see cref="ComputationData.ScanData"/> as Scan*
/// </summary> /// </summary>
public ComponentScan* ComponentScan; public OldComponentScan* ComponentScan;
/// <summary> /// <summary>
/// Pointer to <see cref="ComputationData.Dc"/> /// Pointer to <see cref="ComputationData.Dc"/>
@ -45,7 +45,7 @@ namespace ImageSharp.Formats.Jpeg.GolangPort.Components.Decoder
{ {
this.Block = &basePtr->Block; this.Block = &basePtr->Block;
this.Unzig = basePtr->Unzig.Data; this.Unzig = basePtr->Unzig.Data;
this.ComponentScan = (ComponentScan*)basePtr->ScanData; this.ComponentScan = (OldComponentScan*)basePtr->ScanData;
this.Dc = basePtr->Dc; this.Dc = basePtr->Dc;
} }
} }

20
src/ImageSharp/Formats/Jpeg/GolangPort/Components/Decoder/JpegScanDecoder.cs → src/ImageSharp/Formats/Jpeg/GolangPort/Components/Decoder/OldJpegScanDecoder.cs

@ -30,7 +30,7 @@ namespace ImageSharp.Formats.Jpeg.GolangPort.Components.Decoder
/// For baseline JPEGs, these parameters are hard-coded to 0/63/0/0. /// For baseline JPEGs, these parameters are hard-coded to 0/63/0/0.
/// </summary> /// </summary>
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Sequential)]
internal unsafe partial struct JpegScanDecoder internal unsafe partial struct OldJpegScanDecoder
{ {
// The JpegScanDecoder members should be ordered in a way that results in optimal memory layout. // The JpegScanDecoder members should be ordered in a way that results in optimal memory layout.
#pragma warning disable SA1202 // ElementsMustBeOrderedByAccess #pragma warning disable SA1202 // ElementsMustBeOrderedByAccess
@ -96,12 +96,12 @@ namespace ImageSharp.Formats.Jpeg.GolangPort.Components.Decoder
private int eobRun; private int eobRun;
/// <summary> /// <summary>
/// Initializes a default-constructed <see cref="JpegScanDecoder"/> instance for reading data from <see cref="JpegDecoderCore"/>-s stream. /// Initializes a default-constructed <see cref="OldJpegScanDecoder"/> instance for reading data from <see cref="JpegDecoderCore"/>-s stream.
/// </summary> /// </summary>
/// <param name="p">Pointer to <see cref="JpegScanDecoder"/> on the stack</param> /// <param name="p">Pointer to <see cref="OldJpegScanDecoder"/> on the stack</param>
/// <param name="decoder">The <see cref="JpegDecoderCore"/> instance</param> /// <param name="decoder">The <see cref="JpegDecoderCore"/> instance</param>
/// <param name="remaining">The remaining bytes in the segment block.</param> /// <param name="remaining">The remaining bytes in the segment block.</param>
public static void InitStreamReading(JpegScanDecoder* p, JpegDecoderCore decoder, int remaining) public static void InitStreamReading(OldJpegScanDecoder* p, JpegDecoderCore decoder, int remaining)
{ {
p->data = ComputationData.Create(); p->data = ComputationData.Create();
p->pointers = new DataPointers(&p->data); p->pointers = new DataPointers(&p->data);
@ -140,7 +140,7 @@ namespace ImageSharp.Formats.Jpeg.GolangPort.Components.Decoder
{ {
int blockCount = 0; int blockCount = 0;
int mcu = 0; int mcu = 0;
byte expectedRst = JpegConstants.Markers.RST0; byte expectedRst = OldJpegConstants.Markers.RST0;
for (int my = 0; my < decoder.MCUCountY; my++) for (int my = 0; my < decoder.MCUCountY; my++)
{ {
@ -206,9 +206,9 @@ namespace ImageSharp.Formats.Jpeg.GolangPort.Components.Decoder
} }
expectedRst++; expectedRst++;
if (expectedRst == JpegConstants.Markers.RST7 + 1) if (expectedRst == OldJpegConstants.Markers.RST7 + 1)
{ {
expectedRst = JpegConstants.Markers.RST0; expectedRst = OldJpegConstants.Markers.RST0;
} }
} }
} }
@ -434,7 +434,7 @@ namespace ImageSharp.Formats.Jpeg.GolangPort.Components.Decoder
return ((this.by * decoder.MCUCountX) * this.hi) + this.bx; return ((this.by * decoder.MCUCountX) * this.hi) + this.bx;
} }
private void InitComponentScan(JpegDecoderCore decoder, int i, ref ComponentScan currentComponentScan, ref int totalHv) private void InitComponentScan(JpegDecoderCore decoder, int i, ref OldComponentScan currentComponentScan, ref int totalHv)
{ {
// Component selector. // Component selector.
int cs = decoder.Temp[1 + (2 * i)]; int cs = decoder.Temp[1 + (2 * i)];
@ -461,9 +461,9 @@ namespace ImageSharp.Formats.Jpeg.GolangPort.Components.Decoder
private void ProcessComponentImpl( private void ProcessComponentImpl(
JpegDecoderCore decoder, JpegDecoderCore decoder,
int i, int i,
ref ComponentScan currentComponentScan, ref OldComponentScan currentComponentScan,
ref int totalHv, ref int totalHv,
ref Component currentComponent) ref OldComponent currentComponent)
{ {
// Section B.2.3 states that "the value of Cs_j shall be different from // 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 // the values of Cs_1 through Cs_(j-1)". Since we have previously

50
src/ImageSharp/Formats/Jpeg/GolangPort/JpegDecoderCore.cs

@ -108,14 +108,14 @@ namespace ImageSharp.Formats.Jpeg.GolangPort
this.HuffmanTrees = HuffmanTree.CreateHuffmanTrees(); this.HuffmanTrees = HuffmanTree.CreateHuffmanTrees();
this.QuantizationTables = new Block8x8F[MaxTq + 1]; this.QuantizationTables = new Block8x8F[MaxTq + 1];
this.Temp = new byte[2 * Block8x8F.ScalarCount]; this.Temp = new byte[2 * Block8x8F.ScalarCount];
this.ComponentArray = new Component[MaxComponents]; this.ComponentArray = new OldComponent[MaxComponents];
this.DecodedBlocks = new Buffer<DecodedBlock>[MaxComponents]; this.DecodedBlocks = new Buffer<DecodedBlock>[MaxComponents];
} }
/// <summary> /// <summary>
/// Gets the component array /// Gets the component array
/// </summary> /// </summary>
public Component[] ComponentArray { get; } public OldComponent[] ComponentArray { get; }
/// <summary> /// <summary>
/// Gets the huffman trees /// Gets the huffman trees
@ -272,7 +272,7 @@ namespace ImageSharp.Formats.Jpeg.GolangPort
// Check for the Start Of Image marker. // Check for the Start Of Image marker.
this.InputProcessor.ReadFull(this.Temp, 0, 2); this.InputProcessor.ReadFull(this.Temp, 0, 2);
if (this.Temp[0] != JpegConstants.Markers.XFF || this.Temp[1] != JpegConstants.Markers.SOI) if (this.Temp[0] != OldJpegConstants.Markers.XFF || this.Temp[1] != OldJpegConstants.Markers.SOI)
{ {
throw new ImageFormatException("Missing SOI marker."); throw new ImageFormatException("Missing SOI marker.");
} }
@ -322,12 +322,12 @@ namespace ImageSharp.Formats.Jpeg.GolangPort
} }
// End Of Image. // End Of Image.
if (marker == JpegConstants.Markers.EOI) if (marker == OldJpegConstants.Markers.EOI)
{ {
break; break;
} }
if (marker >= JpegConstants.Markers.RST0 && marker <= JpegConstants.Markers.RST7) if (marker >= OldJpegConstants.Markers.RST0 && marker <= OldJpegConstants.Markers.RST7)
{ {
// Figures B.2 and B.16 of the specification suggest that restart markers should // Figures B.2 and B.16 of the specification suggest that restart markers should
// only occur between Entropy Coded Segments and not after the final ECS. // only occur between Entropy Coded Segments and not after the final ECS.
@ -349,10 +349,10 @@ namespace ImageSharp.Formats.Jpeg.GolangPort
switch (marker) switch (marker)
{ {
case JpegConstants.Markers.SOF0: case OldJpegConstants.Markers.SOF0:
case JpegConstants.Markers.SOF1: case OldJpegConstants.Markers.SOF1:
case JpegConstants.Markers.SOF2: case OldJpegConstants.Markers.SOF2:
this.IsProgressive = marker == JpegConstants.Markers.SOF2; this.IsProgressive = marker == OldJpegConstants.Markers.SOF2;
this.ProcessStartOfFrameMarker(remaining); this.ProcessStartOfFrameMarker(remaining);
if (metadataOnly && this.isJfif) if (metadataOnly && this.isJfif)
{ {
@ -360,7 +360,7 @@ namespace ImageSharp.Formats.Jpeg.GolangPort
} }
break; break;
case JpegConstants.Markers.DHT: case OldJpegConstants.Markers.DHT:
if (metadataOnly) if (metadataOnly)
{ {
this.InputProcessor.Skip(remaining); this.InputProcessor.Skip(remaining);
@ -371,7 +371,7 @@ namespace ImageSharp.Formats.Jpeg.GolangPort
} }
break; break;
case JpegConstants.Markers.DQT: case OldJpegConstants.Markers.DQT:
if (metadataOnly) if (metadataOnly)
{ {
this.InputProcessor.Skip(remaining); this.InputProcessor.Skip(remaining);
@ -382,7 +382,7 @@ namespace ImageSharp.Formats.Jpeg.GolangPort
} }
break; break;
case JpegConstants.Markers.SOS: case OldJpegConstants.Markers.SOS:
if (metadataOnly) if (metadataOnly)
{ {
return; return;
@ -398,7 +398,7 @@ namespace ImageSharp.Formats.Jpeg.GolangPort
} }
break; break;
case JpegConstants.Markers.DRI: case OldJpegConstants.Markers.DRI:
if (metadataOnly) if (metadataOnly)
{ {
this.InputProcessor.Skip(remaining); this.InputProcessor.Skip(remaining);
@ -409,25 +409,25 @@ namespace ImageSharp.Formats.Jpeg.GolangPort
} }
break; break;
case JpegConstants.Markers.APP0: case OldJpegConstants.Markers.APP0:
this.ProcessApplicationHeader(remaining); this.ProcessApplicationHeader(remaining);
break; break;
case JpegConstants.Markers.APP1: case OldJpegConstants.Markers.APP1:
this.ProcessApp1Marker(remaining, metadata); this.ProcessApp1Marker(remaining, metadata);
break; break;
case JpegConstants.Markers.APP2: case OldJpegConstants.Markers.APP2:
this.ProcessApp2Marker(remaining, metadata); this.ProcessApp2Marker(remaining, metadata);
break; break;
case JpegConstants.Markers.APP14: case OldJpegConstants.Markers.APP14:
this.ProcessApp14Marker(remaining); this.ProcessApp14Marker(remaining);
break; break;
default: default:
if ((marker >= JpegConstants.Markers.APP0 && marker <= JpegConstants.Markers.APP15) if ((marker >= OldJpegConstants.Markers.APP0 && marker <= OldJpegConstants.Markers.APP15)
|| marker == JpegConstants.Markers.COM) || marker == OldJpegConstants.Markers.COM)
{ {
this.InputProcessor.Skip(remaining); this.InputProcessor.Skip(remaining);
} }
else if (marker < JpegConstants.Markers.SOF0) else if (marker < OldJpegConstants.Markers.SOF0)
{ {
// See Table B.1 "Marker code assignments". // See Table B.1 "Marker code assignments".
throw new ImageFormatException("Unknown marker"); throw new ImageFormatException("Unknown marker");
@ -452,8 +452,8 @@ namespace ImageSharp.Formats.Jpeg.GolangPort
/// </exception> /// </exception>
private void ProcessStartOfScan(int remaining) private void ProcessStartOfScan(int remaining)
{ {
JpegScanDecoder scan = default(JpegScanDecoder); OldJpegScanDecoder scan = default(OldJpegScanDecoder);
JpegScanDecoder.InitStreamReading(&scan, this, remaining); OldJpegScanDecoder.InitStreamReading(&scan, this, remaining);
this.InputProcessor.Bits = default(Bits); this.InputProcessor.Bits = default(Bits);
this.MakeImage(); this.MakeImage();
scan.DecodeBlocks(this); scan.DecodeBlocks(this);
@ -508,11 +508,11 @@ namespace ImageSharp.Formats.Jpeg.GolangPort
// See http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/JPEG.html#Adobe // See http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/JPEG.html#Adobe
// See https://docs.oracle.com/javase/8/docs/api/javax/imageio/metadata/doc-files/jpeg_metadata.html // See https://docs.oracle.com/javase/8/docs/api/javax/imageio/metadata/doc-files/jpeg_metadata.html
// TODO: YCbCrA? // TODO: YCbCrA?
if (this.adobeTransform == JpegConstants.Adobe.ColorTransformYcck) if (this.adobeTransform == OldJpegConstants.Adobe.ColorTransformYcck)
{ {
this.ConvertFromYcck(image); this.ConvertFromYcck(image);
} }
else if (this.adobeTransform == JpegConstants.Adobe.ColorTransformUnknown) else if (this.adobeTransform == OldJpegConstants.Adobe.ColorTransformUnknown)
{ {
// Assume CMYK // Assume CMYK
this.ConvertFromCmyk(image); this.ConvertFromCmyk(image);
@ -764,7 +764,7 @@ namespace ImageSharp.Formats.Jpeg.GolangPort
return false; return false;
} }
if (this.adobeTransformValid && this.adobeTransform == JpegConstants.Adobe.ColorTransformUnknown) if (this.adobeTransformValid && this.adobeTransform == OldJpegConstants.Adobe.ColorTransformUnknown)
{ {
// http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/JPEG.html#Adobe // http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/JPEG.html#Adobe
// says that 0 means Unknown (and in practice RGB) and 1 means YCbCr. // says that 0 means Unknown (and in practice RGB) and 1 means YCbCr.

32
src/ImageSharp/Formats/Jpeg/GolangPort/JpegEncoderCore.cs

@ -59,7 +59,7 @@ namespace ImageSharp.Formats.Jpeg.GolangPort
/// </summary> /// </summary>
private static readonly byte[] SosHeaderYCbCr = private static readonly byte[] SosHeaderYCbCr =
{ {
JpegConstants.Markers.XFF, JpegConstants.Markers.SOS, OldJpegConstants.Markers.XFF, OldJpegConstants.Markers.SOS,
// Marker // Marker
0x00, 0x0c, 0x00, 0x0c,
@ -198,7 +198,7 @@ namespace ImageSharp.Formats.Jpeg.GolangPort
Guard.NotNull(image, nameof(image)); Guard.NotNull(image, nameof(image));
Guard.NotNull(stream, nameof(stream)); Guard.NotNull(stream, nameof(stream));
ushort max = JpegConstants.MaxLength; ushort max = OldJpegConstants.MaxLength;
if (image.Width >= max || image.Height >= max) if (image.Width >= max || image.Height >= max)
{ {
throw new ImageFormatException($"Image is too large to encode at {image.Width}x{image.Height}."); throw new ImageFormatException($"Image is too large to encode at {image.Width}x{image.Height}.");
@ -247,8 +247,8 @@ namespace ImageSharp.Formats.Jpeg.GolangPort
} }
// Write the End Of Image marker. // Write the End Of Image marker.
this.buffer[0] = JpegConstants.Markers.XFF; this.buffer[0] = OldJpegConstants.Markers.XFF;
this.buffer[1] = JpegConstants.Markers.EOI; this.buffer[1] = OldJpegConstants.Markers.EOI;
stream.Write(this.buffer, 0, 2); stream.Write(this.buffer, 0, 2);
stream.Flush(); stream.Flush();
} }
@ -509,12 +509,12 @@ namespace ImageSharp.Formats.Jpeg.GolangPort
private void WriteApplicationHeader(short horizontalResolution, short verticalResolution) private void WriteApplicationHeader(short horizontalResolution, short verticalResolution)
{ {
// Write the start of image marker. Markers are always prefixed with with 0xff. // Write the start of image marker. Markers are always prefixed with with 0xff.
this.buffer[0] = JpegConstants.Markers.XFF; this.buffer[0] = OldJpegConstants.Markers.XFF;
this.buffer[1] = JpegConstants.Markers.SOI; this.buffer[1] = OldJpegConstants.Markers.SOI;
// Write the JFIF headers // Write the JFIF headers
this.buffer[2] = JpegConstants.Markers.XFF; this.buffer[2] = OldJpegConstants.Markers.XFF;
this.buffer[3] = JpegConstants.Markers.APP0; // Application Marker this.buffer[3] = OldJpegConstants.Markers.APP0; // Application Marker
this.buffer[4] = 0x00; this.buffer[4] = 0x00;
this.buffer[5] = 0x10; this.buffer[5] = 0x10;
this.buffer[6] = 0x4a; // J this.buffer[6] = 0x4a; // J
@ -628,7 +628,7 @@ namespace ImageSharp.Formats.Jpeg.GolangPort
markerlen += 1 + 16 + s.Values.Length; markerlen += 1 + 16 + s.Values.Length;
} }
this.WriteMarkerHeader(JpegConstants.Markers.DHT, markerlen); this.WriteMarkerHeader(OldJpegConstants.Markers.DHT, markerlen);
for (int i = 0; i < specs.Length; i++) for (int i = 0; i < specs.Length; i++)
{ {
HuffmanSpec spec = specs[i]; HuffmanSpec spec = specs[i];
@ -662,7 +662,7 @@ namespace ImageSharp.Formats.Jpeg.GolangPort
{ {
// Marker + quantization table lengths // Marker + quantization table lengths
int markerlen = 2 + (QuantizationTableCount * (1 + Block8x8F.ScalarCount)); int markerlen = 2 + (QuantizationTableCount * (1 + Block8x8F.ScalarCount));
this.WriteMarkerHeader(JpegConstants.Markers.DQT, markerlen); this.WriteMarkerHeader(OldJpegConstants.Markers.DQT, markerlen);
// Loop through and collect the tables as one array. // Loop through and collect the tables as one array.
// This allows us to reduce the number of writes to the stream. // This allows us to reduce the number of writes to the stream.
@ -700,8 +700,8 @@ namespace ImageSharp.Formats.Jpeg.GolangPort
int length = data.Length + 2; int length = data.Length + 2;
this.buffer[0] = JpegConstants.Markers.XFF; this.buffer[0] = OldJpegConstants.Markers.XFF;
this.buffer[1] = JpegConstants.Markers.APP1; // Application Marker this.buffer[1] = OldJpegConstants.Markers.APP1; // Application Marker
this.buffer[2] = (byte)((length >> 8) & 0xFF); this.buffer[2] = (byte)((length >> 8) & 0xFF);
this.buffer[3] = (byte)(length & 0xFF); this.buffer[3] = (byte)(length & 0xFF);
@ -759,8 +759,8 @@ namespace ImageSharp.Formats.Jpeg.GolangPort
dataLength -= length; dataLength -= length;
this.buffer[0] = JpegConstants.Markers.XFF; this.buffer[0] = OldJpegConstants.Markers.XFF;
this.buffer[1] = JpegConstants.Markers.APP2; // Application Marker this.buffer[1] = OldJpegConstants.Markers.APP2; // Application Marker
int markerLength = length + 16; int markerLength = length + 16;
this.buffer[2] = (byte)((markerLength >> 8) & 0xFF); this.buffer[2] = (byte)((markerLength >> 8) & 0xFF);
this.buffer[3] = (byte)(markerLength & 0xFF); this.buffer[3] = (byte)(markerLength & 0xFF);
@ -832,7 +832,7 @@ namespace ImageSharp.Formats.Jpeg.GolangPort
// Length (high byte, low byte), 8 + components * 3. // Length (high byte, low byte), 8 + components * 3.
int markerlen = 8 + (3 * componentCount); int markerlen = 8 + (3 * componentCount);
this.WriteMarkerHeader(JpegConstants.Markers.SOF0, markerlen); this.WriteMarkerHeader(OldJpegConstants.Markers.SOF0, markerlen);
this.buffer[0] = 8; // Data Precision. 8 for now, 12 and 16 bit jpegs not supported this.buffer[0] = 8; // Data Precision. 8 for now, 12 and 16 bit jpegs not supported
this.buffer[1] = (byte)(height >> 8); this.buffer[1] = (byte)(height >> 8);
this.buffer[2] = (byte)(height & 0xff); // (2 bytes, Hi-Lo), must be > 0 if DNL not supported this.buffer[2] = (byte)(height & 0xff); // (2 bytes, Hi-Lo), must be > 0 if DNL not supported
@ -975,7 +975,7 @@ namespace ImageSharp.Formats.Jpeg.GolangPort
private void WriteMarkerHeader(byte marker, int length) private void WriteMarkerHeader(byte marker, int length)
{ {
// Markers are always prefixed with with 0xff. // Markers are always prefixed with with 0xff.
this.buffer[0] = JpegConstants.Markers.XFF; this.buffer[0] = OldJpegConstants.Markers.XFF;
this.buffer[1] = marker; this.buffer[1] = marker;
this.buffer[2] = (byte)(length >> 8); this.buffer[2] = (byte)(length >> 8);
this.buffer[3] = (byte)(length & 0xff); this.buffer[3] = (byte)(length & 0xff);

2
src/ImageSharp/Formats/Jpeg/GolangPort/JpegConstants.cs → src/ImageSharp/Formats/Jpeg/GolangPort/OldJpegConstants.cs

@ -10,7 +10,7 @@ namespace ImageSharp.Formats.Jpeg.GolangPort
/// <summary> /// <summary>
/// Defines jpeg constants defined in the specification. /// Defines jpeg constants defined in the specification.
/// </summary> /// </summary>
internal static class JpegConstants internal static class OldJpegConstants
{ {
/// <summary> /// <summary>
/// The maximum allowable length in each dimension of a jpeg image. /// The maximum allowable length in each dimension of a jpeg image.

2
src/ImageSharp/Formats/Jpeg/GolangPort/Utils/JpegUtils.cs → src/ImageSharp/Formats/Jpeg/GolangPort/Utils/OldJpegUtils.cs

@ -12,7 +12,7 @@ namespace ImageSharp.Formats.Jpeg.GolangPort.Utils
/// <summary> /// <summary>
/// Jpeg specific utilities and extension methods /// Jpeg specific utilities and extension methods
/// </summary> /// </summary>
internal static unsafe class JpegUtils internal static unsafe class OldJpegUtils
{ {
/// <summary> /// <summary>
/// Copy a region of an image into dest. De "outlier" area will be stretched out with pixels on the right and bottom of the image. /// Copy a region of an image into dest. De "outlier" area will be stretched out with pixels on the right and bottom of the image.

4
src/ImageSharp/Formats/Jpeg/JpegFormat.cs

@ -21,9 +21,9 @@ namespace ImageSharp.Formats
public string DefaultMimeType => "image/jpeg"; public string DefaultMimeType => "image/jpeg";
/// <inheritdoc/> /// <inheritdoc/>
public IEnumerable<string> MimeTypes => JpegConstants.MimeTypes; public IEnumerable<string> MimeTypes => OldJpegConstants.MimeTypes;
/// <inheritdoc/> /// <inheritdoc/>
public IEnumerable<string> FileExtensions => JpegConstants.FileExtensions; public IEnumerable<string> FileExtensions => OldJpegConstants.FileExtensions;
} }
} }
Loading…
Cancel
Save