|
|
|
@ -58,17 +58,20 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils |
|
|
|
|
|
|
|
public void LoadSpectralStride(Buffer2D<Block8x8> data, int strideIndex) |
|
|
|
{ |
|
|
|
for (int y = 0; y < data.Height; y++) |
|
|
|
int startIndex = strideIndex * data.Height; |
|
|
|
|
|
|
|
int endIndex = Math.Min(this.HeightInBlocks, startIndex + data.Height); |
|
|
|
|
|
|
|
for (int y = startIndex; y < endIndex; y++) |
|
|
|
{ |
|
|
|
Span<Block8x8> blockRow = data.GetRowSpan(y); |
|
|
|
for (int x = 0; x < data.Width; x++) |
|
|
|
Span<Block8x8> blockRow = data.GetRowSpan(y - startIndex); |
|
|
|
for (int x = 0; x < this.WidthInBlocks; x++) |
|
|
|
{ |
|
|
|
short[] block = blockRow[x].ToArray(); |
|
|
|
|
|
|
|
// x coordinate stays the same - we load entire stride
|
|
|
|
// y coordinate is tricky as we load single stride to full buffer - offset is needed
|
|
|
|
int yOffset = strideIndex * data.Height; |
|
|
|
this.MakeBlock(block, y + yOffset, x); |
|
|
|
this.MakeBlock(block, y, x); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
@ -76,10 +79,10 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils |
|
|
|
public void LoadSpectral(JpegComponent c) |
|
|
|
{ |
|
|
|
Buffer2D<Block8x8> data = c.SpectralBlocks; |
|
|
|
for (int y = 0; y < c.HeightInBlocks; y++) |
|
|
|
for (int y = 0; y < this.HeightInBlocks; y++) |
|
|
|
{ |
|
|
|
Span<Block8x8> blockRow = data.GetRowSpan(y); |
|
|
|
for (int x = 0; x < c.WidthInBlocks; x++) |
|
|
|
for (int x = 0; x < this.WidthInBlocks; x++) |
|
|
|
{ |
|
|
|
short[] block = blockRow[x].ToArray(); |
|
|
|
this.MakeBlock(block, y, x); |
|
|
|
@ -94,16 +97,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils |
|
|
|
c.HeightInBlocks, |
|
|
|
index); |
|
|
|
|
|
|
|
for (int y = 0; y < result.HeightInBlocks; y++) |
|
|
|
{ |
|
|
|
Span<Block8x8> blockRow = c.SpectralBlocks.GetRowSpan(y); |
|
|
|
for (int x = 0; x < result.WidthInBlocks; x++) |
|
|
|
{ |
|
|
|
short[] data = blockRow[x].ToArray(); |
|
|
|
result.MakeBlock(data, y, x); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
result.LoadSpectral(c); |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
|