MythTV  master
Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
BitReader Class Reference

#include <bitreader.h>

Public Member Functions

 BitReader (const uint8_t *buffer, uint64_t size)
 
 ~BitReader ()=default
 
void skip_bits (unsigned n)
 
uint32_t show_bits (unsigned n)
 
uint64_t show_bits64 (unsigned n)
 
bool next_bit ()
 
uint32_t get_bits (unsigned n)
 Read 0-32 bits. More...
 
uint64_t get_bits64 (unsigned n)
 Read 0-64 bits. More...
 
int get_ue_golomb ()
 Read an unsigned Exp-Golomb code in the range 0 to 8190 (2^13 - 2). More...
 
uint32_t get_ue_golomb_long ()
 Read an unsigned Exp-Golomb code in the range 0 to UINT32_MAX-1. More...
 
int get_ue_golomb_31 ()
 read unsigned exp golomb code, constraint to a max of 31. More...
 
int get_se_golomb ()
 read signed exp golomb code. More...
 
int64_t get_bits_left ()
 

Private Member Functions

int get_ue_golomb (unsigned max_length)
 Valid for max_length <= 16. More...
 
void refill_cache (unsigned min_bits)
 

Static Private Member Functions

static unsigned clz (uint32_t v)
 
static constexpr uint64_t get_upper_bits (uint64_t val, unsigned bits)
 

Private Attributes

const uint8_t * m_buffer
 next memory location to read from More...
 
const uint8_t *const m_bufferEnd
 past the end pointer More...
 
unsigned m_bitIndex {0}
 index for next bit read from the MSB More...
 
uint64_t m_cache {0}
 cache for reads. More...
 
unsigned m_cacheSize {0}
 

Detailed Description

Definition at line 38 of file bitreader.h.

Constructor & Destructor Documentation

◆ BitReader()

BitReader::BitReader ( const uint8_t *  buffer,
uint64_t  size 
)
inline

Definition at line 41 of file bitreader.h.

◆ ~BitReader()

BitReader::~BitReader ( )
default

Member Function Documentation

◆ skip_bits()

void BitReader::skip_bits ( unsigned  n)
inline

◆ show_bits()

uint32_t BitReader::show_bits ( unsigned  n)
inline

Definition at line 66 of file bitreader.h.

Referenced by AVCParser::decode_SEI(), get_bits(), get_ue_golomb(), and get_ue_golomb_long().

◆ show_bits64()

uint64_t BitReader::show_bits64 ( unsigned  n)
inline

Definition at line 75 of file bitreader.h.

Referenced by get_bits64().

◆ next_bit()

bool BitReader::next_bit ( )
inline

Definition at line 84 of file bitreader.h.

Referenced by H2645Parser::vui_parameters().

◆ get_bits()

uint32_t BitReader::get_bits ( unsigned  n)
inline

◆ get_bits64()

uint64_t BitReader::get_bits64 ( unsigned  n)
inline

Read 0-64 bits.

Definition at line 93 of file bitreader.h.

◆ get_ue_golomb() [1/2]

int BitReader::get_ue_golomb ( )
inline

◆ get_ue_golomb_long()

uint32_t BitReader::get_ue_golomb_long ( )
inline

Read an unsigned Exp-Golomb code in the range 0 to UINT32_MAX-1.

Returns
the read value or UINT32_MAX on error.

Definition at line 115 of file bitreader.h.

Referenced by get_se_golomb(), and HEVCParser::parseVPS().

◆ get_ue_golomb_31()

int BitReader::get_ue_golomb_31 ( )
inline

read unsigned exp golomb code, constraint to a max of 31.

If the value encountered is not in 0..31, the return value is outside the range 0..30.

Definition at line 136 of file bitreader.h.

Referenced by AVCParser::decode_Header().

◆ get_se_golomb()

int BitReader::get_se_golomb ( )
inline

◆ get_bits_left()

int64_t BitReader::get_bits_left ( )
inline

Definition at line 156 of file bitreader.h.

Referenced by AVCParser::decode_SEI().

◆ get_ue_golomb() [2/2]

int BitReader::get_ue_golomb ( unsigned  max_length)
inlineprivate

Valid for max_length <= 16.

Definition at line 224 of file bitreader.h.

◆ clz()

static unsigned BitReader::clz ( uint32_t  v)
inlinestaticprivate

Definition at line 163 of file bitreader.h.

Referenced by get_ue_golomb(), and get_ue_golomb_long().

◆ get_upper_bits()

static constexpr uint64_t BitReader::get_upper_bits ( uint64_t  val,
unsigned  bits 
)
inlinestaticconstexprprivate

Definition at line 190 of file bitreader.h.

Referenced by show_bits(), and show_bits64().

◆ refill_cache()

void BitReader::refill_cache ( unsigned  min_bits)
inlineprivate

Definition at line 243 of file bitreader.h.

Referenced by show_bits(), and show_bits64().

Member Data Documentation

◆ m_buffer

const uint8_t* BitReader::m_buffer
private

next memory location to read from

Definition at line 206 of file bitreader.h.

Referenced by get_bits_left(), refill_cache(), and skip_bits().

◆ m_bufferEnd

const uint8_t* const BitReader::m_bufferEnd
private

past the end pointer

Definition at line 207 of file bitreader.h.

Referenced by get_bits_left(), and refill_cache().

◆ m_bitIndex

unsigned BitReader::m_bitIndex {0}
private

index for next bit read from the MSB

Definition at line 208 of file bitreader.h.

Referenced by get_bits_left(), refill_cache(), and skip_bits().

◆ m_cache

uint64_t BitReader::m_cache {0}
private

cache for reads.

This is updated such that the next bit to read is always the Most Significant Bit.

Definition at line 216 of file bitreader.h.

Referenced by refill_cache(), show_bits(), show_bits64(), and skip_bits().

◆ m_cacheSize

unsigned BitReader::m_cacheSize {0}
private

Definition at line 217 of file bitreader.h.

Referenced by get_bits_left(), refill_cache(), show_bits(), show_bits64(), and skip_bits().


The documentation for this class was generated from the following file: