libdragon
Loading...
Searching...
No Matches
ringbuf_internal.h
Go to the documentation of this file.
1
5#ifndef LIBDRAGON_COMPRESS_RINGBUF_INTERNAL_H
6#define LIBDRAGON_COMPRESS_RINGBUF_INTERNAL_H
7
8#include <stdint.h>
9
13typedef struct {
14 uint8_t* ringbuf;
15 unsigned int ringbuf_size;
16 unsigned int ringbuf_pos;
18
19
27void __ringbuf_init(decompress_ringbuf_t *ringbuf, uint8_t *buf, int winsize);
28
35static inline void __ringbuf_writebyte(decompress_ringbuf_t *ringbuf, uint8_t byte)
36{
37 ringbuf->ringbuf[ringbuf->ringbuf_pos++] = byte;
38 ringbuf->ringbuf_pos &= ringbuf->ringbuf_size-1;
39}
40
48void __ringbuf_write(decompress_ringbuf_t *ringbuf, uint8_t *src, int count);
49
67void __ringbuf_copy(decompress_ringbuf_t *ringbuf, int copy_offset, uint8_t *dst, int count);
68
69#endif
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.
Definition ringbuf.c:30
unsigned int ringbuf_size
Size of the ring buffer (power of two)
Definition ringbuf_internal.h:15
uint8_t * ringbuf
The ring buffer itself.
Definition ringbuf_internal.h:14
void __ringbuf_init(decompress_ringbuf_t *ringbuf, uint8_t *buf, int winsize)
Initialize a ring buffer for streaming decompression.
Definition ringbuf.c:9
unsigned int ringbuf_pos
Current write position in the ring buffer.
Definition ringbuf_internal.h:16
void __ringbuf_write(decompress_ringbuf_t *ringbuf, uint8_t *src, int count)
Write an array of bytes into the ring buffer.
Definition ringbuf.c:18
A ring buffer used for streaming decompression.
Definition ringbuf_internal.h:13