From 11220a320f920b521b1185831d7adda925317443 Mon Sep 17 00:00:00 2001 From: Dmitry Pentin Date: Sat, 19 Mar 2022 20:36:50 +0300 Subject: [PATCH] Replaced absurdly complicated math from JpegComponentPostProcessor --- .../Decoder/JpegComponentPostProcessor.cs | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/src/ImageSharp/Formats/Jpeg/Components/Decoder/JpegComponentPostProcessor.cs b/src/ImageSharp/Formats/Jpeg/Components/Decoder/JpegComponentPostProcessor.cs index c3bf1cbdd5..1236117267 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/Decoder/JpegComponentPostProcessor.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/Decoder/JpegComponentPostProcessor.cs @@ -21,11 +21,6 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Components.Decoder /// private readonly JpegFrame frame; - /// - /// Gets the maximal number of block rows being processed in one step. - /// - private readonly int blockRowsPerStep; - /// /// Gets the component containing decoding meta information. /// @@ -50,8 +45,6 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Components.Decoder postProcessorBufferSize.Width, postProcessorBufferSize.Height, this.blockAreaSize.Height); - - this.blockRowsPerStep = postProcessorBufferSize.Height / 8 / this.component.SubSamplingDivisors.Height; } /// @@ -73,14 +66,16 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Components.Decoder int destAreaStride = this.ColorBuffer.Width; - int yBlockStart = spectralStep * this.blockRowsPerStep; + int blocksRowsPerStep = this.component.SamplingFactors.Height; + + int yBlockStart = spectralStep * blocksRowsPerStep; Size subSamplingDivisors = this.component.SubSamplingDivisors; Block8x8F dequantTable = this.rawJpeg.QuantizationTables[this.component.QuantizationTableIndex]; Block8x8F workspaceBlock = default; - for (int y = 0; y < this.blockRowsPerStep; y++) + for (int y = 0; y < blocksRowsPerStep; y++) { int yBuffer = y * this.blockAreaSize.Height;