Browse Source

fixed #159 for the other known case, test image is too big though, won't add it

pull/322/head
Anton Firszov 9 years ago
parent
commit
e696d99490
  1. 7
      src/ImageSharp/Formats/Jpeg/GolangPort/Components/Decoder/InputProcessor.cs
  2. 11
      src/ImageSharp/Formats/Jpeg/GolangPort/Components/Decoder/OrigJpegScanDecoder.cs
  3. 2
      tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.cs
  4. 1
      tests/ImageSharp.Tests/TestImages.cs

7
src/ImageSharp/Formats/Jpeg/GolangPort/Components/Decoder/InputProcessor.cs

@ -245,7 +245,12 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.GolangPort.Components.Decoder
{
if (this.Bits.UnreadBits == 0)
{
this.Bits.EnsureNBits(1, ref this);
this.LastErrorCode = this.Bits.EnsureNBitsUnsafe(1, ref this);
if (this.HasError)
{
return this.LastErrorCode;
}
}
if ((this.Bits.Accumulator & this.Bits.Mask) != 0)

11
src/ImageSharp/Formats/Jpeg/GolangPort/Components/Decoder/OrigJpegScanDecoder.cs

@ -137,6 +137,8 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.GolangPort.Components.Decoder
/// <param name="decoder">The <see cref="OrigJpegDecoderCore"/> instance</param>
public void DecodeBlocks(OrigJpegDecoderCore decoder)
{
decoder.InputProcessor.ResetErrorState();
int blockCount = 0;
int mcu = 0;
byte expectedRst = OrigJpegConstants.Markers.RST0;
@ -364,7 +366,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.GolangPort.Components.Decoder
{
int value;
decoder.InputProcessor.DecodeHuffmanUnsafe(ref decoder.HuffmanTrees[huffmannIdx], out value);
if (!decoder.InputProcessor.CheckEOF())
if (decoder.InputProcessor.HasError)
{
return;
}
@ -381,11 +383,16 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.GolangPort.Components.Decoder
int ac;
decoder.InputProcessor.ReceiveExtendUnsafe(val1, out ac);
if (!decoder.InputProcessor.CheckEOFEnsureNoError())
if (decoder.InputProcessor.HasError)
{
return;
}
//if (!decoder.InputProcessor.CheckEOFEnsureNoError())
//{
// return;
//}
// b[Unzig[zig]] = ac << al;
value = ac << this.al;
Block8x8.SetScalarAt(b, this.pointers.Unzig[zig], (short)value);

2
tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.cs

@ -37,8 +37,6 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg
TestImages.Jpeg.Baseline.Jpeg444,
TestImages.Jpeg.Baseline.Bad.BadEOF,
TestImages.Jpeg.Baseline.Bad.ExifUndefType,
TestImages.Jpeg.Issues.MissingFF00Gear159,
};
public static string[] ProgressiveTestJpegs =

1
tests/ImageSharp.Tests/TestImages.cs

@ -117,7 +117,6 @@ namespace SixLabors.ImageSharp.Tests
{
public const string CriticalEOF214 = "Jpg/issues/Issue214-CriticalEOF.jpg";
public const string MissingFF00ProgressiveGirl159 = "Jpg/issues/Issue159-MissingFF00-Progressive-Girl.jpg";
public const string MissingFF00Gear159 = "Jpg/issues/Issue159-MissingFF00-Gear.jpg";
public const string BadCoeffsProgressive178 = "Jpg/issues/Issue178-BadCoeffsProgressive-Lemon.jpg";
}

Loading…
Cancel
Save