![]() |
libdragon
|
Functions | |
void | __ringbuf_init (decompress_ringbuf_t *ringbuf, uint8_t *buf, int size) |
Initialize a ring buffer for streaming decompression. | |
void | __ringbuf_write (decompress_ringbuf_t *ringbuf, uint8_t *src, int count) |
Write an array of bytes into the ring buffer. | |
void | __ringbuf_copy (decompress_ringbuf_t *ringbuf, int copy_offset, uint8_t *dst, int count) |
Extract data from the ring buffer, updating it at the same time. | |
void __ringbuf_init | ( | decompress_ringbuf_t * | ringbuf, |
uint8_t * | buf, | ||
int | winsize | ||
) |
Initialize a ring buffer for streaming decompression.
ringbuf | Pointer to the ring buffer structure to initialize. |
buf | Buffer to use as the ring buffer storage. |
winsize | Window size (must be a power of 2). |
void __ringbuf_write | ( | decompress_ringbuf_t * | ringbuf, |
uint8_t * | src, | ||
int | count | ||
) |
Write an array of bytes into the ring buffer.
ringbuf | The ring buffer to write to. |
src | The source array to write from. |
count | The number of bytes to write. |
void __ringbuf_copy | ( | decompress_ringbuf_t * | ringbuf, |
int | copy_offset, | ||
uint8_t * | dst, | ||
int | count | ||
) |
Extract data from the ring buffer, updating it at the same time.
This function is used to implement a typical match-copy of LZ algorithms. Given the ring buffer and the position to copy from, it will copy the specified number of bytes into the destination buffer, while also updating the ring buffer with the copied data.
It correctly handles overlaps, so if copy_offset is 1 and count is 100, the last character in the ring buffer will be copied 100 times to the output (and to the ring buffer itself).
ringbuf | The ring buffer |
copy_offset | Offset to copy from, relative to the current position. |
dst | Destination buffer |
count | Number of bytes to copy |