Go to the source code of this file.
|
#define | LZ4_DECOMPRESS_INPLACE_MARGIN(compressed_size) (((compressed_size) >> 8) + 32) |
| Calculate the margin required for in-place decompression.
|
|
#define | DECOMPRESS_LZ4_STATE_SIZE 176 |
| Size of the LZ4 decompressor state structure, in bytes.
|
|
|
int | decompress_lz4_full_inplace (const uint8_t *src, size_t src_size, uint8_t *dst, size_t dst_size) |
| Decompress a block of LZ4 data (mem to mem).
|
|
void | decompress_lz4_init (void *state, int fd, int winsize) |
| Initialize the LZ4 decompressor state.
|
|
ssize_t | decompress_lz4_read (void *state, void *buf, size_t len) |
| Read decompressed data from the LZ4 stream.
|
|
void | decompress_lz4_reset (void *state) |
| Reset the LZ4 decompressor state.
|
|
void * | decompress_lz4_full (const char *fn, FILE *fp, size_t cmp_size, size_t size) |
| Decompress a full LZ4 file from a FILE pointer.
|
|
◆ LZ4_DECOMPRESS_INPLACE_MARGIN
#define LZ4_DECOMPRESS_INPLACE_MARGIN |
( |
|
compressed_size | ) |
(((compressed_size) >> 8) + 32) |
Calculate the margin required for in-place decompression.
It is possible to perform in-place decompression of LZ4 data: to do so, allocate a buffer large enough to hold the decompressed data, plus some margin calculated through this function. Then, read the compressed data at the end of the buffer. Finally, call the decompression function (see below).
Example:
void *buf = malloc(buf_size);
fread(buf + buf_size - compressed_size, 1, compressed_size, fp);
decompress_lz4_full_mem(
buf + buf_size - compressed_size, compressed_size,
buf, decompressed_size,
false);
#define LZ4_DECOMPRESS_INPLACE_MARGIN(compressed_size)
Calculate the margin required for in-place decompression.
Definition lz4_dec_internal.h:38
◆ decompress_lz4_full_inplace()
int decompress_lz4_full_inplace |
( |
const uint8_t * |
src, |
|
|
size_t |
src_size, |
|
|
uint8_t * |
dst, |
|
|
size_t |
dst_size |
|
) |
| |
Decompress a block of LZ4 data (mem to mem).
This function run a LZ4 decompressor on a block of data, from memory to memory.
LZ4 is much faster than PI DMA. To benefit even more from this, it is possible to actually run this function in parallel with the DMA transfer, "racing" with it. If called with dma_race
set to true, the function will assume that the source buffer is currently being DMAed into memory, and will throttle itself to never read past the current DMA position.
In addition to this, it is possible to in-place decompress a block of data. See LZ4_DECOMPRESS_INPLACE_MARGIN for more information.
- Parameters
-
src | Pointer to source buffer (compressed data) |
src_size | Size of the compressed data in bytes |
dst | Pointer to destination buffer (decompressed data) |
dst_size | Size of the destination buffer in bytes |
- Returns
- int Number of bytes decompressed, or -1 on error.
◆ decompress_lz4_init()
void decompress_lz4_init |
( |
void * |
state, |
|
|
int |
fd, |
|
|
int |
winsize |
|
) |
| |
Initialize the LZ4 decompressor state.
- Parameters
-
state | Pointer to the decompressor state buffer. |
fd | File descriptor to read compressed data from. |
winsize | Window size for the decompressor. |
◆ decompress_lz4_read()
ssize_t decompress_lz4_read |
( |
void * |
state, |
|
|
void * |
buf, |
|
|
size_t |
len |
|
) |
| |
Read decompressed data from the LZ4 stream.
- Parameters
-
state | Pointer to the decompressor state buffer. |
buf | Buffer to store decompressed data. |
len | Number of bytes to read. |
- Returns
- Number of bytes read, or -1 on error.
◆ decompress_lz4_reset()
void decompress_lz4_reset |
( |
void * |
state | ) |
|
Reset the LZ4 decompressor state.
- Parameters
-
state | Pointer to the decompressor state buffer. |
◆ decompress_lz4_full()
void * decompress_lz4_full |
( |
const char * |
fn, |
|
|
FILE * |
fp, |
|
|
size_t |
cmp_size, |
|
|
size_t |
size |
|
) |
| |
Decompress a full LZ4 file from a FILE pointer.
- Parameters
-
fn | Filename (for error messages). |
fp | FILE pointer to read compressed data from. |
cmp_size | Size of the compressed data. |
size | Size of the decompressed data. |
- Returns
- Pointer to the decompressed data buffer, or NULL on error.