class BitReader

Defined at line 21 of file ../../src/media/third_party/chromium_media/media/base/bit_reader.h

Public Methods

void BitReader (base::span<const uint8_t> data)

Defined at line 17 of file ../../src/media/third_party/chromium_media/media/base/bit_reader.cc

void BitReader (const uint8_t * data, int size)

Initialize the reader to start reading at `data`, `size` being size

of `data` in bytes.

DEPRECATED: Use the above `base::span` variant to avoid unsafe buffer

usage.

TODO(https://crbug.com/40284755): Remove this once the callers are gone.

Defined at line 20 of file ../../src/media/third_party/chromium_media/media/base/bit_reader.cc

void ~BitReader ()

Defined at line 28 of file ../../src/media/third_party/chromium_media/media/base/bit_reader.cc

bool ReadFlag (bool * flag)

Read one bit from the stream and return it as a boolean in `*flag`.

Defined at line 30 of file ../../src/media/third_party/chromium_media/media/base/bit_reader.cc

void BitReader (const BitReader & )

Defined at line 33 of file ../../src/media/third_party/chromium_media/media/base/bit_reader.h

BitReader & operator= (const BitReader & )

Defined at line 34 of file ../../src/media/third_party/chromium_media/media/base/bit_reader.h

bool ReadString (size_t num_bits, std::string * str)

Read `num_bits` of binary data into `str`. `num_bits` must be a positive

multiple of 8. This is not efficient for extracting large strings.

If false is returned, `str` may not be valid.

Defined at line 42 of file ../../src/media/third_party/chromium_media/media/base/bit_reader.cc

bool ReadSpan (base::span<uint8_t> out)

Read binary data into `out`. This is not efficient for extracting large

data.

If false is returned, `out` may not be valid.

Defined at line 50 of file ../../src/media/third_party/chromium_media/media/base/bit_reader.cc

template <typename T>
bool ReadBits (size_t num_bits, T * out)

Read `num_bits` next bits from stream and return in `*out`, first bit

from the stream starting at `num_bits` position in `*out`,

bits of `*out` whose position is strictly greater than `num_bits`

are all set to zero.

Notes:

- `num_bits` cannot be larger than the bits the type can hold.

- From the above description, passing a signed type in `T` does not

mean the first bit read from the stream gives the sign of the value.

Return false if the given number of bits cannot be read (not enough

bits in the stream), true otherwise. When return false, the stream will

enter a state where further ReadBits/SkipBits operations will always

return false unless `num_bits` is 0. The type `T` has to be a primitive

integer type.

Defined at line 53 of file ../../src/media/third_party/chromium_media/media/base/bit_reader.h

bool ReadBits (size_t num_bits, bool * out)

Read one bit from the stream and return it as a boolean in `*out`.

Remark: we do not use the template version for reading a bool

since it generates some optimization warnings during compilation

on Windows platforms.

Defined at line 67 of file ../../src/media/third_party/chromium_media/media/base/bit_reader.h

bool SkipBits (size_t num_bits)

Skip `num_bits` next bits from stream. Return false if the given number of

bits cannot be skipped (not enough bits in the stream), true otherwise.

When return false, the stream will enter a state where further

ReadBits/ReadFlag/SkipBits operations will always return false unless

`num_bits` is 0.

Defined at line 70 of file ../../src/media/third_party/chromium_media/media/base/bit_reader.cc

size_t bits_available ()

Defined at line 92 of file ../../src/media/third_party/chromium_media/media/base/bit_reader.h

size_t bits_read ()

Returns the number of bits read so far.

Defined at line 95 of file ../../src/media/third_party/chromium_media/media/base/bit_reader.h