@@ -216,17 +216,18 @@ private static int Vp8_Sse16xN_Avx2(Span<byte> a, Span<byte> b, int numPairs)
216
216
}
217
217
218
218
[ MethodImpl ( InliningOptions . ShortMethod ) ]
219
- private static int Vp8_Sse16x16_Neon ( Span < byte > a , Span < byte > b )
219
+ private static unsafe int Vp8_Sse16x16_Neon ( Span < byte > a , Span < byte > b )
220
220
{
221
221
Vector128 < uint > sum = Vector128 < uint > . Zero ;
222
- ref byte aRef = ref MemoryMarshal . GetReference ( a ) ;
223
- ref byte bRef = ref MemoryMarshal . GetReference ( b ) ;
224
- for ( int y = 0 ; y < 16 ; y ++ )
222
+ fixed ( byte * aRef = & MemoryMarshal . GetReference ( a ) )
225
223
{
226
- sum = AccumulateSSE16Neon (
227
- ref Unsafe . Add ( ref aRef , y * WebpConstants . Bps ) ,
228
- ref Unsafe . Add ( ref bRef , y * WebpConstants . Bps ) ,
229
- sum ) ;
224
+ fixed ( byte * bRef = & MemoryMarshal . GetReference ( b ) )
225
+ {
226
+ for ( int y = 0 ; y < 16 ; y ++ )
227
+ {
228
+ sum = AccumulateSSE16Neon ( aRef + ( y * WebpConstants . Bps ) , bRef + ( y * WebpConstants . Bps ) , sum ) ;
229
+ }
230
+ }
230
231
}
231
232
232
233
#if NET7_0_OR_GREATER
@@ -237,17 +238,18 @@ ref Unsafe.Add(ref bRef, y * WebpConstants.Bps),
237
238
}
238
239
239
240
[ MethodImpl ( InliningOptions . ShortMethod ) ]
240
- private static int Vp8_Sse16x8_Neon ( Span < byte > a , Span < byte > b )
241
+ private static unsafe int Vp8_Sse16x8_Neon ( Span < byte > a , Span < byte > b )
241
242
{
242
243
Vector128 < uint > sum = Vector128 < uint > . Zero ;
243
- ref byte aRef = ref MemoryMarshal . GetReference ( a ) ;
244
- ref byte bRef = ref MemoryMarshal . GetReference ( b ) ;
245
- for ( int y = 0 ; y < 8 ; y ++ )
244
+ fixed ( byte * aRef = & MemoryMarshal . GetReference ( a ) )
246
245
{
247
- sum = AccumulateSSE16Neon (
248
- ref Unsafe . Add ( ref aRef , y * WebpConstants . Bps ) ,
249
- ref Unsafe . Add ( ref bRef , y * WebpConstants . Bps ) ,
250
- sum ) ;
246
+ fixed ( byte * bRef = & MemoryMarshal . GetReference ( b ) )
247
+ {
248
+ for ( int y = 0 ; y < 8 ; y ++ )
249
+ {
250
+ sum = AccumulateSSE16Neon ( aRef + ( y * WebpConstants . Bps ) , bRef + ( y * WebpConstants . Bps ) , sum ) ;
251
+ }
252
+ }
251
253
}
252
254
253
255
#if NET7_0_OR_GREATER
@@ -296,10 +298,10 @@ private static unsafe Vector128<uint> Load4x4Neon(Span<byte> src)
296
298
}
297
299
298
300
[ MethodImpl ( InliningOptions . ShortMethod ) ]
299
- private static Vector128 < uint > AccumulateSSE16Neon ( ref byte aRef , ref byte bRef , Vector128 < uint > sum )
301
+ private static unsafe Vector128 < uint > AccumulateSSE16Neon ( byte * a , byte * b , Vector128 < uint > sum )
300
302
{
301
- Vector128 < byte > a0 = Unsafe . As < byte , Vector128 < byte > > ( ref aRef ) ;
302
- Vector128 < byte > b0 = Unsafe . As < byte , Vector128 < byte > > ( ref bRef ) ;
303
+ Vector128 < byte > a0 = AdvSimd . LoadVector128 ( a ) ;
304
+ Vector128 < byte > b0 = AdvSimd . LoadVector128 ( b ) ;
303
305
304
306
Vector128 < byte > absDiff = AdvSimd . AbsoluteDifference ( a0 , b0 ) ;
305
307
Vector64 < byte > absDiffLower = absDiff . GetLower ( ) ;
0 commit comments