From 2ca81aec3c83b36060bdd021a5f52688778fab6e Mon Sep 17 00:00:00 2001 From: Brian Popow Date: Wed, 24 Nov 2021 14:07:57 +0100 Subject: [PATCH] Fill buffers with default values only in Debug mode --- src/ImageSharp/Formats/Webp/Lossy/Vp8Decoder.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/ImageSharp/Formats/Webp/Lossy/Vp8Decoder.cs b/src/ImageSharp/Formats/Webp/Lossy/Vp8Decoder.cs index d62d23e17..14bc19e8a 100644 --- a/src/ImageSharp/Formats/Webp/Lossy/Vp8Decoder.cs +++ b/src/ImageSharp/Formats/Webp/Lossy/Vp8Decoder.cs @@ -76,10 +76,14 @@ namespace SixLabors.ImageSharp.Formats.Webp.Lossy this.TmpVBuffer = memoryAllocator.Allocate((int)width); this.Pixels = memoryAllocator.Allocate((int)(width * height * 4)); +#if DEBUG + // Filling those buffers with 205, is only useful for debugging, + // so the default values are the same as the reference libwebp implementation. this.YuvBuffer.Memory.Span.Fill(205); this.CacheY.Memory.Span.Fill(205); this.CacheU.Memory.Span.Fill(205); this.CacheV.Memory.Span.Fill(205); +#endif this.Vp8BitReaders = new Vp8BitReader[WebpConstants.MaxNumPartitions]; }