transforms
ptwm_core::transforms::predictor_xor
PredictorXor — FPC-style intra-plane predictor + XOR residual.
ptwm_core::transforms::predictor_xor
PredictorXor — FPC-style intra-plane predictor + XOR residual.
ptwm_core::transforms::predictor_xor
crates/ptwm-core/src/transforms/predictor_xor.rs:1mod predictor_xor`PredictorXor` — FPC-style intra-plane predictor + XOR residual.
For each element in a plane, predicts its value from the *previous*
values using a small fixed-context-model hash table, then emits
`truth XOR prediction`. The output is concentrated around zero
(heavy leading-zero distribution) when the underlying values change
smoothly — exactly the regime where Huffman / [`crate::codecs::Fpc`]
both win.
## Predictor: fixed-context model (fcm)
Maintains a hash table of `1 << HASH_BITS` entries indexed by a
rolling hash of recent values. On each step:
```text
prediction[i] = table[hash]
residual[i] = value[i] XOR prediction[i]
table[hash] = value[i]
hash = ((hash << SHIFT) ^ value[i]) & ((1 << HASH_BITS) - 1)
```
The first element has an all-zero hash context, so the prediction
is the table's initial (zero) entry and the residual is the value
itself. From then on the predictor learns local patterns. The
decoder runs the same recurrence in lock-step to recover the
original.
## Single-predictor variant
Burtscher's original FPC uses *two* predictors (fcm + dfcm) and
emits one bit per element selecting the better. PTWM ships only the
fcm half here — the dual-predictor variant adds a per-element side
channel that would need its own plane and complicates the chain
shape; the single-predictor version captures most of the gain on
trained-weight exponent streams and stays byte-exact-invertible
through a single byte plane.
## Element widths
Same support matrix as [`crate::transforms::IntDelta`]: `Byte`,
`Word2`, `Word4`, `Word8`. `Nibble` is rejected.
ptwm_core::transforms::predictor_xor::PredictorXor
crates/ptwm-core/src/transforms/predictor_xor.rs:79pub struct PredictorXor;