From 7775c343049e1640dfd699aff0d005355081f042 Mon Sep 17 00:00:00 2001 From: Brian Popow Date: Thu, 25 Nov 2021 14:18:53 +0100 Subject: [PATCH] Group loading y, u, v together --- .../Formats/Webp/Lossy/YuvConversion.cs | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/src/ImageSharp/Formats/Webp/Lossy/YuvConversion.cs b/src/ImageSharp/Formats/Webp/Lossy/YuvConversion.cs index cf211c16e..16d458ed8 100644 --- a/src/ImageSharp/Formats/Webp/Lossy/YuvConversion.cs +++ b/src/ImageSharp/Formats/Webp/Lossy/YuvConversion.cs @@ -739,9 +739,13 @@ namespace SixLabors.ImageSharp.Formats.Webp.Lossy // Convert 32 samples of YUV444 to B/G/R private static void ConvertYuv444ToBgrSse41(ref byte y, ref byte u, ref byte v, out Vector128 r, out Vector128 g, out Vector128 b) { - Vector128 y0 = LoadHigh(ref y); - Vector128 u0 = LoadHigh(ref u); - Vector128 v0 = LoadHigh(ref v); + // Load the bytes into the *upper* part of 16b words. That's "<< 8", basically. + Vector128 y0 = Unsafe.As>(ref y); + Vector128 u0 = Unsafe.As>(ref u); + Vector128 v0 = Unsafe.As>(ref v); + y0 = Sse2.UnpackLow(Vector128.Zero, y0); + u0 = Sse2.UnpackLow(Vector128.Zero, u0); + v0 = Sse2.UnpackLow(Vector128.Zero, v0); Vector128 y1 = Sse2.MultiplyHigh(y0.AsUInt16(), K19077.AsUInt16()); Vector128 r0 = Sse2.MultiplyHigh(v0.AsUInt16(), K26149.AsUInt16()); @@ -765,13 +769,6 @@ namespace SixLabors.ImageSharp.Formats.Webp.Lossy b = Sse2.ShiftRightLogical(b2.AsInt16(), 6); // range: [0, 34238] } - // Load the bytes into the *upper* part of 16b words. That's "<< 8", basically. - [MethodImpl(InliningOptions.ShortMethod)] - private static Vector128 LoadHigh(ref byte src) - { - Vector128 tmp = Unsafe.As>(ref src); - return Sse2.UnpackLow(Vector128.Zero, tmp); - } #endif [MethodImpl(InliningOptions.ShortMethod)]