Skip to main content

CabacDecoder

Struct CabacDecoder 

Source
pub struct CabacDecoder<'a> { /* private fields */ }
Expand description

CABAC arithmetic decoder for HEVC (ITU-T H.265, 9.3.3).

Reads a byte-aligned NAL unit payload and exposes methods for context-modelled decisions, bypass bins, and terminating bins.

Implementations§

Source§

impl<'a> CabacDecoder<'a>

Source

pub fn new(data: &'a [u8]) -> Self

Construct a new CABAC decoder from a NAL payload slice.

The caller is expected to provide the slice data beginning at the first CABAC-coded byte (i.e. immediately after the slice segment header has been consumed by a different reader).

Source

pub fn decode_decision(&mut self, ctx: &mut ContextModel) -> bool

Decode one bin using context-modelled arithmetic coding (spec 9.3.3.2.1).

The context model is read and updated after decoding. Returns true for bin value 1, false for bin value 0.

Source

pub fn decode_bypass(&mut self) -> bool

Decode one bin in bypass (equiprobable) mode (spec 9.3.3.2.3).

No context model is used; the two symbols are equally likely.

Source

pub fn decode_terminate(&mut self) -> bool

Decode the terminating bin (spec 9.3.3.2.4).

Used to detect end-of-slice or end-of-sub-stream. The interval is reduced by 2 first; if the remaining value falls in the upper sub-range the terminating condition is signalled.

Source

pub fn decode_tr( &mut self, ctx: &mut [ContextModel], c_max: u32, c_rice_param: u32, ) -> u32

Decode a truncated Rice (TR) binarized syntax element (spec 9.3.2.2).

  • ctx — context model array; the first entry is used for the prefix unary part, subsequent entries for further bins.
  • c_max — maximum value (capped by the binarization).
  • c_rice_param — Rice parameter controlling the suffix length.

The prefix is decoded as a truncated unary code using context models, and the suffix (if any) is decoded in bypass mode.

Source

pub fn decode_fl(&mut self, n_bits: u32) -> u32

Decode a fixed-length (FL) binarized syntax element using bypass bins (spec 9.3.3.2.3, used via 9.3.2.4).

Reads n_bits bypass bins and returns the resulting value (MSB-first).

Source

pub fn decode_unary(&mut self, ctx: &mut [ContextModel], max: u32) -> u32

Decode a unary (U) binarized syntax element using context models.

Returns the number of 1 bins seen before the first 0 bin, capped at max. Context index for each bin position k is min(k, ctx.len() - 1).

Source

pub fn decode_eg(&mut self, k: u32) -> u32

Decode an Exp-Golomb coded syntax element using bypass bins (spec 9.3.2.5, k-th order).

k is the order parameter. Returns the decoded unsigned value.

Auto Trait Implementations§

§

impl<'a> Freeze for CabacDecoder<'a>

§

impl<'a> RefUnwindSafe for CabacDecoder<'a>

§

impl<'a> Send for CabacDecoder<'a>

§

impl<'a> Sync for CabacDecoder<'a>

§

impl<'a> Unpin for CabacDecoder<'a>

§

impl<'a> UnsafeUnpin for CabacDecoder<'a>

§

impl<'a> UnwindSafe for CabacDecoder<'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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.