PTWM
arithmetic

ptwm_core::entropy::arithmetic::model

Byte models for the arithmetic plane codecs.

ptwm_core::entropy::arithmetic::model

Byte models for the arithmetic plane codecs.

rsmod

ptwm_core::entropy::arithmetic::model

crates/ptwm-core/src/entropy/arithmetic/model.rs:1
mod model

Byte models for the arithmetic plane codecs.

rstype

ptwm_core::entropy::arithmetic::model::ByteModel

crates/ptwm-core/src/entropy/arithmetic/model.rs:13
pub trait ByteModel

A byte probability model the range-coding driver can run. Stateful: adaptive models mutate via [`Self::update`]; static models no-op.

rsfn

ptwm_core::entropy::arithmetic::model::decode_bytes

crates/ptwm-core/src/entropy/arithmetic/model.rs:42
pub fn decode_bytes(model: &mut M, payload: &[u8], decoded_len: usize) -> Vec<u8>

Inverse of [`encode_bytes`]; produces exactly `decoded_len` bytes.

rsfn

ptwm_core::entropy::arithmetic::model::encode_bytes

crates/ptwm-core/src/entropy/arithmetic/model.rs:27
pub fn encode_bytes(model: &mut M, data: &[u8]) -> Vec<u8>

Drive `model` over `data`, returning the range-coded payload.

rstype

ptwm_core::entropy::arithmetic::model::Order0Adaptive

crates/ptwm-core/src/entropy/arithmetic/model.rs:203
pub struct Order0Adaptive

Order-0 model that starts uniform (every byte count = 1) and bumps the observed symbol's count after coding it. Rescales when the total nears [`TOTAL_CAP`]. No serialized state — encoder and decoder stay in lockstep.

rstype

ptwm_core::entropy::arithmetic::model::Order0Static

crates/ptwm-core/src/entropy/arithmetic/model.rs:65
pub struct Order0Static

Order-0 model with a fixed, normalized 256-bin count table.

rstype

ptwm_core::entropy::arithmetic::model::Order1Adaptive

crates/ptwm-core/src/entropy/arithmetic/model.rs:272
pub struct Order1Adaptive

Order-1 model: 256 independent adaptive sub-models keyed on the previous byte. Context starts at 0. Stateless on the wire.

rstype

ptwm_core::entropy::arithmetic::model::Order1Static

crates/ptwm-core/src/entropy/arithmetic/model.rs:372
pub struct Order1Static

Static order-1 (lag-1) model. Counts are fit once on the plane and frozen; [`update`] only advances the context. Contexts never observed as a predecessor fall back to the `marginal` (order-0) table. Every row is Laplace-smoothed and quantized to [`ORDER1_QUANT_TOTAL`], so no symbol is zero-width and the range coder never divides by zero.

[`update`]: ByteModel::update
rsconst

ptwm_core::entropy::arithmetic::model::TOTAL_CAP

crates/ptwm-core/src/entropy/arithmetic/model.rs:9
pub const TOTAL_CAP

Fixed PMF denominator cap. Kept well under the range coder's 2^24 renorm floor so `range / total >= 1` always holds.