1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 01:17:34 +00:00

LibCompress: Add a PackBits decoder

This compression scheme was quite popular during the 80's, and we can
still find it in use inside file formats such as TIFF or PDF.
This commit is contained in:
Lucas CHOLLET 2023-12-21 00:16:04 -05:00 committed by Tim Schumacher
parent 5d0fb4bac3
commit d748edd994
5 changed files with 99 additions and 0 deletions

View file

@ -0,0 +1,25 @@
/*
* Copyright (c) 2023, Lucas Chollet <lucas.chollet@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibTest/TestCase.h>
#include <AK/Array.h>
#include <LibCompress/PackBitsDecoder.h>
TEST_CASE(pack_bits)
{
Array<u8, 15> const compressed {
0xFE, 0xAA, 0x02, 0x80, 0x00, 0x2A, 0xFD, 0xAA, 0x03, 0x80, 0x00, 0x2A, 0x22, 0xF7, 0xAA
};
Array<u8, 24> const raw {
0xAA, 0xAA, 0xAA, 0x80, 0x00, 0x2A, 0xAA, 0xAA, 0xAA, 0xAA, 0x80, 0x00,
0x2A, 0x22, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA
};
auto unpacked = TRY_OR_FAIL(Compress::PackBits::decode_all(compressed));
EXPECT_EQ(unpacked.bytes(), raw);
}