diff --git a/lanes/sb128b-r3.report.md b/lanes/sb128b-r3.report.md new file mode 100644 index 00000000..47828ed8 --- /dev/null +++ b/lanes/sb128b-r3.report.md @@ -0,0 +1,101 @@ +# lane-sb128b r3 — the 128x128 PARTITION_NONE block decodes PIXEL-EXACT (3 root causes), the 10-bit reds were a recipe defect + +Branch `lane-sb128b`, worktree `edith_codecs-sb128b`, commits `dd6f934` (merge main 7a47fc1 + TASK B), +`f2b6f1c` (TASK A), `7ceb309` (merge main 18bf7dc / lane-sb128 5ea5ec8). + +## TASK A — the 128 NONE residual: THREE root causes, none of them where r2 pointed + +r2 read "our first TX_64X64 luma unit reads AC coefficients libaom never wrote". Measured with a +range ladder (instrumented `aomdec` `EC_TRACE_COEFF` vs our `EC_TRACE_COEFF`) that premise is +WRONG: the first luma unit is identical symbol for symbol and range for range +(`all_zero ctx=1 rng=59208 / eob=3 rng=41268 / base_eob level=5 rng=44688 / ... / rng=36616`). +The divergence is at the SECOND element of the block, and it is three separate defects: + +1. **Plane order.** libaom's `decode_token_recon_block` loops 64x64 luma "mu" chunks + (`mu_blocks_wide/high = mi_size_wide[BLOCK_64X64]`) and codes EVERY PLANE of a chunk before the + next chunk. The oracle ladder is Y(0,0) U(0,0) V(0,0) Y(0,16) U(0,8) V(0,8) ... — Y,U,V per + quadrant. We read all four luma units and then all chroma units. Below 128 a block is one chunk, + so the fix (`nchunk = side/64`, luma TUs then chroma units per chunk) is byte-for-byte the old + order at every size the decoder already handled. +2. **The chroma `txb_skip_ctx` offset.** `get_txb_ctx`: chroma ctx is + `combine_entropy_contexts(above,left)` **+7** normally, **+10** when the plane block is LARGER + than the transform. A 128 block's 64x64 uv plane block with TX_32X32 units is AV1's only such + case, and our chroma table only ever carried the offset-7 rows (`txb_skip_chroma_*: [[u16;3];3]`). + Oracle read ctx=10, we read ctx=0. Added `TXB_SKIP_CHROMA_32_BIG{,_Q0,_Q1,_Q3}` from + `av1_default_txb_skip_cdfs[q][TX_32X32][10..13]` (token_cdfs.h, all four q contexts, verified by + re-deriving the existing offset-7 rows from the same array), `txb_skip_chroma_32` is six rows, + caller adds 3 when `cn > 1`. +3. **Deferred chroma context writes.** r2 recorded each chroma unit's coefficient context only + after the whole block, so the second quadrant read ctx 10 where the oracle reads 11 (base 1 from + its left neighbour inside the same block). Now recorded per unit inside the loop; the + post-`record_split_luma` replay stays, because that call would otherwise clobber them whole-block. + +Files: `crates/ec-av1/src/decode.rs` (mu-chunk loop + `chroma_ctx_offset` + per-unit record + +`read_plane`'s chroma `skip_ctx`), `crates/ec-av1/src/cdf.rs` (4 tables), +`crates/ec-av1/src/cdf_state.rs` (`txb_skip_chroma_32` 3 -> 6 rows). + +EVIDENCE: `$HOME/.cache/sb128b-work/{s44.obu,ref44.yuv,ours44.yuv.f0.yuv,ref.ladder}` | +aomenc gate-arm-3 recipe (seed 44 gradients 256x256 cq63 `--sb-size=128 --cpu-used=0 +--enable-tx-size-search=0 ...`), `EC_TRACE_COEFF` ladders of aomdec and `dump_yuv`, then +`dump_yuv` vs `ffmpeg -pix_fmt yuv420p` | **48 `txb_skip` symbols, ranges identical one for one; +0 of 98304 samples differ (pixel-exact)**. Before the fix: 60857 luma samples differed. + +REFUSAL LIFTED (with its gate): `a 128x128 PARTITION_NONE block (...)` deleted from `decode.rs` and +`refusal_inventory.rs`; `a_real_aomenc_key_frame_with_a_128x128_none_partition_decodes_pixel_exact` +un-`#[ignore]`d. +EVIDENCE: `cargo test -p ec-av1 --lib -- a_real_aomenc_key_frame_with_a_128x128_none_partition_decodes_pixel_exact --nocapture` | +4 real-aomenc arms (384x384 seed 42 cq63, 384x384 seed 43 cq55, 256x256 seed 44 cq63, 384x384 seed 45 +10-bit) decoded vs ffmpeg | **ok — 4/4 pixel-exact, 0 named refusals, `part128_none_hits=31`** +(9+9+4+9 128-NONE roots). Sibling gates `a_real_aomenc_128x128_superblock_stream_decodes_pixel_exact`, +`refusal_inventory`, `gate_coverage` re-run green in the same invocation (14 passed / 0 failed). + +## TASK B — the 2 inherited 10-bit reds were an ENCODER RECIPE defect + +`git show main:crates/ec-av1/src/stream.rs` vs the lane's: r2 rewrote `--min-partition-size=16` to +`32` at **13** call sites that main has at 16, including both failing gates. 32 removes the 16-level +the rect/AB gates assert. Reverted all 13 (the lane's own two 128 gates keep their deliberate 32). +EVIDENCE: `cargo test -p ec-av1 --lib -- a_real_aomenc_10bit_rect_and_ab_partitions_decode_pixel_exact a_real_aomenc_10bit_stream_with_a_32_level_ab_partition_decodes_pixel_exact refusal_inventory gate_coverage` | +recipe reverted, rebuilt, re-run | **ok — 14 passed, 0 failed**. Class: +[[gate-recipe-confound]] / the ledger's "a gate that decodes pixel-exact with counter 0 is an +encoder-recipe defect". Swept: those 13 are every 16->32 rewrite in the lane. + +## TASK C — merges + +`git merge main` twice: 7a47fc1 (one conflict, `decode.rs`'s skipped-block arm: took main's +lane-hgkf per-TU prediction + `true_width` guard + `SKIP_SPLIT_TX_HITS`, broadened its condition +from `tx_select && logical_tx < side` to `logical_tx < side` because a 128 block's transform is +TX_64X64 with no tx-depth syntax; the counter keeps its narrow `tx_select` meaning), then 18bf7dc +(= lane-sb128 5ea5ec8; three conflicts in `stream.rs`, ALL resolved to main's side per the batch +coordinator, so main's single seam gate `a_real_aomenc_128x128_superblock_stream_decodes_pixel_exact` +survives and lane-oddh's seam refusal stays deleted). `cdf.rs` merged clean; its NZ_MAP and +FILTER_INTRA regions are byte-identical to main's (`git diff main -- crates/ec-av1/src/cdf.rs` shows +only the four new `TXB_SKIP_CHROMA_32_BIG*` tables). + +## Suite + +EVIDENCE: `$HOME/.cache/sb128b-suite-r3.log` (unit `sb128b-suite-r3-1788323779.service`, tip +`7ceb309`) | `EC_NOMEMGUARD=1 EC_AV1_REQUIRE_AOMENC=1 cargo test -p ec-av1 --lib -j3` | +**test result: ok. 371 passed; 0 failed; 32 ignored; 473.61s** — GREEN. + +## ReelC key frame + +EVIDENCE: `$HOME/.cache/sb128b-work/{reelckf0.obu,reelcours.yuv.f0.yuv,ref.yuv}` | r2's recipe +(`ffmpeg -t 2 -c:v copy -f obu` off the film, 1920x792 yuv420p10le), `dump_yuv` under a 6G scope vs +ffmpeg's rawvideo | **`cmp` says BYTES EQUAL — 4 561 920 bytes, 0 differing samples.** + +Film probe on the 2 s cut (`decode_probe reelc2s.obu`) still stops at +`an inter frame under a 128x128 superblock (this decoder's inter tile path recurses a 64x64 +superblock root only)` — main 18bf7dc (lane-sb128 5ea5ec8) did NOT lift this one on this tree. + +## Open residue + +- deferred: `a 128x128 superblock HORZ/VERT or AB partition` — not started; every 128 root in the + four gate arms resolves NONE or SPLIT, so nothing here is measured. Unblocked by an aomenc recipe + that actually emits a 128-level HORZ/VERT (r2's seed-42 "HORZ/VERT at 128" sighting was our own + desync talking — class [[refusal-from-own-desync]]: with the entropy fixed, that same stream + reads nine NONE roots). +- deferred: `a 128x128 superblock PARTITION_NONE root on an inter frame` and + `an inter frame under a 128x128 superblock` (the ReelC blocker) — inter path untouched this round; + unblocked by the inter tile path recursing a 128 root. +- deferred: the `--enable-tx-size-search=1` arm at 128 (a read tx_depth under a 128 NONE root) — + the four arms all pin `=0`; unblocked now that the NONE arm is exact, so it is a one-arm follow-up.