Browse Source

Parallel.For() in ProcessBlockColorsIntoJpegImageChannels

af/merge-core
Anton Firszov 9 years ago
parent
commit
77f337ffeb
  1. 27
      src/ImageSharp.Formats.Jpeg/JpegDecoderCore.cs
  2. 2
      tests/ImageSharp.Tests/Formats/Jpg/JpegProfilingBenchmarks.cs

27
src/ImageSharp.Formats.Jpeg/JpegDecoderCore.cs

@ -469,19 +469,22 @@ namespace ImageSharp.Formats
private void ProcessBlockColorsIntoJpegImageChannels<TColor>()
where TColor : struct, IPackedPixel, IEquatable<TColor>
{
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);
}
});
}
/// <summary>

2
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)
{

Loading…
Cancel
Save