diff --git a/src/ImageSharp/Formats/Png/Zlib/Adler32.cs b/src/ImageSharp/Formats/Png/Zlib/Adler32.cs index b8cbc8f92..bd354a508 100644 --- a/src/ImageSharp/Formats/Png/Zlib/Adler32.cs +++ b/src/ImageSharp/Formats/Png/Zlib/Adler32.cs @@ -17,6 +17,11 @@ namespace SixLabors.ImageSharp.Formats.Png.Zlib /// internal static class Adler32 { + /// + /// The default initial seed value of a Adler32 checksum calculation. + /// + public const uint SeedValue = 1U; + #if SUPPORTS_RUNTIME_INTRINSICS private const int MinBufferSize = 64; #endif @@ -34,7 +39,7 @@ namespace SixLabors.ImageSharp.Formats.Png.Zlib /// The . [MethodImpl(InliningOptions.ShortMethod)] public static uint Calculate(ReadOnlySpan buffer) - => Calculate(1U, buffer); + => Calculate(SeedValue, buffer); /// /// Calculates the Adler32 checksum with the bytes taken from the span and seed. @@ -47,7 +52,7 @@ namespace SixLabors.ImageSharp.Formats.Png.Zlib { if (buffer.IsEmpty) { - return 1U; + return SeedValue; } #if SUPPORTS_RUNTIME_INTRINSICS diff --git a/src/ImageSharp/Formats/Png/Zlib/Crc32.cs b/src/ImageSharp/Formats/Png/Zlib/Crc32.cs index 633b3b86d..ad047a41d 100644 --- a/src/ImageSharp/Formats/Png/Zlib/Crc32.cs +++ b/src/ImageSharp/Formats/Png/Zlib/Crc32.cs @@ -17,6 +17,11 @@ namespace SixLabors.ImageSharp.Formats.Png.Zlib /// internal static partial class Crc32 { + /// + /// The default initial seed value of a Crc32 checksum calculation. + /// + public const uint SeedValue = 0U; + #if SUPPORTS_RUNTIME_INTRINSICS private const int MinBufferSize = 64; private const int ChunksizeMask = 15; @@ -36,7 +41,7 @@ namespace SixLabors.ImageSharp.Formats.Png.Zlib /// The . [MethodImpl(InliningOptions.ShortMethod)] public static uint Calculate(ReadOnlySpan buffer) - => Calculate(0U, buffer); + => Calculate(SeedValue, buffer); /// /// Calculates the CRC checksum with the bytes taken from the span and seed. @@ -49,7 +54,7 @@ namespace SixLabors.ImageSharp.Formats.Png.Zlib { if (buffer.IsEmpty) { - return 0U; + return SeedValue; } #if SUPPORTS_RUNTIME_INTRINSICS diff --git a/src/ImageSharp/Formats/Png/Zlib/ZlibDeflateStream.cs b/src/ImageSharp/Formats/Png/Zlib/ZlibDeflateStream.cs index 02f5c54e7..3257fa884 100644 --- a/src/ImageSharp/Formats/Png/Zlib/ZlibDeflateStream.cs +++ b/src/ImageSharp/Formats/Png/Zlib/ZlibDeflateStream.cs @@ -21,7 +21,7 @@ namespace SixLabors.ImageSharp.Formats.Png.Zlib /// /// Computes the checksum for the data stream. /// - private uint adler = 1U; + private uint adler = Adler32.SeedValue; /// /// A value indicating whether this instance of the given entity has been disposed.