From e8f5e699fe0a9eb08a4bf3ced9cf153cc928e8ff Mon Sep 17 00:00:00 2001 From: Nico Weber Date: Mon, 3 Apr 2023 19:31:41 -0400 Subject: [PATCH] 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. --- .../LibGfx/ImageFormats/WebPLoader.cpp | 34 +++++++++++++++++-- 1 file 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 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(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