forge
Explore
Log in

Don't you dare go Hollow

ec-av1: lane-av1-422sub8rect review rework -- 444 OBMC back to the parent corner-cut, strided claim corrected

Browse files at this commit

66b4c762ad487552b0c42c87be09d659f6c967bdAhmet Kaan GümüşParent: 19f693e
Review findings on 4d1527f9: the ss-shifted OBMC port (plane-block-keyed
skip_chroma_above, >>ss blend extents) is libaom-conformant but NOT 444
byte-identical, and measurement went against it: on a 10-frame 4:4:4
--enable-obmc=1 fixture (sha256 4b5c0a47..., 2 rect OBMC leaves) parent
and tip read identical symbols and differ in exactly one V sample, with
the conformant tip FARTHER from aomdec (110 vs 111); single-change revert
builds attribute the whole delta to the OBMC change. Per the review
protocol the OBMC semantics are reverted to the parent corner-cut (ss
parameter dropped; encode.rs call unchanged again), deferred to the
owning 444 lane.

The TxParams::strided justification is corrected: pre-existing h<stride
callers DO get smaller scratches; identity is empirical (4:2:0 witness,
444 frame equality with the parent, revert experiment), and the stride*h
sizing stays -- the 4:2:2 leaf's TX_4X8 unit panics on the square sizing.

