diff --git a/src/ImageSharp/Formats/Webp/Lossless/WebpLosslessDecoder.cs b/src/ImageSharp/Formats/Webp/Lossless/WebpLosslessDecoder.cs index 9604160091..768365e44e 100644 --- a/src/ImageSharp/Formats/Webp/Lossless/WebpLosslessDecoder.cs +++ b/src/ImageSharp/Formats/Webp/Lossless/WebpLosslessDecoder.cs @@ -218,7 +218,7 @@ public void DecodeImageData(Vp8LDecoder decoder, Span pixelData) ColorCache colorCache = decoder.Metadata.ColorCache; int colorCacheLimit = lenCodeLimit + colorCacheSize; int mask = decoder.Metadata.HuffmanMask; - HTreeGroup[] hTreeGroup = GetHTreeGroupForPos(decoder.Metadata, col, row); + Span hTreeGroup = GetHTreeGroupForPos(decoder.Metadata, col, row); int totalPixels = width * height; int decodedPixels = 0; @@ -731,7 +731,7 @@ public void DecodeAlphaData(AlphaDecoder dec) int lastRow = height; const int lenCodeLimit = WebpConstants.NumLiteralCodes + WebpConstants.NumLengthCodes; int mask = hdr.HuffmanMask; - HTreeGroup[] htreeGroup = pos < last ? GetHTreeGroupForPos(hdr, col, row) : null; + Span htreeGroup = pos < last ? GetHTreeGroupForPos(hdr, col, row) : null; while (!this.bitReader.Eos && pos < last) { // Only update when changing tile. @@ -815,7 +815,7 @@ private void UpdateDecoder(Vp8LDecoder decoder, int width, int height) decoder.Metadata.HuffmanMask = numBits == 0 ? ~0 : (1 << numBits) - 1; } - private uint ReadPackedSymbols(HTreeGroup[] group, Span pixelData, int decodedPixels) + private uint ReadPackedSymbols(Span group, Span pixelData, int decodedPixels) { uint val = (uint)(this.bitReader.PrefetchBits() & (HuffmanUtils.HuffmanPackedTableSize - 1)); HuffmanCode code = group[0].PackedTable[val]; @@ -895,10 +895,10 @@ private int GetCopyDistance(int distanceSymbol) } [MethodImpl(InliningOptions.ShortMethod)] - private static HTreeGroup[] GetHTreeGroupForPos(Vp8LMetadata metadata, int x, int y) + private static Span GetHTreeGroupForPos(Vp8LMetadata metadata, int x, int y) { uint metaIndex = GetMetaIndex(metadata.HuffmanImage, metadata.HuffmanXSize, metadata.HuffmanSubSampleBits, x, y); - return metadata.HTreeGroups.AsSpan((int)metaIndex).ToArray(); + return metadata.HTreeGroups.AsSpan((int)metaIndex); } [MethodImpl(InliningOptions.ShortMethod)]