A class to read bit streams.
More...
#include <bit_reader.h>
A class to read bit streams.
Definition at line 20 of file bit_reader.h.
◆ BitReader()
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 14 of file bit_reader.cc.
◆ bit_position()
size_t shaka::media::BitReader::bit_position |
( |
| ) |
const |
|
inline |
- Returns
- The current bit position.
Definition at line 97 of file bit_reader.h.
◆ bits_available()
size_t shaka::media::BitReader::bits_available |
( |
| ) |
const |
|
inline |
- Returns
- The number of bits available for reading.
Definition at line 92 of file bit_reader.h.
◆ current_byte_ptr()
const uint8_t* shaka::media::BitReader::current_byte_ptr |
( |
| ) |
const |
|
inline |
- Returns
- A pointer to the current byte.
Definition at line 100 of file bit_reader.h.
◆ ReadBits()
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 38 of file bit_reader.h.
◆ SkipBits()
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 26 of file bit_reader.cc.
◆ SkipBitsConditional()
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 72 of file bit_reader.h.
◆ SkipBytes()
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 65 of file bit_reader.cc.
◆ SkipToNextByte()
void shaka::media::BitReader::SkipToNextByte |
( |
| ) |
|
Skip a number of bits so the stream is byte aligned to the initial data. There could be 0 to 7 bits skipped.
Definition at line 56 of file bit_reader.cc.
The documentation for this class was generated from the following files: