Trait Writer

Source
pub trait Writer {
Show 20 methods // Required methods fn symbol<const CDF_LEN: usize>(&mut self, s: u32, cdf: &[u16; CDF_LEN]); fn symbol_bits(&self, s: u32, cdf: &[u16]) -> u32; fn symbol_with_update<const CDF_LEN: usize>( &mut self, s: u32, cdf: CDFOffset<CDF_LEN>, log: &mut CDFContextLog, fc: &mut CDFContext, ); fn bool(&mut self, val: bool, f: u16); fn bit(&mut self, bit: u16); fn literal(&mut self, bits: u8, s: u32); fn write_golomb(&mut self, level: u32); fn write_quniform(&mut self, n: u32, v: u32); fn count_quniform(&self, n: u32, v: u32) -> u32; fn write_subexp(&mut self, n: u32, k: u8, v: u32); fn count_subexp(&self, n: u32, k: u8, v: u32) -> u32; fn write_unsigned_subexp_with_ref(&mut self, v: u32, mx: u32, k: u8, r: u32); fn count_unsigned_subexp_with_ref( &self, v: u32, mx: u32, k: u8, r: u32, ) -> u32; fn write_signed_subexp_with_ref( &mut self, v: i32, low: i32, high: i32, k: u8, r: i32, ); fn count_signed_subexp_with_ref( &self, v: i32, low: i32, high: i32, k: u8, r: i32, ) -> u32; fn tell(&mut self) -> u32; fn tell_frac(&mut self) -> u32; fn checkpoint(&mut self) -> WriterCheckpoint; fn rollback(&mut self, _: &WriterCheckpoint); fn add_bits_frac(&mut self, bits_frac: u32);
}
Expand description

Public trait interface to a bitstream Writer: a Counter can be used to count bits for cost analysis without actually storing anything (using a new WriterCounter as a Writer), to record tokens for later writing (using a new WriterRecorder as a Writer) to write actual final bits out using a range encoder (using a new WriterEncoder as a Writer). A WriterRecorder’s contents can be replayed into a WriterEncoder.

Required Methods§

Source

fn symbol<const CDF_LEN: usize>(&mut self, s: u32, cdf: &[u16; CDF_LEN])

Write a symbol s, using the passed in cdf reference; leaves cdf unchanged

Source

fn symbol_bits(&self, s: u32, cdf: &[u16]) -> u32

return approximate number of fractional bits in OD_BITRES precision to write a symbol s using the passed in cdf reference; leaves cdf unchanged

Source

fn symbol_with_update<const CDF_LEN: usize>( &mut self, s: u32, cdf: CDFOffset<CDF_LEN>, log: &mut CDFContextLog, fc: &mut CDFContext, )

Write a symbol s, using the passed in cdf reference; updates the referenced cdf.

Source

fn bool(&mut self, val: bool, f: u16)

Write a bool using passed in probability

Source

fn bit(&mut self, bit: u16)

Write a single bit with flat probability

Source

fn literal(&mut self, bits: u8, s: u32)

Write literal bits with flat probability

Source

fn write_golomb(&mut self, level: u32)

Write passed level as a golomb code

Source

fn write_quniform(&mut self, n: u32, v: u32)

Write a value v in [0, n-1] quasi-uniformly

Source

fn count_quniform(&self, n: u32, v: u32) -> u32

Return fractional bits needed to write a value v in [0, n-1] quasi-uniformly

Source

fn write_subexp(&mut self, n: u32, k: u8, v: u32)

Write symbol v in [0, n-1] with parameter k as finite subexponential

Source

fn count_subexp(&self, n: u32, k: u8, v: u32) -> u32

Return fractional bits needed to write symbol v in [0, n-1] with parameter k as finite subexponential

Source

fn write_unsigned_subexp_with_ref(&mut self, v: u32, mx: u32, k: u8, r: u32)

Write symbol v in [0, n-1] with parameter k as finite subexponential based on a reference r also in [0, n-1].

Source

fn count_unsigned_subexp_with_ref(&self, v: u32, mx: u32, k: u8, r: u32) -> u32

Return fractional bits needed to write symbol v in [0, n-1] with parameter k as finite subexponential based on a reference r also in [0, n-1].

Source

fn write_signed_subexp_with_ref( &mut self, v: i32, low: i32, high: i32, k: u8, r: i32, )

Write symbol v in [-(n-1), n-1] with parameter k as finite subexponential based on a reference ref also in [-(n-1), n-1].

Source

fn count_signed_subexp_with_ref( &self, v: i32, low: i32, high: i32, k: u8, r: i32, ) -> u32

Return fractional bits needed to write symbol v in [-(n-1), n-1] with parameter k as finite subexponential based on a reference r also in [-(n-1), n-1].

Source

fn tell(&mut self) -> u32

Return current length of range-coded bitstream in integer bits

Source

fn tell_frac(&mut self) -> u32

Return current length of range-coded bitstream in fractional bits with OD_BITRES decimal precision

Source

fn checkpoint(&mut self) -> WriterCheckpoint

Save current point in coding/recording to a checkpoint

Source

fn rollback(&mut self, _: &WriterCheckpoint)

Restore saved position in coding/recording from a checkpoint

Source

fn add_bits_frac(&mut self, bits_frac: u32)

Add additional bits from rate estimators without coding a real symbol

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<S> Writer for WriterBase<S>

Generic/shared implementation for Writers with StorageBackends (ie, Encoders and Recorders)