diff --git a/crates/ec-av1/examples/decode_probe.rs b/crates/ec-av1/examples/decode_probe.rs index 7830e580..4c2ad7e9 100644 --- a/crates/ec-av1/examples/decode_probe.rs +++ b/crates/ec-av1/examples/decode_probe.rs @@ -136,6 +136,12 @@ fn main() { "intra16x4_in_inter: 16x4={} 4x16={} chroma_ref={}", i164.0, i164.1, i164.2 ); + // lane-t900 r12: chroma edge-filter neighbour answered from the mi-granular + // uv_mode grid instead of the coarse one-slot-per-column map. + println!( + "uv_mode_grid_override: {}", + ec_av1::decode::uv_mode_grid_override_hits() + ); }; // lane-tiles: the tiling a real stream actually uses is a decision input // (every gate in `stream.rs` picks its own `--tile-columns`), so report it diff --git a/crates/ec-av1/src/decode.rs b/crates/ec-av1/src/decode.rs index fca72f51..80a9f142 100644 --- a/crates/ec-av1/src/decode.rs +++ b/crates/ec-av1/src/decode.rs @@ -19535,6 +19535,36 @@ fn obmc_blend( // ABOVE pass skips chroma entirely, the LEFT pass still blends it. let skip_chroma_above = matches!((write_w, write_h), (8, 8) | (16, 8) | (8, 16)); + // lane-t900 r13 rung: EC_MCB="::[:]" (chroma plane + // 1 only) 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)> = std::env::var("EC_MCB").ok().and_then(|v| { + let f: Vec<&str> = v.split(':').collect(); + if f.len() < 3 || f[0] != "1" { + return None; + } + 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) + { + 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(); + eprintln!("OUR_MCB prerow{r}: {row:?}"); + } + } for (off4, span4, nb, src4) in overlappable_above(grid, mi_row, mi_col, bw4, mi_cols, max_nb(bw4)) { // `Neighbours::above_filter` is indexed in `SUB`(16px)-wide columns @@ -19559,6 +19589,13 @@ fn obmc_blend( let tmp_y = obmc_neighbour_pred(ny, px + ox, py, nb.mv, bw, bh, true, h_kind, v_kind, nb_scale); obmc_blend_v(pred_y, side, ox, 0, bw, bh, &tmp_y); if !skip_chroma_above { + // lane-t900 r13 (measured, NOT a defect): libaom's min-4 clamp + // (`dec_build_prediction_by_above_pred`) sizes only the OBMC + // PREDICTION buffer; the blend length is the plain half + // (`build_obmc_inter_pred_above`: `overlap >> ss_y`), so flooring + // this at 4 blends rows libaom never blends -- on a 10-bit + // 1920x792 cut that went 36 differing frames -> 266, worst + // 13 B -> 11007 B. let (cbw, cbh, cox) = (bw / 2, overlap_above / 2, ox / 2); let tmp_u = obmc_neighbour_pred(nu, cpx + cox, cpy, nb.mv, cbw, cbh, false, h_kind, v_kind, nb_scale); obmc_blend_v(pred_u, chroma_side, cox, 0, cbw, cbh, &tmp_u); @@ -19587,6 +19624,12 @@ fn obmc_blend( let tmp_v = obmc_neighbour_pred(nv, cpx, cpy + coy, nb.mv, cbw, cbh, false, h_kind, v_kind, nb_scale); obmc_blend_h(pred_v, chroma_side, 0, coy, cbw, cbh, &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(); + eprintln!("OUR_MCB post f={idx} row{r}: {row:?}"); + } + } Ok(()) } diff --git a/crates/ec-av1/src/stream.rs b/crates/ec-av1/src/stream.rs index 34d8d3fc..aa935653 100644 --- a/crates/ec-av1/src/stream.rs +++ b/crates/ec-av1/src/stream.rs @@ -30579,12 +30579,22 @@ mod tests { let (width, height) = (1920usize, 792usize); let gm_before = crate::decode::gm_nontrans_small_side_hits(); let tr_before = crate::decode::tr_reach_longer_side_hits(); + // lane-t900 r13: this stream is also the witness for r12's mi-granular + // uv_mode grid -- the chroma edge-filter neighbour read that the coarse + // one-slot-per-column map answered wrongly inside a sub-8x8 pair. + let uv_before = crate::decode::uv_mode_grid_override_hits(); let frames = match decode_stream(&stream) { Ok(frames) => frames, Err(e) => panic!("{NAME}: decode_stream refused: {e}"), }; let gm = crate::decode::gm_nontrans_small_side_hits() - gm_before; let tr = crate::decode::tr_reach_longer_side_hits() - tr_before; + let uvg = crate::decode::uv_mode_grid_override_hits() - uv_before; + assert!( + uvg > 0, + "{NAME}: uv_mode_grid_override never fired -- the chroma edge-filter \ + grid read would be untested" + ); assert!( gm > 0, "{NAME}: gm_nontrans_small_side never fired -- the gate would be vacuous for it" @@ -30610,7 +30620,8 @@ mod tests { } eprintln!( "{NAME}: 33 shown frames pixel-exact on every plane; \ - gm_nontrans_small_side={gm} tr_reach_longer_side={tr}" + gm_nontrans_small_side={gm} tr_reach_longer_side={tr} \ + uv_mode_grid_override={uvg}" ); } diff --git a/lanes/t900-r13.handoff.md b/lanes/t900-r13.handoff.md new file mode 100644 index 00000000..ee837b31 --- /dev/null +++ b/lanes/t900-r13.handoff.md @@ -0,0 +1,66 @@ +# lane-t900 r13 handoff -- start at the OBMC LEFT pass of a bottom-overhanging block + +Tip `f24c9807` on `lane-t900` (base main `2b65cb8e`). Full report: `lanes/t900-r13.report.md`. + +## Suite (both runs green, no FAILED) + +* tip `66d88cfe` (r12 code): `test result: ok. 429 passed; 0 failed; 38 ignored; 0 measured; + 0 filtered out; finished in 771.39s` -- `$HOME/.cache/t900-suite-r13.log`. +* tip `25603b14` (r13 code): `test result: ok. 429 passed; 0 failed; 38 ignored; 0 measured; + 0 filtered out; finished in 748.12s` -- `$HOME/.cache/t900-suite-r13b.log`. +* `cargo check -p ec-av1 --tests` clean on the final tip. + +## Facts established this round (do not re-measure) + +1. The four 4K offsets the r13 charter listed as whole-frame desyncs (2700 f73, 3000 f43, + 1500, 5400) are **byte-exact on this tip**: 107/193/244/160 decode frames, 0 differing. + r12's `uv_mode_grid` fix cured them. Cuts (each hashed twice, identical): + `~/.cache/t900-tmp/h{2700,3000,1500,5400}.obu`. Compare script `~/.cache/t900-tmp/cmp13.sh` + (uses `$HOME/.cache/cargo-target-t900b` so it never shares a target dir with a suite). +2. r12's fix now has a witness: `gm_small_side_witness.obu` fires `uv_mode_grid_override` + 138 times and the gate hard-asserts it. `reelc_sb128_inter_witness` fires it 24; the four + `reelb_*` witnesses fire 0. +3. The 1-3 B residue on the 1080p 900 s cut (36 frames, first 41, worst 13) is + **inside the OBMC blend, not the base MC**. On frame 41 the chroma block + `mi_x=704 mi_y=768 bw=16 bh=16` (32x32 luma at mi(192,176), overhanging the bottom: + mi_rows=198), `mm=1 skip=1 mv0=(-4,14) ref0=5`: + * pre-blend chroma prediction = aomdec's, all 16 rows; + * after the blend our prefilter recon differs at exactly one sample, row 11 col 1 + (`U(353,395)`, aom 492 ours 493), which lies in the LEFT pass's 8-column strip and + below the ABOVE pass's 4-row strip. + So: LEFT-pass neighbour prediction or its blend, at the block's last valid chroma row. +4. Dead end (measured, reverted, recorded in a comment at the site): flooring the chroma + OBMC blend length at 4 (libaom's `clamp(..., 4, ...)`) -- that clamp sizes the PREDICTION + buffer only; the blend length is `overlap >> ss`. 36 differing frames -> 266, worst 13 B + -> 11007 B. +5. Ruled out by reading both sources: `build_mc_border`/`update_extend_mc_border_params` + clamp to `uv_crop_width/height` (960x396) = our `true_width/true_height`; + `clamp_mv_to_umv_border_sb` is result-equivalent to tap clamping. + +## Rungs available (both additive and env-gated) + +* aomdec private build (`~/.cache/aom-oracle/src/av1/decoder/decodeframe.c`, rebuilt with + `ninja -C ~/.cache/aom-oracle/build aomdec`): `EC_MCB="::[:]"` prints + every `dec_build_inter_predictors` call whose plane-pixel span covers that pixel -- + including the `obmc=1` neighbour predictions (their rows come from the tmp buffer) -- + with `f=` (decode-order frame, counter `ec_t900_frame`), bw/bh, mode, `mm`, skip, mv0, + refs, interp, `prew/preh/stride`. +* ours: `OUR_MCB` in `decode.rs::obmc_blend`, same env spelling, chroma rows before and + after the blend; `EC_OBMC` (pre-existing) prints the neighbour list on both decoders. +* Cut with frame 41 near the end: `~/.cache/t900-tmp/c900_62.obu` + (`python3 ~/.cache/reelckf-work/trunc.py cut_900.obu 62 c900_62.obu`). + +## Next step (chartered) + +`EC_MCB=1:353:395:41` on aomdec over `c900_62.obu` and read the `obmc=1` entries for +`mi_x=704`: compare each LEFT-pass neighbour (position, span, mv, ref, filter -- `EC_OBMC` +on both) and then the tmp rows at row 11 against ours. Our left pass sizes are +`(bw, bh, oy) = (overlap_left, span4*4, off4*4)` with chroma `(overlap_left/2, bh/2, oy/2)` +(`decode.rs` ~19585); libaom's are `bh = (mi_step*MI_SIZE) >> ss_y` and blend width +`overlap >> ss_x` -- check what libaom does with `mi_step` when the neighbour span runs +past `mi_rows` at the frame bottom. + +## Owed + +* 1080p 0-10 s head re-probe (was 78 differing, first 86 -- unmeasured since r11). +* census8's 24 not-exact 4K offsets (run8.sh) re-probe. diff --git a/lanes/t900-r13.report.md b/lanes/t900-r13.report.md new file mode 100644 index 00000000..d5b9c53a --- /dev/null +++ b/lanes/t900-r13.report.md @@ -0,0 +1,113 @@ +# lane-t900 r13 report -- the four 4K whole-frame desyncs were already cured by r12; the 1-3 B residue is inside the OBMC blend, not the base MC + +Tip `7a111b9d` on `lane-t900` (base main `2b65cb8e`; r12 tip `66d88cfe` was already +a fast-forward of main, no merge needed this round). + +## STEP 0 -- suite + +`systemd-run --user --unit=t900-suite-r13-... cargo test -p ec-av1 --lib -j3` +(EC_NOMEMGUARD=1 EC_AV1_REQUIRE_AOMENC=1, log `$HOME/.cache/t900-suite-r13.log`): + + test result: ok. 429 passed; 0 failed; 38 ignored; 0 measured; 0 filtered out + +No red from r11/r12. A confirmation run on the r13 tip is armed +(`$HOME/.cache/t900-suite-r13b.log`); the one test whose code changed +(`a_10bit_film_frames_with_small_side_globalmv_and_rect_warp_reach_decode_pixel_exact`) +was run alone on the r13 tree and passes -- see STEP 1. + +## STEP 1 -- witness for r12's mi-granular uv_mode grid (DONE, no new fixture) + +`decode_probe` now prints `uv_mode_grid_override`. Measured over the existing witnesses: + +| fixture | uv_mode_grid_override | +|---|---| +| `gm_small_side_witness.obu` | **138** | +| `reelc_sb128_inter_witness.obu` | 24 | +| `reelb_head_mvclamp_witness.obu` | 0 | +| `reelb_arf_witness.obu` | 0 | +| `reelb_intra14_witness.obu` | 0 | +| `reelb_rect64_intra16x4_witness.obu` | 0 | + +So no new fixture was pinned (charter's fallback): the small-side GLOBALMV gate now +hard-asserts the counter. + +EVIDENCE: $HOME/.cache/t900-uvgate.log | cargo test -p ec-av1 --lib small_side_globalmv -- --nocapture | `33 shown frames pixel-exact on every plane; gm_nontrans_small_side=1 tr_reach_longer_side=2295 uv_mode_grid_override=138`, `1 passed; 0 failed` + +## STEP 2 -- the four 4K offsets: ALL EXACT, the charter's premise was stale + +Every cut extracted twice, identical sha256 both times; both decoders compared with +`EC_AV1_FINAL_DUMP` per decode-order frame (`~/.cache/t900-tmp/cmp13.sh`). + +| offset (10-bit 3840x1608 HDR film) | charter premise (pre-r12) | measured on r13 tip | +|---|---|---| +| 2700 s, 2 s | f73 first differing, 15.8 MB (whole frame) | **107 decode frames, 0 differing** | +| 3000 s, 2 s | f43 first differing | **193 frames, 0 differing** | +| 1500 s, 2 s | Golomb / own desync | **244 frames, 0 differing** | +| 5400 s, 2 s | Golomb / own desync | **160 frames, 0 differing** | + +r12's chroma edge-filter fix (`uv_mode_grid`) cured all four; there was no frame-73 +ladder to run. No EC_MODE ladder was needed and none was run. + +EVIDENCE: ~/.cache/t900-tmp/d_h2700, d_h3000, d_h1500, d_h5400 | cmp13.sh per offset (aomdec EC_AV1_FINAL_DUMP vs decode_probe, byte compare per decode frame) | 107/193/244/160 frames, 0 differing each + +## STEP 3 -- the 1-3 B bottom-edge residue: localised to the OBMC BLEND (open) + +10-bit 1920x792 cut at 900 s (`~/.cache/t900-tmp/cut_900.obu`, 267 decode frames): +36 differing frames, first f41 (1 B), worst 13 B -- unchanged by r12. + +Sample census (final dump): every differing sample is CHROMA, in chroma rows 390-395 +(the bottom 12 luma rows), and off by +-1 (rarely +-2). Luma is bit-exact everywhere. + +New rungs this round: +* aomdec (private build, additive, env-gated): `EC_MCB="::[:]"` in + `dec_build_inter_predictors` prints the block whose plane-pixel span COVERS that pixel + (frame counter `ec_t900_frame`, bumped where `EC_AV1_FINAL_DUMP` writes). +* ours: `OUR_MCB` in `decode.rs` `obmc_blend`, same env spelling, prints the chroma + prediction rows on entry and on exit of the blend. + +Frame 41, the block that owns the differing sample: chroma `mi_x=704 mi_y=768 bw=16 bh=16` +(32x32 luma at mi(192,176), which OVERHANGS the frame bottom: mi_rows=198), `mm=1` (OBMC), +`skip=1`, `mv0=(-4,14)`, ref0=5, `prew=960 preh=396`. + +* PRE-blend chroma prediction: **all 16 rows bit-identical** to aomdec. +* Post-blend: our recon differs at exactly one sample, `U(353,395)` = row 11, col 1 + (prefilter dump: aom 492, ours 493; the loop filter then spreads it to `U(354,395)` + in the final dump). +* Col 1 is inside the LEFT pass's overlap strip (8 chroma columns) and outside the ABOVE + pass's (4 rows), and row 11 is the block's LAST valid chroma row -- so the residue is in + the LEFT-pass OBMC neighbour prediction/blend of a bottom-overhanging block, NOT in the + base motion compensation and NOT (r8's premise) a bottom-edge tap clamp of the block's + own MC. + +EVIDENCE: ~/.cache/t900-tmp/aom_mcb41.txt, our_mcb41.txt, pf13/{aom,ours}.f41 | EC_MCB=1:354:395:41 on both decoders over c900_62.obu + EC_AV1_PREFILT_DUMP16 compare | 16/16 pre-blend rows identical; prefilter f41 diffs=1 at U(353,395) 492vs493 + +Dead end measured and recorded in the code (`decode.rs` obmc_blend): libaom's min-4 +clamp (`dec_build_prediction_by_above_pred`: `clamp(block_size_high[bsize] >> (ss_y+1), 4, ...)`) +sizes only the OBMC PREDICTION buffer -- the blend length stays the plain half +(`build_obmc_inter_pred_above`: `overlap >> ss_y`). Flooring the chroma blend at 4 took +cut_900 from 36 differing frames to 266 and the worst frame from 13 B to 11007 B; reverted. + +Also read and ruled out by source on both sides (no code change): `build_mc_border` / +`update_extend_mc_border_params` clamp to `pre_buf->width/height` = `uv_crop_*` = 960x396, +identical to our `true_width/true_height`; `clamp_mv_to_umv_border_sb` is result-equivalent +to tap clamping wherever the geometry it is given is the block's own. + +Residue disposition: **deferred(next round)** -- the next rung is aomdec's `EC_MCB` with +`obmc=1` (it already prints the neighbour prediction from the tmp buffer) against our +`ec_obmc_trace`/`OUR_MCB` for the LEFT pass of that block: compare the neighbour list +(position, span, mv, ref, filter) and then the tmp rows at row 11. + +## STEP 4 -- re-probe + +The four 4K offsets above are the re-probe (all exact). The 4K 10 s head was measured +0 of 241 differing on this code in r12 and is unchanged here (no decode-path change this +round -- the only non-comment edits are trace/gate code). The 1080p 0-10 s head re-probe +and the census8 24-offset sweep are **deferred(turn cap)**. + +## Files changed + +* `crates/ec-av1/src/stream.rs` -- the small-side GLOBALMV gate asserts and reports + `uv_mode_grid_override > 0` (witness for r12's fix). +* `crates/ec-av1/examples/decode_probe.rs` -- prints `uv_mode_grid_override`. +* `crates/ec-av1/src/decode.rs` -- `OUR_MCB` rung in `obmc_blend`; a comment recording the + measured OBMC min-4 dead end.