LZ4 Decompressor

Description

LZ4 decompressor.

Data Structures

struct Lz4Context_t
LZ4 decompressor context.

Macros

#define LZ4_STATE_TOKEN 00U
LZ4 state machine: Token byte.
#define LZ4_STATE_LITERAL_LENGTH 10U
LZ4 state machine: Literal length byte.
#define LZ4_STATE_LITERAL_VALUE 20U
LZ4 state machine: Literal value byte.
#define LZ4_STATE_OFFSET_LSB 30U
LZ4 state machine: LSB of match offset.
#define LZ4_STATE_OFFSET_MSB 35U
LZ4 state machine: MSB of match offset.
#define LZ4_STATE_MATCH_LENGTH 40U
LZ4 state machine: Match length.
#define LZ4_STATE_BACKTRACKING 50U
LZ4 state machine: Backtracking to get matched data.

Typedefs

typedef int32_t(* Lz4DataWrite_t ) (uint8_t *data, size_t length)
Function to output data from LZ4 decompressor.
typedef int32_t(* Lz4DataRead_t ) (size_t backtrackOffset, uint8_t *data, size_t length)
Function to read data into LZ4 decompressor.

Functions

int32_t lz4_init ( Lz4Context_t *ctx, Lz4DataRead_t readFunction)
int32_t lz4_decompress ( Lz4Context_t *ctx, void *inputData, size_t inputLength, Lz4DataWrite_t writeFunction)
int32_t lz4_finish ( Lz4Context_t *ctx)

Function Documentation

int32_t lz4_init ( Lz4Context_t * ctx,
Lz4DataRead_t readFunction
)

Initialize the LZ4 decompressor.

Parameters
ctx Decompressor context
readFunction Function pointer to read back previously written data
Returns
Error code
int32_t lz4_decompress ( Lz4Context_t * ctx,
void * inputData,
size_t inputLength,
Lz4DataWrite_t writeFunction
)

Decompress a chunk of data.

Parameters
ctx Decompressor context
inputData Compressed input data
inputLength Length of inputData in bytes
writeFunction Function pointer that is called with decompressed data
Returns
Error code
int32_t lz4_finish ( Lz4Context_t * ctx )

Finish decompressing data.

Parameters
ctx Decompressor context
Returns
Error code indicating success or failure
Return values
BOOTLOADER_OK on success
BOOTLOADER_ERROR_COMPRESSION_STATE if the last block wasn't completed