Skip to content

Commit 2f673b9

Browse files
committed
Use ref parameter for AccumulateSSE16Neon
1 parent 7ed4c69 commit 2f673b9

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

src/ImageSharp/Formats/Webp/Lossy/LossyUtils.cs

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -219,9 +219,14 @@ private static int Vp8_Sse16xN_Avx2(Span<byte> a, Span<byte> b, int numPairs)
219219
private static int Vp8_Sse16x16_Neon(Span<byte> a, Span<byte> b)
220220
{
221221
Vector128<uint> sum = Vector128<uint>.Zero;
222+
ref byte aRef = ref MemoryMarshal.GetReference(a);
223+
ref byte bRef = ref MemoryMarshal.GetReference(b);
222224
for (int y = 0; y < 16; y++)
223225
{
224-
sum = AccumulateSSE16Neon(a.Slice(y * WebpConstants.Bps), b.Slice(y * WebpConstants.Bps), sum);
226+
sum = AccumulateSSE16Neon(
227+
ref Unsafe.Add(ref aRef, y * WebpConstants.Bps),
228+
ref Unsafe.Add(ref bRef, y * WebpConstants.Bps),
229+
sum);
225230
}
226231

227232
return Numerics.ReduceSumArm(sum);
@@ -231,9 +236,14 @@ private static int Vp8_Sse16x16_Neon(Span<byte> a, Span<byte> b)
231236
private static int Vp8_Sse16x8_Neon(Span<byte> a, Span<byte> b)
232237
{
233238
Vector128<uint> sum = Vector128<uint>.Zero;
239+
ref byte aRef = ref MemoryMarshal.GetReference(a);
240+
ref byte bRef = ref MemoryMarshal.GetReference(b);
234241
for (int y = 0; y < 8; y++)
235242
{
236-
sum = AccumulateSSE16Neon(a.Slice(y * WebpConstants.Bps), b.Slice(y * WebpConstants.Bps), sum);
243+
sum = AccumulateSSE16Neon(
244+
ref Unsafe.Add(ref aRef, y * WebpConstants.Bps),
245+
ref Unsafe.Add(ref bRef, y * WebpConstants.Bps),
246+
sum);
237247
}
238248

239249
return Numerics.ReduceSumArm(sum);
@@ -273,11 +283,8 @@ private static unsafe Vector128<uint> Load4x4Neon(Span<byte> src)
273283
}
274284

275285
[MethodImpl(InliningOptions.ShortMethod)]
276-
private static Vector128<uint> AccumulateSSE16Neon(Span<byte> a, Span<byte> b, Vector128<uint> sum)
286+
private static Vector128<uint> AccumulateSSE16Neon(ref byte aRef, ref byte bRef, Vector128<uint> sum)
277287
{
278-
ref byte aRef = ref MemoryMarshal.GetReference(a);
279-
ref byte bRef = ref MemoryMarshal.GetReference(b);
280-
281288
Vector128<byte> a0 = Unsafe.As<byte, Vector128<byte>>(ref aRef);
282289
Vector128<byte> b0 = Unsafe.As<byte, Vector128<byte>>(ref bRef);
283290

0 commit comments

Comments
 (0)