From 5ba8763ade0ef953eb4d2ec6accffd8ba4a030c7 Mon Sep 17 00:00:00 2001 From: Dmitry Pentin Date: Thu, 8 Jul 2021 15:58:41 +0300 Subject: [PATCH] Replaced hardcoded values with actual calculated ones in postprocessor --- .../Decoder/JpegComponentPostProcessor.cs | 2 +- .../Components/Decoder/JpegImagePostProcessor.cs | 13 +++++++++---- tests/ImageSharp.Tests.ProfilingSandbox/Program.cs | 5 ++++- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/ImageSharp/Formats/Jpeg/Components/Decoder/JpegComponentPostProcessor.cs b/src/ImageSharp/Formats/Jpeg/Components/Decoder/JpegComponentPostProcessor.cs index fc1ebaf92..0a0a2cd9e 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/Decoder/JpegComponentPostProcessor.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/Decoder/JpegComponentPostProcessor.cs @@ -37,7 +37,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Components.Decoder imagePostProcessor.PostProcessorBufferSize.Height, this.blockAreaSize.Height); - this.BlockRowsPerStep = JpegImagePostProcessor.BlockRowsPerStep / this.Component.SubSamplingDivisors.Height; + this.BlockRowsPerStep = imagePostProcessor.BlockRowsPerStep / this.Component.SubSamplingDivisors.Height; } /// diff --git a/src/ImageSharp/Formats/Jpeg/Components/Decoder/JpegImagePostProcessor.cs b/src/ImageSharp/Formats/Jpeg/Components/Decoder/JpegImagePostProcessor.cs index fd3b9b431..5f3389e17 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/Decoder/JpegImagePostProcessor.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/Decoder/JpegImagePostProcessor.cs @@ -29,12 +29,12 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Components.Decoder /// /// The number of block rows to be processed in one Step. /// - public const int BlockRowsPerStep = 4; + public int BlockRowsPerStep; /// /// The number of image pixel rows to be processed in one step. /// - public const int PixelRowsPerStep = 4 * 8; + public int PixelRowsPerStep; /// /// Temporal buffer to store a row of colors. @@ -56,8 +56,13 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Components.Decoder this.configuration = configuration; this.RawJpeg = rawJpeg; IJpegComponent c0 = rawJpeg.Components[0]; - this.NumberOfPostProcessorSteps = c0.SizeInBlocks.Height / BlockRowsPerStep; - this.PostProcessorBufferSize = new Size(c0.SizeInBlocks.Width * 8, PixelRowsPerStep); + + this.BlockRowsPerStep = c0.SamplingFactors.Height; + this.PixelRowsPerStep = this.BlockRowsPerStep * 8; + + this.NumberOfPostProcessorSteps = c0.SizeInBlocks.Height / this.BlockRowsPerStep; + + this.PostProcessorBufferSize = new Size(c0.SizeInBlocks.Width * 8, this.PixelRowsPerStep); MemoryAllocator memoryAllocator = configuration.MemoryAllocator; diff --git a/tests/ImageSharp.Tests.ProfilingSandbox/Program.cs b/tests/ImageSharp.Tests.ProfilingSandbox/Program.cs index 1a956dc9c..e0b7f31a7 100644 --- a/tests/ImageSharp.Tests.ProfilingSandbox/Program.cs +++ b/tests/ImageSharp.Tests.ProfilingSandbox/Program.cs @@ -58,7 +58,6 @@ namespace SixLabors.ImageSharp.Tests.ProfilingSandbox //Test_DebugRun("Channel_digital_image_CMYK_color"); //Console.WriteLine(); - //Test_DebugRun("test_baseline_4k_444", false); //Console.WriteLine(); //Test_DebugRun("test_progressive_4k_444", false); @@ -69,6 +68,10 @@ namespace SixLabors.ImageSharp.Tests.ProfilingSandbox // Binary size of this must be ~2096kb //Test_DebugRun("422", true); + //Test_DebugRun("baseline_4k_420", false); + //Test_DebugRun("baseline_s444_q100", false); + //Test_DebugRun("progressive_s444_q100", false); + Test_DebugRun("baseline_4k_420", true); Test_DebugRun("baseline_s444_q100", true); Test_DebugRun("progressive_s444_q100", true);