diff --git a/src/ImageSharp/Formats/Jpeg/Components/Encoder/RgbToYCbCrConverterVectorized.cs b/src/ImageSharp/Formats/Jpeg/Components/Encoder/RgbToYCbCrConverterVectorized.cs
index 1b7df596c..0fcffbc7e 100644
--- a/src/ImageSharp/Formats/Jpeg/Components/Encoder/RgbToYCbCrConverterVectorized.cs
+++ b/src/ImageSharp/Formats/Jpeg/Components/Encoder/RgbToYCbCrConverterVectorized.cs
@@ -234,7 +234,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Components.Encoder
#endif
}
-#if SUPPORTS_RUNTIME_INTRINSICS
+#if SUPPORTS_RUNTIME_INTRINSICS
///
/// Scales 16x2 matrix to 8x1 using 2x2 average
///
diff --git a/tests/ImageSharp.Tests/Common/SimdUtilsTests.cs b/tests/ImageSharp.Tests/Common/SimdUtilsTests.cs
index 40f0e0c7b..1f680aa6c 100644
--- a/tests/ImageSharp.Tests/Common/SimdUtilsTests.cs
+++ b/tests/ImageSharp.Tests/Common/SimdUtilsTests.cs
@@ -5,9 +5,7 @@ using System;
using System.Linq;
using System.Numerics;
using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
#if SUPPORTS_RUNTIME_INTRINSICS
-using System.Runtime.Intrinsics;
using System.Runtime.Intrinsics.X86;
#endif
using SixLabors.ImageSharp.PixelFormats;
@@ -360,44 +358,6 @@ namespace SixLabors.ImageSharp.Tests.Common
SimdUtils.PackFromRgbPlanes(Configuration.Default, r, g, b, actual));
}
-#if SUPPORTS_RUNTIME_INTRINSICS
- [Theory]
- [InlineData(1)]
- [InlineData(2)]
- [InlineData(3)]
- public void Scale16x2_8x1(int seed)
- {
- if (!Avx.IsSupported)
- {
- return;
- }
-
- Span data = new Random(seed).GenerateRandomFloatArray(Vector256.Count * 4, -1000, 1000);
-
- // Act:
- Vector256 resultVector = SimdUtils.HwIntrinsics.Scale16x2_8x1(MemoryMarshal.Cast>(data));
- ref float result = ref Unsafe.As, float>(ref resultVector);
-
- // Assert:
- // Comparison epsilon is tricky but 10^(-4) is good enough (?)
- var comparer = new ApproximateFloatComparer(0.0001f);
- for (int i = 0; i < Vector256.Count; i++)
- {
- float actual = Unsafe.Add(ref result, i);
- float expected = CalculateAverage16x2_8x1(data, i);
-
- Assert.True(comparer.Equals(actual, expected), $"Pos {i}, Expected: {expected}, Actual: {actual}");
- }
-
- static float CalculateAverage16x2_8x1(Span data, int index)
- {
- int upIdx = index * 2;
- int lowIdx = (index + 8) * 2;
- return 0.25f * (data[upIdx] + data[upIdx + 1] + data[lowIdx] + data[lowIdx + 1]);
- }
- }
-#endif
-
#if SUPPORTS_RUNTIME_INTRINSICS
[Fact]
public void PackFromRgbPlanesAvx2Reduce_Rgb24()
diff --git a/tests/ImageSharp.Tests/Formats/Jpg/RgbToYCbCrConverterTests.cs b/tests/ImageSharp.Tests/Formats/Jpg/RgbToYCbCrConverterTests.cs
index d95191ffe..0d5b55038 100644
--- a/tests/ImageSharp.Tests/Formats/Jpg/RgbToYCbCrConverterTests.cs
+++ b/tests/ImageSharp.Tests/Formats/Jpg/RgbToYCbCrConverterTests.cs
@@ -2,6 +2,12 @@
// Licensed under the Apache License, Version 2.0.
using System;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+#if SUPPORTS_RUNTIME_INTRINSICS
+using System.Runtime.Intrinsics;
+using System.Runtime.Intrinsics.X86;
+#endif
using SixLabors.ImageSharp.ColorSpaces;
using SixLabors.ImageSharp.Formats.Jpeg.Components;
using SixLabors.ImageSharp.Formats.Jpeg.Components.Encoder;
@@ -98,6 +104,43 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg
Verify420(data, yBlocks, ref cb, ref cr, new ApproximateFloatComparer(1F));
}
+#if SUPPORTS_RUNTIME_INTRINSICS
+ [Theory]
+ [InlineData(1)]
+ [InlineData(2)]
+ [InlineData(3)]
+ public void Scale16x2_8x1(int seed)
+ {
+ if (!Avx2.IsSupported)
+ {
+ return;
+ }
+
+ Span data = new Random(seed).GenerateRandomFloatArray(Vector256.Count * 4, -1000, 1000);
+
+ // Act:
+ Vector256 resultVector = RgbToYCbCrConverterVectorized.Scale16x2_8x1(MemoryMarshal.Cast>(data));
+ ref float result = ref Unsafe.As, float>(ref resultVector);
+
+ // Assert:
+ // Comparison epsilon is tricky but 10^(-4) is good enough (?)
+ var comparer = new ApproximateFloatComparer(0.0001f);
+ for (int i = 0; i < Vector256.Count; i++)
+ {
+ float actual = Unsafe.Add(ref result, i);
+ float expected = CalculateAverage16x2_8x1(data, i);
+
+ Assert.True(comparer.Equals(actual, expected), $"Pos {i}, Expected: {expected}, Actual: {actual}");
+ }
+
+ static float CalculateAverage16x2_8x1(Span data, int index)
+ {
+ int upIdx = index * 2;
+ int lowIdx = (index + 8) * 2;
+ return 0.25f * (data[upIdx] + data[upIdx + 1] + data[lowIdx] + data[lowIdx + 1]);
+ }
+ }
+#endif
private static void Verify444(
ReadOnlySpan data,