From b2ba930486832229336c631fb6711d4eac4ca883 Mon Sep 17 00:00:00 2001 From: Jason Nelson Date: Wed, 18 Apr 2018 16:10:50 -0700 Subject: [PATCH] Remove unused support for configuring the maximium number of bits in the LzwEncoder. --- src/ImageSharp/Formats/Gif/LzwEncoder.cs | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/src/ImageSharp/Formats/Gif/LzwEncoder.cs b/src/ImageSharp/Formats/Gif/LzwEncoder.cs index 9adf48843..6c3ede379 100644 --- a/src/ImageSharp/Formats/Gif/LzwEncoder.cs +++ b/src/ImageSharp/Formats/Gif/LzwEncoder.cs @@ -34,11 +34,6 @@ namespace SixLabors.ImageSharp.Formats.Gif /// internal sealed class LzwEncoder : IDisposable { - /// - /// The maximum number of bits. - /// - private const int Bits = 12; - /// /// 80% occupancy /// @@ -53,6 +48,11 @@ namespace SixLabors.ImageSharp.Formats.Gif 0x01FF, 0x03FF, 0x07FF, 0x0FFF, 0x1FFF, 0x3FFF, 0x7FFF, 0xFFFF }; + /// + /// The maximium number of bits/code. + /// + private const int MaxBits = 12; + /// /// The working pixel array. /// @@ -88,11 +88,6 @@ namespace SixLabors.ImageSharp.Formats.Gif /// private int bitCount; - /// - /// User settable max # bits/code - /// - private int maxBits = Bits; - /// /// maximum code, given bitCount /// @@ -101,7 +96,7 @@ namespace SixLabors.ImageSharp.Formats.Gif /// /// should NEVER generate this code /// - private int maxmaxcode = 1 << Bits; + private int maxmaxcode = 1 << MaxBits; /// /// For dynamic table sizing @@ -305,7 +300,7 @@ namespace SixLabors.ImageSharp.Formats.Gif { c = this.NextPixel(); - fcode = (c << this.maxBits) + ent; + fcode = (c << MaxBits) + ent; int i = (c << hshift) ^ ent /* = 0 */; if (Unsafe.Add(ref hashTableRef, i) == fcode) @@ -427,7 +422,7 @@ namespace SixLabors.ImageSharp.Formats.Gif else { ++this.bitCount; - this.maxCode = this.bitCount == this.maxBits + this.maxCode = this.bitCount == MaxBits ? this.maxmaxcode : GetMaxcode(this.bitCount); }