Gnash
0.8.11dev
|
BitsReader is used to encapsulate bit-packed buffer reads. More...
#include <BitsReader.h>
Public Types | |
typedef unsigned char | byte |
Public Member Functions | |
BitsReader (const byte *input, size_t len) | |
Ownership of buffer left to caller. More... | |
BitsReader (const BitsReader &from, size_t len) | |
Create a BitsReader reading a subset of another. More... | |
~BitsReader () | |
size_t | size () const |
void | setBuffer (byte *input, size_t len) |
Set a new buffer to work with. More... | |
unsigned | read_uint (unsigned short bitcount) |
Reads a bit-packed unsigned integer from the stream and returns it. The given bitcount determines the number of bits to read. More... | |
bool | read_bit () |
Reads a single bit off the stream and returns it. More... | |
std::int32_t | read_sint (unsigned short bitcount) |
Reads a bit-packed little-endian signed integer from the stream. The given bitcount determines the number of bits to read. More... | |
std::uint8_t | read_u8 () |
Read a byte as an unsigned int (aligned) More... | |
std::int8_t | read_s8 () |
Read one bytes as a signed int (aligned) More... | |
std::uint16_t | read_u16 () |
Read two bytes as an unsigned int (aligned) More... | |
std::int16_t | read_s16 () |
Read two bytes as a signed int (aligned) More... | |
std::uint32_t | read_u32 () |
Read four bytes as an unsigned int (aligned) More... | |
std::int32_t | read_s32 () |
Read four bytes as an signed int (aligned) More... | |
void | align () |
Discard any unused bit in the current byte and advance to next. More... | |
bool | gotBits (std::uint32_t nbits) const |
Checks if the stream contains X bits. More... | |
BitsReader is used to encapsulate bit-packed buffer reads.
TODO: implement boundary checking, maybe by throwing an exception when attempts are made to read past end of buffer
typedef unsigned char gnash::BitsReader::byte |
|
inline |
Ownership of buffer left to caller.
|
inline |
Create a BitsReader reading a subset of another.
The starting pointer will be taken from the parent reader cursor, including used bits, use align() if need to discard the left over ones.
length will be given explicitly.
|
inline |
|
inline |
Discard any unused bit in the current byte and advance to next.
|
inline |
Checks if the stream contains X bits.
References _, gnash::image::end(), gnash::log_debug(), and start.
bool gnash::BitsReader::read_bit | ( | ) |
Reads a single bit off the stream and returns it.
|
inline |
Read two bytes as a signed int (aligned)
|
inline |
Read four bytes as an signed int (aligned)
|
inline |
Read one bytes as a signed int (aligned)
std::int32_t gnash::BitsReader::read_sint | ( | unsigned short | bitcount | ) |
Reads a bit-packed little-endian signed integer from the stream. The given bitcount determines the number of bits to read.
References read_uint().
|
inline |
Read two bytes as an unsigned int (aligned)
References gnash::image::end().
|
inline |
Read four bytes as an unsigned int (aligned)
References gnash::image::end().
|
inline |
Read a byte as an unsigned int (aligned)
unsigned gnash::BitsReader::read_uint | ( | unsigned short | bitcount | ) |
Reads a bit-packed unsigned integer from the stream and returns it. The given bitcount determines the number of bits to read.
Referenced by read_sint().
|
inline |
Set a new buffer to work with.
References gnash::image::end(), and start.
|
inline |
References gnash::image::end(), and start.