R1 handoff -- root cause, 24-frame key-frame table, gate-recipe sweep state
Browse files at this commit9753274781da365f3ddb63668fad6b09b36c92b0Parent: 8a47132- docs
- r1 handoff -- root cause, 24-frame key-frame table, gate-recipe sweep state
1 changed file +122 -0
- lanes/kf900-r1.handoff.md +122 -0
lanes/kf900-r1.handoff.mdadded+122 -0
| @@ -0,0 +1,122 @@ | ||
| 1 | +# lane-kf900 r1 HANDOFF — mid-frame entropy desync on the 4K 10-bit AV1 key frames | |
| 2 | + | |
| 3 | +Tip: `81b16cc` on `lane-kf900` (worktree `/home/user/Documents/Code/Rust/edith_codecs-kf900`, | |
| 4 | +base `18bf7dc` = main tip at start, no rebase needed). | |
| 5 | + | |
| 6 | +## ROOT CAUSE (fixed) | |
| 7 | + | |
| 8 | +`crates/ec-av1/src/decode.rs`, `decode_leaf8` tail — was: | |
| 9 | + | |
| 10 | +```rust | |
| 11 | +neighbours.fill_lf_grid(leaf_mi, 2, 8, 0); // literal block side | |
| 12 | +``` | |
| 13 | + | |
| 14 | +now `neighbours.fill_lf_grid(leaf_mi, 2, resolved as u8, 0);` | |
| 15 | + | |
| 16 | +libaom calls `set_txfm_ctxs(mbmi->tx_size, bw, bh, skip_txfm && is_inter_block(mbmi), xd)` | |
| 17 | +(`decodemv.c`). For an INTRA block that skip term is **always 0**, so a *skipped* 8x8 intra | |
| 18 | +leaf whose `tx_depth` symbol resolved to `TX_4X4` still publishes **4** to the next block's | |
| 19 | +`get_tx_size_context` (`pred_common.h:342`). Our tail wrote **8** for every 8x8 leaf, | |
| 20 | +including the skipped-and-split ones (`decode_leaf8`'s non-skip `resolved == 4` branch had | |
| 21 | +its own early return with the correct 4 — only the skip path fell through to the literal). | |
| 22 | + | |
| 23 | +Consequence: the 8x16 strip below such a leaf computed `tx_size_context_rect` = 2 where | |
| 24 | +libaom computes 1, and read `tx_size_cat1` **row 2** instead of row 1 — same 3-symbol | |
| 25 | +alphabet, wrong CDF row (class `wrong-alphabet-same-value`). The msac range diverged | |
| 26 | +mid-frame, **no refusal**, everything after it garbage. | |
| 27 | + | |
| 28 | +### Evidence chain (all reproducible from `/home/user/.cache/kf900/`) | |
| 29 | +- `s900_1.obu` (1 frame, sha256 `a273ae99328388be14a1ff8fa1c5a6d391a9948159eaef120e1b50e02015eb83`, | |
| 30 | + hashed twice from two independent `ffmpeg -ss 900 -t 2 -c:v copy -f obu` extracts). | |
| 31 | +- Pre-fix first bad luma sample: **row 186 col 1803**, delta 2, max |d| 929, 5405035 luma | |
| 32 | + samples differing. Pre-filter (`EC_AV1_PREFILT_DUMP16` ours vs aomdec) first difference | |
| 33 | + row 192 col 512 → recon, not loop filter. | |
| 34 | +- Cross-decoder block ladder (new `EC_IMODE` rung, mirrors aomdec `decodemv.c:818`): | |
| 35 | + identical for 3543 blocks, first divergence entering mi (60,124). | |
| 36 | +- Symbol ladder (`EC_TRACE_MODE_STEP`, both sides) inside mi (60,122) — a `BLOCK_8X16` | |
| 37 | + (aomdec `bsize=4`): identical through `filter_intra_mode val=0 rng=33750`, then | |
| 38 | + aomdec `tx_depth val=0 ctx=1 cat=1 rng=53206`, ours `ctx=2`. | |
| 39 | +- New `EC_TXCTX` rung: `mi_row=60 mi_col=122 w=8 h=16 above_px=8 left_px=16 ctx=2`; | |
| 40 | + `above_px` should be 4. New `EC_LFGRID` rung: `mi_row=58 mi_col=122 w_mi=2 h_mi=2 | |
| 41 | + tx_px=8` written by the leaf above, which had `skip=1` and `tx_depth val=1` (TX_4X4). | |
| 42 | + | |
| 43 | +## RESULT — 24 key frames, 1-frame truncation each, ours (EC_PROBE_OUT16) vs `ffmpeg -pix_fmt yuv420p10le` | |
| 44 | + | |
| 45 | +`bytes_before` = census4 pre-fix all-plane byte diff; `bytes_after` = same, post-fix; | |
| 46 | +`luma_after` = differing **luma samples** post-fix. Every segment decodes `OK` (no refusal) | |
| 47 | +at 1 frame. Script: `/home/user/.cache/kf900/census.sh`, raw: `/home/user/.cache/kf900/census.tsv`. | |
| 48 | + | |
| 49 | +| -ss | bytes_before | bytes_after | luma_after | | |
| 50 | +|----:|-------------:|------------:|-----------:| | |
| 51 | +| 0 | 0 | 0 | 0 | | |
| 52 | +| 300 | 463 | 463 | 0 | | |
| 53 | +| 600 | 48771 | 0 | 0 | | |
| 54 | +| 900 | 14057195 | 51272 | 0 | | |
| 55 | +| 1200 | 14 | 14 | 0 | | |
| 56 | +| 1500 | 16649701 | 108644 | 0 | | |
| 57 | +| 1800 | 248 | 248 | 0 | | |
| 58 | +| 2100 | 15147518 | 2383 | 0 | | |
| 59 | +| 2400 | 42343 | 0 | 0 | | |
| 60 | +| 2700 | 7726287 | 1243 | 0 | | |
| 61 | +| 3000 | 0 | 0 | 0 | | |
| 62 | +| 3300 | 44500 | 4529 | 0 | | |
| 63 | +| 3600 | 1 | 1 | 0 | | |
| 64 | +| 3900 | 7554020 | 8 | 0 | | |
| 65 | +| 4200 | 0 | 0 | 0 | | |
| 66 | +| 4500 | 0 | 0 | 0 | | |
| 67 | +| 4800 | 2348 | 2348 | 0 | | |
| 68 | +| 5100 | 0 | 0 | 0 | | |
| 69 | +| 5400 | 0 | 0 | 0 | | |
| 70 | +| 5700 | 0 | 0 | 0 | | |
| 71 | +| 6000 | 15450360 | 10207 | 0 | | |
| 72 | +| 6300 | 15410936 | 146881 | 0 | | |
| 73 | +| 6600 | 15181681 | 67588 | 0 | | |
| 74 | +| 6900 | 0 | 0 | 0 | | |
| 75 | + | |
| 76 | +**24/24 luma-exact.** All remaining diffs are chroma-only. | |
| 77 | + | |
| 78 | +## OPEN RESIDUE | |
| 79 | + | |
| 80 | +1. **Chroma-only defect (deferred — needs its own lane).** On `s900_1.obu` after the fix: | |
| 81 | + Y 0, U 266 samples (max |d| 23), V 47927 (max |d| 2). First at chroma (102,688) = | |
| 82 | + luma (204,1376) = mi (51,344). It is **pre-filter** (`pf/ours2.f0` vs `pf/aom.f0`: | |
| 83 | + Y 0, U 228, V 47800 first at chroma row 102 col 689) → chroma *reconstruction*, not a | |
| 84 | + loop filter. Luma being exact proves the entropy stream is exact, so this is a | |
| 85 | + prediction/inverse-transform bug on one chroma path. Unblocked by: an `EC_TRACE_COEFF` | |
| 86 | + plane-1/2 ladder at mi (51,344) — the entropy side is now a fixed reference. | |
| 87 | +2. **The two new gate arms FAIL on their counter assert** (`stream.rs`, after | |
| 88 | + `a_real_aomenc_multi_tile_intra_stream_...`): | |
| 89 | + `a_real_aomenc_stream_with_a_skipped_8x8_intra_leaf_whose_tx_split_decodes_pixel_exact` | |
| 90 | + and its `_10bit_` twin. Both **decode 6/6 attempts pixel-exact**, but | |
| 91 | + `skip_split_tx_hits() == 0` — the shared `gradients_source` at 256x128 never makes | |
| 92 | + aomenc pick a skipped 8x8 intra leaf that also splits its transform (skip wants the | |
| 93 | + residual quantised away, TX_4X4 wants detail; the film has both at 4K). | |
| 94 | + They are committed FAILING on purpose: an assert that never fires is the | |
| 95 | + `tool-disabled-in-every-gate` class, and `skip_split_tx_hits` was `pub` with **zero** | |
| 96 | + callers anywhere before this round. | |
| 97 | + | |
| 98 | +## EXACT NEXT STEP | |
| 99 | + | |
| 100 | +Sweep for a recipe, then keep or replace the assert: | |
| 101 | +`$HOME/.cache/cargo-target-kf900/release/examples/decode_probe <stream.obu>` now prints | |
| 102 | +`skip_split_tx: N` — sweep aomenc without rebuilding the test binary. | |
| 103 | +On the film's own frame it prints **15**, so the counter is correct. | |
| 104 | +Suggested axes (none tried yet): 4K-ish frame sizes (the film's leaves are 8x8 inside 64x64 | |
| 105 | +SBs at 3840 wide), `--cpu-used=0`, `cq-level` 40..58, and a source with fine detail plus | |
| 106 | +flat regions (`mandelbrot`, `testsrc2` + `noise=all_seed=N:alls=20`), 8- and 10-bit arms. | |
| 107 | +**If no recipe reaches it after a measured sweep** (record every attempt), the charter's | |
| 108 | +fallback applies: commit `crates/ec-av1/fixtures/reelb_kf900.obu` (the 484640-byte | |
| 109 | +`/home/user/.cache/kf900/s900_1.obu`, sha256 above) plus a test that decodes it and | |
| 110 | +compares against a **stored sha256 of the ffmpeg output** (do not commit the yuv), and | |
| 111 | +assert `skip_split_tx_hits() >= 15`. | |
| 112 | + | |
| 113 | +Suite: armed detached as user unit `kf900-suite-r1`, log `$HOME/.cache/kf900-suite-r1.log`. | |
| 114 | +Check with `grep -E "^test result|FAILED" $HOME/.cache/kf900-suite-r1.log`. Expect the two | |
| 115 | +new gate arms to be the failures until the recipe lands. | |
| 116 | + | |
| 117 | +## NOT DONE (charter items) | |
| 118 | +- deferred: block-position printing on refusal in `decode_probe` (frame index, mi_row, | |
| 119 | + mi_col, bsize) — not started, ran out of turns; unblocked by ~10 minutes on | |
| 120 | + `decode.rs`'s `unsupported()` call sites. | |
| 121 | +- deferred: `refusal_inventory.rs` / `gate_coverage.rs` updates — this round lifted no | |
| 122 | + refusal, so neither file needed a change; re-check once the gate recipe lands. |