124 unsigned lz =
clz(buf);
125 unsigned length = lz + 1;
169 static unsigned clz(uint32_t v)
171 return std::countl_zero(v);
185 return val >> (64 - bits);
213 unsigned lz =
clz(buf);
214 unsigned length = lz + 1;
215 unsigned size = lz + length;
219 if (length > max_length || length > 16)
246 m_cache |=
static_cast<uint64_t
>(*m_buffer) << (shift - bits);
253 m_cache |=
static_cast<uint64_t
>(*m_buffer) >> (bits - shift);
unsigned m_bitIndex
index for next bit read from the MSB
int get_ue_golomb_31()
read unsigned exp golomb code, constraint to a max of 31.
uint32_t show_bits(unsigned n)
int get_ue_golomb()
Read an unsigned Exp-Golomb code in the range 0 to 8190 (2^13 - 2).
BitReader(const uint8_t *buffer, uint64_t size)
static constexpr unsigned kCacheSizeMax
static constexpr uint64_t get_upper_bits(uint64_t val, unsigned bits)
static constexpr unsigned kBitsPerRead
static unsigned clz(uint32_t v)
uint64_t get_bits64(unsigned n)
Read 0-64 bits.
void refill_cache(unsigned min_bits)
const uint8_t *const m_bufferEnd
past the end pointer
const uint8_t * m_buffer
next memory location to read from
void skip_bits(unsigned n)
uint32_t get_ue_golomb_long()
Read an unsigned Exp-Golomb code in the range 0 to UINT32_MAX-1.
int get_se_golomb()
read signed exp golomb code.
uint64_t m_cache
cache for reads.
uint64_t show_bits64(unsigned n)
uint32_t get_bits(unsigned n)
Read 0-32 bits.