diff --git a/lanes/av1422444b.report.md b/lanes/av1422444b.report.md new file mode 100644 index 00000000..df9a6247 --- /dev/null +++ b/lanes/av1422444b.report.md @@ -0,0 +1,291 @@ +# lane-av1422444b — `s444_352x242_10b` is ALREADY CLOSED at `main`; the census row is superseded, and here is the measurement that says so + +**Outcome in one line: the cell is byte-exact against ffmpeg on all 16 shown frames and +against instrumented aomdec on all 17 decode-order frames at `main` = `affe70dc`; the +cause is a 4:4:4-specific chroma PALETTE PREDICTION window, already fixed by +`f3afa5b7` and already pinned by the gate +`a_444_lossy_palette_chroma_unit_window_is_byte_exact_at_352x242_10bit` +(`crates/ec-av1/src/stream.rs:51024`); this lane adds no source change and re-proves the +closure, the gate's bite, and the whole 4:4:4 and 4:2:0 control surface.** + +Worktree `/home/user/.cache/wt/av1422444b`, branch `lane/av1422444b`, base +`affe70dc`. `CARGO_TARGET_DIR=/home/user/.cache/tgt/av1422444b`. +**The tree carries no source diff** (`git diff --quiet` → clean, verified after the +mutation of §4 was reverted). The 4:2:2 sequence-header refusal is untouched and +`EC_AV1_ALLOW_422_PROBE` was never needed: 4:4:4 is a supported format, so this cell +decodes on the shipped tree with no bypass. + +--- + +## 1. What the census claimed, and why it no longer holds + +`lanes/av1422census2.report.md` (measured at `ed7c99bc`) lists `s444_352x242_10b` as +DIVERGES `0/1166/1413` over 17 decode frames, and names it as class D, "not 4:2:2: +10-bit 4:4:4 chroma", with the load-bearing note that a 4:2:2 refusal lift would not fix +it. **Both halves of that are now false, and the cause is a commit the census's own +base predates.** + +`git merge-base --is-ancestor f3afa5b7 main` → true. `f3afa5b7` is *"window the 32-capped +chroma palette buffer per unit (the 352x242 4:4:4 chroma divergence)"*, and it landed +after `ed7c99bc`. So the census's row is a true reading of a tree that no longer exists, +not a live defect. Re-measured here on `affe70dc`, the same cell is 0/0/0. + +The census cell and the committed fixture are the same bytes, which is what makes the +two measurements comparable rather than merely similar: + +``` +84df2f37cc7982f9a572443d85dfcc13bf366a64f3fb567391dcd5acd58a0ad2 crates/ec-av1/fixtures/444_lossy_palette_chroma_352x242_10b.obu +84df2f37cc7982f9a572443d85dfcc13bf366a64f3fb567391dcd5acd58a0ad2 ~/.cache/census422b/sweep/s444_352x242_10b.obu +``` + +## 2. The cause, localised — 4:4:4-SPECIFIC, and NOT shared with the 4:2:2 family + +**It does not share a cause with the 4:2:2 family.** The two defects are different arms +at different depths of the pipeline, and the evidence is not merely that both are +"chroma": + +| | 4:2:2 family (`b8eed69f`) | this cell (`f3afa5b7`) | +|---|---|---| +| arm | `sub8_leaf_chroma422` — a SKIPPED INTRABC chroma leaf | `decode_block_rect64` — the 32-capped chroma PALETTE walk | +| what was wrong | the arm took `if skip` and never ran the INTRABC frame copy at its DV | each tiled unit was handed the WHOLE block's palette prediction buffer instead of its own window | +| subsampling reach | 4:2:2 only (`ss_x=1, ss_y=0`) | 4:2:0 is structurally immune (chroma never exceeds 32); 4:4:4 (`ss=00`) is the only shipped format where a 64-axis luma strip's chroma exceeds the 32 cap and gets tiled | +| depth | 8- and 10-bit both | 10-bit only among the shipped sweep cells (the 4:4:4 8-bit cells never tile) | + +The mechanism, in the arm's own terms. `crates/ec-av1/src/decode.rs:20051` computes +`(uw, uh) = (chroma_w.min(32), chroma_h.min(32))` and `(nw, nh) = (chroma_w/uw, +chroma_h/uh)`, so at 4:4:4 a 64x64 luma block yields 4 chroma units of 32x32. Both +tiled arms then did `set_palette_pred(.clone(), fctx)`, and +`PlaneBuf::reconstruct` reads the first `side * side` entries of whatever it is given — +so unit (0,1) reconstructed the block's row-0 palette values where libaom writes row +32's. `f3afa5b7` routes both arms through `palette_window(pbuf, chroma_w, cu_col * uw, +cu_row * uh, uw, uh)` (`decode.rs:3009`), which re-strides the correct sub-rectangle. + +**The sensitive axis is CHROMA UNIT COUNT, not frame width or height** — the census's +own "geometry-sensitive" framing is the misleading part. 352x242 is not special as a +*frame*; what makes this cell bite is that its block structure produces a block whose +4:4:4 chroma is tiled at all. That is why the sibling geometries at the same depth +(320x242 10-bit, 352x250 10-bit, 416x242 10-bit, 416x250 10-bit) were already exact: +their partition search never produced a tiled palette chroma block. + +## 3. The cell, byte-exact on BOTH bases, with a proven-live comparator + +Two independent oracles, two independent bases, same verdict. + +**Base 1 — ffmpeg 8.1.3, SHOWN frames** (the pixel oracle of record): + +``` +ffmpeg -v error -i s444_352x242_10b.obu -f rawvideo -pix_fmt yuv444p10le ref.yuv +# 8177664 B = 16 x 511104 B; 511104 = 352*242*3*2 +``` + +| cell | frames | Y | U | V | verdict | +|---|---|---|---|---|---| +| `s444_352x242_10b` | 16 shown | 0 | 0 | 0 | **BYTE-EXACT** | + +per frame, all 16: `0/0/0`. First divergence: none. Wrong-sample bbox: none in any plane. + +**Base 2 — instrumented aomdec, DECODE-order frames** (17 = 16 shown + 1 hidden altref, +so the hidden frame is not a blind spot): + +| cell | frames | Y | U | V | verdict | +|---|---|---|---|---|---| +| `s444_352x242_10b` | 17 decode | 0 | 0 | 0 | **BYTE-EXACT** | + +per frame, all 17: `0/0/0`. + +### 3.1 The comparator's liveness, proven before any "exact" verdict was read + +`~/.cache/wt444/cmp.py` (shown frames) and `~/.cache/wt444/cmporder.py` (decode order). +Geometry is an explicit argument taken from the cell's own `ffprobe` +`width,height,pix_fmt` — never from a file name, never from a file size. Plane +attribution is per FRAME from that frame's own plane lengths. A wrong SAMPLE is one +`bps`-wide unit. A zero-frame count is a hard error, not a vacuous 0/0/0. + +**Control A — one-sample flip, three planes, on the byte-exact cell.** Bit 0 of one +oracle sample's LOW byte, per plane, in decode frame 0. At 10 bit the sample sits in a +16-bit LE container and `2**10 < 2**16`, so +1 is exact by construction. + +| arm | Y | U | V | +|---|---|---|---| +| baseline | 0 | 0 | 0 | +| flip Y sample 5 | **1** | 0 | 0 | +| flip U sample 7 | 0 | **1** | 0 | +| flip V sample 9 | 0 | 0 | **1** | + +Each arm moves its own plane by exactly +1 and leaves the other two at 0. A comparator +that dropped chroma, mis-attributed a plane, or compared our samples with themselves +fails at least one of these. + +**Control B — the two oracles agree with each other.** `cmp ref.yuv aom.raw` (ffmpeg vs +`aomdec --rawvideo`) is byte-identical over all 8177664 B, so the two bases are not +disagreeing about what the pixels are. + +**Control C — the mutated tree reds on this exact comparator** (§4), which rules out +the comparator being unable to see a 4:4:4 chroma defect at all. + +Two of my own instrument bugs were found and fixed by these controls rather than by +reading a verdict; both are recorded here because each would have produced a confident +wrong number: + +* the first `cmp.py` indexed the ORACLE buffer with the frame offset but read the OURS + buffer at a per-plane-zero offset, reporting 1.36 M wrong chroma samples on a cell that + is in fact exact. It surfaced as an implausible count, not as a plausible one. +* `cmp.py` hardcoded `bps=2` and `cmp.sh` parsed geometry out of the cell's FILE NAME, + which reported the 4:2:0 cells as "ours=16 ref=8" — a name-parsing artefact, since + `ffprobe -count_frames` says 16 and the ref file is 16 frames of 230400 B. Both are + fixed: `bps` is an argument, and geometry comes from the oracle's own `ffprobe`. + +## 4. The gate, and proof that it bites (red-before by mutation, on the current tree) + +The gate is **pre-existing and pins this cell exactly** — no new gate was needed, and +adding a second one for the same cell and the same bytes would be a duplicate. + +* gate: `stream::tests::a_444_lossy_palette_chroma_unit_window_is_byte_exact_at_352x242_10bit` + (`crates/ec-av1/src/stream.rs:51024`) +* fixture: `crates/ec-av1/fixtures/444_lossy_palette_chroma_352x242_10b.obu`, asserted + length 24875 and FNV-1a64 `0x7fda_dbb4_3bbf_9af3` +* non-vacuity: `decode::chroma_palette_window_hits()` read as a delta must be >= 4, and + the counter is guarded on `nw * nh > 1`, so a hit is PROOF the tiled arm ran rather + than proof that some palette chroma block existed +* the gate's own oracle comparator carries a per-plane one-byte-flip liveness control in + the crate (`every_oracle_comparator_reds_on_a_one_byte_wrong_oracle`) + +**Green at `affe70dc`:** + +``` +test stream::tests::a_444_lossy_palette_chroma_unit_window_is_byte_exact_at_352x242_10bit ... ok + 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) +``` + +**Red by mutation, on THIS tree, with `palette_window` reverted in both tiled arms +(`decode.rs:20223` and `decode.rs:20291`, square-unit and rect-unit):** + +``` +panicked at crates/ec-av1/src/stream.rs:11108: +a_444_..._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 +``` + +The same mutation measured through the ffmpeg comparator, shown-frame basis: + +| | Y | U | V | first divergence | +|---|---|---|---|---| +| mutated (fix reverted) | 0 | **1112** | **1362** | frame 0, plane U, row 224 col 64, ours 209, oracle 216 | +| restored (`affe70dc`) | 0 | 0 | 0 | none | + +Wrong-region bbox under mutation, U: rows 222..226, cols 63..118; V: rows 222..226, +cols 63..114. That is a 32x32 chroma unit plus the 19 columns a neighbouring +`PAETH_PRED` block propagates along its own top row, which is precisely the signature +`f3afa5b7`'s commit message describes. The mutated per-frame U counts +(53, 170, 54, 54, 54, 162, 58, 54, 54, 61, 54, 54, 61, 61, 54, 54) confirm the error is +re-seeded by each keyframe and decays between them, i.e. it is a per-frame chroma +reconstruction error and not an entropy-read desync — luma is 0 in every frame, and the +stream parses identically on both sides (the mutation touches reconstruction only, so the +bit reader is untouched by construction). + +**Restored:** the tree is byte-identical to `affe70dc` (`git diff --quiet`, clean) and +the gate is green again. No source change is carried by this lane. + +## 5. Family sweep — the whole 4:4:4 and 4:2:0 surface re-measured + +Not only the target cell. Every 4:4:4 sweep cell and every 4:2:0 control, at `affe70dc`, +against ffmpeg, on the shown-frame basis with the §3.1 comparator. + +**Fresh sweep cells (`~/.cache/census422b/sweep`, the census's own encodes):** + +| class | cells | byte-exact | diverging | skipped | +|---|---|---|---|---| +| `s444_*` (4:4:4) | 18 | **18** | 0 | 0 | +| `s420_*` (4:2:0) | 18 | **18** | 0 | 0 | + +The 10-bit 4:4:4 cells among them, named, since the census named four of them as +controls: `s444_320x242_10b`, `s444_320x250_10b`, **`s444_352x242_10b`**, +`s444_352x250_10b`, `s444_416x242_10b`, `s444_416x250_10b` — all 0/0/0 over 16 frames. + +**Committed corpus (`crates/ec-av1/fixtures`), selected by each cell's own oracle +`pix_fmt`:** + +| class | cells | byte-exact | diverging | skipped | +|---|---|---|---|---| +| 4:4:4 (any depth) | 36 | **36** | 0 | 0 | +| 4:2:0 (any depth) | 69 | **69** | 0 | 0 | + +The 4:2:0 run first reported `pass=68 skip=1`, the skip being +`fixtures/reelb_intra14_witness.obu` with an EMPTY `pix_fmt` — a transient `ffprobe` read +failure in the driver, not a decode or oracle failure, and the shape a "zero skips" claim +is exactly what catches. Re-run standalone, that cell is 3840x1608 `yuv420p10le`, +1 shown frame, **0/0/0 BYTE-EXACT**, so the 4:2:0 corpus is 69 of 69. Zero skips in +either class after that: every cell enumerated, decoded, and compared. A sweep that +silently drops a cell is not a measurement, which is why the skip counter is reported +next to the pass count rather than dropped. + +### 5.1 The 4:2:0 control set is unchanged + +The census's load-bearing control was that 4:2:0 and 4:4:4 were bit-identical across the +4:2:2 fix, so that fix's delta was 4:2:2-specific. That control still holds, and it +holds a second time for the 4:4:4 palette fix: 4:2:0 is structurally immune to this +defect by construction, because at `ss=11` a luma block's chroma never exceeds 32 and so +is never tiled — `nw * nh == 1` on every 4:2:0 block, which is exactly the case the +`palette_window` call is a no-op for. + +The sibling 4:4:4 gate is green as well: +`a_444_palette_chroma_horizontal_unit_window_is_byte_exact_10bit_and_12bit` ... ok — the +horizontal arm of the same 32-capped walk in `decode_block_rect64`, on 640x480 10-bit and +12-bit cells, i.e. the same family at two more depths. + +## 6. Correction to the census of record, stated plainly + +`lanes/av1422census2.report.md` needs three edits, and this lane does not make them +because that report is another lane's artifact and its owner may still be amending it: + +1. §3.2's table row `s444_352x242_10b | 0 | 17/17 | 4:4:4, chroma only` — the cell is + byte-exact at `main`; the row is superseded by `f3afa5b7`. +2. §3.4's "4:4:4 controls: 21 of 22 byte-exact, the single exception `s444_352x242_10b` + (0/1166/1413, identical counts on both trees)" — that "identical on both trees" was + true only of the two trees the census had; a third tree closes it. +3. §7's "a lift would NOT fix class D: `s444_352x242_10b` is a 4:4:4 defect" — still + true as a statement about the 4:2:2 lift, but class D is now empty, so it no longer + constrains the lift. + +The census's own numbers were not wrong; they were bound to `ed7c99bc`, and it said so. + +## 7. What is NOT measured here + +* the 4:2:2 cells. They refuse by name on this tree and this lane does not touch them; + the `EC_AV1_ALLOW_422_PROBE` bypass was neither needed nor used, and no source edit + was made, so the refusal is intact. +* a recipe-dependence sweep over `--cpu-used`. The census measured that axis for 4:2:2; + this lane re-measured the census's own recipe only. The four other 10-bit 4:4:4 sweep + cells at the same depth are exact at that recipe, which bounds but does not eliminate + a recipe-dependent 4:4:4 defect. +* the u8-narrowing dump. It was not used for any 10-bit cell here, by construction: + every 10-bit comparison is depth-correct on both sides. +* no full-suite run and no repo-wide rustfmt, per the lane's tree discipline. + +## 8. Reproduction + +```bash +git worktree add -b lane/av1422444b /home/user/.cache/wt/av1422444b main +cd /home/user/.cache/wt/av1422444b +CARGO_TARGET_DIR=/home/user/.cache/tgt/av1422444b cargo build --release -p ec-av1 --examples + +# the cell, ffmpeg basis +~/.cache/tgt/av1422444b/release/examples/dump_yuv \ + ~/.cache/census422b/sweep/s444_352x242_10b.obu /tmp/ours +ffmpeg -v error -i ~/.cache/census422b/sweep/s444_352x242_10b.obu \ + -f rawvideo -pix_fmt yuv444p10le /tmp/ref.yuv -y +python3 ~/.cache/wt444/cmp.py s444_352x242_10b 352 242 0 0 /tmp/ours /tmp/ref.yuv 2 + +# the gate, with aomdec available +CARGO_TARGET_DIR=$PWD/../../tgt/av1422444b \ +PATH=~/.cache/aom-oracle/build:$PATH \ + cargo test --release -p ec-av1 --lib a_444_lossy_palette_chroma -- --nocapture + +# the family sweeps +bash ~/.cache/wt444/sweep.sh s444_ # 18/18 +bash ~/.cache/wt444/sweep.sh s420_ # 18/18 +bash ~/.cache/wt444/corpus.sh # 36/36 4:4:4 committed fixtures +bash ~/.cache/wt444/corpus420.sh # 4:2:0 committed fixtures +```