Browse Source

Replicate the top-right pixels in 4x4 block

pull/1552/head
Brian Popow 6 years ago
parent
commit
40100f1d8e
  1. 8
      src/ImageSharp/Formats/WebP/LossyUtils.cs
  2. 10
      src/ImageSharp/Formats/WebP/WebPLossyDecoder.cs

8
src/ImageSharp/Formats/WebP/LossyUtils.cs

@ -682,6 +682,14 @@ namespace SixLabors.ImageSharp.Formats.WebP
return Clip8(MultHi(y, 19077) + MultHi(u, 33050) - 17685);
}
public static void Memset(Span<uint> dst, uint value, int startIdx, int count)
{
for (int i = 0; i < count; i++)
{
dst[startIdx + i] = value;
}
}
// Complex In-loop filtering (Paragraph 15.3)
private static void FilterLoop24(
byte[] p,

10
src/ImageSharp/Formats/WebP/WebPLossyDecoder.cs

@ -320,23 +320,23 @@ namespace SixLabors.ImageSharp.Formats.WebP
// Predict and add residuals.
if (block.IsI4x4)
{
// uint32_t* const top_right = (uint32_t*)(y_dst - BPS + 16);
//Span<uint> topRight = MemoryMarshal.Cast<byte, uint>(yuv.AsSpan(yOff - WebPConstants.Bps + 16));
Span<uint> topRight = MemoryMarshal.Cast<byte, uint>(yuv.AsSpan(yOff - WebPConstants.Bps + 16));
if (mby > 0)
{
if (mbx >= dec.MbWidth - 1)
{
// On rightmost border.
// memset(top_right, top_yuv[0].y[15], sizeof(*top_right));
LossyUtils.Memset(topRight, topYuv.Y[15],0, 4);
}
else
{
// memcpy(top_right, top_yuv[1].y, sizeof(*top_right));
Span<uint> topYuvSamples = MemoryMarshal.Cast<byte, uint>(dec.YuvTopSamples[mbx + 1].Y.AsSpan());
topYuvSamples.Slice(0, 4).CopyTo(topRight);
}
}
// Replicate the top-right pixels below.
//topRight[WebPConstants.Bps] = topRight[2 * WebPConstants.Bps] = topRight[3 * WebPConstants.Bps] = topRight[0];
topRight[WebPConstants.Bps] = topRight[2 * WebPConstants.Bps] = topRight[3 * WebPConstants.Bps] = topRight[0];
// Predict and add residuals for all 4x4 blocks in turn.
for (int n = 0; n < 16; ++n, bits <<= 2)

Loading…
Cancel
Save