libdragon
Loading...
Searching...
No Matches
Data Structures | Macros | Functions
lz4_dec.c File Reference

Data Structures

struct  lz4dec_faststate_t
 Fast-access state of the LZ4 algorithm (streaming version). More...
 
struct  lz4dec_state_t
 State of the LZ4 algorithm (streaming version). More...
 

Macros

#define MIN_MATCH_SIZE   4
 Minimum match size for LZ4.
 
#define LITERALS_RUN_LEN   15
 Maximum run length for literals in LZ4.
 
#define MATCH_RUN_LEN   15
 Maximum run length for matches in LZ4.
 
#define LZ4ULTRA_DECOMPRESSOR_BUILD_LEN(__len)
 Decode multi-byte length.
 

Functions

int decompress_lz4_full_inplace (const unsigned char *pInBlock, size_t nBlockSize, unsigned char *pOutData, size_t nBlockMaxSize)
 
void decompress_lz4_init (void *state, int fd, int winsize)
 Initialize the LZ4 decompressor state.
 
void decompress_lz4_reset (void *state)
 Reset the LZ4 decompressor state.
 
ssize_t decompress_lz4_read (void *state, void *buf, size_t len)
 Read decompressed data from the LZ4 stream.
 

Detailed Description

Author
Giovanni Bajo giova.nosp@m.nnib.nosp@m.ajo@g.nosp@m.mail.nosp@m..com

Data Structure Documentation

◆ lz4dec_faststate_t

struct lz4dec_faststate_t

Fast-access state of the LZ4 algorithm (streaming version).

See the LZ4 block format for a better understanding of the fields.

Data Fields
uint8_t token Current token.
int lit_len Number of literals to copy.
int match_len Number of bytes to copy from the ring buffer.
int match_off Offset in the ring buffer to copy from.
int fsm_state Current state of the streaming state machine.

◆ lz4dec_state_t

struct lz4dec_state_t

State of the LZ4 algorithm (streaming version).

Data Fields
uint8_t buf[128] File buffer.
int fd File descriptor to read from.
int buf_idx Current index in the file buffer.
int buf_size Size of the file buffer.
bool eof True if we reached the end of the file.
lz4dec_faststate_t st Fast-access state.
decompress_ringbuf_t ringbuf Ring buffer.

Macro Definition Documentation

◆ LZ4ULTRA_DECOMPRESSOR_BUILD_LEN

#define LZ4ULTRA_DECOMPRESSOR_BUILD_LEN (   __len)
Value:
{ \
unsigned int byte; \
do { \
if (unlikely(pInBlock >= pInBlockEnd)) return -1; \
if (dma_race) wait_dma(pInBlock+1); \
byte = (unsigned int)*pInBlock++; \
__len += byte; \
} while (unlikely(byte == 255)); \
}

Decode multi-byte length.

Function Documentation

◆ decompress_lz4_full_inplace()

int decompress_lz4_full_inplace ( const unsigned char *  pInBlock,
size_t  nBlockSize,
unsigned char *  pOutData,
size_t  nBlockMaxSize 
)

Decompress one data block

Parameters
pInBlockpointer to compressed data
nBlockSizesize of compressed data, in bytes
pOutDatapointer to output decompression buffer (previously decompressed bytes + room for decompressing this block)
nBlockMaxSizetotal size of output decompression buffer, in bytes
Returns
size of decompressed data in bytes, or -1 for error

◆ decompress_lz4_init()

void decompress_lz4_init ( void *  state,
int  fd,
int  winsize 
)

Initialize the LZ4 decompressor state.

Parameters
statePointer to the decompressor state buffer.
fdFile descriptor to read compressed data from.
winsizeWindow size for the decompressor.

◆ decompress_lz4_reset()

void decompress_lz4_reset ( void *  state)

Reset the LZ4 decompressor state.

Parameters
statePointer to the decompressor state buffer.

◆ decompress_lz4_read()

ssize_t decompress_lz4_read ( void *  state,
void *  buf,
size_t  len 
)

Read decompressed data from the LZ4 stream.

Parameters
statePointer to the decompressor state buffer.
bufBuffer to store decompressed data.
lenNumber of bytes to read.
Returns
Number of bytes read, or -1 on error.