Skip to main content

Encoder

Struct Encoder 

Source
pub struct Encoder { /* private fields */ }
Expand description

Range encoder.

Implementations§

Source§

impl Encoder

Source

pub fn new() -> Self

Fresh encoder.

Source

pub fn encode_p(&mut self, bit: bool, p1: u32)

Code bit with P(1) = p1 / 2^16 (clamped).

Source

pub fn encode(&mut self, bit: bool, m: &mut BitModel)

Code bit with an adaptive model, then adapt it.

Source

pub fn encode_raw(&mut self, v: u64, n: u32)

n raw (equiprobable) bits of v, MSB first.

Source

pub fn finish(self) -> Vec<u8> ⓘ

Flush and return the bytes.

Trait Implementations§

Source§

impl Bits for Encoder

Source§

fn bit(&mut self, bit: bool, m: &mut BitModel) -> bool

Code bit (ignored when decoding) with an adaptive model.
Source§

fn bitp(&mut self, bit: bool, p1: u32) -> bool

Code bit with a fixed probability P(1) = p1/2^16.
Source§

fn uint(&mut self, v: u64, m: &mut UintModel) -> u64

Code an unbounded non-negative integer.
Source§

fn tag(&mut self, _t: usize)

Accounting tag for the decisions that follow (no-op for real coders).
Source§

impl Debug for Encoder

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Encoder

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

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> ByRef<T> for T

Source§

fn by_ref(&self) -> &T

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Imply<T> for U
where T: ?Sized, U: ?Sized,

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.