Browse Source

Use nint for offset

pull/2028/head
Brian Popow 4 years ago
parent
commit
8432b9fa4d
  1. 4
      src/ImageSharp/Formats/Png/Filters/SubFilter.cs
  2. 8
      src/ImageSharp/Formats/Png/Filters/UpFilter.cs

4
src/ImageSharp/Formats/Png/Filters/SubFilter.cs

@ -49,7 +49,7 @@ namespace SixLabors.ImageSharp.Formats.Png.Filters
Vector128<byte> d = Vector128<byte>.Zero; Vector128<byte> d = Vector128<byte>.Zero;
int rb = scanline.Length; int rb = scanline.Length;
int offset = 1; nint offset = 1;
while (rb >= 4) while (rb >= 4)
{ {
ref byte scanRef = ref Unsafe.Add(ref scanBaseRef, offset); ref byte scanRef = ref Unsafe.Add(ref scanBaseRef, offset);
@ -71,7 +71,7 @@ namespace SixLabors.ImageSharp.Formats.Png.Filters
ref byte scanBaseRef = ref MemoryMarshal.GetReference(scanline); ref byte scanBaseRef = ref MemoryMarshal.GetReference(scanline);
// Sub(x) + Raw(x-bpp) // Sub(x) + Raw(x-bpp)
int x = bytesPerPixel + 1; nint x = bytesPerPixel + 1;
Unsafe.Add(ref scanBaseRef, x); Unsafe.Add(ref scanBaseRef, x);
for (; x < scanline.Length; ++x) for (; x < scanline.Length; ++x)
{ {

8
src/ImageSharp/Formats/Png/Filters/UpFilter.cs

@ -54,7 +54,7 @@ namespace SixLabors.ImageSharp.Formats.Png.Filters
// Up(x) + Prior(x) // Up(x) + Prior(x)
int rb = scanline.Length; int rb = scanline.Length;
int offset = 1; nint offset = 1;
const int bytesPerBatch = 32; const int bytesPerBatch = 32;
while (rb >= bytesPerBatch) while (rb >= bytesPerBatch)
{ {
@ -70,7 +70,7 @@ namespace SixLabors.ImageSharp.Formats.Png.Filters
} }
// Handle left over. // Handle left over.
for (int i = offset; i < scanline.Length; i++) for (nint i = offset; i < scanline.Length; i++)
{ {
ref byte scan = ref Unsafe.Add(ref scanBaseRef, offset); ref byte scan = ref Unsafe.Add(ref scanBaseRef, offset);
byte above = Unsafe.Add(ref prevBaseRef, offset); byte above = Unsafe.Add(ref prevBaseRef, offset);
@ -86,7 +86,7 @@ namespace SixLabors.ImageSharp.Formats.Png.Filters
// Up(x) + Prior(x) // Up(x) + Prior(x)
int rb = scanline.Length; int rb = scanline.Length;
int offset = 1; nint offset = 1;
const int bytesPerBatch = 16; const int bytesPerBatch = 16;
while (rb >= bytesPerBatch) while (rb >= bytesPerBatch)
{ {
@ -102,7 +102,7 @@ namespace SixLabors.ImageSharp.Formats.Png.Filters
} }
// Handle left over. // Handle left over.
for (int i = offset; i < scanline.Length; i++) for (nint i = offset; i < scanline.Length; i++)
{ {
ref byte scan = ref Unsafe.Add(ref scanBaseRef, offset); ref byte scan = ref Unsafe.Add(ref scanBaseRef, offset);
byte above = Unsafe.Add(ref prevBaseRef, offset); byte above = Unsafe.Add(ref prevBaseRef, offset);

Loading…
Cancel
Save