ec-av1: the EC_MCB rung windows by the frame ss pair, not a /2
Browse files at this commit2bf7a0ee7b5944fbd27a42ec706afacfc34cbb81Parent: 38b69192 changed files +78 -13
- crates/ec-av1/src/decode.rs +16 -13
- lanes/av1ecmcb.report.md +62 -0
crates/ec-av1/src/decode.rsmodified+16 -13
| @@ -29730,7 +29730,8 @@ pub(crate) fn obmc_run( | |||
| 29730 | let (mut tmp_y, mut tmp_u, mut tmp_v) = (Vec::new(), Vec::new(), Vec::new()); | 29730 | let (mut tmp_y, mut tmp_u, mut tmp_v) = (Vec::new(), Vec::new(), Vec::new()); |
| 29731 | 29731 | ||
| 29732 | // lane-t900 r13 rung: EC_MCB="<plane>:<px>:<py>[:<frame>]" (chroma plane | 29732 | // lane-t900 r13 rung: EC_MCB="<plane>:<px>:<py>[:<frame>]" (chroma plane |
| 29733 | - // 1 only) prints this block's chroma prediction rows before and after the | 29733 | + // 1 only; <px>:<py> are chroma-plane pixels, the oracle's own dump |
| 29734 | + // window) prints this block's chroma prediction rows before and after the | ||
| 29734 | // OBMC blend, matching the instrumented aomdec's EC_MCB dump. | 29735 | // OBMC blend, matching the instrumented aomdec's EC_MCB dump. |
| 29735 | let ec_mcb: Option<(usize, usize, i64)> = crate::envflags::env_flag!("EC_MCB") | 29736 | let ec_mcb: Option<(usize, usize, i64)> = crate::envflags::env_flag!("EC_MCB") |
| 29736 | .then(|| crate::envflags::var("EC_MCB").ok()) | 29737 | .then(|| crate::envflags::var("EC_MCB").ok()) |
| @@ -29743,22 +29744,23 @@ pub(crate) fn obmc_run( | |||
| 29743 | let (x, y) = (f[1].parse::<usize>().ok()?, f[2].parse::<usize>().ok()?); | 29744 | let (x, y) = (f[1].parse::<usize>().ok()?, f[2].parse::<usize>().ok()?); |
| 29744 | let fr = f.get(3).and_then(|s| s.parse::<i64>().ok()).unwrap_or(-1); | 29745 | let fr = f.get(3).and_then(|s| s.parse::<i64>().ok()).unwrap_or(-1); |
| 29745 | let idx = PREFILT_PICTURE_IDX.load(std::sync::atomic::Ordering::SeqCst) as i64; | 29746 | let idx = PREFILT_PICTURE_IDX.load(std::sync::atomic::Ordering::SeqCst) as i64; |
| 29746 | - if x >= cpx && x < cpx + write_w / 2 && y >= cpy && y < cpy + write_h / 2 | 29747 | + // lane-av1ecmcb: the window is the CHROMA plane's own write region -- |
| 29747 | - && (fr < 0 || fr == idx) | 29748 | + // the oracle's EC_MCB spans are plane pixels, and at 4:4:4 (ss 0/0) |
| 29748 | - { | 29749 | + // the chroma block is full-size, so nothing halves. The old |
| 29750 | + // `write_w / 2` was a 4:2:0-era assumption that quartered the window | ||
| 29751 | + // (and the dumps below) at ss 0/0. | ||
| 29752 | + let (cw, ch) = (write_w >> ss_x(fctx), write_h >> ss_y(fctx)); | ||
| 29753 | + if x >= cpx && x < cpx + cw && y >= cpy && y < cpy + ch && (fr < 0 || fr == idx) { | ||
| 29749 | Some((x, y, idx)) | 29754 | Some((x, y, idx)) |
| 29750 | } else { | 29755 | } else { |
| 29751 | None | 29756 | None |
| 29752 | } | 29757 | } |
| 29753 | }); | 29758 | }); |
| 29754 | if let Some((_, _, idx)) = ec_mcb { | 29759 | if let Some((_, _, idx)) = ec_mcb { |
| 29755 | - eprintln!( | 29760 | + let (cw, ch) = (write_w >> ss_x(fctx), write_h >> ss_y(fctx)); |
| 29756 | - "OUR_MCB pre f={idx} cpx={cpx} cpy={cpy} cw={} ch={}", | 29761 | + eprintln!("OUR_MCB pre f={idx} cpx={cpx} cpy={cpy} cw={cw} ch={ch}"); |
| 29757 | - write_w / 2, | 29762 | + for r in 0..ch { |
| 29758 | - write_h / 2 | 29763 | + let row: Vec<u16> = (0..cw).map(|c| pred_u[r * chroma_side + c]).collect(); |
| 29759 | - ); | ||
| 29760 | - for r in 0..write_h / 2 { | ||
| 29761 | - let row: Vec<u16> = (0..write_w / 2).map(|c| pred_u[r * chroma_side + c]).collect(); | ||
| 29762 | eprintln!("OUR_MCB prerow{r}: {row:?}"); | 29764 | eprintln!("OUR_MCB prerow{r}: {row:?}"); |
| 29763 | } | 29765 | } |
| 29764 | } | 29766 | } |
| @@ -29809,8 +29811,9 @@ pub(crate) fn obmc_run( | |||
| 29809 | obmc_blend_h(pred_v, chroma_side, 0, coy, cbw, ch, &tmp_v); | 29811 | obmc_blend_h(pred_v, chroma_side, 0, coy, cbw, ch, &tmp_v); |
| 29810 | } | 29812 | } |
| 29811 | if let Some((_, _, idx)) = ec_mcb { | 29813 | if let Some((_, _, idx)) = ec_mcb { |
| 29812 | - for r in 0..write_h / 2 { | 29814 | + let (cw, ch) = (write_w >> ss_x(fctx), write_h >> ss_y(fctx)); |
| 29813 | - let row: Vec<u16> = (0..write_w / 2).map(|c| pred_u[r * chroma_side + c]).collect(); | 29815 | + for r in 0..ch { |
| 29816 | + let row: Vec<u16> = (0..cw).map(|c| pred_u[r * chroma_side + c]).collect(); | ||
| 29814 | eprintln!("OUR_MCB post f={idx} row{r}: {row:?}"); | 29817 | eprintln!("OUR_MCB post f={idx} row{r}: {row:?}"); |
| 29815 | } | 29818 | } |
| 29816 | } | 29819 | } |
lanes/av1ecmcb.report.mdadded+62 -0
| @@ -0,0 +1,62 @@ | |||
| 1 | +# lane-av1ecmcb report -- the EC_MCB rung's halved window | ||
| 2 | + | ||
| 3 | +Branch `lane-av1-ecmcb`, base `fe3e8418`. Single item: close the deferred | ||
| 4 | +`EC_MCB`-rung coordinate defect named in `lanes/av1llpred.report.md` ("still | ||
| 5 | +windows its own dump with `write_w / 2` -- fix-now(deferred to whoever next | ||
| 6 | +touches that rung)"). | ||
| 7 | + | ||
| 8 | +## Verdict: defect REAL, fixed (instrumentation only) | ||
| 9 | + | ||
| 10 | +`decode.rs::obmc_run`'s rung filtered the `EC_MCB="<plane>:<px>:<py>[:<frame>]"` | ||
| 11 | +window and dumped the pre/post-blend chroma rows with `write_w / 2` / | ||
| 12 | +`write_h / 2`. `write_w`/`write_h` are the block's LUMA write dims | ||
| 13 | +(`decode_inter_block` ~30346: `cpx = px >> ss_x`), so the `/2` is correct only | ||
| 14 | +at 4:2:0; at 4:4:4 (`ss 0/0`, decoded by this tree -- refusal inventory names | ||
| 15 | +only 4:2:2) the chroma block is full-size and the old rung quartered both its | ||
| 16 | +window and its row dumps. | ||
| 17 | + | ||
| 18 | +Oracle semantics (r13/r14 ground truth): aomdec's private `EC_MCB` printed | ||
| 19 | +every `dec_build_inter_predictors` call whose PLANE-pixel span covers the | ||
| 20 | +pixel. The saved pairing dumps still pin this: | ||
| 21 | +`~/.cache/t900-tmp/aom_mcb41b.txt` prints `bw=16 bh=16` + 16x16 rows for the | ||
| 22 | +32x32-luma block at mi(176,192) -- plane pixels -- and `our_mcb41.txt` matched | ||
| 23 | +1:1 at 4:2:0. Plane pixels at `ss 0/0` are luma-sized, so the fix is | ||
| 24 | +`write_w >> ss_x(fctx)` / `write_h >> ss_y(fctx)` in the window check and both | ||
| 25 | +row dumps (bit-identical at 4:2:0: dims are even, `>>1 == /2`). | ||
| 26 | + | ||
| 27 | +Note: the oracle's private `EC_MCB` patch is no longer in | ||
| 28 | +`~/.cache/aom-oracle/src` (t900-era tree reverted to pristine); the saved r13 | ||
| 29 | +dumps are the surviving oracle ground truth and are what this closure pairs | ||
| 30 | +against. | ||
| 31 | + | ||
| 32 | +## Verification | ||
| 33 | + | ||
| 34 | +* 4:2:0 pairing unchanged: `EC_MCB=1:353:395:41` on the pinned | ||
| 35 | + `~/.cache/t900-tmp/c900_62.obu` (release `decode_probe`), block | ||
| 36 | + `cpx=352 cpy=384 cw=16 ch=16` -- all 16 prerows byte-equal to the saved | ||
| 37 | + oracle rows AND to the pre-fix `our_mcb41.txt` rows. | ||
| 38 | +* 4:4:4 fail-before / pass-after: `aomenc --profile=1 --enable-obmc=1` gate | ||
| 39 | + recipe (obmc gate's exact flags, `gradients` seed 43, 64x64, 25 frames, | ||
| 40 | + `/tmp/ecmcb/s43.obu`, 444). `EC_MCB=1:48:48`: pre-fix binary fires 0 blocks | ||
| 41 | + (48 is outside `cpy..cpy+16` for the `cpx=32 cpy=32` block); post-fix fires | ||
| 42 | + `OUR_MCB pre f=5 cpx=32 cpy=32 cw=32 ch=32` with full 32-wide rows. | ||
| 43 | +* Decode behavior unchanged: the diff touches only `env_flag!("EC_MCB")`-gated | ||
| 44 | + lines (the closure is `.then`-gated, so with the env unset nothing new | ||
| 45 | + runs). Gate `a_real_aomenc_stream_with_obmc_decodes_pixel_exact`: | ||
| 46 | + `ok. 1 passed` (pixel-exact vs ffmpeg), genuinely ran (no SKIP). | ||
| 47 | +* `cargo check -p ec-av1` (`CARGO_TARGET_DIR=$HOME/.cache/cargo-target-av1ecmcb`): | ||
| 48 | + 0 warnings. | ||
| 49 | + | ||
| 50 | +## EVIDENCE | ||
| 51 | + | ||
| 52 | +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) | ||
| 53 | +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 | ||
| 54 | +EVIDENCE: cargo test -p ec-av1 --lib a_real_aomenc_stream_with_obmc_decodes_pixel_exact | ok. 1 passed; 0 failed (decode path untouched) | ||
| 55 | + | ||
| 56 | +## Disposition | ||
| 57 | + | ||
| 58 | +fix-now (the deferred item): the rung is ss-aware and pairs at both chroma | ||
| 59 | +shapes. No decode-behavior change shipped. The left-pass `OUR_MCB left` tmp | ||
| 60 | +dump still prints the BLEND's own `cbw/cbh` (which reflect the blend's | ||
| 61 | +per-axis halves) -- that is the rung instrumenting real decode geometry, not a | ||
| 62 | +rung-side assumption, and stays as-is. | ||