forge
Explore
Log in

Don't you dare go Hollow

Merge branch 'lane-t900' (deb9f6be): uv_mode grid counter asserted on the small-side GLOBALMV witness; OBMC blend rung on both decoders

Browse files at this commit

deea6ff1e9f83fbb5c29487dac878cd36d96d27cAhmet Kaan GümüşParent: b8fb9be23c7e68
crates/ec-av1/examples/decode_probe.rsmodified+6 -0
@@ -136,6 +136,12 @@ fn main() {
136 "intra16x4_in_inter: 16x4={} 4x16={} chroma_ref={}",136 "intra16x4_in_inter: 16x4={} 4x16={} chroma_ref={}",
137 i164.0, i164.1, i164.2137 i164.0, i164.1, i164.2
138 );138 );
139+ // lane-t900 r12: chroma edge-filter neighbour answered from the mi-granular
140+ // uv_mode grid instead of the coarse one-slot-per-column map.
141+ println!(
142+ "uv_mode_grid_override: {}",
143+ ec_av1::decode::uv_mode_grid_override_hits()
144+ );
139 };145 };
140 // lane-tiles: the tiling a real stream actually uses is a decision input146 // lane-tiles: the tiling a real stream actually uses is a decision input
141 // (every gate in `stream.rs` picks its own `--tile-columns`), so report it147 // (every gate in `stream.rs` picks its own `--tile-columns`), so report it
crates/ec-av1/src/decode.rsmodified+43 -0
@@ -19535,6 +19535,36 @@ fn obmc_blend(
19535 // ABOVE pass skips chroma entirely, the LEFT pass still blends it.19535 // ABOVE pass skips chroma entirely, the LEFT pass still blends it.
19536 let skip_chroma_above = matches!((write_w, write_h), (8, 8) | (16, 8) | (8, 16));19536 let skip_chroma_above = matches!((write_w, write_h), (8, 8) | (16, 8) | (8, 16));
19537 19537
19538+ // lane-t900 r13 rung: EC_MCB="<plane>:<px>:<py>[:<frame>]" (chroma plane
19539+ // 1 only) prints this block's chroma prediction rows before and after the
19540+ // OBMC blend, matching the instrumented aomdec's EC_MCB dump.
19541+ let ec_mcb: Option<(usize, usize, i64)> = std::env::var("EC_MCB").ok().and_then(|v| {
19542+ let f: Vec<&str> = v.split(':').collect();
19543+ if f.len() < 3 || f[0] != "1" {
19544+ return None;
19545+ }
19546+ let (x, y) = (f[1].parse::<usize>().ok()?, f[2].parse::<usize>().ok()?);
19547+ let fr = f.get(3).and_then(|s| s.parse::<i64>().ok()).unwrap_or(-1);
19548+ let idx = PREFILT_PICTURE_IDX.load(std::sync::atomic::Ordering::SeqCst) as i64;
19549+ if x >= cpx && x < cpx + write_w / 2 && y >= cpy && y < cpy + write_h / 2
19550+ && (fr < 0 || fr == idx)
19551+ {
19552+ Some((x, y, idx))
19553+ } else {
19554+ None
19555+ }
19556+ });
19557+ if let Some((_, _, idx)) = ec_mcb {
19558+ eprintln!(
19559+ "OUR_MCB pre f={idx} cpx={cpx} cpy={cpy} cw={} ch={}",
19560+ write_w / 2,
19561+ write_h / 2
19562+ );
19563+ for r in 0..write_h / 2 {
19564+ let row: Vec<u16> = (0..write_w / 2).map(|c| pred_u[r * chroma_side + c]).collect();
19565+ eprintln!("OUR_MCB prerow{r}: {row:?}");
19566+ }
19567+ }
19538 for (off4, span4, nb, src4) in overlappable_above(grid, mi_row, mi_col, bw4, mi_cols, max_nb(bw4))19568 for (off4, span4, nb, src4) in overlappable_above(grid, mi_row, mi_col, bw4, mi_cols, max_nb(bw4))
19539 {19569 {
19540 // `Neighbours::above_filter` is indexed in `SUB`(16px)-wide columns19570 // `Neighbours::above_filter` is indexed in `SUB`(16px)-wide columns
@@ -19559,6 +19589,13 @@ fn obmc_blend(
19559 let tmp_y = obmc_neighbour_pred(ny, px + ox, py, nb.mv, bw, bh, true, h_kind, v_kind, nb_scale);19589 let tmp_y = obmc_neighbour_pred(ny, px + ox, py, nb.mv, bw, bh, true, h_kind, v_kind, nb_scale);
19560 obmc_blend_v(pred_y, side, ox, 0, bw, bh, &tmp_y);19590 obmc_blend_v(pred_y, side, ox, 0, bw, bh, &tmp_y);
19561 if !skip_chroma_above {19591 if !skip_chroma_above {
19592+ // lane-t900 r13 (measured, NOT a defect): libaom's min-4 clamp
19593+ // (`dec_build_prediction_by_above_pred`) sizes only the OBMC
19594+ // PREDICTION buffer; the blend length is the plain half
19595+ // (`build_obmc_inter_pred_above`: `overlap >> ss_y`), so flooring
19596+ // this at 4 blends rows libaom never blends -- on a 10-bit
19597+ // 1920x792 cut that went 36 differing frames -> 266, worst
19598+ // 13 B -> 11007 B.
19562 let (cbw, cbh, cox) = (bw / 2, overlap_above / 2, ox / 2);19599 let (cbw, cbh, cox) = (bw / 2, overlap_above / 2, ox / 2);
19563 let tmp_u = obmc_neighbour_pred(nu, cpx + cox, cpy, nb.mv, cbw, cbh, false, h_kind, v_kind, nb_scale);19600 let tmp_u = obmc_neighbour_pred(nu, cpx + cox, cpy, nb.mv, cbw, cbh, false, h_kind, v_kind, nb_scale);
19564 obmc_blend_v(pred_u, chroma_side, cox, 0, cbw, cbh, &tmp_u);19601 obmc_blend_v(pred_u, chroma_side, cox, 0, cbw, cbh, &tmp_u);
@@ -19587,6 +19624,12 @@ fn obmc_blend(
19587 let tmp_v = obmc_neighbour_pred(nv, cpx, cpy + coy, nb.mv, cbw, cbh, false, h_kind, v_kind, nb_scale);19624 let tmp_v = obmc_neighbour_pred(nv, cpx, cpy + coy, nb.mv, cbw, cbh, false, h_kind, v_kind, nb_scale);
19588 obmc_blend_h(pred_v, chroma_side, 0, coy, cbw, cbh, &tmp_v);19625 obmc_blend_h(pred_v, chroma_side, 0, coy, cbw, cbh, &tmp_v);
19589 }19626 }
19627+ if let Some((_, _, idx)) = ec_mcb {
19628+ for r in 0..write_h / 2 {
19629+ let row: Vec<u16> = (0..write_w / 2).map(|c| pred_u[r * chroma_side + c]).collect();
19630+ eprintln!("OUR_MCB post f={idx} row{r}: {row:?}");
19631+ }
19632+ }
19590 Ok(())19633 Ok(())
19591 }19634 }
19592 19635
crates/ec-av1/src/stream.rsmodified+12 -1
@@ -30579,12 +30579,22 @@ mod tests {
30579 let (width, height) = (1920usize, 792usize);30579 let (width, height) = (1920usize, 792usize);
30580 let gm_before = crate::decode::gm_nontrans_small_side_hits();30580 let gm_before = crate::decode::gm_nontrans_small_side_hits();
30581 let tr_before = crate::decode::tr_reach_longer_side_hits();30581 let tr_before = crate::decode::tr_reach_longer_side_hits();
30582+ // lane-t900 r13: this stream is also the witness for r12's mi-granular
30583+ // uv_mode grid -- the chroma edge-filter neighbour read that the coarse
30584+ // one-slot-per-column map answered wrongly inside a sub-8x8 pair.
30585+ let uv_before = crate::decode::uv_mode_grid_override_hits();
30582 let frames = match decode_stream(&stream) {30586 let frames = match decode_stream(&stream) {
30583 Ok(frames) => frames,30587 Ok(frames) => frames,
30584 Err(e) => panic!("{NAME}: decode_stream refused: {e}"),30588 Err(e) => panic!("{NAME}: decode_stream refused: {e}"),
30585 };30589 };
30586 let gm = crate::decode::gm_nontrans_small_side_hits() - gm_before;30590 let gm = crate::decode::gm_nontrans_small_side_hits() - gm_before;
30587 let tr = crate::decode::tr_reach_longer_side_hits() - tr_before;30591 let tr = crate::decode::tr_reach_longer_side_hits() - tr_before;
30592+ let uvg = crate::decode::uv_mode_grid_override_hits() - uv_before;
30593+ assert!(
30594+ uvg > 0,
30595+ "{NAME}: uv_mode_grid_override never fired -- the chroma edge-filter \
30596+ grid read would be untested"
30597+ );
30588 assert!(30598 assert!(
30589 gm > 0,30599 gm > 0,
30590 "{NAME}: gm_nontrans_small_side never fired -- the gate would be vacuous for it"30600 "{NAME}: gm_nontrans_small_side never fired -- the gate would be vacuous for it"
@@ -30610,7 +30620,8 @@ mod tests {
30610 }30620 }
30611 eprintln!(30621 eprintln!(
30612 "{NAME}: 33 shown frames pixel-exact on every plane; \30622 "{NAME}: 33 shown frames pixel-exact on every plane; \
30613- gm_nontrans_small_side={gm} tr_reach_longer_side={tr}"30623+ gm_nontrans_small_side={gm} tr_reach_longer_side={tr} \
30624+ uv_mode_grid_override={uvg}"
30614 );30625 );
30615 }30626 }
30616 30627
lanes/t900-r13.handoff.mdadded+66 -0
@@ -0,0 +1,66 @@
1+# lane-t900 r13 handoff -- start at the OBMC LEFT pass of a bottom-overhanging block
2+
3+Tip `f24c9807` on `lane-t900` (base main `2b65cb8e`). Full report: `lanes/t900-r13.report.md`.
4+
5+## Suite (both runs green, no FAILED)
6+
7+* tip `66d88cfe` (r12 code): `test result: ok. 429 passed; 0 failed; 38 ignored; 0 measured;
8+ 0 filtered out; finished in 771.39s` -- `$HOME/.cache/t900-suite-r13.log`.
9+* tip `25603b14` (r13 code): `test result: ok. 429 passed; 0 failed; 38 ignored; 0 measured;
10+ 0 filtered out; finished in 748.12s` -- `$HOME/.cache/t900-suite-r13b.log`.
11+* `cargo check -p ec-av1 --tests` clean on the final tip.
12+
13+## Facts established this round (do not re-measure)
14+
15+1. The four 4K offsets the r13 charter listed as whole-frame desyncs (2700 f73, 3000 f43,
16+ 1500, 5400) are **byte-exact on this tip**: 107/193/244/160 decode frames, 0 differing.
17+ r12's `uv_mode_grid` fix cured them. Cuts (each hashed twice, identical):
18+ `~/.cache/t900-tmp/h{2700,3000,1500,5400}.obu`. Compare script `~/.cache/t900-tmp/cmp13.sh`
19+ (uses `$HOME/.cache/cargo-target-t900b` so it never shares a target dir with a suite).
20+2. r12's fix now has a witness: `gm_small_side_witness.obu` fires `uv_mode_grid_override`
21+ 138 times and the gate hard-asserts it. `reelc_sb128_inter_witness` fires it 24; the four
22+ `reelb_*` witnesses fire 0.
23+3. The 1-3 B residue on the 1080p 900 s cut (36 frames, first 41, worst 13) is
24+ **inside the OBMC blend, not the base MC**. On frame 41 the chroma block
25+ `mi_x=704 mi_y=768 bw=16 bh=16` (32x32 luma at mi(192,176), overhanging the bottom:
26+ mi_rows=198), `mm=1 skip=1 mv0=(-4,14) ref0=5`:
27+ * pre-blend chroma prediction = aomdec's, all 16 rows;
28+ * after the blend our prefilter recon differs at exactly one sample, row 11 col 1
29+ (`U(353,395)`, aom 492 ours 493), which lies in the LEFT pass's 8-column strip and
30+ below the ABOVE pass's 4-row strip.
31+ So: LEFT-pass neighbour prediction or its blend, at the block's last valid chroma row.
32+4. Dead end (measured, reverted, recorded in a comment at the site): flooring the chroma
33+ OBMC blend length at 4 (libaom's `clamp(..., 4, ...)`) -- that clamp sizes the PREDICTION
34+ buffer only; the blend length is `overlap >> ss`. 36 differing frames -> 266, worst 13 B
35+ -> 11007 B.
36+5. Ruled out by reading both sources: `build_mc_border`/`update_extend_mc_border_params`
37+ clamp to `uv_crop_width/height` (960x396) = our `true_width/true_height`;
38+ `clamp_mv_to_umv_border_sb` is result-equivalent to tap clamping.
39+
40+## Rungs available (both additive and env-gated)
41+
42+* aomdec private build (`~/.cache/aom-oracle/src/av1/decoder/decodeframe.c`, rebuilt with
43+ `ninja -C ~/.cache/aom-oracle/build aomdec`): `EC_MCB="<plane>:<px>:<py>[:<frame>]"` prints
44+ every `dec_build_inter_predictors` call whose plane-pixel span covers that pixel --
45+ including the `obmc=1` neighbour predictions (their rows come from the tmp buffer) --
46+ with `f=` (decode-order frame, counter `ec_t900_frame`), bw/bh, mode, `mm`, skip, mv0,
47+ refs, interp, `prew/preh/stride`.
48+* ours: `OUR_MCB` in `decode.rs::obmc_blend`, same env spelling, chroma rows before and
49+ after the blend; `EC_OBMC` (pre-existing) prints the neighbour list on both decoders.
50+* Cut with frame 41 near the end: `~/.cache/t900-tmp/c900_62.obu`
51+ (`python3 ~/.cache/reelckf-work/trunc.py cut_900.obu 62 c900_62.obu`).
52+
53+## Next step (chartered)
54+
55+`EC_MCB=1:353:395:41` on aomdec over `c900_62.obu` and read the `obmc=1` entries for
56+`mi_x=704`: compare each LEFT-pass neighbour (position, span, mv, ref, filter -- `EC_OBMC`
57+on both) and then the tmp rows at row 11 against ours. Our left pass sizes are
58+`(bw, bh, oy) = (overlap_left, span4*4, off4*4)` with chroma `(overlap_left/2, bh/2, oy/2)`
59+(`decode.rs` ~19585); libaom's are `bh = (mi_step*MI_SIZE) >> ss_y` and blend width
60+`overlap >> ss_x` -- check what libaom does with `mi_step` when the neighbour span runs
61+past `mi_rows` at the frame bottom.
62+
63+## Owed
64+
65+* 1080p 0-10 s head re-probe (was 78 differing, first 86 -- unmeasured since r11).
66+* census8's 24 not-exact 4K offsets (run8.sh) re-probe.
lanes/t900-r13.report.mdadded+113 -0
@@ -0,0 +1,113 @@
1+# 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
2+
3+Tip `7a111b9d` on `lane-t900` (base main `2b65cb8e`; r12 tip `66d88cfe` was already
4+a fast-forward of main, no merge needed this round).
5+
6+## STEP 0 -- suite
7+
8+`systemd-run --user --unit=t900-suite-r13-... cargo test -p ec-av1 --lib -j3`
9+(EC_NOMEMGUARD=1 EC_AV1_REQUIRE_AOMENC=1, log `$HOME/.cache/t900-suite-r13.log`):
10+
11+ test result: ok. 429 passed; 0 failed; 38 ignored; 0 measured; 0 filtered out
12+
13+No red from r11/r12. A confirmation run on the r13 tip is armed
14+(`$HOME/.cache/t900-suite-r13b.log`); the one test whose code changed
15+(`a_10bit_film_frames_with_small_side_globalmv_and_rect_warp_reach_decode_pixel_exact`)
16+was run alone on the r13 tree and passes -- see STEP 1.
17+
18+## STEP 1 -- witness for r12's mi-granular uv_mode grid (DONE, no new fixture)
19+
20+`decode_probe` now prints `uv_mode_grid_override`. Measured over the existing witnesses:
21+
22+| fixture | uv_mode_grid_override |
23+|---|---|
24+| `gm_small_side_witness.obu` | **138** |
25+| `reelc_sb128_inter_witness.obu` | 24 |
26+| `reelb_head_mvclamp_witness.obu` | 0 |
27+| `reelb_arf_witness.obu` | 0 |
28+| `reelb_intra14_witness.obu` | 0 |
29+| `reelb_rect64_intra16x4_witness.obu` | 0 |
30+
31+So no new fixture was pinned (charter's fallback): the small-side GLOBALMV gate now
32+hard-asserts the counter.
33+
34+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`
35+
36+## STEP 2 -- the four 4K offsets: ALL EXACT, the charter's premise was stale
37+
38+Every cut extracted twice, identical sha256 both times; both decoders compared with
39+`EC_AV1_FINAL_DUMP` per decode-order frame (`~/.cache/t900-tmp/cmp13.sh`).
40+
41+| offset (10-bit 3840x1608 HDR film) | charter premise (pre-r12) | measured on r13 tip |
42+|---|---|---|
43+| 2700 s, 2 s | f73 first differing, 15.8 MB (whole frame) | **107 decode frames, 0 differing** |
44+| 3000 s, 2 s | f43 first differing | **193 frames, 0 differing** |
45+| 1500 s, 2 s | Golomb / own desync | **244 frames, 0 differing** |
46+| 5400 s, 2 s | Golomb / own desync | **160 frames, 0 differing** |
47+
48+r12's chroma edge-filter fix (`uv_mode_grid`) cured all four; there was no frame-73
49+ladder to run. No EC_MODE ladder was needed and none was run.
50+
51+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
52+
53+## STEP 3 -- the 1-3 B bottom-edge residue: localised to the OBMC BLEND (open)
54+
55+10-bit 1920x792 cut at 900 s (`~/.cache/t900-tmp/cut_900.obu`, 267 decode frames):
56+36 differing frames, first f41 (1 B), worst 13 B -- unchanged by r12.
57+
58+Sample census (final dump): every differing sample is CHROMA, in chroma rows 390-395
59+(the bottom 12 luma rows), and off by +-1 (rarely +-2). Luma is bit-exact everywhere.
60+
61+New rungs this round:
62+* aomdec (private build, additive, env-gated): `EC_MCB="<plane>:<px>:<py>[:<frame>]"` in
63+ `dec_build_inter_predictors` prints the block whose plane-pixel span COVERS that pixel
64+ (frame counter `ec_t900_frame`, bumped where `EC_AV1_FINAL_DUMP` writes).
65+* ours: `OUR_MCB` in `decode.rs` `obmc_blend`, same env spelling, prints the chroma
66+ prediction rows on entry and on exit of the blend.
67+
68+Frame 41, the block that owns the differing sample: chroma `mi_x=704 mi_y=768 bw=16 bh=16`
69+(32x32 luma at mi(192,176), which OVERHANGS the frame bottom: mi_rows=198), `mm=1` (OBMC),
70+`skip=1`, `mv0=(-4,14)`, ref0=5, `prew=960 preh=396`.
71+
72+* PRE-blend chroma prediction: **all 16 rows bit-identical** to aomdec.
73+* Post-blend: our recon differs at exactly one sample, `U(353,395)` = row 11, col 1
74+ (prefilter dump: aom 492, ours 493; the loop filter then spreads it to `U(354,395)`
75+ in the final dump).
76+* Col 1 is inside the LEFT pass's overlap strip (8 chroma columns) and outside the ABOVE
77+ pass's (4 rows), and row 11 is the block's LAST valid chroma row -- so the residue is in
78+ the LEFT-pass OBMC neighbour prediction/blend of a bottom-overhanging block, NOT in the
79+ base motion compensation and NOT (r8's premise) a bottom-edge tap clamp of the block's
80+ own MC.
81+
82+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
83+
84+Dead end measured and recorded in the code (`decode.rs` obmc_blend): libaom's min-4
85+clamp (`dec_build_prediction_by_above_pred`: `clamp(block_size_high[bsize] >> (ss_y+1), 4, ...)`)
86+sizes only the OBMC PREDICTION buffer -- the blend length stays the plain half
87+(`build_obmc_inter_pred_above`: `overlap >> ss_y`). Flooring the chroma blend at 4 took
88+cut_900 from 36 differing frames to 266 and the worst frame from 13 B to 11007 B; reverted.
89+
90+Also read and ruled out by source on both sides (no code change): `build_mc_border` /
91+`update_extend_mc_border_params` clamp to `pre_buf->width/height` = `uv_crop_*` = 960x396,
92+identical to our `true_width/true_height`; `clamp_mv_to_umv_border_sb` is result-equivalent
93+to tap clamping wherever the geometry it is given is the block's own.
94+
95+Residue disposition: **deferred(next round)** -- the next rung is aomdec's `EC_MCB` with
96+`obmc=1` (it already prints the neighbour prediction from the tmp buffer) against our
97+`ec_obmc_trace`/`OUR_MCB` for the LEFT pass of that block: compare the neighbour list
98+(position, span, mv, ref, filter) and then the tmp rows at row 11.
99+
100+## STEP 4 -- re-probe
101+
102+The four 4K offsets above are the re-probe (all exact). The 4K 10 s head was measured
103+0 of 241 differing on this code in r12 and is unchanged here (no decode-path change this
104+round -- the only non-comment edits are trace/gate code). The 1080p 0-10 s head re-probe
105+and the census8 24-offset sweep are **deferred(turn cap)**.
106+
107+## Files changed
108+
109+* `crates/ec-av1/src/stream.rs` -- the small-side GLOBALMV gate asserts and reports
110+ `uv_mode_grid_override > 0` (witness for r12's fix).
111+* `crates/ec-av1/examples/decode_probe.rs` -- prints `uv_mode_grid_override`.
112+* `crates/ec-av1/src/decode.rs` -- `OUR_MCB` rung in `obmc_blend`; a comment recording the
113+ measured OBMC min-4 dead end.