ec-av1: lane-av1-422sub8rect review rework -- 444 OBMC back to the parent corner-cut, strided claim corrected
Browse files at this commit66b4c762ad487552b0c42c87be09d659f6c967bdParent: 19f693e3 changed files +76 -46
- crates/ec-av1/src/decode.rs +22 -44
- crates/ec-av1/src/encode.rs +0 -1
- lanes/av1422sub8rect.report.md +54 -1
crates/ec-av1/src/decode.rsmodified+22 -44
| @@ -30987,12 +30987,6 @@ pub(crate) fn obmc_plan( | ||
| 30987 | 30987 | // `av1_setup_build_prediction_by_above_pred` passing that ref's own |
| 30988 | 30988 | // `scale_factors`). |
| 30989 | 30989 | 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), | |
| 30996 | 30990 | ) -> Result<ObmcPlan> { |
| 30997 | 30991 | // lane-rect r2 (libaom av1_build_obmc_inter_prediction): each pass has |
| 30998 | 30992 | // its OWN neighbour cap (width-log2 for above, height-log2 for left) and |
| @@ -31024,16 +31018,16 @@ pub(crate) fn obmc_plan( | ||
| 31024 | 31018 | let overlap_above = write_h.min(64) / 2; |
| 31025 | 31019 | let overlap_left = write_w.min(64) / 2; |
| 31026 | 31020 | // 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)); | |
| 31037 | 31031 | let mut above = Vec::new(); |
| 31038 | 31032 | for (off4, span4, nb, src4) in overlappable_above(grid, mi_row, mi_col, bw4, mi_cols, max_nb(bw4)) |
| 31039 | 31033 | { |
| @@ -31101,7 +31095,6 @@ pub(crate) fn obmc_plan( | ||
| 31101 | 31095 | cpy, |
| 31102 | 31096 | overlap_above, |
| 31103 | 31097 | overlap_left, |
| 31104 | - ss, | |
| 31105 | 31098 | skip_chroma_above, |
| 31106 | 31099 | }) |
| 31107 | 31100 | } |
| @@ -31135,8 +31128,6 @@ pub(crate) struct ObmcPlan { | ||
| 31135 | 31128 | cpy: usize, |
| 31136 | 31129 | overlap_above: usize, |
| 31137 | 31130 | overlap_left: usize, |
| 31138 | - /// The plane's own subsampling shifts ([`obmc_plan`]). | |
| 31139 | - ss: (usize, usize), | |
| 31140 | 31131 | skip_chroma_above: bool, |
| 31141 | 31132 | } |
| 31142 | 31133 | |
| @@ -31164,18 +31155,9 @@ pub(crate) fn obmc_run( | ||
| 31164 | 31155 | cpy, |
| 31165 | 31156 | overlap_above, |
| 31166 | 31157 | overlap_left, |
| 31167 | - ss, | |
| 31168 | 31158 | skip_chroma_above, |
| 31169 | 31159 | .. |
| 31170 | 31160 | } = 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; | |
| 31179 | 31161 | // lane-alloc: one neighbour-prediction buffer per plane for the whole |
| 31180 | 31162 | // block, reused by every neighbour of the above and left passes. |
| 31181 | 31163 | 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( | ||
| 31194 | 31176 | let (x, y) = (f[1].parse::<usize>().ok()?, f[2].parse::<usize>().ok()?); |
| 31195 | 31177 | let fr = f.get(3).and_then(|s| s.parse::<i64>().ok()).unwrap_or(-1); |
| 31196 | 31178 | 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 | |
| 31199 | 31180 | && (fr < 0 || fr == idx) |
| 31200 | 31181 | { |
| 31201 | 31182 | Some((x, y, idx)) |
| @@ -31206,11 +31187,11 @@ pub(crate) fn obmc_run( | ||
| 31206 | 31187 | if let Some((_, _, idx)) = ec_mcb { |
| 31207 | 31188 | eprintln!( |
| 31208 | 31189 | "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 | |
| 31211 | 31192 | ); |
| 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(); | |
| 31214 | 31195 | eprintln!("OUR_MCB prerow{r}: {row:?}"); |
| 31215 | 31196 | } |
| 31216 | 31197 | } |
| @@ -31226,10 +31207,9 @@ pub(crate) fn obmc_run( | ||
| 31226 | 31207 | if !skip_chroma_above { |
| 31227 | 31208 | // lane-t900 r13 (measured, NOT a defect): libaom's min-4 clamp |
| 31228 | 31209 | // 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); | |
| 31233 | 31213 | obmc_neighbour_pred(nu, cpx + cox, cpy, nb.mv, cbw, cbh, false, nb.h_kind, nb.v_kind, nb.scale, &mut tmp_u, fctx); |
| 31234 | 31214 | obmc_blend_v(pred_u, chroma_side, cox, 0, cw, cbh, cbw, &tmp_u); |
| 31235 | 31215 | 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( | ||
| 31244 | 31224 | let (bw, bh, oy) = (overlap_left, nb.span4 * 4, nb.off4 * 4); |
| 31245 | 31225 | obmc_neighbour_pred(ny, px, py + oy, nb.mv, bw, bh, true, nb.h_kind, nb.v_kind, nb.scale, &mut tmp_y, fctx); |
| 31246 | 31226 | 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); | |
| 31248 | 31228 | obmc_neighbour_pred(nu, cpx, cpy + coy, nb.mv, cbw, cbh, false, nb.h_kind, nb.v_kind, nb.scale, &mut tmp_u, fctx); |
| 31249 | 31229 | if let Some((_, _, idx)) = ec_mcb { |
| 31250 | 31230 | eprintln!( |
| @@ -31256,14 +31236,14 @@ pub(crate) fn obmc_run( | ||
| 31256 | 31236 | eprintln!("OUR_MCB lrow{r}: {row:?}"); |
| 31257 | 31237 | } |
| 31258 | 31238 | } |
| 31259 | - let ch = cbh.min(chroma_h - coy); | |
| 31239 | + let ch = cbh.min(write_h / 2 - coy); | |
| 31260 | 31240 | obmc_blend_h(pred_u, chroma_side, 0, coy, cbw, ch, &tmp_u); |
| 31261 | 31241 | obmc_neighbour_pred(nv, cpx, cpy + coy, nb.mv, cbw, cbh, false, nb.h_kind, nb.v_kind, nb.scale, &mut tmp_v, fctx); |
| 31262 | 31242 | obmc_blend_h(pred_v, chroma_side, 0, coy, cbw, ch, &tmp_v); |
| 31263 | 31243 | } |
| 31264 | 31244 | 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(); | |
| 31267 | 31247 | eprintln!("OUR_MCB post f={idx} row{r}: {row:?}"); |
| 31268 | 31248 | } |
| 31269 | 31249 | } |
| @@ -34115,7 +34095,6 @@ fn decode_inter_block( | ||
| 34115 | 34095 | refpix, |
| 34116 | 34096 | interp_fixed, |
| 34117 | 34097 | frame_width, |
| 34118 | - (ss_x(fctx), ss_y(fctx)), | |
| 34119 | 34098 | )?) |
| 34120 | 34099 | } else { |
| 34121 | 34100 | None |
| @@ -39834,7 +39813,6 @@ ss_y(fctx), | ||
| 39834 | 39813 | refpix, |
| 39835 | 39814 | interp_fixed, |
| 39836 | 39815 | frame_width, |
| 39837 | - (ss_x(fctx), ss_y(fctx)), | |
| 39838 | 39816 | )?) |
| 39839 | 39817 | } else { |
| 39840 | 39818 | None |
crates/ec-av1/src/encode.rsmodified+0 -1
| @@ -6809,7 +6809,6 @@ fn obmc_prediction( | ||
| 6809 | 6809 | &refpix, |
| 6810 | 6810 | Some(fctx.interp_filter.get()), |
| 6811 | 6811 | frame_width, |
| 6812 | - (crate::decode::ss_x(fctx), crate::decode::ss_y(fctx)), | |
| 6813 | 6812 | ) |
| 6814 | 6813 | .ok()?; |
| 6815 | 6814 | let mut pred = [ |
lanes/av1422sub8rect.report.mdmodified+54 -1
| @@ -71,7 +71,10 @@ | ||
| 71 | 71 | behaviour, named for the owning lane. |
| 72 | 72 | 4. MEASURED after the port (17-frame probe run under the reverted bypass; |
| 73 | 73 | 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): | |
| 75 | 78 | - frame 0: **byte-exact at PREFILT, POSTCDEF (and FINAL by the u16 |
| 76 | 79 | comparator) on Y, U and V — 0 diffs everywhere**, so the rect read, |
| 77 | 80 | the split4 per-piece model and every shared-helper change are exact on |
| @@ -106,6 +109,56 @@ | ||
| 106 | 109 | - 4:2:0/4:4:4 untouched by construction (ss-keyed arms); the 4:2:0 |
| 107 | 110 | group-tail SKIP arm untouched; `read_coeffs_rect` untouched. |
| 108 | 111 | |
| 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 | + | |
| 109 | 162 | ## Verification |
| 110 | 163 | |
| 111 | 164 | - `cargo check -p ec-av1` (target `~/.cache/cargo-target-av1422sub8rect`): |