Align to next byte
This commit is contained in:
parent
b0f5cd41f9
commit
9f8bcf7769
2 changed files with 11 additions and 2 deletions
|
|
@ -17,6 +17,7 @@ unsigned int get_bits(bitstream *bs, unsigned int size);
|
||||||
void print_bits(int x, int size);
|
void print_bits(int x, int size);
|
||||||
unsigned int reverse(unsigned int x, unsigned int numBits);
|
unsigned int reverse(unsigned int x, unsigned int numBits);
|
||||||
bitstream init_bitstream(char *data, int size, int last_bit_offset);
|
bitstream init_bitstream(char *data, int size, int last_bit_offset);
|
||||||
|
void align_to_next_byte(bitstream *bs);
|
||||||
|
|
||||||
static const unsigned char reverse8[256] = {
|
static const unsigned char reverse8[256] = {
|
||||||
0x00, 0x80, 0x40, 0xC0, 0x20, 0xA0, 0x60, 0xE0, 0x10, 0x90, 0x50, 0xD0,
|
0x00, 0x80, 0x40, 0xC0, 0x20, 0xA0, 0x60, 0xE0, 0x10, 0x90, 0x50, 0xD0,
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,6 @@ unsigned int get_bits(bitstream* bs, unsigned int bit_num)
|
||||||
|
|
||||||
unsigned int reverse(unsigned int x, unsigned int numBits)
|
unsigned int reverse(unsigned int x, unsigned int numBits)
|
||||||
{
|
{
|
||||||
|
|
||||||
assert(x < (unsigned int) (1 << numBits));
|
assert(x < (unsigned int) (1 << numBits));
|
||||||
|
|
||||||
// fast lookup if it fits in a byte
|
// fast lookup if it fits in a byte
|
||||||
|
|
@ -88,4 +87,13 @@ bitstream init_bitstream(char* data, int size, int last_bit_offset)
|
||||||
.last_bit_offset = last_bit_offset};
|
.last_bit_offset = last_bit_offset};
|
||||||
|
|
||||||
return bs;
|
return bs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void align_to_next_byte(bitstream* bs)
|
||||||
|
{
|
||||||
|
if (bs->current_bit_offset)
|
||||||
|
{
|
||||||
|
bs->current_bit_offset = 0;
|
||||||
|
bs->current_data_offset++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue