pub struct Cabac<'a> { /* private fields */ }Expand description
The CABAC decoder: arithmetic engine reading MSB-first from the RBSP plus the 460 adaptive context models.
Implementations§
Source§impl<'a> Cabac<'a>
impl<'a> Cabac<'a>
Sourcepub fn new(
data: &'a [u8],
start_byte: usize,
qp: i32,
init_idc: u32,
is_i: bool,
) -> Self
pub fn new( data: &'a [u8], start_byte: usize, qp: i32, init_idc: u32, is_i: bool, ) -> Self
Initializes from the RBSP data at byte offset start_byte (the slice
data, byte-aligned past the header), the QP of the slice (clamped 0..51),
cabac_init_idc, and whether the slice is I/SI (spec 9.3.1).
Sourcepub fn dbg_state(&self) -> (u32, u32)
pub fn dbg_state(&self) -> (u32, u32)
Engine state (codIRange, codIOffset) – for bring-up verification against
symbol 0 of the oracle (Brick 1.1). At slice start this is (510, first-9-bits).
Sourcepub fn pcm_start_byte(&self) -> usize
pub fn pcm_start_byte(&self) -> usize
I_PCM sample position (spec 7.3.5 + 9.3.3.2.5). The PCM marker is a
terminate bin; after it decodes as 1, the flush output of the encoder is
already inside the borrowed offset bits of the engine, so the raw
pcm_sample_* bytes start at the consumed-bit position rounded up to
the next byte boundary (pcm_alignment_zero_bits). byte_pos*8 - cnt
is that consumed position (offset-field bits count as read, buffered
bits do not). Valid only immediately after decode_terminate()
returned true (no renormalization has run since).
Sourcepub fn reinit_at(&mut self, byte: usize)
pub fn reinit_at(&mut self, byte: usize)
Re-initializes the arithmetic engine at absolute byte (spec 9.3.1.2,
invoked after the I_PCM samples), KEEPING the adaptive context models –
only the engine registers restart. Mirrors the tail of Cabac::new.
Sourcepub fn view(&mut self) -> (&'a [u8], Engine, &mut [u8; 512])
pub fn view(&mut self) -> (&'a [u8], Engine, &mut [u8; 512])
Split into (data, engine copy, contexts) for a register-resident run
over many bins; finish with Cabac::commit.
Sourcepub fn commit(&mut self, eng: Engine)
pub fn commit(&mut self, eng: Engine)
Adopt the engine registers a Cabac::view run ended with.
Sourcepub fn decode_decision(&mut self, ctx_idx: usize) -> u32
pub fn decode_decision(&mut self, ctx_idx: usize) -> u32
One context-coded bin. Single-bin convenience over [Engine::decode_decision];
multi-bin parsers take a Cabac::view instead.
Sourcepub fn decode_bypass(&mut self) -> u32
pub fn decode_bypass(&mut self) -> u32
One bypass bin (see [Engine::decode_bypass]).
Sourcepub fn decode_terminate(&mut self) -> bool
pub fn decode_terminate(&mut self) -> bool
The terminate bin (see [Engine::decode_terminate]).