Browse Source

Fix tests

af/merge-core
James Jackson-South 9 years ago
parent
commit
2f48d33d2f
  1. 2
      src/ImageSharp/Formats/Jpeg/Port/Components/ScanDecoder.cs
  2. 9
      src/ImageSharp/Formats/Jpeg/Port/JpegDecoderCore.cs
  3. 2
      tests/ImageSharp.Tests/FileTestBase.cs
  4. 4
      tests/ImageSharp.Tests/TestFile.cs

2
src/ImageSharp/Formats/Jpeg/Port/Components/ScanDecoder.cs

@ -621,6 +621,8 @@ namespace ImageSharp.Formats.Jpeg.Port.Components
short code = -1;
// TODO: Adding this code introduces error into the decoder.
// NOTES # During investigation of the libjpeg implementation it appears that they pull 32bits at a time and operate on those bits
// using 3 methods: FillBits, PeekBits, and ReadBits. We should attempt to do the same.
// It doesn't appear to speed anything up either.
// if (this.bitsUnRead < 8)
// {

9
src/ImageSharp/Formats/Jpeg/Port/JpegDecoderCore.cs

@ -542,11 +542,6 @@ namespace ImageSharp.Formats.Jpeg.Port
remaining--;
int quantizationTableSpec = this.InputStream.ReadByte();
if (quantizationTableSpec > 3)
{
throw new ImageFormatException($"Bad Tq index value: {quantizationTableSpec}");
}
switch (quantizationTableSpec >> 4)
{
case 0:
@ -561,7 +556,7 @@ namespace ImageSharp.Formats.Jpeg.Port
this.InputStream.Read(this.temp, 0, 64);
remaining -= 64;
Span<short> tableSpan = this.quantizationTables.Tables.GetRowSpan(quantizationTableSpec);
Span<short> tableSpan = this.quantizationTables.Tables.GetRowSpan(quantizationTableSpec & 15);
for (int j = 0; j < 64; j++)
{
tableSpan[QuantizationTables.DctZigZag[j]] = this.temp[j];
@ -581,7 +576,7 @@ namespace ImageSharp.Formats.Jpeg.Port
this.InputStream.Read(this.temp, 0, 128);
remaining -= 128;
Span<short> tableSpan = this.quantizationTables.Tables.GetRowSpan(quantizationTableSpec);
Span<short> tableSpan = this.quantizationTables.Tables.GetRowSpan(quantizationTableSpec & 15);
for (int j = 0; j < 64; j++)
{
tableSpan[QuantizationTables.DctZigZag[j]] = (short)((this.temp[2 * j] << 8) | this.temp[(2 * j) + 1]);

2
tests/ImageSharp.Tests/FileTestBase.cs

@ -70,7 +70,9 @@ namespace ImageSharp.Tests
// TestFile.Create(TestImages.Jpeg.Baseline.Ycck), // Perf: Enable for local testing only
// TestFile.Create(TestImages.Jpeg.Baseline.Cmyk), // Perf: Enable for local testing only
// TestFile.Create(TestImages.Jpeg.Baseline.Floorplan), // Perf: Enable for local testing only
// TestFile.Create(TestImages.Jpeg.Progressive.Festzug), // Perf: Enable for local testing only
// TestFile.Create(TestImages.Jpeg.Baseline.Bad.MissingEOF), // Perf: Enable for local testing only
// TestFile.Create(TestImages.Jpeg.Baseline.Bad.ExifUndefType), // Perf: Enable for local testing only
// TestFile.Create(TestImages.Jpeg.Progressive.Fb), // Perf: Enable for local testing only
// TestFile.Create(TestImages.Jpeg.Progressive.Progress), // Perf: Enable for local testing only
// TestFile.Create(TestImages.Jpeg.Baseline.GammaDalaiLamaGray), // Perf: Enable for local testing only

4
tests/ImageSharp.Tests/TestFile.cs

@ -116,7 +116,7 @@ namespace ImageSharp.Tests
/// </returns>
public string GetFileNameWithoutExtension(object value)
{
return this.FileNameWithoutExtension + "-" + value;
return $"{this.FileNameWithoutExtension}-{value}";
}
/// <summary>
@ -138,7 +138,7 @@ namespace ImageSharp.Tests
/// </returns>
public Image<Rgba32> CreateImage(IImageDecoder decoder)
{
return Image.Load(this.image.Configuration, this.Bytes, decoder);
return Image.Load(this.GetImage().Configuration, this.Bytes, decoder);
}
private Image<Rgba32> GetImage()

Loading…
Cancel
Save