From 2f673b9942ab616e1123b61ea22fe9109e9706e7 Mon Sep 17 00:00:00 2001 From: Brian Popow Date: Sun, 12 Feb 2023 15:07:58 +0100 Subject: [PATCH] Use ref parameter for AccumulateSSE16Neon --- .../Formats/Webp/Lossy/LossyUtils.cs | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/ImageSharp/Formats/Webp/Lossy/LossyUtils.cs b/src/ImageSharp/Formats/Webp/Lossy/LossyUtils.cs index d59af537d3..850f3d876d 100644 --- a/src/ImageSharp/Formats/Webp/Lossy/LossyUtils.cs +++ b/src/ImageSharp/Formats/Webp/Lossy/LossyUtils.cs @@ -219,9 +219,14 @@ internal static class LossyUtils private static int Vp8_Sse16x16_Neon(Span a, Span b) { Vector128 sum = Vector128.Zero; + ref byte aRef = ref MemoryMarshal.GetReference(a); + ref byte bRef = ref MemoryMarshal.GetReference(b); for (int y = 0; y < 16; y++) { - sum = AccumulateSSE16Neon(a.Slice(y * WebpConstants.Bps), b.Slice(y * WebpConstants.Bps), sum); + sum = AccumulateSSE16Neon( + ref Unsafe.Add(ref aRef, y * WebpConstants.Bps), + ref Unsafe.Add(ref bRef, y * WebpConstants.Bps), + sum); } return Numerics.ReduceSumArm(sum); @@ -231,9 +236,14 @@ internal static class LossyUtils private static int Vp8_Sse16x8_Neon(Span a, Span b) { Vector128 sum = Vector128.Zero; + ref byte aRef = ref MemoryMarshal.GetReference(a); + ref byte bRef = ref MemoryMarshal.GetReference(b); for (int y = 0; y < 8; y++) { - sum = AccumulateSSE16Neon(a.Slice(y * WebpConstants.Bps), b.Slice(y * WebpConstants.Bps), sum); + sum = AccumulateSSE16Neon( + ref Unsafe.Add(ref aRef, y * WebpConstants.Bps), + ref Unsafe.Add(ref bRef, y * WebpConstants.Bps), + sum); } return Numerics.ReduceSumArm(sum); @@ -273,11 +283,8 @@ internal static class LossyUtils } [MethodImpl(InliningOptions.ShortMethod)] - private static Vector128 AccumulateSSE16Neon(Span a, Span b, Vector128 sum) + private static Vector128 AccumulateSSE16Neon(ref byte aRef, ref byte bRef, Vector128 sum) { - ref byte aRef = ref MemoryMarshal.GetReference(a); - ref byte bRef = ref MemoryMarshal.GetReference(b); - Vector128 a0 = Unsafe.As>(ref aRef); Vector128 b0 = Unsafe.As>(ref bRef);