Browse Source

Added comments

Added comments to the huffman spec
pull/1673/head
Dmitry Pentin 5 years ago
parent
commit
960145b8df
  1. 4
      src/ImageSharp/Formats/Jpeg/Components/Encoder/HuffmanScanEncoder.cs
  2. 8
      src/ImageSharp/Formats/Jpeg/Components/Encoder/HuffmanSpec.cs

4
src/ImageSharp/Formats/Jpeg/Components/Encoder/HuffmanScanEncoder.cs

@ -306,6 +306,10 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Components.Encoder
{
byte b = (byte)(bits >> 24);
this.emitBuffer[this.emitLen++] = b;
// Adding stuff byte
// This is because by JPEG standard scan data can contain JPEG markers (indicated by the 0xFF byte, followed by a non-zero byte)
// Considering this every 0xFF byte must be followed by 0x00 padding byte to signal that this is not a marker
if (b == byte.MaxValue)
{
this.emitBuffer[this.emitLen++] = byte.MinValue;

8
src/ImageSharp/Formats/Jpeg/Components/Encoder/HuffmanSpec.cs

@ -1,4 +1,4 @@
// Copyright (c) Six Labors.
// Copyright (c) Six Labors.
// Licensed under the Apache License, Version 2.0.
namespace SixLabors.ImageSharp.Formats.Jpeg.Components.Encoder
@ -27,6 +27,8 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Components.Encoder
{
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11
}),
// Luminance AC.
new HuffmanSpec(
new byte[]
{
@ -60,6 +62,8 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Components.Encoder
0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8,
0xf9, 0xfa
}),
// Chrominance DC.
new HuffmanSpec(
new byte[]
{
@ -132,4 +136,4 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Components.Encoder
this.Values = values;
}
}
}
}

Loading…
Cancel
Save