pub struct CabacContext {
pub state: u8,
pub mps: bool,
}Expand description
A single CABAC context model.
Tracks the probability of the MPS (most probable symbol) and adapts after each coded bin using exponential moving average.
Fields§
§state: u8Probability of the MPS in fixed-point (6-bit fractional, range [1, 127]).
mps: boolMost probable symbol (false = 0, true = 1).
Implementations§
Source§impl CabacContext
impl CabacContext
Sourcepub fn with_state(init_state: u8, mps: bool) -> Self
pub fn with_state(init_state: u8, mps: bool) -> Self
Create a context with a biased initial probability.
init_state is in [0, 127], where 0 is strongly biased towards LPS
and 127 is strongly biased towards MPS.
Sourcepub fn update(&mut self, bin: bool)
pub fn update(&mut self, bin: bool)
Update context after observing a bin value.
Uses a simplified adaptation: if the bin matches MPS, state moves towards 127 (more confident); otherwise, state moves towards 0 (less confident), and MPS may flip.
Sourcepub fn mps_probability(&self) -> f64
pub fn mps_probability(&self) -> f64
Return the estimated probability of MPS as a float in (0, 1).
Trait Implementations§
Source§impl Clone for CabacContext
impl Clone for CabacContext
Source§fn clone(&self) -> CabacContext
fn clone(&self) -> CabacContext
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for CabacContext
impl RefUnwindSafe for CabacContext
impl Send for CabacContext
impl Sync for CabacContext
impl Unpin for CabacContext
impl UnsafeUnpin for CabacContext
impl UnwindSafe for CabacContext
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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