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§
Sourcefn symbol<const CDF_LEN: usize>(&mut self, s: u32, cdf: &[u16; CDF_LEN])
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
Sourcefn symbol_bits(&self, s: u32, cdf: &[u16]) -> u32
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
Sourcefn symbol_with_update<const CDF_LEN: usize>(
&mut self,
s: u32,
cdf: CDFOffset<CDF_LEN>,
log: &mut CDFContextLog,
fc: &mut CDFContext,
)
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.
Sourcefn write_golomb(&mut self, level: u32)
fn write_golomb(&mut self, level: u32)
Write passed level
as a golomb code
Sourcefn write_quniform(&mut self, n: u32, v: u32)
fn write_quniform(&mut self, n: u32, v: u32)
Write a value v
in [0, n-1]
quasi-uniformly
Sourcefn count_quniform(&self, n: u32, v: u32) -> u32
fn count_quniform(&self, n: u32, v: u32) -> u32
Return fractional bits needed to write a value v
in [0, n-1]
quasi-uniformly
Sourcefn write_subexp(&mut self, n: u32, k: u8, v: u32)
fn write_subexp(&mut self, n: u32, k: u8, v: u32)
Write symbol v
in [0, n-1]
with parameter k
as finite subexponential
Sourcefn count_subexp(&self, n: u32, k: u8, v: u32) -> u32
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
Sourcefn write_unsigned_subexp_with_ref(&mut self, v: u32, mx: u32, k: u8, r: u32)
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]
.
Sourcefn count_unsigned_subexp_with_ref(&self, v: u32, mx: u32, k: u8, r: u32) -> u32
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]
.
Sourcefn write_signed_subexp_with_ref(
&mut self,
v: i32,
low: i32,
high: i32,
k: u8,
r: i32,
)
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]
.
Sourcefn count_signed_subexp_with_ref(
&self,
v: i32,
low: i32,
high: i32,
k: u8,
r: i32,
) -> u32
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]
.
Sourcefn tell_frac(&mut self) -> u32
fn tell_frac(&mut self) -> u32
Return current length of range-coded bitstream in fractional
bits with OD_BITRES
decimal precision
Sourcefn checkpoint(&mut self) -> WriterCheckpoint
fn checkpoint(&mut self) -> WriterCheckpoint
Save current point in coding/recording to a checkpoint
Sourcefn rollback(&mut self, _: &WriterCheckpoint)
fn rollback(&mut self, _: &WriterCheckpoint)
Restore saved position in coding/recording from a checkpoint
Sourcefn add_bits_frac(&mut self, bits_frac: u32)
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§
impl<S> Writer for WriterBase<S>where
WriterBase<S>: StorageBackend,
Generic/shared implementation for Writer
s with StorageBackend
s
(ie, Encoder
s and Recorder
s)