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 slice’s qp (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 the
oracle’s symbol 0 (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 encoder’s flush output is
already inside the engine’s borrowed offset bits, 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 decode_decision(&mut self, ctx_idx: usize) -> u32
pub fn decode_decision(&mut self, ctx_idx: usize) -> u32
Decodes a context-coded bin (spec §9.3.3.2.1), updating the context model. STATE-RESIDENCY REFUTED (WHYS Part 21): this attribute was added on the Part 19 hypothesis that the engine state round-tripped memory per bin through an outlined call. The symbol table refuted it — LLVM already fully inlined this method in the un-attributed build (zero outlined copies in either binary), and the A/B was null as that predicts. The Part 19 ns/bin sizing was also census-tax-inflated: the true engine cost is ~4 ns/bin, and the residual gap vs ffmpeg’s ~2 is the engine’s per-bin WORK (u64-window renorm bookkeeping vs a 16-bit lazy refill), not call overhead. The attribute stays as documentation + insurance.
Sourcepub fn decode_bypass(&mut self) -> u32
pub fn decode_bypass(&mut self) -> u32
Decodes a bypass (equiprobable) bin (spec §9.3.3.2.3).
Sourcepub fn decode_terminate(&mut self) -> bool
pub fn decode_terminate(&mut self) -> bool
Decodes the terminate bin (spec §9.3.3.2.4); true ends the slice (or
marks I_PCM). No renormalization on terminate.