public static void Shuffle4ChannelReduce( ref ReadOnlySpan <byte> source, ref Span <byte> dest, byte control) { if (Avx2.IsSupported || Ssse3.IsSupported) { int remainder = Avx2.IsSupported ? ImageMaths.ModuloP2(source.Length, Vector256 <byte> .Count) : ImageMaths.ModuloP2(source.Length, Vector128 <byte> .Count); int adjustedCount = source.Length - remainder; if (adjustedCount > 0) { Shuffle4Channel( source.Slice(0, adjustedCount), dest.Slice(0, adjustedCount), control); source = source.Slice(adjustedCount); dest = dest.Slice(adjustedCount); } } }
internal static void NormalizedFloatToByteSaturateReduce( ref ReadOnlySpan <float> source, ref Span <byte> dest) { DebugGuard.IsTrue(source.Length == dest.Length, nameof(source), "Input spans must be of same length!"); if (Avx2.IsSupported) { int remainder = ImageMaths.ModuloP2(source.Length, Vector <byte> .Count); int adjustedCount = source.Length - remainder; if (adjustedCount > 0) { NormalizedFloatToByteSaturate( source.Slice(0, adjustedCount), dest.Slice(0, adjustedCount)); source = source.Slice(adjustedCount); dest = dest.Slice(adjustedCount); } } }
internal static void BulkConvertByteToNormalizedFloatReduce( ref ReadOnlySpan <byte> source, ref Span <float> dest) { DebugGuard.IsTrue(source.Length == dest.Length, nameof(source), "Input spans must be of same length!"); if (!IsAvailable) { return; } int remainder = ImageMaths.ModuloP2(source.Length, Vector <byte> .Count); int adjustedCount = source.Length - remainder; if (adjustedCount > 0) { BulkConvertByteToNormalizedFloat(source.Slice(0, adjustedCount), dest.Slice(0, adjustedCount)); source = source.Slice(adjustedCount); dest = dest.Slice(adjustedCount); } }