Add bitstream utility

This commit is contained in:
atxr 2024-02-19 14:54:37 +01:00
parent 2d34e143d7
commit fa7045bf1c
3 changed files with 124 additions and 0 deletions

View file

@ -0,0 +1,20 @@
#ifndef LIBMINEZIPER_BITSTREAM_H
#define LIBMINEZIPER_BITSTREAM_H
typedef struct bitstream
{
char *data;
int data_size; // size of 'data' array
int last_bit_offset; // last bit in the stream
int current_data_offset; // position in 'data', i.e.
// data[current_data_offset] is current
// reading/writing byte
int current_bit_offset; // which bit we are currently reading/writing
} bitstream;
char get_bits(bitstream *bs, unsigned int size);
void print_bits(int x, int size);
unsigned int reverse(unsigned int x, unsigned int numBits);
#endif