Skip to content

Commit 26d987f

Browse files
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

File tree

src/hpc/codec/mod.rs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,13 @@
88
//! # Module layout (per PR-X12 worker decomposition)
99
//!
1010
//! - [`ctu`] — A1: `Ctu` carrier + `CtuPartition` enum + quad-tree
11-
//! split / merge ops. **Shipped in this PR.**
12-
//! - `mode`, `predict`, `transform`, `quantize`, `rdo`, `ans`, `stream`
13-
//! — A2-A8, queued as follow-up sprints.
11+
//! split / merge ops.
12+
//! - [`mode`] — A2: bit-pack / unpack helpers for the on-wire 16-bit
13+
//! header + per-mode tail (Skip/Merge/Delta/Escape).
14+
//! - [`predict`] — A3-intra: encoder-side mode-decision kernel that
15+
//! picks the cheapest `LeafCu` from a cell + NESW neighbours.
16+
//! - `transform`, `quantize`, `rdo`, `ans`, `stream` — A4-A8, queued as
17+
//! follow-up sprints.
1418
//!
1519
//! # Feature gate
1620
//!
@@ -22,6 +26,13 @@
2226
//! `.claude/knowledge/pr-x12-codec-x265-design.md` — master design doc.
2327
2428
pub mod ctu;
29+
pub mod mode;
30+
pub mod predict;
2531

2632
pub use ctu::{CellMode, MergeDir, MAX_QUAD_TREE_NODES, MAX_SPLIT_DEPTH};
2733
pub use ctu::{Ctu, CtuArena, CtuPartition, LeafCu, MaxSplitDepthReached, MergeError, NodeIdx};
34+
pub use mode::{
35+
pack_header, pack_leaf, pack_merge_dir, packed_byte_len, unpack_header, unpack_leaf, unpack_merge_dir, BASIN_NONE,
36+
MAX_BASIN_IDX,
37+
};
38+
pub use predict::{is_no_basin, predict_intra, IntraConfig, IntraContext};

0 commit comments

Comments
 (0)