forge
Explore
Log in

Don't you dare go Hollow

Lane-hbd r3 report -- scoping only, Picture u8/u16 blocker found, no code merged

Browse files at this commit

0e64463518800eb85f72555cf5fd57292d9a2c4dAhmet Kaan GümüşParent: a5e1e2c
  • docs
    • lane-hbd r3 report -- scoping only, Picture u8/u16 blocker found, no code merged
Show full message
docs(av1): lane-hbd r3 report -- scoping only, Picture u8/u16 blocker found, no code merged
lanes/hbd-r3.report.mdadded+119 -0
@@ -0,0 +1,119 @@
1+# lane-hbd r3 report
2+
3+VERDICT: NO CHANGE MERGEABLE -- scoping round only, tree left clean at 8281618, next lane's charter attached below.
4+
5+## What happened
6+
7+This round budgeted 75 turns for "the payoff": a 10-bit reference path, a
8+real 10-bit aomenc gate, lifting the `bit_depth != 8` refusal, then probing
9+the user's own films. Most of the budget went to establishing that the
10+refusal cannot be honestly lifted without widening `encode::Picture` itself
11+-- a materially bigger job than the charter's framing suggested -- and a
12+first attempt at that widen, which does not fit in what was left. No commit
13+was made; `git diff` is empty, worktree is at 8281618 exactly.
14+
15+## The real blocker (not visible from the charter alone)
16+
17+r2 widened every *intermediate* sample buffer (`PlaneBuf`, `mc.rs`,
18+`warp.rs`, the OBMC/interintra chains) to `u16`, but the FINAL narrowing --
19+where a decoded frame becomes an `encode::Picture` -- was untouched, and
20+`Picture.y/u/v` are still `Vec<u8>`. Two places do `s as u8` on the way out
21+(`decode.rs:6823-6825` for key frames, `decode.rs:12594-12596` for inter
22+frames). Widening only the ffmpeg comparison helper (charter step 1) proves
23+nothing on its own: even with a correct 10-bit-precision decode internally,
24+the value that reaches the caller is still an 8-bit truncation, which is
25+exactly the "silent wrongness" the refusal's own doc names. So "lift the
26+refusal properly" (step 3) requires `Picture` to actually carry 10-bit
27+values, not just the reference path to be able to read them.
28+
29+`encode::Picture` is shared between the encoder (its own reconstruction
30+output, `u8`-only by design per r2's explicit decision) and the decoder
31+(`decode_stream`'s return type, and the DPB's own `ref_slots` storage used
32+for inter-frame motion compensation -- `reference: &Picture` is read for MC,
33+not just written at the end, so reference-frame precision matters for
34+correctness on frame 2+, not only for the final comparison). Widening
35+`Picture.y/u/v` to `Vec<u16>` is the natural single-source-of-truth fix and
36+turned out to have a SMALLER encoder blast radius than first feared --
37+production encoder code only touches `Picture` at ~10 sites (`Plane`
38+construction, `pad_plane`/`crop_plane`, `padded_to`, `crop_encoded`), all
39+either genericizable over the element type or a trivial local `as u8`
40+narrow (the encoder never needs anything but `0..=255`). The real size was
41+in test-fixture churn: `cargo check --lib` alone showed 61 errors, dominated
42+by ~50 encoder test-module literal-assignment sites (`picture.y[i] = ... as
43+u8`) that all need `as u16`, plus the two decode.rs narrowing sites, plus
44+whatever `--tests` adds on top (not reached this round). `film_grain.rs` and
45+`superres.rs` are ADDITIONALLY hardcoded to 8-bit math (grain's scaling LUT
46+is `[i32; 256]`, its doc says "specialized to this crate's only picture
47+shape: 8-bit"; superres's `upscale_row` is `&[u8]` with a literal
48+`.clamp(0, 255) as u8`) -- neither is spec-generalizable to 10-bit inside
49+this round's remaining budget, so the honest plan was to lift the BLANKET
50+`bit_depth != 8` refusal but add two NARROWER ones ("film grain on a stream
51+whose bit depth isn't 8", "use_superres on a stream whose bit depth isn't
52+8") guarding those two subsystems specifically, since the core
53+transform/prediction/MC/deblock/CDEF/LR pipeline is otherwise already
54+bit-depth-generic via `decode::BIT_DEPTH` (which is itself dead code right
55+now -- `set_bit_depth` is defined but never called from `stream.rs`; wiring
56+that is also part of the real fix).
57+
58+A first attempt at the `Picture` widen was made (`Picture.y/u/v: Vec<u16>`,
59+`pad_plane`/`crop_plane` genericized over `T: Copy [+ Default]`, the two
60+decode.rs narrowing sites changed to move `PlaneBuf::data` directly instead
61+of `.map(|s| s as u8)`) and got `cargo check -p ec-av1 --lib` down from 61
62+to a smaller but still nonzero error count before the turn budget forced a
63+stop; the attempt was reverted (`git checkout --`) rather than left
64+half-compiling, so the tree stays green at 8281618. The diff is saved for
65+reference at
66+`/home/user/Documents/Code/Rust/edith_codecs-hbd/../..` -- actually at
67+the session scratchpad: `hbd-r3-picture-widen-attempt.diff` (128 lines,
68+2 files: `decode.rs`, `encode.rs`). It is NOT applied to the worktree.
69+
70+## What was NOT reached
71+
72+Steps 1 (ffmpeg 10-bit helper), 2 (real 10-bit aomenc gate), 3 (lift +
73+inventory update), 4 (probe his films) -- none started. No fixture files
74+were extracted, nothing was written to `fixtures/`.
75+
76+## Next lane's charter (hbd-r4)
77+
78+1. Apply (or redo, it's small and now-scoped) the `Picture.y/u/v ->
79+ Vec<u16>` widen: `encode.rs` struct + `pad_plane`/`crop_plane`
80+ genericized (both already attempted, low-risk) + ~10 production
81+ `Plane`-construction/padding call sites (local `as u8`/`as u16` box,
82+ same pattern as r2's `intra_predict_u8`) + the ~50 encoder test-fixture
83+ literal touch-ups (mechanical, `cargo check --lib` then `--tests`
84+ enumerates every one) + `decode.rs`'s two narrowing sites (drop the `as
85+ u8` map, move `PlaneBuf::data` directly).
86+2. Wire `decode::set_bit_depth(seq.color_config.bit_depth)` in `stream.rs`
87+ before the per-frame decode calls -- currently dead code, defaults to 8
88+ always.
89+3. Add two narrow refusals (`film_grain.rs`'s `apply_grain` and
90+ `header.use_superres`, both gated on `bit_depth != 8`) rather than
91+ generalizing their 8-bit-hardcoded math this round -- name them
92+ explicitly in `refusal_inventory.rs`.
93+4. Lift the blanket `bit_depth != 8` refusal in `stream.rs` once (1)-(3)
94+ compile and the existing 264-test 8-bit suite is still green (it should
95+ be structurally: `Vec<u16>` holding `0..=255` compares byte-for-byte
96+ equal in value to the old `Vec<u8>`, only the comparison TYPE changes).
97+5. THEN do the charter's original steps 1/2/3/4: 10-bit ffmpeg reference
98+ helper (u16 LE parse), real `--bit-depth=10 --profile=0` aomenc gate
99+ hard-asserting `bit_depth == 10` from the sequence header before
100+ trusting any pixel match, and only then probe the user's two real films
101+ (`~/Downloads/reelb.mkv`,
102+ `~/Videos/Films/reelc.mkv`) via `ffmpeg -t 3 -c:v copy -f
103+ obu` into this worktree's `fixtures/` + `decode_probe`. Given both films
104+ are HDR10 (film grain is common in HDR masters), expect the probe to hit
105+ the new film-grain-at-10-bit refusal quickly -- record it verbatim with
106+ header state as instructed, that becomes hbd-r5.
107+
108+## Budget
109+
110+Spent essentially the whole 75-turn budget on: reading the charter/r2
111+report, tracing the full narrowing chain (`Picture` shared by encoder+DPB,
112+not just a comparison-helper concern), sizing the blast radius across
113+encode.rs/decode.rs/film_grain.rs/superres.rs, and one partial widen
114+attempt that was reverted rather than left broken. This was a scoping
115+failure on my part, not a budget-external blocker: the charter's own
116+"expect 10-bit to expose rounding" framing undersold that the OUTPUT type
117+itself, not just intermediate clamps, needed widening -- that should have
118+been the very first thing checked (grep `Picture.*Vec<u8>`) before reading
119+deeply into the rest of the pipeline.