summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibGfx
diff options
context:
space:
mode:
authorNico Weber <thakis@chromium.org>2023-04-04 10:54:01 -0400
committerLinus Groh <mail@linusgroh.de>2023-04-07 09:47:04 +0200
commitb15d3b2329c199855f5297bf600ed38ab29456a3 (patch)
tree71fa8aa0a7a78a36354352727847a11cf48a24fc /Userland/Libraries/LibGfx
parent2fc682c03368d105539977231f84ea95970a1c60 (diff)
downloadserenity-b15d3b2329c199855f5297bf600ed38ab29456a3.zip
LibGfx: Add more dbgln_if()s to webp decoder
They were useful while debugging the decoder. Keep them in for a bit.
Diffstat (limited to 'Userland/Libraries/LibGfx')
-rw-r--r--Userland/Libraries/LibGfx/ImageFormats/WebPLoader.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/Userland/Libraries/LibGfx/ImageFormats/WebPLoader.cpp b/Userland/Libraries/LibGfx/ImageFormats/WebPLoader.cpp
index 6434aa1ed6..415bf43e1d 100644
--- a/Userland/Libraries/LibGfx/ImageFormats/WebPLoader.cpp
+++ b/Userland/Libraries/LibGfx/ImageFormats/WebPLoader.cpp
@@ -382,6 +382,7 @@ static ErrorOr<Compress::CanonicalCode> decode_webp_chunk_VP8L_prefix_code(WebPL
u8 last_non_zero = 8; // "If code 16 is used before a non-zero value has been emitted, a value of 8 is repeated."
// "A prefix table is then built from code_length_code_lengths and used to read up to max_symbol code lengths."
+ dbgln_if(WEBP_DEBUG, " reading {} symbols", max_symbol);
while (code_lengths.size() < max_symbol) {
auto symbol = TRY(code_length_code.read_symbol(bit_stream));
@@ -418,6 +419,7 @@ static ErrorOr<Compress::CanonicalCode> decode_webp_chunk_VP8L_prefix_code(WebPL
if (code_lengths.size() != alphabet_size)
return Error::from_string_literal("Number of code lengths does not match the sum of codes");
+ dbgln_if(WEBP_DEBUG, " done reading symbols");
return Compress::CanonicalCode::from_bytes(code_lengths);
}
@@ -595,11 +597,15 @@ static ErrorOr<NonnullRefPtr<Bitmap>> decode_webp_chunk_VP8L_image(WebPLoadingCo
distance = distance - 120;
}
- if (pixel - bitmap->begin() < distance)
+ if (pixel - bitmap->begin() < distance) {
+ dbgln_if(WEBP_DEBUG, "invalid backref, {} < {}", pixel - bitmap->begin(), distance);
return context.error("WebPImageDecoderPlugin: Backward reference distance out of bounds");
+ }
- if (bitmap->end() - pixel < length)
+ if (bitmap->end() - pixel < length) {
+ dbgln_if(WEBP_DEBUG, "invalid length, {} < {}", bitmap->end() - pixel, length);
return context.error("WebPImageDecoderPlugin: Backward reference length out of bounds");
+ }
ARGB32* src = pixel - distance;
for (u32 i = 0; i < length; ++i)