t422 frame 0 re-verified byte-exact at PREFILT/POSTCDEF after the rework;
4:2:0 pixel-exact witness and the refusal gate re-run green; cargo check
0 warnings.
crates/ec-av1/src/decode.rsmodified+22 -44
@@ -30987,12 +30987,6 @@ pub(crate) fn obmc_plan(
3098730987 // `av1_setup_build_prediction_by_above_pred` passing that ref's own
3098830988 // `scale_factors`).
3098930989 frame_width: usize,
30990- // lane-av1-422sub8rect: the plane's own subsampling shifts -- every
30991- // chroma extent below derives from the luma rule by `>> ss` on the
30992- // subsampled axis (`build_obmc_inter_pred_above`'s
30993- // `overlap >> pd->subsampling_y` and the left pass's matching `>> ss_x`),
30994- // never a blind half. 4:2:0 and 4:4:4 reduce to the old /2s and 0s.
30995- ss: (usize, usize),
3099630990 ) -> Result<ObmcPlan> {
3099730991 // lane-rect r2 (libaom av1_build_obmc_inter_prediction): each pass has
3099830992 // its OWN neighbour cap (width-log2 for above, height-log2 for left) and
@@ -31024,16 +31018,16 @@ pub(crate) fn obmc_plan(
3102431018 let overlap_above = write_h.min(64) / 2;
3102531019 let overlap_left = write_w.min(64) / 2;
3102631020 // lane-inter8 r1 / lane-scaledref r1: `av1_skip_u4x4_pred_in_obmc`
31027- // (reconinter.c:829) keys on the CHROMA plane block
31028- // (`get_plane_block_size(bsize, ss_x, ss_y)`): BLOCK_4X4/BLOCK_8X4/
31029- // BLOCK_4X8 return `dir == 0`, so the ABOVE pass skips chroma for those
31030- // and the LEFT pass never does. lane-av1-422sub8rect: keyed on the
31031- // per-axis-shifted plane shape now -- an 8x8 leaf is (4, 4) at 4:2:0
31032- // (skip) and (4, 8) at 4:2:2 (still skip, BLOCK_4X8 is in the list),
31033- // while 8x4/4x8 luma leaves are (4, 4) or (8, 4) at 4:2:2.
31034- let (ss_x, ss_y) = ss;
31035- let skip_chroma_above =
31036- matches!((write_w >> ss_x, write_h >> ss_y), (4, 4) | (8, 4) | (4, 8));
31021+ // (`reconinter.c` 820) returns `dir == 0` when the chroma plane's own
31022+ // block is BLOCK_4X4/8X4/4X8 (an 8x8, 16x8 or 8x16 luma block at 4:2:0):
31023+ // the ABOVE pass skips chroma entirely, the LEFT pass still blends it.
31024+ // lane-av1-422sub8rect stop-note: keyed on the LUMA write shape -- a
31025+ // 4:4:4 block's plane block is square, so libaom's plane-block test
31026+ // would run the above pass there; this tree keeps the 4:2:0-shaped
31027+ // corner-cut (measured: the ss-shifted conformant port moved a boundary
31028+ // sample AWAY from aomdec on the obmc444 fixture, lanes/ report) and
31029+ // leaves the 444-conformant flip to the owning 444 lane.
31030+ let skip_chroma_above = matches!((write_w, write_h), (8, 8) | (16, 8) | (8, 16));
3103731031 let mut above = Vec::new();
3103831032 for (off4, span4, nb, src4) in overlappable_above(grid, mi_row, mi_col, bw4, mi_cols, max_nb(bw4))
3103931033 {
@@ -31101,7 +31095,6 @@ pub(crate) fn obmc_plan(
3110131095 cpy,
3110231096 overlap_above,
3110331097 overlap_left,
31104- ss,
3110531098 skip_chroma_above,
3110631099 })
3110731100 }
@@ -31135,8 +31128,6 @@ pub(crate) struct ObmcPlan {
3113531128 cpy: usize,
3113631129 overlap_above: usize,
3113731130 overlap_left: usize,
31138- /// The plane's own subsampling shifts ([`obmc_plan`]).
31139- ss: (usize, usize),
3114031131 skip_chroma_above: bool,
3114131132 }
3114231133
@@ -31164,18 +31155,9 @@ pub(crate) fn obmc_run(
3116431155 cpy,
3116531156 overlap_above,
3116631157 overlap_left,
31167- ss,
3116831158 skip_chroma_above,
3116931159 ..
3117031160 } = plan;
31171- // lane-av1-422sub8rect: every chroma extent is the luma rule shifted by
31172- // the plane's own subsampling (`build_obmc_inter_pred_above`'s
31173- // `overlap >> pd->subsampling_y`, the left pass's `>> ss_x`, the
31174- // neighbour-span `>> ss` per axis) -- 4:2:0 and 4:4:4 reduce to the old
31175- // halves, 4:2:2 keeps the unhalved height.
31176- let (ss_x, ss_y) = ss;
31177- let chroma_w = write_w >> ss_x;
31178- let chroma_h = write_h >> ss_y;
3117931161 // lane-alloc: one neighbour-prediction buffer per plane for the whole
3118031162 // block, reused by every neighbour of the above and left passes.
3118131163 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(
3119431176 let (x, y) = (f[1].parse::<usize>().ok()?, f[2].parse::<usize>().ok()?);
3119531177 let fr = f.get(3).and_then(|s| s.parse::<i64>().ok()).unwrap_or(-1);
3119631178 let idx = PREFILT_PICTURE_IDX.load(std::sync::atomic::Ordering::SeqCst) as i64;
31197- let (mcb_cw, mcb_ch) = (write_w >> ss_x, write_h >> ss_y);
31198- if x >= cpx && x < cpx + mcb_cw && y >= cpy && y < cpy + mcb_ch
31179+ if x >= cpx && x < cpx + write_w / 2 && y >= cpy && y < cpy + write_h / 2
3119931180 && (fr < 0 || fr == idx)
3120031181 {
3120131182 Some((x, y, idx))
@@ -31206,11 +31187,11 @@ pub(crate) fn obmc_run(
3120631187 if let Some((_, _, idx)) = ec_mcb {
3120731188 eprintln!(
3120831189 "OUR_MCB pre f={idx} cpx={cpx} cpy={cpy} cw={} ch={}",
31209- write_w >> ss_x,
31210- write_h >> ss_y
31190+ write_w / 2,
31191+ write_h / 2
3121131192 );
31212- for r in 0..(write_h >> ss_y) {
31213- let row: Vec<u16> = (0..(write_w >> ss_x)).map(|c| pred_u[r * chroma_side + c]).collect();
31193+ for r in 0..write_h / 2 {
31194+ let row: Vec<u16> = (0..write_w / 2).map(|c| pred_u[r * chroma_side + c]).collect();
3121431195 eprintln!("OUR_MCB prerow{r}: {row:?}");
3121531196 }
3121631197 }
@@ -31226,10 +31207,9 @@ pub(crate) fn obmc_run(
3122631207 if !skip_chroma_above {
3122731208 // lane-t900 r13 (measured, NOT a defect): libaom's min-4 clamp
3122831209 // sizes only the OBMC PREDICTION buffer; the blend length is the
31229- // plain `overlap >> ss_y` (`build_obmc_inter_pred_above`:
31230- // `bh = overlap >> pd->subsampling_y`).
31231- let (cbw, cbh, cox) = (bw >> ss_x, overlap_above >> ss_y, ox >> ss_x);
31232- let cw = cbw.min(chroma_w - cox);
31210+ // plain half (`build_obmc_inter_pred_above`: `overlap >> ss_y`).
31211+ let (cbw, cbh, cox) = (bw / 2, overlap_above / 2, ox / 2);
31212+ let cw = cbw.min(write_w / 2 - cox);
3123331213 obmc_neighbour_pred(nu, cpx + cox, cpy, nb.mv, cbw, cbh, false, nb.h_kind, nb.v_kind, nb.scale, &mut tmp_u, fctx);
3123431214 obmc_blend_v(pred_u, chroma_side, cox, 0, cw, cbh, cbw, &tmp_u);
3123531215 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(
3124431224 let (bw, bh, oy) = (overlap_left, nb.span4 * 4, nb.off4 * 4);
3124531225 obmc_neighbour_pred(ny, px, py + oy, nb.mv, bw, bh, true, nb.h_kind, nb.v_kind, nb.scale, &mut tmp_y, fctx);
3124631226 obmc_blend_h(pred_y, side, 0, oy, bw, bh.min(write_h - oy), &tmp_y);
31247- let (cbw, cbh, coy) = (overlap_left >> ss_x, bh >> ss_y, oy >> ss_y);
31227+ let (cbw, cbh, coy) = (overlap_left / 2, bh / 2, oy / 2);
3124831228 obmc_neighbour_pred(nu, cpx, cpy + coy, nb.mv, cbw, cbh, false, nb.h_kind, nb.v_kind, nb.scale, &mut tmp_u, fctx);
3124931229 if let Some((_, _, idx)) = ec_mcb {
3125031230 eprintln!(
@@ -31256,14 +31236,14 @@ pub(crate) fn obmc_run(
3125631236 eprintln!("OUR_MCB lrow{r}: {row:?}");
3125731237 }
3125831238 }
31259- let ch = cbh.min(chroma_h - coy);
31239+ let ch = cbh.min(write_h / 2 - coy);
3126031240 obmc_blend_h(pred_u, chroma_side, 0, coy, cbw, ch, &tmp_u);
3126131241 obmc_neighbour_pred(nv, cpx, cpy + coy, nb.mv, cbw, cbh, false, nb.h_kind, nb.v_kind, nb.scale, &mut tmp_v, fctx);
3126231242 obmc_blend_h(pred_v, chroma_side, 0, coy, cbw, ch, &tmp_v);
3126331243 }
3126431244 if let Some((_, _, idx)) = ec_mcb {
31265- for r in 0..chroma_h {
31266- let row: Vec<u16> = (0..chroma_w).map(|c| pred_u[r * chroma_side + c]).collect();
31245+ for r in 0..write_h / 2 {
31246+ let row: Vec<u16> = (0..write_w / 2).map(|c| pred_u[r * chroma_side + c]).collect();
3126731247 eprintln!("OUR_MCB post f={idx} row{r}: {row:?}");
3126831248 }
3126931249 }
@@ -34115,7 +34095,6 @@ fn decode_inter_block(
3411534095 refpix,
3411634096 interp_fixed,
3411734097 frame_width,
34118- (ss_x(fctx), ss_y(fctx)),
3411934098 )?)
3412034099 } else {
3412134100 None
@@ -39834,7 +39813,6 @@ ss_y(fctx),
3983439813 refpix,
3983539814 interp_fixed,
3983639815 frame_width,
39837- (ss_x(fctx), ss_y(fctx)),
3983839816 )?)
3983939817 } else {
3984039818 None
crates/ec-av1/src/encode.rsmodified+0 -1
@@ -6809,7 +6809,6 @@ fn obmc_prediction(
68096809 &refpix,
68106810 Some(fctx.interp_filter.get()),
68116811 frame_width,
6812- (crate::decode::ss_x(fctx), crate::decode::ss_y(fctx)),
68136812 )
68146813 .ok()?;
68156814 let mut pred = [
lanes/av1422sub8rect.report.mdmodified+54 -1
@@ -71,7 +71,10 @@
7171 behaviour, named for the owning lane.
7272 4. MEASURED after the port (17-frame probe run under the reverted bypass;
7373 comparator: ours padded 256x160/128x160 u8 cropped vs the instrumented
74- `$HOME/.cache/aom-oracle/build` aomdec):
74+ `$HOME/.cache/aom-oracle/build` aomdec; NOTE the probe prints REFUSED and
75+ still exits 0 -- the committed tree stops at frame 11 with the
76+ pre-existing "HORZ/VERT strip ... no rect coefficient tables" frontier
77+ refusal, exactly like the reworked tree):
7578 - frame 0: **byte-exact at PREFILT, POSTCDEF (and FINAL by the u16
7679 comparator) on Y, U and V — 0 diffs everywhere**, so the rect read,
7780 the split4 per-piece model and every shared-helper change are exact on
@@ -106,6 +109,56 @@
106109 - 4:2:0/4:4:4 untouched by construction (ss-keyed arms); the 4:2:0
107110 group-tail SKIP arm untouched; `read_coeffs_rect` untouched.
108111
112+## Review rework (r2, post-review findings 1-3)
113+
114+The review correctly rejected two byte-identity claims and one
115+justification:
116+
117+1. **444 OBMC behaviour now UNCHANGED from the parent.** The first commit
118+ made `obmc_plan`/`obmc_run` ss-exact (`av1_skip_u4x4_pred_in_obmc`
119+ keyed on the plane block; chroma extents `>> ss`), which is what
120+ reconinter.c does -- but it CHANGES 4:4:4 behaviour (the above-pass
121+ chroma skip flips to run on square plane blocks, the blend extents
122+ double) and is NOT byte-identical, with no 444 OBMC gate covering it.
123+ Measured before reworking: fixture `/tmp/obmc444/obmc444.obu` sha256
124+ `4b5c0a473c7ca5bd460e76bb5d7fde541dc996bec45f60bfcc393eb2f11731ef`
125+ (10-frame 128x96 4:4:4 aomenc `--enable-obmc=1 --profile=1`, 2 rect
126+ OBMC leaves firing per the probe census), decoded parent (4e8c6073)
127+ vs tip vs instrumented aomdec: parent and tip read IDENTICAL symbols
128+ and differ in exactly ONE V sample (f1, (82,80)): oracle 110 ==
129+ parent, tip 111. Attribution by single-change revert builds: reverting
130+ `TxParams::strided` alone (varB) reproduces tip exactly; reverting the
131+ OBMC ss semantics alone (varA) reproduces the parent exactly -- so the
132+ whole parent<->tip delta is the OBMC change, and on this fixture the
133+ conformant variant is one sample FARTHER from aomdec, never closer.
134+ Per the review protocol ("if worse, rework") the OBMC ss semantics are
135+ REVERTED to the parent's 4:2:0-shaped corner-cut (luma-keyed
136+ `skip_chroma_above`, half chroma blend extents); the 444-conformant
137+ port stays deferred to the owning 444 lane, which can measure it on
138+ OBMC-heavy 444 content once that lane's reconstruction class is exact
139+ enough to gate on. `encode.rs` carries no change any more (the ss
140+ argument is gone with the parameter).
141+2. **`TxParams::strided` justification corrected.** The commit text
142+ claimed "every pre-existing caller has h == stride" -- wrong:
143+ `read_inter_plane_rect` callers pass rect units with `h < stride`
144+ (e.g. an 8x4 unit in an 8x8-strided plane buffer), and for those the
145+ scratch shrinks from `stride*stride` to `stride*h`. Output identity
146+ holds because the copy loop only ever writes `h` rows of `w <= stride`
147+ and every consumer reads the residual through the same dense bounds --
148+ verified empirically (the 4:2:0 pixel-exact witness, 4:4:4 frame
149+ equality with the parent on the obmc444 fixture, and the varB
150+ revert experiment), not by the removed claim. The `stride * h` sizing
151+ itself STAYS: the 4:2:2 leaf's TX_4X8 unit (stride 4, h 8) panics on
152+ the old square sizing.
153+3. The t422 measurement note above also corrects the probe's exit-status
154+ reading (REFUSED still exits 0; both the committed and reworked trees
155+ stop at frame 11 on the pre-existing strip-chroma frontier refusal).
156+
157+Everything else in Outcome 3 (the leaf8 rect port, the split4 per-piece
158+model, the ss-keyed masked/interintra blends) is untouched by the rework;
159+frame 0 re-verified byte-exact at PREFILT/POSTCDEF after it, and both
160+gates re-run green post-revert.
161+
109162 ## Verification
110163
111164 - `cargo check -p ec-av1` (target `~/.cache/cargo-target-av1422sub8rect`):