From 6ae2eb9eb208681a20bbcfbc8932fea5feae60f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=BCnther=20Foidl?= Date: Mon, 13 Mar 2023 13:17:26 +0100 Subject: [PATCH 01/12] Used unsigned division for vector sizes to get better codegen Cf. https://sharplab.io/#v2:EYLgxg9gTgpgtADwGwBYA0AXEBDAzgWwB8ABAJgEYBYAKGIAYACY8gOgCUBXAOwwEt8YLAJI8ovLrl5hcAbho1iAZiakGAYQYBvGg11NlXcRgYBZcgAojDADYwuAcwwALAJQMAvAD4bdx04YA9AwAajBgGNDkpAAcADwAZtYQ2BieLGoQ3Bhy1Hr6DIY8pqSWRbYOzm5eDOaFGC7mHEYu5X6BIWERUFFxicmp6Zk8OQC+QA= --- src/ImageSharp/Common/Helpers/Numerics.cs | 12 ++- .../Helpers/SimdUtils.ExtendedIntrinsics.cs | 8 +- .../Common/Helpers/SimdUtils.HwIntrinsics.cs | 84 +++++++++---------- .../Formats/Jpeg/Components/Block8x8F.cs | 4 +- .../JpegColorConverter.CmykAvx.cs | 4 +- .../JpegColorConverter.CmykVector.cs | 4 +- .../JpegColorConverter.GrayScaleAvx.cs | 4 +- .../JpegColorConverter.GrayScaleVector.cs | 4 +- .../JpegColorConverter.RgbAvx.cs | 2 +- .../JpegColorConverter.RgbVector.cs | 2 +- .../JpegColorConverter.YCbCrAvx.cs | 4 +- .../JpegColorConverter.YCbCrVector.cs | 4 +- .../JpegColorConverter.YccKAvx.cs | 4 +- .../JpegColorConverter.YccKVector.cs | 4 +- .../Components/Encoder/ComponentProcessor.cs | 8 +- .../ImageSharp.Benchmarks/Bulk/FromVector4.cs | 4 +- .../Bulk/ToVector4_Rgba32.cs | 12 +-- .../PixelConversion_PackFromRgbPlanes.cs | 4 +- .../General/Vectorization/UInt32ToSingle.cs | 16 ++-- .../General/Vectorization/VectorFetching.cs | 18 ++-- .../Vectorization/WidenBytesToUInt32.cs | 4 +- 21 files changed, 108 insertions(+), 102 deletions(-) diff --git a/src/ImageSharp/Common/Helpers/Numerics.cs b/src/ImageSharp/Common/Helpers/Numerics.cs index 7ba60cfe57..6fbd48f8cd 100644 --- a/src/ImageSharp/Common/Helpers/Numerics.cs +++ b/src/ImageSharp/Common/Helpers/Numerics.cs @@ -55,6 +55,12 @@ public static int LeastCommonMultiple(int a, int b) [MethodImpl(MethodImplOptions.AggressiveInlining)] public static int Modulo4(int x) => x & 3; + /// + /// Calculates % 4 + /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static nint Modulo4(nint x) => x & 3; + /// /// Calculates % 8 /// @@ -430,9 +436,9 @@ private static void ClampImpl(Span span, T min, T max) var vmin = new Vector(min); var vmax = new Vector(max); - int n = span.Length / Vector.Count; - int m = Modulo4(n); - int u = n - m; + nint n = (nint)(uint)span.Length / Vector.Count; + nint m = Modulo4(n); + nint u = n - m; ref Vector vs0 = ref Unsafe.As>(ref MemoryMarshal.GetReference(span)); ref Vector vs1 = ref Unsafe.Add(ref vs0, 1); diff --git a/src/ImageSharp/Common/Helpers/SimdUtils.ExtendedIntrinsics.cs b/src/ImageSharp/Common/Helpers/SimdUtils.ExtendedIntrinsics.cs index 2014a2a35b..9d2da7dc83 100644 --- a/src/ImageSharp/Common/Helpers/SimdUtils.ExtendedIntrinsics.cs +++ b/src/ImageSharp/Common/Helpers/SimdUtils.ExtendedIntrinsics.cs @@ -97,12 +97,12 @@ internal static void ByteToNormalizedFloat(ReadOnlySpan source, Span.Count); - int n = dest.Length / Vector.Count; + nint n = (nint)(uint)dest.Length / Vector.Count; ref Vector sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); ref Vector destBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(dest)); - for (int i = 0; i < n; i++) + for (nint i = 0; i < n; i++) { Vector b = Unsafe.Add(ref sourceBase, i); @@ -132,13 +132,13 @@ internal static void NormalizedFloatToByteSaturate( { VerifySpanInput(source, dest, Vector.Count); - int n = dest.Length / Vector.Count; + nint n = (nint)(uint)dest.Length / Vector.Count; ref Vector sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); ref Vector destBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(dest)); - for (int i = 0; i < n; i++) + for (nint i = 0; i < n; i++) { ref Vector s = ref Unsafe.Add(ref sourceBase, i * 4); diff --git a/src/ImageSharp/Common/Helpers/SimdUtils.HwIntrinsics.cs b/src/ImageSharp/Common/Helpers/SimdUtils.HwIntrinsics.cs index 3841b64b4d..a82b5559c7 100644 --- a/src/ImageSharp/Common/Helpers/SimdUtils.HwIntrinsics.cs +++ b/src/ImageSharp/Common/Helpers/SimdUtils.HwIntrinsics.cs @@ -221,11 +221,11 @@ private static void Shuffle4( ref Vector256 destBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(dest)); - int n = dest.Length / Vector256.Count; - int m = Numerics.Modulo4(n); - int u = n - m; + nint n = (nint)(uint)dest.Length / Vector256.Count; + nint m = Numerics.Modulo4(n); + nint u = n - m; - for (int i = 0; i < u; i += 4) + for (nint i = 0; i < u; i += 4) { ref Vector256 vd0 = ref Unsafe.Add(ref destBase, i); ref Vector256 vs0 = ref Unsafe.Add(ref sourceBase, i); @@ -238,7 +238,7 @@ private static void Shuffle4( if (m > 0) { - for (int i = u; i < n; i++) + for (nint i = u; i < n; i++) { Unsafe.Add(ref destBase, i) = Avx.Permute(Unsafe.Add(ref sourceBase, i), control); } @@ -253,11 +253,11 @@ private static void Shuffle4( ref Vector128 destBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(dest)); - int n = dest.Length / Vector128.Count; - int m = Numerics.Modulo4(n); - int u = n - m; + nint n = (nint)(uint)dest.Length / Vector128.Count; + nint m = Numerics.Modulo4(n); + nint u = n - m; - for (int i = 0; i < u; i += 4) + for (nint i = 0; i < u; i += 4) { ref Vector128 vd0 = ref Unsafe.Add(ref destBase, i); ref Vector128 vs0 = ref Unsafe.Add(ref sourceBase, i); @@ -276,7 +276,7 @@ private static void Shuffle4( if (m > 0) { - for (int i = u; i < n; i++) + for (nint i = u; i < n; i++) { Vector128 vs = Unsafe.Add(ref sourceBase, i); Unsafe.Add(ref destBase, i) = Sse.Shuffle(vs, vs, control); @@ -306,11 +306,11 @@ private static void Shuffle4( ref Vector256 destBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(dest)); - int n = dest.Length / Vector256.Count; - int m = Numerics.Modulo4(n); - int u = n - m; + nint n = (nint)(uint)dest.Length / Vector256.Count; + nint m = Numerics.Modulo4(n); + nint u = n - m; - for (int i = 0; i < u; i += 4) + for (nint i = 0; i < u; i += 4) { ref Vector256 vs0 = ref Unsafe.Add(ref sourceBase, i); ref Vector256 vd0 = ref Unsafe.Add(ref destBase, i); @@ -323,7 +323,7 @@ private static void Shuffle4( if (m > 0) { - for (int i = u; i < n; i++) + for (nint i = u; i < n; i++) { Unsafe.Add(ref destBase, i) = Avx2.Shuffle(Unsafe.Add(ref sourceBase, i), vshuffle); } @@ -342,11 +342,11 @@ private static void Shuffle4( ref Vector128 destBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(dest)); - int n = dest.Length / Vector128.Count; - int m = Numerics.Modulo4(n); - int u = n - m; + nint n = (nint)(uint)dest.Length / Vector128.Count; + nint m = Numerics.Modulo4(n); + nint u = n - m; - for (int i = 0; i < u; i += 4) + for (nint i = 0; i < u; i += 4) { ref Vector128 vs0 = ref Unsafe.Add(ref sourceBase, i); ref Vector128 vd0 = ref Unsafe.Add(ref destBase, i); @@ -359,7 +359,7 @@ private static void Shuffle4( if (m > 0) { - for (int i = u; i < n; i++) + for (nint i = u; i < n; i++) { Unsafe.Add(ref destBase, i) = Ssse3.Shuffle(Unsafe.Add(ref sourceBase, i), vshuffle); } @@ -391,9 +391,9 @@ private static void Shuffle3( ref Vector128 destBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(dest)); - int n = source.Length / Vector128.Count; + nint n = (nint)(uint)source.Length / Vector128.Count; - for (int i = 0; i < n; i += 3) + for (nint i = 0; i < n; i += 3) { ref Vector128 vs = ref Unsafe.Add(ref sourceBase, i); @@ -454,9 +454,9 @@ private static void Pad3Shuffle4( ref Vector128 destBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(dest)); - int n = source.Length / Vector128.Count; + nint n = (nint)(uint)source.Length / Vector128.Count; - for (int i = 0, j = 0; i < n; i += 3, j += 4) + for (nint i = 0, j = 0; i < n; i += 3, j += 4) { ref Vector128 v0 = ref Unsafe.Add(ref sourceBase, i); Vector128 v1 = Unsafe.Add(ref v0, 1); @@ -498,9 +498,9 @@ private static void Shuffle4Slice3( ref Vector128 destBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(dest)); - int n = source.Length / Vector128.Count; + nint n = (nint)(uint)source.Length / Vector128.Count; - for (int i = 0, j = 0; i < n; i += 4, j += 3) + for (nint i = 0, j = 0; i < n; i += 4, j += 3) { ref Vector128 vs = ref Unsafe.Add(ref sourceBase, i); @@ -650,16 +650,16 @@ internal static unsafe void ByteToNormalizedFloat( { VerifySpanInput(source, dest, Vector256.Count); - int n = dest.Length / Vector256.Count; + nint n = (nint)(uint)dest.Length / Vector256.Count; ref Vector256 destBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(dest)); var scale = Vector256.Create(1 / (float)byte.MaxValue); - for (int i = 0; i < n; i++) + for (nint i = 0; i < n; i++) { - int si = Vector256.Count * i; + nint si = Vector256.Count * i; Vector256 i0 = Avx2.ConvertToVector256Int32(sourceBase + si); Vector256 i1 = Avx2.ConvertToVector256Int32(sourceBase + si + Vector256.Count); Vector256 i2 = Avx2.ConvertToVector256Int32(sourceBase + si + (Vector256.Count * 2)); @@ -683,7 +683,7 @@ internal static unsafe void ByteToNormalizedFloat( // Sse VerifySpanInput(source, dest, Vector128.Count); - int n = dest.Length / Vector128.Count; + nint n = (nint)(uint)dest.Length / Vector128.Count; ref Vector128 destBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(dest)); @@ -691,9 +691,9 @@ internal static unsafe void ByteToNormalizedFloat( var scale = Vector128.Create(1 / (float)byte.MaxValue); Vector128 zero = Vector128.Zero; - for (int i = 0; i < n; i++) + for (nint i = 0; i < n; i++) { - int si = Vector128.Count * i; + nint si = Vector128.Count * i; Vector128 i0, i1, i2, i3; if (Sse41.IsSupported) @@ -782,7 +782,7 @@ internal static void NormalizedFloatToByteSaturate( { VerifySpanInput(source, dest, Vector256.Count); - int n = dest.Length / Vector256.Count; + nint n = (nint)(uint)dest.Length / Vector256.Count; ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -794,7 +794,7 @@ internal static void NormalizedFloatToByteSaturate( ref byte maskBase = ref MemoryMarshal.GetReference(PermuteMaskDeinterleave8x32); Vector256 mask = Unsafe.As>(ref maskBase); - for (int i = 0; i < n; i++) + for (nint i = 0; i < n; i++) { ref Vector256 s = ref Unsafe.Add(ref sourceBase, i * 4); @@ -821,7 +821,7 @@ internal static void NormalizedFloatToByteSaturate( // Sse VerifySpanInput(source, dest, Vector128.Count); - int n = dest.Length / Vector128.Count; + nint n = (nint)(uint)dest.Length / Vector128.Count; ref Vector128 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -831,7 +831,7 @@ internal static void NormalizedFloatToByteSaturate( var scale = Vector128.Create((float)byte.MaxValue); - for (int i = 0; i < n; i++) + for (nint i = 0; i < n; i++) { ref Vector128 s = ref Unsafe.Add(ref sourceBase, i * 4); @@ -864,7 +864,7 @@ internal static void PackFromRgbPlanesAvx2Reduce( ref Vector256 bBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(blueChannel)); ref byte dBase = ref Unsafe.As(ref MemoryMarshal.GetReference(destination)); - int count = redChannel.Length / Vector256.Count; + nint count = (nint)(uint)redChannel.Length / Vector256.Count; ref byte control1Bytes = ref MemoryMarshal.GetReference(PermuteMaskEvenOdd8x32); Vector256 control1 = Unsafe.As>(ref control1Bytes); @@ -875,7 +875,7 @@ internal static void PackFromRgbPlanesAvx2Reduce( Vector256 shuffleAlpha = Unsafe.As>(ref MemoryMarshal.GetReference(ShuffleMaskShiftAlpha)); - for (int i = 0; i < count; i++) + for (nint i = 0; i < count; i++) { Vector256 r0 = Unsafe.Add(ref rBase, i); Vector256 g0 = Unsafe.Add(ref gBase, i); @@ -918,7 +918,7 @@ internal static void PackFromRgbPlanesAvx2Reduce( Unsafe.As>(ref d4) = rgb4; } - int slice = count * Vector256.Count; + int slice = (int)count * Vector256.Count; redChannel = redChannel[slice..]; greenChannel = greenChannel[slice..]; blueChannel = blueChannel[slice..]; @@ -936,12 +936,12 @@ internal static void PackFromRgbPlanesAvx2Reduce( ref Vector256 bBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(blueChannel)); ref Vector256 dBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - int count = redChannel.Length / Vector256.Count; + nint count = (nint)(uint)redChannel.Length / Vector256.Count; ref byte control1Bytes = ref MemoryMarshal.GetReference(PermuteMaskEvenOdd8x32); Vector256 control1 = Unsafe.As>(ref control1Bytes); var a = Vector256.Create((byte)255); - for (int i = 0; i < count; i++) + for (nint i = 0; i < count; i++) { Vector256 r0 = Unsafe.Add(ref rBase, i); Vector256 g0 = Unsafe.Add(ref gBase, i); @@ -970,7 +970,7 @@ internal static void PackFromRgbPlanesAvx2Reduce( Unsafe.Add(ref d0, 3) = rgb4; } - int slice = count * Vector256.Count; + int slice = (int)count * Vector256.Count; redChannel = redChannel[slice..]; greenChannel = greenChannel[slice..]; blueChannel = blueChannel[slice..]; diff --git a/src/ImageSharp/Formats/Jpeg/Components/Block8x8F.cs b/src/ImageSharp/Formats/Jpeg/Components/Block8x8F.cs index 3bd5d28e74..a0a8cd28e2 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/Block8x8F.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/Block8x8F.cs @@ -425,7 +425,7 @@ public bool EqualsToScalar(int value) Vector256 targetVector = Vector256.Create(value); ref Vector256 blockStride = ref this.V0; - for (int i = 0; i < RowCount; i++) + for (nint i = 0; i < RowCount; i++) { Vector256 areEqual = Avx2.CompareEqual(Avx.ConvertToVector256Int32WithTruncation(Unsafe.Add(ref this.V0, i)), targetVector); if (Avx2.MoveMask(areEqual.AsByte()) != equalityMask) @@ -439,7 +439,7 @@ public bool EqualsToScalar(int value) ref float scalars = ref Unsafe.As(ref this); - for (int i = 0; i < Size; i++) + for (nint i = 0; i < Size; i++) { if ((int)Unsafe.Add(ref scalars, i) != value) { diff --git a/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.CmykAvx.cs b/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.CmykAvx.cs index 7d7b7e1859..3144afa76b 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.CmykAvx.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.CmykAvx.cs @@ -32,7 +32,7 @@ public override void ConvertToRgbInplace(in ComponentValues values) // Used for the color conversion var scale = Vector256.Create(1 / (this.MaximumValue * this.MaximumValue)); - nint n = values.Component0.Length / Vector256.Count; + nint n = (nint)(uint)values.Component0.Length / Vector256.Count; for (nint i = 0; i < n; i++) { ref Vector256 c = ref Unsafe.Add(ref c0Base, i); @@ -71,7 +71,7 @@ public static void ConvertFromRgb(in ComponentValues values, float maxValue, Spa var scale = Vector256.Create(maxValue); - nint n = values.Component0.Length / Vector256.Count; + nint n = (nint)(uint)values.Component0.Length / Vector256.Count; for (nint i = 0; i < n; i++) { Vector256 ctmp = Avx.Subtract(scale, Unsafe.Add(ref srcR, i)); diff --git a/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.CmykVector.cs b/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.CmykVector.cs index 93dcd378c8..03d9a1532a 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.CmykVector.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.CmykVector.cs @@ -30,7 +30,7 @@ protected override void ConvertToRgbInplaceVectorized(in ComponentValues values) var scale = new Vector(1 / (this.MaximumValue * this.MaximumValue)); - nint n = values.Component0.Length / Vector.Count; + nint n = (nint)(uint)values.Component0.Length / Vector.Count; for (nint i = 0; i < n; i++) { ref Vector c = ref Unsafe.Add(ref cBase, i); @@ -78,7 +78,7 @@ public static void ConvertFromRgbInplaceVectorized(in ComponentValues values, fl // Used for the color conversion var scale = new Vector(maxValue); - nint n = values.Component0.Length / Vector.Count; + nint n = (nint)(uint)values.Component0.Length / Vector.Count; for (nint i = 0; i < n; i++) { Vector ctmp = scale - Unsafe.Add(ref srcR, i); diff --git a/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.GrayScaleAvx.cs b/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.GrayScaleAvx.cs index 9cdbe71e84..4bb9869728 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.GrayScaleAvx.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.GrayScaleAvx.cs @@ -27,7 +27,7 @@ public override void ConvertToRgbInplace(in ComponentValues values) // Used for the color conversion var scale = Vector256.Create(1 / this.MaximumValue); - nint n = values.Component0.Length / Vector256.Count; + nint n = (nint)(uint)values.Component0.Length / Vector256.Count; for (nint i = 0; i < n; i++) { ref Vector256 c0 = ref Unsafe.Add(ref c0Base, i); @@ -53,7 +53,7 @@ public override void ConvertFromRgb(in ComponentValues values, Span rLane var f0587 = Vector256.Create(0.587f); var f0114 = Vector256.Create(0.114f); - nint n = values.Component0.Length / Vector256.Count; + nint n = (nint)(uint)values.Component0.Length / Vector256.Count; for (nint i = 0; i < n; i++) { ref Vector256 r = ref Unsafe.Add(ref srcRed, i); diff --git a/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.GrayScaleVector.cs b/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.GrayScaleVector.cs index 4d2355b95d..d8ba115d24 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.GrayScaleVector.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.GrayScaleVector.cs @@ -24,7 +24,7 @@ protected override void ConvertToRgbInplaceVectorized(in ComponentValues values) var scale = new Vector(1 / this.MaximumValue); - nint n = values.Component0.Length / Vector.Count; + nint n = (nint)(uint)values.Component0.Length / Vector.Count; for (nint i = 0; i < n; i++) { ref Vector c0 = ref Unsafe.Add(ref cBase, i); @@ -53,7 +53,7 @@ protected override void ConvertFromRgbVectorized(in ComponentValues values, Span var gMult = new Vector(0.587f); var bMult = new Vector(0.114f); - nint n = values.Component0.Length / Vector.Count; + nint n = (nint)(uint)values.Component0.Length / Vector.Count; for (nint i = 0; i < n; i++) { Vector r = Unsafe.Add(ref srcR, i); diff --git a/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.RgbAvx.cs b/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.RgbAvx.cs index b6c5117d44..76b2e9936c 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.RgbAvx.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.RgbAvx.cs @@ -29,7 +29,7 @@ public override void ConvertToRgbInplace(in ComponentValues values) // Used for the color conversion var scale = Vector256.Create(1 / this.MaximumValue); - nint n = values.Component0.Length / Vector256.Count; + nint n = (nint)(uint)values.Component0.Length / Vector256.Count; for (nint i = 0; i < n; i++) { ref Vector256 r = ref Unsafe.Add(ref rBase, i); diff --git a/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.RgbVector.cs b/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.RgbVector.cs index e51b0df4d2..5d85bb0482 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.RgbVector.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.RgbVector.cs @@ -28,7 +28,7 @@ protected override void ConvertToRgbInplaceVectorized(in ComponentValues values) var scale = new Vector(1 / this.MaximumValue); - nint n = values.Component0.Length / Vector.Count; + nint n = (nint)(uint)values.Component0.Length / Vector.Count; for (nint i = 0; i < n; i++) { ref Vector r = ref Unsafe.Add(ref rBase, i); diff --git a/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.YCbCrAvx.cs b/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.YCbCrAvx.cs index 081b985dbb..59f24493a1 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.YCbCrAvx.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.YCbCrAvx.cs @@ -38,7 +38,7 @@ public override void ConvertToRgbInplace(in ComponentValues values) var bCbMult = Vector256.Create(YCbCrScalar.BCbMult); // Walking 8 elements at one step: - nint n = values.Component0.Length / Vector256.Count; + nint n = (nint)(uint)values.Component0.Length / Vector256.Count; for (nint i = 0; i < n; i++) { // y = yVals[i]; @@ -98,7 +98,7 @@ public override void ConvertFromRgb(in ComponentValues values, Span rLane var fn0081312F = Vector256.Create(-0.081312F); var f05 = Vector256.Create(0.5f); - nint n = values.Component0.Length / Vector256.Count; + nint n = (nint)(uint)values.Component0.Length / Vector256.Count; for (nint i = 0; i < n; i++) { Vector256 r = Unsafe.Add(ref srcR, i); diff --git a/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.YCbCrVector.cs b/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.YCbCrVector.cs index 85211d4abf..0f7a364868 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.YCbCrVector.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.YCbCrVector.cs @@ -35,7 +35,7 @@ protected override void ConvertToRgbInplaceVectorized(in ComponentValues values) var gCrMult = new Vector(-YCbCrScalar.GCrMult); var bCbMult = new Vector(YCbCrScalar.BCbMult); - nint n = values.Component0.Length / Vector.Count; + nint n = (nint)(uint)values.Component0.Length / Vector.Count; for (nint i = 0; i < n; i++) { // y = yVals[i]; @@ -103,7 +103,7 @@ protected override void ConvertFromRgbVectorized(in ComponentValues values, Span var gCrMult = new Vector(0.418688f); var bCrMult = new Vector(0.081312f); - nint n = values.Component0.Length / Vector.Count; + nint n = (nint)(uint)values.Component0.Length / Vector.Count; for (nint i = 0; i < n; i++) { Vector r = Unsafe.Add(ref srcR, i); diff --git a/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.YccKAvx.cs b/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.YccKAvx.cs index 1f79cbffb6..0cfb3201b4 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.YccKAvx.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.YccKAvx.cs @@ -40,7 +40,7 @@ public override void ConvertToRgbInplace(in ComponentValues values) var bCbMult = Vector256.Create(YCbCrScalar.BCbMult); // Walking 8 elements at one step: - nint n = values.Component0.Length / Vector256.Count; + nint n = (nint)(uint)values.Component0.Length / Vector256.Count; for (nint i = 0; i < n; i++) { // y = yVals[i]; @@ -109,7 +109,7 @@ public override void ConvertFromRgb(in ComponentValues values, Span rLane var fn0081312F = Vector256.Create(-0.081312F); var f05 = Vector256.Create(0.5f); - nint n = values.Component0.Length / Vector256.Count; + nint n = (nint)(uint)values.Component0.Length / Vector256.Count; for (nint i = 0; i < n; i++) { Vector256 r = Avx.Subtract(maxSampleValue, Unsafe.Add(ref srcR, i)); diff --git a/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.YccKVector.cs b/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.YccKVector.cs index 91a6cedc06..feefe3021d 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.YccKVector.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.YccKVector.cs @@ -36,7 +36,7 @@ protected override void ConvertToRgbInplaceVectorized(in ComponentValues values) var gCrMult = new Vector(-YCbCrScalar.GCrMult); var bCbMult = new Vector(YCbCrScalar.BCbMult); - nint n = values.Component0.Length / Vector.Count; + nint n = (nint)(uint)values.Component0.Length / Vector.Count; for (nint i = 0; i < n; i++) { // y = yVals[i]; @@ -107,7 +107,7 @@ protected override void ConvertFromRgbVectorized(in ComponentValues values, Span var gCrMult = new Vector(0.418688f); var bCrMult = new Vector(0.081312f); - nint n = values.Component0.Length / Vector.Count; + nint n = (nint)(uint)values.Component0.Length / Vector.Count; for (nint i = 0; i < n; i++) { Vector r = maxSampleValue - Unsafe.Add(ref srcR, i); diff --git a/src/ImageSharp/Formats/Jpeg/Components/Encoder/ComponentProcessor.cs b/src/ImageSharp/Formats/Jpeg/Components/Encoder/ComponentProcessor.cs index 2bc1405509..23ddd0e495 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/Encoder/ComponentProcessor.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/Encoder/ComponentProcessor.cs @@ -122,7 +122,7 @@ static void SumVertical(Span target, Span source) ref Vector256 sourceVectorRef = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); // Spans are guaranteed to be multiple of 8 so no extra 'remainder' steps are needed - nint count = source.Length / Vector256.Count; + nint count = (nint)(uint)source.Length / Vector256.Count; for (nint i = 0; i < count; i++) { Unsafe.Add(ref targetVectorRef, i) = Avx.Add(Unsafe.Add(ref targetVectorRef, i), Unsafe.Add(ref sourceVectorRef, i)); @@ -133,7 +133,7 @@ static void SumVertical(Span target, Span source) ref Vector targetVectorRef = ref Unsafe.As>(ref MemoryMarshal.GetReference(target)); ref Vector sourceVectorRef = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); - nint count = source.Length / Vector.Count; + nint count = (nint)(uint)source.Length / Vector.Count; for (nint i = 0; i < count; i++) { Unsafe.Add(ref targetVectorRef, i) += Unsafe.Add(ref sourceVectorRef, i); @@ -200,7 +200,7 @@ static void MultiplyToAverage(Span target, float multiplier) ref Vector256 targetVectorRef = ref Unsafe.As>(ref MemoryMarshal.GetReference(target)); // Spans are guaranteed to be multiple of 8 so no extra 'remainder' steps are needed - nint count = target.Length / Vector256.Count; + nint count = (nint)(uint)target.Length / Vector256.Count; var multiplierVector = Vector256.Create(multiplier); for (nint i = 0; i < count; i++) { @@ -211,7 +211,7 @@ static void MultiplyToAverage(Span target, float multiplier) { ref Vector targetVectorRef = ref Unsafe.As>(ref MemoryMarshal.GetReference(target)); - nint count = target.Length / Vector.Count; + nint count = (nint)(uint)target.Length / Vector.Count; var multiplierVector = new Vector(multiplier); for (nint i = 0; i < count; i++) { diff --git a/tests/ImageSharp.Benchmarks/Bulk/FromVector4.cs b/tests/ImageSharp.Benchmarks/Bulk/FromVector4.cs index dd3fb8ac82..0637b33347 100644 --- a/tests/ImageSharp.Benchmarks/Bulk/FromVector4.cs +++ b/tests/ImageSharp.Benchmarks/Bulk/FromVector4.cs @@ -103,7 +103,7 @@ public void UseAvx2_Grouped() Span src = MemoryMarshal.Cast(this.source.GetSpan()); Span dest = MemoryMarshal.Cast(this.destination.GetSpan()); - int n = dest.Length / Vector.Count; + nint n = (nint)(uint)dest.Length / Vector.Count; ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(src)); @@ -114,7 +114,7 @@ public void UseAvx2_Grouped() var maxBytes = Vector256.Create(255f); - for (int i = 0; i < n; i++) + for (nint i = 0; i < n; i++) { ref Vector256 s = ref Unsafe.Add(ref sourceBase, i * 4); diff --git a/tests/ImageSharp.Benchmarks/Bulk/ToVector4_Rgba32.cs b/tests/ImageSharp.Benchmarks/Bulk/ToVector4_Rgba32.cs index b0eb6b46dc..913ab24dc1 100644 --- a/tests/ImageSharp.Benchmarks/Bulk/ToVector4_Rgba32.cs +++ b/tests/ImageSharp.Benchmarks/Bulk/ToVector4_Rgba32.cs @@ -54,13 +54,13 @@ public void ExtendedIntrinsics_BulkConvertByteToNormalizedFloat_2Loops() Span sBytes = MemoryMarshal.Cast(this.source.GetSpan()); Span dFloats = MemoryMarshal.Cast(this.destination.GetSpan()); - int n = dFloats.Length / Vector.Count; + nint n = (nint)(uint)dFloats.Length / Vector.Count; ref Vector sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference((ReadOnlySpan)sBytes)); ref Vector destBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(dFloats)); ref Vector destBaseU = ref Unsafe.As, Vector>(ref destBase); - for (int i = 0; i < n; i++) + for (nint i = 0; i < n; i++) { Vector b = Unsafe.Add(ref sourceBase, i); @@ -75,10 +75,10 @@ public void ExtendedIntrinsics_BulkConvertByteToNormalizedFloat_2Loops() Unsafe.Add(ref d, 3) = w3; } - n = dFloats.Length / Vector.Count; + n = (nint)(uint)dFloats.Length / Vector.Count; var scale = new Vector(1f / 255f); - for (int i = 0; i < n; i++) + for (nint i = 0; i < n; i++) { ref Vector dRef = ref Unsafe.Add(ref destBase, i); @@ -96,13 +96,13 @@ public void ExtendedIntrinsics_BulkConvertByteToNormalizedFloat_ConvertInSameLoo Span sBytes = MemoryMarshal.Cast(this.source.GetSpan()); Span dFloats = MemoryMarshal.Cast(this.destination.GetSpan()); - int n = dFloats.Length / Vector.Count; + nint n = (nint)(uint)dFloats.Length / Vector.Count; ref Vector sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference((ReadOnlySpan)sBytes)); ref Vector destBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(dFloats)); var scale = new Vector(1f / 255f); - for (int i = 0; i < n; i++) + for (nint i = 0; i < n; i++) { Vector b = Unsafe.Add(ref sourceBase, i); diff --git a/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_PackFromRgbPlanes.cs b/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_PackFromRgbPlanes.cs index 86ac928af9..061b1e1269 100644 --- a/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_PackFromRgbPlanes.cs +++ b/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_PackFromRgbPlanes.cs @@ -205,14 +205,14 @@ public void Rgba32_Avx2_Float() ref Vector256 bBase = ref Unsafe.As>(ref this.bFloat[0]); ref Vector256 resultBase = ref Unsafe.As>(ref this.rgbaFloat[0]); - int count = this.Count / Vector256.Count; + nint count = (nint)(uint)this.Count / Vector256.Count; ref byte control = ref MemoryMarshal.GetReference(SimdUtils.HwIntrinsics.PermuteMaskEvenOdd8x32); Vector256 vcontrol = Unsafe.As>(ref control); var va = Vector256.Create(1F); - for (int i = 0; i < count; i++) + for (nint i = 0; i < count; i++) { Vector256 r = Unsafe.Add(ref rBase, i); Vector256 g = Unsafe.Add(ref gBase, i); diff --git a/tests/ImageSharp.Benchmarks/General/Vectorization/UInt32ToSingle.cs b/tests/ImageSharp.Benchmarks/General/Vectorization/UInt32ToSingle.cs index 63d363c688..57c7b6faf7 100644 --- a/tests/ImageSharp.Benchmarks/General/Vectorization/UInt32ToSingle.cs +++ b/tests/ImageSharp.Benchmarks/General/Vectorization/UInt32ToSingle.cs @@ -25,14 +25,14 @@ public void MagicMethod() { ref Vector b = ref Unsafe.As>(ref this.data[0]); - int n = Count / Vector.Count; + nint n = Count / Vector.Count; var bVec = new Vector(256.0f / 255.0f); var magicFloat = new Vector(32768.0f); var magicInt = new Vector(1191182336); // reinterpreted value of 32768.0f var mask = new Vector(255); - for (int i = 0; i < n; i++) + for (nint i = 0; i < n; i++) { ref Vector df = ref Unsafe.Add(ref b, i); @@ -50,14 +50,14 @@ public void MagicMethod() [Benchmark] public void StandardSimd() { - int n = Count / Vector.Count; + nint n = Count / Vector.Count; ref Vector bf = ref Unsafe.As>(ref this.data[0]); ref Vector bu = ref Unsafe.As, Vector>(ref bf); var scale = new Vector(1f / 255f); - for (int i = 0; i < n; i++) + for (nint i = 0; i < n; i++) { Vector u = Unsafe.Add(ref bu, i); Vector v = Vector.ConvertToSingle(u); @@ -69,14 +69,14 @@ public void StandardSimd() [Benchmark] public void StandardSimdFromInt() { - int n = Count / Vector.Count; + nint n = Count / Vector.Count; ref Vector bf = ref Unsafe.As>(ref this.data[0]); ref Vector bu = ref Unsafe.As, Vector>(ref bf); var scale = new Vector(1f / 255f); - for (int i = 0; i < n; i++) + for (nint i = 0; i < n; i++) { Vector u = Unsafe.Add(ref bu, i); Vector v = Vector.ConvertToSingle(u); @@ -88,12 +88,12 @@ public void StandardSimdFromInt() [Benchmark] public void StandardSimdFromInt_RefCast() { - int n = Count / Vector.Count; + nint n = Count / Vector.Count; ref Vector bf = ref Unsafe.As>(ref this.data[0]); var scale = new Vector(1f / 255f); - for (int i = 0; i < n; i++) + for (nint i = 0; i < n; i++) { ref Vector fRef = ref Unsafe.Add(ref bf, i); diff --git a/tests/ImageSharp.Benchmarks/General/Vectorization/VectorFetching.cs b/tests/ImageSharp.Benchmarks/General/Vectorization/VectorFetching.cs index 07ace06686..7da2626dcc 100644 --- a/tests/ImageSharp.Benchmarks/General/Vectorization/VectorFetching.cs +++ b/tests/ImageSharp.Benchmarks/General/Vectorization/VectorFetching.cs @@ -63,14 +63,14 @@ public void FetchWithUnsafeCast() var v = new Vector(this.testValue); ref Vector start = ref Unsafe.As>(ref this.data[0]); - int n = this.InputSize / Vector.Count; + nint n = (nint)(uint)this.InputSize / Vector.Count; - for (int i = 0; i < n; i++) + for (nint i = 0; i < n; i++) { ref Vector p = ref Unsafe.Add(ref start, i); Vector a = p; - a = a * v; + a *= v; p = a; } @@ -82,12 +82,12 @@ public void FetchWithUnsafeCastNoTempVector() var v = new Vector(this.testValue); ref Vector start = ref Unsafe.As>(ref this.data[0]); - int n = this.InputSize / Vector.Count; + nint n = (nint)(uint)this.InputSize / Vector.Count; - for (int i = 0; i < n; i++) + for (nint i = 0; i < n; i++) { ref Vector a = ref Unsafe.Add(ref start, i); - a = a * v; + a *= v; } } @@ -100,12 +100,12 @@ public void FetchWithUnsafeCastFromReference() ref Vector start = ref Unsafe.As>(ref MemoryMarshal.GetReference(span)); - int n = this.InputSize / Vector.Count; + nint n = (nint)(uint)this.InputSize / Vector.Count; - for (int i = 0; i < n; i++) + for (nint i = 0; i < n; i++) { ref Vector a = ref Unsafe.Add(ref start, i); - a = a * v; + a *= v; } } } diff --git a/tests/ImageSharp.Benchmarks/General/Vectorization/WidenBytesToUInt32.cs b/tests/ImageSharp.Benchmarks/General/Vectorization/WidenBytesToUInt32.cs index 429475ffd3..4615376a5f 100644 --- a/tests/ImageSharp.Benchmarks/General/Vectorization/WidenBytesToUInt32.cs +++ b/tests/ImageSharp.Benchmarks/General/Vectorization/WidenBytesToUInt32.cs @@ -42,12 +42,12 @@ public void Standard() [Benchmark] public void Simd() { - int n = Count / Vector.Count; + nint n = Count / Vector.Count; ref Vector sBase = ref Unsafe.As>(ref this.source[0]); ref Vector dBase = ref Unsafe.As>(ref this.dest[0]); - for (int i = 0; i < n; i++) + for (nint i = 0; i < n; i++) { Vector b = Unsafe.Add(ref sBase, i); From 1920e28ed0313e998a2fae6735969ebfc1242c61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=BCnther=20Foidl?= Date: Mon, 13 Mar 2023 16:47:32 +0100 Subject: [PATCH 02/12] Revised Unsafe.Add to avoid the sign-extending move --- .../ColorSpaces/Companding/SRgbCompanding.cs | 4 +- .../Conversion/ColorSpaceConverter.CieLab.cs | 26 +- .../Conversion/ColorSpaceConverter.CieLch.cs | 26 +- .../ColorSpaceConverter.CieLchuv.cs | 26 +- .../Conversion/ColorSpaceConverter.CieLuv.cs | 26 +- .../Conversion/ColorSpaceConverter.CieXyy.cs | 26 +- .../Conversion/ColorSpaceConverter.CieXyz.cs | 26 +- .../Conversion/ColorSpaceConverter.Cmyk.cs | 26 +- .../Conversion/ColorSpaceConverter.Hsl.cs | 26 +- .../Conversion/ColorSpaceConverter.Hsv.cs | 26 +- .../ColorSpaceConverter.HunterLab.cs | 26 +- .../ColorSpaceConverter.LinearRgb.cs | 26 +- .../Conversion/ColorSpaceConverter.Lms.cs | 28 +- .../Conversion/ColorSpaceConverter.Rgb.cs | 26 +- .../Conversion/ColorSpaceConverter.YCbCr.cs | 24 +- .../VonKriesChromaticAdaptation.cs | 2 +- src/ImageSharp/Common/Helpers/Numerics.cs | 24 +- .../Helpers/Shuffle/IComponentShuffle.cs | 20 +- .../Common/Helpers/Shuffle/IPad3Shuffle4.cs | 12 +- .../Common/Helpers/Shuffle/IShuffle3.cs | 8 +- .../Common/Helpers/Shuffle/IShuffle4Slice3.cs | 14 +- .../SimdUtils.FallbackIntrinsics128.cs | 4 +- .../Common/Helpers/SimdUtils.HwIntrinsics.cs | 4 +- .../Common/Helpers/SimdUtils.Pack.cs | 18 +- .../Common/Helpers/SimdUtils.Shuffle.cs | 18 +- src/ImageSharp/Compression/Zlib/Crc32.cs | 2 +- .../Compression/Zlib/DeflaterHuffman.cs | 94 ++-- src/ImageSharp/Formats/Gif/GifDecoderCore.cs | 8 +- src/ImageSharp/Formats/Gif/GifEncoderCore.cs | 2 +- src/ImageSharp/Formats/Gif/LzwDecoder.cs | 38 +- src/ImageSharp/Formats/Gif/LzwEncoder.cs | 22 +- .../Formats/Jpeg/Components/Block8x8.cs | 10 +- .../Jpeg/Components/Block8x8F.Generated.cs | 18 +- .../Jpeg/Components/Block8x8F.Intrinsic.cs | 6 +- .../Jpeg/Components/Block8x8F.ScaledCopy.cs | 12 +- .../JpegColorConverter.GrayScaleScalar.cs | 2 +- .../Decoder/ArithmeticScanDecoder.cs | 4 +- .../Components/Decoder/HuffmanScanDecoder.cs | 12 +- .../Components/Encoder/ComponentProcessor.cs | 12 +- .../Components/Encoder/HuffmanScanEncoder.cs | 4 +- .../Formats/Png/Filters/AverageFilter.cs | 16 +- .../Formats/Png/Filters/PaethFilter.cs | 12 +- .../Formats/Png/Filters/SubFilter.cs | 14 +- .../Formats/Png/Filters/UpFilter.cs | 14 +- src/ImageSharp/Formats/Png/PngDecoderCore.cs | 4 +- src/ImageSharp/Formats/Png/PngEncoderCore.cs | 14 +- .../Formats/Png/PngEncoderHelpers.cs | 6 +- .../Formats/Png/PngScanlineProcessor.cs | 110 ++--- .../Decompressors/T6TiffCompression.cs | 2 +- .../BlackIsZero1TiffColor{TPixel}.cs | 6 +- .../WhiteIsZero1TiffColor{TPixel}.cs | 6 +- src/ImageSharp/Formats/Webp/AlphaDecoder.cs | 11 +- .../Formats/Webp/Lossless/LosslessUtils.cs | 22 +- .../Formats/Webp/Lossless/Vp8LHistogram.cs | 29 +- .../Formats/Webp/Lossy/LossyUtils.cs | 114 ++--- src/ImageSharp/Formats/Webp/Lossy/QuantEnc.cs | 2 +- .../Formats/Webp/Lossy/YuvConversion.cs | 8 +- .../Allocators/Internals/ManagedBufferBase.cs | 2 +- .../DiscontiguousBuffers/MemoryGroup{T}.cs | 2 +- .../DefaultPixelBlenders.Generated.cs | 432 +++++++++--------- .../DefaultPixelBlenders.Generated.tt | 4 +- .../PixelImplementations/Abgr32.cs | 2 +- .../PixelImplementations/Bgr24.cs | 2 +- .../Abgr32.PixelOperations.Generated.cs | 14 +- .../Argb32.PixelOperations.Generated.cs | 14 +- .../Bgr24.PixelOperations.Generated.cs | 14 +- .../Bgra32.PixelOperations.Generated.cs | 14 +- .../Bgra5551.PixelOperations.Generated.cs | 24 +- .../L16.PixelOperations.Generated.cs | 24 +- .../Generated/L8.PixelOperations.Generated.cs | 24 +- .../La16.PixelOperations.Generated.cs | 6 +- .../Rgb24.PixelOperations.Generated.cs | 14 +- .../Rgb48.PixelOperations.Generated.cs | 24 +- .../Generated/_Common.ttinclude | 2 +- .../RgbaVector.PixelOperations.cs | 4 +- .../PixelOperations{TPixel}.Generated.cs | 52 +-- .../PixelOperations{TPixel}.Generated.tt | 4 +- .../PixelFormats/PixelOperations{TPixel}.cs | 4 +- .../Utils/Vector4Converters.Default.cs | 10 +- .../Convolution/BokehBlurProcessor.cs | 6 +- .../Convolution/BokehBlurProcessor{TPixel}.cs | 16 +- .../Convolution2DRowOperation{TPixel}.cs | 30 +- .../Convolution/Convolution2DState.cs | 4 +- .../Convolution2PassProcessor{TPixel}.cs | 30 +- .../ConvolutionProcessor{TPixel}.cs | 20 +- .../Convolution/ConvolutionState.cs | 4 +- .../EdgeDetectorCompassProcessor{TPixel}.cs | 4 +- .../Processors/Convolution/Kernel.cs | 6 +- .../Convolution/KernelSamplingMap.cs | 2 +- .../Convolution/MedianConvolutionState.cs | 4 +- .../Convolution/MedianRowOperation{TPixel}.cs | 14 +- .../Parameters/BokehBlurKernelDataProvider.cs | 16 +- .../Processors/Convolution/ReadOnlyKernel.cs | 2 +- .../Processors/Dithering/ErrorDither.cs | 6 +- .../Effects/OilPaintingProcessor{TPixel}.cs | 24 +- .../Filters/OpaqueProcessor{TPixel}.cs | 2 +- ...alizationSlidingWindowProcessor{TPixel}.cs | 10 +- .../AutoLevelProcessor{TPixel}.cs | 10 +- ...lHistogramEqualizationProcessor{TPixel}.cs | 6 +- .../GrayscaleLevelsRowOperation{TPixel}.cs | 4 +- .../HistogramEqualizationProcessor{TPixel}.cs | 8 +- .../Quantization/EuclideanPixelMap{TPixel}.cs | 4 +- .../Transforms/Resize/ResizeWorker.cs | 6 +- .../ImageSharp.Benchmarks/Bulk/FromVector4.cs | 2 +- .../Bulk/PremultiplyVector4.cs | 4 +- .../Bulk/UnPremultiplyVector4.cs | 4 +- .../BlockOperations/Block8x8F_CopyTo1x1.cs | 78 ++-- .../BlockOperations/Block8x8F_CopyTo2x2.cs | 68 +-- .../Jpeg/BlockOperations/Block8x8F_Round.cs | 8 +- .../PixelConversion_ConvertFromRgba32.cs | 10 +- .../PixelConversion_ConvertFromVector4.cs | 4 +- .../PixelConversion_ConvertToRgba32.cs | 4 +- ...vertToRgba32_AsPartOfCompositeOperation.cs | 4 +- .../PixelConversion_ConvertToVector4.cs | 4 +- ...ertToVector4_AsPartOfCompositeOperation.cs | 4 +- .../PixelConversion_PackFromRgbPlanes.cs | 6 +- .../PixelConversion_Rgba32_To_Argb32.cs | 12 +- .../PixelConversion_Rgba32_To_Bgra32.cs | 26 +- .../Vectorization/WidenBytesToUInt32.cs | 2 +- .../PorterDuffBulkVsSingleVector.cs | 2 +- .../Formats/Png/ReferenceImplementations.cs | 22 +- ...ConverterTests.ReferenceImplementations.cs | 6 +- .../PixelOperations/PixelOperationsTests.cs | 2 +- 123 files changed, 1166 insertions(+), 1164 deletions(-) diff --git a/src/ImageSharp/ColorSpaces/Companding/SRgbCompanding.cs b/src/ImageSharp/ColorSpaces/Companding/SRgbCompanding.cs index e776a0dc20..2a6fcb0832 100644 --- a/src/ImageSharp/ColorSpaces/Companding/SRgbCompanding.cs +++ b/src/ImageSharp/ColorSpaces/Companding/SRgbCompanding.cs @@ -175,7 +175,7 @@ private static unsafe void CompandAvx2(Span vectors, float[] table) // Divide by 2 as 4 elements per Vector4 and 8 per Vector256 ref Vector256 vectorsBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(vectors)); - ref Vector256 vectorsLast = ref Unsafe.Add(ref vectorsBase, (IntPtr)((uint)vectors.Length / 2u)); + ref Vector256 vectorsLast = ref Unsafe.Add(ref vectorsBase, (uint)vectors.Length / 2u); while (Unsafe.IsAddressLessThan(ref vectorsBase, ref vectorsLast)) { @@ -204,7 +204,7 @@ private static unsafe void CompandScalar(Span vectors, float[] table) Vector4 zero = Vector4.Zero; var scale = new Vector4(Scale); ref Vector4 vectorsBase = ref MemoryMarshal.GetReference(vectors); - ref Vector4 vectorsLast = ref Unsafe.Add(ref vectorsBase, vectors.Length); + ref Vector4 vectorsLast = ref Unsafe.Add(ref vectorsBase, (uint)vectors.Length); while (Unsafe.IsAddressLessThan(ref vectorsBase, ref vectorsLast)) { diff --git a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieLab.cs b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieLab.cs index 721df36678..88343cbab4 100644 --- a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieLab.cs +++ b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieLab.cs @@ -37,7 +37,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref CieLch sourceRef = ref MemoryMarshal.GetReference(source); ref CieLab destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref CieLch sp = ref Unsafe.Add(ref sourceRef, i); ref CieLab dp = ref Unsafe.Add(ref destRef, i); @@ -70,7 +70,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref CieLchuv sourceRef = ref MemoryMarshal.GetReference(source); ref CieLab destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref CieLchuv sp = ref Unsafe.Add(ref sourceRef, i); ref CieLab dp = ref Unsafe.Add(ref destRef, i); @@ -103,7 +103,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref CieLuv sourceRef = ref MemoryMarshal.GetReference(source); ref CieLab destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref CieLuv sp = ref Unsafe.Add(ref sourceRef, i); ref CieLab dp = ref Unsafe.Add(ref destRef, i); @@ -136,7 +136,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref CieXyy sourceRef = ref MemoryMarshal.GetReference(source); ref CieLab destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref CieXyy sp = ref Unsafe.Add(ref sourceRef, i); ref CieLab dp = ref Unsafe.Add(ref destRef, i); @@ -169,7 +169,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref CieXyz sourceRef = ref MemoryMarshal.GetReference(source); ref CieLab destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref CieXyz sp = ref Unsafe.Add(ref sourceRef, i); ref CieLab dp = ref Unsafe.Add(ref destRef, i); @@ -201,7 +201,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref Cmyk sourceRef = ref MemoryMarshal.GetReference(source); ref CieLab destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref Cmyk sp = ref Unsafe.Add(ref sourceRef, i); ref CieLab dp = ref Unsafe.Add(ref destRef, i); @@ -234,7 +234,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref Hsl sourceRef = ref MemoryMarshal.GetReference(source); ref CieLab destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref Hsl sp = ref Unsafe.Add(ref sourceRef, i); ref CieLab dp = ref Unsafe.Add(ref destRef, i); @@ -266,7 +266,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref Hsv sourceRef = ref MemoryMarshal.GetReference(source); ref CieLab destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref Hsv sp = ref Unsafe.Add(ref sourceRef, i); ref CieLab dp = ref Unsafe.Add(ref destRef, i); @@ -299,7 +299,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref HunterLab sourceRef = ref MemoryMarshal.GetReference(source); ref CieLab destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref HunterLab sp = ref Unsafe.Add(ref sourceRef, i); ref CieLab dp = ref Unsafe.Add(ref destRef, i); @@ -332,7 +332,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref Lms sourceRef = ref MemoryMarshal.GetReference(source); ref CieLab destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref Lms sp = ref Unsafe.Add(ref sourceRef, i); ref CieLab dp = ref Unsafe.Add(ref destRef, i); @@ -365,7 +365,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref LinearRgb sourceRef = ref MemoryMarshal.GetReference(source); ref CieLab destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref LinearRgb sp = ref Unsafe.Add(ref sourceRef, i); ref CieLab dp = ref Unsafe.Add(ref destRef, i); @@ -398,7 +398,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref Rgb sourceRef = ref MemoryMarshal.GetReference(source); ref CieLab destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref Rgb sp = ref Unsafe.Add(ref sourceRef, i); ref CieLab dp = ref Unsafe.Add(ref destRef, i); @@ -431,7 +431,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref YCbCr sourceRef = ref MemoryMarshal.GetReference(source); ref CieLab destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref YCbCr sp = ref Unsafe.Add(ref sourceRef, i); ref CieLab dp = ref Unsafe.Add(ref destRef, i); diff --git a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieLch.cs b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieLch.cs index da8e68b480..dcd6be185c 100644 --- a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieLch.cs +++ b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieLch.cs @@ -36,7 +36,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref CieLab sourceRef = ref MemoryMarshal.GetReference(source); ref CieLch destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref CieLab sp = ref Unsafe.Add(ref sourceRef, i); ref CieLch dp = ref Unsafe.Add(ref destRef, i); @@ -69,7 +69,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref CieLchuv sourceRef = ref MemoryMarshal.GetReference(source); ref CieLch destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref CieLchuv sp = ref Unsafe.Add(ref sourceRef, i); ref CieLch dp = ref Unsafe.Add(ref destRef, i); @@ -102,7 +102,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref CieLuv sourceRef = ref MemoryMarshal.GetReference(source); ref CieLch destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref CieLuv sp = ref Unsafe.Add(ref sourceRef, i); ref CieLch dp = ref Unsafe.Add(ref destRef, i); @@ -135,7 +135,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref CieXyy sourceRef = ref MemoryMarshal.GetReference(source); ref CieLch destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref CieXyy sp = ref Unsafe.Add(ref sourceRef, i); ref CieLch dp = ref Unsafe.Add(ref destRef, i); @@ -168,7 +168,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref CieXyz sourceRef = ref MemoryMarshal.GetReference(source); ref CieLch destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref CieXyz sp = ref Unsafe.Add(ref sourceRef, i); ref CieLch dp = ref Unsafe.Add(ref destRef, i); @@ -200,7 +200,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref Cmyk sourceRef = ref MemoryMarshal.GetReference(source); ref CieLch destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref Cmyk sp = ref Unsafe.Add(ref sourceRef, i); ref CieLch dp = ref Unsafe.Add(ref destRef, i); @@ -233,7 +233,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref Hsl sourceRef = ref MemoryMarshal.GetReference(source); ref CieLch destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref Hsl sp = ref Unsafe.Add(ref sourceRef, i); ref CieLch dp = ref Unsafe.Add(ref destRef, i); @@ -266,7 +266,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref Hsv sourceRef = ref MemoryMarshal.GetReference(source); ref CieLch destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref Hsv sp = ref Unsafe.Add(ref sourceRef, i); ref CieLch dp = ref Unsafe.Add(ref destRef, i); @@ -299,7 +299,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref HunterLab sourceRef = ref MemoryMarshal.GetReference(source); ref CieLch destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref HunterLab sp = ref Unsafe.Add(ref sourceRef, i); ref CieLch dp = ref Unsafe.Add(ref destRef, i); @@ -332,7 +332,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref LinearRgb sourceRef = ref MemoryMarshal.GetReference(source); ref CieLch destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref LinearRgb sp = ref Unsafe.Add(ref sourceRef, i); ref CieLch dp = ref Unsafe.Add(ref destRef, i); @@ -365,7 +365,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref Lms sourceRef = ref MemoryMarshal.GetReference(source); ref CieLch destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref Lms sp = ref Unsafe.Add(ref sourceRef, i); ref CieLch dp = ref Unsafe.Add(ref destRef, i); @@ -398,7 +398,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref Rgb sourceRef = ref MemoryMarshal.GetReference(source); ref CieLch destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref Rgb sp = ref Unsafe.Add(ref sourceRef, i); ref CieLch dp = ref Unsafe.Add(ref destRef, i); @@ -431,7 +431,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref YCbCr sourceRef = ref MemoryMarshal.GetReference(source); ref CieLch destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref YCbCr sp = ref Unsafe.Add(ref sourceRef, i); ref CieLch dp = ref Unsafe.Add(ref destRef, i); diff --git a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieLchuv.cs b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieLchuv.cs index 75e955e41f..eb21394a09 100644 --- a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieLchuv.cs +++ b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieLchuv.cs @@ -36,7 +36,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref CieLab sourceRef = ref MemoryMarshal.GetReference(source); ref CieLchuv destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref CieLab sp = ref Unsafe.Add(ref sourceRef, i); ref CieLchuv dp = ref Unsafe.Add(ref destRef, i); @@ -69,7 +69,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref CieLch sourceRef = ref MemoryMarshal.GetReference(source); ref CieLchuv destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref CieLch sp = ref Unsafe.Add(ref sourceRef, i); ref CieLchuv dp = ref Unsafe.Add(ref destRef, i); @@ -102,7 +102,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref CieLuv sourceRef = ref MemoryMarshal.GetReference(source); ref CieLchuv destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref CieLuv sp = ref Unsafe.Add(ref sourceRef, i); ref CieLchuv dp = ref Unsafe.Add(ref destRef, i); @@ -135,7 +135,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref CieXyy sourceRef = ref MemoryMarshal.GetReference(source); ref CieLchuv destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref CieXyy sp = ref Unsafe.Add(ref sourceRef, i); ref CieLchuv dp = ref Unsafe.Add(ref destRef, i); @@ -168,7 +168,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref CieXyz sourceRef = ref MemoryMarshal.GetReference(source); ref CieLchuv destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref CieXyz sp = ref Unsafe.Add(ref sourceRef, i); ref CieLchuv dp = ref Unsafe.Add(ref destRef, i); @@ -201,7 +201,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref Cmyk sourceRef = ref MemoryMarshal.GetReference(source); ref CieLchuv destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref Cmyk sp = ref Unsafe.Add(ref sourceRef, i); ref CieLchuv dp = ref Unsafe.Add(ref destRef, i); @@ -234,7 +234,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref Hsl sourceRef = ref MemoryMarshal.GetReference(source); ref CieLchuv destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref Hsl sp = ref Unsafe.Add(ref sourceRef, i); ref CieLchuv dp = ref Unsafe.Add(ref destRef, i); @@ -267,7 +267,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref Hsv sourceRef = ref MemoryMarshal.GetReference(source); ref CieLchuv destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref Hsv sp = ref Unsafe.Add(ref sourceRef, i); ref CieLchuv dp = ref Unsafe.Add(ref destRef, i); @@ -300,7 +300,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref HunterLab sourceRef = ref MemoryMarshal.GetReference(source); ref CieLchuv destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref HunterLab sp = ref Unsafe.Add(ref sourceRef, i); ref CieLchuv dp = ref Unsafe.Add(ref destRef, i); @@ -333,7 +333,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref LinearRgb sourceRef = ref MemoryMarshal.GetReference(source); ref CieLchuv destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref LinearRgb sp = ref Unsafe.Add(ref sourceRef, i); ref CieLchuv dp = ref Unsafe.Add(ref destRef, i); @@ -366,7 +366,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref Lms sourceRef = ref MemoryMarshal.GetReference(source); ref CieLchuv destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref Lms sp = ref Unsafe.Add(ref sourceRef, i); ref CieLchuv dp = ref Unsafe.Add(ref destRef, i); @@ -399,7 +399,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref Rgb sourceRef = ref MemoryMarshal.GetReference(source); ref CieLchuv destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref Rgb sp = ref Unsafe.Add(ref sourceRef, i); ref CieLchuv dp = ref Unsafe.Add(ref destRef, i); @@ -431,7 +431,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref YCbCr sourceRef = ref MemoryMarshal.GetReference(source); ref CieLchuv destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref YCbCr sp = ref Unsafe.Add(ref sourceRef, i); ref CieLchuv dp = ref Unsafe.Add(ref destRef, i); diff --git a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieLuv.cs b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieLuv.cs index b04acc9907..1b6735e623 100644 --- a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieLuv.cs +++ b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieLuv.cs @@ -35,7 +35,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref CieLab sourceRef = ref MemoryMarshal.GetReference(source); ref CieLuv destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref CieLab sp = ref Unsafe.Add(ref sourceRef, i); ref CieLuv dp = ref Unsafe.Add(ref destRef, i); @@ -67,7 +67,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref CieLch sourceRef = ref MemoryMarshal.GetReference(source); ref CieLuv destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref CieLch sp = ref Unsafe.Add(ref sourceRef, i); ref CieLuv dp = ref Unsafe.Add(ref destRef, i); @@ -102,7 +102,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref CieLchuv sourceRef = ref MemoryMarshal.GetReference(source); ref CieLuv destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref CieLchuv sp = ref Unsafe.Add(ref sourceRef, i); ref CieLuv dp = ref Unsafe.Add(ref destRef, i); @@ -134,7 +134,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref CieXyy sourceRef = ref MemoryMarshal.GetReference(source); ref CieLuv destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref CieXyy sp = ref Unsafe.Add(ref sourceRef, i); ref CieLuv dp = ref Unsafe.Add(ref destRef, i); @@ -169,7 +169,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref CieXyz sourceRef = ref MemoryMarshal.GetReference(source); ref CieLuv destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref CieXyz sp = ref Unsafe.Add(ref sourceRef, i); ref CieLuv dp = ref Unsafe.Add(ref destRef, i); @@ -201,7 +201,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref Cmyk sourceRef = ref MemoryMarshal.GetReference(source); ref CieLuv destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref Cmyk sp = ref Unsafe.Add(ref sourceRef, i); ref CieLuv dp = ref Unsafe.Add(ref destRef, i); @@ -233,7 +233,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref Hsl sourceRef = ref MemoryMarshal.GetReference(source); ref CieLuv destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref Hsl sp = ref Unsafe.Add(ref sourceRef, i); ref CieLuv dp = ref Unsafe.Add(ref destRef, i); @@ -265,7 +265,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref Hsv sourceRef = ref MemoryMarshal.GetReference(source); ref CieLuv destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref Hsv sp = ref Unsafe.Add(ref sourceRef, i); ref CieLuv dp = ref Unsafe.Add(ref destRef, i); @@ -297,7 +297,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref HunterLab sourceRef = ref MemoryMarshal.GetReference(source); ref CieLuv destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref HunterLab sp = ref Unsafe.Add(ref sourceRef, i); ref CieLuv dp = ref Unsafe.Add(ref destRef, i); @@ -329,7 +329,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref Lms sourceRef = ref MemoryMarshal.GetReference(source); ref CieLuv destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref Lms sp = ref Unsafe.Add(ref sourceRef, i); ref CieLuv dp = ref Unsafe.Add(ref destRef, i); @@ -361,7 +361,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref LinearRgb sourceRef = ref MemoryMarshal.GetReference(source); ref CieLuv destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref LinearRgb sp = ref Unsafe.Add(ref sourceRef, i); ref CieLuv dp = ref Unsafe.Add(ref destRef, i); @@ -393,7 +393,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref Rgb sourceRef = ref MemoryMarshal.GetReference(source); ref CieLuv destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref Rgb sp = ref Unsafe.Add(ref sourceRef, i); ref CieLuv dp = ref Unsafe.Add(ref destRef, i); @@ -425,7 +425,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref YCbCr sourceRef = ref MemoryMarshal.GetReference(source); ref CieLuv destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref YCbCr sp = ref Unsafe.Add(ref sourceRef, i); ref CieLuv dp = ref Unsafe.Add(ref destRef, i); diff --git a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieXyy.cs b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieXyy.cs index a3851de9f0..2b34e66f2e 100644 --- a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieXyy.cs +++ b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieXyy.cs @@ -36,7 +36,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref CieLab sourceRef = ref MemoryMarshal.GetReference(source); ref CieXyy destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref CieLab sp = ref Unsafe.Add(ref sourceRef, i); ref CieXyy dp = ref Unsafe.Add(ref destRef, i); @@ -69,7 +69,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref CieLch sourceRef = ref MemoryMarshal.GetReference(source); ref CieXyy destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref CieLch sp = ref Unsafe.Add(ref sourceRef, i); ref CieXyy dp = ref Unsafe.Add(ref destRef, i); @@ -102,7 +102,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref CieLchuv sourceRef = ref MemoryMarshal.GetReference(source); ref CieXyy destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref CieLchuv sp = ref Unsafe.Add(ref sourceRef, i); ref CieXyy dp = ref Unsafe.Add(ref destRef, i); @@ -135,7 +135,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref CieLuv sourceRef = ref MemoryMarshal.GetReference(source); ref CieXyy destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref CieLuv sp = ref Unsafe.Add(ref sourceRef, i); ref CieXyy dp = ref Unsafe.Add(ref destRef, i); @@ -163,7 +163,7 @@ public static void Convert(ReadOnlySpan source, Span destination ref CieXyz sourceRef = ref MemoryMarshal.GetReference(source); ref CieXyy destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref CieXyz sp = ref Unsafe.Add(ref sourceRef, i); ref CieXyy dp = ref Unsafe.Add(ref destRef, i); @@ -196,7 +196,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref Cmyk sourceRef = ref MemoryMarshal.GetReference(source); ref CieXyy destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref Cmyk sp = ref Unsafe.Add(ref sourceRef, i); ref CieXyy dp = ref Unsafe.Add(ref destRef, i); @@ -229,7 +229,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref Hsl sourceRef = ref MemoryMarshal.GetReference(source); ref CieXyy destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref Hsl sp = ref Unsafe.Add(ref sourceRef, i); ref CieXyy dp = ref Unsafe.Add(ref destRef, i); @@ -262,7 +262,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref Hsv sourceRef = ref MemoryMarshal.GetReference(source); ref CieXyy destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref Hsv sp = ref Unsafe.Add(ref sourceRef, i); ref CieXyy dp = ref Unsafe.Add(ref destRef, i); @@ -295,7 +295,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref HunterLab sourceRef = ref MemoryMarshal.GetReference(source); ref CieXyy destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref HunterLab sp = ref Unsafe.Add(ref sourceRef, i); ref CieXyy dp = ref Unsafe.Add(ref destRef, i); @@ -328,7 +328,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref LinearRgb sourceRef = ref MemoryMarshal.GetReference(source); ref CieXyy destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref LinearRgb sp = ref Unsafe.Add(ref sourceRef, i); ref CieXyy dp = ref Unsafe.Add(ref destRef, i); @@ -361,7 +361,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref Lms sourceRef = ref MemoryMarshal.GetReference(source); ref CieXyy destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref Lms sp = ref Unsafe.Add(ref sourceRef, i); ref CieXyy dp = ref Unsafe.Add(ref destRef, i); @@ -394,7 +394,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref Rgb sourceRef = ref MemoryMarshal.GetReference(source); ref CieXyy destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref Rgb sp = ref Unsafe.Add(ref sourceRef, i); ref CieXyy dp = ref Unsafe.Add(ref destRef, i); @@ -427,7 +427,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref YCbCr sourceRef = ref MemoryMarshal.GetReference(source); ref CieXyy destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref YCbCr sp = ref Unsafe.Add(ref sourceRef, i); ref CieXyy dp = ref Unsafe.Add(ref destRef, i); diff --git a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieXyz.cs b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieXyz.cs index 1244655227..1495a28b64 100644 --- a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieXyz.cs +++ b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieXyz.cs @@ -41,7 +41,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref CieLab sourceRef = ref MemoryMarshal.GetReference(source); ref CieXyz destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref CieLab sp = ref Unsafe.Add(ref sourceRef, i); ref CieXyz dp = ref Unsafe.Add(ref destRef, i); @@ -76,7 +76,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref CieLch sourceRef = ref MemoryMarshal.GetReference(source); ref CieXyz destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref CieLch sp = ref Unsafe.Add(ref sourceRef, i); ref CieXyz dp = ref Unsafe.Add(ref destRef, i); @@ -111,7 +111,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref CieLchuv sourceRef = ref MemoryMarshal.GetReference(source); ref CieXyz destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref CieLchuv sp = ref Unsafe.Add(ref sourceRef, i); ref CieXyz dp = ref Unsafe.Add(ref destRef, i); @@ -146,7 +146,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref CieLuv sourceRef = ref MemoryMarshal.GetReference(source); ref CieXyz destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref CieLuv sp = ref Unsafe.Add(ref sourceRef, i); ref CieXyz dp = ref Unsafe.Add(ref destRef, i); @@ -177,7 +177,7 @@ public static void Convert(ReadOnlySpan source, Span destination ref CieXyy sourceRef = ref MemoryMarshal.GetReference(source); ref CieXyz destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref CieXyy sp = ref Unsafe.Add(ref sourceRef, i); ref CieXyz dp = ref Unsafe.Add(ref destRef, i); @@ -210,7 +210,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref Cmyk sourceRef = ref MemoryMarshal.GetReference(source); ref CieXyz destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref Cmyk sp = ref Unsafe.Add(ref sourceRef, i); ref CieXyz dp = ref Unsafe.Add(ref destRef, i); @@ -243,7 +243,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref Hsl sourceRef = ref MemoryMarshal.GetReference(source); ref CieXyz destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref Hsl sp = ref Unsafe.Add(ref sourceRef, i); ref CieXyz dp = ref Unsafe.Add(ref destRef, i); @@ -277,7 +277,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref Hsv sourceRef = ref MemoryMarshal.GetReference(source); ref CieXyz destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref Hsv sp = ref Unsafe.Add(ref sourceRef, i); ref CieXyz dp = ref Unsafe.Add(ref destRef, i); @@ -310,7 +310,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref HunterLab sourceRef = ref MemoryMarshal.GetReference(source); ref CieXyz destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref HunterLab sp = ref Unsafe.Add(ref sourceRef, i); ref CieXyz dp = ref Unsafe.Add(ref destRef, i); @@ -345,7 +345,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref LinearRgb sourceRef = ref MemoryMarshal.GetReference(source); ref CieXyz destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref LinearRgb sp = ref Unsafe.Add(ref sourceRef, i); ref CieXyz dp = ref Unsafe.Add(ref destRef, i); @@ -374,7 +374,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref Lms sourceRef = ref MemoryMarshal.GetReference(source); ref CieXyz destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref Lms sp = ref Unsafe.Add(ref sourceRef, i); ref CieXyz dp = ref Unsafe.Add(ref destRef, i); @@ -407,7 +407,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref Rgb sourceRef = ref MemoryMarshal.GetReference(source); ref CieXyz destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref Rgb sp = ref Unsafe.Add(ref sourceRef, i); ref CieXyz dp = ref Unsafe.Add(ref destRef, i); @@ -440,7 +440,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref YCbCr sourceRef = ref MemoryMarshal.GetReference(source); ref CieXyz destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref YCbCr sp = ref Unsafe.Add(ref sourceRef, i); ref CieXyz dp = ref Unsafe.Add(ref destRef, i); diff --git a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Cmyk.cs b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Cmyk.cs index cadcc9e03f..068583e82f 100644 --- a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Cmyk.cs +++ b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Cmyk.cs @@ -36,7 +36,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref CieLab sourceRef = ref MemoryMarshal.GetReference(source); ref Cmyk destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref CieLab sp = ref Unsafe.Add(ref sourceRef, i); ref Cmyk dp = ref Unsafe.Add(ref destRef, i); @@ -69,7 +69,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref CieLch sourceRef = ref MemoryMarshal.GetReference(source); ref Cmyk destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref CieLch sp = ref Unsafe.Add(ref sourceRef, i); ref Cmyk dp = ref Unsafe.Add(ref destRef, i); @@ -102,7 +102,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref CieLchuv sourceRef = ref MemoryMarshal.GetReference(source); ref Cmyk destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref CieLchuv sp = ref Unsafe.Add(ref sourceRef, i); ref Cmyk dp = ref Unsafe.Add(ref destRef, i); @@ -135,7 +135,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref CieLuv sourceRef = ref MemoryMarshal.GetReference(source); ref Cmyk destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref CieLuv sp = ref Unsafe.Add(ref sourceRef, i); ref Cmyk dp = ref Unsafe.Add(ref destRef, i); @@ -168,7 +168,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref CieXyy sourceRef = ref MemoryMarshal.GetReference(source); ref Cmyk destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref CieXyy sp = ref Unsafe.Add(ref sourceRef, i); ref Cmyk dp = ref Unsafe.Add(ref destRef, i); @@ -201,7 +201,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref CieXyz sourceRef = ref MemoryMarshal.GetReference(source); ref Cmyk destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref CieXyz sp = ref Unsafe.Add(ref sourceRef, i); ref Cmyk dp = ref Unsafe.Add(ref destRef, i); @@ -234,7 +234,7 @@ public static void Convert(ReadOnlySpan source, Span destination) ref Hsl sourceRef = ref MemoryMarshal.GetReference(source); ref Cmyk destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref Hsl sp = ref Unsafe.Add(ref sourceRef, i); ref Cmyk dp = ref Unsafe.Add(ref destRef, i); @@ -267,7 +267,7 @@ public static void Convert(ReadOnlySpan source, Span destination) ref Hsv sourceRef = ref MemoryMarshal.GetReference(source); ref Cmyk destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref Hsv sp = ref Unsafe.Add(ref sourceRef, i); ref Cmyk dp = ref Unsafe.Add(ref destRef, i); @@ -300,7 +300,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref HunterLab sourceRef = ref MemoryMarshal.GetReference(source); ref Cmyk destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref HunterLab sp = ref Unsafe.Add(ref sourceRef, i); ref Cmyk dp = ref Unsafe.Add(ref destRef, i); @@ -333,7 +333,7 @@ public static void Convert(ReadOnlySpan source, Span destinatio ref LinearRgb sourceRef = ref MemoryMarshal.GetReference(source); ref Cmyk destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref LinearRgb sp = ref Unsafe.Add(ref sourceRef, i); ref Cmyk dp = ref Unsafe.Add(ref destRef, i); @@ -366,7 +366,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref Lms sourceRef = ref MemoryMarshal.GetReference(source); ref Cmyk destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref Lms sp = ref Unsafe.Add(ref sourceRef, i); ref Cmyk dp = ref Unsafe.Add(ref destRef, i); @@ -394,7 +394,7 @@ public static void Convert(ReadOnlySpan source, Span destination) ref Rgb sourceRef = ref MemoryMarshal.GetReference(source); ref Cmyk destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref Rgb sp = ref Unsafe.Add(ref sourceRef, i); ref Cmyk dp = ref Unsafe.Add(ref destRef, i); @@ -427,7 +427,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref YCbCr sourceRef = ref MemoryMarshal.GetReference(source); ref Cmyk destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref YCbCr sp = ref Unsafe.Add(ref sourceRef, i); ref Cmyk dp = ref Unsafe.Add(ref destRef, i); diff --git a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Hsl.cs b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Hsl.cs index b763a3ebe7..f40544b7a9 100644 --- a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Hsl.cs +++ b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Hsl.cs @@ -36,7 +36,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref CieLab sourceRef = ref MemoryMarshal.GetReference(source); ref Hsl destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref CieLab sp = ref Unsafe.Add(ref sourceRef, i); ref Hsl dp = ref Unsafe.Add(ref destRef, i); @@ -69,7 +69,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref CieLch sourceRef = ref MemoryMarshal.GetReference(source); ref Hsl destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref CieLch sp = ref Unsafe.Add(ref sourceRef, i); ref Hsl dp = ref Unsafe.Add(ref destRef, i); @@ -102,7 +102,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref CieLchuv sourceRef = ref MemoryMarshal.GetReference(source); ref Hsl destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref CieLchuv sp = ref Unsafe.Add(ref sourceRef, i); ref Hsl dp = ref Unsafe.Add(ref destRef, i); @@ -135,7 +135,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref CieLuv sourceRef = ref MemoryMarshal.GetReference(source); ref Hsl destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref CieLuv sp = ref Unsafe.Add(ref sourceRef, i); ref Hsl dp = ref Unsafe.Add(ref destRef, i); @@ -168,7 +168,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref CieXyy sourceRef = ref MemoryMarshal.GetReference(source); ref Hsl destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref CieXyy sp = ref Unsafe.Add(ref sourceRef, i); ref Hsl dp = ref Unsafe.Add(ref destRef, i); @@ -201,7 +201,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref CieXyz sourceRef = ref MemoryMarshal.GetReference(source); ref Hsl destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref CieXyz sp = ref Unsafe.Add(ref sourceRef, i); ref Hsl dp = ref Unsafe.Add(ref destRef, i); @@ -234,7 +234,7 @@ public static void Convert(ReadOnlySpan source, Span destination) ref Cmyk sourceRef = ref MemoryMarshal.GetReference(source); ref Hsl destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref Cmyk sp = ref Unsafe.Add(ref sourceRef, i); ref Hsl dp = ref Unsafe.Add(ref destRef, i); @@ -267,7 +267,7 @@ public static void Convert(ReadOnlySpan source, Span destination) ref Hsv sourceRef = ref MemoryMarshal.GetReference(source); ref Hsl destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref Hsv sp = ref Unsafe.Add(ref sourceRef, i); ref Hsl dp = ref Unsafe.Add(ref destRef, i); @@ -300,7 +300,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref HunterLab sourceRef = ref MemoryMarshal.GetReference(source); ref Hsl destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref HunterLab sp = ref Unsafe.Add(ref sourceRef, i); ref Hsl dp = ref Unsafe.Add(ref destRef, i); @@ -333,7 +333,7 @@ public static void Convert(ReadOnlySpan source, Span destination ref LinearRgb sourceRef = ref MemoryMarshal.GetReference(source); ref Hsl destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref LinearRgb sp = ref Unsafe.Add(ref sourceRef, i); ref Hsl dp = ref Unsafe.Add(ref destRef, i); @@ -366,7 +366,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref Lms sourceRef = ref MemoryMarshal.GetReference(source); ref Hsl destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref Lms sp = ref Unsafe.Add(ref sourceRef, i); ref Hsl dp = ref Unsafe.Add(ref destRef, i); @@ -394,7 +394,7 @@ public static void Convert(ReadOnlySpan source, Span destination) ref Rgb sourceRef = ref MemoryMarshal.GetReference(source); ref Hsl destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref Rgb sp = ref Unsafe.Add(ref sourceRef, i); ref Hsl dp = ref Unsafe.Add(ref destRef, i); @@ -427,7 +427,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref YCbCr sourceRef = ref MemoryMarshal.GetReference(source); ref Hsl destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref YCbCr sp = ref Unsafe.Add(ref sourceRef, i); ref Hsl dp = ref Unsafe.Add(ref destRef, i); diff --git a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Hsv.cs b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Hsv.cs index 4b4b9d0077..8bd014ed96 100644 --- a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Hsv.cs +++ b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Hsv.cs @@ -36,7 +36,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref CieLab sourceRef = ref MemoryMarshal.GetReference(source); ref Hsv destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref CieLab sp = ref Unsafe.Add(ref sourceRef, i); ref Hsv dp = ref Unsafe.Add(ref destRef, i); @@ -69,7 +69,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref CieLch sourceRef = ref MemoryMarshal.GetReference(source); ref Hsv destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref CieLch sp = ref Unsafe.Add(ref sourceRef, i); ref Hsv dp = ref Unsafe.Add(ref destRef, i); @@ -102,7 +102,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref CieLchuv sourceRef = ref MemoryMarshal.GetReference(source); ref Hsv destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref CieLchuv sp = ref Unsafe.Add(ref sourceRef, i); ref Hsv dp = ref Unsafe.Add(ref destRef, i); @@ -135,7 +135,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref CieLuv sourceRef = ref MemoryMarshal.GetReference(source); ref Hsv destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref CieLuv sp = ref Unsafe.Add(ref sourceRef, i); ref Hsv dp = ref Unsafe.Add(ref destRef, i); @@ -168,7 +168,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref CieXyy sourceRef = ref MemoryMarshal.GetReference(source); ref Hsv destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref CieXyy sp = ref Unsafe.Add(ref sourceRef, i); ref Hsv dp = ref Unsafe.Add(ref destRef, i); @@ -201,7 +201,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref CieXyz sourceRef = ref MemoryMarshal.GetReference(source); ref Hsv destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref CieXyz sp = ref Unsafe.Add(ref sourceRef, i); ref Hsv dp = ref Unsafe.Add(ref destRef, i); @@ -234,7 +234,7 @@ public static void Convert(ReadOnlySpan source, Span destination) ref Cmyk sourceRef = ref MemoryMarshal.GetReference(source); ref Hsv destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref Cmyk sp = ref Unsafe.Add(ref sourceRef, i); ref Hsv dp = ref Unsafe.Add(ref destRef, i); @@ -267,7 +267,7 @@ public static void Convert(ReadOnlySpan source, Span destination) ref Hsl sourceRef = ref MemoryMarshal.GetReference(source); ref Hsv destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref Hsl sp = ref Unsafe.Add(ref sourceRef, i); ref Hsv dp = ref Unsafe.Add(ref destRef, i); @@ -300,7 +300,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref HunterLab sourceRef = ref MemoryMarshal.GetReference(source); ref Hsv destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref HunterLab sp = ref Unsafe.Add(ref sourceRef, i); ref Hsv dp = ref Unsafe.Add(ref destRef, i); @@ -333,7 +333,7 @@ public static void Convert(ReadOnlySpan source, Span destination ref LinearRgb sourceRef = ref MemoryMarshal.GetReference(source); ref Hsv destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref LinearRgb sp = ref Unsafe.Add(ref sourceRef, i); ref Hsv dp = ref Unsafe.Add(ref destRef, i); @@ -366,7 +366,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref Lms sourceRef = ref MemoryMarshal.GetReference(source); ref Hsv destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref Lms sp = ref Unsafe.Add(ref sourceRef, i); ref Hsv dp = ref Unsafe.Add(ref destRef, i); @@ -394,7 +394,7 @@ public static void Convert(ReadOnlySpan source, Span destination) ref Rgb sourceRef = ref MemoryMarshal.GetReference(source); ref Hsv destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref Rgb sp = ref Unsafe.Add(ref sourceRef, i); ref Hsv dp = ref Unsafe.Add(ref destRef, i); @@ -427,7 +427,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref YCbCr sourceRef = ref MemoryMarshal.GetReference(source); ref Hsv destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref YCbCr sp = ref Unsafe.Add(ref sourceRef, i); ref Hsv dp = ref Unsafe.Add(ref destRef, i); diff --git a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.HunterLab.cs b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.HunterLab.cs index 01c040231a..2890594651 100644 --- a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.HunterLab.cs +++ b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.HunterLab.cs @@ -24,7 +24,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref CieLab sourceRef = ref MemoryMarshal.GetReference(source); ref HunterLab destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref CieLab sp = ref Unsafe.Add(ref sourceRef, i); ref HunterLab dp = ref Unsafe.Add(ref destRef, i); @@ -45,7 +45,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref CieLch sourceRef = ref MemoryMarshal.GetReference(source); ref HunterLab destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref CieLch sp = ref Unsafe.Add(ref sourceRef, i); ref HunterLab dp = ref Unsafe.Add(ref destRef, i); @@ -66,7 +66,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref CieLchuv sourceRef = ref MemoryMarshal.GetReference(source); ref HunterLab destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref CieLchuv sp = ref Unsafe.Add(ref sourceRef, i); ref HunterLab dp = ref Unsafe.Add(ref destRef, i); @@ -87,7 +87,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref CieLuv sourceRef = ref MemoryMarshal.GetReference(source); ref HunterLab destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref CieLuv sp = ref Unsafe.Add(ref sourceRef, i); ref HunterLab dp = ref Unsafe.Add(ref destRef, i); @@ -108,7 +108,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref CieXyy sourceRef = ref MemoryMarshal.GetReference(source); ref HunterLab destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref CieXyy sp = ref Unsafe.Add(ref sourceRef, i); ref HunterLab dp = ref Unsafe.Add(ref destRef, i); @@ -129,7 +129,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref CieXyz sourceRef = ref MemoryMarshal.GetReference(source); ref HunterLab destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref CieXyz sp = ref Unsafe.Add(ref sourceRef, i); ref HunterLab dp = ref Unsafe.Add(ref destRef, i); @@ -150,7 +150,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref Cmyk sourceRef = ref MemoryMarshal.GetReference(source); ref HunterLab destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref Cmyk sp = ref Unsafe.Add(ref sourceRef, i); ref HunterLab dp = ref Unsafe.Add(ref destRef, i); @@ -171,7 +171,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref Hsl sourceRef = ref MemoryMarshal.GetReference(source); ref HunterLab destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref Hsl sp = ref Unsafe.Add(ref sourceRef, i); ref HunterLab dp = ref Unsafe.Add(ref destRef, i); @@ -192,7 +192,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref Hsv sourceRef = ref MemoryMarshal.GetReference(source); ref HunterLab destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref Hsv sp = ref Unsafe.Add(ref sourceRef, i); ref HunterLab dp = ref Unsafe.Add(ref destRef, i); @@ -213,7 +213,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref LinearRgb sourceRef = ref MemoryMarshal.GetReference(source); ref HunterLab destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref LinearRgb sp = ref Unsafe.Add(ref sourceRef, i); ref HunterLab dp = ref Unsafe.Add(ref destRef, i); @@ -234,7 +234,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref Lms sourceRef = ref MemoryMarshal.GetReference(source); ref HunterLab destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref Lms sp = ref Unsafe.Add(ref sourceRef, i); ref HunterLab dp = ref Unsafe.Add(ref destRef, i); @@ -255,7 +255,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref Rgb sourceRef = ref MemoryMarshal.GetReference(source); ref HunterLab destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref Rgb sp = ref Unsafe.Add(ref sourceRef, i); ref HunterLab dp = ref Unsafe.Add(ref destRef, i); @@ -276,7 +276,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref YCbCr sourceRef = ref MemoryMarshal.GetReference(source); ref HunterLab destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref YCbCr sp = ref Unsafe.Add(ref sourceRef, i); ref HunterLab dp = ref Unsafe.Add(ref destRef, i); diff --git a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.LinearRgb.cs b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.LinearRgb.cs index 416274e003..897ec02a0f 100644 --- a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.LinearRgb.cs +++ b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.LinearRgb.cs @@ -24,7 +24,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref CieLab sourceRef = ref MemoryMarshal.GetReference(source); ref LinearRgb destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref CieLab sp = ref Unsafe.Add(ref sourceRef, i); ref LinearRgb dp = ref Unsafe.Add(ref destRef, i); @@ -45,7 +45,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref CieLch sourceRef = ref MemoryMarshal.GetReference(source); ref LinearRgb destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref CieLch sp = ref Unsafe.Add(ref sourceRef, i); ref LinearRgb dp = ref Unsafe.Add(ref destRef, i); @@ -66,7 +66,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref CieLchuv sourceRef = ref MemoryMarshal.GetReference(source); ref LinearRgb destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref CieLchuv sp = ref Unsafe.Add(ref sourceRef, i); ref LinearRgb dp = ref Unsafe.Add(ref destRef, i); @@ -87,7 +87,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref CieLuv sourceRef = ref MemoryMarshal.GetReference(source); ref LinearRgb destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref CieLuv sp = ref Unsafe.Add(ref sourceRef, i); ref LinearRgb dp = ref Unsafe.Add(ref destRef, i); @@ -108,7 +108,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref CieXyy sourceRef = ref MemoryMarshal.GetReference(source); ref LinearRgb destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref CieXyy sp = ref Unsafe.Add(ref sourceRef, i); ref LinearRgb dp = ref Unsafe.Add(ref destRef, i); @@ -129,7 +129,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref CieXyz sourceRef = ref MemoryMarshal.GetReference(source); ref LinearRgb destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref CieXyz sp = ref Unsafe.Add(ref sourceRef, i); ref LinearRgb dp = ref Unsafe.Add(ref destRef, i); @@ -150,7 +150,7 @@ public static void Convert(ReadOnlySpan source, Span destinatio ref Cmyk sourceRef = ref MemoryMarshal.GetReference(source); ref LinearRgb destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref Cmyk sp = ref Unsafe.Add(ref sourceRef, i); ref LinearRgb dp = ref Unsafe.Add(ref destRef, i); @@ -171,7 +171,7 @@ public static void Convert(ReadOnlySpan source, Span destination ref Hsl sourceRef = ref MemoryMarshal.GetReference(source); ref LinearRgb destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref Hsl sp = ref Unsafe.Add(ref sourceRef, i); ref LinearRgb dp = ref Unsafe.Add(ref destRef, i); @@ -192,7 +192,7 @@ public static void Convert(ReadOnlySpan source, Span destination ref Hsv sourceRef = ref MemoryMarshal.GetReference(source); ref LinearRgb destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref Hsv sp = ref Unsafe.Add(ref sourceRef, i); ref LinearRgb dp = ref Unsafe.Add(ref destRef, i); @@ -213,7 +213,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref HunterLab sourceRef = ref MemoryMarshal.GetReference(source); ref LinearRgb destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref HunterLab sp = ref Unsafe.Add(ref sourceRef, i); ref LinearRgb dp = ref Unsafe.Add(ref destRef, i); @@ -234,7 +234,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref Lms sourceRef = ref MemoryMarshal.GetReference(source); ref LinearRgb destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref Lms sp = ref Unsafe.Add(ref sourceRef, i); ref LinearRgb dp = ref Unsafe.Add(ref destRef, i); @@ -255,7 +255,7 @@ public static void Convert(ReadOnlySpan source, Span destination ref Rgb sourceRef = ref MemoryMarshal.GetReference(source); ref LinearRgb destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref Rgb sp = ref Unsafe.Add(ref sourceRef, i); ref LinearRgb dp = ref Unsafe.Add(ref destRef, i); @@ -276,7 +276,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref YCbCr sourceRef = ref MemoryMarshal.GetReference(source); ref LinearRgb destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref YCbCr sp = ref Unsafe.Add(ref sourceRef, i); ref LinearRgb dp = ref Unsafe.Add(ref destRef, i); diff --git a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Lms.cs b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Lms.cs index e2870a6eb4..291f3a5fac 100644 --- a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Lms.cs +++ b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Lms.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors. +// Copyright (c) Six Labors. // Licensed under the Six Labors Split License. using System.Runtime.CompilerServices; @@ -24,7 +24,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref CieLab sourceRef = ref MemoryMarshal.GetReference(source); ref Lms destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref CieLab sp = ref Unsafe.Add(ref sourceRef, i); ref Lms dp = ref Unsafe.Add(ref destRef, i); @@ -45,7 +45,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref CieLch sourceRef = ref MemoryMarshal.GetReference(source); ref Lms destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref CieLch sp = ref Unsafe.Add(ref sourceRef, i); ref Lms dp = ref Unsafe.Add(ref destRef, i); @@ -66,7 +66,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref CieLchuv sourceRef = ref MemoryMarshal.GetReference(source); ref Lms destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref CieLchuv sp = ref Unsafe.Add(ref sourceRef, i); ref Lms dp = ref Unsafe.Add(ref destRef, i); @@ -87,7 +87,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref CieLuv sourceRef = ref MemoryMarshal.GetReference(source); ref Lms destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref CieLuv sp = ref Unsafe.Add(ref sourceRef, i); ref Lms dp = ref Unsafe.Add(ref destRef, i); @@ -108,7 +108,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref CieXyy sourceRef = ref MemoryMarshal.GetReference(source); ref Lms destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref CieXyy sp = ref Unsafe.Add(ref sourceRef, i); ref Lms dp = ref Unsafe.Add(ref destRef, i); @@ -129,7 +129,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref CieXyz sourceRef = ref MemoryMarshal.GetReference(source); ref Lms destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref CieXyz sp = ref Unsafe.Add(ref sourceRef, i); ref Lms dp = ref Unsafe.Add(ref destRef, i); @@ -150,7 +150,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref Cmyk sourceRef = ref MemoryMarshal.GetReference(source); ref Lms destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref Cmyk sp = ref Unsafe.Add(ref sourceRef, i); ref Lms dp = ref Unsafe.Add(ref destRef, i); @@ -171,7 +171,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref Hsl sourceRef = ref MemoryMarshal.GetReference(source); ref Lms destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref Hsl sp = ref Unsafe.Add(ref sourceRef, i); ref Lms dp = ref Unsafe.Add(ref destRef, i); @@ -192,7 +192,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref Hsv sourceRef = ref MemoryMarshal.GetReference(source); ref Lms destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref Hsv sp = ref Unsafe.Add(ref sourceRef, i); ref Lms dp = ref Unsafe.Add(ref destRef, i); @@ -213,7 +213,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref HunterLab sourceRef = ref MemoryMarshal.GetReference(source); ref Lms destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref HunterLab sp = ref Unsafe.Add(ref sourceRef, i); ref Lms dp = ref Unsafe.Add(ref destRef, i); @@ -234,7 +234,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref LinearRgb sourceRef = ref MemoryMarshal.GetReference(source); ref Lms destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref LinearRgb sp = ref Unsafe.Add(ref sourceRef, i); ref Lms dp = ref Unsafe.Add(ref destRef, i); @@ -255,7 +255,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref Rgb sourceRef = ref MemoryMarshal.GetReference(source); ref Lms destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref Rgb sp = ref Unsafe.Add(ref sourceRef, i); ref Lms dp = ref Unsafe.Add(ref destRef, i); @@ -276,7 +276,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref YCbCr sourceRef = ref MemoryMarshal.GetReference(source); ref Lms destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref YCbCr sp = ref Unsafe.Add(ref sourceRef, i); ref Lms dp = ref Unsafe.Add(ref destRef, i); diff --git a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Rgb.cs b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Rgb.cs index 7346a28f33..557c294992 100644 --- a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Rgb.cs +++ b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Rgb.cs @@ -24,7 +24,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref CieLab sourceRef = ref MemoryMarshal.GetReference(source); ref Rgb destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref CieLab sp = ref Unsafe.Add(ref sourceRef, i); ref Rgb dp = ref Unsafe.Add(ref destRef, i); @@ -45,7 +45,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref CieLch sourceRef = ref MemoryMarshal.GetReference(source); ref Rgb destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref CieLch sp = ref Unsafe.Add(ref sourceRef, i); ref Rgb dp = ref Unsafe.Add(ref destRef, i); @@ -66,7 +66,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref CieLchuv sourceRef = ref MemoryMarshal.GetReference(source); ref Rgb destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref CieLchuv sp = ref Unsafe.Add(ref sourceRef, i); ref Rgb dp = ref Unsafe.Add(ref destRef, i); @@ -87,7 +87,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref CieLuv sourceRef = ref MemoryMarshal.GetReference(source); ref Rgb destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref CieLuv sp = ref Unsafe.Add(ref sourceRef, i); ref Rgb dp = ref Unsafe.Add(ref destRef, i); @@ -108,7 +108,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref CieXyy sourceRef = ref MemoryMarshal.GetReference(source); ref Rgb destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref CieXyy sp = ref Unsafe.Add(ref sourceRef, i); ref Rgb dp = ref Unsafe.Add(ref destRef, i); @@ -129,7 +129,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref CieXyz sourceRef = ref MemoryMarshal.GetReference(source); ref Rgb destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref CieXyz sp = ref Unsafe.Add(ref sourceRef, i); ref Rgb dp = ref Unsafe.Add(ref destRef, i); @@ -150,7 +150,7 @@ public static void Convert(ReadOnlySpan source, Span destination) ref Cmyk sourceRef = ref MemoryMarshal.GetReference(source); ref Rgb destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref Cmyk sp = ref Unsafe.Add(ref sourceRef, i); ref Rgb dp = ref Unsafe.Add(ref destRef, i); @@ -171,7 +171,7 @@ public static void Convert(ReadOnlySpan source, Span destination) ref Hsv sourceRef = ref MemoryMarshal.GetReference(source); ref Rgb destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref Hsv sp = ref Unsafe.Add(ref sourceRef, i); ref Rgb dp = ref Unsafe.Add(ref destRef, i); @@ -192,7 +192,7 @@ public static void Convert(ReadOnlySpan source, Span destination) ref Hsl sourceRef = ref MemoryMarshal.GetReference(source); ref Rgb destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref Hsl sp = ref Unsafe.Add(ref sourceRef, i); ref Rgb dp = ref Unsafe.Add(ref destRef, i); @@ -213,7 +213,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref HunterLab sourceRef = ref MemoryMarshal.GetReference(source); ref Rgb destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref HunterLab sp = ref Unsafe.Add(ref sourceRef, i); ref Rgb dp = ref Unsafe.Add(ref destRef, i); @@ -234,7 +234,7 @@ public static void Convert(ReadOnlySpan source, Span destination ref LinearRgb sourceRef = ref MemoryMarshal.GetReference(source); ref Rgb destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref LinearRgb sp = ref Unsafe.Add(ref sourceRef, i); ref Rgb dp = ref Unsafe.Add(ref destRef, i); @@ -255,7 +255,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref Lms sourceRef = ref MemoryMarshal.GetReference(source); ref Rgb destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref Lms sp = ref Unsafe.Add(ref sourceRef, i); ref Rgb dp = ref Unsafe.Add(ref destRef, i); @@ -276,7 +276,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref YCbCr sourceRef = ref MemoryMarshal.GetReference(source); ref Rgb destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref YCbCr sp = ref Unsafe.Add(ref sourceRef, i); ref Rgb dp = ref Unsafe.Add(ref destRef, i); diff --git a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.YCbCr.cs b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.YCbCr.cs index f267a0d89d..8ea875a3d7 100644 --- a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.YCbCr.cs +++ b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.YCbCr.cs @@ -24,7 +24,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref CieLab sourceRef = ref MemoryMarshal.GetReference(source); ref YCbCr destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref CieLab sp = ref Unsafe.Add(ref sourceRef, i); ref YCbCr dp = ref Unsafe.Add(ref destRef, i); @@ -45,7 +45,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref CieLch sourceRef = ref MemoryMarshal.GetReference(source); ref YCbCr destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref CieLch sp = ref Unsafe.Add(ref sourceRef, i); ref YCbCr dp = ref Unsafe.Add(ref destRef, i); @@ -66,7 +66,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref CieLuv sourceRef = ref MemoryMarshal.GetReference(source); ref YCbCr destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref CieLuv sp = ref Unsafe.Add(ref sourceRef, i); ref YCbCr dp = ref Unsafe.Add(ref destRef, i); @@ -87,7 +87,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref CieXyy sourceRef = ref MemoryMarshal.GetReference(source); ref YCbCr destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref CieXyy sp = ref Unsafe.Add(ref sourceRef, i); ref YCbCr dp = ref Unsafe.Add(ref destRef, i); @@ -108,7 +108,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref CieXyz sourceRef = ref MemoryMarshal.GetReference(source); ref YCbCr destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref CieXyz sp = ref Unsafe.Add(ref sourceRef, i); ref YCbCr dp = ref Unsafe.Add(ref destRef, i); @@ -129,7 +129,7 @@ public static void Convert(ReadOnlySpan source, Span destination) ref Cmyk sourceRef = ref MemoryMarshal.GetReference(source); ref YCbCr destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref Cmyk sp = ref Unsafe.Add(ref sourceRef, i); ref YCbCr dp = ref Unsafe.Add(ref destRef, i); @@ -150,7 +150,7 @@ public static void Convert(ReadOnlySpan source, Span destination) ref Hsl sourceRef = ref MemoryMarshal.GetReference(source); ref YCbCr destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref Hsl sp = ref Unsafe.Add(ref sourceRef, i); ref YCbCr dp = ref Unsafe.Add(ref destRef, i); @@ -171,7 +171,7 @@ public static void Convert(ReadOnlySpan source, Span destination) ref Hsv sourceRef = ref MemoryMarshal.GetReference(source); ref YCbCr destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref Hsv sp = ref Unsafe.Add(ref sourceRef, i); ref YCbCr dp = ref Unsafe.Add(ref destRef, i); @@ -192,7 +192,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref HunterLab sourceRef = ref MemoryMarshal.GetReference(source); ref YCbCr destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref HunterLab sp = ref Unsafe.Add(ref sourceRef, i); ref YCbCr dp = ref Unsafe.Add(ref destRef, i); @@ -213,7 +213,7 @@ public static void Convert(ReadOnlySpan source, Span destinati ref LinearRgb sourceRef = ref MemoryMarshal.GetReference(source); ref YCbCr destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref LinearRgb sp = ref Unsafe.Add(ref sourceRef, i); ref YCbCr dp = ref Unsafe.Add(ref destRef, i); @@ -234,7 +234,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref Lms sourceRef = ref MemoryMarshal.GetReference(source); ref YCbCr destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref Lms sp = ref Unsafe.Add(ref sourceRef, i); ref YCbCr dp = ref Unsafe.Add(ref destRef, i); @@ -255,7 +255,7 @@ public static void Convert(ReadOnlySpan source, Span destination) ref Rgb sourceRef = ref MemoryMarshal.GetReference(source); ref YCbCr destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref Rgb sp = ref Unsafe.Add(ref sourceRef, i); ref YCbCr dp = ref Unsafe.Add(ref destRef, i); diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/VonKriesChromaticAdaptation.cs b/src/ImageSharp/ColorSpaces/Conversion/Implementation/VonKriesChromaticAdaptation.cs index 7b9915c23f..55ed41220d 100644 --- a/src/ImageSharp/ColorSpaces/Conversion/Implementation/VonKriesChromaticAdaptation.cs +++ b/src/ImageSharp/ColorSpaces/Conversion/Implementation/VonKriesChromaticAdaptation.cs @@ -81,7 +81,7 @@ public void Transform( ref CieXyz sourceRef = ref MemoryMarshal.GetReference(source); ref CieXyz destRef = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref CieXyz sp = ref Unsafe.Add(ref sourceRef, i); ref CieXyz dp = ref Unsafe.Add(ref destRef, i); diff --git a/src/ImageSharp/Common/Helpers/Numerics.cs b/src/ImageSharp/Common/Helpers/Numerics.cs index 6fbd48f8cd..876f6e1fe6 100644 --- a/src/ImageSharp/Common/Helpers/Numerics.cs +++ b/src/ImageSharp/Common/Helpers/Numerics.cs @@ -297,7 +297,7 @@ public static void Clamp(Span span, byte min, byte max) if (remainder.Length > 0) { ref byte remainderStart = ref MemoryMarshal.GetReference(remainder); - ref byte remainderEnd = ref Unsafe.Add(ref remainderStart, remainder.Length); + ref byte remainderEnd = ref Unsafe.Add(ref remainderStart, (uint)remainder.Length); while (Unsafe.IsAddressLessThan(ref remainderStart, ref remainderEnd)) { @@ -322,7 +322,7 @@ public static void Clamp(Span span, uint min, uint max) if (remainder.Length > 0) { ref uint remainderStart = ref MemoryMarshal.GetReference(remainder); - ref uint remainderEnd = ref Unsafe.Add(ref remainderStart, remainder.Length); + ref uint remainderEnd = ref Unsafe.Add(ref remainderStart, (uint)remainder.Length); while (Unsafe.IsAddressLessThan(ref remainderStart, ref remainderEnd)) { @@ -347,7 +347,7 @@ public static void Clamp(Span span, int min, int max) if (remainder.Length > 0) { ref int remainderStart = ref MemoryMarshal.GetReference(remainder); - ref int remainderEnd = ref Unsafe.Add(ref remainderStart, remainder.Length); + ref int remainderEnd = ref Unsafe.Add(ref remainderStart, (uint)remainder.Length); while (Unsafe.IsAddressLessThan(ref remainderStart, ref remainderEnd)) { @@ -372,7 +372,7 @@ public static void Clamp(Span span, float min, float max) if (remainder.Length > 0) { ref float remainderStart = ref MemoryMarshal.GetReference(remainder); - ref float remainderEnd = ref Unsafe.Add(ref remainderStart, remainder.Length); + ref float remainderEnd = ref Unsafe.Add(ref remainderStart, (uint)remainder.Length); while (Unsafe.IsAddressLessThan(ref remainderStart, ref remainderEnd)) { @@ -397,7 +397,7 @@ public static void Clamp(Span span, double min, double max) if (remainder.Length > 0) { ref double remainderStart = ref MemoryMarshal.GetReference(remainder); - ref double remainderEnd = ref Unsafe.Add(ref remainderStart, remainder.Length); + ref double remainderEnd = ref Unsafe.Add(ref remainderStart, (uint)remainder.Length); while (Unsafe.IsAddressLessThan(ref remainderStart, ref remainderEnd)) { @@ -497,7 +497,7 @@ public static void Premultiply(Span vectors) { // Divide by 2 as 4 elements per Vector4 and 8 per Vector256 ref Vector256 vectorsBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(vectors)); - ref Vector256 vectorsLast = ref Unsafe.Add(ref vectorsBase, (IntPtr)((uint)vectors.Length / 2u)); + ref Vector256 vectorsLast = ref Unsafe.Add(ref vectorsBase, (uint)vectors.Length / 2u); while (Unsafe.IsAddressLessThan(ref vectorsBase, ref vectorsLast)) { @@ -516,7 +516,7 @@ public static void Premultiply(Span vectors) else { ref Vector4 vectorsStart = ref MemoryMarshal.GetReference(vectors); - ref Vector4 vectorsEnd = ref Unsafe.Add(ref vectorsStart, vectors.Length); + ref Vector4 vectorsEnd = ref Unsafe.Add(ref vectorsStart, (uint)vectors.Length); while (Unsafe.IsAddressLessThan(ref vectorsStart, ref vectorsEnd)) { @@ -562,7 +562,7 @@ public static void UnPremultiply(Span vectors) { // Divide by 2 as 4 elements per Vector4 and 8 per Vector256 ref Vector256 vectorsBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(vectors)); - ref Vector256 vectorsLast = ref Unsafe.Add(ref vectorsBase, (IntPtr)((uint)vectors.Length / 2u)); + ref Vector256 vectorsLast = ref Unsafe.Add(ref vectorsBase, (uint)vectors.Length / 2u); Vector256 epsilon = Vector256.Create(Constants.Epsilon); while (Unsafe.IsAddressLessThan(ref vectorsBase, ref vectorsLast)) @@ -582,7 +582,7 @@ public static void UnPremultiply(Span vectors) else { ref Vector4 vectorsStart = ref MemoryMarshal.GetReference(vectors); - ref Vector4 vectorsEnd = ref Unsafe.Add(ref vectorsStart, vectors.Length); + ref Vector4 vectorsEnd = ref Unsafe.Add(ref vectorsStart, (uint)vectors.Length); while (Unsafe.IsAddressLessThan(ref vectorsStart, ref vectorsEnd)) { @@ -656,7 +656,7 @@ public static Vector4 WithW(Vector4 value, Vector4 w) public static unsafe void CubePowOnXYZ(Span vectors) { ref Vector4 baseRef = ref MemoryMarshal.GetReference(vectors); - ref Vector4 endRef = ref Unsafe.Add(ref baseRef, vectors.Length); + ref Vector4 endRef = ref Unsafe.Add(ref baseRef, (uint)vectors.Length); while (Unsafe.IsAddressLessThan(ref baseRef, ref endRef)) { @@ -687,7 +687,7 @@ public static unsafe void CubeRootOnXYZ(Span vectors) if (Sse41.IsSupported) { ref Vector128 vectors128Ref = ref Unsafe.As>(ref MemoryMarshal.GetReference(vectors)); - ref Vector128 vectors128End = ref Unsafe.Add(ref vectors128Ref, vectors.Length); + ref Vector128 vectors128End = ref Unsafe.Add(ref vectors128Ref, (uint)vectors.Length); var v128_341 = Vector128.Create(341); Vector128 v128_negativeZero = Vector128.Create(-0.0f).AsInt32(); @@ -736,7 +736,7 @@ public static unsafe void CubeRootOnXYZ(Span vectors) else { ref Vector4 vectorsRef = ref MemoryMarshal.GetReference(vectors); - ref Vector4 vectorsEnd = ref Unsafe.Add(ref vectorsRef, vectors.Length); + ref Vector4 vectorsEnd = ref Unsafe.Add(ref vectorsRef, (uint)vectors.Length); // Fallback with scalar preprocessing and vectorized approximation steps while (Unsafe.IsAddressLessThan(ref vectorsRef, ref vectorsEnd)) diff --git a/src/ImageSharp/Common/Helpers/Shuffle/IComponentShuffle.cs b/src/ImageSharp/Common/Helpers/Shuffle/IComponentShuffle.cs index 9b73eb6ccf..18daaed481 100644 --- a/src/ImageSharp/Common/Helpers/Shuffle/IComponentShuffle.cs +++ b/src/ImageSharp/Common/Helpers/Shuffle/IComponentShuffle.cs @@ -63,12 +63,12 @@ public void RunFallbackShuffle(ReadOnlySpan source, Span dest) Shuffle.InverseMMShuffle(this.Control, out int p3, out int p2, out int p1, out int p0); - for (int i = 0; i < source.Length; i += 4) + for (nint i = 0; i < (uint)source.Length; i += 4) { - Unsafe.Add(ref dBase, i) = Unsafe.Add(ref sBase, p0 + i); - Unsafe.Add(ref dBase, i + 1) = Unsafe.Add(ref sBase, p1 + i); - Unsafe.Add(ref dBase, i + 2) = Unsafe.Add(ref sBase, p2 + i); - Unsafe.Add(ref dBase, i + 3) = Unsafe.Add(ref sBase, p3 + i); + Unsafe.Add(ref dBase, i + 0) = Unsafe.Add(ref sBase, (nint)(uint)p0 + i); + Unsafe.Add(ref dBase, i + 1) = Unsafe.Add(ref sBase, (nint)(uint)p1 + i); + Unsafe.Add(ref dBase, i + 2) = Unsafe.Add(ref sBase, (nint)(uint)p2 + i); + Unsafe.Add(ref dBase, i + 3) = Unsafe.Add(ref sBase, (nint)(uint)p3 + i); } } } @@ -86,7 +86,7 @@ public void RunFallbackShuffle(ReadOnlySpan source, Span dest) ref uint dBase = ref Unsafe.As(ref MemoryMarshal.GetReference(dest)); int n = source.Length / 4; - for (int i = 0; i < n; i++) + for (nint i = 0; i < (uint)n; i++) { uint packed = Unsafe.Add(ref sBase, i); @@ -110,7 +110,7 @@ public void RunFallbackShuffle(ReadOnlySpan source, Span dest) ref uint dBase = ref Unsafe.As(ref MemoryMarshal.GetReference(dest)); int n = source.Length / 4; - for (int i = 0; i < n; i++) + for (nint i = 0; i < (uint)n; i++) { uint packed = Unsafe.Add(ref sBase, i); @@ -134,7 +134,7 @@ public void RunFallbackShuffle(ReadOnlySpan source, Span dest) ref uint dBase = ref Unsafe.As(ref MemoryMarshal.GetReference(dest)); int n = source.Length / 4; - for (int i = 0; i < n; i++) + for (nint i = 0; i < (uint)n; i++) { uint packed = Unsafe.Add(ref sBase, i); @@ -158,7 +158,7 @@ public void RunFallbackShuffle(ReadOnlySpan source, Span dest) ref uint dBase = ref Unsafe.As(ref MemoryMarshal.GetReference(dest)); int n = source.Length / 4; - for (int i = 0; i < n; i++) + for (nint i = 0; i < (uint)n; i++) { uint packed = Unsafe.Add(ref sBase, i); @@ -189,7 +189,7 @@ public void RunFallbackShuffle(ReadOnlySpan source, Span dest) ref uint dBase = ref Unsafe.As(ref MemoryMarshal.GetReference(dest)); int n = source.Length / 4; - for (int i = 0; i < n; i++) + for (nint i = 0; i < (uint)n; i++) { uint packed = Unsafe.Add(ref sBase, i); diff --git a/src/ImageSharp/Common/Helpers/Shuffle/IPad3Shuffle4.cs b/src/ImageSharp/Common/Helpers/Shuffle/IPad3Shuffle4.cs index 5dfdd91718..3e1084d313 100644 --- a/src/ImageSharp/Common/Helpers/Shuffle/IPad3Shuffle4.cs +++ b/src/ImageSharp/Common/Helpers/Shuffle/IPad3Shuffle4.cs @@ -35,15 +35,15 @@ public void RunFallbackShuffle(ReadOnlySpan source, Span dest) ref byte t = ref MemoryMarshal.GetReference(temp); ref uint tu = ref Unsafe.As(ref t); - for (int i = 0, j = 0; i < source.Length; i += 3, j += 4) + for (nint i = 0, j = 0; i < (uint)source.Length; i += 3, j += 4) { ref byte s = ref Unsafe.Add(ref sBase, i); tu = Unsafe.As(ref s) | 0xFF000000; - Unsafe.Add(ref dBase, j) = Unsafe.Add(ref t, p0); - Unsafe.Add(ref dBase, j + 1) = Unsafe.Add(ref t, p1); - Unsafe.Add(ref dBase, j + 2) = Unsafe.Add(ref t, p2); - Unsafe.Add(ref dBase, j + 3) = Unsafe.Add(ref t, p3); + Unsafe.Add(ref dBase, j + 0) = Unsafe.Add(ref t, (uint)p0); + Unsafe.Add(ref dBase, j + 1) = Unsafe.Add(ref t, (uint)p1); + Unsafe.Add(ref dBase, j + 2) = Unsafe.Add(ref t, (uint)p2); + Unsafe.Add(ref dBase, j + 3) = Unsafe.Add(ref t, (uint)p3); } } } @@ -60,7 +60,7 @@ public void RunFallbackShuffle(ReadOnlySpan source, Span dest) ref byte sBase = ref MemoryMarshal.GetReference(source); ref byte dBase = ref MemoryMarshal.GetReference(dest); - ref byte sEnd = ref Unsafe.Add(ref sBase, source.Length); + ref byte sEnd = ref Unsafe.Add(ref sBase, (uint)source.Length); ref byte sLoopEnd = ref Unsafe.Subtract(ref sEnd, 4); while (Unsafe.IsAddressLessThan(ref sBase, ref sLoopEnd)) diff --git a/src/ImageSharp/Common/Helpers/Shuffle/IShuffle3.cs b/src/ImageSharp/Common/Helpers/Shuffle/IShuffle3.cs index 6bf8c5f03d..b149bde09d 100644 --- a/src/ImageSharp/Common/Helpers/Shuffle/IShuffle3.cs +++ b/src/ImageSharp/Common/Helpers/Shuffle/IShuffle3.cs @@ -31,11 +31,11 @@ public void RunFallbackShuffle(ReadOnlySpan source, Span dest) Shuffle.InverseMMShuffle(this.Control, out _, out int p2, out int p1, out int p0); - for (int i = 0; i < source.Length; i += 3) + for (nint i = 0; i < (uint)source.Length; i += 3) { - Unsafe.Add(ref dBase, i) = Unsafe.Add(ref sBase, p0 + i); - Unsafe.Add(ref dBase, i + 1) = Unsafe.Add(ref sBase, p1 + i); - Unsafe.Add(ref dBase, i + 2) = Unsafe.Add(ref sBase, p2 + i); + Unsafe.Add(ref dBase, i + 0) = Unsafe.Add(ref sBase, (nint)(uint)p0 + i); + Unsafe.Add(ref dBase, i + 1) = Unsafe.Add(ref sBase, (nint)(uint)p1 + i); + Unsafe.Add(ref dBase, i + 2) = Unsafe.Add(ref sBase, (nint)(uint)p2 + i); } } } diff --git a/src/ImageSharp/Common/Helpers/Shuffle/IShuffle4Slice3.cs b/src/ImageSharp/Common/Helpers/Shuffle/IShuffle4Slice3.cs index ef46661f5f..1f12cea257 100644 --- a/src/ImageSharp/Common/Helpers/Shuffle/IShuffle4Slice3.cs +++ b/src/ImageSharp/Common/Helpers/Shuffle/IShuffle4Slice3.cs @@ -31,11 +31,11 @@ public void RunFallbackShuffle(ReadOnlySpan source, Span dest) Shuffle.InverseMMShuffle(this.Control, out _, out int p2, out int p1, out int p0); - for (int i = 0, j = 0; i < dest.Length; i += 3, j += 4) + for (nint i = 0, j = 0; i < (uint)dest.Length; i += 3, j += 4) { - Unsafe.Add(ref dBase, i) = Unsafe.Add(ref sBase, p0 + j); - Unsafe.Add(ref dBase, i + 1) = Unsafe.Add(ref sBase, p1 + j); - Unsafe.Add(ref dBase, i + 2) = Unsafe.Add(ref sBase, p2 + j); + Unsafe.Add(ref dBase, i + 0) = Unsafe.Add(ref sBase, (nint)(uint)p0 + j); + Unsafe.Add(ref dBase, i + 1) = Unsafe.Add(ref sBase, (nint)(uint)p1 + j); + Unsafe.Add(ref dBase, i + 2) = Unsafe.Add(ref sBase, (nint)(uint)p2 + j); } } } @@ -52,9 +52,9 @@ public void RunFallbackShuffle(ReadOnlySpan source, Span dest) ref uint sBase = ref Unsafe.As(ref MemoryMarshal.GetReference(source)); ref Byte3 dBase = ref Unsafe.As(ref MemoryMarshal.GetReference(dest)); - int n = source.Length / 4; - int m = Numerics.Modulo4(n); - int u = n - m; + nint n = (nint)(uint)source.Length / 4; + nint m = Numerics.Modulo4(n); + nint u = n - m; ref uint sLoopEnd = ref Unsafe.Add(ref sBase, u); ref uint sEnd = ref Unsafe.Add(ref sBase, n); diff --git a/src/ImageSharp/Common/Helpers/SimdUtils.FallbackIntrinsics128.cs b/src/ImageSharp/Common/Helpers/SimdUtils.FallbackIntrinsics128.cs index 84760f2815..8c79b181ce 100644 --- a/src/ImageSharp/Common/Helpers/SimdUtils.FallbackIntrinsics128.cs +++ b/src/ImageSharp/Common/Helpers/SimdUtils.FallbackIntrinsics128.cs @@ -83,7 +83,7 @@ internal static void ByteToNormalizedFloat(ReadOnlySpan source, Span(ref MemoryMarshal.GetReference(blueChannel)); ref Rgb24 rgb = ref MemoryMarshal.GetReference(destination); - int count = redChannel.Length / 4; - for (int i = 0; i < count; i++) + uint count = (uint)redChannel.Length / 4; + for (nint i = 0; i < count; i++) { ref Rgb24 d0 = ref Unsafe.Add(ref rgb, i * 4); ref Rgb24 d1 = ref Unsafe.Add(ref d0, 1); @@ -115,7 +115,7 @@ private static void PackFromRgbPlanesScalarBatchedReduce( d3.B = bb.V3; } - int finished = count * 4; + int finished = (int)(count * 4); redChannel = redChannel[finished..]; greenChannel = greenChannel[finished..]; blueChannel = blueChannel[finished..]; @@ -133,9 +133,9 @@ private static void PackFromRgbPlanesScalarBatchedReduce( ref ByteTuple4 b = ref Unsafe.As(ref MemoryMarshal.GetReference(blueChannel)); ref Rgba32 rgb = ref MemoryMarshal.GetReference(destination); - int count = redChannel.Length / 4; + uint count = (uint)redChannel.Length / 4; destination.Fill(new Rgba32(0, 0, 0, 255)); - for (int i = 0; i < count; i++) + for (nint i = 0; i < count; i++) { ref Rgba32 d0 = ref Unsafe.Add(ref rgb, i * 4); ref Rgba32 d1 = ref Unsafe.Add(ref d0, 1); @@ -163,7 +163,7 @@ private static void PackFromRgbPlanesScalarBatchedReduce( d3.B = bb.V3; } - int finished = count * 4; + int finished = (int)(count * 4); redChannel = redChannel[finished..]; greenChannel = greenChannel[finished..]; blueChannel = blueChannel[finished..]; @@ -181,7 +181,7 @@ private static void PackFromRgbPlanesRemainder( ref byte b = ref MemoryMarshal.GetReference(blueChannel); ref Rgb24 rgb = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < destination.Length; i++) + for (nint i = 0; i < (uint)destination.Length; i++) { ref Rgb24 d = ref Unsafe.Add(ref rgb, i); d.R = Unsafe.Add(ref r, i); @@ -201,7 +201,7 @@ private static void PackFromRgbPlanesRemainder( ref byte b = ref MemoryMarshal.GetReference(blueChannel); ref Rgba32 rgba = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < destination.Length; i++) + for (nint i = 0; i < (uint)destination.Length; i++) { ref Rgba32 d = ref Unsafe.Add(ref rgba, i); d.R = Unsafe.Add(ref r, i); @@ -226,7 +226,7 @@ private static void UnpackToRgbPlanesScalar( ref float b = ref MemoryMarshal.GetReference(blueChannel); ref Rgb24 rgb = ref MemoryMarshal.GetReference(source); - for (int i = 0; i < source.Length; i++) + for (nint i = 0; i < (uint)source.Length; i++) { ref Rgb24 src = ref Unsafe.Add(ref rgb, i); Unsafe.Add(ref r, i) = src.R; diff --git a/src/ImageSharp/Common/Helpers/SimdUtils.Shuffle.cs b/src/ImageSharp/Common/Helpers/SimdUtils.Shuffle.cs index aecdaa6390..532f9d4fab 100644 --- a/src/ImageSharp/Common/Helpers/SimdUtils.Shuffle.cs +++ b/src/ImageSharp/Common/Helpers/SimdUtils.Shuffle.cs @@ -147,12 +147,12 @@ private static void Shuffle4Remainder( ref float dBase = ref MemoryMarshal.GetReference(dest); Shuffle.InverseMMShuffle(control, out int p3, out int p2, out int p1, out int p0); - for (int i = 0; i < source.Length; i += 4) + for (nint i = 0; i < (uint)source.Length; i += 4) { - Unsafe.Add(ref dBase, i) = Unsafe.Add(ref sBase, p0 + i); - Unsafe.Add(ref dBase, i + 1) = Unsafe.Add(ref sBase, p1 + i); - Unsafe.Add(ref dBase, i + 2) = Unsafe.Add(ref sBase, p2 + i); - Unsafe.Add(ref dBase, i + 3) = Unsafe.Add(ref sBase, p3 + i); + Unsafe.Add(ref dBase, i + 0) = Unsafe.Add(ref sBase, (nint)(uint)p0 + i); + Unsafe.Add(ref dBase, i + 1) = Unsafe.Add(ref sBase, (nint)(uint)p1 + i); + Unsafe.Add(ref dBase, i + 2) = Unsafe.Add(ref sBase, (nint)(uint)p2 + i); + Unsafe.Add(ref dBase, i + 3) = Unsafe.Add(ref sBase, (nint)(uint)p3 + i); } } @@ -501,10 +501,10 @@ public static void MMShuffleSpan(ref Span span, byte control) for (int i = 0; i < span.Length; i += 4) { - Unsafe.Add(ref spanBase, i) = (byte)(p0 + i); - Unsafe.Add(ref spanBase, i + 1) = (byte)(p1 + i); - Unsafe.Add(ref spanBase, i + 2) = (byte)(p2 + i); - Unsafe.Add(ref spanBase, i + 3) = (byte)(p3 + i); + Unsafe.Add(ref spanBase, (uint)(i + 0)) = (byte)(p0 + i); + Unsafe.Add(ref spanBase, (uint)(i + 1)) = (byte)(p1 + i); + Unsafe.Add(ref spanBase, (uint)(i + 2)) = (byte)(p2 + i); + Unsafe.Add(ref spanBase, (uint)(i + 3)) = (byte)(p3 + i); } } diff --git a/src/ImageSharp/Compression/Zlib/Crc32.cs b/src/ImageSharp/Compression/Zlib/Crc32.cs index 39c535c773..2d0a09bd4c 100644 --- a/src/ImageSharp/Compression/Zlib/Crc32.cs +++ b/src/ImageSharp/Compression/Zlib/Crc32.cs @@ -300,7 +300,7 @@ private static uint CalculateScalar(uint crc, ReadOnlySpan buffer) for (int i = 0; i < buffer.Length; i++) { - crc = Unsafe.Add(ref crcTableRef, (int)((crc ^ Unsafe.Add(ref bufferRef, i)) & 0xFF)) ^ (crc >> 8); + crc = Unsafe.Add(ref crcTableRef, (crc ^ Unsafe.Add(ref bufferRef, i)) & 0xFF) ^ (crc >> 8); } return crc; diff --git a/src/ImageSharp/Compression/Zlib/DeflaterHuffman.cs b/src/ImageSharp/Compression/Zlib/DeflaterHuffman.cs index dc11de4259..d507d88c51 100644 --- a/src/ImageSharp/Compression/Zlib/DeflaterHuffman.cs +++ b/src/ImageSharp/Compression/Zlib/DeflaterHuffman.cs @@ -286,13 +286,13 @@ public void FlushBlock(ReadOnlySpan stored, int storedOffset, int storedLe int static_len = this.extraBits; ref byte staticLLengthRef = ref MemoryMarshal.GetReference(StaticLLength); - for (int i = 0; i < LiteralNumber; i++) + for (nint i = 0; i < LiteralNumber; i++) { static_len += this.literalTree.Frequencies[i] * Unsafe.Add(ref staticLLengthRef, i); } ref byte staticDLengthRef = ref MemoryMarshal.GetReference(StaticDLength); - for (int i = 0; i < DistanceNumber; i++) + for (nint i = 0; i < DistanceNumber; i++) { static_len += this.distTree.Frequencies[i] * Unsafe.Add(ref staticDLengthRef, i); } @@ -405,10 +405,10 @@ public static short BitReverse(int toReverse) ref byte bit4ReverseRef = ref MemoryMarshal.GetReference(Bit4Reverse); - return (short)(Unsafe.Add(ref bit4ReverseRef, toReverse & 0xF) << 12 - | Unsafe.Add(ref bit4ReverseRef, (toReverse >> 4) & 0xF) << 8 - | Unsafe.Add(ref bit4ReverseRef, (toReverse >> 8) & 0xF) << 4 - | Unsafe.Add(ref bit4ReverseRef, toReverseRightShiftBy12)); + return (short)((Unsafe.Add(ref bit4ReverseRef, (uint)toReverse & 0xF) << 12) + | (Unsafe.Add(ref bit4ReverseRef, (uint)(toReverse >> 4) & 0xF) << 8) + | (Unsafe.Add(ref bit4ReverseRef, (uint)(toReverse >> 8) & 0xF) << 4) + | Unsafe.Add(ref bit4ReverseRef, (uint)toReverseRightShiftBy12)); } /// @@ -551,8 +551,8 @@ public void BuildCodes() int code = 0; for (int bits = 0; bits < this.maxLength; bits++) { - Unsafe.Add(ref nextCodeRef, bits) = code; - code += Unsafe.Add(ref bitLengthCountsRef, bits) << (15 - bits); + Unsafe.Add(ref nextCodeRef, (uint)bits) = code; + code += Unsafe.Add(ref bitLengthCountsRef, (uint)bits) << (15 - bits); } for (int i = 0; i < this.NumCodes; i++) @@ -560,8 +560,8 @@ public void BuildCodes() int bits = this.Length[i]; if (bits > 0) { - this.codes[i] = BitReverse(Unsafe.Add(ref nextCodeRef, bits - 1)); - Unsafe.Add(ref nextCodeRef, bits - 1) += 1 << (16 - bits); + this.codes[i] = BitReverse(Unsafe.Add(ref nextCodeRef, (uint)(bits - 1))); + Unsafe.Add(ref nextCodeRef, (uint)(bits - 1)) += 1 << (16 - bits); } } } @@ -593,13 +593,13 @@ public void BuildTree() // Insert n into heap int pos = heapLen++; int ppos; - while (pos > 0 && this.Frequencies[Unsafe.Add(ref heapRef, ppos = (pos - 1) >> 1)] > freq) + while (pos > 0 && this.Frequencies[Unsafe.Add(ref heapRef, (uint)(ppos = (pos - 1) >> 1))] > freq) { - Unsafe.Add(ref heapRef, pos) = Unsafe.Add(ref heapRef, ppos); + Unsafe.Add(ref heapRef, pos) = Unsafe.Add(ref heapRef, (uint)ppos); pos = ppos; } - Unsafe.Add(ref heapRef, pos) = n; + Unsafe.Add(ref heapRef, (uint)pos) = n; maxCode = n; } @@ -611,7 +611,7 @@ public void BuildTree() // this case, both literals get a 1 bit code. while (heapLen < 2) { - Unsafe.Add(ref heapRef, heapLen++) = maxCode < 2 ? ++maxCode : 0; + Unsafe.Add(ref heapRef, (uint)heapLen++) = maxCode < 2 ? ++maxCode : 0; } this.NumCodes = Math.Max(maxCode + 1, this.minNumCodes); @@ -625,14 +625,14 @@ public void BuildTree() ref int valuesRef = ref MemoryMarshal.GetReference(valuesMemoryOwner.Memory.Span); int numNodes = numLeafs; - for (int i = 0; i < heapLen; i++) + for (nint i = 0; i < (uint)heapLen; i++) { int node = Unsafe.Add(ref heapRef, i); - int i2 = 2 * i; + nint i2 = 2 * i; Unsafe.Add(ref childrenRef, i2) = node; Unsafe.Add(ref childrenRef, i2 + 1) = -1; Unsafe.Add(ref valuesRef, i) = this.Frequencies[node] << 8; - Unsafe.Add(ref heapRef, i) = i; + Unsafe.Add(ref heapRef, i) = (int)i; } // Construct the Huffman tree by repeatedly combining the least two @@ -640,7 +640,7 @@ public void BuildTree() do { int first = Unsafe.Add(ref heapRef, 0); - int last = Unsafe.Add(ref heapRef, --heapLen); + int last = Unsafe.Add(ref heapRef, (uint)--heapLen); // Propagate the hole to the leafs of the heap int ppos = 0; @@ -648,35 +648,35 @@ public void BuildTree() while (path < heapLen) { - if (path + 1 < heapLen && Unsafe.Add(ref valuesRef, Unsafe.Add(ref heapRef, path)) > Unsafe.Add(ref valuesRef, Unsafe.Add(ref heapRef, path + 1))) + if (path + 1 < heapLen && Unsafe.Add(ref valuesRef, (uint)Unsafe.Add(ref heapRef, (uint)path)) > Unsafe.Add(ref valuesRef, (uint)Unsafe.Add(ref heapRef, (uint)(path + 1)))) { path++; } - Unsafe.Add(ref heapRef, ppos) = Unsafe.Add(ref heapRef, path); + Unsafe.Add(ref heapRef, (uint)ppos) = Unsafe.Add(ref heapRef, (uint)path); ppos = path; path = (path * 2) + 1; } // Now propagate the last element down along path. Normally // it shouldn't go too deep. - int lastVal = Unsafe.Add(ref valuesRef, last); + int lastVal = Unsafe.Add(ref valuesRef, (uint)last); while ((path = ppos) > 0 - && Unsafe.Add(ref valuesRef, Unsafe.Add(ref heapRef, ppos = (path - 1) >> 1)) > lastVal) + && Unsafe.Add(ref valuesRef, (uint)Unsafe.Add(ref heapRef, (uint)(ppos = (path - 1) >> 1))) > lastVal) { - Unsafe.Add(ref heapRef, path) = Unsafe.Add(ref heapRef, ppos); + Unsafe.Add(ref heapRef, (uint)path) = Unsafe.Add(ref heapRef, (uint)ppos); } - Unsafe.Add(ref heapRef, path) = last; + Unsafe.Add(ref heapRef, (uint)path) = last; int second = Unsafe.Add(ref heapRef, 0); // Create a new node father of first and second last = numNodes++; - Unsafe.Add(ref childrenRef, 2 * last) = first; - Unsafe.Add(ref childrenRef, (2 * last) + 1) = second; - int mindepth = Math.Min(Unsafe.Add(ref valuesRef, first) & 0xFF, Unsafe.Add(ref valuesRef, second) & 0xFF); - Unsafe.Add(ref valuesRef, last) = lastVal = Unsafe.Add(ref valuesRef, first) + Unsafe.Add(ref valuesRef, second) - mindepth + 1; + Unsafe.Add(ref childrenRef, (uint)(2 * last)) = first; + Unsafe.Add(ref childrenRef, (uint)((2 * last) + 1)) = second; + int mindepth = Math.Min(Unsafe.Add(ref valuesRef, (uint)first) & 0xFF, Unsafe.Add(ref valuesRef, (uint)second) & 0xFF); + Unsafe.Add(ref valuesRef, (uint)last) = lastVal = Unsafe.Add(ref valuesRef, (uint)first) + Unsafe.Add(ref valuesRef, (uint)second) - mindepth + 1; // Again, propagate the hole to the leafs ppos = 0; @@ -685,23 +685,23 @@ public void BuildTree() while (path < heapLen) { if (path + 1 < heapLen - && Unsafe.Add(ref valuesRef, Unsafe.Add(ref heapRef, path)) > Unsafe.Add(ref valuesRef, Unsafe.Add(ref heapRef, path + 1))) + && Unsafe.Add(ref valuesRef, (uint)Unsafe.Add(ref heapRef, (uint)path)) > Unsafe.Add(ref valuesRef, (uint)Unsafe.Add(ref heapRef, (uint)(path + 1)))) { path++; } - Unsafe.Add(ref heapRef, ppos) = Unsafe.Add(ref heapRef, path); + Unsafe.Add(ref heapRef, (uint)ppos) = Unsafe.Add(ref heapRef, (uint)path); ppos = path; path = (ppos * 2) + 1; } // Now propagate the new element down along path - while ((path = ppos) > 0 && Unsafe.Add(ref valuesRef, Unsafe.Add(ref heapRef, ppos = (path - 1) >> 1)) > lastVal) + while ((path = ppos) > 0 && Unsafe.Add(ref valuesRef, (uint)Unsafe.Add(ref heapRef, (uint)(ppos = (path - 1) >> 1))) > lastVal) { - Unsafe.Add(ref heapRef, path) = Unsafe.Add(ref heapRef, ppos); + Unsafe.Add(ref heapRef, (uint)path) = Unsafe.Add(ref heapRef, (uint)ppos); } - Unsafe.Add(ref heapRef, path) = last; + Unsafe.Add(ref heapRef, (uint)path) = last; } while (heapLen > 1); @@ -886,21 +886,21 @@ private void BuildLength(ReadOnlySpan children) { if (children[(2 * i) + 1] != -1) { - int bitLength = Unsafe.Add(ref lengthsRef, i) + 1; + int bitLength = Unsafe.Add(ref lengthsRef, (uint)i) + 1; if (bitLength > maxLen) { bitLength = maxLen; overflow++; } - Unsafe.Add(ref lengthsRef, Unsafe.Add(ref childrenRef, 2 * i)) = Unsafe.Add(ref lengthsRef, Unsafe.Add(ref childrenRef, (2 * i) + 1)) = bitLength; + Unsafe.Add(ref lengthsRef, (uint)Unsafe.Add(ref childrenRef, (uint)(2 * i))) = Unsafe.Add(ref lengthsRef, (uint)Unsafe.Add(ref childrenRef, (uint)((2 * i) + 1))) = bitLength; } else { // A leaf node - int bitLength = Unsafe.Add(ref lengthsRef, i); - Unsafe.Add(ref bitLengthCountsRef, bitLength - 1)++; - lengthPtr[Unsafe.Add(ref childrenRef, 2 * i)] = (byte)Unsafe.Add(ref lengthsRef, i); + int bitLength = Unsafe.Add(ref lengthsRef, (uint)i); + Unsafe.Add(ref bitLengthCountsRef, (uint)(bitLength - 1))++; + lengthPtr[Unsafe.Add(ref childrenRef, (uint)(2 * i))] = (byte)Unsafe.Add(ref lengthsRef, (uint)i); } } } @@ -914,7 +914,7 @@ private void BuildLength(ReadOnlySpan children) do { // Find the first bit length which could increase: - while (Unsafe.Add(ref bitLengthCountsRef, --incrBitLen) == 0) + while (Unsafe.Add(ref bitLengthCountsRef, (uint)--incrBitLen) == 0) { } @@ -922,8 +922,8 @@ private void BuildLength(ReadOnlySpan children) // number of overflow nodes. do { - Unsafe.Add(ref bitLengthCountsRef, incrBitLen)--; - Unsafe.Add(ref bitLengthCountsRef, ++incrBitLen)++; + Unsafe.Add(ref bitLengthCountsRef, (uint)incrBitLen)--; + Unsafe.Add(ref bitLengthCountsRef, (uint)++incrBitLen)++; overflow -= 1 << (maxLen - 1 - incrBitLen); } while (overflow > 0 && incrBitLen < maxLen - 1); @@ -932,8 +932,8 @@ private void BuildLength(ReadOnlySpan children) // We may have overshot above. Move some nodes from maxLength to // maxLength-1 in that case. - Unsafe.Add(ref bitLengthCountsRef, maxLen - 1) += overflow; - Unsafe.Add(ref bitLengthCountsRef, maxLen - 2) -= overflow; + Unsafe.Add(ref bitLengthCountsRef, (uint)(maxLen - 1)) += overflow; + Unsafe.Add(ref bitLengthCountsRef, (uint)(maxLen - 2)) -= overflow; // Now recompute all bit lengths, scanning in increasing // frequency. It is simpler to reconstruct all lengths instead of @@ -945,14 +945,14 @@ private void BuildLength(ReadOnlySpan children) int nodeIndex = 2 * numLeafs; for (int bits = maxLen; bits != 0; bits--) { - int n = Unsafe.Add(ref bitLengthCountsRef, bits - 1); + int n = Unsafe.Add(ref bitLengthCountsRef, (uint)(bits - 1)); while (n > 0) { - int childIndex = 2 * Unsafe.Add(ref childrenRef, nodeIndex++); - if (Unsafe.Add(ref childrenRef, childIndex + 1) == -1) + int childIndex = 2 * Unsafe.Add(ref childrenRef, (uint)nodeIndex++); + if (Unsafe.Add(ref childrenRef, (uint)(childIndex + 1)) == -1) { // We found another leaf - lengthPtr[Unsafe.Add(ref childrenRef, childIndex)] = (byte)bits; + lengthPtr[Unsafe.Add(ref childrenRef, (uint)childIndex)] = (byte)bits; n--; } } diff --git a/src/ImageSharp/Formats/Gif/GifDecoderCore.cs b/src/ImageSharp/Formats/Gif/GifDecoderCore.cs index 17b5d8ec9b..6ff2723ddd 100644 --- a/src/ImageSharp/Formats/Gif/GifDecoderCore.cs +++ b/src/ImageSharp/Formats/Gif/GifDecoderCore.cs @@ -578,8 +578,8 @@ private void ReadFrameColors(ref Image? image, ref ImageFrame(ref Image? image, ref ImageFrame colorTableMaxIdx || rawIndex == transIndex) @@ -597,7 +597,7 @@ private void ReadFrameColors(ref Image? image, ref ImageFrame(IndexedImageFrame quantiz for (int i = rgbaSpan.Length - 1; i >= 0; i--) { - if (Unsafe.Add(ref rgbaSpanRef, i).Equals(default)) + if (Unsafe.Add(ref rgbaSpanRef, (uint)i).Equals(default)) { index = i; } diff --git a/src/ImageSharp/Formats/Gif/LzwDecoder.cs b/src/ImageSharp/Formats/Gif/LzwDecoder.cs index 64b9cf386c..4d282f26c6 100644 --- a/src/ImageSharp/Formats/Gif/LzwDecoder.cs +++ b/src/ImageSharp/Formats/Gif/LzwDecoder.cs @@ -115,7 +115,7 @@ public void DecodePixels(int minCodeSize, Buffer2D pixels) for (code = 0; code < clearCode; code++) { - Unsafe.Add(ref suffixRef, code) = (byte)code; + Unsafe.Add(ref suffixRef, (uint)code) = (byte)code; } Span buffer = stackalloc byte[byte.MaxValue]; @@ -182,7 +182,7 @@ public void DecodePixels(int minCodeSize, Buffer2D pixels) if (oldCode == NullCode) { - Unsafe.Add(ref pixelStackRef, top++) = Unsafe.Add(ref suffixRef, code); + Unsafe.Add(ref pixelStackRef, (uint)top++) = Unsafe.Add(ref suffixRef, (uint)code); oldCode = code; first = code; continue; @@ -191,27 +191,27 @@ public void DecodePixels(int minCodeSize, Buffer2D pixels) int inCode = code; if (code == availableCode) { - Unsafe.Add(ref pixelStackRef, top++) = (byte)first; + Unsafe.Add(ref pixelStackRef, (uint)top++) = (byte)first; code = oldCode; } while (code > clearCode) { - Unsafe.Add(ref pixelStackRef, top++) = Unsafe.Add(ref suffixRef, code); - code = Unsafe.Add(ref prefixRef, code); + Unsafe.Add(ref pixelStackRef, (uint)top++) = Unsafe.Add(ref suffixRef, (uint)code); + code = Unsafe.Add(ref prefixRef, (uint)code); } - int suffixCode = Unsafe.Add(ref suffixRef, code); + int suffixCode = Unsafe.Add(ref suffixRef, (uint)code); first = suffixCode; - Unsafe.Add(ref pixelStackRef, top++) = suffixCode; + Unsafe.Add(ref pixelStackRef, (uint)top++) = suffixCode; // Fix for Gifs that have "deferred clear code" as per here : // https://bugzilla.mozilla.org/show_bug.cgi?id=55918 if (availableCode < MaxStackSize) { - Unsafe.Add(ref prefixRef, availableCode) = oldCode; - Unsafe.Add(ref suffixRef, availableCode) = first; + Unsafe.Add(ref prefixRef, (uint)availableCode) = oldCode; + Unsafe.Add(ref suffixRef, (uint)availableCode) = first; availableCode++; if (availableCode == codeMask + 1 && availableCode < MaxStackSize) { @@ -228,7 +228,7 @@ public void DecodePixels(int minCodeSize, Buffer2D pixels) // Clear missing pixels xyz++; - Unsafe.Add(ref pixelsRowRef, x++) = (byte)Unsafe.Add(ref pixelStackRef, top); + Unsafe.Add(ref pixelsRowRef, (uint)x++) = (byte)Unsafe.Add(ref pixelStackRef, (uint)top); } } @@ -282,7 +282,7 @@ public void SkipIndices(int minCodeSize, int length) for (code = 0; code < clearCode; code++) { - Unsafe.Add(ref suffixRef, code) = (byte)code; + Unsafe.Add(ref suffixRef, (uint)code) = (byte)code; } Span buffer = stackalloc byte[byte.MaxValue]; @@ -336,7 +336,7 @@ public void SkipIndices(int minCodeSize, int length) if (oldCode == NullCode) { - Unsafe.Add(ref pixelStackRef, top++) = Unsafe.Add(ref suffixRef, code); + Unsafe.Add(ref pixelStackRef, (uint)top++) = Unsafe.Add(ref suffixRef, (uint)code); oldCode = code; first = code; continue; @@ -345,27 +345,27 @@ public void SkipIndices(int minCodeSize, int length) int inCode = code; if (code == availableCode) { - Unsafe.Add(ref pixelStackRef, top++) = (byte)first; + Unsafe.Add(ref pixelStackRef, (uint)top++) = (byte)first; code = oldCode; } while (code > clearCode) { - Unsafe.Add(ref pixelStackRef, top++) = Unsafe.Add(ref suffixRef, code); - code = Unsafe.Add(ref prefixRef, code); + Unsafe.Add(ref pixelStackRef, (uint)top++) = Unsafe.Add(ref suffixRef, (uint)code); + code = Unsafe.Add(ref prefixRef, (uint)code); } - int suffixCode = Unsafe.Add(ref suffixRef, code); + int suffixCode = Unsafe.Add(ref suffixRef, (uint)code); first = suffixCode; - Unsafe.Add(ref pixelStackRef, top++) = suffixCode; + Unsafe.Add(ref pixelStackRef, (uint)top++) = suffixCode; // Fix for Gifs that have "deferred clear code" as per here : // https://bugzilla.mozilla.org/show_bug.cgi?id=55918 if (availableCode < MaxStackSize) { - Unsafe.Add(ref prefixRef, availableCode) = oldCode; - Unsafe.Add(ref suffixRef, availableCode) = first; + Unsafe.Add(ref prefixRef, (uint)availableCode) = oldCode; + Unsafe.Add(ref suffixRef, (uint)availableCode) = first; availableCode++; if (availableCode == codeMask + 1 && availableCode < MaxStackSize) { diff --git a/src/ImageSharp/Formats/Gif/LzwEncoder.cs b/src/ImageSharp/Formats/Gif/LzwEncoder.cs index fe27e7bf93..5253c0978a 100644 --- a/src/ImageSharp/Formats/Gif/LzwEncoder.cs +++ b/src/ImageSharp/Formats/Gif/LzwEncoder.cs @@ -216,7 +216,7 @@ public void Encode(Buffer2D indexedPixels, Stream stream) [MethodImpl(MethodImplOptions.AggressiveInlining)] private void AddCharacter(byte c, ref byte accumulatorsRef, Stream stream) { - Unsafe.Add(ref accumulatorsRef, this.accumulatorCount++) = c; + Unsafe.Add(ref accumulatorsRef, (uint)this.accumulatorCount++) = c; if (this.accumulatorCount >= 254) { this.FlushPacket(stream); @@ -278,18 +278,18 @@ private void Compress(Buffer2D indexedPixels, int initialBits, Stream stre for (int x = offsetX; x < indexedPixels.Width; x++) { - int code = Unsafe.Add(ref rowSpanRef, x); + int code = Unsafe.Add(ref rowSpanRef, (uint)x); int freeCode = (code << MaxBits) + entry; int hashIndex = (code << HashShift) ^ entry; - if (Unsafe.Add(ref hashTableRef, hashIndex) == freeCode) + if (Unsafe.Add(ref hashTableRef, (uint)hashIndex) == freeCode) { - entry = Unsafe.Add(ref codeTableRef, hashIndex); + entry = Unsafe.Add(ref codeTableRef, (uint)hashIndex); continue; } // Non-empty slot - if (Unsafe.Add(ref hashTableRef, hashIndex) >= 0) + if (Unsafe.Add(ref hashTableRef, (uint)hashIndex) >= 0) { int disp = 1; if (hashIndex != 0) @@ -304,15 +304,15 @@ private void Compress(Buffer2D indexedPixels, int initialBits, Stream stre hashIndex += HashSize; } - if (Unsafe.Add(ref hashTableRef, hashIndex) == freeCode) + if (Unsafe.Add(ref hashTableRef, (uint)hashIndex) == freeCode) { - entry = Unsafe.Add(ref codeTableRef, hashIndex); + entry = Unsafe.Add(ref codeTableRef, (uint)hashIndex); break; } } - while (Unsafe.Add(ref hashTableRef, hashIndex) >= 0); + while (Unsafe.Add(ref hashTableRef, (uint)hashIndex) >= 0); - if (Unsafe.Add(ref hashTableRef, hashIndex) == freeCode) + if (Unsafe.Add(ref hashTableRef, (uint)hashIndex) == freeCode) { continue; } @@ -322,8 +322,8 @@ private void Compress(Buffer2D indexedPixels, int initialBits, Stream stre entry = code; if (this.freeEntry < MaxMaxCode) { - Unsafe.Add(ref codeTableRef, hashIndex) = this.freeEntry++; // code -> hashtable - Unsafe.Add(ref hashTableRef, hashIndex) = freeCode; + Unsafe.Add(ref codeTableRef, (uint)hashIndex) = this.freeEntry++; // code -> hashtable + Unsafe.Add(ref hashTableRef, (uint)hashIndex) = freeCode; } else { diff --git a/src/ImageSharp/Formats/Jpeg/Components/Block8x8.cs b/src/ImageSharp/Formats/Jpeg/Components/Block8x8.cs index 325d6c26f5..d119a18c8b 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/Block8x8.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/Block8x8.cs @@ -47,7 +47,7 @@ public short this[int idx] DebugGuard.MustBeBetweenOrEqualTo(idx, 0, Size - 1, nameof(idx)); ref short selfRef = ref Unsafe.As(ref this); - return Unsafe.Add(ref selfRef, idx); + return Unsafe.Add(ref selfRef, (uint)idx); } [MethodImpl(MethodImplOptions.AggressiveInlining)] @@ -56,7 +56,7 @@ public short this[int idx] DebugGuard.MustBeBetweenOrEqualTo(idx, 0, Size - 1, nameof(idx)); ref short selfRef = ref Unsafe.As(ref this); - Unsafe.Add(ref selfRef, idx) = value; + Unsafe.Add(ref selfRef, (uint)idx) = value; } } @@ -207,12 +207,12 @@ public nint GetLastNonZeroIndex() // Given mask is not actually suitable for lzcnt as 1's represent zero elements and 0's represent non-zero elements // So we need to invert it - int lzcnt = BitOperations.LeadingZeroCount(~(uint)areEqual); + uint lzcnt = (uint)BitOperations.LeadingZeroCount(~(uint)areEqual); // As input number is represented by 2 bits in the mask, we need to divide lzcnt result by 2 // to get the exact number of zero elements in the stride - int strideRelativeIndex = 15 - (lzcnt / 2); - return (i * 16) + strideRelativeIndex; + uint strideRelativeIndex = 15 - (lzcnt / 2); + return (i * 16) + (nint)strideRelativeIndex; } } diff --git a/src/ImageSharp/Formats/Jpeg/Components/Block8x8F.Generated.cs b/src/ImageSharp/Formats/Jpeg/Components/Block8x8F.Generated.cs index 2610befcfe..d1cb3559b2 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/Block8x8F.Generated.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/Block8x8F.Generated.cs @@ -44,31 +44,31 @@ public void NormalizeColorsAndRoundInPlaceVector8(float maximum) { var off = new Vector(MathF.Ceiling(maximum / 2)); var max = new Vector(maximum); - + ref Vector row0 = ref Unsafe.As>(ref this.V0L); row0 = NormalizeAndRound(row0, off, max); - + ref Vector row1 = ref Unsafe.As>(ref this.V1L); row1 = NormalizeAndRound(row1, off, max); - + ref Vector row2 = ref Unsafe.As>(ref this.V2L); row2 = NormalizeAndRound(row2, off, max); - + ref Vector row3 = ref Unsafe.As>(ref this.V3L); row3 = NormalizeAndRound(row3, off, max); - + ref Vector row4 = ref Unsafe.As>(ref this.V4L); row4 = NormalizeAndRound(row4, off, max); - + ref Vector row5 = ref Unsafe.As>(ref this.V5L); row5 = NormalizeAndRound(row5, off, max); - + ref Vector row6 = ref Unsafe.As>(ref this.V6L); row6 = NormalizeAndRound(row6, off, max); - + ref Vector row7 = ref Unsafe.As>(ref this.V7L); row7 = NormalizeAndRound(row7, off, max); - + } /// diff --git a/src/ImageSharp/Formats/Jpeg/Components/Block8x8F.Intrinsic.cs b/src/ImageSharp/Formats/Jpeg/Components/Block8x8F.Intrinsic.cs index 78c82f11a0..7611d403ac 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/Block8x8F.Intrinsic.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/Block8x8F.Intrinsic.cs @@ -51,7 +51,7 @@ private static unsafe void MultiplyIntoInt16_Avx2(ref Block8x8F a, ref Block8x8F Vector256 row = Avx2.PackSignedSaturate(row0, row1); row = Avx2.PermuteVar8x32(row.AsInt32(), multiplyIntoInt16ShuffleMask).AsInt16(); - Unsafe.Add(ref destRef, (IntPtr)((uint)i / 2)) = row; + Unsafe.Add(ref destRef, i / 2) = row; } } @@ -64,13 +64,13 @@ private static void MultiplyIntoInt16_Sse2(ref Block8x8F a, ref Block8x8F b, ref ref Vector128 destBase = ref Unsafe.As>(ref dest); - for (int i = 0; i < 16; i += 2) + for (nint i = 0; i < 16; i += 2) { Vector128 left = Sse2.ConvertToVector128Int32(Sse.Multiply(Unsafe.Add(ref aBase, i + 0), Unsafe.Add(ref bBase, i + 0))); Vector128 right = Sse2.ConvertToVector128Int32(Sse.Multiply(Unsafe.Add(ref aBase, i + 1), Unsafe.Add(ref bBase, i + 1))); Vector128 row = Sse2.PackSignedSaturate(left, right); - Unsafe.Add(ref destBase, (IntPtr)((uint)i / 2)) = row; + Unsafe.Add(ref destBase, i / 2) = row; } } diff --git a/src/ImageSharp/Formats/Jpeg/Components/Block8x8F.ScaledCopy.cs b/src/ImageSharp/Formats/Jpeg/Components/Block8x8F.ScaledCopy.cs index 813d9c37b7..e68ede9fbb 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/Block8x8F.ScaledCopy.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/Block8x8F.ScaledCopy.cs @@ -98,11 +98,11 @@ private void CopyArbitraryScale(ref float areaOrigin, int areaStride, int horizo int xx = x * horizontalScale; float value = this[y8 + x]; - nint baseIdx = (yy * areaStride) + xx; + nint baseIdx = (nint)(uint)((yy * areaStride) + xx); for (nint i = 0; i < verticalScale; i++, baseIdx += areaStride) { - for (nint j = 0; j < horizontalScale; j++) + for (nint j = 0; j < (uint)horizontalScale; j++) { // area[xx + j, yy + i] = value; Unsafe.Add(ref areaOrigin, baseIdx + j) = value; @@ -128,8 +128,8 @@ private static void CopyTo1x1Scale(ref byte origin, ref byte dest, int areaStrid [MethodImpl(MethodImplOptions.AggressiveInlining)] static void CopyRowImpl(ref byte origin, ref byte dest, int destStride, int row) { - origin = ref Unsafe.Add(ref origin, row * 8 * sizeof(float)); - dest = ref Unsafe.Add(ref dest, row * destStride); + origin = ref Unsafe.Add(ref origin, (uint)row * 8 * sizeof(float)); + dest = ref Unsafe.Add(ref dest, (uint)(row * destStride)); Unsafe.CopyBlock(ref dest, ref origin, 8 * sizeof(float)); } } @@ -150,8 +150,8 @@ private static void CopyFrom1x1Scale(ref byte origin, ref byte dest, int areaStr [MethodImpl(MethodImplOptions.AggressiveInlining)] static void CopyRowImpl(ref byte origin, ref byte dest, int sourceStride, int row) { - origin = ref Unsafe.Add(ref origin, row * sourceStride); - dest = ref Unsafe.Add(ref dest, row * 8 * sizeof(float)); + origin = ref Unsafe.Add(ref origin, (uint)(row * sourceStride)); + dest = ref Unsafe.Add(ref dest, (uint)row * 8 * sizeof(float)); Unsafe.CopyBlock(ref dest, ref origin, 8 * sizeof(float)); } } diff --git a/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.GrayScaleScalar.cs b/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.GrayScaleScalar.cs index 16dd7c768a..df511594af 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.GrayScaleScalar.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.GrayScaleScalar.cs @@ -28,7 +28,7 @@ internal static void ConvertToRgbInplace(Span values, float maxValue) ref float valuesRef = ref MemoryMarshal.GetReference(values); float scale = 1 / maxValue; - for (nint i = 0; i < values.Length; i++) + for (nint i = 0; i < (uint)values.Length; i++) { Unsafe.Add(ref valuesRef, i) *= scale; } diff --git a/src/ImageSharp/Formats/Jpeg/Components/Decoder/ArithmeticScanDecoder.cs b/src/ImageSharp/Formats/Jpeg/Components/Decoder/ArithmeticScanDecoder.cs index 922d7093b6..59789dcd25 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/Decoder/ArithmeticScanDecoder.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/Decoder/ArithmeticScanDecoder.cs @@ -705,7 +705,7 @@ private void DecodeBlockProgressiveDc(ArithmeticDecodingComponent component, ref // Sections F.2.4.1 & F.1.4.4.1: Decoding of DC coefficients. // Table F.4: Point to statistics bin S0 for DC coefficient coding. - ref byte st = ref Unsafe.Add(ref component.DcStatistics.GetReference(), component.DcContext); + ref byte st = ref Unsafe.Add(ref component.DcStatistics.GetReference(), (uint)component.DcContext); // Figure F.19: Decode_DC_DIFF if (this.DecodeBinaryDecision(ref reader, ref st) == 0) @@ -955,7 +955,7 @@ private void DecodeBlockBaseline( // Sections F.2.4.1 & F.1.4.4.1: Decoding of DC coefficients. // Table F.4: Point to statistics bin S0 for DC coefficient coding. - ref byte st = ref Unsafe.Add(ref component.DcStatistics.GetReference(), component.DcContext); + ref byte st = ref Unsafe.Add(ref component.DcStatistics.GetReference(), (uint)component.DcContext); /* Figure F.19: Decode_DC_DIFF */ if (this.DecodeBinaryDecision(ref reader, ref st) == 0) diff --git a/src/ImageSharp/Formats/Jpeg/Components/Decoder/HuffmanScanDecoder.cs b/src/ImageSharp/Formats/Jpeg/Components/Decoder/HuffmanScanDecoder.cs index e5c5098d05..bbd2bff53b 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/Decoder/HuffmanScanDecoder.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/Decoder/HuffmanScanDecoder.cs @@ -211,7 +211,7 @@ private void ParseBaselineDataInterleaved() this.DecodeBlockBaseline( component, - ref Unsafe.Add(ref blockRef, blockCol), + ref Unsafe.Add(ref blockRef, (uint)blockCol), ref dcHuffmanTable, ref acHuffmanTable); } @@ -255,7 +255,7 @@ private void ParseBaselineDataNonInterleaved() this.DecodeBlockBaseline( component, - ref Unsafe.Add(ref blockRef, i), + ref Unsafe.Add(ref blockRef, (uint)i), ref dcHuffmanTable, ref acHuffmanTable); @@ -297,7 +297,7 @@ private void ParseBaselineDataSingleComponent() this.DecodeBlockBaseline( component, - ref Unsafe.Add(ref blockRef, k), + ref Unsafe.Add(ref blockRef, (uint)k), ref dcHuffmanTable, ref acHuffmanTable); @@ -417,7 +417,7 @@ private void ParseProgressiveDataInterleaved() this.DecodeBlockProgressiveDC( component, - ref Unsafe.Add(ref blockRef, blockCol), + ref Unsafe.Add(ref blockRef, (uint)blockCol), ref dcHuffmanTable); } } @@ -459,7 +459,7 @@ private void ParseProgressiveDataNonInterleaved() this.DecodeBlockProgressiveDC( component, - ref Unsafe.Add(ref blockRef, i), + ref Unsafe.Add(ref blockRef, (uint)i), ref dcHuffmanTable); this.HandleRestart(); @@ -485,7 +485,7 @@ ref Unsafe.Add(ref blockRef, i), } this.DecodeBlockProgressiveAC( - ref Unsafe.Add(ref blockRef, i), + ref Unsafe.Add(ref blockRef, (uint)i), ref acHuffmanTable); this.HandleRestart(); diff --git a/src/ImageSharp/Formats/Jpeg/Components/Encoder/ComponentProcessor.cs b/src/ImageSharp/Formats/Jpeg/Components/Encoder/ComponentProcessor.cs index 23ddd0e495..3c89ab1fb6 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/Encoder/ComponentProcessor.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/Encoder/ComponentProcessor.cs @@ -141,7 +141,7 @@ static void SumVertical(Span target, Span source) ref float targetRef = ref MemoryMarshal.GetReference(target); ref float sourceRef = ref MemoryMarshal.GetReference(source); - for (nint i = count * Vector.Count; i < source.Length; i++) + for (nint i = count * Vector.Count; i < (uint)source.Length; i++) { Unsafe.Add(ref targetRef, i) += Unsafe.Add(ref sourceRef, i); } @@ -166,16 +166,16 @@ static void SumHorizontal(Span target, int factor) source = source.Slice(touchedCount); target = target.Slice(touchedCount / factor); - uint length = (uint)touchedCount / (uint)Vector256.Count; + nint length = (nint)(uint)touchedCount / Vector256.Count; for (int i = 0; i < haddIterationsCount; i++) { length /= 2; - for (nuint j = 0; j < length; j++) + for (nint j = 0; j < length; j++) { - nuint indexLeft = j * 2; - nuint indexRight = indexLeft + 1; + nint indexLeft = j * 2; + nint indexRight = indexLeft + 1; Vector256 sum = Avx.HorizontalAdd(Unsafe.Add(ref targetRef, indexLeft), Unsafe.Add(ref targetRef, indexRight)); Unsafe.Add(ref targetRef, j) = Avx2.Permute4x64(sum.AsDouble(), 0b11_01_10_00).AsSingle(); } @@ -219,7 +219,7 @@ static void MultiplyToAverage(Span target, float multiplier) } ref float targetRef = ref MemoryMarshal.GetReference(target); - for (nint i = count * Vector.Count; i < target.Length; i++) + for (nint i = count * Vector.Count; i < (uint)target.Length; i++) { Unsafe.Add(ref targetRef, i) *= multiplier; } diff --git a/src/ImageSharp/Formats/Jpeg/Components/Encoder/HuffmanScanEncoder.cs b/src/ImageSharp/Formats/Jpeg/Components/Encoder/HuffmanScanEncoder.cs index 8edbc3c407..f479df7e2d 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/Encoder/HuffmanScanEncoder.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/Encoder/HuffmanScanEncoder.cs @@ -180,7 +180,7 @@ public void EncodeScanBaselineSingleComponent(Component component, Spect Span blockSpan = component.SpectralBlocks.DangerousGetRowSpan(y: 0); ref Block8x8 blockRef = ref MemoryMarshal.GetReference(blockSpan); - for (nint k = 0; k < w; k++) + for (nint k = 0; k < (uint)w; k++) { this.WriteBlock( component, @@ -219,7 +219,7 @@ public void EncodeScanBaseline(Component component, CancellationToken cancellati Span blockSpan = component.SpectralBlocks.DangerousGetRowSpan(y: i); ref Block8x8 blockRef = ref MemoryMarshal.GetReference(blockSpan); - for (nint k = 0; k < w; k++) + for (nint k = 0; k < (uint)w; k++) { this.WriteBlock( component, diff --git a/src/ImageSharp/Formats/Png/Filters/AverageFilter.cs b/src/ImageSharp/Formats/Png/Filters/AverageFilter.cs index 34e05d7796..0e601f5262 100644 --- a/src/ImageSharp/Formats/Png/Filters/AverageFilter.cs +++ b/src/ImageSharp/Formats/Png/Filters/AverageFilter.cs @@ -42,7 +42,7 @@ public static void Decode(Span scanline, Span previousScanline, int } else { - DecodeScalar(scanline, previousScanline, bytesPerPixel); + DecodeScalar(scanline, previousScanline, (nint)(uint)bytesPerPixel); } } @@ -88,7 +88,7 @@ public static void DecodeArm(Span scanline, Span previousScanline) Vector64 d = Vector64.Zero; int rb = scanline.Length; - int offset = 1; + nint offset = 1; const int bytesPerBatch = 4; while (rb >= bytesPerBatch) { @@ -108,7 +108,7 @@ public static void DecodeArm(Span scanline, Span previousScanline) } [MethodImpl(MethodImplOptions.AggressiveInlining)] - private static void DecodeScalar(Span scanline, Span previousScanline, int bytesPerPixel) + private static void DecodeScalar(Span scanline, Span previousScanline, nint bytesPerPixel) { ref byte scanBaseRef = ref MemoryMarshal.GetReference(scanline); ref byte prevBaseRef = ref MemoryMarshal.GetReference(previousScanline); @@ -121,7 +121,7 @@ private static void DecodeScalar(Span scanline, Span previousScanlin scan = (byte)(scan + (above >> 1)); } - for (; x < scanline.Length; ++x) + for (; x < (uint)scanline.Length; ++x) { ref byte scan = ref Unsafe.Add(ref scanBaseRef, x); byte left = Unsafe.Add(ref scanBaseRef, x - bytesPerPixel); @@ -153,7 +153,7 @@ public static void Encode(ReadOnlySpan scanline, ReadOnlySpan previo resultBaseRef = (byte)FilterType.Average; nint x = 0; - for (; x < bytesPerPixel; /* Note: ++x happens in the body to avoid one add operation */) + for (; x < (uint)bytesPerPixel; /* Note: ++x happens in the body to avoid one add operation */) { byte scan = Unsafe.Add(ref scanBaseRef, x); byte above = Unsafe.Add(ref prevBaseRef, x); @@ -169,7 +169,7 @@ public static void Encode(ReadOnlySpan scanline, ReadOnlySpan previo Vector256 sumAccumulator = Vector256.Zero; Vector256 allBitsSet = Avx2.CompareEqual(sumAccumulator, sumAccumulator).AsByte(); - for (nint xLeft = x - bytesPerPixel; x <= scanline.Length - Vector256.Count; xLeft += Vector256.Count) + for (nint xLeft = x - (nint)(uint)bytesPerPixel; x <= (uint)scanline.Length - Vector256.Count; xLeft += Vector256.Count) { Vector256 scan = Unsafe.As>(ref Unsafe.Add(ref scanBaseRef, x)); Vector256 left = Unsafe.As>(ref Unsafe.Add(ref scanBaseRef, xLeft)); @@ -192,7 +192,7 @@ public static void Encode(ReadOnlySpan scanline, ReadOnlySpan previo Vector128 sumAccumulator = Vector128.Zero; Vector128 allBitsSet = Sse2.CompareEqual(sumAccumulator, sumAccumulator).AsByte(); - for (nint xLeft = x - bytesPerPixel; x <= scanline.Length - Vector128.Count; xLeft += Vector128.Count) + for (nint xLeft = x - (nint)(uint)bytesPerPixel; x <= (uint)scanline.Length - Vector128.Count; xLeft += Vector128.Count) { Vector128 scan = Unsafe.As>(ref Unsafe.Add(ref scanBaseRef, x)); Vector128 left = Unsafe.As>(ref Unsafe.Add(ref scanBaseRef, xLeft)); @@ -221,7 +221,7 @@ public static void Encode(ReadOnlySpan scanline, ReadOnlySpan previo sum += Numerics.EvenReduceSum(sumAccumulator); } - for (nint xLeft = x - bytesPerPixel; x < scanline.Length; ++xLeft /* Note: ++x happens in the body to avoid one add operation */) + for (nint xLeft = x - (nint)(uint)bytesPerPixel; x < (uint)scanline.Length; ++xLeft /* Note: ++x happens in the body to avoid one add operation */) { byte scan = Unsafe.Add(ref scanBaseRef, x); byte left = Unsafe.Add(ref scanBaseRef, xLeft); diff --git a/src/ImageSharp/Formats/Png/Filters/PaethFilter.cs b/src/ImageSharp/Formats/Png/Filters/PaethFilter.cs index 8998d6bc0f..540ec63231 100644 --- a/src/ImageSharp/Formats/Png/Filters/PaethFilter.cs +++ b/src/ImageSharp/Formats/Png/Filters/PaethFilter.cs @@ -187,14 +187,14 @@ private static void DecodeScalar(Span scanline, Span previousScanlin // Paeth(x) + PaethPredictor(Raw(x-bpp), Prior(x), Prior(x-bpp)) int offset = bytesPerPixel + 1; // Add one because x starts at one. nint x = 1; - for (; x < offset; x++) + for (; x < (uint)offset; x++) { ref byte scan = ref Unsafe.Add(ref scanBaseRef, x); byte above = Unsafe.Add(ref prevBaseRef, x); scan = (byte)(scan + above); } - for (; x < scanline.Length; x++) + for (; x < (uint)scanline.Length; x++) { ref byte scan = ref Unsafe.Add(ref scanBaseRef, x); byte left = Unsafe.Add(ref scanBaseRef, x - bytesPerPixel); @@ -227,7 +227,7 @@ public static void Encode(ReadOnlySpan scanline, ReadOnlySpan previo resultBaseRef = (byte)FilterType.Paeth; nint x = 0; - for (; x < bytesPerPixel; /* Note: ++x happens in the body to avoid one add operation */) + for (; x < (uint)bytesPerPixel; /* Note: ++x happens in the body to avoid one add operation */) { byte scan = Unsafe.Add(ref scanBaseRef, x); byte above = Unsafe.Add(ref prevBaseRef, x); @@ -242,7 +242,7 @@ public static void Encode(ReadOnlySpan scanline, ReadOnlySpan previo Vector256 zero = Vector256.Zero; Vector256 sumAccumulator = Vector256.Zero; - for (nint xLeft = x - bytesPerPixel; x <= scanline.Length - Vector256.Count; xLeft += Vector256.Count) + for (nint xLeft = x - (nint)(uint)bytesPerPixel; x <= (nint)(uint)scanline.Length - Vector256.Count; xLeft += Vector256.Count) { Vector256 scan = Unsafe.As>(ref Unsafe.Add(ref scanBaseRef, x)); Vector256 left = Unsafe.As>(ref Unsafe.Add(ref scanBaseRef, xLeft)); @@ -262,7 +262,7 @@ public static void Encode(ReadOnlySpan scanline, ReadOnlySpan previo { Vector sumAccumulator = Vector.Zero; - for (nint xLeft = x - bytesPerPixel; x <= scanline.Length - Vector.Count; xLeft += Vector.Count) + for (nint xLeft = x - (nint)(uint)bytesPerPixel; x <= (nint)(uint)scanline.Length - Vector.Count; xLeft += Vector.Count) { Vector scan = Unsafe.As>(ref Unsafe.Add(ref scanBaseRef, x)); Vector left = Unsafe.As>(ref Unsafe.Add(ref scanBaseRef, xLeft)); @@ -282,7 +282,7 @@ public static void Encode(ReadOnlySpan scanline, ReadOnlySpan previo } } - for (nint xLeft = x - bytesPerPixel; x < scanline.Length; ++xLeft /* Note: ++x happens in the body to avoid one add operation */) + for (nint xLeft = x - (nint)(uint)bytesPerPixel; x < (nint)(uint)scanline.Length; ++xLeft /* Note: ++x happens in the body to avoid one add operation */) { byte scan = Unsafe.Add(ref scanBaseRef, x); byte left = Unsafe.Add(ref scanBaseRef, xLeft); diff --git a/src/ImageSharp/Formats/Png/Filters/SubFilter.cs b/src/ImageSharp/Formats/Png/Filters/SubFilter.cs index 0f4aa3fcff..5dc7b15d74 100644 --- a/src/ImageSharp/Formats/Png/Filters/SubFilter.cs +++ b/src/ImageSharp/Formats/Png/Filters/SubFilter.cs @@ -36,7 +36,7 @@ public static void Decode(Span scanline, int bytesPerPixel) } else { - DecodeScalar(scanline, bytesPerPixel); + DecodeScalar(scanline, (nint)(uint)bytesPerPixel); } } @@ -70,7 +70,7 @@ public static void DecodeArm(Span scanline) Vector64 d = Vector64.Zero; int rb = scanline.Length; - int offset = 1; + nint offset = 1; const int bytesPerBatch = 4; while (rb >= bytesPerBatch) { @@ -87,7 +87,7 @@ public static void DecodeArm(Span scanline) } } - private static void DecodeScalar(Span scanline, int bytesPerPixel) + private static void DecodeScalar(Span scanline, nint bytesPerPixel) { ref byte scanBaseRef = ref MemoryMarshal.GetReference(scanline); @@ -122,7 +122,7 @@ public static void Encode(ReadOnlySpan scanline, ReadOnlySpan result resultBaseRef = (byte)FilterType.Sub; nint x = 0; - for (; x < bytesPerPixel; /* Note: ++x happens in the body to avoid one add operation */) + for (; x < (nint)(uint)bytesPerPixel; /* Note: ++x happens in the body to avoid one add operation */) { byte scan = Unsafe.Add(ref scanBaseRef, x); ++x; @@ -136,7 +136,7 @@ public static void Encode(ReadOnlySpan scanline, ReadOnlySpan result Vector256 zero = Vector256.Zero; Vector256 sumAccumulator = Vector256.Zero; - for (nint xLeft = x - bytesPerPixel; x <= scanline.Length - Vector256.Count; xLeft += Vector256.Count) + for (nint xLeft = x - (nint)(uint)bytesPerPixel; x <= (nint)(uint)scanline.Length - Vector256.Count; xLeft += Vector256.Count) { Vector256 scan = Unsafe.As>(ref Unsafe.Add(ref scanBaseRef, x)); Vector256 prev = Unsafe.As>(ref Unsafe.Add(ref scanBaseRef, xLeft)); @@ -154,7 +154,7 @@ public static void Encode(ReadOnlySpan scanline, ReadOnlySpan result { Vector sumAccumulator = Vector.Zero; - for (nint xLeft = x - bytesPerPixel; x <= scanline.Length - Vector.Count; xLeft += Vector.Count) + for (nint xLeft = x - (nint)(uint)bytesPerPixel; x <= (nint)(uint)scanline.Length - Vector.Count; xLeft += Vector.Count) { Vector scan = Unsafe.As>(ref Unsafe.Add(ref scanBaseRef, x)); Vector prev = Unsafe.As>(ref Unsafe.Add(ref scanBaseRef, xLeft)); @@ -172,7 +172,7 @@ public static void Encode(ReadOnlySpan scanline, ReadOnlySpan result } } - for (nint xLeft = x - bytesPerPixel; x < scanline.Length; ++xLeft /* Note: ++x happens in the body to avoid one add operation */) + for (nint xLeft = x - (nint)(uint)bytesPerPixel; x < (nint)(uint)scanline.Length; ++xLeft /* Note: ++x happens in the body to avoid one add operation */) { byte scan = Unsafe.Add(ref scanBaseRef, x); byte prev = Unsafe.Add(ref scanBaseRef, xLeft); diff --git a/src/ImageSharp/Formats/Png/Filters/UpFilter.cs b/src/ImageSharp/Formats/Png/Filters/UpFilter.cs index f90b129b62..55cc9ad6eb 100644 --- a/src/ImageSharp/Formats/Png/Filters/UpFilter.cs +++ b/src/ImageSharp/Formats/Png/Filters/UpFilter.cs @@ -66,7 +66,7 @@ private static void DecodeAvx2(Span scanline, Span previousScanline) } // Handle left over. - for (nint i = offset; i < scanline.Length; i++) + for (nint i = offset; i < (uint)scanline.Length; i++) { ref byte scan = ref Unsafe.Add(ref scanBaseRef, offset); byte above = Unsafe.Add(ref prevBaseRef, offset); @@ -96,7 +96,7 @@ private static void DecodeSse2(Span scanline, Span previousScanline) } // Handle left over. - for (nint i = offset; i < scanline.Length; i++) + for (nint i = offset; i < (uint)scanline.Length; i++) { ref byte scan = ref Unsafe.Add(ref scanBaseRef, offset); byte above = Unsafe.Add(ref prevBaseRef, offset); @@ -127,7 +127,7 @@ private static void DecodeArm(Span scanline, Span previousScanline) } // Handle left over. - for (nint i = offset; i < scanline.Length; i++) + for (nint i = offset; i < (uint)scanline.Length; i++) { ref byte scan = ref Unsafe.Add(ref scanBaseRef, offset); byte above = Unsafe.Add(ref prevBaseRef, offset); @@ -143,7 +143,7 @@ private static void DecodeScalar(Span scanline, Span previousScanlin ref byte prevBaseRef = ref MemoryMarshal.GetReference(previousScanline); // Up(x) + Prior(x) - for (nint x = 1; x < scanline.Length; x++) + for (nint x = 1; x < (uint)scanline.Length; x++) { ref byte scan = ref Unsafe.Add(ref scanBaseRef, x); byte above = Unsafe.Add(ref prevBaseRef, x); @@ -179,7 +179,7 @@ public static void Encode(ReadOnlySpan scanline, ReadOnlySpan previo Vector256 zero = Vector256.Zero; Vector256 sumAccumulator = Vector256.Zero; - for (; x <= scanline.Length - Vector256.Count;) + for (; x <= (nint)(uint)(scanline.Length - Vector256.Count);) { Vector256 scan = Unsafe.As>(ref Unsafe.Add(ref scanBaseRef, x)); Vector256 above = Unsafe.As>(ref Unsafe.Add(ref prevBaseRef, x)); @@ -197,7 +197,7 @@ public static void Encode(ReadOnlySpan scanline, ReadOnlySpan previo { Vector sumAccumulator = Vector.Zero; - for (; x <= scanline.Length - Vector.Count;) + for (; x <= (nint)(uint)(scanline.Length - Vector.Count);) { Vector scan = Unsafe.As>(ref Unsafe.Add(ref scanBaseRef, x)); Vector above = Unsafe.As>(ref Unsafe.Add(ref prevBaseRef, x)); @@ -215,7 +215,7 @@ public static void Encode(ReadOnlySpan scanline, ReadOnlySpan previo } } - for (; x < scanline.Length; /* Note: ++x happens in the body to avoid one add operation */) + for (; x < (nint)(uint)scanline.Length; /* Note: ++x happens in the body to avoid one add operation */) { byte scan = Unsafe.Add(ref scanBaseRef, x); byte above = Unsafe.Add(ref prevBaseRef, x); diff --git a/src/ImageSharp/Formats/Png/PngDecoderCore.cs b/src/ImageSharp/Formats/Png/PngDecoderCore.cs index 5c74232119..ea8120a5c1 100644 --- a/src/ImageSharp/Formats/Png/PngDecoderCore.cs +++ b/src/ImageSharp/Formats/Png/PngDecoderCore.cs @@ -414,11 +414,11 @@ private bool TryScaleUpTo8BitArray(ReadOnlySpan source, int bytesPerScanli for (int i = 0; i < bytesPerScanline; i++) { - byte b = Unsafe.Add(ref sourceRef, i); + byte b = Unsafe.Add(ref sourceRef, (uint)i); for (int shift = 0; shift < 8; shift += bits) { int colorIndex = (b >> (8 - bits - shift)) & mask; - Unsafe.Add(ref resultRef, resultOffset) = (byte)colorIndex; + Unsafe.Add(ref resultRef, (uint)resultOffset) = (byte)colorIndex; resultOffset++; } } diff --git a/src/ImageSharp/Formats/Png/PngEncoderCore.cs b/src/ImageSharp/Formats/Png/PngEncoderCore.cs index 5a66fc7d4b..4657ab17bb 100644 --- a/src/ImageSharp/Formats/Png/PngEncoderCore.cs +++ b/src/ImageSharp/Formats/Png/PngEncoderCore.cs @@ -266,7 +266,7 @@ private void CollectGrayscaleBytes(ReadOnlySpan rowSpan) // Can't map directly to byte array as it's big-endian. for (int x = 0, o = 0; x < luminanceSpan.Length; x++, o += 2) { - L16 luminance = Unsafe.Add(ref luminanceRef, x); + L16 luminance = Unsafe.Add(ref luminanceRef, (uint)x); BinaryPrimitives.WriteUInt16BigEndian(rawScanlineSpan.Slice(o, 2), luminance.PackedValue); } } @@ -306,7 +306,7 @@ private void CollectGrayscaleBytes(ReadOnlySpan rowSpan) // Can't map directly to byte array as it's big endian. for (int x = 0, o = 0; x < laSpan.Length; x++, o += 4) { - La32 la = Unsafe.Add(ref laRef, x); + La32 la = Unsafe.Add(ref laRef, (uint)x); BinaryPrimitives.WriteUInt16BigEndian(rawScanlineSpan.Slice(o, 2), la.L); BinaryPrimitives.WriteUInt16BigEndian(rawScanlineSpan.Slice(o + 2, 2), la.A); } @@ -366,7 +366,7 @@ private void CollectTPixelBytes(ReadOnlySpan rowSpan) // Can't map directly to byte array as it's big endian. for (int x = 0, o = 0; x < rowSpan.Length; x++, o += 8) { - Rgba64 rgba = Unsafe.Add(ref rgbaRef, x); + Rgba64 rgba = Unsafe.Add(ref rgbaRef, (uint)x); BinaryPrimitives.WriteUInt16BigEndian(rawScanlineSpan.Slice(o, 2), rgba.R); BinaryPrimitives.WriteUInt16BigEndian(rawScanlineSpan.Slice(o + 2, 2), rgba.G); BinaryPrimitives.WriteUInt16BigEndian(rawScanlineSpan.Slice(o + 4, 2), rgba.B); @@ -388,7 +388,7 @@ private void CollectTPixelBytes(ReadOnlySpan rowSpan) // Can't map directly to byte array as it's big endian. for (int x = 0, o = 0; x < rowSpan.Length; x++, o += 6) { - Rgb48 rgb = Unsafe.Add(ref rgbRef, x); + Rgb48 rgb = Unsafe.Add(ref rgbRef, (uint)x); BinaryPrimitives.WriteUInt16BigEndian(rawScanlineSpan.Slice(o, 2), rgb.R); BinaryPrimitives.WriteUInt16BigEndian(rawScanlineSpan.Slice(o + 2, 2), rgb.G); BinaryPrimitives.WriteUInt16BigEndian(rawScanlineSpan.Slice(o + 4, 2), rgb.B); @@ -617,17 +617,17 @@ private void WritePaletteChunk(Stream stream, IndexedImageFrame // Loop, assign, and extract alpha values from the palette. for (int i = 0; i < paletteLength; i++) { - Rgba32 rgba = Unsafe.Add(ref rgbaPaletteRef, i); + Rgba32 rgba = Unsafe.Add(ref rgbaPaletteRef, (uint)i); byte alpha = rgba.A; - Unsafe.Add(ref colorTableRef, i) = rgba.Rgb; + Unsafe.Add(ref colorTableRef, (uint)i) = rgba.Rgb; if (alpha > this.encoder.Threshold) { alpha = byte.MaxValue; } hasAlpha = hasAlpha || alpha < byte.MaxValue; - Unsafe.Add(ref alphaTableRef, i) = alpha; + Unsafe.Add(ref alphaTableRef, (uint)i) = alpha; } this.WriteChunk(stream, PngChunkType.Palette, colorTable.GetSpan(), 0, colorTableLength); diff --git a/src/ImageSharp/Formats/Png/PngEncoderHelpers.cs b/src/ImageSharp/Formats/Png/PngEncoderHelpers.cs index 5bee1ebd53..712bd0e06a 100644 --- a/src/ImageSharp/Formats/Png/PngEncoderHelpers.cs +++ b/src/ImageSharp/Formats/Png/PngEncoderHelpers.cs @@ -31,13 +31,13 @@ public static void ScaleDownFrom8BitArray(ReadOnlySpan source, Span for (int i = 0; i < source.Length; i++) { - int value = ((int)MathF.Round(Unsafe.Add(ref sourceRef, i) / scale)) & mask; + int value = ((int)MathF.Round(Unsafe.Add(ref sourceRef, (uint)i) / scale)) & mask; v |= value << shift; if (shift == 0) { shift = shift0; - Unsafe.Add(ref resultRef, resultOffset) = (byte)v; + Unsafe.Add(ref resultRef, (uint)resultOffset) = (byte)v; resultOffset++; v = 0; } @@ -49,7 +49,7 @@ public static void ScaleDownFrom8BitArray(ReadOnlySpan source, Span if (shift != shift0) { - Unsafe.Add(ref resultRef, resultOffset) = (byte)v; + Unsafe.Add(ref resultRef, (uint)resultOffset) = (byte)v; } } } diff --git a/src/ImageSharp/Formats/Png/PngScanlineProcessor.cs b/src/ImageSharp/Formats/Png/PngScanlineProcessor.cs index cf77788bc0..25c4a0d700 100644 --- a/src/ImageSharp/Formats/Png/PngScanlineProcessor.cs +++ b/src/ImageSharp/Formats/Png/PngScanlineProcessor.cs @@ -36,16 +36,16 @@ public static void ProcessGrayscaleScanline( { ushort luminance = BinaryPrimitives.ReadUInt16BigEndian(scanlineSpan.Slice(o, 2)); pixel.FromL16(Unsafe.As(ref luminance)); - Unsafe.Add(ref rowSpanRef, x) = pixel; + Unsafe.Add(ref rowSpanRef, (uint)x) = pixel; } } else { for (int x = 0; x < header.Width; x++) { - byte luminance = (byte)(Unsafe.Add(ref scanlineSpanRef, x) * scaleFactor); + byte luminance = (byte)(Unsafe.Add(ref scanlineSpanRef, (uint)x) * scaleFactor); pixel.FromL8(Unsafe.As(ref luminance)); - Unsafe.Add(ref rowSpanRef, x) = pixel; + Unsafe.Add(ref rowSpanRef, (uint)x) = pixel; } } @@ -62,7 +62,7 @@ public static void ProcessGrayscaleScanline( source.A = luminance.Equals(luminance16Trans.PackedValue) ? ushort.MinValue : ushort.MaxValue; pixel.FromLa32(source); - Unsafe.Add(ref rowSpanRef, x) = pixel; + Unsafe.Add(ref rowSpanRef, (uint)x) = pixel; } } else @@ -71,12 +71,12 @@ public static void ProcessGrayscaleScanline( byte scaledLuminanceTrans = (byte)(luminanceTrans.PackedValue * scaleFactor); for (int x = 0; x < header.Width; x++) { - byte luminance = (byte)(Unsafe.Add(ref scanlineSpanRef, x) * scaleFactor); + byte luminance = (byte)(Unsafe.Add(ref scanlineSpanRef, (uint)x) * scaleFactor); source.L = luminance; source.A = luminance.Equals(scaledLuminanceTrans) ? byte.MinValue : byte.MaxValue; pixel.FromLa16(source); - Unsafe.Add(ref rowSpanRef, x) = pixel; + Unsafe.Add(ref rowSpanRef, (uint)x) = pixel; } } } @@ -105,16 +105,16 @@ public static void ProcessInterlacedGrayscaleScanline( { ushort luminance = BinaryPrimitives.ReadUInt16BigEndian(scanlineSpan.Slice(o, 2)); pixel.FromL16(Unsafe.As(ref luminance)); - Unsafe.Add(ref rowSpanRef, x) = pixel; + Unsafe.Add(ref rowSpanRef, (uint)x) = pixel; } } else { for (int x = pixelOffset, o = 0; x < header.Width; x += increment, o++) { - byte luminance = (byte)(Unsafe.Add(ref scanlineSpanRef, o) * scaleFactor); + byte luminance = (byte)(Unsafe.Add(ref scanlineSpanRef, (uint)o) * scaleFactor); pixel.FromL8(Unsafe.As(ref luminance)); - Unsafe.Add(ref rowSpanRef, x) = pixel; + Unsafe.Add(ref rowSpanRef, (uint)x) = pixel; } } @@ -131,7 +131,7 @@ public static void ProcessInterlacedGrayscaleScanline( source.A = luminance.Equals(luminance16Trans.PackedValue) ? ushort.MinValue : ushort.MaxValue; pixel.FromLa32(source); - Unsafe.Add(ref rowSpanRef, x) = pixel; + Unsafe.Add(ref rowSpanRef, (uint)x) = pixel; } } else @@ -140,12 +140,12 @@ public static void ProcessInterlacedGrayscaleScanline( byte scaledLuminanceTrans = (byte)(luminanceTrans.PackedValue * scaleFactor); for (int x = pixelOffset, o = 0; x < header.Width; x += increment, o++) { - byte luminance = (byte)(Unsafe.Add(ref scanlineSpanRef, o) * scaleFactor); + byte luminance = (byte)(Unsafe.Add(ref scanlineSpanRef, (uint)o) * scaleFactor); source.L = luminance; source.A = luminance.Equals(scaledLuminanceTrans) ? byte.MinValue : byte.MaxValue; pixel.FromLa16(source); - Unsafe.Add(ref rowSpanRef, x) = pixel; + Unsafe.Add(ref rowSpanRef, (uint)x) = pixel; } } } @@ -171,7 +171,7 @@ public static void ProcessGrayscaleWithAlphaScanline( source.A = BinaryPrimitives.ReadUInt16BigEndian(scanlineSpan.Slice(o + 2, 2)); pixel.FromLa32(source); - Unsafe.Add(ref rowSpanRef, x) = pixel; + Unsafe.Add(ref rowSpanRef, (uint)x) = pixel; } } else @@ -180,11 +180,11 @@ public static void ProcessGrayscaleWithAlphaScanline( for (int x = 0; x < header.Width; x++) { int offset = x * bytesPerPixel; - source.L = Unsafe.Add(ref scanlineSpanRef, offset); - source.A = Unsafe.Add(ref scanlineSpanRef, offset + bytesPerSample); + source.L = Unsafe.Add(ref scanlineSpanRef, (uint)offset); + source.A = Unsafe.Add(ref scanlineSpanRef, (uint)(offset + bytesPerSample)); pixel.FromLa16(source); - Unsafe.Add(ref rowSpanRef, x) = pixel; + Unsafe.Add(ref rowSpanRef, (uint)x) = pixel; } } } @@ -212,7 +212,7 @@ public static void ProcessInterlacedGrayscaleWithAlphaScanline( source.A = BinaryPrimitives.ReadUInt16BigEndian(scanlineSpan.Slice(o + 2, 2)); pixel.FromLa32(source); - Unsafe.Add(ref rowSpanRef, x) = pixel; + Unsafe.Add(ref rowSpanRef, (uint)x) = pixel; } } else @@ -221,11 +221,11 @@ public static void ProcessInterlacedGrayscaleWithAlphaScanline( La16 source = default; for (int x = pixelOffset; x < header.Width; x += increment) { - source.L = Unsafe.Add(ref scanlineSpanRef, offset); - source.A = Unsafe.Add(ref scanlineSpanRef, offset + bytesPerSample); + source.L = Unsafe.Add(ref scanlineSpanRef, (uint)offset); + source.A = Unsafe.Add(ref scanlineSpanRef, (uint)(offset + bytesPerSample)); pixel.FromLa16(source); - Unsafe.Add(ref rowSpanRef, x) = pixel; + Unsafe.Add(ref rowSpanRef, (uint)x) = pixel; offset += bytesPerPixel; } } @@ -259,23 +259,23 @@ public static void ProcessPaletteScanline( for (int x = 0; x < header.Width; x++) { - int index = Unsafe.Add(ref scanlineSpanRef, x); - rgba.Rgb = Unsafe.Add(ref palettePixelsRef, index); - rgba.A = paletteAlpha.Length > index ? Unsafe.Add(ref paletteAlphaRef, index) : byte.MaxValue; + int index = Unsafe.Add(ref scanlineSpanRef, (uint)x); + rgba.Rgb = Unsafe.Add(ref palettePixelsRef, (uint)index); + rgba.A = paletteAlpha.Length > index ? Unsafe.Add(ref paletteAlphaRef, (uint)index) : byte.MaxValue; pixel.FromRgba32(rgba); - Unsafe.Add(ref rowSpanRef, x) = pixel; + Unsafe.Add(ref rowSpanRef, (uint)x) = pixel; } } else { for (int x = 0; x < header.Width; x++) { - int index = Unsafe.Add(ref scanlineSpanRef, x); - Rgb24 rgb = Unsafe.Add(ref palettePixelsRef, index); + int index = Unsafe.Add(ref scanlineSpanRef, (uint)x); + Rgb24 rgb = Unsafe.Add(ref palettePixelsRef, (uint)index); pixel.FromRgb24(rgb); - Unsafe.Add(ref rowSpanRef, x) = pixel; + Unsafe.Add(ref rowSpanRef, (uint)x) = pixel; } } } @@ -304,23 +304,23 @@ public static void ProcessInterlacedPaletteScanline( ref byte paletteAlphaRef = ref paletteAlpha[0]; for (int x = pixelOffset, o = 0; x < header.Width; x += increment, o++) { - int index = Unsafe.Add(ref scanlineSpanRef, o); - rgba.A = paletteAlpha.Length > index ? Unsafe.Add(ref paletteAlphaRef, index) : byte.MaxValue; - rgba.Rgb = Unsafe.Add(ref palettePixelsRef, index); + int index = Unsafe.Add(ref scanlineSpanRef, (uint)o); + rgba.A = paletteAlpha.Length > index ? Unsafe.Add(ref paletteAlphaRef, (uint)index) : byte.MaxValue; + rgba.Rgb = Unsafe.Add(ref palettePixelsRef, (uint)index); pixel.FromRgba32(rgba); - Unsafe.Add(ref rowSpanRef, x) = pixel; + Unsafe.Add(ref rowSpanRef, (uint)x) = pixel; } } else { for (int x = pixelOffset, o = 0; x < header.Width; x += increment, o++) { - int index = Unsafe.Add(ref scanlineSpanRef, o); - Rgb24 rgb = Unsafe.Add(ref palettePixelsRef, index); + int index = Unsafe.Add(ref scanlineSpanRef, (uint)o); + Rgb24 rgb = Unsafe.Add(ref palettePixelsRef, (uint)index); pixel.FromRgb24(rgb); - Unsafe.Add(ref rowSpanRef, x) = pixel; + Unsafe.Add(ref rowSpanRef, (uint)x) = pixel; } } } @@ -352,7 +352,7 @@ public static void ProcessRgbScanline( rgb48.B = BinaryPrimitives.ReadUInt16BigEndian(scanlineSpan.Slice(o + (2 * bytesPerSample), bytesPerSample)); pixel.FromRgb48(rgb48); - Unsafe.Add(ref rowSpanRef, x) = pixel; + Unsafe.Add(ref rowSpanRef, (uint)x) = pixel; } } else @@ -377,7 +377,7 @@ public static void ProcessRgbScanline( rgba64.A = rgb48.Equals(rgb48Trans) ? ushort.MinValue : ushort.MaxValue; pixel.FromRgba64(rgba64); - Unsafe.Add(ref rowSpanRef, x) = pixel; + Unsafe.Add(ref rowSpanRef, (uint)x) = pixel; } } else @@ -387,12 +387,12 @@ public static void ProcessRgbScanline( ref Rgb24 rgb24SpanRef = ref MemoryMarshal.GetReference(rgb24Span); for (int x = 0; x < header.Width; x++) { - ref readonly Rgb24 rgb24 = ref Unsafe.Add(ref rgb24SpanRef, x); + ref readonly Rgb24 rgb24 = ref Unsafe.Add(ref rgb24SpanRef, (uint)x); rgba32.Rgb = rgb24; rgba32.A = rgb24.Equals(rgb24Trans) ? byte.MinValue : byte.MaxValue; pixel.FromRgba32(rgba32); - Unsafe.Add(ref rowSpanRef, x) = pixel; + Unsafe.Add(ref rowSpanRef, (uint)x) = pixel; } } } @@ -430,7 +430,7 @@ public static void ProcessInterlacedRgbScanline( rgba64.A = rgb48.Equals(rgb48Trans) ? ushort.MinValue : ushort.MaxValue; pixel.FromRgba64(rgba64); - Unsafe.Add(ref rowSpanRef, x) = pixel; + Unsafe.Add(ref rowSpanRef, (uint)x) = pixel; } } else @@ -443,7 +443,7 @@ public static void ProcessInterlacedRgbScanline( rgb48.B = BinaryPrimitives.ReadUInt16BigEndian(scanlineSpan.Slice(o + (2 * bytesPerSample), bytesPerSample)); pixel.FromRgb48(rgb48); - Unsafe.Add(ref rowSpanRef, x) = pixel; + Unsafe.Add(ref rowSpanRef, (uint)x) = pixel; } } @@ -455,13 +455,13 @@ public static void ProcessInterlacedRgbScanline( Rgba32 rgba = default; for (int x = pixelOffset, o = 0; x < header.Width; x += increment, o += bytesPerPixel) { - rgba.R = Unsafe.Add(ref scanlineSpanRef, o); - rgba.G = Unsafe.Add(ref scanlineSpanRef, o + bytesPerSample); - rgba.B = Unsafe.Add(ref scanlineSpanRef, o + (2 * bytesPerSample)); + rgba.R = Unsafe.Add(ref scanlineSpanRef, (uint)o); + rgba.G = Unsafe.Add(ref scanlineSpanRef, (uint)(o + bytesPerSample)); + rgba.B = Unsafe.Add(ref scanlineSpanRef, (uint)(o + (2 * bytesPerSample))); rgba.A = rgb24Trans.Equals(rgba.Rgb) ? byte.MinValue : byte.MaxValue; pixel.FromRgba32(rgba); - Unsafe.Add(ref rowSpanRef, x) = pixel; + Unsafe.Add(ref rowSpanRef, (uint)x) = pixel; } } else @@ -469,12 +469,12 @@ public static void ProcessInterlacedRgbScanline( Rgb24 rgb = default; for (int x = pixelOffset, o = 0; x < header.Width; x += increment, o += bytesPerPixel) { - rgb.R = Unsafe.Add(ref scanlineSpanRef, o); - rgb.G = Unsafe.Add(ref scanlineSpanRef, o + bytesPerSample); - rgb.B = Unsafe.Add(ref scanlineSpanRef, o + (2 * bytesPerSample)); + rgb.R = Unsafe.Add(ref scanlineSpanRef, (uint)o); + rgb.G = Unsafe.Add(ref scanlineSpanRef, (uint)(o + bytesPerSample)); + rgb.B = Unsafe.Add(ref scanlineSpanRef, (uint)(o + (2 * bytesPerSample))); pixel.FromRgb24(rgb); - Unsafe.Add(ref rowSpanRef, x) = pixel; + Unsafe.Add(ref rowSpanRef, (uint)x) = pixel; } } } @@ -502,7 +502,7 @@ public static void ProcessRgbaScanline( rgba64.A = BinaryPrimitives.ReadUInt16BigEndian(scanlineSpan.Slice(o + (3 * bytesPerSample), bytesPerSample)); pixel.FromRgba64(rgba64); - Unsafe.Add(ref rowSpanRef, x) = pixel; + Unsafe.Add(ref rowSpanRef, (uint)x) = pixel; } } else @@ -536,7 +536,7 @@ public static void ProcessInterlacedRgbaScanline( rgba64.A = BinaryPrimitives.ReadUInt16BigEndian(scanlineSpan.Slice(o + (3 * bytesPerSample), bytesPerSample)); pixel.FromRgba64(rgba64); - Unsafe.Add(ref rowSpanRef, x) = pixel; + Unsafe.Add(ref rowSpanRef, (uint)x) = pixel; } } else @@ -544,13 +544,13 @@ public static void ProcessInterlacedRgbaScanline( Rgba32 rgba = default; for (int x = pixelOffset, o = 0; x < header.Width; x += increment, o += bytesPerPixel) { - rgba.R = Unsafe.Add(ref scanlineSpanRef, o); - rgba.G = Unsafe.Add(ref scanlineSpanRef, o + bytesPerSample); - rgba.B = Unsafe.Add(ref scanlineSpanRef, o + (2 * bytesPerSample)); - rgba.A = Unsafe.Add(ref scanlineSpanRef, o + (3 * bytesPerSample)); + rgba.R = Unsafe.Add(ref scanlineSpanRef, (uint)o); + rgba.G = Unsafe.Add(ref scanlineSpanRef, (uint)(o + bytesPerSample)); + rgba.B = Unsafe.Add(ref scanlineSpanRef, (uint)(o + (2 * bytesPerSample))); + rgba.A = Unsafe.Add(ref scanlineSpanRef, (uint)(o + (3 * bytesPerSample))); pixel.FromRgba32(rgba); - Unsafe.Add(ref rowSpanRef, x) = pixel; + Unsafe.Add(ref rowSpanRef, (uint)x) = pixel; } } } diff --git a/src/ImageSharp/Formats/Tiff/Compression/Decompressors/T6TiffCompression.cs b/src/ImageSharp/Formats/Tiff/Compression/Decompressors/T6TiffCompression.cs index eb97272cb8..1cd8e0dc80 100644 --- a/src/ImageSharp/Formats/Tiff/Compression/Decompressors/T6TiffCompression.cs +++ b/src/ImageSharp/Formats/Tiff/Compression/Decompressors/T6TiffCompression.cs @@ -78,7 +78,7 @@ private nint WriteScanLine(Span buffer, Span scanLine, nint bitsWrit nint bitPos = Numerics.Modulo8(bitsWritten); nint bufferPos = bitsWritten / 8; ref byte scanLineRef = ref MemoryMarshal.GetReference(scanLine); - for (nint i = 0; i < scanLine.Length; i++) + for (nint i = 0; i < (uint)scanLine.Length; i++) { if (Unsafe.Add(ref scanLineRef, i) != this.white) { diff --git a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/BlackIsZero1TiffColor{TPixel}.cs b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/BlackIsZero1TiffColor{TPixel}.cs index 6187ab8faa..a5a04d19d5 100644 --- a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/BlackIsZero1TiffColor{TPixel}.cs +++ b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/BlackIsZero1TiffColor{TPixel}.cs @@ -29,7 +29,7 @@ public override void Decode(ReadOnlySpan data, Buffer2D pixels, in { Span pixelRowSpan = pixels.DangerousGetRowSpan((int)y); ref TPixel pixelRowRef = ref MemoryMarshal.GetReference(pixelRowSpan); - for (nint x = left; x < left + width; x += 8) + for (nint x = (nint)(uint)left; x < (nint)(uint)(left + width); x += 8) { byte b = Unsafe.Add(ref dataRef, offset++); nint maxShift = Math.Min(left + width - x, 8); @@ -70,9 +70,9 @@ public override void Decode(ReadOnlySpan data, Buffer2D pixels, in } else { - for (int shift = 0; shift < maxShift; shift++) + for (nint shift = 0; shift < maxShift; shift++) { - int bit = (b >> (7 - shift)) & 1; + int bit = (b >> (7 - (int)shift)) & 1; ref TPixel pixel = ref Unsafe.Add(ref pixelRowRef, x + shift); pixel = bit == 0 ? colorBlack : colorWhite; diff --git a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/WhiteIsZero1TiffColor{TPixel}.cs b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/WhiteIsZero1TiffColor{TPixel}.cs index a7519bc144..737f957676 100644 --- a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/WhiteIsZero1TiffColor{TPixel}.cs +++ b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/WhiteIsZero1TiffColor{TPixel}.cs @@ -24,11 +24,11 @@ public override void Decode(ReadOnlySpan data, Buffer2D pixels, in colorBlack.FromRgba32(Color.Black); colorWhite.FromRgba32(Color.White); ref byte dataRef = ref MemoryMarshal.GetReference(data); - for (nint y = top; y < top + height; y++) + for (nint y = top; y < (nint)(uint)(top + height); y++) { Span pixelRowSpan = pixels.DangerousGetRowSpan((int)y); ref TPixel pixelRowRef = ref MemoryMarshal.GetReference(pixelRowSpan); - for (nint x = left; x < left + width; x += 8) + for (nint x = left; x < (nint)(uint)(left + width); x += 8) { byte b = Unsafe.Add(ref dataRef, offset++); nint maxShift = Math.Min(left + width - x, 8); @@ -73,7 +73,7 @@ public override void Decode(ReadOnlySpan data, Buffer2D pixels, in { int bit = (b >> (7 - shift)) & 1; - ref TPixel pixel = ref Unsafe.Add(ref pixelRowRef, x + shift); + ref TPixel pixel = ref Unsafe.Add(ref pixelRowRef, x + (nint)(uint)shift); pixel = bit == 0 ? colorWhite : colorBlack; } } diff --git a/src/ImageSharp/Formats/Webp/AlphaDecoder.cs b/src/ImageSharp/Formats/Webp/AlphaDecoder.cs index 8875ae1150..637a38d1e4 100644 --- a/src/ImageSharp/Formats/Webp/AlphaDecoder.cs +++ b/src/ImageSharp/Formats/Webp/AlphaDecoder.cs @@ -322,7 +322,8 @@ private static void HorizontalUnfilter(Span prev, Span input, Span last = Vector128.Zero.WithElement(0, dst[0]); ref byte srcRef = ref MemoryMarshal.GetReference(input); - for (i = 1; i + 8 <= width; i += 8) + ref byte dstRef = ref MemoryMarshal.GetReference(dst); + for (i = 1; i <= (uint)width - 8; i += 8) { Vector128 a0 = Vector128.Create(Unsafe.As(ref Unsafe.Add(ref srcRef, i)), 0); Vector128 a1 = Sse2.Add(a0.AsByte(), last.AsByte()); @@ -333,12 +334,12 @@ private static void HorizontalUnfilter(Span prev, Span input, Span a6 = Sse2.ShiftLeftLogical128BitLane(a5, 4); Vector128 a7 = Sse2.Add(a5, a6); - ref byte outputRef = ref Unsafe.Add(ref MemoryMarshal.GetReference(dst), i); + ref byte outputRef = ref Unsafe.Add(ref dstRef, i); Unsafe.As>(ref outputRef) = a7.GetLower(); last = Sse2.ShiftRightLogical(a7.AsInt64(), 56).AsInt32(); } - for (; i < width; ++i) + for (; i < (uint)width; ++i) { dst[(int)i] = (byte)(input[(int)i] + dst[(int)i - 1]); } @@ -366,7 +367,7 @@ private static void VerticalUnfilter(Span prev, Span input, Span a0 = Unsafe.As>(ref Unsafe.Add(ref MemoryMarshal.GetReference(input), i)); Vector256 b0 = Unsafe.As>(ref Unsafe.Add(ref MemoryMarshal.GetReference(prev), i)); @@ -375,7 +376,7 @@ private static void VerticalUnfilter(Span prev, Span input, Span>(ref outputRef) = c0; } - for (; i < width; i++) + for (; i < (uint) width; i++) { dst[(int)i] = (byte)(prev[(int)i] + input[(int)i]); } diff --git a/src/ImageSharp/Formats/Webp/Lossless/LosslessUtils.cs b/src/ImageSharp/Formats/Webp/Lossless/LosslessUtils.cs index ac92ce6a6a..d4db3db53b 100644 --- a/src/ImageSharp/Formats/Webp/Lossless/LosslessUtils.cs +++ b/src/ImageSharp/Formats/Webp/Lossless/LosslessUtils.cs @@ -51,7 +51,7 @@ public static int VectorMismatch(ReadOnlySpan array1, ReadOnlySpan a ref uint array1Ref = ref MemoryMarshal.GetReference(array1); ref uint array2Ref = ref MemoryMarshal.GetReference(array2); - while (matchLen < length && Unsafe.Add(ref array1Ref, matchLen) == Unsafe.Add(ref array2Ref, matchLen)) + while (matchLen < length && Unsafe.Add(ref array1Ref, (uint)matchLen) == Unsafe.Add(ref array2Ref, (uint)matchLen)) { matchLen++; } @@ -99,7 +99,7 @@ public static void AddGreenToBlueAndRed(Span pixelData) Vector256 addGreenToBlueAndRedMaskAvx2 = Vector256.Create(1, 255, 1, 255, 5, 255, 5, 255, 9, 255, 9, 255, 13, 255, 13, 255, 17, 255, 17, 255, 21, 255, 21, 255, 25, 255, 25, 255, 29, 255, 29, 255); int numPixels = pixelData.Length; nint i; - for (i = 0; i <= numPixels - 8; i += 8) + for (i = 0; i <= (nint)(uint)numPixels - 8; i += 8) { ref uint pos = ref Unsafe.Add(ref MemoryMarshal.GetReference(pixelData), i); Vector256 input = Unsafe.As>(ref pos).AsByte(); @@ -118,7 +118,7 @@ public static void AddGreenToBlueAndRed(Span pixelData) Vector128 addGreenToBlueAndRedMaskSsse3 = Vector128.Create(1, 255, 1, 255, 5, 255, 5, 255, 9, 255, 9, 255, 13, 255, 13, 255); int numPixels = pixelData.Length; nint i; - for (i = 0; i <= numPixels - 4; i += 4) + for (i = 0; i <= (nint)(uint)numPixels - 4; i += 4) { ref uint pos = ref Unsafe.Add(ref MemoryMarshal.GetReference(pixelData), i); Vector128 input = Unsafe.As>(ref pos).AsByte(); @@ -136,7 +136,7 @@ public static void AddGreenToBlueAndRed(Span pixelData) { int numPixels = pixelData.Length; nint i; - for (i = 0; i <= numPixels - 4; i += 4) + for (i = 0; i <= (nint)(uint)numPixels - 4; i += 4) { ref uint pos = ref Unsafe.Add(ref MemoryMarshal.GetReference(pixelData), i); Vector128 input = Unsafe.As>(ref pos).AsByte(); @@ -179,7 +179,7 @@ public static void SubtractGreenFromBlueAndRed(Span pixelData) Vector256 subtractGreenFromBlueAndRedMaskAvx2 = Vector256.Create(1, 255, 1, 255, 5, 255, 5, 255, 9, 255, 9, 255, 13, 255, 13, 255, 17, 255, 17, 255, 21, 255, 21, 255, 25, 255, 25, 255, 29, 255, 29, 255); int numPixels = pixelData.Length; nint i; - for (i = 0; i <= numPixels - 8; i += 8) + for (i = 0; i <= (nint)(uint)numPixels - 8; i += 8) { ref uint pos = ref Unsafe.Add(ref MemoryMarshal.GetReference(pixelData), i); Vector256 input = Unsafe.As>(ref pos).AsByte(); @@ -198,7 +198,7 @@ public static void SubtractGreenFromBlueAndRed(Span pixelData) Vector128 subtractGreenFromBlueAndRedMaskSsse3 = Vector128.Create(1, 255, 1, 255, 5, 255, 5, 255, 9, 255, 9, 255, 13, 255, 13, 255); int numPixels = pixelData.Length; nint i; - for (i = 0; i <= numPixels - 4; i += 4) + for (i = 0; i <= (nint)(uint)numPixels - 4; i += 4) { ref uint pos = ref Unsafe.Add(ref MemoryMarshal.GetReference(pixelData), i); Vector128 input = Unsafe.As>(ref pos).AsByte(); @@ -216,7 +216,7 @@ public static void SubtractGreenFromBlueAndRed(Span pixelData) { int numPixels = pixelData.Length; nint i; - for (i = 0; i <= numPixels - 4; i += 4) + for (i = 0; i <= (nint)(uint)numPixels - 4; i += 4) { ref uint pos = ref Unsafe.Add(ref MemoryMarshal.GetReference(pixelData), i); Vector128 input = Unsafe.As>(ref pos).AsByte(); @@ -373,7 +373,7 @@ public static void TransformColor(Vp8LMultipliers m, Span pixelData, int n Vector256 multsb2 = MkCst32(Cst5b(m.RedToBlue), 0); nint idx; - for (idx = 0; idx <= numPixels - 8; idx += 8) + for (idx = 0; idx <= (nint)(uint)numPixels - 8; idx += 8) { ref uint pos = ref Unsafe.Add(ref MemoryMarshal.GetReference(pixelData), idx); Vector256 input = Unsafe.As>(ref pos); @@ -402,7 +402,7 @@ public static void TransformColor(Vp8LMultipliers m, Span pixelData, int n Vector128 multsrb = MkCst16(Cst5b(m.GreenToRed), Cst5b(m.GreenToBlue)); Vector128 multsb2 = MkCst16(Cst5b(m.RedToBlue), 0); nint idx; - for (idx = 0; idx <= numPixels - 4; idx += 4) + for (idx = 0; idx <= (nint)(uint)numPixels - 4; idx += 4) { ref uint pos = ref Unsafe.Add(ref MemoryMarshal.GetReference(pixelData), idx); Vector128 input = Unsafe.As>(ref pos); @@ -461,7 +461,7 @@ public static void TransformColorInverse(Vp8LMultipliers m, Span pixelData Vector256 multsrb = MkCst32(Cst5b(m.GreenToRed), Cst5b(m.GreenToBlue)); Vector256 multsb2 = MkCst32(Cst5b(m.RedToBlue), 0); nint idx; - for (idx = 0; idx <= pixelData.Length - 8; idx += 8) + for (idx = 0; idx <= (nint)(uint)pixelData.Length - 8; idx += 8) { ref uint pos = ref Unsafe.Add(ref MemoryMarshal.GetReference(pixelData), idx); Vector256 input = Unsafe.As>(ref pos); @@ -491,7 +491,7 @@ public static void TransformColorInverse(Vp8LMultipliers m, Span pixelData Vector128 multsb2 = MkCst16(Cst5b(m.RedToBlue), 0); nint idx; - for (idx = 0; idx <= pixelData.Length - 4; idx += 4) + for (idx = 0; idx <= (nint)(uint)pixelData.Length - 4; idx += 4) { ref uint pos = ref Unsafe.Add(ref MemoryMarshal.GetReference(pixelData), idx); Vector128 input = Unsafe.As>(ref pos); diff --git a/src/ImageSharp/Formats/Webp/Lossless/Vp8LHistogram.cs b/src/ImageSharp/Formats/Webp/Lossless/Vp8LHistogram.cs index a4bb2168d2..3f44a1bc05 100644 --- a/src/ImageSharp/Formats/Webp/Lossless/Vp8LHistogram.cs +++ b/src/ImageSharp/Formats/Webp/Lossless/Vp8LHistogram.cs @@ -518,28 +518,29 @@ private static void AddVector(Span a, Span b, Span output, int ref uint aRef = ref MemoryMarshal.GetReference(a); ref uint bRef = ref MemoryMarshal.GetReference(b); ref uint outputRef = ref MemoryMarshal.GetReference(output); - int i; + nint idx; - for (i = 0; i + 32 <= count; i += 32) + for (idx = 0; idx <= (nint)(uint)count - 32; idx += 32) { // Load values. - Vector256 a0 = Unsafe.As>(ref Unsafe.Add(ref aRef, i)); - Vector256 a1 = Unsafe.As>(ref Unsafe.Add(ref aRef, i + 8)); - Vector256 a2 = Unsafe.As>(ref Unsafe.Add(ref aRef, i + 16)); - Vector256 a3 = Unsafe.As>(ref Unsafe.Add(ref aRef, i + 24)); - Vector256 b0 = Unsafe.As>(ref Unsafe.Add(ref bRef, i)); - Vector256 b1 = Unsafe.As>(ref Unsafe.Add(ref bRef, i + 8)); - Vector256 b2 = Unsafe.As>(ref Unsafe.Add(ref bRef, i + 16)); - Vector256 b3 = Unsafe.As>(ref Unsafe.Add(ref bRef, i + 24)); + Vector256 a0 = Unsafe.As>(ref Unsafe.Add(ref aRef, idx)); + Vector256 a1 = Unsafe.As>(ref Unsafe.Add(ref aRef, idx + 8)); + Vector256 a2 = Unsafe.As>(ref Unsafe.Add(ref aRef, idx + 16)); + Vector256 a3 = Unsafe.As>(ref Unsafe.Add(ref aRef, idx + 24)); + Vector256 b0 = Unsafe.As>(ref Unsafe.Add(ref bRef, idx)); + Vector256 b1 = Unsafe.As>(ref Unsafe.Add(ref bRef, idx + 8)); + Vector256 b2 = Unsafe.As>(ref Unsafe.Add(ref bRef, idx + 16)); + Vector256 b3 = Unsafe.As>(ref Unsafe.Add(ref bRef, idx + 24)); // Note we are adding uint32_t's as *signed* int32's (using _mm_add_epi32). But // that's ok since the histogram values are less than 1<<28 (max picture count). - Unsafe.As>(ref Unsafe.Add(ref outputRef, i)) = Avx2.Add(a0, b0); - Unsafe.As>(ref Unsafe.Add(ref outputRef, i + 8)) = Avx2.Add(a1, b1); - Unsafe.As>(ref Unsafe.Add(ref outputRef, i + 16)) = Avx2.Add(a2, b2); - Unsafe.As>(ref Unsafe.Add(ref outputRef, i + 24)) = Avx2.Add(a3, b3); + Unsafe.As>(ref Unsafe.Add(ref outputRef, idx)) = Avx2.Add(a0, b0); + Unsafe.As>(ref Unsafe.Add(ref outputRef, idx + 8)) = Avx2.Add(a1, b1); + Unsafe.As>(ref Unsafe.Add(ref outputRef, idx + 16)) = Avx2.Add(a2, b2); + Unsafe.As>(ref Unsafe.Add(ref outputRef, idx + 24)) = Avx2.Add(a3, b3); } + int i = (int)idx; for (; i < count; i++) { output[i] = a[i] + b[i]; diff --git a/src/ImageSharp/Formats/Webp/Lossy/LossyUtils.cs b/src/ImageSharp/Formats/Webp/Lossy/LossyUtils.cs index 316c705e39..565e4c0293 100644 --- a/src/ImageSharp/Formats/Webp/Lossy/LossyUtils.cs +++ b/src/ImageSharp/Formats/Webp/Lossy/LossyUtils.cs @@ -1427,17 +1427,17 @@ public static void SimpleVFilter16(Span p, int offset, int stride, int thr if (Sse2.IsSupported) { // Load. - ref byte pRef = ref Unsafe.Add(ref MemoryMarshal.GetReference(p), offset); + ref byte pRef = ref Unsafe.Add(ref MemoryMarshal.GetReference(p), (uint)offset); Vector128 p1 = Unsafe.As>(ref Unsafe.Subtract(ref pRef, 2 * stride)); Vector128 p0 = Unsafe.As>(ref Unsafe.Subtract(ref pRef, stride)); Vector128 q0 = Unsafe.As>(ref pRef); - Vector128 q1 = Unsafe.As>(ref Unsafe.Add(ref pRef, stride)); + Vector128 q1 = Unsafe.As>(ref Unsafe.Add(ref pRef, (uint)stride)); DoFilter2Sse2(ref p1, ref p0, ref q0, ref q1, thresh); // Store. - ref byte outputRef = ref Unsafe.Add(ref MemoryMarshal.GetReference(p), offset); + ref byte outputRef = ref Unsafe.Add(ref MemoryMarshal.GetReference(p), (uint)offset); Unsafe.As>(ref Unsafe.Subtract(ref outputRef, stride)) = p0.AsSByte(); Unsafe.As>(ref outputRef) = q0.AsSByte(); } @@ -1460,11 +1460,11 @@ public static void SimpleHFilter16(Span p, int offset, int stride, int thr if (Sse2.IsSupported) { // Beginning of p1 - ref byte pRef = ref Unsafe.Add(ref MemoryMarshal.GetReference(p), offset - 2); + ref byte pRef = ref Unsafe.Add(ref MemoryMarshal.GetReference(p), (uint)(offset - 2)); - Load16x4(ref pRef, ref Unsafe.Add(ref pRef, 8 * stride), stride, out Vector128 p1, out Vector128 p0, out Vector128 q0, out Vector128 q1); + Load16x4(ref pRef, ref Unsafe.Add(ref pRef, 8 * (uint)stride), stride, out Vector128 p1, out Vector128 p0, out Vector128 q0, out Vector128 q1); DoFilter2Sse2(ref p1, ref p0, ref q0, ref q1, thresh); - Store16x4(p1, p0, q0, q1, ref pRef, ref Unsafe.Add(ref pRef, 8 * stride), stride); + Store16x4(p1, p0, q0, q1, ref pRef, ref Unsafe.Add(ref pRef, 8 * (uint)stride), stride); } else { @@ -1527,19 +1527,19 @@ public static void VFilter16(Span p, int offset, int stride, int thresh, i if (Sse2.IsSupported) { ref byte pRef = ref MemoryMarshal.GetReference(p); - Vector128 t1 = Unsafe.As>(ref Unsafe.Add(ref pRef, offset - (4 * stride))); - Vector128 p2 = Unsafe.As>(ref Unsafe.Add(ref pRef, offset - (3 * stride))); - Vector128 p1 = Unsafe.As>(ref Unsafe.Add(ref pRef, offset - (2 * stride))); - Vector128 p0 = Unsafe.As>(ref Unsafe.Add(ref pRef, offset - stride)); + Vector128 t1 = Unsafe.As>(ref Unsafe.Add(ref pRef, (uint)(offset - (4 * stride)))); + Vector128 p2 = Unsafe.As>(ref Unsafe.Add(ref pRef, (uint)(offset - (3 * stride)))); + Vector128 p1 = Unsafe.As>(ref Unsafe.Add(ref pRef, (uint)(offset - (2 * stride)))); + Vector128 p0 = Unsafe.As>(ref Unsafe.Add(ref pRef, (uint)(offset - stride))); Vector128 mask = Abs(p1, p0); mask = Sse2.Max(mask, Abs(t1, p2)); mask = Sse2.Max(mask, Abs(p2, p1)); - Vector128 q0 = Unsafe.As>(ref Unsafe.Add(ref pRef, offset)); - Vector128 q1 = Unsafe.As>(ref Unsafe.Add(ref pRef, offset + stride)); - Vector128 q2 = Unsafe.As>(ref Unsafe.Add(ref pRef, offset + (2 * stride))); - t1 = Unsafe.As>(ref Unsafe.Add(ref pRef, offset + (3 * stride))); + Vector128 q0 = Unsafe.As>(ref Unsafe.Add(ref pRef, (uint)offset)); + Vector128 q1 = Unsafe.As>(ref Unsafe.Add(ref pRef, (uint)(offset + stride))); + Vector128 q2 = Unsafe.As>(ref Unsafe.Add(ref pRef, (uint)(offset + (2 * stride)))); + t1 = Unsafe.As>(ref Unsafe.Add(ref pRef, (uint)(offset + (3 * stride)))); mask = Sse2.Max(mask, Abs(q1, q0)); mask = Sse2.Max(mask, Abs(t1, q2)); @@ -1550,12 +1550,12 @@ public static void VFilter16(Span p, int offset, int stride, int thresh, i // Store. ref byte outputRef = ref MemoryMarshal.GetReference(p); - Unsafe.As>(ref Unsafe.Add(ref outputRef, offset - (3 * stride))) = p2.AsInt32(); - Unsafe.As>(ref Unsafe.Add(ref outputRef, offset - (2 * stride))) = p1.AsInt32(); - Unsafe.As>(ref Unsafe.Add(ref outputRef, offset - stride)) = p0.AsInt32(); - Unsafe.As>(ref Unsafe.Add(ref outputRef, offset)) = q0.AsInt32(); - Unsafe.As>(ref Unsafe.Add(ref outputRef, offset + stride)) = q1.AsInt32(); - Unsafe.As>(ref Unsafe.Add(ref outputRef, offset + (2 * stride))) = q2.AsInt32(); + Unsafe.As>(ref Unsafe.Add(ref outputRef, (uint)(offset - (3 * stride)))) = p2.AsInt32(); + Unsafe.As>(ref Unsafe.Add(ref outputRef, (uint)(offset - (2 * stride)))) = p1.AsInt32(); + Unsafe.As>(ref Unsafe.Add(ref outputRef, (uint)(offset - stride))) = p0.AsInt32(); + Unsafe.As>(ref Unsafe.Add(ref outputRef, (uint)(offset))) = q0.AsInt32(); + Unsafe.As>(ref Unsafe.Add(ref outputRef, (uint)(offset + stride))) = q1.AsInt32(); + Unsafe.As>(ref Unsafe.Add(ref outputRef, (uint)(offset + (2 * stride)))) = q2.AsInt32(); } else { @@ -1569,14 +1569,14 @@ public static void HFilter16(Span p, int offset, int stride, int thresh, i if (Sse2.IsSupported) { ref byte pRef = ref MemoryMarshal.GetReference(p); - ref byte bRef = ref Unsafe.Add(ref pRef, offset - 4); - Load16x4(ref bRef, ref Unsafe.Add(ref bRef, 8 * stride), stride, out Vector128 p3, out Vector128 p2, out Vector128 p1, out Vector128 p0); + ref byte bRef = ref Unsafe.Add(ref pRef, (uint)offset - 4); + Load16x4(ref bRef, ref Unsafe.Add(ref bRef, 8 * (uint)stride), stride, out Vector128 p3, out Vector128 p2, out Vector128 p1, out Vector128 p0); Vector128 mask = Abs(p1, p0); mask = Sse2.Max(mask, Abs(p3, p2)); mask = Sse2.Max(mask, Abs(p2, p1)); - Load16x4(ref Unsafe.Add(ref pRef, offset), ref Unsafe.Add(ref pRef, offset + (8 * stride)), stride, out Vector128 q0, out Vector128 q1, out Vector128 q2, out Vector128 q3); + Load16x4(ref Unsafe.Add(ref pRef, (uint)offset), ref Unsafe.Add(ref pRef, (uint)(offset + (8 * stride))), stride, out Vector128 q0, out Vector128 q1, out Vector128 q2, out Vector128 q3); mask = Sse2.Max(mask, Abs(q1, q0)); mask = Sse2.Max(mask, Abs(q3, q2)); @@ -1585,8 +1585,8 @@ public static void HFilter16(Span p, int offset, int stride, int thresh, i ComplexMask(p1, p0, q0, q1, thresh, ithresh, ref mask); DoFilter6Sse2(ref p2, ref p1, ref p0, ref q0, ref q1, ref q2, mask, hevThresh); - Store16x4(p3, p2, p1, p0, ref bRef, ref Unsafe.Add(ref bRef, 8 * stride), stride); - Store16x4(q0, q1, q2, q3, ref Unsafe.Add(ref pRef, offset), ref Unsafe.Add(ref pRef, offset + (8 * stride)), stride); + Store16x4(p3, p2, p1, p0, ref bRef, ref Unsafe.Add(ref bRef, 8 * (uint)stride), stride); + Store16x4(q0, q1, q2, q3, ref Unsafe.Add(ref pRef, (uint)offset), ref Unsafe.Add(ref pRef, (uint)(offset + (8 * stride))), stride); } else { @@ -1599,10 +1599,10 @@ public static void VFilter16i(Span p, int offset, int stride, int thresh, if (Sse2.IsSupported) { ref byte pRef = ref MemoryMarshal.GetReference(p); - Vector128 p3 = Unsafe.As>(ref Unsafe.Add(ref pRef, offset)); - Vector128 p2 = Unsafe.As>(ref Unsafe.Add(ref pRef, offset + stride)); - Vector128 p1 = Unsafe.As>(ref Unsafe.Add(ref pRef, offset + (2 * stride))); - Vector128 p0 = Unsafe.As>(ref Unsafe.Add(ref pRef, offset + (3 * stride))); + Vector128 p3 = Unsafe.As>(ref Unsafe.Add(ref pRef, (uint)(offset))); + Vector128 p2 = Unsafe.As>(ref Unsafe.Add(ref pRef, (uint)(offset + stride))); + Vector128 p1 = Unsafe.As>(ref Unsafe.Add(ref pRef, (uint)(offset + (2 * stride)))); + Vector128 p0 = Unsafe.As>(ref Unsafe.Add(ref pRef, (uint)(offset + (3 * stride)))); for (int k = 3; k > 0; k--) { @@ -1614,10 +1614,10 @@ public static void VFilter16i(Span p, int offset, int stride, int thresh, mask = Sse2.Max(mask, Abs(p3, p2)); mask = Sse2.Max(mask, Abs(p2, p1)); - p3 = Unsafe.As>(ref Unsafe.Add(ref pRef, offset)); - p2 = Unsafe.As>(ref Unsafe.Add(ref pRef, offset + stride)); - Vector128 tmp1 = Unsafe.As>(ref Unsafe.Add(ref pRef, offset + (2 * stride))); - Vector128 tmp2 = Unsafe.As>(ref Unsafe.Add(ref pRef, offset + (3 * stride))); + p3 = Unsafe.As>(ref Unsafe.Add(ref pRef, (uint)offset)); + p2 = Unsafe.As>(ref Unsafe.Add(ref pRef, (uint)(offset + stride))); + Vector128 tmp1 = Unsafe.As>(ref Unsafe.Add(ref pRef, (uint)(offset + (2 * stride)))); + Vector128 tmp2 = Unsafe.As>(ref Unsafe.Add(ref pRef, (uint)(offset + (3 * stride)))); mask = Sse2.Max(mask, Abs(tmp1, tmp2)); mask = Sse2.Max(mask, Abs(p3, p2)); @@ -1631,9 +1631,9 @@ public static void VFilter16i(Span p, int offset, int stride, int thresh, // Store. ref byte outputRef = ref MemoryMarshal.GetReference(b); Unsafe.As>(ref outputRef) = p1.AsInt32(); - Unsafe.As>(ref Unsafe.Add(ref outputRef, stride)) = p0.AsInt32(); - Unsafe.As>(ref Unsafe.Add(ref outputRef, stride * 2)) = p3.AsInt32(); - Unsafe.As>(ref Unsafe.Add(ref outputRef, stride * 3)) = p2.AsInt32(); + Unsafe.As>(ref Unsafe.Add(ref outputRef, (uint)stride)) = p0.AsInt32(); + Unsafe.As>(ref Unsafe.Add(ref outputRef, (uint)(stride * 2))) = p3.AsInt32(); + Unsafe.As>(ref Unsafe.Add(ref outputRef, (uint)(stride * 3))) = p2.AsInt32(); // Rotate samples. p1 = tmp1; @@ -1655,13 +1655,13 @@ public static void HFilter16i(Span p, int offset, int stride, int thresh, if (Sse2.IsSupported) { ref byte pRef = ref MemoryMarshal.GetReference(p); - Load16x4(ref Unsafe.Add(ref pRef, offset), ref Unsafe.Add(ref pRef, offset + (8 * stride)), stride, out Vector128 p3, out Vector128 p2, out Vector128 p1, out Vector128 p0); + Load16x4(ref Unsafe.Add(ref pRef, (uint)offset), ref Unsafe.Add(ref pRef, (uint)(offset + (8 * stride))), stride, out Vector128 p3, out Vector128 p2, out Vector128 p1, out Vector128 p0); Vector128 mask; for (int k = 3; k > 0; k--) { // Beginning of p1. - ref byte bRef = ref Unsafe.Add(ref pRef, offset + 2); + ref byte bRef = ref Unsafe.Add(ref pRef, (uint)offset + 2); // Beginning of q0 (and next span). offset += 4; @@ -1671,7 +1671,7 @@ public static void HFilter16i(Span p, int offset, int stride, int thresh, mask = Sse2.Max(mask, Abs(p3, p2)); mask = Sse2.Max(mask, Abs(p2, p1)); - Load16x4(ref Unsafe.Add(ref pRef, offset), ref Unsafe.Add(ref pRef, offset + (8 * stride)), stride, out p3, out p2, out Vector128 tmp1, out Vector128 tmp2); + Load16x4(ref Unsafe.Add(ref pRef, (uint)offset), ref Unsafe.Add(ref pRef, (uint)(offset + (8 * stride))), stride, out p3, out p2, out Vector128 tmp1, out Vector128 tmp2); mask = Sse2.Max(mask, Abs(tmp1, tmp2)); mask = Sse2.Max(mask, Abs(p3, p2)); @@ -1680,7 +1680,7 @@ public static void HFilter16i(Span p, int offset, int stride, int thresh, ComplexMask(p1, p0, p3, p2, thresh, ithresh, ref mask); DoFilter4Sse2(ref p1, ref p0, ref p3, ref p2, mask, hevThresh); - Store16x4(p1, p0, p3, p2, ref bRef, ref Unsafe.Add(ref bRef, 8 * stride), stride); + Store16x4(p1, p0, p3, p2, ref bRef, ref Unsafe.Add(ref bRef, 8 * (uint)stride), stride); // Rotate samples. p1 = tmp1; @@ -1749,13 +1749,13 @@ public static void HFilter8(Span u, Span v, int offset, int stride, { ref byte uRef = ref MemoryMarshal.GetReference(u); ref byte vRef = ref MemoryMarshal.GetReference(v); - Load16x4(ref Unsafe.Add(ref uRef, offset - 4), ref Unsafe.Add(ref vRef, offset - 4), stride, out Vector128 p3, out Vector128 p2, out Vector128 p1, out Vector128 p0); + Load16x4(ref Unsafe.Add(ref uRef, (uint)offset - 4), ref Unsafe.Add(ref vRef, (uint)offset - 4), stride, out Vector128 p3, out Vector128 p2, out Vector128 p1, out Vector128 p0); Vector128 mask = Abs(p1, p0); mask = Sse2.Max(mask, Abs(p3, p2)); mask = Sse2.Max(mask, Abs(p2, p1)); - Load16x4(ref Unsafe.Add(ref uRef, offset), ref Unsafe.Add(ref vRef, offset), stride, out Vector128 q0, out Vector128 q1, out Vector128 q2, out Vector128 q3); + Load16x4(ref Unsafe.Add(ref uRef, (uint)offset), ref Unsafe.Add(ref vRef, (uint)offset), stride, out Vector128 q0, out Vector128 q1, out Vector128 q2, out Vector128 q3); mask = Sse2.Max(mask, Abs(q1, q0)); mask = Sse2.Max(mask, Abs(q3, q2)); @@ -1764,8 +1764,8 @@ public static void HFilter8(Span u, Span v, int offset, int stride, ComplexMask(p1, p0, q0, q1, thresh, ithresh, ref mask); DoFilter6Sse2(ref p2, ref p1, ref p0, ref q0, ref q1, ref q2, mask, hevThresh); - Store16x4(p3, p2, p1, p0, ref Unsafe.Add(ref uRef, offset - 4), ref Unsafe.Add(ref vRef, offset - 4), stride); - Store16x4(q0, q1, q2, q3, ref Unsafe.Add(ref uRef, offset), ref Unsafe.Add(ref vRef, offset), stride); + Store16x4(p3, p2, p1, p0, ref Unsafe.Add(ref uRef, (uint)offset - 4), ref Unsafe.Add(ref vRef, (uint)offset - 4), stride); + Store16x4(q0, q1, q2, q3, ref Unsafe.Add(ref uRef, (uint)offset), ref Unsafe.Add(ref vRef, (uint)offset), stride); } else { @@ -1826,7 +1826,7 @@ public static void HFilter8i(Span u, Span v, int offset, int stride, { ref byte uRef = ref MemoryMarshal.GetReference(u); ref byte vRef = ref MemoryMarshal.GetReference(v); - Load16x4(ref Unsafe.Add(ref uRef, offset), ref Unsafe.Add(ref vRef, offset), stride, out Vector128 t2, out Vector128 t1, out Vector128 p1, out Vector128 p0); + Load16x4(ref Unsafe.Add(ref uRef, (uint)offset), ref Unsafe.Add(ref vRef, (uint)offset), stride, out Vector128 t2, out Vector128 t1, out Vector128 p1, out Vector128 p0); Vector128 mask = Abs(p1, p0); mask = Sse2.Max(mask, Abs(t2, t1)); @@ -1835,7 +1835,7 @@ public static void HFilter8i(Span u, Span v, int offset, int stride, // Beginning of q0. offset += 4; - Load16x4(ref Unsafe.Add(ref uRef, offset), ref Unsafe.Add(ref vRef, offset), stride, out Vector128 q0, out Vector128 q1, out t1, out t2); + Load16x4(ref Unsafe.Add(ref uRef, (uint)offset), ref Unsafe.Add(ref vRef, (uint)offset), stride, out Vector128 q0, out Vector128 q1, out t1, out t2); mask = Sse2.Max(mask, Abs(q1, q0)); mask = Sse2.Max(mask, Abs(t2, t1)); @@ -1846,7 +1846,7 @@ public static void HFilter8i(Span u, Span v, int offset, int stride, // Beginning of p1. offset -= 2; - Store16x4(p1, p0, q0, q1, ref Unsafe.Add(ref uRef, offset), ref Unsafe.Add(ref vRef, offset), stride); + Store16x4(p1, p0, q0, q1, ref Unsafe.Add(ref uRef, (uint)offset), ref Unsafe.Add(ref vRef, (uint)offset), stride); } else { @@ -2278,8 +2278,8 @@ private static void Load16x4(ref byte r0, ref byte r8, int stride, out Vector128 // q0 = 73 63 53 43 33 23 13 03 72 62 52 42 32 22 12 02 // p0 = f1 e1 d1 c1 b1 a1 91 81 f0 e0 d0 c0 b0 a0 90 80 // q1 = f3 e3 d3 c3 b3 a3 93 83 f2 e2 d2 c2 b2 a2 92 82 - Load8x4(ref r0, stride, out Vector128 t1, out Vector128 t2); - Load8x4(ref r8, stride, out p0, out q1); + Load8x4(ref r0, (nint)(uint)stride, out Vector128 t1, out Vector128 t2); + Load8x4(ref r8, (nint)(uint)stride, out p0, out q1); // p1 = f0 e0 d0 c0 b0 a0 90 80 70 60 50 40 30 20 10 00 // p0 = f1 e1 d1 c1 b1 a1 91 81 71 61 51 41 31 21 11 01 @@ -2292,7 +2292,7 @@ private static void Load16x4(ref byte r0, ref byte r8, int stride, out Vector128 } // Reads 8 rows across a vertical edge. - private static void Load8x4(ref byte bRef, int stride, out Vector128 p, out Vector128 q) + private static void Load8x4(ref byte bRef, nint stride, out Vector128 p, out Vector128 q) { // A0 = 63 62 61 60 23 22 21 20 43 42 41 40 03 02 01 00 // A1 = 73 72 71 70 33 32 31 30 53 52 51 50 13 12 11 10 @@ -2349,10 +2349,10 @@ private static void Store16x4(Vector128 p1, Vector128 p0, Vector128< q1s = Sse2.UnpackHigh(t1.AsInt16(), q1s.AsInt16()).AsByte(); Store4x4(p0s, ref r0Ref, stride); - Store4x4(q0s, ref Unsafe.Add(ref r0Ref, 4 * stride), stride); + Store4x4(q0s, ref Unsafe.Add(ref r0Ref, 4 * (uint)stride), stride); Store4x4(p1s, ref r8Ref, stride); - Store4x4(q1s, ref Unsafe.Add(ref r8Ref, 4 * stride), stride); + Store4x4(q1s, ref Unsafe.Add(ref r8Ref, 4 * (uint)stride), stride); } private static void Store4x4(Vector128 x, ref byte dstRef, int stride) @@ -2360,7 +2360,7 @@ private static void Store4x4(Vector128 x, ref byte dstRef, int stride) int offset = 0; for (int i = 0; i < 4; i++) { - Unsafe.As(ref Unsafe.Add(ref dstRef, offset)) = Sse2.ConvertToInt32(x.AsInt32()); + Unsafe.As(ref Unsafe.Add(ref dstRef, (uint)offset)) = Sse2.ConvertToInt32(x.AsInt32()); x = Sse2.ShiftRightLogical128BitLane(x, 4); offset += stride; } @@ -2421,16 +2421,16 @@ private static void Update2Pixels(ref Vector128 pi, ref Vector128 qi [MethodImpl(InliningOptions.ShortMethod)] private static Vector128 LoadUvEdge(ref byte uRef, ref byte vRef, int offset) { - var uVec = Vector128.Create(Unsafe.As(ref Unsafe.Add(ref uRef, offset)), 0); - var vVec = Vector128.Create(Unsafe.As(ref Unsafe.Add(ref vRef, offset)), 0); + var uVec = Vector128.Create(Unsafe.As(ref Unsafe.Add(ref uRef, (uint)offset)), 0); + var vVec = Vector128.Create(Unsafe.As(ref Unsafe.Add(ref vRef, (uint)offset)), 0); return Sse2.UnpackLow(uVec, vVec).AsByte(); } [MethodImpl(InliningOptions.ShortMethod)] private static void StoreUv(Vector128 x, ref byte uRef, ref byte vRef, int offset) { - Unsafe.As>(ref Unsafe.Add(ref uRef, offset)) = x.GetLower(); - Unsafe.As>(ref Unsafe.Add(ref vRef, offset)) = x.GetUpper(); + Unsafe.As>(ref Unsafe.Add(ref uRef, (uint)offset)) = x.GetLower(); + Unsafe.As>(ref Unsafe.Add(ref vRef, (uint)offset)) = x.GetUpper(); } // Compute abs(p - q) = subs(p - q) OR subs(q - p) diff --git a/src/ImageSharp/Formats/Webp/Lossy/QuantEnc.cs b/src/ImageSharp/Formats/Webp/Lossy/QuantEnc.cs index fca0d03f23..75b92a1aaa 100644 --- a/src/ImageSharp/Formats/Webp/Lossy/QuantEnc.cs +++ b/src/ImageSharp/Formats/Webp/Lossy/QuantEnc.cs @@ -789,7 +789,7 @@ private static bool IsFlat(Span levels, int numBlocks, int thresh) { int score = 0; ref short levelsRef = ref MemoryMarshal.GetReference(levels); - int offset = 0; + nint offset = 0; while (numBlocks-- > 0) { for (nint i = 1; i < 16; i++) diff --git a/src/ImageSharp/Formats/Webp/Lossy/YuvConversion.cs b/src/ImageSharp/Formats/Webp/Lossy/YuvConversion.cs index 5c6dde6224..8ef7fe9cba 100644 --- a/src/ImageSharp/Formats/Webp/Lossy/YuvConversion.cs +++ b/src/ImageSharp/Formats/Webp/Lossy/YuvConversion.cs @@ -138,8 +138,8 @@ private static void UpSampleSse41(Span topY, Span bottomY, Span topY, Span bottomY, Span GetRowSpanCoreUnsafe(int y, int width) { ref byte b0 = ref MemoryMarshal.GetReference(this.memoryGroupSpanCache.SingleArray); ref T e0 = ref Unsafe.As(ref b0); - e0 = ref Unsafe.Add(ref e0, y * width); + e0 = ref Unsafe.Add(ref e0, (uint)(y * width)); return MemoryMarshal.CreateSpan(ref e0, width); } diff --git a/src/ImageSharp/PixelFormats/PixelBlenders/DefaultPixelBlenders.Generated.cs b/src/ImageSharp/PixelFormats/PixelBlenders/DefaultPixelBlenders.Generated.cs index 2db61a06f3..0792306760 100644 --- a/src/ImageSharp/PixelFormats/PixelBlenders/DefaultPixelBlenders.Generated.cs +++ b/src/ImageSharp/PixelFormats/PixelBlenders/DefaultPixelBlenders.Generated.cs @@ -52,7 +52,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -89,7 +89,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -157,7 +157,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -194,7 +194,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -262,7 +262,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -299,7 +299,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -367,7 +367,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -404,7 +404,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -472,7 +472,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -509,7 +509,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -577,7 +577,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -614,7 +614,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -682,7 +682,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -719,7 +719,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -787,7 +787,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -824,7 +824,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -892,7 +892,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -929,7 +929,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -997,7 +997,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -1034,7 +1034,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -1102,7 +1102,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -1139,7 +1139,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -1207,7 +1207,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -1244,7 +1244,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -1312,7 +1312,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -1349,7 +1349,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -1417,7 +1417,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -1454,7 +1454,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -1522,7 +1522,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -1559,7 +1559,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -1627,7 +1627,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -1664,7 +1664,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -1732,7 +1732,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -1769,7 +1769,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -1837,7 +1837,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -1874,7 +1874,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -1942,7 +1942,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -1979,7 +1979,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -2047,7 +2047,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -2084,7 +2084,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -2152,7 +2152,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -2189,7 +2189,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -2257,7 +2257,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -2294,7 +2294,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -2362,7 +2362,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -2399,7 +2399,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -2467,7 +2467,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -2504,7 +2504,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -2572,7 +2572,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -2609,7 +2609,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -2677,7 +2677,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -2714,7 +2714,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -2782,7 +2782,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -2819,7 +2819,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -2887,7 +2887,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -2924,7 +2924,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -2992,7 +2992,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -3029,7 +3029,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -3097,7 +3097,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -3134,7 +3134,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -3202,7 +3202,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -3239,7 +3239,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -3307,7 +3307,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -3344,7 +3344,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -3412,7 +3412,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -3449,7 +3449,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -3517,7 +3517,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -3554,7 +3554,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -3622,7 +3622,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -3659,7 +3659,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -3727,7 +3727,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -3764,7 +3764,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -3832,7 +3832,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -3869,7 +3869,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -3937,7 +3937,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -3974,7 +3974,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -4042,7 +4042,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -4079,7 +4079,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -4147,7 +4147,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -4184,7 +4184,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -4252,7 +4252,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -4289,7 +4289,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -4357,7 +4357,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -4394,7 +4394,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -4462,7 +4462,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -4499,7 +4499,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -4567,7 +4567,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -4604,7 +4604,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -4672,7 +4672,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -4709,7 +4709,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -4777,7 +4777,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -4814,7 +4814,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -4882,7 +4882,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -4919,7 +4919,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -4987,7 +4987,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -5024,7 +5024,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -5092,7 +5092,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -5129,7 +5129,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -5197,7 +5197,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -5234,7 +5234,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -5302,7 +5302,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -5339,7 +5339,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -5407,7 +5407,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -5444,7 +5444,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -5512,7 +5512,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -5549,7 +5549,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -5617,7 +5617,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -5654,7 +5654,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -5722,7 +5722,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -5759,7 +5759,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -5827,7 +5827,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -5864,7 +5864,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -5932,7 +5932,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -5969,7 +5969,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -6037,7 +6037,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -6074,7 +6074,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -6142,7 +6142,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -6179,7 +6179,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -6247,7 +6247,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -6284,7 +6284,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -6352,7 +6352,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -6389,7 +6389,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -6457,7 +6457,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -6494,7 +6494,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -6562,7 +6562,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -6599,7 +6599,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -6667,7 +6667,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -6704,7 +6704,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -6772,7 +6772,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -6809,7 +6809,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -6877,7 +6877,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -6914,7 +6914,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -6982,7 +6982,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -7019,7 +7019,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -7087,7 +7087,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -7124,7 +7124,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -7192,7 +7192,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -7229,7 +7229,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -7297,7 +7297,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -7334,7 +7334,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -7402,7 +7402,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -7439,7 +7439,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -7507,7 +7507,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -7544,7 +7544,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -7612,7 +7612,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -7649,7 +7649,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -7717,7 +7717,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -7754,7 +7754,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -7822,7 +7822,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -7859,7 +7859,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -7927,7 +7927,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -7964,7 +7964,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -8032,7 +8032,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -8069,7 +8069,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -8137,7 +8137,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -8174,7 +8174,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -8242,7 +8242,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -8279,7 +8279,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -8347,7 +8347,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -8384,7 +8384,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -8452,7 +8452,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -8489,7 +8489,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -8557,7 +8557,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -8594,7 +8594,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -8662,7 +8662,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -8699,7 +8699,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -8767,7 +8767,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -8804,7 +8804,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -8872,7 +8872,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -8909,7 +8909,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -8977,7 +8977,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -9014,7 +9014,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -9082,7 +9082,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -9119,7 +9119,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -9187,7 +9187,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -9224,7 +9224,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -9292,7 +9292,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -9329,7 +9329,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -9397,7 +9397,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -9434,7 +9434,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -9502,7 +9502,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -9539,7 +9539,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -9607,7 +9607,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -9644,7 +9644,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -9712,7 +9712,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -9749,7 +9749,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -9817,7 +9817,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -9854,7 +9854,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -9922,7 +9922,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -9959,7 +9959,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -10027,7 +10027,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -10064,7 +10064,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -10132,7 +10132,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -10169,7 +10169,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -10237,7 +10237,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -10274,7 +10274,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -10342,7 +10342,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -10379,7 +10379,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -10447,7 +10447,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -10484,7 +10484,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -10552,7 +10552,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -10589,7 +10589,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -10657,7 +10657,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -10694,7 +10694,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -10762,7 +10762,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -10799,7 +10799,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -10867,7 +10867,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -10904,7 +10904,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -10972,7 +10972,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -11009,7 +11009,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -11077,7 +11077,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -11114,7 +11114,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -11182,7 +11182,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -11219,7 +11219,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -11287,7 +11287,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -11324,7 +11324,7 @@ protected override void BlendFunction(Span destination, ReadOnlySpan ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); diff --git a/src/ImageSharp/PixelFormats/PixelBlenders/DefaultPixelBlenders.Generated.tt b/src/ImageSharp/PixelFormats/PixelBlenders/DefaultPixelBlenders.Generated.tt index 22b9ebf982..da6208eaa2 100644 --- a/src/ImageSharp/PixelFormats/PixelBlenders/DefaultPixelBlenders.Generated.tt +++ b/src/ImageSharp/PixelFormats/PixelBlenders/DefaultPixelBlenders.Generated.tt @@ -95,7 +95,7 @@ var blenders = new []{ { // Divide by 2 as 4 elements per Vector4 and 8 per Vector256 ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -132,7 +132,7 @@ var blenders = new []{ { // Divide by 2 as 4 elements per Vector4 and 8 per Vector256 ref Vector256 destinationBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (IntPtr)((uint)destination.Length / 2u)); + ref Vector256 destinationLast = ref Unsafe.Add(ref destinationBase, (uint)destination.Length / 2u); ref Vector256 backgroundBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(background)); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Abgr32.cs b/src/ImageSharp/PixelFormats/PixelImplementations/Abgr32.cs index ca68c5aaf9..4891abba8c 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/Abgr32.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/Abgr32.cs @@ -216,7 +216,7 @@ public void FromBgr24(Bgr24 source) { // We can assign the Bgr24 value directly to last three bytes of this instance. ref byte thisRef = ref Unsafe.As(ref this); - ref byte thisRefFromB = ref Unsafe.AddByteOffset(ref thisRef, new IntPtr(1)); + ref byte thisRefFromB = ref Unsafe.AddByteOffset(ref thisRef, 1); Unsafe.As(ref thisRefFromB) = source; this.A = byte.MaxValue; } diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Bgr24.cs b/src/ImageSharp/PixelFormats/PixelImplementations/Bgr24.cs index 65b36059b8..aedf4ad198 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/Bgr24.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/Bgr24.cs @@ -190,7 +190,7 @@ public void FromAbgr32(Abgr32 source) { // We can assign this instances value directly to last three bytes of the Abgr32. ref byte sourceRef = ref Unsafe.As(ref source); - ref byte sourceRefFromB = ref Unsafe.AddByteOffset(ref sourceRef, new IntPtr(1)); + ref byte sourceRefFromB = ref Unsafe.AddByteOffset(ref sourceRef, 1); this = Unsafe.As(ref sourceRefFromB); } diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Abgr32.PixelOperations.Generated.cs b/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Abgr32.PixelOperations.Generated.cs index cb67f7ffb6..9fca0cdc35 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Abgr32.PixelOperations.Generated.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Abgr32.PixelOperations.Generated.cs @@ -210,7 +210,7 @@ public override void ToL8( ref Abgr32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref L8 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < sourcePixels.Length; i++) + for (nint i = 0; i < (uint)sourcePixels.Length; i++) { ref Abgr32 sp = ref Unsafe.Add(ref sourceRef, i); ref L8 dp = ref Unsafe.Add(ref destRef, i); @@ -231,7 +231,7 @@ public override void ToL16( ref Abgr32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref L16 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < sourcePixels.Length; i++) + for (nint i = 0; i < (uint)sourcePixels.Length; i++) { ref Abgr32 sp = ref Unsafe.Add(ref sourceRef, i); ref L16 dp = ref Unsafe.Add(ref destRef, i); @@ -252,7 +252,7 @@ public override void ToLa16( ref Abgr32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref La16 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < sourcePixels.Length; i++) + for (nint i = 0; i < (uint)sourcePixels.Length; i++) { ref Abgr32 sp = ref Unsafe.Add(ref sourceRef, i); ref La16 dp = ref Unsafe.Add(ref destRef, i); @@ -273,7 +273,7 @@ public override void ToLa32( ref Abgr32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref La32 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < sourcePixels.Length; i++) + for (nint i = 0; i < (uint)sourcePixels.Length; i++) { ref Abgr32 sp = ref Unsafe.Add(ref sourceRef, i); ref La32 dp = ref Unsafe.Add(ref destRef, i); @@ -294,7 +294,7 @@ public override void ToRgb48( ref Abgr32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Rgb48 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < sourcePixels.Length; i++) + for (nint i = 0; i < (uint)sourcePixels.Length; i++) { ref Abgr32 sp = ref Unsafe.Add(ref sourceRef, i); ref Rgb48 dp = ref Unsafe.Add(ref destRef, i); @@ -315,7 +315,7 @@ public override void ToRgba64( ref Abgr32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Rgba64 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < sourcePixels.Length; i++) + for (nint i = 0; i < (uint)sourcePixels.Length; i++) { ref Abgr32 sp = ref Unsafe.Add(ref sourceRef, i); ref Rgba64 dp = ref Unsafe.Add(ref destRef, i); @@ -336,7 +336,7 @@ public override void ToBgra5551( ref Abgr32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Bgra5551 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < sourcePixels.Length; i++) + for (nint i = 0; i < (uint)sourcePixels.Length; i++) { ref Abgr32 sp = ref Unsafe.Add(ref sourceRef, i); ref Bgra5551 dp = ref Unsafe.Add(ref destRef, i); diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Argb32.PixelOperations.Generated.cs b/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Argb32.PixelOperations.Generated.cs index 5dcca2ad1e..e87926be8b 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Argb32.PixelOperations.Generated.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Argb32.PixelOperations.Generated.cs @@ -210,7 +210,7 @@ public override void ToL8( ref Argb32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref L8 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < sourcePixels.Length; i++) + for (nint i = 0; i < (uint)sourcePixels.Length; i++) { ref Argb32 sp = ref Unsafe.Add(ref sourceRef, i); ref L8 dp = ref Unsafe.Add(ref destRef, i); @@ -231,7 +231,7 @@ public override void ToL16( ref Argb32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref L16 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < sourcePixels.Length; i++) + for (nint i = 0; i < (uint)sourcePixels.Length; i++) { ref Argb32 sp = ref Unsafe.Add(ref sourceRef, i); ref L16 dp = ref Unsafe.Add(ref destRef, i); @@ -252,7 +252,7 @@ public override void ToLa16( ref Argb32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref La16 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < sourcePixels.Length; i++) + for (nint i = 0; i < (uint)sourcePixels.Length; i++) { ref Argb32 sp = ref Unsafe.Add(ref sourceRef, i); ref La16 dp = ref Unsafe.Add(ref destRef, i); @@ -273,7 +273,7 @@ public override void ToLa32( ref Argb32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref La32 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < sourcePixels.Length; i++) + for (nint i = 0; i < (uint)sourcePixels.Length; i++) { ref Argb32 sp = ref Unsafe.Add(ref sourceRef, i); ref La32 dp = ref Unsafe.Add(ref destRef, i); @@ -294,7 +294,7 @@ public override void ToRgb48( ref Argb32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Rgb48 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < sourcePixels.Length; i++) + for (nint i = 0; i < (uint)sourcePixels.Length; i++) { ref Argb32 sp = ref Unsafe.Add(ref sourceRef, i); ref Rgb48 dp = ref Unsafe.Add(ref destRef, i); @@ -315,7 +315,7 @@ public override void ToRgba64( ref Argb32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Rgba64 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < sourcePixels.Length; i++) + for (nint i = 0; i < (uint)sourcePixels.Length; i++) { ref Argb32 sp = ref Unsafe.Add(ref sourceRef, i); ref Rgba64 dp = ref Unsafe.Add(ref destRef, i); @@ -336,7 +336,7 @@ public override void ToBgra5551( ref Argb32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Bgra5551 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < sourcePixels.Length; i++) + for (nint i = 0; i < (uint)sourcePixels.Length; i++) { ref Argb32 sp = ref Unsafe.Add(ref sourceRef, i); ref Bgra5551 dp = ref Unsafe.Add(ref destRef, i); diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Bgr24.PixelOperations.Generated.cs b/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Bgr24.PixelOperations.Generated.cs index dbadb86014..32eed0ce40 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Bgr24.PixelOperations.Generated.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Bgr24.PixelOperations.Generated.cs @@ -210,7 +210,7 @@ public override void ToL8( ref Bgr24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref L8 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < sourcePixels.Length; i++) + for (nint i = 0; i < (uint)sourcePixels.Length; i++) { ref Bgr24 sp = ref Unsafe.Add(ref sourceRef, i); ref L8 dp = ref Unsafe.Add(ref destRef, i); @@ -231,7 +231,7 @@ public override void ToL16( ref Bgr24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref L16 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < sourcePixels.Length; i++) + for (nint i = 0; i < (uint)sourcePixels.Length; i++) { ref Bgr24 sp = ref Unsafe.Add(ref sourceRef, i); ref L16 dp = ref Unsafe.Add(ref destRef, i); @@ -252,7 +252,7 @@ public override void ToLa16( ref Bgr24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref La16 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < sourcePixels.Length; i++) + for (nint i = 0; i < (uint)sourcePixels.Length; i++) { ref Bgr24 sp = ref Unsafe.Add(ref sourceRef, i); ref La16 dp = ref Unsafe.Add(ref destRef, i); @@ -273,7 +273,7 @@ public override void ToLa32( ref Bgr24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref La32 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < sourcePixels.Length; i++) + for (nint i = 0; i < (uint)sourcePixels.Length; i++) { ref Bgr24 sp = ref Unsafe.Add(ref sourceRef, i); ref La32 dp = ref Unsafe.Add(ref destRef, i); @@ -294,7 +294,7 @@ public override void ToRgb48( ref Bgr24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Rgb48 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < sourcePixels.Length; i++) + for (nint i = 0; i < (uint)sourcePixels.Length; i++) { ref Bgr24 sp = ref Unsafe.Add(ref sourceRef, i); ref Rgb48 dp = ref Unsafe.Add(ref destRef, i); @@ -315,7 +315,7 @@ public override void ToRgba64( ref Bgr24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Rgba64 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < sourcePixels.Length; i++) + for (nint i = 0; i < (uint)sourcePixels.Length; i++) { ref Bgr24 sp = ref Unsafe.Add(ref sourceRef, i); ref Rgba64 dp = ref Unsafe.Add(ref destRef, i); @@ -336,7 +336,7 @@ public override void ToBgra5551( ref Bgr24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Bgra5551 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < sourcePixels.Length; i++) + for (nint i = 0; i < (uint)sourcePixels.Length; i++) { ref Bgr24 sp = ref Unsafe.Add(ref sourceRef, i); ref Bgra5551 dp = ref Unsafe.Add(ref destRef, i); diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Bgra32.PixelOperations.Generated.cs b/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Bgra32.PixelOperations.Generated.cs index b3643313c4..4e7800c624 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Bgra32.PixelOperations.Generated.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Bgra32.PixelOperations.Generated.cs @@ -210,7 +210,7 @@ public override void ToL8( ref Bgra32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref L8 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < sourcePixels.Length; i++) + for (nint i = 0; i < (uint)sourcePixels.Length; i++) { ref Bgra32 sp = ref Unsafe.Add(ref sourceRef, i); ref L8 dp = ref Unsafe.Add(ref destRef, i); @@ -231,7 +231,7 @@ public override void ToL16( ref Bgra32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref L16 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < sourcePixels.Length; i++) + for (nint i = 0; i < (uint)sourcePixels.Length; i++) { ref Bgra32 sp = ref Unsafe.Add(ref sourceRef, i); ref L16 dp = ref Unsafe.Add(ref destRef, i); @@ -252,7 +252,7 @@ public override void ToLa16( ref Bgra32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref La16 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < sourcePixels.Length; i++) + for (nint i = 0; i < (uint)sourcePixels.Length; i++) { ref Bgra32 sp = ref Unsafe.Add(ref sourceRef, i); ref La16 dp = ref Unsafe.Add(ref destRef, i); @@ -273,7 +273,7 @@ public override void ToLa32( ref Bgra32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref La32 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < sourcePixels.Length; i++) + for (nint i = 0; i < (uint)sourcePixels.Length; i++) { ref Bgra32 sp = ref Unsafe.Add(ref sourceRef, i); ref La32 dp = ref Unsafe.Add(ref destRef, i); @@ -294,7 +294,7 @@ public override void ToRgb48( ref Bgra32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Rgb48 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < sourcePixels.Length; i++) + for (nint i = 0; i < (uint)sourcePixels.Length; i++) { ref Bgra32 sp = ref Unsafe.Add(ref sourceRef, i); ref Rgb48 dp = ref Unsafe.Add(ref destRef, i); @@ -315,7 +315,7 @@ public override void ToRgba64( ref Bgra32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Rgba64 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < sourcePixels.Length; i++) + for (nint i = 0; i < (uint)sourcePixels.Length; i++) { ref Bgra32 sp = ref Unsafe.Add(ref sourceRef, i); ref Rgba64 dp = ref Unsafe.Add(ref destRef, i); @@ -336,7 +336,7 @@ public override void ToBgra5551( ref Bgra32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Bgra5551 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < sourcePixels.Length; i++) + for (nint i = 0; i < (uint)sourcePixels.Length; i++) { ref Bgra32 sp = ref Unsafe.Add(ref sourceRef, i); ref Bgra5551 dp = ref Unsafe.Add(ref destRef, i); diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Bgra5551.PixelOperations.Generated.cs b/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Bgra5551.PixelOperations.Generated.cs index 52022b0c78..62864ad209 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Bgra5551.PixelOperations.Generated.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Bgra5551.PixelOperations.Generated.cs @@ -50,7 +50,7 @@ public override void ToArgb32( ref Bgra5551 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Argb32 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < sourcePixels.Length; i++) + for (nint i = 0; i < (uint)sourcePixels.Length; i++) { ref Bgra5551 sp = ref Unsafe.Add(ref sourceRef, i); ref Argb32 dp = ref Unsafe.Add(ref destRef, i); @@ -71,7 +71,7 @@ public override void ToAbgr32( ref Bgra5551 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Abgr32 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < sourcePixels.Length; i++) + for (nint i = 0; i < (uint)sourcePixels.Length; i++) { ref Bgra5551 sp = ref Unsafe.Add(ref sourceRef, i); ref Abgr32 dp = ref Unsafe.Add(ref destRef, i); @@ -92,7 +92,7 @@ public override void ToBgr24( ref Bgra5551 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Bgr24 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < sourcePixels.Length; i++) + for (nint i = 0; i < (uint)sourcePixels.Length; i++) { ref Bgra5551 sp = ref Unsafe.Add(ref sourceRef, i); ref Bgr24 dp = ref Unsafe.Add(ref destRef, i); @@ -113,7 +113,7 @@ public override void ToBgra32( ref Bgra5551 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Bgra32 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < sourcePixels.Length; i++) + for (nint i = 0; i < (uint)sourcePixels.Length; i++) { ref Bgra5551 sp = ref Unsafe.Add(ref sourceRef, i); ref Bgra32 dp = ref Unsafe.Add(ref destRef, i); @@ -134,7 +134,7 @@ public override void ToL8( ref Bgra5551 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref L8 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < sourcePixels.Length; i++) + for (nint i = 0; i < (uint)sourcePixels.Length; i++) { ref Bgra5551 sp = ref Unsafe.Add(ref sourceRef, i); ref L8 dp = ref Unsafe.Add(ref destRef, i); @@ -155,7 +155,7 @@ public override void ToL16( ref Bgra5551 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref L16 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < sourcePixels.Length; i++) + for (nint i = 0; i < (uint)sourcePixels.Length; i++) { ref Bgra5551 sp = ref Unsafe.Add(ref sourceRef, i); ref L16 dp = ref Unsafe.Add(ref destRef, i); @@ -176,7 +176,7 @@ public override void ToLa16( ref Bgra5551 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref La16 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < sourcePixels.Length; i++) + for (nint i = 0; i < (uint)sourcePixels.Length; i++) { ref Bgra5551 sp = ref Unsafe.Add(ref sourceRef, i); ref La16 dp = ref Unsafe.Add(ref destRef, i); @@ -197,7 +197,7 @@ public override void ToLa32( ref Bgra5551 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref La32 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < sourcePixels.Length; i++) + for (nint i = 0; i < (uint)sourcePixels.Length; i++) { ref Bgra5551 sp = ref Unsafe.Add(ref sourceRef, i); ref La32 dp = ref Unsafe.Add(ref destRef, i); @@ -218,7 +218,7 @@ public override void ToRgb24( ref Bgra5551 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Rgb24 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < sourcePixels.Length; i++) + for (nint i = 0; i < (uint)sourcePixels.Length; i++) { ref Bgra5551 sp = ref Unsafe.Add(ref sourceRef, i); ref Rgb24 dp = ref Unsafe.Add(ref destRef, i); @@ -239,7 +239,7 @@ public override void ToRgba32( ref Bgra5551 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Rgba32 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < sourcePixels.Length; i++) + for (nint i = 0; i < (uint)sourcePixels.Length; i++) { ref Bgra5551 sp = ref Unsafe.Add(ref sourceRef, i); ref Rgba32 dp = ref Unsafe.Add(ref destRef, i); @@ -260,7 +260,7 @@ public override void ToRgb48( ref Bgra5551 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Rgb48 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < sourcePixels.Length; i++) + for (nint i = 0; i < (uint)sourcePixels.Length; i++) { ref Bgra5551 sp = ref Unsafe.Add(ref sourceRef, i); ref Rgb48 dp = ref Unsafe.Add(ref destRef, i); @@ -281,7 +281,7 @@ public override void ToRgba64( ref Bgra5551 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Rgba64 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < sourcePixels.Length; i++) + for (nint i = 0; i < (uint)sourcePixels.Length; i++) { ref Bgra5551 sp = ref Unsafe.Add(ref sourceRef, i); ref Rgba64 dp = ref Unsafe.Add(ref destRef, i); diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/L16.PixelOperations.Generated.cs b/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/L16.PixelOperations.Generated.cs index a1a59727ff..b37d9d86aa 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/L16.PixelOperations.Generated.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/L16.PixelOperations.Generated.cs @@ -50,7 +50,7 @@ public override void ToArgb32( ref L16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Argb32 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < sourcePixels.Length; i++) + for (nint i = 0; i < (uint)sourcePixels.Length; i++) { ref L16 sp = ref Unsafe.Add(ref sourceRef, i); ref Argb32 dp = ref Unsafe.Add(ref destRef, i); @@ -71,7 +71,7 @@ public override void ToAbgr32( ref L16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Abgr32 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < sourcePixels.Length; i++) + for (nint i = 0; i < (uint)sourcePixels.Length; i++) { ref L16 sp = ref Unsafe.Add(ref sourceRef, i); ref Abgr32 dp = ref Unsafe.Add(ref destRef, i); @@ -92,7 +92,7 @@ public override void ToBgr24( ref L16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Bgr24 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < sourcePixels.Length; i++) + for (nint i = 0; i < (uint)sourcePixels.Length; i++) { ref L16 sp = ref Unsafe.Add(ref sourceRef, i); ref Bgr24 dp = ref Unsafe.Add(ref destRef, i); @@ -113,7 +113,7 @@ public override void ToBgra32( ref L16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Bgra32 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < sourcePixels.Length; i++) + for (nint i = 0; i < (uint)sourcePixels.Length; i++) { ref L16 sp = ref Unsafe.Add(ref sourceRef, i); ref Bgra32 dp = ref Unsafe.Add(ref destRef, i); @@ -134,7 +134,7 @@ public override void ToL8( ref L16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref L8 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < sourcePixels.Length; i++) + for (nint i = 0; i < (uint)sourcePixels.Length; i++) { ref L16 sp = ref Unsafe.Add(ref sourceRef, i); ref L8 dp = ref Unsafe.Add(ref destRef, i); @@ -155,7 +155,7 @@ public override void ToLa16( ref L16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref La16 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < sourcePixels.Length; i++) + for (nint i = 0; i < (uint)sourcePixels.Length; i++) { ref L16 sp = ref Unsafe.Add(ref sourceRef, i); ref La16 dp = ref Unsafe.Add(ref destRef, i); @@ -176,7 +176,7 @@ public override void ToLa32( ref L16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref La32 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < sourcePixels.Length; i++) + for (nint i = 0; i < (uint)sourcePixels.Length; i++) { ref L16 sp = ref Unsafe.Add(ref sourceRef, i); ref La32 dp = ref Unsafe.Add(ref destRef, i); @@ -197,7 +197,7 @@ public override void ToRgb24( ref L16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Rgb24 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < sourcePixels.Length; i++) + for (nint i = 0; i < (uint)sourcePixels.Length; i++) { ref L16 sp = ref Unsafe.Add(ref sourceRef, i); ref Rgb24 dp = ref Unsafe.Add(ref destRef, i); @@ -218,7 +218,7 @@ public override void ToRgba32( ref L16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Rgba32 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < sourcePixels.Length; i++) + for (nint i = 0; i < (uint)sourcePixels.Length; i++) { ref L16 sp = ref Unsafe.Add(ref sourceRef, i); ref Rgba32 dp = ref Unsafe.Add(ref destRef, i); @@ -239,7 +239,7 @@ public override void ToRgb48( ref L16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Rgb48 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < sourcePixels.Length; i++) + for (nint i = 0; i < (uint)sourcePixels.Length; i++) { ref L16 sp = ref Unsafe.Add(ref sourceRef, i); ref Rgb48 dp = ref Unsafe.Add(ref destRef, i); @@ -260,7 +260,7 @@ public override void ToRgba64( ref L16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Rgba64 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < sourcePixels.Length; i++) + for (nint i = 0; i < (uint)sourcePixels.Length; i++) { ref L16 sp = ref Unsafe.Add(ref sourceRef, i); ref Rgba64 dp = ref Unsafe.Add(ref destRef, i); @@ -281,7 +281,7 @@ public override void ToBgra5551( ref L16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Bgra5551 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < sourcePixels.Length; i++) + for (nint i = 0; i < (uint)sourcePixels.Length; i++) { ref L16 sp = ref Unsafe.Add(ref sourceRef, i); ref Bgra5551 dp = ref Unsafe.Add(ref destRef, i); diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/L8.PixelOperations.Generated.cs b/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/L8.PixelOperations.Generated.cs index f0ada6459c..9d67d8741f 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/L8.PixelOperations.Generated.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/L8.PixelOperations.Generated.cs @@ -50,7 +50,7 @@ public override void ToArgb32( ref L8 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Argb32 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < sourcePixels.Length; i++) + for (nint i = 0; i < (uint)sourcePixels.Length; i++) { ref L8 sp = ref Unsafe.Add(ref sourceRef, i); ref Argb32 dp = ref Unsafe.Add(ref destRef, i); @@ -71,7 +71,7 @@ public override void ToAbgr32( ref L8 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Abgr32 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < sourcePixels.Length; i++) + for (nint i = 0; i < (uint)sourcePixels.Length; i++) { ref L8 sp = ref Unsafe.Add(ref sourceRef, i); ref Abgr32 dp = ref Unsafe.Add(ref destRef, i); @@ -92,7 +92,7 @@ public override void ToBgr24( ref L8 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Bgr24 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < sourcePixels.Length; i++) + for (nint i = 0; i < (uint)sourcePixels.Length; i++) { ref L8 sp = ref Unsafe.Add(ref sourceRef, i); ref Bgr24 dp = ref Unsafe.Add(ref destRef, i); @@ -113,7 +113,7 @@ public override void ToBgra32( ref L8 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Bgra32 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < sourcePixels.Length; i++) + for (nint i = 0; i < (uint)sourcePixels.Length; i++) { ref L8 sp = ref Unsafe.Add(ref sourceRef, i); ref Bgra32 dp = ref Unsafe.Add(ref destRef, i); @@ -134,7 +134,7 @@ public override void ToL16( ref L8 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref L16 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < sourcePixels.Length; i++) + for (nint i = 0; i < (uint)sourcePixels.Length; i++) { ref L8 sp = ref Unsafe.Add(ref sourceRef, i); ref L16 dp = ref Unsafe.Add(ref destRef, i); @@ -155,7 +155,7 @@ public override void ToLa16( ref L8 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref La16 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < sourcePixels.Length; i++) + for (nint i = 0; i < (uint)sourcePixels.Length; i++) { ref L8 sp = ref Unsafe.Add(ref sourceRef, i); ref La16 dp = ref Unsafe.Add(ref destRef, i); @@ -176,7 +176,7 @@ public override void ToLa32( ref L8 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref La32 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < sourcePixels.Length; i++) + for (nint i = 0; i < (uint)sourcePixels.Length; i++) { ref L8 sp = ref Unsafe.Add(ref sourceRef, i); ref La32 dp = ref Unsafe.Add(ref destRef, i); @@ -197,7 +197,7 @@ public override void ToRgb24( ref L8 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Rgb24 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < sourcePixels.Length; i++) + for (nint i = 0; i < (uint)sourcePixels.Length; i++) { ref L8 sp = ref Unsafe.Add(ref sourceRef, i); ref Rgb24 dp = ref Unsafe.Add(ref destRef, i); @@ -218,7 +218,7 @@ public override void ToRgba32( ref L8 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Rgba32 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < sourcePixels.Length; i++) + for (nint i = 0; i < (uint)sourcePixels.Length; i++) { ref L8 sp = ref Unsafe.Add(ref sourceRef, i); ref Rgba32 dp = ref Unsafe.Add(ref destRef, i); @@ -239,7 +239,7 @@ public override void ToRgb48( ref L8 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Rgb48 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < sourcePixels.Length; i++) + for (nint i = 0; i < (uint)sourcePixels.Length; i++) { ref L8 sp = ref Unsafe.Add(ref sourceRef, i); ref Rgb48 dp = ref Unsafe.Add(ref destRef, i); @@ -260,7 +260,7 @@ public override void ToRgba64( ref L8 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Rgba64 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < sourcePixels.Length; i++) + for (nint i = 0; i < (uint)sourcePixels.Length; i++) { ref L8 sp = ref Unsafe.Add(ref sourceRef, i); ref Rgba64 dp = ref Unsafe.Add(ref destRef, i); @@ -281,7 +281,7 @@ public override void ToBgra5551( ref L8 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Bgra5551 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < sourcePixels.Length; i++) + for (nint i = 0; i < (uint)sourcePixels.Length; i++) { ref L8 sp = ref Unsafe.Add(ref sourceRef, i); ref Bgra5551 dp = ref Unsafe.Add(ref destRef, i); diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/La16.PixelOperations.Generated.cs b/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/La16.PixelOperations.Generated.cs index d0610037d5..5afea82021 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/La16.PixelOperations.Generated.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/La16.PixelOperations.Generated.cs @@ -50,7 +50,7 @@ public override void ToArgb32( ref La16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Argb32 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < sourcePixels.Length; i++) + for (nint i = 0; i < (uint)sourcePixels.Length; i++) { ref La16 sp = ref Unsafe.Add(ref sourceRef, i); ref Argb32 dp = ref Unsafe.Add(ref destRef, i); @@ -71,7 +71,7 @@ public override void ToAbgr32( ref La16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Abgr32 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < sourcePixels.Length; i++) + for (nint i = 0; i < (uint)sourcePixels.Length; i++) { ref La16 sp = ref Unsafe.Add(ref sourceRef, i); ref Abgr32 dp = ref Unsafe.Add(ref destRef, i); @@ -92,7 +92,7 @@ public override void ToBgr24( ref La16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Bgr24 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < sourcePixels.Length; i++) + for (nint i = 0; i < (uint)sourcePixels.Length; i++) { ref La16 sp = ref Unsafe.Add(ref sourceRef, i); ref Bgr24 dp = ref Unsafe.Add(ref destRef, i); diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Rgb24.PixelOperations.Generated.cs b/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Rgb24.PixelOperations.Generated.cs index fd1cfd74de..519f1a6936 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Rgb24.PixelOperations.Generated.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Rgb24.PixelOperations.Generated.cs @@ -210,7 +210,7 @@ public override void ToL8( ref Rgb24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref L8 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < sourcePixels.Length; i++) + for (nint i = 0; i < (uint)sourcePixels.Length; i++) { ref Rgb24 sp = ref Unsafe.Add(ref sourceRef, i); ref L8 dp = ref Unsafe.Add(ref destRef, i); @@ -231,7 +231,7 @@ public override void ToL16( ref Rgb24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref L16 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < sourcePixels.Length; i++) + for (nint i = 0; i < (uint)sourcePixels.Length; i++) { ref Rgb24 sp = ref Unsafe.Add(ref sourceRef, i); ref L16 dp = ref Unsafe.Add(ref destRef, i); @@ -252,7 +252,7 @@ public override void ToLa16( ref Rgb24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref La16 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < sourcePixels.Length; i++) + for (nint i = 0; i < (uint)sourcePixels.Length; i++) { ref Rgb24 sp = ref Unsafe.Add(ref sourceRef, i); ref La16 dp = ref Unsafe.Add(ref destRef, i); @@ -273,7 +273,7 @@ public override void ToLa32( ref Rgb24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref La32 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < sourcePixels.Length; i++) + for (nint i = 0; i < (uint)sourcePixels.Length; i++) { ref Rgb24 sp = ref Unsafe.Add(ref sourceRef, i); ref La32 dp = ref Unsafe.Add(ref destRef, i); @@ -294,7 +294,7 @@ public override void ToRgb48( ref Rgb24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Rgb48 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < sourcePixels.Length; i++) + for (nint i = 0; i < (uint)sourcePixels.Length; i++) { ref Rgb24 sp = ref Unsafe.Add(ref sourceRef, i); ref Rgb48 dp = ref Unsafe.Add(ref destRef, i); @@ -315,7 +315,7 @@ public override void ToRgba64( ref Rgb24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Rgba64 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < sourcePixels.Length; i++) + for (nint i = 0; i < (uint)sourcePixels.Length; i++) { ref Rgb24 sp = ref Unsafe.Add(ref sourceRef, i); ref Rgba64 dp = ref Unsafe.Add(ref destRef, i); @@ -336,7 +336,7 @@ public override void ToBgra5551( ref Rgb24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Bgra5551 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < sourcePixels.Length; i++) + for (nint i = 0; i < (uint)sourcePixels.Length; i++) { ref Rgb24 sp = ref Unsafe.Add(ref sourceRef, i); ref Bgra5551 dp = ref Unsafe.Add(ref destRef, i); diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Rgb48.PixelOperations.Generated.cs b/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Rgb48.PixelOperations.Generated.cs index 417ed34334..e58818deac 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Rgb48.PixelOperations.Generated.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Rgb48.PixelOperations.Generated.cs @@ -50,7 +50,7 @@ public override void ToArgb32( ref Rgb48 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Argb32 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < sourcePixels.Length; i++) + for (nint i = 0; i < (uint)sourcePixels.Length; i++) { ref Rgb48 sp = ref Unsafe.Add(ref sourceRef, i); ref Argb32 dp = ref Unsafe.Add(ref destRef, i); @@ -71,7 +71,7 @@ public override void ToAbgr32( ref Rgb48 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Abgr32 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < sourcePixels.Length; i++) + for (nint i = 0; i < (uint)sourcePixels.Length; i++) { ref Rgb48 sp = ref Unsafe.Add(ref sourceRef, i); ref Abgr32 dp = ref Unsafe.Add(ref destRef, i); @@ -92,7 +92,7 @@ public override void ToBgr24( ref Rgb48 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Bgr24 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < sourcePixels.Length; i++) + for (nint i = 0; i < (uint)sourcePixels.Length; i++) { ref Rgb48 sp = ref Unsafe.Add(ref sourceRef, i); ref Bgr24 dp = ref Unsafe.Add(ref destRef, i); @@ -113,7 +113,7 @@ public override void ToBgra32( ref Rgb48 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Bgra32 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < sourcePixels.Length; i++) + for (nint i = 0; i < (uint)sourcePixels.Length; i++) { ref Rgb48 sp = ref Unsafe.Add(ref sourceRef, i); ref Bgra32 dp = ref Unsafe.Add(ref destRef, i); @@ -134,7 +134,7 @@ public override void ToL8( ref Rgb48 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref L8 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < sourcePixels.Length; i++) + for (nint i = 0; i < (uint)sourcePixels.Length; i++) { ref Rgb48 sp = ref Unsafe.Add(ref sourceRef, i); ref L8 dp = ref Unsafe.Add(ref destRef, i); @@ -155,7 +155,7 @@ public override void ToL16( ref Rgb48 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref L16 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < sourcePixels.Length; i++) + for (nint i = 0; i < (uint)sourcePixels.Length; i++) { ref Rgb48 sp = ref Unsafe.Add(ref sourceRef, i); ref L16 dp = ref Unsafe.Add(ref destRef, i); @@ -176,7 +176,7 @@ public override void ToLa16( ref Rgb48 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref La16 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < sourcePixels.Length; i++) + for (nint i = 0; i < (uint)sourcePixels.Length; i++) { ref Rgb48 sp = ref Unsafe.Add(ref sourceRef, i); ref La16 dp = ref Unsafe.Add(ref destRef, i); @@ -197,7 +197,7 @@ public override void ToLa32( ref Rgb48 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref La32 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < sourcePixels.Length; i++) + for (nint i = 0; i < (uint)sourcePixels.Length; i++) { ref Rgb48 sp = ref Unsafe.Add(ref sourceRef, i); ref La32 dp = ref Unsafe.Add(ref destRef, i); @@ -218,7 +218,7 @@ public override void ToRgb24( ref Rgb48 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Rgb24 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < sourcePixels.Length; i++) + for (nint i = 0; i < (uint)sourcePixels.Length; i++) { ref Rgb48 sp = ref Unsafe.Add(ref sourceRef, i); ref Rgb24 dp = ref Unsafe.Add(ref destRef, i); @@ -239,7 +239,7 @@ public override void ToRgba32( ref Rgb48 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Rgba32 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < sourcePixels.Length; i++) + for (nint i = 0; i < (uint)sourcePixels.Length; i++) { ref Rgb48 sp = ref Unsafe.Add(ref sourceRef, i); ref Rgba32 dp = ref Unsafe.Add(ref destRef, i); @@ -260,7 +260,7 @@ public override void ToRgba64( ref Rgb48 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Rgba64 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < sourcePixels.Length; i++) + for (nint i = 0; i < (uint)sourcePixels.Length; i++) { ref Rgb48 sp = ref Unsafe.Add(ref sourceRef, i); ref Rgba64 dp = ref Unsafe.Add(ref destRef, i); @@ -281,7 +281,7 @@ public override void ToBgra5551( ref Rgb48 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Bgra5551 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < sourcePixels.Length; i++) + for (nint i = 0; i < (uint)sourcePixels.Length; i++) { ref Rgb48 sp = ref Unsafe.Add(ref sourceRef, i); ref Bgra5551 dp = ref Unsafe.Add(ref destRef, i); diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/_Common.ttinclude b/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/_Common.ttinclude index ab08bfa570..5a5d135db1 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/_Common.ttinclude +++ b/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/_Common.ttinclude @@ -103,7 +103,7 @@ using SixLabors.ImageSharp.PixelFormats.Utils; ref <#=fromPixelType#> sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref <#=toPixelType#> destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < sourcePixels.Length; i++) + for (nint i = 0; i < (uint)sourcePixels.Length; i++) { ref <#=fromPixelType#> sp = ref Unsafe.Add(ref sourceRef, i); ref <#=toPixelType#> dp = ref Unsafe.Add(ref destRef, i); diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/RgbaVector.PixelOperations.cs b/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/RgbaVector.PixelOperations.cs index 3fcb4bc610..ed1d3cb2bd 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/RgbaVector.PixelOperations.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/RgbaVector.PixelOperations.cs @@ -72,7 +72,7 @@ public override void ToL8( ref Vector4 sourceBaseRef = ref Unsafe.As(ref MemoryMarshal.GetReference(sourcePixels)); ref L8 destBaseRef = ref MemoryMarshal.GetReference(destinationPixels); - for (int i = 0; i < sourcePixels.Length; i++) + for (nint i = 0; i < (uint)sourcePixels.Length; i++) { ref Vector4 sp = ref Unsafe.Add(ref sourceBaseRef, i); ref L8 dp = ref Unsafe.Add(ref destBaseRef, i); @@ -91,7 +91,7 @@ public override void ToL16( ref Vector4 sourceBaseRef = ref Unsafe.As(ref MemoryMarshal.GetReference(sourcePixels)); ref L16 destBaseRef = ref MemoryMarshal.GetReference(destinationPixels); - for (int i = 0; i < sourcePixels.Length; i++) + for (nint i = 0; i < (uint)sourcePixels.Length; i++) { ref Vector4 sp = ref Unsafe.Add(ref sourceBaseRef, i); ref L16 dp = ref Unsafe.Add(ref destBaseRef, i); diff --git a/src/ImageSharp/PixelFormats/PixelOperations{TPixel}.Generated.cs b/src/ImageSharp/PixelFormats/PixelOperations{TPixel}.Generated.cs index a4c2fb7a0c..26ca4d1b5a 100644 --- a/src/ImageSharp/PixelFormats/PixelOperations{TPixel}.Generated.cs +++ b/src/ImageSharp/PixelFormats/PixelOperations{TPixel}.Generated.cs @@ -22,7 +22,7 @@ public virtual void FromArgb32(Configuration configuration, ReadOnlySpan ref Argb32 sourceBaseRef = ref MemoryMarshal.GetReference(source); ref TPixel destBaseRef = ref MemoryMarshal.GetReference(destinationPixels); - for (int i = 0; i < source.Length; i++) + for (nint i = 0; i < (uint)source.Length; i++) { ref Argb32 sp = ref Unsafe.Add(ref sourceBaseRef, i); ref TPixel dp = ref Unsafe.Add(ref destBaseRef, i); @@ -58,7 +58,7 @@ public virtual void ToArgb32(Configuration configuration, ReadOnlySpan s ref TPixel sourceBaseRef = ref MemoryMarshal.GetReference(sourcePixels); ref Argb32 destBaseRef = ref MemoryMarshal.GetReference(destinationPixels); - for (int i = 0; i < sourcePixels.Length; i++) + for (nint i = 0; i < (uint)sourcePixels.Length; i++) { ref TPixel sp = ref Unsafe.Add(ref sourceBaseRef, i); ref Argb32 dp = ref Unsafe.Add(ref destBaseRef, i); @@ -94,7 +94,7 @@ public virtual void FromAbgr32(Configuration configuration, ReadOnlySpan ref Abgr32 sourceBaseRef = ref MemoryMarshal.GetReference(source); ref TPixel destBaseRef = ref MemoryMarshal.GetReference(destinationPixels); - for (int i = 0; i < source.Length; i++) + for (nint i = 0; i < (uint)source.Length; i++) { ref Abgr32 sp = ref Unsafe.Add(ref sourceBaseRef, i); ref TPixel dp = ref Unsafe.Add(ref destBaseRef, i); @@ -130,7 +130,7 @@ public virtual void ToAbgr32(Configuration configuration, ReadOnlySpan s ref TPixel sourceBaseRef = ref MemoryMarshal.GetReference(sourcePixels); ref Abgr32 destBaseRef = ref MemoryMarshal.GetReference(destinationPixels); - for (int i = 0; i < sourcePixels.Length; i++) + for (nint i = 0; i < (uint)sourcePixels.Length; i++) { ref TPixel sp = ref Unsafe.Add(ref sourceBaseRef, i); ref Abgr32 dp = ref Unsafe.Add(ref destBaseRef, i); @@ -166,7 +166,7 @@ public virtual void FromBgr24(Configuration configuration, ReadOnlySpan s ref Bgr24 sourceBaseRef = ref MemoryMarshal.GetReference(source); ref TPixel destBaseRef = ref MemoryMarshal.GetReference(destinationPixels); - for (int i = 0; i < source.Length; i++) + for (nint i = 0; i < (uint)source.Length; i++) { ref Bgr24 sp = ref Unsafe.Add(ref sourceBaseRef, i); ref TPixel dp = ref Unsafe.Add(ref destBaseRef, i); @@ -202,7 +202,7 @@ public virtual void ToBgr24(Configuration configuration, ReadOnlySpan so ref TPixel sourceBaseRef = ref MemoryMarshal.GetReference(sourcePixels); ref Bgr24 destBaseRef = ref MemoryMarshal.GetReference(destinationPixels); - for (int i = 0; i < sourcePixels.Length; i++) + for (nint i = 0; i < (uint)sourcePixels.Length; i++) { ref TPixel sp = ref Unsafe.Add(ref sourceBaseRef, i); ref Bgr24 dp = ref Unsafe.Add(ref destBaseRef, i); @@ -238,7 +238,7 @@ public virtual void FromBgra32(Configuration configuration, ReadOnlySpan ref Bgra32 sourceBaseRef = ref MemoryMarshal.GetReference(source); ref TPixel destBaseRef = ref MemoryMarshal.GetReference(destinationPixels); - for (int i = 0; i < source.Length; i++) + for (nint i = 0; i < (uint)source.Length; i++) { ref Bgra32 sp = ref Unsafe.Add(ref sourceBaseRef, i); ref TPixel dp = ref Unsafe.Add(ref destBaseRef, i); @@ -274,7 +274,7 @@ public virtual void ToBgra32(Configuration configuration, ReadOnlySpan s ref TPixel sourceBaseRef = ref MemoryMarshal.GetReference(sourcePixels); ref Bgra32 destBaseRef = ref MemoryMarshal.GetReference(destinationPixels); - for (int i = 0; i < sourcePixels.Length; i++) + for (nint i = 0; i < (uint)sourcePixels.Length; i++) { ref TPixel sp = ref Unsafe.Add(ref sourceBaseRef, i); ref Bgra32 dp = ref Unsafe.Add(ref destBaseRef, i); @@ -310,7 +310,7 @@ public virtual void FromL8(Configuration configuration, ReadOnlySpan source, ref L8 sourceBaseRef = ref MemoryMarshal.GetReference(source); ref TPixel destBaseRef = ref MemoryMarshal.GetReference(destinationPixels); - for (int i = 0; i < source.Length; i++) + for (nint i = 0; i < (uint)source.Length; i++) { ref L8 sp = ref Unsafe.Add(ref sourceBaseRef, i); ref TPixel dp = ref Unsafe.Add(ref destBaseRef, i); @@ -346,7 +346,7 @@ public virtual void ToL8(Configuration configuration, ReadOnlySpan sourc ref TPixel sourceBaseRef = ref MemoryMarshal.GetReference(sourcePixels); ref L8 destBaseRef = ref MemoryMarshal.GetReference(destinationPixels); - for (int i = 0; i < sourcePixels.Length; i++) + for (nint i = 0; i < (uint)sourcePixels.Length; i++) { ref TPixel sp = ref Unsafe.Add(ref sourceBaseRef, i); ref L8 dp = ref Unsafe.Add(ref destBaseRef, i); @@ -382,7 +382,7 @@ public virtual void FromL16(Configuration configuration, ReadOnlySpan sourc ref L16 sourceBaseRef = ref MemoryMarshal.GetReference(source); ref TPixel destBaseRef = ref MemoryMarshal.GetReference(destinationPixels); - for (int i = 0; i < source.Length; i++) + for (nint i = 0; i < (uint)source.Length; i++) { ref L16 sp = ref Unsafe.Add(ref sourceBaseRef, i); ref TPixel dp = ref Unsafe.Add(ref destBaseRef, i); @@ -418,7 +418,7 @@ public virtual void ToL16(Configuration configuration, ReadOnlySpan sour ref TPixel sourceBaseRef = ref MemoryMarshal.GetReference(sourcePixels); ref L16 destBaseRef = ref MemoryMarshal.GetReference(destinationPixels); - for (int i = 0; i < sourcePixels.Length; i++) + for (nint i = 0; i < (uint)sourcePixels.Length; i++) { ref TPixel sp = ref Unsafe.Add(ref sourceBaseRef, i); ref L16 dp = ref Unsafe.Add(ref destBaseRef, i); @@ -454,7 +454,7 @@ public virtual void FromLa16(Configuration configuration, ReadOnlySpan sou ref La16 sourceBaseRef = ref MemoryMarshal.GetReference(source); ref TPixel destBaseRef = ref MemoryMarshal.GetReference(destinationPixels); - for (int i = 0; i < source.Length; i++) + for (nint i = 0; i < (uint)source.Length; i++) { ref La16 sp = ref Unsafe.Add(ref sourceBaseRef, i); ref TPixel dp = ref Unsafe.Add(ref destBaseRef, i); @@ -490,7 +490,7 @@ public virtual void ToLa16(Configuration configuration, ReadOnlySpan sou ref TPixel sourceBaseRef = ref MemoryMarshal.GetReference(sourcePixels); ref La16 destBaseRef = ref MemoryMarshal.GetReference(destinationPixels); - for (int i = 0; i < sourcePixels.Length; i++) + for (nint i = 0; i < (uint)sourcePixels.Length; i++) { ref TPixel sp = ref Unsafe.Add(ref sourceBaseRef, i); ref La16 dp = ref Unsafe.Add(ref destBaseRef, i); @@ -526,7 +526,7 @@ public virtual void FromLa32(Configuration configuration, ReadOnlySpan sou ref La32 sourceBaseRef = ref MemoryMarshal.GetReference(source); ref TPixel destBaseRef = ref MemoryMarshal.GetReference(destinationPixels); - for (int i = 0; i < source.Length; i++) + for (nint i = 0; i < (uint)source.Length; i++) { ref La32 sp = ref Unsafe.Add(ref sourceBaseRef, i); ref TPixel dp = ref Unsafe.Add(ref destBaseRef, i); @@ -562,7 +562,7 @@ public virtual void ToLa32(Configuration configuration, ReadOnlySpan sou ref TPixel sourceBaseRef = ref MemoryMarshal.GetReference(sourcePixels); ref La32 destBaseRef = ref MemoryMarshal.GetReference(destinationPixels); - for (int i = 0; i < sourcePixels.Length; i++) + for (nint i = 0; i < (uint)sourcePixels.Length; i++) { ref TPixel sp = ref Unsafe.Add(ref sourceBaseRef, i); ref La32 dp = ref Unsafe.Add(ref destBaseRef, i); @@ -598,7 +598,7 @@ public virtual void FromRgb24(Configuration configuration, ReadOnlySpan s ref Rgb24 sourceBaseRef = ref MemoryMarshal.GetReference(source); ref TPixel destBaseRef = ref MemoryMarshal.GetReference(destinationPixels); - for (int i = 0; i < source.Length; i++) + for (nint i = 0; i < (uint)source.Length; i++) { ref Rgb24 sp = ref Unsafe.Add(ref sourceBaseRef, i); ref TPixel dp = ref Unsafe.Add(ref destBaseRef, i); @@ -634,7 +634,7 @@ public virtual void ToRgb24(Configuration configuration, ReadOnlySpan so ref TPixel sourceBaseRef = ref MemoryMarshal.GetReference(sourcePixels); ref Rgb24 destBaseRef = ref MemoryMarshal.GetReference(destinationPixels); - for (int i = 0; i < sourcePixels.Length; i++) + for (nint i = 0; i < (uint)sourcePixels.Length; i++) { ref TPixel sp = ref Unsafe.Add(ref sourceBaseRef, i); ref Rgb24 dp = ref Unsafe.Add(ref destBaseRef, i); @@ -670,7 +670,7 @@ public virtual void FromRgba32(Configuration configuration, ReadOnlySpan ref Rgba32 sourceBaseRef = ref MemoryMarshal.GetReference(source); ref TPixel destBaseRef = ref MemoryMarshal.GetReference(destinationPixels); - for (int i = 0; i < source.Length; i++) + for (nint i = 0; i < (uint)source.Length; i++) { ref Rgba32 sp = ref Unsafe.Add(ref sourceBaseRef, i); ref TPixel dp = ref Unsafe.Add(ref destBaseRef, i); @@ -706,7 +706,7 @@ public virtual void ToRgba32(Configuration configuration, ReadOnlySpan s ref TPixel sourceBaseRef = ref MemoryMarshal.GetReference(sourcePixels); ref Rgba32 destBaseRef = ref MemoryMarshal.GetReference(destinationPixels); - for (int i = 0; i < sourcePixels.Length; i++) + for (nint i = 0; i < (uint)sourcePixels.Length; i++) { ref TPixel sp = ref Unsafe.Add(ref sourceBaseRef, i); ref Rgba32 dp = ref Unsafe.Add(ref destBaseRef, i); @@ -742,7 +742,7 @@ public virtual void FromRgb48(Configuration configuration, ReadOnlySpan s ref Rgb48 sourceBaseRef = ref MemoryMarshal.GetReference(source); ref TPixel destBaseRef = ref MemoryMarshal.GetReference(destinationPixels); - for (int i = 0; i < source.Length; i++) + for (nint i = 0; i < (uint)source.Length; i++) { ref Rgb48 sp = ref Unsafe.Add(ref sourceBaseRef, i); ref TPixel dp = ref Unsafe.Add(ref destBaseRef, i); @@ -778,7 +778,7 @@ public virtual void ToRgb48(Configuration configuration, ReadOnlySpan so ref TPixel sourceBaseRef = ref MemoryMarshal.GetReference(sourcePixels); ref Rgb48 destBaseRef = ref MemoryMarshal.GetReference(destinationPixels); - for (int i = 0; i < sourcePixels.Length; i++) + for (nint i = 0; i < (uint)sourcePixels.Length; i++) { ref TPixel sp = ref Unsafe.Add(ref sourceBaseRef, i); ref Rgb48 dp = ref Unsafe.Add(ref destBaseRef, i); @@ -814,7 +814,7 @@ public virtual void FromRgba64(Configuration configuration, ReadOnlySpan ref Rgba64 sourceBaseRef = ref MemoryMarshal.GetReference(source); ref TPixel destBaseRef = ref MemoryMarshal.GetReference(destinationPixels); - for (int i = 0; i < source.Length; i++) + for (nint i = 0; i < (uint)source.Length; i++) { ref Rgba64 sp = ref Unsafe.Add(ref sourceBaseRef, i); ref TPixel dp = ref Unsafe.Add(ref destBaseRef, i); @@ -850,7 +850,7 @@ public virtual void ToRgba64(Configuration configuration, ReadOnlySpan s ref TPixel sourceBaseRef = ref MemoryMarshal.GetReference(sourcePixels); ref Rgba64 destBaseRef = ref MemoryMarshal.GetReference(destinationPixels); - for (int i = 0; i < sourcePixels.Length; i++) + for (nint i = 0; i < (uint)sourcePixels.Length; i++) { ref TPixel sp = ref Unsafe.Add(ref sourceBaseRef, i); ref Rgba64 dp = ref Unsafe.Add(ref destBaseRef, i); @@ -886,7 +886,7 @@ public virtual void FromBgra5551(Configuration configuration, ReadOnlySpan ref TPixel sourceBaseRef = ref MemoryMarshal.GetReference(sourcePixels); ref Bgra5551 destBaseRef = ref MemoryMarshal.GetReference(destinationPixels); - for (int i = 0; i < sourcePixels.Length; i++) + for (nint i = 0; i < (uint)sourcePixels.Length; i++) { ref TPixel sp = ref Unsafe.Add(ref sourceBaseRef, i); ref Bgra5551 dp = ref Unsafe.Add(ref destBaseRef, i); diff --git a/src/ImageSharp/PixelFormats/PixelOperations{TPixel}.Generated.tt b/src/ImageSharp/PixelFormats/PixelOperations{TPixel}.Generated.tt index 31bd0ce6d0..39cf873bfd 100644 --- a/src/ImageSharp/PixelFormats/PixelOperations{TPixel}.Generated.tt +++ b/src/ImageSharp/PixelFormats/PixelOperations{TPixel}.Generated.tt @@ -28,7 +28,7 @@ ref <#=pixelType#> sourceBaseRef = ref MemoryMarshal.GetReference(source); ref TPixel destBaseRef = ref MemoryMarshal.GetReference(destinationPixels); - for (int i = 0; i < source.Length; i++) + for (nint i = 0; i < (uint)source.Length; i++) { ref <#=pixelType#> sp = ref Unsafe.Add(ref sourceBaseRef, i); ref TPixel dp = ref Unsafe.Add(ref destBaseRef, i); @@ -70,7 +70,7 @@ ref TPixel sourceBaseRef = ref MemoryMarshal.GetReference(sourcePixels); ref <#=pixelType#> destBaseRef = ref MemoryMarshal.GetReference(destinationPixels); - for (int i = 0; i < sourcePixels.Length; i++) + for (nint i = 0; i < (uint)sourcePixels.Length; i++) { ref TPixel sp = ref Unsafe.Add(ref sourceBaseRef, i); ref <#=pixelType#> dp = ref Unsafe.Add(ref destBaseRef, i); diff --git a/src/ImageSharp/PixelFormats/PixelOperations{TPixel}.cs b/src/ImageSharp/PixelFormats/PixelOperations{TPixel}.cs index 2465493f58..b18e38f4d5 100644 --- a/src/ImageSharp/PixelFormats/PixelOperations{TPixel}.cs +++ b/src/ImageSharp/PixelFormats/PixelOperations{TPixel}.cs @@ -187,7 +187,7 @@ internal virtual void PackFromRgbPlanes( ref byte b = ref MemoryMarshal.GetReference(blueChannel); ref TPixel d = ref MemoryMarshal.GetReference(destination); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { rgb24.R = Unsafe.Add(ref r, i); rgb24.G = Unsafe.Add(ref g, i); @@ -218,7 +218,7 @@ internal virtual void UnpackIntoRgbPlanes( ref float g = ref MemoryMarshal.GetReference(greenChannel); ref float b = ref MemoryMarshal.GetReference(blueChannel); ref TPixel src = ref MemoryMarshal.GetReference(source); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { Unsafe.Add(ref src, i).ToRgba32(ref rgba32); Unsafe.Add(ref r, i) = rgba32.R; diff --git a/src/ImageSharp/PixelFormats/Utils/Vector4Converters.Default.cs b/src/ImageSharp/PixelFormats/Utils/Vector4Converters.Default.cs index 251f8d64db..4d07a8a9b6 100644 --- a/src/ImageSharp/PixelFormats/Utils/Vector4Converters.Default.cs +++ b/src/ImageSharp/PixelFormats/Utils/Vector4Converters.Default.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors. +// Copyright (c) Six Labors. // Licensed under the Six Labors Split License. using System.Numerics; @@ -88,7 +88,7 @@ private static void UnsafeFromVector4Core( where TPixel : unmanaged, IPixel { ref Vector4 sourceStart = ref MemoryMarshal.GetReference(sourceVectors); - ref Vector4 sourceEnd = ref Unsafe.Add(ref sourceStart, sourceVectors.Length); + ref Vector4 sourceEnd = ref Unsafe.Add(ref sourceStart, (uint)sourceVectors.Length); ref TPixel destRef = ref MemoryMarshal.GetReference(destPixels); while (Unsafe.IsAddressLessThan(ref sourceStart, ref sourceEnd)) @@ -107,7 +107,7 @@ private static void UnsafeToVector4Core( where TPixel : unmanaged, IPixel { ref TPixel sourceStart = ref MemoryMarshal.GetReference(sourcePixels); - ref TPixel sourceEnd = ref Unsafe.Add(ref sourceStart, sourcePixels.Length); + ref TPixel sourceEnd = ref Unsafe.Add(ref sourceStart, (uint)sourcePixels.Length); ref Vector4 destRef = ref MemoryMarshal.GetReference(destVectors); while (Unsafe.IsAddressLessThan(ref sourceStart, ref sourceEnd)) @@ -126,7 +126,7 @@ private static void UnsafeFromScaledVector4Core( where TPixel : unmanaged, IPixel { ref Vector4 sourceStart = ref MemoryMarshal.GetReference(sourceVectors); - ref Vector4 sourceEnd = ref Unsafe.Add(ref sourceStart, sourceVectors.Length); + ref Vector4 sourceEnd = ref Unsafe.Add(ref sourceStart, (uint)sourceVectors.Length); ref TPixel destRef = ref MemoryMarshal.GetReference(destinationColors); while (Unsafe.IsAddressLessThan(ref sourceStart, ref sourceEnd)) @@ -145,7 +145,7 @@ private static void UnsafeToScaledVector4Core( where TPixel : unmanaged, IPixel { ref TPixel sourceStart = ref MemoryMarshal.GetReference(sourceColors); - ref TPixel sourceEnd = ref Unsafe.Add(ref sourceStart, sourceColors.Length); + ref TPixel sourceEnd = ref Unsafe.Add(ref sourceStart, (uint)sourceColors.Length); ref Vector4 destRef = ref MemoryMarshal.GetReference(destinationVectors); while (Unsafe.IsAddressLessThan(ref sourceStart, ref sourceEnd)) diff --git a/src/ImageSharp/Processing/Processors/Convolution/BokehBlurProcessor.cs b/src/ImageSharp/Processing/Processors/Convolution/BokehBlurProcessor.cs index 0ceb5bc130..04653bd6ec 100644 --- a/src/ImageSharp/Processing/Processors/Convolution/BokehBlurProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Convolution/BokehBlurProcessor.cs @@ -128,19 +128,19 @@ public void Invoke(int y) int boundsWidth = this.bounds.Width; int kernelSize = this.kernel.Length; - ref int sampleRowBase = ref Unsafe.Add(ref MemoryMarshal.GetReference(this.map.GetRowOffsetSpan()), (y - this.bounds.Y) * kernelSize); + ref int sampleRowBase = ref Unsafe.Add(ref MemoryMarshal.GetReference(this.map.GetRowOffsetSpan()), (uint)((y - this.bounds.Y) * kernelSize)); // The target buffer is zeroed initially and then it accumulates the results // of each partial convolution, so we don't have to clear it here as well ref Vector4 targetBase = ref this.targetValues.GetElementUnsafe(boundsX, y); ref Complex64 kernelStart = ref this.kernel[0]; - ref Complex64 kernelEnd = ref Unsafe.Add(ref kernelStart, kernelSize); + ref Complex64 kernelEnd = ref Unsafe.Add(ref kernelStart, (uint)kernelSize); while (Unsafe.IsAddressLessThan(ref kernelStart, ref kernelEnd)) { // Get the precalculated source sample row for this kernel row and copy to our buffer ref ComplexVector4 sourceBase = ref this.sourceValues.GetElementUnsafe(0, sampleRowBase); - ref ComplexVector4 sourceEnd = ref Unsafe.Add(ref sourceBase, boundsWidth); + ref ComplexVector4 sourceEnd = ref Unsafe.Add(ref sourceBase, (uint)boundsWidth); ref Vector4 targetStart = ref targetBase; Complex64 factor = kernelStart; diff --git a/src/ImageSharp/Processing/Processors/Convolution/BokehBlurProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Convolution/BokehBlurProcessor{TPixel}.cs index 55c03abe6a..2508a7da25 100644 --- a/src/ImageSharp/Processing/Processors/Convolution/BokehBlurProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Convolution/BokehBlurProcessor{TPixel}.cs @@ -157,8 +157,8 @@ private void OnFrameApplyCore( for (int i = 0; i < this.kernels.Length; i++) { // Compute the resulting complex buffer for the current component - Complex64[] kernel = Unsafe.Add(ref baseRef, i); - Vector4 parameters = Unsafe.Add(ref paramsRef, i); + Complex64[] kernel = Unsafe.Add(ref baseRef, (uint)i); + Vector4 parameters = Unsafe.Add(ref paramsRef, (uint)i); // Horizontal convolution var horizontalOperation = new FirstPassConvolutionRowOperation( @@ -243,9 +243,9 @@ public void Invoke(int y, Span span) ref Vector4 sourceBase = ref MemoryMarshal.GetReference(span); ref ComplexVector4 targetStart = ref MemoryMarshal.GetReference(targetBuffer); - ref ComplexVector4 targetEnd = ref Unsafe.Add(ref targetStart, span.Length); + ref ComplexVector4 targetEnd = ref Unsafe.Add(ref targetStart, (uint)span.Length); ref Complex64 kernelBase = ref this.kernel[0]; - ref Complex64 kernelEnd = ref Unsafe.Add(ref kernelBase, kernelSize); + ref Complex64 kernelEnd = ref Unsafe.Add(ref kernelBase, (uint)kernelSize); ref int sampleColumnBase = ref MemoryMarshal.GetReference(this.map.GetColumnOffsetSpan()); while (Unsafe.IsAddressLessThan(ref targetStart, ref targetEnd)) @@ -255,7 +255,7 @@ public void Invoke(int y, Span span) while (Unsafe.IsAddressLessThan(ref kernelStart, ref kernelEnd)) { - Vector4 sample = Unsafe.Add(ref sourceBase, sampleColumnStart - boundsX); + Vector4 sample = Unsafe.Add(ref sourceBase, (uint)(sampleColumnStart - boundsX)); targetStart.Sum(kernelStart * sample); @@ -265,7 +265,7 @@ public void Invoke(int y, Span span) // Shift the base column sampling reference by one row at the end of each outer // iteration so that the inner tight loop indexing can skip the multiplication - sampleColumnBase = ref Unsafe.Add(ref sampleColumnBase, kernelSize); + sampleColumnBase = ref Unsafe.Add(ref sampleColumnBase, (uint)kernelSize); targetStart = ref Unsafe.Add(ref targetStart, 1); } } @@ -309,7 +309,7 @@ public void Invoke(int y, Span span) for (int x = 0; x < this.bounds.Width; x++) { - ref Vector4 v = ref Unsafe.Add(ref baseRef, x); + ref Vector4 v = ref Unsafe.Add(ref baseRef, (uint)x); v.X = MathF.Pow(v.X, this.gamma); v.Y = MathF.Pow(v.Y, this.gamma); v.Z = MathF.Pow(v.Z, this.gamma); @@ -399,7 +399,7 @@ public void Invoke(int y) for (int x = 0; x < this.bounds.Width; x++) { - ref Vector4 v = ref Unsafe.Add(ref sourceRef, x); + ref Vector4 v = ref Unsafe.Add(ref sourceRef, (uint)x); Vector4 clamp = Numerics.Clamp(v, low, high); v.X = MathF.Pow(clamp.X, this.inverseGamma); v.Y = MathF.Pow(clamp.Y, this.inverseGamma); diff --git a/src/ImageSharp/Processing/Processors/Convolution/Convolution2DRowOperation{TPixel}.cs b/src/ImageSharp/Processing/Processors/Convolution/Convolution2DRowOperation{TPixel}.cs index e5963bd390..91fc3a1b1d 100644 --- a/src/ImageSharp/Processing/Processors/Convolution/Convolution2DRowOperation{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Convolution/Convolution2DRowOperation{TPixel}.cs @@ -90,7 +90,7 @@ private void Convolve3(int y, Span span) for (int kY = 0; kY < kernelY.Rows; kY++) { // Get the precalculated source sample row for this kernel row and copy to our buffer. - int sampleY = Unsafe.Add(ref sampleRowBase, kY); + int sampleY = Unsafe.Add(ref sampleRowBase, (uint)kY); sourceRow = this.sourcePixels.DangerousGetRowSpan(sampleY).Slice(boundsX, boundsWidth); PixelOperations.Instance.ToVector4(this.configuration, sourceRow, sourceBuffer); @@ -99,13 +99,13 @@ private void Convolve3(int y, Span span) for (int x = 0; x < sourceBuffer.Length; x++) { ref int sampleColumnBase = ref state.GetSampleColumn(x); - ref Vector4 targetY = ref Unsafe.Add(ref targetBaseY, x); - ref Vector4 targetX = ref Unsafe.Add(ref targetBaseX, x); + ref Vector4 targetY = ref Unsafe.Add(ref targetBaseY, (uint)x); + ref Vector4 targetX = ref Unsafe.Add(ref targetBaseX, (uint)x); for (int kX = 0; kX < kernelY.Columns; kX++) { - int sampleX = Unsafe.Add(ref sampleColumnBase, kX) - boundsX; - Vector4 sample = Unsafe.Add(ref sourceBase, sampleX); + int sampleX = Unsafe.Add(ref sampleColumnBase, (uint)kX) - boundsX; + Vector4 sample = Unsafe.Add(ref sourceBase, (uint)sampleX); targetY += kernelX[kY, kX] * sample; targetX += kernelY[kY, kX] * sample; } @@ -119,12 +119,12 @@ private void Convolve3(int y, Span span) for (int x = 0; x < sourceRow.Length; x++) { - ref Vector4 target = ref Unsafe.Add(ref targetBaseY, x); + ref Vector4 target = ref Unsafe.Add(ref targetBaseY, (uint)x); Vector4 vectorY = target; - Vector4 vectorX = Unsafe.Add(ref targetBaseX, x); + Vector4 vectorX = Unsafe.Add(ref targetBaseX, (uint)x); target = Vector4.SquareRoot((vectorX * vectorX) + (vectorY * vectorY)); - target.W = Unsafe.Add(ref MemoryMarshal.GetReference(sourceBuffer), x).W; + target.W = Unsafe.Add(ref MemoryMarshal.GetReference(sourceBuffer), (uint)x).W; } Span targetRowSpan = this.targetPixels.DangerousGetRowSpan(y).Slice(boundsX, boundsWidth); @@ -155,7 +155,7 @@ private void Convolve4(int y, Span span) for (int kY = 0; kY < kernelY.Rows; kY++) { // Get the precalculated source sample row for this kernel row and copy to our buffer. - int sampleY = Unsafe.Add(ref sampleRowBase, kY); + int sampleY = Unsafe.Add(ref sampleRowBase, (uint)kY); Span sourceRow = this.sourcePixels.DangerousGetRowSpan(sampleY).Slice(boundsX, boundsWidth); PixelOperations.Instance.ToVector4(this.configuration, sourceRow, sourceBuffer); @@ -165,13 +165,13 @@ private void Convolve4(int y, Span span) for (int x = 0; x < sourceBuffer.Length; x++) { ref int sampleColumnBase = ref state.GetSampleColumn(x); - ref Vector4 targetY = ref Unsafe.Add(ref targetBaseY, x); - ref Vector4 targetX = ref Unsafe.Add(ref targetBaseX, x); + ref Vector4 targetY = ref Unsafe.Add(ref targetBaseY, (uint)x); + ref Vector4 targetX = ref Unsafe.Add(ref targetBaseX, (uint)x); for (int kX = 0; kX < kernelY.Columns; kX++) { - int sampleX = Unsafe.Add(ref sampleColumnBase, kX) - boundsX; - Vector4 sample = Unsafe.Add(ref sourceBase, sampleX); + int sampleX = Unsafe.Add(ref sampleColumnBase, (uint)kX) - boundsX; + Vector4 sample = Unsafe.Add(ref sourceBase, (uint)sampleX); targetY += kernelX[kY, kX] * sample; targetX += kernelY[kY, kX] * sample; } @@ -181,9 +181,9 @@ private void Convolve4(int y, Span span) // Now we need to combine the values for (int x = 0; x < targetYBuffer.Length; x++) { - ref Vector4 target = ref Unsafe.Add(ref targetBaseY, x); + ref Vector4 target = ref Unsafe.Add(ref targetBaseY, (uint)x); Vector4 vectorY = target; - Vector4 vectorX = Unsafe.Add(ref targetBaseX, x); + Vector4 vectorX = Unsafe.Add(ref targetBaseX, (uint)x); target = Vector4.SquareRoot((vectorX * vectorX) + (vectorY * vectorY)); } diff --git a/src/ImageSharp/Processing/Processors/Convolution/Convolution2DState.cs b/src/ImageSharp/Processing/Processors/Convolution/Convolution2DState.cs index 6052934d89..88d955ab71 100644 --- a/src/ImageSharp/Processing/Processors/Convolution/Convolution2DState.cs +++ b/src/ImageSharp/Processing/Processors/Convolution/Convolution2DState.cs @@ -44,9 +44,9 @@ public readonly ReadOnlyKernel KernelX [MethodImpl(MethodImplOptions.AggressiveInlining)] public readonly ref int GetSampleRow(int row) - => ref Unsafe.Add(ref MemoryMarshal.GetReference(this.rowOffsetMap), row * this.kernelHeight); + => ref Unsafe.Add(ref MemoryMarshal.GetReference(this.rowOffsetMap), (uint)(row * this.kernelHeight)); [MethodImpl(MethodImplOptions.AggressiveInlining)] public readonly ref int GetSampleColumn(int column) - => ref Unsafe.Add(ref MemoryMarshal.GetReference(this.columnOffsetMap), column * this.kernelWidth); + => ref Unsafe.Add(ref MemoryMarshal.GetReference(this.columnOffsetMap), (uint)(column * this.kernelWidth)); } diff --git a/src/ImageSharp/Processing/Processors/Convolution/Convolution2PassProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Convolution/Convolution2PassProcessor{TPixel}.cs index 094a96f787..b09db9fa05 100644 --- a/src/ImageSharp/Processing/Processors/Convolution/Convolution2PassProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Convolution/Convolution2PassProcessor{TPixel}.cs @@ -178,9 +178,9 @@ private void Convolve3(int y, Span span) ref Vector4 sourceBase = ref MemoryMarshal.GetReference(sourceBuffer); ref Vector4 targetStart = ref MemoryMarshal.GetReference(targetBuffer); - ref Vector4 targetEnd = ref Unsafe.Add(ref targetStart, sourceBuffer.Length); + ref Vector4 targetEnd = ref Unsafe.Add(ref targetStart, (uint)sourceBuffer.Length); ref float kernelBase = ref this.kernel[0]; - ref float kernelEnd = ref Unsafe.Add(ref kernelBase, kernelSize); + ref float kernelEnd = ref Unsafe.Add(ref kernelBase, (uint)kernelSize); ref int sampleColumnBase = ref MemoryMarshal.GetReference(this.map.GetColumnOffsetSpan()); while (Unsafe.IsAddressLessThan(ref targetStart, ref targetEnd)) @@ -190,7 +190,7 @@ private void Convolve3(int y, Span span) while (Unsafe.IsAddressLessThan(ref kernelStart, ref kernelEnd)) { - Vector4 sample = Unsafe.Add(ref sourceBase, sampleColumnStart - boundsX); + Vector4 sample = Unsafe.Add(ref sourceBase, (uint)(sampleColumnStart - boundsX)); targetStart += kernelStart * sample; @@ -199,7 +199,7 @@ private void Convolve3(int y, Span span) } targetStart = ref Unsafe.Add(ref targetStart, 1); - sampleColumnBase = ref Unsafe.Add(ref sampleColumnBase, kernelSize); + sampleColumnBase = ref Unsafe.Add(ref sampleColumnBase, (uint)kernelSize); } // Now we need to copy the original alpha values from the source row. @@ -242,9 +242,9 @@ private void Convolve4(int y, Span span) ref Vector4 sourceBase = ref MemoryMarshal.GetReference(sourceBuffer); ref Vector4 targetStart = ref MemoryMarshal.GetReference(targetBuffer); - ref Vector4 targetEnd = ref Unsafe.Add(ref targetStart, sourceBuffer.Length); + ref Vector4 targetEnd = ref Unsafe.Add(ref targetStart, (uint)sourceBuffer.Length); ref float kernelBase = ref this.kernel[0]; - ref float kernelEnd = ref Unsafe.Add(ref kernelBase, kernelSize); + ref float kernelEnd = ref Unsafe.Add(ref kernelBase, (uint)kernelSize); ref int sampleColumnBase = ref MemoryMarshal.GetReference(this.map.GetColumnOffsetSpan()); while (Unsafe.IsAddressLessThan(ref targetStart, ref targetEnd)) @@ -254,7 +254,7 @@ private void Convolve4(int y, Span span) while (Unsafe.IsAddressLessThan(ref kernelStart, ref kernelEnd)) { - Vector4 sample = Unsafe.Add(ref sourceBase, sampleColumnStart - boundsX); + Vector4 sample = Unsafe.Add(ref sourceBase, (uint)(sampleColumnStart - boundsX)); targetStart += kernelStart * sample; @@ -263,7 +263,7 @@ private void Convolve4(int y, Span span) } targetStart = ref Unsafe.Add(ref targetStart, 1); - sampleColumnBase = ref Unsafe.Add(ref sampleColumnBase, kernelSize); + sampleColumnBase = ref Unsafe.Add(ref sampleColumnBase, (uint)kernelSize); } Numerics.UnPremultiply(targetBuffer); @@ -335,14 +335,14 @@ private void Convolve3(int y, Span span) Span sourceBuffer = span[..this.bounds.Width]; Span targetBuffer = span[this.bounds.Width..]; - ref int sampleRowBase = ref Unsafe.Add(ref MemoryMarshal.GetReference(this.map.GetRowOffsetSpan()), (y - this.bounds.Y) * kernelSize); + ref int sampleRowBase = ref Unsafe.Add(ref MemoryMarshal.GetReference(this.map.GetRowOffsetSpan()), (uint)((y - this.bounds.Y) * kernelSize)); // Clear the target buffer for each row run. targetBuffer.Clear(); ref Vector4 targetBase = ref MemoryMarshal.GetReference(targetBuffer); ref float kernelStart = ref this.kernel[0]; - ref float kernelEnd = ref Unsafe.Add(ref kernelStart, kernelSize); + ref float kernelEnd = ref Unsafe.Add(ref kernelStart, (uint)kernelSize); Span sourceRow; while (Unsafe.IsAddressLessThan(ref kernelStart, ref kernelEnd)) @@ -353,7 +353,7 @@ private void Convolve3(int y, Span span) PixelOperations.Instance.ToVector4(this.configuration, sourceRow, sourceBuffer); ref Vector4 sourceBase = ref MemoryMarshal.GetReference(sourceBuffer); - ref Vector4 sourceEnd = ref Unsafe.Add(ref sourceBase, sourceBuffer.Length); + ref Vector4 sourceEnd = ref Unsafe.Add(ref sourceBase, (uint)sourceBuffer.Length); ref Vector4 targetStart = ref targetBase; float factor = kernelStart; @@ -374,7 +374,7 @@ private void Convolve3(int y, Span span) PixelOperations.Instance.ToVector4(this.configuration, sourceRow, sourceBuffer); { ref Vector4 sourceBase = ref MemoryMarshal.GetReference(sourceBuffer); - ref Vector4 sourceEnd = ref Unsafe.Add(ref sourceBase, sourceBuffer.Length); + ref Vector4 sourceEnd = ref Unsafe.Add(ref sourceBase, (uint)sourceBuffer.Length); while (Unsafe.IsAddressLessThan(ref sourceBase, ref sourceEnd)) { @@ -400,14 +400,14 @@ private void Convolve4(int y, Span span) Span sourceBuffer = span[..this.bounds.Width]; Span targetBuffer = span[this.bounds.Width..]; - ref int sampleRowBase = ref Unsafe.Add(ref MemoryMarshal.GetReference(this.map.GetRowOffsetSpan()), (y - this.bounds.Y) * kernelSize); + ref int sampleRowBase = ref Unsafe.Add(ref MemoryMarshal.GetReference(this.map.GetRowOffsetSpan()), (uint)((y - this.bounds.Y) * kernelSize)); // Clear the target buffer for each row run. targetBuffer.Clear(); ref Vector4 targetBase = ref MemoryMarshal.GetReference(targetBuffer); ref float kernelStart = ref this.kernel[0]; - ref float kernelEnd = ref Unsafe.Add(ref kernelStart, kernelSize); + ref float kernelEnd = ref Unsafe.Add(ref kernelStart, (uint)kernelSize); Span sourceRow; while (Unsafe.IsAddressLessThan(ref kernelStart, ref kernelEnd)) @@ -420,7 +420,7 @@ private void Convolve4(int y, Span span) Numerics.Premultiply(sourceBuffer); ref Vector4 sourceBase = ref MemoryMarshal.GetReference(sourceBuffer); - ref Vector4 sourceEnd = ref Unsafe.Add(ref sourceBase, sourceBuffer.Length); + ref Vector4 sourceEnd = ref Unsafe.Add(ref sourceBase, (uint)sourceBuffer.Length); ref Vector4 targetStart = ref targetBase; float factor = kernelStart; diff --git a/src/ImageSharp/Processing/Processors/Convolution/ConvolutionProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Convolution/ConvolutionProcessor{TPixel}.cs index 54dad64a6b..4cbca8d74e 100644 --- a/src/ImageSharp/Processing/Processors/Convolution/ConvolutionProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Convolution/ConvolutionProcessor{TPixel}.cs @@ -135,7 +135,7 @@ public void Invoke(int y, Span span) for (int kY = 0; kY < state.Kernel.Rows; kY++) { // Get the precalculated source sample row for this kernel row and copy to our buffer. - int offsetY = Unsafe.Add(ref sampleRowBase, kY); + int offsetY = Unsafe.Add(ref sampleRowBase, (uint)kY); sourceRow = this.sourcePixels.DangerousGetRowSpan(offsetY).Slice(boundsX, boundsWidth); PixelOperations.Instance.ToVector4(this.configuration, sourceRow, sourceBuffer); @@ -144,12 +144,12 @@ public void Invoke(int y, Span span) for (int x = 0; x < sourceBuffer.Length; x++) { ref int sampleColumnBase = ref state.GetSampleColumn(x); - ref Vector4 target = ref Unsafe.Add(ref targetBase, x); + ref Vector4 target = ref Unsafe.Add(ref targetBase, (uint)x); for (int kX = 0; kX < state.Kernel.Columns; kX++) { - int offsetX = Unsafe.Add(ref sampleColumnBase, kX) - boundsX; - Vector4 sample = Unsafe.Add(ref sourceBase, offsetX); + int offsetX = Unsafe.Add(ref sampleColumnBase, (uint)kX) - boundsX; + Vector4 sample = Unsafe.Add(ref sourceBase, (uint)offsetX); target += state.Kernel[kY, kX] * sample; } } @@ -161,8 +161,8 @@ public void Invoke(int y, Span span) for (int x = 0; x < sourceRow.Length; x++) { - ref Vector4 target = ref Unsafe.Add(ref targetBase, x); - target.W = Unsafe.Add(ref MemoryMarshal.GetReference(sourceBuffer), x).W; + ref Vector4 target = ref Unsafe.Add(ref targetBase, (uint)x); + target.W = Unsafe.Add(ref MemoryMarshal.GetReference(sourceBuffer), (uint)x).W; } } else @@ -174,7 +174,7 @@ public void Invoke(int y, Span span) for (int kY = 0; kY < state.Kernel.Rows; kY++) { // Get the precalculated source sample row for this kernel row and copy to our buffer. - int offsetY = Unsafe.Add(ref sampleRowBase, kY); + int offsetY = Unsafe.Add(ref sampleRowBase, (uint)kY); Span sourceRow = this.sourcePixels.DangerousGetRowSpan(offsetY).Slice(boundsX, boundsWidth); PixelOperations.Instance.ToVector4(this.configuration, sourceRow, sourceBuffer); @@ -184,12 +184,12 @@ public void Invoke(int y, Span span) for (int x = 0; x < sourceBuffer.Length; x++) { ref int sampleColumnBase = ref state.GetSampleColumn(x); - ref Vector4 target = ref Unsafe.Add(ref targetBase, x); + ref Vector4 target = ref Unsafe.Add(ref targetBase, (uint)x); for (int kX = 0; kX < state.Kernel.Columns; kX++) { - int offsetX = Unsafe.Add(ref sampleColumnBase, kX) - boundsX; - Vector4 sample = Unsafe.Add(ref sourceBase, offsetX); + int offsetX = Unsafe.Add(ref sampleColumnBase, (uint)kX) - boundsX; + Vector4 sample = Unsafe.Add(ref sourceBase, (uint)offsetX); target += state.Kernel[kY, kX] * sample; } } diff --git a/src/ImageSharp/Processing/Processors/Convolution/ConvolutionState.cs b/src/ImageSharp/Processing/Processors/Convolution/ConvolutionState.cs index 3d0e551b68..dbf90d0170 100644 --- a/src/ImageSharp/Processing/Processors/Convolution/ConvolutionState.cs +++ b/src/ImageSharp/Processing/Processors/Convolution/ConvolutionState.cs @@ -35,9 +35,9 @@ public readonly ReadOnlyKernel Kernel [MethodImpl(MethodImplOptions.AggressiveInlining)] public readonly ref int GetSampleRow(int row) - => ref Unsafe.Add(ref MemoryMarshal.GetReference(this.rowOffsetMap), row * this.kernelHeight); + => ref Unsafe.Add(ref MemoryMarshal.GetReference(this.rowOffsetMap), (uint)(row * this.kernelHeight)); [MethodImpl(MethodImplOptions.AggressiveInlining)] public readonly ref int GetSampleColumn(int column) - => ref Unsafe.Add(ref MemoryMarshal.GetReference(this.columnOffsetMap), column * this.kernelWidth); + => ref Unsafe.Add(ref MemoryMarshal.GetReference(this.columnOffsetMap), (uint)(column * this.kernelWidth)); } diff --git a/src/ImageSharp/Processing/Processors/Convolution/EdgeDetectorCompassProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Convolution/EdgeDetectorCompassProcessor{TPixel}.cs index 75e8e98e91..8de92bee81 100644 --- a/src/ImageSharp/Processing/Processors/Convolution/EdgeDetectorCompassProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Convolution/EdgeDetectorCompassProcessor{TPixel}.cs @@ -123,8 +123,8 @@ public void Invoke(int y) for (int x = this.minX; x < this.maxX; x++) { // Grab the max components of the two pixels - ref TPixel currentPassPixel = ref Unsafe.Add(ref passPixelsBase, x); - ref TPixel currentTargetPixel = ref Unsafe.Add(ref targetPixelsBase, x); + ref TPixel currentPassPixel = ref Unsafe.Add(ref passPixelsBase, (uint)x); + ref TPixel currentTargetPixel = ref Unsafe.Add(ref targetPixelsBase, (uint)x); var pixelValue = Vector4.Max(currentPassPixel.ToVector4(), currentTargetPixel.ToVector4()); diff --git a/src/ImageSharp/Processing/Processors/Convolution/Kernel.cs b/src/ImageSharp/Processing/Processors/Convolution/Kernel.cs index 35aa933cf7..b225b55e5f 100644 --- a/src/ImageSharp/Processing/Processors/Convolution/Kernel.cs +++ b/src/ImageSharp/Processing/Processors/Convolution/Kernel.cs @@ -49,7 +49,7 @@ public ReadOnlySpan Span { this.CheckCoordinates(row, column); ref T vBase = ref MemoryMarshal.GetReference(this.values); - return Unsafe.Add(ref vBase, (row * this.Columns) + column); + return Unsafe.Add(ref vBase, (uint)((row * this.Columns) + column)); } [MethodImpl(MethodImplOptions.AggressiveInlining)] @@ -57,7 +57,7 @@ public ReadOnlySpan Span { this.CheckCoordinates(row, column); ref T vBase = ref MemoryMarshal.GetReference(this.values); - Unsafe.Add(ref vBase, (row * this.Columns) + column) = value; + Unsafe.Add(ref vBase, (uint)((row * this.Columns) + column)) = value; } } @@ -66,7 +66,7 @@ public void SetValue(int index, T value) { this.CheckIndex(index); ref T vBase = ref MemoryMarshal.GetReference(this.values); - Unsafe.Add(ref vBase, index) = value; + Unsafe.Add(ref vBase, (uint)index) = value; } [MethodImpl(MethodImplOptions.AggressiveInlining)] diff --git a/src/ImageSharp/Processing/Processors/Convolution/KernelSamplingMap.cs b/src/ImageSharp/Processing/Processors/Convolution/KernelSamplingMap.cs index 8128d01196..7653aeaa96 100644 --- a/src/ImageSharp/Processing/Processors/Convolution/KernelSamplingMap.cs +++ b/src/ImageSharp/Processing/Processors/Convolution/KernelSamplingMap.cs @@ -92,7 +92,7 @@ private static void BuildOffsets(IMemoryOwner offsets, int boundsSize, int int chunkBase = chunk * kernelSize; for (int i = 0; i < kernelSize; i++) { - Unsafe.Add(ref spanBase, chunkBase + i) = chunk + i + min - radius; + Unsafe.Add(ref spanBase, (uint)(chunkBase + i)) = chunk + i + min - radius; } } diff --git a/src/ImageSharp/Processing/Processors/Convolution/MedianConvolutionState.cs b/src/ImageSharp/Processing/Processors/Convolution/MedianConvolutionState.cs index d557896e3c..137334c29e 100644 --- a/src/ImageSharp/Processing/Processors/Convolution/MedianConvolutionState.cs +++ b/src/ImageSharp/Processing/Processors/Convolution/MedianConvolutionState.cs @@ -36,9 +36,9 @@ public readonly Kernel Kernel [MethodImpl(MethodImplOptions.AggressiveInlining)] public readonly ref int GetSampleRow(int row) - => ref Unsafe.Add(ref MemoryMarshal.GetReference(this.rowOffsetMap), row * this.kernelHeight); + => ref Unsafe.Add(ref MemoryMarshal.GetReference(this.rowOffsetMap), (uint)(row * this.kernelHeight)); [MethodImpl(MethodImplOptions.AggressiveInlining)] public readonly ref int GetSampleColumn(int column) - => ref Unsafe.Add(ref MemoryMarshal.GetReference(this.columnOffsetMap), column * this.kernelWidth); + => ref Unsafe.Add(ref MemoryMarshal.GetReference(this.columnOffsetMap), (uint)(column * this.kernelWidth)); } diff --git a/src/ImageSharp/Processing/Processors/Convolution/MedianRowOperation{TPixel}.cs b/src/ImageSharp/Processing/Processors/Convolution/MedianRowOperation{TPixel}.cs index dbb62f0c58..ca2cabab55 100644 --- a/src/ImageSharp/Processing/Processors/Convolution/MedianRowOperation{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Convolution/MedianRowOperation{TPixel}.cs @@ -75,7 +75,7 @@ public void Invoke(int y, Span span) // First convert the required source rows to Vector4. for (int i = 0; i < this.kernelSize; i++) { - int currentYIndex = Unsafe.Add(ref sampleRowBase, i); + int currentYIndex = Unsafe.Add(ref sampleRowBase, (uint)i); Span sourceRow = this.sourcePixels.DangerousGetRowSpan(currentYIndex).Slice(boundsX, boundsWidth); Span sourceVectorRow = sourceVectorBuffer.Slice(i * boundsWidth, boundsWidth); PixelOperations.Instance.ToVector4(this.configuration, sourceRow, sourceVectorRow); @@ -87,15 +87,15 @@ public void Invoke(int y, Span span) { int index = 0; ref int sampleColumnBase = ref state.GetSampleColumn(x); - ref Vector4 target = ref Unsafe.Add(ref targetBase, x); + ref Vector4 target = ref Unsafe.Add(ref targetBase, (uint)x); for (int kY = 0; kY < state.Kernel.Rows; kY++) { Span sourceRow = sourceVectorBuffer[(kY * boundsWidth)..]; ref Vector4 sourceRowBase = ref MemoryMarshal.GetReference(sourceRow); for (int kX = 0; kX < state.Kernel.Columns; kX++) { - int currentXIndex = Unsafe.Add(ref sampleColumnBase, kX) - boundsX; - Vector4 pixel = Unsafe.Add(ref sourceRowBase, currentXIndex); + int currentXIndex = Unsafe.Add(ref sampleColumnBase, (uint)kX) - boundsX; + Vector4 pixel = Unsafe.Add(ref sourceRowBase, (uint)currentXIndex); state.Kernel.SetValue(index, pixel); index++; } @@ -111,15 +111,15 @@ public void Invoke(int y, Span span) { int index = 0; ref int sampleColumnBase = ref state.GetSampleColumn(x); - ref Vector4 target = ref Unsafe.Add(ref targetBase, x); + ref Vector4 target = ref Unsafe.Add(ref targetBase, (uint)x); for (int kY = 0; kY < state.Kernel.Rows; kY++) { Span sourceRow = sourceVectorBuffer[(kY * boundsWidth)..]; ref Vector4 sourceRowBase = ref MemoryMarshal.GetReference(sourceRow); for (int kX = 0; kX < state.Kernel.Columns; kX++) { - int currentXIndex = Unsafe.Add(ref sampleColumnBase, kX) - boundsX; - Vector4 pixel = Unsafe.Add(ref sourceRowBase, currentXIndex); + int currentXIndex = Unsafe.Add(ref sampleColumnBase, (uint)kX) - boundsX; + Vector4 pixel = Unsafe.Add(ref sourceRowBase, (uint)currentXIndex); state.Kernel.SetValue(index, pixel); index++; } diff --git a/src/ImageSharp/Processing/Processors/Convolution/Parameters/BokehBlurKernelDataProvider.cs b/src/ImageSharp/Processing/Processors/Convolution/Parameters/BokehBlurKernelDataProvider.cs index 08dee86a4e..8f501da23e 100644 --- a/src/ImageSharp/Processing/Processors/Convolution/Parameters/BokehBlurKernelDataProvider.cs +++ b/src/ImageSharp/Processing/Processors/Convolution/Parameters/BokehBlurKernelDataProvider.cs @@ -134,7 +134,7 @@ private static Complex64[][] CreateComplexKernels( ref Vector4 baseRef = ref MemoryMarshal.GetReference(kernelParameters.AsSpan()); for (int i = 0; i < kernelParameters.Length; i++) { - ref Vector4 paramsRef = ref Unsafe.Add(ref baseRef, i); + ref Vector4 paramsRef = ref Unsafe.Add(ref baseRef, (uint)i); kernels[i] = CreateComplex1DKernel(radius, kernelSize, kernelsScale, paramsRef.X, paramsRef.Y); } @@ -167,7 +167,7 @@ private static Complex64[] CreateComplex1DKernel( value *= value; // Fill in the complex kernel values - Unsafe.Add(ref baseRef, i) = new Complex64( + Unsafe.Add(ref baseRef, (uint)i) = new Complex64( MathF.Exp(-a * value) * MathF.Cos(b * value), MathF.Exp(-a * value) * MathF.Sin(b * value)); } @@ -190,17 +190,17 @@ private static void NormalizeKernels(Complex64[][] kernels, Vector4[] kernelPara for (int i = 0; i < kernelParameters.Length; i++) { - ref Complex64[] kernelRef = ref Unsafe.Add(ref baseKernelsRef, i); + ref Complex64[] kernelRef = ref Unsafe.Add(ref baseKernelsRef, (uint)i); int length = kernelRef.Length; ref Complex64 valueRef = ref kernelRef[0]; - ref Vector4 paramsRef = ref Unsafe.Add(ref baseParamsRef, i); + ref Vector4 paramsRef = ref Unsafe.Add(ref baseParamsRef, (uint)i); for (int j = 0; j < length; j++) { for (int k = 0; k < length; k++) { - ref Complex64 jRef = ref Unsafe.Add(ref valueRef, j); - ref Complex64 kRef = ref Unsafe.Add(ref valueRef, k); + ref Complex64 jRef = ref Unsafe.Add(ref valueRef, (uint)j); + ref Complex64 kRef = ref Unsafe.Add(ref valueRef, (uint)k); total += (paramsRef.Z * ((jRef.Real * kRef.Real) - (jRef.Imaginary * kRef.Imaginary))) + (paramsRef.W * ((jRef.Real * kRef.Imaginary) + (jRef.Imaginary * kRef.Real))); @@ -212,13 +212,13 @@ private static void NormalizeKernels(Complex64[][] kernels, Vector4[] kernelPara float scalar = 1f / MathF.Sqrt(total); for (int i = 0; i < kernelsSpan.Length; i++) { - ref Complex64[] kernelsRef = ref Unsafe.Add(ref baseKernelsRef, i); + ref Complex64[] kernelsRef = ref Unsafe.Add(ref baseKernelsRef, (uint)i); int length = kernelsRef.Length; ref Complex64 valueRef = ref kernelsRef[0]; for (int j = 0; j < length; j++) { - Unsafe.Add(ref valueRef, j) *= scalar; + Unsafe.Add(ref valueRef, (uint)j) *= scalar; } } } diff --git a/src/ImageSharp/Processing/Processors/Convolution/ReadOnlyKernel.cs b/src/ImageSharp/Processing/Processors/Convolution/ReadOnlyKernel.cs index 641a8ae8b0..46c35c62c7 100644 --- a/src/ImageSharp/Processing/Processors/Convolution/ReadOnlyKernel.cs +++ b/src/ImageSharp/Processing/Processors/Convolution/ReadOnlyKernel.cs @@ -41,7 +41,7 @@ public int Rows { this.CheckCoordinates(row, column); ref float vBase = ref MemoryMarshal.GetReference(this.values); - return Unsafe.Add(ref vBase, (row * this.Columns) + column); + return Unsafe.Add(ref vBase, (uint)((row * this.Columns) + column)); } } diff --git a/src/ImageSharp/Processing/Processors/Dithering/ErrorDither.cs b/src/ImageSharp/Processing/Processors/Dithering/ErrorDither.cs index 3a869a0a28..754aac90ea 100644 --- a/src/ImageSharp/Processing/Processors/Dithering/ErrorDither.cs +++ b/src/ImageSharp/Processing/Processors/Dithering/ErrorDither.cs @@ -114,8 +114,8 @@ public void ApplyQuantizationDither( for (int x = bounds.Left; x < bounds.Right; x++) { - TPixel sourcePixel = Unsafe.Add(ref sourceRowRef, x); - Unsafe.Add(ref destinationRowRef, x - offsetX) = quantizer.GetQuantizedColor(sourcePixel, out TPixel transformed); + TPixel sourcePixel = Unsafe.Add(ref sourceRowRef, (uint)x); + Unsafe.Add(ref destinationRowRef, (uint)(x - offsetX)) = quantizer.GetQuantizedColor(sourcePixel, out TPixel transformed); this.Dither(source, bounds, sourcePixel, transformed, x, y, scale); } } @@ -142,7 +142,7 @@ public void ApplyPaletteDither( ref TPixel sourceRowRef = ref MemoryMarshal.GetReference(sourceBuffer.DangerousGetRowSpan(y)); for (int x = bounds.Left; x < bounds.Right; x++) { - ref TPixel sourcePixel = ref Unsafe.Add(ref sourceRowRef, x); + ref TPixel sourcePixel = ref Unsafe.Add(ref sourceRowRef, (uint)x); TPixel transformed = Unsafe.AsRef(processor).GetPaletteColor(sourcePixel); this.Dither(source, bounds, sourcePixel, transformed, x, y, scale); sourcePixel = transformed; diff --git a/src/ImageSharp/Processing/Processors/Effects/OilPaintingProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Effects/OilPaintingProcessor{TPixel}.cs index 67964f0ebd..6352230de2 100644 --- a/src/ImageSharp/Processing/Processors/Effects/OilPaintingProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Effects/OilPaintingProcessor{TPixel}.cs @@ -107,9 +107,9 @@ public void Invoke(in RowInterval rows) ref float binsRef = ref bins.GetReference(); ref int intensityBinRef = ref Unsafe.As(ref binsRef); - ref float redBinRef = ref Unsafe.Add(ref binsRef, this.levels); - ref float blueBinRef = ref Unsafe.Add(ref redBinRef, this.levels); - ref float greenBinRef = ref Unsafe.Add(ref blueBinRef, this.levels); + ref float redBinRef = ref Unsafe.Add(ref binsRef, (uint)this.levels); + ref float blueBinRef = ref Unsafe.Add(ref redBinRef, (uint)this.levels); + ref float greenBinRef = ref Unsafe.Add(ref blueBinRef, (uint)this.levels); for (int y = rows.Min; y < rows.Max; y++) { @@ -148,21 +148,21 @@ public void Invoke(in RowInterval rows) int currentIntensity = (int)MathF.Round((sourceBlue + sourceGreen + sourceRed) / 3F * (this.levels - 1)); - Unsafe.Add(ref intensityBinRef, currentIntensity)++; - Unsafe.Add(ref redBinRef, currentIntensity) += sourceRed; - Unsafe.Add(ref blueBinRef, currentIntensity) += sourceBlue; - Unsafe.Add(ref greenBinRef, currentIntensity) += sourceGreen; + Unsafe.Add(ref intensityBinRef, (uint)currentIntensity)++; + Unsafe.Add(ref redBinRef, (uint)currentIntensity) += sourceRed; + Unsafe.Add(ref blueBinRef, (uint)currentIntensity) += sourceBlue; + Unsafe.Add(ref greenBinRef, (uint)currentIntensity) += sourceGreen; - if (Unsafe.Add(ref intensityBinRef, currentIntensity) > maxIntensity) + if (Unsafe.Add(ref intensityBinRef, (uint)currentIntensity) > maxIntensity) { - maxIntensity = Unsafe.Add(ref intensityBinRef, currentIntensity); + maxIntensity = Unsafe.Add(ref intensityBinRef, (uint)currentIntensity); maxIndex = currentIntensity; } } - float red = MathF.Abs(Unsafe.Add(ref redBinRef, maxIndex) / maxIntensity); - float blue = MathF.Abs(Unsafe.Add(ref blueBinRef, maxIndex) / maxIntensity); - float green = MathF.Abs(Unsafe.Add(ref greenBinRef, maxIndex) / maxIntensity); + float red = MathF.Abs(Unsafe.Add(ref redBinRef, (uint)maxIndex) / maxIntensity); + float blue = MathF.Abs(Unsafe.Add(ref blueBinRef, (uint)maxIndex) / maxIntensity); + float green = MathF.Abs(Unsafe.Add(ref greenBinRef, (uint)maxIndex) / maxIntensity); float alpha = sourceRowVector4Span[x].W; targetRowVector4Span[x] = new Vector4(red, green, blue, alpha); diff --git a/src/ImageSharp/Processing/Processors/Filters/OpaqueProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Filters/OpaqueProcessor{TPixel}.cs index 4b8fd9056e..93e600106a 100644 --- a/src/ImageSharp/Processing/Processors/Filters/OpaqueProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Filters/OpaqueProcessor{TPixel}.cs @@ -61,7 +61,7 @@ public void Invoke(int y, Span span) for (int x = 0; x < this.bounds.Width; x++) { - ref Vector4 v = ref Unsafe.Add(ref baseRef, x); + ref Vector4 v = ref Unsafe.Add(ref baseRef, (uint)x); v.W = 1F; } diff --git a/src/ImageSharp/Processing/Processors/Normalization/AdaptiveHistogramEqualizationSlidingWindowProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Normalization/AdaptiveHistogramEqualizationSlidingWindowProcessor{TPixel}.cs index 3aaf2631ae..f25db12c28 100644 --- a/src/ImageSharp/Processing/Processors/Normalization/AdaptiveHistogramEqualizationSlidingWindowProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Normalization/AdaptiveHistogramEqualizationSlidingWindowProcessor{TPixel}.cs @@ -256,8 +256,8 @@ private static void AddPixelsToHistogram(ref Vector4 greyValuesBase, ref int his { for (nint idx = 0; idx < length; idx++) { - int luminance = ColorNumerics.GetBT709Luminance(ref Unsafe.Add(ref greyValuesBase, idx), luminanceLevels); - Unsafe.Add(ref histogramBase, luminance)++; + int luminance = ColorNumerics.GetBT709Luminance(ref Unsafe.Add(ref greyValuesBase, (uint)idx), luminanceLevels); + Unsafe.Add(ref histogramBase, (uint)luminance)++; } } @@ -273,8 +273,8 @@ private static void RemovePixelsFromHistogram(ref Vector4 greyValuesBase, ref in { for (int idx = 0; idx < length; idx++) { - int luminance = ColorNumerics.GetBT709Luminance(ref Unsafe.Add(ref greyValuesBase, idx), luminanceLevels); - Unsafe.Add(ref histogramBase, luminance)--; + int luminance = ColorNumerics.GetBT709Luminance(ref Unsafe.Add(ref greyValuesBase, (uint)idx), luminanceLevels); + Unsafe.Add(ref histogramBase, (uint)luminance)--; } } @@ -382,7 +382,7 @@ public void Invoke(int x) // Map the current pixel to the new equalized value. int luminance = GetLuminance(this.source[x, y], this.processor.LuminanceLevels); - float luminanceEqualized = Unsafe.Add(ref cdfBase, luminance) / numberOfPixelsMinusCdfMin; + float luminanceEqualized = Unsafe.Add(ref cdfBase, (uint)luminance) / numberOfPixelsMinusCdfMin; this.targetPixels[x, y].FromVector4(new Vector4(luminanceEqualized, luminanceEqualized, luminanceEqualized, this.source[x, y].ToVector4().W)); // Remove top most row from the histogram, mirroring rows which exceeds the borders. diff --git a/src/ImageSharp/Processing/Processors/Normalization/AutoLevelProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Normalization/AutoLevelProcessor{TPixel}.cs index c07ac3aa34..6f4493f951 100644 --- a/src/ImageSharp/Processing/Processors/Normalization/AutoLevelProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Normalization/AutoLevelProcessor{TPixel}.cs @@ -148,12 +148,12 @@ public void Invoke(int y, Span span) for (int x = 0; x < this.bounds.Width; x++) { - var vector = Unsafe.Add(ref vectorRef, x); + var vector = Unsafe.Add(ref vectorRef, (uint)x); int luminance = ColorNumerics.GetBT709Luminance(ref vector, levels); - float scaledLuminance = Unsafe.Add(ref cdfBase, luminance) / noOfPixelsMinusCdfMin; + float scaledLuminance = Unsafe.Add(ref cdfBase, (uint)luminance) / noOfPixelsMinusCdfMin; float scalingFactor = scaledLuminance * levels / luminance; Vector4 scaledVector = new Vector4(scalingFactor * vector.X, scalingFactor * vector.Y, scalingFactor * vector.Z, vector.W); - Unsafe.Add(ref vectorRef, x) = scaledVector; + Unsafe.Add(ref vectorRef, (uint)x) = scaledVector; } PixelOperations.Instance.FromVector4Destructive(this.configuration, vectorBuffer, pixelRow); @@ -209,7 +209,7 @@ public void Invoke(int y, Span span) for (int x = 0; x < this.bounds.Width; x++) { - var vector = Unsafe.Add(ref vectorRef, x) * levelsMinusOne; + var vector = Unsafe.Add(ref vectorRef, (uint)x) * levelsMinusOne; uint originalX = (uint)MathF.Round(vector.X); float scaledX = Unsafe.Add(ref cdfBase, originalX) / noOfPixelsMinusCdfMin; @@ -217,7 +217,7 @@ public void Invoke(int y, Span span) float scaledY = Unsafe.Add(ref cdfBase, originalY) / noOfPixelsMinusCdfMin; uint originalZ = (uint)MathF.Round(vector.Z); float scaledZ = Unsafe.Add(ref cdfBase, originalZ) / noOfPixelsMinusCdfMin; - Unsafe.Add(ref vectorRef, x) = new Vector4(scaledX, scaledY, scaledZ, vector.W); + Unsafe.Add(ref vectorRef, (uint)x) = new Vector4(scaledX, scaledY, scaledZ, vector.W); } PixelOperations.Instance.FromVector4Destructive(this.configuration, vectorBuffer, pixelRow); diff --git a/src/ImageSharp/Processing/Processors/Normalization/GlobalHistogramEqualizationProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Normalization/GlobalHistogramEqualizationProcessor{TPixel}.cs index 7e9e064642..e7433899bf 100644 --- a/src/ImageSharp/Processing/Processors/Normalization/GlobalHistogramEqualizationProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Normalization/GlobalHistogramEqualizationProcessor{TPixel}.cs @@ -129,10 +129,10 @@ public void Invoke(int y, Span span) for (int x = 0; x < this.bounds.Width; x++) { - var vector = Unsafe.Add(ref vectorRef, x); + var vector = Unsafe.Add(ref vectorRef, (uint)x); int luminance = ColorNumerics.GetBT709Luminance(ref vector, levels); - float luminanceEqualized = Unsafe.Add(ref cdfBase, luminance) / noOfPixelsMinusCdfMin; - Unsafe.Add(ref vectorRef, x) = new Vector4(luminanceEqualized, luminanceEqualized, luminanceEqualized, vector.W); + float luminanceEqualized = Unsafe.Add(ref cdfBase, (uint)luminance) / noOfPixelsMinusCdfMin; + Unsafe.Add(ref vectorRef, (uint)x) = new Vector4(luminanceEqualized, luminanceEqualized, luminanceEqualized, vector.W); } PixelOperations.Instance.FromVector4Destructive(this.configuration, vectorBuffer, pixelRow); diff --git a/src/ImageSharp/Processing/Processors/Normalization/GrayscaleLevelsRowOperation{TPixel}.cs b/src/ImageSharp/Processing/Processors/Normalization/GrayscaleLevelsRowOperation{TPixel}.cs index 8895fdc612..0a8690ba70 100644 --- a/src/ImageSharp/Processing/Processors/Normalization/GrayscaleLevelsRowOperation{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Normalization/GrayscaleLevelsRowOperation{TPixel}.cs @@ -56,9 +56,9 @@ public void Invoke(int y, Span span) for (int x = 0; x < this.bounds.Width; x++) { - var vector = Unsafe.Add(ref vectorRef, x); + var vector = Unsafe.Add(ref vectorRef, (uint)x); int luminance = ColorNumerics.GetBT709Luminance(ref vector, levels); - Interlocked.Increment(ref Unsafe.Add(ref histogramBase, luminance)); + Interlocked.Increment(ref Unsafe.Add(ref histogramBase, (uint)luminance)); } } } diff --git a/src/ImageSharp/Processing/Processors/Normalization/HistogramEqualizationProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Normalization/HistogramEqualizationProcessor{TPixel}.cs index 49168f4b24..80f2b15bc1 100644 --- a/src/ImageSharp/Processing/Processors/Normalization/HistogramEqualizationProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Normalization/HistogramEqualizationProcessor{TPixel}.cs @@ -73,7 +73,7 @@ public static int CalculateCdf(ref int cdfBase, ref int histogramBase, int maxId int cdfMin = 0; bool cdfMinFound = false; - for (int i = 0; i <= maxIdx; i++) + for (nint i = 0; i <= (uint)maxIdx; i++) { histSum += Unsafe.Add(ref histogramBase, i); if (!cdfMinFound && histSum != 0) @@ -101,7 +101,7 @@ public void ClipHistogram(Span histogram, int clipLimit) int sumOverClip = 0; ref int histogramBase = ref MemoryMarshal.GetReference(histogram); - for (int i = 0; i < histogram.Length; i++) + for (nint i = 0; i < (uint)histogram.Length; i++) { ref int histogramLevel = ref Unsafe.Add(ref histogramBase, i); if (histogramLevel > clipLimit) @@ -115,7 +115,7 @@ public void ClipHistogram(Span histogram, int clipLimit) int addToEachBin = sumOverClip > 0 ? (int)MathF.Floor(sumOverClip / this.luminanceLevelsFloat) : 0; if (addToEachBin > 0) { - for (int i = 0; i < histogram.Length; i++) + for (nint i = 0; i < (uint)histogram.Length; i++) { Unsafe.Add(ref histogramBase, i) += addToEachBin; } @@ -125,7 +125,7 @@ public void ClipHistogram(Span histogram, int clipLimit) if (residual != 0) { int residualStep = Math.Max(this.LuminanceLevels / residual, 1); - for (int i = 0; i < this.LuminanceLevels && residual > 0; i += residualStep, residual--) + for (nint i = 0; i < (uint)this.LuminanceLevels && residual > 0; i += residualStep, residual--) { ref int histogramLevel = ref Unsafe.Add(ref histogramBase, i); histogramLevel++; diff --git a/src/ImageSharp/Processing/Processors/Quantization/EuclideanPixelMap{TPixel}.cs b/src/ImageSharp/Processing/Processors/Quantization/EuclideanPixelMap{TPixel}.cs index a8cf4d3e91..786248339b 100644 --- a/src/ImageSharp/Processing/Processors/Quantization/EuclideanPixelMap{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Quantization/EuclideanPixelMap{TPixel}.cs @@ -75,7 +75,7 @@ public int GetClosestColor(TPixel color, out TPixel match) return this.GetClosestColorSlow(rgba, ref paletteRef, out match); } - match = Unsafe.Add(ref paletteRef, index); + match = Unsafe.Add(ref paletteRef, (ushort)index); return index; } @@ -119,7 +119,7 @@ private int GetClosestColorSlow(Rgba32 rgba, ref TPixel paletteRef, out TPixel m // Now I have the index, pop it into the cache for next time this.cache.Add(rgba, (byte)index); - match = Unsafe.Add(ref paletteRef, index); + match = Unsafe.Add(ref paletteRef, (uint)index); return index; } diff --git a/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeWorker.cs b/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeWorker.cs index 5cd9976a58..10525641ca 100644 --- a/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeWorker.cs +++ b/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeWorker.cs @@ -134,7 +134,7 @@ public void FillDestinationPixels(RowInterval rowInterval, Buffer2D dest for (nint x = 0; x < (right - left); x++) { - ref Vector4 firstPassColumnBase = ref Unsafe.Add(ref fpBase, x * this.workerHeight); + ref Vector4 firstPassColumnBase = ref Unsafe.Add(ref fpBase, x * (nint)(uint)this.workerHeight); // Destination color components Unsafe.Add(ref tempRowBase, x) = kernel.ConvolveCore(ref firstPassColumnBase); @@ -186,13 +186,13 @@ private void CalculateFirstPassValues(RowInterval calculationInterval) // Span firstPassSpan = transposedFirstPassBufferSpan.Slice(y - this.currentWindow.Min); ref Vector4 firstPassBaseRef = ref transposedFirstPassBufferSpan[y - this.currentWindow.Min]; - for (nint x = left, z = 0; x < right; x++, z++) + for (nint x = left, z = 0; x < (nint)(uint)right; x++, z++) { ResizeKernel kernel = this.horizontalKernelMap.GetKernel(x - targetOriginX); // optimization for: // firstPassSpan[x * this.workerHeight] = kernel.Convolve(tempRowSpan); - Unsafe.Add(ref firstPassBaseRef, z * this.workerHeight) = kernel.Convolve(tempRowSpan); + Unsafe.Add(ref firstPassBaseRef, z * (nint)(uint)this.workerHeight) = kernel.Convolve(tempRowSpan); } } } diff --git a/tests/ImageSharp.Benchmarks/Bulk/FromVector4.cs b/tests/ImageSharp.Benchmarks/Bulk/FromVector4.cs index 0637b33347..ed129fca2f 100644 --- a/tests/ImageSharp.Benchmarks/Bulk/FromVector4.cs +++ b/tests/ImageSharp.Benchmarks/Bulk/FromVector4.cs @@ -47,7 +47,7 @@ public void PerElement() { ref Vector4 s = ref MemoryMarshal.GetReference(this.source.GetSpan()); ref TPixel d = ref MemoryMarshal.GetReference(this.destination.GetSpan()); - for (int i = 0; i < this.Count; i++) + for (nint i = 0; i < (uint)this.Count; i++) { Unsafe.Add(ref d, i).FromVector4(Unsafe.Add(ref s, i)); } diff --git a/tests/ImageSharp.Benchmarks/Bulk/PremultiplyVector4.cs b/tests/ImageSharp.Benchmarks/Bulk/PremultiplyVector4.cs index d22fc18ac6..355216de34 100644 --- a/tests/ImageSharp.Benchmarks/Bulk/PremultiplyVector4.cs +++ b/tests/ImageSharp.Benchmarks/Bulk/PremultiplyVector4.cs @@ -17,7 +17,7 @@ public void PremultiplyBaseline() { ref Vector4 baseRef = ref MemoryMarshal.GetReference(Vectors); - for (int i = 0; i < Vectors.Length; i++) + for (nint i = 0; i < (uint)Vectors.Length; i++) { ref Vector4 v = ref Unsafe.Add(ref baseRef, i); Premultiply(ref v); @@ -29,7 +29,7 @@ public void Premultiply() { ref Vector4 baseRef = ref MemoryMarshal.GetReference(Vectors); - for (int i = 0; i < Vectors.Length; i++) + for (nint i = 0; i < (uint)Vectors.Length; i++) { ref Vector4 v = ref Unsafe.Add(ref baseRef, i); Numerics.Premultiply(ref v); diff --git a/tests/ImageSharp.Benchmarks/Bulk/UnPremultiplyVector4.cs b/tests/ImageSharp.Benchmarks/Bulk/UnPremultiplyVector4.cs index 3dc8fdc9c6..309eea34fd 100644 --- a/tests/ImageSharp.Benchmarks/Bulk/UnPremultiplyVector4.cs +++ b/tests/ImageSharp.Benchmarks/Bulk/UnPremultiplyVector4.cs @@ -17,7 +17,7 @@ public void UnPremultiplyBaseline() { ref Vector4 baseRef = ref MemoryMarshal.GetReference(Vectors); - for (int i = 0; i < Vectors.Length; i++) + for (nint i = 0; i < (uint)Vectors.Length; i++) { ref Vector4 v = ref Unsafe.Add(ref baseRef, i); @@ -30,7 +30,7 @@ public void UnPremultiply() { ref Vector4 baseRef = ref MemoryMarshal.GetReference(Vectors); - for (int i = 0; i < Vectors.Length; i++) + for (nint i = 0; i < (uint)Vectors.Length; i++) { ref Vector4 v = ref Unsafe.Add(ref baseRef, i); Numerics.UnPremultiply(ref v); diff --git a/tests/ImageSharp.Benchmarks/Codecs/Jpeg/BlockOperations/Block8x8F_CopyTo1x1.cs b/tests/ImageSharp.Benchmarks/Codecs/Jpeg/BlockOperations/Block8x8F_CopyTo1x1.cs index f36f92e907..abdd6908da 100644 --- a/tests/ImageSharp.Benchmarks/Codecs/Jpeg/BlockOperations/Block8x8F_CopyTo1x1.cs +++ b/tests/ImageSharp.Benchmarks/Codecs/Jpeg/BlockOperations/Block8x8F_CopyTo1x1.cs @@ -72,8 +72,8 @@ public void Original() [MethodImpl(MethodImplOptions.AggressiveInlining)] private static void CopyRowImpl(ref byte selfBase, ref byte destBase, int destStride, int row) { - ref byte s = ref Unsafe.Add(ref selfBase, row * 8 * sizeof(float)); - ref byte d = ref Unsafe.Add(ref destBase, row * destStride); + ref byte s = ref Unsafe.Add(ref selfBase, (uint)row * 8 * sizeof(float)); + ref byte d = ref Unsafe.Add(ref destBase, (uint)(row * destStride)); Unsafe.CopyBlock(ref d, ref s, 8 * sizeof(float)); } @@ -82,7 +82,7 @@ public void UseVector8() { ref Block8x8F s = ref this.block; ref float origin = ref Unsafe.AsRef(this.bufferPtr); - int stride = Width; + nint stride = (nint)(uint)Width; ref Vector d0 = ref Unsafe.As>(ref origin); ref Vector d1 = ref Unsafe.As>(ref Unsafe.Add(ref origin, stride)); @@ -117,7 +117,7 @@ public void UseVector8_V2() { ref Block8x8F s = ref this.block; ref float origin = ref Unsafe.AsRef(this.bufferPtr); - int stride = Width; + nint stride = (nint)(uint)Width; ref Vector d0 = ref Unsafe.As>(ref origin); ref Vector d1 = ref Unsafe.As>(ref Unsafe.Add(ref origin, stride)); @@ -141,29 +141,29 @@ public void UseVector8_V2() [Benchmark] public void UseVector8_V3() { - int stride = Width * sizeof(float); + nint stride = (nint)(uint)Width * sizeof(float); ref float d = ref this.unpinnedBuffer[0]; ref Vector s = ref Unsafe.As>(ref this.block); Vector v0 = s; - Vector v1 = Unsafe.AddByteOffset(ref s, (IntPtr)1); - Vector v2 = Unsafe.AddByteOffset(ref s, (IntPtr)2); - Vector v3 = Unsafe.AddByteOffset(ref s, (IntPtr)3); + Vector v1 = Unsafe.AddByteOffset(ref s, 1); + Vector v2 = Unsafe.AddByteOffset(ref s, 2); + Vector v3 = Unsafe.AddByteOffset(ref s, 3); Unsafe.As>(ref d) = v0; - Unsafe.As>(ref Unsafe.AddByteOffset(ref d, (IntPtr)stride)) = v1; - Unsafe.As>(ref Unsafe.AddByteOffset(ref d, (IntPtr)(stride * 2))) = v2; - Unsafe.As>(ref Unsafe.AddByteOffset(ref d, (IntPtr)(stride * 3))) = v3; - - v0 = Unsafe.AddByteOffset(ref s, (IntPtr)4); - v1 = Unsafe.AddByteOffset(ref s, (IntPtr)5); - v2 = Unsafe.AddByteOffset(ref s, (IntPtr)6); - v3 = Unsafe.AddByteOffset(ref s, (IntPtr)7); - - Unsafe.As>(ref Unsafe.AddByteOffset(ref d, (IntPtr)(stride * 4))) = v0; - Unsafe.As>(ref Unsafe.AddByteOffset(ref d, (IntPtr)(stride * 5))) = v1; - Unsafe.As>(ref Unsafe.AddByteOffset(ref d, (IntPtr)(stride * 6))) = v2; - Unsafe.As>(ref Unsafe.AddByteOffset(ref d, (IntPtr)(stride * 7))) = v3; + Unsafe.As>(ref Unsafe.AddByteOffset(ref d, stride)) = v1; + Unsafe.As>(ref Unsafe.AddByteOffset(ref d, stride * 2)) = v2; + Unsafe.As>(ref Unsafe.AddByteOffset(ref d, stride * 3)) = v3; + + v0 = Unsafe.AddByteOffset(ref s, 4); + v1 = Unsafe.AddByteOffset(ref s, 5); + v2 = Unsafe.AddByteOffset(ref s, 6); + v3 = Unsafe.AddByteOffset(ref s, 7); + + Unsafe.As>(ref Unsafe.AddByteOffset(ref d, stride * 4)) = v0; + Unsafe.As>(ref Unsafe.AddByteOffset(ref d, stride * 5)) = v1; + Unsafe.As>(ref Unsafe.AddByteOffset(ref d, stride * 6)) = v2; + Unsafe.As>(ref Unsafe.AddByteOffset(ref d, stride * 7)) = v3; } [Benchmark] @@ -254,7 +254,7 @@ public void UseVector256_Avx2_Variant3() [Benchmark] public void UseVector256_Avx2_Variant3_RefCast() { - int stride = Width; + nint stride = (nint)(uint)Width; ref float d = ref this.unpinnedBuffer[0]; ref Vector256 s = ref Unsafe.As>(ref this.block); @@ -282,29 +282,29 @@ public void UseVector256_Avx2_Variant3_RefCast() [Benchmark] public void UseVector256_Avx2_Variant3_RefCast_Mod() { - int stride = Width * sizeof(float); + nint stride = (nint)(uint)Width * sizeof(float); ref float d = ref this.unpinnedBuffer[0]; ref Vector256 s = ref Unsafe.As>(ref this.block); Vector256 v0 = s; - Vector256 v1 = Unsafe.AddByteOffset(ref s, (IntPtr)1); - Vector256 v2 = Unsafe.AddByteOffset(ref s, (IntPtr)2); - Vector256 v3 = Unsafe.AddByteOffset(ref s, (IntPtr)3); + Vector256 v1 = Unsafe.AddByteOffset(ref s, 1); + Vector256 v2 = Unsafe.AddByteOffset(ref s, 2); + Vector256 v3 = Unsafe.AddByteOffset(ref s, 3); Unsafe.As>(ref d) = v0; - Unsafe.As>(ref Unsafe.AddByteOffset(ref d, (IntPtr)stride)) = v1; - Unsafe.As>(ref Unsafe.AddByteOffset(ref d, (IntPtr)(stride * 2))) = v2; - Unsafe.As>(ref Unsafe.AddByteOffset(ref d, (IntPtr)(stride * 3))) = v3; - - v0 = Unsafe.AddByteOffset(ref s, (IntPtr)4); - v1 = Unsafe.AddByteOffset(ref s, (IntPtr)5); - v2 = Unsafe.AddByteOffset(ref s, (IntPtr)6); - v3 = Unsafe.AddByteOffset(ref s, (IntPtr)7); - - Unsafe.As>(ref Unsafe.AddByteOffset(ref d, (IntPtr)(stride * 4))) = v0; - Unsafe.As>(ref Unsafe.AddByteOffset(ref d, (IntPtr)(stride * 5))) = v1; - Unsafe.As>(ref Unsafe.AddByteOffset(ref d, (IntPtr)(stride * 6))) = v2; - Unsafe.As>(ref Unsafe.AddByteOffset(ref d, (IntPtr)(stride * 7))) = v3; + Unsafe.As>(ref Unsafe.AddByteOffset(ref d, stride)) = v1; + Unsafe.As>(ref Unsafe.AddByteOffset(ref d, stride * 2)) = v2; + Unsafe.As>(ref Unsafe.AddByteOffset(ref d, stride * 3)) = v3; + + v0 = Unsafe.AddByteOffset(ref s, 4); + v1 = Unsafe.AddByteOffset(ref s, 5); + v2 = Unsafe.AddByteOffset(ref s, 6); + v3 = Unsafe.AddByteOffset(ref s, 7); + + Unsafe.As>(ref Unsafe.AddByteOffset(ref d, stride * 4)) = v0; + Unsafe.As>(ref Unsafe.AddByteOffset(ref d, stride * 5)) = v1; + Unsafe.As>(ref Unsafe.AddByteOffset(ref d, stride * 6)) = v2; + Unsafe.As>(ref Unsafe.AddByteOffset(ref d, stride * 7)) = v3; } // [Benchmark] diff --git a/tests/ImageSharp.Benchmarks/Codecs/Jpeg/BlockOperations/Block8x8F_CopyTo2x2.cs b/tests/ImageSharp.Benchmarks/Codecs/Jpeg/BlockOperations/Block8x8F_CopyTo2x2.cs index 88c0098230..72b6bb72e8 100644 --- a/tests/ImageSharp.Benchmarks/Codecs/Jpeg/BlockOperations/Block8x8F_CopyTo2x2.cs +++ b/tests/ImageSharp.Benchmarks/Codecs/Jpeg/BlockOperations/Block8x8F_CopyTo2x2.cs @@ -47,9 +47,9 @@ public void Original() [MethodImpl(MethodImplOptions.AggressiveInlining)] private static void WidenCopyImpl2x2(ref Block8x8F src, ref float destBase, int row, int destStride) { - ref Vector4 selfLeft = ref Unsafe.Add(ref src.V0L, 2 * row); + ref Vector4 selfLeft = ref Unsafe.Add(ref src.V0L, 2 * (uint)row); ref Vector4 selfRight = ref Unsafe.Add(ref selfLeft, 1); - ref float destLocalOrigo = ref Unsafe.Add(ref destBase, row * 2 * destStride); + ref float destLocalOrigo = ref Unsafe.Add(ref destBase, (uint)(row * 2 * destStride)); Unsafe.Add(ref destLocalOrigo, 0) = selfLeft.X; Unsafe.Add(ref destLocalOrigo, 1) = selfLeft.X; @@ -69,23 +69,23 @@ private static void WidenCopyImpl2x2(ref Block8x8F src, ref float destBase, int Unsafe.Add(ref Unsafe.Add(ref destLocalOrigo, 8), 6) = selfRight.W; Unsafe.Add(ref Unsafe.Add(ref destLocalOrigo, 8), 7) = selfRight.W; - Unsafe.Add(ref Unsafe.Add(ref destLocalOrigo, destStride), 0) = selfLeft.X; - Unsafe.Add(ref Unsafe.Add(ref destLocalOrigo, destStride), 1) = selfLeft.X; - Unsafe.Add(ref Unsafe.Add(ref destLocalOrigo, destStride), 2) = selfLeft.Y; - Unsafe.Add(ref Unsafe.Add(ref destLocalOrigo, destStride), 3) = selfLeft.Y; - Unsafe.Add(ref Unsafe.Add(ref destLocalOrigo, destStride), 4) = selfLeft.Z; - Unsafe.Add(ref Unsafe.Add(ref destLocalOrigo, destStride), 5) = selfLeft.Z; - Unsafe.Add(ref Unsafe.Add(ref destLocalOrigo, destStride), 6) = selfLeft.W; - Unsafe.Add(ref Unsafe.Add(ref destLocalOrigo, destStride), 7) = selfLeft.W; - - Unsafe.Add(ref Unsafe.Add(ref destLocalOrigo, destStride + 8), 0) = selfRight.X; - Unsafe.Add(ref Unsafe.Add(ref destLocalOrigo, destStride + 8), 1) = selfRight.X; - Unsafe.Add(ref Unsafe.Add(ref destLocalOrigo, destStride + 8), 2) = selfRight.Y; - Unsafe.Add(ref Unsafe.Add(ref destLocalOrigo, destStride + 8), 3) = selfRight.Y; - Unsafe.Add(ref Unsafe.Add(ref destLocalOrigo, destStride + 8), 4) = selfRight.Z; - Unsafe.Add(ref Unsafe.Add(ref destLocalOrigo, destStride + 8), 5) = selfRight.Z; - Unsafe.Add(ref Unsafe.Add(ref destLocalOrigo, destStride + 8), 6) = selfRight.W; - Unsafe.Add(ref Unsafe.Add(ref destLocalOrigo, destStride + 8), 7) = selfRight.W; + Unsafe.Add(ref Unsafe.Add(ref destLocalOrigo, (uint)destStride), 0) = selfLeft.X; + Unsafe.Add(ref Unsafe.Add(ref destLocalOrigo, (uint)destStride), 1) = selfLeft.X; + Unsafe.Add(ref Unsafe.Add(ref destLocalOrigo, (uint)destStride), 2) = selfLeft.Y; + Unsafe.Add(ref Unsafe.Add(ref destLocalOrigo, (uint)destStride), 3) = selfLeft.Y; + Unsafe.Add(ref Unsafe.Add(ref destLocalOrigo, (uint)destStride), 4) = selfLeft.Z; + Unsafe.Add(ref Unsafe.Add(ref destLocalOrigo, (uint)destStride), 5) = selfLeft.Z; + Unsafe.Add(ref Unsafe.Add(ref destLocalOrigo, (uint)destStride), 6) = selfLeft.W; + Unsafe.Add(ref Unsafe.Add(ref destLocalOrigo, (uint)destStride), 7) = selfLeft.W; + + Unsafe.Add(ref Unsafe.Add(ref destLocalOrigo, (uint)destStride + 8), 0) = selfRight.X; + Unsafe.Add(ref Unsafe.Add(ref destLocalOrigo, (uint)destStride + 8), 1) = selfRight.X; + Unsafe.Add(ref Unsafe.Add(ref destLocalOrigo, (uint)destStride + 8), 2) = selfRight.Y; + Unsafe.Add(ref Unsafe.Add(ref destLocalOrigo, (uint)destStride + 8), 3) = selfRight.Y; + Unsafe.Add(ref Unsafe.Add(ref destLocalOrigo, (uint)destStride + 8), 4) = selfRight.Z; + Unsafe.Add(ref Unsafe.Add(ref destLocalOrigo, (uint)destStride + 8), 5) = selfRight.Z; + Unsafe.Add(ref Unsafe.Add(ref destLocalOrigo, (uint)destStride + 8), 6) = selfRight.W; + Unsafe.Add(ref Unsafe.Add(ref destLocalOrigo, (uint)destStride + 8), 7) = selfRight.W; } [Benchmark] @@ -109,9 +109,9 @@ public void Original_V2() [MethodImpl(MethodImplOptions.AggressiveInlining)] private static void WidenCopyImpl2x2_V2(ref Block8x8F src, ref float destBase, int row, int destStride) { - ref Vector4 selfLeft = ref Unsafe.Add(ref src.V0L, 2 * row); + ref Vector4 selfLeft = ref Unsafe.Add(ref src.V0L, 2 * (uint)row); ref Vector4 selfRight = ref Unsafe.Add(ref selfLeft, 1); - ref float dest0 = ref Unsafe.Add(ref destBase, row * 2 * destStride); + ref float dest0 = ref Unsafe.Add(ref destBase, (uint)(row * 2 * destStride)); Unsafe.Add(ref dest0, 0) = selfLeft.X; Unsafe.Add(ref dest0, 1) = selfLeft.X; @@ -133,7 +133,7 @@ private static void WidenCopyImpl2x2_V2(ref Block8x8F src, ref float destBase, i Unsafe.Add(ref dest1, 6) = selfRight.W; Unsafe.Add(ref dest1, 7) = selfRight.W; - ref float dest2 = ref Unsafe.Add(ref dest0, destStride); + ref float dest2 = ref Unsafe.Add(ref dest0, (uint)destStride); Unsafe.Add(ref dest2, 0) = selfLeft.X; Unsafe.Add(ref dest2, 1) = selfLeft.X; @@ -177,12 +177,12 @@ public void UseVector2() [MethodImpl(MethodImplOptions.AggressiveInlining)] private static void WidenCopyImpl2x2_Vector2(ref Block8x8F src, ref Vector2 destBase, int row, int destStride) { - ref Vector4 sLeft = ref Unsafe.Add(ref src.V0L, 2 * row); + ref Vector4 sLeft = ref Unsafe.Add(ref src.V0L, 2 * (uint)row); ref Vector4 sRight = ref Unsafe.Add(ref sLeft, 1); - ref Vector2 dTopLeft = ref Unsafe.Add(ref destBase, 2 * row * destStride); + ref Vector2 dTopLeft = ref Unsafe.Add(ref destBase, (uint)(2 * row * destStride)); ref Vector2 dTopRight = ref Unsafe.Add(ref dTopLeft, 4); - ref Vector2 dBottomLeft = ref Unsafe.Add(ref dTopLeft, destStride); + ref Vector2 dBottomLeft = ref Unsafe.Add(ref dTopLeft, (uint)destStride); ref Vector2 dBottomRight = ref Unsafe.Add(ref dBottomLeft, 4); var xLeft = new Vector2(sLeft.X); @@ -237,12 +237,12 @@ public void UseVector4() [MethodImpl(MethodImplOptions.AggressiveInlining)] private static void WidenCopyImpl2x2_Vector4(ref Block8x8F src, ref Vector2 destBase, int row, int destStride) { - ref Vector4 sLeft = ref Unsafe.Add(ref src.V0L, 2 * row); + ref Vector4 sLeft = ref Unsafe.Add(ref src.V0L, 2 * (uint)row); ref Vector4 sRight = ref Unsafe.Add(ref sLeft, 1); - ref Vector2 dTopLeft = ref Unsafe.Add(ref destBase, 2 * row * destStride); + ref Vector2 dTopLeft = ref Unsafe.Add(ref destBase, (uint)(2 * row * destStride)); ref Vector2 dTopRight = ref Unsafe.Add(ref dTopLeft, 4); - ref Vector2 dBottomLeft = ref Unsafe.Add(ref dTopLeft, destStride); + ref Vector2 dBottomLeft = ref Unsafe.Add(ref dTopLeft, (uint)destStride); ref Vector2 dBottomRight = ref Unsafe.Add(ref dBottomLeft, 4); var xLeft = new Vector4(sLeft.X); @@ -297,11 +297,11 @@ public void UseVector4_SafeRightCorner() [MethodImpl(MethodImplOptions.AggressiveInlining)] private static void WidenCopyImpl2x2_Vector4_SafeRightCorner(ref Block8x8F src, ref Vector2 destBase, int row, int destStride) { - ref Vector4 sLeft = ref Unsafe.Add(ref src.V0L, 2 * row); + ref Vector4 sLeft = ref Unsafe.Add(ref src.V0L, 2 * (uint)row); ref Vector4 sRight = ref Unsafe.Add(ref sLeft, 1); - ref Vector2 dTopLeft = ref Unsafe.Add(ref destBase, 2 * row * destStride); - ref Vector2 dBottomLeft = ref Unsafe.Add(ref dTopLeft, destStride); + ref Vector2 dTopLeft = ref Unsafe.Add(ref destBase, (uint)(2 * row * destStride)); + ref Vector2 dBottomLeft = ref Unsafe.Add(ref dTopLeft, (uint)destStride); var xLeft = new Vector4(sLeft.X); var yLeft = new Vector4(sLeft.Y); @@ -355,12 +355,12 @@ public void UseVector4_V2() [MethodImpl(MethodImplOptions.AggressiveInlining)] private static void WidenCopyImpl2x2_Vector4_V2(ref Block8x8F src, ref Vector2 destBase, int row, int destStride) { - ref Vector4 sLeft = ref Unsafe.Add(ref src.V0L, 2 * row); + ref Vector4 sLeft = ref Unsafe.Add(ref src.V0L, 2 * (uint)row); ref Vector4 sRight = ref Unsafe.Add(ref sLeft, 1); int offset = 2 * row * destStride; - ref Vector4 dTopLeft = ref Unsafe.As(ref Unsafe.Add(ref destBase, offset)); - ref Vector4 dBottomLeft = ref Unsafe.As(ref Unsafe.Add(ref destBase, offset + destStride)); + ref Vector4 dTopLeft = ref Unsafe.As(ref Unsafe.Add(ref destBase, (uint)offset)); + ref Vector4 dBottomLeft = ref Unsafe.As(ref Unsafe.Add(ref destBase, (uint)(offset + destStride))); var xyLeft = new Vector4(sLeft.X) { diff --git a/tests/ImageSharp.Benchmarks/Codecs/Jpeg/BlockOperations/Block8x8F_Round.cs b/tests/ImageSharp.Benchmarks/Codecs/Jpeg/BlockOperations/Block8x8F_Round.cs index afe9d94ae8..2cc084885f 100644 --- a/tests/ImageSharp.Benchmarks/Codecs/Jpeg/BlockOperations/Block8x8F_Round.cs +++ b/tests/ImageSharp.Benchmarks/Codecs/Jpeg/BlockOperations/Block8x8F_Round.cs @@ -54,7 +54,7 @@ public void ScalarRound() { ref float b = ref Unsafe.As(ref this.block); - for (int i = 0; i < Block8x8F.Size; i++) + for (nint i = 0; i < Block8x8F.Size; i++) { ref float v = ref Unsafe.Add(ref b, i); v = (float)Math.Round(v); @@ -178,7 +178,7 @@ public unsafe void Sse41_V2() { ref Vector128 p = ref Unsafe.As>(ref this.block); p = Sse41.RoundToNearestInteger(p); - var offset = (IntPtr)sizeof(Vector128); + nint offset = sizeof(Vector128); p = Sse41.RoundToNearestInteger(p); p = ref Unsafe.AddByteOffset(ref p, offset); @@ -218,7 +218,7 @@ public unsafe void Sse41_V3() { ref Vector128 p = ref Unsafe.As>(ref this.block); p = Sse41.RoundToNearestInteger(p); - var offset = (IntPtr)sizeof(Vector128); + nint offset = sizeof(Vector128); for (int i = 0; i < 15; i++) { @@ -231,7 +231,7 @@ public unsafe void Sse41_V3() public unsafe void Sse41_V4() { ref Vector128 p = ref Unsafe.As>(ref this.block); - var offset = (IntPtr)sizeof(Vector128); + nint offset = sizeof(Vector128); ref Vector128 a = ref p; ref Vector128 b = ref Unsafe.AddByteOffset(ref a, offset); diff --git a/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertFromRgba32.cs b/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertFromRgba32.cs index d418c45fe3..29e03111b9 100644 --- a/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertFromRgba32.cs +++ b/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertFromRgba32.cs @@ -34,7 +34,7 @@ public void RunByRefConversion() ref T destBaseRef = ref this.Dest[0]; ref Rgba32 sourceBaseRef = ref this.Source[0]; - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { Unsafe.Add(ref destBaseRef, i).FromRgba32(ref Unsafe.Add(ref sourceBaseRef, i)); } @@ -48,7 +48,7 @@ public void RunByValConversion() ref T destBaseRef = ref this.Dest[0]; ref Rgba32 sourceBaseRef = ref this.Source[0]; - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { Unsafe.Add(ref destBaseRef, i).FromRgba32(Unsafe.Add(ref sourceBaseRef, i)); } @@ -62,7 +62,7 @@ public void RunFromBytesConversion() ref T destBaseRef = ref this.Dest[0]; ref Rgba32 sourceBaseRef = ref this.Source[0]; - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref Rgba32 s = ref Unsafe.Add(ref sourceBaseRef, i); Unsafe.Add(ref destBaseRef, i).FromBytes(s.R, s.G, s.B, s.A); @@ -111,7 +111,7 @@ public void Inline() ref Rgba32 sBase = ref this.CompatibleMemLayoutRunner.Source[0]; ref Rgba32 dBase = ref Unsafe.As(ref this.CompatibleMemLayoutRunner.Dest[0]); - for (int i = 0; i < this.Count; i++) + for (nint i = 0; i < (uint)this.Count; i++) { Unsafe.Add(ref dBase, i) = Unsafe.Add(ref sBase, i); } @@ -151,7 +151,7 @@ public void InlineShuffle() ref Rgba32 sBase = ref this.PermutedRunnerRgbaToArgb.Source[0]; ref TestArgb dBase = ref this.PermutedRunnerRgbaToArgb.Dest[0]; - for (int i = 0; i < this.Count; i++) + for (nint i = 0; i < (uint)this.Count; i++) { Rgba32 s = Unsafe.Add(ref sBase, i); ref TestArgb d = ref Unsafe.Add(ref dBase, i); diff --git a/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertFromVector4.cs b/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertFromVector4.cs index a167ade12b..faf23efe09 100644 --- a/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertFromVector4.cs +++ b/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertFromVector4.cs @@ -71,7 +71,7 @@ public void RunByRefConversion() ref T destBaseRef = ref this.dest[0]; ref Vector4 sourceBaseRef = ref this.source[0]; - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { Unsafe.Add(ref destBaseRef, i).FromVector4(ref Unsafe.Add(ref sourceBaseRef, i)); } @@ -85,7 +85,7 @@ public void RunByValConversion() ref T destBaseRef = ref this.dest[0]; ref Vector4 sourceBaseRef = ref this.source[0]; - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { Unsafe.Add(ref destBaseRef, i).FromVector4(Unsafe.Add(ref sourceBaseRef, i)); } diff --git a/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertToRgba32.cs b/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertToRgba32.cs index cd8307614e..ef1ebdd429 100644 --- a/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertToRgba32.cs +++ b/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertToRgba32.cs @@ -38,7 +38,7 @@ public void RunRetvalConversion() ref T sourceBaseRef = ref this.source[0]; ref Rgba32 destBaseRef = ref this.dest[0]; - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { Unsafe.Add(ref destBaseRef, i) = Unsafe.Add(ref sourceBaseRef, i).ToRgba32(); } @@ -52,7 +52,7 @@ public void RunCopyToConversion() ref T sourceBaseRef = ref this.source[0]; ref Rgba32 destBaseRef = ref this.dest[0]; - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { Unsafe.Add(ref sourceBaseRef, i).CopyToRgba32(ref Unsafe.Add(ref destBaseRef, i)); } diff --git a/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertToRgba32_AsPartOfCompositeOperation.cs b/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertToRgba32_AsPartOfCompositeOperation.cs index 9ea0c04c77..29412e6ed6 100644 --- a/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertToRgba32_AsPartOfCompositeOperation.cs +++ b/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertToRgba32_AsPartOfCompositeOperation.cs @@ -33,7 +33,7 @@ public void RunRetvalConversion() Rgba32 temp; - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { temp = Unsafe.Add(ref sourceBaseRef, i).ToRgba32(); @@ -54,7 +54,7 @@ public void RunCopyToConversion() Rgba32 temp = default; - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { Unsafe.Add(ref sourceBaseRef, i).CopyToRgba32(ref temp); diff --git a/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertToVector4.cs b/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertToVector4.cs index c03560e106..29e8b00b6f 100644 --- a/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertToVector4.cs +++ b/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertToVector4.cs @@ -30,7 +30,7 @@ public void RunRetvalConversion() ref T sourceBaseRef = ref this.source[0]; ref Vector4 destBaseRef = ref this.dest[0]; - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { Unsafe.Add(ref destBaseRef, i) = Unsafe.Add(ref sourceBaseRef, i).ToVector4(); } @@ -44,7 +44,7 @@ public void RunCopyToConversion() ref T sourceBaseRef = ref this.source[0]; ref Vector4 destBaseRef = ref this.dest[0]; - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { Unsafe.Add(ref sourceBaseRef, i).CopyToVector4(ref Unsafe.Add(ref destBaseRef, i)); } diff --git a/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertToVector4_AsPartOfCompositeOperation.cs b/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertToVector4_AsPartOfCompositeOperation.cs index 462bbbf7b3..65b1717349 100644 --- a/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertToVector4_AsPartOfCompositeOperation.cs +++ b/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertToVector4_AsPartOfCompositeOperation.cs @@ -32,7 +32,7 @@ public void RunRetvalConversion() Vector4 temp; - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { temp = Unsafe.Add(ref sourceBaseRef, i).ToVector4(); @@ -53,7 +53,7 @@ public void RunCopyToConversion() Vector4 temp = default; - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { Unsafe.Add(ref sourceBaseRef, i).CopyToVector4(ref temp); diff --git a/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_PackFromRgbPlanes.cs b/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_PackFromRgbPlanes.cs index 061b1e1269..5c9bfd763a 100644 --- a/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_PackFromRgbPlanes.cs +++ b/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_PackFromRgbPlanes.cs @@ -92,7 +92,7 @@ public void Rgb24_Scalar_PerElement_Unsafe() ref byte b = ref this.rBuf[0]; ref Rgb24 rgb = ref this.rgbBuf[0]; - for (int i = 0; i < this.Count; i++) + for (nint i = 0; i < (uint)this.Count; i++) { ref Rgb24 d = ref Unsafe.Add(ref rgb, i); d.R = Unsafe.Add(ref r, i); @@ -110,7 +110,7 @@ public void Rgb24_Scalar_PerElement_Batched8() ref Rgb24 rgb = ref this.rgbBuf[0]; int count = this.Count / 8; - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref Rgb24 d0 = ref Unsafe.Add(ref rgb, i * 8); ref Rgb24 d1 = ref Unsafe.Add(ref d0, 1); @@ -168,7 +168,7 @@ public void Rgb24_Scalar_PerElement_Batched4() ref Rgb24 rgb = ref this.rgbBuf[0]; int count = this.Count / 4; - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref Rgb24 d0 = ref Unsafe.Add(ref rgb, i * 4); ref Rgb24 d1 = ref Unsafe.Add(ref d0, 1); diff --git a/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_Rgba32_To_Argb32.cs b/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_Rgba32_To_Argb32.cs index 9ae36cc8b7..f1d08b9fb9 100644 --- a/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_Rgba32_To_Argb32.cs +++ b/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_Rgba32_To_Argb32.cs @@ -31,7 +31,7 @@ public void Default() ref Rgba32 sBase = ref this.source[0]; ref Argb32 dBase = ref this.dest[0]; - for (int i = 0; i < this.Count; i++) + for (nint i = 0; i < (uint)this.Count; i++) { Rgba32 s = Unsafe.Add(ref sBase, i); Unsafe.Add(ref dBase, i).FromRgba32(s); @@ -45,7 +45,7 @@ private static void Default_GenericImpl(ReadOnlySpan source, Spa ref Rgba32 sBase = ref MemoryMarshal.GetReference(source); ref TPixel dBase = ref MemoryMarshal.GetReference(dest); - for (int i = 0; i < source.Length; i++) + for (nint i = 0; i < (uint)source.Length; i++) { Rgba32 s = Unsafe.Add(ref sBase, i); Unsafe.Add(ref dBase, i).FromRgba32(s); @@ -64,7 +64,7 @@ public void Default_Group2() ref Rgba32 sBase = ref this.source[0]; ref Argb32 dBase = ref this.dest[0]; - for (int i = 0; i < this.Count; i += 2) + for (nint i = 0; i < (uint)this.Count; i += 2) { ref Rgba32 s0 = ref Unsafe.Add(ref sBase, i); Rgba32 s1 = Unsafe.Add(ref s0, 1); @@ -81,7 +81,7 @@ public void Default_Group4() ref Rgba32 sBase = ref this.source[0]; ref Argb32 dBase = ref this.dest[0]; - for (int i = 0; i < this.Count; i += 4) + for (nint i = 0; i < (uint)this.Count; i += 4) { ref Rgba32 s0 = ref Unsafe.Add(ref sBase, i); ref Rgba32 s1 = ref Unsafe.Add(ref s0, 1); @@ -105,7 +105,7 @@ public void BitOps() ref uint sBase = ref Unsafe.As(ref this.source[0]); ref uint dBase = ref Unsafe.As(ref this.dest[0]); - for (int i = 0; i < this.Count; i++) + for (nint i = 0; i < (uint)this.Count; i++) { uint s = Unsafe.Add(ref sBase, i); Unsafe.Add(ref dBase, i) = FromRgba32.ToArgb32(s); @@ -118,7 +118,7 @@ public void BitOps_GroupAsULong() ref ulong sBase = ref Unsafe.As(ref this.source[0]); ref ulong dBase = ref Unsafe.As(ref this.dest[0]); - for (int i = 0; i < this.Count / 2; i++) + for (nint i = 0; i < (uint)this.Count / 2; i++) { ulong s = Unsafe.Add(ref sBase, i); uint lo = (uint)s; diff --git a/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_Rgba32_To_Bgra32.cs b/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_Rgba32_To_Bgra32.cs index b7b9392379..0da28c897d 100644 --- a/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_Rgba32_To_Bgra32.cs +++ b/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_Rgba32_To_Bgra32.cs @@ -52,7 +52,7 @@ public void Default() ref Rgba32 sBase = ref this.source[0]; ref Bgra32 dBase = ref this.dest[0]; - for (int i = 0; i < this.Count; i++) + for (nint i = 0; i < (uint)this.Count; i++) { ref Rgba32 s = ref Unsafe.Add(ref sBase, i); Unsafe.Add(ref dBase, i).FromRgba32(s); @@ -66,7 +66,7 @@ private static void Default_GenericImpl(ReadOnlySpan source, Spa ref Rgba32 sBase = ref MemoryMarshal.GetReference(source); ref TPixel dBase = ref MemoryMarshal.GetReference(dest); - for (int i = 0; i < source.Length; i++) + for (nint i = 0; i < (uint)source.Length; i++) { ref Rgba32 s = ref Unsafe.Add(ref sBase, i); Unsafe.Add(ref dBase, i).FromRgba32(s); @@ -85,7 +85,7 @@ public void Default_Group2() ref Rgba32 sBase = ref this.source[0]; ref Bgra32 dBase = ref this.dest[0]; - for (int i = 0; i < this.Count; i += 2) + for (nint i = 0; i < (uint)this.Count; i += 2) { ref Rgba32 s0 = ref Unsafe.Add(ref sBase, i); Rgba32 s1 = Unsafe.Add(ref s0, 1); @@ -102,7 +102,7 @@ public void Default_Group4() ref Rgba32 sBase = ref this.source[0]; ref Bgra32 dBase = ref this.dest[0]; - for (int i = 0; i < this.Count; i += 4) + for (nint i = 0; i < (uint)this.Count; i += 4) { ref Rgba32 s0 = ref Unsafe.Add(ref sBase, i); ref Rgba32 s1 = ref Unsafe.Add(ref s0, 1); @@ -127,7 +127,7 @@ private static void Group4GenericImpl(ReadOnlySpan source, Span< ref Rgba32 sBase = ref MemoryMarshal.GetReference(source); ref TPixel dBase = ref MemoryMarshal.GetReference(dest); - for (int i = 0; i < source.Length; i += 4) + for (nint i = 0; i < (uint)source.Length; i += 4) { ref Rgba32 s0 = ref Unsafe.Add(ref sBase, i); ref Rgba32 s1 = ref Unsafe.Add(ref s0, 1); @@ -157,7 +157,7 @@ public void Default_Group8() ref Rgba32 sBase = ref this.source[0]; ref Bgra32 dBase = ref this.dest[0]; - for (int i = 0; i < this.Count / 4; i += 4) + for (nint i = 0; i < (uint)this.Count / 4; i += 4) { ref Rgba32 s0 = ref Unsafe.Add(ref sBase, i); ref Rgba32 s1 = ref Unsafe.Add(ref s0, 1); @@ -196,7 +196,7 @@ public void BitOps() ref uint sBase = ref Unsafe.As(ref this.source[0]); ref uint dBase = ref Unsafe.As(ref this.dest[0]); - for (int i = 0; i < this.Count; i++) + for (nint i = 0; i < (uint)this.Count; i++) { uint s = Unsafe.Add(ref sBase, i); Unsafe.Add(ref dBase, i) = FromRgba32.ToBgra32(s); @@ -209,7 +209,7 @@ public void Bitops_Tuple() ref Tuple4OfUInt32 sBase = ref Unsafe.As(ref this.source[0]); ref Tuple4OfUInt32 dBase = ref Unsafe.As(ref this.dest[0]); - for (int i = 0; i < this.Count / 4; i++) + for (nint i = 0; i < (uint)this.Count / 4; i++) { ref Tuple4OfUInt32 d = ref Unsafe.Add(ref dBase, i); d = Unsafe.Add(ref sBase, i); @@ -222,7 +222,7 @@ public void Bitops_SingleTuple() { ref Tuple4OfUInt32 sBase = ref Unsafe.As(ref this.source[0]); - for (int i = 0; i < this.Count / 4; i++) + for (nint i = 0; i < (uint)this.Count / 4; i++) { Unsafe.Add(ref sBase, i).ConvertMe(); } @@ -234,7 +234,7 @@ public void Bitops_Simd() ref Octet sBase = ref Unsafe.As>(ref this.source[0]); ref Octet dBase = ref Unsafe.As>(ref this.dest[0]); - for (int i = 0; i < this.Count / 8; i++) + for (nint i = 0; i < (uint)this.Count / 8; i++) { BitopsSimdImpl(ref Unsafe.Add(ref sBase, i), ref Unsafe.Add(ref dBase, i)); } @@ -289,7 +289,7 @@ public void BitOps_Group2() ref uint sBase = ref Unsafe.As(ref this.source[0]); ref uint dBase = ref Unsafe.As(ref this.dest[0]); - for (int i = 0; i < this.Count; i++) + for (nint i = 0; i < (uint)this.Count; i++) { ref uint s0 = ref Unsafe.Add(ref sBase, i); uint s1 = Unsafe.Add(ref s0, 1); @@ -306,7 +306,7 @@ public void BitOps_GroupAsULong() ref ulong sBase = ref Unsafe.As(ref this.source[0]); ref ulong dBase = ref Unsafe.As(ref this.dest[0]); - for (int i = 0; i < this.Count / 2; i++) + for (nint i = 0; i < (uint)this.Count / 2; i++) { ulong s = Unsafe.Add(ref sBase, i); uint lo = (uint)s; @@ -326,7 +326,7 @@ public void BitOps_GroupAsULong_V2() ref ulong sBase = ref Unsafe.As(ref this.source[0]); ref ulong dBase = ref Unsafe.As(ref this.dest[0]); - for (int i = 0; i < this.Count / 2; i++) + for (nint i = 0; i < (uint)this.Count / 2; i++) { ulong s = Unsafe.Add(ref sBase, i); uint lo = (uint)s; diff --git a/tests/ImageSharp.Benchmarks/General/Vectorization/WidenBytesToUInt32.cs b/tests/ImageSharp.Benchmarks/General/Vectorization/WidenBytesToUInt32.cs index 4615376a5f..586618fcb1 100644 --- a/tests/ImageSharp.Benchmarks/General/Vectorization/WidenBytesToUInt32.cs +++ b/tests/ImageSharp.Benchmarks/General/Vectorization/WidenBytesToUInt32.cs @@ -33,7 +33,7 @@ public void Standard() ref Octet sBase = ref Unsafe.As>(ref this.source[0]); ref Octet dBase = ref Unsafe.As>(ref this.dest[0]); - for (int i = 0; i < N; i++) + for (nint i = 0; i < N; i++) { Unsafe.Add(ref dBase, i).LoadFrom(ref Unsafe.Add(ref sBase, i)); } diff --git a/tests/ImageSharp.Benchmarks/PixelBlenders/PorterDuffBulkVsSingleVector.cs b/tests/ImageSharp.Benchmarks/PixelBlenders/PorterDuffBulkVsSingleVector.cs index fcf7e9dcce..33f5720aab 100644 --- a/tests/ImageSharp.Benchmarks/PixelBlenders/PorterDuffBulkVsSingleVector.cs +++ b/tests/ImageSharp.Benchmarks/PixelBlenders/PorterDuffBulkVsSingleVector.cs @@ -58,7 +58,7 @@ public Vector256 OverlayValueFunction_Avx() Vector256 result = default; Vector256 opacity = Vector256.Create(.5F); int count = this.backdrop.Length / 2; - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { result = PorterDuffFunctions.NormalSrcOver(Unsafe.Add(ref backdrop, i), Unsafe.Add(ref source, i), opacity); } diff --git a/tests/ImageSharp.Tests/Formats/Png/ReferenceImplementations.cs b/tests/ImageSharp.Tests/Formats/Png/ReferenceImplementations.cs index d57a775876..7610023afc 100644 --- a/tests/ImageSharp.Tests/Formats/Png/ReferenceImplementations.cs +++ b/tests/ImageSharp.Tests/Formats/Png/ReferenceImplementations.cs @@ -34,8 +34,8 @@ public static void EncodePaethFilter(ReadOnlySpan scanline, Span pre // Paeth(x) = Raw(x) - PaethPredictor(Raw(x-bpp), Prior(x), Prior(x - bpp)) resultBaseRef = 4; - int x = 0; - for (; x < bytesPerPixel; /* Note: ++x happens in the body to avoid one add operation */) + nint x = 0; + for (; x < (nint)(uint)bytesPerPixel; /* Note: ++x happens in the body to avoid one add operation */) { byte scan = Unsafe.Add(ref scanBaseRef, x); byte above = Unsafe.Add(ref prevBaseRef, x); @@ -45,7 +45,7 @@ public static void EncodePaethFilter(ReadOnlySpan scanline, Span pre sum += Numerics.Abs(unchecked((sbyte)res)); } - for (int xLeft = x - bytesPerPixel; x < scanline.Length; ++xLeft /* Note: ++x happens in the body to avoid one add operation */) + for (nint xLeft = x - (nint)(uint)bytesPerPixel; x < (nint)(uint)scanline.Length; ++xLeft /* Note: ++x happens in the body to avoid one add operation */) { byte scan = Unsafe.Add(ref scanBaseRef, x); byte left = Unsafe.Add(ref scanBaseRef, xLeft); @@ -77,8 +77,8 @@ public static void EncodeSubFilter(ReadOnlySpan scanline, Span resul // Sub(x) = Raw(x) - Raw(x-bpp) resultBaseRef = 1; - int x = 0; - for (; x < bytesPerPixel; /* Note: ++x happens in the body to avoid one add operation */) + nint x = 0; + for (; x < (nint)(uint)bytesPerPixel; /* Note: ++x happens in the body to avoid one add operation */) { byte scan = Unsafe.Add(ref scanBaseRef, x); ++x; @@ -87,7 +87,7 @@ public static void EncodeSubFilter(ReadOnlySpan scanline, Span resul sum += Numerics.Abs(unchecked((sbyte)res)); } - for (int xLeft = x - bytesPerPixel; x < scanline.Length; ++xLeft /* Note: ++x happens in the body to avoid one add operation */) + for (nint xLeft = x - (nint)(uint)bytesPerPixel; x < (nint)(uint)scanline.Length; ++xLeft /* Note: ++x happens in the body to avoid one add operation */) { byte scan = Unsafe.Add(ref scanBaseRef, x); byte prev = Unsafe.Add(ref scanBaseRef, xLeft); @@ -119,9 +119,9 @@ public static void EncodeUpFilter(ReadOnlySpan scanline, Span previo // Up(x) = Raw(x) - Prior(x) resultBaseRef = 2; - int x = 0; + nint x = 0; - for (; x < scanline.Length; /* Note: ++x happens in the body to avoid one add operation */) + for (; x < (nint)(uint)scanline.Length; /* Note: ++x happens in the body to avoid one add operation */) { byte scan = Unsafe.Add(ref scanBaseRef, x); byte above = Unsafe.Add(ref prevBaseRef, x); @@ -154,8 +154,8 @@ public static void EncodeAverageFilter(ReadOnlySpan scanline, ReadOnlySpan // Average(x) = Raw(x) - floor((Raw(x-bpp)+Prior(x))/2) resultBaseRef = 3; - int x = 0; - for (; x < bytesPerPixel; /* Note: ++x happens in the body to avoid one add operation */) + nint x = 0; + for (; x < (nint)(uint)bytesPerPixel; /* Note: ++x happens in the body to avoid one add operation */) { byte scan = Unsafe.Add(ref scanBaseRef, x); byte above = Unsafe.Add(ref prevBaseRef, x); @@ -165,7 +165,7 @@ public static void EncodeAverageFilter(ReadOnlySpan scanline, ReadOnlySpan sum += Numerics.Abs(unchecked((sbyte)res)); } - for (int xLeft = x - bytesPerPixel; x < scanline.Length; ++xLeft /* Note: ++x happens in the body to avoid one add operation */) + for (nint xLeft = x - (nint)(uint)bytesPerPixel; x < (nint)(uint)scanline.Length; ++xLeft /* Note: ++x happens in the body to avoid one add operation */) { byte scan = Unsafe.Add(ref scanBaseRef, x); byte left = Unsafe.Add(ref scanBaseRef, xLeft); diff --git a/tests/ImageSharp.Tests/PixelFormats/PixelConverterTests.ReferenceImplementations.cs b/tests/ImageSharp.Tests/PixelFormats/PixelConverterTests.ReferenceImplementations.cs index 006cb9eb61..521270e3be 100644 --- a/tests/ImageSharp.Tests/PixelFormats/PixelConverterTests.ReferenceImplementations.cs +++ b/tests/ImageSharp.Tests/PixelFormats/PixelConverterTests.ReferenceImplementations.cs @@ -100,7 +100,7 @@ internal static void To( if (typeof(TDestinationPixel) == typeof(L16)) { ref L16 l16Ref = ref MemoryMarshal.GetReference(MemoryMarshal.Cast(destinationPixels)); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref TSourcePixel sp = ref Unsafe.Add(ref sourceRef, i); ref L16 dp = ref Unsafe.Add(ref l16Ref, i); @@ -113,7 +113,7 @@ internal static void To( if (typeof(TDestinationPixel) == typeof(L8)) { ref L8 l8Ref = ref MemoryMarshal.GetReference(MemoryMarshal.Cast(destinationPixels)); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref TSourcePixel sp = ref Unsafe.Add(ref sourceRef, i); ref L8 dp = ref Unsafe.Add(ref l8Ref, i); @@ -125,7 +125,7 @@ internal static void To( // Normal conversion ref TDestinationPixel destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (int i = 0; i < count; i++) + for (nint i = 0; i < (uint)count; i++) { ref TSourcePixel sp = ref Unsafe.Add(ref sourceRef, i); ref TDestinationPixel dp = ref Unsafe.Add(ref destRef, i); diff --git a/tests/ImageSharp.Tests/PixelFormats/PixelOperations/PixelOperationsTests.cs b/tests/ImageSharp.Tests/PixelFormats/PixelOperations/PixelOperationsTests.cs index a9b3ee9a42..73305183f6 100644 --- a/tests/ImageSharp.Tests/PixelFormats/PixelOperations/PixelOperationsTests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/PixelOperations/PixelOperationsTests.cs @@ -1184,7 +1184,7 @@ public byte this[int idx] get { ref byte self = ref Unsafe.As(ref this); - return Unsafe.Add(ref self, idx); + return Unsafe.Add(ref self, (uint)idx); } } } From 1faf5a599d97c9851c999e68eafb15df2da49137 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=BCnther=20Foidl?= Date: Mon, 13 Mar 2023 17:11:53 +0100 Subject: [PATCH 03/12] Removed some bound checks for arr[0] indexing to get a reference --- src/ImageSharp/Compression/Zlib/DeflaterEngine.cs | 5 +++-- .../Jpeg/Components/Decoder/ArithmeticScanDecoder.cs | 5 +++-- .../Jpeg/Components/Decoder/ArithmeticStatistics.cs | 4 +++- src/ImageSharp/Formats/Png/PngScanlineProcessor.cs | 4 ++-- src/ImageSharp/Formats/Tga/TgaDecoderCore.cs | 7 ++++--- .../Processors/Convolution/BokehBlurProcessor.cs | 2 +- .../Processors/Convolution/BokehBlurProcessor{TPixel}.cs | 2 +- .../Convolution/Convolution2PassProcessor{TPixel}.cs | 8 ++++---- .../Convolution/Parameters/BokehBlurKernelDataProvider.cs | 4 ++-- .../Processors/Quantization/WuQuantizer{TPixel}.cs | 2 +- 10 files changed, 24 insertions(+), 19 deletions(-) diff --git a/src/ImageSharp/Compression/Zlib/DeflaterEngine.cs b/src/ImageSharp/Compression/Zlib/DeflaterEngine.cs index 31fa0238bf..6009fdfbc0 100644 --- a/src/ImageSharp/Compression/Zlib/DeflaterEngine.cs +++ b/src/ImageSharp/Compression/Zlib/DeflaterEngine.cs @@ -3,6 +3,7 @@ using System.Buffers; using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; using SixLabors.ImageSharp.Memory; namespace SixLabors.ImageSharp.Compression.Zlib; @@ -426,8 +427,8 @@ private int InsertString() private void SlideWindow() { Unsafe.CopyBlockUnaligned( - ref this.window.Span[0], - ref this.window.Span[DeflaterConstants.WSIZE], + ref MemoryMarshal.GetReference(this.window.Span), + ref Unsafe.Add(ref MemoryMarshal.GetReference(this.window.Span), DeflaterConstants.WSIZE), DeflaterConstants.WSIZE); this.matchStart -= DeflaterConstants.WSIZE; diff --git a/src/ImageSharp/Formats/Jpeg/Components/Decoder/ArithmeticScanDecoder.cs b/src/ImageSharp/Formats/Jpeg/Components/Decoder/ArithmeticScanDecoder.cs index 59789dcd25..1b043b68f2 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/Decoder/ArithmeticScanDecoder.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/Decoder/ArithmeticScanDecoder.cs @@ -53,7 +53,8 @@ internal class ArithmeticScanDecoder : IJpegScanDecoder private ArithmeticDecodingTable[] acDecodingTables; - private readonly byte[] fixedBin = { 113, 0, 0, 0 }; + // Use C#'s optimization to refer to assembly's data segment, no allocation occurs. + private ReadOnlySpan fixedBin => new byte[] { 113, 0, 0, 0 }; private readonly CancellationToken cancellationToken; @@ -231,7 +232,7 @@ public void InitDecodingTables(List arithmeticDecodingT } } - private ref byte GetFixedBinReference() => ref this.fixedBin[0]; + private ref byte GetFixedBinReference() => ref MemoryMarshal.GetReference(fixedBin); /// /// Decodes the entropy coded data. diff --git a/src/ImageSharp/Formats/Jpeg/Components/Decoder/ArithmeticStatistics.cs b/src/ImageSharp/Formats/Jpeg/Components/Decoder/ArithmeticStatistics.cs index 1e890d8269..9bd4110d07 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/Decoder/ArithmeticStatistics.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/Decoder/ArithmeticStatistics.cs @@ -1,6 +1,8 @@ // Copyright (c) Six Labors. // Licensed under the Six Labors Split License. +using System.Runtime.InteropServices; + namespace SixLabors.ImageSharp.Formats.Jpeg.Components.Decoder; internal class ArithmeticStatistics @@ -18,7 +20,7 @@ public ArithmeticStatistics(bool dc, int identifier) public int Identifier { get; private set; } - public ref byte GetReference() => ref this.statistics[0]; + public ref byte GetReference() => ref MemoryMarshal.GetArrayDataReference(this.statistics); public ref byte GetReference(int offset) => ref this.statistics[offset]; diff --git a/src/ImageSharp/Formats/Png/PngScanlineProcessor.cs b/src/ImageSharp/Formats/Png/PngScanlineProcessor.cs index 25c4a0d700..51b23242c8 100644 --- a/src/ImageSharp/Formats/Png/PngScanlineProcessor.cs +++ b/src/ImageSharp/Formats/Png/PngScanlineProcessor.cs @@ -255,7 +255,7 @@ public static void ProcessPaletteScanline( // If the alpha palette is not null and has one or more entries, this means, that the image contains an alpha // channel and we should try to read it. Rgba32 rgba = default; - ref byte paletteAlphaRef = ref paletteAlpha[0]; + ref byte paletteAlphaRef = ref MemoryMarshal.GetArrayDataReference(paletteAlpha); for (int x = 0; x < header.Width; x++) { @@ -301,7 +301,7 @@ public static void ProcessInterlacedPaletteScanline( // If the alpha palette is not null and has one or more entries, this means, that the image contains an alpha // channel and we should try to read it. Rgba32 rgba = default; - ref byte paletteAlphaRef = ref paletteAlpha[0]; + ref byte paletteAlphaRef = ref MemoryMarshal.GetArrayDataReference(paletteAlpha); for (int x = pixelOffset, o = 0; x < header.Width; x += increment, o++) { int index = Unsafe.Add(ref scanlineSpanRef, (uint)o); diff --git a/src/ImageSharp/Formats/Tga/TgaDecoderCore.cs b/src/ImageSharp/Formats/Tga/TgaDecoderCore.cs index ce4f566b87..e7dca00f79 100644 --- a/src/ImageSharp/Formats/Tga/TgaDecoderCore.cs +++ b/src/ImageSharp/Formats/Tga/TgaDecoderCore.cs @@ -4,6 +4,7 @@ using System.Buffers; using System.Diagnostics.CodeAnalysis; using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; using SixLabors.ImageSharp.IO; using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.Metadata; @@ -429,11 +430,11 @@ private void ReadBgra16(BufferedReadStream stream, int width, int height if (this.fileHeader.ImageType == TgaImageType.BlackAndWhite) { - color.FromLa16(Unsafe.As(ref this.scratchBuffer[0])); + color.FromLa16(Unsafe.As(ref MemoryMarshal.GetArrayDataReference(this.scratchBuffer))); } else { - color.FromBgra5551(Unsafe.As(ref this.scratchBuffer[0])); + color.FromBgra5551(Unsafe.As(ref MemoryMarshal.GetArrayDataReference(this.scratchBuffer))); } pixelSpan[x] = color; @@ -695,7 +696,7 @@ private void ReadBgr24Pixel(BufferedReadStream stream, TPixel color, int TgaThrowHelper.ThrowInvalidImageContentException("Not enough data to read a bgr pixel"); } - color.FromBgr24(Unsafe.As(ref this.scratchBuffer[0])); + color.FromBgr24(Unsafe.As(ref MemoryMarshal.GetArrayDataReference(this.scratchBuffer))); pixelSpan[x] = color; } diff --git a/src/ImageSharp/Processing/Processors/Convolution/BokehBlurProcessor.cs b/src/ImageSharp/Processing/Processors/Convolution/BokehBlurProcessor.cs index 04653bd6ec..bc023ec450 100644 --- a/src/ImageSharp/Processing/Processors/Convolution/BokehBlurProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Convolution/BokehBlurProcessor.cs @@ -133,7 +133,7 @@ public void Invoke(int y) // The target buffer is zeroed initially and then it accumulates the results // of each partial convolution, so we don't have to clear it here as well ref Vector4 targetBase = ref this.targetValues.GetElementUnsafe(boundsX, y); - ref Complex64 kernelStart = ref this.kernel[0]; + ref Complex64 kernelStart = ref MemoryMarshal.GetArrayDataReference(this.kernel); ref Complex64 kernelEnd = ref Unsafe.Add(ref kernelStart, (uint)kernelSize); while (Unsafe.IsAddressLessThan(ref kernelStart, ref kernelEnd)) diff --git a/src/ImageSharp/Processing/Processors/Convolution/BokehBlurProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Convolution/BokehBlurProcessor{TPixel}.cs index 2508a7da25..e4b0a60ab0 100644 --- a/src/ImageSharp/Processing/Processors/Convolution/BokehBlurProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Convolution/BokehBlurProcessor{TPixel}.cs @@ -244,7 +244,7 @@ public void Invoke(int y, Span span) ref Vector4 sourceBase = ref MemoryMarshal.GetReference(span); ref ComplexVector4 targetStart = ref MemoryMarshal.GetReference(targetBuffer); ref ComplexVector4 targetEnd = ref Unsafe.Add(ref targetStart, (uint)span.Length); - ref Complex64 kernelBase = ref this.kernel[0]; + ref Complex64 kernelBase = ref MemoryMarshal.GetArrayDataReference(this.kernel); ref Complex64 kernelEnd = ref Unsafe.Add(ref kernelBase, (uint)kernelSize); ref int sampleColumnBase = ref MemoryMarshal.GetReference(this.map.GetColumnOffsetSpan()); diff --git a/src/ImageSharp/Processing/Processors/Convolution/Convolution2PassProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Convolution/Convolution2PassProcessor{TPixel}.cs index b09db9fa05..cc6e1e5fb2 100644 --- a/src/ImageSharp/Processing/Processors/Convolution/Convolution2PassProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Convolution/Convolution2PassProcessor{TPixel}.cs @@ -179,7 +179,7 @@ private void Convolve3(int y, Span span) ref Vector4 sourceBase = ref MemoryMarshal.GetReference(sourceBuffer); ref Vector4 targetStart = ref MemoryMarshal.GetReference(targetBuffer); ref Vector4 targetEnd = ref Unsafe.Add(ref targetStart, (uint)sourceBuffer.Length); - ref float kernelBase = ref this.kernel[0]; + ref float kernelBase = ref MemoryMarshal.GetArrayDataReference(this.kernel); ref float kernelEnd = ref Unsafe.Add(ref kernelBase, (uint)kernelSize); ref int sampleColumnBase = ref MemoryMarshal.GetReference(this.map.GetColumnOffsetSpan()); @@ -243,7 +243,7 @@ private void Convolve4(int y, Span span) ref Vector4 sourceBase = ref MemoryMarshal.GetReference(sourceBuffer); ref Vector4 targetStart = ref MemoryMarshal.GetReference(targetBuffer); ref Vector4 targetEnd = ref Unsafe.Add(ref targetStart, (uint)sourceBuffer.Length); - ref float kernelBase = ref this.kernel[0]; + ref float kernelBase = ref MemoryMarshal.GetArrayDataReference(this.kernel); ref float kernelEnd = ref Unsafe.Add(ref kernelBase, (uint)kernelSize); ref int sampleColumnBase = ref MemoryMarshal.GetReference(this.map.GetColumnOffsetSpan()); @@ -341,7 +341,7 @@ private void Convolve3(int y, Span span) targetBuffer.Clear(); ref Vector4 targetBase = ref MemoryMarshal.GetReference(targetBuffer); - ref float kernelStart = ref this.kernel[0]; + ref float kernelStart = ref MemoryMarshal.GetArrayDataReference(this.kernel); ref float kernelEnd = ref Unsafe.Add(ref kernelStart, (uint)kernelSize); Span sourceRow; @@ -406,7 +406,7 @@ private void Convolve4(int y, Span span) targetBuffer.Clear(); ref Vector4 targetBase = ref MemoryMarshal.GetReference(targetBuffer); - ref float kernelStart = ref this.kernel[0]; + ref float kernelStart = ref MemoryMarshal.GetArrayDataReference(this.kernel); ref float kernelEnd = ref Unsafe.Add(ref kernelStart, (uint)kernelSize); Span sourceRow; diff --git a/src/ImageSharp/Processing/Processors/Convolution/Parameters/BokehBlurKernelDataProvider.cs b/src/ImageSharp/Processing/Processors/Convolution/Parameters/BokehBlurKernelDataProvider.cs index 8f501da23e..a680393c8c 100644 --- a/src/ImageSharp/Processing/Processors/Convolution/Parameters/BokehBlurKernelDataProvider.cs +++ b/src/ImageSharp/Processing/Processors/Convolution/Parameters/BokehBlurKernelDataProvider.cs @@ -192,7 +192,7 @@ private static void NormalizeKernels(Complex64[][] kernels, Vector4[] kernelPara { ref Complex64[] kernelRef = ref Unsafe.Add(ref baseKernelsRef, (uint)i); int length = kernelRef.Length; - ref Complex64 valueRef = ref kernelRef[0]; + ref Complex64 valueRef = ref MemoryMarshal.GetArrayDataReference(kernelRef); ref Vector4 paramsRef = ref Unsafe.Add(ref baseParamsRef, (uint)i); for (int j = 0; j < length; j++) @@ -214,7 +214,7 @@ private static void NormalizeKernels(Complex64[][] kernels, Vector4[] kernelPara { ref Complex64[] kernelsRef = ref Unsafe.Add(ref baseKernelsRef, (uint)i); int length = kernelsRef.Length; - ref Complex64 valueRef = ref kernelsRef[0]; + ref Complex64 valueRef = ref MemoryMarshal.GetArrayDataReference(kernelsRef); for (int j = 0; j < length; j++) { diff --git a/src/ImageSharp/Processing/Processors/Quantization/WuQuantizer{TPixel}.cs b/src/ImageSharp/Processing/Processors/Quantization/WuQuantizer{TPixel}.cs index edf293d39e..a231d6dee7 100644 --- a/src/ImageSharp/Processing/Processors/Quantization/WuQuantizer{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Quantization/WuQuantizer{TPixel}.cs @@ -684,7 +684,7 @@ private void BuildCube() using IMemoryOwner vvOwner = this.Configuration.MemoryAllocator.Allocate(this.maxColors); Span vv = vvOwner.GetSpan(); - ref Box cube = ref this.colorCube[0]; + ref Box cube = ref MemoryMarshal.GetArrayDataReference(this.colorCube); cube.RMin = cube.GMin = cube.BMin = cube.AMin = 0; cube.RMax = cube.GMax = cube.BMax = IndexCount - 1; cube.AMax = IndexAlphaCount - 1; From 9b7e41f6ca10dbd5cbded4d436f7ed8ebc487c3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=BCnther=20Foidl?= Date: Mon, 13 Mar 2023 18:25:23 +0100 Subject: [PATCH 04/12] Optimized division by constants --- .../Converters/CieXyzToCieLabConverter.cs | 10 ++++--- src/ImageSharp/Common/Helpers/HexConverter.cs | 14 +++++----- .../Helpers/Shuffle/IComponentShuffle.cs | 10 +++---- .../SimdUtils.FallbackIntrinsics128.cs | 4 +-- .../Common/Helpers/SimdUtils.HwIntrinsics.cs | 4 +-- .../Compression/Zlib/DeflaterHuffman.cs | 6 ++--- src/ImageSharp/Formats/Bmp/BmpDecoderCore.cs | 2 +- src/ImageSharp/Formats/Bmp/BmpEncoderCore.cs | 2 +- .../Jpeg/Components/Block8x8F.Generated.cs | 4 +-- .../Jpeg/Components/Block8x8F.Generated.tt | 4 +-- .../ColorConverters/JpegColorConverterBase.cs | 2 +- .../DownScalingComponentProcessor2.cs | 2 +- .../DownScalingComponentProcessor4.cs | 2 +- .../DownScalingComponentProcessor8.cs | 2 +- .../Components/Encoder/HuffmanScanEncoder.cs | 2 +- .../Jpeg/Components/ScaledFloatingPointDCT.cs | 24 ++++++++--------- src/ImageSharp/Formats/Png/Adam7.cs | 26 ++++++++++++------- .../Tiff/Compression/TiffBaseCompression.cs | 2 +- .../Formats/Tiff/TiffDecoderCore.cs | 2 +- .../Writers/TiffBaseColorWriter{TPixel}.cs | 2 +- .../Formats/Webp/BitWriter/Vp8BitWriter.cs | 2 +- .../Formats/Webp/Lossless/HistogramEncoder.cs | 4 +-- .../Formats/Webp/Lossless/HuffmanUtils.cs | 4 +-- .../Formats/Webp/Lossless/LosslessUtils.cs | 7 ++++- .../Formats/Webp/Lossless/Vp8LEncoder.cs | 4 +-- .../Formats/Webp/Lossless/Vp8LHashChain.cs | 4 +-- .../Formats/Webp/Lossy/Vp8Encoder.cs | 6 ++--- .../Formats/Webp/Lossy/WebpLossyDecoder.cs | 2 +- src/ImageSharp/IO/ChunkedMemoryStream.cs | 2 +- ...iformUnmanagedMemoryPoolMemoryAllocator.cs | 2 +- src/ImageSharp/Primitives/Rectangle.cs | 2 +- .../BinaryThresholdProcessor{TPixel}.cs | 11 ++++---- ...eHistogramEqualizationProcessor{TPixel}.cs | 8 +++--- ...alizationSlidingWindowProcessor{TPixel}.cs | 2 +- .../Linear/FlipProcessor{TPixel}.cs | 2 +- .../Transforms/Resize/ResizeHelper.cs | 12 ++++----- 36 files changed, 106 insertions(+), 94 deletions(-) diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Converters/CieXyzToCieLabConverter.cs b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Converters/CieXyzToCieLabConverter.cs index df7686c316..0ce6e3c9ff 100644 --- a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Converters/CieXyzToCieLabConverter.cs +++ b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Converters/CieXyzToCieLabConverter.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors. +// Copyright (c) Six Labors. // Licensed under the Six Labors Split License. using System.Runtime.CompilerServices; @@ -42,9 +42,11 @@ public CieLab Convert(in CieXyz input) float xr = input.X / wx, yr = input.Y / wy, zr = input.Z / wz; - float fx = xr > CieConstants.Epsilon ? MathF.Pow(xr, 0.3333333F) : ((CieConstants.Kappa * xr) + 16F) / 116F; - float fy = yr > CieConstants.Epsilon ? MathF.Pow(yr, 0.3333333F) : ((CieConstants.Kappa * yr) + 16F) / 116F; - float fz = zr > CieConstants.Epsilon ? MathF.Pow(zr, 0.3333333F) : ((CieConstants.Kappa * zr) + 16F) / 116F; + const float inv116 = 1 / 116F; + + float fx = xr > CieConstants.Epsilon ? MathF.Pow(xr, 0.3333333F) : ((CieConstants.Kappa * xr) + 16F) * inv116; + float fy = yr > CieConstants.Epsilon ? MathF.Pow(yr, 0.3333333F) : ((CieConstants.Kappa * yr) + 16F) * inv116; + float fz = zr > CieConstants.Epsilon ? MathF.Pow(zr, 0.3333333F) : ((CieConstants.Kappa * zr) + 16F) * inv116; float l = (116F * fy) - 16F; float a = 500F * (fx - fy); diff --git a/src/ImageSharp/Common/Helpers/HexConverter.cs b/src/ImageSharp/Common/Helpers/HexConverter.cs index 7ec0ca625c..3c863cc37c 100644 --- a/src/ImageSharp/Common/Helpers/HexConverter.cs +++ b/src/ImageSharp/Common/Helpers/HexConverter.cs @@ -16,21 +16,19 @@ internal static class HexConverter /// The number of bytes written to . public static int HexStringToBytes(ReadOnlySpan chars, Span bytes) { - if ((chars.Length % 2) != 0) + if ((chars.Length & 1) != 0) // bit-hack for % 2 { throw new ArgumentException("Input string length must be a multiple of 2", nameof(chars)); } - if ((bytes.Length * 2) < chars.Length) + if ((bytes.Length << 1) < chars.Length) // bit-hack for * 2 { throw new ArgumentException("Output span must be at least half the length of the input string"); } - else - { - // Slightly better performance in the loop below, allows us to skip a bounds check - // while still supporting output buffers that are larger than necessary - bytes = bytes[..(chars.Length / 2)]; - } + + // Slightly better performance in the loop below, allows us to skip a bounds check + // while still supporting output buffers that are larger than necessary + bytes = bytes[..(chars.Length >> 1)]; // bit-hack for / 2 [MethodImpl(MethodImplOptions.AggressiveInlining)] static int FromChar(int c) diff --git a/src/ImageSharp/Common/Helpers/Shuffle/IComponentShuffle.cs b/src/ImageSharp/Common/Helpers/Shuffle/IComponentShuffle.cs index 18daaed481..f2135b7645 100644 --- a/src/ImageSharp/Common/Helpers/Shuffle/IComponentShuffle.cs +++ b/src/ImageSharp/Common/Helpers/Shuffle/IComponentShuffle.cs @@ -84,7 +84,7 @@ public void RunFallbackShuffle(ReadOnlySpan source, Span dest) { ref uint sBase = ref Unsafe.As(ref MemoryMarshal.GetReference(source)); ref uint dBase = ref Unsafe.As(ref MemoryMarshal.GetReference(dest)); - int n = source.Length / 4; + int n = (int)((uint)source.Length / 4); for (nint i = 0; i < (uint)n; i++) { @@ -108,7 +108,7 @@ public void RunFallbackShuffle(ReadOnlySpan source, Span dest) { ref uint sBase = ref Unsafe.As(ref MemoryMarshal.GetReference(source)); ref uint dBase = ref Unsafe.As(ref MemoryMarshal.GetReference(dest)); - int n = source.Length / 4; + int n = (int)((uint)source.Length / 4); for (nint i = 0; i < (uint)n; i++) { @@ -132,7 +132,7 @@ public void RunFallbackShuffle(ReadOnlySpan source, Span dest) { ref uint sBase = ref Unsafe.As(ref MemoryMarshal.GetReference(source)); ref uint dBase = ref Unsafe.As(ref MemoryMarshal.GetReference(dest)); - int n = source.Length / 4; + int n = (int)((uint)source.Length / 4); for (nint i = 0; i < (uint)n; i++) { @@ -156,7 +156,7 @@ public void RunFallbackShuffle(ReadOnlySpan source, Span dest) { ref uint sBase = ref Unsafe.As(ref MemoryMarshal.GetReference(source)); ref uint dBase = ref Unsafe.As(ref MemoryMarshal.GetReference(dest)); - int n = source.Length / 4; + int n = (int)((uint)source.Length / 4); for (nint i = 0; i < (uint)n; i++) { @@ -187,7 +187,7 @@ public void RunFallbackShuffle(ReadOnlySpan source, Span dest) { ref uint sBase = ref Unsafe.As(ref MemoryMarshal.GetReference(source)); ref uint dBase = ref Unsafe.As(ref MemoryMarshal.GetReference(dest)); - int n = source.Length / 4; + int n = (int)((uint)source.Length / 4); for (nint i = 0; i < (uint)n; i++) { diff --git a/src/ImageSharp/Common/Helpers/SimdUtils.FallbackIntrinsics128.cs b/src/ImageSharp/Common/Helpers/SimdUtils.FallbackIntrinsics128.cs index 8c79b181ce..6fc36cd701 100644 --- a/src/ImageSharp/Common/Helpers/SimdUtils.FallbackIntrinsics128.cs +++ b/src/ImageSharp/Common/Helpers/SimdUtils.FallbackIntrinsics128.cs @@ -71,7 +71,7 @@ internal static void ByteToNormalizedFloat(ReadOnlySpan source, Span.Count * 3); int sourceCount = source.Length - remainder; - int destCount = sourceCount * 4 / 3; + int destCount = (int)((uint)sourceCount * 4 / 3); if (sourceCount > 0) { @@ -192,7 +192,7 @@ public static void Shuffle4Slice3Reduce( int remainder = source.Length % (Vector128.Count * 4); int sourceCount = source.Length - remainder; - int destCount = sourceCount * 3 / 4; + int destCount = (int)((uint)sourceCount * 3 / 4); if (sourceCount > 0) { diff --git a/src/ImageSharp/Compression/Zlib/DeflaterHuffman.cs b/src/ImageSharp/Compression/Zlib/DeflaterHuffman.cs index d507d88c51..ebc43f8822 100644 --- a/src/ImageSharp/Compression/Zlib/DeflaterHuffman.cs +++ b/src/ImageSharp/Compression/Zlib/DeflaterHuffman.cs @@ -206,8 +206,8 @@ public void CompressBlock() int lc = Lcode(litlen); this.literalTree.WriteSymbol(pendingBuffer, lc); - int bits = (lc - 261) / 4; - if (bits > 0 && bits <= 5) + int bits = (int)(((uint)lc - 261) / 4); + if (bits is > 0 and <= 5) { this.Pending.WriteBits(litlen & ((1 << bits) - 1), bits); } @@ -364,7 +364,7 @@ public bool TallyDist(int distance, int length) this.literalTree.Frequencies[lc]++; if (lc >= 265 && lc < 285) { - this.extraBits += (lc - 261) / 4; + this.extraBits += (int)(((uint)lc - 261) / 4); } int dc = Dcode(distance - 1); diff --git a/src/ImageSharp/Formats/Bmp/BmpDecoderCore.cs b/src/ImageSharp/Formats/Bmp/BmpDecoderCore.cs index dfc6bb9611..4a71dc8b89 100644 --- a/src/ImageSharp/Formats/Bmp/BmpDecoderCore.cs +++ b/src/ImageSharp/Formats/Bmp/BmpDecoderCore.cs @@ -489,7 +489,7 @@ private void UncompressRle4(BufferedReadStream stream, int w, Span buffer, // If the second byte > 2, we are in 'absolute mode'. // The second byte contains the number of color indexes that follow. int max = cmd[1]; - int bytesToRead = (max + 1) / 2; + int bytesToRead = (int)(((uint)max + 1) / 2); byte[] run = new byte[bytesToRead]; diff --git a/src/ImageSharp/Formats/Bmp/BmpEncoderCore.cs b/src/ImageSharp/Formats/Bmp/BmpEncoderCore.cs index f30369d19b..a2c7058233 100644 --- a/src/ImageSharp/Formats/Bmp/BmpEncoderCore.cs +++ b/src/ImageSharp/Formats/Bmp/BmpEncoderCore.cs @@ -124,7 +124,7 @@ public void Encode(Image image, Stream stream, CancellationToken this.bitsPerPixel ??= bmpMetadata.BitsPerPixel; short bpp = (short)this.bitsPerPixel; - int bytesPerLine = 4 * (((image.Width * bpp) + 31) / 32); + int bytesPerLine = (int)(4 * ((((uint)image.Width * (ushort)bpp) + 31) / 32)); this.padding = bytesPerLine - (int)(image.Width * (bpp / 8F)); int colorPaletteSize = this.bitsPerPixel switch diff --git a/src/ImageSharp/Formats/Jpeg/Components/Block8x8F.Generated.cs b/src/ImageSharp/Formats/Jpeg/Components/Block8x8F.Generated.cs index d1cb3559b2..e5d252f432 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/Block8x8F.Generated.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/Block8x8F.Generated.cs @@ -16,7 +16,7 @@ public void NormalizeColorsInPlace(float maximum) { var CMin4 = new Vector4(0F); var CMax4 = new Vector4(maximum); - var COff4 = new Vector4(MathF.Ceiling(maximum / 2)); + var COff4 = new Vector4(MathF.Ceiling(maximum * 0.5F)); // /2 this.V0L = Numerics.Clamp(this.V0L + COff4, CMin4, CMax4); this.V0R = Numerics.Clamp(this.V0R + COff4, CMin4, CMax4); @@ -42,7 +42,7 @@ public void NormalizeColorsInPlace(float maximum) [MethodImpl(InliningOptions.ShortMethod)] public void NormalizeColorsAndRoundInPlaceVector8(float maximum) { - var off = new Vector(MathF.Ceiling(maximum / 2)); + var off = new Vector(MathF.Ceiling(maximum * 0.5F)); // /2 var max = new Vector(maximum); ref Vector row0 = ref Unsafe.As>(ref this.V0L); diff --git a/src/ImageSharp/Formats/Jpeg/Components/Block8x8F.Generated.tt b/src/ImageSharp/Formats/Jpeg/Components/Block8x8F.Generated.tt index aa211ea22b..7350edd38b 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/Block8x8F.Generated.tt +++ b/src/ImageSharp/Formats/Jpeg/Components/Block8x8F.Generated.tt @@ -29,7 +29,7 @@ internal partial struct Block8x8F { var CMin4 = new Vector4(0F); var CMax4 = new Vector4(maximum); - var COff4 = new Vector4(MathF.Ceiling(maximum / 2)); + var COff4 = new Vector4(MathF.Ceiling(maximum * 0.5F)); // /2 <# @@ -53,7 +53,7 @@ internal partial struct Block8x8F [MethodImpl(InliningOptions.ShortMethod)] public void NormalizeColorsAndRoundInPlaceVector8(float maximum) { - var off = new Vector(MathF.Ceiling(maximum / 2)); + var off = new Vector(MathF.Ceiling(maximum * 0.5F)); // /2 var max = new Vector(maximum); <# diff --git a/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverterBase.cs b/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverterBase.cs index 62f48af16e..1291beb47a 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverterBase.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverterBase.cs @@ -26,7 +26,7 @@ protected JpegColorConverterBase(JpegColorSpace colorSpace, int precision) this.ColorSpace = colorSpace; this.Precision = precision; this.MaximumValue = MathF.Pow(2, precision) - 1; - this.HalfValue = MathF.Ceiling(this.MaximumValue / 2); + this.HalfValue = MathF.Ceiling(this.MaximumValue * 0.5F); // /2 } /// diff --git a/src/ImageSharp/Formats/Jpeg/Components/Decoder/ComponentProcessors/DownScalingComponentProcessor2.cs b/src/ImageSharp/Formats/Jpeg/Components/Decoder/ComponentProcessors/DownScalingComponentProcessor2.cs index 51d8d03593..8b4256e3b9 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/Decoder/ComponentProcessors/DownScalingComponentProcessor2.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/Decoder/ComponentProcessors/DownScalingComponentProcessor2.cs @@ -25,7 +25,7 @@ public override void CopyBlocksToColorBuffer(int spectralStep) Buffer2D spectralBuffer = this.Component.SpectralBlocks; float maximumValue = this.Frame.MaxColorChannelValue; - float normalizationValue = MathF.Ceiling(maximumValue / 2); + float normalizationValue = MathF.Ceiling(maximumValue * 0.5F); // /2 int destAreaStride = this.ColorBuffer.Width; diff --git a/src/ImageSharp/Formats/Jpeg/Components/Decoder/ComponentProcessors/DownScalingComponentProcessor4.cs b/src/ImageSharp/Formats/Jpeg/Components/Decoder/ComponentProcessors/DownScalingComponentProcessor4.cs index b8a40f53b1..170cdbb3c8 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/Decoder/ComponentProcessors/DownScalingComponentProcessor4.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/Decoder/ComponentProcessors/DownScalingComponentProcessor4.cs @@ -25,7 +25,7 @@ public override void CopyBlocksToColorBuffer(int spectralStep) Buffer2D spectralBuffer = this.Component.SpectralBlocks; float maximumValue = this.Frame.MaxColorChannelValue; - float normalizationValue = MathF.Ceiling(maximumValue / 2); + float normalizationValue = MathF.Ceiling(maximumValue * 0.5F); // /2 int destAreaStride = this.ColorBuffer.Width; diff --git a/src/ImageSharp/Formats/Jpeg/Components/Decoder/ComponentProcessors/DownScalingComponentProcessor8.cs b/src/ImageSharp/Formats/Jpeg/Components/Decoder/ComponentProcessors/DownScalingComponentProcessor8.cs index 121b745465..81104d2f3d 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/Decoder/ComponentProcessors/DownScalingComponentProcessor8.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/Decoder/ComponentProcessors/DownScalingComponentProcessor8.cs @@ -22,7 +22,7 @@ public override void CopyBlocksToColorBuffer(int spectralStep) Buffer2D spectralBuffer = this.Component.SpectralBlocks; float maximumValue = this.Frame.MaxColorChannelValue; - float normalizationValue = MathF.Ceiling(maximumValue / 2); + float normalizationValue = MathF.Ceiling(maximumValue * 0.5F); // /2 int destAreaStride = this.ColorBuffer.Width; diff --git a/src/ImageSharp/Formats/Jpeg/Components/Encoder/HuffmanScanEncoder.cs b/src/ImageSharp/Formats/Jpeg/Components/Encoder/HuffmanScanEncoder.cs index f479df7e2d..1453b0a568 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/Encoder/HuffmanScanEncoder.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/Encoder/HuffmanScanEncoder.cs @@ -123,7 +123,7 @@ public HuffmanScanEncoder(int blocksPerCodingUnit, Stream outputStream) private bool IsStreamFlushNeeded { [MethodImpl(MethodImplOptions.AggressiveInlining)] - get => this.emitWriteIndex < (uint)this.emitBuffer.Length / 2; + get => this.emitWriteIndex < (int)((uint)this.emitBuffer.Length / 2); } public void BuildHuffmanTable(JpegHuffmanTableConfig tableConfig) diff --git a/src/ImageSharp/Formats/Jpeg/Components/ScaledFloatingPointDCT.cs b/src/ImageSharp/Formats/Jpeg/Components/ScaledFloatingPointDCT.cs index 369626a96b..4f67b7dfe9 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/ScaledFloatingPointDCT.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/ScaledFloatingPointDCT.cs @@ -103,10 +103,10 @@ public static void TransformIDCT_4x4(ref Block8x8F block, ref Block8x8F dequantT // temporal result is saved to +4 shifted indices // because result is saved into the top left 2x2 region of the // input block - block[(ctr * 8) + 0 + 4] = (tmp10 + tmp2) / 2; - block[(ctr * 8) + 3 + 4] = (tmp10 - tmp2) / 2; - block[(ctr * 8) + 1 + 4] = (tmp12 + tmp0) / 2; - block[(ctr * 8) + 2 + 4] = (tmp12 - tmp0) / 2; + block[(ctr * 8) + 0 + 4] = (tmp10 + tmp2) * 0.5F; + block[(ctr * 8) + 3 + 4] = (tmp10 - tmp2) * 0.5F; + block[(ctr * 8) + 1 + 4] = (tmp12 + tmp0) * 0.5F; + block[(ctr * 8) + 2 + 4] = (tmp12 - tmp0) * 0.5F; } for (int ctr = 0; ctr < 4; ctr++) @@ -136,10 +136,10 @@ public static void TransformIDCT_4x4(ref Block8x8F block, ref Block8x8F dequantT (z4 * FP32_2_562915447); // Save results to the top left 4x4 subregion - block[(ctr * 8) + 0] = MathF.Round(Numerics.Clamp(((tmp10 + tmp2) / 2) + normalizationValue, 0, maxValue)); - block[(ctr * 8) + 3] = MathF.Round(Numerics.Clamp(((tmp10 - tmp2) / 2) + normalizationValue, 0, maxValue)); - block[(ctr * 8) + 1] = MathF.Round(Numerics.Clamp(((tmp12 + tmp0) / 2) + normalizationValue, 0, maxValue)); - block[(ctr * 8) + 2] = MathF.Round(Numerics.Clamp(((tmp12 - tmp0) / 2) + normalizationValue, 0, maxValue)); + block[(ctr * 8) + 0] = MathF.Round(Numerics.Clamp(((tmp10 + tmp2) * 0.5F) + normalizationValue, 0, maxValue)); + block[(ctr * 8) + 3] = MathF.Round(Numerics.Clamp(((tmp10 - tmp2) * 0.5F) + normalizationValue, 0, maxValue)); + block[(ctr * 8) + 1] = MathF.Round(Numerics.Clamp(((tmp12 + tmp0) * 0.5F) + normalizationValue, 0, maxValue)); + block[(ctr * 8) + 2] = MathF.Round(Numerics.Clamp(((tmp12 - tmp0) * 0.5F) + normalizationValue, 0, maxValue)); } } @@ -183,8 +183,8 @@ public static void TransformIDCT_2x2(ref Block8x8F block, ref Block8x8F dequantT // temporal result is saved to +2 shifted indices // because result is saved into the top left 2x2 region of the // input block - block[(ctr * 8) + 2] = (tmp10 + tmp0) / 4; - block[(ctr * 8) + 3] = (tmp10 - tmp0) / 4; + block[(ctr * 8) + 2] = (tmp10 + tmp0) * 0.25F; // /4 + block[(ctr * 8) + 3] = (tmp10 - tmp0) * 0.25F; // /4 } for (int ctr = 0; ctr < 2; ctr++) @@ -199,8 +199,8 @@ public static void TransformIDCT_2x2(ref Block8x8F block, ref Block8x8F dequantT (block[ctr + (8 * 1) + 2] * FP32_3_624509785); // Save results to the top left 2x2 subregion - block[(ctr * 8) + 0] = MathF.Round(Numerics.Clamp(((tmp10 + tmp0) / 4) + normalizationValue, 0, maxValue)); - block[(ctr * 8) + 1] = MathF.Round(Numerics.Clamp(((tmp10 - tmp0) / 4) + normalizationValue, 0, maxValue)); + block[(ctr * 8) + 0] = MathF.Round(Numerics.Clamp(((tmp10 + tmp0) * 0.25F) + normalizationValue, 0, maxValue)); + block[(ctr * 8) + 1] = MathF.Round(Numerics.Clamp(((tmp10 - tmp0) * 0.25F) + normalizationValue, 0, maxValue)); } } diff --git a/src/ImageSharp/Formats/Png/Adam7.cs b/src/ImageSharp/Formats/Png/Adam7.cs index f52a66c265..8310ca64c8 100644 --- a/src/ImageSharp/Formats/Png/Adam7.cs +++ b/src/ImageSharp/Formats/Png/Adam7.cs @@ -67,16 +67,22 @@ public static int ComputeBlockHeight(int height, int pass) [MethodImpl(MethodImplOptions.AggressiveInlining)] public static int ComputeColumns(int width, int passIndex) { - switch (passIndex) + uint w = (uint)width; + + uint result = passIndex switch { - case 0: return (width + 7) / 8; - case 1: return (width + 3) / 8; - case 2: return (width + 3) / 4; - case 3: return (width + 1) / 4; - case 4: return (width + 1) / 2; - case 5: return width / 2; - case 6: return width; - default: throw new ArgumentException($"Not a valid pass index: {passIndex}"); - } + 0 => (w + 7) / 8, + 1 => (w + 3) / 8, + 2 => (w + 3) / 4, + 3 => (w + 1) / 4, + 4 => (w + 1) / 2, + 5 => w / 2, + 6 => w, + _ => Throw(passIndex) + }; + + return (int)result; + + static uint Throw(int passIndex) => throw new ArgumentException($"Not a valid pass index: {passIndex}"); } } diff --git a/src/ImageSharp/Formats/Tiff/Compression/TiffBaseCompression.cs b/src/ImageSharp/Formats/Tiff/Compression/TiffBaseCompression.cs index 36f8c20d72..d57dea994f 100644 --- a/src/ImageSharp/Formats/Tiff/Compression/TiffBaseCompression.cs +++ b/src/ImageSharp/Formats/Tiff/Compression/TiffBaseCompression.cs @@ -16,7 +16,7 @@ protected TiffBaseCompression(MemoryAllocator allocator, int width, int bitsPerP this.Width = width; this.BitsPerPixel = bitsPerPixel; this.Predictor = predictor; - this.BytesPerRow = ((width * bitsPerPixel) + 7) / 8; + this.BytesPerRow = (int)(((uint)(width * bitsPerPixel) + 7) / 8); } /// diff --git a/src/ImageSharp/Formats/Tiff/TiffDecoderCore.cs b/src/ImageSharp/Formats/Tiff/TiffDecoderCore.cs index 45bbed12d5..4499c55833 100644 --- a/src/ImageSharp/Formats/Tiff/TiffDecoderCore.cs +++ b/src/ImageSharp/Formats/Tiff/TiffDecoderCore.cs @@ -793,7 +793,7 @@ private int CalculateStripBufferSize(int width, int height, int plane = -1) } } - int bytesPerRow = ((width * bitsPerPixel) + 7) / 8; + int bytesPerRow = (int)(((uint)(width * bitsPerPixel) + 7) / 8); return bytesPerRow * height; } diff --git a/src/ImageSharp/Formats/Tiff/Writers/TiffBaseColorWriter{TPixel}.cs b/src/ImageSharp/Formats/Tiff/Writers/TiffBaseColorWriter{TPixel}.cs index 189c8fd6ac..c4a7492553 100644 --- a/src/ImageSharp/Formats/Tiff/Writers/TiffBaseColorWriter{TPixel}.cs +++ b/src/ImageSharp/Formats/Tiff/Writers/TiffBaseColorWriter{TPixel}.cs @@ -29,7 +29,7 @@ protected TiffBaseColorWriter(ImageFrame image, MemoryAllocator memoryAl /// /// Gets the bytes per row. /// - public int BytesPerRow => ((this.Image.Width * this.BitsPerPixel) + 7) / 8; + public int BytesPerRow => (int)(((uint)(this.Image.Width * this.BitsPerPixel) + 7) / 8); protected ImageFrame Image { get; } diff --git a/src/ImageSharp/Formats/Webp/BitWriter/Vp8BitWriter.cs b/src/ImageSharp/Formats/Webp/BitWriter/Vp8BitWriter.cs index b83b44fa14..5b4eab64a3 100644 --- a/src/ImageSharp/Formats/Webp/BitWriter/Vp8BitWriter.cs +++ b/src/ImageSharp/Formats/Webp/BitWriter/Vp8BitWriter.cs @@ -457,7 +457,7 @@ public void WriteEncodedImageToStream( this.Finish(); uint numBytes = (uint)this.NumBytes(); int mbSize = this.enc.Mbw * this.enc.Mbh; - int expectedSize = mbSize * 7 / 8; + int expectedSize = (int)((uint)mbSize * 7 / 8); Vp8BitWriter bitWriterPartZero = new(expectedSize, this.enc); diff --git a/src/ImageSharp/Formats/Webp/Lossless/HistogramEncoder.cs b/src/ImageSharp/Formats/Webp/Lossless/HistogramEncoder.cs index 1395181634..5eec2a2ca3 100644 --- a/src/ImageSharp/Formats/Webp/Lossless/HistogramEncoder.cs +++ b/src/ImageSharp/Formats/Webp/Lossless/HistogramEncoder.cs @@ -316,7 +316,7 @@ private static bool HistogramCombineStochastic(List histograms, i int triesWithNoSuccess = 0; int numUsed = histograms.Count(h => h != null); int outerIters = numUsed; - int numTriesNoSuccess = outerIters / 2; + int numTriesNoSuccess = (int)((uint)outerIters / 2); var stats = new Vp8LStreaks(); var bitsEntropy = new Vp8LBitEntropy(); @@ -346,7 +346,7 @@ private static bool HistogramCombineStochastic(List histograms, i for (int iter = 0; iter < outerIters && numUsed >= minClusterSize && ++triesWithNoSuccess < numTriesNoSuccess; iter++) { double bestCost = histoPriorityList.Count == 0 ? 0.0d : histoPriorityList[0].CostDiff; - int numTries = numUsed / 2; + int numTries = (int)((uint)numUsed / 2); uint randRange = (uint)((numUsed - 1) * numUsed); // Pick random samples. diff --git a/src/ImageSharp/Formats/Webp/Lossless/HuffmanUtils.cs b/src/ImageSharp/Formats/Webp/Lossless/HuffmanUtils.cs index 5cee6bc396..18104331ce 100644 --- a/src/ImageSharp/Formats/Webp/Lossless/HuffmanUtils.cs +++ b/src/ImageSharp/Formats/Webp/Lossless/HuffmanUtils.cs @@ -100,7 +100,7 @@ public static void OptimizeHuffmanForRle(int length, bool[] goodForRle, uint[] c uint k; // The stride must end, collapse what we have, if we have enough (4). - uint count = (uint)((sum + (stride / 2)) / stride); + uint count = (sum + ((uint)stride / 2)) / (uint)stride; if (count < 1) { count = 1; @@ -144,7 +144,7 @@ public static void OptimizeHuffmanForRle(int length, bool[] goodForRle, uint[] c sum += counts[i]; if (stride >= 4) { - limit = (uint)((sum + (stride / 2)) / stride); + limit = (sum + ((uint)stride / 2)) / (uint)stride; } } } diff --git a/src/ImageSharp/Formats/Webp/Lossless/LosslessUtils.cs b/src/ImageSharp/Formats/Webp/Lossless/LosslessUtils.cs index d4db3db53b..8a5ec162fb 100644 --- a/src/ImageSharp/Formats/Webp/Lossless/LosslessUtils.cs +++ b/src/ImageSharp/Formats/Webp/Lossless/LosslessUtils.cs @@ -1440,7 +1440,12 @@ private static uint ClampedAddSubtractHalf(uint c0, uint c1, uint c2) } [MethodImpl(InliningOptions.ShortMethod)] - private static int AddSubtractComponentHalf(int a, int b) => (int)Clip255((uint)(a + ((a - b) / 2))); + private static int AddSubtractComponentHalf(int a, int b) + { + uint ua = (uint)a; + uint ub = (uint)b; + return (int)Clip255(ua + ((ua - ub) / 2)); + } [MethodImpl(InliningOptions.ShortMethod)] private static int AddSubtractComponentFull(int a, int b, int c) => (int)Clip255((uint)(a + b - c)); diff --git a/src/ImageSharp/Formats/Webp/Lossless/Vp8LEncoder.cs b/src/ImageSharp/Formats/Webp/Lossless/Vp8LEncoder.cs index e714a77253..7be0e69f72 100644 --- a/src/ImageSharp/Formats/Webp/Lossless/Vp8LEncoder.cs +++ b/src/ImageSharp/Formats/Webp/Lossless/Vp8LEncoder.cs @@ -963,7 +963,7 @@ private void StoreFullHuffmanCode(HuffmanTree[] huffTree, HuffmanTreeToken[] tok else { int nBits = BitOperations.Log2((uint)trimmedLength - 2); - int nBitPairs = (nBits / 2) + 1; + int nBitPairs = (int)(((uint)nBits / 2) + 1); this.bitWriter.PutBits((uint)nBitPairs - 1, 3); this.bitWriter.PutBits((uint)trimmedLength - 2, nBitPairs * 2); } @@ -1820,7 +1820,7 @@ public void AllocateTransformBuffer(int width, int height) { // VP8LResidualImage needs room for 2 scanlines of uint32 pixels with an extra // pixel in each, plus 2 regular scanlines of bytes. - int bgraScratchSize = this.UsePredictorTransform ? ((width + 1) * 2) + (((width * 2) + 4 - 1) / 4) : 0; + int bgraScratchSize = this.UsePredictorTransform ? (int)((((uint)width + 1) * 2) + ((((uint)width * 2) + 4 - 1) / 4)) : 0; int transformDataSize = this.UsePredictorTransform || this.UseCrossColorTransform ? LosslessUtils.SubSampleSize(width, this.TransformBits) * LosslessUtils.SubSampleSize(height, this.TransformBits) : 0; this.BgraScratch = this.memoryAllocator.Allocate(bgraScratchSize); diff --git a/src/ImageSharp/Formats/Webp/Lossless/Vp8LHashChain.cs b/src/ImageSharp/Formats/Webp/Lossless/Vp8LHashChain.cs index 527242906b..32d4fcbb68 100644 --- a/src/ImageSharp/Formats/Webp/Lossless/Vp8LHashChain.cs +++ b/src/ImageSharp/Formats/Webp/Lossless/Vp8LHashChain.cs @@ -59,7 +59,7 @@ public Vp8LHashChain(MemoryAllocator memoryAllocator, int size) public void Fill(ReadOnlySpan bgra, int quality, int xSize, int ySize, bool lowEffort) { int size = xSize * ySize; - int iterMax = GetMaxItersForQuality(quality); + int iterMax = GetMaxItersForQuality((uint)quality); int windowSize = GetWindowSizeForHashChain(quality, xSize); int pos; @@ -272,7 +272,7 @@ private static uint GetPixPairHash64(ReadOnlySpan bgra) /// The quality. /// Number of hash chain lookups. [MethodImpl(InliningOptions.ShortMethod)] - private static int GetMaxItersForQuality(int quality) => 8 + (quality * quality / 128); + private static int GetMaxItersForQuality(uint quality) => (int)(8 + (quality * quality / 128)); [MethodImpl(InliningOptions.ShortMethod)] private static int GetWindowSizeForHashChain(int quality, int xSize) diff --git a/src/ImageSharp/Formats/Webp/Lossy/Vp8Encoder.cs b/src/ImageSharp/Formats/Webp/Lossy/Vp8Encoder.cs index 16b4c827ef..186aa6c216 100644 --- a/src/ImageSharp/Formats/Webp/Lossy/Vp8Encoder.cs +++ b/src/ImageSharp/Formats/Webp/Lossy/Vp8Encoder.cs @@ -683,7 +683,7 @@ private void AssignSegments(int[] alphas) { if (accum[n] != 0) { - int newCenter = (distAccum[n] + (accum[n] / 2)) / accum[n]; + int newCenter = (distAccum[n] + (accum[n] >> 1)) / accum[n]; // >> 1 is bit-hack for / 2 displaced += Math.Abs(centers[n] - newCenter); centers[n] = newCenter; weightedAverage += newCenter * accum[n]; @@ -691,7 +691,7 @@ private void AssignSegments(int[] alphas) } } - weightedAverage = (weightedAverage + (totalWeight / 2)) / totalWeight; + weightedAverage = (weightedAverage + (totalWeight >> 1)) / totalWeight; // >> 1 is bit-hack for / 2 if (displaced < 5) { break; // no need to keep on looping... @@ -1177,6 +1177,6 @@ private static int GetProba(int a, int b) { int total = a + b; return total == 0 ? 255 // that's the default probability. - : ((255 * a) + (total / 2)) / total; // rounded proba + : ((255 * a) + (int)((uint)total / 2)) / total; // rounded proba } } diff --git a/src/ImageSharp/Formats/Webp/Lossy/WebpLossyDecoder.cs b/src/ImageSharp/Formats/Webp/Lossy/WebpLossyDecoder.cs index e63a7ef74e..36f3abcd9d 100644 --- a/src/ImageSharp/Formats/Webp/Lossy/WebpLossyDecoder.cs +++ b/src/ImageSharp/Formats/Webp/Lossy/WebpLossyDecoder.cs @@ -731,7 +731,7 @@ private static int EmitRgb(Vp8Decoder dec, Vp8Io io) Span dst = buf[dstStartIdx..]; int yEnd = io.MbY + io.MbH; int mbw = io.MbW; - int uvw = (mbw + 1) / 2; + int uvw = (int)(((uint)mbw + 1) / 2); int y = io.MbY; byte[] uvBuffer = new byte[(14 * 32) + 15]; diff --git a/src/ImageSharp/IO/ChunkedMemoryStream.cs b/src/ImageSharp/IO/ChunkedMemoryStream.cs index da52f7ca85..2534548141 100644 --- a/src/ImageSharp/IO/ChunkedMemoryStream.cs +++ b/src/ImageSharp/IO/ChunkedMemoryStream.cs @@ -547,7 +547,7 @@ private static int GetChunkSize(int i) #pragma warning disable IDE1006 // Naming Styles const int _128K = 1 << 17; const int _4M = 1 << 22; - return i < 16 ? _128K * (1 << (i / 4)) : _4M; + return i < 16 ? _128K * (1 << (int)((uint)i / 4)) : _4M; #pragma warning restore IDE1006 // Naming Styles } diff --git a/src/ImageSharp/Memory/Allocators/UniformUnmanagedMemoryPoolMemoryAllocator.cs b/src/ImageSharp/Memory/Allocators/UniformUnmanagedMemoryPoolMemoryAllocator.cs index 2cb4421d5e..798edf9b22 100644 --- a/src/ImageSharp/Memory/Allocators/UniformUnmanagedMemoryPoolMemoryAllocator.cs +++ b/src/ImageSharp/Memory/Allocators/UniformUnmanagedMemoryPoolMemoryAllocator.cs @@ -156,7 +156,7 @@ private static long GetDefaultMaxPoolSizeBytes() // Workaround for https://github.com/dotnet/runtime/issues/65466 if (total > 0) { - return total / 8; + return (long)((ulong)total / 8); } } diff --git a/src/ImageSharp/Primitives/Rectangle.cs b/src/ImageSharp/Primitives/Rectangle.cs index baffbc7f49..2f0df3574e 100644 --- a/src/ImageSharp/Primitives/Rectangle.cs +++ b/src/ImageSharp/Primitives/Rectangle.cs @@ -195,7 +195,7 @@ public int Bottom /// The rectangle. /// The . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Point Center(Rectangle rectangle) => new(rectangle.Left + (rectangle.Width / 2), rectangle.Top + (rectangle.Height / 2)); + public static Point Center(Rectangle rectangle) => new(rectangle.Left + (rectangle.Width & 1), rectangle.Top + (rectangle.Height & 1)); // & 1 is bit-hack for / 2 /// /// Creates a rectangle that represents the intersection between and diff --git a/src/ImageSharp/Processing/Processors/Binarization/BinaryThresholdProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Binarization/BinaryThresholdProcessor{TPixel}.cs index b710243a56..1c76ea6a45 100644 --- a/src/ImageSharp/Processing/Processors/Binarization/BinaryThresholdProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Binarization/BinaryThresholdProcessor{TPixel}.cs @@ -132,7 +132,7 @@ public void Invoke(int y, Span span) case BinaryThresholdMode.MaxChroma: { - float threshold = this.threshold / 2F; + float threshold = this.threshold * 0.5F; // /2 for (int x = 0; x < rowSpan.Length; x++) { float chroma = GetMaxChroma(span[x]); @@ -149,9 +149,10 @@ public void Invoke(int y, Span span) private static float GetSaturation(Rgb24 rgb) { // Slimmed down RGB => HSL formula. See HslAndRgbConverter. - float r = rgb.R / 255F; - float g = rgb.G / 255F; - float b = rgb.B / 255F; + const float inv255 = 1 / 255F; + float r = rgb.R * inv255; + float g = rgb.G * inv255; + float b = rgb.B * inv255; float max = MathF.Max(r, MathF.Max(g, b)); float min = MathF.Min(r, MathF.Min(g, b)); @@ -162,7 +163,7 @@ private static float GetSaturation(Rgb24 rgb) return 0F; } - float l = (max + min) / 2F; + float l = (max + min) * 0.5F; // /2 if (l <= .5F) { diff --git a/src/ImageSharp/Processing/Processors/Normalization/AdaptiveHistogramEqualizationProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Normalization/AdaptiveHistogramEqualizationProcessor{TPixel}.cs index e2272db039..0baa87a611 100644 --- a/src/ImageSharp/Processing/Processors/Normalization/AdaptiveHistogramEqualizationProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Normalization/AdaptiveHistogramEqualizationProcessor{TPixel}.cs @@ -59,8 +59,8 @@ protected override void OnFrameApply(ImageFrame source) int tileWidth = (int)MathF.Ceiling(sourceWidth / (float)this.Tiles); int tileHeight = (int)MathF.Ceiling(sourceHeight / (float)this.Tiles); int tileCount = this.Tiles; - int halfTileWidth = tileWidth / 2; - int halfTileHeight = tileHeight / 2; + int halfTileWidth = (int)((uint)tileWidth / 2); + int halfTileHeight = (int)((uint)tileHeight / 2); int luminanceLevels = this.LuminanceLevels; // The image is split up into tiles. For each tile the cumulative distribution function will be calculated. @@ -176,7 +176,7 @@ private static void ProcessBorderColumn( int xEnd, int luminanceLevels) { - int halfTileHeight = tileHeight / 2; + int halfTileHeight = (int)((uint)tileHeight / 2); int cdfY = 0; int y = halfTileHeight; @@ -228,7 +228,7 @@ private static void ProcessBorderRow( int yEnd, int luminanceLevels) { - int halfTileWidth = tileWidth / 2; + int halfTileWidth = (int)((uint)tileWidth / 2); int cdfX = 0; int x = halfTileWidth; diff --git a/src/ImageSharp/Processing/Processors/Normalization/AdaptiveHistogramEqualizationSlidingWindowProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Normalization/AdaptiveHistogramEqualizationSlidingWindowProcessor{TPixel}.cs index f25db12c28..bbac9b9d8e 100644 --- a/src/ImageSharp/Processing/Processors/Normalization/AdaptiveHistogramEqualizationSlidingWindowProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Normalization/AdaptiveHistogramEqualizationSlidingWindowProcessor{TPixel}.cs @@ -59,7 +59,7 @@ protected override void OnFrameApply(ImageFrame source) int tileWidth = source.Width / this.Tiles; int tileHeight = tileWidth; int pixelInTile = tileWidth * tileHeight; - int halfTileHeight = tileHeight / 2; + int halfTileHeight = (int)((uint)tileHeight / 2); int halfTileWidth = halfTileHeight; SlidingWindowInfos slidingWindowInfos = new(tileWidth, tileHeight, halfTileWidth, halfTileHeight, pixelInTile); diff --git a/src/ImageSharp/Processing/Processors/Transforms/Linear/FlipProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Transforms/Linear/FlipProcessor{TPixel}.cs index 11befd5dac..14da3ac890 100644 --- a/src/ImageSharp/Processing/Processors/Transforms/Linear/FlipProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Transforms/Linear/FlipProcessor{TPixel}.cs @@ -54,7 +54,7 @@ private static void FlipX(Buffer2D source, Configuration configuration) using IMemoryOwner tempBuffer = configuration.MemoryAllocator.Allocate(source.Width); Span temp = tempBuffer.Memory.Span; - for (int yTop = 0; yTop < height / 2; yTop++) + for (int yTop = 0; yTop < (int)((uint)height / 2); yTop++) { int yBottom = height - yTop - 1; Span topRow = source.DangerousGetRowSpan(yBottom); diff --git a/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeHelper.cs b/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeHelper.cs index d03a694ba5..d90f948b6f 100644 --- a/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeHelper.cs +++ b/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeHelper.cs @@ -105,11 +105,11 @@ private static (Size Size, Rectangle Rectangle) CalculateBoxPadRectangle( switch (options.Position) { case AnchorPositionMode.Left: - targetY = (height - sourceHeight) / 2; + targetY = (int)((uint)(height - sourceHeight) / 2); targetX = 0; break; case AnchorPositionMode.Right: - targetY = (height - sourceHeight) / 2; + targetY = (int)((uint)(height - sourceHeight) / 2); targetX = width - sourceWidth; break; case AnchorPositionMode.TopRight: @@ -118,7 +118,7 @@ private static (Size Size, Rectangle Rectangle) CalculateBoxPadRectangle( break; case AnchorPositionMode.Top: targetY = 0; - targetX = (width - sourceWidth) / 2; + targetX = (int)((uint)(width - sourceWidth) / 2); break; case AnchorPositionMode.TopLeft: targetY = 0; @@ -130,15 +130,15 @@ private static (Size Size, Rectangle Rectangle) CalculateBoxPadRectangle( break; case AnchorPositionMode.Bottom: targetY = height - sourceHeight; - targetX = (width - sourceWidth) / 2; + targetX = (int)((uint)(width - sourceWidth) / 2); break; case AnchorPositionMode.BottomLeft: targetY = height - sourceHeight; targetX = 0; break; default: - targetY = (height - sourceHeight) / 2; - targetX = (width - sourceWidth) / 2; + targetY = (int)((uint)(height - sourceHeight) / 2); + targetX = (int)((uint)(width - sourceWidth) / 2); break; } From 957ee98259d615fe5df7cd3f95b091ae0b0d48c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=BCnther=20Foidl?= Date: Mon, 13 Mar 2023 19:45:09 +0100 Subject: [PATCH 05/12] Fixed warnings from CI --- src/ImageSharp/Common/Helpers/HexConverter.cs | 4 ++-- .../Decoder/ArithmeticScanDecoder.cs | 19 +++++++++++-------- src/ImageSharp/Formats/Webp/AlphaDecoder.cs | 2 +- .../Formats/Webp/Lossy/LossyUtils.cs | 4 ++-- 4 files changed, 16 insertions(+), 13 deletions(-) diff --git a/src/ImageSharp/Common/Helpers/HexConverter.cs b/src/ImageSharp/Common/Helpers/HexConverter.cs index 3c863cc37c..590b9d63c7 100644 --- a/src/ImageSharp/Common/Helpers/HexConverter.cs +++ b/src/ImageSharp/Common/Helpers/HexConverter.cs @@ -16,12 +16,12 @@ internal static class HexConverter /// The number of bytes written to . public static int HexStringToBytes(ReadOnlySpan chars, Span bytes) { - if ((chars.Length & 1) != 0) // bit-hack for % 2 + if ((chars.Length & 1 /* bit-hack for % 2 */) != 0) { throw new ArgumentException("Input string length must be a multiple of 2", nameof(chars)); } - if ((bytes.Length << 1) < chars.Length) // bit-hack for * 2 + if ((bytes.Length << 1 /* bit-hack for * 2 */) < chars.Length) { throw new ArgumentException("Output span must be at least half the length of the input string"); } diff --git a/src/ImageSharp/Formats/Jpeg/Components/Decoder/ArithmeticScanDecoder.cs b/src/ImageSharp/Formats/Jpeg/Components/Decoder/ArithmeticScanDecoder.cs index 1b043b68f2..423e56378a 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/Decoder/ArithmeticScanDecoder.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/Decoder/ArithmeticScanDecoder.cs @@ -53,9 +53,6 @@ internal class ArithmeticScanDecoder : IJpegScanDecoder private ArithmeticDecodingTable[] acDecodingTables; - // Use C#'s optimization to refer to assembly's data segment, no allocation occurs. - private ReadOnlySpan fixedBin => new byte[] { 113, 0, 0, 0 }; - private readonly CancellationToken cancellationToken; private static readonly int[] ArithmeticTable = @@ -232,7 +229,13 @@ public void InitDecodingTables(List arithmeticDecodingT } } - private ref byte GetFixedBinReference() => ref MemoryMarshal.GetReference(fixedBin); + private static ref byte GetFixedBinReference() + { + // This uses C#'s optimization to refer to the static data segment of the assembly. + // No allocation occurs. + ReadOnlySpan fixedBin = new byte[] { 113, 0, 0, 0 }; + return ref MemoryMarshal.GetReference(fixedBin); + } /// /// Decodes the entropy coded data. @@ -776,7 +779,7 @@ private void DecodeBlockProgressiveDc(ArithmeticDecodingComponent component, ref else { // Refinement scan. - ref byte st = ref this.GetFixedBinReference(); + ref byte st = ref GetFixedBinReference(); blockDataRef |= (short)(this.DecodeBinaryDecision(ref reader, ref st) << this.SuccessiveLow); } @@ -822,7 +825,7 @@ private void DecodeBlockProgressiveAc(ArithmeticDecodingComponent component, ref // Figure F.21: Decoding nonzero value v. // Figure F.22: Decoding the sign of v. - int sign = this.DecodeBinaryDecision(ref reader, ref this.GetFixedBinReference()); + int sign = this.DecodeBinaryDecision(ref reader, ref GetFixedBinReference()); st = ref Unsafe.Add(ref st, 2); // Figure F.23: Decoding the magnitude category of v. @@ -918,7 +921,7 @@ private void ReadBlockProgressiveAcRefined(ArithmeticStatistics acStatistics, re if (this.DecodeBinaryDecision(ref reader, ref Unsafe.Add(ref st, 1)) != 0) { - bool flag = this.DecodeBinaryDecision(ref reader, ref this.GetFixedBinReference()) != 0; + bool flag = this.DecodeBinaryDecision(ref reader, ref GetFixedBinReference()) != 0; coef = (short)(coef + (flag ? m1 : p1)); break; @@ -1048,7 +1051,7 @@ private void DecodeBlockBaseline( // Figure F.21: Decoding nonzero value v. // Figure F.22: Decoding the sign of v. - int sign = this.DecodeBinaryDecision(ref reader, ref this.GetFixedBinReference()); + int sign = this.DecodeBinaryDecision(ref reader, ref GetFixedBinReference()); st = ref Unsafe.Add(ref st, 2); // Figure F.23: Decoding the magnitude category of v. diff --git a/src/ImageSharp/Formats/Webp/AlphaDecoder.cs b/src/ImageSharp/Formats/Webp/AlphaDecoder.cs index 637a38d1e4..2678a6f70f 100644 --- a/src/ImageSharp/Formats/Webp/AlphaDecoder.cs +++ b/src/ImageSharp/Formats/Webp/AlphaDecoder.cs @@ -376,7 +376,7 @@ private static void VerticalUnfilter(Span prev, Span input, Span>(ref outputRef) = c0; } - for (; i < (uint) width; i++) + for (; i < (uint)width; i++) { dst[(int)i] = (byte)(prev[(int)i] + input[(int)i]); } diff --git a/src/ImageSharp/Formats/Webp/Lossy/LossyUtils.cs b/src/ImageSharp/Formats/Webp/Lossy/LossyUtils.cs index 565e4c0293..2dc2881b03 100644 --- a/src/ImageSharp/Formats/Webp/Lossy/LossyUtils.cs +++ b/src/ImageSharp/Formats/Webp/Lossy/LossyUtils.cs @@ -1553,7 +1553,7 @@ public static void VFilter16(Span p, int offset, int stride, int thresh, i Unsafe.As>(ref Unsafe.Add(ref outputRef, (uint)(offset - (3 * stride)))) = p2.AsInt32(); Unsafe.As>(ref Unsafe.Add(ref outputRef, (uint)(offset - (2 * stride)))) = p1.AsInt32(); Unsafe.As>(ref Unsafe.Add(ref outputRef, (uint)(offset - stride))) = p0.AsInt32(); - Unsafe.As>(ref Unsafe.Add(ref outputRef, (uint)(offset))) = q0.AsInt32(); + Unsafe.As>(ref Unsafe.Add(ref outputRef, (uint)offset)) = q0.AsInt32(); Unsafe.As>(ref Unsafe.Add(ref outputRef, (uint)(offset + stride))) = q1.AsInt32(); Unsafe.As>(ref Unsafe.Add(ref outputRef, (uint)(offset + (2 * stride)))) = q2.AsInt32(); } @@ -1599,7 +1599,7 @@ public static void VFilter16i(Span p, int offset, int stride, int thresh, if (Sse2.IsSupported) { ref byte pRef = ref MemoryMarshal.GetReference(p); - Vector128 p3 = Unsafe.As>(ref Unsafe.Add(ref pRef, (uint)(offset))); + Vector128 p3 = Unsafe.As>(ref Unsafe.Add(ref pRef, (uint)offset)); Vector128 p2 = Unsafe.As>(ref Unsafe.Add(ref pRef, (uint)(offset + stride))); Vector128 p1 = Unsafe.As>(ref Unsafe.Add(ref pRef, (uint)(offset + (2 * stride)))); Vector128 p0 = Unsafe.As>(ref Unsafe.Add(ref pRef, (uint)(offset + (3 * stride)))); From bc6178167f92d8c77df8c70901b3cd5529542944 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=BCnther=20Foidl?= Date: Mon, 13 Mar 2023 21:03:24 +0100 Subject: [PATCH 06/12] Fixed bugs --- .../Decoder/ArithmeticScanDecoder.cs | 18 +++++++----------- src/ImageSharp/Primitives/Rectangle.cs | 2 +- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/src/ImageSharp/Formats/Jpeg/Components/Decoder/ArithmeticScanDecoder.cs b/src/ImageSharp/Formats/Jpeg/Components/Decoder/ArithmeticScanDecoder.cs index 423e56378a..73de430730 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/Decoder/ArithmeticScanDecoder.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/Decoder/ArithmeticScanDecoder.cs @@ -53,6 +53,8 @@ internal class ArithmeticScanDecoder : IJpegScanDecoder private ArithmeticDecodingTable[] acDecodingTables; + private static readonly byte[] FixedBin = { 113, 0, 0, 0 }; + private readonly CancellationToken cancellationToken; private static readonly int[] ArithmeticTable = @@ -229,13 +231,7 @@ public void InitDecodingTables(List arithmeticDecodingT } } - private static ref byte GetFixedBinReference() - { - // This uses C#'s optimization to refer to the static data segment of the assembly. - // No allocation occurs. - ReadOnlySpan fixedBin = new byte[] { 113, 0, 0, 0 }; - return ref MemoryMarshal.GetReference(fixedBin); - } + private static ref byte GetFixedBinReference() => ref MemoryMarshal.GetArrayDataReference(FixedBin); /// /// Decodes the entropy coded data. @@ -765,7 +761,7 @@ private void DecodeBlockProgressiveDc(ArithmeticDecodingComponent component, ref } } - v += 1; + v++; if (sign != 0) { v = -v; @@ -860,7 +856,7 @@ private void DecodeBlockProgressiveAc(ArithmeticDecodingComponent component, ref } } - v += 1; + v++; if (sign != 0) { v = -v; @@ -1016,7 +1012,7 @@ private void DecodeBlockBaseline( } } - v += 1; + v++; if (sign != 0) { v = -v; @@ -1086,7 +1082,7 @@ private void DecodeBlockBaseline( } } - v += 1; + v++; if (sign != 0) { v = -v; diff --git a/src/ImageSharp/Primitives/Rectangle.cs b/src/ImageSharp/Primitives/Rectangle.cs index 2f0df3574e..e2ae5071ef 100644 --- a/src/ImageSharp/Primitives/Rectangle.cs +++ b/src/ImageSharp/Primitives/Rectangle.cs @@ -195,7 +195,7 @@ public int Bottom /// The rectangle. /// The . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Point Center(Rectangle rectangle) => new(rectangle.Left + (rectangle.Width & 1), rectangle.Top + (rectangle.Height & 1)); // & 1 is bit-hack for / 2 + public static Point Center(Rectangle rectangle) => new(rectangle.Left + (rectangle.Width >> 1), rectangle.Top + (rectangle.Height >> 1)); // >> 1 is bit-hack for / 2 /// /// Creates a rectangle that represents the intersection between and From deaabf1571c190209ec1c4a98e01cd56bd70d38c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=BCnther=20Foidl?= Date: Mon, 13 Mar 2023 22:11:18 +0100 Subject: [PATCH 07/12] Fixed Bug Pt. II --- .../Jpeg/Components/Decoder/ArithmeticScanDecoder.cs | 12 ++++++------ .../Formats/Webp/Lossless/LosslessUtils.cs | 7 +------ 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/src/ImageSharp/Formats/Jpeg/Components/Decoder/ArithmeticScanDecoder.cs b/src/ImageSharp/Formats/Jpeg/Components/Decoder/ArithmeticScanDecoder.cs index 73de430730..fcefe542d4 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/Decoder/ArithmeticScanDecoder.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/Decoder/ArithmeticScanDecoder.cs @@ -53,7 +53,7 @@ internal class ArithmeticScanDecoder : IJpegScanDecoder private ArithmeticDecodingTable[] acDecodingTables; - private static readonly byte[] FixedBin = { 113, 0, 0, 0 }; + private readonly byte[] fixedBin = { 113, 0, 0, 0 }; private readonly CancellationToken cancellationToken; @@ -231,7 +231,7 @@ public void InitDecodingTables(List arithmeticDecodingT } } - private static ref byte GetFixedBinReference() => ref MemoryMarshal.GetArrayDataReference(FixedBin); + private ref byte GetFixedBinReference() => ref MemoryMarshal.GetArrayDataReference(this.fixedBin); /// /// Decodes the entropy coded data. @@ -775,7 +775,7 @@ private void DecodeBlockProgressiveDc(ArithmeticDecodingComponent component, ref else { // Refinement scan. - ref byte st = ref GetFixedBinReference(); + ref byte st = ref this.GetFixedBinReference(); blockDataRef |= (short)(this.DecodeBinaryDecision(ref reader, ref st) << this.SuccessiveLow); } @@ -821,7 +821,7 @@ private void DecodeBlockProgressiveAc(ArithmeticDecodingComponent component, ref // Figure F.21: Decoding nonzero value v. // Figure F.22: Decoding the sign of v. - int sign = this.DecodeBinaryDecision(ref reader, ref GetFixedBinReference()); + int sign = this.DecodeBinaryDecision(ref reader, ref this.GetFixedBinReference()); st = ref Unsafe.Add(ref st, 2); // Figure F.23: Decoding the magnitude category of v. @@ -917,7 +917,7 @@ private void ReadBlockProgressiveAcRefined(ArithmeticStatistics acStatistics, re if (this.DecodeBinaryDecision(ref reader, ref Unsafe.Add(ref st, 1)) != 0) { - bool flag = this.DecodeBinaryDecision(ref reader, ref GetFixedBinReference()) != 0; + bool flag = this.DecodeBinaryDecision(ref reader, ref this.GetFixedBinReference()) != 0; coef = (short)(coef + (flag ? m1 : p1)); break; @@ -1047,7 +1047,7 @@ private void DecodeBlockBaseline( // Figure F.21: Decoding nonzero value v. // Figure F.22: Decoding the sign of v. - int sign = this.DecodeBinaryDecision(ref reader, ref GetFixedBinReference()); + int sign = this.DecodeBinaryDecision(ref reader, ref this.GetFixedBinReference()); st = ref Unsafe.Add(ref st, 2); // Figure F.23: Decoding the magnitude category of v. diff --git a/src/ImageSharp/Formats/Webp/Lossless/LosslessUtils.cs b/src/ImageSharp/Formats/Webp/Lossless/LosslessUtils.cs index 8a5ec162fb..5a8137754b 100644 --- a/src/ImageSharp/Formats/Webp/Lossless/LosslessUtils.cs +++ b/src/ImageSharp/Formats/Webp/Lossless/LosslessUtils.cs @@ -1440,12 +1440,7 @@ private static uint ClampedAddSubtractHalf(uint c0, uint c1, uint c2) } [MethodImpl(InliningOptions.ShortMethod)] - private static int AddSubtractComponentHalf(int a, int b) - { - uint ua = (uint)a; - uint ub = (uint)b; - return (int)Clip255(ua + ((ua - ub) / 2)); - } + private static int AddSubtractComponentHalf(int a, int b) => (int)Clip255((uint)(a + ((a - b) >> 1))); // >> 1 is bit-hack for / 2 [MethodImpl(InliningOptions.ShortMethod)] private static int AddSubtractComponentFull(int a, int b, int c) => (int)Clip255((uint)(a + b - c)); From f746e686df7ac0287118ac4ec143f2ac1bd9f62e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=BCnther=20Foidl?= Date: Mon, 20 Mar 2023 20:04:02 +0100 Subject: [PATCH 08/12] PR feedback + use nuint instead of nint --- .../Conversion/ColorSpaceConverter.CieLab.cs | 26 +-- .../Conversion/ColorSpaceConverter.CieLch.cs | 26 +-- .../ColorSpaceConverter.CieLchuv.cs | 26 +-- .../Conversion/ColorSpaceConverter.CieLuv.cs | 26 +-- .../Conversion/ColorSpaceConverter.CieXyy.cs | 26 +-- .../Conversion/ColorSpaceConverter.CieXyz.cs | 26 +-- .../Conversion/ColorSpaceConverter.Cmyk.cs | 26 +-- .../Conversion/ColorSpaceConverter.Hsl.cs | 26 +-- .../Conversion/ColorSpaceConverter.Hsv.cs | 26 +-- .../ColorSpaceConverter.HunterLab.cs | 26 +-- .../ColorSpaceConverter.LinearRgb.cs | 26 +-- .../Conversion/ColorSpaceConverter.Lms.cs | 26 +-- .../Conversion/ColorSpaceConverter.Rgb.cs | 26 +-- .../Conversion/ColorSpaceConverter.YCbCr.cs | 24 +-- .../VonKriesChromaticAdaptation.cs | 2 +- src/ImageSharp/Common/Helpers/HexConverter.cs | 6 +- .../Helpers/Shuffle/IComponentShuffle.cs | 22 +-- .../Common/Helpers/Shuffle/IPad3Shuffle4.cs | 12 +- .../Common/Helpers/Shuffle/IShuffle3.cs | 10 +- .../Common/Helpers/Shuffle/IShuffle4Slice3.cs | 10 +- .../Helpers/SimdUtils.ExtendedIntrinsics.cs | 8 +- .../SimdUtils.FallbackIntrinsics128.cs | 4 +- .../Common/Helpers/SimdUtils.HwIntrinsics.cs | 48 ++--- .../Common/Helpers/SimdUtils.Pack.cs | 14 +- .../Common/Helpers/SimdUtils.Shuffle.cs | 46 ++--- .../Compression/Zlib/DeflaterHuffman.cs | 8 +- src/ImageSharp/Formats/Bmp/BmpEncoderCore.cs | 8 +- .../Formats/ImageExtensions.Save.tt | 8 +- .../Jpeg/Components/Block8x8F.Generated.cs | 4 +- .../Jpeg/Components/Block8x8F.Generated.tt | 4 +- .../Jpeg/Components/Block8x8F.Intrinsic.cs | 6 +- .../Jpeg/Components/Block8x8F.ScaledCopy.cs | 28 +-- .../Formats/Jpeg/Components/Block8x8F.cs | 22 ++- .../JpegColorConverter.CmykAvx.cs | 8 +- .../JpegColorConverter.CmykVector.cs | 8 +- .../JpegColorConverter.GrayScaleAvx.cs | 8 +- .../JpegColorConverter.GrayScaleScalar.cs | 2 +- .../JpegColorConverter.GrayScaleVector.cs | 8 +- .../JpegColorConverter.RgbArm.cs | 4 +- .../JpegColorConverter.RgbAvx.cs | 4 +- .../JpegColorConverter.RgbVector.cs | 4 +- .../JpegColorConverter.YCbCrAvx.cs | 8 +- .../JpegColorConverter.YCbCrVector.cs | 8 +- .../JpegColorConverter.YccKAvx.cs | 8 +- .../JpegColorConverter.YccKVector.cs | 8 +- .../Decoder/ArithmeticScanDecoder.cs | 16 +- .../DownScalingComponentProcessor2.cs | 22 +-- .../DownScalingComponentProcessor4.cs | 22 +-- .../DownScalingComponentProcessor8.cs | 12 +- .../Components/Encoder/ComponentProcessor.cs | 28 +-- .../Components/Encoder/HuffmanScanEncoder.cs | 32 +-- .../Jpeg/Components/FloatingPointDCT.cs | 4 +- .../Jpeg/Components/ScaledFloatingPointDCT.cs | 2 +- .../Formats/Png/Filters/AverageFilter.cs | 26 +-- .../Formats/Png/Filters/PaethFilter.cs | 26 +-- .../Formats/Png/Filters/SubFilter.cs | 26 +-- .../Formats/Png/Filters/UpFilter.cs | 30 +-- src/ImageSharp/Formats/Png/PngDecoderCore.cs | 28 +-- src/ImageSharp/Formats/Png/PngEncoderCore.cs | 4 +- .../Formats/Png/PngScanlineProcessor.cs | 187 ++++++++++-------- .../Decompressors/T6TiffCompression.cs | 2 +- .../Tiff/Compression/TiffBaseCompression.cs | 2 +- .../BlackIsZero1TiffColor{TPixel}.cs | 14 +- .../WhiteIsZero1TiffColor{TPixel}.cs | 14 +- .../Formats/Tiff/TiffDecoderCore.cs | 2 +- src/ImageSharp/Formats/Webp/AlphaDecoder.cs | 16 +- .../Webp/Lossless/ColorSpaceTransformUtils.cs | 24 +-- .../Formats/Webp/Lossless/LosslessUtils.cs | 94 +++++---- .../Formats/Webp/Lossless/Vp8LHistogram.cs | 4 +- .../Formats/Webp/Lossy/LossyUtils.cs | 10 +- src/ImageSharp/Formats/Webp/Lossy/QuantEnc.cs | 6 +- .../Abgr32.PixelOperations.Generated.cs | 44 ++--- .../Argb32.PixelOperations.Generated.cs | 44 ++--- .../Bgr24.PixelOperations.Generated.cs | 44 ++--- .../Bgra32.PixelOperations.Generated.cs | 44 ++--- .../Bgra5551.PixelOperations.Generated.cs | 24 +-- .../L16.PixelOperations.Generated.cs | 24 +-- .../Generated/L8.PixelOperations.Generated.cs | 24 +-- .../La16.PixelOperations.Generated.cs | 24 +-- .../La32.PixelOperations.Generated.cs | 24 +-- .../Rgb24.PixelOperations.Generated.cs | 44 ++--- .../Rgb48.PixelOperations.Generated.cs | 24 +-- .../Rgba32.PixelOperations.Generated.cs | 44 ++--- .../Rgba64.PixelOperations.Generated.cs | 24 +-- .../Generated/_Common.ttinclude | 2 +- .../RgbaVector.PixelOperations.cs | 4 +- .../PixelOperations{TPixel}.Generated.cs | 52 ++--- .../PixelOperations{TPixel}.Generated.tt | 4 +- .../PixelFormats/PixelOperations{TPixel}.cs | 4 +- ...alizationSlidingWindowProcessor{TPixel}.cs | 8 +- .../HistogramEqualizationProcessor{TPixel}.cs | 10 +- .../Transforms/Resize/ResizeKernelMap.cs | 2 +- .../Transforms/Resize/ResizeWorker.cs | 16 +- .../ImageSharp.Benchmarks/Bulk/FromVector4.cs | 6 +- .../Bulk/PremultiplyVector4.cs | 4 +- .../Bulk/ToVector4_Rgba32.cs | 12 +- .../Bulk/UnPremultiplyVector4.cs | 4 +- .../BlockOperations/Block8x8F_CopyTo1x1.cs | 10 +- .../Jpeg/BlockOperations/Block8x8F_Round.cs | 8 +- .../PixelConversion_ConvertFromRgba32.cs | 10 +- .../PixelConversion_ConvertFromVector4.cs | 4 +- .../PixelConversion_ConvertToRgba32.cs | 4 +- ...vertToRgba32_AsPartOfCompositeOperation.cs | 4 +- .../PixelConversion_ConvertToVector4.cs | 4 +- ...ertToVector4_AsPartOfCompositeOperation.cs | 4 +- .../PixelConversion_PackFromRgbPlanes.cs | 10 +- .../PixelConversion_Rgba32_To_Argb32.cs | 12 +- .../PixelConversion_Rgba32_To_Bgra32.cs | 26 +-- .../General/Vectorization/UInt32ToSingle.cs | 16 +- .../General/Vectorization/VectorFetching.cs | 12 +- .../Vectorization/WidenBytesToUInt32.cs | 6 +- .../PorterDuffBulkVsSingleVector.cs | 2 +- .../Common/SimdUtilsTests.Shuffle.cs | 48 ++--- .../Formats/Png/PngEncoderFilterTests.cs | 2 +- .../Formats/Png/ReferenceImplementations.cs | 22 +-- ...ConverterTests.ReferenceImplementations.cs | 6 +- .../PixelOperations/PixelOperationsTests.cs | 2 +- .../Transforms/ResizeKernelMapTests.cs | 4 +- 118 files changed, 1090 insertions(+), 1049 deletions(-) diff --git a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieLab.cs b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieLab.cs index 88343cbab4..54667ca2af 100644 --- a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieLab.cs +++ b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieLab.cs @@ -37,7 +37,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref CieLch sourceRef = ref MemoryMarshal.GetReference(source); ref CieLab destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref CieLch sp = ref Unsafe.Add(ref sourceRef, i); ref CieLab dp = ref Unsafe.Add(ref destRef, i); @@ -70,7 +70,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref CieLchuv sourceRef = ref MemoryMarshal.GetReference(source); ref CieLab destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref CieLchuv sp = ref Unsafe.Add(ref sourceRef, i); ref CieLab dp = ref Unsafe.Add(ref destRef, i); @@ -103,7 +103,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref CieLuv sourceRef = ref MemoryMarshal.GetReference(source); ref CieLab destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref CieLuv sp = ref Unsafe.Add(ref sourceRef, i); ref CieLab dp = ref Unsafe.Add(ref destRef, i); @@ -136,7 +136,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref CieXyy sourceRef = ref MemoryMarshal.GetReference(source); ref CieLab destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref CieXyy sp = ref Unsafe.Add(ref sourceRef, i); ref CieLab dp = ref Unsafe.Add(ref destRef, i); @@ -169,7 +169,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref CieXyz sourceRef = ref MemoryMarshal.GetReference(source); ref CieLab destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref CieXyz sp = ref Unsafe.Add(ref sourceRef, i); ref CieLab dp = ref Unsafe.Add(ref destRef, i); @@ -201,7 +201,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref Cmyk sourceRef = ref MemoryMarshal.GetReference(source); ref CieLab destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref Cmyk sp = ref Unsafe.Add(ref sourceRef, i); ref CieLab dp = ref Unsafe.Add(ref destRef, i); @@ -234,7 +234,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref Hsl sourceRef = ref MemoryMarshal.GetReference(source); ref CieLab destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref Hsl sp = ref Unsafe.Add(ref sourceRef, i); ref CieLab dp = ref Unsafe.Add(ref destRef, i); @@ -266,7 +266,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref Hsv sourceRef = ref MemoryMarshal.GetReference(source); ref CieLab destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref Hsv sp = ref Unsafe.Add(ref sourceRef, i); ref CieLab dp = ref Unsafe.Add(ref destRef, i); @@ -299,7 +299,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref HunterLab sourceRef = ref MemoryMarshal.GetReference(source); ref CieLab destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref HunterLab sp = ref Unsafe.Add(ref sourceRef, i); ref CieLab dp = ref Unsafe.Add(ref destRef, i); @@ -332,7 +332,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref Lms sourceRef = ref MemoryMarshal.GetReference(source); ref CieLab destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref Lms sp = ref Unsafe.Add(ref sourceRef, i); ref CieLab dp = ref Unsafe.Add(ref destRef, i); @@ -365,7 +365,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref LinearRgb sourceRef = ref MemoryMarshal.GetReference(source); ref CieLab destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref LinearRgb sp = ref Unsafe.Add(ref sourceRef, i); ref CieLab dp = ref Unsafe.Add(ref destRef, i); @@ -398,7 +398,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref Rgb sourceRef = ref MemoryMarshal.GetReference(source); ref CieLab destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref Rgb sp = ref Unsafe.Add(ref sourceRef, i); ref CieLab dp = ref Unsafe.Add(ref destRef, i); @@ -431,7 +431,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref YCbCr sourceRef = ref MemoryMarshal.GetReference(source); ref CieLab destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref YCbCr sp = ref Unsafe.Add(ref sourceRef, i); ref CieLab dp = ref Unsafe.Add(ref destRef, i); diff --git a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieLch.cs b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieLch.cs index dcd6be185c..9949b5d91b 100644 --- a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieLch.cs +++ b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieLch.cs @@ -36,7 +36,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref CieLab sourceRef = ref MemoryMarshal.GetReference(source); ref CieLch destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref CieLab sp = ref Unsafe.Add(ref sourceRef, i); ref CieLch dp = ref Unsafe.Add(ref destRef, i); @@ -69,7 +69,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref CieLchuv sourceRef = ref MemoryMarshal.GetReference(source); ref CieLch destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref CieLchuv sp = ref Unsafe.Add(ref sourceRef, i); ref CieLch dp = ref Unsafe.Add(ref destRef, i); @@ -102,7 +102,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref CieLuv sourceRef = ref MemoryMarshal.GetReference(source); ref CieLch destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref CieLuv sp = ref Unsafe.Add(ref sourceRef, i); ref CieLch dp = ref Unsafe.Add(ref destRef, i); @@ -135,7 +135,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref CieXyy sourceRef = ref MemoryMarshal.GetReference(source); ref CieLch destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref CieXyy sp = ref Unsafe.Add(ref sourceRef, i); ref CieLch dp = ref Unsafe.Add(ref destRef, i); @@ -168,7 +168,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref CieXyz sourceRef = ref MemoryMarshal.GetReference(source); ref CieLch destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref CieXyz sp = ref Unsafe.Add(ref sourceRef, i); ref CieLch dp = ref Unsafe.Add(ref destRef, i); @@ -200,7 +200,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref Cmyk sourceRef = ref MemoryMarshal.GetReference(source); ref CieLch destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref Cmyk sp = ref Unsafe.Add(ref sourceRef, i); ref CieLch dp = ref Unsafe.Add(ref destRef, i); @@ -233,7 +233,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref Hsl sourceRef = ref MemoryMarshal.GetReference(source); ref CieLch destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref Hsl sp = ref Unsafe.Add(ref sourceRef, i); ref CieLch dp = ref Unsafe.Add(ref destRef, i); @@ -266,7 +266,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref Hsv sourceRef = ref MemoryMarshal.GetReference(source); ref CieLch destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref Hsv sp = ref Unsafe.Add(ref sourceRef, i); ref CieLch dp = ref Unsafe.Add(ref destRef, i); @@ -299,7 +299,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref HunterLab sourceRef = ref MemoryMarshal.GetReference(source); ref CieLch destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref HunterLab sp = ref Unsafe.Add(ref sourceRef, i); ref CieLch dp = ref Unsafe.Add(ref destRef, i); @@ -332,7 +332,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref LinearRgb sourceRef = ref MemoryMarshal.GetReference(source); ref CieLch destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref LinearRgb sp = ref Unsafe.Add(ref sourceRef, i); ref CieLch dp = ref Unsafe.Add(ref destRef, i); @@ -365,7 +365,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref Lms sourceRef = ref MemoryMarshal.GetReference(source); ref CieLch destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref Lms sp = ref Unsafe.Add(ref sourceRef, i); ref CieLch dp = ref Unsafe.Add(ref destRef, i); @@ -398,7 +398,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref Rgb sourceRef = ref MemoryMarshal.GetReference(source); ref CieLch destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref Rgb sp = ref Unsafe.Add(ref sourceRef, i); ref CieLch dp = ref Unsafe.Add(ref destRef, i); @@ -431,7 +431,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref YCbCr sourceRef = ref MemoryMarshal.GetReference(source); ref CieLch destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref YCbCr sp = ref Unsafe.Add(ref sourceRef, i); ref CieLch dp = ref Unsafe.Add(ref destRef, i); diff --git a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieLchuv.cs b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieLchuv.cs index eb21394a09..4b856d1189 100644 --- a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieLchuv.cs +++ b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieLchuv.cs @@ -36,7 +36,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref CieLab sourceRef = ref MemoryMarshal.GetReference(source); ref CieLchuv destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref CieLab sp = ref Unsafe.Add(ref sourceRef, i); ref CieLchuv dp = ref Unsafe.Add(ref destRef, i); @@ -69,7 +69,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref CieLch sourceRef = ref MemoryMarshal.GetReference(source); ref CieLchuv destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref CieLch sp = ref Unsafe.Add(ref sourceRef, i); ref CieLchuv dp = ref Unsafe.Add(ref destRef, i); @@ -102,7 +102,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref CieLuv sourceRef = ref MemoryMarshal.GetReference(source); ref CieLchuv destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref CieLuv sp = ref Unsafe.Add(ref sourceRef, i); ref CieLchuv dp = ref Unsafe.Add(ref destRef, i); @@ -135,7 +135,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref CieXyy sourceRef = ref MemoryMarshal.GetReference(source); ref CieLchuv destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref CieXyy sp = ref Unsafe.Add(ref sourceRef, i); ref CieLchuv dp = ref Unsafe.Add(ref destRef, i); @@ -168,7 +168,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref CieXyz sourceRef = ref MemoryMarshal.GetReference(source); ref CieLchuv destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref CieXyz sp = ref Unsafe.Add(ref sourceRef, i); ref CieLchuv dp = ref Unsafe.Add(ref destRef, i); @@ -201,7 +201,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref Cmyk sourceRef = ref MemoryMarshal.GetReference(source); ref CieLchuv destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref Cmyk sp = ref Unsafe.Add(ref sourceRef, i); ref CieLchuv dp = ref Unsafe.Add(ref destRef, i); @@ -234,7 +234,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref Hsl sourceRef = ref MemoryMarshal.GetReference(source); ref CieLchuv destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref Hsl sp = ref Unsafe.Add(ref sourceRef, i); ref CieLchuv dp = ref Unsafe.Add(ref destRef, i); @@ -267,7 +267,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref Hsv sourceRef = ref MemoryMarshal.GetReference(source); ref CieLchuv destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref Hsv sp = ref Unsafe.Add(ref sourceRef, i); ref CieLchuv dp = ref Unsafe.Add(ref destRef, i); @@ -300,7 +300,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref HunterLab sourceRef = ref MemoryMarshal.GetReference(source); ref CieLchuv destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref HunterLab sp = ref Unsafe.Add(ref sourceRef, i); ref CieLchuv dp = ref Unsafe.Add(ref destRef, i); @@ -333,7 +333,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref LinearRgb sourceRef = ref MemoryMarshal.GetReference(source); ref CieLchuv destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref LinearRgb sp = ref Unsafe.Add(ref sourceRef, i); ref CieLchuv dp = ref Unsafe.Add(ref destRef, i); @@ -366,7 +366,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref Lms sourceRef = ref MemoryMarshal.GetReference(source); ref CieLchuv destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref Lms sp = ref Unsafe.Add(ref sourceRef, i); ref CieLchuv dp = ref Unsafe.Add(ref destRef, i); @@ -399,7 +399,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref Rgb sourceRef = ref MemoryMarshal.GetReference(source); ref CieLchuv destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref Rgb sp = ref Unsafe.Add(ref sourceRef, i); ref CieLchuv dp = ref Unsafe.Add(ref destRef, i); @@ -431,7 +431,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref YCbCr sourceRef = ref MemoryMarshal.GetReference(source); ref CieLchuv destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref YCbCr sp = ref Unsafe.Add(ref sourceRef, i); ref CieLchuv dp = ref Unsafe.Add(ref destRef, i); diff --git a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieLuv.cs b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieLuv.cs index 1b6735e623..2e8029f64a 100644 --- a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieLuv.cs +++ b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieLuv.cs @@ -35,7 +35,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref CieLab sourceRef = ref MemoryMarshal.GetReference(source); ref CieLuv destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref CieLab sp = ref Unsafe.Add(ref sourceRef, i); ref CieLuv dp = ref Unsafe.Add(ref destRef, i); @@ -67,7 +67,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref CieLch sourceRef = ref MemoryMarshal.GetReference(source); ref CieLuv destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref CieLch sp = ref Unsafe.Add(ref sourceRef, i); ref CieLuv dp = ref Unsafe.Add(ref destRef, i); @@ -102,7 +102,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref CieLchuv sourceRef = ref MemoryMarshal.GetReference(source); ref CieLuv destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref CieLchuv sp = ref Unsafe.Add(ref sourceRef, i); ref CieLuv dp = ref Unsafe.Add(ref destRef, i); @@ -134,7 +134,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref CieXyy sourceRef = ref MemoryMarshal.GetReference(source); ref CieLuv destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref CieXyy sp = ref Unsafe.Add(ref sourceRef, i); ref CieLuv dp = ref Unsafe.Add(ref destRef, i); @@ -169,7 +169,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref CieXyz sourceRef = ref MemoryMarshal.GetReference(source); ref CieLuv destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref CieXyz sp = ref Unsafe.Add(ref sourceRef, i); ref CieLuv dp = ref Unsafe.Add(ref destRef, i); @@ -201,7 +201,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref Cmyk sourceRef = ref MemoryMarshal.GetReference(source); ref CieLuv destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref Cmyk sp = ref Unsafe.Add(ref sourceRef, i); ref CieLuv dp = ref Unsafe.Add(ref destRef, i); @@ -233,7 +233,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref Hsl sourceRef = ref MemoryMarshal.GetReference(source); ref CieLuv destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref Hsl sp = ref Unsafe.Add(ref sourceRef, i); ref CieLuv dp = ref Unsafe.Add(ref destRef, i); @@ -265,7 +265,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref Hsv sourceRef = ref MemoryMarshal.GetReference(source); ref CieLuv destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref Hsv sp = ref Unsafe.Add(ref sourceRef, i); ref CieLuv dp = ref Unsafe.Add(ref destRef, i); @@ -297,7 +297,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref HunterLab sourceRef = ref MemoryMarshal.GetReference(source); ref CieLuv destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref HunterLab sp = ref Unsafe.Add(ref sourceRef, i); ref CieLuv dp = ref Unsafe.Add(ref destRef, i); @@ -329,7 +329,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref Lms sourceRef = ref MemoryMarshal.GetReference(source); ref CieLuv destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref Lms sp = ref Unsafe.Add(ref sourceRef, i); ref CieLuv dp = ref Unsafe.Add(ref destRef, i); @@ -361,7 +361,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref LinearRgb sourceRef = ref MemoryMarshal.GetReference(source); ref CieLuv destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref LinearRgb sp = ref Unsafe.Add(ref sourceRef, i); ref CieLuv dp = ref Unsafe.Add(ref destRef, i); @@ -393,7 +393,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref Rgb sourceRef = ref MemoryMarshal.GetReference(source); ref CieLuv destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref Rgb sp = ref Unsafe.Add(ref sourceRef, i); ref CieLuv dp = ref Unsafe.Add(ref destRef, i); @@ -425,7 +425,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref YCbCr sourceRef = ref MemoryMarshal.GetReference(source); ref CieLuv destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref YCbCr sp = ref Unsafe.Add(ref sourceRef, i); ref CieLuv dp = ref Unsafe.Add(ref destRef, i); diff --git a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieXyy.cs b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieXyy.cs index 2b34e66f2e..13b2a225c3 100644 --- a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieXyy.cs +++ b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieXyy.cs @@ -36,7 +36,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref CieLab sourceRef = ref MemoryMarshal.GetReference(source); ref CieXyy destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref CieLab sp = ref Unsafe.Add(ref sourceRef, i); ref CieXyy dp = ref Unsafe.Add(ref destRef, i); @@ -69,7 +69,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref CieLch sourceRef = ref MemoryMarshal.GetReference(source); ref CieXyy destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref CieLch sp = ref Unsafe.Add(ref sourceRef, i); ref CieXyy dp = ref Unsafe.Add(ref destRef, i); @@ -102,7 +102,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref CieLchuv sourceRef = ref MemoryMarshal.GetReference(source); ref CieXyy destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref CieLchuv sp = ref Unsafe.Add(ref sourceRef, i); ref CieXyy dp = ref Unsafe.Add(ref destRef, i); @@ -135,7 +135,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref CieLuv sourceRef = ref MemoryMarshal.GetReference(source); ref CieXyy destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref CieLuv sp = ref Unsafe.Add(ref sourceRef, i); ref CieXyy dp = ref Unsafe.Add(ref destRef, i); @@ -163,7 +163,7 @@ public static void Convert(ReadOnlySpan source, Span destination ref CieXyz sourceRef = ref MemoryMarshal.GetReference(source); ref CieXyy destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref CieXyz sp = ref Unsafe.Add(ref sourceRef, i); ref CieXyy dp = ref Unsafe.Add(ref destRef, i); @@ -196,7 +196,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref Cmyk sourceRef = ref MemoryMarshal.GetReference(source); ref CieXyy destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref Cmyk sp = ref Unsafe.Add(ref sourceRef, i); ref CieXyy dp = ref Unsafe.Add(ref destRef, i); @@ -229,7 +229,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref Hsl sourceRef = ref MemoryMarshal.GetReference(source); ref CieXyy destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref Hsl sp = ref Unsafe.Add(ref sourceRef, i); ref CieXyy dp = ref Unsafe.Add(ref destRef, i); @@ -262,7 +262,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref Hsv sourceRef = ref MemoryMarshal.GetReference(source); ref CieXyy destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref Hsv sp = ref Unsafe.Add(ref sourceRef, i); ref CieXyy dp = ref Unsafe.Add(ref destRef, i); @@ -295,7 +295,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref HunterLab sourceRef = ref MemoryMarshal.GetReference(source); ref CieXyy destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref HunterLab sp = ref Unsafe.Add(ref sourceRef, i); ref CieXyy dp = ref Unsafe.Add(ref destRef, i); @@ -328,7 +328,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref LinearRgb sourceRef = ref MemoryMarshal.GetReference(source); ref CieXyy destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref LinearRgb sp = ref Unsafe.Add(ref sourceRef, i); ref CieXyy dp = ref Unsafe.Add(ref destRef, i); @@ -361,7 +361,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref Lms sourceRef = ref MemoryMarshal.GetReference(source); ref CieXyy destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref Lms sp = ref Unsafe.Add(ref sourceRef, i); ref CieXyy dp = ref Unsafe.Add(ref destRef, i); @@ -394,7 +394,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref Rgb sourceRef = ref MemoryMarshal.GetReference(source); ref CieXyy destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref Rgb sp = ref Unsafe.Add(ref sourceRef, i); ref CieXyy dp = ref Unsafe.Add(ref destRef, i); @@ -427,7 +427,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref YCbCr sourceRef = ref MemoryMarshal.GetReference(source); ref CieXyy destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref YCbCr sp = ref Unsafe.Add(ref sourceRef, i); ref CieXyy dp = ref Unsafe.Add(ref destRef, i); diff --git a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieXyz.cs b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieXyz.cs index 1495a28b64..2212ca2e58 100644 --- a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieXyz.cs +++ b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieXyz.cs @@ -41,7 +41,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref CieLab sourceRef = ref MemoryMarshal.GetReference(source); ref CieXyz destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref CieLab sp = ref Unsafe.Add(ref sourceRef, i); ref CieXyz dp = ref Unsafe.Add(ref destRef, i); @@ -76,7 +76,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref CieLch sourceRef = ref MemoryMarshal.GetReference(source); ref CieXyz destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref CieLch sp = ref Unsafe.Add(ref sourceRef, i); ref CieXyz dp = ref Unsafe.Add(ref destRef, i); @@ -111,7 +111,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref CieLchuv sourceRef = ref MemoryMarshal.GetReference(source); ref CieXyz destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref CieLchuv sp = ref Unsafe.Add(ref sourceRef, i); ref CieXyz dp = ref Unsafe.Add(ref destRef, i); @@ -146,7 +146,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref CieLuv sourceRef = ref MemoryMarshal.GetReference(source); ref CieXyz destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref CieLuv sp = ref Unsafe.Add(ref sourceRef, i); ref CieXyz dp = ref Unsafe.Add(ref destRef, i); @@ -177,7 +177,7 @@ public static void Convert(ReadOnlySpan source, Span destination ref CieXyy sourceRef = ref MemoryMarshal.GetReference(source); ref CieXyz destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref CieXyy sp = ref Unsafe.Add(ref sourceRef, i); ref CieXyz dp = ref Unsafe.Add(ref destRef, i); @@ -210,7 +210,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref Cmyk sourceRef = ref MemoryMarshal.GetReference(source); ref CieXyz destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref Cmyk sp = ref Unsafe.Add(ref sourceRef, i); ref CieXyz dp = ref Unsafe.Add(ref destRef, i); @@ -243,7 +243,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref Hsl sourceRef = ref MemoryMarshal.GetReference(source); ref CieXyz destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref Hsl sp = ref Unsafe.Add(ref sourceRef, i); ref CieXyz dp = ref Unsafe.Add(ref destRef, i); @@ -277,7 +277,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref Hsv sourceRef = ref MemoryMarshal.GetReference(source); ref CieXyz destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref Hsv sp = ref Unsafe.Add(ref sourceRef, i); ref CieXyz dp = ref Unsafe.Add(ref destRef, i); @@ -310,7 +310,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref HunterLab sourceRef = ref MemoryMarshal.GetReference(source); ref CieXyz destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref HunterLab sp = ref Unsafe.Add(ref sourceRef, i); ref CieXyz dp = ref Unsafe.Add(ref destRef, i); @@ -345,7 +345,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref LinearRgb sourceRef = ref MemoryMarshal.GetReference(source); ref CieXyz destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref LinearRgb sp = ref Unsafe.Add(ref sourceRef, i); ref CieXyz dp = ref Unsafe.Add(ref destRef, i); @@ -374,7 +374,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref Lms sourceRef = ref MemoryMarshal.GetReference(source); ref CieXyz destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref Lms sp = ref Unsafe.Add(ref sourceRef, i); ref CieXyz dp = ref Unsafe.Add(ref destRef, i); @@ -407,7 +407,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref Rgb sourceRef = ref MemoryMarshal.GetReference(source); ref CieXyz destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref Rgb sp = ref Unsafe.Add(ref sourceRef, i); ref CieXyz dp = ref Unsafe.Add(ref destRef, i); @@ -440,7 +440,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref YCbCr sourceRef = ref MemoryMarshal.GetReference(source); ref CieXyz destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref YCbCr sp = ref Unsafe.Add(ref sourceRef, i); ref CieXyz dp = ref Unsafe.Add(ref destRef, i); diff --git a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Cmyk.cs b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Cmyk.cs index 068583e82f..ea9a5d734b 100644 --- a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Cmyk.cs +++ b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Cmyk.cs @@ -36,7 +36,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref CieLab sourceRef = ref MemoryMarshal.GetReference(source); ref Cmyk destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref CieLab sp = ref Unsafe.Add(ref sourceRef, i); ref Cmyk dp = ref Unsafe.Add(ref destRef, i); @@ -69,7 +69,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref CieLch sourceRef = ref MemoryMarshal.GetReference(source); ref Cmyk destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref CieLch sp = ref Unsafe.Add(ref sourceRef, i); ref Cmyk dp = ref Unsafe.Add(ref destRef, i); @@ -102,7 +102,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref CieLchuv sourceRef = ref MemoryMarshal.GetReference(source); ref Cmyk destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref CieLchuv sp = ref Unsafe.Add(ref sourceRef, i); ref Cmyk dp = ref Unsafe.Add(ref destRef, i); @@ -135,7 +135,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref CieLuv sourceRef = ref MemoryMarshal.GetReference(source); ref Cmyk destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref CieLuv sp = ref Unsafe.Add(ref sourceRef, i); ref Cmyk dp = ref Unsafe.Add(ref destRef, i); @@ -168,7 +168,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref CieXyy sourceRef = ref MemoryMarshal.GetReference(source); ref Cmyk destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref CieXyy sp = ref Unsafe.Add(ref sourceRef, i); ref Cmyk dp = ref Unsafe.Add(ref destRef, i); @@ -201,7 +201,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref CieXyz sourceRef = ref MemoryMarshal.GetReference(source); ref Cmyk destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref CieXyz sp = ref Unsafe.Add(ref sourceRef, i); ref Cmyk dp = ref Unsafe.Add(ref destRef, i); @@ -234,7 +234,7 @@ public static void Convert(ReadOnlySpan source, Span destination) ref Hsl sourceRef = ref MemoryMarshal.GetReference(source); ref Cmyk destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref Hsl sp = ref Unsafe.Add(ref sourceRef, i); ref Cmyk dp = ref Unsafe.Add(ref destRef, i); @@ -267,7 +267,7 @@ public static void Convert(ReadOnlySpan source, Span destination) ref Hsv sourceRef = ref MemoryMarshal.GetReference(source); ref Cmyk destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref Hsv sp = ref Unsafe.Add(ref sourceRef, i); ref Cmyk dp = ref Unsafe.Add(ref destRef, i); @@ -300,7 +300,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref HunterLab sourceRef = ref MemoryMarshal.GetReference(source); ref Cmyk destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref HunterLab sp = ref Unsafe.Add(ref sourceRef, i); ref Cmyk dp = ref Unsafe.Add(ref destRef, i); @@ -333,7 +333,7 @@ public static void Convert(ReadOnlySpan source, Span destinatio ref LinearRgb sourceRef = ref MemoryMarshal.GetReference(source); ref Cmyk destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref LinearRgb sp = ref Unsafe.Add(ref sourceRef, i); ref Cmyk dp = ref Unsafe.Add(ref destRef, i); @@ -366,7 +366,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref Lms sourceRef = ref MemoryMarshal.GetReference(source); ref Cmyk destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref Lms sp = ref Unsafe.Add(ref sourceRef, i); ref Cmyk dp = ref Unsafe.Add(ref destRef, i); @@ -394,7 +394,7 @@ public static void Convert(ReadOnlySpan source, Span destination) ref Rgb sourceRef = ref MemoryMarshal.GetReference(source); ref Cmyk destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref Rgb sp = ref Unsafe.Add(ref sourceRef, i); ref Cmyk dp = ref Unsafe.Add(ref destRef, i); @@ -427,7 +427,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref YCbCr sourceRef = ref MemoryMarshal.GetReference(source); ref Cmyk destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref YCbCr sp = ref Unsafe.Add(ref sourceRef, i); ref Cmyk dp = ref Unsafe.Add(ref destRef, i); diff --git a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Hsl.cs b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Hsl.cs index f40544b7a9..67ec162917 100644 --- a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Hsl.cs +++ b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Hsl.cs @@ -36,7 +36,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref CieLab sourceRef = ref MemoryMarshal.GetReference(source); ref Hsl destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref CieLab sp = ref Unsafe.Add(ref sourceRef, i); ref Hsl dp = ref Unsafe.Add(ref destRef, i); @@ -69,7 +69,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref CieLch sourceRef = ref MemoryMarshal.GetReference(source); ref Hsl destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref CieLch sp = ref Unsafe.Add(ref sourceRef, i); ref Hsl dp = ref Unsafe.Add(ref destRef, i); @@ -102,7 +102,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref CieLchuv sourceRef = ref MemoryMarshal.GetReference(source); ref Hsl destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref CieLchuv sp = ref Unsafe.Add(ref sourceRef, i); ref Hsl dp = ref Unsafe.Add(ref destRef, i); @@ -135,7 +135,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref CieLuv sourceRef = ref MemoryMarshal.GetReference(source); ref Hsl destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref CieLuv sp = ref Unsafe.Add(ref sourceRef, i); ref Hsl dp = ref Unsafe.Add(ref destRef, i); @@ -168,7 +168,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref CieXyy sourceRef = ref MemoryMarshal.GetReference(source); ref Hsl destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref CieXyy sp = ref Unsafe.Add(ref sourceRef, i); ref Hsl dp = ref Unsafe.Add(ref destRef, i); @@ -201,7 +201,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref CieXyz sourceRef = ref MemoryMarshal.GetReference(source); ref Hsl destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref CieXyz sp = ref Unsafe.Add(ref sourceRef, i); ref Hsl dp = ref Unsafe.Add(ref destRef, i); @@ -234,7 +234,7 @@ public static void Convert(ReadOnlySpan source, Span destination) ref Cmyk sourceRef = ref MemoryMarshal.GetReference(source); ref Hsl destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref Cmyk sp = ref Unsafe.Add(ref sourceRef, i); ref Hsl dp = ref Unsafe.Add(ref destRef, i); @@ -267,7 +267,7 @@ public static void Convert(ReadOnlySpan source, Span destination) ref Hsv sourceRef = ref MemoryMarshal.GetReference(source); ref Hsl destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref Hsv sp = ref Unsafe.Add(ref sourceRef, i); ref Hsl dp = ref Unsafe.Add(ref destRef, i); @@ -300,7 +300,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref HunterLab sourceRef = ref MemoryMarshal.GetReference(source); ref Hsl destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref HunterLab sp = ref Unsafe.Add(ref sourceRef, i); ref Hsl dp = ref Unsafe.Add(ref destRef, i); @@ -333,7 +333,7 @@ public static void Convert(ReadOnlySpan source, Span destination ref LinearRgb sourceRef = ref MemoryMarshal.GetReference(source); ref Hsl destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref LinearRgb sp = ref Unsafe.Add(ref sourceRef, i); ref Hsl dp = ref Unsafe.Add(ref destRef, i); @@ -366,7 +366,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref Lms sourceRef = ref MemoryMarshal.GetReference(source); ref Hsl destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref Lms sp = ref Unsafe.Add(ref sourceRef, i); ref Hsl dp = ref Unsafe.Add(ref destRef, i); @@ -394,7 +394,7 @@ public static void Convert(ReadOnlySpan source, Span destination) ref Rgb sourceRef = ref MemoryMarshal.GetReference(source); ref Hsl destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref Rgb sp = ref Unsafe.Add(ref sourceRef, i); ref Hsl dp = ref Unsafe.Add(ref destRef, i); @@ -427,7 +427,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref YCbCr sourceRef = ref MemoryMarshal.GetReference(source); ref Hsl destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref YCbCr sp = ref Unsafe.Add(ref sourceRef, i); ref Hsl dp = ref Unsafe.Add(ref destRef, i); diff --git a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Hsv.cs b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Hsv.cs index 8bd014ed96..47ee42dc5a 100644 --- a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Hsv.cs +++ b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Hsv.cs @@ -36,7 +36,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref CieLab sourceRef = ref MemoryMarshal.GetReference(source); ref Hsv destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref CieLab sp = ref Unsafe.Add(ref sourceRef, i); ref Hsv dp = ref Unsafe.Add(ref destRef, i); @@ -69,7 +69,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref CieLch sourceRef = ref MemoryMarshal.GetReference(source); ref Hsv destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref CieLch sp = ref Unsafe.Add(ref sourceRef, i); ref Hsv dp = ref Unsafe.Add(ref destRef, i); @@ -102,7 +102,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref CieLchuv sourceRef = ref MemoryMarshal.GetReference(source); ref Hsv destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref CieLchuv sp = ref Unsafe.Add(ref sourceRef, i); ref Hsv dp = ref Unsafe.Add(ref destRef, i); @@ -135,7 +135,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref CieLuv sourceRef = ref MemoryMarshal.GetReference(source); ref Hsv destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref CieLuv sp = ref Unsafe.Add(ref sourceRef, i); ref Hsv dp = ref Unsafe.Add(ref destRef, i); @@ -168,7 +168,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref CieXyy sourceRef = ref MemoryMarshal.GetReference(source); ref Hsv destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref CieXyy sp = ref Unsafe.Add(ref sourceRef, i); ref Hsv dp = ref Unsafe.Add(ref destRef, i); @@ -201,7 +201,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref CieXyz sourceRef = ref MemoryMarshal.GetReference(source); ref Hsv destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref CieXyz sp = ref Unsafe.Add(ref sourceRef, i); ref Hsv dp = ref Unsafe.Add(ref destRef, i); @@ -234,7 +234,7 @@ public static void Convert(ReadOnlySpan source, Span destination) ref Cmyk sourceRef = ref MemoryMarshal.GetReference(source); ref Hsv destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref Cmyk sp = ref Unsafe.Add(ref sourceRef, i); ref Hsv dp = ref Unsafe.Add(ref destRef, i); @@ -267,7 +267,7 @@ public static void Convert(ReadOnlySpan source, Span destination) ref Hsl sourceRef = ref MemoryMarshal.GetReference(source); ref Hsv destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref Hsl sp = ref Unsafe.Add(ref sourceRef, i); ref Hsv dp = ref Unsafe.Add(ref destRef, i); @@ -300,7 +300,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref HunterLab sourceRef = ref MemoryMarshal.GetReference(source); ref Hsv destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref HunterLab sp = ref Unsafe.Add(ref sourceRef, i); ref Hsv dp = ref Unsafe.Add(ref destRef, i); @@ -333,7 +333,7 @@ public static void Convert(ReadOnlySpan source, Span destination ref LinearRgb sourceRef = ref MemoryMarshal.GetReference(source); ref Hsv destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref LinearRgb sp = ref Unsafe.Add(ref sourceRef, i); ref Hsv dp = ref Unsafe.Add(ref destRef, i); @@ -366,7 +366,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref Lms sourceRef = ref MemoryMarshal.GetReference(source); ref Hsv destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref Lms sp = ref Unsafe.Add(ref sourceRef, i); ref Hsv dp = ref Unsafe.Add(ref destRef, i); @@ -394,7 +394,7 @@ public static void Convert(ReadOnlySpan source, Span destination) ref Rgb sourceRef = ref MemoryMarshal.GetReference(source); ref Hsv destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref Rgb sp = ref Unsafe.Add(ref sourceRef, i); ref Hsv dp = ref Unsafe.Add(ref destRef, i); @@ -427,7 +427,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref YCbCr sourceRef = ref MemoryMarshal.GetReference(source); ref Hsv destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref YCbCr sp = ref Unsafe.Add(ref sourceRef, i); ref Hsv dp = ref Unsafe.Add(ref destRef, i); diff --git a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.HunterLab.cs b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.HunterLab.cs index 2890594651..0604027760 100644 --- a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.HunterLab.cs +++ b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.HunterLab.cs @@ -24,7 +24,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref CieLab sourceRef = ref MemoryMarshal.GetReference(source); ref HunterLab destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref CieLab sp = ref Unsafe.Add(ref sourceRef, i); ref HunterLab dp = ref Unsafe.Add(ref destRef, i); @@ -45,7 +45,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref CieLch sourceRef = ref MemoryMarshal.GetReference(source); ref HunterLab destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref CieLch sp = ref Unsafe.Add(ref sourceRef, i); ref HunterLab dp = ref Unsafe.Add(ref destRef, i); @@ -66,7 +66,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref CieLchuv sourceRef = ref MemoryMarshal.GetReference(source); ref HunterLab destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref CieLchuv sp = ref Unsafe.Add(ref sourceRef, i); ref HunterLab dp = ref Unsafe.Add(ref destRef, i); @@ -87,7 +87,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref CieLuv sourceRef = ref MemoryMarshal.GetReference(source); ref HunterLab destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref CieLuv sp = ref Unsafe.Add(ref sourceRef, i); ref HunterLab dp = ref Unsafe.Add(ref destRef, i); @@ -108,7 +108,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref CieXyy sourceRef = ref MemoryMarshal.GetReference(source); ref HunterLab destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref CieXyy sp = ref Unsafe.Add(ref sourceRef, i); ref HunterLab dp = ref Unsafe.Add(ref destRef, i); @@ -129,7 +129,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref CieXyz sourceRef = ref MemoryMarshal.GetReference(source); ref HunterLab destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref CieXyz sp = ref Unsafe.Add(ref sourceRef, i); ref HunterLab dp = ref Unsafe.Add(ref destRef, i); @@ -150,7 +150,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref Cmyk sourceRef = ref MemoryMarshal.GetReference(source); ref HunterLab destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref Cmyk sp = ref Unsafe.Add(ref sourceRef, i); ref HunterLab dp = ref Unsafe.Add(ref destRef, i); @@ -171,7 +171,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref Hsl sourceRef = ref MemoryMarshal.GetReference(source); ref HunterLab destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref Hsl sp = ref Unsafe.Add(ref sourceRef, i); ref HunterLab dp = ref Unsafe.Add(ref destRef, i); @@ -192,7 +192,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref Hsv sourceRef = ref MemoryMarshal.GetReference(source); ref HunterLab destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref Hsv sp = ref Unsafe.Add(ref sourceRef, i); ref HunterLab dp = ref Unsafe.Add(ref destRef, i); @@ -213,7 +213,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref LinearRgb sourceRef = ref MemoryMarshal.GetReference(source); ref HunterLab destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref LinearRgb sp = ref Unsafe.Add(ref sourceRef, i); ref HunterLab dp = ref Unsafe.Add(ref destRef, i); @@ -234,7 +234,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref Lms sourceRef = ref MemoryMarshal.GetReference(source); ref HunterLab destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref Lms sp = ref Unsafe.Add(ref sourceRef, i); ref HunterLab dp = ref Unsafe.Add(ref destRef, i); @@ -255,7 +255,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref Rgb sourceRef = ref MemoryMarshal.GetReference(source); ref HunterLab destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref Rgb sp = ref Unsafe.Add(ref sourceRef, i); ref HunterLab dp = ref Unsafe.Add(ref destRef, i); @@ -276,7 +276,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref YCbCr sourceRef = ref MemoryMarshal.GetReference(source); ref HunterLab destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref YCbCr sp = ref Unsafe.Add(ref sourceRef, i); ref HunterLab dp = ref Unsafe.Add(ref destRef, i); diff --git a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.LinearRgb.cs b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.LinearRgb.cs index 897ec02a0f..fd385a15b0 100644 --- a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.LinearRgb.cs +++ b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.LinearRgb.cs @@ -24,7 +24,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref CieLab sourceRef = ref MemoryMarshal.GetReference(source); ref LinearRgb destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref CieLab sp = ref Unsafe.Add(ref sourceRef, i); ref LinearRgb dp = ref Unsafe.Add(ref destRef, i); @@ -45,7 +45,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref CieLch sourceRef = ref MemoryMarshal.GetReference(source); ref LinearRgb destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref CieLch sp = ref Unsafe.Add(ref sourceRef, i); ref LinearRgb dp = ref Unsafe.Add(ref destRef, i); @@ -66,7 +66,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref CieLchuv sourceRef = ref MemoryMarshal.GetReference(source); ref LinearRgb destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref CieLchuv sp = ref Unsafe.Add(ref sourceRef, i); ref LinearRgb dp = ref Unsafe.Add(ref destRef, i); @@ -87,7 +87,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref CieLuv sourceRef = ref MemoryMarshal.GetReference(source); ref LinearRgb destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref CieLuv sp = ref Unsafe.Add(ref sourceRef, i); ref LinearRgb dp = ref Unsafe.Add(ref destRef, i); @@ -108,7 +108,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref CieXyy sourceRef = ref MemoryMarshal.GetReference(source); ref LinearRgb destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref CieXyy sp = ref Unsafe.Add(ref sourceRef, i); ref LinearRgb dp = ref Unsafe.Add(ref destRef, i); @@ -129,7 +129,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref CieXyz sourceRef = ref MemoryMarshal.GetReference(source); ref LinearRgb destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref CieXyz sp = ref Unsafe.Add(ref sourceRef, i); ref LinearRgb dp = ref Unsafe.Add(ref destRef, i); @@ -150,7 +150,7 @@ public static void Convert(ReadOnlySpan source, Span destinatio ref Cmyk sourceRef = ref MemoryMarshal.GetReference(source); ref LinearRgb destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref Cmyk sp = ref Unsafe.Add(ref sourceRef, i); ref LinearRgb dp = ref Unsafe.Add(ref destRef, i); @@ -171,7 +171,7 @@ public static void Convert(ReadOnlySpan source, Span destination ref Hsl sourceRef = ref MemoryMarshal.GetReference(source); ref LinearRgb destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref Hsl sp = ref Unsafe.Add(ref sourceRef, i); ref LinearRgb dp = ref Unsafe.Add(ref destRef, i); @@ -192,7 +192,7 @@ public static void Convert(ReadOnlySpan source, Span destination ref Hsv sourceRef = ref MemoryMarshal.GetReference(source); ref LinearRgb destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref Hsv sp = ref Unsafe.Add(ref sourceRef, i); ref LinearRgb dp = ref Unsafe.Add(ref destRef, i); @@ -213,7 +213,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref HunterLab sourceRef = ref MemoryMarshal.GetReference(source); ref LinearRgb destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref HunterLab sp = ref Unsafe.Add(ref sourceRef, i); ref LinearRgb dp = ref Unsafe.Add(ref destRef, i); @@ -234,7 +234,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref Lms sourceRef = ref MemoryMarshal.GetReference(source); ref LinearRgb destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref Lms sp = ref Unsafe.Add(ref sourceRef, i); ref LinearRgb dp = ref Unsafe.Add(ref destRef, i); @@ -255,7 +255,7 @@ public static void Convert(ReadOnlySpan source, Span destination ref Rgb sourceRef = ref MemoryMarshal.GetReference(source); ref LinearRgb destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref Rgb sp = ref Unsafe.Add(ref sourceRef, i); ref LinearRgb dp = ref Unsafe.Add(ref destRef, i); @@ -276,7 +276,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref YCbCr sourceRef = ref MemoryMarshal.GetReference(source); ref LinearRgb destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref YCbCr sp = ref Unsafe.Add(ref sourceRef, i); ref LinearRgb dp = ref Unsafe.Add(ref destRef, i); diff --git a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Lms.cs b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Lms.cs index 291f3a5fac..56f61ef80b 100644 --- a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Lms.cs +++ b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Lms.cs @@ -24,7 +24,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref CieLab sourceRef = ref MemoryMarshal.GetReference(source); ref Lms destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref CieLab sp = ref Unsafe.Add(ref sourceRef, i); ref Lms dp = ref Unsafe.Add(ref destRef, i); @@ -45,7 +45,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref CieLch sourceRef = ref MemoryMarshal.GetReference(source); ref Lms destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref CieLch sp = ref Unsafe.Add(ref sourceRef, i); ref Lms dp = ref Unsafe.Add(ref destRef, i); @@ -66,7 +66,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref CieLchuv sourceRef = ref MemoryMarshal.GetReference(source); ref Lms destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref CieLchuv sp = ref Unsafe.Add(ref sourceRef, i); ref Lms dp = ref Unsafe.Add(ref destRef, i); @@ -87,7 +87,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref CieLuv sourceRef = ref MemoryMarshal.GetReference(source); ref Lms destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref CieLuv sp = ref Unsafe.Add(ref sourceRef, i); ref Lms dp = ref Unsafe.Add(ref destRef, i); @@ -108,7 +108,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref CieXyy sourceRef = ref MemoryMarshal.GetReference(source); ref Lms destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref CieXyy sp = ref Unsafe.Add(ref sourceRef, i); ref Lms dp = ref Unsafe.Add(ref destRef, i); @@ -129,7 +129,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref CieXyz sourceRef = ref MemoryMarshal.GetReference(source); ref Lms destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref CieXyz sp = ref Unsafe.Add(ref sourceRef, i); ref Lms dp = ref Unsafe.Add(ref destRef, i); @@ -150,7 +150,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref Cmyk sourceRef = ref MemoryMarshal.GetReference(source); ref Lms destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref Cmyk sp = ref Unsafe.Add(ref sourceRef, i); ref Lms dp = ref Unsafe.Add(ref destRef, i); @@ -171,7 +171,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref Hsl sourceRef = ref MemoryMarshal.GetReference(source); ref Lms destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref Hsl sp = ref Unsafe.Add(ref sourceRef, i); ref Lms dp = ref Unsafe.Add(ref destRef, i); @@ -192,7 +192,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref Hsv sourceRef = ref MemoryMarshal.GetReference(source); ref Lms destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref Hsv sp = ref Unsafe.Add(ref sourceRef, i); ref Lms dp = ref Unsafe.Add(ref destRef, i); @@ -213,7 +213,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref HunterLab sourceRef = ref MemoryMarshal.GetReference(source); ref Lms destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref HunterLab sp = ref Unsafe.Add(ref sourceRef, i); ref Lms dp = ref Unsafe.Add(ref destRef, i); @@ -234,7 +234,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref LinearRgb sourceRef = ref MemoryMarshal.GetReference(source); ref Lms destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref LinearRgb sp = ref Unsafe.Add(ref sourceRef, i); ref Lms dp = ref Unsafe.Add(ref destRef, i); @@ -255,7 +255,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref Rgb sourceRef = ref MemoryMarshal.GetReference(source); ref Lms destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref Rgb sp = ref Unsafe.Add(ref sourceRef, i); ref Lms dp = ref Unsafe.Add(ref destRef, i); @@ -276,7 +276,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref YCbCr sourceRef = ref MemoryMarshal.GetReference(source); ref Lms destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref YCbCr sp = ref Unsafe.Add(ref sourceRef, i); ref Lms dp = ref Unsafe.Add(ref destRef, i); diff --git a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Rgb.cs b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Rgb.cs index 557c294992..080e1fc4bf 100644 --- a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Rgb.cs +++ b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Rgb.cs @@ -24,7 +24,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref CieLab sourceRef = ref MemoryMarshal.GetReference(source); ref Rgb destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref CieLab sp = ref Unsafe.Add(ref sourceRef, i); ref Rgb dp = ref Unsafe.Add(ref destRef, i); @@ -45,7 +45,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref CieLch sourceRef = ref MemoryMarshal.GetReference(source); ref Rgb destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref CieLch sp = ref Unsafe.Add(ref sourceRef, i); ref Rgb dp = ref Unsafe.Add(ref destRef, i); @@ -66,7 +66,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref CieLchuv sourceRef = ref MemoryMarshal.GetReference(source); ref Rgb destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref CieLchuv sp = ref Unsafe.Add(ref sourceRef, i); ref Rgb dp = ref Unsafe.Add(ref destRef, i); @@ -87,7 +87,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref CieLuv sourceRef = ref MemoryMarshal.GetReference(source); ref Rgb destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref CieLuv sp = ref Unsafe.Add(ref sourceRef, i); ref Rgb dp = ref Unsafe.Add(ref destRef, i); @@ -108,7 +108,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref CieXyy sourceRef = ref MemoryMarshal.GetReference(source); ref Rgb destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref CieXyy sp = ref Unsafe.Add(ref sourceRef, i); ref Rgb dp = ref Unsafe.Add(ref destRef, i); @@ -129,7 +129,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref CieXyz sourceRef = ref MemoryMarshal.GetReference(source); ref Rgb destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref CieXyz sp = ref Unsafe.Add(ref sourceRef, i); ref Rgb dp = ref Unsafe.Add(ref destRef, i); @@ -150,7 +150,7 @@ public static void Convert(ReadOnlySpan source, Span destination) ref Cmyk sourceRef = ref MemoryMarshal.GetReference(source); ref Rgb destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref Cmyk sp = ref Unsafe.Add(ref sourceRef, i); ref Rgb dp = ref Unsafe.Add(ref destRef, i); @@ -171,7 +171,7 @@ public static void Convert(ReadOnlySpan source, Span destination) ref Hsv sourceRef = ref MemoryMarshal.GetReference(source); ref Rgb destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref Hsv sp = ref Unsafe.Add(ref sourceRef, i); ref Rgb dp = ref Unsafe.Add(ref destRef, i); @@ -192,7 +192,7 @@ public static void Convert(ReadOnlySpan source, Span destination) ref Hsl sourceRef = ref MemoryMarshal.GetReference(source); ref Rgb destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref Hsl sp = ref Unsafe.Add(ref sourceRef, i); ref Rgb dp = ref Unsafe.Add(ref destRef, i); @@ -213,7 +213,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref HunterLab sourceRef = ref MemoryMarshal.GetReference(source); ref Rgb destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref HunterLab sp = ref Unsafe.Add(ref sourceRef, i); ref Rgb dp = ref Unsafe.Add(ref destRef, i); @@ -234,7 +234,7 @@ public static void Convert(ReadOnlySpan source, Span destination ref LinearRgb sourceRef = ref MemoryMarshal.GetReference(source); ref Rgb destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref LinearRgb sp = ref Unsafe.Add(ref sourceRef, i); ref Rgb dp = ref Unsafe.Add(ref destRef, i); @@ -255,7 +255,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref Lms sourceRef = ref MemoryMarshal.GetReference(source); ref Rgb destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref Lms sp = ref Unsafe.Add(ref sourceRef, i); ref Rgb dp = ref Unsafe.Add(ref destRef, i); @@ -276,7 +276,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref YCbCr sourceRef = ref MemoryMarshal.GetReference(source); ref Rgb destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref YCbCr sp = ref Unsafe.Add(ref sourceRef, i); ref Rgb dp = ref Unsafe.Add(ref destRef, i); diff --git a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.YCbCr.cs b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.YCbCr.cs index 8ea875a3d7..da8e046ff7 100644 --- a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.YCbCr.cs +++ b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.YCbCr.cs @@ -24,7 +24,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref CieLab sourceRef = ref MemoryMarshal.GetReference(source); ref YCbCr destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref CieLab sp = ref Unsafe.Add(ref sourceRef, i); ref YCbCr dp = ref Unsafe.Add(ref destRef, i); @@ -45,7 +45,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref CieLch sourceRef = ref MemoryMarshal.GetReference(source); ref YCbCr destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref CieLch sp = ref Unsafe.Add(ref sourceRef, i); ref YCbCr dp = ref Unsafe.Add(ref destRef, i); @@ -66,7 +66,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref CieLuv sourceRef = ref MemoryMarshal.GetReference(source); ref YCbCr destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref CieLuv sp = ref Unsafe.Add(ref sourceRef, i); ref YCbCr dp = ref Unsafe.Add(ref destRef, i); @@ -87,7 +87,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref CieXyy sourceRef = ref MemoryMarshal.GetReference(source); ref YCbCr destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref CieXyy sp = ref Unsafe.Add(ref sourceRef, i); ref YCbCr dp = ref Unsafe.Add(ref destRef, i); @@ -108,7 +108,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref CieXyz sourceRef = ref MemoryMarshal.GetReference(source); ref YCbCr destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref CieXyz sp = ref Unsafe.Add(ref sourceRef, i); ref YCbCr dp = ref Unsafe.Add(ref destRef, i); @@ -129,7 +129,7 @@ public static void Convert(ReadOnlySpan source, Span destination) ref Cmyk sourceRef = ref MemoryMarshal.GetReference(source); ref YCbCr destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref Cmyk sp = ref Unsafe.Add(ref sourceRef, i); ref YCbCr dp = ref Unsafe.Add(ref destRef, i); @@ -150,7 +150,7 @@ public static void Convert(ReadOnlySpan source, Span destination) ref Hsl sourceRef = ref MemoryMarshal.GetReference(source); ref YCbCr destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref Hsl sp = ref Unsafe.Add(ref sourceRef, i); ref YCbCr dp = ref Unsafe.Add(ref destRef, i); @@ -171,7 +171,7 @@ public static void Convert(ReadOnlySpan source, Span destination) ref Hsv sourceRef = ref MemoryMarshal.GetReference(source); ref YCbCr destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref Hsv sp = ref Unsafe.Add(ref sourceRef, i); ref YCbCr dp = ref Unsafe.Add(ref destRef, i); @@ -192,7 +192,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref HunterLab sourceRef = ref MemoryMarshal.GetReference(source); ref YCbCr destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref HunterLab sp = ref Unsafe.Add(ref sourceRef, i); ref YCbCr dp = ref Unsafe.Add(ref destRef, i); @@ -213,7 +213,7 @@ public static void Convert(ReadOnlySpan source, Span destinati ref LinearRgb sourceRef = ref MemoryMarshal.GetReference(source); ref YCbCr destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref LinearRgb sp = ref Unsafe.Add(ref sourceRef, i); ref YCbCr dp = ref Unsafe.Add(ref destRef, i); @@ -234,7 +234,7 @@ public void Convert(ReadOnlySpan source, Span destination) ref Lms sourceRef = ref MemoryMarshal.GetReference(source); ref YCbCr destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref Lms sp = ref Unsafe.Add(ref sourceRef, i); ref YCbCr dp = ref Unsafe.Add(ref destRef, i); @@ -255,7 +255,7 @@ public static void Convert(ReadOnlySpan source, Span destination) ref Rgb sourceRef = ref MemoryMarshal.GetReference(source); ref YCbCr destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref Rgb sp = ref Unsafe.Add(ref sourceRef, i); ref YCbCr dp = ref Unsafe.Add(ref destRef, i); diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/VonKriesChromaticAdaptation.cs b/src/ImageSharp/ColorSpaces/Conversion/Implementation/VonKriesChromaticAdaptation.cs index 55ed41220d..97e9cee813 100644 --- a/src/ImageSharp/ColorSpaces/Conversion/Implementation/VonKriesChromaticAdaptation.cs +++ b/src/ImageSharp/ColorSpaces/Conversion/Implementation/VonKriesChromaticAdaptation.cs @@ -81,7 +81,7 @@ public void Transform( ref CieXyz sourceRef = ref MemoryMarshal.GetReference(source); ref CieXyz destRef = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref CieXyz sp = ref Unsafe.Add(ref sourceRef, i); ref CieXyz dp = ref Unsafe.Add(ref destRef, i); diff --git a/src/ImageSharp/Common/Helpers/HexConverter.cs b/src/ImageSharp/Common/Helpers/HexConverter.cs index 590b9d63c7..8c473688f3 100644 --- a/src/ImageSharp/Common/Helpers/HexConverter.cs +++ b/src/ImageSharp/Common/Helpers/HexConverter.cs @@ -16,12 +16,12 @@ internal static class HexConverter /// The number of bytes written to . public static int HexStringToBytes(ReadOnlySpan chars, Span bytes) { - if ((chars.Length & 1 /* bit-hack for % 2 */) != 0) + if (Numerics.Modulo2(chars.Length) != 0) { throw new ArgumentException("Input string length must be a multiple of 2", nameof(chars)); } - if ((bytes.Length << 1 /* bit-hack for * 2 */) < chars.Length) + if ((bytes.Length << 1 /* bit-hack for *2 */) < chars.Length) { throw new ArgumentException("Output span must be at least half the length of the input string"); } @@ -55,7 +55,7 @@ static int FromChar(int c) 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 255 }; - return c >= charToHexLookup.Length ? 0xFF : charToHexLookup[c]; + return (uint)c >= (uint)charToHexLookup.Length ? 0xFF : charToHexLookup[c]; } // See https://source.dot.net/#System.Private.CoreLib/HexConverter.cs,4681d45a0aa0b361 diff --git a/src/ImageSharp/Common/Helpers/Shuffle/IComponentShuffle.cs b/src/ImageSharp/Common/Helpers/Shuffle/IComponentShuffle.cs index f2135b7645..a86355135e 100644 --- a/src/ImageSharp/Common/Helpers/Shuffle/IComponentShuffle.cs +++ b/src/ImageSharp/Common/Helpers/Shuffle/IComponentShuffle.cs @@ -61,14 +61,14 @@ public void RunFallbackShuffle(ReadOnlySpan source, Span dest) ref byte sBase = ref MemoryMarshal.GetReference(source); ref byte dBase = ref MemoryMarshal.GetReference(dest); - Shuffle.InverseMMShuffle(this.Control, out int p3, out int p2, out int p1, out int p0); + Shuffle.InverseMMShuffle(this.Control, out uint p3, out uint p2, out uint p1, out uint p0); - for (nint i = 0; i < (uint)source.Length; i += 4) + for (nuint i = 0; i < (uint)source.Length; i += 4) { - Unsafe.Add(ref dBase, i + 0) = Unsafe.Add(ref sBase, (nint)(uint)p0 + i); - Unsafe.Add(ref dBase, i + 1) = Unsafe.Add(ref sBase, (nint)(uint)p1 + i); - Unsafe.Add(ref dBase, i + 2) = Unsafe.Add(ref sBase, (nint)(uint)p2 + i); - Unsafe.Add(ref dBase, i + 3) = Unsafe.Add(ref sBase, (nint)(uint)p3 + i); + Unsafe.Add(ref dBase, i + 0) = Unsafe.Add(ref sBase, p0 + i); + Unsafe.Add(ref dBase, i + 1) = Unsafe.Add(ref sBase, p1 + i); + Unsafe.Add(ref dBase, i + 2) = Unsafe.Add(ref sBase, p2 + i); + Unsafe.Add(ref dBase, i + 3) = Unsafe.Add(ref sBase, p3 + i); } } } @@ -86,7 +86,7 @@ public void RunFallbackShuffle(ReadOnlySpan source, Span dest) ref uint dBase = ref Unsafe.As(ref MemoryMarshal.GetReference(dest)); int n = (int)((uint)source.Length / 4); - for (nint i = 0; i < (uint)n; i++) + for (nuint i = 0; i < (uint)n; i++) { uint packed = Unsafe.Add(ref sBase, i); @@ -110,7 +110,7 @@ public void RunFallbackShuffle(ReadOnlySpan source, Span dest) ref uint dBase = ref Unsafe.As(ref MemoryMarshal.GetReference(dest)); int n = (int)((uint)source.Length / 4); - for (nint i = 0; i < (uint)n; i++) + for (nuint i = 0; i < (uint)n; i++) { uint packed = Unsafe.Add(ref sBase, i); @@ -134,7 +134,7 @@ public void RunFallbackShuffle(ReadOnlySpan source, Span dest) ref uint dBase = ref Unsafe.As(ref MemoryMarshal.GetReference(dest)); int n = (int)((uint)source.Length / 4); - for (nint i = 0; i < (uint)n; i++) + for (nuint i = 0; i < (uint)n; i++) { uint packed = Unsafe.Add(ref sBase, i); @@ -158,7 +158,7 @@ public void RunFallbackShuffle(ReadOnlySpan source, Span dest) ref uint dBase = ref Unsafe.As(ref MemoryMarshal.GetReference(dest)); int n = (int)((uint)source.Length / 4); - for (nint i = 0; i < (uint)n; i++) + for (nuint i = 0; i < (uint)n; i++) { uint packed = Unsafe.Add(ref sBase, i); @@ -189,7 +189,7 @@ public void RunFallbackShuffle(ReadOnlySpan source, Span dest) ref uint dBase = ref Unsafe.As(ref MemoryMarshal.GetReference(dest)); int n = (int)((uint)source.Length / 4); - for (nint i = 0; i < (uint)n; i++) + for (nuint i = 0; i < (uint)n; i++) { uint packed = Unsafe.Add(ref sBase, i); diff --git a/src/ImageSharp/Common/Helpers/Shuffle/IPad3Shuffle4.cs b/src/ImageSharp/Common/Helpers/Shuffle/IPad3Shuffle4.cs index 3e1084d313..6cf6eef08e 100644 --- a/src/ImageSharp/Common/Helpers/Shuffle/IPad3Shuffle4.cs +++ b/src/ImageSharp/Common/Helpers/Shuffle/IPad3Shuffle4.cs @@ -29,21 +29,21 @@ public void RunFallbackShuffle(ReadOnlySpan source, Span dest) ref byte sBase = ref MemoryMarshal.GetReference(source); ref byte dBase = ref MemoryMarshal.GetReference(dest); - Shuffle.InverseMMShuffle(this.Control, out int p3, out int p2, out int p1, out int p0); + Shuffle.InverseMMShuffle(this.Control, out uint p3, out uint p2, out uint p1, out uint p0); Span temp = stackalloc byte[4]; ref byte t = ref MemoryMarshal.GetReference(temp); ref uint tu = ref Unsafe.As(ref t); - for (nint i = 0, j = 0; i < (uint)source.Length; i += 3, j += 4) + for (nuint i = 0, j = 0; i < (uint)source.Length; i += 3, j += 4) { ref byte s = ref Unsafe.Add(ref sBase, i); tu = Unsafe.As(ref s) | 0xFF000000; - Unsafe.Add(ref dBase, j + 0) = Unsafe.Add(ref t, (uint)p0); - Unsafe.Add(ref dBase, j + 1) = Unsafe.Add(ref t, (uint)p1); - Unsafe.Add(ref dBase, j + 2) = Unsafe.Add(ref t, (uint)p2); - Unsafe.Add(ref dBase, j + 3) = Unsafe.Add(ref t, (uint)p3); + Unsafe.Add(ref dBase, j + 0) = Unsafe.Add(ref t, p0); + Unsafe.Add(ref dBase, j + 1) = Unsafe.Add(ref t, p1); + Unsafe.Add(ref dBase, j + 2) = Unsafe.Add(ref t, p2); + Unsafe.Add(ref dBase, j + 3) = Unsafe.Add(ref t, p3); } } } diff --git a/src/ImageSharp/Common/Helpers/Shuffle/IShuffle3.cs b/src/ImageSharp/Common/Helpers/Shuffle/IShuffle3.cs index b149bde09d..2cd586212e 100644 --- a/src/ImageSharp/Common/Helpers/Shuffle/IShuffle3.cs +++ b/src/ImageSharp/Common/Helpers/Shuffle/IShuffle3.cs @@ -29,13 +29,13 @@ public void RunFallbackShuffle(ReadOnlySpan source, Span dest) ref byte sBase = ref MemoryMarshal.GetReference(source); ref byte dBase = ref MemoryMarshal.GetReference(dest); - Shuffle.InverseMMShuffle(this.Control, out _, out int p2, out int p1, out int p0); + Shuffle.InverseMMShuffle(this.Control, out _, out uint p2, out uint p1, out uint p0); - for (nint i = 0; i < (uint)source.Length; i += 3) + for (nuint i = 0; i < (uint)source.Length; i += 3) { - Unsafe.Add(ref dBase, i + 0) = Unsafe.Add(ref sBase, (nint)(uint)p0 + i); - Unsafe.Add(ref dBase, i + 1) = Unsafe.Add(ref sBase, (nint)(uint)p1 + i); - Unsafe.Add(ref dBase, i + 2) = Unsafe.Add(ref sBase, (nint)(uint)p2 + i); + Unsafe.Add(ref dBase, i + 0) = Unsafe.Add(ref sBase, p0 + i); + Unsafe.Add(ref dBase, i + 1) = Unsafe.Add(ref sBase, p1 + i); + Unsafe.Add(ref dBase, i + 2) = Unsafe.Add(ref sBase, p2 + i); } } } diff --git a/src/ImageSharp/Common/Helpers/Shuffle/IShuffle4Slice3.cs b/src/ImageSharp/Common/Helpers/Shuffle/IShuffle4Slice3.cs index 1f12cea257..5e82973e33 100644 --- a/src/ImageSharp/Common/Helpers/Shuffle/IShuffle4Slice3.cs +++ b/src/ImageSharp/Common/Helpers/Shuffle/IShuffle4Slice3.cs @@ -29,13 +29,13 @@ public void RunFallbackShuffle(ReadOnlySpan source, Span dest) ref byte sBase = ref MemoryMarshal.GetReference(source); ref byte dBase = ref MemoryMarshal.GetReference(dest); - Shuffle.InverseMMShuffle(this.Control, out _, out int p2, out int p1, out int p0); + Shuffle.InverseMMShuffle(this.Control, out _, out uint p2, out uint p1, out uint p0); - for (nint i = 0, j = 0; i < (uint)dest.Length; i += 3, j += 4) + for (nuint i = 0, j = 0; i < (uint)dest.Length; i += 3, j += 4) { - Unsafe.Add(ref dBase, i + 0) = Unsafe.Add(ref sBase, (nint)(uint)p0 + j); - Unsafe.Add(ref dBase, i + 1) = Unsafe.Add(ref sBase, (nint)(uint)p1 + j); - Unsafe.Add(ref dBase, i + 2) = Unsafe.Add(ref sBase, (nint)(uint)p2 + j); + Unsafe.Add(ref dBase, i + 0) = Unsafe.Add(ref sBase, p0 + j); + Unsafe.Add(ref dBase, i + 1) = Unsafe.Add(ref sBase, p1 + j); + Unsafe.Add(ref dBase, i + 2) = Unsafe.Add(ref sBase, p2 + j); } } } diff --git a/src/ImageSharp/Common/Helpers/SimdUtils.ExtendedIntrinsics.cs b/src/ImageSharp/Common/Helpers/SimdUtils.ExtendedIntrinsics.cs index 9d2da7dc83..43998d0ec9 100644 --- a/src/ImageSharp/Common/Helpers/SimdUtils.ExtendedIntrinsics.cs +++ b/src/ImageSharp/Common/Helpers/SimdUtils.ExtendedIntrinsics.cs @@ -97,12 +97,12 @@ internal static void ByteToNormalizedFloat(ReadOnlySpan source, Span.Count); - nint n = (nint)(uint)dest.Length / Vector.Count; + nuint n = (uint)(dest.Length / Vector.Count); ref Vector sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); ref Vector destBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(dest)); - for (nint i = 0; i < n; i++) + for (nuint i = 0; i < n; i++) { Vector b = Unsafe.Add(ref sourceBase, i); @@ -132,13 +132,13 @@ internal static void NormalizedFloatToByteSaturate( { VerifySpanInput(source, dest, Vector.Count); - nint n = (nint)(uint)dest.Length / Vector.Count; + nuint n = (uint)(dest.Length / Vector.Count); ref Vector sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); ref Vector destBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(dest)); - for (nint i = 0; i < n; i++) + for (nuint i = 0; i < n; i++) { ref Vector s = ref Unsafe.Add(ref sourceBase, i * 4); diff --git a/src/ImageSharp/Common/Helpers/SimdUtils.FallbackIntrinsics128.cs b/src/ImageSharp/Common/Helpers/SimdUtils.FallbackIntrinsics128.cs index 6fc36cd701..d456d8e42f 100644 --- a/src/ImageSharp/Common/Helpers/SimdUtils.FallbackIntrinsics128.cs +++ b/src/ImageSharp/Common/Helpers/SimdUtils.FallbackIntrinsics128.cs @@ -83,7 +83,7 @@ internal static void ByteToNormalizedFloat(ReadOnlySpan source, Span destBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(dest)); - nint n = (nint)(uint)dest.Length / Vector256.Count; + nint n = (nint)(uint)(dest.Length / Vector256.Count); nint m = Numerics.Modulo4(n); nint u = n - m; @@ -391,9 +391,9 @@ private static void Shuffle3( ref Vector128 destBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(dest)); - nint n = (nint)(uint)source.Length / Vector128.Count; + nuint n = (uint)(source.Length / Vector128.Count); - for (nint i = 0; i < n; i += 3) + for (nuint i = 0; i < n; i += 3) { ref Vector128 vs = ref Unsafe.Add(ref sourceBase, i); @@ -454,9 +454,9 @@ private static void Pad3Shuffle4( ref Vector128 destBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(dest)); - nint n = (nint)(uint)source.Length / Vector128.Count; + nuint n = (uint)(source.Length / Vector128.Count); - for (nint i = 0, j = 0; i < n; i += 3, j += 4) + for (nuint i = 0, j = 0; i < n; i += 3, j += 4) { ref Vector128 v0 = ref Unsafe.Add(ref sourceBase, i); Vector128 v1 = Unsafe.Add(ref v0, 1); @@ -498,9 +498,9 @@ private static void Shuffle4Slice3( ref Vector128 destBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(dest)); - nint n = (nint)(uint)source.Length / Vector128.Count; + nuint n = (uint)(source.Length / Vector128.Count); - for (nint i = 0, j = 0; i < n; i += 4, j += 3) + for (nuint i = 0, j = 0; i < n; i += 4, j += 3) { ref Vector128 vs = ref Unsafe.Add(ref sourceBase, i); @@ -650,16 +650,16 @@ internal static unsafe void ByteToNormalizedFloat( { VerifySpanInput(source, dest, Vector256.Count); - nint n = (nint)(uint)dest.Length / Vector256.Count; + nuint n = (uint)(dest.Length / Vector256.Count); ref Vector256 destBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(dest)); var scale = Vector256.Create(1 / (float)byte.MaxValue); - for (nint i = 0; i < n; i++) + for (nuint i = 0; i < n; i++) { - nint si = Vector256.Count * i; + nuint si = (uint)Vector256.Count * i; Vector256 i0 = Avx2.ConvertToVector256Int32(sourceBase + si); Vector256 i1 = Avx2.ConvertToVector256Int32(sourceBase + si + Vector256.Count); Vector256 i2 = Avx2.ConvertToVector256Int32(sourceBase + si + (Vector256.Count * 2)); @@ -683,7 +683,7 @@ internal static unsafe void ByteToNormalizedFloat( // Sse VerifySpanInput(source, dest, Vector128.Count); - nint n = (nint)(uint)dest.Length / Vector128.Count; + nuint n = (uint)(dest.Length / Vector128.Count); ref Vector128 destBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(dest)); @@ -691,9 +691,9 @@ internal static unsafe void ByteToNormalizedFloat( var scale = Vector128.Create(1 / (float)byte.MaxValue); Vector128 zero = Vector128.Zero; - for (nint i = 0; i < n; i++) + for (nuint i = 0; i < n; i++) { - nint si = Vector128.Count * i; + nuint si = (uint)Vector128.Count * i; Vector128 i0, i1, i2, i3; if (Sse41.IsSupported) @@ -782,7 +782,7 @@ internal static void NormalizedFloatToByteSaturate( { VerifySpanInput(source, dest, Vector256.Count); - nint n = (nint)(uint)dest.Length / Vector256.Count; + nuint n = (uint)(dest.Length / Vector256.Count); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -794,7 +794,7 @@ internal static void NormalizedFloatToByteSaturate( ref byte maskBase = ref MemoryMarshal.GetReference(PermuteMaskDeinterleave8x32); Vector256 mask = Unsafe.As>(ref maskBase); - for (nint i = 0; i < n; i++) + for (nuint i = 0; i < n; i++) { ref Vector256 s = ref Unsafe.Add(ref sourceBase, i * 4); @@ -821,7 +821,7 @@ internal static void NormalizedFloatToByteSaturate( // Sse VerifySpanInput(source, dest, Vector128.Count); - nint n = (nint)(uint)dest.Length / Vector128.Count; + nuint n = (uint)(dest.Length / Vector128.Count); ref Vector128 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -831,7 +831,7 @@ internal static void NormalizedFloatToByteSaturate( var scale = Vector128.Create((float)byte.MaxValue); - for (nint i = 0; i < n; i++) + for (nuint i = 0; i < n; i++) { ref Vector128 s = ref Unsafe.Add(ref sourceBase, i * 4); @@ -864,7 +864,7 @@ internal static void PackFromRgbPlanesAvx2Reduce( ref Vector256 bBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(blueChannel)); ref byte dBase = ref Unsafe.As(ref MemoryMarshal.GetReference(destination)); - nint count = (nint)(uint)redChannel.Length / Vector256.Count; + nuint count = (uint)(redChannel.Length / Vector256.Count); ref byte control1Bytes = ref MemoryMarshal.GetReference(PermuteMaskEvenOdd8x32); Vector256 control1 = Unsafe.As>(ref control1Bytes); @@ -875,7 +875,7 @@ internal static void PackFromRgbPlanesAvx2Reduce( Vector256 shuffleAlpha = Unsafe.As>(ref MemoryMarshal.GetReference(ShuffleMaskShiftAlpha)); - for (nint i = 0; i < count; i++) + for (nuint i = 0; i < count; i++) { Vector256 r0 = Unsafe.Add(ref rBase, i); Vector256 g0 = Unsafe.Add(ref gBase, i); @@ -936,12 +936,12 @@ internal static void PackFromRgbPlanesAvx2Reduce( ref Vector256 bBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(blueChannel)); ref Vector256 dBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - nint count = (nint)(uint)redChannel.Length / Vector256.Count; + nuint count = (uint)(redChannel.Length / Vector256.Count); ref byte control1Bytes = ref MemoryMarshal.GetReference(PermuteMaskEvenOdd8x32); Vector256 control1 = Unsafe.As>(ref control1Bytes); var a = Vector256.Create((byte)255); - for (nint i = 0; i < count; i++) + for (nuint i = 0; i < count; i++) { Vector256 r0 = Unsafe.Add(ref rBase, i); Vector256 g0 = Unsafe.Add(ref gBase, i); @@ -994,8 +994,8 @@ internal static void UnpackToRgbPlanesAvx2Reduce( Vector256 r, g, b; const int bytesPerRgbStride = 24; - int count = (int)((uint)source.Length / 8); - for (nint i = 0; i < (uint)count; i++) + nuint count = (uint)source.Length / 8; + for (nuint i = 0; i < count; i++) { rgb = Avx2.PermuteVar8x32(Unsafe.AddByteOffset(ref rgbByteSpan, (uint)(bytesPerRgbStride * i)).AsUInt32(), extractToLanesMask).AsByte(); @@ -1013,7 +1013,7 @@ internal static void UnpackToRgbPlanesAvx2Reduce( Unsafe.Add(ref destBRef, i) = b; } - int sliceCount = count * 8; + int sliceCount = (int)(count * 8); redChannel = redChannel.Slice(sliceCount); greenChannel = greenChannel.Slice(sliceCount); blueChannel = blueChannel.Slice(sliceCount); diff --git a/src/ImageSharp/Common/Helpers/SimdUtils.Pack.cs b/src/ImageSharp/Common/Helpers/SimdUtils.Pack.cs index ff8323df03..f471d0231b 100644 --- a/src/ImageSharp/Common/Helpers/SimdUtils.Pack.cs +++ b/src/ImageSharp/Common/Helpers/SimdUtils.Pack.cs @@ -86,8 +86,8 @@ private static void PackFromRgbPlanesScalarBatchedReduce( ref ByteTuple4 b = ref Unsafe.As(ref MemoryMarshal.GetReference(blueChannel)); ref Rgb24 rgb = ref MemoryMarshal.GetReference(destination); - uint count = (uint)redChannel.Length / 4; - for (nint i = 0; i < count; i++) + nuint count = (uint)redChannel.Length / 4; + for (nuint i = 0; i < count; i++) { ref Rgb24 d0 = ref Unsafe.Add(ref rgb, i * 4); ref Rgb24 d1 = ref Unsafe.Add(ref d0, 1); @@ -133,9 +133,9 @@ private static void PackFromRgbPlanesScalarBatchedReduce( ref ByteTuple4 b = ref Unsafe.As(ref MemoryMarshal.GetReference(blueChannel)); ref Rgba32 rgb = ref MemoryMarshal.GetReference(destination); - uint count = (uint)redChannel.Length / 4; + nuint count = (uint)redChannel.Length / 4; destination.Fill(new Rgba32(0, 0, 0, 255)); - for (nint i = 0; i < count; i++) + for (nuint i = 0; i < count; i++) { ref Rgba32 d0 = ref Unsafe.Add(ref rgb, i * 4); ref Rgba32 d1 = ref Unsafe.Add(ref d0, 1); @@ -181,7 +181,7 @@ private static void PackFromRgbPlanesRemainder( ref byte b = ref MemoryMarshal.GetReference(blueChannel); ref Rgb24 rgb = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)destination.Length; i++) + for (nuint i = 0; i < (uint)destination.Length; i++) { ref Rgb24 d = ref Unsafe.Add(ref rgb, i); d.R = Unsafe.Add(ref r, i); @@ -201,7 +201,7 @@ private static void PackFromRgbPlanesRemainder( ref byte b = ref MemoryMarshal.GetReference(blueChannel); ref Rgba32 rgba = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)destination.Length; i++) + for (nuint i = 0; i < (uint)destination.Length; i++) { ref Rgba32 d = ref Unsafe.Add(ref rgba, i); d.R = Unsafe.Add(ref r, i); @@ -226,7 +226,7 @@ private static void UnpackToRgbPlanesScalar( ref float b = ref MemoryMarshal.GetReference(blueChannel); ref Rgb24 rgb = ref MemoryMarshal.GetReference(source); - for (nint i = 0; i < (uint)source.Length; i++) + for (nuint i = 0; i < (uint)source.Length; i++) { ref Rgb24 src = ref Unsafe.Add(ref rgb, i); Unsafe.Add(ref r, i) = src.R; diff --git a/src/ImageSharp/Common/Helpers/SimdUtils.Shuffle.cs b/src/ImageSharp/Common/Helpers/SimdUtils.Shuffle.cs index 532f9d4fab..c1437c05e6 100644 --- a/src/ImageSharp/Common/Helpers/SimdUtils.Shuffle.cs +++ b/src/ImageSharp/Common/Helpers/SimdUtils.Shuffle.cs @@ -145,14 +145,14 @@ private static void Shuffle4Remainder( { ref float sBase = ref MemoryMarshal.GetReference(source); ref float dBase = ref MemoryMarshal.GetReference(dest); - Shuffle.InverseMMShuffle(control, out int p3, out int p2, out int p1, out int p0); + Shuffle.InverseMMShuffle(control, out uint p3, out uint p2, out uint p1, out uint p0); - for (nint i = 0; i < (uint)source.Length; i += 4) + for (nuint i = 0; i < (uint)source.Length; i += 4) { - Unsafe.Add(ref dBase, i + 0) = Unsafe.Add(ref sBase, (nint)(uint)p0 + i); - Unsafe.Add(ref dBase, i + 1) = Unsafe.Add(ref sBase, (nint)(uint)p1 + i); - Unsafe.Add(ref dBase, i + 2) = Unsafe.Add(ref sBase, (nint)(uint)p2 + i); - Unsafe.Add(ref dBase, i + 3) = Unsafe.Add(ref sBase, (nint)(uint)p3 + i); + Unsafe.Add(ref dBase, i + 0) = Unsafe.Add(ref sBase, p0 + i); + Unsafe.Add(ref dBase, i + 1) = Unsafe.Add(ref sBase, p1 + i); + Unsafe.Add(ref dBase, i + 2) = Unsafe.Add(ref sBase, p2 + i); + Unsafe.Add(ref dBase, i + 3) = Unsafe.Add(ref sBase, p3 + i); } } @@ -492,34 +492,34 @@ public static void MMShuffleSpan(ref Span span, byte control) { InverseMMShuffle( control, - out int p3, - out int p2, - out int p1, - out int p0); + out uint p3, + out uint p2, + out uint p1, + out uint p0); ref byte spanBase = ref MemoryMarshal.GetReference(span); - for (int i = 0; i < span.Length; i += 4) + for (nuint i = 0; i < (uint)span.Length; i += 4) { - Unsafe.Add(ref spanBase, (uint)(i + 0)) = (byte)(p0 + i); - Unsafe.Add(ref spanBase, (uint)(i + 1)) = (byte)(p1 + i); - Unsafe.Add(ref spanBase, (uint)(i + 2)) = (byte)(p2 + i); - Unsafe.Add(ref spanBase, (uint)(i + 3)) = (byte)(p3 + i); + Unsafe.Add(ref spanBase, i + 0) = (byte)(p0 + i); + Unsafe.Add(ref spanBase, i + 1) = (byte)(p1 + i); + Unsafe.Add(ref spanBase, i + 2) = (byte)(p2 + i); + Unsafe.Add(ref spanBase, i + 3) = (byte)(p3 + i); } } [MethodImpl(InliningOptions.ShortMethod)] public static void InverseMMShuffle( byte control, - out int p3, - out int p2, - out int p1, - out int p0) + out uint p3, + out uint p2, + out uint p1, + out uint p0) { - p3 = (control >> 6) & 0x3; - p2 = (control >> 4) & 0x3; - p1 = (control >> 2) & 0x3; - p0 = (control >> 0) & 0x3; + p3 = (uint)((control >> 6) & 0x3); + p2 = (uint)((control >> 4) & 0x3); + p1 = (uint)((control >> 2) & 0x3); + p0 = (uint)((control >> 0) & 0x3); } } } diff --git a/src/ImageSharp/Compression/Zlib/DeflaterHuffman.cs b/src/ImageSharp/Compression/Zlib/DeflaterHuffman.cs index ebc43f8822..e4dc1945a8 100644 --- a/src/ImageSharp/Compression/Zlib/DeflaterHuffman.cs +++ b/src/ImageSharp/Compression/Zlib/DeflaterHuffman.cs @@ -286,13 +286,13 @@ public void FlushBlock(ReadOnlySpan stored, int storedOffset, int storedLe int static_len = this.extraBits; ref byte staticLLengthRef = ref MemoryMarshal.GetReference(StaticLLength); - for (nint i = 0; i < LiteralNumber; i++) + for (nuint i = 0; i < LiteralNumber; i++) { static_len += this.literalTree.Frequencies[i] * Unsafe.Add(ref staticLLengthRef, i); } ref byte staticDLengthRef = ref MemoryMarshal.GetReference(StaticDLength); - for (nint i = 0; i < DistanceNumber; i++) + for (nuint i = 0; i < DistanceNumber; i++) { static_len += this.distTree.Frequencies[i] * Unsafe.Add(ref staticDLengthRef, i); } @@ -625,10 +625,10 @@ public void BuildTree() ref int valuesRef = ref MemoryMarshal.GetReference(valuesMemoryOwner.Memory.Span); int numNodes = numLeafs; - for (nint i = 0; i < (uint)heapLen; i++) + for (nuint i = 0; i < (uint)heapLen; i++) { int node = Unsafe.Add(ref heapRef, i); - nint i2 = 2 * i; + nuint i2 = 2 * i; Unsafe.Add(ref childrenRef, i2) = node; Unsafe.Add(ref childrenRef, i2 + 1) = -1; Unsafe.Add(ref valuesRef, i) = this.Frequencies[node] << 8; diff --git a/src/ImageSharp/Formats/Bmp/BmpEncoderCore.cs b/src/ImageSharp/Formats/Bmp/BmpEncoderCore.cs index a2c7058233..60f18c8023 100644 --- a/src/ImageSharp/Formats/Bmp/BmpEncoderCore.cs +++ b/src/ImageSharp/Formats/Bmp/BmpEncoderCore.cs @@ -123,8 +123,8 @@ public void Encode(Image image, Stream stream, CancellationToken BmpMetadata bmpMetadata = metadata.GetBmpMetadata(); this.bitsPerPixel ??= bmpMetadata.BitsPerPixel; - short bpp = (short)this.bitsPerPixel; - int bytesPerLine = (int)(4 * ((((uint)image.Width * (ushort)bpp) + 31) / 32)); + ushort bpp = (ushort)this.bitsPerPixel; + int bytesPerLine = (int)(4 * ((((uint)image.Width * bpp) + 31) / 32)); this.padding = bytesPerLine - (int)(image.Width * (bpp / 8F)); int colorPaletteSize = this.bitsPerPixel switch @@ -176,7 +176,7 @@ public void Encode(Image image, Stream stream, CancellationToken /// The metadata. /// The icc profile data. /// The bitmap information header. - private BmpInfoHeader CreateBmpInfoHeader(int width, int height, int infoHeaderSize, short bpp, int bytesPerLine, ImageMetadata metadata, byte[]? iccProfileData) + private BmpInfoHeader CreateBmpInfoHeader(int width, int height, int infoHeaderSize, ushort bpp, int bytesPerLine, ImageMetadata metadata, byte[]? iccProfileData) { int hResolution = 0; int vResolution = 0; @@ -212,7 +212,7 @@ private BmpInfoHeader CreateBmpInfoHeader(int width, int height, int infoHeaderS width: width, height: height, planes: 1, - bitsPerPixel: bpp, + bitsPerPixel: (short)bpp, imageSize: height * bytesPerLine, xPelsPerMeter: hResolution, yPelsPerMeter: vResolution, diff --git a/src/ImageSharp/Formats/ImageExtensions.Save.tt b/src/ImageSharp/Formats/ImageExtensions.Save.tt index 7498aa7c3b..64f3bde9cc 100644 --- a/src/ImageSharp/Formats/ImageExtensions.Save.tt +++ b/src/ImageSharp/Formats/ImageExtensions.Save.tt @@ -77,7 +77,7 @@ public static partial class ImageExtensions public static void SaveAs<#= fmt #>(this Image source, string path, <#= fmt #>Encoder encoder) => source.Save( path, - encoder ?? source.GetConfiguration().ImageFormatsManager.FindEncoder(<#= fmt #>Format.Instance)); + encoder ?? source.GetConfiguration().ImageFormatsManager.GetEncoder(<#= fmt #>Format.Instance)); /// /// Saves the image to the given stream with the <#= fmt #> format. @@ -91,7 +91,7 @@ public static partial class ImageExtensions public static Task SaveAs<#= fmt #>Async(this Image source, string path, <#= fmt #>Encoder encoder, CancellationToken cancellationToken = default) => source.SaveAsync( path, - encoder ?? source.GetConfiguration().ImageFormatsManager.FindEncoder(<#= fmt #>Format.Instance), + encoder ?? source.GetConfiguration().ImageFormatsManager.GetEncoder(<#= fmt #>Format.Instance), cancellationToken); /// @@ -124,7 +124,7 @@ public static partial class ImageExtensions public static void SaveAs<#= fmt #>(this Image source, Stream stream, <#= fmt #>Encoder encoder) => source.Save( stream, - encoder ?? source.GetConfiguration().ImageFormatsManager.FindEncoder(<#= fmt #>Format.Instance)); + encoder ?? source.GetConfiguration().ImageFormatsManager.GetEncoder(<#= fmt #>Format.Instance)); /// /// Saves the image to the given stream with the <#= fmt #> format. @@ -138,7 +138,7 @@ public static partial class ImageExtensions public static Task SaveAs<#= fmt #>Async(this Image source, Stream stream, <#= fmt #>Encoder encoder, CancellationToken cancellationToken = default) => source.SaveAsync( stream, - encoder ?? source.GetConfiguration().ImageFormatsManager.FindEncoder(<#= fmt #>Format.Instance), + encoder ?? source.GetConfiguration().ImageFormatsManager.GetEncoder(<#= fmt #>Format.Instance), cancellationToken); <# diff --git a/src/ImageSharp/Formats/Jpeg/Components/Block8x8F.Generated.cs b/src/ImageSharp/Formats/Jpeg/Components/Block8x8F.Generated.cs index e5d252f432..93bb7be36e 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/Block8x8F.Generated.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/Block8x8F.Generated.cs @@ -16,7 +16,7 @@ public void NormalizeColorsInPlace(float maximum) { var CMin4 = new Vector4(0F); var CMax4 = new Vector4(maximum); - var COff4 = new Vector4(MathF.Ceiling(maximum * 0.5F)); // /2 + var COff4 = new Vector4(MathF.Ceiling(maximum * 0.5F)); this.V0L = Numerics.Clamp(this.V0L + COff4, CMin4, CMax4); this.V0R = Numerics.Clamp(this.V0R + COff4, CMin4, CMax4); @@ -42,7 +42,7 @@ public void NormalizeColorsInPlace(float maximum) [MethodImpl(InliningOptions.ShortMethod)] public void NormalizeColorsAndRoundInPlaceVector8(float maximum) { - var off = new Vector(MathF.Ceiling(maximum * 0.5F)); // /2 + var off = new Vector(MathF.Ceiling(maximum * 0.5F)); var max = new Vector(maximum); ref Vector row0 = ref Unsafe.As>(ref this.V0L); diff --git a/src/ImageSharp/Formats/Jpeg/Components/Block8x8F.Generated.tt b/src/ImageSharp/Formats/Jpeg/Components/Block8x8F.Generated.tt index 7350edd38b..19b795c23a 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/Block8x8F.Generated.tt +++ b/src/ImageSharp/Formats/Jpeg/Components/Block8x8F.Generated.tt @@ -29,7 +29,7 @@ internal partial struct Block8x8F { var CMin4 = new Vector4(0F); var CMax4 = new Vector4(maximum); - var COff4 = new Vector4(MathF.Ceiling(maximum * 0.5F)); // /2 + var COff4 = new Vector4(MathF.Ceiling(maximum * 0.5F)); <# @@ -53,7 +53,7 @@ internal partial struct Block8x8F [MethodImpl(InliningOptions.ShortMethod)] public void NormalizeColorsAndRoundInPlaceVector8(float maximum) { - var off = new Vector(MathF.Ceiling(maximum * 0.5F)); // /2 + var off = new Vector(MathF.Ceiling(maximum * 0.5F)); var max = new Vector(maximum); <# diff --git a/src/ImageSharp/Formats/Jpeg/Components/Block8x8F.Intrinsic.cs b/src/ImageSharp/Formats/Jpeg/Components/Block8x8F.Intrinsic.cs index 7611d403ac..63be76f00f 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/Block8x8F.Intrinsic.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/Block8x8F.Intrinsic.cs @@ -41,9 +41,9 @@ private static unsafe void MultiplyIntoInt16_Avx2(ref Block8x8F a, ref Block8x8F ref Vector256 bBase = ref b.V0; ref Vector256 destRef = ref dest.V01; - var multiplyIntoInt16ShuffleMask = Vector256.Create(0, 1, 4, 5, 2, 3, 6, 7); + Vector256 multiplyIntoInt16ShuffleMask = Vector256.Create(0, 1, 4, 5, 2, 3, 6, 7); - for (nint i = 0; i < 8; i += 2) + for (nuint i = 0; i < 8; i += 2) { Vector256 row0 = Avx.ConvertToVector256Int32(Avx.Multiply(Unsafe.Add(ref aBase, i + 0), Unsafe.Add(ref bBase, i + 0))); Vector256 row1 = Avx.ConvertToVector256Int32(Avx.Multiply(Unsafe.Add(ref aBase, i + 1), Unsafe.Add(ref bBase, i + 1))); @@ -64,7 +64,7 @@ private static void MultiplyIntoInt16_Sse2(ref Block8x8F a, ref Block8x8F b, ref ref Vector128 destBase = ref Unsafe.As>(ref dest); - for (nint i = 0; i < 16; i += 2) + for (nuint i = 0; i < 16; i += 2) { Vector128 left = Sse2.ConvertToVector128Int32(Sse.Multiply(Unsafe.Add(ref aBase, i + 0), Unsafe.Add(ref bBase, i + 0))); Vector128 right = Sse2.ConvertToVector128Int32(Sse.Multiply(Unsafe.Add(ref aBase, i + 1), Unsafe.Add(ref bBase, i + 1))); diff --git a/src/ImageSharp/Formats/Jpeg/Components/Block8x8F.ScaledCopy.cs b/src/ImageSharp/Formats/Jpeg/Components/Block8x8F.ScaledCopy.cs index e68ede9fbb..652c064ad5 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/Block8x8F.ScaledCopy.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/Block8x8F.ScaledCopy.cs @@ -30,13 +30,13 @@ public void ScaledCopyTo(ref float areaOrigin, int areaStride, int horizontalSca } // TODO: Optimize: implement all cases with scale-specific, loopless code! - this.CopyArbitraryScale(ref areaOrigin, areaStride, horizontalScale, verticalScale); + this.CopyArbitraryScale(ref areaOrigin, (uint)areaStride, (uint)horizontalScale, (uint)verticalScale); } private void CopyTo2x2Scale(ref float areaOrigin, int areaStride) { ref Vector2 destBase = ref Unsafe.As(ref areaOrigin); - int destStride = (int)((uint)areaStride / 2); + nuint destStride = (uint)areaStride / 2; WidenCopyRowImpl2x2(ref this.V0L, ref destBase, 0, destStride); WidenCopyRowImpl2x2(ref this.V0L, ref destBase, 1, destStride); @@ -48,12 +48,12 @@ private void CopyTo2x2Scale(ref float areaOrigin, int areaStride) WidenCopyRowImpl2x2(ref this.V0L, ref destBase, 7, destStride); [MethodImpl(MethodImplOptions.AggressiveInlining)] - static void WidenCopyRowImpl2x2(ref Vector4 selfBase, ref Vector2 destBase, nint row, nint destStride) + static void WidenCopyRowImpl2x2(ref Vector4 selfBase, ref Vector2 destBase, nuint row, nuint destStride) { ref Vector4 sLeft = ref Unsafe.Add(ref selfBase, 2 * row); ref Vector4 sRight = ref Unsafe.Add(ref sLeft, 1); - nint offset = 2 * row * destStride; + nuint offset = 2 * row * destStride; ref Vector4 dTopLeft = ref Unsafe.As(ref Unsafe.Add(ref destBase, offset)); ref Vector4 dBottomLeft = ref Unsafe.As(ref Unsafe.Add(ref destBase, offset + destStride)); @@ -86,23 +86,23 @@ static void WidenCopyRowImpl2x2(ref Vector4 selfBase, ref Vector2 destBase, nint } [MethodImpl(InliningOptions.ColdPath)] - private void CopyArbitraryScale(ref float areaOrigin, int areaStride, int horizontalScale, int verticalScale) + private void CopyArbitraryScale(ref float areaOrigin, uint areaStride, uint horizontalScale, uint verticalScale) { - for (int y = 0; y < 8; y++) + for (nuint y = 0; y < 8; y++) { - int yy = y * verticalScale; - int y8 = y * 8; + nuint yy = y * verticalScale; + nuint y8 = y * 8; - for (int x = 0; x < 8; x++) + for (nuint x = 0; x < 8; x++) { - int xx = x * horizontalScale; + nuint xx = x * horizontalScale; - float value = this[y8 + x]; - nint baseIdx = (nint)(uint)((yy * areaStride) + xx); + float value = this[(int)(y8 + x)]; + nuint baseIdx = (uint)((yy * areaStride) + xx); - for (nint i = 0; i < verticalScale; i++, baseIdx += areaStride) + for (nuint i = 0; i < verticalScale; i++, baseIdx += areaStride) { - for (nint j = 0; j < (uint)horizontalScale; j++) + for (nuint j = 0; j < horizontalScale; j++) { // area[xx + j, yy + i] = value; Unsafe.Add(ref areaOrigin, baseIdx + j) = value; diff --git a/src/ImageSharp/Formats/Jpeg/Components/Block8x8F.cs b/src/ImageSharp/Formats/Jpeg/Components/Block8x8F.cs index a0a8cd28e2..21971a8c7d 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/Block8x8F.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/Block8x8F.cs @@ -71,28 +71,34 @@ internal partial struct Block8x8F : IEquatable /// The index /// The float value at the specified index public float this[int idx] + { + get => this[(uint)idx]; + set => this[(uint)idx] = value; + } + + internal float this[nuint idx] { [MethodImpl(MethodImplOptions.AggressiveInlining)] get { - DebugGuard.MustBeBetweenOrEqualTo(idx, 0, Size - 1, nameof(idx)); + DebugGuard.MustBeBetweenOrEqualTo((int)idx, 0, Size - 1, nameof(idx)); ref float selfRef = ref Unsafe.As(ref this); - return Unsafe.Add(ref selfRef, (nint)(uint)idx); + return Unsafe.Add(ref selfRef, idx); } [MethodImpl(MethodImplOptions.AggressiveInlining)] set { - DebugGuard.MustBeBetweenOrEqualTo(idx, 0, Size - 1, nameof(idx)); + DebugGuard.MustBeBetweenOrEqualTo((int)idx, 0, Size - 1, nameof(idx)); ref float selfRef = ref Unsafe.As(ref this); - Unsafe.Add(ref selfRef, (nint)(uint)idx) = value; + Unsafe.Add(ref selfRef, idx) = value; } } public float this[int x, int y] { - get => this[(y * 8) + x]; - set => this[(y * 8) + x] = value; + get => this[((uint)y * 8) + (uint)x]; + set => this[((uint)y * 8) + (uint)x] = value; } public static Block8x8F Load(Span data) @@ -425,7 +431,7 @@ public bool EqualsToScalar(int value) Vector256 targetVector = Vector256.Create(value); ref Vector256 blockStride = ref this.V0; - for (nint i = 0; i < RowCount; i++) + for (nuint i = 0; i < RowCount; i++) { Vector256 areEqual = Avx2.CompareEqual(Avx.ConvertToVector256Int32WithTruncation(Unsafe.Add(ref this.V0, i)), targetVector); if (Avx2.MoveMask(areEqual.AsByte()) != equalityMask) @@ -439,7 +445,7 @@ public bool EqualsToScalar(int value) ref float scalars = ref Unsafe.As(ref this); - for (nint i = 0; i < Size; i++) + for (nuint i = 0; i < Size; i++) { if ((int)Unsafe.Add(ref scalars, i) != value) { diff --git a/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.CmykAvx.cs b/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.CmykAvx.cs index 3144afa76b..07ba3648c4 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.CmykAvx.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.CmykAvx.cs @@ -32,8 +32,8 @@ public override void ConvertToRgbInplace(in ComponentValues values) // Used for the color conversion var scale = Vector256.Create(1 / (this.MaximumValue * this.MaximumValue)); - nint n = (nint)(uint)values.Component0.Length / Vector256.Count; - for (nint i = 0; i < n; i++) + nuint n = (uint)(values.Component0.Length / Vector256.Count); + for (nuint i = 0; i < n; i++) { ref Vector256 c = ref Unsafe.Add(ref c0Base, i); ref Vector256 m = ref Unsafe.Add(ref c1Base, i); @@ -71,8 +71,8 @@ public static void ConvertFromRgb(in ComponentValues values, float maxValue, Spa var scale = Vector256.Create(maxValue); - nint n = (nint)(uint)values.Component0.Length / Vector256.Count; - for (nint i = 0; i < n; i++) + nuint n = (uint)(values.Component0.Length / Vector256.Count); + for (nuint i = 0; i < n; i++) { Vector256 ctmp = Avx.Subtract(scale, Unsafe.Add(ref srcR, i)); Vector256 mtmp = Avx.Subtract(scale, Unsafe.Add(ref srcG, i)); diff --git a/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.CmykVector.cs b/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.CmykVector.cs index 03d9a1532a..2e2ff08bf9 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.CmykVector.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.CmykVector.cs @@ -30,8 +30,8 @@ protected override void ConvertToRgbInplaceVectorized(in ComponentValues values) var scale = new Vector(1 / (this.MaximumValue * this.MaximumValue)); - nint n = (nint)(uint)values.Component0.Length / Vector.Count; - for (nint i = 0; i < n; i++) + nuint n = (uint)(values.Component0.Length / Vector.Count); + for (nuint i = 0; i < n; i++) { ref Vector c = ref Unsafe.Add(ref cBase, i); ref Vector m = ref Unsafe.Add(ref mBase, i); @@ -78,8 +78,8 @@ public static void ConvertFromRgbInplaceVectorized(in ComponentValues values, fl // Used for the color conversion var scale = new Vector(maxValue); - nint n = (nint)(uint)values.Component0.Length / Vector.Count; - for (nint i = 0; i < n; i++) + nuint n = (uint)(values.Component0.Length / Vector.Count); + for (nuint i = 0; i < n; i++) { Vector ctmp = scale - Unsafe.Add(ref srcR, i); Vector mtmp = scale - Unsafe.Add(ref srcG, i); diff --git a/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.GrayScaleAvx.cs b/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.GrayScaleAvx.cs index 4bb9869728..80ae6621c4 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.GrayScaleAvx.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.GrayScaleAvx.cs @@ -27,8 +27,8 @@ public override void ConvertToRgbInplace(in ComponentValues values) // Used for the color conversion var scale = Vector256.Create(1 / this.MaximumValue); - nint n = (nint)(uint)values.Component0.Length / Vector256.Count; - for (nint i = 0; i < n; i++) + nuint n = (uint)(values.Component0.Length / Vector256.Count); + for (nuint i = 0; i < n; i++) { ref Vector256 c0 = ref Unsafe.Add(ref c0Base, i); c0 = Avx.Multiply(c0, scale); @@ -53,8 +53,8 @@ public override void ConvertFromRgb(in ComponentValues values, Span rLane var f0587 = Vector256.Create(0.587f); var f0114 = Vector256.Create(0.114f); - nint n = (nint)(uint)values.Component0.Length / Vector256.Count; - for (nint i = 0; i < n; i++) + nuint n = (uint)(values.Component0.Length / Vector256.Count); + for (nuint i = 0; i < n; i++) { ref Vector256 r = ref Unsafe.Add(ref srcRed, i); ref Vector256 g = ref Unsafe.Add(ref srcGreen, i); diff --git a/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.GrayScaleScalar.cs b/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.GrayScaleScalar.cs index df511594af..4d3b5c60bd 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.GrayScaleScalar.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.GrayScaleScalar.cs @@ -28,7 +28,7 @@ internal static void ConvertToRgbInplace(Span values, float maxValue) ref float valuesRef = ref MemoryMarshal.GetReference(values); float scale = 1 / maxValue; - for (nint i = 0; i < (uint)values.Length; i++) + for (nuint i = 0; i < (uint)values.Length; i++) { Unsafe.Add(ref valuesRef, i) *= scale; } diff --git a/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.GrayScaleVector.cs b/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.GrayScaleVector.cs index d8ba115d24..018e0ca442 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.GrayScaleVector.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.GrayScaleVector.cs @@ -24,8 +24,8 @@ protected override void ConvertToRgbInplaceVectorized(in ComponentValues values) var scale = new Vector(1 / this.MaximumValue); - nint n = (nint)(uint)values.Component0.Length / Vector.Count; - for (nint i = 0; i < n; i++) + nuint n = (uint)(values.Component0.Length / Vector.Count); + for (nuint i = 0; i < n; i++) { ref Vector c0 = ref Unsafe.Add(ref cBase, i); c0 *= scale; @@ -53,8 +53,8 @@ protected override void ConvertFromRgbVectorized(in ComponentValues values, Span var gMult = new Vector(0.587f); var bMult = new Vector(0.114f); - nint n = (nint)(uint)values.Component0.Length / Vector.Count; - for (nint i = 0; i < n; i++) + nuint n = (uint)(values.Component0.Length / Vector.Count); + for (nuint i = 0; i < n; i++) { Vector r = Unsafe.Add(ref srcR, i); Vector g = Unsafe.Add(ref srcR, i); diff --git a/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.RgbArm.cs b/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.RgbArm.cs index 4a2112592f..72d8340a0f 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.RgbArm.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.RgbArm.cs @@ -30,8 +30,8 @@ public override void ConvertToRgbInplace(in ComponentValues values) // Used for the color conversion var scale = Vector128.Create(1 / this.MaximumValue); - nint n = (nint)(uint)values.Component0.Length / Vector128.Count; - for (nint i = 0; i < n; i++) + nuint n = (uint)(values.Component0.Length / Vector128.Count); + for (nuint i = 0; i < n; i++) { ref Vector128 r = ref Unsafe.Add(ref rBase, i); ref Vector128 g = ref Unsafe.Add(ref gBase, i); diff --git a/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.RgbAvx.cs b/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.RgbAvx.cs index 76b2e9936c..8c095309c7 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.RgbAvx.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.RgbAvx.cs @@ -29,8 +29,8 @@ public override void ConvertToRgbInplace(in ComponentValues values) // Used for the color conversion var scale = Vector256.Create(1 / this.MaximumValue); - nint n = (nint)(uint)values.Component0.Length / Vector256.Count; - for (nint i = 0; i < n; i++) + nuint n = (uint)(values.Component0.Length / Vector256.Count); + for (nuint i = 0; i < n; i++) { ref Vector256 r = ref Unsafe.Add(ref rBase, i); ref Vector256 g = ref Unsafe.Add(ref gBase, i); diff --git a/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.RgbVector.cs b/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.RgbVector.cs index 5d85bb0482..cbba796440 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.RgbVector.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.RgbVector.cs @@ -28,8 +28,8 @@ protected override void ConvertToRgbInplaceVectorized(in ComponentValues values) var scale = new Vector(1 / this.MaximumValue); - nint n = (nint)(uint)values.Component0.Length / Vector.Count; - for (nint i = 0; i < n; i++) + nuint n = (uint)(values.Component0.Length / Vector.Count); + for (nuint i = 0; i < n; i++) { ref Vector r = ref Unsafe.Add(ref rBase, i); ref Vector g = ref Unsafe.Add(ref gBase, i); diff --git a/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.YCbCrAvx.cs b/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.YCbCrAvx.cs index 59f24493a1..e828ba1179 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.YCbCrAvx.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.YCbCrAvx.cs @@ -38,8 +38,8 @@ public override void ConvertToRgbInplace(in ComponentValues values) var bCbMult = Vector256.Create(YCbCrScalar.BCbMult); // Walking 8 elements at one step: - nint n = (nint)(uint)values.Component0.Length / Vector256.Count; - for (nint i = 0; i < n; i++) + nuint n = (uint)(values.Component0.Length / Vector256.Count); + for (nuint i = 0; i < n; i++) { // y = yVals[i]; // cb = cbVals[i] - 128F; @@ -98,8 +98,8 @@ public override void ConvertFromRgb(in ComponentValues values, Span rLane var fn0081312F = Vector256.Create(-0.081312F); var f05 = Vector256.Create(0.5f); - nint n = (nint)(uint)values.Component0.Length / Vector256.Count; - for (nint i = 0; i < n; i++) + nuint n = (uint)(values.Component0.Length / Vector256.Count); + for (nuint i = 0; i < n; i++) { Vector256 r = Unsafe.Add(ref srcR, i); Vector256 g = Unsafe.Add(ref srcG, i); diff --git a/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.YCbCrVector.cs b/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.YCbCrVector.cs index 0f7a364868..e3b4be235f 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.YCbCrVector.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.YCbCrVector.cs @@ -35,8 +35,8 @@ protected override void ConvertToRgbInplaceVectorized(in ComponentValues values) var gCrMult = new Vector(-YCbCrScalar.GCrMult); var bCbMult = new Vector(YCbCrScalar.BCbMult); - nint n = (nint)(uint)values.Component0.Length / Vector.Count; - for (nint i = 0; i < n; i++) + nuint n = (uint)(values.Component0.Length / Vector.Count); + for (nuint i = 0; i < n; i++) { // y = yVals[i]; // cb = cbVals[i] - 128F; @@ -103,8 +103,8 @@ protected override void ConvertFromRgbVectorized(in ComponentValues values, Span var gCrMult = new Vector(0.418688f); var bCrMult = new Vector(0.081312f); - nint n = (nint)(uint)values.Component0.Length / Vector.Count; - for (nint i = 0; i < n; i++) + nuint n = (uint)(values.Component0.Length / Vector.Count); + for (nuint i = 0; i < n; i++) { Vector r = Unsafe.Add(ref srcR, i); Vector g = Unsafe.Add(ref srcG, i); diff --git a/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.YccKAvx.cs b/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.YccKAvx.cs index 0cfb3201b4..8ab2dd3d67 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.YccKAvx.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.YccKAvx.cs @@ -40,8 +40,8 @@ public override void ConvertToRgbInplace(in ComponentValues values) var bCbMult = Vector256.Create(YCbCrScalar.BCbMult); // Walking 8 elements at one step: - nint n = (nint)(uint)values.Component0.Length / Vector256.Count; - for (nint i = 0; i < n; i++) + nuint n = (uint)(values.Component0.Length / Vector256.Count); + for (nuint i = 0; i < n; i++) { // y = yVals[i]; // cb = cbVals[i] - 128F; @@ -109,8 +109,8 @@ public override void ConvertFromRgb(in ComponentValues values, Span rLane var fn0081312F = Vector256.Create(-0.081312F); var f05 = Vector256.Create(0.5f); - nint n = (nint)(uint)values.Component0.Length / Vector256.Count; - for (nint i = 0; i < n; i++) + nuint n = (uint)(values.Component0.Length / Vector256.Count); + for (nuint i = 0; i < n; i++) { Vector256 r = Avx.Subtract(maxSampleValue, Unsafe.Add(ref srcR, i)); Vector256 g = Avx.Subtract(maxSampleValue, Unsafe.Add(ref srcG, i)); diff --git a/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.YccKVector.cs b/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.YccKVector.cs index feefe3021d..711b0fe3bb 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.YccKVector.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.YccKVector.cs @@ -36,8 +36,8 @@ protected override void ConvertToRgbInplaceVectorized(in ComponentValues values) var gCrMult = new Vector(-YCbCrScalar.GCrMult); var bCbMult = new Vector(YCbCrScalar.BCbMult); - nint n = (nint)(uint)values.Component0.Length / Vector.Count; - for (nint i = 0; i < n; i++) + nuint n = (uint)(values.Component0.Length / Vector.Count); + for (nuint i = 0; i < n; i++) { // y = yVals[i]; // cb = cbVals[i] - 128F; @@ -107,8 +107,8 @@ protected override void ConvertFromRgbVectorized(in ComponentValues values, Span var gCrMult = new Vector(0.418688f); var bCrMult = new Vector(0.081312f); - nint n = (nint)(uint)values.Component0.Length / Vector.Count; - for (nint i = 0; i < n; i++) + nuint n = (uint)(values.Component0.Length / Vector.Count); + for (nuint i = 0; i < n; i++) { Vector r = maxSampleValue - Unsafe.Add(ref srcR, i); Vector g = maxSampleValue - Unsafe.Add(ref srcG, i); diff --git a/src/ImageSharp/Formats/Jpeg/Components/Decoder/ArithmeticScanDecoder.cs b/src/ImageSharp/Formats/Jpeg/Components/Decoder/ArithmeticScanDecoder.cs index fcefe542d4..5ecf779615 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/Decoder/ArithmeticScanDecoder.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/Decoder/ArithmeticScanDecoder.cs @@ -470,7 +470,7 @@ private void ParseBaselineDataInterleaved() this.DecodeBlockBaseline( component, - ref Unsafe.Add(ref blockRef, (nint)(uint)blockCol), + ref Unsafe.Add(ref blockRef, (uint)blockCol), ref acDecodingTable, ref dcDecodingTable); } @@ -521,7 +521,7 @@ private void ParseBaselineDataSingleComponent() this.DecodeBlockBaseline( component, - ref Unsafe.Add(ref blockRef, (nint)(uint)k), + ref Unsafe.Add(ref blockRef, (uint)k), ref acDecodingTable, ref dcDecodingTable); @@ -560,7 +560,7 @@ private void ParseBaselineDataNonInterleaved() this.DecodeBlockBaseline( component, - ref Unsafe.Add(ref blockRef, (nint)(uint)i), + ref Unsafe.Add(ref blockRef, (uint)i), ref acDecodingTable, ref dcDecodingTable); @@ -611,7 +611,7 @@ private void ParseProgressiveDataInterleaved() this.DecodeBlockProgressiveDc( component, - ref Unsafe.Add(ref blockRef, (nint)(uint)blockCol), + ref Unsafe.Add(ref blockRef, (uint)blockCol), ref dcDecodingTable); } } @@ -653,7 +653,7 @@ private void ParseProgressiveDataNonInterleaved() this.DecodeBlockProgressiveDc( component, - ref Unsafe.Add(ref blockRef, (nint)(uint)i), + ref Unsafe.Add(ref blockRef, (uint)i), ref dcDecodingTable); this.HandleRestart(); @@ -680,7 +680,7 @@ ref Unsafe.Add(ref blockRef, (nint)(uint)i), this.DecodeBlockProgressiveAc( component, - ref Unsafe.Add(ref blockRef, (nint)(uint)i), + ref Unsafe.Add(ref blockRef, (uint)i), ref acDecodingTable); this.HandleRestart(); @@ -717,7 +717,7 @@ private void DecodeBlockProgressiveDc(ArithmeticDecodingComponent component, ref // Figure F.21: Decoding nonzero value v. // Figure F.22: Decoding the sign of v. int sign = this.DecodeBinaryDecision(ref reader, ref Unsafe.Add(ref st, 1)); - st = ref Unsafe.Add(ref st, (nint)(uint)(2 + sign)); + st = ref Unsafe.Add(ref st, (uint)(2 + sign)); // Figure F.23: Decoding the magnitude category of v. int m = this.DecodeBinaryDecision(ref reader, ref st); @@ -967,7 +967,7 @@ private void DecodeBlockBaseline( // Figure F.21: Decoding nonzero value v // Figure F.22: Decoding the sign of v int sign = this.DecodeBinaryDecision(ref reader, ref Unsafe.Add(ref st, 1)); - st = ref Unsafe.Add(ref st, (nint)(uint)(2 + sign)); + st = ref Unsafe.Add(ref st, (uint)(2 + sign)); // Figure F.23: Decoding the magnitude category of v. int m = this.DecodeBinaryDecision(ref reader, ref st); diff --git a/src/ImageSharp/Formats/Jpeg/Components/Decoder/ComponentProcessors/DownScalingComponentProcessor2.cs b/src/ImageSharp/Formats/Jpeg/Components/Decoder/ComponentProcessors/DownScalingComponentProcessor2.cs index 8b4256e3b9..0ec7500e0d 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/Decoder/ComponentProcessors/DownScalingComponentProcessor2.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/Decoder/ComponentProcessors/DownScalingComponentProcessor2.cs @@ -67,30 +67,30 @@ public override void CopyBlocksToColorBuffer(int spectralStep) public static void ScaledCopyTo(ref Block8x8F block, ref float destRef, int destStrideWidth, int horizontalScale, int verticalScale) { // TODO: Optimize: implement all cases with scale-specific, loopless code! - CopyArbitraryScale(ref block, ref destRef, destStrideWidth, horizontalScale, verticalScale); + CopyArbitraryScale(ref block, ref destRef, (uint)destStrideWidth, (uint)horizontalScale, (uint)verticalScale); [MethodImpl(InliningOptions.ColdPath)] - static void CopyArbitraryScale(ref Block8x8F block, ref float areaOrigin, int areaStride, int horizontalScale, int verticalScale) + static void CopyArbitraryScale(ref Block8x8F block, ref float areaOrigin, uint areaStride, uint horizontalScale, uint verticalScale) { - for (int y = 0; y < 4; y++) + for (nuint y = 0; y < 4; y++) { - int yy = y * verticalScale; - int y8 = y * 8; + nuint yy = y * verticalScale; + nuint y8 = y * 8; - for (int x = 0; x < 4; x++) + for (nuint x = 0; x < 4; x++) { - int xx = x * horizontalScale; + nuint xx = x * horizontalScale; float value = block[y8 + x]; - for (int i = 0; i < verticalScale; i++) + for (nuint i = 0; i < verticalScale; i++) { - int baseIdx = ((yy + i) * areaStride) + xx; + nuint baseIdx = ((yy + i) * areaStride) + xx; - for (int j = 0; j < horizontalScale; j++) + for (nuint j = 0; j < horizontalScale; j++) { // area[xx + j, yy + i] = value; - Unsafe.Add(ref areaOrigin, (nint)(uint)(baseIdx + j)) = value; + Unsafe.Add(ref areaOrigin, baseIdx + j) = value; } } } diff --git a/src/ImageSharp/Formats/Jpeg/Components/Decoder/ComponentProcessors/DownScalingComponentProcessor4.cs b/src/ImageSharp/Formats/Jpeg/Components/Decoder/ComponentProcessors/DownScalingComponentProcessor4.cs index 170cdbb3c8..99daaa49e7 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/Decoder/ComponentProcessors/DownScalingComponentProcessor4.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/Decoder/ComponentProcessors/DownScalingComponentProcessor4.cs @@ -67,30 +67,30 @@ public override void CopyBlocksToColorBuffer(int spectralStep) public static void ScaledCopyTo(ref Block8x8F block, ref float destRef, int destStrideWidth, int horizontalScale, int verticalScale) { // TODO: Optimize: implement all cases with scale-specific, loopless code! - CopyArbitraryScale(ref block, ref destRef, destStrideWidth, horizontalScale, verticalScale); + CopyArbitraryScale(ref block, ref destRef, (uint)destStrideWidth, (uint)horizontalScale, (uint)verticalScale); [MethodImpl(InliningOptions.ColdPath)] - static void CopyArbitraryScale(ref Block8x8F block, ref float areaOrigin, int areaStride, int horizontalScale, int verticalScale) + static void CopyArbitraryScale(ref Block8x8F block, ref float areaOrigin, uint areaStride, uint horizontalScale, uint verticalScale) { - for (int y = 0; y < 2; y++) + for (nuint y = 0; y < 2; y++) { - int yy = y * verticalScale; - int y8 = y * 8; + nuint yy = y * verticalScale; + nuint y8 = y * 8; - for (int x = 0; x < 2; x++) + for (nuint x = 0; x < 2; x++) { - int xx = x * horizontalScale; + nuint xx = x * horizontalScale; float value = block[y8 + x]; - for (int i = 0; i < verticalScale; i++) + for (nuint i = 0; i < verticalScale; i++) { - int baseIdx = ((yy + i) * areaStride) + xx; + nuint baseIdx = ((yy + i) * areaStride) + xx; - for (int j = 0; j < horizontalScale; j++) + for (nuint j = 0; j < horizontalScale; j++) { // area[xx + j, yy + i] = value; - Unsafe.Add(ref areaOrigin, (nint)(uint)(baseIdx + j)) = value; + Unsafe.Add(ref areaOrigin, baseIdx + j) = value; } } } diff --git a/src/ImageSharp/Formats/Jpeg/Components/Decoder/ComponentProcessors/DownScalingComponentProcessor8.cs b/src/ImageSharp/Formats/Jpeg/Components/Decoder/ComponentProcessors/DownScalingComponentProcessor8.cs index 81104d2f3d..cf321d7cd9 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/Decoder/ComponentProcessors/DownScalingComponentProcessor8.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/Decoder/ComponentProcessors/DownScalingComponentProcessor8.cs @@ -67,20 +67,20 @@ public static void ScaledCopyTo(float value, ref float destRef, int destStrideWi { destRef = value; Unsafe.Add(ref destRef, 1) = value; - Unsafe.Add(ref destRef, 0 + (nint)(uint)destStrideWidth) = value; - Unsafe.Add(ref destRef, 1 + (nint)(uint)destStrideWidth) = value; + Unsafe.Add(ref destRef, 0 + (uint)destStrideWidth) = value; + Unsafe.Add(ref destRef, 1 + (uint)destStrideWidth) = value; return; } // TODO: Optimize: implement all cases with scale-specific, loopless code! - for (int y = 0; y < verticalScale; y++) + for (nuint y = 0; y < (uint)verticalScale; y++) { - for (int x = 0; x < horizontalScale; x++) + for (nuint x = 0; x < (uint)horizontalScale; x++) { - Unsafe.Add(ref destRef, (nint)(uint)x) = value; + Unsafe.Add(ref destRef, x) = value; } - destRef = ref Unsafe.Add(ref destRef, (nint)(uint)destStrideWidth); + destRef = ref Unsafe.Add(ref destRef, (uint)destStrideWidth); } } } diff --git a/src/ImageSharp/Formats/Jpeg/Components/Encoder/ComponentProcessor.cs b/src/ImageSharp/Formats/Jpeg/Components/Encoder/ComponentProcessor.cs index 3c89ab1fb6..9b08175051 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/Encoder/ComponentProcessor.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/Encoder/ComponentProcessor.cs @@ -122,8 +122,8 @@ static void SumVertical(Span target, Span source) ref Vector256 sourceVectorRef = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); // Spans are guaranteed to be multiple of 8 so no extra 'remainder' steps are needed - nint count = (nint)(uint)source.Length / Vector256.Count; - for (nint i = 0; i < count; i++) + nuint count = (uint)(source.Length / Vector256.Count); + for (nuint i = 0; i < count; i++) { Unsafe.Add(ref targetVectorRef, i) = Avx.Add(Unsafe.Add(ref targetVectorRef, i), Unsafe.Add(ref sourceVectorRef, i)); } @@ -133,15 +133,15 @@ static void SumVertical(Span target, Span source) ref Vector targetVectorRef = ref Unsafe.As>(ref MemoryMarshal.GetReference(target)); ref Vector sourceVectorRef = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); - nint count = (nint)(uint)source.Length / Vector.Count; - for (nint i = 0; i < count; i++) + nuint count = (uint)(source.Length / Vector.Count); + for (nuint i = 0; i < count; i++) { Unsafe.Add(ref targetVectorRef, i) += Unsafe.Add(ref sourceVectorRef, i); } ref float targetRef = ref MemoryMarshal.GetReference(target); ref float sourceRef = ref MemoryMarshal.GetReference(source); - for (nint i = count * Vector.Count; i < (uint)source.Length; i++) + for (nuint i = count * (uint)Vector.Count; i < (uint)source.Length; i++) { Unsafe.Add(ref targetRef, i) += Unsafe.Add(ref sourceRef, i); } @@ -166,16 +166,16 @@ static void SumHorizontal(Span target, int factor) source = source.Slice(touchedCount); target = target.Slice(touchedCount / factor); - nint length = (nint)(uint)touchedCount / Vector256.Count; + nuint length = (uint)(touchedCount / Vector256.Count); for (int i = 0; i < haddIterationsCount; i++) { length /= 2; - for (nint j = 0; j < length; j++) + for (nuint j = 0; j < length; j++) { - nint indexLeft = j * 2; - nint indexRight = indexLeft + 1; + nuint indexLeft = j * 2; + nuint indexRight = indexLeft + 1; Vector256 sum = Avx.HorizontalAdd(Unsafe.Add(ref targetRef, indexLeft), Unsafe.Add(ref targetRef, indexRight)); Unsafe.Add(ref targetRef, j) = Avx2.Permute4x64(sum.AsDouble(), 0b11_01_10_00).AsSingle(); } @@ -200,9 +200,9 @@ static void MultiplyToAverage(Span target, float multiplier) ref Vector256 targetVectorRef = ref Unsafe.As>(ref MemoryMarshal.GetReference(target)); // Spans are guaranteed to be multiple of 8 so no extra 'remainder' steps are needed - nint count = (nint)(uint)target.Length / Vector256.Count; + nuint count = (uint)(target.Length / Vector256.Count); var multiplierVector = Vector256.Create(multiplier); - for (nint i = 0; i < count; i++) + for (nuint i = 0; i < count; i++) { Unsafe.Add(ref targetVectorRef, i) = Avx.Multiply(Unsafe.Add(ref targetVectorRef, i), multiplierVector); } @@ -211,15 +211,15 @@ static void MultiplyToAverage(Span target, float multiplier) { ref Vector targetVectorRef = ref Unsafe.As>(ref MemoryMarshal.GetReference(target)); - nint count = (nint)(uint)target.Length / Vector.Count; + nuint count = (uint)(target.Length / Vector.Count); var multiplierVector = new Vector(multiplier); - for (nint i = 0; i < count; i++) + for (nuint i = 0; i < count; i++) { Unsafe.Add(ref targetVectorRef, i) *= multiplierVector; } ref float targetRef = ref MemoryMarshal.GetReference(target); - for (nint i = count * Vector.Count; i < (uint)target.Length; i++) + for (nuint i = count * (uint)Vector.Count; i < (uint)target.Length; i++) { Unsafe.Add(ref targetRef, i) *= multiplier; } diff --git a/src/ImageSharp/Formats/Jpeg/Components/Encoder/HuffmanScanEncoder.cs b/src/ImageSharp/Formats/Jpeg/Components/Encoder/HuffmanScanEncoder.cs index 1453b0a568..d74494f9e5 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/Encoder/HuffmanScanEncoder.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/Encoder/HuffmanScanEncoder.cs @@ -180,7 +180,7 @@ public void EncodeScanBaselineSingleComponent(Component component, Spect Span blockSpan = component.SpectralBlocks.DangerousGetRowSpan(y: 0); ref Block8x8 blockRef = ref MemoryMarshal.GetReference(blockSpan); - for (nint k = 0; k < (uint)w; k++) + for (nuint k = 0; k < (uint)w; k++) { this.WriteBlock( component, @@ -219,7 +219,7 @@ public void EncodeScanBaseline(Component component, CancellationToken cancellati Span blockSpan = component.SpectralBlocks.DangerousGetRowSpan(y: i); ref Block8x8 blockRef = ref MemoryMarshal.GetReference(blockSpan); - for (nint k = 0; k < (uint)w; k++) + for (nuint k = 0; k < (uint)w; k++) { this.WriteBlock( component, @@ -246,9 +246,9 @@ ref Unsafe.Add(ref blockRef, k), private void EncodeScanBaselineInterleaved(JpegFrame frame, SpectralConverter converter, CancellationToken cancellationToken) where TPixel : unmanaged, IPixel { - nint mcu = 0; - nint mcusPerColumn = frame.McusPerColumn; - nint mcusPerLine = frame.McusPerLine; + int mcu = 0; + int mcusPerColumn = frame.McusPerColumn; + int mcusPerLine = frame.McusPerLine; for (int j = 0; j < mcusPerColumn; j++) { @@ -258,21 +258,21 @@ private void EncodeScanBaselineInterleaved(JpegFrame frame, SpectralConv converter.ConvertStrideBaseline(); // Encode spectral to binary - for (nint i = 0; i < mcusPerLine; i++) + for (int i = 0; i < mcusPerLine; i++) { // Scan an interleaved mcu... process components in order - nint mcuCol = mcu % mcusPerLine; - for (nint k = 0; k < frame.Components.Length; k++) + int mcuCol = mcu % mcusPerLine; + for (int k = 0; k < frame.Components.Length; k++) { Component component = frame.Components[k]; ref HuffmanLut dcHuffmanTable = ref this.dcHuffmanTables[component.DcTableId]; ref HuffmanLut acHuffmanTable = ref this.acHuffmanTables[component.AcTableId]; - nint h = component.HorizontalSamplingFactor; + int h = component.HorizontalSamplingFactor; int v = component.VerticalSamplingFactor; - nint blockColBase = mcuCol * h; + nuint blockColBase = (uint)(mcuCol * h); // Scan out an mcu's worth of this component; that's just determined // by the basic H and V specified for the component @@ -281,9 +281,9 @@ private void EncodeScanBaselineInterleaved(JpegFrame frame, SpectralConv Span blockSpan = component.SpectralBlocks.DangerousGetRowSpan(y); ref Block8x8 blockRef = ref MemoryMarshal.GetReference(blockSpan); - for (nint x = 0; x < h; x++) + for (nuint x = 0; x < (uint)h; x++) { - nint blockCol = blockColBase + x; + nuint blockCol = blockColBase + x; this.WriteBlock( component, @@ -315,8 +315,8 @@ ref Unsafe.Add(ref blockRef, blockCol), private void EncodeThreeComponentBaselineInterleavedScanNoSubsampling(JpegFrame frame, SpectralConverter converter, CancellationToken cancellationToken) where TPixel : unmanaged, IPixel { - nint mcusPerColumn = frame.McusPerColumn; - nint mcusPerLine = frame.McusPerLine; + nuint mcusPerColumn = (uint)frame.McusPerColumn; + nuint mcusPerLine = (uint)frame.McusPerLine; Component c2 = frame.Components[2]; Component c1 = frame.Components[1]; @@ -333,7 +333,7 @@ private void EncodeThreeComponentBaselineInterleavedScanNoSubsampling(Jp ref Block8x8 c1BlockRef = ref MemoryMarshal.GetReference(c1.SpectralBlocks.DangerousGetRowSpan(y: 0)); ref Block8x8 c2BlockRef = ref MemoryMarshal.GetReference(c2.SpectralBlocks.DangerousGetRowSpan(y: 0)); - for (nint j = 0; j < mcusPerColumn; j++) + for (nuint j = 0; j < mcusPerColumn; j++) { cancellationToken.ThrowIfCancellationRequested(); @@ -341,7 +341,7 @@ private void EncodeThreeComponentBaselineInterleavedScanNoSubsampling(Jp converter.ConvertStrideBaseline(); // Encode spectral to binary - for (nint i = 0; i < mcusPerLine; i++) + for (nuint i = 0; i < mcusPerLine; i++) { this.WriteBlock( c0, diff --git a/src/ImageSharp/Formats/Jpeg/Components/FloatingPointDCT.cs b/src/ImageSharp/Formats/Jpeg/Components/FloatingPointDCT.cs index 15348d4474..0aca33b4c9 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/FloatingPointDCT.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/FloatingPointDCT.cs @@ -69,7 +69,7 @@ public static void AdjustToIDCT(ref Block8x8F quantTable) { ref float tableRef = ref Unsafe.As(ref quantTable); ref float multipliersRef = ref MemoryMarshal.GetReference(AdjustmentCoefficients); - for (nint i = 0; i < Block8x8F.Size; i++) + for (nuint i = 0; i < Block8x8F.Size; i++) { ref float elemRef = ref Unsafe.Add(ref tableRef, i); elemRef = 0.125f * elemRef * Unsafe.Add(ref multipliersRef, i); @@ -88,7 +88,7 @@ public static void AdjustToFDCT(ref Block8x8F quantTable) { ref float tableRef = ref Unsafe.As(ref quantTable); ref float multipliersRef = ref MemoryMarshal.GetReference(AdjustmentCoefficients); - for (nint i = 0; i < Block8x8F.Size; i++) + for (nuint i = 0; i < Block8x8F.Size; i++) { ref float elemRef = ref Unsafe.Add(ref tableRef, i); elemRef = 0.125f / (elemRef * Unsafe.Add(ref multipliersRef, i)); diff --git a/src/ImageSharp/Formats/Jpeg/Components/ScaledFloatingPointDCT.cs b/src/ImageSharp/Formats/Jpeg/Components/ScaledFloatingPointDCT.cs index 4f67b7dfe9..1a2767308f 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/ScaledFloatingPointDCT.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/ScaledFloatingPointDCT.cs @@ -40,7 +40,7 @@ internal static class ScaledFloatingPointDCT public static void AdjustToIDCT(ref Block8x8F quantTable) { ref float tableRef = ref Unsafe.As(ref quantTable); - for (nint i = 0; i < Block8x8F.Size; i++) + for (nuint i = 0; i < Block8x8F.Size; i++) { ref float elemRef = ref Unsafe.Add(ref tableRef, i); elemRef = 0.125f * elemRef; diff --git a/src/ImageSharp/Formats/Png/Filters/AverageFilter.cs b/src/ImageSharp/Formats/Png/Filters/AverageFilter.cs index 0e601f5262..2750aa6808 100644 --- a/src/ImageSharp/Formats/Png/Filters/AverageFilter.cs +++ b/src/ImageSharp/Formats/Png/Filters/AverageFilter.cs @@ -42,7 +42,7 @@ public static void Decode(Span scanline, Span previousScanline, int } else { - DecodeScalar(scanline, previousScanline, (nint)(uint)bytesPerPixel); + DecodeScalar(scanline, previousScanline, (uint)bytesPerPixel); } } @@ -56,7 +56,7 @@ private static void DecodeSse2(Span scanline, Span previousScanline) Vector128 ones = Vector128.Create((byte)1); int rb = scanline.Length; - nint offset = 1; + nuint offset = 1; while (rb >= 4) { ref byte scanRef = ref Unsafe.Add(ref scanBaseRef, offset); @@ -88,7 +88,7 @@ public static void DecodeArm(Span scanline, Span previousScanline) Vector64 d = Vector64.Zero; int rb = scanline.Length; - nint offset = 1; + nuint offset = 1; const int bytesPerBatch = 4; while (rb >= bytesPerBatch) { @@ -108,12 +108,12 @@ public static void DecodeArm(Span scanline, Span previousScanline) } [MethodImpl(MethodImplOptions.AggressiveInlining)] - private static void DecodeScalar(Span scanline, Span previousScanline, nint bytesPerPixel) + private static void DecodeScalar(Span scanline, Span previousScanline, uint bytesPerPixel) { ref byte scanBaseRef = ref MemoryMarshal.GetReference(scanline); ref byte prevBaseRef = ref MemoryMarshal.GetReference(previousScanline); - nint x = 1; + nuint x = 1; for (; x <= bytesPerPixel /* Note the <= because x starts at 1 */; ++x) { ref byte scan = ref Unsafe.Add(ref scanBaseRef, x); @@ -139,7 +139,7 @@ private static void DecodeScalar(Span scanline, Span previousScanlin /// The bytes per pixel. /// The sum of the total variance of the filtered row. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void Encode(ReadOnlySpan scanline, ReadOnlySpan previousScanline, Span result, int bytesPerPixel, out int sum) + public static void Encode(ReadOnlySpan scanline, ReadOnlySpan previousScanline, Span result, uint bytesPerPixel, out int sum) { DebugGuard.MustBeSameSized(scanline, previousScanline, nameof(scanline)); DebugGuard.MustBeSizedAtLeast(result, scanline, nameof(result)); @@ -152,8 +152,8 @@ public static void Encode(ReadOnlySpan scanline, ReadOnlySpan previo // Average(x) = Raw(x) - floor((Raw(x-bpp)+Prior(x))/2) resultBaseRef = (byte)FilterType.Average; - nint x = 0; - for (; x < (uint)bytesPerPixel; /* Note: ++x happens in the body to avoid one add operation */) + nuint x = 0; + for (; x < bytesPerPixel; /* Note: ++x happens in the body to avoid one add operation */) { byte scan = Unsafe.Add(ref scanBaseRef, x); byte above = Unsafe.Add(ref prevBaseRef, x); @@ -169,7 +169,7 @@ public static void Encode(ReadOnlySpan scanline, ReadOnlySpan previo Vector256 sumAccumulator = Vector256.Zero; Vector256 allBitsSet = Avx2.CompareEqual(sumAccumulator, sumAccumulator).AsByte(); - for (nint xLeft = x - (nint)(uint)bytesPerPixel; x <= (uint)scanline.Length - Vector256.Count; xLeft += Vector256.Count) + for (nuint xLeft = x - bytesPerPixel; x <= (uint)(scanline.Length - Vector256.Count); xLeft += (uint)Vector256.Count) { Vector256 scan = Unsafe.As>(ref Unsafe.Add(ref scanBaseRef, x)); Vector256 left = Unsafe.As>(ref Unsafe.Add(ref scanBaseRef, xLeft)); @@ -179,7 +179,7 @@ public static void Encode(ReadOnlySpan scanline, ReadOnlySpan previo Vector256 res = Avx2.Subtract(scan, avg); Unsafe.As>(ref Unsafe.Add(ref resultBaseRef, x + 1)) = res; // +1 to skip filter type - x += Vector256.Count; + x += (uint)Vector256.Count; sumAccumulator = Avx2.Add(sumAccumulator, Avx2.SumAbsoluteDifferences(Avx2.Abs(res.AsSByte()), zero).AsInt32()); } @@ -192,7 +192,7 @@ public static void Encode(ReadOnlySpan scanline, ReadOnlySpan previo Vector128 sumAccumulator = Vector128.Zero; Vector128 allBitsSet = Sse2.CompareEqual(sumAccumulator, sumAccumulator).AsByte(); - for (nint xLeft = x - (nint)(uint)bytesPerPixel; x <= (uint)scanline.Length - Vector128.Count; xLeft += Vector128.Count) + for (nuint xLeft = x - bytesPerPixel; x <= (uint)(scanline.Length - Vector128.Count); xLeft += (uint)Vector128.Count) { Vector128 scan = Unsafe.As>(ref Unsafe.Add(ref scanBaseRef, x)); Vector128 left = Unsafe.As>(ref Unsafe.Add(ref scanBaseRef, xLeft)); @@ -202,7 +202,7 @@ public static void Encode(ReadOnlySpan scanline, ReadOnlySpan previo Vector128 res = Sse2.Subtract(scan, avg); Unsafe.As>(ref Unsafe.Add(ref resultBaseRef, x + 1)) = res; // +1 to skip filter type - x += Vector128.Count; + x += (uint)Vector128.Count; Vector128 absRes; if (Ssse3.IsSupported) @@ -221,7 +221,7 @@ public static void Encode(ReadOnlySpan scanline, ReadOnlySpan previo sum += Numerics.EvenReduceSum(sumAccumulator); } - for (nint xLeft = x - (nint)(uint)bytesPerPixel; x < (uint)scanline.Length; ++xLeft /* Note: ++x happens in the body to avoid one add operation */) + for (nuint xLeft = x - bytesPerPixel; x < (uint)scanline.Length; ++xLeft /* Note: ++x happens in the body to avoid one add operation */) { byte scan = Unsafe.Add(ref scanBaseRef, x); byte left = Unsafe.Add(ref scanBaseRef, xLeft); diff --git a/src/ImageSharp/Formats/Png/Filters/PaethFilter.cs b/src/ImageSharp/Formats/Png/Filters/PaethFilter.cs index 540ec63231..f2226974c9 100644 --- a/src/ImageSharp/Formats/Png/Filters/PaethFilter.cs +++ b/src/ImageSharp/Formats/Png/Filters/PaethFilter.cs @@ -45,7 +45,7 @@ public static void Decode(Span scanline, Span previousScanline, int } else { - DecodeScalar(scanline, previousScanline, bytesPerPixel); + DecodeScalar(scanline, previousScanline, (uint)bytesPerPixel); } } @@ -59,7 +59,7 @@ private static void DecodeSse41(Span scanline, Span previousScanline Vector128 d = Vector128.Zero; int rb = scanline.Length; - nint offset = 1; + nuint offset = 1; while (rb >= 4) { ref byte scanRef = ref Unsafe.Add(ref scanBaseRef, offset); @@ -113,7 +113,7 @@ public static void DecodeArm(Span scanline, Span previousScanline) Vector128 d = Vector128.Zero; int rb = scanline.Length; - nint offset = 1; + nuint offset = 1; const int bytesPerBatch = 4; while (rb >= bytesPerBatch) { @@ -179,15 +179,15 @@ private static Vector128 BlendVariable(Vector128 a, Vector128 } [MethodImpl(MethodImplOptions.AggressiveInlining)] - private static void DecodeScalar(Span scanline, Span previousScanline, int bytesPerPixel) + private static void DecodeScalar(Span scanline, Span previousScanline, uint bytesPerPixel) { ref byte scanBaseRef = ref MemoryMarshal.GetReference(scanline); ref byte prevBaseRef = ref MemoryMarshal.GetReference(previousScanline); // Paeth(x) + PaethPredictor(Raw(x-bpp), Prior(x), Prior(x-bpp)) - int offset = bytesPerPixel + 1; // Add one because x starts at one. - nint x = 1; - for (; x < (uint)offset; x++) + nuint offset = bytesPerPixel + 1; // Add one because x starts at one. + nuint x = 1; + for (; x < offset; x++) { ref byte scan = ref Unsafe.Add(ref scanBaseRef, x); byte above = Unsafe.Add(ref prevBaseRef, x); @@ -226,7 +226,7 @@ public static void Encode(ReadOnlySpan scanline, ReadOnlySpan previo // Paeth(x) = Raw(x) - PaethPredictor(Raw(x-bpp), Prior(x), Prior(x - bpp)) resultBaseRef = (byte)FilterType.Paeth; - nint x = 0; + nuint x = 0; for (; x < (uint)bytesPerPixel; /* Note: ++x happens in the body to avoid one add operation */) { byte scan = Unsafe.Add(ref scanBaseRef, x); @@ -242,7 +242,7 @@ public static void Encode(ReadOnlySpan scanline, ReadOnlySpan previo Vector256 zero = Vector256.Zero; Vector256 sumAccumulator = Vector256.Zero; - for (nint xLeft = x - (nint)(uint)bytesPerPixel; x <= (nint)(uint)scanline.Length - Vector256.Count; xLeft += Vector256.Count) + for (nuint xLeft = x - (uint)bytesPerPixel; (int)x <= scanline.Length - Vector256.Count; xLeft += (uint)Vector256.Count) { Vector256 scan = Unsafe.As>(ref Unsafe.Add(ref scanBaseRef, x)); Vector256 left = Unsafe.As>(ref Unsafe.Add(ref scanBaseRef, xLeft)); @@ -251,7 +251,7 @@ public static void Encode(ReadOnlySpan scanline, ReadOnlySpan previo Vector256 res = Avx2.Subtract(scan, PaethPredictor(left, above, upperLeft)); Unsafe.As>(ref Unsafe.Add(ref resultBaseRef, x + 1)) = res; // +1 to skip filter type - x += Vector256.Count; + x += (uint)Vector256.Count; sumAccumulator = Avx2.Add(sumAccumulator, Avx2.SumAbsoluteDifferences(Avx2.Abs(res.AsSByte()), zero).AsInt32()); } @@ -262,7 +262,7 @@ public static void Encode(ReadOnlySpan scanline, ReadOnlySpan previo { Vector sumAccumulator = Vector.Zero; - for (nint xLeft = x - (nint)(uint)bytesPerPixel; x <= (nint)(uint)scanline.Length - Vector.Count; xLeft += Vector.Count) + for (nuint xLeft = x - (uint)bytesPerPixel; (int)x <= scanline.Length - Vector.Count; xLeft += (uint)Vector.Count) { Vector scan = Unsafe.As>(ref Unsafe.Add(ref scanBaseRef, x)); Vector left = Unsafe.As>(ref Unsafe.Add(ref scanBaseRef, xLeft)); @@ -271,7 +271,7 @@ public static void Encode(ReadOnlySpan scanline, ReadOnlySpan previo Vector res = scan - PaethPredictor(left, above, upperLeft); Unsafe.As>(ref Unsafe.Add(ref resultBaseRef, x + 1)) = res; // +1 to skip filter type - x += Vector.Count; + x += (uint)Vector.Count; Numerics.Accumulate(ref sumAccumulator, Vector.AsVectorByte(Vector.Abs(Vector.AsVectorSByte(res)))); } @@ -282,7 +282,7 @@ public static void Encode(ReadOnlySpan scanline, ReadOnlySpan previo } } - for (nint xLeft = x - (nint)(uint)bytesPerPixel; x < (nint)(uint)scanline.Length; ++xLeft /* Note: ++x happens in the body to avoid one add operation */) + for (nuint xLeft = x - (uint)bytesPerPixel; (int)x < scanline.Length; ++xLeft /* Note: ++x happens in the body to avoid one add operation */) { byte scan = Unsafe.Add(ref scanBaseRef, x); byte left = Unsafe.Add(ref scanBaseRef, xLeft); diff --git a/src/ImageSharp/Formats/Png/Filters/SubFilter.cs b/src/ImageSharp/Formats/Png/Filters/SubFilter.cs index 5dc7b15d74..d58ac6fb7b 100644 --- a/src/ImageSharp/Formats/Png/Filters/SubFilter.cs +++ b/src/ImageSharp/Formats/Png/Filters/SubFilter.cs @@ -36,7 +36,7 @@ public static void Decode(Span scanline, int bytesPerPixel) } else { - DecodeScalar(scanline, (nint)(uint)bytesPerPixel); + DecodeScalar(scanline, (uint)bytesPerPixel); } } @@ -47,7 +47,7 @@ private static void DecodeSse2(Span scanline) Vector128 d = Vector128.Zero; int rb = scanline.Length; - nint offset = 1; + nuint offset = 1; while (rb >= 4) { ref byte scanRef = ref Unsafe.Add(ref scanBaseRef, offset); @@ -70,7 +70,7 @@ public static void DecodeArm(Span scanline) Vector64 d = Vector64.Zero; int rb = scanline.Length; - nint offset = 1; + nuint offset = 1; const int bytesPerBatch = 4; while (rb >= bytesPerBatch) { @@ -87,14 +87,14 @@ public static void DecodeArm(Span scanline) } } - private static void DecodeScalar(Span scanline, nint bytesPerPixel) + private static void DecodeScalar(Span scanline, nuint bytesPerPixel) { ref byte scanBaseRef = ref MemoryMarshal.GetReference(scanline); // Sub(x) + Raw(x-bpp) - nint x = bytesPerPixel + 1; + nuint x = bytesPerPixel + 1; Unsafe.Add(ref scanBaseRef, x); - for (; x < scanline.Length; ++x) + for (; x < (uint)scanline.Length; ++x) { ref byte scan = ref Unsafe.Add(ref scanBaseRef, x); byte prev = Unsafe.Add(ref scanBaseRef, x - bytesPerPixel); @@ -121,8 +121,8 @@ public static void Encode(ReadOnlySpan scanline, ReadOnlySpan result // Sub(x) = Raw(x) - Raw(x-bpp) resultBaseRef = (byte)FilterType.Sub; - nint x = 0; - for (; x < (nint)(uint)bytesPerPixel; /* Note: ++x happens in the body to avoid one add operation */) + nuint x = 0; + for (; x < (uint)bytesPerPixel; /* Note: ++x happens in the body to avoid one add operation */) { byte scan = Unsafe.Add(ref scanBaseRef, x); ++x; @@ -136,14 +136,14 @@ public static void Encode(ReadOnlySpan scanline, ReadOnlySpan result Vector256 zero = Vector256.Zero; Vector256 sumAccumulator = Vector256.Zero; - for (nint xLeft = x - (nint)(uint)bytesPerPixel; x <= (nint)(uint)scanline.Length - Vector256.Count; xLeft += Vector256.Count) + for (nuint xLeft = x - (uint)bytesPerPixel; x <= (uint)(scanline.Length - Vector256.Count); xLeft += (uint)Vector256.Count) { Vector256 scan = Unsafe.As>(ref Unsafe.Add(ref scanBaseRef, x)); Vector256 prev = Unsafe.As>(ref Unsafe.Add(ref scanBaseRef, xLeft)); Vector256 res = Avx2.Subtract(scan, prev); Unsafe.As>(ref Unsafe.Add(ref resultBaseRef, x + 1)) = res; // +1 to skip filter type - x += Vector256.Count; + x += (uint)Vector256.Count; sumAccumulator = Avx2.Add(sumAccumulator, Avx2.SumAbsoluteDifferences(Avx2.Abs(res.AsSByte()), zero).AsInt32()); } @@ -154,14 +154,14 @@ public static void Encode(ReadOnlySpan scanline, ReadOnlySpan result { Vector sumAccumulator = Vector.Zero; - for (nint xLeft = x - (nint)(uint)bytesPerPixel; x <= (nint)(uint)scanline.Length - Vector.Count; xLeft += Vector.Count) + for (nuint xLeft = x - (uint)bytesPerPixel; x <= (uint)(scanline.Length - Vector.Count); xLeft += (uint)Vector.Count) { Vector scan = Unsafe.As>(ref Unsafe.Add(ref scanBaseRef, x)); Vector prev = Unsafe.As>(ref Unsafe.Add(ref scanBaseRef, xLeft)); Vector res = scan - prev; Unsafe.As>(ref Unsafe.Add(ref resultBaseRef, x + 1)) = res; // +1 to skip filter type - x += Vector.Count; + x += (uint)Vector.Count; Numerics.Accumulate(ref sumAccumulator, Vector.AsVectorByte(Vector.Abs(Vector.AsVectorSByte(res)))); } @@ -172,7 +172,7 @@ public static void Encode(ReadOnlySpan scanline, ReadOnlySpan result } } - for (nint xLeft = x - (nint)(uint)bytesPerPixel; x < (nint)(uint)scanline.Length; ++xLeft /* Note: ++x happens in the body to avoid one add operation */) + for (nuint xLeft = x - (uint)bytesPerPixel; x < (uint)scanline.Length; ++xLeft /* Note: ++x happens in the body to avoid one add operation */) { byte scan = Unsafe.Add(ref scanBaseRef, x); byte prev = Unsafe.Add(ref scanBaseRef, xLeft); diff --git a/src/ImageSharp/Formats/Png/Filters/UpFilter.cs b/src/ImageSharp/Formats/Png/Filters/UpFilter.cs index 55cc9ad6eb..dd3c2d8612 100644 --- a/src/ImageSharp/Formats/Png/Filters/UpFilter.cs +++ b/src/ImageSharp/Formats/Png/Filters/UpFilter.cs @@ -52,7 +52,7 @@ private static void DecodeAvx2(Span scanline, Span previousScanline) // Up(x) + Prior(x) int rb = scanline.Length; - nint offset = 1; + nuint offset = 1; while (rb >= Vector256.Count) { ref byte scanRef = ref Unsafe.Add(ref scanBaseRef, offset); @@ -61,12 +61,12 @@ private static void DecodeAvx2(Span scanline, Span previousScanline) Unsafe.As>(ref scanRef) = Avx2.Add(up, prior); - offset += Vector256.Count; + offset += (uint)Vector256.Count; rb -= Vector256.Count; } // Handle left over. - for (nint i = offset; i < (uint)scanline.Length; i++) + for (nuint i = offset; i < (uint)scanline.Length; i++) { ref byte scan = ref Unsafe.Add(ref scanBaseRef, offset); byte above = Unsafe.Add(ref prevBaseRef, offset); @@ -82,7 +82,7 @@ private static void DecodeSse2(Span scanline, Span previousScanline) // Up(x) + Prior(x) int rb = scanline.Length; - nint offset = 1; + nuint offset = 1; while (rb >= Vector128.Count) { ref byte scanRef = ref Unsafe.Add(ref scanBaseRef, offset); @@ -91,12 +91,12 @@ private static void DecodeSse2(Span scanline, Span previousScanline) Unsafe.As>(ref scanRef) = Sse2.Add(up, prior); - offset += Vector128.Count; + offset += (uint)Vector128.Count; rb -= Vector128.Count; } // Handle left over. - for (nint i = offset; i < (uint)scanline.Length; i++) + for (nuint i = offset; i < (uint)scanline.Length; i++) { ref byte scan = ref Unsafe.Add(ref scanBaseRef, offset); byte above = Unsafe.Add(ref prevBaseRef, offset); @@ -112,7 +112,7 @@ private static void DecodeArm(Span scanline, Span previousScanline) // Up(x) + Prior(x) int rb = scanline.Length; - nint offset = 1; + nuint offset = 1; const int bytesPerBatch = 16; while (rb >= bytesPerBatch) { @@ -127,7 +127,7 @@ private static void DecodeArm(Span scanline, Span previousScanline) } // Handle left over. - for (nint i = offset; i < (uint)scanline.Length; i++) + for (nuint i = offset; i < (uint)scanline.Length; i++) { ref byte scan = ref Unsafe.Add(ref scanBaseRef, offset); byte above = Unsafe.Add(ref prevBaseRef, offset); @@ -143,7 +143,7 @@ private static void DecodeScalar(Span scanline, Span previousScanlin ref byte prevBaseRef = ref MemoryMarshal.GetReference(previousScanline); // Up(x) + Prior(x) - for (nint x = 1; x < (uint)scanline.Length; x++) + for (nuint x = 1; x < (uint)scanline.Length; x++) { ref byte scan = ref Unsafe.Add(ref scanBaseRef, x); byte above = Unsafe.Add(ref prevBaseRef, x); @@ -172,21 +172,21 @@ public static void Encode(ReadOnlySpan scanline, ReadOnlySpan previo // Up(x) = Raw(x) - Prior(x) resultBaseRef = (byte)FilterType.Up; - nint x = 0; + nuint x = 0; if (Avx2.IsSupported) { Vector256 zero = Vector256.Zero; Vector256 sumAccumulator = Vector256.Zero; - for (; x <= (nint)(uint)(scanline.Length - Vector256.Count);) + for (; x <= (uint)(scanline.Length - Vector256.Count);) { Vector256 scan = Unsafe.As>(ref Unsafe.Add(ref scanBaseRef, x)); Vector256 above = Unsafe.As>(ref Unsafe.Add(ref prevBaseRef, x)); Vector256 res = Avx2.Subtract(scan, above); Unsafe.As>(ref Unsafe.Add(ref resultBaseRef, x + 1)) = res; // +1 to skip filter type - x += Vector256.Count; + x += (uint)Vector256.Count; sumAccumulator = Avx2.Add(sumAccumulator, Avx2.SumAbsoluteDifferences(Avx2.Abs(res.AsSByte()), zero).AsInt32()); } @@ -197,14 +197,14 @@ public static void Encode(ReadOnlySpan scanline, ReadOnlySpan previo { Vector sumAccumulator = Vector.Zero; - for (; x <= (nint)(uint)(scanline.Length - Vector.Count);) + for (; x <= (uint)(scanline.Length - Vector.Count);) { Vector scan = Unsafe.As>(ref Unsafe.Add(ref scanBaseRef, x)); Vector above = Unsafe.As>(ref Unsafe.Add(ref prevBaseRef, x)); Vector res = scan - above; Unsafe.As>(ref Unsafe.Add(ref resultBaseRef, x + 1)) = res; // +1 to skip filter type - x += Vector.Count; + x += (uint)Vector.Count; Numerics.Accumulate(ref sumAccumulator, Vector.AsVectorByte(Vector.Abs(Vector.AsVectorSByte(res)))); } @@ -215,7 +215,7 @@ public static void Encode(ReadOnlySpan scanline, ReadOnlySpan previo } } - for (; x < (nint)(uint)scanline.Length; /* Note: ++x happens in the body to avoid one add operation */) + for (; x < (uint)scanline.Length; /* Note: ++x happens in the body to avoid one add operation */) { byte scan = Unsafe.Add(ref scanBaseRef, x); byte above = Unsafe.Add(ref prevBaseRef, x); diff --git a/src/ImageSharp/Formats/Png/PngDecoderCore.cs b/src/ImageSharp/Formats/Png/PngDecoderCore.cs index ea8120a5c1..3ecc363fa4 100644 --- a/src/ImageSharp/Formats/Png/PngDecoderCore.cs +++ b/src/ImageSharp/Formats/Png/PngDecoderCore.cs @@ -777,8 +777,8 @@ private void ProcessDefilteredScanline(ReadOnlySpan defilteredScan this.header, scanlineSpan, rowSpan, - this.bytesPerPixel, - this.bytesPerSample); + (uint)this.bytesPerPixel, + (uint)this.bytesPerSample); break; @@ -858,8 +858,8 @@ private void ProcessInterlacedDefilteredScanline(ReadOnlySpan defi this.header, scanlineSpan, rowSpan, - pixelOffset, - increment, + (uint)pixelOffset, + (uint)increment, pngMetadata.HasTransparency, pngMetadata.TransparentL16.GetValueOrDefault(), pngMetadata.TransparentL8.GetValueOrDefault()); @@ -871,10 +871,10 @@ private void ProcessInterlacedDefilteredScanline(ReadOnlySpan defi this.header, scanlineSpan, rowSpan, - pixelOffset, - increment, - this.bytesPerPixel, - this.bytesPerSample); + (uint)pixelOffset, + (uint)increment, + (uint)this.bytesPerPixel, + (uint)this.bytesPerSample); break; @@ -883,8 +883,8 @@ private void ProcessInterlacedDefilteredScanline(ReadOnlySpan defi this.header, scanlineSpan, rowSpan, - pixelOffset, - increment, + (uint)pixelOffset, + (uint)increment, this.palette, this.paletteAlpha); @@ -895,8 +895,8 @@ private void ProcessInterlacedDefilteredScanline(ReadOnlySpan defi this.header, scanlineSpan, rowSpan, - pixelOffset, - increment, + (uint)pixelOffset, + (uint)increment, this.bytesPerPixel, this.bytesPerSample, pngMetadata.HasTransparency, @@ -910,8 +910,8 @@ private void ProcessInterlacedDefilteredScanline(ReadOnlySpan defi this.header, scanlineSpan, rowSpan, - pixelOffset, - increment, + (uint)pixelOffset, + (uint)increment, this.bytesPerPixel, this.bytesPerSample); diff --git a/src/ImageSharp/Formats/Png/PngEncoderCore.cs b/src/ImageSharp/Formats/Png/PngEncoderCore.cs index 4657ab17bb..5794da3d56 100644 --- a/src/ImageSharp/Formats/Png/PngEncoderCore.cs +++ b/src/ImageSharp/Formats/Png/PngEncoderCore.cs @@ -455,7 +455,7 @@ private void FilterPixelBytes(ref Span filter, ref Span attempt) break; case PngFilterMethod.Average: - AverageFilter.Encode(this.currentScanline.GetSpan(), this.previousScanline.GetSpan(), filter, this.bytesPerPixel, out int _); + AverageFilter.Encode(this.currentScanline.GetSpan(), this.previousScanline.GetSpan(), filter, (uint)this.bytesPerPixel, out int _); break; case PngFilterMethod.Paeth: @@ -547,7 +547,7 @@ private void ApplyOptimalFilteredScanline(ref Span filter, ref Span RuntimeUtility.Swap(ref filter, ref attempt); } - AverageFilter.Encode(current, previous, attempt, this.bytesPerPixel, out sum); + AverageFilter.Encode(current, previous, attempt, (uint)this.bytesPerPixel, out sum); if (sum < min) { min = sum; diff --git a/src/ImageSharp/Formats/Png/PngScanlineProcessor.cs b/src/ImageSharp/Formats/Png/PngScanlineProcessor.cs index 51b23242c8..04a23308cc 100644 --- a/src/ImageSharp/Formats/Png/PngScanlineProcessor.cs +++ b/src/ImageSharp/Formats/Png/PngScanlineProcessor.cs @@ -32,20 +32,21 @@ public static void ProcessGrayscaleScanline( { if (header.BitDepth == 16) { - for (int x = 0, o = 0; x < header.Width; x++, o += 2) + int o = 0; + for (nuint x = 0; x < (uint)header.Width; x++, o += 2) { ushort luminance = BinaryPrimitives.ReadUInt16BigEndian(scanlineSpan.Slice(o, 2)); pixel.FromL16(Unsafe.As(ref luminance)); - Unsafe.Add(ref rowSpanRef, (uint)x) = pixel; + Unsafe.Add(ref rowSpanRef, x) = pixel; } } else { - for (int x = 0; x < header.Width; x++) + for (nuint x = 0; x < (uint)header.Width; x++) { - byte luminance = (byte)(Unsafe.Add(ref scanlineSpanRef, (uint)x) * scaleFactor); + byte luminance = (byte)(Unsafe.Add(ref scanlineSpanRef, x) * scaleFactor); pixel.FromL8(Unsafe.As(ref luminance)); - Unsafe.Add(ref rowSpanRef, (uint)x) = pixel; + Unsafe.Add(ref rowSpanRef, x) = pixel; } } @@ -55,28 +56,29 @@ public static void ProcessGrayscaleScanline( if (header.BitDepth == 16) { La32 source = default; - for (int x = 0, o = 0; x < header.Width; x++, o += 2) + int o = 0; + for (nuint x = 0; x < (uint)header.Width; x++, o += 2) { ushort luminance = BinaryPrimitives.ReadUInt16BigEndian(scanlineSpan.Slice(o, 2)); source.L = luminance; source.A = luminance.Equals(luminance16Trans.PackedValue) ? ushort.MinValue : ushort.MaxValue; pixel.FromLa32(source); - Unsafe.Add(ref rowSpanRef, (uint)x) = pixel; + Unsafe.Add(ref rowSpanRef, x) = pixel; } } else { La16 source = default; byte scaledLuminanceTrans = (byte)(luminanceTrans.PackedValue * scaleFactor); - for (int x = 0; x < header.Width; x++) + for (nuint x = 0; x < (uint)header.Width; x++) { - byte luminance = (byte)(Unsafe.Add(ref scanlineSpanRef, (uint)x) * scaleFactor); + byte luminance = (byte)(Unsafe.Add(ref scanlineSpanRef, x) * scaleFactor); source.L = luminance; source.A = luminance.Equals(scaledLuminanceTrans) ? byte.MinValue : byte.MaxValue; pixel.FromLa16(source); - Unsafe.Add(ref rowSpanRef, (uint)x) = pixel; + Unsafe.Add(ref rowSpanRef, x) = pixel; } } } @@ -85,8 +87,8 @@ public static void ProcessInterlacedGrayscaleScanline( in PngHeader header, ReadOnlySpan scanlineSpan, Span rowSpan, - int pixelOffset, - int increment, + uint pixelOffset, + uint increment, bool hasTrans, L16 luminance16Trans, L8 luminanceTrans) @@ -101,20 +103,21 @@ public static void ProcessInterlacedGrayscaleScanline( { if (header.BitDepth == 16) { - for (int x = pixelOffset, o = 0; x < header.Width; x += increment, o += 2) + int o = 0; + for (nuint x = pixelOffset; x < (uint)header.Width; x += increment, o += 2) { ushort luminance = BinaryPrimitives.ReadUInt16BigEndian(scanlineSpan.Slice(o, 2)); pixel.FromL16(Unsafe.As(ref luminance)); - Unsafe.Add(ref rowSpanRef, (uint)x) = pixel; + Unsafe.Add(ref rowSpanRef, x) = pixel; } } else { - for (int x = pixelOffset, o = 0; x < header.Width; x += increment, o++) + for (nuint x = pixelOffset, o = 0; x < (uint)header.Width; x += increment, o++) { - byte luminance = (byte)(Unsafe.Add(ref scanlineSpanRef, (uint)o) * scaleFactor); + byte luminance = (byte)(Unsafe.Add(ref scanlineSpanRef, o) * scaleFactor); pixel.FromL8(Unsafe.As(ref luminance)); - Unsafe.Add(ref rowSpanRef, (uint)x) = pixel; + Unsafe.Add(ref rowSpanRef, x) = pixel; } } @@ -124,28 +127,29 @@ public static void ProcessInterlacedGrayscaleScanline( if (header.BitDepth == 16) { La32 source = default; - for (int x = pixelOffset, o = 0; x < header.Width; x += increment, o += 2) + int o = 0; + for (nuint x = pixelOffset; x < (uint)header.Width; x += increment, o += 2) { ushort luminance = BinaryPrimitives.ReadUInt16BigEndian(scanlineSpan.Slice(o, 2)); source.L = luminance; source.A = luminance.Equals(luminance16Trans.PackedValue) ? ushort.MinValue : ushort.MaxValue; pixel.FromLa32(source); - Unsafe.Add(ref rowSpanRef, (uint)x) = pixel; + Unsafe.Add(ref rowSpanRef, x) = pixel; } } else { La16 source = default; byte scaledLuminanceTrans = (byte)(luminanceTrans.PackedValue * scaleFactor); - for (int x = pixelOffset, o = 0; x < header.Width; x += increment, o++) + for (nuint x = pixelOffset, o = 0; x < (uint)header.Width; x += increment, o++) { - byte luminance = (byte)(Unsafe.Add(ref scanlineSpanRef, (uint)o) * scaleFactor); + byte luminance = (byte)(Unsafe.Add(ref scanlineSpanRef, o) * scaleFactor); source.L = luminance; source.A = luminance.Equals(scaledLuminanceTrans) ? byte.MinValue : byte.MaxValue; pixel.FromLa16(source); - Unsafe.Add(ref rowSpanRef, (uint)x) = pixel; + Unsafe.Add(ref rowSpanRef, x) = pixel; } } } @@ -154,8 +158,8 @@ public static void ProcessGrayscaleWithAlphaScanline( in PngHeader header, ReadOnlySpan scanlineSpan, Span rowSpan, - int bytesPerPixel, - int bytesPerSample) + uint bytesPerPixel, + uint bytesPerSample) where TPixel : unmanaged, IPixel { TPixel pixel = default; @@ -165,26 +169,27 @@ public static void ProcessGrayscaleWithAlphaScanline( if (header.BitDepth == 16) { La32 source = default; - for (int x = 0, o = 0; x < header.Width; x++, o += 4) + int o = 0; + for (nuint x = 0; x < (uint)header.Width; x++, o += 4) { source.L = BinaryPrimitives.ReadUInt16BigEndian(scanlineSpan.Slice(o, 2)); source.A = BinaryPrimitives.ReadUInt16BigEndian(scanlineSpan.Slice(o + 2, 2)); pixel.FromLa32(source); - Unsafe.Add(ref rowSpanRef, (uint)x) = pixel; + Unsafe.Add(ref rowSpanRef, x) = pixel; } } else { La16 source = default; - for (int x = 0; x < header.Width; x++) + for (nuint x = 0; x < (uint)header.Width; x++) { - int offset = x * bytesPerPixel; - source.L = Unsafe.Add(ref scanlineSpanRef, (uint)offset); - source.A = Unsafe.Add(ref scanlineSpanRef, (uint)(offset + bytesPerSample)); + nuint offset = x * bytesPerPixel; + source.L = Unsafe.Add(ref scanlineSpanRef, offset); + source.A = Unsafe.Add(ref scanlineSpanRef, offset + bytesPerSample); pixel.FromLa16(source); - Unsafe.Add(ref rowSpanRef, (uint)x) = pixel; + Unsafe.Add(ref rowSpanRef, x) = pixel; } } } @@ -193,10 +198,10 @@ public static void ProcessInterlacedGrayscaleWithAlphaScanline( in PngHeader header, ReadOnlySpan scanlineSpan, Span rowSpan, - int pixelOffset, - int increment, - int bytesPerPixel, - int bytesPerSample) + uint pixelOffset, + uint increment, + uint bytesPerPixel, + uint bytesPerSample) where TPixel : unmanaged, IPixel { TPixel pixel = default; @@ -206,7 +211,8 @@ public static void ProcessInterlacedGrayscaleWithAlphaScanline( if (header.BitDepth == 16) { La32 source = default; - for (int x = pixelOffset, o = 0; x < header.Width; x += increment, o += 4) + int o = 0; + for (nuint x = pixelOffset; x < (uint)header.Width; x += increment, o += 4) { source.L = BinaryPrimitives.ReadUInt16BigEndian(scanlineSpan.Slice(o, 2)); source.A = BinaryPrimitives.ReadUInt16BigEndian(scanlineSpan.Slice(o + 2, 2)); @@ -217,15 +223,15 @@ public static void ProcessInterlacedGrayscaleWithAlphaScanline( } else { - int offset = 0; La16 source = default; - for (int x = pixelOffset; x < header.Width; x += increment) + nuint offset = 0; + for (nuint x = pixelOffset; x < (uint)header.Width; x += increment) { - source.L = Unsafe.Add(ref scanlineSpanRef, (uint)offset); - source.A = Unsafe.Add(ref scanlineSpanRef, (uint)(offset + bytesPerSample)); + source.L = Unsafe.Add(ref scanlineSpanRef, offset); + source.A = Unsafe.Add(ref scanlineSpanRef, offset + bytesPerSample); pixel.FromLa16(source); - Unsafe.Add(ref rowSpanRef, (uint)x) = pixel; + Unsafe.Add(ref rowSpanRef, x) = pixel; offset += bytesPerPixel; } } @@ -257,25 +263,25 @@ public static void ProcessPaletteScanline( Rgba32 rgba = default; ref byte paletteAlphaRef = ref MemoryMarshal.GetArrayDataReference(paletteAlpha); - for (int x = 0; x < header.Width; x++) + for (nuint x = 0; x < (uint)header.Width; x++) { - int index = Unsafe.Add(ref scanlineSpanRef, (uint)x); - rgba.Rgb = Unsafe.Add(ref palettePixelsRef, (uint)index); - rgba.A = paletteAlpha.Length > index ? Unsafe.Add(ref paletteAlphaRef, (uint)index) : byte.MaxValue; + uint index = Unsafe.Add(ref scanlineSpanRef, x); + rgba.Rgb = Unsafe.Add(ref palettePixelsRef, index); + rgba.A = paletteAlpha.Length > index ? Unsafe.Add(ref paletteAlphaRef, index) : byte.MaxValue; pixel.FromRgba32(rgba); - Unsafe.Add(ref rowSpanRef, (uint)x) = pixel; + Unsafe.Add(ref rowSpanRef, x) = pixel; } } else { - for (int x = 0; x < header.Width; x++) + for (nuint x = 0; x < (uint)header.Width; x++) { - int index = Unsafe.Add(ref scanlineSpanRef, (uint)x); - Rgb24 rgb = Unsafe.Add(ref palettePixelsRef, (uint)index); + int index = Unsafe.Add(ref scanlineSpanRef, x); + Rgb24 rgb = Unsafe.Add(ref palettePixelsRef, index); pixel.FromRgb24(rgb); - Unsafe.Add(ref rowSpanRef, (uint)x) = pixel; + Unsafe.Add(ref rowSpanRef, x) = pixel; } } } @@ -284,8 +290,8 @@ public static void ProcessInterlacedPaletteScanline( in PngHeader header, ReadOnlySpan scanlineSpan, Span rowSpan, - int pixelOffset, - int increment, + uint pixelOffset, + uint increment, ReadOnlySpan palette, byte[] paletteAlpha) where TPixel : unmanaged, IPixel @@ -302,25 +308,25 @@ public static void ProcessInterlacedPaletteScanline( // channel and we should try to read it. Rgba32 rgba = default; ref byte paletteAlphaRef = ref MemoryMarshal.GetArrayDataReference(paletteAlpha); - for (int x = pixelOffset, o = 0; x < header.Width; x += increment, o++) + for (nuint x = pixelOffset, o = 0; x < (uint)header.Width; x += increment, o++) { - int index = Unsafe.Add(ref scanlineSpanRef, (uint)o); - rgba.A = paletteAlpha.Length > index ? Unsafe.Add(ref paletteAlphaRef, (uint)index) : byte.MaxValue; - rgba.Rgb = Unsafe.Add(ref palettePixelsRef, (uint)index); + uint index = Unsafe.Add(ref scanlineSpanRef, o); + rgba.A = paletteAlpha.Length > index ? Unsafe.Add(ref paletteAlphaRef, index) : byte.MaxValue; + rgba.Rgb = Unsafe.Add(ref palettePixelsRef, index); pixel.FromRgba32(rgba); - Unsafe.Add(ref rowSpanRef, (uint)x) = pixel; + Unsafe.Add(ref rowSpanRef, x) = pixel; } } else { - for (int x = pixelOffset, o = 0; x < header.Width; x += increment, o++) + for (nuint x = pixelOffset, o = 0; x < (uint)header.Width; x += increment, o++) { - int index = Unsafe.Add(ref scanlineSpanRef, (uint)o); - Rgb24 rgb = Unsafe.Add(ref palettePixelsRef, (uint)index); + int index = Unsafe.Add(ref scanlineSpanRef, o); + Rgb24 rgb = Unsafe.Add(ref palettePixelsRef, index); pixel.FromRgb24(rgb); - Unsafe.Add(ref rowSpanRef, (uint)x) = pixel; + Unsafe.Add(ref rowSpanRef, x) = pixel; } } } @@ -345,14 +351,15 @@ public static void ProcessRgbScanline( if (header.BitDepth == 16) { Rgb48 rgb48 = default; - for (int x = 0, o = 0; x < header.Width; x++, o += bytesPerPixel) + int o = 0; + for (nuint x = 0; x < (uint)header.Width; x++, o += bytesPerPixel) { rgb48.R = BinaryPrimitives.ReadUInt16BigEndian(scanlineSpan.Slice(o, bytesPerSample)); rgb48.G = BinaryPrimitives.ReadUInt16BigEndian(scanlineSpan.Slice(o + bytesPerSample, bytesPerSample)); rgb48.B = BinaryPrimitives.ReadUInt16BigEndian(scanlineSpan.Slice(o + (2 * bytesPerSample), bytesPerSample)); pixel.FromRgb48(rgb48); - Unsafe.Add(ref rowSpanRef, (uint)x) = pixel; + Unsafe.Add(ref rowSpanRef, x) = pixel; } } else @@ -367,7 +374,8 @@ public static void ProcessRgbScanline( { Rgb48 rgb48 = default; Rgba64 rgba64 = default; - for (int x = 0, o = 0; x < header.Width; x++, o += bytesPerPixel) + int o = 0; + for (nuint x = 0; x < (uint)header.Width; x++, o += bytesPerPixel) { rgb48.R = BinaryPrimitives.ReadUInt16BigEndian(scanlineSpan.Slice(o, bytesPerSample)); rgb48.G = BinaryPrimitives.ReadUInt16BigEndian(scanlineSpan.Slice(o + bytesPerSample, bytesPerSample)); @@ -377,7 +385,7 @@ public static void ProcessRgbScanline( rgba64.A = rgb48.Equals(rgb48Trans) ? ushort.MinValue : ushort.MaxValue; pixel.FromRgba64(rgba64); - Unsafe.Add(ref rowSpanRef, (uint)x) = pixel; + Unsafe.Add(ref rowSpanRef, x) = pixel; } } else @@ -385,14 +393,14 @@ public static void ProcessRgbScanline( Rgba32 rgba32 = default; ReadOnlySpan rgb24Span = MemoryMarshal.Cast(scanlineSpan); ref Rgb24 rgb24SpanRef = ref MemoryMarshal.GetReference(rgb24Span); - for (int x = 0; x < header.Width; x++) + for (nuint x = 0; x < (uint)header.Width; x++) { - ref readonly Rgb24 rgb24 = ref Unsafe.Add(ref rgb24SpanRef, (uint)x); + ref readonly Rgb24 rgb24 = ref Unsafe.Add(ref rgb24SpanRef, x); rgba32.Rgb = rgb24; rgba32.A = rgb24.Equals(rgb24Trans) ? byte.MinValue : byte.MaxValue; pixel.FromRgba32(rgba32); - Unsafe.Add(ref rowSpanRef, (uint)x) = pixel; + Unsafe.Add(ref rowSpanRef, x) = pixel; } } } @@ -401,8 +409,8 @@ public static void ProcessInterlacedRgbScanline( in PngHeader header, ReadOnlySpan scanlineSpan, Span rowSpan, - int pixelOffset, - int increment, + uint pixelOffset, + uint increment, int bytesPerPixel, int bytesPerSample, bool hasTrans, @@ -420,7 +428,8 @@ public static void ProcessInterlacedRgbScanline( { Rgb48 rgb48 = default; Rgba64 rgba64 = default; - for (int x = pixelOffset, o = 0; x < header.Width; x += increment, o += bytesPerPixel) + int o = 0; + for (nuint x = pixelOffset; x < (uint)header.Width; x += increment, o += bytesPerPixel) { rgb48.R = BinaryPrimitives.ReadUInt16BigEndian(scanlineSpan.Slice(o, bytesPerSample)); rgb48.G = BinaryPrimitives.ReadUInt16BigEndian(scanlineSpan.Slice(o + bytesPerSample, bytesPerSample)); @@ -430,20 +439,21 @@ public static void ProcessInterlacedRgbScanline( rgba64.A = rgb48.Equals(rgb48Trans) ? ushort.MinValue : ushort.MaxValue; pixel.FromRgba64(rgba64); - Unsafe.Add(ref rowSpanRef, (uint)x) = pixel; + Unsafe.Add(ref rowSpanRef, x) = pixel; } } else { Rgb48 rgb48 = default; - for (int x = pixelOffset, o = 0; x < header.Width; x += increment, o += bytesPerPixel) + int o = 0; + for (nuint x = pixelOffset; x < (uint)header.Width; x += increment, o += bytesPerPixel) { rgb48.R = BinaryPrimitives.ReadUInt16BigEndian(scanlineSpan.Slice(o, bytesPerSample)); rgb48.G = BinaryPrimitives.ReadUInt16BigEndian(scanlineSpan.Slice(o + bytesPerSample, bytesPerSample)); rgb48.B = BinaryPrimitives.ReadUInt16BigEndian(scanlineSpan.Slice(o + (2 * bytesPerSample), bytesPerSample)); pixel.FromRgb48(rgb48); - Unsafe.Add(ref rowSpanRef, (uint)x) = pixel; + Unsafe.Add(ref rowSpanRef, x) = pixel; } } @@ -453,7 +463,8 @@ public static void ProcessInterlacedRgbScanline( if (hasTrans) { Rgba32 rgba = default; - for (int x = pixelOffset, o = 0; x < header.Width; x += increment, o += bytesPerPixel) + int o = 0; + for (nuint x = pixelOffset; x < (uint)header.Width; x += increment, o += bytesPerPixel) { rgba.R = Unsafe.Add(ref scanlineSpanRef, (uint)o); rgba.G = Unsafe.Add(ref scanlineSpanRef, (uint)(o + bytesPerSample)); @@ -461,20 +472,21 @@ public static void ProcessInterlacedRgbScanline( rgba.A = rgb24Trans.Equals(rgba.Rgb) ? byte.MinValue : byte.MaxValue; pixel.FromRgba32(rgba); - Unsafe.Add(ref rowSpanRef, (uint)x) = pixel; + Unsafe.Add(ref rowSpanRef, x) = pixel; } } else { Rgb24 rgb = default; - for (int x = pixelOffset, o = 0; x < header.Width; x += increment, o += bytesPerPixel) + int o = 0; + for (nuint x = pixelOffset; x < (uint)header.Width; x += increment, o += bytesPerPixel) { rgb.R = Unsafe.Add(ref scanlineSpanRef, (uint)o); rgb.G = Unsafe.Add(ref scanlineSpanRef, (uint)(o + bytesPerSample)); rgb.B = Unsafe.Add(ref scanlineSpanRef, (uint)(o + (2 * bytesPerSample))); pixel.FromRgb24(rgb); - Unsafe.Add(ref rowSpanRef, (uint)x) = pixel; + Unsafe.Add(ref rowSpanRef, x) = pixel; } } } @@ -494,7 +506,8 @@ public static void ProcessRgbaScanline( if (header.BitDepth == 16) { Rgba64 rgba64 = default; - for (int x = 0, o = 0; x < header.Width; x++, o += bytesPerPixel) + int o = 0; + for (nuint x = 0; x < (uint)header.Width; x++, o += bytesPerPixel) { rgba64.R = BinaryPrimitives.ReadUInt16BigEndian(scanlineSpan.Slice(o, bytesPerSample)); rgba64.G = BinaryPrimitives.ReadUInt16BigEndian(scanlineSpan.Slice(o + bytesPerSample, bytesPerSample)); @@ -502,7 +515,7 @@ public static void ProcessRgbaScanline( rgba64.A = BinaryPrimitives.ReadUInt16BigEndian(scanlineSpan.Slice(o + (3 * bytesPerSample), bytesPerSample)); pixel.FromRgba64(rgba64); - Unsafe.Add(ref rowSpanRef, (uint)x) = pixel; + Unsafe.Add(ref rowSpanRef, x) = pixel; } } else @@ -515,8 +528,8 @@ public static void ProcessInterlacedRgbaScanline( in PngHeader header, ReadOnlySpan scanlineSpan, Span rowSpan, - int pixelOffset, - int increment, + uint pixelOffset, + uint increment, int bytesPerPixel, int bytesPerSample) where TPixel : unmanaged, IPixel @@ -528,7 +541,8 @@ public static void ProcessInterlacedRgbaScanline( if (header.BitDepth == 16) { Rgba64 rgba64 = default; - for (int x = pixelOffset, o = 0; x < header.Width; x += increment, o += bytesPerPixel) + int o = 0; + for (nuint x = pixelOffset; x < (uint)header.Width; x += increment, o += bytesPerPixel) { rgba64.R = BinaryPrimitives.ReadUInt16BigEndian(scanlineSpan.Slice(o, bytesPerSample)); rgba64.G = BinaryPrimitives.ReadUInt16BigEndian(scanlineSpan.Slice(o + bytesPerSample, bytesPerSample)); @@ -536,13 +550,14 @@ public static void ProcessInterlacedRgbaScanline( rgba64.A = BinaryPrimitives.ReadUInt16BigEndian(scanlineSpan.Slice(o + (3 * bytesPerSample), bytesPerSample)); pixel.FromRgba64(rgba64); - Unsafe.Add(ref rowSpanRef, (uint)x) = pixel; + Unsafe.Add(ref rowSpanRef, x) = pixel; } } else { Rgba32 rgba = default; - for (int x = pixelOffset, o = 0; x < header.Width; x += increment, o += bytesPerPixel) + int o = 0; + for (nuint x = pixelOffset; x < (uint)header.Width; x += increment, o += bytesPerPixel) { rgba.R = Unsafe.Add(ref scanlineSpanRef, (uint)o); rgba.G = Unsafe.Add(ref scanlineSpanRef, (uint)(o + bytesPerSample)); @@ -550,7 +565,7 @@ public static void ProcessInterlacedRgbaScanline( rgba.A = Unsafe.Add(ref scanlineSpanRef, (uint)(o + (3 * bytesPerSample))); pixel.FromRgba32(rgba); - Unsafe.Add(ref rowSpanRef, (uint)x) = pixel; + Unsafe.Add(ref rowSpanRef, x) = pixel; } } } diff --git a/src/ImageSharp/Formats/Tiff/Compression/Decompressors/T6TiffCompression.cs b/src/ImageSharp/Formats/Tiff/Compression/Decompressors/T6TiffCompression.cs index 1cd8e0dc80..c868fec626 100644 --- a/src/ImageSharp/Formats/Tiff/Compression/Decompressors/T6TiffCompression.cs +++ b/src/ImageSharp/Formats/Tiff/Compression/Decompressors/T6TiffCompression.cs @@ -78,7 +78,7 @@ private nint WriteScanLine(Span buffer, Span scanLine, nint bitsWrit nint bitPos = Numerics.Modulo8(bitsWritten); nint bufferPos = bitsWritten / 8; ref byte scanLineRef = ref MemoryMarshal.GetReference(scanLine); - for (nint i = 0; i < (uint)scanLine.Length; i++) + for (nuint i = 0; i < (uint)scanLine.Length; i++) { if (Unsafe.Add(ref scanLineRef, i) != this.white) { diff --git a/src/ImageSharp/Formats/Tiff/Compression/TiffBaseCompression.cs b/src/ImageSharp/Formats/Tiff/Compression/TiffBaseCompression.cs index d57dea994f..36f8c20d72 100644 --- a/src/ImageSharp/Formats/Tiff/Compression/TiffBaseCompression.cs +++ b/src/ImageSharp/Formats/Tiff/Compression/TiffBaseCompression.cs @@ -16,7 +16,7 @@ protected TiffBaseCompression(MemoryAllocator allocator, int width, int bitsPerP this.Width = width; this.BitsPerPixel = bitsPerPixel; this.Predictor = predictor; - this.BytesPerRow = (int)(((uint)(width * bitsPerPixel) + 7) / 8); + this.BytesPerRow = ((width * bitsPerPixel) + 7) / 8; } /// diff --git a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/BlackIsZero1TiffColor{TPixel}.cs b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/BlackIsZero1TiffColor{TPixel}.cs index a5a04d19d5..a8a70f7272 100644 --- a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/BlackIsZero1TiffColor{TPixel}.cs +++ b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/BlackIsZero1TiffColor{TPixel}.cs @@ -18,21 +18,21 @@ internal class BlackIsZero1TiffColor : TiffBaseColorDecoder /// public override void Decode(ReadOnlySpan data, Buffer2D pixels, int left, int top, int width, int height) { - nint offset = 0; - var colorBlack = default(TPixel); - var colorWhite = default(TPixel); + nuint offset = 0; + TPixel colorBlack = default; + TPixel colorWhite = default; colorBlack.FromRgba32(Color.Black); colorWhite.FromRgba32(Color.White); ref byte dataRef = ref MemoryMarshal.GetReference(data); - for (nint y = top; y < top + height; y++) + for (nuint y = (uint)top; y < (uint)(top + height); y++) { Span pixelRowSpan = pixels.DangerousGetRowSpan((int)y); ref TPixel pixelRowRef = ref MemoryMarshal.GetReference(pixelRowSpan); - for (nint x = (nint)(uint)left; x < (nint)(uint)(left + width); x += 8) + for (nuint x = (uint)left; x < (uint)(left + width); x += 8) { byte b = Unsafe.Add(ref dataRef, offset++); - nint maxShift = Math.Min(left + width - x, 8); + nuint maxShift = Math.Min((uint)(left + width) - x, 8); if (maxShift == 8) { @@ -70,7 +70,7 @@ public override void Decode(ReadOnlySpan data, Buffer2D pixels, in } else { - for (nint shift = 0; shift < maxShift; shift++) + for (nuint shift = 0; shift < maxShift; shift++) { int bit = (b >> (7 - (int)shift)) & 1; diff --git a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/WhiteIsZero1TiffColor{TPixel}.cs b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/WhiteIsZero1TiffColor{TPixel}.cs index 737f957676..c5b662979e 100644 --- a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/WhiteIsZero1TiffColor{TPixel}.cs +++ b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/WhiteIsZero1TiffColor{TPixel}.cs @@ -17,21 +17,21 @@ internal class WhiteIsZero1TiffColor : TiffBaseColorDecoder /// public override void Decode(ReadOnlySpan data, Buffer2D pixels, int left, int top, int width, int height) { - nint offset = 0; + nuint offset = 0; var colorBlack = default(TPixel); var colorWhite = default(TPixel); colorBlack.FromRgba32(Color.Black); colorWhite.FromRgba32(Color.White); ref byte dataRef = ref MemoryMarshal.GetReference(data); - for (nint y = top; y < (nint)(uint)(top + height); y++) + for (nuint y = (uint)top; y < (uint)(top + height); y++) { Span pixelRowSpan = pixels.DangerousGetRowSpan((int)y); ref TPixel pixelRowRef = ref MemoryMarshal.GetReference(pixelRowSpan); - for (nint x = left; x < (nint)(uint)(left + width); x += 8) + for (nuint x = (uint)left; x < (uint)(left + width); x += 8) { byte b = Unsafe.Add(ref dataRef, offset++); - nint maxShift = Math.Min(left + width - x, 8); + nuint maxShift = Math.Min((uint)(left + width) - x, 8); if (maxShift == 8) { @@ -69,11 +69,11 @@ public override void Decode(ReadOnlySpan data, Buffer2D pixels, in } else { - for (int shift = 0; shift < maxShift; shift++) + for (nuint shift = 0; shift < maxShift; shift++) { - int bit = (b >> (7 - shift)) & 1; + int bit = (b >> (7 - (int)shift)) & 1; - ref TPixel pixel = ref Unsafe.Add(ref pixelRowRef, x + (nint)(uint)shift); + ref TPixel pixel = ref Unsafe.Add(ref pixelRowRef, x + shift); pixel = bit == 0 ? colorWhite : colorBlack; } } diff --git a/src/ImageSharp/Formats/Tiff/TiffDecoderCore.cs b/src/ImageSharp/Formats/Tiff/TiffDecoderCore.cs index 4499c55833..45bbed12d5 100644 --- a/src/ImageSharp/Formats/Tiff/TiffDecoderCore.cs +++ b/src/ImageSharp/Formats/Tiff/TiffDecoderCore.cs @@ -793,7 +793,7 @@ private int CalculateStripBufferSize(int width, int height, int plane = -1) } } - int bytesPerRow = (int)(((uint)(width * bitsPerPixel) + 7) / 8); + int bytesPerRow = ((width * bitsPerPixel) + 7) / 8; return bytesPerRow * height; } diff --git a/src/ImageSharp/Formats/Webp/AlphaDecoder.cs b/src/ImageSharp/Formats/Webp/AlphaDecoder.cs index 2678a6f70f..289ebd35ca 100644 --- a/src/ImageSharp/Formats/Webp/AlphaDecoder.cs +++ b/src/ImageSharp/Formats/Webp/AlphaDecoder.cs @@ -319,7 +319,7 @@ private static void HorizontalUnfilter(Span prev, Span input, Span last = Vector128.Zero.WithElement(0, dst[0]); ref byte srcRef = ref MemoryMarshal.GetReference(input); ref byte dstRef = ref MemoryMarshal.GetReference(dst); @@ -365,20 +365,24 @@ private static void VerticalUnfilter(Span prev, Span input, Span a0 = Unsafe.As>(ref Unsafe.Add(ref MemoryMarshal.GetReference(input), i)); - Vector256 b0 = Unsafe.As>(ref Unsafe.Add(ref MemoryMarshal.GetReference(prev), i)); + Vector256 a0 = Unsafe.As>(ref Unsafe.Add(ref inputRef, i)); + Vector256 b0 = Unsafe.As>(ref Unsafe.Add(ref prevRef, i)); Vector256 c0 = Avx2.Add(a0.AsByte(), b0.AsByte()); - ref byte outputRef = ref Unsafe.Add(ref MemoryMarshal.GetReference(dst), i); + ref byte outputRef = ref Unsafe.Add(ref dstRef, i); Unsafe.As>(ref outputRef) = c0; } for (; i < (uint)width; i++) { - dst[(int)i] = (byte)(prev[(int)i] + input[(int)i]); + Unsafe.Add(ref dstRef, i) = (byte)(Unsafe.Add(ref prevRef, i) + Unsafe.Add(ref inputRef, i)); } } else diff --git a/src/ImageSharp/Formats/Webp/Lossless/ColorSpaceTransformUtils.cs b/src/ImageSharp/Formats/Webp/Lossless/ColorSpaceTransformUtils.cs index 45de1b9553..9a6dfb66e8 100644 --- a/src/ImageSharp/Formats/Webp/Lossless/ColorSpaceTransformUtils.cs +++ b/src/ImageSharp/Formats/Webp/Lossless/ColorSpaceTransformUtils.cs @@ -27,10 +27,10 @@ public static void CollectColorBlueTransforms(Span bgra, int stride, int t { Span srcSpan = bgra[(y * stride)..]; ref uint inputRef = ref MemoryMarshal.GetReference(srcSpan); - for (nint x = 0; x <= tileWidth - span; x += span) + for (nuint x = 0; x <= (uint)tileWidth - span; x += span) { - nint input0Idx = x; - nint input1Idx = x + (span / 2); + nuint input0Idx = x; + nuint input1Idx = x + (span / 2); Vector256 input0 = Unsafe.As>(ref Unsafe.Add(ref inputRef, input0Idx)).AsByte(); Vector256 input1 = Unsafe.As>(ref Unsafe.Add(ref inputRef, input1Idx)).AsByte(); Vector256 r0 = Avx2.Shuffle(input0, collectColorBlueTransformsShuffleLowMask256); @@ -77,10 +77,10 @@ public static void CollectColorBlueTransforms(Span bgra, int stride, int t { Span srcSpan = bgra[(y * stride)..]; ref uint inputRef = ref MemoryMarshal.GetReference(srcSpan); - for (nint x = 0; x <= tileWidth - span; x += span) + for (nuint x = 0; (int)x <= tileWidth - span; x += span) { - nint input0Idx = x; - nint input1Idx = x + (span / 2); + nuint input0Idx = x; + nuint input1Idx = x + (span / 2); Vector128 input0 = Unsafe.As>(ref Unsafe.Add(ref inputRef, input0Idx)).AsByte(); Vector128 input1 = Unsafe.As>(ref Unsafe.Add(ref inputRef, input1Idx)).AsByte(); Vector128 r0 = Ssse3.Shuffle(input0, collectColorBlueTransformsShuffleLowMask); @@ -146,10 +146,10 @@ public static void CollectColorRedTransforms(Span bgra, int stride, int ti { Span srcSpan = bgra[(y * stride)..]; ref uint inputRef = ref MemoryMarshal.GetReference(srcSpan); - for (nint x = 0; x <= tileWidth - span; x += span) + for (nuint x = 0; x <= (uint)tileWidth - span; x += span) { - nint input0Idx = x; - nint input1Idx = x + (span / 2); + nuint input0Idx = x; + nuint input1Idx = x + (span / 2); Vector256 input0 = Unsafe.As>(ref Unsafe.Add(ref inputRef, input0Idx)).AsByte(); Vector256 input1 = Unsafe.As>(ref Unsafe.Add(ref inputRef, input1Idx)).AsByte(); Vector256 g0 = Avx2.And(input0, collectColorRedTransformsGreenMask256); // 0 0 | g 0 @@ -189,10 +189,10 @@ public static void CollectColorRedTransforms(Span bgra, int stride, int ti { Span srcSpan = bgra[(y * stride)..]; ref uint inputRef = ref MemoryMarshal.GetReference(srcSpan); - for (nint x = 0; x <= tileWidth - span; x += span) + for (nuint x = 0; (int)x <= tileWidth - span; x += span) { - nint input0Idx = x; - nint input1Idx = x + (span / 2); + nuint input0Idx = x; + nuint input1Idx = x + (span / 2); Vector128 input0 = Unsafe.As>(ref Unsafe.Add(ref inputRef, input0Idx)).AsByte(); Vector128 input1 = Unsafe.As>(ref Unsafe.Add(ref inputRef, input1Idx)).AsByte(); Vector128 g0 = Sse2.And(input0, collectColorRedTransformsGreenMask); // 0 0 | g 0 diff --git a/src/ImageSharp/Formats/Webp/Lossless/LosslessUtils.cs b/src/ImageSharp/Formats/Webp/Lossless/LosslessUtils.cs index 5a8137754b..05b6001c91 100644 --- a/src/ImageSharp/Formats/Webp/Lossless/LosslessUtils.cs +++ b/src/ImageSharp/Formats/Webp/Lossless/LosslessUtils.cs @@ -94,49 +94,53 @@ public static int PrefixEncode(int distance, ref int extraBits, ref int extraBit /// The pixel data to apply the transformation. public static void AddGreenToBlueAndRed(Span pixelData) { - if (Avx2.IsSupported) + if (Avx2.IsSupported && pixelData.Length >= 8) { Vector256 addGreenToBlueAndRedMaskAvx2 = Vector256.Create(1, 255, 1, 255, 5, 255, 5, 255, 9, 255, 9, 255, 13, 255, 13, 255, 17, 255, 17, 255, 21, 255, 21, 255, 25, 255, 25, 255, 29, 255, 29, 255); - int numPixels = pixelData.Length; - nint i; - for (i = 0; i <= (nint)(uint)numPixels - 8; i += 8) + nuint numPixels = (uint)pixelData.Length; + nuint i = 0; + do { ref uint pos = ref Unsafe.Add(ref MemoryMarshal.GetReference(pixelData), i); Vector256 input = Unsafe.As>(ref pos).AsByte(); Vector256 in0g0g = Avx2.Shuffle(input, addGreenToBlueAndRedMaskAvx2); Vector256 output = Avx2.Add(input, in0g0g); Unsafe.As>(ref pos) = output.AsUInt32(); + i += 8; } + while (i <= numPixels - 8); if (i != numPixels) { AddGreenToBlueAndRedScalar(pixelData[(int)i..]); } } - else if (Ssse3.IsSupported) + else if (Ssse3.IsSupported && pixelData.Length >= 4) { Vector128 addGreenToBlueAndRedMaskSsse3 = Vector128.Create(1, 255, 1, 255, 5, 255, 5, 255, 9, 255, 9, 255, 13, 255, 13, 255); - int numPixels = pixelData.Length; - nint i; - for (i = 0; i <= (nint)(uint)numPixels - 4; i += 4) + nuint numPixels = (uint)pixelData.Length; + nuint i = 0; + do { ref uint pos = ref Unsafe.Add(ref MemoryMarshal.GetReference(pixelData), i); Vector128 input = Unsafe.As>(ref pos).AsByte(); Vector128 in0g0g = Ssse3.Shuffle(input, addGreenToBlueAndRedMaskSsse3); Vector128 output = Sse2.Add(input, in0g0g); Unsafe.As>(ref pos) = output.AsUInt32(); + i += 4; } + while (i <= numPixels - 4); if (i != numPixels) { AddGreenToBlueAndRedScalar(pixelData[(int)i..]); } } - else if (Sse2.IsSupported) + else if (Sse2.IsSupported && pixelData.Length >= 4) { - int numPixels = pixelData.Length; - nint i; - for (i = 0; i <= (nint)(uint)numPixels - 4; i += 4) + nuint numPixels = (uint)pixelData.Length; + nuint i = 0; + do { ref uint pos = ref Unsafe.Add(ref MemoryMarshal.GetReference(pixelData), i); Vector128 input = Unsafe.As>(ref pos).AsByte(); @@ -145,7 +149,9 @@ public static void AddGreenToBlueAndRed(Span pixelData) Vector128 c = Sse2.ShuffleHigh(b, SimdUtils.Shuffle.MMShuffle2200); // 0g0g Vector128 output = Sse2.Add(input.AsByte(), c.AsByte()); Unsafe.As>(ref pos) = output.AsUInt32(); + i += 4; } + while (i <= numPixels - 4); if (i != numPixels) { @@ -174,49 +180,53 @@ private static void AddGreenToBlueAndRedScalar(Span pixelData) public static void SubtractGreenFromBlueAndRed(Span pixelData) { - if (Avx2.IsSupported) + if (Avx2.IsSupported && pixelData.Length >= 8) { Vector256 subtractGreenFromBlueAndRedMaskAvx2 = Vector256.Create(1, 255, 1, 255, 5, 255, 5, 255, 9, 255, 9, 255, 13, 255, 13, 255, 17, 255, 17, 255, 21, 255, 21, 255, 25, 255, 25, 255, 29, 255, 29, 255); - int numPixels = pixelData.Length; - nint i; - for (i = 0; i <= (nint)(uint)numPixels - 8; i += 8) + nuint numPixels = (uint)pixelData.Length; + nuint i = 0; + do { ref uint pos = ref Unsafe.Add(ref MemoryMarshal.GetReference(pixelData), i); Vector256 input = Unsafe.As>(ref pos).AsByte(); Vector256 in0g0g = Avx2.Shuffle(input, subtractGreenFromBlueAndRedMaskAvx2); Vector256 output = Avx2.Subtract(input, in0g0g); Unsafe.As>(ref pos) = output.AsUInt32(); + i += 8; } + while (i <= numPixels - 8); if (i != numPixels) { SubtractGreenFromBlueAndRedScalar(pixelData[(int)i..]); } } - else if (Ssse3.IsSupported) + else if (Ssse3.IsSupported && pixelData.Length >= 4) { Vector128 subtractGreenFromBlueAndRedMaskSsse3 = Vector128.Create(1, 255, 1, 255, 5, 255, 5, 255, 9, 255, 9, 255, 13, 255, 13, 255); - int numPixels = pixelData.Length; - nint i; - for (i = 0; i <= (nint)(uint)numPixels - 4; i += 4) + nuint numPixels = (uint)pixelData.Length; + nuint i = 0; + do { ref uint pos = ref Unsafe.Add(ref MemoryMarshal.GetReference(pixelData), i); Vector128 input = Unsafe.As>(ref pos).AsByte(); Vector128 in0g0g = Ssse3.Shuffle(input, subtractGreenFromBlueAndRedMaskSsse3); Vector128 output = Sse2.Subtract(input, in0g0g); Unsafe.As>(ref pos) = output.AsUInt32(); + i += 4; } + while (i <= numPixels - 4); if (i != numPixels) { SubtractGreenFromBlueAndRedScalar(pixelData[(int)i..]); } } - else if (Sse2.IsSupported) + else if (Sse2.IsSupported && pixelData.Length >= 4) { - int numPixels = pixelData.Length; - nint i; - for (i = 0; i <= (nint)(uint)numPixels - 4; i += 4) + nuint numPixels = (uint)pixelData.Length; + nuint i = 0; + do { ref uint pos = ref Unsafe.Add(ref MemoryMarshal.GetReference(pixelData), i); Vector128 input = Unsafe.As>(ref pos).AsByte(); @@ -225,7 +235,9 @@ public static void SubtractGreenFromBlueAndRed(Span pixelData) Vector128 c = Sse2.ShuffleHigh(b, SimdUtils.Shuffle.MMShuffle2200); // 0g0g Vector128 output = Sse2.Subtract(input.AsByte(), c.AsByte()); Unsafe.As>(ref pos) = output.AsUInt32(); + i += 4; } + while (i <= numPixels - 4); if (i != numPixels) { @@ -372,8 +384,8 @@ public static void TransformColor(Vp8LMultipliers m, Span pixelData, int n Vector256 multsrb = MkCst32(Cst5b(m.GreenToRed), Cst5b(m.GreenToBlue)); Vector256 multsb2 = MkCst32(Cst5b(m.RedToBlue), 0); - nint idx; - for (idx = 0; idx <= (nint)(uint)numPixels - 8; idx += 8) + nuint idx = 0; + do { ref uint pos = ref Unsafe.Add(ref MemoryMarshal.GetReference(pixelData), idx); Vector256 input = Unsafe.As>(ref pos); @@ -388,21 +400,23 @@ public static void TransformColor(Vp8LMultipliers m, Span pixelData, int n Vector256 i = Avx2.And(h, transformColorRedBlueMask256); Vector256 output = Avx2.Subtract(input.AsByte(), i); Unsafe.As>(ref pos) = output.AsUInt32(); + idx += 8; } + while (idx <= (uint)numPixels - 8); - if (idx != numPixels) + if (idx != (uint)numPixels) { TransformColorScalar(m, pixelData[(int)idx..], numPixels - (int)idx); } } - else if (Sse2.IsSupported) + else if (Sse2.IsSupported && numPixels >= 4) { Vector128 transformColorAlphaGreenMask = Vector128.Create(0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255); Vector128 transformColorRedBlueMask = Vector128.Create(255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0); Vector128 multsrb = MkCst16(Cst5b(m.GreenToRed), Cst5b(m.GreenToBlue)); Vector128 multsb2 = MkCst16(Cst5b(m.RedToBlue), 0); - nint idx; - for (idx = 0; idx <= (nint)(uint)numPixels - 4; idx += 4) + nuint idx = 0; + do { ref uint pos = ref Unsafe.Add(ref MemoryMarshal.GetReference(pixelData), idx); Vector128 input = Unsafe.As>(ref pos); @@ -417,9 +431,11 @@ public static void TransformColor(Vp8LMultipliers m, Span pixelData, int n Vector128 i = Sse2.And(h, transformColorRedBlueMask); Vector128 output = Sse2.Subtract(input.AsByte(), i); Unsafe.As>(ref pos) = output.AsUInt32(); + idx += 4; } + while ((int)idx <= numPixels - 4); - if (idx != numPixels) + if ((int)idx != numPixels) { TransformColorScalar(m, pixelData[(int)idx..], numPixels - (int)idx); } @@ -460,8 +476,8 @@ public static void TransformColorInverse(Vp8LMultipliers m, Span pixelData Vector256 transformColorInverseAlphaGreenMask256 = Vector256.Create(0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255); Vector256 multsrb = MkCst32(Cst5b(m.GreenToRed), Cst5b(m.GreenToBlue)); Vector256 multsb2 = MkCst32(Cst5b(m.RedToBlue), 0); - nint idx; - for (idx = 0; idx <= (nint)(uint)pixelData.Length - 8; idx += 8) + nuint idx; + for (idx = 0; idx <= (uint)pixelData.Length - 8; idx += 8) { ref uint pos = ref Unsafe.Add(ref MemoryMarshal.GetReference(pixelData), idx); Vector256 input = Unsafe.As>(ref pos); @@ -479,19 +495,19 @@ public static void TransformColorInverse(Vp8LMultipliers m, Span pixelData Unsafe.As>(ref pos) = output.AsUInt32(); } - if (idx != pixelData.Length) + if (idx != (uint)pixelData.Length) { TransformColorInverseScalar(m, pixelData[(int)idx..]); } } - else if (Sse2.IsSupported) + else if (Sse2.IsSupported && pixelData.Length >= 4) { Vector128 transformColorInverseAlphaGreenMask = Vector128.Create(0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255); Vector128 multsrb = MkCst16(Cst5b(m.GreenToRed), Cst5b(m.GreenToBlue)); Vector128 multsb2 = MkCst16(Cst5b(m.RedToBlue), 0); - nint idx; - for (idx = 0; idx <= (nint)(uint)pixelData.Length - 4; idx += 4) + nuint idx; + for (idx = 0; idx <= (uint)pixelData.Length - 4; idx += 4) { ref uint pos = ref Unsafe.Add(ref MemoryMarshal.GetReference(pixelData), idx); Vector128 input = Unsafe.As>(ref pos); @@ -509,7 +525,7 @@ public static void TransformColorInverse(Vp8LMultipliers m, Span pixelData Unsafe.As>(ref pos) = output.AsUInt32(); } - if (idx != pixelData.Length) + if (idx != (uint)pixelData.Length) { TransformColorInverseScalar(m, pixelData[(int)idx..]); } @@ -740,7 +756,7 @@ public static float CombinedShannonEntropy(Span x, Span y) Vector256 sumXY256 = Vector256.Zero; Vector256 sumX256 = Vector256.Zero; ref int tmpRef = ref Unsafe.As, int>(ref tmp); - for (nint i = 0; i < 256; i += 8) + for (nuint i = 0; i < 256; i += 8) { Vector256 xVec = Unsafe.As>(ref Unsafe.Add(ref xRef, i)); Vector256 yVec = Unsafe.As>(ref Unsafe.Add(ref yRef, i)); diff --git a/src/ImageSharp/Formats/Webp/Lossless/Vp8LHistogram.cs b/src/ImageSharp/Formats/Webp/Lossless/Vp8LHistogram.cs index 3f44a1bc05..3df979f96b 100644 --- a/src/ImageSharp/Formats/Webp/Lossless/Vp8LHistogram.cs +++ b/src/ImageSharp/Formats/Webp/Lossless/Vp8LHistogram.cs @@ -518,9 +518,9 @@ private static void AddVector(Span a, Span b, Span output, int ref uint aRef = ref MemoryMarshal.GetReference(a); ref uint bRef = ref MemoryMarshal.GetReference(b); ref uint outputRef = ref MemoryMarshal.GetReference(output); - nint idx; + nuint idx; - for (idx = 0; idx <= (nint)(uint)count - 32; idx += 32) + for (idx = 0; idx <= (uint)count - 32; idx += 32) { // Load values. Vector256 a0 = Unsafe.As>(ref Unsafe.Add(ref aRef, idx)); diff --git a/src/ImageSharp/Formats/Webp/Lossy/LossyUtils.cs b/src/ImageSharp/Formats/Webp/Lossy/LossyUtils.cs index 2dc2881b03..de3f1586af 100644 --- a/src/ImageSharp/Formats/Webp/Lossy/LossyUtils.cs +++ b/src/ImageSharp/Formats/Webp/Lossy/LossyUtils.cs @@ -161,7 +161,7 @@ public static int Vp8_SseNxN(Span a, Span b, int w, int h) private static int Vp8_Sse16xN_Sse2(Span a, Span b, int numPairs) { Vector128 sum = Vector128.Zero; - nint offset = 0; + nuint offset = 0; ref byte aRef = ref MemoryMarshal.GetReference(a); ref byte bRef = ref MemoryMarshal.GetReference(b); for (int i = 0; i < numPairs; i++) @@ -186,7 +186,7 @@ private static int Vp8_Sse16xN_Sse2(Span a, Span b, int numPairs) private static int Vp8_Sse16xN_Avx2(Span a, Span b, int numPairs) { Vector256 sum = Vector256.Zero; - nint offset = 0; + nuint offset = 0; ref byte aRef = ref MemoryMarshal.GetReference(a); ref byte bRef = ref MemoryMarshal.GetReference(b); for (int i = 0; i < numPairs; i++) @@ -2278,8 +2278,8 @@ private static void Load16x4(ref byte r0, ref byte r8, int stride, out Vector128 // q0 = 73 63 53 43 33 23 13 03 72 62 52 42 32 22 12 02 // p0 = f1 e1 d1 c1 b1 a1 91 81 f0 e0 d0 c0 b0 a0 90 80 // q1 = f3 e3 d3 c3 b3 a3 93 83 f2 e2 d2 c2 b2 a2 92 82 - Load8x4(ref r0, (nint)(uint)stride, out Vector128 t1, out Vector128 t2); - Load8x4(ref r8, (nint)(uint)stride, out p0, out q1); + Load8x4(ref r0, (uint)stride, out Vector128 t1, out Vector128 t2); + Load8x4(ref r8, (uint)stride, out p0, out q1); // p1 = f0 e0 d0 c0 b0 a0 90 80 70 60 50 40 30 20 10 00 // p0 = f1 e1 d1 c1 b1 a1 91 81 71 61 51 41 31 21 11 01 @@ -2292,7 +2292,7 @@ private static void Load16x4(ref byte r0, ref byte r8, int stride, out Vector128 } // Reads 8 rows across a vertical edge. - private static void Load8x4(ref byte bRef, nint stride, out Vector128 p, out Vector128 q) + private static void Load8x4(ref byte bRef, nuint stride, out Vector128 p, out Vector128 q) { // A0 = 63 62 61 60 23 22 21 20 43 42 41 40 03 02 01 00 // A1 = 73 72 71 70 33 32 31 30 53 52 51 50 13 12 11 10 diff --git a/src/ImageSharp/Formats/Webp/Lossy/QuantEnc.cs b/src/ImageSharp/Formats/Webp/Lossy/QuantEnc.cs index 75b92a1aaa..76de2e8f4a 100644 --- a/src/ImageSharp/Formats/Webp/Lossy/QuantEnc.cs +++ b/src/ImageSharp/Formats/Webp/Lossy/QuantEnc.cs @@ -770,7 +770,7 @@ private static bool IsFlatSource16(Span src) { uint v = src[0] * 0x01010101u; Span vSpan = BitConverter.GetBytes(v).AsSpan(); - for (nint i = 0; i < 16; i++) + for (nuint i = 0; i < 16; i++) { if (!src[..4].SequenceEqual(vSpan) || !src.Slice(4, 4).SequenceEqual(vSpan) || !src.Slice(8, 4).SequenceEqual(vSpan) || !src.Slice(12, 4).SequenceEqual(vSpan)) @@ -789,10 +789,10 @@ private static bool IsFlat(Span levels, int numBlocks, int thresh) { int score = 0; ref short levelsRef = ref MemoryMarshal.GetReference(levels); - nint offset = 0; + nuint offset = 0; while (numBlocks-- > 0) { - for (nint i = 1; i < 16; i++) + for (nuint i = 1; i < 16; i++) { // omit DC, we're only interested in AC score += Unsafe.Add(ref levelsRef, offset) != 0 ? 1 : 0; diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Abgr32.PixelOperations.Generated.cs b/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Abgr32.PixelOperations.Generated.cs index 9fca0cdc35..f24ed6fae8 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Abgr32.PixelOperations.Generated.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Abgr32.PixelOperations.Generated.cs @@ -57,7 +57,7 @@ public override void ToVector4( { Vector4Converters.RgbaCompatible.ToVector4(configuration, this, sourcePixels, destVectors, modifiers.Remove(PixelConversionModifiers.Scale)); } - + /// public override void ToRgba32( Configuration configuration, @@ -71,7 +71,7 @@ public override void ToRgba32( Span dest = MemoryMarshal.Cast(destinationPixels); PixelConverter.FromAbgr32.ToRgba32(source, dest); } - + /// public override void FromRgba32( Configuration configuration, @@ -84,8 +84,8 @@ public override void FromRgba32( ReadOnlySpan source = MemoryMarshal.Cast(sourcePixels); Span dest = MemoryMarshal.Cast(destinationPixels); PixelConverter.FromRgba32.ToAbgr32(source, dest); - } - + } + /// public override void ToArgb32( Configuration configuration, @@ -99,7 +99,7 @@ public override void ToArgb32( Span dest = MemoryMarshal.Cast(destinationPixels); PixelConverter.FromAbgr32.ToArgb32(source, dest); } - + /// public override void FromArgb32( Configuration configuration, @@ -112,8 +112,8 @@ public override void FromArgb32( ReadOnlySpan source = MemoryMarshal.Cast(sourcePixels); Span dest = MemoryMarshal.Cast(destinationPixels); PixelConverter.FromArgb32.ToAbgr32(source, dest); - } - + } + /// public override void ToBgra32( Configuration configuration, @@ -127,7 +127,7 @@ public override void ToBgra32( Span dest = MemoryMarshal.Cast(destinationPixels); PixelConverter.FromAbgr32.ToBgra32(source, dest); } - + /// public override void FromBgra32( Configuration configuration, @@ -140,8 +140,8 @@ public override void FromBgra32( ReadOnlySpan source = MemoryMarshal.Cast(sourcePixels); Span dest = MemoryMarshal.Cast(destinationPixels); PixelConverter.FromBgra32.ToAbgr32(source, dest); - } - + } + /// public override void ToRgb24( Configuration configuration, @@ -155,7 +155,7 @@ public override void ToRgb24( Span dest = MemoryMarshal.Cast(destinationPixels); PixelConverter.FromAbgr32.ToRgb24(source, dest); } - + /// public override void FromRgb24( Configuration configuration, @@ -168,8 +168,8 @@ public override void FromRgb24( ReadOnlySpan source = MemoryMarshal.Cast(sourcePixels); Span dest = MemoryMarshal.Cast(destinationPixels); PixelConverter.FromRgb24.ToAbgr32(source, dest); - } - + } + /// public override void ToBgr24( Configuration configuration, @@ -183,7 +183,7 @@ public override void ToBgr24( Span dest = MemoryMarshal.Cast(destinationPixels); PixelConverter.FromAbgr32.ToBgr24(source, dest); } - + /// public override void FromBgr24( Configuration configuration, @@ -196,7 +196,7 @@ public override void FromBgr24( ReadOnlySpan source = MemoryMarshal.Cast(sourcePixels); Span dest = MemoryMarshal.Cast(destinationPixels); PixelConverter.FromBgr24.ToAbgr32(source, dest); - } + } /// public override void ToL8( @@ -210,7 +210,7 @@ public override void ToL8( ref Abgr32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref L8 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref Abgr32 sp = ref Unsafe.Add(ref sourceRef, i); ref L8 dp = ref Unsafe.Add(ref destRef, i); @@ -231,7 +231,7 @@ public override void ToL16( ref Abgr32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref L16 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref Abgr32 sp = ref Unsafe.Add(ref sourceRef, i); ref L16 dp = ref Unsafe.Add(ref destRef, i); @@ -252,7 +252,7 @@ public override void ToLa16( ref Abgr32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref La16 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref Abgr32 sp = ref Unsafe.Add(ref sourceRef, i); ref La16 dp = ref Unsafe.Add(ref destRef, i); @@ -273,7 +273,7 @@ public override void ToLa32( ref Abgr32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref La32 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref Abgr32 sp = ref Unsafe.Add(ref sourceRef, i); ref La32 dp = ref Unsafe.Add(ref destRef, i); @@ -294,7 +294,7 @@ public override void ToRgb48( ref Abgr32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Rgb48 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref Abgr32 sp = ref Unsafe.Add(ref sourceRef, i); ref Rgb48 dp = ref Unsafe.Add(ref destRef, i); @@ -315,7 +315,7 @@ public override void ToRgba64( ref Abgr32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Rgba64 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref Abgr32 sp = ref Unsafe.Add(ref sourceRef, i); ref Rgba64 dp = ref Unsafe.Add(ref destRef, i); @@ -336,7 +336,7 @@ public override void ToBgra5551( ref Abgr32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Bgra5551 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref Abgr32 sp = ref Unsafe.Add(ref sourceRef, i); ref Bgra5551 dp = ref Unsafe.Add(ref destRef, i); diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Argb32.PixelOperations.Generated.cs b/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Argb32.PixelOperations.Generated.cs index e87926be8b..37ac39a851 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Argb32.PixelOperations.Generated.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Argb32.PixelOperations.Generated.cs @@ -57,7 +57,7 @@ public override void ToVector4( { Vector4Converters.RgbaCompatible.ToVector4(configuration, this, sourcePixels, destVectors, modifiers.Remove(PixelConversionModifiers.Scale)); } - + /// public override void ToRgba32( Configuration configuration, @@ -71,7 +71,7 @@ public override void ToRgba32( Span dest = MemoryMarshal.Cast(destinationPixels); PixelConverter.FromArgb32.ToRgba32(source, dest); } - + /// public override void FromRgba32( Configuration configuration, @@ -84,8 +84,8 @@ public override void FromRgba32( ReadOnlySpan source = MemoryMarshal.Cast(sourcePixels); Span dest = MemoryMarshal.Cast(destinationPixels); PixelConverter.FromRgba32.ToArgb32(source, dest); - } - + } + /// public override void ToAbgr32( Configuration configuration, @@ -99,7 +99,7 @@ public override void ToAbgr32( Span dest = MemoryMarshal.Cast(destinationPixels); PixelConverter.FromArgb32.ToAbgr32(source, dest); } - + /// public override void FromAbgr32( Configuration configuration, @@ -112,8 +112,8 @@ public override void FromAbgr32( ReadOnlySpan source = MemoryMarshal.Cast(sourcePixels); Span dest = MemoryMarshal.Cast(destinationPixels); PixelConverter.FromAbgr32.ToArgb32(source, dest); - } - + } + /// public override void ToBgra32( Configuration configuration, @@ -127,7 +127,7 @@ public override void ToBgra32( Span dest = MemoryMarshal.Cast(destinationPixels); PixelConverter.FromArgb32.ToBgra32(source, dest); } - + /// public override void FromBgra32( Configuration configuration, @@ -140,8 +140,8 @@ public override void FromBgra32( ReadOnlySpan source = MemoryMarshal.Cast(sourcePixels); Span dest = MemoryMarshal.Cast(destinationPixels); PixelConverter.FromBgra32.ToArgb32(source, dest); - } - + } + /// public override void ToRgb24( Configuration configuration, @@ -155,7 +155,7 @@ public override void ToRgb24( Span dest = MemoryMarshal.Cast(destinationPixels); PixelConverter.FromArgb32.ToRgb24(source, dest); } - + /// public override void FromRgb24( Configuration configuration, @@ -168,8 +168,8 @@ public override void FromRgb24( ReadOnlySpan source = MemoryMarshal.Cast(sourcePixels); Span dest = MemoryMarshal.Cast(destinationPixels); PixelConverter.FromRgb24.ToArgb32(source, dest); - } - + } + /// public override void ToBgr24( Configuration configuration, @@ -183,7 +183,7 @@ public override void ToBgr24( Span dest = MemoryMarshal.Cast(destinationPixels); PixelConverter.FromArgb32.ToBgr24(source, dest); } - + /// public override void FromBgr24( Configuration configuration, @@ -196,7 +196,7 @@ public override void FromBgr24( ReadOnlySpan source = MemoryMarshal.Cast(sourcePixels); Span dest = MemoryMarshal.Cast(destinationPixels); PixelConverter.FromBgr24.ToArgb32(source, dest); - } + } /// public override void ToL8( @@ -210,7 +210,7 @@ public override void ToL8( ref Argb32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref L8 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref Argb32 sp = ref Unsafe.Add(ref sourceRef, i); ref L8 dp = ref Unsafe.Add(ref destRef, i); @@ -231,7 +231,7 @@ public override void ToL16( ref Argb32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref L16 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref Argb32 sp = ref Unsafe.Add(ref sourceRef, i); ref L16 dp = ref Unsafe.Add(ref destRef, i); @@ -252,7 +252,7 @@ public override void ToLa16( ref Argb32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref La16 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref Argb32 sp = ref Unsafe.Add(ref sourceRef, i); ref La16 dp = ref Unsafe.Add(ref destRef, i); @@ -273,7 +273,7 @@ public override void ToLa32( ref Argb32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref La32 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref Argb32 sp = ref Unsafe.Add(ref sourceRef, i); ref La32 dp = ref Unsafe.Add(ref destRef, i); @@ -294,7 +294,7 @@ public override void ToRgb48( ref Argb32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Rgb48 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref Argb32 sp = ref Unsafe.Add(ref sourceRef, i); ref Rgb48 dp = ref Unsafe.Add(ref destRef, i); @@ -315,7 +315,7 @@ public override void ToRgba64( ref Argb32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Rgba64 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref Argb32 sp = ref Unsafe.Add(ref sourceRef, i); ref Rgba64 dp = ref Unsafe.Add(ref destRef, i); @@ -336,7 +336,7 @@ public override void ToBgra5551( ref Argb32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Bgra5551 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref Argb32 sp = ref Unsafe.Add(ref sourceRef, i); ref Bgra5551 dp = ref Unsafe.Add(ref destRef, i); diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Bgr24.PixelOperations.Generated.cs b/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Bgr24.PixelOperations.Generated.cs index 32eed0ce40..f604d6f970 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Bgr24.PixelOperations.Generated.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Bgr24.PixelOperations.Generated.cs @@ -57,7 +57,7 @@ public override void ToVector4( { Vector4Converters.RgbaCompatible.ToVector4(configuration, this, sourcePixels, destVectors, modifiers.Remove(PixelConversionModifiers.Scale | PixelConversionModifiers.Premultiply)); } - + /// public override void ToRgba32( Configuration configuration, @@ -71,7 +71,7 @@ public override void ToRgba32( Span dest = MemoryMarshal.Cast(destinationPixels); PixelConverter.FromBgr24.ToRgba32(source, dest); } - + /// public override void FromRgba32( Configuration configuration, @@ -84,8 +84,8 @@ public override void FromRgba32( ReadOnlySpan source = MemoryMarshal.Cast(sourcePixels); Span dest = MemoryMarshal.Cast(destinationPixels); PixelConverter.FromRgba32.ToBgr24(source, dest); - } - + } + /// public override void ToArgb32( Configuration configuration, @@ -99,7 +99,7 @@ public override void ToArgb32( Span dest = MemoryMarshal.Cast(destinationPixels); PixelConverter.FromBgr24.ToArgb32(source, dest); } - + /// public override void FromArgb32( Configuration configuration, @@ -112,8 +112,8 @@ public override void FromArgb32( ReadOnlySpan source = MemoryMarshal.Cast(sourcePixels); Span dest = MemoryMarshal.Cast(destinationPixels); PixelConverter.FromArgb32.ToBgr24(source, dest); - } - + } + /// public override void ToAbgr32( Configuration configuration, @@ -127,7 +127,7 @@ public override void ToAbgr32( Span dest = MemoryMarshal.Cast(destinationPixels); PixelConverter.FromBgr24.ToAbgr32(source, dest); } - + /// public override void FromAbgr32( Configuration configuration, @@ -140,8 +140,8 @@ public override void FromAbgr32( ReadOnlySpan source = MemoryMarshal.Cast(sourcePixels); Span dest = MemoryMarshal.Cast(destinationPixels); PixelConverter.FromAbgr32.ToBgr24(source, dest); - } - + } + /// public override void ToBgra32( Configuration configuration, @@ -155,7 +155,7 @@ public override void ToBgra32( Span dest = MemoryMarshal.Cast(destinationPixels); PixelConverter.FromBgr24.ToBgra32(source, dest); } - + /// public override void FromBgra32( Configuration configuration, @@ -168,8 +168,8 @@ public override void FromBgra32( ReadOnlySpan source = MemoryMarshal.Cast(sourcePixels); Span dest = MemoryMarshal.Cast(destinationPixels); PixelConverter.FromBgra32.ToBgr24(source, dest); - } - + } + /// public override void ToRgb24( Configuration configuration, @@ -183,7 +183,7 @@ public override void ToRgb24( Span dest = MemoryMarshal.Cast(destinationPixels); PixelConverter.FromBgr24.ToRgb24(source, dest); } - + /// public override void FromRgb24( Configuration configuration, @@ -196,7 +196,7 @@ public override void FromRgb24( ReadOnlySpan source = MemoryMarshal.Cast(sourcePixels); Span dest = MemoryMarshal.Cast(destinationPixels); PixelConverter.FromRgb24.ToBgr24(source, dest); - } + } /// public override void ToL8( @@ -210,7 +210,7 @@ public override void ToL8( ref Bgr24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref L8 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref Bgr24 sp = ref Unsafe.Add(ref sourceRef, i); ref L8 dp = ref Unsafe.Add(ref destRef, i); @@ -231,7 +231,7 @@ public override void ToL16( ref Bgr24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref L16 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref Bgr24 sp = ref Unsafe.Add(ref sourceRef, i); ref L16 dp = ref Unsafe.Add(ref destRef, i); @@ -252,7 +252,7 @@ public override void ToLa16( ref Bgr24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref La16 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref Bgr24 sp = ref Unsafe.Add(ref sourceRef, i); ref La16 dp = ref Unsafe.Add(ref destRef, i); @@ -273,7 +273,7 @@ public override void ToLa32( ref Bgr24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref La32 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref Bgr24 sp = ref Unsafe.Add(ref sourceRef, i); ref La32 dp = ref Unsafe.Add(ref destRef, i); @@ -294,7 +294,7 @@ public override void ToRgb48( ref Bgr24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Rgb48 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref Bgr24 sp = ref Unsafe.Add(ref sourceRef, i); ref Rgb48 dp = ref Unsafe.Add(ref destRef, i); @@ -315,7 +315,7 @@ public override void ToRgba64( ref Bgr24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Rgba64 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref Bgr24 sp = ref Unsafe.Add(ref sourceRef, i); ref Rgba64 dp = ref Unsafe.Add(ref destRef, i); @@ -336,7 +336,7 @@ public override void ToBgra5551( ref Bgr24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Bgra5551 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref Bgr24 sp = ref Unsafe.Add(ref sourceRef, i); ref Bgra5551 dp = ref Unsafe.Add(ref destRef, i); diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Bgra32.PixelOperations.Generated.cs b/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Bgra32.PixelOperations.Generated.cs index 4e7800c624..b9f7a49e11 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Bgra32.PixelOperations.Generated.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Bgra32.PixelOperations.Generated.cs @@ -57,7 +57,7 @@ public override void ToVector4( { Vector4Converters.RgbaCompatible.ToVector4(configuration, this, sourcePixels, destVectors, modifiers.Remove(PixelConversionModifiers.Scale)); } - + /// public override void ToRgba32( Configuration configuration, @@ -71,7 +71,7 @@ public override void ToRgba32( Span dest = MemoryMarshal.Cast(destinationPixels); PixelConverter.FromBgra32.ToRgba32(source, dest); } - + /// public override void FromRgba32( Configuration configuration, @@ -84,8 +84,8 @@ public override void FromRgba32( ReadOnlySpan source = MemoryMarshal.Cast(sourcePixels); Span dest = MemoryMarshal.Cast(destinationPixels); PixelConverter.FromRgba32.ToBgra32(source, dest); - } - + } + /// public override void ToArgb32( Configuration configuration, @@ -99,7 +99,7 @@ public override void ToArgb32( Span dest = MemoryMarshal.Cast(destinationPixels); PixelConverter.FromBgra32.ToArgb32(source, dest); } - + /// public override void FromArgb32( Configuration configuration, @@ -112,8 +112,8 @@ public override void FromArgb32( ReadOnlySpan source = MemoryMarshal.Cast(sourcePixels); Span dest = MemoryMarshal.Cast(destinationPixels); PixelConverter.FromArgb32.ToBgra32(source, dest); - } - + } + /// public override void ToAbgr32( Configuration configuration, @@ -127,7 +127,7 @@ public override void ToAbgr32( Span dest = MemoryMarshal.Cast(destinationPixels); PixelConverter.FromBgra32.ToAbgr32(source, dest); } - + /// public override void FromAbgr32( Configuration configuration, @@ -140,8 +140,8 @@ public override void FromAbgr32( ReadOnlySpan source = MemoryMarshal.Cast(sourcePixels); Span dest = MemoryMarshal.Cast(destinationPixels); PixelConverter.FromAbgr32.ToBgra32(source, dest); - } - + } + /// public override void ToRgb24( Configuration configuration, @@ -155,7 +155,7 @@ public override void ToRgb24( Span dest = MemoryMarshal.Cast(destinationPixels); PixelConverter.FromBgra32.ToRgb24(source, dest); } - + /// public override void FromRgb24( Configuration configuration, @@ -168,8 +168,8 @@ public override void FromRgb24( ReadOnlySpan source = MemoryMarshal.Cast(sourcePixels); Span dest = MemoryMarshal.Cast(destinationPixels); PixelConverter.FromRgb24.ToBgra32(source, dest); - } - + } + /// public override void ToBgr24( Configuration configuration, @@ -183,7 +183,7 @@ public override void ToBgr24( Span dest = MemoryMarshal.Cast(destinationPixels); PixelConverter.FromBgra32.ToBgr24(source, dest); } - + /// public override void FromBgr24( Configuration configuration, @@ -196,7 +196,7 @@ public override void FromBgr24( ReadOnlySpan source = MemoryMarshal.Cast(sourcePixels); Span dest = MemoryMarshal.Cast(destinationPixels); PixelConverter.FromBgr24.ToBgra32(source, dest); - } + } /// public override void ToL8( @@ -210,7 +210,7 @@ public override void ToL8( ref Bgra32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref L8 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref Bgra32 sp = ref Unsafe.Add(ref sourceRef, i); ref L8 dp = ref Unsafe.Add(ref destRef, i); @@ -231,7 +231,7 @@ public override void ToL16( ref Bgra32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref L16 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref Bgra32 sp = ref Unsafe.Add(ref sourceRef, i); ref L16 dp = ref Unsafe.Add(ref destRef, i); @@ -252,7 +252,7 @@ public override void ToLa16( ref Bgra32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref La16 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref Bgra32 sp = ref Unsafe.Add(ref sourceRef, i); ref La16 dp = ref Unsafe.Add(ref destRef, i); @@ -273,7 +273,7 @@ public override void ToLa32( ref Bgra32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref La32 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref Bgra32 sp = ref Unsafe.Add(ref sourceRef, i); ref La32 dp = ref Unsafe.Add(ref destRef, i); @@ -294,7 +294,7 @@ public override void ToRgb48( ref Bgra32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Rgb48 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref Bgra32 sp = ref Unsafe.Add(ref sourceRef, i); ref Rgb48 dp = ref Unsafe.Add(ref destRef, i); @@ -315,7 +315,7 @@ public override void ToRgba64( ref Bgra32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Rgba64 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref Bgra32 sp = ref Unsafe.Add(ref sourceRef, i); ref Rgba64 dp = ref Unsafe.Add(ref destRef, i); @@ -336,7 +336,7 @@ public override void ToBgra5551( ref Bgra32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Bgra5551 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref Bgra32 sp = ref Unsafe.Add(ref sourceRef, i); ref Bgra5551 dp = ref Unsafe.Add(ref destRef, i); diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Bgra5551.PixelOperations.Generated.cs b/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Bgra5551.PixelOperations.Generated.cs index 62864ad209..c1ba4f0618 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Bgra5551.PixelOperations.Generated.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Bgra5551.PixelOperations.Generated.cs @@ -50,7 +50,7 @@ public override void ToArgb32( ref Bgra5551 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Argb32 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref Bgra5551 sp = ref Unsafe.Add(ref sourceRef, i); ref Argb32 dp = ref Unsafe.Add(ref destRef, i); @@ -71,7 +71,7 @@ public override void ToAbgr32( ref Bgra5551 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Abgr32 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref Bgra5551 sp = ref Unsafe.Add(ref sourceRef, i); ref Abgr32 dp = ref Unsafe.Add(ref destRef, i); @@ -92,7 +92,7 @@ public override void ToBgr24( ref Bgra5551 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Bgr24 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref Bgra5551 sp = ref Unsafe.Add(ref sourceRef, i); ref Bgr24 dp = ref Unsafe.Add(ref destRef, i); @@ -113,7 +113,7 @@ public override void ToBgra32( ref Bgra5551 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Bgra32 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref Bgra5551 sp = ref Unsafe.Add(ref sourceRef, i); ref Bgra32 dp = ref Unsafe.Add(ref destRef, i); @@ -134,7 +134,7 @@ public override void ToL8( ref Bgra5551 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref L8 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref Bgra5551 sp = ref Unsafe.Add(ref sourceRef, i); ref L8 dp = ref Unsafe.Add(ref destRef, i); @@ -155,7 +155,7 @@ public override void ToL16( ref Bgra5551 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref L16 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref Bgra5551 sp = ref Unsafe.Add(ref sourceRef, i); ref L16 dp = ref Unsafe.Add(ref destRef, i); @@ -176,7 +176,7 @@ public override void ToLa16( ref Bgra5551 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref La16 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref Bgra5551 sp = ref Unsafe.Add(ref sourceRef, i); ref La16 dp = ref Unsafe.Add(ref destRef, i); @@ -197,7 +197,7 @@ public override void ToLa32( ref Bgra5551 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref La32 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref Bgra5551 sp = ref Unsafe.Add(ref sourceRef, i); ref La32 dp = ref Unsafe.Add(ref destRef, i); @@ -218,7 +218,7 @@ public override void ToRgb24( ref Bgra5551 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Rgb24 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref Bgra5551 sp = ref Unsafe.Add(ref sourceRef, i); ref Rgb24 dp = ref Unsafe.Add(ref destRef, i); @@ -239,7 +239,7 @@ public override void ToRgba32( ref Bgra5551 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Rgba32 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref Bgra5551 sp = ref Unsafe.Add(ref sourceRef, i); ref Rgba32 dp = ref Unsafe.Add(ref destRef, i); @@ -260,7 +260,7 @@ public override void ToRgb48( ref Bgra5551 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Rgb48 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref Bgra5551 sp = ref Unsafe.Add(ref sourceRef, i); ref Rgb48 dp = ref Unsafe.Add(ref destRef, i); @@ -281,7 +281,7 @@ public override void ToRgba64( ref Bgra5551 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Rgba64 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref Bgra5551 sp = ref Unsafe.Add(ref sourceRef, i); ref Rgba64 dp = ref Unsafe.Add(ref destRef, i); diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/L16.PixelOperations.Generated.cs b/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/L16.PixelOperations.Generated.cs index b37d9d86aa..c38d752ea6 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/L16.PixelOperations.Generated.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/L16.PixelOperations.Generated.cs @@ -50,7 +50,7 @@ public override void ToArgb32( ref L16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Argb32 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref L16 sp = ref Unsafe.Add(ref sourceRef, i); ref Argb32 dp = ref Unsafe.Add(ref destRef, i); @@ -71,7 +71,7 @@ public override void ToAbgr32( ref L16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Abgr32 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref L16 sp = ref Unsafe.Add(ref sourceRef, i); ref Abgr32 dp = ref Unsafe.Add(ref destRef, i); @@ -92,7 +92,7 @@ public override void ToBgr24( ref L16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Bgr24 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref L16 sp = ref Unsafe.Add(ref sourceRef, i); ref Bgr24 dp = ref Unsafe.Add(ref destRef, i); @@ -113,7 +113,7 @@ public override void ToBgra32( ref L16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Bgra32 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref L16 sp = ref Unsafe.Add(ref sourceRef, i); ref Bgra32 dp = ref Unsafe.Add(ref destRef, i); @@ -134,7 +134,7 @@ public override void ToL8( ref L16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref L8 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref L16 sp = ref Unsafe.Add(ref sourceRef, i); ref L8 dp = ref Unsafe.Add(ref destRef, i); @@ -155,7 +155,7 @@ public override void ToLa16( ref L16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref La16 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref L16 sp = ref Unsafe.Add(ref sourceRef, i); ref La16 dp = ref Unsafe.Add(ref destRef, i); @@ -176,7 +176,7 @@ public override void ToLa32( ref L16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref La32 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref L16 sp = ref Unsafe.Add(ref sourceRef, i); ref La32 dp = ref Unsafe.Add(ref destRef, i); @@ -197,7 +197,7 @@ public override void ToRgb24( ref L16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Rgb24 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref L16 sp = ref Unsafe.Add(ref sourceRef, i); ref Rgb24 dp = ref Unsafe.Add(ref destRef, i); @@ -218,7 +218,7 @@ public override void ToRgba32( ref L16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Rgba32 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref L16 sp = ref Unsafe.Add(ref sourceRef, i); ref Rgba32 dp = ref Unsafe.Add(ref destRef, i); @@ -239,7 +239,7 @@ public override void ToRgb48( ref L16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Rgb48 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref L16 sp = ref Unsafe.Add(ref sourceRef, i); ref Rgb48 dp = ref Unsafe.Add(ref destRef, i); @@ -260,7 +260,7 @@ public override void ToRgba64( ref L16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Rgba64 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref L16 sp = ref Unsafe.Add(ref sourceRef, i); ref Rgba64 dp = ref Unsafe.Add(ref destRef, i); @@ -281,7 +281,7 @@ public override void ToBgra5551( ref L16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Bgra5551 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref L16 sp = ref Unsafe.Add(ref sourceRef, i); ref Bgra5551 dp = ref Unsafe.Add(ref destRef, i); diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/L8.PixelOperations.Generated.cs b/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/L8.PixelOperations.Generated.cs index 9d67d8741f..656a0546ba 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/L8.PixelOperations.Generated.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/L8.PixelOperations.Generated.cs @@ -50,7 +50,7 @@ public override void ToArgb32( ref L8 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Argb32 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref L8 sp = ref Unsafe.Add(ref sourceRef, i); ref Argb32 dp = ref Unsafe.Add(ref destRef, i); @@ -71,7 +71,7 @@ public override void ToAbgr32( ref L8 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Abgr32 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref L8 sp = ref Unsafe.Add(ref sourceRef, i); ref Abgr32 dp = ref Unsafe.Add(ref destRef, i); @@ -92,7 +92,7 @@ public override void ToBgr24( ref L8 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Bgr24 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref L8 sp = ref Unsafe.Add(ref sourceRef, i); ref Bgr24 dp = ref Unsafe.Add(ref destRef, i); @@ -113,7 +113,7 @@ public override void ToBgra32( ref L8 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Bgra32 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref L8 sp = ref Unsafe.Add(ref sourceRef, i); ref Bgra32 dp = ref Unsafe.Add(ref destRef, i); @@ -134,7 +134,7 @@ public override void ToL16( ref L8 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref L16 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref L8 sp = ref Unsafe.Add(ref sourceRef, i); ref L16 dp = ref Unsafe.Add(ref destRef, i); @@ -155,7 +155,7 @@ public override void ToLa16( ref L8 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref La16 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref L8 sp = ref Unsafe.Add(ref sourceRef, i); ref La16 dp = ref Unsafe.Add(ref destRef, i); @@ -176,7 +176,7 @@ public override void ToLa32( ref L8 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref La32 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref L8 sp = ref Unsafe.Add(ref sourceRef, i); ref La32 dp = ref Unsafe.Add(ref destRef, i); @@ -197,7 +197,7 @@ public override void ToRgb24( ref L8 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Rgb24 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref L8 sp = ref Unsafe.Add(ref sourceRef, i); ref Rgb24 dp = ref Unsafe.Add(ref destRef, i); @@ -218,7 +218,7 @@ public override void ToRgba32( ref L8 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Rgba32 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref L8 sp = ref Unsafe.Add(ref sourceRef, i); ref Rgba32 dp = ref Unsafe.Add(ref destRef, i); @@ -239,7 +239,7 @@ public override void ToRgb48( ref L8 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Rgb48 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref L8 sp = ref Unsafe.Add(ref sourceRef, i); ref Rgb48 dp = ref Unsafe.Add(ref destRef, i); @@ -260,7 +260,7 @@ public override void ToRgba64( ref L8 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Rgba64 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref L8 sp = ref Unsafe.Add(ref sourceRef, i); ref Rgba64 dp = ref Unsafe.Add(ref destRef, i); @@ -281,7 +281,7 @@ public override void ToBgra5551( ref L8 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Bgra5551 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref L8 sp = ref Unsafe.Add(ref sourceRef, i); ref Bgra5551 dp = ref Unsafe.Add(ref destRef, i); diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/La16.PixelOperations.Generated.cs b/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/La16.PixelOperations.Generated.cs index 5afea82021..82be1323cd 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/La16.PixelOperations.Generated.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/La16.PixelOperations.Generated.cs @@ -50,7 +50,7 @@ public override void ToArgb32( ref La16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Argb32 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref La16 sp = ref Unsafe.Add(ref sourceRef, i); ref Argb32 dp = ref Unsafe.Add(ref destRef, i); @@ -71,7 +71,7 @@ public override void ToAbgr32( ref La16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Abgr32 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref La16 sp = ref Unsafe.Add(ref sourceRef, i); ref Abgr32 dp = ref Unsafe.Add(ref destRef, i); @@ -92,7 +92,7 @@ public override void ToBgr24( ref La16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Bgr24 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref La16 sp = ref Unsafe.Add(ref sourceRef, i); ref Bgr24 dp = ref Unsafe.Add(ref destRef, i); @@ -113,7 +113,7 @@ public override void ToBgra32( ref La16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Bgra32 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref La16 sp = ref Unsafe.Add(ref sourceRef, i); ref Bgra32 dp = ref Unsafe.Add(ref destRef, i); @@ -134,7 +134,7 @@ public override void ToL8( ref La16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref L8 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref La16 sp = ref Unsafe.Add(ref sourceRef, i); ref L8 dp = ref Unsafe.Add(ref destRef, i); @@ -155,7 +155,7 @@ public override void ToL16( ref La16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref L16 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref La16 sp = ref Unsafe.Add(ref sourceRef, i); ref L16 dp = ref Unsafe.Add(ref destRef, i); @@ -176,7 +176,7 @@ public override void ToLa32( ref La16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref La32 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref La16 sp = ref Unsafe.Add(ref sourceRef, i); ref La32 dp = ref Unsafe.Add(ref destRef, i); @@ -197,7 +197,7 @@ public override void ToRgb24( ref La16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Rgb24 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref La16 sp = ref Unsafe.Add(ref sourceRef, i); ref Rgb24 dp = ref Unsafe.Add(ref destRef, i); @@ -218,7 +218,7 @@ public override void ToRgba32( ref La16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Rgba32 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref La16 sp = ref Unsafe.Add(ref sourceRef, i); ref Rgba32 dp = ref Unsafe.Add(ref destRef, i); @@ -239,7 +239,7 @@ public override void ToRgb48( ref La16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Rgb48 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref La16 sp = ref Unsafe.Add(ref sourceRef, i); ref Rgb48 dp = ref Unsafe.Add(ref destRef, i); @@ -260,7 +260,7 @@ public override void ToRgba64( ref La16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Rgba64 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref La16 sp = ref Unsafe.Add(ref sourceRef, i); ref Rgba64 dp = ref Unsafe.Add(ref destRef, i); @@ -281,7 +281,7 @@ public override void ToBgra5551( ref La16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Bgra5551 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref La16 sp = ref Unsafe.Add(ref sourceRef, i); ref Bgra5551 dp = ref Unsafe.Add(ref destRef, i); diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/La32.PixelOperations.Generated.cs b/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/La32.PixelOperations.Generated.cs index 76da66a1ad..a9ee9d6b78 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/La32.PixelOperations.Generated.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/La32.PixelOperations.Generated.cs @@ -50,7 +50,7 @@ public override void ToArgb32( ref La32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Argb32 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref La32 sp = ref Unsafe.Add(ref sourceRef, i); ref Argb32 dp = ref Unsafe.Add(ref destRef, i); @@ -71,7 +71,7 @@ public override void ToAbgr32( ref La32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Abgr32 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref La32 sp = ref Unsafe.Add(ref sourceRef, i); ref Abgr32 dp = ref Unsafe.Add(ref destRef, i); @@ -92,7 +92,7 @@ public override void ToBgr24( ref La32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Bgr24 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref La32 sp = ref Unsafe.Add(ref sourceRef, i); ref Bgr24 dp = ref Unsafe.Add(ref destRef, i); @@ -113,7 +113,7 @@ public override void ToBgra32( ref La32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Bgra32 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref La32 sp = ref Unsafe.Add(ref sourceRef, i); ref Bgra32 dp = ref Unsafe.Add(ref destRef, i); @@ -134,7 +134,7 @@ public override void ToL8( ref La32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref L8 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref La32 sp = ref Unsafe.Add(ref sourceRef, i); ref L8 dp = ref Unsafe.Add(ref destRef, i); @@ -155,7 +155,7 @@ public override void ToL16( ref La32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref L16 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref La32 sp = ref Unsafe.Add(ref sourceRef, i); ref L16 dp = ref Unsafe.Add(ref destRef, i); @@ -176,7 +176,7 @@ public override void ToLa16( ref La32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref La16 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref La32 sp = ref Unsafe.Add(ref sourceRef, i); ref La16 dp = ref Unsafe.Add(ref destRef, i); @@ -197,7 +197,7 @@ public override void ToRgb24( ref La32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Rgb24 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref La32 sp = ref Unsafe.Add(ref sourceRef, i); ref Rgb24 dp = ref Unsafe.Add(ref destRef, i); @@ -218,7 +218,7 @@ public override void ToRgba32( ref La32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Rgba32 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref La32 sp = ref Unsafe.Add(ref sourceRef, i); ref Rgba32 dp = ref Unsafe.Add(ref destRef, i); @@ -239,7 +239,7 @@ public override void ToRgb48( ref La32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Rgb48 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref La32 sp = ref Unsafe.Add(ref sourceRef, i); ref Rgb48 dp = ref Unsafe.Add(ref destRef, i); @@ -260,7 +260,7 @@ public override void ToRgba64( ref La32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Rgba64 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref La32 sp = ref Unsafe.Add(ref sourceRef, i); ref Rgba64 dp = ref Unsafe.Add(ref destRef, i); @@ -281,7 +281,7 @@ public override void ToBgra5551( ref La32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Bgra5551 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref La32 sp = ref Unsafe.Add(ref sourceRef, i); ref Bgra5551 dp = ref Unsafe.Add(ref destRef, i); diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Rgb24.PixelOperations.Generated.cs b/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Rgb24.PixelOperations.Generated.cs index 519f1a6936..1d87121e92 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Rgb24.PixelOperations.Generated.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Rgb24.PixelOperations.Generated.cs @@ -57,7 +57,7 @@ public override void ToVector4( { Vector4Converters.RgbaCompatible.ToVector4(configuration, this, sourcePixels, destVectors, modifiers.Remove(PixelConversionModifiers.Scale | PixelConversionModifiers.Premultiply)); } - + /// public override void ToRgba32( Configuration configuration, @@ -71,7 +71,7 @@ public override void ToRgba32( Span dest = MemoryMarshal.Cast(destinationPixels); PixelConverter.FromRgb24.ToRgba32(source, dest); } - + /// public override void FromRgba32( Configuration configuration, @@ -84,8 +84,8 @@ public override void FromRgba32( ReadOnlySpan source = MemoryMarshal.Cast(sourcePixels); Span dest = MemoryMarshal.Cast(destinationPixels); PixelConverter.FromRgba32.ToRgb24(source, dest); - } - + } + /// public override void ToArgb32( Configuration configuration, @@ -99,7 +99,7 @@ public override void ToArgb32( Span dest = MemoryMarshal.Cast(destinationPixels); PixelConverter.FromRgb24.ToArgb32(source, dest); } - + /// public override void FromArgb32( Configuration configuration, @@ -112,8 +112,8 @@ public override void FromArgb32( ReadOnlySpan source = MemoryMarshal.Cast(sourcePixels); Span dest = MemoryMarshal.Cast(destinationPixels); PixelConverter.FromArgb32.ToRgb24(source, dest); - } - + } + /// public override void ToAbgr32( Configuration configuration, @@ -127,7 +127,7 @@ public override void ToAbgr32( Span dest = MemoryMarshal.Cast(destinationPixels); PixelConverter.FromRgb24.ToAbgr32(source, dest); } - + /// public override void FromAbgr32( Configuration configuration, @@ -140,8 +140,8 @@ public override void FromAbgr32( ReadOnlySpan source = MemoryMarshal.Cast(sourcePixels); Span dest = MemoryMarshal.Cast(destinationPixels); PixelConverter.FromAbgr32.ToRgb24(source, dest); - } - + } + /// public override void ToBgra32( Configuration configuration, @@ -155,7 +155,7 @@ public override void ToBgra32( Span dest = MemoryMarshal.Cast(destinationPixels); PixelConverter.FromRgb24.ToBgra32(source, dest); } - + /// public override void FromBgra32( Configuration configuration, @@ -168,8 +168,8 @@ public override void FromBgra32( ReadOnlySpan source = MemoryMarshal.Cast(sourcePixels); Span dest = MemoryMarshal.Cast(destinationPixels); PixelConverter.FromBgra32.ToRgb24(source, dest); - } - + } + /// public override void ToBgr24( Configuration configuration, @@ -183,7 +183,7 @@ public override void ToBgr24( Span dest = MemoryMarshal.Cast(destinationPixels); PixelConverter.FromRgb24.ToBgr24(source, dest); } - + /// public override void FromBgr24( Configuration configuration, @@ -196,7 +196,7 @@ public override void FromBgr24( ReadOnlySpan source = MemoryMarshal.Cast(sourcePixels); Span dest = MemoryMarshal.Cast(destinationPixels); PixelConverter.FromBgr24.ToRgb24(source, dest); - } + } /// public override void ToL8( @@ -210,7 +210,7 @@ public override void ToL8( ref Rgb24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref L8 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref Rgb24 sp = ref Unsafe.Add(ref sourceRef, i); ref L8 dp = ref Unsafe.Add(ref destRef, i); @@ -231,7 +231,7 @@ public override void ToL16( ref Rgb24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref L16 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref Rgb24 sp = ref Unsafe.Add(ref sourceRef, i); ref L16 dp = ref Unsafe.Add(ref destRef, i); @@ -252,7 +252,7 @@ public override void ToLa16( ref Rgb24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref La16 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref Rgb24 sp = ref Unsafe.Add(ref sourceRef, i); ref La16 dp = ref Unsafe.Add(ref destRef, i); @@ -273,7 +273,7 @@ public override void ToLa32( ref Rgb24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref La32 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref Rgb24 sp = ref Unsafe.Add(ref sourceRef, i); ref La32 dp = ref Unsafe.Add(ref destRef, i); @@ -294,7 +294,7 @@ public override void ToRgb48( ref Rgb24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Rgb48 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref Rgb24 sp = ref Unsafe.Add(ref sourceRef, i); ref Rgb48 dp = ref Unsafe.Add(ref destRef, i); @@ -315,7 +315,7 @@ public override void ToRgba64( ref Rgb24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Rgba64 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref Rgb24 sp = ref Unsafe.Add(ref sourceRef, i); ref Rgba64 dp = ref Unsafe.Add(ref destRef, i); @@ -336,7 +336,7 @@ public override void ToBgra5551( ref Rgb24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Bgra5551 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref Rgb24 sp = ref Unsafe.Add(ref sourceRef, i); ref Bgra5551 dp = ref Unsafe.Add(ref destRef, i); diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Rgb48.PixelOperations.Generated.cs b/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Rgb48.PixelOperations.Generated.cs index e58818deac..60cfdad4b6 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Rgb48.PixelOperations.Generated.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Rgb48.PixelOperations.Generated.cs @@ -50,7 +50,7 @@ public override void ToArgb32( ref Rgb48 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Argb32 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref Rgb48 sp = ref Unsafe.Add(ref sourceRef, i); ref Argb32 dp = ref Unsafe.Add(ref destRef, i); @@ -71,7 +71,7 @@ public override void ToAbgr32( ref Rgb48 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Abgr32 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref Rgb48 sp = ref Unsafe.Add(ref sourceRef, i); ref Abgr32 dp = ref Unsafe.Add(ref destRef, i); @@ -92,7 +92,7 @@ public override void ToBgr24( ref Rgb48 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Bgr24 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref Rgb48 sp = ref Unsafe.Add(ref sourceRef, i); ref Bgr24 dp = ref Unsafe.Add(ref destRef, i); @@ -113,7 +113,7 @@ public override void ToBgra32( ref Rgb48 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Bgra32 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref Rgb48 sp = ref Unsafe.Add(ref sourceRef, i); ref Bgra32 dp = ref Unsafe.Add(ref destRef, i); @@ -134,7 +134,7 @@ public override void ToL8( ref Rgb48 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref L8 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref Rgb48 sp = ref Unsafe.Add(ref sourceRef, i); ref L8 dp = ref Unsafe.Add(ref destRef, i); @@ -155,7 +155,7 @@ public override void ToL16( ref Rgb48 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref L16 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref Rgb48 sp = ref Unsafe.Add(ref sourceRef, i); ref L16 dp = ref Unsafe.Add(ref destRef, i); @@ -176,7 +176,7 @@ public override void ToLa16( ref Rgb48 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref La16 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref Rgb48 sp = ref Unsafe.Add(ref sourceRef, i); ref La16 dp = ref Unsafe.Add(ref destRef, i); @@ -197,7 +197,7 @@ public override void ToLa32( ref Rgb48 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref La32 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref Rgb48 sp = ref Unsafe.Add(ref sourceRef, i); ref La32 dp = ref Unsafe.Add(ref destRef, i); @@ -218,7 +218,7 @@ public override void ToRgb24( ref Rgb48 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Rgb24 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref Rgb48 sp = ref Unsafe.Add(ref sourceRef, i); ref Rgb24 dp = ref Unsafe.Add(ref destRef, i); @@ -239,7 +239,7 @@ public override void ToRgba32( ref Rgb48 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Rgba32 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref Rgb48 sp = ref Unsafe.Add(ref sourceRef, i); ref Rgba32 dp = ref Unsafe.Add(ref destRef, i); @@ -260,7 +260,7 @@ public override void ToRgba64( ref Rgb48 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Rgba64 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref Rgb48 sp = ref Unsafe.Add(ref sourceRef, i); ref Rgba64 dp = ref Unsafe.Add(ref destRef, i); @@ -281,7 +281,7 @@ public override void ToBgra5551( ref Rgb48 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Bgra5551 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref Rgb48 sp = ref Unsafe.Add(ref sourceRef, i); ref Bgra5551 dp = ref Unsafe.Add(ref destRef, i); diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Rgba32.PixelOperations.Generated.cs b/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Rgba32.PixelOperations.Generated.cs index c635a4d6a4..da7c9a6c91 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Rgba32.PixelOperations.Generated.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Rgba32.PixelOperations.Generated.cs @@ -37,7 +37,7 @@ public override void ToRgba32(Configuration configuration, ReadOnlySpan sourcePixels.CopyTo(destinationPixels.Slice(0, sourcePixels.Length)); } - + /// public override void ToArgb32( Configuration configuration, @@ -51,7 +51,7 @@ public override void ToArgb32( Span dest = MemoryMarshal.Cast(destinationPixels); PixelConverter.FromRgba32.ToArgb32(source, dest); } - + /// public override void FromArgb32( Configuration configuration, @@ -64,8 +64,8 @@ public override void FromArgb32( ReadOnlySpan source = MemoryMarshal.Cast(sourcePixels); Span dest = MemoryMarshal.Cast(destinationPixels); PixelConverter.FromArgb32.ToRgba32(source, dest); - } - + } + /// public override void ToAbgr32( Configuration configuration, @@ -79,7 +79,7 @@ public override void ToAbgr32( Span dest = MemoryMarshal.Cast(destinationPixels); PixelConverter.FromRgba32.ToAbgr32(source, dest); } - + /// public override void FromAbgr32( Configuration configuration, @@ -92,8 +92,8 @@ public override void FromAbgr32( ReadOnlySpan source = MemoryMarshal.Cast(sourcePixels); Span dest = MemoryMarshal.Cast(destinationPixels); PixelConverter.FromAbgr32.ToRgba32(source, dest); - } - + } + /// public override void ToBgra32( Configuration configuration, @@ -107,7 +107,7 @@ public override void ToBgra32( Span dest = MemoryMarshal.Cast(destinationPixels); PixelConverter.FromRgba32.ToBgra32(source, dest); } - + /// public override void FromBgra32( Configuration configuration, @@ -120,8 +120,8 @@ public override void FromBgra32( ReadOnlySpan source = MemoryMarshal.Cast(sourcePixels); Span dest = MemoryMarshal.Cast(destinationPixels); PixelConverter.FromBgra32.ToRgba32(source, dest); - } - + } + /// public override void ToRgb24( Configuration configuration, @@ -135,7 +135,7 @@ public override void ToRgb24( Span dest = MemoryMarshal.Cast(destinationPixels); PixelConverter.FromRgba32.ToRgb24(source, dest); } - + /// public override void FromRgb24( Configuration configuration, @@ -148,8 +148,8 @@ public override void FromRgb24( ReadOnlySpan source = MemoryMarshal.Cast(sourcePixels); Span dest = MemoryMarshal.Cast(destinationPixels); PixelConverter.FromRgb24.ToRgba32(source, dest); - } - + } + /// public override void ToBgr24( Configuration configuration, @@ -163,7 +163,7 @@ public override void ToBgr24( Span dest = MemoryMarshal.Cast(destinationPixels); PixelConverter.FromRgba32.ToBgr24(source, dest); } - + /// public override void FromBgr24( Configuration configuration, @@ -176,7 +176,7 @@ public override void FromBgr24( ReadOnlySpan source = MemoryMarshal.Cast(sourcePixels); Span dest = MemoryMarshal.Cast(destinationPixels); PixelConverter.FromBgr24.ToRgba32(source, dest); - } + } /// public override void ToL8( @@ -190,7 +190,7 @@ public override void ToL8( ref Rgba32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref L8 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref Rgba32 sp = ref Unsafe.Add(ref sourceRef, i); ref L8 dp = ref Unsafe.Add(ref destRef, i); @@ -211,7 +211,7 @@ public override void ToL16( ref Rgba32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref L16 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref Rgba32 sp = ref Unsafe.Add(ref sourceRef, i); ref L16 dp = ref Unsafe.Add(ref destRef, i); @@ -232,7 +232,7 @@ public override void ToLa16( ref Rgba32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref La16 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref Rgba32 sp = ref Unsafe.Add(ref sourceRef, i); ref La16 dp = ref Unsafe.Add(ref destRef, i); @@ -253,7 +253,7 @@ public override void ToLa32( ref Rgba32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref La32 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref Rgba32 sp = ref Unsafe.Add(ref sourceRef, i); ref La32 dp = ref Unsafe.Add(ref destRef, i); @@ -274,7 +274,7 @@ public override void ToRgb48( ref Rgba32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Rgb48 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref Rgba32 sp = ref Unsafe.Add(ref sourceRef, i); ref Rgb48 dp = ref Unsafe.Add(ref destRef, i); @@ -295,7 +295,7 @@ public override void ToRgba64( ref Rgba32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Rgba64 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref Rgba32 sp = ref Unsafe.Add(ref sourceRef, i); ref Rgba64 dp = ref Unsafe.Add(ref destRef, i); @@ -316,7 +316,7 @@ public override void ToBgra5551( ref Rgba32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Bgra5551 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref Rgba32 sp = ref Unsafe.Add(ref sourceRef, i); ref Bgra5551 dp = ref Unsafe.Add(ref destRef, i); diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Rgba64.PixelOperations.Generated.cs b/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Rgba64.PixelOperations.Generated.cs index 395f7e88e0..b6236f8a66 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Rgba64.PixelOperations.Generated.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/Rgba64.PixelOperations.Generated.cs @@ -50,7 +50,7 @@ public override void ToArgb32( ref Rgba64 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Argb32 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref Rgba64 sp = ref Unsafe.Add(ref sourceRef, i); ref Argb32 dp = ref Unsafe.Add(ref destRef, i); @@ -71,7 +71,7 @@ public override void ToAbgr32( ref Rgba64 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Abgr32 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref Rgba64 sp = ref Unsafe.Add(ref sourceRef, i); ref Abgr32 dp = ref Unsafe.Add(ref destRef, i); @@ -92,7 +92,7 @@ public override void ToBgr24( ref Rgba64 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Bgr24 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref Rgba64 sp = ref Unsafe.Add(ref sourceRef, i); ref Bgr24 dp = ref Unsafe.Add(ref destRef, i); @@ -113,7 +113,7 @@ public override void ToBgra32( ref Rgba64 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Bgra32 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref Rgba64 sp = ref Unsafe.Add(ref sourceRef, i); ref Bgra32 dp = ref Unsafe.Add(ref destRef, i); @@ -134,7 +134,7 @@ public override void ToL8( ref Rgba64 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref L8 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref Rgba64 sp = ref Unsafe.Add(ref sourceRef, i); ref L8 dp = ref Unsafe.Add(ref destRef, i); @@ -155,7 +155,7 @@ public override void ToL16( ref Rgba64 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref L16 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref Rgba64 sp = ref Unsafe.Add(ref sourceRef, i); ref L16 dp = ref Unsafe.Add(ref destRef, i); @@ -176,7 +176,7 @@ public override void ToLa16( ref Rgba64 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref La16 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref Rgba64 sp = ref Unsafe.Add(ref sourceRef, i); ref La16 dp = ref Unsafe.Add(ref destRef, i); @@ -197,7 +197,7 @@ public override void ToLa32( ref Rgba64 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref La32 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref Rgba64 sp = ref Unsafe.Add(ref sourceRef, i); ref La32 dp = ref Unsafe.Add(ref destRef, i); @@ -218,7 +218,7 @@ public override void ToRgb24( ref Rgba64 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Rgb24 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref Rgba64 sp = ref Unsafe.Add(ref sourceRef, i); ref Rgb24 dp = ref Unsafe.Add(ref destRef, i); @@ -239,7 +239,7 @@ public override void ToRgba32( ref Rgba64 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Rgba32 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref Rgba64 sp = ref Unsafe.Add(ref sourceRef, i); ref Rgba32 dp = ref Unsafe.Add(ref destRef, i); @@ -260,7 +260,7 @@ public override void ToRgb48( ref Rgba64 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Rgb48 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref Rgba64 sp = ref Unsafe.Add(ref sourceRef, i); ref Rgb48 dp = ref Unsafe.Add(ref destRef, i); @@ -281,7 +281,7 @@ public override void ToBgra5551( ref Rgba64 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref Bgra5551 destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref Rgba64 sp = ref Unsafe.Add(ref sourceRef, i); ref Bgra5551 dp = ref Unsafe.Add(ref destRef, i); diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/_Common.ttinclude b/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/_Common.ttinclude index 5a5d135db1..f7e178d7f2 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/_Common.ttinclude +++ b/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/_Common.ttinclude @@ -103,7 +103,7 @@ using SixLabors.ImageSharp.PixelFormats.Utils; ref <#=fromPixelType#> sourceRef = ref MemoryMarshal.GetReference(sourcePixels); ref <#=toPixelType#> destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref <#=fromPixelType#> sp = ref Unsafe.Add(ref sourceRef, i); ref <#=toPixelType#> dp = ref Unsafe.Add(ref destRef, i); diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/RgbaVector.PixelOperations.cs b/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/RgbaVector.PixelOperations.cs index ed1d3cb2bd..a3833583fc 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/RgbaVector.PixelOperations.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/RgbaVector.PixelOperations.cs @@ -72,7 +72,7 @@ public override void ToL8( ref Vector4 sourceBaseRef = ref Unsafe.As(ref MemoryMarshal.GetReference(sourcePixels)); ref L8 destBaseRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref Vector4 sp = ref Unsafe.Add(ref sourceBaseRef, i); ref L8 dp = ref Unsafe.Add(ref destBaseRef, i); @@ -91,7 +91,7 @@ public override void ToL16( ref Vector4 sourceBaseRef = ref Unsafe.As(ref MemoryMarshal.GetReference(sourcePixels)); ref L16 destBaseRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref Vector4 sp = ref Unsafe.Add(ref sourceBaseRef, i); ref L16 dp = ref Unsafe.Add(ref destBaseRef, i); diff --git a/src/ImageSharp/PixelFormats/PixelOperations{TPixel}.Generated.cs b/src/ImageSharp/PixelFormats/PixelOperations{TPixel}.Generated.cs index 26ca4d1b5a..7e84bd6392 100644 --- a/src/ImageSharp/PixelFormats/PixelOperations{TPixel}.Generated.cs +++ b/src/ImageSharp/PixelFormats/PixelOperations{TPixel}.Generated.cs @@ -22,7 +22,7 @@ public virtual void FromArgb32(Configuration configuration, ReadOnlySpan ref Argb32 sourceBaseRef = ref MemoryMarshal.GetReference(source); ref TPixel destBaseRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)source.Length; i++) + for (nuint i = 0; i < (uint)source.Length; i++) { ref Argb32 sp = ref Unsafe.Add(ref sourceBaseRef, i); ref TPixel dp = ref Unsafe.Add(ref destBaseRef, i); @@ -58,7 +58,7 @@ public virtual void ToArgb32(Configuration configuration, ReadOnlySpan s ref TPixel sourceBaseRef = ref MemoryMarshal.GetReference(sourcePixels); ref Argb32 destBaseRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref TPixel sp = ref Unsafe.Add(ref sourceBaseRef, i); ref Argb32 dp = ref Unsafe.Add(ref destBaseRef, i); @@ -94,7 +94,7 @@ public virtual void FromAbgr32(Configuration configuration, ReadOnlySpan ref Abgr32 sourceBaseRef = ref MemoryMarshal.GetReference(source); ref TPixel destBaseRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)source.Length; i++) + for (nuint i = 0; i < (uint)source.Length; i++) { ref Abgr32 sp = ref Unsafe.Add(ref sourceBaseRef, i); ref TPixel dp = ref Unsafe.Add(ref destBaseRef, i); @@ -130,7 +130,7 @@ public virtual void ToAbgr32(Configuration configuration, ReadOnlySpan s ref TPixel sourceBaseRef = ref MemoryMarshal.GetReference(sourcePixels); ref Abgr32 destBaseRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref TPixel sp = ref Unsafe.Add(ref sourceBaseRef, i); ref Abgr32 dp = ref Unsafe.Add(ref destBaseRef, i); @@ -166,7 +166,7 @@ public virtual void FromBgr24(Configuration configuration, ReadOnlySpan s ref Bgr24 sourceBaseRef = ref MemoryMarshal.GetReference(source); ref TPixel destBaseRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)source.Length; i++) + for (nuint i = 0; i < (uint)source.Length; i++) { ref Bgr24 sp = ref Unsafe.Add(ref sourceBaseRef, i); ref TPixel dp = ref Unsafe.Add(ref destBaseRef, i); @@ -202,7 +202,7 @@ public virtual void ToBgr24(Configuration configuration, ReadOnlySpan so ref TPixel sourceBaseRef = ref MemoryMarshal.GetReference(sourcePixels); ref Bgr24 destBaseRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref TPixel sp = ref Unsafe.Add(ref sourceBaseRef, i); ref Bgr24 dp = ref Unsafe.Add(ref destBaseRef, i); @@ -238,7 +238,7 @@ public virtual void FromBgra32(Configuration configuration, ReadOnlySpan ref Bgra32 sourceBaseRef = ref MemoryMarshal.GetReference(source); ref TPixel destBaseRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)source.Length; i++) + for (nuint i = 0; i < (uint)source.Length; i++) { ref Bgra32 sp = ref Unsafe.Add(ref sourceBaseRef, i); ref TPixel dp = ref Unsafe.Add(ref destBaseRef, i); @@ -274,7 +274,7 @@ public virtual void ToBgra32(Configuration configuration, ReadOnlySpan s ref TPixel sourceBaseRef = ref MemoryMarshal.GetReference(sourcePixels); ref Bgra32 destBaseRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref TPixel sp = ref Unsafe.Add(ref sourceBaseRef, i); ref Bgra32 dp = ref Unsafe.Add(ref destBaseRef, i); @@ -310,7 +310,7 @@ public virtual void FromL8(Configuration configuration, ReadOnlySpan source, ref L8 sourceBaseRef = ref MemoryMarshal.GetReference(source); ref TPixel destBaseRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)source.Length; i++) + for (nuint i = 0; i < (uint)source.Length; i++) { ref L8 sp = ref Unsafe.Add(ref sourceBaseRef, i); ref TPixel dp = ref Unsafe.Add(ref destBaseRef, i); @@ -346,7 +346,7 @@ public virtual void ToL8(Configuration configuration, ReadOnlySpan sourc ref TPixel sourceBaseRef = ref MemoryMarshal.GetReference(sourcePixels); ref L8 destBaseRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref TPixel sp = ref Unsafe.Add(ref sourceBaseRef, i); ref L8 dp = ref Unsafe.Add(ref destBaseRef, i); @@ -382,7 +382,7 @@ public virtual void FromL16(Configuration configuration, ReadOnlySpan sourc ref L16 sourceBaseRef = ref MemoryMarshal.GetReference(source); ref TPixel destBaseRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)source.Length; i++) + for (nuint i = 0; i < (uint)source.Length; i++) { ref L16 sp = ref Unsafe.Add(ref sourceBaseRef, i); ref TPixel dp = ref Unsafe.Add(ref destBaseRef, i); @@ -418,7 +418,7 @@ public virtual void ToL16(Configuration configuration, ReadOnlySpan sour ref TPixel sourceBaseRef = ref MemoryMarshal.GetReference(sourcePixels); ref L16 destBaseRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref TPixel sp = ref Unsafe.Add(ref sourceBaseRef, i); ref L16 dp = ref Unsafe.Add(ref destBaseRef, i); @@ -454,7 +454,7 @@ public virtual void FromLa16(Configuration configuration, ReadOnlySpan sou ref La16 sourceBaseRef = ref MemoryMarshal.GetReference(source); ref TPixel destBaseRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)source.Length; i++) + for (nuint i = 0; i < (uint)source.Length; i++) { ref La16 sp = ref Unsafe.Add(ref sourceBaseRef, i); ref TPixel dp = ref Unsafe.Add(ref destBaseRef, i); @@ -490,7 +490,7 @@ public virtual void ToLa16(Configuration configuration, ReadOnlySpan sou ref TPixel sourceBaseRef = ref MemoryMarshal.GetReference(sourcePixels); ref La16 destBaseRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref TPixel sp = ref Unsafe.Add(ref sourceBaseRef, i); ref La16 dp = ref Unsafe.Add(ref destBaseRef, i); @@ -526,7 +526,7 @@ public virtual void FromLa32(Configuration configuration, ReadOnlySpan sou ref La32 sourceBaseRef = ref MemoryMarshal.GetReference(source); ref TPixel destBaseRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)source.Length; i++) + for (nuint i = 0; i < (uint)source.Length; i++) { ref La32 sp = ref Unsafe.Add(ref sourceBaseRef, i); ref TPixel dp = ref Unsafe.Add(ref destBaseRef, i); @@ -562,7 +562,7 @@ public virtual void ToLa32(Configuration configuration, ReadOnlySpan sou ref TPixel sourceBaseRef = ref MemoryMarshal.GetReference(sourcePixels); ref La32 destBaseRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref TPixel sp = ref Unsafe.Add(ref sourceBaseRef, i); ref La32 dp = ref Unsafe.Add(ref destBaseRef, i); @@ -598,7 +598,7 @@ public virtual void FromRgb24(Configuration configuration, ReadOnlySpan s ref Rgb24 sourceBaseRef = ref MemoryMarshal.GetReference(source); ref TPixel destBaseRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)source.Length; i++) + for (nuint i = 0; i < (uint)source.Length; i++) { ref Rgb24 sp = ref Unsafe.Add(ref sourceBaseRef, i); ref TPixel dp = ref Unsafe.Add(ref destBaseRef, i); @@ -634,7 +634,7 @@ public virtual void ToRgb24(Configuration configuration, ReadOnlySpan so ref TPixel sourceBaseRef = ref MemoryMarshal.GetReference(sourcePixels); ref Rgb24 destBaseRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref TPixel sp = ref Unsafe.Add(ref sourceBaseRef, i); ref Rgb24 dp = ref Unsafe.Add(ref destBaseRef, i); @@ -670,7 +670,7 @@ public virtual void FromRgba32(Configuration configuration, ReadOnlySpan ref Rgba32 sourceBaseRef = ref MemoryMarshal.GetReference(source); ref TPixel destBaseRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)source.Length; i++) + for (nuint i = 0; i < (uint)source.Length; i++) { ref Rgba32 sp = ref Unsafe.Add(ref sourceBaseRef, i); ref TPixel dp = ref Unsafe.Add(ref destBaseRef, i); @@ -706,7 +706,7 @@ public virtual void ToRgba32(Configuration configuration, ReadOnlySpan s ref TPixel sourceBaseRef = ref MemoryMarshal.GetReference(sourcePixels); ref Rgba32 destBaseRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref TPixel sp = ref Unsafe.Add(ref sourceBaseRef, i); ref Rgba32 dp = ref Unsafe.Add(ref destBaseRef, i); @@ -742,7 +742,7 @@ public virtual void FromRgb48(Configuration configuration, ReadOnlySpan s ref Rgb48 sourceBaseRef = ref MemoryMarshal.GetReference(source); ref TPixel destBaseRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)source.Length; i++) + for (nuint i = 0; i < (uint)source.Length; i++) { ref Rgb48 sp = ref Unsafe.Add(ref sourceBaseRef, i); ref TPixel dp = ref Unsafe.Add(ref destBaseRef, i); @@ -778,7 +778,7 @@ public virtual void ToRgb48(Configuration configuration, ReadOnlySpan so ref TPixel sourceBaseRef = ref MemoryMarshal.GetReference(sourcePixels); ref Rgb48 destBaseRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref TPixel sp = ref Unsafe.Add(ref sourceBaseRef, i); ref Rgb48 dp = ref Unsafe.Add(ref destBaseRef, i); @@ -814,7 +814,7 @@ public virtual void FromRgba64(Configuration configuration, ReadOnlySpan ref Rgba64 sourceBaseRef = ref MemoryMarshal.GetReference(source); ref TPixel destBaseRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)source.Length; i++) + for (nuint i = 0; i < (uint)source.Length; i++) { ref Rgba64 sp = ref Unsafe.Add(ref sourceBaseRef, i); ref TPixel dp = ref Unsafe.Add(ref destBaseRef, i); @@ -850,7 +850,7 @@ public virtual void ToRgba64(Configuration configuration, ReadOnlySpan s ref TPixel sourceBaseRef = ref MemoryMarshal.GetReference(sourcePixels); ref Rgba64 destBaseRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref TPixel sp = ref Unsafe.Add(ref sourceBaseRef, i); ref Rgba64 dp = ref Unsafe.Add(ref destBaseRef, i); @@ -886,7 +886,7 @@ public virtual void FromBgra5551(Configuration configuration, ReadOnlySpan ref TPixel sourceBaseRef = ref MemoryMarshal.GetReference(sourcePixels); ref Bgra5551 destBaseRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref TPixel sp = ref Unsafe.Add(ref sourceBaseRef, i); ref Bgra5551 dp = ref Unsafe.Add(ref destBaseRef, i); diff --git a/src/ImageSharp/PixelFormats/PixelOperations{TPixel}.Generated.tt b/src/ImageSharp/PixelFormats/PixelOperations{TPixel}.Generated.tt index 39cf873bfd..8ba3398e39 100644 --- a/src/ImageSharp/PixelFormats/PixelOperations{TPixel}.Generated.tt +++ b/src/ImageSharp/PixelFormats/PixelOperations{TPixel}.Generated.tt @@ -28,7 +28,7 @@ ref <#=pixelType#> sourceBaseRef = ref MemoryMarshal.GetReference(source); ref TPixel destBaseRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)source.Length; i++) + for (nuint i = 0; i < (uint)source.Length; i++) { ref <#=pixelType#> sp = ref Unsafe.Add(ref sourceBaseRef, i); ref TPixel dp = ref Unsafe.Add(ref destBaseRef, i); @@ -70,7 +70,7 @@ ref TPixel sourceBaseRef = ref MemoryMarshal.GetReference(sourcePixels); ref <#=pixelType#> destBaseRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)sourcePixels.Length; i++) + for (nuint i = 0; i < (uint)sourcePixels.Length; i++) { ref TPixel sp = ref Unsafe.Add(ref sourceBaseRef, i); ref <#=pixelType#> dp = ref Unsafe.Add(ref destBaseRef, i); diff --git a/src/ImageSharp/PixelFormats/PixelOperations{TPixel}.cs b/src/ImageSharp/PixelFormats/PixelOperations{TPixel}.cs index b18e38f4d5..9d93d27aca 100644 --- a/src/ImageSharp/PixelFormats/PixelOperations{TPixel}.cs +++ b/src/ImageSharp/PixelFormats/PixelOperations{TPixel}.cs @@ -187,7 +187,7 @@ internal virtual void PackFromRgbPlanes( ref byte b = ref MemoryMarshal.GetReference(blueChannel); ref TPixel d = ref MemoryMarshal.GetReference(destination); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { rgb24.R = Unsafe.Add(ref r, i); rgb24.G = Unsafe.Add(ref g, i); @@ -218,7 +218,7 @@ internal virtual void UnpackIntoRgbPlanes( ref float g = ref MemoryMarshal.GetReference(greenChannel); ref float b = ref MemoryMarshal.GetReference(blueChannel); ref TPixel src = ref MemoryMarshal.GetReference(source); - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { Unsafe.Add(ref src, i).ToRgba32(ref rgba32); Unsafe.Add(ref r, i) = rgba32.R; diff --git a/src/ImageSharp/Processing/Processors/Normalization/AdaptiveHistogramEqualizationSlidingWindowProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Normalization/AdaptiveHistogramEqualizationSlidingWindowProcessor{TPixel}.cs index bbac9b9d8e..d2bec0b49b 100644 --- a/src/ImageSharp/Processing/Processors/Normalization/AdaptiveHistogramEqualizationSlidingWindowProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Normalization/AdaptiveHistogramEqualizationSlidingWindowProcessor{TPixel}.cs @@ -254,9 +254,9 @@ private static void CopyPixelRowFast( [MethodImpl(InliningOptions.ShortMethod)] private static void AddPixelsToHistogram(ref Vector4 greyValuesBase, ref int histogramBase, int luminanceLevels, int length) { - for (nint idx = 0; idx < length; idx++) + for (nuint idx = 0; idx < (uint)length; idx++) { - int luminance = ColorNumerics.GetBT709Luminance(ref Unsafe.Add(ref greyValuesBase, (uint)idx), luminanceLevels); + int luminance = ColorNumerics.GetBT709Luminance(ref Unsafe.Add(ref greyValuesBase, idx), luminanceLevels); Unsafe.Add(ref histogramBase, (uint)luminance)++; } } @@ -271,9 +271,9 @@ private static void AddPixelsToHistogram(ref Vector4 greyValuesBase, ref int his [MethodImpl(InliningOptions.ShortMethod)] private static void RemovePixelsFromHistogram(ref Vector4 greyValuesBase, ref int histogramBase, int luminanceLevels, int length) { - for (int idx = 0; idx < length; idx++) + for (nuint idx = 0; idx < (uint)length; idx++) { - int luminance = ColorNumerics.GetBT709Luminance(ref Unsafe.Add(ref greyValuesBase, (uint)idx), luminanceLevels); + int luminance = ColorNumerics.GetBT709Luminance(ref Unsafe.Add(ref greyValuesBase, idx), luminanceLevels); Unsafe.Add(ref histogramBase, (uint)luminance)--; } } diff --git a/src/ImageSharp/Processing/Processors/Normalization/HistogramEqualizationProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Normalization/HistogramEqualizationProcessor{TPixel}.cs index 80f2b15bc1..6ac36f3ce0 100644 --- a/src/ImageSharp/Processing/Processors/Normalization/HistogramEqualizationProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Normalization/HistogramEqualizationProcessor{TPixel}.cs @@ -73,7 +73,7 @@ public static int CalculateCdf(ref int cdfBase, ref int histogramBase, int maxId int cdfMin = 0; bool cdfMinFound = false; - for (nint i = 0; i <= (uint)maxIdx; i++) + for (nuint i = 0; i <= (uint)maxIdx; i++) { histSum += Unsafe.Add(ref histogramBase, i); if (!cdfMinFound && histSum != 0) @@ -101,7 +101,7 @@ public void ClipHistogram(Span histogram, int clipLimit) int sumOverClip = 0; ref int histogramBase = ref MemoryMarshal.GetReference(histogram); - for (nint i = 0; i < (uint)histogram.Length; i++) + for (nuint i = 0; i < (uint)histogram.Length; i++) { ref int histogramLevel = ref Unsafe.Add(ref histogramBase, i); if (histogramLevel > clipLimit) @@ -115,7 +115,7 @@ public void ClipHistogram(Span histogram, int clipLimit) int addToEachBin = sumOverClip > 0 ? (int)MathF.Floor(sumOverClip / this.luminanceLevelsFloat) : 0; if (addToEachBin > 0) { - for (nint i = 0; i < (uint)histogram.Length; i++) + for (nuint i = 0; i < (uint)histogram.Length; i++) { Unsafe.Add(ref histogramBase, i) += addToEachBin; } @@ -124,8 +124,8 @@ public void ClipHistogram(Span histogram, int clipLimit) int residual = sumOverClip - (addToEachBin * this.LuminanceLevels); if (residual != 0) { - int residualStep = Math.Max(this.LuminanceLevels / residual, 1); - for (nint i = 0; i < (uint)this.LuminanceLevels && residual > 0; i += residualStep, residual--) + uint residualStep = (uint)Math.Max(this.LuminanceLevels / residual, 1); + for (nuint i = 0; i < (uint)this.LuminanceLevels && residual > 0; i += residualStep, residual--) { ref int histogramLevel = ref Unsafe.Add(ref histogramBase, i); histogramLevel++; diff --git a/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeKernelMap.cs b/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeKernelMap.cs index e492011788..c1907bb520 100644 --- a/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeKernelMap.cs +++ b/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeKernelMap.cs @@ -100,7 +100,7 @@ protected virtual void Dispose(bool disposing) /// Returns a for an index value between 0 and DestinationSize - 1. /// [MethodImpl(InliningOptions.ShortMethod)] - internal ref ResizeKernel GetKernel(nint destIdx) => ref this.kernels[destIdx]; + internal ref ResizeKernel GetKernel(nuint destIdx) => ref this.kernels[(int)destIdx]; /// /// Computes the weights to apply at each pixel when resizing. diff --git a/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeWorker.cs b/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeWorker.cs index 10525641ca..cce27a401c 100644 --- a/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeWorker.cs +++ b/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeWorker.cs @@ -119,7 +119,7 @@ public void FillDestinationPixels(RowInterval rowInterval, Buffer2D dest for (int y = rowInterval.Min; y < rowInterval.Max; y++) { // Ensure offsets are normalized for cropping and padding. - ResizeKernel kernel = this.verticalKernelMap.GetKernel(y - this.targetOrigin.Y); + ResizeKernel kernel = this.verticalKernelMap.GetKernel((uint)(y - this.targetOrigin.Y)); while (kernel.StartIndex + kernel.Length > this.currentWindow.Max) { @@ -132,9 +132,9 @@ public void FillDestinationPixels(RowInterval rowInterval, Buffer2D dest ref Vector4 fpBase = ref transposedFirstPassBufferSpan[top]; - for (nint x = 0; x < (right - left); x++) + for (nuint x = 0; x < (uint)(right - left); x++) { - ref Vector4 firstPassColumnBase = ref Unsafe.Add(ref fpBase, x * (nint)(uint)this.workerHeight); + ref Vector4 firstPassColumnBase = ref Unsafe.Add(ref fpBase, x * (uint)this.workerHeight); // Destination color components Unsafe.Add(ref tempRowBase, x) = kernel.ConvolveCore(ref firstPassColumnBase); @@ -169,9 +169,9 @@ private void CalculateFirstPassValues(RowInterval calculationInterval) Span tempRowSpan = this.tempRowBuffer.GetSpan(); Span transposedFirstPassBufferSpan = this.transposedFirstPassBuffer.DangerousGetSingleSpan(); - int left = this.targetWorkingRect.Left; - int right = this.targetWorkingRect.Right; - int targetOriginX = this.targetOrigin.X; + nuint left = (uint)this.targetWorkingRect.Left; + nuint right = (uint)this.targetWorkingRect.Right; + nuint targetOriginX = (uint)this.targetOrigin.X; for (int y = calculationInterval.Min; y < calculationInterval.Max; y++) { Span sourceRow = this.source.DangerousGetRowSpan(y); @@ -186,13 +186,13 @@ private void CalculateFirstPassValues(RowInterval calculationInterval) // Span firstPassSpan = transposedFirstPassBufferSpan.Slice(y - this.currentWindow.Min); ref Vector4 firstPassBaseRef = ref transposedFirstPassBufferSpan[y - this.currentWindow.Min]; - for (nint x = left, z = 0; x < (nint)(uint)right; x++, z++) + for (nuint x = left, z = 0; x < right; x++, z++) { ResizeKernel kernel = this.horizontalKernelMap.GetKernel(x - targetOriginX); // optimization for: // firstPassSpan[x * this.workerHeight] = kernel.Convolve(tempRowSpan); - Unsafe.Add(ref firstPassBaseRef, z * (nint)(uint)this.workerHeight) = kernel.Convolve(tempRowSpan); + Unsafe.Add(ref firstPassBaseRef, z * (uint)this.workerHeight) = kernel.Convolve(tempRowSpan); } } } diff --git a/tests/ImageSharp.Benchmarks/Bulk/FromVector4.cs b/tests/ImageSharp.Benchmarks/Bulk/FromVector4.cs index ed129fca2f..f0eeb5afb7 100644 --- a/tests/ImageSharp.Benchmarks/Bulk/FromVector4.cs +++ b/tests/ImageSharp.Benchmarks/Bulk/FromVector4.cs @@ -47,7 +47,7 @@ public void PerElement() { ref Vector4 s = ref MemoryMarshal.GetReference(this.source.GetSpan()); ref TPixel d = ref MemoryMarshal.GetReference(this.destination.GetSpan()); - for (nint i = 0; i < (uint)this.Count; i++) + for (nuint i = 0; i < (uint)this.Count; i++) { Unsafe.Add(ref d, i).FromVector4(Unsafe.Add(ref s, i)); } @@ -103,7 +103,7 @@ public void UseAvx2_Grouped() Span src = MemoryMarshal.Cast(this.source.GetSpan()); Span dest = MemoryMarshal.Cast(this.destination.GetSpan()); - nint n = (nint)(uint)dest.Length / Vector.Count; + nuint n = (uint)(dest.Length / Vector.Count); ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(src)); @@ -114,7 +114,7 @@ public void UseAvx2_Grouped() var maxBytes = Vector256.Create(255f); - for (nint i = 0; i < n; i++) + for (nuint i = 0; i < n; i++) { ref Vector256 s = ref Unsafe.Add(ref sourceBase, i * 4); diff --git a/tests/ImageSharp.Benchmarks/Bulk/PremultiplyVector4.cs b/tests/ImageSharp.Benchmarks/Bulk/PremultiplyVector4.cs index 355216de34..4e2d2d36e9 100644 --- a/tests/ImageSharp.Benchmarks/Bulk/PremultiplyVector4.cs +++ b/tests/ImageSharp.Benchmarks/Bulk/PremultiplyVector4.cs @@ -17,7 +17,7 @@ public void PremultiplyBaseline() { ref Vector4 baseRef = ref MemoryMarshal.GetReference(Vectors); - for (nint i = 0; i < (uint)Vectors.Length; i++) + for (nuint i = 0; i < (uint)Vectors.Length; i++) { ref Vector4 v = ref Unsafe.Add(ref baseRef, i); Premultiply(ref v); @@ -29,7 +29,7 @@ public void Premultiply() { ref Vector4 baseRef = ref MemoryMarshal.GetReference(Vectors); - for (nint i = 0; i < (uint)Vectors.Length; i++) + for (nuint i = 0; i < (uint)Vectors.Length; i++) { ref Vector4 v = ref Unsafe.Add(ref baseRef, i); Numerics.Premultiply(ref v); diff --git a/tests/ImageSharp.Benchmarks/Bulk/ToVector4_Rgba32.cs b/tests/ImageSharp.Benchmarks/Bulk/ToVector4_Rgba32.cs index 913ab24dc1..ce3fb70c88 100644 --- a/tests/ImageSharp.Benchmarks/Bulk/ToVector4_Rgba32.cs +++ b/tests/ImageSharp.Benchmarks/Bulk/ToVector4_Rgba32.cs @@ -54,13 +54,13 @@ public void ExtendedIntrinsics_BulkConvertByteToNormalizedFloat_2Loops() Span sBytes = MemoryMarshal.Cast(this.source.GetSpan()); Span dFloats = MemoryMarshal.Cast(this.destination.GetSpan()); - nint n = (nint)(uint)dFloats.Length / Vector.Count; + nuint n = (uint)(dFloats.Length / Vector.Count); ref Vector sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference((ReadOnlySpan)sBytes)); ref Vector destBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(dFloats)); ref Vector destBaseU = ref Unsafe.As, Vector>(ref destBase); - for (nint i = 0; i < n; i++) + for (nuint i = 0; i < n; i++) { Vector b = Unsafe.Add(ref sourceBase, i); @@ -75,10 +75,10 @@ public void ExtendedIntrinsics_BulkConvertByteToNormalizedFloat_2Loops() Unsafe.Add(ref d, 3) = w3; } - n = (nint)(uint)dFloats.Length / Vector.Count; + n = (uint)(dFloats.Length / Vector.Count); var scale = new Vector(1f / 255f); - for (nint i = 0; i < n; i++) + for (nuint i = 0; i < n; i++) { ref Vector dRef = ref Unsafe.Add(ref destBase, i); @@ -96,13 +96,13 @@ public void ExtendedIntrinsics_BulkConvertByteToNormalizedFloat_ConvertInSameLoo Span sBytes = MemoryMarshal.Cast(this.source.GetSpan()); Span dFloats = MemoryMarshal.Cast(this.destination.GetSpan()); - nint n = (nint)(uint)dFloats.Length / Vector.Count; + nuint n = (uint)(dFloats.Length / Vector.Count); ref Vector sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference((ReadOnlySpan)sBytes)); ref Vector destBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(dFloats)); var scale = new Vector(1f / 255f); - for (nint i = 0; i < n; i++) + for (nuint i = 0; i < n; i++) { Vector b = Unsafe.Add(ref sourceBase, i); diff --git a/tests/ImageSharp.Benchmarks/Bulk/UnPremultiplyVector4.cs b/tests/ImageSharp.Benchmarks/Bulk/UnPremultiplyVector4.cs index 309eea34fd..95fdd9a8c3 100644 --- a/tests/ImageSharp.Benchmarks/Bulk/UnPremultiplyVector4.cs +++ b/tests/ImageSharp.Benchmarks/Bulk/UnPremultiplyVector4.cs @@ -17,7 +17,7 @@ public void UnPremultiplyBaseline() { ref Vector4 baseRef = ref MemoryMarshal.GetReference(Vectors); - for (nint i = 0; i < (uint)Vectors.Length; i++) + for (nuint i = 0; i < (uint)Vectors.Length; i++) { ref Vector4 v = ref Unsafe.Add(ref baseRef, i); @@ -30,7 +30,7 @@ public void UnPremultiply() { ref Vector4 baseRef = ref MemoryMarshal.GetReference(Vectors); - for (nint i = 0; i < (uint)Vectors.Length; i++) + for (nuint i = 0; i < (uint)Vectors.Length; i++) { ref Vector4 v = ref Unsafe.Add(ref baseRef, i); Numerics.UnPremultiply(ref v); diff --git a/tests/ImageSharp.Benchmarks/Codecs/Jpeg/BlockOperations/Block8x8F_CopyTo1x1.cs b/tests/ImageSharp.Benchmarks/Codecs/Jpeg/BlockOperations/Block8x8F_CopyTo1x1.cs index abdd6908da..14598c747a 100644 --- a/tests/ImageSharp.Benchmarks/Codecs/Jpeg/BlockOperations/Block8x8F_CopyTo1x1.cs +++ b/tests/ImageSharp.Benchmarks/Codecs/Jpeg/BlockOperations/Block8x8F_CopyTo1x1.cs @@ -82,7 +82,7 @@ public void UseVector8() { ref Block8x8F s = ref this.block; ref float origin = ref Unsafe.AsRef(this.bufferPtr); - nint stride = (nint)(uint)Width; + nuint stride = (uint)Width; ref Vector d0 = ref Unsafe.As>(ref origin); ref Vector d1 = ref Unsafe.As>(ref Unsafe.Add(ref origin, stride)); @@ -117,7 +117,7 @@ public void UseVector8_V2() { ref Block8x8F s = ref this.block; ref float origin = ref Unsafe.AsRef(this.bufferPtr); - nint stride = (nint)(uint)Width; + nuint stride = (uint)Width; ref Vector d0 = ref Unsafe.As>(ref origin); ref Vector d1 = ref Unsafe.As>(ref Unsafe.Add(ref origin, stride)); @@ -141,7 +141,7 @@ public void UseVector8_V2() [Benchmark] public void UseVector8_V3() { - nint stride = (nint)(uint)Width * sizeof(float); + nuint stride = (uint)Width * sizeof(float); ref float d = ref this.unpinnedBuffer[0]; ref Vector s = ref Unsafe.As>(ref this.block); @@ -254,7 +254,7 @@ public void UseVector256_Avx2_Variant3() [Benchmark] public void UseVector256_Avx2_Variant3_RefCast() { - nint stride = (nint)(uint)Width; + nuint stride = (uint)Width; ref float d = ref this.unpinnedBuffer[0]; ref Vector256 s = ref Unsafe.As>(ref this.block); @@ -282,7 +282,7 @@ public void UseVector256_Avx2_Variant3_RefCast() [Benchmark] public void UseVector256_Avx2_Variant3_RefCast_Mod() { - nint stride = (nint)(uint)Width * sizeof(float); + nuint stride = (uint)Width * sizeof(float); ref float d = ref this.unpinnedBuffer[0]; ref Vector256 s = ref Unsafe.As>(ref this.block); diff --git a/tests/ImageSharp.Benchmarks/Codecs/Jpeg/BlockOperations/Block8x8F_Round.cs b/tests/ImageSharp.Benchmarks/Codecs/Jpeg/BlockOperations/Block8x8F_Round.cs index 2cc084885f..8a520b22d3 100644 --- a/tests/ImageSharp.Benchmarks/Codecs/Jpeg/BlockOperations/Block8x8F_Round.cs +++ b/tests/ImageSharp.Benchmarks/Codecs/Jpeg/BlockOperations/Block8x8F_Round.cs @@ -54,7 +54,7 @@ public void ScalarRound() { ref float b = ref Unsafe.As(ref this.block); - for (nint i = 0; i < Block8x8F.Size; i++) + for (nuint i = 0; i < Block8x8F.Size; i++) { ref float v = ref Unsafe.Add(ref b, i); v = (float)Math.Round(v); @@ -178,7 +178,7 @@ public unsafe void Sse41_V2() { ref Vector128 p = ref Unsafe.As>(ref this.block); p = Sse41.RoundToNearestInteger(p); - nint offset = sizeof(Vector128); + nuint offset = (uint)sizeof(Vector128); p = Sse41.RoundToNearestInteger(p); p = ref Unsafe.AddByteOffset(ref p, offset); @@ -218,7 +218,7 @@ public unsafe void Sse41_V3() { ref Vector128 p = ref Unsafe.As>(ref this.block); p = Sse41.RoundToNearestInteger(p); - nint offset = sizeof(Vector128); + nuint offset = (uint)sizeof(Vector128); for (int i = 0; i < 15; i++) { @@ -231,7 +231,7 @@ public unsafe void Sse41_V3() public unsafe void Sse41_V4() { ref Vector128 p = ref Unsafe.As>(ref this.block); - nint offset = sizeof(Vector128); + nuint offset = (uint)sizeof(Vector128); ref Vector128 a = ref p; ref Vector128 b = ref Unsafe.AddByteOffset(ref a, offset); diff --git a/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertFromRgba32.cs b/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertFromRgba32.cs index 29e03111b9..8d16849825 100644 --- a/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertFromRgba32.cs +++ b/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertFromRgba32.cs @@ -34,7 +34,7 @@ public void RunByRefConversion() ref T destBaseRef = ref this.Dest[0]; ref Rgba32 sourceBaseRef = ref this.Source[0]; - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { Unsafe.Add(ref destBaseRef, i).FromRgba32(ref Unsafe.Add(ref sourceBaseRef, i)); } @@ -48,7 +48,7 @@ public void RunByValConversion() ref T destBaseRef = ref this.Dest[0]; ref Rgba32 sourceBaseRef = ref this.Source[0]; - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { Unsafe.Add(ref destBaseRef, i).FromRgba32(Unsafe.Add(ref sourceBaseRef, i)); } @@ -62,7 +62,7 @@ public void RunFromBytesConversion() ref T destBaseRef = ref this.Dest[0]; ref Rgba32 sourceBaseRef = ref this.Source[0]; - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref Rgba32 s = ref Unsafe.Add(ref sourceBaseRef, i); Unsafe.Add(ref destBaseRef, i).FromBytes(s.R, s.G, s.B, s.A); @@ -111,7 +111,7 @@ public void Inline() ref Rgba32 sBase = ref this.CompatibleMemLayoutRunner.Source[0]; ref Rgba32 dBase = ref Unsafe.As(ref this.CompatibleMemLayoutRunner.Dest[0]); - for (nint i = 0; i < (uint)this.Count; i++) + for (nuint i = 0; i < (uint)this.Count; i++) { Unsafe.Add(ref dBase, i) = Unsafe.Add(ref sBase, i); } @@ -151,7 +151,7 @@ public void InlineShuffle() ref Rgba32 sBase = ref this.PermutedRunnerRgbaToArgb.Source[0]; ref TestArgb dBase = ref this.PermutedRunnerRgbaToArgb.Dest[0]; - for (nint i = 0; i < (uint)this.Count; i++) + for (nuint i = 0; i < (uint)this.Count; i++) { Rgba32 s = Unsafe.Add(ref sBase, i); ref TestArgb d = ref Unsafe.Add(ref dBase, i); diff --git a/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertFromVector4.cs b/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertFromVector4.cs index faf23efe09..dd85d06417 100644 --- a/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertFromVector4.cs +++ b/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertFromVector4.cs @@ -71,7 +71,7 @@ public void RunByRefConversion() ref T destBaseRef = ref this.dest[0]; ref Vector4 sourceBaseRef = ref this.source[0]; - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { Unsafe.Add(ref destBaseRef, i).FromVector4(ref Unsafe.Add(ref sourceBaseRef, i)); } @@ -85,7 +85,7 @@ public void RunByValConversion() ref T destBaseRef = ref this.dest[0]; ref Vector4 sourceBaseRef = ref this.source[0]; - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { Unsafe.Add(ref destBaseRef, i).FromVector4(Unsafe.Add(ref sourceBaseRef, i)); } diff --git a/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertToRgba32.cs b/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertToRgba32.cs index ef1ebdd429..1a03a0c04f 100644 --- a/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertToRgba32.cs +++ b/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertToRgba32.cs @@ -38,7 +38,7 @@ public void RunRetvalConversion() ref T sourceBaseRef = ref this.source[0]; ref Rgba32 destBaseRef = ref this.dest[0]; - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { Unsafe.Add(ref destBaseRef, i) = Unsafe.Add(ref sourceBaseRef, i).ToRgba32(); } @@ -52,7 +52,7 @@ public void RunCopyToConversion() ref T sourceBaseRef = ref this.source[0]; ref Rgba32 destBaseRef = ref this.dest[0]; - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { Unsafe.Add(ref sourceBaseRef, i).CopyToRgba32(ref Unsafe.Add(ref destBaseRef, i)); } diff --git a/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertToRgba32_AsPartOfCompositeOperation.cs b/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertToRgba32_AsPartOfCompositeOperation.cs index 29412e6ed6..69a71734a3 100644 --- a/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertToRgba32_AsPartOfCompositeOperation.cs +++ b/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertToRgba32_AsPartOfCompositeOperation.cs @@ -33,7 +33,7 @@ public void RunRetvalConversion() Rgba32 temp; - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { temp = Unsafe.Add(ref sourceBaseRef, i).ToRgba32(); @@ -54,7 +54,7 @@ public void RunCopyToConversion() Rgba32 temp = default; - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { Unsafe.Add(ref sourceBaseRef, i).CopyToRgba32(ref temp); diff --git a/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertToVector4.cs b/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertToVector4.cs index 29e8b00b6f..9b498b0f2e 100644 --- a/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertToVector4.cs +++ b/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertToVector4.cs @@ -30,7 +30,7 @@ public void RunRetvalConversion() ref T sourceBaseRef = ref this.source[0]; ref Vector4 destBaseRef = ref this.dest[0]; - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { Unsafe.Add(ref destBaseRef, i) = Unsafe.Add(ref sourceBaseRef, i).ToVector4(); } @@ -44,7 +44,7 @@ public void RunCopyToConversion() ref T sourceBaseRef = ref this.source[0]; ref Vector4 destBaseRef = ref this.dest[0]; - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { Unsafe.Add(ref sourceBaseRef, i).CopyToVector4(ref Unsafe.Add(ref destBaseRef, i)); } diff --git a/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertToVector4_AsPartOfCompositeOperation.cs b/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertToVector4_AsPartOfCompositeOperation.cs index 65b1717349..50c3d0d131 100644 --- a/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertToVector4_AsPartOfCompositeOperation.cs +++ b/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertToVector4_AsPartOfCompositeOperation.cs @@ -32,7 +32,7 @@ public void RunRetvalConversion() Vector4 temp; - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { temp = Unsafe.Add(ref sourceBaseRef, i).ToVector4(); @@ -53,7 +53,7 @@ public void RunCopyToConversion() Vector4 temp = default; - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { Unsafe.Add(ref sourceBaseRef, i).CopyToVector4(ref temp); diff --git a/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_PackFromRgbPlanes.cs b/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_PackFromRgbPlanes.cs index 5c9bfd763a..e3677d238d 100644 --- a/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_PackFromRgbPlanes.cs +++ b/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_PackFromRgbPlanes.cs @@ -92,7 +92,7 @@ public void Rgb24_Scalar_PerElement_Unsafe() ref byte b = ref this.rBuf[0]; ref Rgb24 rgb = ref this.rgbBuf[0]; - for (nint i = 0; i < (uint)this.Count; i++) + for (nuint i = 0; i < (uint)this.Count; i++) { ref Rgb24 d = ref Unsafe.Add(ref rgb, i); d.R = Unsafe.Add(ref r, i); @@ -110,7 +110,7 @@ public void Rgb24_Scalar_PerElement_Batched8() ref Rgb24 rgb = ref this.rgbBuf[0]; int count = this.Count / 8; - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref Rgb24 d0 = ref Unsafe.Add(ref rgb, i * 8); ref Rgb24 d1 = ref Unsafe.Add(ref d0, 1); @@ -168,7 +168,7 @@ public void Rgb24_Scalar_PerElement_Batched4() ref Rgb24 rgb = ref this.rgbBuf[0]; int count = this.Count / 4; - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { ref Rgb24 d0 = ref Unsafe.Add(ref rgb, i * 4); ref Rgb24 d1 = ref Unsafe.Add(ref d0, 1); @@ -205,14 +205,14 @@ public void Rgba32_Avx2_Float() ref Vector256 bBase = ref Unsafe.As>(ref this.bFloat[0]); ref Vector256 resultBase = ref Unsafe.As>(ref this.rgbaFloat[0]); - nint count = (nint)(uint)this.Count / Vector256.Count; + nuint count = (uint)(this.Count / Vector256.Count); ref byte control = ref MemoryMarshal.GetReference(SimdUtils.HwIntrinsics.PermuteMaskEvenOdd8x32); Vector256 vcontrol = Unsafe.As>(ref control); var va = Vector256.Create(1F); - for (nint i = 0; i < count; i++) + for (nuint i = 0; i < count; i++) { Vector256 r = Unsafe.Add(ref rBase, i); Vector256 g = Unsafe.Add(ref gBase, i); diff --git a/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_Rgba32_To_Argb32.cs b/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_Rgba32_To_Argb32.cs index f1d08b9fb9..0ee507832a 100644 --- a/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_Rgba32_To_Argb32.cs +++ b/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_Rgba32_To_Argb32.cs @@ -31,7 +31,7 @@ public void Default() ref Rgba32 sBase = ref this.source[0]; ref Argb32 dBase = ref this.dest[0]; - for (nint i = 0; i < (uint)this.Count; i++) + for (nuint i = 0; i < (uint)this.Count; i++) { Rgba32 s = Unsafe.Add(ref sBase, i); Unsafe.Add(ref dBase, i).FromRgba32(s); @@ -45,7 +45,7 @@ private static void Default_GenericImpl(ReadOnlySpan source, Spa ref Rgba32 sBase = ref MemoryMarshal.GetReference(source); ref TPixel dBase = ref MemoryMarshal.GetReference(dest); - for (nint i = 0; i < (uint)source.Length; i++) + for (nuint i = 0; i < (uint)source.Length; i++) { Rgba32 s = Unsafe.Add(ref sBase, i); Unsafe.Add(ref dBase, i).FromRgba32(s); @@ -64,7 +64,7 @@ public void Default_Group2() ref Rgba32 sBase = ref this.source[0]; ref Argb32 dBase = ref this.dest[0]; - for (nint i = 0; i < (uint)this.Count; i += 2) + for (nuint i = 0; i < (uint)this.Count; i += 2) { ref Rgba32 s0 = ref Unsafe.Add(ref sBase, i); Rgba32 s1 = Unsafe.Add(ref s0, 1); @@ -81,7 +81,7 @@ public void Default_Group4() ref Rgba32 sBase = ref this.source[0]; ref Argb32 dBase = ref this.dest[0]; - for (nint i = 0; i < (uint)this.Count; i += 4) + for (nuint i = 0; i < (uint)this.Count; i += 4) { ref Rgba32 s0 = ref Unsafe.Add(ref sBase, i); ref Rgba32 s1 = ref Unsafe.Add(ref s0, 1); @@ -105,7 +105,7 @@ public void BitOps() ref uint sBase = ref Unsafe.As(ref this.source[0]); ref uint dBase = ref Unsafe.As(ref this.dest[0]); - for (nint i = 0; i < (uint)this.Count; i++) + for (nuint i = 0; i < (uint)this.Count; i++) { uint s = Unsafe.Add(ref sBase, i); Unsafe.Add(ref dBase, i) = FromRgba32.ToArgb32(s); @@ -118,7 +118,7 @@ public void BitOps_GroupAsULong() ref ulong sBase = ref Unsafe.As(ref this.source[0]); ref ulong dBase = ref Unsafe.As(ref this.dest[0]); - for (nint i = 0; i < (uint)this.Count / 2; i++) + for (nuint i = 0; i < (uint)this.Count / 2; i++) { ulong s = Unsafe.Add(ref sBase, i); uint lo = (uint)s; diff --git a/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_Rgba32_To_Bgra32.cs b/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_Rgba32_To_Bgra32.cs index 0da28c897d..499f3483dc 100644 --- a/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_Rgba32_To_Bgra32.cs +++ b/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_Rgba32_To_Bgra32.cs @@ -52,7 +52,7 @@ public void Default() ref Rgba32 sBase = ref this.source[0]; ref Bgra32 dBase = ref this.dest[0]; - for (nint i = 0; i < (uint)this.Count; i++) + for (nuint i = 0; i < (uint)this.Count; i++) { ref Rgba32 s = ref Unsafe.Add(ref sBase, i); Unsafe.Add(ref dBase, i).FromRgba32(s); @@ -66,7 +66,7 @@ private static void Default_GenericImpl(ReadOnlySpan source, Spa ref Rgba32 sBase = ref MemoryMarshal.GetReference(source); ref TPixel dBase = ref MemoryMarshal.GetReference(dest); - for (nint i = 0; i < (uint)source.Length; i++) + for (nuint i = 0; i < (uint)source.Length; i++) { ref Rgba32 s = ref Unsafe.Add(ref sBase, i); Unsafe.Add(ref dBase, i).FromRgba32(s); @@ -85,7 +85,7 @@ public void Default_Group2() ref Rgba32 sBase = ref this.source[0]; ref Bgra32 dBase = ref this.dest[0]; - for (nint i = 0; i < (uint)this.Count; i += 2) + for (nuint i = 0; i < (uint)this.Count; i += 2) { ref Rgba32 s0 = ref Unsafe.Add(ref sBase, i); Rgba32 s1 = Unsafe.Add(ref s0, 1); @@ -102,7 +102,7 @@ public void Default_Group4() ref Rgba32 sBase = ref this.source[0]; ref Bgra32 dBase = ref this.dest[0]; - for (nint i = 0; i < (uint)this.Count; i += 4) + for (nuint i = 0; i < (uint)this.Count; i += 4) { ref Rgba32 s0 = ref Unsafe.Add(ref sBase, i); ref Rgba32 s1 = ref Unsafe.Add(ref s0, 1); @@ -127,7 +127,7 @@ private static void Group4GenericImpl(ReadOnlySpan source, Span< ref Rgba32 sBase = ref MemoryMarshal.GetReference(source); ref TPixel dBase = ref MemoryMarshal.GetReference(dest); - for (nint i = 0; i < (uint)source.Length; i += 4) + for (nuint i = 0; i < (uint)source.Length; i += 4) { ref Rgba32 s0 = ref Unsafe.Add(ref sBase, i); ref Rgba32 s1 = ref Unsafe.Add(ref s0, 1); @@ -157,7 +157,7 @@ public void Default_Group8() ref Rgba32 sBase = ref this.source[0]; ref Bgra32 dBase = ref this.dest[0]; - for (nint i = 0; i < (uint)this.Count / 4; i += 4) + for (nuint i = 0; i < (uint)this.Count / 4; i += 4) { ref Rgba32 s0 = ref Unsafe.Add(ref sBase, i); ref Rgba32 s1 = ref Unsafe.Add(ref s0, 1); @@ -196,7 +196,7 @@ public void BitOps() ref uint sBase = ref Unsafe.As(ref this.source[0]); ref uint dBase = ref Unsafe.As(ref this.dest[0]); - for (nint i = 0; i < (uint)this.Count; i++) + for (nuint i = 0; i < (uint)this.Count; i++) { uint s = Unsafe.Add(ref sBase, i); Unsafe.Add(ref dBase, i) = FromRgba32.ToBgra32(s); @@ -209,7 +209,7 @@ public void Bitops_Tuple() ref Tuple4OfUInt32 sBase = ref Unsafe.As(ref this.source[0]); ref Tuple4OfUInt32 dBase = ref Unsafe.As(ref this.dest[0]); - for (nint i = 0; i < (uint)this.Count / 4; i++) + for (nuint i = 0; i < (uint)this.Count / 4; i++) { ref Tuple4OfUInt32 d = ref Unsafe.Add(ref dBase, i); d = Unsafe.Add(ref sBase, i); @@ -222,7 +222,7 @@ public void Bitops_SingleTuple() { ref Tuple4OfUInt32 sBase = ref Unsafe.As(ref this.source[0]); - for (nint i = 0; i < (uint)this.Count / 4; i++) + for (nuint i = 0; i < (uint)this.Count / 4; i++) { Unsafe.Add(ref sBase, i).ConvertMe(); } @@ -234,7 +234,7 @@ public void Bitops_Simd() ref Octet sBase = ref Unsafe.As>(ref this.source[0]); ref Octet dBase = ref Unsafe.As>(ref this.dest[0]); - for (nint i = 0; i < (uint)this.Count / 8; i++) + for (nuint i = 0; i < (uint)this.Count / 8; i++) { BitopsSimdImpl(ref Unsafe.Add(ref sBase, i), ref Unsafe.Add(ref dBase, i)); } @@ -289,7 +289,7 @@ public void BitOps_Group2() ref uint sBase = ref Unsafe.As(ref this.source[0]); ref uint dBase = ref Unsafe.As(ref this.dest[0]); - for (nint i = 0; i < (uint)this.Count; i++) + for (nuint i = 0; i < (uint)this.Count; i++) { ref uint s0 = ref Unsafe.Add(ref sBase, i); uint s1 = Unsafe.Add(ref s0, 1); @@ -306,7 +306,7 @@ public void BitOps_GroupAsULong() ref ulong sBase = ref Unsafe.As(ref this.source[0]); ref ulong dBase = ref Unsafe.As(ref this.dest[0]); - for (nint i = 0; i < (uint)this.Count / 2; i++) + for (nuint i = 0; i < (uint)this.Count / 2; i++) { ulong s = Unsafe.Add(ref sBase, i); uint lo = (uint)s; @@ -326,7 +326,7 @@ public void BitOps_GroupAsULong_V2() ref ulong sBase = ref Unsafe.As(ref this.source[0]); ref ulong dBase = ref Unsafe.As(ref this.dest[0]); - for (nint i = 0; i < (uint)this.Count / 2; i++) + for (nuint i = 0; i < (uint)this.Count / 2; i++) { ulong s = Unsafe.Add(ref sBase, i); uint lo = (uint)s; diff --git a/tests/ImageSharp.Benchmarks/General/Vectorization/UInt32ToSingle.cs b/tests/ImageSharp.Benchmarks/General/Vectorization/UInt32ToSingle.cs index 57c7b6faf7..010e1f52b3 100644 --- a/tests/ImageSharp.Benchmarks/General/Vectorization/UInt32ToSingle.cs +++ b/tests/ImageSharp.Benchmarks/General/Vectorization/UInt32ToSingle.cs @@ -25,14 +25,14 @@ public void MagicMethod() { ref Vector b = ref Unsafe.As>(ref this.data[0]); - nint n = Count / Vector.Count; + nuint n = (uint)(Count / Vector.Count); var bVec = new Vector(256.0f / 255.0f); var magicFloat = new Vector(32768.0f); var magicInt = new Vector(1191182336); // reinterpreted value of 32768.0f var mask = new Vector(255); - for (nint i = 0; i < n; i++) + for (nuint i = 0; i < n; i++) { ref Vector df = ref Unsafe.Add(ref b, i); @@ -50,14 +50,14 @@ public void MagicMethod() [Benchmark] public void StandardSimd() { - nint n = Count / Vector.Count; + nuint n = (uint)(Count / Vector.Count); ref Vector bf = ref Unsafe.As>(ref this.data[0]); ref Vector bu = ref Unsafe.As, Vector>(ref bf); var scale = new Vector(1f / 255f); - for (nint i = 0; i < n; i++) + for (nuint i = 0; i < n; i++) { Vector u = Unsafe.Add(ref bu, i); Vector v = Vector.ConvertToSingle(u); @@ -69,14 +69,14 @@ public void StandardSimd() [Benchmark] public void StandardSimdFromInt() { - nint n = Count / Vector.Count; + nuint n = (uint)(Count / Vector.Count); ref Vector bf = ref Unsafe.As>(ref this.data[0]); ref Vector bu = ref Unsafe.As, Vector>(ref bf); var scale = new Vector(1f / 255f); - for (nint i = 0; i < n; i++) + for (nuint i = 0; i < n; i++) { Vector u = Unsafe.Add(ref bu, i); Vector v = Vector.ConvertToSingle(u); @@ -88,12 +88,12 @@ public void StandardSimdFromInt() [Benchmark] public void StandardSimdFromInt_RefCast() { - nint n = Count / Vector.Count; + nuint n = (uint)(Count / Vector.Count); ref Vector bf = ref Unsafe.As>(ref this.data[0]); var scale = new Vector(1f / 255f); - for (nint i = 0; i < n; i++) + for (nuint i = 0; i < n; i++) { ref Vector fRef = ref Unsafe.Add(ref bf, i); diff --git a/tests/ImageSharp.Benchmarks/General/Vectorization/VectorFetching.cs b/tests/ImageSharp.Benchmarks/General/Vectorization/VectorFetching.cs index 7da2626dcc..32027729b2 100644 --- a/tests/ImageSharp.Benchmarks/General/Vectorization/VectorFetching.cs +++ b/tests/ImageSharp.Benchmarks/General/Vectorization/VectorFetching.cs @@ -63,9 +63,9 @@ public void FetchWithUnsafeCast() var v = new Vector(this.testValue); ref Vector start = ref Unsafe.As>(ref this.data[0]); - nint n = (nint)(uint)this.InputSize / Vector.Count; + nuint n = (uint)(this.InputSize / Vector.Count); - for (nint i = 0; i < n; i++) + for (nuint i = 0; i < n; i++) { ref Vector p = ref Unsafe.Add(ref start, i); @@ -82,9 +82,9 @@ public void FetchWithUnsafeCastNoTempVector() var v = new Vector(this.testValue); ref Vector start = ref Unsafe.As>(ref this.data[0]); - nint n = (nint)(uint)this.InputSize / Vector.Count; + nuint n = (uint)(this.InputSize / Vector.Count); - for (nint i = 0; i < n; i++) + for (nuint i = 0; i < n; i++) { ref Vector a = ref Unsafe.Add(ref start, i); a *= v; @@ -100,9 +100,9 @@ public void FetchWithUnsafeCastFromReference() ref Vector start = ref Unsafe.As>(ref MemoryMarshal.GetReference(span)); - nint n = (nint)(uint)this.InputSize / Vector.Count; + nuint n = (uint)(this.InputSize / Vector.Count); - for (nint i = 0; i < n; i++) + for (nuint i = 0; i < n; i++) { ref Vector a = ref Unsafe.Add(ref start, i); a *= v; diff --git a/tests/ImageSharp.Benchmarks/General/Vectorization/WidenBytesToUInt32.cs b/tests/ImageSharp.Benchmarks/General/Vectorization/WidenBytesToUInt32.cs index 586618fcb1..6ad7827eb1 100644 --- a/tests/ImageSharp.Benchmarks/General/Vectorization/WidenBytesToUInt32.cs +++ b/tests/ImageSharp.Benchmarks/General/Vectorization/WidenBytesToUInt32.cs @@ -33,7 +33,7 @@ public void Standard() ref Octet sBase = ref Unsafe.As>(ref this.source[0]); ref Octet dBase = ref Unsafe.As>(ref this.dest[0]); - for (nint i = 0; i < N; i++) + for (nuint i = 0; i < N; i++) { Unsafe.Add(ref dBase, i).LoadFrom(ref Unsafe.Add(ref sBase, i)); } @@ -42,12 +42,12 @@ public void Standard() [Benchmark] public void Simd() { - nint n = Count / Vector.Count; + nuint n = (uint)(Count / Vector.Count); ref Vector sBase = ref Unsafe.As>(ref this.source[0]); ref Vector dBase = ref Unsafe.As>(ref this.dest[0]); - for (nint i = 0; i < n; i++) + for (nuint i = 0; i < n; i++) { Vector b = Unsafe.Add(ref sBase, i); diff --git a/tests/ImageSharp.Benchmarks/PixelBlenders/PorterDuffBulkVsSingleVector.cs b/tests/ImageSharp.Benchmarks/PixelBlenders/PorterDuffBulkVsSingleVector.cs index 33f5720aab..ecf8b125f7 100644 --- a/tests/ImageSharp.Benchmarks/PixelBlenders/PorterDuffBulkVsSingleVector.cs +++ b/tests/ImageSharp.Benchmarks/PixelBlenders/PorterDuffBulkVsSingleVector.cs @@ -58,7 +58,7 @@ public Vector256 OverlayValueFunction_Avx() Vector256 result = default; Vector256 opacity = Vector256.Create(.5F); int count = this.backdrop.Length / 2; - for (nint i = 0; i < (uint)count; i++) + for (nuint i = 0; i < (uint)count; i++) { result = PorterDuffFunctions.NormalSrcOver(Unsafe.Add(ref backdrop, i), Unsafe.Add(ref source, i), opacity); } diff --git a/tests/ImageSharp.Tests/Common/SimdUtilsTests.Shuffle.cs b/tests/ImageSharp.Tests/Common/SimdUtilsTests.Shuffle.cs index 960b0613e6..ba37ee1661 100644 --- a/tests/ImageSharp.Tests/Common/SimdUtilsTests.Shuffle.cs +++ b/tests/ImageSharp.Tests/Common/SimdUtilsTests.Shuffle.cs @@ -493,10 +493,10 @@ private static void TestShuffleFloat4Channel( SimdUtils.Shuffle.InverseMMShuffle( control, - out int p3, - out int p2, - out int p1, - out int p0); + out uint p3, + out uint p2, + out uint p1, + out uint p0); for (int i = 0; i < expected.Length; i += 4) { @@ -524,10 +524,10 @@ private static void TestShuffleByte4Channel( SimdUtils.Shuffle.InverseMMShuffle( control, - out int p3, - out int p2, - out int p1, - out int p0); + out uint p3, + out uint p2, + out uint p1, + out uint p0); for (int i = 0; i < expected.Length; i += 4) { @@ -555,10 +555,10 @@ private static void TestShuffleByte3Channel( SimdUtils.Shuffle.InverseMMShuffle( control, - out int _, - out int p2, - out int p1, - out int p0); + out uint _, + out uint p2, + out uint p1, + out uint p0); for (int i = 0; i < expected.Length; i += 3) { @@ -586,10 +586,10 @@ private static void TestPad3Shuffle4Channel( SimdUtils.Shuffle.InverseMMShuffle( control, - out int p3, - out int p2, - out int p1, - out int p0); + out uint p3, + out uint p2, + out uint p1, + out uint p0); for (int i = 0, j = 0; i < expected.Length; i += 4, j += 3) { @@ -607,10 +607,10 @@ private static void TestPad3Shuffle4Channel( temp[2] = source[j + 2]; temp[3] = byte.MaxValue; - expected[i] = temp[p0]; - expected[i + 1] = temp[p1]; - expected[i + 2] = temp[p2]; - expected[i + 3] = temp[p3]; + expected[i] = temp[(int)p0]; + expected[i + 1] = temp[(int)p1]; + expected[i + 2] = temp[(int)p2]; + expected[i + 3] = temp[(int)p3]; } convert(source, result); @@ -637,10 +637,10 @@ private static void TestShuffle4Slice3Channel( SimdUtils.Shuffle.InverseMMShuffle( control, - out int _, - out int p2, - out int p1, - out int p0); + out uint _, + out uint p2, + out uint p1, + out uint p0); for (int i = 0, j = 0; i < expected.Length; i += 3, j += 4) { diff --git a/tests/ImageSharp.Tests/Formats/Png/PngEncoderFilterTests.cs b/tests/ImageSharp.Tests/Formats/Png/PngEncoderFilterTests.cs index e50e40bd22..796d35bf72 100644 --- a/tests/ImageSharp.Tests/Formats/Png/PngEncoderFilterTests.cs +++ b/tests/ImageSharp.Tests/Formats/Png/PngEncoderFilterTests.cs @@ -287,7 +287,7 @@ public void TestFilter() break; case PngFilterMethod.Average: - AverageFilter.Encode(this.previousScanline, this.scanline, this.resultBuffer, this.bpp, out sum); + AverageFilter.Encode(this.previousScanline, this.scanline, this.resultBuffer, (uint)this.bpp, out sum); break; case PngFilterMethod.Paeth: diff --git a/tests/ImageSharp.Tests/Formats/Png/ReferenceImplementations.cs b/tests/ImageSharp.Tests/Formats/Png/ReferenceImplementations.cs index 7610023afc..d57a775876 100644 --- a/tests/ImageSharp.Tests/Formats/Png/ReferenceImplementations.cs +++ b/tests/ImageSharp.Tests/Formats/Png/ReferenceImplementations.cs @@ -34,8 +34,8 @@ public static void EncodePaethFilter(ReadOnlySpan scanline, Span pre // Paeth(x) = Raw(x) - PaethPredictor(Raw(x-bpp), Prior(x), Prior(x - bpp)) resultBaseRef = 4; - nint x = 0; - for (; x < (nint)(uint)bytesPerPixel; /* Note: ++x happens in the body to avoid one add operation */) + int x = 0; + for (; x < bytesPerPixel; /* Note: ++x happens in the body to avoid one add operation */) { byte scan = Unsafe.Add(ref scanBaseRef, x); byte above = Unsafe.Add(ref prevBaseRef, x); @@ -45,7 +45,7 @@ public static void EncodePaethFilter(ReadOnlySpan scanline, Span pre sum += Numerics.Abs(unchecked((sbyte)res)); } - for (nint xLeft = x - (nint)(uint)bytesPerPixel; x < (nint)(uint)scanline.Length; ++xLeft /* Note: ++x happens in the body to avoid one add operation */) + for (int xLeft = x - bytesPerPixel; x < scanline.Length; ++xLeft /* Note: ++x happens in the body to avoid one add operation */) { byte scan = Unsafe.Add(ref scanBaseRef, x); byte left = Unsafe.Add(ref scanBaseRef, xLeft); @@ -77,8 +77,8 @@ public static void EncodeSubFilter(ReadOnlySpan scanline, Span resul // Sub(x) = Raw(x) - Raw(x-bpp) resultBaseRef = 1; - nint x = 0; - for (; x < (nint)(uint)bytesPerPixel; /* Note: ++x happens in the body to avoid one add operation */) + int x = 0; + for (; x < bytesPerPixel; /* Note: ++x happens in the body to avoid one add operation */) { byte scan = Unsafe.Add(ref scanBaseRef, x); ++x; @@ -87,7 +87,7 @@ public static void EncodeSubFilter(ReadOnlySpan scanline, Span resul sum += Numerics.Abs(unchecked((sbyte)res)); } - for (nint xLeft = x - (nint)(uint)bytesPerPixel; x < (nint)(uint)scanline.Length; ++xLeft /* Note: ++x happens in the body to avoid one add operation */) + for (int xLeft = x - bytesPerPixel; x < scanline.Length; ++xLeft /* Note: ++x happens in the body to avoid one add operation */) { byte scan = Unsafe.Add(ref scanBaseRef, x); byte prev = Unsafe.Add(ref scanBaseRef, xLeft); @@ -119,9 +119,9 @@ public static void EncodeUpFilter(ReadOnlySpan scanline, Span previo // Up(x) = Raw(x) - Prior(x) resultBaseRef = 2; - nint x = 0; + int x = 0; - for (; x < (nint)(uint)scanline.Length; /* Note: ++x happens in the body to avoid one add operation */) + for (; x < scanline.Length; /* Note: ++x happens in the body to avoid one add operation */) { byte scan = Unsafe.Add(ref scanBaseRef, x); byte above = Unsafe.Add(ref prevBaseRef, x); @@ -154,8 +154,8 @@ public static void EncodeAverageFilter(ReadOnlySpan scanline, ReadOnlySpan // Average(x) = Raw(x) - floor((Raw(x-bpp)+Prior(x))/2) resultBaseRef = 3; - nint x = 0; - for (; x < (nint)(uint)bytesPerPixel; /* Note: ++x happens in the body to avoid one add operation */) + int x = 0; + for (; x < bytesPerPixel; /* Note: ++x happens in the body to avoid one add operation */) { byte scan = Unsafe.Add(ref scanBaseRef, x); byte above = Unsafe.Add(ref prevBaseRef, x); @@ -165,7 +165,7 @@ public static void EncodeAverageFilter(ReadOnlySpan scanline, ReadOnlySpan sum += Numerics.Abs(unchecked((sbyte)res)); } - for (nint xLeft = x - (nint)(uint)bytesPerPixel; x < (nint)(uint)scanline.Length; ++xLeft /* Note: ++x happens in the body to avoid one add operation */) + for (int xLeft = x - bytesPerPixel; x < scanline.Length; ++xLeft /* Note: ++x happens in the body to avoid one add operation */) { byte scan = Unsafe.Add(ref scanBaseRef, x); byte left = Unsafe.Add(ref scanBaseRef, xLeft); diff --git a/tests/ImageSharp.Tests/PixelFormats/PixelConverterTests.ReferenceImplementations.cs b/tests/ImageSharp.Tests/PixelFormats/PixelConverterTests.ReferenceImplementations.cs index 521270e3be..006cb9eb61 100644 --- a/tests/ImageSharp.Tests/PixelFormats/PixelConverterTests.ReferenceImplementations.cs +++ b/tests/ImageSharp.Tests/PixelFormats/PixelConverterTests.ReferenceImplementations.cs @@ -100,7 +100,7 @@ internal static void To( if (typeof(TDestinationPixel) == typeof(L16)) { ref L16 l16Ref = ref MemoryMarshal.GetReference(MemoryMarshal.Cast(destinationPixels)); - for (nint i = 0; i < (uint)count; i++) + for (int i = 0; i < count; i++) { ref TSourcePixel sp = ref Unsafe.Add(ref sourceRef, i); ref L16 dp = ref Unsafe.Add(ref l16Ref, i); @@ -113,7 +113,7 @@ internal static void To( if (typeof(TDestinationPixel) == typeof(L8)) { ref L8 l8Ref = ref MemoryMarshal.GetReference(MemoryMarshal.Cast(destinationPixels)); - for (nint i = 0; i < (uint)count; i++) + for (int i = 0; i < count; i++) { ref TSourcePixel sp = ref Unsafe.Add(ref sourceRef, i); ref L8 dp = ref Unsafe.Add(ref l8Ref, i); @@ -125,7 +125,7 @@ internal static void To( // Normal conversion ref TDestinationPixel destRef = ref MemoryMarshal.GetReference(destinationPixels); - for (nint i = 0; i < (uint)count; i++) + for (int i = 0; i < count; i++) { ref TSourcePixel sp = ref Unsafe.Add(ref sourceRef, i); ref TDestinationPixel dp = ref Unsafe.Add(ref destRef, i); diff --git a/tests/ImageSharp.Tests/PixelFormats/PixelOperations/PixelOperationsTests.cs b/tests/ImageSharp.Tests/PixelFormats/PixelOperations/PixelOperationsTests.cs index 73305183f6..a9b3ee9a42 100644 --- a/tests/ImageSharp.Tests/PixelFormats/PixelOperations/PixelOperationsTests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/PixelOperations/PixelOperationsTests.cs @@ -1184,7 +1184,7 @@ public byte this[int idx] get { ref byte self = ref Unsafe.As(ref this); - return Unsafe.Add(ref self, (uint)idx); + return Unsafe.Add(ref self, idx); } } } diff --git a/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeKernelMapTests.cs b/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeKernelMapTests.cs index 3cea431fbb..c6da46ee2f 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeKernelMapTests.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeKernelMapTests.cs @@ -128,7 +128,7 @@ private void VerifyKernelMapContentIsCorrect(TResampler resampler, i for (int i = 0; i < kernelMap.DestinationLength; i++) { - ResizeKernel kernel = kernelMap.GetKernel(i); + ResizeKernel kernel = kernelMap.GetKernel((uint)i); ReferenceKernel referenceKernel = referenceMap.GetKernel(i); @@ -153,7 +153,7 @@ private void VerifyKernelMapContentIsCorrect(TResampler resampler, i } private static string PrintKernelMap(ResizeKernelMap kernelMap) - => PrintKernelMap(kernelMap, km => km.DestinationLength, (km, i) => km.GetKernel(i)); + => PrintKernelMap(kernelMap, km => km.DestinationLength, (km, i) => km.GetKernel((uint)i)); private static string PrintKernelMap(ReferenceKernelMap kernelMap) => PrintKernelMap(kernelMap, km => km.DestinationSize, (km, i) => km.GetKernel(i)); From a95ab1768086d46f5fd70d713d7d88b934bfc9c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=BCnther=20Foidl?= Date: Mon, 20 Mar 2023 22:56:23 +0100 Subject: [PATCH 09/12] Removed unnecessary comments --- .../ComponentProcessors/DownScalingComponentProcessor2.cs | 2 +- .../ComponentProcessors/DownScalingComponentProcessor4.cs | 2 +- .../ComponentProcessors/DownScalingComponentProcessor8.cs | 2 +- .../Formats/Jpeg/Components/ScaledFloatingPointDCT.cs | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/ImageSharp/Formats/Jpeg/Components/Decoder/ComponentProcessors/DownScalingComponentProcessor2.cs b/src/ImageSharp/Formats/Jpeg/Components/Decoder/ComponentProcessors/DownScalingComponentProcessor2.cs index 0ec7500e0d..300a773311 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/Decoder/ComponentProcessors/DownScalingComponentProcessor2.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/Decoder/ComponentProcessors/DownScalingComponentProcessor2.cs @@ -25,7 +25,7 @@ public override void CopyBlocksToColorBuffer(int spectralStep) Buffer2D spectralBuffer = this.Component.SpectralBlocks; float maximumValue = this.Frame.MaxColorChannelValue; - float normalizationValue = MathF.Ceiling(maximumValue * 0.5F); // /2 + float normalizationValue = MathF.Ceiling(maximumValue * 0.5F); int destAreaStride = this.ColorBuffer.Width; diff --git a/src/ImageSharp/Formats/Jpeg/Components/Decoder/ComponentProcessors/DownScalingComponentProcessor4.cs b/src/ImageSharp/Formats/Jpeg/Components/Decoder/ComponentProcessors/DownScalingComponentProcessor4.cs index 99daaa49e7..7984169902 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/Decoder/ComponentProcessors/DownScalingComponentProcessor4.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/Decoder/ComponentProcessors/DownScalingComponentProcessor4.cs @@ -25,7 +25,7 @@ public override void CopyBlocksToColorBuffer(int spectralStep) Buffer2D spectralBuffer = this.Component.SpectralBlocks; float maximumValue = this.Frame.MaxColorChannelValue; - float normalizationValue = MathF.Ceiling(maximumValue * 0.5F); // /2 + float normalizationValue = MathF.Ceiling(maximumValue * 0.5F); int destAreaStride = this.ColorBuffer.Width; diff --git a/src/ImageSharp/Formats/Jpeg/Components/Decoder/ComponentProcessors/DownScalingComponentProcessor8.cs b/src/ImageSharp/Formats/Jpeg/Components/Decoder/ComponentProcessors/DownScalingComponentProcessor8.cs index cf321d7cd9..f3b09e6b49 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/Decoder/ComponentProcessors/DownScalingComponentProcessor8.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/Decoder/ComponentProcessors/DownScalingComponentProcessor8.cs @@ -22,7 +22,7 @@ public override void CopyBlocksToColorBuffer(int spectralStep) Buffer2D spectralBuffer = this.Component.SpectralBlocks; float maximumValue = this.Frame.MaxColorChannelValue; - float normalizationValue = MathF.Ceiling(maximumValue * 0.5F); // /2 + float normalizationValue = MathF.Ceiling(maximumValue * 0.5F); int destAreaStride = this.ColorBuffer.Width; diff --git a/src/ImageSharp/Formats/Jpeg/Components/ScaledFloatingPointDCT.cs b/src/ImageSharp/Formats/Jpeg/Components/ScaledFloatingPointDCT.cs index 1a2767308f..98e3857973 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/ScaledFloatingPointDCT.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/ScaledFloatingPointDCT.cs @@ -183,8 +183,8 @@ public static void TransformIDCT_2x2(ref Block8x8F block, ref Block8x8F dequantT // temporal result is saved to +2 shifted indices // because result is saved into the top left 2x2 region of the // input block - block[(ctr * 8) + 2] = (tmp10 + tmp0) * 0.25F; // /4 - block[(ctr * 8) + 3] = (tmp10 - tmp0) * 0.25F; // /4 + block[(ctr * 8) + 2] = (tmp10 + tmp0) * 0.25F; + block[(ctr * 8) + 3] = (tmp10 - tmp0) * 0.25F; } for (int ctr = 0; ctr < 2; ctr++) From d6aeba1501e391f17d6b5f5c605e9ba8e0711eb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=BCnther=20Foidl?= Date: Mon, 20 Mar 2023 22:57:16 +0100 Subject: [PATCH 10/12] Switched from for-loop to if + do-while in Vp8LHistogram --- src/ImageSharp/Formats/Webp/Lossless/Vp8LHistogram.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/ImageSharp/Formats/Webp/Lossless/Vp8LHistogram.cs b/src/ImageSharp/Formats/Webp/Lossless/Vp8LHistogram.cs index 3df979f96b..765c84e602 100644 --- a/src/ImageSharp/Formats/Webp/Lossless/Vp8LHistogram.cs +++ b/src/ImageSharp/Formats/Webp/Lossless/Vp8LHistogram.cs @@ -513,14 +513,14 @@ private static void AddVector(Span a, Span b, Span output, int DebugGuard.MustBeGreaterThanOrEqualTo(b.Length, count, nameof(b.Length)); DebugGuard.MustBeGreaterThanOrEqualTo(output.Length, count, nameof(output.Length)); - if (Avx2.IsSupported) + if (Avx2.IsSupported && count >= 32) { ref uint aRef = ref MemoryMarshal.GetReference(a); ref uint bRef = ref MemoryMarshal.GetReference(b); ref uint outputRef = ref MemoryMarshal.GetReference(output); - nuint idx; - for (idx = 0; idx <= (uint)count - 32; idx += 32) + nuint idx = 0; + do { // Load values. Vector256 a0 = Unsafe.As>(ref Unsafe.Add(ref aRef, idx)); @@ -538,7 +538,9 @@ private static void AddVector(Span a, Span b, Span output, int Unsafe.As>(ref Unsafe.Add(ref outputRef, idx + 8)) = Avx2.Add(a1, b1); Unsafe.As>(ref Unsafe.Add(ref outputRef, idx + 16)) = Avx2.Add(a2, b2); Unsafe.As>(ref Unsafe.Add(ref outputRef, idx + 24)) = Avx2.Add(a3, b3); + idx += 32; } + while (idx <= (uint)count - 32); int i = (int)idx; for (; i < count; i++) From e234b003efeaad9b9527ad6afcfa675c0fb2de38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=BCnther=20Foidl?= Date: Thu, 23 Mar 2023 20:33:52 +0100 Subject: [PATCH 11/12] PR feedback --- .../Helpers/Shuffle/IComponentShuffle.cs | 20 ++++---- .../SimdUtils.FallbackIntrinsics128.cs | 8 ++-- src/ImageSharp/Formats/Bmp/BmpDecoderCore.cs | 2 +- src/ImageSharp/Formats/Bmp/BmpEncoderCore.cs | 2 +- src/ImageSharp/Formats/Bmp/BmpInfoHeader.cs | 20 ++++---- .../Components/Encoder/ComponentProcessor.cs | 4 +- .../Webp/Lossless/BackwardReferenceEncoder.cs | 4 +- .../Formats/Webp/Lossless/HistogramEncoder.cs | 4 +- .../Formats/Webp/Lossless/PredictorEncoder.cs | 12 ++--- .../Formats/Webp/Lossless/Vp8LEncoder.cs | 10 ++-- .../Formats/Webp/Lossless/Vp8LHashChain.cs | 12 ++--- .../Formats/Webp/Lossless/Vp8LHistogram.cs | 6 +-- .../Formats/Webp/Lossy/PassStats.cs | 2 +- .../Formats/Webp/Lossy/Vp8EncIterator.cs | 6 +-- .../Formats/Webp/Lossy/Vp8Encoder.cs | 8 ++-- .../Formats/Webp/Lossy/WebpLossyDecoder.cs | 2 +- .../Formats/Webp/WebpEncoderCore.cs | 4 +- .../Convolution2DRowOperation{TPixel}.cs | 48 +++++++++---------- .../Convolution/Convolution2DState.cs | 16 +++---- .../ConvolutionProcessor{TPixel}.cs | 32 ++++++------- .../Convolution/ConvolutionState.cs | 16 +++---- .../EdgeDetectorCompassProcessor{TPixel}.cs | 14 +++--- .../Processors/Convolution/ReadOnlyKernel.cs | 18 +++---- 23 files changed, 135 insertions(+), 135 deletions(-) diff --git a/src/ImageSharp/Common/Helpers/Shuffle/IComponentShuffle.cs b/src/ImageSharp/Common/Helpers/Shuffle/IComponentShuffle.cs index a86355135e..683ac518b8 100644 --- a/src/ImageSharp/Common/Helpers/Shuffle/IComponentShuffle.cs +++ b/src/ImageSharp/Common/Helpers/Shuffle/IComponentShuffle.cs @@ -84,9 +84,9 @@ public void RunFallbackShuffle(ReadOnlySpan source, Span dest) { ref uint sBase = ref Unsafe.As(ref MemoryMarshal.GetReference(source)); ref uint dBase = ref Unsafe.As(ref MemoryMarshal.GetReference(dest)); - int n = (int)((uint)source.Length / 4); + uint n = (uint)source.Length / 4; - for (nuint i = 0; i < (uint)n; i++) + for (nuint i = 0; i < n; i++) { uint packed = Unsafe.Add(ref sBase, i); @@ -108,9 +108,9 @@ public void RunFallbackShuffle(ReadOnlySpan source, Span dest) { ref uint sBase = ref Unsafe.As(ref MemoryMarshal.GetReference(source)); ref uint dBase = ref Unsafe.As(ref MemoryMarshal.GetReference(dest)); - int n = (int)((uint)source.Length / 4); + uint n = (uint)source.Length / 4; - for (nuint i = 0; i < (uint)n; i++) + for (nuint i = 0; i < n; i++) { uint packed = Unsafe.Add(ref sBase, i); @@ -132,9 +132,9 @@ public void RunFallbackShuffle(ReadOnlySpan source, Span dest) { ref uint sBase = ref Unsafe.As(ref MemoryMarshal.GetReference(source)); ref uint dBase = ref Unsafe.As(ref MemoryMarshal.GetReference(dest)); - int n = (int)((uint)source.Length / 4); + uint n = (uint)source.Length / 4; - for (nuint i = 0; i < (uint)n; i++) + for (nuint i = 0; i < n; i++) { uint packed = Unsafe.Add(ref sBase, i); @@ -156,9 +156,9 @@ public void RunFallbackShuffle(ReadOnlySpan source, Span dest) { ref uint sBase = ref Unsafe.As(ref MemoryMarshal.GetReference(source)); ref uint dBase = ref Unsafe.As(ref MemoryMarshal.GetReference(dest)); - int n = (int)((uint)source.Length / 4); + uint n = (uint)source.Length / 4; - for (nuint i = 0; i < (uint)n; i++) + for (nuint i = 0; i < n; i++) { uint packed = Unsafe.Add(ref sBase, i); @@ -187,9 +187,9 @@ public void RunFallbackShuffle(ReadOnlySpan source, Span dest) { ref uint sBase = ref Unsafe.As(ref MemoryMarshal.GetReference(source)); ref uint dBase = ref Unsafe.As(ref MemoryMarshal.GetReference(dest)); - int n = (int)((uint)source.Length / 4); + uint n = (uint)source.Length / 4; - for (nuint i = 0; i < (uint)n; i++) + for (nuint i = 0; i < n; i++) { uint packed = Unsafe.Add(ref sBase, i); diff --git a/src/ImageSharp/Common/Helpers/SimdUtils.FallbackIntrinsics128.cs b/src/ImageSharp/Common/Helpers/SimdUtils.FallbackIntrinsics128.cs index d456d8e42f..a551cebd05 100644 --- a/src/ImageSharp/Common/Helpers/SimdUtils.FallbackIntrinsics128.cs +++ b/src/ImageSharp/Common/Helpers/SimdUtils.FallbackIntrinsics128.cs @@ -71,7 +71,7 @@ internal static void ByteToNormalizedFloat(ReadOnlySpan source, Span source, Span - public short BitsPerPixel { get; set; } + public ushort BitsPerPixel { get; set; } /// /// Gets or sets the compression method being used. @@ -311,7 +311,7 @@ public BmpInfoHeader( width: BinaryPrimitives.ReadUInt16LittleEndian(data.Slice(4, 2)), height: BinaryPrimitives.ReadUInt16LittleEndian(data.Slice(6, 2)), planes: BinaryPrimitives.ReadInt16LittleEndian(data.Slice(8, 2)), - bitsPerPixel: BinaryPrimitives.ReadInt16LittleEndian(data.Slice(10, 2))); + bitsPerPixel: BinaryPrimitives.ReadUInt16LittleEndian(data.Slice(10, 2))); /// /// Parses a short variant of the OS22XBITMAPHEADER. It is identical to the BITMAPCOREHEADER, except that the width and height @@ -325,7 +325,7 @@ public BmpInfoHeader( width: BinaryPrimitives.ReadInt32LittleEndian(data.Slice(4, 4)), height: BinaryPrimitives.ReadInt32LittleEndian(data.Slice(8, 4)), planes: BinaryPrimitives.ReadInt16LittleEndian(data.Slice(12, 2)), - bitsPerPixel: BinaryPrimitives.ReadInt16LittleEndian(data.Slice(14, 2))); + bitsPerPixel: BinaryPrimitives.ReadUInt16LittleEndian(data.Slice(14, 2))); /// /// Parses the full BMP Version 3 BITMAPINFOHEADER header (40 bytes). @@ -338,7 +338,7 @@ public BmpInfoHeader( width: BinaryPrimitives.ReadInt32LittleEndian(data.Slice(4, 4)), height: BinaryPrimitives.ReadInt32LittleEndian(data.Slice(8, 4)), planes: BinaryPrimitives.ReadInt16LittleEndian(data.Slice(12, 2)), - bitsPerPixel: BinaryPrimitives.ReadInt16LittleEndian(data.Slice(14, 2)), + bitsPerPixel: BinaryPrimitives.ReadUInt16LittleEndian(data.Slice(14, 2)), compression: (BmpCompression)BinaryPrimitives.ReadInt32LittleEndian(data.Slice(16, 4)), imageSize: BinaryPrimitives.ReadInt32LittleEndian(data.Slice(20, 4)), xPelsPerMeter: BinaryPrimitives.ReadInt32LittleEndian(data.Slice(24, 4)), @@ -359,7 +359,7 @@ public BmpInfoHeader( width: BinaryPrimitives.ReadInt32LittleEndian(data.Slice(4, 4)), height: BinaryPrimitives.ReadInt32LittleEndian(data.Slice(8, 4)), planes: BinaryPrimitives.ReadInt16LittleEndian(data.Slice(12, 2)), - bitsPerPixel: BinaryPrimitives.ReadInt16LittleEndian(data.Slice(14, 2)), + bitsPerPixel: BinaryPrimitives.ReadUInt16LittleEndian(data.Slice(14, 2)), compression: (BmpCompression)BinaryPrimitives.ReadInt32LittleEndian(data.Slice(16, 4)), imageSize: BinaryPrimitives.ReadInt32LittleEndian(data.Slice(20, 4)), xPelsPerMeter: BinaryPrimitives.ReadInt32LittleEndian(data.Slice(24, 4)), @@ -386,7 +386,7 @@ public static BmpInfoHeader ParseOs2Version2(ReadOnlySpan data) width: BinaryPrimitives.ReadInt32LittleEndian(data.Slice(4, 4)), height: BinaryPrimitives.ReadInt32LittleEndian(data.Slice(8, 4)), planes: BinaryPrimitives.ReadInt16LittleEndian(data.Slice(12, 2)), - bitsPerPixel: BinaryPrimitives.ReadInt16LittleEndian(data.Slice(14, 2))); + bitsPerPixel: BinaryPrimitives.ReadUInt16LittleEndian(data.Slice(14, 2))); // The compression value in OS/2 bitmap has a different meaning than in windows bitmaps. // Map the OS/2 value to the windows values. @@ -431,7 +431,7 @@ public static BmpInfoHeader ParseOs2Version2(ReadOnlySpan data) width: BinaryPrimitives.ReadInt32LittleEndian(data.Slice(4, 4)), height: BinaryPrimitives.ReadInt32LittleEndian(data.Slice(8, 4)), planes: BinaryPrimitives.ReadInt16LittleEndian(data.Slice(12, 2)), - bitsPerPixel: BinaryPrimitives.ReadInt16LittleEndian(data.Slice(14, 2)), + bitsPerPixel: BinaryPrimitives.ReadUInt16LittleEndian(data.Slice(14, 2)), compression: (BmpCompression)BinaryPrimitives.ReadInt32LittleEndian(data.Slice(16, 4)), imageSize: BinaryPrimitives.ReadInt32LittleEndian(data.Slice(20, 4)), xPelsPerMeter: BinaryPrimitives.ReadInt32LittleEndian(data.Slice(24, 4)), @@ -484,7 +484,7 @@ public void WriteV3Header(Span buffer) BinaryPrimitives.WriteInt32LittleEndian(buffer.Slice(4, 4), this.Width); BinaryPrimitives.WriteInt32LittleEndian(buffer.Slice(8, 4), this.Height); BinaryPrimitives.WriteInt16LittleEndian(buffer.Slice(12, 2), this.Planes); - BinaryPrimitives.WriteInt16LittleEndian(buffer.Slice(14, 2), this.BitsPerPixel); + BinaryPrimitives.WriteUInt16LittleEndian(buffer.Slice(14, 2), this.BitsPerPixel); BinaryPrimitives.WriteInt32LittleEndian(buffer.Slice(16, 4), (int)this.Compression); BinaryPrimitives.WriteInt32LittleEndian(buffer.Slice(20, 4), this.ImageSize); BinaryPrimitives.WriteInt32LittleEndian(buffer.Slice(24, 4), this.XPelsPerMeter); @@ -504,7 +504,7 @@ public void WriteV4Header(Span buffer) BinaryPrimitives.WriteInt32LittleEndian(buffer.Slice(4, 4), this.Width); BinaryPrimitives.WriteInt32LittleEndian(buffer.Slice(8, 4), this.Height); BinaryPrimitives.WriteInt16LittleEndian(buffer.Slice(12, 2), this.Planes); - BinaryPrimitives.WriteInt16LittleEndian(buffer.Slice(14, 2), this.BitsPerPixel); + BinaryPrimitives.WriteUInt16LittleEndian(buffer.Slice(14, 2), this.BitsPerPixel); BinaryPrimitives.WriteInt32LittleEndian(buffer.Slice(16, 4), (int)this.Compression); BinaryPrimitives.WriteInt32LittleEndian(buffer.Slice(20, 4), this.ImageSize); BinaryPrimitives.WriteInt32LittleEndian(buffer.Slice(24, 4), this.XPelsPerMeter); diff --git a/src/ImageSharp/Formats/Jpeg/Components/Encoder/ComponentProcessor.cs b/src/ImageSharp/Formats/Jpeg/Components/Encoder/ComponentProcessor.cs index 9b08175051..c7d9498b6b 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/Encoder/ComponentProcessor.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/Encoder/ComponentProcessor.cs @@ -157,7 +157,7 @@ static void SumHorizontal(Span target, int factor) // Ideally we need to use log2: Numerics.Log2((uint)factor) // but division by 2 works just fine in this case - int haddIterationsCount = (int)((uint)factor / 2); + uint haddIterationsCount = (uint)factor / 2; // Transform spans so that it only contains 'remainder' // values for the scalar fallback code @@ -168,7 +168,7 @@ static void SumHorizontal(Span target, int factor) nuint length = (uint)(touchedCount / Vector256.Count); - for (int i = 0; i < haddIterationsCount; i++) + for (uint i = 0; i < haddIterationsCount; i++) { length /= 2; diff --git a/src/ImageSharp/Formats/Webp/Lossless/BackwardReferenceEncoder.cs b/src/ImageSharp/Formats/Webp/Lossless/BackwardReferenceEncoder.cs index df19c26e0b..61133142bf 100644 --- a/src/ImageSharp/Formats/Webp/Lossless/BackwardReferenceEncoder.cs +++ b/src/ImageSharp/Formats/Webp/Lossless/BackwardReferenceEncoder.cs @@ -38,7 +38,7 @@ public static Vp8LBackwardRefs GetBackwardReferences( int width, int height, ReadOnlySpan bgra, - int quality, + uint quality, int lz77TypesToTry, ref int cacheBits, MemoryAllocator memoryAllocator, @@ -123,7 +123,7 @@ public static Vp8LBackwardRefs GetBackwardReferences( /// The local color cache is also disabled for the lower (smaller then 25) quality. /// /// Best cache size. - private static int CalculateBestCacheSize(ReadOnlySpan bgra, int quality, Vp8LBackwardRefs refs, int bestCacheBits) + private static int CalculateBestCacheSize(ReadOnlySpan bgra, uint quality, Vp8LBackwardRefs refs, int bestCacheBits) { int cacheBitsMax = quality <= 25 ? 0 : bestCacheBits; if (cacheBitsMax == 0) diff --git a/src/ImageSharp/Formats/Webp/Lossless/HistogramEncoder.cs b/src/ImageSharp/Formats/Webp/Lossless/HistogramEncoder.cs index 5eec2a2ca3..5ac3301519 100644 --- a/src/ImageSharp/Formats/Webp/Lossless/HistogramEncoder.cs +++ b/src/ImageSharp/Formats/Webp/Lossless/HistogramEncoder.cs @@ -27,7 +27,7 @@ internal class HistogramEncoder private const ushort InvalidHistogramSymbol = ushort.MaxValue; - public static void GetHistoImageSymbols(int xSize, int ySize, Vp8LBackwardRefs refs, int quality, int histoBits, int cacheBits, List imageHisto, Vp8LHistogram tmpHisto, ushort[] histogramSymbols) + public static void GetHistoImageSymbols(int xSize, int ySize, Vp8LBackwardRefs refs, uint quality, int histoBits, int cacheBits, List imageHisto, Vp8LHistogram tmpHisto, ushort[] histogramSymbols) { int histoXSize = histoBits > 0 ? LosslessUtils.SubSampleSize(xSize, histoBits) : 1; int histoYSize = histoBits > 0 ? LosslessUtils.SubSampleSize(ySize, histoBits) : 1; @@ -660,7 +660,7 @@ private static void HistogramAdd(Vp8LHistogram a, Vp8LHistogram b, Vp8LHistogram output.TrivialSymbol = a.TrivialSymbol == b.TrivialSymbol ? a.TrivialSymbol : NonTrivialSym; } - private static double GetCombineCostFactor(int histoSize, int quality) + private static double GetCombineCostFactor(int histoSize, uint quality) { double combineCostFactor = 0.16d; if (quality < 90) diff --git a/src/ImageSharp/Formats/Webp/Lossless/PredictorEncoder.cs b/src/ImageSharp/Formats/Webp/Lossless/PredictorEncoder.cs index 5d8d3203b1..689c63f5b1 100644 --- a/src/ImageSharp/Formats/Webp/Lossless/PredictorEncoder.cs +++ b/src/ImageSharp/Formats/Webp/Lossless/PredictorEncoder.cs @@ -113,7 +113,7 @@ public static void ResidualImage( lowEffort); } - public static void ColorSpaceTransform(int width, int height, int bits, int quality, Span bgra, Span image, Span scratch) + public static void ColorSpaceTransform(int width, int height, int bits, uint quality, Span bgra, Span image, Span scratch) { int maxTileSize = 1 << bits; int tileXSize = LosslessUtils.SubSampleSize(width, bits); @@ -837,7 +837,7 @@ private static Vp8LMultipliers GetBestColorTransformForTile( int bits, Vp8LMultipliers prevX, Vp8LMultipliers prevY, - int quality, + uint quality, int xSize, int ySize, int[] accumulatedRedHisto, @@ -871,14 +871,14 @@ private static void GetBestGreenToRed( int tileHeight, Vp8LMultipliers prevX, Vp8LMultipliers prevY, - int quality, + uint quality, int[] accumulatedRedHisto, ref Vp8LMultipliers bestTx) { - int maxIters = 4 + ((7 * quality) >> 8); // in range [4..6] + uint maxIters = 4 + ((7 * quality) / 256); // in range [4..6] int greenToRedBest = 0; double bestDiff = GetPredictionCostCrossColorRed(argb, stride, scratch, tileWidth, tileHeight, prevX, prevY, greenToRedBest, accumulatedRedHisto); - for (int iter = 0; iter < maxIters; iter++) + for (int iter = 0; iter < (int)maxIters; iter++) { // ColorTransformDelta is a 3.5 bit fixed point, so 32 is equal to // one in color computation. Having initial delta here as 1 is sufficient @@ -901,7 +901,7 @@ private static void GetBestGreenToRed( bestTx.GreenToRed = (byte)(greenToRedBest & 0xff); } - private static void GetBestGreenRedToBlue(Span argb, int stride, Span scratch, int tileWidth, int tileHeight, Vp8LMultipliers prevX, Vp8LMultipliers prevY, int quality, int[] accumulatedBlueHisto, ref Vp8LMultipliers bestTx) + private static void GetBestGreenRedToBlue(Span argb, int stride, Span scratch, int tileWidth, int tileHeight, Vp8LMultipliers prevX, Vp8LMultipliers prevY, uint quality, int[] accumulatedBlueHisto, ref Vp8LMultipliers bestTx) { int iters = (quality < 25) ? 1 : (quality > 50) ? GreenRedToBlueMaxIters : 4; int greenToBlueBest = 0; diff --git a/src/ImageSharp/Formats/Webp/Lossless/Vp8LEncoder.cs b/src/ImageSharp/Formats/Webp/Lossless/Vp8LEncoder.cs index 7be0e69f72..d678da6028 100644 --- a/src/ImageSharp/Formats/Webp/Lossless/Vp8LEncoder.cs +++ b/src/ImageSharp/Formats/Webp/Lossless/Vp8LEncoder.cs @@ -57,7 +57,7 @@ internal class Vp8LEncoder : IDisposable /// /// The quality, that will be used to encode the image. /// - private readonly int quality; + private readonly uint quality; /// /// Quality/speed trade-off (0=fast, 6=slower-better). @@ -110,7 +110,7 @@ public Vp8LEncoder( Configuration configuration, int width, int height, - int quality, + uint quality, bool skipMetadata, WebpEncodingMethod method, WebpTransparentColorMode transparentColorMode, @@ -122,7 +122,7 @@ public Vp8LEncoder( this.memoryAllocator = memoryAllocator; this.configuration = configuration; - this.quality = Numerics.Clamp(quality, 0, 100); + this.quality = Math.Min(quality, 100u); this.skipMetadata = skipMetadata; this.method = method; this.transparentColorMode = transparentColorMode; @@ -772,7 +772,7 @@ private void ApplyCrossColorFilter(int width, int height, bool lowEffort) this.EncodeImageNoHuffman(this.TransformData.GetSpan(), this.HashChain, this.Refs[0], this.Refs[1], transformWidth, transformHeight, this.quality, lowEffort); } - private void EncodeImageNoHuffman(Span bgra, Vp8LHashChain hashChain, Vp8LBackwardRefs refsTmp1, Vp8LBackwardRefs refsTmp2, int width, int height, int quality, bool lowEffort) + private void EncodeImageNoHuffman(Span bgra, Vp8LHashChain hashChain, Vp8LBackwardRefs refsTmp1, Vp8LBackwardRefs refsTmp2, int width, int height, uint quality, bool lowEffort) { int cacheBits = 0; ushort[] histogramSymbols = new ushort[1]; // Only one tree, one symbol. @@ -1820,7 +1820,7 @@ public void AllocateTransformBuffer(int width, int height) { // VP8LResidualImage needs room for 2 scanlines of uint32 pixels with an extra // pixel in each, plus 2 regular scanlines of bytes. - int bgraScratchSize = this.UsePredictorTransform ? (int)((((uint)width + 1) * 2) + ((((uint)width * 2) + 4 - 1) / 4)) : 0; + int bgraScratchSize = this.UsePredictorTransform ? ((width + 1) * 2) + (((width * 2) + 4 - 1) / 4) : 0; int transformDataSize = this.UsePredictorTransform || this.UseCrossColorTransform ? LosslessUtils.SubSampleSize(width, this.TransformBits) * LosslessUtils.SubSampleSize(height, this.TransformBits) : 0; this.BgraScratch = this.memoryAllocator.Allocate(bgraScratchSize); diff --git a/src/ImageSharp/Formats/Webp/Lossless/Vp8LHashChain.cs b/src/ImageSharp/Formats/Webp/Lossless/Vp8LHashChain.cs index 32d4fcbb68..3b3864a49d 100644 --- a/src/ImageSharp/Formats/Webp/Lossless/Vp8LHashChain.cs +++ b/src/ImageSharp/Formats/Webp/Lossless/Vp8LHashChain.cs @@ -56,10 +56,10 @@ public Vp8LHashChain(MemoryAllocator memoryAllocator, int size) /// public int Size { get; } - public void Fill(ReadOnlySpan bgra, int quality, int xSize, int ySize, bool lowEffort) + public void Fill(ReadOnlySpan bgra, uint quality, int xSize, int ySize, bool lowEffort) { int size = xSize * ySize; - int iterMax = GetMaxItersForQuality((uint)quality); + int iterMax = GetMaxItersForQuality(quality); int windowSize = GetWindowSizeForHashChain(quality, xSize); int pos; @@ -275,11 +275,11 @@ private static uint GetPixPairHash64(ReadOnlySpan bgra) private static int GetMaxItersForQuality(uint quality) => (int)(8 + (quality * quality / 128)); [MethodImpl(InliningOptions.ShortMethod)] - private static int GetWindowSizeForHashChain(int quality, int xSize) + private static int GetWindowSizeForHashChain(uint quality, int xSize) { - int maxWindowSize = quality > 75 ? WindowSize - : quality > 50 ? xSize << 8 - : quality > 25 ? xSize << 6 + int maxWindowSize = quality > 75u ? WindowSize + : quality > 50u ? xSize << 8 + : quality > 25u ? xSize << 6 : xSize << 4; return maxWindowSize > WindowSize ? WindowSize : maxWindowSize; diff --git a/src/ImageSharp/Formats/Webp/Lossless/Vp8LHistogram.cs b/src/ImageSharp/Formats/Webp/Lossless/Vp8LHistogram.cs index 765c84e602..5ec3f0d53d 100644 --- a/src/ImageSharp/Formats/Webp/Lossless/Vp8LHistogram.cs +++ b/src/ImageSharp/Formats/Webp/Lossless/Vp8LHistogram.cs @@ -523,18 +523,18 @@ private static void AddVector(Span a, Span b, Span output, int do { // Load values. - Vector256 a0 = Unsafe.As>(ref Unsafe.Add(ref aRef, idx)); + Vector256 a0 = Unsafe.As>(ref Unsafe.Add(ref aRef, idx + 0)); Vector256 a1 = Unsafe.As>(ref Unsafe.Add(ref aRef, idx + 8)); Vector256 a2 = Unsafe.As>(ref Unsafe.Add(ref aRef, idx + 16)); Vector256 a3 = Unsafe.As>(ref Unsafe.Add(ref aRef, idx + 24)); - Vector256 b0 = Unsafe.As>(ref Unsafe.Add(ref bRef, idx)); + Vector256 b0 = Unsafe.As>(ref Unsafe.Add(ref bRef, idx + 0)); Vector256 b1 = Unsafe.As>(ref Unsafe.Add(ref bRef, idx + 8)); Vector256 b2 = Unsafe.As>(ref Unsafe.Add(ref bRef, idx + 16)); Vector256 b3 = Unsafe.As>(ref Unsafe.Add(ref bRef, idx + 24)); // Note we are adding uint32_t's as *signed* int32's (using _mm_add_epi32). But // that's ok since the histogram values are less than 1<<28 (max picture count). - Unsafe.As>(ref Unsafe.Add(ref outputRef, idx)) = Avx2.Add(a0, b0); + Unsafe.As>(ref Unsafe.Add(ref outputRef, idx + 0)) = Avx2.Add(a0, b0); Unsafe.As>(ref Unsafe.Add(ref outputRef, idx + 8)) = Avx2.Add(a1, b1); Unsafe.As>(ref Unsafe.Add(ref outputRef, idx + 16)) = Avx2.Add(a2, b2); Unsafe.As>(ref Unsafe.Add(ref outputRef, idx + 24)) = Avx2.Add(a3, b3); diff --git a/src/ImageSharp/Formats/Webp/Lossy/PassStats.cs b/src/ImageSharp/Formats/Webp/Lossy/PassStats.cs index ba554866e3..470c9c1042 100644 --- a/src/ImageSharp/Formats/Webp/Lossy/PassStats.cs +++ b/src/ImageSharp/Formats/Webp/Lossy/PassStats.cs @@ -8,7 +8,7 @@ namespace SixLabors.ImageSharp.Formats.Webp.Lossy; /// internal class PassStats { - public PassStats(long targetSize, float targetPsnr, int qMin, int qMax, int quality) + public PassStats(long targetSize, float targetPsnr, int qMin, int qMax, uint quality) { bool doSizeSearch = targetSize != 0; diff --git a/src/ImageSharp/Formats/Webp/Lossy/Vp8EncIterator.cs b/src/ImageSharp/Formats/Webp/Lossy/Vp8EncIterator.cs index fa5fe51c79..b33ef57a6b 100644 --- a/src/ImageSharp/Formats/Webp/Lossy/Vp8EncIterator.cs +++ b/src/ImageSharp/Formats/Webp/Lossy/Vp8EncIterator.cs @@ -347,12 +347,12 @@ public void Import(Span y, Span u, Span v, int yStride, int uv } } - public int FastMbAnalyze(int quality) + public int FastMbAnalyze(uint quality) { // Empirical cut-off value, should be around 16 (~=block size). We use the // [8-17] range and favor intra4 at high quality, intra16 for low quality. - int q = quality; - int kThreshold = 8 + ((17 - 8) * q / 100); + uint q = quality; + uint kThreshold = 8 + ((17 - 8) * q / 100); int k; Span dc = stackalloc uint[16]; uint m; diff --git a/src/ImageSharp/Formats/Webp/Lossy/Vp8Encoder.cs b/src/ImageSharp/Formats/Webp/Lossy/Vp8Encoder.cs index 186aa6c216..ed3c1cd60d 100644 --- a/src/ImageSharp/Formats/Webp/Lossy/Vp8Encoder.cs +++ b/src/ImageSharp/Formats/Webp/Lossy/Vp8Encoder.cs @@ -31,7 +31,7 @@ internal class Vp8Encoder : IDisposable /// /// The quality, that will be used to encode the image. /// - private readonly int quality; + private readonly uint quality; /// /// Quality/speed trade-off (0=fast, 6=slower-better). @@ -113,7 +113,7 @@ public Vp8Encoder( Configuration configuration, int width, int height, - int quality, + uint quality, bool skipMetadata, WebpEncodingMethod method, int entropyPasses, @@ -125,7 +125,7 @@ public Vp8Encoder( this.configuration = configuration; this.Width = width; this.Height = height; - this.quality = Numerics.Clamp(quality, 0, 100); + this.quality = Math.Min(quality, 100); this.skipMetadata = skipMetadata; this.method = method; this.entropyPasses = Numerics.Clamp(entropyPasses, 1, 10); @@ -1177,6 +1177,6 @@ private static int GetProba(int a, int b) { int total = a + b; return total == 0 ? 255 // that's the default probability. - : ((255 * a) + (int)((uint)total / 2)) / total; // rounded proba + : ((255 * a) + (total >> 1)) / total; // rounded proba } } diff --git a/src/ImageSharp/Formats/Webp/Lossy/WebpLossyDecoder.cs b/src/ImageSharp/Formats/Webp/Lossy/WebpLossyDecoder.cs index 36f3abcd9d..96ed8903a0 100644 --- a/src/ImageSharp/Formats/Webp/Lossy/WebpLossyDecoder.cs +++ b/src/ImageSharp/Formats/Webp/Lossy/WebpLossyDecoder.cs @@ -731,7 +731,7 @@ private static int EmitRgb(Vp8Decoder dec, Vp8Io io) Span dst = buf[dstStartIdx..]; int yEnd = io.MbY + io.MbH; int mbw = io.MbW; - int uvw = (int)(((uint)mbw + 1) / 2); + int uvw = (mbw + 1) >> 1; // >> 1 is bit-hack for / 2 int y = io.MbY; byte[] uvBuffer = new byte[(14 * 32) + 15]; diff --git a/src/ImageSharp/Formats/Webp/WebpEncoderCore.cs b/src/ImageSharp/Formats/Webp/WebpEncoderCore.cs index 33189ba845..49512e03b5 100644 --- a/src/ImageSharp/Formats/Webp/WebpEncoderCore.cs +++ b/src/ImageSharp/Formats/Webp/WebpEncoderCore.cs @@ -27,7 +27,7 @@ internal sealed class WebpEncoderCore : IImageEncoderInternals /// /// Compression quality. Between 0 and 100. /// - private readonly int quality; + private readonly uint quality; /// /// Quality/speed trade-off (0=fast, 6=slower-better). @@ -92,7 +92,7 @@ public WebpEncoderCore(WebpEncoder encoder, Configuration configuration) this.memoryAllocator = configuration.MemoryAllocator; this.alphaCompression = encoder.UseAlphaCompression; this.fileFormat = encoder.FileFormat; - this.quality = encoder.Quality; + this.quality = (uint)encoder.Quality; this.method = encoder.Method; this.entropyPasses = encoder.EntropyPasses; this.spatialNoiseShaping = encoder.SpatialNoiseShaping; diff --git a/src/ImageSharp/Processing/Processors/Convolution/Convolution2DRowOperation{TPixel}.cs b/src/ImageSharp/Processing/Processors/Convolution/Convolution2DRowOperation{TPixel}.cs index 91fc3a1b1d..2a4a1abf02 100644 --- a/src/ImageSharp/Processing/Processors/Convolution/Convolution2DRowOperation{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Convolution/Convolution2DRowOperation{TPixel}.cs @@ -76,7 +76,7 @@ private void Convolve3(int y, Span span) Span targetXBuffer = span.Slice(boundsWidth * 2, boundsWidth); var state = new Convolution2DState(in this.kernelMatrixY, in this.kernelMatrixX, this.map); - ref int sampleRowBase = ref state.GetSampleRow(y - this.bounds.Y); + ref int sampleRowBase = ref state.GetSampleRow((uint)(y - this.bounds.Y)); // Clear the target buffers for each row run. targetYBuffer.Clear(); @@ -87,24 +87,24 @@ private void Convolve3(int y, Span span) ReadOnlyKernel kernelY = state.KernelY; ReadOnlyKernel kernelX = state.KernelX; Span sourceRow; - for (int kY = 0; kY < kernelY.Rows; kY++) + for (uint kY = 0; kY < kernelY.Rows; kY++) { // Get the precalculated source sample row for this kernel row and copy to our buffer. - int sampleY = Unsafe.Add(ref sampleRowBase, (uint)kY); + int sampleY = Unsafe.Add(ref sampleRowBase, kY); sourceRow = this.sourcePixels.DangerousGetRowSpan(sampleY).Slice(boundsX, boundsWidth); PixelOperations.Instance.ToVector4(this.configuration, sourceRow, sourceBuffer); ref Vector4 sourceBase = ref MemoryMarshal.GetReference(sourceBuffer); - for (int x = 0; x < sourceBuffer.Length; x++) + for (uint x = 0; x < (uint)sourceBuffer.Length; x++) { ref int sampleColumnBase = ref state.GetSampleColumn(x); - ref Vector4 targetY = ref Unsafe.Add(ref targetBaseY, (uint)x); - ref Vector4 targetX = ref Unsafe.Add(ref targetBaseX, (uint)x); + ref Vector4 targetY = ref Unsafe.Add(ref targetBaseY, x); + ref Vector4 targetX = ref Unsafe.Add(ref targetBaseX, x); - for (int kX = 0; kX < kernelY.Columns; kX++) + for (uint kX = 0; kX < kernelY.Columns; kX++) { - int sampleX = Unsafe.Add(ref sampleColumnBase, (uint)kX) - boundsX; + int sampleX = Unsafe.Add(ref sampleColumnBase, kX) - boundsX; Vector4 sample = Unsafe.Add(ref sourceBase, (uint)sampleX); targetY += kernelX[kY, kX] * sample; targetX += kernelY[kY, kX] * sample; @@ -117,14 +117,14 @@ private void Convolve3(int y, Span span) sourceRow = this.sourcePixels.DangerousGetRowSpan(y).Slice(boundsX, boundsWidth); PixelOperations.Instance.ToVector4(this.configuration, sourceRow, sourceBuffer); - for (int x = 0; x < sourceRow.Length; x++) + for (nuint x = 0; x < (uint)sourceRow.Length; x++) { - ref Vector4 target = ref Unsafe.Add(ref targetBaseY, (uint)x); + ref Vector4 target = ref Unsafe.Add(ref targetBaseY, x); Vector4 vectorY = target; - Vector4 vectorX = Unsafe.Add(ref targetBaseX, (uint)x); + Vector4 vectorX = Unsafe.Add(ref targetBaseX, x); target = Vector4.SquareRoot((vectorX * vectorX) + (vectorY * vectorY)); - target.W = Unsafe.Add(ref MemoryMarshal.GetReference(sourceBuffer), (uint)x).W; + target.W = Unsafe.Add(ref MemoryMarshal.GetReference(sourceBuffer), x).W; } Span targetRowSpan = this.targetPixels.DangerousGetRowSpan(y).Slice(boundsX, boundsWidth); @@ -142,7 +142,7 @@ private void Convolve4(int y, Span span) Span targetXBuffer = span.Slice(boundsWidth * 2, boundsWidth); var state = new Convolution2DState(in this.kernelMatrixY, in this.kernelMatrixX, this.map); - ref int sampleRowBase = ref state.GetSampleRow(y - this.bounds.Y); + ref int sampleRowBase = ref state.GetSampleRow((uint)(y - this.bounds.Y)); // Clear the target buffers for each row run. targetYBuffer.Clear(); @@ -152,26 +152,26 @@ private void Convolve4(int y, Span span) ReadOnlyKernel kernelY = state.KernelY; ReadOnlyKernel kernelX = state.KernelX; - for (int kY = 0; kY < kernelY.Rows; kY++) + for (uint kY = 0; kY < kernelY.Rows; kY++) { // Get the precalculated source sample row for this kernel row and copy to our buffer. - int sampleY = Unsafe.Add(ref sampleRowBase, (uint)kY); + int sampleY = Unsafe.Add(ref sampleRowBase, kY); Span sourceRow = this.sourcePixels.DangerousGetRowSpan(sampleY).Slice(boundsX, boundsWidth); PixelOperations.Instance.ToVector4(this.configuration, sourceRow, sourceBuffer); Numerics.Premultiply(sourceBuffer); ref Vector4 sourceBase = ref MemoryMarshal.GetReference(sourceBuffer); - for (int x = 0; x < sourceBuffer.Length; x++) + for (uint x = 0; x < (uint)sourceBuffer.Length; x++) { ref int sampleColumnBase = ref state.GetSampleColumn(x); - ref Vector4 targetY = ref Unsafe.Add(ref targetBaseY, (uint)x); - ref Vector4 targetX = ref Unsafe.Add(ref targetBaseX, (uint)x); + ref Vector4 targetY = ref Unsafe.Add(ref targetBaseY, x); + ref Vector4 targetX = ref Unsafe.Add(ref targetBaseX, x); - for (int kX = 0; kX < kernelY.Columns; kX++) + for (uint kX = 0; kX < kernelY.Columns; kX++) { - int sampleX = Unsafe.Add(ref sampleColumnBase, (uint)kX) - boundsX; - Vector4 sample = Unsafe.Add(ref sourceBase, (uint)sampleX); + int sampleX = Unsafe.Add(ref sampleColumnBase, kX) - boundsX; + Vector4 sample = Unsafe.Add(ref sourceBase, sampleX); targetY += kernelX[kY, kX] * sample; targetX += kernelY[kY, kX] * sample; } @@ -179,11 +179,11 @@ private void Convolve4(int y, Span span) } // Now we need to combine the values - for (int x = 0; x < targetYBuffer.Length; x++) + for (nuint x = 0; x < (uint)targetYBuffer.Length; x++) { - ref Vector4 target = ref Unsafe.Add(ref targetBaseY, (uint)x); + ref Vector4 target = ref Unsafe.Add(ref targetBaseY, x); Vector4 vectorY = target; - Vector4 vectorX = Unsafe.Add(ref targetBaseX, (uint)x); + Vector4 vectorX = Unsafe.Add(ref targetBaseX, x); target = Vector4.SquareRoot((vectorX * vectorX) + (vectorY * vectorY)); } diff --git a/src/ImageSharp/Processing/Processors/Convolution/Convolution2DState.cs b/src/ImageSharp/Processing/Processors/Convolution/Convolution2DState.cs index 88d955ab71..6f5388e22b 100644 --- a/src/ImageSharp/Processing/Processors/Convolution/Convolution2DState.cs +++ b/src/ImageSharp/Processing/Processors/Convolution/Convolution2DState.cs @@ -13,8 +13,8 @@ internal readonly ref struct Convolution2DState { private readonly Span rowOffsetMap; private readonly Span columnOffsetMap; - private readonly int kernelHeight; - private readonly int kernelWidth; + private readonly uint kernelHeight; + private readonly uint kernelWidth; public Convolution2DState( in DenseMatrix kernelY, @@ -24,8 +24,8 @@ public Convolution2DState( // We check the kernels are the same size upstream. this.KernelY = new ReadOnlyKernel(kernelY); this.KernelX = new ReadOnlyKernel(kernelX); - this.kernelHeight = kernelY.Rows; - this.kernelWidth = kernelY.Columns; + this.kernelHeight = (uint)kernelY.Rows; + this.kernelWidth = (uint)kernelY.Columns; this.rowOffsetMap = map.GetRowOffsetSpan(); this.columnOffsetMap = map.GetColumnOffsetSpan(); } @@ -43,10 +43,10 @@ public readonly ReadOnlyKernel KernelX } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public readonly ref int GetSampleRow(int row) - => ref Unsafe.Add(ref MemoryMarshal.GetReference(this.rowOffsetMap), (uint)(row * this.kernelHeight)); + public readonly ref int GetSampleRow(uint row) + => ref Unsafe.Add(ref MemoryMarshal.GetReference(this.rowOffsetMap), row * this.kernelHeight); [MethodImpl(MethodImplOptions.AggressiveInlining)] - public readonly ref int GetSampleColumn(int column) - => ref Unsafe.Add(ref MemoryMarshal.GetReference(this.columnOffsetMap), (uint)(column * this.kernelWidth)); + public readonly ref int GetSampleColumn(uint column) + => ref Unsafe.Add(ref MemoryMarshal.GetReference(this.columnOffsetMap), column * this.kernelWidth); } diff --git a/src/ImageSharp/Processing/Processors/Convolution/ConvolutionProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Convolution/ConvolutionProcessor{TPixel}.cs index 4cbca8d74e..d059ebe030 100644 --- a/src/ImageSharp/Processing/Processors/Convolution/ConvolutionProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Convolution/ConvolutionProcessor{TPixel}.cs @@ -123,7 +123,7 @@ public void Invoke(int y, Span span) var state = new ConvolutionState(in this.kernel, this.map); int row = y - this.bounds.Y; - ref int sampleRowBase = ref state.GetSampleRow(row); + ref int sampleRowBase = ref state.GetSampleRow((uint)row); if (this.preserveAlpha) { @@ -132,23 +132,23 @@ public void Invoke(int y, Span span) ref Vector4 targetBase = ref MemoryMarshal.GetReference(targetBuffer); Span sourceRow; - for (int kY = 0; kY < state.Kernel.Rows; kY++) + for (uint kY = 0; kY < state.Kernel.Rows; kY++) { // Get the precalculated source sample row for this kernel row and copy to our buffer. - int offsetY = Unsafe.Add(ref sampleRowBase, (uint)kY); + int offsetY = Unsafe.Add(ref sampleRowBase, kY); sourceRow = this.sourcePixels.DangerousGetRowSpan(offsetY).Slice(boundsX, boundsWidth); PixelOperations.Instance.ToVector4(this.configuration, sourceRow, sourceBuffer); ref Vector4 sourceBase = ref MemoryMarshal.GetReference(sourceBuffer); - for (int x = 0; x < sourceBuffer.Length; x++) + for (uint x = 0; x < (uint)sourceBuffer.Length; x++) { ref int sampleColumnBase = ref state.GetSampleColumn(x); - ref Vector4 target = ref Unsafe.Add(ref targetBase, (uint)x); + ref Vector4 target = ref Unsafe.Add(ref targetBase, x); - for (int kX = 0; kX < state.Kernel.Columns; kX++) + for (uint kX = 0; kX < state.Kernel.Columns; kX++) { - int offsetX = Unsafe.Add(ref sampleColumnBase, (uint)kX) - boundsX; + int offsetX = Unsafe.Add(ref sampleColumnBase, kX) - boundsX; Vector4 sample = Unsafe.Add(ref sourceBase, (uint)offsetX); target += state.Kernel[kY, kX] * sample; } @@ -159,10 +159,10 @@ public void Invoke(int y, Span span) sourceRow = this.sourcePixels.DangerousGetRowSpan(y).Slice(boundsX, boundsWidth); PixelOperations.Instance.ToVector4(this.configuration, sourceRow, sourceBuffer); - for (int x = 0; x < sourceRow.Length; x++) + for (nuint x = 0; x < (uint)sourceRow.Length; x++) { - ref Vector4 target = ref Unsafe.Add(ref targetBase, (uint)x); - target.W = Unsafe.Add(ref MemoryMarshal.GetReference(sourceBuffer), (uint)x).W; + ref Vector4 target = ref Unsafe.Add(ref targetBase, x); + target.W = Unsafe.Add(ref MemoryMarshal.GetReference(sourceBuffer), x).W; } } else @@ -171,24 +171,24 @@ public void Invoke(int y, Span span) targetBuffer.Clear(); ref Vector4 targetBase = ref MemoryMarshal.GetReference(targetBuffer); - for (int kY = 0; kY < state.Kernel.Rows; kY++) + for (uint kY = 0; kY < state.Kernel.Rows; kY++) { // Get the precalculated source sample row for this kernel row and copy to our buffer. - int offsetY = Unsafe.Add(ref sampleRowBase, (uint)kY); + int offsetY = Unsafe.Add(ref sampleRowBase, kY); Span sourceRow = this.sourcePixels.DangerousGetRowSpan(offsetY).Slice(boundsX, boundsWidth); PixelOperations.Instance.ToVector4(this.configuration, sourceRow, sourceBuffer); Numerics.Premultiply(sourceBuffer); ref Vector4 sourceBase = ref MemoryMarshal.GetReference(sourceBuffer); - for (int x = 0; x < sourceBuffer.Length; x++) + for (uint x = 0; x < (uint)sourceBuffer.Length; x++) { ref int sampleColumnBase = ref state.GetSampleColumn(x); - ref Vector4 target = ref Unsafe.Add(ref targetBase, (uint)x); + ref Vector4 target = ref Unsafe.Add(ref targetBase, x); - for (int kX = 0; kX < state.Kernel.Columns; kX++) + for (uint kX = 0; kX < state.Kernel.Columns; kX++) { - int offsetX = Unsafe.Add(ref sampleColumnBase, (uint)kX) - boundsX; + int offsetX = Unsafe.Add(ref sampleColumnBase, kX) - boundsX; Vector4 sample = Unsafe.Add(ref sourceBase, (uint)offsetX); target += state.Kernel[kY, kX] * sample; } diff --git a/src/ImageSharp/Processing/Processors/Convolution/ConvolutionState.cs b/src/ImageSharp/Processing/Processors/Convolution/ConvolutionState.cs index dbf90d0170..6663c45021 100644 --- a/src/ImageSharp/Processing/Processors/Convolution/ConvolutionState.cs +++ b/src/ImageSharp/Processing/Processors/Convolution/ConvolutionState.cs @@ -13,16 +13,16 @@ internal readonly ref struct ConvolutionState { private readonly Span rowOffsetMap; private readonly Span columnOffsetMap; - private readonly int kernelHeight; - private readonly int kernelWidth; + private readonly uint kernelHeight; + private readonly uint kernelWidth; public ConvolutionState( in DenseMatrix kernel, KernelSamplingMap map) { this.Kernel = new ReadOnlyKernel(kernel); - this.kernelHeight = kernel.Rows; - this.kernelWidth = kernel.Columns; + this.kernelHeight = (uint)kernel.Rows; + this.kernelWidth = (uint)kernel.Columns; this.rowOffsetMap = map.GetRowOffsetSpan(); this.columnOffsetMap = map.GetColumnOffsetSpan(); } @@ -34,10 +34,10 @@ public readonly ReadOnlyKernel Kernel } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public readonly ref int GetSampleRow(int row) - => ref Unsafe.Add(ref MemoryMarshal.GetReference(this.rowOffsetMap), (uint)(row * this.kernelHeight)); + public readonly ref int GetSampleRow(uint row) + => ref Unsafe.Add(ref MemoryMarshal.GetReference(this.rowOffsetMap), row * this.kernelHeight); [MethodImpl(MethodImplOptions.AggressiveInlining)] - public readonly ref int GetSampleColumn(int column) - => ref Unsafe.Add(ref MemoryMarshal.GetReference(this.columnOffsetMap), (uint)(column * this.kernelWidth)); + public readonly ref int GetSampleColumn(uint column) + => ref Unsafe.Add(ref MemoryMarshal.GetReference(this.columnOffsetMap), column * this.kernelWidth); } diff --git a/src/ImageSharp/Processing/Processors/Convolution/EdgeDetectorCompassProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Convolution/EdgeDetectorCompassProcessor{TPixel}.cs index 8de92bee81..cbf893915c 100644 --- a/src/ImageSharp/Processing/Processors/Convolution/EdgeDetectorCompassProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Convolution/EdgeDetectorCompassProcessor{TPixel}.cs @@ -98,8 +98,8 @@ protected override void OnFrameApply(ImageFrame source) { private readonly Buffer2D targetPixels; private readonly Buffer2D passPixels; - private readonly int minX; - private readonly int maxX; + private readonly uint minX; + private readonly uint maxX; [MethodImpl(InliningOptions.ShortMethod)] public RowOperation( @@ -109,8 +109,8 @@ public RowOperation( { this.targetPixels = targetPixels; this.passPixels = passPixels; - this.minX = bounds.X; - this.maxX = bounds.Right; + this.minX = (uint)bounds.X; + this.maxX = (uint)bounds.Right; } /// @@ -120,11 +120,11 @@ public void Invoke(int y) ref TPixel passPixelsBase = ref MemoryMarshal.GetReference(this.passPixels.DangerousGetRowSpan(y)); ref TPixel targetPixelsBase = ref MemoryMarshal.GetReference(this.targetPixels.DangerousGetRowSpan(y)); - for (int x = this.minX; x < this.maxX; x++) + for (nuint x = this.minX; x < this.maxX; x++) { // Grab the max components of the two pixels - ref TPixel currentPassPixel = ref Unsafe.Add(ref passPixelsBase, (uint)x); - ref TPixel currentTargetPixel = ref Unsafe.Add(ref targetPixelsBase, (uint)x); + ref TPixel currentPassPixel = ref Unsafe.Add(ref passPixelsBase, x); + ref TPixel currentTargetPixel = ref Unsafe.Add(ref targetPixelsBase, x); var pixelValue = Vector4.Max(currentPassPixel.ToVector4(), currentTargetPixel.ToVector4()); diff --git a/src/ImageSharp/Processing/Processors/Convolution/ReadOnlyKernel.cs b/src/ImageSharp/Processing/Processors/Convolution/ReadOnlyKernel.cs index 46c35c62c7..2a09589bda 100644 --- a/src/ImageSharp/Processing/Processors/Convolution/ReadOnlyKernel.cs +++ b/src/ImageSharp/Processing/Processors/Convolution/ReadOnlyKernel.cs @@ -17,43 +17,43 @@ internal readonly ref struct ReadOnlyKernel public ReadOnlyKernel(DenseMatrix matrix) { - this.Columns = matrix.Columns; - this.Rows = matrix.Rows; + this.Columns = (uint)matrix.Columns; + this.Rows = (uint)matrix.Rows; this.values = matrix.Span; } - public int Columns + public uint Columns { [MethodImpl(MethodImplOptions.AggressiveInlining)] get; } - public int Rows + public uint Rows { [MethodImpl(MethodImplOptions.AggressiveInlining)] get; } - public float this[int row, int column] + public float this[uint row, uint column] { [MethodImpl(MethodImplOptions.AggressiveInlining)] get { this.CheckCoordinates(row, column); ref float vBase = ref MemoryMarshal.GetReference(this.values); - return Unsafe.Add(ref vBase, (uint)((row * this.Columns) + column)); + return Unsafe.Add(ref vBase, (row * this.Columns) + column); } } [Conditional("DEBUG")] - private void CheckCoordinates(int row, int column) + private void CheckCoordinates(uint row, uint column) { - if (row < 0 || row >= this.Rows) + if (row >= this.Rows) { throw new ArgumentOutOfRangeException(nameof(row), row, $"{row} is outwith the matrix bounds."); } - if (column < 0 || column >= this.Columns) + if (column >= this.Columns) { throw new ArgumentOutOfRangeException(nameof(column), column, $"{column} is outwith the matrix bounds."); } From 2bbf1cb9b30ec5b529a6af6bab106a481d8d637a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=BCnther=20Foidl?= Date: Fri, 24 Mar 2023 11:38:36 +0100 Subject: [PATCH 12/12] Fixed division by vector length --- .../Helpers/SimdUtils.ExtendedIntrinsics.cs | 4 ++-- .../Common/Helpers/SimdUtils.HwIntrinsics.cs | 18 +++++++++--------- .../Jpeg/Components/Block8x8F.ScaledCopy.cs | 2 +- .../JpegColorConverter.CmykAvx.cs | 4 ++-- .../JpegColorConverter.CmykVector.cs | 4 ++-- .../JpegColorConverter.GrayScaleAvx.cs | 4 ++-- .../JpegColorConverter.GrayScaleVector.cs | 4 ++-- .../JpegColorConverter.RgbArm.cs | 2 +- .../JpegColorConverter.RgbAvx.cs | 2 +- .../JpegColorConverter.RgbVector.cs | 2 +- .../JpegColorConverter.YCbCrAvx.cs | 4 ++-- .../JpegColorConverter.YCbCrVector.cs | 4 ++-- .../JpegColorConverter.YccKAvx.cs | 4 ++-- .../JpegColorConverter.YccKVector.cs | 4 ++-- .../Components/Encoder/ComponentProcessor.cs | 10 +++++----- .../ImageSharp.Benchmarks/Bulk/FromVector4.cs | 5 ++--- .../Bulk/ToVector4_Rgba32.cs | 4 ++-- .../PixelConversion_PackFromRgbPlanes.cs | 2 +- .../General/Vectorization/UInt32ToSingle.cs | 10 +++++----- .../General/Vectorization/VectorFetching.cs | 6 +++--- .../Vectorization/WidenBytesToUInt32.cs | 2 +- 21 files changed, 50 insertions(+), 51 deletions(-) diff --git a/src/ImageSharp/Common/Helpers/SimdUtils.ExtendedIntrinsics.cs b/src/ImageSharp/Common/Helpers/SimdUtils.ExtendedIntrinsics.cs index 43998d0ec9..b9505ba3ef 100644 --- a/src/ImageSharp/Common/Helpers/SimdUtils.ExtendedIntrinsics.cs +++ b/src/ImageSharp/Common/Helpers/SimdUtils.ExtendedIntrinsics.cs @@ -97,7 +97,7 @@ internal static void ByteToNormalizedFloat(ReadOnlySpan source, Span.Count); - nuint n = (uint)(dest.Length / Vector.Count); + nuint n = (uint)dest.Length / (uint)Vector.Count; ref Vector sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); ref Vector destBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(dest)); @@ -132,7 +132,7 @@ internal static void NormalizedFloatToByteSaturate( { VerifySpanInput(source, dest, Vector.Count); - nuint n = (uint)(dest.Length / Vector.Count); + nuint n = (uint)dest.Length / (uint)Vector.Count; ref Vector sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); diff --git a/src/ImageSharp/Common/Helpers/SimdUtils.HwIntrinsics.cs b/src/ImageSharp/Common/Helpers/SimdUtils.HwIntrinsics.cs index 5f83ccd6be..ce6f335a8f 100644 --- a/src/ImageSharp/Common/Helpers/SimdUtils.HwIntrinsics.cs +++ b/src/ImageSharp/Common/Helpers/SimdUtils.HwIntrinsics.cs @@ -391,7 +391,7 @@ private static void Shuffle3( ref Vector128 destBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(dest)); - nuint n = (uint)(source.Length / Vector128.Count); + nuint n = (uint)source.Length / (uint)Vector128.Count; for (nuint i = 0; i < n; i += 3) { @@ -454,7 +454,7 @@ private static void Pad3Shuffle4( ref Vector128 destBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(dest)); - nuint n = (uint)(source.Length / Vector128.Count); + nuint n = (uint)source.Length / (uint)Vector128.Count; for (nuint i = 0, j = 0; i < n; i += 3, j += 4) { @@ -498,7 +498,7 @@ private static void Shuffle4Slice3( ref Vector128 destBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(dest)); - nuint n = (uint)(source.Length / Vector128.Count); + nuint n = (uint)source.Length / (uint)Vector128.Count; for (nuint i = 0, j = 0; i < n; i += 4, j += 3) { @@ -650,7 +650,7 @@ internal static unsafe void ByteToNormalizedFloat( { VerifySpanInput(source, dest, Vector256.Count); - nuint n = (uint)(dest.Length / Vector256.Count); + nuint n = (uint)dest.Length / (uint)Vector256.Count; ref Vector256 destBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(dest)); @@ -683,7 +683,7 @@ internal static unsafe void ByteToNormalizedFloat( // Sse VerifySpanInput(source, dest, Vector128.Count); - nuint n = (uint)(dest.Length / Vector128.Count); + nuint n = (uint)dest.Length / (uint)Vector128.Count; ref Vector128 destBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(dest)); @@ -782,7 +782,7 @@ internal static void NormalizedFloatToByteSaturate( { VerifySpanInput(source, dest, Vector256.Count); - nuint n = (uint)(dest.Length / Vector256.Count); + nuint n = (uint)dest.Length / (uint)Vector256.Count; ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -821,7 +821,7 @@ internal static void NormalizedFloatToByteSaturate( // Sse VerifySpanInput(source, dest, Vector128.Count); - nuint n = (uint)(dest.Length / Vector128.Count); + nuint n = (uint)dest.Length / (uint)Vector128.Count; ref Vector128 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); @@ -864,7 +864,7 @@ internal static void PackFromRgbPlanesAvx2Reduce( ref Vector256 bBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(blueChannel)); ref byte dBase = ref Unsafe.As(ref MemoryMarshal.GetReference(destination)); - nuint count = (uint)(redChannel.Length / Vector256.Count); + nuint count = (uint)redChannel.Length / (uint)Vector256.Count; ref byte control1Bytes = ref MemoryMarshal.GetReference(PermuteMaskEvenOdd8x32); Vector256 control1 = Unsafe.As>(ref control1Bytes); @@ -936,7 +936,7 @@ internal static void PackFromRgbPlanesAvx2Reduce( ref Vector256 bBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(blueChannel)); ref Vector256 dBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(destination)); - nuint count = (uint)(redChannel.Length / Vector256.Count); + nuint count = (uint)redChannel.Length / (uint)Vector256.Count; ref byte control1Bytes = ref MemoryMarshal.GetReference(PermuteMaskEvenOdd8x32); Vector256 control1 = Unsafe.As>(ref control1Bytes); var a = Vector256.Create((byte)255); diff --git a/src/ImageSharp/Formats/Jpeg/Components/Block8x8F.ScaledCopy.cs b/src/ImageSharp/Formats/Jpeg/Components/Block8x8F.ScaledCopy.cs index 652c064ad5..efc1dbd729 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/Block8x8F.ScaledCopy.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/Block8x8F.ScaledCopy.cs @@ -98,7 +98,7 @@ private void CopyArbitraryScale(ref float areaOrigin, uint areaStride, uint hori nuint xx = x * horizontalScale; float value = this[(int)(y8 + x)]; - nuint baseIdx = (uint)((yy * areaStride) + xx); + nuint baseIdx = (yy * areaStride) + xx; for (nuint i = 0; i < verticalScale; i++, baseIdx += areaStride) { diff --git a/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.CmykAvx.cs b/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.CmykAvx.cs index 07ba3648c4..0283e83d0f 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.CmykAvx.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.CmykAvx.cs @@ -32,7 +32,7 @@ public override void ConvertToRgbInplace(in ComponentValues values) // Used for the color conversion var scale = Vector256.Create(1 / (this.MaximumValue * this.MaximumValue)); - nuint n = (uint)(values.Component0.Length / Vector256.Count); + nuint n = (uint)values.Component0.Length / (uint)Vector256.Count; for (nuint i = 0; i < n; i++) { ref Vector256 c = ref Unsafe.Add(ref c0Base, i); @@ -71,7 +71,7 @@ public static void ConvertFromRgb(in ComponentValues values, float maxValue, Spa var scale = Vector256.Create(maxValue); - nuint n = (uint)(values.Component0.Length / Vector256.Count); + nuint n = (uint)values.Component0.Length / (uint)Vector256.Count; for (nuint i = 0; i < n; i++) { Vector256 ctmp = Avx.Subtract(scale, Unsafe.Add(ref srcR, i)); diff --git a/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.CmykVector.cs b/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.CmykVector.cs index 2e2ff08bf9..4cc8c0665f 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.CmykVector.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.CmykVector.cs @@ -30,7 +30,7 @@ protected override void ConvertToRgbInplaceVectorized(in ComponentValues values) var scale = new Vector(1 / (this.MaximumValue * this.MaximumValue)); - nuint n = (uint)(values.Component0.Length / Vector.Count); + nuint n = (uint)values.Component0.Length / (uint)Vector.Count; for (nuint i = 0; i < n; i++) { ref Vector c = ref Unsafe.Add(ref cBase, i); @@ -78,7 +78,7 @@ public static void ConvertFromRgbInplaceVectorized(in ComponentValues values, fl // Used for the color conversion var scale = new Vector(maxValue); - nuint n = (uint)(values.Component0.Length / Vector.Count); + nuint n = (uint)values.Component0.Length / (uint)Vector.Count; for (nuint i = 0; i < n; i++) { Vector ctmp = scale - Unsafe.Add(ref srcR, i); diff --git a/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.GrayScaleAvx.cs b/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.GrayScaleAvx.cs index 80ae6621c4..4efb6f8514 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.GrayScaleAvx.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.GrayScaleAvx.cs @@ -27,7 +27,7 @@ public override void ConvertToRgbInplace(in ComponentValues values) // Used for the color conversion var scale = Vector256.Create(1 / this.MaximumValue); - nuint n = (uint)(values.Component0.Length / Vector256.Count); + nuint n = (uint)values.Component0.Length / (uint)Vector256.Count; for (nuint i = 0; i < n; i++) { ref Vector256 c0 = ref Unsafe.Add(ref c0Base, i); @@ -53,7 +53,7 @@ public override void ConvertFromRgb(in ComponentValues values, Span rLane var f0587 = Vector256.Create(0.587f); var f0114 = Vector256.Create(0.114f); - nuint n = (uint)(values.Component0.Length / Vector256.Count); + nuint n = (uint)values.Component0.Length / (uint)Vector256.Count; for (nuint i = 0; i < n; i++) { ref Vector256 r = ref Unsafe.Add(ref srcRed, i); diff --git a/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.GrayScaleVector.cs b/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.GrayScaleVector.cs index 018e0ca442..4156a5968b 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.GrayScaleVector.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.GrayScaleVector.cs @@ -24,7 +24,7 @@ protected override void ConvertToRgbInplaceVectorized(in ComponentValues values) var scale = new Vector(1 / this.MaximumValue); - nuint n = (uint)(values.Component0.Length / Vector.Count); + nuint n = (uint)values.Component0.Length / (uint)Vector.Count; for (nuint i = 0; i < n; i++) { ref Vector c0 = ref Unsafe.Add(ref cBase, i); @@ -53,7 +53,7 @@ protected override void ConvertFromRgbVectorized(in ComponentValues values, Span var gMult = new Vector(0.587f); var bMult = new Vector(0.114f); - nuint n = (uint)(values.Component0.Length / Vector.Count); + nuint n = (uint)values.Component0.Length / (uint)Vector.Count; for (nuint i = 0; i < n; i++) { Vector r = Unsafe.Add(ref srcR, i); diff --git a/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.RgbArm.cs b/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.RgbArm.cs index 72d8340a0f..8889223064 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.RgbArm.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.RgbArm.cs @@ -30,7 +30,7 @@ public override void ConvertToRgbInplace(in ComponentValues values) // Used for the color conversion var scale = Vector128.Create(1 / this.MaximumValue); - nuint n = (uint)(values.Component0.Length / Vector128.Count); + nuint n = (uint)values.Component0.Length / (uint)Vector128.Count; for (nuint i = 0; i < n; i++) { ref Vector128 r = ref Unsafe.Add(ref rBase, i); diff --git a/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.RgbAvx.cs b/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.RgbAvx.cs index 8c095309c7..ae9b943aaf 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.RgbAvx.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.RgbAvx.cs @@ -29,7 +29,7 @@ public override void ConvertToRgbInplace(in ComponentValues values) // Used for the color conversion var scale = Vector256.Create(1 / this.MaximumValue); - nuint n = (uint)(values.Component0.Length / Vector256.Count); + nuint n = (uint)values.Component0.Length / (uint)Vector256.Count; for (nuint i = 0; i < n; i++) { ref Vector256 r = ref Unsafe.Add(ref rBase, i); diff --git a/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.RgbVector.cs b/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.RgbVector.cs index cbba796440..5e3cf9b2b3 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.RgbVector.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.RgbVector.cs @@ -28,7 +28,7 @@ protected override void ConvertToRgbInplaceVectorized(in ComponentValues values) var scale = new Vector(1 / this.MaximumValue); - nuint n = (uint)(values.Component0.Length / Vector.Count); + nuint n = (uint)values.Component0.Length / (uint)Vector.Count; for (nuint i = 0; i < n; i++) { ref Vector r = ref Unsafe.Add(ref rBase, i); diff --git a/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.YCbCrAvx.cs b/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.YCbCrAvx.cs index e828ba1179..0a2cfd084c 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.YCbCrAvx.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.YCbCrAvx.cs @@ -38,7 +38,7 @@ public override void ConvertToRgbInplace(in ComponentValues values) var bCbMult = Vector256.Create(YCbCrScalar.BCbMult); // Walking 8 elements at one step: - nuint n = (uint)(values.Component0.Length / Vector256.Count); + nuint n = (uint)values.Component0.Length / (uint)Vector256.Count; for (nuint i = 0; i < n; i++) { // y = yVals[i]; @@ -98,7 +98,7 @@ public override void ConvertFromRgb(in ComponentValues values, Span rLane var fn0081312F = Vector256.Create(-0.081312F); var f05 = Vector256.Create(0.5f); - nuint n = (uint)(values.Component0.Length / Vector256.Count); + nuint n = (uint)values.Component0.Length / (uint)Vector256.Count; for (nuint i = 0; i < n; i++) { Vector256 r = Unsafe.Add(ref srcR, i); diff --git a/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.YCbCrVector.cs b/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.YCbCrVector.cs index e3b4be235f..ca01aed612 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.YCbCrVector.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.YCbCrVector.cs @@ -35,7 +35,7 @@ protected override void ConvertToRgbInplaceVectorized(in ComponentValues values) var gCrMult = new Vector(-YCbCrScalar.GCrMult); var bCbMult = new Vector(YCbCrScalar.BCbMult); - nuint n = (uint)(values.Component0.Length / Vector.Count); + nuint n = (uint)values.Component0.Length / (uint)Vector.Count; for (nuint i = 0; i < n; i++) { // y = yVals[i]; @@ -103,7 +103,7 @@ protected override void ConvertFromRgbVectorized(in ComponentValues values, Span var gCrMult = new Vector(0.418688f); var bCrMult = new Vector(0.081312f); - nuint n = (uint)(values.Component0.Length / Vector.Count); + nuint n = (uint)values.Component0.Length / (uint)Vector.Count; for (nuint i = 0; i < n; i++) { Vector r = Unsafe.Add(ref srcR, i); diff --git a/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.YccKAvx.cs b/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.YccKAvx.cs index 8ab2dd3d67..337741622a 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.YccKAvx.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.YccKAvx.cs @@ -40,7 +40,7 @@ public override void ConvertToRgbInplace(in ComponentValues values) var bCbMult = Vector256.Create(YCbCrScalar.BCbMult); // Walking 8 elements at one step: - nuint n = (uint)(values.Component0.Length / Vector256.Count); + nuint n = (uint)values.Component0.Length / (uint)Vector256.Count; for (nuint i = 0; i < n; i++) { // y = yVals[i]; @@ -109,7 +109,7 @@ public override void ConvertFromRgb(in ComponentValues values, Span rLane var fn0081312F = Vector256.Create(-0.081312F); var f05 = Vector256.Create(0.5f); - nuint n = (uint)(values.Component0.Length / Vector256.Count); + nuint n = (uint)values.Component0.Length / (uint)Vector256.Count; for (nuint i = 0; i < n; i++) { Vector256 r = Avx.Subtract(maxSampleValue, Unsafe.Add(ref srcR, i)); diff --git a/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.YccKVector.cs b/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.YccKVector.cs index 711b0fe3bb..d67fad3080 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.YccKVector.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.YccKVector.cs @@ -36,7 +36,7 @@ protected override void ConvertToRgbInplaceVectorized(in ComponentValues values) var gCrMult = new Vector(-YCbCrScalar.GCrMult); var bCbMult = new Vector(YCbCrScalar.BCbMult); - nuint n = (uint)(values.Component0.Length / Vector.Count); + nuint n = (uint)values.Component0.Length / (uint)Vector.Count; for (nuint i = 0; i < n; i++) { // y = yVals[i]; @@ -107,7 +107,7 @@ protected override void ConvertFromRgbVectorized(in ComponentValues values, Span var gCrMult = new Vector(0.418688f); var bCrMult = new Vector(0.081312f); - nuint n = (uint)(values.Component0.Length / Vector.Count); + nuint n = (uint)values.Component0.Length / (uint)Vector.Count; for (nuint i = 0; i < n; i++) { Vector r = maxSampleValue - Unsafe.Add(ref srcR, i); diff --git a/src/ImageSharp/Formats/Jpeg/Components/Encoder/ComponentProcessor.cs b/src/ImageSharp/Formats/Jpeg/Components/Encoder/ComponentProcessor.cs index c7d9498b6b..4815baa62f 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/Encoder/ComponentProcessor.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/Encoder/ComponentProcessor.cs @@ -122,7 +122,7 @@ static void SumVertical(Span target, Span source) ref Vector256 sourceVectorRef = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); // Spans are guaranteed to be multiple of 8 so no extra 'remainder' steps are needed - nuint count = (uint)(source.Length / Vector256.Count); + nuint count = (uint)source.Length / (uint)Vector256.Count; for (nuint i = 0; i < count; i++) { Unsafe.Add(ref targetVectorRef, i) = Avx.Add(Unsafe.Add(ref targetVectorRef, i), Unsafe.Add(ref sourceVectorRef, i)); @@ -133,7 +133,7 @@ static void SumVertical(Span target, Span source) ref Vector targetVectorRef = ref Unsafe.As>(ref MemoryMarshal.GetReference(target)); ref Vector sourceVectorRef = ref Unsafe.As>(ref MemoryMarshal.GetReference(source)); - nuint count = (uint)(source.Length / Vector.Count); + nuint count = (uint)source.Length / (uint)Vector.Count; for (nuint i = 0; i < count; i++) { Unsafe.Add(ref targetVectorRef, i) += Unsafe.Add(ref sourceVectorRef, i); @@ -166,7 +166,7 @@ static void SumHorizontal(Span target, int factor) source = source.Slice(touchedCount); target = target.Slice(touchedCount / factor); - nuint length = (uint)(touchedCount / Vector256.Count); + nuint length = (uint)touchedCount / (uint)Vector256.Count; for (uint i = 0; i < haddIterationsCount; i++) { @@ -200,7 +200,7 @@ static void MultiplyToAverage(Span target, float multiplier) ref Vector256 targetVectorRef = ref Unsafe.As>(ref MemoryMarshal.GetReference(target)); // Spans are guaranteed to be multiple of 8 so no extra 'remainder' steps are needed - nuint count = (uint)(target.Length / Vector256.Count); + nuint count = (uint)target.Length / (uint)Vector256.Count; var multiplierVector = Vector256.Create(multiplier); for (nuint i = 0; i < count; i++) { @@ -211,7 +211,7 @@ static void MultiplyToAverage(Span target, float multiplier) { ref Vector targetVectorRef = ref Unsafe.As>(ref MemoryMarshal.GetReference(target)); - nuint count = (uint)(target.Length / Vector.Count); + nuint count = (uint)target.Length / (uint)Vector.Count; var multiplierVector = new Vector(multiplier); for (nuint i = 0; i < count; i++) { diff --git a/tests/ImageSharp.Benchmarks/Bulk/FromVector4.cs b/tests/ImageSharp.Benchmarks/Bulk/FromVector4.cs index f0eeb5afb7..7e6cec2018 100644 --- a/tests/ImageSharp.Benchmarks/Bulk/FromVector4.cs +++ b/tests/ImageSharp.Benchmarks/Bulk/FromVector4.cs @@ -103,10 +103,9 @@ public void UseAvx2_Grouped() Span src = MemoryMarshal.Cast(this.source.GetSpan()); Span dest = MemoryMarshal.Cast(this.destination.GetSpan()); - nuint n = (uint)(dest.Length / Vector.Count); + nuint n = (uint)dest.Length / (uint)Vector.Count; - ref Vector256 sourceBase = - ref Unsafe.As>(ref MemoryMarshal.GetReference(src)); + ref Vector256 sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(src)); ref Vector256 destBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(dest)); ref byte maskBase = ref MemoryMarshal.GetReference(PermuteMaskDeinterleave8x32); diff --git a/tests/ImageSharp.Benchmarks/Bulk/ToVector4_Rgba32.cs b/tests/ImageSharp.Benchmarks/Bulk/ToVector4_Rgba32.cs index ce3fb70c88..9abf0ed22a 100644 --- a/tests/ImageSharp.Benchmarks/Bulk/ToVector4_Rgba32.cs +++ b/tests/ImageSharp.Benchmarks/Bulk/ToVector4_Rgba32.cs @@ -54,7 +54,7 @@ public void ExtendedIntrinsics_BulkConvertByteToNormalizedFloat_2Loops() Span sBytes = MemoryMarshal.Cast(this.source.GetSpan()); Span dFloats = MemoryMarshal.Cast(this.destination.GetSpan()); - nuint n = (uint)(dFloats.Length / Vector.Count); + nuint n = (uint)dFloats.Length / (uint)Vector.Count; ref Vector sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference((ReadOnlySpan)sBytes)); ref Vector destBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(dFloats)); @@ -96,7 +96,7 @@ public void ExtendedIntrinsics_BulkConvertByteToNormalizedFloat_ConvertInSameLoo Span sBytes = MemoryMarshal.Cast(this.source.GetSpan()); Span dFloats = MemoryMarshal.Cast(this.destination.GetSpan()); - nuint n = (uint)(dFloats.Length / Vector.Count); + nuint n = (uint)dFloats.Length / (uint)Vector.Count; ref Vector sourceBase = ref Unsafe.As>(ref MemoryMarshal.GetReference((ReadOnlySpan)sBytes)); ref Vector destBase = ref Unsafe.As>(ref MemoryMarshal.GetReference(dFloats)); diff --git a/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_PackFromRgbPlanes.cs b/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_PackFromRgbPlanes.cs index e3677d238d..ddf192af87 100644 --- a/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_PackFromRgbPlanes.cs +++ b/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_PackFromRgbPlanes.cs @@ -205,7 +205,7 @@ public void Rgba32_Avx2_Float() ref Vector256 bBase = ref Unsafe.As>(ref this.bFloat[0]); ref Vector256 resultBase = ref Unsafe.As>(ref this.rgbaFloat[0]); - nuint count = (uint)(this.Count / Vector256.Count); + nuint count = (uint)this.Count / (uint)Vector256.Count; ref byte control = ref MemoryMarshal.GetReference(SimdUtils.HwIntrinsics.PermuteMaskEvenOdd8x32); Vector256 vcontrol = Unsafe.As>(ref control); diff --git a/tests/ImageSharp.Benchmarks/General/Vectorization/UInt32ToSingle.cs b/tests/ImageSharp.Benchmarks/General/Vectorization/UInt32ToSingle.cs index 010e1f52b3..fc4dc1fa16 100644 --- a/tests/ImageSharp.Benchmarks/General/Vectorization/UInt32ToSingle.cs +++ b/tests/ImageSharp.Benchmarks/General/Vectorization/UInt32ToSingle.cs @@ -12,7 +12,7 @@ public class UInt32ToSingle { private float[] data; - private const int Count = 32; + private const uint Count = 32; [GlobalSetup] public void Setup() @@ -25,7 +25,7 @@ public void MagicMethod() { ref Vector b = ref Unsafe.As>(ref this.data[0]); - nuint n = (uint)(Count / Vector.Count); + nuint n = Count / (uint)Vector.Count; var bVec = new Vector(256.0f / 255.0f); var magicFloat = new Vector(32768.0f); @@ -50,7 +50,7 @@ public void MagicMethod() [Benchmark] public void StandardSimd() { - nuint n = (uint)(Count / Vector.Count); + nuint n = Count / (uint)Vector.Count; ref Vector bf = ref Unsafe.As>(ref this.data[0]); ref Vector bu = ref Unsafe.As, Vector>(ref bf); @@ -69,7 +69,7 @@ public void StandardSimd() [Benchmark] public void StandardSimdFromInt() { - nuint n = (uint)(Count / Vector.Count); + nuint n = Count / (uint)Vector.Count; ref Vector bf = ref Unsafe.As>(ref this.data[0]); ref Vector bu = ref Unsafe.As, Vector>(ref bf); @@ -88,7 +88,7 @@ public void StandardSimdFromInt() [Benchmark] public void StandardSimdFromInt_RefCast() { - nuint n = (uint)(Count / Vector.Count); + nuint n = Count / (uint)Vector.Count; ref Vector bf = ref Unsafe.As>(ref this.data[0]); var scale = new Vector(1f / 255f); diff --git a/tests/ImageSharp.Benchmarks/General/Vectorization/VectorFetching.cs b/tests/ImageSharp.Benchmarks/General/Vectorization/VectorFetching.cs index 32027729b2..5d20f29d18 100644 --- a/tests/ImageSharp.Benchmarks/General/Vectorization/VectorFetching.cs +++ b/tests/ImageSharp.Benchmarks/General/Vectorization/VectorFetching.cs @@ -63,7 +63,7 @@ public void FetchWithUnsafeCast() var v = new Vector(this.testValue); ref Vector start = ref Unsafe.As>(ref this.data[0]); - nuint n = (uint)(this.InputSize / Vector.Count); + nuint n = (uint)this.InputSize / (uint)Vector.Count; for (nuint i = 0; i < n; i++) { @@ -82,7 +82,7 @@ public void FetchWithUnsafeCastNoTempVector() var v = new Vector(this.testValue); ref Vector start = ref Unsafe.As>(ref this.data[0]); - nuint n = (uint)(this.InputSize / Vector.Count); + nuint n = (uint)this.InputSize / (uint)Vector.Count; for (nuint i = 0; i < n; i++) { @@ -100,7 +100,7 @@ public void FetchWithUnsafeCastFromReference() ref Vector start = ref Unsafe.As>(ref MemoryMarshal.GetReference(span)); - nuint n = (uint)(this.InputSize / Vector.Count); + nuint n = (uint)this.InputSize / (uint)Vector.Count; for (nuint i = 0; i < n; i++) { diff --git a/tests/ImageSharp.Benchmarks/General/Vectorization/WidenBytesToUInt32.cs b/tests/ImageSharp.Benchmarks/General/Vectorization/WidenBytesToUInt32.cs index 6ad7827eb1..f391e42012 100644 --- a/tests/ImageSharp.Benchmarks/General/Vectorization/WidenBytesToUInt32.cs +++ b/tests/ImageSharp.Benchmarks/General/Vectorization/WidenBytesToUInt32.cs @@ -42,7 +42,7 @@ public void Standard() [Benchmark] public void Simd() { - nuint n = (uint)(Count / Vector.Count); + nuint n = Count / (uint)Vector.Count; ref Vector sBase = ref Unsafe.As>(ref this.source[0]); ref Vector dBase = ref Unsafe.As>(ref this.dest[0]);