浏览代码

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.
Nico Weber 2 年之前
父节点
当前提交
e8f5e699fe
共有 1 个文件被更改,包括 32 次插入2 次删除
  1. 32 2
      Userland/Libraries/LibGfx/ImageFormats/WebPLoader.cpp

+ 32 - 2
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
     // https://developers.google.com/speed/webp/docs/webp_lossless_bitstream_specification#72_structure_of_transforms
 
 
     // optional-transform   =  (%b1 transform optional-transform) / %b0
     // 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#623_decoding_entropy-coded_image_data
     // https://developers.google.com/speed/webp/docs/webp_lossless_bitstream_specification#523_color_cache_coding
     // https://developers.google.com/speed/webp/docs/webp_lossless_bitstream_specification#523_color_cache_coding