mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 05:27:46 +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:
parent
5d0fb4bac3
commit
d748edd994
5 changed files with 99 additions and 0 deletions
27
Userland/Libraries/LibCompress/PackBitsDecoder.h
Normal file
27
Userland/Libraries/LibCompress/PackBitsDecoder.h
Normal file
|
@ -0,0 +1,27 @@
|
|||
/*
|
||||
* Copyright (c) 2023, Lucas Chollet <lucas.chollet@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AK/ByteBuffer.h>
|
||||
#include <AK/Optional.h>
|
||||
|
||||
namespace Compress::PackBits {
|
||||
|
||||
// This implements the PackBits compression scheme, aka run-length compression
|
||||
// It is fairly simple and described here: https://web.archive.org/web/20080705155158/http://developer.apple.com/technotes/tn/tn1023.html
|
||||
// But also in section:
|
||||
// - 7.4.5 RunLengthDecode Filter of the PDF specification
|
||||
// - Section 9: PackBits Compression of the TIFF specification
|
||||
|
||||
enum class CompatibilityMode {
|
||||
Original, // 128 is defined as no-op
|
||||
PDF, // 128 is defined as end of stream
|
||||
};
|
||||
|
||||
ErrorOr<ByteBuffer> decode_all(ReadonlyBytes bytes, Optional<u64> expected_output_size = {}, CompatibilityMode mode = CompatibilityMode::Original);
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue