|
FreeNOS
|
Decompress data using the LZ4 algorithm created by Yann Collet. More...
#include <Lz4Decompressor.h>
Public Types | |
| enum | Result { Success, IOError, InvalidArgument, NotSupported } |
| Result codes. More... | |
Public Member Functions | |
| Lz4Decompressor (const void *data, const Size size) | |
| Constructor function. More... | |
| Result | initialize () |
| Initialize the decompressor. More... | |
| u64 | getUncompressedSize () const |
| Get size of the uncompressed data. More... | |
| Result | read (void *buffer, const Size size) const |
| Reads compressed data. More... | |
Private Types | |
| enum | FrameFlgFields { FrameDictIdShift = 0, FrameContentChkShift = 2, FrameContentSzShift = 3, FrameBlockChkShift = 4, FrameBlockIndShift = 5, FrameVersionShift = 6 } |
| Frame FLG Field Shift values. More... | |
Private Member Functions | |
| const u32 | decompress (const u8 *input, const Size inputSize, u8 *output, const Size outputSize) const |
| Decompress a block of compressed data. More... | |
| const u32 | integerDecode (const u32 initial, const u8 *next, Size &byteCount) const |
| Decode input data as integer (little-endian, 32-bit unsigned) More... | |
Private Attributes | |
| const u8 * | m_inputData |
| Compressed input data. More... | |
| const Size | m_inputSize |
| Total size in bytes of the compressed input data. More... | |
| Size | m_frameDescSize |
| Size of the frame descriptor in bytes. More... | |
| bool | m_blockChecksums |
| True if blocks have checksums enabled. More... | |
| bool | m_contentChecksum |
| True if the input data buffer contains content checksum. More... | |
| u64 | m_contentSize |
| Content size as specified in the frame header. More... | |
| Size | m_blockMaximumSize |
| Maximum block size in bytes of the uncompressed content. More... | |
Static Private Attributes | |
| static const u32 | FrameMagic = 0x184D2204 |
| Magic number value marks the start of the frame header. More... | |
| static const u8 | FrameVersion = 0x01 |
| Current supported version of the LZ4 algorithm. More... | |
| static const u32 | EndMark = 0x00000000 |
| EndMark marks the end of the data stream. More... | |
Decompress data using the LZ4 algorithm created by Yann Collet.
Definition at line 39 of file Lz4Decompressor.h.
|
private |
Frame FLG Field Shift values.
| Enumerator | |
|---|---|
| FrameDictIdShift | |
| FrameContentChkShift | |
| FrameContentSzShift | |
| FrameBlockChkShift | |
| FrameBlockIndShift | |
| FrameVersionShift | |
Definition at line 49 of file Lz4Decompressor.h.
Result codes.
| Enumerator | |
|---|---|
| Success | |
| IOError | |
| InvalidArgument | |
| NotSupported | |
Definition at line 70 of file Lz4Decompressor.h.
| Lz4Decompressor::Lz4Decompressor | ( | const void * | data, |
| const Size | size | ||
| ) |
Constructor function.
| data | Input data buffer |
| size | Size in bytes of the input buffer |
Definition at line 24 of file Lz4Decompressor.cpp.
|
private |
Decompress a block of compressed data.
| input | Compressed block data |
| inputSize | Number of compressed bytes |
| output | Output buffer to decompress to |
| outputSize | Maximum number of bytes to decompress |
Definition at line 204 of file Lz4Decompressor.cpp.
References assert, MemoryBlock::copy(), DEBUG, integerDecode(), m_blockMaximumSize, and readLe16().
Referenced by read().
| u64 Lz4Decompressor::getUncompressedSize | ( | ) | const |
Get size of the uncompressed data.
Definition at line 125 of file Lz4Decompressor.cpp.
References m_contentSize.
Referenced by Decompress::decompressFile(), forkexec(), MpiTarget::initializeMaster(), CoreServer::loadKernel(), RecoveryServer::reloadProgram(), and MpiProxy::startRemoteProcess().
| Lz4Decompressor::Result Lz4Decompressor::initialize | ( | ) |
Initialize the decompressor.
Definition at line 35 of file Lz4Decompressor.cpp.
References ERROR, FrameBlockChkShift, FrameBlockIndShift, FrameContentChkShift, FrameContentSzShift, FrameDictIdShift, FrameMagic, FrameVersion, FrameVersionShift, InvalidArgument, KiloByte, m_blockChecksums, m_blockMaximumSize, m_contentChecksum, m_contentSize, m_frameDescSize, m_inputData, m_inputSize, MegaByte, NotSupported, readLe32(), readLe64(), and Success.
Referenced by Decompress::decompressFile(), forkexec(), MpiTarget::initializeMaster(), CoreServer::loadKernel(), RecoveryServer::reloadProgram(), and MpiProxy::startRemoteProcess().
|
inlineprivate |
Decode input data as integer (little-endian, 32-bit unsigned)
| initial | The initial integer value to use |
| next | Pointer to next data to decode as integer |
| byteCount | On output contains the number of bytes decoded |
Definition at line 179 of file Lz4Decompressor.cpp.
Referenced by decompress().
| Lz4Decompressor::Result Lz4Decompressor::read | ( | void * | buffer, |
| const Size | size | ||
| ) | const |
Reads compressed data.
| buffer | Output buffer. |
| size | Number of bytes of uncompressed data to copy. |
Definition at line 130 of file Lz4Decompressor.cpp.
References assert, MemoryBlock::copy(), decompress(), EndMark, m_blockChecksums, m_blockMaximumSize, m_frameDescSize, m_inputData, m_inputSize, readLe32(), and Success.
Referenced by Decompress::decompressFile(), forkexec(), MpiTarget::initializeMaster(), CoreServer::loadKernel(), RecoveryServer::reloadProgram(), and MpiProxy::startRemoteProcess().
|
staticprivate |
EndMark marks the end of the data stream.
Definition at line 63 of file Lz4Decompressor.h.
Referenced by read().
|
staticprivate |
Magic number value marks the start of the frame header.
Definition at line 44 of file Lz4Decompressor.h.
Referenced by initialize().
|
staticprivate |
Current supported version of the LZ4 algorithm.
Definition at line 60 of file Lz4Decompressor.h.
Referenced by initialize().
|
private |
True if blocks have checksums enabled.
Definition at line 154 of file Lz4Decompressor.h.
Referenced by initialize(), and read().
|
private |
Maximum block size in bytes of the uncompressed content.
Definition at line 163 of file Lz4Decompressor.h.
Referenced by decompress(), initialize(), and read().
|
private |
True if the input data buffer contains content checksum.
Definition at line 157 of file Lz4Decompressor.h.
Referenced by initialize().
|
private |
Content size as specified in the frame header.
Definition at line 160 of file Lz4Decompressor.h.
Referenced by getUncompressedSize(), and initialize().
|
private |
Size of the frame descriptor in bytes.
Definition at line 151 of file Lz4Decompressor.h.
Referenced by initialize(), and read().
|
private |
Compressed input data.
Definition at line 145 of file Lz4Decompressor.h.
Referenced by initialize(), and read().
|
private |
Total size in bytes of the compressed input data.
Definition at line 148 of file Lz4Decompressor.h.
Referenced by initialize(), and read().
1.8.17