forge
Explore
Log in

Don't you dare go Hollow

wip(av1): warp fixture found + decisive pinned mismatch -- COMPILING WIP

Browse files at this commit

fefaafbc6c2157a37a3b10b75bca481ac89d82b6Ahmet Kaan GümüşParent: efe3e65
lane-warp round 3, budget-capped stop.

Resolved r2's puzzle first: leaf8 (decode_inter_block8) STILL refuses
motion_mode==2 unconditionally (decode.rs ~6558) -- confirmed by direct
read, not inferred. The gate's fixture partition is forced to 32x32
(--min/max-partition-size=32), so leaf8 (an 8x8 leaf) is structurally
unreachable on that content; the puzzle's (a) was a red herring. The real
reason the warp gate reported "40 named refusals, 0 matches" is a
never-fired-instrument shape from a DIFFERENT angle: every one of the 40
attempts happens to *also* hit some other real, unrelated named refusal
(allow_screen_content_tools, partition-below-16x16, partition-type-never-
written, interintra, directional-chroma) before or regardless of whether
warp fires -- confirmed by instrumenting the gate to print every refusal
string and WARP_SELECTED_HITS (leaf16's counter): even the charter's own
--auto-alt-ref=1 --lag-in-frames=16 --enable-fwd-kf=0
--enable-ref-frame-mvs=0 recipe (already present in the gate, unlike r2's
guess) still gets swamped by aomenc's `gradients` synthetic content
tripping screen-content-tools detection at cpu-used=0. Widening the sweep
(new EC_WARP_GATE_ATTEMPTS env override, default 40) to 200 seeds found
warp firing 14-75 times per run (leaf16 exercised for real) but never
once producing a clean pixel-exact pass across two separate 200-seed
runs -- same seed set gave DIFFERENT refusal shapes on each rerun
(matches the documented aomenc-RD-nondeterminism class:
parallel-flake-is-attempt-selection), so the fixture itself isn't
reproducible by seed alone.

DECISIVE FIND: seed 49 (this run) decoded WITHOUT hitting any other named
refusal, warp fired exactly once (WARP_SELECTED_HITS 0->1), and frame 1
luma mismatched ffmpeg -- a real, isolated warp_affine/find_projection
bug, not a confound. Stream pinned to
$SP/warp-mismatch.obu (621 bytes, 64x64, 24 frames) and a new
`pinned_warp_stream_decodes_pixel_exact` #[ignore]d test added
(stream.rs) that re-decodes it deterministically (no aomenc/ffmpeg
re-encode) and dumps an ASCII diff mask on mismatch.

Diff shape: small-magnitude ('o', delta<4) errors spread across roughly
the frame's upper-left half in a diagonal band, not a sharply-bounded
single-block region of gross error -- consistent with a subtle
coefficient/rounding bug in the warp path rather than a wrong-block/
desync bug. Spent the rest of the round auditing warp.rs's math line by
line against av1/common/warped_motion.c and mvref_common.c: confirmed
FAITHFUL (no bug found yet) in find_affine_int's LS_MV_MAX inner-loop
gate, LS_SQUARE/LS_PRODUCT1/LS_PRODUCT2 shift constants (LS_MAT_DOWN_BITS
=2, >>4 matches), get_mult_shift_diag/ndiag (confirmed we use the
USE_LIMITED_PREC_MULT=0 -- i.e. simple Px*iDet + ROUND_POWER_OF_TWO_
SIGNED_64 -- branch, matching libaom's actual compiled path, not the
unused resolve_multiplier_64 branch), get_shear_params/av1_get_shear_
params (alpha/beta/gamma/delta derivation, WARP_PARAM_REDUCE_BITS
rounding, is_affine_shear_allowed bound), av1_warp_affine_c's whole
horizontal+vertical two-pass loop (offset_bits, reduce_bits, sx4/sy4
alpha/beta/gamma/delta stepping, tap-offset formula, final clip_pixel
formula) all transcribed correctly, and the DIV_LUT table's first ~20
entries spot-checked byte-identical.

NOT YET CHECKED / next round's first move: record_sample's row_offset/
col_offset sign conventions and find_samples' above/left/TL/TR traversal
order against av1_find_warp_samples in mvref_common.c (only structurally
skimmed, not line-audited) -- since every arithmetic primitive downstream
now checks out clean, a wrong *input sample* (wrong neighbour MV/position
recorded) is the next most likely place for a small-but-real numeric
error to originate. Also worth trying: print our own wmmat/alpha/beta/
gamma/delta for this pinned block and compare against libaom's
find_affine_int by adding a debug printf at the av1_find_projection call
site in decodemv.c (~1624) and rebuilding aomdec -- would immediately
localize the bug to sample-gathering vs. estimation vs. filtering without
more manual line-diffing.

Gate/test changes this round (stream.rs): EC_WARP_GATE_ATTEMPTS env
override on the refuse-or-match gate's seed count; dump-on-mismatch via
EC_AV1_GATE_DUMP added to that gate (previously missing); new pinned
`pinned_warp_stream_decodes_pixel_exact` test with ASCII diff-mask
eprintln on failure. cargo check -p ec-av1 --lib and --tests both clean,
0 errors/warnings-of-note (only pre-existing missing-doc lint noise).
Gate itself NOT flipped to require pixel-exact yet -- still legally
refuses-or-matches, correctly reflecting that warp is not yet proven
correct.

tmpfs at session start: 65% (11G/16G), not a blocker this round.
crates/ec-av1/src/stream.rsmodified+65 -2
@@ -3322,7 +3322,11 @@ mod tests {
3322 let (width, height, frame_count) = (64usize, 64usize, 24usize);3322 let (width, height, frame_count) = (64usize, 64usize, 24usize);
3323 let mut named_refusals = 0u32;3323 let mut named_refusals = 0u32;
3324 let mut matched = 0u32;3324 let mut matched = 0u32;
3325- for attempt in 0..40u32 {3325+ let n_attempts: u32 = std::env::var("EC_WARP_GATE_ATTEMPTS")
3326+ .ok()
3327+ .and_then(|s| s.parse().ok())
3328+ .unwrap_or(40);
3329+ for attempt in 0..n_attempts {
3326 let seed = 42 + attempt;3330 let seed = 42 + attempt;
3327 let duration = frame_count as f64 / 25.0;3331 let duration = frame_count as f64 / 25.0;
3328 let source =3332 let source =
@@ -3366,6 +3370,7 @@ mod tests {
3366 "--enable-order-hint=1",3370 "--enable-order-hint=1",
3367 "--enable-warped-motion=1",3371 "--enable-warped-motion=1",
3368 "--enable-obmc=1",3372 "--enable-obmc=1",
3373+ "--tune-content=default",
3369 "--enable-masked-comp=0",3374 "--enable-masked-comp=0",
3370 "--enable-interintra-comp=0",3375 "--enable-interintra-comp=0",
3371 "--enable-onesided-comp=0",3376 "--enable-onesided-comp=0",
@@ -3421,12 +3426,21 @@ mod tests {
3421 "{NAME} failed outright, not a named refusal (seed {seed}): {msg}"3426 "{NAME} failed outright, not a named refusal (seed {seed}): {msg}"
3422 );3427 );
3423 named_refusals += 1;3428 named_refusals += 1;
3429+ eprintln!("seed {seed} refusal: {msg}");
3424 continue;3430 continue;
3425 }3431 }
3426 Ok(frames) => frames,3432 Ok(frames) => frames,
3427 };3433 };
3428 let ffmpeg_frames = ffmpeg_decode_sequence(&stream, width, height, frame_count);3434 let ffmpeg_frames = ffmpeg_decode_sequence(&stream, width, height, frame_count);
3429 assert_eq!(frames.len(), frame_count);3435 assert_eq!(frames.len(), frame_count);
3436+ let mismatched = frames
3437+ .iter()
3438+ .zip(&ffmpeg_frames)
3439+ .any(|(got, want)| got.y != want.y || got.u != want.u || got.v != want.v);
3440+ if mismatched && let Ok(path) = std::env::var("EC_AV1_GATE_DUMP") {
3441+ std::fs::write(&path, &stream).expect("writing pinned stream");
3442+ eprintln!("EC_AV1_GATE_DUMP: wrote mismatching stream (seed {seed}) to {path}");
3443+ }
3430 for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() {3444 for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() {
3431 assert_eq!(3445 assert_eq!(
3432 got.y, want.y,3446 got.y, want.y,
@@ -3439,10 +3453,59 @@ mod tests {
3439 matched += 1;3453 matched += 1;
3440 }3454 }
3441 eprintln!(3455 eprintln!(
3442- "{NAME}: {named_refusals} named refusals, {matched} pixel-exact matches out of 40"3456+ "{NAME}: {named_refusals} named refusals, {matched} pixel-exact matches out of {n_attempts}, warp_selected_hits={}",
3457+ crate::decode::warp_selected_hits()
3443 );3458 );
3444 }3459 }
3445 3460
3461+ /// lane-warp round 3: reproduces the pinned mismatch bytes captured by
3462+ /// `EC_AV1_GATE_DUMP=$SP/warp-mismatch.obu` off
3463+ /// `a_real_aomenc_stream_with_warped_motion_refuses_or_matches` (seed 49,
3464+ /// frame 1). Deterministic and static -- `#[ignore]`d, run manually.
3465+ #[test]
3466+ #[ignore = "reads a pinned fixture path outside the repo; run manually"]
3467+ fn pinned_warp_stream_decodes_pixel_exact() {
3468+ use crate::decode::warp_selected_hits;
3469+ let path = std::env::var("EC_AV1_GATE_DUMP_PIN").unwrap_or_else(|_| {
3470+ "/tmp/claude-1000/-home-user-Documents-Code-Rust-edith-codecs/\
3471+ 51b5f611-f998-43a8-b975-e64cb643a3e1/scratchpad/warp-mismatch.obu"
3472+ .to_string()
3473+ });
3474+ let stream = std::fs::read(&path).expect("reading pinned stream");
3475+ if !have_ffmpeg() {
3476+ eprintln!("SKIP pinned_warp_stream_decodes_pixel_exact: no ffmpeg");
3477+ return;
3478+ }
3479+ let before = warp_selected_hits();
3480+ let frames = decode_stream(&stream).expect("pinned stream must decode");
3481+ eprintln!(
3482+ "warp_selected_hits before={before} after={}",
3483+ warp_selected_hits()
3484+ );
3485+ let ffmpeg_frames = ffmpeg_decode_sequence(&stream, 64, 64, 24);
3486+ for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() {
3487+ if got.y != want.y {
3488+ for row in 0..64 {
3489+ let mut line = String::new();
3490+ for col in 0..64 {
3491+ let d = got.y[row * 64 + col] as i32 - want.y[row * 64 + col] as i32;
3492+ line.push(if d == 0 {
3493+ '.'
3494+ } else if d.abs() < 4 {
3495+ 'o'
3496+ } else {
3497+ 'X'
3498+ });
3499+ }
3500+ eprintln!("{line}");
3501+ }
3502+ }
3503+ assert_eq!(got.y, want.y, "frame {i} luma vs ffmpeg (pinned)");
3504+ assert_eq!(got.u, want.u, "frame {i} U vs ffmpeg (pinned)");
3505+ assert_eq!(got.v, want.v, "frame {i} V vs ffmpeg (pinned)");
3506+ }
3507+ }
3508+
3446 /// `LAST2_FRAME`/`LAST3_FRAME` are just older slots in the same forward3509 /// `LAST2_FRAME`/`LAST3_FRAME` are just older slots in the same forward
3447 /// reference-buffer ring `LAST_FRAME`/`GOLDEN_FRAME` already prove --3510 /// reference-buffer ring `LAST_FRAME`/`GOLDEN_FRAME` already prove --
3448 /// dropping the golden gate's `--max-reference-frames=33511 /// dropping the golden gate's `--max-reference-frames=3