From 3c024bfcbab29d958f1708db1ac8a48654a071ee 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 05:36:41 +0300 Subject: [PATCH] feat(av1): OBMC on a 16x8/8x16 inter leaf -- refusal lifted, gated by an --enable-obmc=1 arm The r3 refusal is disproved on this tree: an EC_OBMC rung in both our decoder and the oracle aomdec emits the same 9 neighbour invocations on the exact stream r3 measured, and all six EC_AV1_PREFILT_DUMP frames are byte-identical. Ship the blend, count it (OBMC_RECT_LEAF_HITS), and prove it with 16 extra --enable-obmc=1 attempts in the 16-level rect leaf gate (10 blends 8-bit / 4 blends 10-bit, 0 mismatches). Also re-measures r2's ignored 32x16/16x32 rect-residual gate: still red, and the blocker is now rectangular INTRA prediction (10 of 12 refusals), not this lane. --- crates/ec-av1/src/decode.rs | 34 ++++++--- crates/ec-av1/src/refusal_inventory.rs | 1 - crates/ec-av1/src/stream.rs | 40 ++++++++--- lanes/inter4-r4.report.md | 98 ++++++++++++++++++++++++++ 4 files changed, 153 insertions(+), 20 deletions(-) create mode 100644 lanes/inter4-r4.report.md diff --git a/crates/ec-av1/src/decode.rs b/crates/ec-av1/src/decode.rs index 1239ae48..c84cb856 100644 --- a/crates/ec-av1/src/decode.rs +++ b/crates/ec-av1/src/decode.rs @@ -1351,6 +1351,19 @@ pub(crate) fn wii_hits() -> usize { WII_HITS.with(|c| c.get()) } +// lane-inter4 r4: how many 16x8/8x16 INTER LEAVES actually ran the OBMC +// blend -- the gate's proof that `--enable-obmc=1` reached this shape (the +// r3 refusal's replacement: prefilt frames are bit-exact vs an instrumented +// aomdec, neighbour list included). +thread_local! { + static OBMC_RECT_LEAF_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; +} + +/// Current value of [`OBMC_RECT_LEAF_HITS`]. +pub(crate) fn obmc_rect_leaf_hits() -> usize { + OBMC_RECT_LEAF_HITS.with(|c| c.get()) +} + /// Current value of [`OBMC_HITS_8`]. pub(crate) fn obmc_hits_8() -> usize { OBMC_HITS_8.with(|c| c.get()) @@ -12827,18 +12840,17 @@ fn obmc_blend( 5..=8 => 3, _ => 4, }; - // lane-inter4 r3: OBMC on a 16-level rect inter leaf mismatches ffmpeg - // (192x128 testsrc-style motion, cq 22, `--enable-obmc=1`: 5302 luma - // pixels of frame 5 wrong, max |delta| 84, while the SAME recipe with - // `--enable-obmc=0` decodes 5 rect-leaf-carrying attempts pixel-exact). - // The blend geometry here matches libaom `build_obmc_inter_pred_*` for - // these shapes, so the cause is upstream (neighbour walk or mv stack for - // a 2:1 leaf) and unidentified -- refuse by name rather than ship wrong - // pixels. Deleting this block is the whole lift once it is found. + // lane-inter4 r4: r3 refused OBMC on a 16x8/8x16 leaf (5302 luma pixels + // of one frame wrong). Re-measured on this tree with an `EC_OBMC` rung in + // both decoders on that exact stream: the neighbour lists agree entry for + // entry (position, span, mv, ref, size, filter) and all six pre-filter + // frames are byte-identical to the instrumented aomdec's. The refusal is + // gone; the counter below is what the gate's `--enable-obmc=1` arm reads. + // The only decode-path change between r3's measurement and this one is the + // lane-interbis merge (`build_motion_field`'s compound slot walk), which + // moves temporal MV candidates -- not bisected further. if matches!((write_w, write_h), (16, 8) | (8, 16)) { - return Err(unsupported( - "OBMC on a 16x8/8x16 inter leaf (blend mismatches the reference on this shape)", - )); + OBMC_RECT_LEAF_HITS.with(|c| c.set(c.get() + 1)); } let overlap_above = write_h / 2; let overlap_left = write_w / 2; diff --git a/crates/ec-av1/src/refusal_inventory.rs b/crates/ec-av1/src/refusal_inventory.rs index 10d6ece0..d0de1286 100644 --- a/crates/ec-av1/src/refusal_inventory.rs +++ b/crates/ec-av1/src/refusal_inventory.rs @@ -65,7 +65,6 @@ const REFUSALS: &[&str] = &[ "an inter SB-level AB partition (HORZ_A/HORZ_B/VERT_A/VERT_B; this decoder's inter tile path codes a superblock as NONE, SPLIT, HORZ, VERT, HORZ_4 or VERT_4)", "a masked compound 64x64 inter block (compound_type is inferred, not coded, at this size)", "an inter 16x16-level AB or 1:4 partition (HORZ_A/HORZ_B/VERT_A/VERT_B/HORZ_4/VERT_4; this decoder's inter path codes a 16x16 as NONE, HORZ, VERT or SPLIT)", - "OBMC on a 16x8/8x16 inter leaf (blend mismatches the reference on this shape)", "an intra mode this decoder does not code (round 2)", "an intra-coded HORZ/VERT strip needs rectangular intra prediction this decoder does not code yet", // Lifted for the 16x8/8x16 leaf by lane-fistrip; still live one level diff --git a/crates/ec-av1/src/stream.rs b/crates/ec-av1/src/stream.rs index f7aab93d..e7572ac6 100644 --- a/crates/ec-av1/src/stream.rs +++ b/crates/ec-av1/src/stream.rs @@ -1945,10 +1945,10 @@ mod tests { // masked compound, palette, ...) are other lanes' work; // this gate is about hidden frames, not about them. "--enable-warped-motion=0", - // lane-inter4 r3: OBMC on a 16x8/8x16 leaf is a NAMED - // REFUSAL (see decode.rs `obmc_blend`) -- it mismatches - // the reference on this shape, so the gate spells the - // tool off rather than counting its refusals as passes. + // OBMC stays off HERE (this gate is about hidden frames); + // the tool's own coverage is the `obmc*` gates and, on a + // 16x8/8x16 leaf, the `--enable-obmc=1` arm of + // `..._with_a_16_level_rect_leaf_...` (lane-inter4 r4). "--enable-obmc=0", "--enable-masked-comp=0", "--enable-interintra-comp=0", @@ -4891,7 +4891,15 @@ mod tests { // shape additionally needs `default_inter_ext_tx_cdf[2][TX_8X8]` (the // 12-symbol DTT9_IDTX_1DDCT row, only reachable through a rect // transform), which this round did not add. See lanes/inter4-r2.report.md. - #[ignore = "lane-inter4 r2: every real-content attempt stops at the 16x8/8x16 inter leaf or intra-rect-strip refusal before reaching a 32x16/16x32 strip; the rect residual path itself is unproven, not claimed"] + // lane-inter4 r4 re-measured after the 16-level rect inter leaf shipped + // (r3): STILL RED, and the blocker moved -- 12 named refusals over 16 + // 8-bit attempts, 10 of them "an intra-coded HORZ/VERT strip needs + // rectangular intra prediction this decoder does not code yet" and 2 the + // 16-level AB/1:4 inter refusal; 4 attempts decoded with no rect inter + // residual at all and none of them mismatched (tu=0, split=0). Neither + // remaining blocker is this lane's: the gate un-ignores when the intra + // rect strip lands. + #[ignore = "lane-inter4 r4 (re-measured): 12/16 8-bit attempts stop at the intra-rect-strip (10) or 16-level inter AB/1:4 (2) refusal, the other 4 code no rect inter residual -- tu=0, split=0; blocked on rectangular INTRA prediction, not on this lane"] fn a_real_aomenc_inter_sequence_with_a_coded_rectangular_residual_decodes_pixel_exact() { const NAME: &str = "a_real_aomenc_inter_sequence_with_a_coded_rectangular_residual_decodes_pixel_exact"; @@ -5089,7 +5097,14 @@ mod tests { (0u32, 0u32, 0u32, 0u32); let (mut tu_proved, mut split_proved) = (0usize, 0usize); let (mut horz_proved, mut vert_proved, mut sub16_split) = (0u32, 0u32, 0usize); - for attempt in 0..16u32 { + // lane-inter4 r4: attempts 16..32 repeat the same sweep with + // `--enable-obmc=1`. r3 refused OBMC on this shape; r4's + // instrumented-aomdec comparison showed the neighbour list AND + // every pre-filter frame bit-exact, so the arm is a gate now. + let mut obmc_leaf_proved = 0usize; + for attempt in 0..32u32 { + let obmc_arg = if attempt >= 16 { "--enable-obmc=1" } else { "--enable-obmc=0" }; + let attempt = attempt % 16; // Two sources (a translating textured ramp, and testsrc2's // natural motion) x two quantisers x two tx-size-search arms x // two motion steps. @@ -5152,7 +5167,7 @@ mod tests { "--enable-rect-partitions=1", "--enable-ab-partitions=0", "--enable-1to4-partitions=0", "--min-partition-size=8", "--max-partition-size=16", - "--enable-obmc=0", + obmc_arg, "--obu", "-o", "-", "-", ]; let mut child = Command::new(aomenc_path()) @@ -5176,6 +5191,7 @@ mod tests { ); let stream = out.stdout; let before = (decode::rect_inter_tu_hits(), decode::rect_inter_txsplit_hits()); + let before_obmc_leaf = decode::obmc_rect_leaf_hits(); let before_leaf = ( decode::inter_leaf16_horz_hits(), decode::inter_leaf16_vert_hits(), @@ -5197,6 +5213,7 @@ mod tests { }; let after = (decode::rect_inter_tu_hits(), decode::rect_inter_txsplit_hits()); let (tu, split) = (after.0 - before.0, after.1 - before.1); + let obmc_leaf = decode::obmc_rect_leaf_hits() - before_obmc_leaf; let (horz, vert, splits16) = ( decode::inter_leaf16_horz_hits() - before_leaf.0, decode::inter_leaf16_vert_hits() - before_leaf.1, @@ -5253,6 +5270,7 @@ mod tests { assert_eq!(got.v, want.v, "{NAME} frame {i} V vs ffmpeg (attempt {attempt}, {bit_depth}-bit, tx_search={tx_search})"); } tu_proved += tu; + obmc_leaf_proved += obmc_leaf; split_proved += split; sub16_split += splits16; if horz > 0 { @@ -5267,7 +5285,8 @@ mod tests { "{NAME} ({bit_depth}-bit): {named_refusals} named refusals, {matched} pixel-exact \ attempts carrying a 16-level rect inter leaf, 16x8-carrying={horz_proved}, \ 8x16-carrying={vert_proved}, whole-block rect TUs={tu_proved}, rect trees that \ - split={split_proved}, 16x16 SPLITs={sub16_split}, {out_of_scope} attempts \ + split={split_proved}, 16x16 SPLITs={sub16_split}, OBMC blends on a rect \ + leaf={obmc_leaf_proved}, {out_of_scope} attempts \ carried none ({oos_mismatch} of them mismatched)" ); assert_eq!( @@ -5282,6 +5301,11 @@ mod tests { SPLITs={sub16_split}, {named_refusals} refusals, {out_of_scope} out of \ scope) -- gate proved nothing" ); + assert!( + obmc_leaf_proved > 0, + "{NAME} ({bit_depth}-bit): no pixel-exact attempt ever ran the OBMC blend on a \ + 16x8/8x16 inter leaf -- the `--enable-obmc=1` arm proved nothing" + ); tu_total += tu_proved; } assert!( diff --git a/lanes/inter4-r4.report.md b/lanes/inter4-r4.report.md new file mode 100644 index 00000000..60c3cfea --- /dev/null +++ b/lanes/inter4-r4.report.md @@ -0,0 +1,98 @@ +# lane-inter4 r4 — OBMC on a 16x8/8x16 inter leaf (refusal lifted, gated) + +Branch `lane-inter4`, worktree `/home/user/Documents/Code/Rust/edith_codecs-inter4`, +off r3's `96847a3`, with `lane-interbis` (`8a6bede`, `build_motion_field`'s compound +slot walk) merged FIRST as chartered. + +## TASK 1 — r2's ignored 32x16/16x32 gate: re-measured, STILL RED, blocker moved + + cargo test -p ec-av1 --lib coded_rectangular_residual -- --ignored --nocapture + +`a_real_aomenc_inter_sequence_with_a_coded_rectangular_residual_decodes_pixel_exact` +still cannot prove itself: over its 16 8-bit attempts, **12 named refusals** — 10 of +them `"an intra-coded HORZ/VERT strip needs rectangular intra prediction this decoder +does not code yet"` and 2 `"an inter 16x16-level AB or 1:4 partition ..."` — and the +other 4 attempts decode with **zero** rect inter residual (`tu=0`, `split=0`, 0 +mismatches). So the 16-level leaf landing in r3 did NOT unblock it: what stops these +streams now is rectangular *intra* prediction, another lane's refusal. Kept `#[ignore]`, +with the reason string replaced by that measurement (stream.rs:4902). + +EVIDENCE: $HOME/.cache/inter4-t1.log | 16 aomenc encodes, decode + counter read | 12 named refusals (10 intra-rect-strip, 2 inter AB/1:4), 4 attempts with tu=0/split=0, 0 mismatches + +## TASK 2 — the OBMC residue: no defect left; refusal lifted + +r3 refused `"OBMC on a 16x8/8x16 inter leaf (blend mismatches the reference on this +shape)"` off a measured 5302-luma-pixel mismatch (attempt 10, 8-bit, cq 22, frame 5). +Re-measured on THIS tree before touching any code: + +- Rebuilt that exact stream from the gate's attempt-10 recipe with `--enable-obmc=1` + (`scratchpad/o10.obu`, md5 `b643a93a8db45e2a1b89b2d777147ee3`, 828 B). +- Added an `EC_OBMC` rung to the oracle `aomdec` + (`dec_build_prediction_by_above_pred` / `_left_pred`, printing the block, the + neighbour's rel position, `op_mi_size`, mv, ref, bsize, filter) and the matching + rung to our `obmc_blend`, then compared. + +Both decoders emit **exactly 9 OBMC neighbour invocations**, in the same order, with +identical block shape, `off4`/`rel`, `span4`/`op_mi_size`, neighbour mv, ref frame and +filter — including the three on `wh=(8x16)` leaves. And every one of the six +`EC_AV1_PREFILT_DUMP` frames is **byte-identical** between our decoder and aomdec +(luma diff 0 on f0..f5). There is nothing left to fix on this shape: the mismatch r3 +saw is gone. The only decode-path change between r3's measurement and this one is the +lane-interbis merge (temporal MV candidates); not bisected further. + +EVIDENCE: scratchpad/{ours.obmc,ref.obmc,ours.yuv.f0-5,ref.yuv.f0-5} | EC_OBMC + EC_AV1_PREFILT_DUMP on o10.obu, ours (release decode_probe) vs instrumented aomdec | 9 vs 9 identical neighbour lines; per-frame luma diff 0/0/0/0/0/0 + +### What shipped + +- `crates/ec-av1/src/decode.rs` (`obmc_blend`, ~12843): the `(16,8)|(8,16)` refusal + deleted; in its place the new `OBMC_RECT_LEAF_HITS` counter (+ `obmc_rect_leaf_hits()` + at ~1355) that the gate reads. +- `crates/ec-av1/src/refusal_inventory.rs`: the OBMC-rect-leaf string removed. +- `crates/ec-av1/src/stream.rs` (`..._with_a_16_level_rect_leaf_...`, ~5090): the sweep + runs **32 attempts** now — the same 16 (2 sources x 2 quantisers x 2 tx-size-search + arms x 2 motion steps) with `--enable-obmc=0`, then repeated with `--enable-obmc=1` + as the LAST flag. New hard assert per bit depth: `obmc_leaf_proved > 0`. +- `crates/ec-av1/src/stream.rs` ~1948: the hidden-frames gate's `--enable-obmc=0` + comment no longer cites a refusal that does not exist. + +### Gate — GREEN + + cargo test -p ec-av1 --lib 16_level_rect_leaf -- --nocapture + +- 8-bit: 15 named refusals, 9 pixel-exact leaf-carrying attempts (16x8=5, 8x16=4), + whole-block rect TUs=4, **OBMC blends on a rect leaf=10**, 8 attempts carried none + (0 mismatched). +- 10-bit: 4 named refusals, 8 pixel-exact leaf-carrying attempts (16x8=4, 8x16=6), + **OBMC blends on a rect leaf=4**, 20 carried none (0 mismatched). + +EVIDENCE: $HOME/.cache/inter4-g4.log | 64 aomenc encodes (32 attempts x 2 depths), every decoded frame Y/U/V vs ffmpeg | test result: ok. 1 passed; 0 failed; OBMC-on-rect-leaf blends 10 (8-bit) / 4 (10-bit), 0 mismatches + +## Refusals + +Lifted: `"OBMC on a 16x8/8x16 inter leaf (blend mismatches the reference on this shape)"`. +None added. + +## Suite + + $HOME/.cache/inter4-suite-r4.log + +See the tail of that log for the totals (systemd user unit, `cargo test -p ec-av1 --lib`). + +## Film + +`scratchpad/hg-head.obu` through the release `decode_probe` on this lane still stops at +`unsupported: AV1 tile (filter intra on a HORZ/VERT strip (this decoder predicts +square-only))` — an intra refusal owned by another lane, unchanged by this round. + +EVIDENCE: scratchpad/hg-head.obu | release decode_probe under a 6G scope | REFUSED: filter intra on a HORZ/VERT strip + +## Residue + +- deferred: r2's 32x16/16x32 rect-residual gate — still `#[ignore]`d — unblocked by + rectangular INTRA prediction (`an intra-coded HORZ/VERT strip ...`) landing, not by + anything in this lane. +- accepted: which change fixed r3's OBMC mismatch is not bisected (interbis merge is the + only candidate); the shape is now proven exact against an instrumented aomdec, so the + question is archaeology, not a defect. +- accepted: `16x16 SPLITs=0` under this recipe (aomenc picks NONE/HORZ/VERT at 16); + covered by the 8x8-leaf sibling gate.