Browse Source

better names and comments

pull/90/head
Anton Firszov 10 years ago
parent
commit
cc33a8abed
  1. 13
      src/ImageSharp.Formats.Jpeg/Components/Decoder/JpegScanDecoder.cs
  2. 8
      src/ImageSharp.Formats.Jpeg/JpegDecoderCore.cs

13
src/ImageSharp.Formats.Jpeg/Components/Decoder/JpegScanDecoder.cs

@ -10,6 +10,7 @@ namespace ImageSharp.Formats.Jpg
/// <summary> /// <summary>
/// Encapsulates the impementation of Jpeg SOS decoder. See JpegScanDecoder.md! /// Encapsulates the impementation of Jpeg SOS decoder. See JpegScanDecoder.md!
/// TODO: Split JpegScanDecoder: 1. JpegScanDecoder for Huffman-decoding (<see cref="DecodeBlocks"/>) 2. JpegBlockProcessor for processing (<see cref="ProcessBlockColors"/>)
/// <see cref="zigStart"/> and <see cref="zigEnd"/> are the spectral selection bounds. /// <see cref="zigStart"/> and <see cref="zigEnd"/> are the spectral selection bounds.
/// <see cref="ah"/> and <see cref="al"/> are the successive approximation high and low values. /// <see cref="ah"/> and <see cref="al"/> are the successive approximation high and low values.
/// The spec calls these values Ss, Se, Ah and Al. /// The spec calls these values Ss, Se, Ah and Al.
@ -131,7 +132,9 @@ namespace ImageSharp.Formats.Jpg
} }
/// <summary> /// <summary>
/// Reads the blocks from the <see cref="JpegDecoderCore"/>-s stream, and processes them into the corresponding <see cref="JpegPixelArea"/> instances. /// Read Huffman data from Jpeg scans in <see cref="JpegDecoderCore.InputStream"/>,
/// and decode it as <see cref="Block8x8F"/> into <see cref="JpegDecoderCore.DecodedBlocks"/>.
///
/// The blocks are traversed one MCU at a time. For 4:2:0 chroma /// The blocks are traversed one MCU at a time. For 4:2:0 chroma
/// subsampling, there are four Y 8x8 blocks in every 16x16 MCU. /// subsampling, there are four Y 8x8 blocks in every 16x16 MCU.
/// For a baseline 32x16 pixel image, the Y blocks visiting order is: /// For a baseline 32x16 pixel image, the Y blocks visiting order is:
@ -156,7 +159,7 @@ namespace ImageSharp.Formats.Jpg
/// 3 4 5 /// 3 4 5
/// </summary> /// </summary>
/// <param name="decoder">The <see cref="JpegDecoderCore"/> instance</param> /// <param name="decoder">The <see cref="JpegDecoderCore"/> instance</param>
public void ReadBlocks(JpegDecoderCore decoder) public void DecodeBlocks(JpegDecoderCore decoder)
{ {
int blockCount = 0; int blockCount = 0;
int mcu = 0; int mcu = 0;
@ -191,7 +194,7 @@ namespace ImageSharp.Formats.Jpg
} }
} }
this.ReadBlock(decoder, scanIndex); this.DecodeBlock(decoder, scanIndex);
} }
// for j // for j
@ -236,7 +239,7 @@ namespace ImageSharp.Formats.Jpg
/// Dequantize, perform the inverse DCT and store the block to the into the corresponding <see cref="JpegPixelArea"/> instances. /// Dequantize, perform the inverse DCT and store the block to the into the corresponding <see cref="JpegPixelArea"/> instances.
/// </summary> /// </summary>
/// <param name="decoder">The <see cref="JpegDecoderCore"/> instance</param> /// <param name="decoder">The <see cref="JpegDecoderCore"/> instance</param>
public void ProcessBlock(JpegDecoderCore decoder) public void ProcessBlockColors(JpegDecoderCore decoder)
{ {
int qtIndex = decoder.ComponentArray[this.ComponentIndex].Selector; int qtIndex = decoder.ComponentArray[this.ComponentIndex].Selector;
this.data.QuantiazationTable = decoder.QuantizationTables[qtIndex]; this.data.QuantiazationTable = decoder.QuantizationTables[qtIndex];
@ -329,7 +332,7 @@ namespace ImageSharp.Formats.Jpg
/// </summary> /// </summary>
/// <param name="decoder">The decoder</param> /// <param name="decoder">The decoder</param>
/// <param name="scanIndex">The index of the scan</param> /// <param name="scanIndex">The index of the scan</param>
private void ReadBlock(JpegDecoderCore decoder, int scanIndex) private void DecodeBlock(JpegDecoderCore decoder, int scanIndex)
{ {
int blockIndex = this.GetBlockIndex(decoder); int blockIndex = this.GetBlockIndex(decoder);
this.data.Block = decoder.DecodedBlocks[this.ComponentIndex][blockIndex].Block; this.data.Block = decoder.DecodedBlocks[this.ComponentIndex][blockIndex].Block;

8
src/ImageSharp.Formats.Jpeg/JpegDecoderCore.cs

@ -181,7 +181,7 @@ namespace ImageSharp.Formats
this.ProcessStream(image, stream, metadataOnly); this.ProcessStream(image, stream, metadataOnly);
if (!metadataOnly) if (!metadataOnly)
{ {
this.DecodeBlocksIntoJpegImageChannels<TColor>(); this.ProcessBlockColorsIntoJpegImageChannels<TColor>();
this.ConvertJpegPixelsToImagePixels(image); this.ConvertJpegPixelsToImagePixels(image);
} }
} }
@ -636,7 +636,7 @@ namespace ImageSharp.Formats
/// Process the blocks in <see cref="DecodedBlocks"/> into Jpeg image channels (<see cref="YCbCrImage"/> and <see cref="JpegPixelArea"/>) /// Process the blocks in <see cref="DecodedBlocks"/> into Jpeg image channels (<see cref="YCbCrImage"/> and <see cref="JpegPixelArea"/>)
/// </summary> /// </summary>
/// <typeparam name="TColor">The pixel type</typeparam> /// <typeparam name="TColor">The pixel type</typeparam>
private void DecodeBlocksIntoJpegImageChannels<TColor>() private void ProcessBlockColorsIntoJpegImageChannels<TColor>()
where TColor : struct, IPackedPixel, IEquatable<TColor> where TColor : struct, IPackedPixel, IEquatable<TColor>
{ {
JpegScanDecoder scanDecoder = default(JpegScanDecoder); JpegScanDecoder scanDecoder = default(JpegScanDecoder);
@ -649,7 +649,7 @@ namespace ImageSharp.Formats
for (int i = 0; i < blockArray.Length; i++) for (int i = 0; i < blockArray.Length; i++)
{ {
scanDecoder.LoadMemento(ref blockArray[i]); scanDecoder.LoadMemento(ref blockArray[i]);
scanDecoder.ProcessBlock(this); scanDecoder.ProcessBlockColors(this);
} }
} }
} }
@ -1499,7 +1499,7 @@ namespace ImageSharp.Formats
JpegScanDecoder.InitStreamReading(&scan, this, remaining); JpegScanDecoder.InitStreamReading(&scan, this, remaining);
this.Bits = default(Bits); this.Bits = default(Bits);
this.MakeImage(); this.MakeImage();
scan.ReadBlocks(this); scan.DecodeBlocks(this);
} }
/// <summary> /// <summary>

Loading…
Cancel
Save