瀏覽代碼

LibGfx/JBIG2: Call decode_immediate_text_region for lossless text region

It seems to do the right thing already, and nothing in the spec says
not to do this as far as I can tell.

With this, we can finally decode the test input from #23659.

See f391c7822dee7 for a similar change for generic regions and
lossless generic regions.
Nico Weber 1 年之前
父節點
當前提交
ced21d8419
共有 1 個文件被更改,包括 6 次插入8 次删除
  1. 6 8
      Userland/Libraries/LibGfx/ImageFormats/JBIG2Loader.cpp

+ 6 - 8
Userland/Libraries/LibGfx/ImageFormats/JBIG2Loader.cpp

@@ -1665,11 +1665,6 @@ static ErrorOr<void> decode_immediate_text_region(JBIG2LoadingContext& context,
     return {};
 }
 
-static ErrorOr<void> decode_immediate_lossless_text_region(JBIG2LoadingContext&, SegmentData const&)
-{
-    return Error::from_string_literal("JBIG2ImageDecoderPlugin: Cannot decode immediate lossless text region yet");
-}
-
 static ErrorOr<void> decode_pattern_dictionary(JBIG2LoadingContext&, SegmentData const&)
 {
     return Error::from_string_literal("JBIG2ImageDecoderPlugin: Cannot decode pattern dictionary yet");
@@ -1943,10 +1938,13 @@ static ErrorOr<void> decode_data(JBIG2LoadingContext& context)
             TRY(decode_intermediate_text_region(context, segment));
             break;
         case SegmentType::ImmediateTextRegion:
-            TRY(decode_immediate_text_region(context, segment));
-            break;
         case SegmentType::ImmediateLosslessTextRegion:
-            TRY(decode_immediate_lossless_text_region(context, segment));
+            // 7.4.3 Text region segment syntax
+            // "The data parts of all three of the text region segment types ("intermediate text region", "immediate text region" and
+            //  "immediate lossless text region") are coded identically, but are acted upon differently, see 8.2."
+            // But 8.2 only describes a difference between intermediate and immediate regions as far as I can tell,
+            // and calling the immediate text region handler for immediate lossless text regions seems to do the right thing (?).
+            TRY(decode_immediate_text_region(context, segment));
             break;
         case SegmentType::PatternDictionary:
             TRY(decode_pattern_dictionary(context, segment));