# lane-av1444d10 — the 10-bit 4:4:4 352x242 chroma divergence is a chroma PALETTE PREDICTION window, fixed, and gated byte-exact **Status: FIXED and GATED.** The census cell `s444_352x242_10b` is byte-exact on all 17 decode-order frames against the instrumented aomdec, and so are all 106 committed fixtures except the nine 4:2:2 ones that refuse by name. Two commits: `f3afa5b7` (the fix) and `eb73ef89` (the fixture + the byte-exact gate + the reachability counter). Base `ed7c99bc`. The census was right that this cell diverged and right that it was outside the 4:2:2 question. It was not, however, "geometry-sensitive" in the way its own framing implies: **352x242's distinction is not frame width or height at all — it is the number of CHROMA TRANSFORM UNITS in one block.** --- ## 0. The cell, pinned | field | value | |---|---| | name | `s444_352x242_10b` (census) → `fixtures/444_lossy_palette_chroma_352x242_10b.obu` (committed) | | sha256 | `84df2f37cc7982f9a572443d85dfcc13bf366a64f3fb567391dcd5acd58a0ad2` | | size | 24 875 B | | FNV-1a64 | `0x7fda_dbb4_3bbf_9af3` | | shape | 352x242, `ss_x = ss_y = 0` (4:4:4), 10-bit, profile 1 | | frames | 17 decode-order (16 shown + 1 hidden altref) | Recipe — the census's own sweep driver, re-run here and byte-reproduced (the sha256 matched the census cell exactly, so the recipe is the census's, not a re-derivation): ```text ffmpeg -v error -f lavfi -i "testsrc2=size=352x242:rate=25" -frames:v 16 \ -pix_fmt yuv444p10le -f rawvideo cell.raw -y # y4m built by hand: header line, then "FRAME\n" + 352*242*3*2 bytes per frame # (libaom's y4minput.c:1163-1171 requires the six bytes "FRAME\n" before EVERY frame) aomenc --codec=av1 --profile=1 --input-bit-depth=10 --bit-depth=10 --limit=16 \ --lag-in-frames=25 --auto-alt-ref=1 --enable-global-motion=1 --pass=1 \ --cq-level=24 --threads=4 --kf-min-dist=0 --kf-max-dist=999999 \ --width=352 --height=242 --cpu-used=0 --obu -o cell.obu cell.y4m ``` Driver: `~/.cache/lanes/av1444d10/mksweep.sh` (a copy of the census's, unmodified), invoked as `OUT=... DEPTHS=10 WIDTHS="320 352 416" HEIGHTS="242 250" bash mksweep.sh`. The four other 4:4:4 10-bit cells named as controls reproduce byte-identically too (sha256 in §4). Instrument: my own driver, `~/.cache/lanes/av1444d10/run.py` / `corpus.py`, over the census's `cmp422.py` comparator — geometry parsed from **aomdec's own y4m header**, never from a file size; per-plane spans from each frame's own plane lengths; wrong sample counted at the stream's own sample depth (2 B here, so a 10-bit difference in the top bits cannot hide); hard error on an empty frame set. Both sides are `EC_AV1_FINAL_DUMP` (`.f` indexed by DECODE index, hidden alt-refs included), so every total below is on the **decode-order** basis. --- ## 1. Reproduction on my tip The census measured at its own parent. Nothing moved. `repro_before.json`: | cell | status | frames | Y | U | V | first bad (decode frame, plane, row, col, ours, oracle) | |---|---|---|---|---|---|---| | `s444_320x242_10b` | BYTE-EXACT | 17 | 0 | 0 | 0 | — | | `s444_320x250_10b` | BYTE-EXACT | 17 | 0 | 0 | 0 | — | | **`s444_352x242_10b`** | **DIVERGES** | 17 | **0** | **1166** | **1413** | **0, U, 224, 64, 209, 216** | | `s444_352x250_10b` | BYTE-EXACT | 17 | 0 | 0 | 0 | — | | `s444_416x242_10b` | BYTE-EXACT | 17 | 0 | 0 | 0 | — | | `s444_416x250_10b` | BYTE-EXACT | 17 | 0 | 0 | 0 | — | 17 of 17 decode frames carry at least one wrong sample, first bad at decode frame 0 — identical to the census. **Comparator liveness, three planes, one run each:** with the tip build the cell is `0/0/0`, and flipping bit 0 of the low byte of ONE oracle sample per plane at decode frame 0 (so `+1` is exact by construction) moves the count by exactly `+1` in that plane and leaves the other two at 0: ``` baseline (tip build) Y/U/V: 0 0 0 flip Y (frame 0): Y +1 U +0 V +0 (abs 1/0/0) flip U (frame 0): Y +0 U +1 V +0 (abs 0/1/0) flip V (frame 0): Y +0 U +0 V +1 (abs 0/0/1) ``` Per-decode-frame Y/U/V, before (all 17 frames, every one bad): | frame | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | |---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---| | U | 53 | 54 | 54 | 54 | 170 | 54 | 162 | 54 | 58 | 54 | 61 | 54 | 54 | 61 | 61 | 54 | 54 | | V | 51 | 51 | 51 | 52 | 160 | 52 | 158 | 52 | 58 | 52 | 158 | 52 | 51 | 156 | 156 | 52 | 51 | Y is 0 in every frame. The per-plane wrong-sample bounding box over all 17 frames is `U rows 222..226, cols 63..118` and `V rows 222..226, cols 63..114`. --- ## 2. PREDICTION or RESIDUAL: the filter chain is exonerated, and it is a PREDICTION defect The brief asked me to check the frame header before assuming the filter chain is inert. It is inert here, and the check does not need the header: **the oracle's own pre-filter dump equals the oracle's own final dump.** | oracle rung | what it is | frame-0 size | vs FINAL (low byte), every sample | |---|---|---|---| | `EC_AV1_PREFILT_DUMP` | after tile decode, before ANY loop filter, `p[c] & 0xFF` | 255 552 B (352x242x3, 1 B/sample) | **0 differences** | | `EC_AV1_FINAL_DUMP` | after CDEF + superres + LR, u16 LE | 511 104 B | (the reference) | Both rungs narrow to the same projection (`narrow[c] = p[c] & 0xFF`, per the rung's own `ec_dump_narrow_row`), so the comparison is apples to apples: **deblock, CDEF, loop restoration and superres changed no low byte anywhere in this cell.** Ours, same way: our `EC_AV1_PREFILT_DUMP` (352x256 aligned, 1 B/sample) against the oracle's over the crop region has **exactly 104 differences — U row 224 cols 64..116 (53) and V row 224 cols 64..114 (51)** — i.e. the *same set* as our FINAL diff set, and not one more. The defect is therefore pre-filter: **reconstruction**, and inside reconstruction, **prediction, not residual**: | stage | measured | what it rules out | |---|---|---| | entropy decode | in lockstep: 17/17 frames on both sides, no desync, byte-identical bitstream parse | syntax / mode / coefficient read | | residual (probe) | `res0 = [0,0,0,0,0,0,0,0]`, `rescol0 = [0,…]` on the owning unit; the residual is read identically on both sides | inverse transform, dequant | | **prediction (probe)** | **the owning unit's prediction buffer is wrong**: see §3 | — | | deblock / CDEF / LR / superres | oracle PREFILT == oracle FINAL, low byte, every sample | all four | `EC_PRED=1` on our side (the `OUR_PRED` / `OUR_RECON` rungs, `decode.rs:4650`) prints, for the owning unit: ```text OUR_PRED x=64 y=224 plane=1 side=32 mode=0 sum=442144 row0=[209 x32] col0=[209,216,216,…] ``` against the oracle's, which for that block prints **nothing at all** — because the oracle's `EC_PREDND` only fires for non-directional predictions and a palette block returns before it. Aligning the two traces by `(plane, txw, txh, sum)` (the oracle's `mi_row`/`mi_col` in that print are not pixel/8, so coordinates do not align) the sides agree on every event until this one, where ours has TWO extra `plane=1 txw=32 txh=32 mode=0` events the oracle does not have. --- ## 3. The owning block, and the named expression **Block.** A 32x64 luma strip at pixel (64, 192) — the oracle's own rung says `plane=0 row_off=0 col_off=0 txw=32 txh=64`. At `ss_x = ss_y = 0` its chroma plane block is **also 32x64**, which `decode_block_rect` tiles into `nh = 2` units of 32x32 at pixel (64, 192) and **(64, 224)**. **Chroma mode: PALETTE.** `EC_DEBUG_PAL=1` shows the unit at (64, 224) consuming a 2048-entry (= 32x64, the whole plane block) palette prediction buffer handed over by `set_palette_pred` at `decode.rs:20086`, with `stale=false`. `EC_PRED=1` on our side confirms the `pred: Option>` override was taken (`pred_opt=true`) while the neighbouring block at (96, 224) took the ordinary `PAETH_PRED` path (`pred_opt=false`). **THE EXPRESSION — ours vs libaom.** | | libaom | ours (before) | |---|---|---| | where a palette chroma unit's prediction comes from | `av1_visit_palette` → `av1_predict_intra_block_palette` (`reconintra.c:1707`) hands `av1_predict_intra_block` a `ref` pointer at the unit's own origin, and `read_coeffs` walks the plane block with each unit's own `blk_row`/`blk_col` | `FrameCtx::palette_pred` (thread-local `Option>`), `decode.rs:20086`, handed **the whole block buffer** | | the read | the unit's pixels are the unit's | `PlaneBuf::reconstruct` (`decode.rs:21336`) does `prediction[idx]` for `idx in 0..side*side` (write loop at `decode.rs:21406-21433`) — **the first `side*side` entries, i.e. always the buffer's top-left corner** | So on the 32-capped tiled chroma walk, unit (0, 1) at pixel (64, 224) reconstructed **the block's row-192 palette values** (flat 209) where libaom writes **row 224's** (216). Both arms were wrong: the `uw == uh` square-unit arm (`decode.rs:20086`) and the rect-unit arm (`decode.rs:20140`) — both line numbers PRE-fix, quoted as they stood at `ed7c99bc`. `palette_window` already existed for exactly this (`decode.rs:2968-2974`: "A unit reads its prediction at ITS OWN stride, so handing it the whole-block buffer makes every unit reconstruct the block's top-left corner … the luma split-transform paths already window; the chroma ones did not"). Its doc comment records the 4x4 **lossless** chroma instance as fixed. The 32-capped 4:4:4 instance was still un-windowed: the same defect, a second walk. **Why 53 wrong columns and not 32 — the halo is the same bug, not a second one.** Unit (0,1) writes 209 at col 95, row 224. The neighbouring 32x32 `PAETH_PRED` block at (96, 224) has that pixel as its left edge, and `EC_DEBUG_EDGES=1` prints its edges as ```text above=[216 x18, 215, 220, 228, 185, 95, 49, 59, 63, 63, 64, 64, 65, 64, 63] left =[209, 216, 216, …] corner=216 ``` `paeth(above, left[0], corner)` with `left[0]=209` returns `left` exactly where `|above − corner| <= |above + left − 2·corner|`, i.e. for `above ∈ {216, 215}` — 19 columns — and returns `above` for `above ∈ {220, 228}` (the two columns where it is wrong for the other reason) and from col 117 on. That reproduces our observed row `[209 x19, 216, 216, 185, 95, …]` term for term, and the 53 = 32 + 19 + 2 span the census measured. **One defect, one fix, both symptoms.** I did not chase the halo as a second bug, and §4 shows the fix removes it. **The fix** (post-commit `decode.rs:20106-20113` and `:20164-20172`): ```rust let pbuf = if plane_idx == 1 { ub } else { vb }; set_palette_pred( palette_window(pbuf, chroma_w, cu_col * uw, cu_row * uh, uw, uh), fctx, ); ``` --- ## 4. The geometry question, answered The brief asked what 352x242 has that 320x242 / 352x250 / 416x242 / 416x250 do not. Measured, it is **not** a partial column at a block or tile boundary, not a plane extent landing on a 4:4:4 granularity edge, and not a sub-8x8 leaf at the right edge. It is: > **a block whose CHROMA is taller than the 32-pixel unit cap at `ss (0,0)`, so > `decode_block_rect`'s chroma walk has `nh = 2` and every unit after the first is > handed the wrong window.** `352 = 5.5 superblocks at 64` and `242` odd were the census's tells, and both are real facts about the frame — but neither is the discriminator, which is why the census could only say "geometry-sensitive". The 416x250 cell has an odd height too and is exact; the 352x250 cell has the same width and is exact; 320x242 has the same odd height and is exact. What separates 352x242 is that its partition happens to contain a 32x64 chroma plane block with a UV palette. Same recipe, same 10-bit depth, six cells, before → after: | cell | sha256 (16) | before | after | |---|---|---|---| | `s444_320x242_10b` | `e73548ca94270469` | 0 / 0 / 0 | **0 / 0 / 0** | | `s444_320x250_10b` | `a6dfbd67f3ff662f` | 0 / 0 / 0 | **0 / 0 / 0** | | **`s444_352x242_10b`** | `84df2f37cc7982f9` | **0 / 1166 / 1413** | **0 / 0 / 0** | | `s444_352x250_10b` | `a46036e9926dc0db` | 0 / 0 / 0 | **0 / 0 / 0** | | `s444_416x242_10b` | `48a48fa8596887d4` | 0 / 0 / 0 | **0 / 0 / 0** | | `s444_416x250_10b` | `5973d87cc934cbb7` | 0 / 0 / 0 | **0 / 0 / 0** | (The five controls were already exact before the fix and are unchanged after it, so the fix is not "the comparator got weaker" — the cell that moved is the only one that could.) --- ## 5. The gate Committed, reachable, and it bites. ```text fixture crates/ec-av1/fixtures/444_lossy_palette_chroma_352x242_10b.obu sha256 84df2f37cc7982f9a572443d85dfcc13bf366a64f3fb567391dcd5acd58a0ad2 size 24875 B FNV-1a64 0x7fda_dbb4_3bbf_9af3 gate stream::tests::a_444_lossy_palette_chroma_unit_window_is_byte_exact_at_352x242_10bit reach decode::chroma_palette_window_hits() (reset_chroma_palette_window_hits() first) ``` Four non-vacuity arms, all required to pass: 1. the pinned bytes — length 24 875 and FNV-1a64 `0x7fda_dbb4_3bbf_9af3` (a missing file is a **failure**, not a skip); 2. 16 shown frames at 352x242 with `f.u.len() == 352*242` — full-resolution chroma, so a decoder that kept the 4:2:0 extent cannot pass the byte compare; 3. `chroma_palette_window_hits()` read as a **delta** with a **measured floor of 4** (two tiled palette chroma blocks x U and V). It is incremented on the two fixed lines and nowhere else, so a gate that passed without them running would be gate-blind-to-feature, not byte-exact; 4. the oracle comparator has its own per-plane one-byte-flip liveness control in the crate (`every_oracle_comparator_reds_on_a_one_byte_wrong_oracle`), and my own three-plane flip run above. **Green:** ```text a_444_lossy_palette_chroma_unit_window_is_byte_exact_at_352x242_10bit: fixtures/444_lossy_palette_chroma_352x242_10b.obu 17 decode-order frame(s) (1 hidden) byte-exact vs aomdec, 4 windowed palette chroma unit(s) test result: ok. 1 passed; 0 failed ``` **Mutation proof — red, by name, then green.** The two `palette_window` calls were replaced by the whole-buffer hand-off, the `hit!` left in place so the reachability arm still fires (the gate must bite on the BYTES, not on the counter): ```text thread 'stream::tests::a_444_lossy_palette_chroma_unit_window_is_byte_exact_at_352x242_10bit' panicked at crates/ec-av1/src/stream.rs:10848:17: a_444_lossy_palette_chroma_unit_window_is_byte_exact_at_352x242_10bit: decode-order frame 0 of 17 (16 shown, 1 hidden) differs from the oracle at byte 328192 (ours 209 vs 216), 104 bytes differ test result: FAILED. 0 passed; 1 failed ``` Byte 328192 = frame 0, past the 170 368-byte Y plane, `157824 / 2 = 78 912` samples in = `row 224, col 64` — **the census's own first bad sample**, from a gate written after the fix. Restored: green (the message above). --- ## 6. Corpus-wide, every committed fixture All 106 `.obu` files under `crates/ec-av1/fixtures/`, both binaries, same instrument, same comparator, decode-order basis. Base = `ed7c99bc` build; tip = this lane. | | BYTE-EXACT | DIVERGES | REFUSES (by name) | oracle refused | |---|---|---|---|---| | base `ed7c99bc` | 95 | **1** | 9 | 1 | | tip `eb73ef89` | **96** | **0** | 9 | 1 | The single status change is `444_lossy_palette_chroma_352x242_10b`: `DIVERGES (0/1166/1413)` → `BYTE-EXACT`. No fixture changed status in the other direction and no sample count moved on any exact cell. The 9 refusals are the 4:2:2 fixtures, all with the sequence-header refusal string (`unsupported: AV1 decode_stream (a chroma format of 4:2:2 (su…`) — untouched by this lane; the 4:2:2 header guard was not read for edit and is not in either diff. The one oracle refusal is `440_request_is_422.obu`, a request-only file aomdec itself rejects. --- ## 7. Regression ```text cargo test -p ec-av1 --lib -- 444 420 lossless warp intra \ --skip bitrate_target_lands_within_5_percent_over_48_frames test result: ok. 178 passed; 0 failed; 2 ignored; 0 measured; 623 filtered out; 302.41s ``` The two ignored are pre-existing `#[ignore]`d gates, not new ones — this lane adds no `#[ignore]`. --- ## 8. What I did NOT do, and what a reviewer should attack * **Not a superblock/tile-boundary, odd-dimension or sub-8 defect.** I checked the three hypotheses the brief named and refuted all three on the controls: same-depth same-width (352x250), same-depth same-height (320x242, 416x242) and wider 4:4:4 at the same odd height are all exact. The discriminator is chroma unit count. * **No filter stage involved**, and that is measured, not assumed (§2). * **Not the 4:2:0 group-tail chroma SKIP arm** — different format, different write path, and that arm is left exactly as it was. * **The 4:2:2 sequence-header guard was not touched.** Both diffs are `decode.rs` (the two `palette_window` arms + the counter) and `stream.rs` (the gate), plus one new binary fixture. * **The mutation proof is the strongest single check here and it is honest**: the windowing was removed while the counter stayed, so the byte compare — not the reachability assert — is what reddened. * **What a reviewer should attack first.** The counter's floor of 4 is measured on this one stream. It is a *reachability* floor, not a census: a second palette-chroma fixture would move it, and the gate would then need its floor re-measured. The byte-exactness arm is the one that carries the exactness claim and it does not depend on the number. * **Not swept beyond the one walk.** I audited every `set_palette_pred` call site in `decode.rs` (~100). All the others either pass a whole-block buffer to exactly ONE push (correct by construction) or already window with `palette_window`. The two I changed were the only whole-buffer hand-offs inside a tiled unit loop. I did not build a 4:4:4 12-bit or a `nw > 1` variant to prove the `nw > 1` arm; on this stream `nw == 1` always and the horizontal windowing is unmeasured. --- ## 9. Handover * Fixed lines: `crates/ec-av1/src/decode.rs:20106-20113` and `:20164-20172` (`palette_window` in the two arms of `decode_block_rect`'s 32-capped tiled chroma walk). * Counter: `decode.rs:2721-2743` (`CHROMA_PALETTE_WINDOW_HITS`, `chroma_palette_window_hits` at `:2734`, `reset_chroma_palette_window_hits` at `:2741`). * Gate: `crates/ec-av1/src/stream.rs:50715-50823`. * Fixture: `crates/ec-av1/fixtures/444_lossy_palette_chroma_352x242_10b.obu`. * Driver + instruments (not committed; probe evidence): `~/.cache/lanes/av1444d10/{run.py,corpus.py,cmp422.py,mksweep.sh,sweep/,work/,stage/}`, results `repro_before.json`, `after.json`, `corpus_base.json`, `corpus_tip.json`, `flipctl.txt`. The census was right that this cell diverged and right that it was outside the 4:2:2 question. It was not, however, "geometry-sensitive" in the way its own framing implies: **352x242's distinction is not frame width or height at all — it is the number of CHROMA TRANSFORM UNITS in one block.**