Skip to main content

Module mix_coder

Module mix_coder 

Source
Expand description

MNF13-R5: the dual-timescale adaptive mix coder — MNF8 backend id 4 (fixed-point dual-EWA estimators, zero model transport; docs/mnf13-r5.md). MNF13-R5 — the dual-timescale adaptive mix coder (backend id 4), MNF13-R6 — the R6-tuned variant (backend id 5).

Per-context FAST and SLOW adaptive fixed-point (2^24-scale) estimators over the full 256-symbol alphabet, mixed by a log-space EWA weight updated per symbol from the DECODED symbol — identical model evolution on both sides (zero model transport; the wire = [u32 stream_len] + LE u32 words). ConstricTON 0.5’s stream range coder carries the fixed-point probabilities (2^24 scale, no fp in the wire data path). The exact-inverse contract is asserted by the conformance suite (tests/mnf8_conformance.rs) and the corpus gate.

Wire (v1.14.0): MNF8 backend ids 4 (v1.13.0, frozen) and 5 (MNF13-R6; the measured grid winner, docs/mnf13-r6.md). The payload the backend field addresses = the mix-coded residual byte stream in the file’s own coded order; every context key recomputes from already-coded bytes, so the decoder needs no side tables and rejects malformed inputs with errors (never panics).

Backend 4: context = the previous coded byte bucketed to 8 keys; FAST cap 4,096, SLOW cap 65,536. Measured docs/mnf13-r5.md: −1.80% complete corpus at the v1.12 pick level, wins 19/19 photographic record files, zero regressions elsewhere.

Backend 5 (MNF13-R6): context = the previous byte’s bucket + a 2-band coarse pre-prev key (16 total); FAST cap 32,768, SLOW cap 1,048,576 (the long horizon). Same algorithmic family; the DECODE evolution differs by the constants, which is why the backend id is distinct. Measured docs/mnf13-r6.md: −3,376 B on the 20 backend-4 corpus files (−0.62%), 20/20 fires, zero regressions; corpus projection 816,341 → 812,965 (−0.41%).

Structs§

MixParams
One coder configuration; backend 4 and 5 differ ONLY here.

Constants§

MIX5_FAST_CAP
Backend 5’s FAST estimator halving cap (MNF13-R6).
MIX5_NCTX
Backend 5’s context count (prev bucket + 2-band pre-prev key).
MIX5_SLOW_CAP
Backend 5’s SLOW estimator halving cap — the long horizon (MNF13-R6).
MIX_FAST_CAP
Backend 4’s FAST estimator halving cap (frozen with v1.13.0).
MIX_SLOW_CAP
Backend 4’s SLOW estimator halving cap (frozen with v1.13.0).

Functions§

mix_ctx_bucket
The previous-coded-byte magnitude context (0; 1-2; 3-5; 6-11; 12-24; 25-48; 49-96; 97+) — shared by both backends’ key rules.
mix_decode
The backend-4 form (v1.13.0 constants).
mix_decode_with
The inverse under params: decode the wire back to its stream bytes. Errors, never panics, on malformed input.
mix_encode
The backend-4 form (v1.13.0 constants; byte-identical to the 1.13.0 release’s behavior).
mix_encode_with
The mix coder: encode data (the residual bytes in coded order) under params. Zero transport; the model evolves from the bytes themselves.