From 422337ccf598dce7619f15a3b42682ae918862bb Mon Sep 17 00:00:00 2001 From: Brian Popow Date: Sun, 4 Jul 2021 14:39:50 +0200 Subject: [PATCH] Enable PickBestIntra4 --- src/ImageSharp/Formats/WebP/Lossy/LossyUtils.cs | 6 +++--- src/ImageSharp/Formats/WebP/Lossy/QuantEnc.cs | 2 +- src/ImageSharp/Formats/WebP/Lossy/Vp8Encoder.cs | 3 +-- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/ImageSharp/Formats/WebP/Lossy/LossyUtils.cs b/src/ImageSharp/Formats/WebP/Lossy/LossyUtils.cs index a03d2c5c5..c7c5119d8 100644 --- a/src/ImageSharp/Formats/WebP/Lossy/LossyUtils.cs +++ b/src/ImageSharp/Formats/WebP/Lossy/LossyUtils.cs @@ -49,11 +49,11 @@ namespace SixLabors.ImageSharp.Formats.Webp.Lossy [MethodImpl(InliningOptions.ShortMethod)] public static void Copy(Span src, Span dst, int w, int h) { + int offset = 0; for (int y = 0; y < h; ++y) { - src.Slice(0, w).CopyTo(dst); - src = src.Slice(WebpConstants.Bps); - dst = dst.Slice(WebpConstants.Bps); + src.Slice(offset, w).CopyTo(dst.Slice(offset, w)); + offset += WebpConstants.Bps; } } diff --git a/src/ImageSharp/Formats/WebP/Lossy/QuantEnc.cs b/src/ImageSharp/Formats/WebP/Lossy/QuantEnc.cs index 0cc28b423..f62161dbb 100644 --- a/src/ImageSharp/Formats/WebP/Lossy/QuantEnc.cs +++ b/src/ImageSharp/Formats/WebP/Lossy/QuantEnc.cs @@ -168,7 +168,7 @@ namespace SixLabors.ImageSharp.Formats.Webp.Lossy Span tmp = tmpDst; tmpDst = bestBlock; bestBlock = tmp; - tmpLevels.AsSpan().CopyTo(rdBest.YAcLevels); + tmpLevels.CopyTo(rdBest.YAcLevels.AsSpan(it.I4 * 16, 16)); } } diff --git a/src/ImageSharp/Formats/WebP/Lossy/Vp8Encoder.cs b/src/ImageSharp/Formats/WebP/Lossy/Vp8Encoder.cs index a0dfc143c..83f44e1ee 100644 --- a/src/ImageSharp/Formats/WebP/Lossy/Vp8Encoder.cs +++ b/src/ImageSharp/Formats/WebP/Lossy/Vp8Encoder.cs @@ -893,8 +893,7 @@ namespace SixLabors.ImageSharp.Formats.Webp.Lossy QuantEnc.PickBestIntra16(it, ref rd, this.SegmentInfos, this.Proba); if (this.method >= 2) { - // TODO: there is still a bug in PickBestIntra4, therefore disabled. - // QuantEnc.PickBestIntra4(it, ref rd, this.SegmentInfos, this.Proba, this.maxI4HeaderBits); + QuantEnc.PickBestIntra4(it, ref rd, this.SegmentInfos, this.Proba, this.maxI4HeaderBits); } QuantEnc.PickBestUv(it, ref rd, this.SegmentInfos, this.Proba);