A class to read bit streams.
More...
#include <bit_reader.h>
A class to read bit streams.
Definition at line 17 of file bit_reader.h.
shaka::media::BitReader::BitReader |
( |
const uint8_t * |
data, |
|
|
size_t |
size |
|
) |
| |
Initialize the BitReader object to read a data buffer.
- Parameters
-
data | points to the beginning of the buffer. |
size | is the buffer size in bytes. |
Definition at line 12 of file bit_reader.cc.
size_t shaka::media::BitReader::bit_position |
( |
| ) |
const |
|
inline |
- Returns
- The current bit position.
Definition at line 90 of file bit_reader.h.
size_t shaka::media::BitReader::bits_available |
( |
| ) |
const |
|
inline |
- Returns
- The number of bits available for reading.
Definition at line 85 of file bit_reader.h.
template<typename T >
bool shaka::media::BitReader::ReadBits |
( |
size_t |
num_bits, |
|
|
T * |
out |
|
) |
| |
|
inline |
Read a number of bits from stream.
- Parameters
-
| num_bits | specifies the number of bits to read. It cannot be larger than the number of bits the type can hold. |
[out] | out | stores the output. The type T has to be a primitive integer type. |
- Returns
- false if the given number of bits cannot be read (not enough bits in the stream), true otherwise. When false is returned, the stream will enter a state where further ReadBits/SkipBits operations will always return false unless num_bits is 0.
Definition at line 35 of file bit_reader.h.
bool shaka::media::BitReader::SkipBits |
( |
size_t |
num_bits | ) |
|
Skip a number of bits from stream.
- Parameters
-
num_bits | specifies the number of bits to be skipped. |
- Returns
- false if the given number of bits cannot be skipped (not enough bits in the stream), true otherwise. When false is returned, the stream will enter a state where further ReadXXX/SkipXXX operations will always return false unless |num_bits/bytes| is 0.
Definition at line 24 of file bit_reader.cc.
bool shaka::media::BitReader::SkipBitsConditional |
( |
bool |
condition, |
|
|
size_t |
num_bits |
|
) |
| |
|
inline |
Read one bit then skip the number of bits specified if that bit matches condition.
- Parameters
-
condition | indicates when the number of bits should be skipped. |
num_bits | specifies the number of bits to be skipped. |
- Returns
- false if the one bit cannot be read (not enough bits in the stream) or if the bit is set but the given number of bits cannot be skipped (not enough bits in the stream), true otherwise. When false is returned, the stream will enter a state where further ReadXXX/SkipXXX operations will always return false.
Definition at line 69 of file bit_reader.h.
bool shaka::media::BitReader::SkipBytes |
( |
size_t |
num_bytes | ) |
|
Skip a number of bytes from stream. The current posision should be byte aligned, otherwise a false is returned and bytes are not skipped.
- Parameters
-
num_bytes | specifies the number of bytes to be skipped. |
- Returns
- false if the current position is not byte aligned or if the given number of bytes cannot be skipped (not enough bytes in the stream), true otherwise.
Definition at line 54 of file bit_reader.cc.
The documentation for this class was generated from the following files: