Browse Source

Reverted some pinning changes to have less verbose C# code

pull/2418/head
Günther Foidl 3 years ago
parent
commit
4b84aecb94
  1. 2
      src/ImageSharp/Common/Helpers/SimdUtils.HwIntrinsics.cs
  2. 2
      src/ImageSharp/Compression/Zlib/Adler32.cs
  3. 6
      src/ImageSharp/Compression/Zlib/Crc32.cs
  4. 2
      src/ImageSharp/Formats/Webp/Lossless/LosslessUtils.cs
  5. 10
      src/ImageSharp/Formats/Webp/Lossless/PredictorEncoder.cs
  6. 2
      src/ImageSharp/Formats/Webp/WebpCommonUtils.cs
  7. 2
      src/ImageSharp/Memory/Buffer2DExtensions.cs

2
src/ImageSharp/Common/Helpers/SimdUtils.HwIntrinsics.cs

@ -673,7 +673,7 @@ internal static partial class SimdUtils
ReadOnlySpan<byte> source, ReadOnlySpan<byte> source,
Span<float> dest) Span<float> dest)
{ {
fixed (byte* sourceBase = &MemoryMarshal.GetReference(source)) fixed (byte* sourceBase = source)
{ {
if (Avx2.IsSupported) if (Avx2.IsSupported)
{ {

2
src/ImageSharp/Compression/Zlib/Adler32.cs

@ -387,7 +387,7 @@ internal static class Adler32
uint s1 = adler & 0xFFFF; uint s1 = adler & 0xFFFF;
uint s2 = (adler >> 16) & 0xFFFF; uint s2 = (adler >> 16) & 0xFFFF;
fixed (byte* bufferPtr = &MemoryMarshal.GetReference(buffer)) fixed (byte* bufferPtr = buffer)
{ {
byte* localBufferPtr = bufferPtr; byte* localBufferPtr = bufferPtr;
uint length = (uint)buffer.Length; uint length = (uint)buffer.Length;

6
src/ImageSharp/Compression/Zlib/Crc32.cs

@ -81,7 +81,7 @@ internal static partial class Crc32
int chunksize = buffer.Length & ~ChunksizeMask; int chunksize = buffer.Length & ~ChunksizeMask;
int length = chunksize; int length = chunksize;
fixed (byte* bufferPtr = &MemoryMarshal.GetReference(buffer)) fixed (byte* bufferPtr = buffer)
{ {
fixed (ulong* k05PolyPtr = K05Poly) fixed (ulong* k05PolyPtr = K05Poly)
{ {
@ -201,7 +201,7 @@ internal static partial class Crc32
[MethodImpl(InliningOptions.HotPath | InliningOptions.ShortMethod)] [MethodImpl(InliningOptions.HotPath | InliningOptions.ShortMethod)]
private static unsafe uint CalculateArm(uint crc, ReadOnlySpan<byte> buffer) private static unsafe uint CalculateArm(uint crc, ReadOnlySpan<byte> buffer)
{ {
fixed (byte* bufferPtr = &MemoryMarshal.GetReference(buffer)) fixed (byte* bufferPtr = buffer)
{ {
byte* localBufferPtr = bufferPtr; byte* localBufferPtr = bufferPtr;
int len = buffer.Length; int len = buffer.Length;
@ -248,7 +248,7 @@ internal static partial class Crc32
[MethodImpl(InliningOptions.HotPath | InliningOptions.ShortMethod)] [MethodImpl(InliningOptions.HotPath | InliningOptions.ShortMethod)]
private static unsafe uint CalculateArm64(uint crc, ReadOnlySpan<byte> buffer) private static unsafe uint CalculateArm64(uint crc, ReadOnlySpan<byte> buffer)
{ {
fixed (byte* bufferPtr = &MemoryMarshal.GetReference(buffer)) fixed (byte* bufferPtr = buffer)
{ {
byte* localBufferPtr = bufferPtr; byte* localBufferPtr = bufferPtr;
int len = buffer.Length; int len = buffer.Length;

2
src/ImageSharp/Formats/Webp/Lossless/LosslessUtils.cs

@ -569,7 +569,7 @@ internal static unsafe class LosslessUtils
Span<uint> pixelData, Span<uint> pixelData,
Span<uint> outputSpan) Span<uint> outputSpan)
{ {
fixed (uint* inputFixed = &MemoryMarshal.GetReference(pixelData)) fixed (uint* inputFixed = pixelData)
{ {
fixed (uint* outputFixed = outputSpan) fixed (uint* outputFixed = outputSpan)
{ {

10
src/ImageSharp/Formats/Webp/Lossless/PredictorEncoder.cs

@ -353,8 +353,8 @@ internal static unsafe class PredictorEncoder
else else
{ {
#pragma warning disable SA1503 // Braces should not be omitted #pragma warning disable SA1503 // Braces should not be omitted
fixed (uint* currentRow = &MemoryMarshal.GetReference(currentRowSpan)) fixed (uint* currentRow = currentRowSpan)
fixed (uint* upperRow = &MemoryMarshal.GetReference(upperRowSpan)) fixed (uint* upperRow = upperRowSpan)
{ {
for (int x = xStart; x < xEnd; x++) for (int x = xStart; x < xEnd; x++)
{ {
@ -664,9 +664,9 @@ internal static unsafe class PredictorEncoder
Span<short> scratch) Span<short> scratch)
{ {
#pragma warning disable SA1503 // Braces should not be omitted #pragma warning disable SA1503 // Braces should not be omitted
fixed (uint* current = &MemoryMarshal.GetReference(currentSpan)) fixed (uint* current = currentSpan)
fixed (uint* upper = &MemoryMarshal.GetReference(upperSpan)) fixed (uint* upper = upperSpan)
fixed (uint* outputFixed = &MemoryMarshal.GetReference(outputSpan)) fixed (uint* outputFixed = outputSpan)
{ {
uint* output = outputFixed; uint* output = outputFixed;
if (xStart == 0) if (xStart == 0)

2
src/ImageSharp/Formats/Webp/WebpCommonUtils.cs

@ -81,7 +81,7 @@ internal static class WebpCommonUtils
ReadOnlySpan<byte> rowBytes = MemoryMarshal.AsBytes(row); ReadOnlySpan<byte> rowBytes = MemoryMarshal.AsBytes(row);
int i = 0; int i = 0;
int length = (row.Length * 4) - 3; int length = (row.Length * 4) - 3;
fixed (byte* src = &MemoryMarshal.GetReference(rowBytes)) fixed (byte* src = rowBytes)
{ {
for (; i + 64 <= length; i += 64) for (; i + 64 <= length; i += 64)
{ {

2
src/ImageSharp/Memory/Buffer2DExtensions.cs

@ -50,7 +50,7 @@ public static class Buffer2DExtensions
Span<byte> span = MemoryMarshal.AsBytes(buffer.DangerousGetSingleMemory().Span); Span<byte> span = MemoryMarshal.AsBytes(buffer.DangerousGetSingleMemory().Span);
fixed (byte* ptr = &MemoryMarshal.GetReference(span)) fixed (byte* ptr = span)
{ {
byte* basePtr = ptr; byte* basePtr = ptr;
for (int y = 0; y < buffer.Height; y++) for (int y = 0; y < buffer.Height; y++)

Loading…
Cancel
Save