@@ -221,10 +221,10 @@ public static void ITransformOne(Span<byte> reference, Span<short> input, Span<b
221
221
ref byte referenceRef = ref MemoryMarshal . GetReference ( reference ) ;
222
222
223
223
// Load four bytes/pixels per line.
224
- Vector128 < byte > ref0 = Vector128 . CreateScalar ( Unsafe . As < byte , int > ( ref referenceRef ) ) . AsByte ( ) ;
225
- Vector128 < byte > ref1 = Vector128 . CreateScalar ( Unsafe . As < byte , int > ( ref Unsafe . Add ( ref referenceRef , WebpConstants . Bps ) ) ) . AsByte ( ) ;
226
- Vector128 < byte > ref2 = Vector128 . CreateScalar ( Unsafe . As < byte , int > ( ref Unsafe . Add ( ref referenceRef , WebpConstants . Bps * 2 ) ) ) . AsByte ( ) ;
227
- Vector128 < byte > ref3 = Vector128 . CreateScalar ( Unsafe . As < byte , int > ( ref Unsafe . Add ( ref referenceRef , WebpConstants . Bps * 3 ) ) ) . AsByte ( ) ;
224
+ Vector128 < byte > ref0 = Vector128 . CreateScalar ( Unsafe . ReadUnaligned < int > ( ref referenceRef ) ) . AsByte ( ) ;
225
+ Vector128 < byte > ref1 = Vector128 . CreateScalar ( Unsafe . ReadUnaligned < int > ( ref Unsafe . Add ( ref referenceRef , WebpConstants . Bps ) ) ) . AsByte ( ) ;
226
+ Vector128 < byte > ref2 = Vector128 . CreateScalar ( Unsafe . ReadUnaligned < int > ( ref Unsafe . Add ( ref referenceRef , WebpConstants . Bps * 2 ) ) ) . AsByte ( ) ;
227
+ Vector128 < byte > ref3 = Vector128 . CreateScalar ( Unsafe . ReadUnaligned < int > ( ref Unsafe . Add ( ref referenceRef , WebpConstants . Bps * 3 ) ) ) . AsByte ( ) ;
228
228
229
229
// Convert to 16b.
230
230
ref0 = Vector128_ . UnpackLow ( ref0 , Vector128 < byte > . Zero ) ;
@@ -253,10 +253,10 @@ public static void ITransformOne(Span<byte> reference, Span<short> input, Span<b
253
253
int output2 = ref2 . AsInt32 ( ) . ToScalar ( ) ;
254
254
int output3 = ref3 . AsInt32 ( ) . ToScalar ( ) ;
255
255
256
- Unsafe . As < byte , int > ( ref outputRef ) = output0;
257
- Unsafe . As < byte , int > ( ref Unsafe . Add ( ref outputRef , WebpConstants . Bps ) ) = output1;
258
- Unsafe . As < byte , int > ( ref Unsafe . Add ( ref outputRef , WebpConstants . Bps * 2 ) ) = output2;
259
- Unsafe . As < byte , int > ( ref Unsafe . Add ( ref outputRef , WebpConstants . Bps * 3 ) ) = output3;
256
+ Unsafe . WriteUnaligned ( ref outputRef , output0 ) ;
257
+ Unsafe . WriteUnaligned ( ref Unsafe . Add ( ref outputRef , WebpConstants . Bps ) , output1 ) ;
258
+ Unsafe . WriteUnaligned ( ref Unsafe . Add ( ref outputRef , WebpConstants . Bps * 2 ) , output2 ) ;
259
+ Unsafe . WriteUnaligned ( ref Unsafe . Add ( ref outputRef , WebpConstants . Bps * 3 ) , output3 ) ;
260
260
}
261
261
else
262
262
{
0 commit comments