summaryrefslogtreecommitdiff
path: root/Userland/Libraries
diff options
context:
space:
mode:
authorNico Weber <thakis@chromium.org>2023-04-03 19:31:41 -0400
committerLinus Groh <mail@linusgroh.de>2023-04-06 00:16:52 +0100
commite8f5e699fe0a9eb08a4bf3ced9cf153cc928e8ff (patch)
treeeb0bacdf85a392a59bca3a84fd14a837d2f4a58b /Userland/Libraries
parent8e6911c8f64bcbdb6fc7036a281236b1d626c131 (diff)
downloadserenity-e8f5e699fe0a9eb08a4bf3ced9cf153cc928e8ff.zip
LibGfx: Read transform type in webp lossless decoder
Doesn't do anything with it yet, so this only makes the "not yet implemented" message a bit more detailed.
Diffstat (limited to 'Userland/Libraries')
-rw-r--r--Userland/Libraries/LibGfx/ImageFormats/WebPLoader.cpp34
1 files changed, 32 insertions, 2 deletions
diff --git a/Userland/Libraries/LibGfx/ImageFormats/WebPLoader.cpp b/Userland/Libraries/LibGfx/ImageFormats/WebPLoader.cpp
index 9193e852c1..bd8fb9864a 100644
--- a/Userland/Libraries/LibGfx/ImageFormats/WebPLoader.cpp
+++ b/Userland/Libraries/LibGfx/ImageFormats/WebPLoader.cpp
@@ -463,8 +463,38 @@ static ErrorOr<void> decode_webp_chunk_VP8L(WebPLoadingContext& context, Chunk c
// https://developers.google.com/speed/webp/docs/webp_lossless_bitstream_specification#72_structure_of_transforms
// optional-transform = (%b1 transform optional-transform) / %b0
- if (TRY(bit_stream.read_bits(1)))
- return context.error("WebPImageDecoderPlugin: VP8L transform handling not yet implemented");
+ while (TRY(bit_stream.read_bits(1))) {
+ // transform = predictor-tx / color-tx / subtract-green-tx
+ // transform =/ color-indexing-tx
+
+ enum TransformType {
+ // predictor-tx = %b00 predictor-image
+ PREDICTOR_TRANSFORM = 0,
+
+ // color-tx = %b01 color-image
+ COLOR_TRANSFORM = 1,
+
+ // subtract-green-tx = %b10
+ SUBTRACT_GREEN_TRANSFORM = 2,
+
+ // color-indexing-tx = %b11 color-indexing-image
+ COLOR_INDEXING_TRANSFORM = 3,
+ };
+
+ TransformType transform_type = static_cast<TransformType>(TRY(bit_stream.read_bits(2)));
+ dbgln_if(WEBP_DEBUG, "transform type {}", (int)transform_type);
+
+ switch (transform_type) {
+ case PREDICTOR_TRANSFORM:
+ return context.error("WebPImageDecoderPlugin: VP8L PREDICTOR_TRANSFORM handling not yet implemented");
+ case COLOR_TRANSFORM:
+ return context.error("WebPImageDecoderPlugin: VP8L COLOR_TRANSFORM handling not yet implemented");
+ case SUBTRACT_GREEN_TRANSFORM:
+ return context.error("WebPImageDecoderPlugin: VP8L SUBTRACT_GREEN_TRANSFORM handling not yet implemented");
+ case COLOR_INDEXING_TRANSFORM:
+ return context.error("WebPImageDecoderPlugin: VP8L COLOR_INDEXING_TRANSFORM handling not yet implemented");
+ }
+ }
// https://developers.google.com/speed/webp/docs/webp_lossless_bitstream_specification#623_decoding_entropy-coded_image_data
// https://developers.google.com/speed/webp/docs/webp_lossless_bitstream_specification#523_color_cache_coding