pub struct RangeCoder {
pub buf: Vec<u8>,
pub storage: u32,
pub end_offs: u32,
pub end_window: u32,
pub nend_bits: i32,
pub nbits_total: i32,
pub offs: u32,
pub rng: u32,
pub val: u32,
pub ext: u32,
pub rem: i32,
pub error: i32,
}Fields§
§buf: Vec<u8>§storage: u32§end_offs: u32§end_window: u32§nend_bits: i32§nbits_total: i32§offs: u32§rng: u32§val: u32§ext: u32§rem: i32§error: i32Implementations§
Source§impl RangeCoder
impl RangeCoder
pub fn new_encoder(size: u32) -> Self
Sourcepub fn reset_for_encode(&mut self, size: u32)
pub fn reset_for_encode(&mut self, size: u32)
Reset encoder state for reuse with a (possibly different) buffer size. Reuses the existing allocation if it’s large enough, avoiding per-frame heap allocation.
pub fn new_decoder(data: &[u8]) -> Self
pub fn enc_uint(&mut self, fl: u32, ft: u32)
pub fn dec_uint(&mut self, ft: u32) -> u32
pub fn enc_bits(&mut self, val: u32, bits: u32)
Sourcepub fn pad_to_bits(&mut self, target_bits: i32)
pub fn pad_to_bits(&mut self, target_bits: i32)
Efficiently pad with zero bits up to a target bit count. This is much faster than calling enc_bits(0, 1) in a loop because it processes whole bytes at once.
pub fn dec_bits(&mut self, bits: u32) -> u32
Sourcepub fn tell_frac(&self) -> i32
pub fn tell_frac(&self) -> i32
Compute the fractional number of bits used. This is a hot path function - force inlining for performance.
pub fn tell(&self) -> i32
Sourcepub fn tell_fast(&self) -> i32
pub fn tell_fast(&self) -> i32
Fast tell that only returns integer bits used (no fraction). This is much faster than tell_frac() but less precise. Use when only approximate bit position is needed.
Sourcepub fn encode(&mut self, fl: u32, fh: u32, ft: u32)
pub fn encode(&mut self, fl: u32, fh: u32, ft: u32)
All arithmetic on val uses wrapping_* to match C opus unsigned 32-bit behavior.
pub fn encode_bit_logp(&mut self, val: bool, logp: u32)
pub fn encode_icdf(&mut self, s: i32, icdf: &[u8], ftb: u32)
pub fn decode_bit_logp(&mut self, logp: u32) -> bool
Sourcepub fn decode_icdf(&mut self, icdf: &[u8], ftb: u32) -> i32
pub fn decode_icdf(&mut self, icdf: &[u8], ftb: u32) -> i32
Decode a symbol using an inverse CDF table. Uses do-while pattern like C opus for better performance.
pub fn decode(&mut self, ft: u32) -> u32
pub fn update(&mut self, fl: u32, fh: u32, ft: u32)
pub fn laplace_encode(&mut self, value: &mut i32, fs: u32, decay: i32)
pub fn laplace_decode(&mut self, fs: u32, decay: i32) -> i32
pub fn patch_initial_bits(&mut self, val: u32, nbits: u32)
pub fn done(&mut self)
pub fn finish(&mut self) -> Vec<u8> ⓘ
Trait Implementations§
Source§impl Clone for RangeCoder
impl Clone for RangeCoder
Source§fn clone(&self) -> RangeCoder
fn clone(&self) -> RangeCoder
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more