PTWM
context_mixing

ptwm_core::entropy::context_mixing::model

Four byte-history context models (orders 0–3). Each maps a context — a hash of recent whole bytes combined with the partial-byte register c0 — to an adaptive 12-bit probability counter in a fixed hash table.

ptwm_core::entropy::context_mixing::model

Four byte-history context models (orders 0–3). Each maps a context — a hash of recent whole bytes combined with the partial-byte register c0 — to an adaptive 12-bit probability counter in a fixed hash table.

rsmod

ptwm_core::entropy::context_mixing::model

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

Four byte-history context models (orders 0–3). Each maps a context — a hash of recent whole bytes combined with the partial-byte register `c0` — to an adaptive 12-bit probability counter in a fixed hash table.

rstype

ptwm_core::entropy::context_mixing::model::Models

crates/ptwm-core/src/entropy/context_mixing/model.rs:34
pub struct Models

The four models. The counter tables share one flat `Vec<u16>` of `N_MODELS * TABLE_SIZE` (~512 KiB, one allocation, no double indirection in the per-bit hot path); model `m` owns `[m*TABLE_SIZE, (m+1)*TABLE_SIZE)`. Allocated fresh per encode/decode call — CM is opt-in and per-bit-compute-dominated, so the once-per-plane allocation is negligible.

rsconst

ptwm_core::entropy::context_mixing::model::N_MODELS

crates/ptwm-core/src/entropy/context_mixing/model.rs:6
pub const N_MODELS

Number of context models.

rsfn

ptwm_core::entropy::context_mixing::model::update_counter

crates/ptwm-core/src/entropy/context_mixing/model.rs:23
pub fn update_counter(p: &mut u16, bit: u8)

Move a 12-bit probability counter (`0..=4095`, stored in u16) toward the observed `bit` (target 4095 for `bit == 1`, 0 for `bit == 0`).