Commit 26d987f
committed
feat(codec): PR-X12 A2 mode bit-pack + A3-intra prediction kernel
A2 — mode.rs (~270 lines, 11 tests):
- 16-bit header: 2-bit mode (Skip/Merge/Delta/Escape) + 12-bit basin_idx
- MergeDir 2-bit pack/unpack (high bits masked)
- Whole-leaf compact pack/unpack: Skip=2B, Merge=3B, Delta=3B, Escape=6B
- packed_byte_len() const fn for buffer pre-sizing
- MAX_BASIN_IDX (4095) + BASIN_NONE sentinel
- Stream roundtrip test for mixed-mode leaves
A3-intra — predict.rs (~330 lines, 12 tests):
- IntraContext { basin_idx, delta_i32, NESW neighbours }
- IntraConfig { escape_next_idx: Option<u32> }
- predict_intra() decision tree: Skip → Merge → Delta → Escape
(monotone wire cost 2 → 3 → 3 → 6 bytes; cheapest-fit policy)
- Merge match: same basin_idx + same δ as u8 (sign-tolerant wrapping cast)
- Escape fallback: lossy i8 clamp when allocator absent (never panics)
- End-to-end pack/unpack chain test through the decision
Deferred to follow-up: A3-inter (cross-tier neighbour scan from
BlockedGrid L2/L3), A4 transform, A6 RDO, A7 rANS, A8 stream framing.1 parent 6ff6f48 commit 26d987f
3 files changed
Lines changed: 791 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
12 | | - | |
13 | | - | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
14 | 18 | | |
15 | 19 | | |
16 | 20 | | |
| |||
22 | 26 | | |
23 | 27 | | |
24 | 28 | | |
| 29 | + | |
| 30 | + | |
25 | 31 | | |
26 | 32 | | |
27 | 33 | | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
0 commit comments