FreeNOS
Lz4Decompressor.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2020 Niek Linnenbank
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#ifndef __LIB_LIBEXEC_LZ4DECOMPRESSOR_H
19#define __LIB_LIBEXEC_LZ4DECOMPRESSOR_H
20
21#include <Types.h>
22#include <Index.h>
23
40{
41 private:
42
44 static const u32 FrameMagic = 0x184D2204;
45
58
60 static const u8 FrameVersion = 0x01;
61
63 static const u32 EndMark = 0x00000000;
64
65 public:
66
77
78 public:
79
86 Lz4Decompressor(const void *data, const Size size);
87
94
100 u64 getUncompressedSize() const;
101
110 Result read(void *buffer, const Size size) const;
111
112 private:
113
124 const u32 decompress(const u8 *input,
125 const Size inputSize,
126 u8 *output,
127 const Size outputSize) const;
128
138 inline const u32 integerDecode(const u32 initial,
139 const u8 *next,
140 Size &byteCount) const;
141
142 private:
143
146
149
152
155
158
161
164};
165
171#endif /* __LIB_LIBEXEC_LZ4DECOMPRESSOR_H */
Decompress data using the LZ4 algorithm created by Yann Collet.
Result initialize()
Initialize the decompressor.
u64 m_contentSize
Content size as specified in the frame header.
const Size m_inputSize
Total size in bytes of the compressed input data.
const u32 integerDecode(const u32 initial, const u8 *next, Size &byteCount) const
Decode input data as integer (little-endian, 32-bit unsigned)
Size m_blockMaximumSize
Maximum block size in bytes of the uncompressed content.
u64 getUncompressedSize() const
Get size of the uncompressed data.
const u8 * m_inputData
Compressed input data.
Size m_frameDescSize
Size of the frame descriptor in bytes.
bool m_blockChecksums
True if blocks have checksums enabled.
static const u32 EndMark
EndMark marks the end of the data stream.
bool m_contentChecksum
True if the input data buffer contains content checksum.
FrameFlgFields
Frame FLG Field Shift values.
const u32 decompress(const u8 *input, const Size inputSize, u8 *output, const Size outputSize) const
Decompress a block of compressed data.
Result
Result codes.
static const u32 FrameMagic
Magic number value marks the start of the frame header.
Result read(void *buffer, const Size size) const
Reads compressed data.
static const u8 FrameVersion
Current supported version of the LZ4 algorithm.
unsigned int u32
Unsigned 32-bit number.
Definition Types.h:53
unsigned int Size
Any sane size indicator cannot go negative.
Definition Types.h:128
unsigned long long u64
Unsigned 64-bit number.
Definition Types.h:50
unsigned char u8
Unsigned 8-bit number.
Definition Types.h:59