forge
Explore
Log in

Don't you dare go Hollow

edith_codecs

Clone
★ 0

0 watching0 forksRust370.3 MiB9b67700Tahinli3 days ago4021 commits

t900-r11.handoff.md6.7 KiBHistoryRawDownload

lane-t900 r11 handoff -- target A was NOT loop restoration: it was the mv-stack frame-edge clamp, computed in usize

Tip: 2b56599b on lane-t900 (r10 tip 2aa87a34, merged to main as 99692ed0; main fast-forwarded into the lane before any edit).

Target A -- 4K decode frame 88, 221 bytes: ROOT CAUSE FOUND, FIXED, gated

The charter premise (self-guided restoration last stripe) is DEAD. The stage bisection killed it in two runs: the 221-byte mismatch is already present in the PRE-loop-filter dump, so no filter stage is involved.

  • post-deblock dump (EC_AV1_POSTDEBLOCK_DUMP16 both decoders): rows 1594..1605 differ.
  • pre-filter dump (EC_AV1_PREFILT_DUMP16 both decoders): Y rows 1600,1601,1602, x 1472..1535 -- exactly one 64x64 block -- plus 4 chroma samples.

Ladder: EC_TRACE_MODE both decoders at decode frame 88 (ours labels frames with EC_PICT idx=, aomdec does not -- locate its lines by matching our rng):

aomdec  EC_MODE     mi_row=400 mi_col=368 rng=32962
        EC_MODE_MV  mode=16 mv0=(32,568)  rng=42514
        EC_STACK    ref=1 i=0 this=(192,-320) w=2
ours    EC_MODE     mi_row=400 mi_col=368 rng=32962 is_inter=1 skip=1 side=64
        EC_STACK    ref=1 i=0 this=(384,-320) w=2
        EC_MODE_VAL mode=16 mv0=(224,568)  rng=42514

Identical range at both rungs -- the entropy stream never diverged, only the reconstructed MV. EC_TRACE_TPL on both showed every temporal candidate at that block is mfmv0=(0,0), so the stack entry is not temporal-projection related.

Root cause (crates/ec-av1/src/mvstack.rs:807 clamp_mv_ref): libaom's mb_to_right_edge/mb_to_bottom_edge (set_mi_row_col, av1_common_int.h) are SIGNED and a block overhanging the frame's right/bottom edge keeps its full bw4/bh4. Frame height 1608 -> mi_rows == 402, so the 64x64 block at mi_row 400 has mb_to_bottom_edge = (402-16-400)*4*8 = -448 and the window top is -448 + 512 + 128 = 192. We computed that with usize::saturating_sub -> 0, window 640, so 384 passed through unclamped. Full-pel MV, so the block is a straight copy: with row 224 (28 px) every source row was past 1607 and our MC replicated the last reference row; libaom with row 32 (4 px) reads real reference rows 1604..1606 of decode-order frame 83 (verified by patch search: f88[1600:1603,1472:1536] occurs exactly once in the reference set, at frame 83 row 1604 col 1543 = mv (4 px, 71 px)).

Fix 2b56599b: both edge terms computed in i32; new counter mvstack::mv_clamp_edge_overhang_hits (printed by decode_probe).

Measured effect:

stream before after
4K head, 148-OBU / 100-frame prefix (~/.cache/t900-tmp/hgw_a.obu) 1 frame differs (f88, 221 B) 0 of 100
4K head, full 10 s (~/.cache/hg-0-10s.obu, 241 f) not measured before 66 differ, first 161, worst 199 B (f188)
1080p @900 s cut (267 f) 36 differ, first 41, worst 13 B unchanged (36 / 41 / 13)
1080p @5400 s cut (275 f) 134 differ, first 61, f113=1942 B unchanged (134 / 61 / f113=1942, worst 2410 @ f244)
1080p head 0-10 s (241 f) 78 differ, first 86 unchanged (78 / 86, worst 5214 @ f188)
1080p 16-frame head cut t900_h.obu exact exact

