From 7382151db8e72d31cfb6c0626d148353b8db538f Mon Sep 17 00:00:00 2001 From: Simon Kammermeier Date: Mon, 29 Aug 2022 16:30:22 +0200 Subject: [PATCH] Convert transforms list and colorCache to local variables This is needed because on recursion new (empty) ones are necessary. --- .../imageio/plugins/webp/lossless/VP8LDecoder.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/imageio/imageio-webp/src/main/java/com/twelvemonkeys/imageio/plugins/webp/lossless/VP8LDecoder.java b/imageio/imageio-webp/src/main/java/com/twelvemonkeys/imageio/plugins/webp/lossless/VP8LDecoder.java index 860f2b9e..ade640b3 100644 --- a/imageio/imageio-webp/src/main/java/com/twelvemonkeys/imageio/plugins/webp/lossless/VP8LDecoder.java +++ b/imageio/imageio-webp/src/main/java/com/twelvemonkeys/imageio/plugins/webp/lossless/VP8LDecoder.java @@ -52,9 +52,6 @@ public final class VP8LDecoder { private final ImageInputStream imageInput; private final LSBBitReader lsbBitReader; - private final List transforms = new ArrayList<>(); - private ColorCache colorCache; - public VP8LDecoder(final ImageInputStream imageInput, final boolean debug) { this.imageInput = imageInput; lsbBitReader = new LSBBitReader(imageInput); @@ -67,8 +64,9 @@ public final class VP8LDecoder { int ySize = raster.getHeight(); // Read transforms + ArrayList transforms = new ArrayList<>(); while (topLevel && lsbBitReader.readBit() == 1) { - xSize = readTransform(xSize, ySize); + xSize = readTransform(xSize, ySize, transforms); } // Read color cache size @@ -83,6 +81,8 @@ public final class VP8LDecoder { // Read Huffman codes readHuffmanCodes(colorCacheBits, topLevel); + ColorCache colorCache = null; + if (colorCacheBits > 0) { colorCache = new ColorCache(colorCacheBits); } @@ -91,7 +91,7 @@ public final class VP8LDecoder { // decodeImageData(raster, ) } - private int readTransform(int xSize, int ySize) throws IOException { + private int readTransform(int xSize, int ySize, List transforms) throws IOException { int transformType = (int) lsbBitReader.readBits(2); // TODO: Each transform type can only be present once in the stream.