Skip to content

Commit

Permalink
prefixing GolangPort stuff with Old*** #Round1
Browse files Browse the repository at this point in the history
  • Loading branch information
antonfirsov committed Aug 18, 2017
1 parent 80380d9 commit 51b430b
Show file tree
Hide file tree
Showing 11 changed files with 66 additions and 66 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public DecoderErrorCode ReadByteStuffedByteUnsafe(Stream inputStream, out int x)
x = this.BufferAsInt[this.I];
this.I++;
this.UnreadableBytes = 1;
if (x != JpegConstants.Markers.XFFInt)
if (x != OldJpegConstants.Markers.XFFInt)
{
return DecoderErrorCode.NoError;
}
Expand All @@ -107,7 +107,7 @@ public DecoderErrorCode ReadByteStuffedByteUnsafe(Stream inputStream, out int x)

this.I++;
this.UnreadableBytes = 2;
x = JpegConstants.Markers.XFF;
x = OldJpegConstants.Markers.XFF;
return DecoderErrorCode.NoError;
}

Expand All @@ -120,7 +120,7 @@ public DecoderErrorCode ReadByteStuffedByteUnsafe(Stream inputStream, out int x)
return errorCode;
}

if (x != JpegConstants.Markers.XFF)
if (x != OldJpegConstants.Markers.XFF)
{
return DecoderErrorCode.NoError;
}
Expand All @@ -137,7 +137,7 @@ public DecoderErrorCode ReadByteStuffedByteUnsafe(Stream inputStream, out int x)
return DecoderErrorCode.MissingFF00;
}

