From bc50fc76cbcf034117299c3b205046e9df98be7a Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Mon, 16 Apr 2018 15:48:45 +1000 Subject: [PATCH] Populate QT Tables Nearly there... Getting some odd errors in individual images. Otherwise accuraccy is 100% same as Golang port. --- .../Jpeg/PdfJsPort/Components/PdfJsFrameComponent.cs | 6 +++--- .../Formats/Jpeg/PdfJsPort/PdfJsJpegDecoderCore.cs | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/ImageSharp/Formats/Jpeg/PdfJsPort/Components/PdfJsFrameComponent.cs b/src/ImageSharp/Formats/Jpeg/PdfJsPort/Components/PdfJsFrameComponent.cs index 25ccf863a..7d195374a 100644 --- a/src/ImageSharp/Formats/Jpeg/PdfJsPort/Components/PdfJsFrameComponent.cs +++ b/src/ImageSharp/Formats/Jpeg/PdfJsPort/Components/PdfJsFrameComponent.cs @@ -126,8 +126,8 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.PdfJsPort.Components } else { - // TODO: Check division accuracy here. May need to divide by float - this.SubSamplingDivisors = this.SamplingFactors.DivideBy(new Size(this.Frame.MaxHorizontalFactor, this.Frame.MaxVerticalFactor)); + PdfJsFrameComponent c0 = this.Frame.Components[0]; + this.SubSamplingDivisors = c0.SamplingFactors.DivideBy(this.SamplingFactors); } this.SpectralBlocks = this.memoryManager.Allocate2D(this.SizeInBlocks.Width, this.SizeInBlocks.Height, true); @@ -137,7 +137,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.PdfJsPort.Components public int GetBlockBufferOffset(int row, int col) { // return 64 * (((this.WidthInBlocks + 1) * row) + col); - return 64 * ((this.SpectralBlocks.Width * row) + col); + return 64 * ((this.WidthInBlocks * row) + col); } } } \ No newline at end of file diff --git a/src/ImageSharp/Formats/Jpeg/PdfJsPort/PdfJsJpegDecoderCore.cs b/src/ImageSharp/Formats/Jpeg/PdfJsPort/PdfJsJpegDecoderCore.cs index 37605d71f..822bcbb0e 100644 --- a/src/ImageSharp/Formats/Jpeg/PdfJsPort/PdfJsJpegDecoderCore.cs +++ b/src/ImageSharp/Formats/Jpeg/PdfJsPort/PdfJsJpegDecoderCore.cs @@ -653,7 +653,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.PdfJsPort this.InputStream.Read(this.temp, 0, 64); remaining -= 64; - Block8x8F table = this.QuantizationTables[quantizationTableSpec & 15]; + ref Block8x8F table = ref this.QuantizationTables[quantizationTableSpec & 15]; for (int j = 0; j < 64; j++) { table[j] = this.temp[j]; @@ -673,7 +673,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.PdfJsPort this.InputStream.Read(this.temp, 0, 128); remaining -= 128; - Block8x8F table = this.QuantizationTables[quantizationTableSpec & 15]; + ref Block8x8F table = ref this.QuantizationTables[quantizationTableSpec & 15]; for (int j = 0; j < 64; j++) { table[j] = (this.temp[2 * j] << 8) | this.temp[(2 * j) + 1];