# 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.