From b80bbd764cb3660e52e9ee773256ea11cede43a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Wed, 2 Sep 2026 09:06:11 +0300 Subject: [PATCH] docs(kf900): r3 report + handoff -- the silent 10-bit desync was the palette colour reader, key-frame census 24/24 bit-exact, suite still running at the cap --- lanes/kf900-r3.handoff.md | 117 ++++++++++++++++++++++++++ lanes/kf900-r3.report.md | 171 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 288 insertions(+) create mode 100644 lanes/kf900-r3.handoff.md create mode 100644 lanes/kf900-r3.report.md diff --git a/lanes/kf900-r3.handoff.md b/lanes/kf900-r3.handoff.md new file mode 100644 index 00000000..cd1b6943 --- /dev/null +++ b/lanes/kf900-r3.handoff.md @@ -0,0 +1,117 @@ +# lane-kf900 r3 HANDOFF + +Tip: see `git log --oneline -3 lane-kf900` (merge `4267082`, fix+gate `667eb51`, this +commit). Worktree `/home/user/Documents/Code/Rust/edith_codecs-kf900`, base `18bf7dc`, +merged main `8e9ba81`. Full detail in `lanes/kf900-r3.report.md`. + +## 1. The silent 10-bit desync -- ROOT CAUSE FOUND AND FIXED + +Stream: `testsrc2=s=256x192 --bit-depth=10 --cq-level=59 --cpu-used=0`, recipe +`$HOME/.cache/kf900/sweep/sweep.sh`, md5 `e5f033d8fe34e4418d8cca3ac9d2b595` +(`$HOME/.cache/kf900/sweep/g.obu`). + +Symbol: the FIRST block's Y palette colours. mi(0,0) is BLOCK_32X16, DC_PRED, +2-colour Y palette. `decode.rs::read_palette_colors_y` / `read_palette_colors_uv` +read every raw literal at a hardcoded 8 bits; libaom `decodemv.c:478` (Y) and +`:509` (UV) size them all by the sequence `bit_depth`: first colour +`aom_read_literal(r, bit_depth)`, `min_bits = bit_depth - 3` (Y/U) and +`bit_depth - 4` (V delta mode), `range = (1 << bit_depth) - first - 1` (Y) / +`- first` (U), clamp bound `(1 << bit_depth) - 1`, V wrap modulus `1 << bit_depth`. +So a 10-bit palette block read TWO BITS TOO FEW per transmitted colour and decoded +the whole rest of the tile from the wrong bit position, with no refusal. + +Fix (commit `667eb51`): `let bd = u32::from(bit_depth());` (the already-present +thread-local, decode.rs:200) inside both readers; no signature threading. + +Before: `OK: 1 frames decoded` with 73687/73728 samples differing from ffmpeg, +max |d| 933 (Y 49117/49152, U 12286/12288, V 12284/12288, first diff at (0,0)). +After: the entropy stream is in lockstep with aomdec -- our first 1024 +`EC_PAL`/`EC_PAL_VAL` lines are byte-identical to aomdec's `EC_TRACE_PALETTE`, and +the block grid follows aomdec's (`EC_IMODE` mi(0,0) 32x16, (4,0) 16x16, (4,4) 16x16, +(0,8) 32x8, (2,8) 32x8, (4,8) 32x8 == aomdec bsize 8,6,6,19,19,19). + +WHY 108 SWEEP RECIPES AND A RANGE LADDER MISSED IT: raw literals are EQUIPROBABLE +and at the ranges this content reaches an equiprobable read is a FIXED POINT of the +msac range (62728 -> v=31364, either branch 31364, renorm 62728). A cross-decoder +RANGE ladder stays bit-identical straight through a wrong literal WIDTH; only the +decoded VALUE moves. aomdec and we both printed `rng=62728` and disagreed on the +first colour index (0 vs 1). Compare VALUES, not range alone. + +This stream is NOT a whole-frame gate: at mi(4,8) it hits a 32x8 (4:1) strip that +really uses a palette, and the 1:4 rect decoder is called with `palette: None` +(decode.rs:7167 and :7556), so it now stops at the pre-existing refusal +`"a 1:4 rect strip that actually uses a palette (reconstruction is not ported at +this shape)"`. Silent desync -> named refusal. + +## 2. The chroma residual at mi(97,320) -- GONE, and not by my fix + +r2's first remaining chroma difference on the s=900 4K key frame -- chroma (195,640) += mi(97,320) -- is ZERO on the merged tree. No ladder was needed: the census (below) +came back clean. Credit is the merged lane-reelckf `55532c7` (skipped CfL blocks still +predict; the 1:4 chroma pair edge-filter mi), NOT the palette fix -- the film frame +reads zero palette symbols +(`EC_AV1_TRACE=1 decode_probe crates/ec-av1/fixtures/reelb_kf900.obu | grep -c "^EC_PAL "` += 0). + +The charter's chroma-`tx_type` suspicion was audited and cleared rather than needed: +`av1_get_tx_type`'s `plane > 0` intra path is `intra_mode_to_tx_type(mbmi, +PLANE_TYPE_UV)` = our `default_intra_tx_type` (decode.rs:3229) fed with +`uv_predict_mode`, which already maps `UV_CFL_PRED` -> `DC_PRED`; the +`!av1_ext_tx_used[tx_set_type][tx_type]` narrowing can only bite at +`txsize_sqr_up >= TX_32X32`, and both chroma call sites already force `DCT_DCT` +there (decode.rs:6089 `chroma_w.max(chroma_h) >= 32`, decode.rs:9254 `side >= 32`). +All four values the table can produce are members of `EXT_TX_SET_DTT4_IDTX` and +`..._1DDCT`, the only two intra sets below 32. + +## 3. Census -- 24/24 BIT-EXACT (was 15/24 at r2) + +`$HOME/.cache/kf900/census_r3.sh` -> `$HOME/.cache/kf900/census_r3.tsv`: all 24 +key frames decode `OK: 1 frames decoded, 3840x1608` with Y=U=V=0 differing samples +and max |d| 0/0/0. Full table in the report. + +## 4. Gate state + +NEW, committed, PASSING: +`crates/ec-av1/src/stream.rs::a_real_aomenc_palette_stream_decodes_pixel_exact_at_8_and_10_bit` +-- the existing 8-bit `..._with_palette_y_...` recipe (smptebars 64x64, +`--tune-content=screen --enable-palette=1`, rect/AB/1:4 off) with the depth as the +only variable (depth flags appended AFTER the base recipe: last flag wins). Each arm +hard-asserts `decode::palette_hits()` moved and compares Y, U and V vs ffmpeg. +`cargo test -p ec-av1 --lib palette_stream_decodes_pixel_exact_at_8_and_10` -> 1 +passed, 0 failed. DISCRIMINATION CHECK RUN: with `let bd = u32::from(bit_depth())` +reverted to `let bd = 8u32` the test FAILS on "luma at 10-bit" and the 8-bit arm +still passes (tree restored from a scratch copy afterwards). + +No refusal was lifted this round, so `refusal_inventory.rs` / `gate_coverage.rs` are +untouched (byte-identical to main's). + +Class sweep for the same shape (bit-depth-scaled reader hardcoding 8): +`grep -n "literal(8)\|255i32\|, 255)\|(1 << 8)" crates/ec-av1/src/decode.rs` -> only +the qindex clamps at :332 and :544 survive, and those are correct at every depth. +No sibling instances. + +## 5. Suite state -- INCOMPLETE, ZERO FAILURES SO FAR + +`systemd-run --user --unit=kf900-suite-r3-1788328486 -p MemoryMax=10G ... cargo test +-p ec-av1 --lib -j3 > $HOME/.cache/kf900-suite-r3.log`. At the turn cap: **272 `ok`, +0 `FAILED`, no `test result` line yet**. Resolve the unit name with +`systemctl --user list-units --all | grep kf900` before believing it finished. + +## 6. EXACT NEXT STEP + +1. `grep -E "^test result|FAILED" $HOME/.cache/kf900-suite-r3.log` -- expect + `374 passed; 0 failed` (373 at r2 + the new depth gate). If a `FAILED` appears, + the only behavioural change on this branch is the palette bit-depth widening, so + look at the three existing palette gates first + (`a_real_aomenc_stream_with_palette_y_...`, `..._palette_uv_...`, + `..._rect_palette_...`, `a_real_aomenc_multi_tile_palette_stream_...`). +2. Merge into main. +3. Then the open lane work, in this order: + a. Tighten `..._skipped_8x8_intra_leaves_that_split_their_transform_decodes_luma_exact` + from luma-only to all three planes -- the census is 24/24 exact now, so its U/V + arms should hold. + b. Port palette reconstruction to the 1:4 rect decoder (decode.rs:7167 and :7556 + pass `palette: None`); that is the ONLY thing between us and a whole-frame + pixel gate for `skip_split_tx` on the pinned 10-bit stream above. Probably + lane-palette2's territory. + c. Carry-over: block-position printing on refusal in `decode_probe`. diff --git a/lanes/kf900-r3.report.md b/lanes/kf900-r3.report.md new file mode 100644 index 00000000..1f9b3a69 --- /dev/null +++ b/lanes/kf900-r3.report.md @@ -0,0 +1,171 @@ +# lane-kf900 r3 -- the silent 10-bit desync was the palette colour reader + +Tip: `667eb51`+ on `lane-kf900` (worktree `/home/user/Documents/Code/Rust/edith_codecs-kf900`), +base `18bf7dc`, merged main `8e9ba81` (lane-reelckf `55532c7`). + +## 1. Merge (charter item 1) + +`git merge --no-commit main` -> clean, no conflicts (commit `4267082`). Both +chroma-reference-mi fixes kept: lane-reelckf passes `pair_mi` at the sub-8 +`smooth_uv_neighbour` call site (decode.rs:7778), r2's own snap +`let (mi_r, mi_c) = (mi_r & !1, mi_c & !1);` lives inside the function +(decode.rs:4662) -- idempotent together, re-read to confirm. +`cdf.rs`, `cdf_state.rs`, `mvstack.rs`, `refusal_inventory.rs`, +`gate_coverage.rs` byte-compare SAME as `main:`'s copies (sha256 of each). + +## 2. The silent 10-bit desync -- ROOT CAUSE, fixed and gated (charter item 2) + +`decode.rs::read_palette_colors_y` / `read_palette_colors_uv` read every raw +literal at a **hardcoded 8 bits**. libaom `decodemv.c:478`/`:509` size all of +them by the sequence `bit_depth`: + +* first colour = `aom_read_literal(r, bit_depth)` +* `min_bits = bit_depth - 3` (Y and U), `bit_depth - 4` (V delta mode) +* `range = (1 << bit_depth) - first - 1` (Y) / `- first` (U) +* clamp bound `(1 << bit_depth) - 1`, V wrap modulus `1 << bit_depth` + +so a 10-bit palette block read **two bits too few per transmitted colour** and +decoded the whole remainder of the tile from the wrong bit position, with no +refusal. Fixed by taking the already-present thread-local `bit_depth()` inside +both readers (no signature threading). + +### Why 108 gate recipes and a range ladder could not see it + +Raw literals are EQUIPROBABLE, and at the ranges this content reaches an +equiprobable read is a FIXED POINT of the msac range: 62728 -> v = 31364, +either branch leaves 31364, renormalised back to 62728. A cross-decoder RANGE +ladder therefore stays bit-identical straight through the miscount and only +the decoded VALUE moves. That is the blind spot of the `compare-range-not-tell` +method, and it is why this stream reported `OK: 1 frames decoded` with +73687/73728 samples wrong. + +### The pin + +`testsrc2=s=256x192 --bit-depth=10 --cq-level=59 --cpu-used=0` (recipe +`$HOME/.cache/kf900/sweep/sweep.sh`, stream md5 +`e5f033d8fe34e4418d8cca3ac9d2b595`). Its first block is mi(0,0) BLOCK_32X16, +DC_PRED, with a real 2-colour Y palette. + +* before: `EC_PAL row=0 col=0 ctx=-1 n=2 rng=62728` on BOTH decoders, then + aomdec `color_idx=0`, ours `color_idx=1` -- identical range, opposite value. +* after: our first 1024 `EC_PAL`/`EC_PAL_VAL` lines are **byte-identical** to + aomdec's, and the block grid follows aomdec's for the rest of the frame + (`EC_IMODE` mi(0,0) 32x16, mi(4,0) 16x16, mi(4,4) 16x16, mi(0,8) 32x8, + mi(2,8) 32x8, mi(4,8) 32x8 == aomdec bsize 8,6,6,19,19,19). + +EVIDENCE: $HOME/.cache/kf900/r3/{ours.pal,aom.pal} | EC_AV1_TRACE on +decode_probe vs EC_TRACE_PALETTE on the instrumented aomdec over the pinned +stream | `diff <(head -1024 ours.pal) <(head -1024 aom.pal)` empty; before the +fix the two disagreed on the first colour index at an identical range + +That stream is NOT a whole-frame gate: at mi(4,8) it hits a 32x8 (4:1) strip +that really uses a palette, and the 1:4 rect decoder is called with +`palette: None` (decode.rs:7167/7556), so it now stops at the existing refusal +`"a 1:4 rect strip that actually uses a palette (reconstruction is not ported +at this shape)"`. Silent desync -> named refusal is itself the honest outcome; +the pixel gate is a different recipe: + +### Gate + +`stream.rs::a_real_aomenc_palette_stream_decodes_pixel_exact_at_8_and_10_bit` +-- the existing 8-bit `..._with_palette_y_...` recipe (smptebars 64x64, +`--tune-content=screen --enable-palette=1`, all rect/AB/1:4 off) with the +depth as the ONLY variable (depth flags appended AFTER the base recipe, per +the last-flag-wins rule). Each arm hard-asserts `decode::palette_hits()` moved +and compares Y, U and V against ffmpeg's decode of the same bytes. + +EVIDENCE: crates/ec-av1/src/stream.rs | `cargo test -p ec-av1 --lib +palette_stream_decodes_pixel_exact_at_8_and_10` | 1 passed / 0 failed; with +`let bd = u32::from(bit_depth())` reverted to `let bd = 8u32` the same test +FAILS on "luma at 10-bit" and the 8-bit arm still passes (discrimination check +run, tree restored from a scratch copy) + +Class sweep for the same shape (a bit-depth-scaled reader hardcoding 8): +`grep -n "literal(8)\|255i32\|, 255)\|(1 << 8)" decode.rs` -> the only two +survivors are the qindex clamps at decode.rs:332 and :544, which are correct +(qindex is 0..255 at every bit depth). No sibling instances. + +## 3. Chroma residual on the 4K 10-bit key frame (charter item 3) -- GONE + +r2's open residue (first chroma difference at (195,640) = mi(97,320)) is zero +on the merged tree. It is NOT my palette fix: the film frame reads **zero** +palette symbols (`EC_AV1_TRACE ... | grep -c "^EC_PAL "` = 0 on +`crates/ec-av1/fixtures/reelb_kf900.obu`), so the credit belongs to the merged +lane-reelckf commits (skipped CfL blocks still predict; the 1:4 chroma pair +edge-filter mi). + +The chroma `tx_type` suspicion from the charter was audited and cleared rather +than needed: `av1_get_tx_type`'s `plane > 0` intra path is +`intra_mode_to_tx_type(mbmi, PLANE_TYPE_UV)` (our `default_intra_tx_type`, +decode.rs:3229) fed with `uv_predict_mode`, which already maps `UV_CFL_PRED` +to `DC_PRED`; the `!av1_ext_tx_used[tx_set_type][tx_type]` narrowing can only +bite at `txsize_sqr_up >= TX_32X32`, and both chroma call sites already force +`DCT_DCT` there (decode.rs:6089 `chroma_w.max(chroma_h) >= 32`, decode.rs:9254 +`side >= 32`). Every value the table can produce is a member of +`EXT_TX_SET_DTT4_IDTX` and `..._1DDCT`, the only two intra sets below 32. + +## 4. 24-key-frame census on the merged tree (charter item 4) + +Recipe `$HOME/.cache/kf900/census_r3.sh` (r2's script, own `c3/` scratch and +`census_r3.tsv`): `ffmpeg -ss -t 2 -c:v copy -f obu`, truncated to one +frame, `EC_PROBE_OUT16` vs `ffmpeg -pix_fmt yuv420p10le`, per-plane DIFFERING +SAMPLES. + +| -ss | Y | U | V | max Y/U/V | r2 U | r2 V | +|----:|--:|--:|--:|:---------|-----:|-----:| +| 0 | 0 | 0 | 0 | 0/0/0 | 0 | 0 | +| 300 | 0 | 0 | 0 | 0/0/0 | 219 | 220 | +| 600 | 0 | 0 | 0 | 0/0/0 | 0 | 0 | +| 900 | 0 | 0 | 0 | 0/0/0 | 221 | 47912 | +| 1200 | 0 | 0 | 0 | 0/0/0 | 0 | 0 | +| 1500 | 0 | 0 | 0 | 0/0/0 | 0 | 0 | +| 1800 | 0 | 0 | 0 | 0/0/0 | 0 | 0 | +| 2100 | 0 | 0 | 0 | 0/0/0 | 1041 | 1008 | +| 2400 | 0 | 0 | 0 | 0/0/0 | 0 | 0 | +| 2700 | 0 | 0 | 0 | 0/0/0 | 442 | 800 | +| 3000 | 0 | 0 | 0 | 0/0/0 | 0 | 0 | +| 3300 | 0 | 0 | 0 | 0/0/0 | 0 | 0 | +| 3600 | 0 | 0 | 0 | 0/0/0 | 0 | 0 | +| 3900 | 0 | 0 | 0 | 0/0/0 | 4 | 4 | +| 4200 | 0 | 0 | 0 | 0/0/0 | 0 | 0 | +| 4500 | 0 | 0 | 0 | 0/0/0 | 0 | 0 | +| 4800 | 0 | 0 | 0 | 0/0/0 | 2316 | 5 | +| 5100 | 0 | 0 | 0 | 0/0/0 | 0 | 0 | +| 5400 | 0 | 0 | 0 | 0/0/0 | 0 | 0 | +| 5700 | 0 | 0 | 0 | 0/0/0 | 0 | 0 | +| 6000 | 0 | 0 | 0 | 0/0/0 | 210 | 0 | +| 6300 | 0 | 0 | 0 | 0/0/0 | 145195 | 0 | +| 6600 | 0 | 0 | 0 | 0/0/0 | 30873 | 897 | +| 6900 | 0 | 0 | 0 | 0/0/0 | 0 | 0 | + +**24/24 key frames now decode BIT-EXACT on all three planes** (r2: 15/24). +Every decode reported `OK: 1 frames decoded, 3840x1608`. + +EVIDENCE: $HOME/.cache/kf900/census_r3.tsv | 24 x (extract 2 s, truncate to 1 +frame, decode ours + ffmpeg, per-plane compare) | Y/U/V all 0 on all 24 rows + +## 5. Suite (charter item 5) + +`systemd-run --user --unit=kf900-suite-r3-... -p MemoryMax=10G ... cargo test +-p ec-av1 --lib -j3` -> `$HOME/.cache/kf900-suite-r3.log`: +**still running at the turn cap** -- 272 `ok`, 0 `FAILED` at the last poll, no `test result` line yet (unit `kf900-suite-r3-1788328486.service`). See the handoff. + +## Residue + +1. **deferred: a whole-frame pixel gate for `skip_split_tx`** -- the only + aomenc recipe found (of 108 + this round's) that fires the counter is the + pinned 10-bit `testsrc2` stream, and it now stops at the 1:4-rect-palette + refusal. Unblocked by porting palette reconstruction to the 1:4 rect + decoder (decode.rs:7167/7556 pass `palette: None`) -- lane-palette2's + territory, not a kf900 defect. The fixture gate + `..._skipped_8x8_intra_leaves_that_split_their_transform_decodes_luma_exact` + still pins the counter at 15 and now compares luma only by construction; + with the census at 24/24 its U/V arms could be tightened next round. +2. **deferred (r1/r2 carry-over): block-position printing on refusal in + `decode_probe`**, plus `refusal_inventory.rs` / `gate_coverage.rs` updates + -- this round lifted no refusal (it turned a silent desync into an existing + named one), so neither file changed. Unblocked by ~10 min on `decode.rs`'s + `unsupported()` call sites. +3. **accepted: the pinned 10-bit palette stream is not committed as a fixture** + -- it is reproducible from `sweep.sh` and its md5 is recorded here; the + committed gate builds its own stream from aomenc at test time.