diff --git a/src/ImageSharp/Formats/Webp/Lossy/LossyUtils.cs b/src/ImageSharp/Formats/Webp/Lossy/LossyUtils.cs index ac3b1d3806..3064ccc030 100644 --- a/src/ImageSharp/Formats/Webp/Lossy/LossyUtils.cs +++ b/src/ImageSharp/Formats/Webp/Lossy/LossyUtils.cs @@ -13,7 +13,7 @@ using System.Runtime.Intrinsics.X86; // ReSharper disable InconsistentNaming namespace SixLabors.ImageSharp.Formats.Webp.Lossy { - internal static unsafe class LossyUtils + internal static class LossyUtils { #if SUPPORTS_RUNTIME_INTRINSICS private static readonly Vector128 Mean16x4Mask = Vector128.Create((short)0x00ff).AsByte(); @@ -967,11 +967,10 @@ namespace SixLabors.ImageSharp.Formats.Webp.Lossy Vector128 e1 = Sse2.Add(d2, d3); Vector128 f0 = Sse2.Add(e0, e1); Vector128 hadd = Ssse3.HorizontalAdd(f0.AsInt16(), f0.AsInt16()); + Vector128 wide = Sse2.UnpackLow(hadd, Vector128.Zero).AsUInt32(); - dc[3] = (uint)hadd.GetElement(3); - dc[2] = (uint)hadd.GetElement(2); - dc[1] = (uint)hadd.GetElement(1); - dc[0] = (uint)hadd.GetElement(0); + ref uint outputRef = ref MemoryMarshal.GetReference(dc); + Unsafe.As>(ref outputRef) = wide; } else #endif