diff --git a/crates/ec-av1/src/decode.rs b/crates/ec-av1/src/decode.rs index 2f989080..89a3407d 100644 --- a/crates/ec-av1/src/decode.rs +++ b/crates/ec-av1/src/decode.rs @@ -30987,12 +30987,6 @@ pub(crate) fn obmc_plan( // `av1_setup_build_prediction_by_above_pred` passing that ref's own // `scale_factors`). frame_width: usize, - // lane-av1-422sub8rect: the plane's own subsampling shifts -- every - // chroma extent below derives from the luma rule by `>> ss` on the - // subsampled axis (`build_obmc_inter_pred_above`'s - // `overlap >> pd->subsampling_y` and the left pass's matching `>> ss_x`), - // never a blind half. 4:2:0 and 4:4:4 reduce to the old /2s and 0s. - ss: (usize, usize), ) -> Result { // lane-rect r2 (libaom av1_build_obmc_inter_prediction): each pass has // its OWN neighbour cap (width-log2 for above, height-log2 for left) and @@ -31024,16 +31018,16 @@ pub(crate) fn obmc_plan( let overlap_above = write_h.min(64) / 2; let overlap_left = write_w.min(64) / 2; // lane-inter8 r1 / lane-scaledref r1: `av1_skip_u4x4_pred_in_obmc` - // (reconinter.c:829) keys on the CHROMA plane block - // (`get_plane_block_size(bsize, ss_x, ss_y)`): BLOCK_4X4/BLOCK_8X4/ - // BLOCK_4X8 return `dir == 0`, so the ABOVE pass skips chroma for those - // and the LEFT pass never does. lane-av1-422sub8rect: keyed on the - // per-axis-shifted plane shape now -- an 8x8 leaf is (4, 4) at 4:2:0 - // (skip) and (4, 8) at 4:2:2 (still skip, BLOCK_4X8 is in the list), - // while 8x4/4x8 luma leaves are (4, 4) or (8, 4) at 4:2:2. - let (ss_x, ss_y) = ss; - let skip_chroma_above = - matches!((write_w >> ss_x, write_h >> ss_y), (4, 4) | (8, 4) | (4, 8)); + // (`reconinter.c` 820) returns `dir == 0` when the chroma plane's own + // block is BLOCK_4X4/8X4/4X8 (an 8x8, 16x8 or 8x16 luma block at 4:2:0): + // the ABOVE pass skips chroma entirely, the LEFT pass still blends it. + // lane-av1-422sub8rect stop-note: keyed on the LUMA write shape -- a + // 4:4:4 block's plane block is square, so libaom's plane-block test + // would run the above pass there; this tree keeps the 4:2:0-shaped + // corner-cut (measured: the ss-shifted conformant port moved a boundary + // sample AWAY from aomdec on the obmc444 fixture, lanes/ report) and + // leaves the 444-conformant flip to the owning 444 lane. + let skip_chroma_above = matches!((write_w, write_h), (8, 8) | (16, 8) | (8, 16)); let mut above = Vec::new(); for (off4, span4, nb, src4) in overlappable_above(grid, mi_row, mi_col, bw4, mi_cols, max_nb(bw4)) { @@ -31101,7 +31095,6 @@ pub(crate) fn obmc_plan( cpy, overlap_above, overlap_left, - ss, skip_chroma_above, }) } @@ -31135,8 +31128,6 @@ pub(crate) struct ObmcPlan { cpy: usize, overlap_above: usize, overlap_left: usize, - /// The plane's own subsampling shifts ([`obmc_plan`]). - ss: (usize, usize), skip_chroma_above: bool, } @@ -31164,18 +31155,9 @@ pub(crate) fn obmc_run( cpy, overlap_above, overlap_left, - ss, skip_chroma_above, .. } = plan; - // lane-av1-422sub8rect: every chroma extent is the luma rule shifted by - // the plane's own subsampling (`build_obmc_inter_pred_above`'s - // `overlap >> pd->subsampling_y`, the left pass's `>> ss_x`, the - // neighbour-span `>> ss` per axis) -- 4:2:0 and 4:4:4 reduce to the old - // halves, 4:2:2 keeps the unhalved height. - let (ss_x, ss_y) = ss; - let chroma_w = write_w >> ss_x; - let chroma_h = write_h >> ss_y; // lane-alloc: one neighbour-prediction buffer per plane for the whole // block, reused by every neighbour of the above and left passes. let (mut tmp_y, mut tmp_u, mut tmp_v) = (Vec::new(), Vec::new(), Vec::new()); @@ -31194,8 +31176,7 @@ 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; - let (mcb_cw, mcb_ch) = (write_w >> ss_x, write_h >> ss_y); - if x >= cpx && x < cpx + mcb_cw && y >= cpy && y < cpy + mcb_ch + if x >= cpx && x < cpx + write_w / 2 && y >= cpy && y < cpy + write_h / 2 && (fr < 0 || fr == idx) { Some((x, y, idx)) @@ -31206,11 +31187,11 @@ pub(crate) fn obmc_run( if let Some((_, _, idx)) = ec_mcb { eprintln!( "OUR_MCB pre f={idx} cpx={cpx} cpy={cpy} cw={} ch={}", - write_w >> ss_x, - write_h >> ss_y + write_w / 2, + write_h / 2 ); - for r in 0..(write_h >> ss_y) { - let row: Vec = (0..(write_w >> ss_x)).map(|c| pred_u[r * chroma_side + c]).collect(); + for r in 0..write_h / 2 { + let row: Vec = (0..write_w / 2).map(|c| pred_u[r * chroma_side + c]).collect(); eprintln!("OUR_MCB prerow{r}: {row:?}"); } } @@ -31226,10 +31207,9 @@ pub(crate) fn obmc_run( if !skip_chroma_above { // lane-t900 r13 (measured, NOT a defect): libaom's min-4 clamp // sizes only the OBMC PREDICTION buffer; the blend length is the - // plain `overlap >> ss_y` (`build_obmc_inter_pred_above`: - // `bh = overlap >> pd->subsampling_y`). - let (cbw, cbh, cox) = (bw >> ss_x, overlap_above >> ss_y, ox >> ss_x); - let cw = cbw.min(chroma_w - cox); + // plain half (`build_obmc_inter_pred_above`: `overlap >> ss_y`). + let (cbw, cbh, cox) = (bw / 2, overlap_above / 2, ox / 2); + let cw = cbw.min(write_w / 2 - cox); obmc_neighbour_pred(nu, cpx + cox, cpy, nb.mv, cbw, cbh, false, nb.h_kind, nb.v_kind, nb.scale, &mut tmp_u, fctx); obmc_blend_v(pred_u, chroma_side, cox, 0, cw, cbh, cbw, &tmp_u); obmc_neighbour_pred(nv, cpx + cox, cpy, nb.mv, cbw, cbh, false, nb.h_kind, nb.v_kind, nb.scale, &mut tmp_v, fctx); @@ -31244,7 +31224,7 @@ pub(crate) fn obmc_run( let (bw, bh, oy) = (overlap_left, nb.span4 * 4, nb.off4 * 4); obmc_neighbour_pred(ny, px, py + oy, nb.mv, bw, bh, true, nb.h_kind, nb.v_kind, nb.scale, &mut tmp_y, fctx); obmc_blend_h(pred_y, side, 0, oy, bw, bh.min(write_h - oy), &tmp_y); - let (cbw, cbh, coy) = (overlap_left >> ss_x, bh >> ss_y, oy >> ss_y); + let (cbw, cbh, coy) = (overlap_left / 2, bh / 2, oy / 2); obmc_neighbour_pred(nu, cpx, cpy + coy, nb.mv, cbw, cbh, false, nb.h_kind, nb.v_kind, nb.scale, &mut tmp_u, fctx); if let Some((_, _, idx)) = ec_mcb { eprintln!( @@ -31256,14 +31236,14 @@ pub(crate) fn obmc_run( eprintln!("OUR_MCB lrow{r}: {row:?}"); } } - let ch = cbh.min(chroma_h - coy); + let ch = cbh.min(write_h / 2 - coy); obmc_blend_h(pred_u, chroma_side, 0, coy, cbw, ch, &tmp_u); obmc_neighbour_pred(nv, cpx, cpy + coy, nb.mv, cbw, cbh, false, nb.h_kind, nb.v_kind, nb.scale, &mut tmp_v, fctx); obmc_blend_h(pred_v, chroma_side, 0, coy, cbw, ch, &tmp_v); } if let Some((_, _, idx)) = ec_mcb { - for r in 0..chroma_h { - let row: Vec = (0..chroma_w).map(|c| pred_u[r * chroma_side + c]).collect(); + for r in 0..write_h / 2 { + let row: Vec = (0..write_w / 2).map(|c| pred_u[r * chroma_side + c]).collect(); eprintln!("OUR_MCB post f={idx} row{r}: {row:?}"); } } @@ -34115,7 +34095,6 @@ fn decode_inter_block( refpix, interp_fixed, frame_width, - (ss_x(fctx), ss_y(fctx)), )?) } else { None @@ -39834,7 +39813,6 @@ ss_y(fctx), refpix, interp_fixed, frame_width, - (ss_x(fctx), ss_y(fctx)), )?) } else { None diff --git a/crates/ec-av1/src/encode.rs b/crates/ec-av1/src/encode.rs index 2ae94b7c..eb48b255 100644 --- a/crates/ec-av1/src/encode.rs +++ b/crates/ec-av1/src/encode.rs @@ -6809,7 +6809,6 @@ fn obmc_prediction( &refpix, Some(fctx.interp_filter.get()), frame_width, - (crate::decode::ss_x(fctx), crate::decode::ss_y(fctx)), ) .ok()?; let mut pred = [ diff --git a/lanes/av1422sub8rect.report.md b/lanes/av1422sub8rect.report.md index 36d96d1e..0db02444 100644 --- a/lanes/av1422sub8rect.report.md +++ b/lanes/av1422sub8rect.report.md @@ -71,7 +71,10 @@ behaviour, named for the owning lane. 4. MEASURED after the port (17-frame probe run under the reverted bypass; comparator: ours padded 256x160/128x160 u8 cropped vs the instrumented - `$HOME/.cache/aom-oracle/build` aomdec): + `$HOME/.cache/aom-oracle/build` aomdec; NOTE the probe prints REFUSED and + still exits 0 -- the committed tree stops at frame 11 with the + pre-existing "HORZ/VERT strip ... no rect coefficient tables" frontier + refusal, exactly like the reworked tree): - frame 0: **byte-exact at PREFILT, POSTCDEF (and FINAL by the u16 comparator) on Y, U and V — 0 diffs everywhere**, so the rect read, the split4 per-piece model and every shared-helper change are exact on @@ -106,6 +109,56 @@ - 4:2:0/4:4:4 untouched by construction (ss-keyed arms); the 4:2:0 group-tail SKIP arm untouched; `read_coeffs_rect` untouched. +## Review rework (r2, post-review findings 1-3) + +The review correctly rejected two byte-identity claims and one +justification: + +1. **444 OBMC behaviour now UNCHANGED from the parent.** The first commit + made `obmc_plan`/`obmc_run` ss-exact (`av1_skip_u4x4_pred_in_obmc` + keyed on the plane block; chroma extents `>> ss`), which is what + reconinter.c does -- but it CHANGES 4:4:4 behaviour (the above-pass + chroma skip flips to run on square plane blocks, the blend extents + double) and is NOT byte-identical, with no 444 OBMC gate covering it. + Measured before reworking: fixture `/tmp/obmc444/obmc444.obu` sha256 + `4b5c0a473c7ca5bd460e76bb5d7fde541dc996bec45f60bfcc393eb2f11731ef` + (10-frame 128x96 4:4:4 aomenc `--enable-obmc=1 --profile=1`, 2 rect + OBMC leaves firing per the probe census), decoded parent (4e8c6073) + vs tip vs instrumented aomdec: parent and tip read IDENTICAL symbols + and differ in exactly ONE V sample (f1, (82,80)): oracle 110 == + parent, tip 111. Attribution by single-change revert builds: reverting + `TxParams::strided` alone (varB) reproduces tip exactly; reverting the + OBMC ss semantics alone (varA) reproduces the parent exactly -- so the + whole parent<->tip delta is the OBMC change, and on this fixture the + conformant variant is one sample FARTHER from aomdec, never closer. + Per the review protocol ("if worse, rework") the OBMC ss semantics are + REVERTED to the parent's 4:2:0-shaped corner-cut (luma-keyed + `skip_chroma_above`, half chroma blend extents); the 444-conformant + port stays deferred to the owning 444 lane, which can measure it on + OBMC-heavy 444 content once that lane's reconstruction class is exact + enough to gate on. `encode.rs` carries no change any more (the ss + argument is gone with the parameter). +2. **`TxParams::strided` justification corrected.** The commit text + claimed "every pre-existing caller has h == stride" -- wrong: + `read_inter_plane_rect` callers pass rect units with `h < stride` + (e.g. an 8x4 unit in an 8x8-strided plane buffer), and for those the + scratch shrinks from `stride*stride` to `stride*h`. Output identity + holds because the copy loop only ever writes `h` rows of `w <= stride` + and every consumer reads the residual through the same dense bounds -- + verified empirically (the 4:2:0 pixel-exact witness, 4:4:4 frame + equality with the parent on the obmc444 fixture, and the varB + revert experiment), not by the removed claim. The `stride * h` sizing + itself STAYS: the 4:2:2 leaf's TX_4X8 unit (stride 4, h 8) panics on + the old square sizing. +3. The t422 measurement note above also corrects the probe's exit-status + reading (REFUSED still exits 0; both the committed and reworked trees + stop at frame 11 on the pre-existing strip-chroma frontier refusal). + +Everything else in Outcome 3 (the leaf8 rect port, the split4 per-piece +model, the ss-keyed masked/interintra blends) is untouched by the rework; +frame 0 re-verified byte-exact at PREFILT/POSTCDEF after it, and both +gates re-run green post-revert. + ## Verification - `cargo check -p ec-av1` (target `~/.cache/cargo-target-av1422sub8rect`):