Skip to main content

Cabac

Struct Cabac 

Source
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>

Source

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).

Source

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).

Source

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).

Source

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.

Source

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.

Source

pub fn commit(&mut self, eng: Engine)

Adopt the engine registers a Cabac::view run ended with.

Source

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.

Source

pub fn decode_bypass(&mut self) -> u32

One bypass bin (see [Engine::decode_bypass]).

Source

pub fn decode_terminate(&mut self) -> bool

The terminate bin (see [Engine::decode_terminate]).

Auto Trait Implementations§

§

impl<'a> Freeze for Cabac<'a>

§

impl<'a> RefUnwindSafe for Cabac<'a>

§

impl<'a> Send for Cabac<'a>

§

impl<'a> Sync for Cabac<'a>

§

impl<'a> Unpin for Cabac<'a>

§

impl<'a> UnsafeUnpin for Cabac<'a>

§

impl<'a> UnwindSafe for Cabac<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.