Browse Source

Fix vectorized subsampling

pull/1554/head
Nicolas Portmann 6 years ago
parent
commit
af4e4ff018
  1. 11
      src/ImageSharp/Formats/Jpeg/Components/Block8x8F.cs

11
src/ImageSharp/Formats/Jpeg/Components/Block8x8F.cs

@ -494,12 +494,14 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Components
var f2 = Vector256.Create(2f); var f2 = Vector256.Create(2f);
var f025 = Vector256.Create(0.25f); var f025 = Vector256.Create(0.25f);
Vector256<int> switchInnerDoubleWords = Unsafe.As<byte, Vector256<int>>(ref MemoryMarshal.GetReference(SimdUtils.HwIntrinsics.PermuteMaskSwitchInnerDWords8x32)); Vector256<int> switchInnerDoubleWords = Unsafe.As<byte, Vector256<int>>(ref MemoryMarshal.GetReference(SimdUtils.HwIntrinsics.PermuteMaskSwitchInnerDWords8x32));
ref Vector256<float> in1 = ref Unsafe.As<Block8x8F, Vector256<float>>(ref MemoryMarshal.GetReference(source));
ref Vector256<float> in2 = ref Unsafe.As<Block8x8F, Vector256<float>>(ref Unsafe.Add(ref MemoryMarshal.GetReference(source), 1));
ref Vector256<float> destRef = ref Unsafe.As<Block8x8F, Vector256<float>>(ref destination); ref Vector256<float> destRef = ref Unsafe.As<Block8x8F, Vector256<float>>(ref destination);
for (int i = 0; i < 8; i++) for (int i = 0; i < 2; i++)
{
ref Vector256<float> in1 = ref Unsafe.As<Block8x8F, Vector256<float>>(ref Unsafe.Add(ref MemoryMarshal.GetReference(source), 2 * i));
ref Vector256<float> in2 = ref Unsafe.As<Block8x8F, Vector256<float>>(ref Unsafe.Add(ref MemoryMarshal.GetReference(source), (2 * i) + 1));
for (int j = 0; j < 4; j++)
{ {
Vector256<float> a = in1; Vector256<float> a = in1;
Vector256<float> b = Unsafe.Add(ref in1, 1); Vector256<float> b = Unsafe.Add(ref in1, 1);
@ -521,6 +523,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Components
in1 = ref Unsafe.Add(ref in1, 2); in1 = ref Unsafe.Add(ref in1, 2);
in2 = ref Unsafe.Add(ref in2, 2); in2 = ref Unsafe.Add(ref in2, 2);
} }
}
#endif #endif
} }

Loading…
Cancel
Save