codecs
ptwm_core::codecs::fpc
FPC-style leading-zero plane codec.
ptwm_core::codecs::fpc
FPC-style leading-zero plane codec.
ptwm_core::codecs::fpc
crates/ptwm-core/src/codecs/fpc.rs:1mod fpcFPC-style leading-zero plane codec.
Targets the residual streams produced by predictor-based transforms
(notably [`crate::transforms::PredictorXor`]) — those streams have a
heavy distribution of small-magnitude integers with many leading
zero bytes after the high-order byte. The codec encodes each value
with a 4-bit leading-zero-byte count (enough to count 0..=8 zero
bytes for the widest supported element) followed by the non-zero
suffix bytes, packing two values per header byte to keep the
framing tight.
The codec is intentionally generic: it works on any byte stream
whose elements are width-aligned (1/2/4/8) and have a leading-zero-
heavy distribution. It does not require a paired predictor.
## Wire layout
```text
[u8 width] element width in bytes (1, 2, 4, or 8)
[u32 LE n_elements] element count
[packed headers] ceil(n / 2) bytes, each carrying two
4-bit leading-zero-byte counts (high
nibble = first elem, low nibble = second
elem).
[suffix bytes] n_elements groups, each (width - lzcount)
bytes; per FPC convention the leading-zero
bytes are *implied zero* and never stored.
```
Decoder reverses the layout: for each element read the 4-bit
header, then the (width - lzcount) suffix bytes, and zero-extend on
the high side.
## Single-predictor variant
Burtscher's original FPC pairs two predictors and stores a 1-bit
per-element selector. PTWM ships only the single-predictor variant
(see [`crate::transforms::PredictorXor`]) and therefore omits the
selector bit from the header nibble.
ptwm_core::codecs::fpc::Fpc
crates/ptwm-core/src/codecs/fpc.rs:46pub struct Fpc;context_mixing
Opt-in context-mixing plane codec. Stateless; self-delimiting (the coder frames the plane length, so decode ignores the container's decoded_len). NOT in the default dispatch menu — selected only when named in codec_menu.
huff_llm
huff_llm_5bit — field-separated Huffman codec for 16-bit float planes.