forge
Explore
Log in

Don't you dare go Hollow

Lane-midcut r1 handoff -- mid-film cuts are a reconstruction desync (not alignment, not grain)

Browse files at this commit

3667e83b5da30699b6051dc127eec33f9a7868baAhmet Kaan GümüşParent: f48ab1b
  • docs
    • lane-midcut r1 handoff -- mid-film cuts are a reconstruction desync (not alignment, not grain)
    • rect interintra fixed, NEARMV mv-stack defect named
Show full message
docs(av1): lane-midcut r1 handoff -- mid-film cuts are a reconstruction desync (not alignment, not grain); rect interintra fixed, NEARMV mv-stack defect named

Adds the rect-interintra assert to the interintra gate (delta-counted, not yet
run) and the r1 handoff: reproducer, the three measurements that ruled out frame
alignment and film grain, the fixed defect, the next block-level witness
(mi 112,288 NEARMV: ours (-40,-340) vs aomdec (-32,-350)) and the re-measured
24-offset table.
crates/ec-av1/src/stream.rsmodified+11 -1
@@ -13983,6 +13983,10 @@ mod tests {
1398313983 return;
1398413984 }
1398513985 let (width, height, frame_count) = (64usize, 64usize, 24usize);
13986+ // lane-midcut r1: rect interintra (`write_w != write_h`) built its
13987+ // intra predictor at the square `side`; this gate passed with that
13988+ // bug, so the shape gets its own delta-counted assert below.
13989+ let rect_before = crate::decode::interintra_rect_hits();
1398613990 let mut named_refusals = 0u32;
1398713991 let mut matched = 0u32;
1398813992 let n_attempts: u32 = std::env::var("EC_INTERINTRA_GATE_ATTEMPTS")
@@ -14157,9 +14161,15 @@ mod tests {
1415714161 "{NAME}: {matched} matches but zero UNIDIR_COMP_REFERENCE pairs read -- \
1415814162 --enable-onesided-comp=1 never reached the uni_comp_ref alphabet"
1415914163 );
14164+ assert!(
14165+ crate::decode::interintra_rect_hits() > rect_before,
14166+ "{NAME}: {matched} matches but zero RECTANGULAR interintra blocks fired -- the \
14167+ square-only blend defect (lane-midcut r1) would pass this gate unseen"
14168+ );
1416014169 eprintln!(
14161- "{NAME}: {named_refusals} other-capability refusals, {matched} pixel-exact matches out of {n_attempts}, interintra_hits={} uni_comp_hits={}",
14170+ "{NAME}: {named_refusals} other-capability refusals, {matched} pixel-exact matches out of {n_attempts}, interintra_hits={} interintra_rect_hits={} uni_comp_hits={}",
1416214171 crate::decode::interintra_hits(),
14172+ crate::decode::interintra_rect_hits() - rect_before,
1416314173 crate::decode::uni_comp_hits()
1416414174 );
1416514175 }
lanes/midcut-r1.handoff.mdadded+76 -0
@@ -0,0 +1,76 @@
1+# lane-midcut r1 handoff (turn cap)
2+
3+## Verdict: (C) real reconstruction desync. NOT (A) alignment, NOT (B) film grain.
4+
5+Reproducer, hashed twice, 325 KB: `~/.cache/midcut-tmp/h2400.t2.obu`
6+= `ffmpeg -ss 2400 -t 2 -c:v copy -f obu` on the 10-bit 3840x1608 stream
7+(sha256 2f62dd1f74bffe10973494404ee4d1a695d2d327b88fb1891c63452b5d47c895 for the
8+full 2 s cut) truncated to its first 2 frame OBUs (census7 `trunc.py`).
9+It holds the whole defect: key frame + first hidden alt-ref.
10+
11+### Measurements that separated A/B/C
12+1. (A) ruled out. ffmpeg decodes 261 frames from the 2 s cut; our OUT16 frames
13+ are in display order and monotone in `order_hint` (HDR dump: 114 key, then
14+ 115,116(show_existing 7),117,118(se 6),119,120,121...). An 8x8 cross-compare
15+ of our 8 shown frames vs ffmpeg's 8 (grain off both sides) has NO near-zero
16+ off-diagonal: every ours[i] is 13-16 MB from every ffmpeg[j]. Frames are
17+ aligned; the census tool was measuring the truth.
18+2. (B) ruled out. `EC_AV1_NO_GRAIN=1` (added this round, `stream.rs`) vs
19+ `ffmpeg -c:v libdav1d -filmgrain 0`: first_diff_frame=1, 13450726 bytes --
20+ the same mismatch as grain-on/grain-on (13458423). Grain is not it.
21+3. (C) located. Decode-order compare of `EC_AV1_PREFILT_DUMP16` ours vs the
22+ instrumented aomdec: f0 (key) EXACT, f1 (hidden ARF) 4386319 luma px wrong,
23+ confined to superblocks (0,17) and (0,58) at first, then spreading.
24+ Pre-deblock and post-deblock diffs are identical -> reconstruction, not filters.
25+
26+### Root cause found and FIXED (commit 43e9909)
27+First bad pixel (17,1088) sat in the block aomdec reports as
28+`EC_MODE_VAL mi_row=4 mi_col=272 mode=13 ref0=1 ref1=0` -- ref1=0 is INTRA_FRAME,
29+i.e. an INTERINTRA block, and its footprint is 32x16.
30+`decode.rs interintra_blend` took ONE `side` and used it for the edge fetch, the
31+intra predictor's (bw,bh), `ii_size_scales` and the blend bounds. On a rect block
32+`side` is the LONGER dimension, so a 32x16 block got a 32x32 SMOOTH/DC predictor
33+built off 32 rows of left edge (16 of them not yet decoded). The error signature
34+matches exactly: rank-1 (sv 90 vs 18), exactly 0 on the block's first row, growing
35+downward -- the `sm_weights_h` divergence between height-32 and height-16 SMOOTH_PRED.
36+Fix: `interintra_blend(plane, x, y, bw, bh, stride, ..)` -- `edges_rect`/`predict`
37+at the true footprint, mask scale `128 / max(bw,bh)`, loop `bh x bw`, `pred`
38+indexed at the buffer stride. New `interintra_rect_hits()` counter + `decode_probe`
39+line + a delta-counted hard assert in
40+`a_real_aomenc_stream_with_interintra_decodes_pixel_exact` (NOT yet run: turn cap).
41+Result: superblock (0,17) is now exact; f1's first mismatch moves to (448,1152).
42+
43+### The NEXT defect (this is the exact next step)
44+Same 2-frame reproducer, frame 1, block mi_row=112 mi_col=288, a 32x16 NEARMV
45+block (`TRACE_RECT_SPLIT mi_row=108 mi_col=288 bw=32 bh=16`):
46+ aomdec `EC_MODE_VAL mi_row=112 mi_col=288 mode=14 ref0=1 ref1=-1 mv0=(-32,-350) stack=4`
47+ ours `EC_TRACE mi_row=112 mi_col=288 mv=(-40,-340) is_new_mv=false bsize=32`
48+Entropy stays in sync (later blocks' rng match; the frame does not refuse), so it
49+is the mv STACK content/order, not a symbol. Suspect the same class as the fix
50+above: an mv-stack scan taking the square `side` instead of the block's true
51+`write_w`/`write_h` (`find_mv_stack` call sites decode.rs:18005 and :30091 --
52+check the bw4/bh4 arguments there first). Ladder: aomdec `EC_TRACE_MODE=1`
53+(`EC_MODE_MV` lines) vs ours for that mi; artifacts already on disk:
54+`~/.cache/midcut-tmp/am.txt` (aomdec, 2-frame cut) and `tr2.txt` (ours).
55+
56+### Re-measured table (24 offsets, 2 s cut truncated to 4 frame OBUs,
57+### decode-order bytes vs instrumented aomdec, AFTER the fix)
58+`~/.cache/midcut-tmp/cen/after.tsv`. f0 is exact at EVERY offset. ss=0 is fully
59+exact (0,0,0,0) -- and is the ONLY offset with `interintra_rect: 0`, which is why
60+the head cut never saw this bug. Every other offset still diverges at f1 or f2
61+because of the NEARMV defect above; rect-interintra blocks per 4-frame prefix run
62+1..645. Sample: 0 -> 0,0,0,0 | 300 -> 0,2362684,5576522,10902022 |
63+2400 -> 0,11010633,7316581,15127483 | 4200 -> 0,607935,837,586 |
64+4800 -> 0,537,5724744,14232841 | 6000 -> 0,806,6192253,13728776.
65+
66+### Owed / not done (turn cap)
67+- deferred: run `a_real_aomenc_stream_with_interintra_decodes_pixel_exact` with the
68+ new rect assert (`cargo test -p ec-av1 --lib interintra`) -- unblocked by a free
69+ turn; `cargo check -p ec-av1 --lib` is CLEAN on this tree.
70+- deferred: full suite. A run was started under unit `midcut-suite-r1-1788371174`
71+ on commit 43e9909 (log `$HOME/.cache/midcut-suite.log`) and had not reached
72+ `test result` at the cap.
73+- deferred: no fixture pinned. The film prefix is NOT pixel-exact yet (the NEARMV
74+ defect), so a hard-counter gate on it would have to assert a mismatch; pin it
75+ once the mv-stack defect is fixed.
76+- no refusal was lifted or moved; refusal_inventory/gate_coverage untouched.