From 985203794bdca90b28f71713a859e4fdd94cc2b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Wed, 2 Sep 2026 06:54:21 +0300 Subject: [PATCH] fix(av1): keep the MV stack's top-right grid probe (the has_top_right port red-lined 8 gates); docs(sb128): r2 report --- crates/ec-av1/src/mvstack.rs | 6 +- lanes/sb128-r2.report.md | 123 +++++++++++++++++++++++++++++++++++ 2 files changed, 125 insertions(+), 4 deletions(-) create mode 100644 lanes/sb128-r2.report.md diff --git a/crates/ec-av1/src/mvstack.rs b/crates/ec-av1/src/mvstack.rs index 08b11d34..6c77a20b 100644 --- a/crates/ec-av1/src/mvstack.rs +++ b/crates/ec-av1/src/mvstack.rs @@ -816,8 +816,7 @@ pub fn find_mv_stack_with_sign_bias( &mut newmv_count, &mut processed_cols, ); - let found_top_right = has_top_right(mi_row, mi_col, bw4, bh4) - && scan_top_right( + let found_top_right = scan_top_right( grid, mi_row, mi_col, @@ -1576,8 +1575,7 @@ pub fn find_mv_stack_compound( &mut newmv_count, &mut processed_cols, ); - let found_top_right = has_top_right(mi_row, mi_col, bw4, bh4) - && scan_top_right_compound( + let found_top_right = scan_top_right_compound( grid, mi_row, mi_col, diff --git a/lanes/sb128-r2.report.md b/lanes/sb128-r2.report.md new file mode 100644 index 00000000..d45b6442 --- /dev/null +++ b/lanes/sb128-r2.report.md @@ -0,0 +1,123 @@ +# lane-sb128 r2 — the 128 root on INTER frames + +Branch `lane-sb128` (merged `main` 0df090a first, clean), worktree `edith_codecs-sb128`, +commit `8b4a36f`. + +## Film first + +Both probes ran with the inter refusal LIFTED locally (the code as committed refuses again — +see Residual), i.e. these are what the new inter-128 path reaches: + +EVIDENCE: `/tmp/.../b6d8a07f.../scratchpad/reelc-head.obu` | release `decode_probe` (6G scope) +| `REFUSED: unsupported: AV1 tile (a 128x128 superblock partition other than SPLIT +(NONE/HORZ/VERT and the four AB arms at the 128 root are not decoded))` after 17 frame headers +— i.e. ReelC's own head reaches a TASK-B arm, not the inter gap. + +EVIDENCE: `/tmp/.../cdc46329.../scratchpad/reelc5.obu` | release `decode_probe` (6G scope) | +`REFUSED: unsupported: AV1 tile (a 1:4 partition below 16x16 (PARTITION_HORZ_4/VERT_4, four +16x4/4x16 strips ...))` after 78 frame headers, `rect4_32: horz=8 vert=28 coded=32` — r1's stop +on this file ("a HORZ/VERT intra strip below 16x16 with a split transform") was lifted by the +merge from main; the film now stops on a sub-16 1:4 partition, another lane's cluster. + +With the committed tree the product path stops earlier, at the restored inter refusal. + +## What changed + +- `crates/ec-av1/src/decode.rs` + - `read_sb128_root()` (~11250): the 128 root extracted out of the key-frame loop — one + `read_lr` over the whole 128x128, one `partition_w128` symbol (8 symbols, `gather_of` + + `VERT_ALIKE128`/`HORZ_ALIKE128` at the frame edge), refusal by name for the seven + non-SPLIT arms. Both tile loops call it, so they cannot drift apart. + - `decode_inter_frame_tile_with_cdfs` (~18380, ~18570): `let sb128 = sb128();` and the + superblock loop replaced by `sb_visit_order(...)` + the 128 prologue. `delta_q`/`delta_lf` + already key off `sb_mi_cur()`; `CDEF_TRANSMITTED` is reset per 64x64 quadrant, which is + exactly libaom `read_cdef`'s per-quadrant `cdef_transmitted[index]`, index + `(mi_col&16)>>4 + 2*((mi_row&16)>>4)`. + - warp-sample `has_top_right` (13470) hardcoded `SB_MI` (a 64x64 superblock); now delegates + to the single sb-aware port. +- `crates/ec-av1/src/mvstack.rs`: `has_top_right()` ported from libaom `mvref_common.c:264` + (`sb_mi_size = mi_size_wide[seq.sb_size]`, so the mask loop runs one level further at 128); + both `scan_top_right` and `scan_top_right_compound` are now gated on it instead of a bare + "is the grid cell populated" probe. corner-cut in the doc: the three rect/`VERT_A` shape + refinements are not ported (ceiling = rect/AB INTER leaves, refused by name today). +- `crates/ec-av1/src/stream.rs`: the r1 refusal test replaced by the r2 gate (below), plus the + `sb128_r2_control_sb64` control; the inter refusal restored with the residual named. + +MEASURED, against the charter's premise: libaom `check_sb_border` (mvref_common.c:318) uses +`mi_size_wide[BLOCK_64X64]`, **hardcoded**, NOT `seq_params.sb_size` — the charter said to port +it as sb-derived. `mvstack.rs`'s `sb_mask = 16` is therefore already correct at 128 and was +left alone. `has_top_right` (line 266) is the one that is sb-derived. + +## Gate + +`a_real_aomenc_inter_sequence_with_128x128_superblocks_decodes_pixel_exact` — real aomenc +`--sb-size=128 --max-partition-size=64 --min-partition-size=32 --limit=8`, default +lag/alt-ref (1 hidden frame), gradients+`noise=all_seed=53:alls=12` (a clean gradient codes +with `cdef_bits=0` and the cdef counter stays 0), 8-bit and 10-bit, compared in DECODE order +frame by frame against the instrumented aomdec (`decode_all_frames_vs_oracle`, hidden frames +included), per-attempt counter deltas hard-asserted (`part128_symbols>=3`, `cdef_idx_hits>=1`, +`tmv_hits>=1`). It is `#[ignore]`d: it is a reproducer, not a passing gate. + +EVIDENCE: `cargo test -p ec-av1 --lib -- --nocapture inter_sequence_with_128x128` | +8-frame aomenc encode decoded in decode order vs aomdec | frames 0-5 and 7-8 byte-exact, +`decode-order frame 6 of 9 (8 shown, 1 hidden) differs at byte 24070 (ours 43 vs 42), 996 +bytes differ` — entropy stream in sync (a desync would corrupt the tail, not 996 bytes). + +EVIDENCE: `cargo test -p ec-av1 --lib -- --ignored --nocapture sb128_r2_control_sb64` | the +SAME source/recipe encoded at `--sb-size=64` | `control sb64: 9 frames exact (1 hidden)` — +the residual is sb128-specific, not a pre-existing inter defect the new recipe uncovered. + +Ablations run on the way (each a full gate run): `--enable-cdef=0` still mismatches (380 bytes, +byte 40960) so it is not the cdef read; the `has_top_right` port and the warp-sample fix each +changed nothing on this stream (both are libaom-faithful and stay). + +## Refusals + +- `an inter frame under a 128x128 superblock (...)` — **NOT lifted**, restored in `stream.rs` + with the residual named in the comment; still listed in `refusal_inventory.rs`. + fix-now(next round): identify the frame-6 block (the stream is pinned by the gate's panic + message under `/tmp/ec-av1-sb128-inter-8-/in.obu`; re-pin it, then range-ladder ours vs + aomdec on frame 6 — the entropy stream matches, so start at the PREDICTION side: OBMC + neighbour walk and mvstack candidates for the quadrant at mi_row 16..31 of an SB row). +- `a 128x128 superblock partition other than SPLIT (...)` — TASK B, deferred: 128-level + NONE/HORZ/VERT/AB — needs a multi-TU chroma loop in `decode_block` (a 128x128 block is + 2x2 TX_64X64 luma + 2x2 TX_32X32 chroma) — unblocked by that loop; ReelC's head stops here. +- `intrabc under a 128x128 superblock (...)` — accepted, unchanged. + +## Suite + +`cargo test -p ec-av1 --lib` under a user systemd unit, log `$HOME/.cache/sb128-suite-r2.log`: +tail appended below. + +``` +test result: FAILED. 348 passed; 8 failed; 31 ignored; finished in 522.44s +``` +- `mvstack::tests::all_same_mv_neighbourhood_dedupes_to_one_entry` — CAUSED BY THIS ROUND and + FIXED: gating `scan_top_right` on the new `has_top_right` red-lined it (the unported rect/ + `VERT_A` refinements). The MV stack keeps its grid probe; only the warp-sample gather uses + the port. Re-run after the fix: `ok`. +- The other 7 (`*_32_level_ab_partition_*`, `*_rect_and_ab_partitions_*`, + `*_superblock_level_1to4_partition_*`, `*_split_transform_horz_vert_strip_*`, + `*_chroma_is_a_4to1_or_sub8_rect_*`, `*_filter_intra_on_a_horz_vert_strip_*`) STILL FAIL after + that fix, and they fail on a FIRING COUNTER, not on pixels: e.g. "16 attempt(s) decoded + pixel-exact but HORZ_A_32 never fired". Every one of them is a rect/AB gate owned by the + lanes main merged today (rectsplitx/rect1d/fiinter/modectx); this lane's only non-sb128 code + change is the warp-sample `has_top_right` delegate, which is bit-identical at `sb_size == 64` + (`sb_mi_cur() == 16`), and all 7 streams are 64-superblock streams whose decode is exact. + NOT PROVEN either way inside this round's budget. + deferred: attribute the 7 — build `main` 0df090a in a detached worktree with its own + CARGO_TARGET_DIR and run the same 7 by name; if red there, they are a merge residue, not + this lane's — unblocked by one clean-tree suite run. + +## Coordinator items from the r1 verifier + +- (1) content-free r1 gate arms (mandelbrot + `--deltaq-mode=2` / `--enable-restoration=1`): + deferred — not started; the r2 gate already carries the noise/cdef fix for its own arms — + unblocked by a round that owns the r1 gate recipe. +- (2) `Reach::table(64)` falling back to the 16x16 rows: deferred — inert today, and TASK B + (the 128-level NONE/HORZ/VERT/AB arms that would hit it) is not started this round. +- (3) lane-oddh's `"a sequence using 128x128 superblocks on a frame larger than 64x64"` + refusal + its gate: NOT PRESENT in `main` 0df090a at merge time (`grep` finds neither the + string nor an asserting gate), so nothing to delete. +- TASK B (128-level NONE/HORZ/VERT/AB roots): deferred, not started — needs the chroma multi-TU + loop in `decode_block` first — unblocked by that loop.