1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 05:47:35 +00:00

LibCompress/LZW: Use a LittleEndianBitStream

No need to manually implement bit stream logic when we have a helper for
this task.
This commit is contained in:
Lucas CHOLLET 2023-11-04 17:53:54 -04:00 committed by Tim Schumacher
parent b00476abac
commit 5e2b049de8
2 changed files with 12 additions and 35 deletions

View file

@ -6,6 +6,7 @@
*/
#include <AK/Array.h>
#include <AK/BitStream.h>
#include <AK/Debug.h>
#include <AK/Endian.h>
#include <AK/Error.h>
@ -183,7 +184,10 @@ static ErrorOr<void> decode_frame(GIFLoadingContext& context, size_t frame_index
if (image->lzw_min_code_size > 8)
return Error::from_string_literal("LZW minimum code size is greater than 8");
Compress::LZWDecoder decoder(image->lzw_encoded_bytes, image->lzw_min_code_size);
FixedMemoryStream stream { image->lzw_encoded_bytes, FixedMemoryStream::Mode::ReadOnly };
auto bit_stream = make<LittleEndianInputBitStream>(MaybeOwned<Stream>(stream));
Compress::LZWDecoder decoder(MaybeOwned<LittleEndianInputBitStream> { move(bit_stream) }, image->lzw_min_code_size);
// Add GIF-specific control codes
int const clear_code = decoder.add_control_code();