forge
Explore
Log in

Don't you dare go Hollow

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

Browse files at this commit

b80bbd764cb3660e52e9ee773256ea11cede43a9Ahmet Kaan GümüşParent: 769ba67
  • docs
    • 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
Show full message
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.mdadded+117 -0
@@ -0,0 +1,117 @@
1+# lane-kf900 r3 HANDOFF
2+
3+Tip: see `git log --oneline -3 lane-kf900` (merge `4267082`, fix+gate `667eb51`, this
4+commit). Worktree `/home/user/Documents/Code/Rust/edith_codecs-kf900`, base `18bf7dc`,
5+merged main `8e9ba81`. Full detail in `lanes/kf900-r3.report.md`.
6+
7+## 1. The silent 10-bit desync -- ROOT CAUSE FOUND AND FIXED
8+
9+Stream: `testsrc2=s=256x192 --bit-depth=10 --cq-level=59 --cpu-used=0`, recipe
10+`$HOME/.cache/kf900/sweep/sweep.sh`, md5 `e5f033d8fe34e4418d8cca3ac9d2b595`
11+(`$HOME/.cache/kf900/sweep/g.obu`).
12+
13+Symbol: the FIRST block's Y palette colours. mi(0,0) is BLOCK_32X16, DC_PRED,
14+2-colour Y palette. `decode.rs::read_palette_colors_y` / `read_palette_colors_uv`
15+read every raw literal at a hardcoded 8 bits; libaom `decodemv.c:478` (Y) and
16+`:509` (UV) size them all by the sequence `bit_depth`: first colour
17+`aom_read_literal(r, bit_depth)`, `min_bits = bit_depth - 3` (Y/U) and
18+`bit_depth - 4` (V delta mode), `range = (1 << bit_depth) - first - 1` (Y) /
19+`- first` (U), clamp bound `(1 << bit_depth) - 1`, V wrap modulus `1 << bit_depth`.
20+So a 10-bit palette block read TWO BITS TOO FEW per transmitted colour and decoded
21+the whole rest of the tile from the wrong bit position, with no refusal.
22+
23+Fix (commit `667eb51`): `let bd = u32::from(bit_depth());` (the already-present
24+thread-local, decode.rs:200) inside both readers; no signature threading.
25+
26+Before: `OK: 1 frames decoded` with 73687/73728 samples differing from ffmpeg,
27+max |d| 933 (Y 49117/49152, U 12286/12288, V 12284/12288, first diff at (0,0)).
28+After: the entropy stream is in lockstep with aomdec -- our first 1024
29+`EC_PAL`/`EC_PAL_VAL` lines are byte-identical to aomdec's `EC_TRACE_PALETTE`, and
30+the block grid follows aomdec's (`EC_IMODE` mi(0,0) 32x16, (4,0) 16x16, (4,4) 16x16,
31+(0,8) 32x8, (2,8) 32x8, (4,8) 32x8 == aomdec bsize 8,6,6,19,19,19).
32+
33+WHY 108 SWEEP RECIPES AND A RANGE LADDER MISSED IT: raw literals are EQUIPROBABLE
34+and at the ranges this content reaches an equiprobable read is a FIXED POINT of the
35+msac range (62728 -> v=31364, either branch 31364, renorm 62728). A cross-decoder
36+RANGE ladder stays bit-identical straight through a wrong literal WIDTH; only the
37+decoded VALUE moves. aomdec and we both printed `rng=62728` and disagreed on the
38+first colour index (0 vs 1). Compare VALUES, not range alone.
39+
40+This stream is NOT a whole-frame gate: at mi(4,8) it hits a 32x8 (4:1) strip that
41+really uses a palette, and the 1:4 rect decoder is called with `palette: None`
42+(decode.rs:7167 and :7556), so it now stops at the pre-existing refusal
43+`"a 1:4 rect strip that actually uses a palette (reconstruction is not ported at
44+this shape)"`. Silent desync -> named refusal.
45+
46+## 2. The chroma residual at mi(97,320) -- GONE, and not by my fix
47+
48+r2's first remaining chroma difference on the s=900 4K key frame -- chroma (195,640)
49+= mi(97,320) -- is ZERO on the merged tree. No ladder was needed: the census (below)
50+came back clean. Credit is the merged lane-reelckf `55532c7` (skipped CfL blocks still
51+predict; the 1:4 chroma pair edge-filter mi), NOT the palette fix -- the film frame
52+reads zero palette symbols
53+(`EC_AV1_TRACE=1 decode_probe crates/ec-av1/fixtures/reelb_kf900.obu | grep -c "^EC_PAL "`
54+= 0).
55+
56+The charter's chroma-`tx_type` suspicion was audited and cleared rather than needed:
57+`av1_get_tx_type`'s `plane > 0` intra path is `intra_mode_to_tx_type(mbmi,
58+PLANE_TYPE_UV)` = our `default_intra_tx_type` (decode.rs:3229) fed with
59+`uv_predict_mode`, which already maps `UV_CFL_PRED` -> `DC_PRED`; the
60+`!av1_ext_tx_used[tx_set_type][tx_type]` narrowing can only bite at
61+`txsize_sqr_up >= TX_32X32`, and both chroma call sites already force `DCT_DCT`
62+there (decode.rs:6089 `chroma_w.max(chroma_h) >= 32`, decode.rs:9254 `side >= 32`).
63+All four values the table can produce are members of `EXT_TX_SET_DTT4_IDTX` and
64+`..._1DDCT`, the only two intra sets below 32.
65+
66+## 3. Census -- 24/24 BIT-EXACT (was 15/24 at r2)
67+
68+`$HOME/.cache/kf900/census_r3.sh` -> `$HOME/.cache/kf900/census_r3.tsv`: all 24
69+key frames decode `OK: 1 frames decoded, 3840x1608` with Y=U=V=0 differing samples
70+and max |d| 0/0/0. Full table in the report.
71+
72+## 4. Gate state
73+
74+NEW, committed, PASSING:
75+`crates/ec-av1/src/stream.rs::a_real_aomenc_palette_stream_decodes_pixel_exact_at_8_and_10_bit`
76+-- the existing 8-bit `..._with_palette_y_...` recipe (smptebars 64x64,
77+`--tune-content=screen --enable-palette=1`, rect/AB/1:4 off) with the depth as the
78+only variable (depth flags appended AFTER the base recipe: last flag wins). Each arm
79+hard-asserts `decode::palette_hits()` moved and compares Y, U and V vs ffmpeg.
80+`cargo test -p ec-av1 --lib palette_stream_decodes_pixel_exact_at_8_and_10` -> 1
81+passed, 0 failed. DISCRIMINATION CHECK RUN: with `let bd = u32::from(bit_depth())`
82+reverted to `let bd = 8u32` the test FAILS on "luma at 10-bit" and the 8-bit arm
83+still passes (tree restored from a scratch copy afterwards).
84+
85+No refusal was lifted this round, so `refusal_inventory.rs` / `gate_coverage.rs` are
86+untouched (byte-identical to main's).
87+
88+Class sweep for the same shape (bit-depth-scaled reader hardcoding 8):
89+`grep -n "literal(8)\|255i32\|, 255)\|(1 << 8)" crates/ec-av1/src/decode.rs` -> only
90+the qindex clamps at :332 and :544 survive, and those are correct at every depth.
91+No sibling instances.
92+
93+## 5. Suite state -- INCOMPLETE, ZERO FAILURES SO FAR
94+
95+`systemd-run --user --unit=kf900-suite-r3-1788328486 -p MemoryMax=10G ... cargo test
96+-p ec-av1 --lib -j3 > $HOME/.cache/kf900-suite-r3.log`. At the turn cap: **272 `ok`,
97+0 `FAILED`, no `test result` line yet**. Resolve the unit name with
98+`systemctl --user list-units --all | grep kf900` before believing it finished.
99+
100+## 6. EXACT NEXT STEP
101+
102+1. `grep -E "^test result|FAILED" $HOME/.cache/kf900-suite-r3.log` -- expect
103+ `374 passed; 0 failed` (373 at r2 + the new depth gate). If a `FAILED` appears,
104+ the only behavioural change on this branch is the palette bit-depth widening, so
105+ look at the three existing palette gates first
106+ (`a_real_aomenc_stream_with_palette_y_...`, `..._palette_uv_...`,
107+ `..._rect_palette_...`, `a_real_aomenc_multi_tile_palette_stream_...`).
108+2. Merge into main.
109+3. Then the open lane work, in this order:
110+ a. Tighten `..._skipped_8x8_intra_leaves_that_split_their_transform_decodes_luma_exact`
111+ from luma-only to all three planes -- the census is 24/24 exact now, so its U/V
112+ arms should hold.
113+ b. Port palette reconstruction to the 1:4 rect decoder (decode.rs:7167 and :7556
114+ pass `palette: None`); that is the ONLY thing between us and a whole-frame
115+ pixel gate for `skip_split_tx` on the pinned 10-bit stream above. Probably
116+ lane-palette2's territory.
117+ c. Carry-over: block-position printing on refusal in `decode_probe`.
lanes/kf900-r3.report.mdadded+171 -0
@@ -0,0 +1,171 @@
1+# lane-kf900 r3 -- the silent 10-bit desync was the palette colour reader
2+
3+Tip: `667eb51`+ on `lane-kf900` (worktree `/home/user/Documents/Code/Rust/edith_codecs-kf900`),
4+base `18bf7dc`, merged main `8e9ba81` (lane-reelckf `55532c7`).
5+
6+## 1. Merge (charter item 1)
7+
8+`git merge --no-commit main` -> clean, no conflicts (commit `4267082`). Both
9+chroma-reference-mi fixes kept: lane-reelckf passes `pair_mi` at the sub-8
10+`smooth_uv_neighbour` call site (decode.rs:7778), r2's own snap
11+`let (mi_r, mi_c) = (mi_r & !1, mi_c & !1);` lives inside the function
12+(decode.rs:4662) -- idempotent together, re-read to confirm.
13+`cdf.rs`, `cdf_state.rs`, `mvstack.rs`, `refusal_inventory.rs`,
14+`gate_coverage.rs` byte-compare SAME as `main:`'s copies (sha256 of each).
15+
16+## 2. The silent 10-bit desync -- ROOT CAUSE, fixed and gated (charter item 2)
17+
18+`decode.rs::read_palette_colors_y` / `read_palette_colors_uv` read every raw
19+literal at a **hardcoded 8 bits**. libaom `decodemv.c:478`/`:509` size all of
20+them by the sequence `bit_depth`:
21+
22+* first colour = `aom_read_literal(r, bit_depth)`
23+* `min_bits = bit_depth - 3` (Y and U), `bit_depth - 4` (V delta mode)
24+* `range = (1 << bit_depth) - first - 1` (Y) / `- first` (U)
25+* clamp bound `(1 << bit_depth) - 1`, V wrap modulus `1 << bit_depth`
26+
27+so a 10-bit palette block read **two bits too few per transmitted colour** and
28+decoded the whole remainder of the tile from the wrong bit position, with no
29+refusal. Fixed by taking the already-present thread-local `bit_depth()` inside
30+both readers (no signature threading).
31+
32+### Why 108 gate recipes and a range ladder could not see it
33+
34+Raw literals are EQUIPROBABLE, and at the ranges this content reaches an
35+equiprobable read is a FIXED POINT of the msac range: 62728 -> v = 31364,
36+either branch leaves 31364, renormalised back to 62728. A cross-decoder RANGE
37+ladder therefore stays bit-identical straight through the miscount and only
38+the decoded VALUE moves. That is the blind spot of the `compare-range-not-tell`
39+method, and it is why this stream reported `OK: 1 frames decoded` with
40+73687/73728 samples wrong.
41+
42+### The pin
43+
44+`testsrc2=s=256x192 --bit-depth=10 --cq-level=59 --cpu-used=0` (recipe
45+`$HOME/.cache/kf900/sweep/sweep.sh`, stream md5
46+`e5f033d8fe34e4418d8cca3ac9d2b595`). Its first block is mi(0,0) BLOCK_32X16,
47+DC_PRED, with a real 2-colour Y palette.
48+
49+* before: `EC_PAL row=0 col=0 ctx=-1 n=2 rng=62728` on BOTH decoders, then
50+ aomdec `color_idx=0`, ours `color_idx=1` -- identical range, opposite value.
51+* after: our first 1024 `EC_PAL`/`EC_PAL_VAL` lines are **byte-identical** to
52+ aomdec's, and the block grid follows aomdec's for the rest of the frame
53+ (`EC_IMODE` mi(0,0) 32x16, mi(4,0) 16x16, mi(4,4) 16x16, mi(0,8) 32x8,
54+ mi(2,8) 32x8, mi(4,8) 32x8 == aomdec bsize 8,6,6,19,19,19).
55+
56+EVIDENCE: $HOME/.cache/kf900/r3/{ours.pal,aom.pal} | EC_AV1_TRACE on
57+decode_probe vs EC_TRACE_PALETTE on the instrumented aomdec over the pinned
58+stream | `diff <(head -1024 ours.pal) <(head -1024 aom.pal)` empty; before the
59+fix the two disagreed on the first colour index at an identical range
60+
61+That stream is NOT a whole-frame gate: at mi(4,8) it hits a 32x8 (4:1) strip
62+that really uses a palette, and the 1:4 rect decoder is called with
63+`palette: None` (decode.rs:7167/7556), so it now stops at the existing refusal
64+`"a 1:4 rect strip that actually uses a palette (reconstruction is not ported
65+at this shape)"`. Silent desync -> named refusal is itself the honest outcome;
66+the pixel gate is a different recipe:
67+
68+### Gate
69+
70+`stream.rs::a_real_aomenc_palette_stream_decodes_pixel_exact_at_8_and_10_bit`
71+-- the existing 8-bit `..._with_palette_y_...` recipe (smptebars 64x64,
72+`--tune-content=screen --enable-palette=1`, all rect/AB/1:4 off) with the
73+depth as the ONLY variable (depth flags appended AFTER the base recipe, per
74+the last-flag-wins rule). Each arm hard-asserts `decode::palette_hits()` moved
75+and compares Y, U and V against ffmpeg's decode of the same bytes.
76+
77+EVIDENCE: crates/ec-av1/src/stream.rs | `cargo test -p ec-av1 --lib
78+palette_stream_decodes_pixel_exact_at_8_and_10` | 1 passed / 0 failed; with
79+`let bd = u32::from(bit_depth())` reverted to `let bd = 8u32` the same test
80+FAILS on "luma at 10-bit" and the 8-bit arm still passes (discrimination check
81+run, tree restored from a scratch copy)
82+
83+Class sweep for the same shape (a bit-depth-scaled reader hardcoding 8):
84+`grep -n "literal(8)\|255i32\|, 255)\|(1 << 8)" decode.rs` -> the only two
85+survivors are the qindex clamps at decode.rs:332 and :544, which are correct
86+(qindex is 0..255 at every bit depth). No sibling instances.
87+
88+## 3. Chroma residual on the 4K 10-bit key frame (charter item 3) -- GONE
89+
90+r2's open residue (first chroma difference at (195,640) = mi(97,320)) is zero
91+on the merged tree. It is NOT my palette fix: the film frame reads **zero**
92+palette symbols (`EC_AV1_TRACE ... | grep -c "^EC_PAL "` = 0 on
93+`crates/ec-av1/fixtures/reelb_kf900.obu`), so the credit belongs to the merged
94+lane-reelckf commits (skipped CfL blocks still predict; the 1:4 chroma pair
95+edge-filter mi).
96+
97+The chroma `tx_type` suspicion from the charter was audited and cleared rather
98+than needed: `av1_get_tx_type`'s `plane > 0` intra path is
99+`intra_mode_to_tx_type(mbmi, PLANE_TYPE_UV)` (our `default_intra_tx_type`,
100+decode.rs:3229) fed with `uv_predict_mode`, which already maps `UV_CFL_PRED`
101+to `DC_PRED`; the `!av1_ext_tx_used[tx_set_type][tx_type]` narrowing can only
102+bite at `txsize_sqr_up >= TX_32X32`, and both chroma call sites already force
103+`DCT_DCT` there (decode.rs:6089 `chroma_w.max(chroma_h) >= 32`, decode.rs:9254
104+`side >= 32`). Every value the table can produce is a member of
105+`EXT_TX_SET_DTT4_IDTX` and `..._1DDCT`, the only two intra sets below 32.
106+
107+## 4. 24-key-frame census on the merged tree (charter item 4)
108+
109+Recipe `$HOME/.cache/kf900/census_r3.sh` (r2's script, own `c3/` scratch and
110+`census_r3.tsv`): `ffmpeg -ss <s> -t 2 -c:v copy -f obu`, truncated to one
111+frame, `EC_PROBE_OUT16` vs `ffmpeg -pix_fmt yuv420p10le`, per-plane DIFFERING
112+SAMPLES.
113+
114+| -ss | Y | U | V | max Y/U/V | r2 U | r2 V |
115+|----:|--:|--:|--:|:---------|-----:|-----:|
116+| 0 | 0 | 0 | 0 | 0/0/0 | 0 | 0 |
117+| 300 | 0 | 0 | 0 | 0/0/0 | 219 | 220 |
118+| 600 | 0 | 0 | 0 | 0/0/0 | 0 | 0 |
119+| 900 | 0 | 0 | 0 | 0/0/0 | 221 | 47912 |
120+| 1200 | 0 | 0 | 0 | 0/0/0 | 0 | 0 |
121+| 1500 | 0 | 0 | 0 | 0/0/0 | 0 | 0 |
122+| 1800 | 0 | 0 | 0 | 0/0/0 | 0 | 0 |
123+| 2100 | 0 | 0 | 0 | 0/0/0 | 1041 | 1008 |
124+| 2400 | 0 | 0 | 0 | 0/0/0 | 0 | 0 |
125+| 2700 | 0 | 0 | 0 | 0/0/0 | 442 | 800 |
126+| 3000 | 0 | 0 | 0 | 0/0/0 | 0 | 0 |
127+| 3300 | 0 | 0 | 0 | 0/0/0 | 0 | 0 |
128+| 3600 | 0 | 0 | 0 | 0/0/0 | 0 | 0 |
129+| 3900 | 0 | 0 | 0 | 0/0/0 | 4 | 4 |
130+| 4200 | 0 | 0 | 0 | 0/0/0 | 0 | 0 |
131+| 4500 | 0 | 0 | 0 | 0/0/0 | 0 | 0 |
132+| 4800 | 0 | 0 | 0 | 0/0/0 | 2316 | 5 |
133+| 5100 | 0 | 0 | 0 | 0/0/0 | 0 | 0 |
134+| 5400 | 0 | 0 | 0 | 0/0/0 | 0 | 0 |
135+| 5700 | 0 | 0 | 0 | 0/0/0 | 0 | 0 |
136+| 6000 | 0 | 0 | 0 | 0/0/0 | 210 | 0 |
137+| 6300 | 0 | 0 | 0 | 0/0/0 | 145195 | 0 |
138+| 6600 | 0 | 0 | 0 | 0/0/0 | 30873 | 897 |
139+| 6900 | 0 | 0 | 0 | 0/0/0 | 0 | 0 |
140+
141+**24/24 key frames now decode BIT-EXACT on all three planes** (r2: 15/24).
142+Every decode reported `OK: 1 frames decoded, 3840x1608`.
143+
144+EVIDENCE: $HOME/.cache/kf900/census_r3.tsv | 24 x (extract 2 s, truncate to 1
145+frame, decode ours + ffmpeg, per-plane compare) | Y/U/V all 0 on all 24 rows
146+
147+## 5. Suite (charter item 5)
148+
149+`systemd-run --user --unit=kf900-suite-r3-... -p MemoryMax=10G ... cargo test
150+-p ec-av1 --lib -j3` -> `$HOME/.cache/kf900-suite-r3.log`:
151+**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.
152+
153+## Residue
154+
155+1. **deferred: a whole-frame pixel gate for `skip_split_tx`** -- the only
156+ aomenc recipe found (of 108 + this round's) that fires the counter is the
157+ pinned 10-bit `testsrc2` stream, and it now stops at the 1:4-rect-palette
158+ refusal. Unblocked by porting palette reconstruction to the 1:4 rect
159+ decoder (decode.rs:7167/7556 pass `palette: None`) -- lane-palette2's
160+ territory, not a kf900 defect. The fixture gate
161+ `..._skipped_8x8_intra_leaves_that_split_their_transform_decodes_luma_exact`
162+ still pins the counter at 15 and now compares luma only by construction;
163+ with the census at 24/24 its U/V arms could be tightened next round.
164+2. **deferred (r1/r2 carry-over): block-position printing on refusal in
165+ `decode_probe`**, plus `refusal_inventory.rs` / `gate_coverage.rs` updates
166+ -- this round lifted no refusal (it turned a silent desync into an existing
167+ named one), so neither file changed. Unblocked by ~10 min on `decode.rs`'s
168+ `unsupported()` call sites.
169+3. **accepted: the pinned 10-bit palette stream is not committed as a fixture**
170+ -- it is reproducible from `sweep.sh` and its md5 is recorded here; the
171+ committed gate builds its own stream from aomenc at test time.