瀏覽代碼

LibCompress: Rename LZWDecoder => LzwDecompressor

This is more idiomatic for LibCompress' decoders.
Lucas CHOLLET 1 年之前
父節點
當前提交
70a3f1f02b

+ 11 - 11
Userland/Libraries/LibCompress/Lzw.h

@@ -18,12 +18,12 @@
 namespace Compress {
 namespace Compress {
 
 
 template<InputBitStream InputStream>
 template<InputBitStream InputStream>
-class LZWDecoder {
+class LzwDecompressor {
 private:
 private:
     static constexpr int max_code_size = 12;
     static constexpr int max_code_size = 12;
 
 
 public:
 public:
-    explicit LZWDecoder(MaybeOwned<InputStream> lzw_stream, u8 min_code_size, i32 offset_for_size_change = 0)
+    explicit LzwDecompressor(MaybeOwned<InputStream> lzw_stream, u8 min_code_size, i32 offset_for_size_change = 0)
         : m_bit_stream(move(lzw_stream))
         : m_bit_stream(move(lzw_stream))
         , m_code_size(min_code_size)
         , m_code_size(min_code_size)
         , m_original_code_size(min_code_size)
         , m_original_code_size(min_code_size)
@@ -34,32 +34,32 @@ public:
         init_code_table();
         init_code_table();
     }
     }
 
 
-    static ErrorOr<ByteBuffer> decode_all(ReadonlyBytes bytes, u8 initial_code_size, i32 offset_for_size_change = 0)
+    static ErrorOr<ByteBuffer> decompress_all(ReadonlyBytes bytes, u8 initial_code_size, i32 offset_for_size_change = 0)
     {
     {
         auto memory_stream = make<FixedMemoryStream>(bytes);
         auto memory_stream = make<FixedMemoryStream>(bytes);
         auto lzw_stream = make<InputStream>(MaybeOwned<Stream>(move(memory_stream)));
         auto lzw_stream = make<InputStream>(MaybeOwned<Stream>(move(memory_stream)));
-        Compress::LZWDecoder lzw_decoder { MaybeOwned<InputStream> { move(lzw_stream) }, initial_code_size, offset_for_size_change };
+        LzwDecompressor lzw_decompressor { MaybeOwned<InputStream> { move(lzw_stream) }, initial_code_size, offset_for_size_change };
 
 
-        ByteBuffer decoded;
+        ByteBuffer decompressed;
 
 
-        u16 const clear_code = lzw_decoder.add_control_code();
-        u16 const end_of_data_code = lzw_decoder.add_control_code();
+        u16 const clear_code = lzw_decompressor.add_control_code();
+        u16 const end_of_data_code = lzw_decompressor.add_control_code();
 
 
         while (true) {
         while (true) {
-            auto const code = TRY(lzw_decoder.next_code());
+            auto const code = TRY(lzw_decompressor.next_code());
 
 
             if (code == clear_code) {
             if (code == clear_code) {
-                lzw_decoder.reset();
+                lzw_decompressor.reset();
                 continue;
                 continue;
             }
             }
 
 
             if (code == end_of_data_code)
             if (code == end_of_data_code)
                 break;
                 break;
 
 
-            TRY(decoded.try_append(lzw_decoder.get_output()));
+            TRY(decompressed.try_append(lzw_decompressor.get_output()));
         }
         }
 
 
-        return decoded;
+        return decompressed;
     }
     }
 
 
     u16 add_control_code()
     u16 add_control_code()

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

@@ -184,7 +184,7 @@ static ErrorOr<void> decode_frame(GIFLoadingContext& context, size_t frame_index
         if (image->lzw_min_code_size > 8)
         if (image->lzw_min_code_size > 8)
             return Error::from_string_literal("LZW minimum code size is greater than 8");
             return Error::from_string_literal("LZW minimum code size is greater than 8");
 
 
-        auto decoded_stream = TRY(Compress::LZWDecoder<LittleEndianInputBitStream>::decode_all(image->lzw_encoded_bytes, image->lzw_min_code_size));
+        auto decoded_stream = TRY(Compress::LzwDecompressor<LittleEndianInputBitStream>::decompress_all(image->lzw_encoded_bytes, image->lzw_min_code_size));
 
 
         auto const& color_map = image->use_global_color_map ? context.logical_screen.color_map : image->color_map;
         auto const& color_map = image->use_global_color_map ? context.logical_screen.color_map : image->color_map;
 
 

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

@@ -490,9 +490,9 @@ private:
                 //       Fortunately, as the first byte of a LZW stream is a constant we can guess the endianess
                 //       Fortunately, as the first byte of a LZW stream is a constant we can guess the endianess
                 //       and deduce the version from it. The first code is 0x100 (9-bits).
                 //       and deduce the version from it. The first code is 0x100 (9-bits).
                 if (encoded_bytes[0] == 0x00)
                 if (encoded_bytes[0] == 0x00)
-                    decoded_bytes = TRY(Compress::LZWDecoder<LittleEndianInputBitStream>::decode_all(encoded_bytes, 8, 0));
+                    decoded_bytes = TRY(Compress::LzwDecompressor<LittleEndianInputBitStream>::decompress_all(encoded_bytes, 8, 0));
                 else
                 else
-                    decoded_bytes = TRY(Compress::LZWDecoder<BigEndianInputBitStream>::decode_all(encoded_bytes, 8, -1));
+                    decoded_bytes = TRY(Compress::LzwDecompressor<BigEndianInputBitStream>::decompress_all(encoded_bytes, 8, -1));
 
 
                 return decoded_bytes;
                 return decoded_bytes;
             };
             };

+ 1 - 1
Userland/Libraries/LibPDF/Filter.cpp

@@ -262,7 +262,7 @@ PDFErrorOr<ByteBuffer> Filter::decode_lzw(ReadonlyBytes bytes, RefPtr<DictObject
     if (decode_parms && decode_parms->contains(CommonNames::EarlyChange))
     if (decode_parms && decode_parms->contains(CommonNames::EarlyChange))
         early_change = decode_parms->get_value(CommonNames::EarlyChange).get<int>();
         early_change = decode_parms->get_value(CommonNames::EarlyChange).get<int>();
 
 
-    auto decoded = TRY(Compress::LZWDecoder<BigEndianInputBitStream>::decode_all(bytes, 8, -early_change));
+    auto decoded = TRY(Compress::LzwDecompressor<BigEndianInputBitStream>::decompress_all(bytes, 8, -early_change));
     return handle_lzw_and_flate_parameters(move(decoded), decode_parms);
     return handle_lzw_and_flate_parameters(move(decoded), decode_parms);
 }
 }