Browse Source

LibGfx/TIFF+CCITT: Clarify naming of compression type 2

Type 2 <=> One-dimensional Group3, customized for TIFF
Type 3 <=> Two-dimensional Group3, uses the original 1D internally
Type 4 <=> Two-dimensional Group4

So let's clarify that this is not Group3 1D but the TIFF variant, which
is called `CCITTRLE` in libtiff. So let's stick with this name to avoid
confusion.
Lucas CHOLLET 1 year ago
parent
commit
edffdc35a9

+ 2 - 2
Tests/LibGfx/TestImageDecoder.cpp

@@ -543,9 +543,9 @@ TEST_CASE(test_tiff_uncompressed)
     EXPECT_EQ(frame.image->get_pixel(60, 75), Gfx::Color::NamedColor::Red);
 }
 
-TEST_CASE(test_tiff_ccitt3_1d)
+TEST_CASE(test_tiff_ccitt_rle)
 {
-    auto file = TRY_OR_FAIL(Core::MappedFile::map(TEST_INPUT("tiff/ccitt3_1d.tiff"sv)));
+    auto file = TRY_OR_FAIL(Core::MappedFile::map(TEST_INPUT("tiff/ccitt_rle.tiff"sv)));
     EXPECT(Gfx::TIFFImageDecoderPlugin::sniff(file->bytes()));
     auto plugin_decoder = TRY_OR_FAIL(Gfx::TIFFImageDecoderPlugin::create(file->bytes()));
 

+ 0 - 0
Tests/LibGfx/test-inputs/tiff/ccitt3_1d.tiff → Tests/LibGfx/test-inputs/tiff/ccitt_rle.tiff


+ 1 - 1
Userland/Libraries/LibGfx/ImageFormats/CCITTDecoder.cpp

@@ -266,7 +266,7 @@ Optional<Code> get_terminal_code(Color color, u16 code_word, u8 code_size)
 
 }
 
-ErrorOr<ByteBuffer> decode_ccitt3_1d(ReadonlyBytes bytes, u32 image_width, u32 image_height)
+ErrorOr<ByteBuffer> decode_ccitt_rle(ReadonlyBytes bytes, u32 image_width, u32 image_height)
 {
     auto strip_stream = make<FixedMemoryStream>(bytes);
     auto bit_stream = make<BigEndianInputBitStream>(MaybeOwned<Stream>(*strip_stream));

+ 1 - 1
Userland/Libraries/LibGfx/ImageFormats/CCITTDecoder.h

@@ -21,6 +21,6 @@ namespace Gfx::CCITT {
 // However, this function implements the TIFF variant (see TIFFLoader.h for a spec link),
 // differences are detailed in section:
 // Section 10: Modified Huffman Compression
-ErrorOr<ByteBuffer> decode_ccitt3_1d(ReadonlyBytes bytes, u32 image_width, u32 image_height);
+ErrorOr<ByteBuffer> decode_ccitt_rle(ReadonlyBytes bytes, u32 image_width, u32 image_height);
 
 }

+ 4 - 4
Userland/Libraries/LibGfx/ImageFormats/TIFFLoader.cpp

@@ -281,17 +281,17 @@ private:
             TRY(loop_over_pixels(move(identity)));
             break;
         }
-        case Compression::CCITT: {
+        case Compression::CCITTRLE: {
             TRY(ensure_tags_are_correct_for_ccitt());
 
             ByteBuffer decoded_bytes {};
-            auto decode_ccitt_1D_strip = [&](u32 num_bytes) -> ErrorOr<ReadonlyBytes> {
+            auto decode_ccitt_rle_strip = [&](u32 num_bytes) -> ErrorOr<ReadonlyBytes> {
                 auto const encoded_bytes = TRY(m_stream->read_in_place<u8 const>(num_bytes));
-                decoded_bytes = TRY(CCITT::decode_ccitt3_1d(encoded_bytes, *m_metadata.image_width(), *m_metadata.rows_per_strip()));
+                decoded_bytes = TRY(CCITT::decode_ccitt_rle(encoded_bytes, *m_metadata.image_width(), *m_metadata.rows_per_strip()));
                 return decoded_bytes;
             };
 
-            TRY(loop_over_pixels(move(decode_ccitt_1D_strip)));
+            TRY(loop_over_pixels(move(decode_ccitt_rle_strip)));
             break;
         }
         case Compression::LZW: {

+ 1 - 1
Userland/Libraries/LibGfx/TIFFGenerator.py

@@ -51,7 +51,7 @@ class Predictor(EnumWithExportName):
 
 class Compression(EnumWithExportName):
     NoCompression = 1
-    CCITT = 2
+    CCITTRLE = 2
     Group3Fax = 3
     Group4Fax = 4
     LZW = 5