Gates (both PASS, cargo test -p ec-av1 --lib -- frame_edge_mv_clamping clamp_mv_ref_window -> 2 passed, 0 failed, 179.96 s):

  • stream::tests::a_10bit_film_frames_with_frame_edge_mv_clamping_decode_pixel_exact -- new fixture crates/ec-av1/fixtures/reelb_head_mvclamp_witness.obu, 72158 bytes, sha256 451a9b138995e636f22308847a123b5c8621d4908cd93772cf5bbf2b37df39d7 (truncated twice, identical hashes), 80 frame-carrying OBUs = 55 decode / 52 shown frames of the 4K head. SMALLEST prefix that fires the counter (N=79 -> 0, N=80 -> 5). All 55 decode-order frames byte-identical to aomdec; the gate compares the 52 shown frames on all planes vs ffmpeg and hard-asserts mv_clamp_edge_overhang > 0. CAVEAT, stated plainly: this fixture stops before frame 88, so it is a REGRESSION guard, not a reproducer of the 221-byte defect. The defect witness is the unit test:
  • mvstack::tests::clamp_mv_ref_window_is_signed_at_the_frame_bottom_edge -- the ladder's exact numbers (clamp_mv_ref((384,-320), 400, 368, 16, 16, 960, 402) == (192,-320)), which the pre-r11 code fails.

No existing fixture in the repo fires the counter (all 12 crates/ec-av1/fixtures/*.obu and fixtures/*.obu measured at 0), which is why a new one was needed.

Target B -- 1080p bottom-edge chroma MC clamp: NOT fixed, and NOT the same class

Unchanged by A (cut_900 still 36 frames, first bad f41 = 1 byte). The r8 localisation still stands (skip 32x32 mi(192,176) mv0=(-4,14) SMOOTH, chroma vertical taps at the last chroma row). Note for the next round: that block DOES overhang (mi_rows=198, bh4=8, 192+8=200), but its MV is far inside the clamp window, so the r11 fix cannot touch it -- the charter's "reference plane replicates from the aligned rather than the cropped height" premise is still UNTESTED. For 1920x792 the chroma crop height (396) and the mi-aligned chroma height (396) are EQUAL, so a crop-vs-aligned difference cannot be the explanation there; measure the actual tap rows instead (EC_PRED/MC rung on both decoders at chroma (353,395), frame 41 of ~/.cache/t900-tmp/cut_900.obu).

Target C -- the KB walls: localised, not diagnosed

@5400 decode frame 113 (1942 B) via python3 sb.py d_r11_cut_5400 113 64: CHROMA ONLY, luma bit-exact. Deltas +-1..2, concentrated in SB(0,6)..SB(0,8)/SB(1,7)/SB(1,8) -- chroma x 220..260, y 16..32 (luma x 440..520, y 32..64) plus a 11-sample tail at SB(8,13). Every block in that region is INTRA inside an inter frame (EC_TRACE_MODE, frame 113: mi(8..16, 112..128) all is_inter=0 side=16). So the wall is a chroma intra path (CfL / chroma angular / chroma TX), not MC and not entropy-visible at the mode layer. 1080p head f130 (1143 B) and the true worst f188 (5214 B) NOT measured this round.

Exact next steps

  1. Target C: run EC_PRED on BOTH decoders for cut_5400 frame 113 restricted to plane=1/2 at mi(8,112) (ours prints pixel origin x=224 y=16; aomdec prints mi_row/mi_col/plane/row_off/col_off + ft=), and compare sum=/row0=/col0=: that separates chroma prediction from chroma residual in one run.
  2. Target A residue: the 4K frontier moved from frame 88 to frame 161 of ~/.cache/hg-0-10s.obu (dumps kept in ~/.cache/t900-tmp/d_r11_reelb10/); start there with px4k.py d_r11_reelb10 161 3840 1608.
  3. Target B as above.

Tooling notes for the successor: px4k.py <dumpdir> <frame> 3840 1608 (new this round, ~/.cache/t900-tmp/) is the 4K twin of px.py; ~/.cache/reelckf-work/trunc.py <in> <N> <out> keeps N frame-carrying OBUs; cmp.sh <name> <obu> writes d_<name>/.