pub struct ArithmeticEncoder<W: Write> { /* private fields */ }Expand description
Binary arithmetic encoder.
Implementations§
Source§impl<W: Write> ArithmeticEncoder<W>
impl<W: Write> ArithmeticEncoder<W>
Sourcepub fn encode_counts(&mut self, c_lo: u64, c_hi: u64, total: u64) -> Result<()>
pub fn encode_counts(&mut self, c_lo: u64, c_hi: u64, total: u64) -> Result<()>
Encode a symbol using integer CDF bounds.
§Arguments
c_lo- Lower CDF bound (cumulative probability before symbol)c_hi- Upper CDF bound (cumulative probability including symbol)total- Total CDF range (should be CDF_TOTAL)
Sourcepub fn encode_symbol(&mut self, pdf: &[f64], sym: usize) -> Result<()>
pub fn encode_symbol(&mut self, pdf: &[f64], sym: usize) -> Result<()>
Encode a symbol given its PDF and symbol index.
This is a convenience method that quantizes the PDF to CDF internally.
Sourcepub fn finish(self) -> Result<W>
pub fn finish(self) -> Result<W>
Finish encoding and flush remaining bits.
Returns the underlying writer.
Sourcepub fn bytes_written(&self) -> u64
pub fn bytes_written(&self) -> u64
Get the number of bytes written so far.
Auto Trait Implementations§
impl<W> Freeze for ArithmeticEncoder<W>where
W: Freeze,
impl<W> RefUnwindSafe for ArithmeticEncoder<W>where
W: RefUnwindSafe,
impl<W> Send for ArithmeticEncoder<W>where
W: Send,
impl<W> Sync for ArithmeticEncoder<W>where
W: Sync,
impl<W> Unpin for ArithmeticEncoder<W>where
W: Unpin,
impl<W> UnwindSafe for ArithmeticEncoder<W>where
W: UnwindSafe,
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> 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