From 2bf7a0ee7b5944fbd27a42ec706afacfc34cbb81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Sat, 26 Sep 2026 03:36:40 +0300 Subject: [PATCH] ec-av1: the EC_MCB rung windows by the frame ss pair, not a /2 The rung's env window and pre/post row dumps halved write_w/write_h unconditionally -- right only at 4:2:0, a quarter-window at 4:4:4 (ss 0/0, decoded by this tree). The oracle's EC_MCB spans are plane pixels (saved r13 dump: bw=16 bh=16 rows for a 32x32 luma block), so the rung now uses write_w >> ss_x / write_h >> ss_y. 4:2:0 output is bit-identical (dims are even); on a 4:4:4 obmc-gate-recipe stream the same EC_MCB pixel that fired 0 blocks pre-fix now fires the full 32x32 chroma dump. Env-gated instrumentation only; the obmc gate stays pixel-exact vs ffmpeg. --- crates/ec-av1/src/decode.rs | 29 +++++++++-------- lanes/av1ecmcb.report.md | 62 +++++++++++++++++++++++++++++++++++++ 2 files changed, 78 insertions(+), 13 deletions(-) create mode 100644 lanes/av1ecmcb.report.md diff --git a/crates/ec-av1/src/decode.rs b/crates/ec-av1/src/decode.rs index cf2f181e..6427af3f 100644 --- a/crates/ec-av1/src/decode.rs +++ b/crates/ec-av1/src/decode.rs @@ -29730,7 +29730,8 @@ pub(crate) fn obmc_run( let (mut tmp_y, mut tmp_u, mut tmp_v) = (Vec::new(), Vec::new(), Vec::new()); // lane-t900 r13 rung: EC_MCB="::[:]" (chroma plane - // 1 only) prints this block's chroma prediction rows before and after the + // 1 only; : are chroma-plane pixels, the oracle's own dump + // window) prints this block's chroma prediction rows before and after the // OBMC blend, matching the instrumented aomdec's EC_MCB dump. let ec_mcb: Option<(usize, usize, i64)> = crate::envflags::env_flag!("EC_MCB") .then(|| crate::envflags::var("EC_MCB").ok()) @@ -29743,22 +29744,23 @@ pub(crate) fn obmc_run( let (x, y) = (f[1].parse::().ok()?, f[2].parse::().ok()?); let fr = f.get(3).and_then(|s| s.parse::().ok()).unwrap_or(-1); let idx = PREFILT_PICTURE_IDX.load(std::sync::atomic::Ordering::SeqCst) as i64; - if x >= cpx && x < cpx + write_w / 2 && y >= cpy && y < cpy + write_h / 2 - && (fr < 0 || fr == idx) - { + // lane-av1ecmcb: the window is the CHROMA plane's own write region -- + // the oracle's EC_MCB spans are plane pixels, and at 4:4:4 (ss 0/0) + // the chroma block is full-size, so nothing halves. The old + // `write_w / 2` was a 4:2:0-era assumption that quartered the window + // (and the dumps below) at ss 0/0. + let (cw, ch) = (write_w >> ss_x(fctx), write_h >> ss_y(fctx)); + if x >= cpx && x < cpx + cw && y >= cpy && y < cpy + ch && (fr < 0 || fr == idx) { Some((x, y, idx)) } else { None } }); if let Some((_, _, idx)) = ec_mcb { - eprintln!( - "OUR_MCB pre f={idx} cpx={cpx} cpy={cpy} cw={} ch={}", - write_w / 2, - write_h / 2 - ); - for r in 0..write_h / 2 { - let row: Vec = (0..write_w / 2).map(|c| pred_u[r * chroma_side + c]).collect(); + let (cw, ch) = (write_w >> ss_x(fctx), write_h >> ss_y(fctx)); + eprintln!("OUR_MCB pre f={idx} cpx={cpx} cpy={cpy} cw={cw} ch={ch}"); + for r in 0..ch { + let row: Vec = (0..cw).map(|c| pred_u[r * chroma_side + c]).collect(); eprintln!("OUR_MCB prerow{r}: {row:?}"); } } @@ -29809,8 +29811,9 @@ pub(crate) fn obmc_run( obmc_blend_h(pred_v, chroma_side, 0, coy, cbw, ch, &tmp_v); } if let Some((_, _, idx)) = ec_mcb { - for r in 0..write_h / 2 { - let row: Vec = (0..write_w / 2).map(|c| pred_u[r * chroma_side + c]).collect(); + let (cw, ch) = (write_w >> ss_x(fctx), write_h >> ss_y(fctx)); + for r in 0..ch { + let row: Vec = (0..cw).map(|c| pred_u[r * chroma_side + c]).collect(); eprintln!("OUR_MCB post f={idx} row{r}: {row:?}"); } } diff --git a/lanes/av1ecmcb.report.md b/lanes/av1ecmcb.report.md new file mode 100644 index 00000000..3519b5fd --- /dev/null +++ b/lanes/av1ecmcb.report.md @@ -0,0 +1,62 @@ +# lane-av1ecmcb report -- the EC_MCB rung's halved window + +Branch `lane-av1-ecmcb`, base `fe3e8418`. Single item: close the deferred +`EC_MCB`-rung coordinate defect named in `lanes/av1llpred.report.md` ("still +windows its own dump with `write_w / 2` -- fix-now(deferred to whoever next +touches that rung)"). + +## Verdict: defect REAL, fixed (instrumentation only) + +`decode.rs::obmc_run`'s rung filtered the `EC_MCB="::[:]"` +window and dumped the pre/post-blend chroma rows with `write_w / 2` / +`write_h / 2`. `write_w`/`write_h` are the block's LUMA write dims +(`decode_inter_block` ~30346: `cpx = px >> ss_x`), so the `/2` is correct only +at 4:2:0; at 4:4:4 (`ss 0/0`, decoded by this tree -- refusal inventory names +only 4:2:2) the chroma block is full-size and the old rung quartered both its +window and its row dumps. + +Oracle semantics (r13/r14 ground truth): aomdec's private `EC_MCB` printed +every `dec_build_inter_predictors` call whose PLANE-pixel span covers the +pixel. The saved pairing dumps still pin this: +`~/.cache/t900-tmp/aom_mcb41b.txt` prints `bw=16 bh=16` + 16x16 rows for the +32x32-luma block at mi(176,192) -- plane pixels -- and `our_mcb41.txt` matched +1:1 at 4:2:0. Plane pixels at `ss 0/0` are luma-sized, so the fix is +`write_w >> ss_x(fctx)` / `write_h >> ss_y(fctx)` in the window check and both +row dumps (bit-identical at 4:2:0: dims are even, `>>1 == /2`). + +Note: the oracle's private `EC_MCB` patch is no longer in +`~/.cache/aom-oracle/src` (t900-era tree reverted to pristine); the saved r13 +dumps are the surviving oracle ground truth and are what this closure pairs +against. + +## Verification + +* 4:2:0 pairing unchanged: `EC_MCB=1:353:395:41` on the pinned + `~/.cache/t900-tmp/c900_62.obu` (release `decode_probe`), block + `cpx=352 cpy=384 cw=16 ch=16` -- all 16 prerows byte-equal to the saved + oracle rows AND to the pre-fix `our_mcb41.txt` rows. +* 4:4:4 fail-before / pass-after: `aomenc --profile=1 --enable-obmc=1` gate + recipe (obmc gate's exact flags, `gradients` seed 43, 64x64, 25 frames, + `/tmp/ecmcb/s43.obu`, 444). `EC_MCB=1:48:48`: pre-fix binary fires 0 blocks + (48 is outside `cpy..cpy+16` for the `cpx=32 cpy=32` block); post-fix fires + `OUR_MCB pre f=5 cpx=32 cpy=32 cw=32 ch=32` with full 32-wide rows. +* Decode behavior unchanged: the diff touches only `env_flag!("EC_MCB")`-gated + lines (the closure is `.then`-gated, so with the env unset nothing new + runs). Gate `a_real_aomenc_stream_with_obmc_decodes_pixel_exact`: + `ok. 1 passed` (pixel-exact vs ffmpeg), genuinely ran (no SKIP). +* `cargo check -p ec-av1` (`CARGO_TARGET_DIR=$HOME/.cache/cargo-target-av1ecmcb`): + 0 warnings. + +## EVIDENCE + +EVIDENCE: ~/.cache/t900-tmp/aom_mcb41b.txt + /tmp/ecmcb/our_now_block.txt | EC_MCB=1:353:395:41 both decoders on c900_62.obu, block cpx=352 cpy=384 | 16/16 prerow values equal to the oracle's saved plane-pixel rows (post-fix) +EVIDENCE: /tmp/ecmcb/s43.obu + /tmp/ecmcb/post48.txt | aomenc --profile=1 --enable-obmc=1 (obmc-gate recipe, seed 43) + EC_MCB=1:48:48 | pre-fix 0 fires, post-fix `cw=32 ch=32` full-block dump at 4:4:4 +EVIDENCE: cargo test -p ec-av1 --lib a_real_aomenc_stream_with_obmc_decodes_pixel_exact | ok. 1 passed; 0 failed (decode path untouched) + +## Disposition + +fix-now (the deferred item): the rung is ss-aware and pairs at both chroma +shapes. No decode-behavior change shipped. The left-pass `OUR_MCB left` tmp +dump still prints the BLEND's own `cbw/cbh` (which reflect the blend's +per-axis halves) -- that is the rung instrumenting real decode geometry, not a +rung-side assumption, and stays as-is.