diff --git a/src/ImageSharp.Formats.Jpeg/JpegDecoderCore.cs b/src/ImageSharp.Formats.Jpeg/JpegDecoderCore.cs index cad81238c..609eb5f5f 100644 --- a/src/ImageSharp.Formats.Jpeg/JpegDecoderCore.cs +++ b/src/ImageSharp.Formats.Jpeg/JpegDecoderCore.cs @@ -469,19 +469,22 @@ namespace ImageSharp.Formats private void ProcessBlockColorsIntoJpegImageChannels() where TColor : struct, IPackedPixel, IEquatable { - JpegScanDecoder scanDecoder = default(JpegScanDecoder); - JpegScanDecoder.Init(&scanDecoder); + Parallel.For( + 0, + this.ComponentCount, + componentIndex => + { + JpegScanDecoder scanDecoder = default(JpegScanDecoder); + JpegScanDecoder.Init(&scanDecoder); - for (int componentIndex = 0; componentIndex < this.ComponentCount; componentIndex++) - { - scanDecoder.ComponentIndex = componentIndex; - DecodedBlockMemento[] blockArray = this.DecodedBlocks[componentIndex]; - for (int i = 0; i < blockArray.Length; i++) - { - scanDecoder.LoadMemento(ref blockArray[i]); - scanDecoder.ProcessBlockColors(this); - } - } + scanDecoder.ComponentIndex = componentIndex; + DecodedBlockMemento[] blockArray = this.DecodedBlocks[componentIndex]; + for (int i = 0; i < blockArray.Length; i++) + { + scanDecoder.LoadMemento(ref blockArray[i]); + scanDecoder.ProcessBlockColors(this); + } + }); } /// diff --git a/tests/ImageSharp.Tests/Formats/Jpg/JpegProfilingBenchmarks.cs b/tests/ImageSharp.Tests/Formats/Jpg/JpegProfilingBenchmarks.cs index bfe1f1e76..3f8995088 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/JpegProfilingBenchmarks.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/JpegProfilingBenchmarks.cs @@ -32,7 +32,7 @@ namespace ImageSharp.Tests TestImages.Jpeg.Baseline.Jpeg444, }; - // [Theory] // Benchmark, enable manually + [Theory] // Benchmark, enable manually [MemberData(nameof(DecodeJpegData))] public void DecodeJpeg(string fileName) {