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