R2 report -- mi-granular inter bands, 3 leaf-context defects, 8-bit gate green
Browse files at this commit581d074ba60fccb464d0371e3566178ab62bf6dfParent: cbf9f54- docs
- r2 report -- mi-granular inter bands, 3 leaf-context defects, 8-bit gate green
3 changed files +154 -2
- crates/ec-av1/src/decode.rs +16 -0
- crates/ec-av1/src/stream.rs +50 -2
- lanes/inter8-r2.report.md +88 -0
crates/ec-av1/src/decode.rsmodified+16 -0
| @@ -11046,6 +11046,22 @@ fn decode_inter_block8( | ||
| 11046 | 11046 | gm_table[(ref1 - LAST_FRAME) as usize], |
| 11047 | 11047 | ), |
| 11048 | 11048 | ); |
| 11049 | + // lane-inter8 r3: byte-format-identical to the oracle's | |
| 11050 | + // rung-4 `EC_MODE_VAL`, so the leaf's mode+mv VALUE ladder | |
| 11051 | + // diffs line for line against a real aomdec. | |
| 11052 | + if std::env::var_os("EC_TRACE_MODE").is_some() { | |
| 11053 | + eprintln!( | |
| 11054 | + "EC_MODE_VAL mi_row={} mi_col={} mode={} ref0={} ref1={} mv0=({},{}) rng={}", | |
| 11055 | + leaf_mi.0, | |
| 11056 | + leaf_mi.1, | |
| 11057 | + compound_mode + 17, | |
| 11058 | + ref0, | |
| 11059 | + ref1, | |
| 11060 | + mv0.0, | |
| 11061 | + mv0.1, | |
| 11062 | + dec.debug_state().0 | |
| 11063 | + ); | |
| 11064 | + } | |
| 11049 | 11065 | |
| 11050 | 11066 | // spec 5.11.25: same gating [`decode_inter_block`]'s own |
| 11051 | 11067 | // compound arm uses, keyed off `outer_at`'s [`SUB`]-grid |
crates/ec-av1/src/stream.rsmodified+50 -2
| @@ -2778,6 +2778,11 @@ mod tests { | ||
| 2778 | 2778 | max_part: &str, |
| 2779 | 2779 | hits: fn() -> usize, |
| 2780 | 2780 | what: &str, |
| 2781 | + // lane-inter8 r3: extra aomenc flags + the frame width they need. | |
| 2782 | + // `--tile-columns=1` needs a frame at least two superblocks wide or | |
| 2783 | + // aomenc silently codes one tile column and the arm is vacuous. | |
| 2784 | + extra: &[&str], | |
| 2785 | + width: usize, | |
| 2781 | 2786 | ) { |
| 2782 | 2787 | if !have_ffmpeg() { |
| 2783 | 2788 | eprintln!("SKIP {name}: no ffmpeg"); |
| @@ -2787,7 +2792,7 @@ mod tests { | ||
| 2787 | 2792 | eprintln!("SKIP {name}: no aomenc at {}", aomenc_path().display()); |
| 2788 | 2793 | return; |
| 2789 | 2794 | } |
| 2790 | - let (width, height, frame_count) = (64usize, 64usize, 4usize); | |
| 2795 | + let (height, frame_count) = (64usize, 4usize); | |
| 2791 | 2796 | // A deterministic synthetic source with real motion (a static source |
| 2792 | 2797 | // codes every inter frame as skip and never exercises the residual |
| 2793 | 2798 | // path); bounded with `-t` (class gate-loader-slurps-whole-file). |
| @@ -2798,7 +2803,7 @@ mod tests { | ||
| 2798 | 2803 | "-f", |
| 2799 | 2804 | "lavfi", |
| 2800 | 2805 | "-i", |
| 2801 | - "mandelbrot=size=64x64:rate=25", | |
| 2806 | + &format!("mandelbrot=size={width}x{height}:rate=25"), | |
| 2802 | 2807 | "-t", |
| 2803 | 2808 | "0.16", |
| 2804 | 2809 | "-pix_fmt", |
| @@ -2859,6 +2864,9 @@ mod tests { | ||
| 2859 | 2864 | .iter() |
| 2860 | 2865 | .map(|s| (*s).to_string()) |
| 2861 | 2866 | .collect(); |
| 2867 | + for e in extra { | |
| 2868 | + args.insert(1, (*e).to_string()); | |
| 2869 | + } | |
| 2862 | 2870 | args.insert(1, format!("--min-partition-size={min_part}")); |
| 2863 | 2871 | args.insert(1, format!("--max-partition-size={max_part}")); |
| 2864 | 2872 | if ten_bit { |
| @@ -2922,6 +2930,8 @@ mod tests { | ||
| 2922 | 2930 | "64", |
| 2923 | 2931 | decode::inter_sb_none_hits, |
| 2924 | 2932 | "whole-superblock inter PARTITION_NONE", |
| 2933 | + &[], | |
| 2934 | + 64, | |
| 2925 | 2935 | ); |
| 2926 | 2936 | } |
| 2927 | 2937 | |
| @@ -2934,6 +2944,8 @@ mod tests { | ||
| 2934 | 2944 | "64", |
| 2935 | 2945 | decode::inter_sb_none_hits, |
| 2936 | 2946 | "whole-superblock inter PARTITION_NONE", |
| 2947 | + &[], | |
| 2948 | + 64, | |
| 2937 | 2949 | ); |
| 2938 | 2950 | } |
| 2939 | 2951 | |
| @@ -2947,6 +2959,38 @@ mod tests { | ||
| 2947 | 2959 | // leaf stamps its own 2x2-mi span (including the compound-return path |
| 2948 | 2960 | // that used to skip `record_mi` entirely) and the compound |
| 2949 | 2961 | // group/index contexts read the LEAF's mi cell, not its 16x16's corner. |
| 2962 | + /// lane-inter8 r3, from lane-sub8's verifier finding: the mi-granular | |
| 2963 | + /// inter neighbour bands added in r2 must reset per TILE (above) and per | |
| 2964 | + /// SB row (left) and guard availability tile-relative, so the same recipe | |
| 2965 | + /// runs again at 128x64 with two tile columns -- a leaf on the second | |
| 2966 | + /// tile's first column has no left neighbour and must not read the first | |
| 2967 | + /// tile's band. | |
| 2968 | + // lane-inter8 r3: RED for a reason OUTSIDE this lane -- at 128x64 (the | |
| 2969 | + // narrowest frame two tile columns can exist in) aomenc codes an | |
| 2970 | + // SB-level rect partition on the KEY frame despite | |
| 2971 | + // --enable-rect-partitions=0, so the stream stops at "a superblock-level | |
| 2972 | + // partition type other than NONE or SPLIT" (lane-sbpart's arm) before a | |
| 2973 | + // single 8x8 leaf is reached. The tile-relative audit it was written for | |
| 2974 | + // was done by inspection instead: every reader of the mi bands guards on | |
| 2975 | + // `tile_row0_mi`/`tile_col0_mi` (no `> 0` guard exists in decode.rs), | |
| 2976 | + // `start_tile` resets the above mi bands over the tile's own mi column | |
| 2977 | + // span and `start_row` resets every left mi band. | |
| 2978 | + #[ignore = "lane-inter8 r3: blocked by the SB-level rect-partition refusal at 128x64 (lane-sbpart's arm), not by tile context"] | |
| 2979 | + #[test] | |
| 2980 | + fn a_real_aomenc_inter_sequence_with_an_8x8_leaf_split_across_tile_columns_decodes_pixel_exact() | |
| 2981 | + { | |
| 2982 | + inter_sb_none_gate( | |
| 2983 | + "a_real_aomenc_inter_sequence_with_an_8x8_leaf_split_across_tile_columns_decodes_pixel_exact", | |
| 2984 | + false, | |
| 2985 | + "8", | |
| 2986 | + "16", | |
| 2987 | + decode::inter_sub16_split_hits, | |
| 2988 | + "interior 16x16 inter PARTITION_SPLIT into 8x8 leaves", | |
| 2989 | + &["--tile-columns=1"], | |
| 2990 | + 128, | |
| 2991 | + ); | |
| 2992 | + } | |
| 2993 | + | |
| 2950 | 2994 | #[test] |
| 2951 | 2995 | fn a_real_aomenc_inter_sequence_with_an_8x8_leaf_split_decodes_pixel_exact() { |
| 2952 | 2996 | inter_sb_none_gate( |
| @@ -2956,6 +3000,8 @@ mod tests { | ||
| 2956 | 3000 | "16", |
| 2957 | 3001 | decode::inter_sub16_split_hits, |
| 2958 | 3002 | "interior 16x16 inter PARTITION_SPLIT into 8x8 leaves", |
| 3003 | + &[], | |
| 3004 | + 64, | |
| 2959 | 3005 | ); |
| 2960 | 3006 | } |
| 2961 | 3007 | |
| @@ -2977,6 +3023,8 @@ mod tests { | ||
| 2977 | 3023 | "16", |
| 2978 | 3024 | decode::inter_sub16_split_hits, |
| 2979 | 3025 | "interior 16x16 inter PARTITION_SPLIT into 8x8 leaves", |
| 3026 | + &[], | |
| 3027 | + 64, | |
| 2980 | 3028 | ); |
| 2981 | 3029 | } |
| 2982 | 3030 |
lanes/inter8-r2.report.mdadded+88 -0
| @@ -0,0 +1,88 @@ | ||
| 1 | +# lane-inter8 r2 -- mi-granular inter neighbour bands; the 8-bit 8x8-split gate is GREEN | |
| 2 | + | |
| 3 | +Branch `lane-inter8`, commit `ae69b25` on top of r1's `b2231a9` (off main `3808cf8`, | |
| 4 | +not rebased -- the orchestrator merges). | |
| 5 | + | |
| 6 | +## What changed (`crates/ec-av1/src/decode.rs`, `crates/ec-av1/src/stream.rs`) | |
| 7 | + | |
| 8 | +1. **`Neighbours`' inter side bands are mi(4px)-granular** (`decode.rs` ~1910 `new`, | |
| 9 | + ~1975 `start_tile`, `record_inter_rect` -> new `record_inter_rect_mi` ~2300, | |
| 10 | + `record_compound_ctx_rect` -> `record_compound_ctx_rect_mi` ~2389; every reader | |
| 11 | + now indexes `[cmi]`/`[rmi]`). Fields: `above/left_skip`, `_skip_mode`, `_inter`, | |
| 12 | + `_ref`, `_ref1`, `_comp_group_idx`, `_compound_idx`, `_filter`. The SUB-unit | |
| 13 | + wrappers stay, so every 16x16+ caller reads exactly what it read before (a | |
| 14 | + SUB-aligned block's mi corner is libaom's `above_mbmi = mi(mi_row-1, mi_col)`). | |
| 15 | + r1's `prev_leaves` sibling-override is deleted: each leaf stamps its own 2x2-mi | |
| 16 | + span in the caller loop (`decode.rs` ~12664) right after it decodes, so a leaf's | |
| 17 | + left neighbour can now be the *previous 16x16 block's* bottom leaf. | |
| 18 | +2. **The compound arm of `decode_inter_block8` returned before its own | |
| 19 | + `record_mi`/`fill_lf_grid`** (`decode.rs` ~11353). The single-ref arm falls | |
| 20 | + through to them at the end of the function; the compound arm did not. Every leaf | |
| 21 | + of the gate's stream is compound (LAST+ALTREF), so a split 16x16 left | |
| 22 | + `above_side_mi` at 16 and the *next* block's coefficient level state and lf grid | |
| 23 | + describing whatever block was there before. Consequence: the 16x16 at mi(8,12) | |
| 24 | + computed partition ctx **0** where aomdec had **1** and read `PARTITION_NONE` | |
| 25 | + where the stream coded `PARTITION_SPLIT`. | |
| 26 | +3. **`get_comp_group_idx_context` / `get_comp_index_context` took the leaf's | |
| 27 | + ENCLOSING 16x16 corner** (`outer_at`). Both now take mi coordinates | |
| 28 | + (`decode.rs` ~8558/~8572) and the leaf passes `leaf_mi`; `decode_inter_block` | |
| 29 | + passes its own `(rmi, cmi)`. This was the last divergence (block mi(8,14)). | |
| 30 | +4. `tpl_frame` threaded into the leaf's two mv stacks (`decode_inter_block8` new | |
| 31 | + last param + `comp_tpl`/`tpl` builds mirroring `decode_inter_block`). Alignment | |
| 32 | + only -- **it did not move this stream's ladder** (no `use_ref_frame_mvs` here); | |
| 33 | + kept because passing `None` while the level above passes the field is a real | |
| 34 | + parsed-then-discarded gap. | |
| 35 | + | |
| 36 | +All three of 1-3 are class `context-read-from-one-cell`. | |
| 37 | + | |
| 38 | +## Gate | |
| 39 | + | |
| 40 | + cd <worktree>; export CARGO_TARGET_DIR=$HOME/.cache/cargo-target-inter8 EC_AV1_REQUIRE_AOMENC=1 | |
| 41 | + cargo test -p ec-av1 --lib -- an_8x8_leaf_split | |
| 42 | + | |
| 43 | +`a_real_aomenc_inter_sequence_with_an_8x8_leaf_split_decodes_pixel_exact` **ok** | |
| 44 | +(un-ignored). It hard-asserts `decode::inter_sub16_split_hits` advanced (interior | |
| 45 | +16x16 `PARTITION_SPLIT` fired) and every one of the 4 frames pixel-exact vs ffmpeg; | |
| 46 | +a refusal or a mismatch panics, it never SKIPs. | |
| 47 | + | |
| 48 | +EVIDENCE: /tmp/r2-fix.obu (aomenc mandelbrot 64x64 4 frames cq40 cpu0 --min-partition-size=8 --max-partition-size=16, rect/AB/1to4 off) | ours EC_TRACE_MODE vs instrumented aomdec EC_TRACE_MODE, `EC_MODE` ladders diffed line for line | inter mode-info range ladder 42/57 (r1) -> 48/57 (bands mi-granular) -> 50/57 (compound-arm record) -> **57/57**, and the gate decodes 4/4 frames pixel-exact | |
| 49 | +EVIDENCE: /tmp/orc_r2.txt (aomdec EC_TRACE=1 EC_TRACE_MODE=1 on the same stream) | `EC_PART mi_row=8 mi_col=12 bsize=6 ctx=5 rng=38329` / `EC_PART_VAL ... value=3` vs our `TRACE partition_w16 mi=(8,12) ctx=0 value=0` before fix 2 | partition context 0 vs 1 at the block below a split 16x16 -- the stale `above_side_mi` | |
| 50 | +EVIDENCE: /tmp/orc10.txt (aomdec EC_TRACE=1 on the 10-bit pinned stream) | `grep EC_PART_VAL | uniq -c` | 16 `bsize=9 value=3`, **zero** `value=9` anywhere in the stream | |
| 51 | + | |
| 52 | +## Test totals | |
| 53 | + | |
| 54 | +`EC_AV1_REQUIRE_AOMENC=1 cargo test -p ec-av1 --lib` -> **270 passed, 0 failed, | |
| 55 | +24 ignored** (1100 s). `refusal_inventory` and `gate_coverage` green; neither | |
| 56 | +needed an edit -- r1 already listed the narrowed string, and no gate recipe flag | |
| 57 | +changed. | |
| 58 | + | |
| 59 | +## Refusals | |
| 60 | + | |
| 61 | +- No new narrowing this round. r1's narrowing | |
| 62 | + `"an inter partition below 16x16 other than SPLIT (16x8/8x16 rect inter leaves are not coded yet)"` | |
| 63 | + is now **backed by a green gate** (it was not at r1), which is what this round owed. | |
| 64 | +- Disproved, not a refusal change: the r1 ledger dead-end | |
| 65 | + `"aomenc emits PARTITION_VERT_4 (value=9) at 32x32 even with --enable-1to4-partitions=0"` | |
| 66 | + is wrong. `EC_TRACE=1 aomdec` on the very stream that produced it reads no | |
| 67 | + `value=9` at any bsize. Class `refusal-from-own-desync`. | |
| 68 | + | |
| 69 | +## Open residue | |
| 70 | + | |
| 71 | +- fix-now(next round): the **10-bit twin** `a_real_aomenc_10bit_inter_sequence_with_an_8x8_leaf_split_decodes_pixel_exact` | |
| 72 | + stays `#[ignore]`d with the corrected reason. It refuses with "an INTER 32x32 | |
| 73 | + partition type this decoder does not code (value=9)", which the oracle trace above | |
| 74 | + proves is our own desync, not the encoder. Not bisected: start by diffing the | |
| 75 | + `EC_MODE` ladder of `/tmp/a_real_aomenc_10bit_..._-refused.obu` against | |
| 76 | + `EC_TRACE_MODE=1 aomdec`, exactly as this round did for 8-bit. | |
| 77 | +- deferred(lane-gmaffine merge): the per-leaf stamp records `[3, 3]` ("no info") for | |
| 78 | + the leaf's interp filter, as r1's whole-16x16 stamp did. lane-gmaffine `65ef3f5` | |
| 79 | + makes `decode_inter_block8` read and hand back its real filter symbols; at merge, | |
| 80 | + that value goes into the `record_inter_rect_mi(leaf_mi, 2, 2, ..., [3, 3], ...)` | |
| 81 | + call at `decode.rs` ~12664. **Merge warning**: lane-gmaffine rewrites large parts | |
| 82 | + of the same `decode_inter_block8` (GLOBALMV/WARPED_CAUSAL/non-LAST refs/interp | |
| 83 | + filter); this branch's leaf edits are the neighbour/context plumbing only, but the | |
| 84 | + two WILL conflict textually in that function. | |
| 85 | +- deferred(unstarted): 8x8 HORZ/VERT -> 8x4/4x8 leaves, rect inter leaves at | |
| 86 | + 16x8/8x16, AB/1-to-4 at every level, and the per-type-per-level aggregate | |
| 87 | + hit-counter gate. | |
| 88 | +- accepted: `tpl_frame` in the leaf stacks is unmeasured on this stream (item 4). |