forge
Explore
Log in

Don't you dare go Hollow

Lane-hbd r1 charter -- fresh branch for the u16 widen, replay r10's saved diff

Browse files at this commit

c3da14ba0848f1f2ba43783b938d44c65c6b70d3Ahmet Kaan GümüşParent: 318c22b
  • docs
    • lane-hbd r1 charter -- fresh branch for the u16 widen, replay r10's saved diff
Show full message
docs(av1): lane-hbd r1 charter -- fresh branch for the u16 widen, replay r10's saved diff
lanes/hbd-r1.charter.mdadded+51 -0
@@ -0,0 +1,51 @@
1+# lane-hbd r1 — widen the sample type
2+
3+Fresh worktree off main (71a2624), suite green at 263/0. This lane replaces
4+lane-realworld, whose decode work is all merged; only the high-bit-depth job is
5+left, and it now has a clean branch instead of a stale one. Read
6+`lanes/realworld-r8.report.md` (site inventory) and `lanes/realworld-r10.report.md`
7+(the previous attempt) first.
8+
9+**Why this matters:** both AV1 films in the user's library are `yuv420p10le` and
10+stop at the `bit_depth != 8` refusal. This is the critical path to his own files.
11+
12+## Start from the saved diff, do not retype it
13+r10 got `PlaneBuf::data -> Vec<u16>` plus all of `intra.rs` type-correct before
14+its cap, then reverted, saving the 500-line diff at
15+`/tmp/claude-1000/-home-user-Documents-Code-Rust-edith-codecs/baaa03f8-c4ff-4469-8ebb-83100429b150/scratchpad/r10-attempt.diff`.
16+`git apply` it first. If it no longer applies (main moved: UV palette landed),
17+re-apply what does and redo the rest by hand — but check before assuming.
18+
19+Then, in this order, per r10's own handoff:
20+1. `restoration.rs`'s `apply_loop_restoration_plane` (still `Vec<u8>` in/out,
21+ 3 call sites at `decode.rs` ~5445/5457/5469), two debug-dump narrowing
22+ closures, and `reconstruct_mc`'s clamp — all small and mechanical.
23+2. `mc.rs` LAST: 6 functions still `&[u8]`/`&mut [u8]`, ~24 `decode.rs` call
24+ sites resolve for free once they widen. Use the `sample_max()` pattern
25+ `intra.rs` proved.
26+3. `encode.rs`'s 3 call sites into `intra.rs` (~600, ~820, ~872) — the encoder
27+ shares those predictors. r10 found these; they were NOT in the original
28+ inventory. Decide deliberately: widen the encoder's buffers too, or box
29+ u8<->u16 locally at those three sites. Say which and why.
30+
31+**8-bit output must stay bit-exact.** The 263-test suite is the regression gate;
32+run it before every commit. Do NOT lift the `bit_depth != 8` refusal and do not
33+build a 10-bit gate this round — `ffmpeg_decode_sequence` hardcodes
34+`-pix_fmt yuv420p`, so a 10-bit gate needs a second helper with u16 LE parsing,
35+and that plus the first real 10-bit stream is the next round.
36+
37+Note from r10: `git checkout` and `git stash` were blocked in that session;
38+`git apply -R <saved-diff>` is the working revert mechanism if you need one.
39+
40+## Budget discipline
41+75 turns, no reset on resume. At about turn 55, stop starting new work: commit
42+what compiles and passes, and write your report. Do NOT revert working partial
43+work to make the report tidier — a compiling, green, partially widened crate is
44+a fine place to stop.
45+
46+Hard rules: `CARGO_TARGET_DIR=$HOME/.cache/cargo-target-hbd`; foreground
47+`nice -n 19 cargo ... -j4`; every `cargo test` a timeout >= 600000 ms;
48+`EC_AV1_REQUIRE_AOMENC=1`. Do NOT open the user's media in a GUI app — ffmpeg
49+and `decode_probe` only. Sibling worktrees have live agents — never build in or
50+edit them. Never push, never merge into main; I handle merges. End with
51+`lanes/hbd-r1.report.md`, VERDICT on line 1.
lanes/realworld-r10.report.mdadded+127 -0
@@ -0,0 +1,127 @@
1+VERDICT: No commit this round. The `u16` widen of `PlaneBuf::data` was attempted,
2+got substantially further than r9 (67 -> ~35 remaining `cargo check` errors,
3+`decode.rs`'s own internal sites plus all of `intra.rs` fully widened and
4+type-correct on their own), but did not reach a compiling state inside the
5+turn budget. Per the charter's own rule ("a non-compiling [crate] is not [a
6+fine place to stop]"), the attempt was reversed with `git apply -R` against a
7+saved diff rather than committed half-wired. Working tree is clean, at
8+b8ad140 + the r10 charter commit c7b3fa0, `cargo check -p ec-av1 --lib`
9+clean, matching the round-start state (262/0 suite, unexercised this round
10+since nothing changed).
11+
12+## What was reached this round (and reverted)
13+
14+`PlaneBuf::data: Vec<u8>` -> `Vec<u16>` (`decode.rs:3428`), `sample_max()`
15+made `pub(crate)` for cross-module reuse, then the checker-driven sweep:
16+
17+- `PlaneBuf::edges`/`edges_rect` return types -> `(Option<Vec<u16>>,
18+ Option<Vec<u16>>, Option<u16>)`.
19+- `PlaneBuf::reconstruct`/`reconstruct_rect`: prediction buffer `vec![0u16;
20+ ..]`, both clamp-and-write sites -> `.clamp(0, sample_max()) as u16`.
21+- `PALETTE_PRED` thread-local widened to `Vec<u16>` (its `colors` source was
22+ already `u16`, this dropped a stale `as u8` truncation).
23+- CDEF's single write-back site (`decode.rs:4687`) -> `sample_max()`/`u16`.
24+- The whole deblock `filter_edge` function (`decode.rs:5121`,
25+ 4/6/8/14-tap taps, ~14 write sites) -> `data: &mut [u16]`, every
26+ `.clamp(0, 255) as u8` -> `.clamp(0, sample_max()) as u16`.
27+- Every `PlaneBuf { data: vec![0u8; ...], ... }` zero-init (key frame, inter
28+ frame, and one more decode entry point — 3 sites) -> `vec![0u16; ...]`.
29+- Reference-frame ingestion (`Picture.y/u/v` -> `PlaneBuf.data`, 6 struct
30+ literals: `reference.{y,u,v}` and the per-slot `g.{y,u,v}` loop) ->
31+ `.iter().map(|&s| s as u16).collect()` (widening in from `Picture`, which
32+ stays `u8` this stage).
33+- The two `PlaneBuf -> Picture` narrowing points (both `y/u/v: y.data, ...`
34+ struct literals) -> `.into_iter().map(|s| s as u8).collect()` (narrowing
35+ out to `Picture`, which stays `u8` this stage — this is the exact site r8's
36+ report named as still open, now closed).
37+- `intra.rs` fully widened end to end: `Edges::build`, `predict`,
38+ `directional`, `dc`, `predict_filter_intra` all take/return `&[u16]`/
39+ `Option<u16>`/`&mut [u16]` now, every `.clamp(0, 255) as u8` (5 sites,
40+ including 2 internal accumulator clamps that were previously untouched)
41+ -> `.clamp(0, crate::decode::sample_max()) as u16`. Its own `#[cfg(test)]`
42+ module (`fill`/`checksum`/the two `predict()` call sites) updated in step;
43+ this file alone type-checked clean in isolation before the wider sweep
44+ continued.
45+
46+That diff (500 lines) is saved at
47+`/tmp/claude-1000/.../scratchpad/r10-attempt.diff` for the next round to
48+replay rather than redo by hand — it is NOT applied to the tree right now.
49+
50+## Exact remaining error clusters (the live checklist, ~35 sites when this
51+round stopped, `cargo check -p ec-av1 --lib` against the PlaneBuf-widened
52+tree)
53+
54+- `crates/ec-av1/src/restoration.rs`'s `apply_loop_restoration_plane` still
55+ takes/returns `Vec<u8>` (`decode.rs:5445/5457/5469`, the 3 call sites that
56+ assign its result into `y.data`/`u.data`/`v.data`) — untouched this round,
57+ not inspected past its signature.
58+- The two remaining debug-dump `write_all(&y.data)` blocks
59+ (`decode.rs:6165-6167` and `12109-12111`, `EC_AV1_PREFILT_DUMP`) and the
60+ `crop_wide`/`crop` closures (`6174`-ish and `6209`/`12151`-ish, both build
61+ a cropped `Vec<u8>` from `plane.data`) still assume `u8` — these are
62+ debug/superres-crop paths, need the same `.iter().map(|&s| s as u8)`
63+ narrowing pattern already used at the two `Picture` literals.
64+- `decode.rs:6520` — `reconstruct_mc`'s own `prediction: &[u8]` param + its
65+ `.clamp(0, 255) as u8` write, the same pattern as `reconstruct`/
66+ `reconstruct_rect` above it, not yet touched.
67+- `decode.rs:6996`/`7071` and `8242` through `10202` (~24 call sites,
68+ `mc::predict`/`predict_with_filter(s)`/`predict_compound_intermediate`/
69+ `combine_compound`/`blend_masked_compound`, plus `interintra_blend`'s own
70+ `pred: &mut [u8]` and its internal `vec![0u8; side*side]` intra buffer at
71+ `~7040`) — `mc.rs` itself (907 lines, `predict`/`predict_with_filter(s)`/
72+ `predict_compound_intermediate`/`combine_compound`/
73+ `blend_masked_compound`, all six still `&[u8]`/`&mut [u8]`) is the one
74+ big remaining piece; the charter's own note that a prior round widened
75+ `mc.rs` alone in ~10 tool calls (using the same `sample_max()` pattern
76+ just proven out in `intra.rs` this round) makes it the right next step —
77+ do it FIRST next round since PlaneBuf is already committed by then and
78+ `cargo check` will point at exactly these call sites.
79+- `crates/ec-av1/src/encode.rs:600/820/872` — three call sites into
80+ `intra::predict`/`predict_filter_intra` from the ENCODER side, not
81+ inventoried by r8 or the charter at all (a new site class this round's
82+ attempt surfaced: the encoder shares `intra.rs` with the decoder, so
83+ widening `intra.rs` fans out into `encode.rs` too, still on `u8` sample
84+ buffers there — untouched, not even read this round; next round needs to
85+ either widen `encode.rs`'s own picture buffers in step or box the u8<->u16
86+ conversion at those three call sites specifically since the encoder isn't
87+ in this charter's scope).
88+- `warp.rs`, `superres.rs` — never reached (errors upstream of them all still
89+ open); charter's own inventory (1 clamp-and-cast site each) is presumably
90+ still accurate but unverified this round.
91+
92+## Why this round stopped short
93+
94+Turn-budget math: intra.rs's full widen (13 signature/body edits across a
95+970-line file) and decode.rs's own ~20-site internal sweep both landed
96+clean and are real, reusable progress — verified by literally getting the
97+error count from 67 to ~35 with `cargo check` as the checklist, exactly as
98+charter directed. What remained (`restoration.rs`, `mc.rs`, the newly
99+discovered `encode.rs` fan-out, two debug-dump closures) was correctly
100+estimated as too large to land AND leave green before the ~turn-55 stop
101+point, so the attempt was reversed rather than committed non-compiling.
102+
103+## Recommendation for r11
104+
105+1. Re-apply `/tmp/claude-1000/.../scratchpad/r10-attempt.diff` (git apply,
106+ not by hand) as the starting point — it is the PlaneBuf widen +
107+ `intra.rs` widen, both proven type-correct in isolation.
108+2. Fix `restoration.rs`'s `apply_loop_restoration_plane` (small, self
109+ contained — likely one function).
110+3. Fix the two debug-dump narrowing closures + `reconstruct_mc`'s clamp
111+ (small, same pattern as everything already done).
112+4. Widen `mc.rs` LAST as the charter said, following the exact pattern this
113+ round proved out in `intra.rs` (`sample_max()`, no other new machinery
114+ needed) — expect ~24 decode.rs call sites to resolve for free once its
115+ six functions take `&[u16]`/`&mut [u16]`.
116+5. New this round: budget a pass over `encode.rs`'s 3 call sites into
117+ `intra.rs` — decide whether the encoder's own picture buffers widen too
118+ (likely no, out of this charter's scope) or whether those 3 sites get a
119+ local u8<->u16 box.
120+6. Run the 262-test suite before committing (per charter); it was NOT run
121+ this round since nothing new landed to test.
122+
123+## Merge note
124+
125+`git status` clean; nothing to merge. No refusal strings touched. `intra.rs`
126+and `decode.rs` are byte-identical to c7b3fa0 (`git apply -R` verified with
127+a clean `cargo check -p ec-av1 --lib`, matching the round-start baseline).
lanes/realworld-r8.report.mdadded+98 -0
@@ -0,0 +1,98 @@
1+VERDICT: Stage 1 partially landed and committed at bd91ad0 (probe + BIT_DEPTH
2+thread-local + dequant call-site threading). The `u16` widening of
3+`PlaneBuf`/prediction buffers (item 2 of the charter) was attempted this round,
4+proved larger than the remaining turn budget, and was REVERTED rather than
5+left half-wired — this is the charter's own explicitly-sanctioned outcome
6+("half-wired is the one unacceptable outcome; incomplete-but-named is fine").
7+
8+## What's landed (bd91ad0, prior round)
9+
10+- Probed both real films: `ReelB...mkv` -> 3840x1608, `yuv420p10le`,
11+ HDR10 mastering-display metadata present; `ReelC...mkv` -> 1920x792,
12+ `yuv420p10le`, bt709. Neither ffmpeg header dump showed film grain. Both
13+ still stop at the `bit_depth != 8` refusal, as expected.
14+- `BIT_DEPTH` thread-local + `sample_max()` helper (decode.rs), set once per
15+ frame from the sequence header's real `color_config.bit_depth` in
16+ `stream.rs`'s decode loop.
17+- The real `bit_depth` threaded into the `dequant_and_inverse_typed*`/`_wh`
18+ call sites that hardcoded `8`.
19+- Refusal is still in place, so behaviour is provably unchanged for every
20+ existing (8-bit) stream — this increment is inert until PlaneBuf is
21+ widened and the refusal comes off.
22+
23+## What was attempted and reverted this round
24+
25+Widened `mc.rs`'s prediction/reference functions (`sample`, `predict`,
26+`predict_with_filter(s)`, `predict_compound_intermediate`, `combine_compound`,
27+`blend_masked_compound`) from `&[u8]`/`&mut [u8]` to `&[u16]`/`&mut [u16]`,
28+clamped against `crate::decode::sample_max()` instead of the literal `255`,
29+and made `sample_max()` `pub(crate)` so `mc.rs` could call it. That much is a
30+clean, self-contained, mechanically-correct sub-step (`mc.rs`'s own unit test
31+was updated in step with it).
32+
33+It does NOT compile standing alone, because `PlaneBuf::data` (decode.rs:3425)
34+— every caller of `mc::predict`/`combine_compound`/etc.'s actual argument
35+type — is still `Vec<u8>`. Starting the PlaneBuf widen (`data: Vec<u16>`)
36+immediately fans out: `edges()` returns `(Option<Vec<u8>>, Option<Vec<u8>>,
37+Option<u8>)` consumed by `intra::predict`, `reconstruct`/`reconstruct_rect`/
38+`reconstruct_mc`/`reconstruct_mc_rect` all take/write `&[u8]`/`u8` and
39+`.clamp(0, 255) as u8`, CDEF and ~14 deblock taps do the same, `warp.rs` and
40+`superres.rs` each have one more clamp-and-cast site, and the final
41+`PlaneBuf -> Picture` conversion needs an explicit `as u8` narrowing added
42+back in (Picture's own `y`/`u`/`v` stay `Vec<u8>` in this stage — lifting
43+that too is stage 2's job, tied to the pixel-format helper `stream.rs`'s own
44+gate needs). `cargo check -p ec-av1 --lib --tests` on the attempt: **34
45+library errors + 40 additional test errors**, all `E0308` mismatched-types /
46+wrong-argument-type from that one root cause (`PlaneBuf::data` untouched)
47+propagating through every call site, plus 2 `u16` vs `u8` comparison errors
48+in existing tests.
49+
50+Given the turn budget remaining when this was discovered (partway through a
51+55-tool-call-deep session), finishing all ~30+ remaining sites blind risked
52+landing exactly the state the charter calls out by name as unacceptable — a
53+compiling-looking but subtly wrong half-widen, or an out-of-budget commit
54+with the crate not compiling at all. Reverted with `git checkout --
55+crates/ec-av1/src/decode.rs crates/ec-av1/src/mc.rs`, back to the clean,
56+green bd91ad0. No uncommitted work lost invisibly: the attempt was stashed
57+first, popped back, inspected, and only then discarded once its scope was
58+confirmed too large for the remaining budget — worth stating plainly rather
59+than silently.
60+
61+## Exact sites still assuming 8 bits (for the next round)
62+
63+- `decode.rs:3425` `PlaneBuf::data: Vec<u8>` — the root type, must go first.
64+- `decode.rs` `PlaneBuf::edges()` (~3472) — returns `(Option<Vec<u8>>,
65+ Option<Vec<u8>>, Option<u8>)`, consumed by `intra::predict`.
66+- `decode.rs` `PlaneBuf::reconstruct`/`reconstruct_rect` and
67+ `reconstruct_mc`/`reconstruct_mc_rect` (~6404 onward) — `prediction: &[u8]`
68+ params, `.clamp(0, 255) as u8` writes (this is the ~30-site sweep the
69+ charter named; 22 `Vec<u8>`/`&[u8]`/`&mut [u8]` occurrences counted in
70+ decode.rs alone this round, plus 4 in `intra.rs`, 1 each in `warp.rs` and
71+ `superres.rs`).
72+- CDEF's own reconstruction write and the ~14 deblock taps (decode.rs,
73+ un-enumerated this round — same `.clamp(0, 255) as u8` pattern, grep it).
74+- `mc.rs` — DONE this round in the attempt (stashed then reverted along with
75+ everything else since it doesn't compile alone); the diff is not preserved
76+ anywhere durable, so the next round redoes this specific file, but it is
77+ the smallest, most mechanical piece and took under 10 tool calls the first
78+ time.
79+- The final `PlaneBuf -> Picture` narrowing point (wherever a finished
80+ `PlaneBuf` is copied into `Picture.y`/`.u`/`.v`) needs an explicit `as u8`
81+ added, since `Picture` itself stays 8-bit output this stage.
82+
83+## Recommendation for the next round
84+
85+Do the PlaneBuf widen (`data: Vec<u16>`) FIRST, in its own commit-sized step,
86+before touching `mc.rs` again — the errors it produces are exactly the map
87+of every remaining site (`cargo check` becomes the sweep's own checklist).
88+Budget the whole stage 1 as its own round with nothing else assigned, since
89+one afternoon's attempt (this round, ~20 tool calls) got through `mc.rs`
90+alone before running short.
91+
92+## Merge note
93+
94+No refusal strings changed this round (the bit_depth refusal from r7 is
95+untouched). `crates/ec-av1/src/decode.rs` and `crates/ec-av1/src/mc.rs` are
96+both back at their bd91ad0 committed content — `git status` clean, nothing
97+new to merge from this session beyond bd91ad0 (already committed) and this
98+report.