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>
impl<'a> CabacDecoder<'a>
Sourcepub fn new(data: &'a [u8]) -> Self
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).
Sourcepub fn decode_decision(&mut self, ctx: &mut ContextModel) -> bool
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.
Sourcepub fn decode_bypass(&mut self) -> bool
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.
Sourcepub fn decode_terminate(&mut self) -> bool
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.
Sourcepub fn decode_tr(
&mut self,
ctx: &mut [ContextModel],
c_max: u32,
c_rice_param: u32,
) -> u32
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.
Sourcepub fn decode_fl(&mut self, n_bits: u32) -> u32
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).
Sourcepub fn decode_unary(&mut self, ctx: &mut [ContextModel], max: u32) -> u32
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).
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> 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
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>
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>
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