Align to next byte

This commit is contained in:
atxr 2024-02-21 16:11:01 +01:00
parent b0f5cd41f9
commit 9f8bcf7769
2 changed files with 11 additions and 2 deletions

View file

@ -17,6 +17,7 @@ unsigned int get_bits(bitstream *bs, unsigned int size);
void print_bits(int x, int size);
unsigned int reverse(unsigned int x, unsigned int numBits);
bitstream init_bitstream(char *data, int size, int last_bit_offset);
void align_to_next_byte(bitstream *bs);
static const unsigned char reverse8[256] = {
0x00, 0x80, 0x40, 0xC0, 0x20, 0xA0, 0x60, 0xE0, 0x10, 0x90, 0x50, 0xD0,

View file

@ -37,7 +37,6 @@ unsigned int get_bits(bitstream* bs, unsigned int bit_num)
unsigned int reverse(unsigned int x, unsigned int numBits)
{
assert(x < (unsigned int) (1 << numBits));
// fast lookup if it fits in a byte
@ -89,3 +88,12 @@ bitstream init_bitstream(char* data, int size, int last_bit_offset)
return bs;
}
void align_to_next_byte(bitstream* bs)
{
if (bs->current_bit_offset)
{
bs->current_bit_offset = 0;
bs->current_data_offset++;
}
}