x = JpegConstants.Markers.XFF;
x = OldJpegConstants.Markers.XFF;
return DecoderErrorCode.NoError;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace ImageSharp.Formats.Jpeg.GolangPort.Components.Decoder
/// <summary>
/// Represents a single color component
/// </summary>
internal struct Component
internal struct OldComponent
{
/// <summary>
/// Gets or sets the horizontal sampling factor.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace ImageSharp.Formats.Jpeg.GolangPort.Components.Decoder
/// Represents a component scan
/// </summary>
[StructLayout(LayoutKind.Sequential)]
internal struct ComponentScan
internal struct OldComponentScan
{
/// <summary>
/// Gets or sets the component index.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace ImageSharp.Formats.Jpeg.GolangPort.Components.Decoder
/// <content>
/// Conains the definition of <see cref="ComputationData"/>
/// </content>
internal unsafe partial struct JpegScanDecoder
internal unsafe partial struct OldJpegScanDecoder
{
/// <summary>
/// Holds the "large" data blocks needed for computations.
Expand All @@ -30,7 +30,7 @@ public struct ComputationData
public UnzigData Unzig;

/// <summary>
/// The buffer storing the <see cref="ComponentScan"/>-s for each component
/// The buffer storing the <see cref="OldComponentScan"/>-s for each component
/// </summary>
public fixed byte ScanData[3 * JpegDecoderCore.MaxComponents];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace ImageSharp.Formats.Jpeg.GolangPort.Components.Decoder
/// <content>
/// Conains the definition of <see cref="DataPointers"/>
/// </content>
internal unsafe partial struct JpegScanDecoder
internal unsafe partial struct OldJpegScanDecoder
{
/// <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"/>
Expand All @@ -30,7 +30,7 @@ public struct DataPointers
/// <summary>
/// Pointer to <see cref="ComputationData.ScanData"/> as Scan*
/// </summary>
public ComponentScan* ComponentScan;
public OldComponentScan* ComponentScan;

/// <summary>
/// Pointer to <see cref="ComputationData.Dc"/>
Expand All @@ -45,7 +45,7 @@ public DataPointers(ComputationData* basePtr)
{
this.Block = &basePtr->Block;
this.Unzig = basePtr->Unzig.Data;
this.ComponentScan = (ComponentScan*)basePtr->ScanData;
this.ComponentScan = (OldComponentScan*)basePtr->ScanData;
this.Dc = basePtr->Dc;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ namespace ImageSharp.Formats.Jpeg.GolangPort.Components.Decoder
/// For baseline JPEGs, these parameters are hard-coded to 0/63/0/0.
/// </summary>
[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.
#pragma warning disable SA1202 // ElementsMustBeOrderedByAccess
Expand Down Expand Up @@ -96,12 +96,12 @@ internal unsafe partial struct JpegScanDecoder
private int eobRun;

/// <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>
/// <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="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->pointers = new DataPointers(&p->data);
Expand Down Expand Up @@ -140,7 +140,7 @@ public void DecodeBlocks(JpegDecoderCore decoder)
{
int blockCount = 0;
int mcu = 0;
byte expectedRst = JpegConstants.Markers.RST0;
byte expectedRst = OldJpegConstants.Markers.RST0;

for (int my = 0; my < decoder.MCUCountY; my++)
{
Expand Down Expand Up @@ -206,9 +206,9 @@ public void DecodeBlocks(JpegDecoderCore decoder)
}

expectedRst++;
if (expectedRst == JpegConstants.Markers.RST7 + 1)
if (expectedRst == OldJpegConstants.Markers.RST7 + 1)
{
expectedRst = JpegConstants.Markers.RST0;
expectedRst = OldJpegConstants.Markers.RST0;
}
}
}
Expand Down Expand Up @@ -434,7 +434,7 @@ private int GetBlockIndex(JpegDecoderCore decoder)
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.
int cs = decoder.Temp[1 + (2 * i)];
Expand All @@ -461,9 +461,9 @@ private void InitComponentScan(JpegDecoderCore decoder, int i, ref ComponentScan
private void ProcessComponentImpl(
JpegDecoderCore decoder,
int i,
ref ComponentScan currentComponentScan,
ref OldComponentScan currentComponentScan,
ref int totalHv,
ref Component currentComponent)
ref OldComponent 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
Expand Down
50 changes: 25 additions & 25 deletions src/ImageSharp/Formats/Jpeg/GolangPort/JpegDecoderCore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,14 +108,14 @@ public JpegDecoderCore(Configuration configuration, IJpegDecoderOptions options)
this.HuffmanTrees = HuffmanTree.CreateHuffmanTrees();
this.QuantizationTables = new Block8x8F[MaxTq + 1];
this.Temp = new byte[2 * Block8x8F.ScalarCount];
this.ComponentArray = new Component[MaxComponents];
this.ComponentArray = new OldComponent[MaxComponents];
this.DecodedBlocks = new Buffer<DecodedBlock>[MaxComponents];
}

/// <summary>
/// Gets the component array
/// </summary>
public Component[] ComponentArray { get; }
public OldComponent[] ComponentArray { get; }

/// <summary>
/// Gets the huffman trees
Expand Down Expand Up @@ -272,7 +272,7 @@ private void ProcessStream(ImageMetaData metadata, Stream stream, bool metadataO

// Check for the Start Of Image marker.
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.");
}
Expand Down Expand Up @@ -322,12 +322,12 @@ private void ProcessStream(ImageMetaData metadata, Stream stream, bool metadataO
}

// End Of Image.
if (marker == JpegConstants.Markers.EOI)
if (marker == OldJpegConstants.Markers.EOI)
{
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
// only occur between Entropy Coded Segments and not after the final ECS.
Expand All @@ -349,18 +349,18 @@ private void ProcessStream(ImageMetaData metadata, Stream stream, bool metadataO

switch (marker)
{
case JpegConstants.Markers.SOF0:
case JpegConstants.Markers.SOF1:
case JpegConstants.Markers.SOF2:
this.IsProgressive = marker == JpegConstants.Markers.SOF2;
case OldJpegConstants.Markers.SOF0:
case OldJpegConstants.Markers.SOF1:
case OldJpegConstants.Markers.SOF2:
this.IsProgressive = marker == OldJpegConstants.Markers.SOF2;
this.ProcessStartOfFrameMarker(remaining);
if (metadataOnly && this.isJfif)
{
return;
}

break;
case JpegConstants.Markers.DHT:
case OldJpegConstants.Markers.DHT:
if (metadataOnly)
{
this.InputProcessor.Skip(remaining);
Expand All @@ -371,7 +371,7 @@ private void ProcessStream(ImageMetaData metadata, Stream stream, bool metadataO
}

break;
case JpegConstants.Markers.DQT:
case OldJpegConstants.Markers.DQT:
if (metadataOnly)
{
this.InputProcessor.Skip(remaining);
Expand All @@ -382,7 +382,7 @@ private void ProcessStream(ImageMetaData metadata, Stream stream, bool metadataO
}

break;
case JpegConstants.Markers.SOS:
case OldJpegConstants.Markers.SOS:
if (metadataOnly)
{
return;
Expand All @@ -398,7 +398,7 @@ private void ProcessStream(ImageMetaData metadata, Stream stream, bool metadataO
}

break;
case JpegConstants.Markers.DRI:
case OldJpegConstants.Markers.DRI:
if (metadataOnly)
{
this.InputProcessor.Skip(remaining);
Expand All @@ -409,25 +409,25 @@ private void ProcessStream(ImageMetaData metadata, Stream stream, bool metadataO
}

break;
case JpegConstants.Markers.APP0:
case OldJpegConstants.Markers.APP0:
this.ProcessApplicationHeader(remaining);
break;
case JpegConstants.Markers.APP1:
case OldJpegConstants.Markers.APP1:
this.ProcessApp1Marker(remaining, metadata);
break;
case JpegConstants.Markers.APP2:
case OldJpegConstants.Markers.APP2:
this.ProcessApp2Marker(remaining, metadata);
break;
case JpegConstants.Markers.APP14:
case OldJpegConstants.Markers.APP14:
this.ProcessApp14Marker(remaining);
break;
default:
if ((marker >= JpegConstants.Markers.APP0 && marker <= JpegConstants.Markers.APP15)
|| marker == JpegConstants.Markers.COM)
if ((marker >= OldJpegConstants.Markers.APP0 && marker <= OldJpegConstants.Markers.APP15)
|| marker == OldJpegConstants.Markers.COM)
{
this.InputProcessor.Skip(remaining);
}
else if (marker < JpegConstants.Markers.SOF0)
else if (marker < OldJpegConstants.Markers.SOF0)
{
// See Table B.1 "Marker code assignments".
throw new ImageFormatException("Unknown marker");
Expand All @@ -452,8 +452,8 @@ private void ProcessStream(ImageMetaData metadata, Stream stream, bool metadataO
/// </exception>
private void ProcessStartOfScan(int remaining)
{
JpegScanDecoder scan = default(JpegScanDecoder);
JpegScanDecoder.InitStreamReading(&scan, this, remaining);
OldJpegScanDecoder scan = default(OldJpegScanDecoder);
OldJpegScanDecoder.InitStreamReading(&scan, this, remaining);
this.InputProcessor.Bits = default(Bits);
this.MakeImage();
scan.DecodeBlocks(this);
Expand Down Expand Up @@ -508,11 +508,11 @@ private Image<TPixel> ConvertJpegPixelsToImagePixels<TPixel>(ImageMetaData metad
// 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
// TODO: YCbCrA?
if (this.adobeTransform == JpegConstants.Adobe.ColorTransformYcck)
if (this.adobeTransform == OldJpegConstants.Adobe.ColorTransformYcck)
{
this.ConvertFromYcck(image);
}
else if (this.adobeTransform == JpegConstants.Adobe.ColorTransformUnknown)
else if (this.adobeTransform == OldJpegConstants.Adobe.ColorTransformUnknown)
{
// Assume CMYK
this.ConvertFromCmyk(image);
Expand Down Expand Up @@ -764,7 +764,7 @@ private bool IsRGB()
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
// says that 0 means Unknown (and in practice RGB) and 1 means YCbCr.
Expand Down
Loading

0 comments on commit 51b430b

Please sign in to comment.