From 8d5c79fd726cf062c8ccac81a88f4abfe9698a34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Fri, 28 Aug 2026 21:06:00 +0300 Subject: [PATCH] feat(av1): flip the warp gate to must-decode; r5e report refuses-or-matches -> warp refusals forbidden, matched>0 and warp_selected_hits>0 required (non-warp capability refusals still skip). KNOWN: cross-run encoder non-determinism observed (warp_selected_hits 156/103 across identical-seed sweeps) and one run caught a seed-66 frame-13 mismatch -- flake hunt with EC_AV1_GATE_DUMP in flight; a caught stream becomes the next pin. --- crates/ec-av1/src/stream.rs | 42 +++++++++++++++++++++++-------------- lanes/warp-r5e.report.md | 41 ++++++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+), 16 deletions(-) create mode 100644 lanes/warp-r5e.report.md diff --git a/crates/ec-av1/src/stream.rs b/crates/ec-av1/src/stream.rs index 117091ae..fe88fbf1 100644 --- a/crates/ec-av1/src/stream.rs +++ b/crates/ec-av1/src/stream.rs @@ -3298,15 +3298,15 @@ mod tests { ); } - /// lane-motionmode round 1: `--enable-warped-motion=1` must be a NAMED - /// refusal, never a silent mis-decode -- this decoder does not port - /// `av1_findSamples`/`num_proj_ref`, so it cannot tell `OBMC_CAUSAL` - /// from `WARPED_CAUSAL` at an eligible block once the header allows - /// warp (see `decode_inter_block`'s own `allow_warped_motion` refusal). - /// Every attempt across the seed sweep must either name the refusal or - /// decode pixel-exact (an eligible block simply never fired in that - /// attempt) -- a silent pixel mismatch here would mean the refusal - /// failed to fire on a stream that actually needed it. + /// lane-warp r5e (flipped from lane-motionmode r1's refuses-or-matches): + /// `--enable-warped-motion=1` streams must DECODE pixel-exact -- + /// `av1_findSamples`/`num_proj_ref`, the 3-symbol `motion_mode` read, + /// the affine projection/filter, and the WARPED_CAUSAL interp-filter + /// derivation are all ported. A refusal naming warp, or any pixel + /// mismatch, fails the gate; refusals for OTHER named capabilities + /// (screen content tools) still skip that seed. The sweep must also + /// actually exercise warp (`warp_selected_hits > 0`) so a decoder that + /// silently stops selecting WARPED_CAUSAL cannot pass vacuously. #[test] fn a_real_aomenc_stream_with_warped_motion_refuses_or_matches() { const NAME: &str = "a_real_aomenc_stream_with_warped_motion_refuses_or_matches"; @@ -3425,8 +3425,13 @@ mod tests { msg.contains("unsupported"), "{NAME} failed outright, not a named refusal (seed {seed}): {msg}" ); + assert!( + !msg.contains("warp"), + "{NAME} refused on warp (seed {seed}) -- warp decode is ported, this \ + refusal must not exist: {msg}" + ); named_refusals += 1; - eprintln!("seed {seed} refusal: {msg}"); + eprintln!("seed {seed} refusal (non-warp capability): {msg}"); continue; } Ok(frames) => frames, @@ -3442,18 +3447,23 @@ mod tests { eprintln!("EC_AV1_GATE_DUMP: wrote mismatching stream (seed {seed}) to {path}"); } for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() { - assert_eq!( - got.y, want.y, - "{NAME} frame {i} luma vs ffmpeg (seed {seed}) -- decoded without a named \ - refusal but mismatched, meaning the refusal failed to fire" - ); + assert_eq!(got.y, want.y, "{NAME} frame {i} luma vs ffmpeg (seed {seed})"); assert_eq!(got.u, want.u, "{NAME} frame {i} U vs ffmpeg (seed {seed})"); assert_eq!(got.v, want.v, "{NAME} frame {i} V vs ffmpeg (seed {seed})"); } matched += 1; } + assert!( + matched > 0, + "{NAME}: every attempt refused on other capabilities; the gate never exercised warp" + ); + assert!( + crate::decode::warp_selected_hits() > 0, + "{NAME}: {matched} matches but zero WARPED_CAUSAL blocks fired -- the gate decodes \ + warp streams without ever selecting warp, so it proves nothing about warp" + ); eprintln!( - "{NAME}: {named_refusals} named refusals, {matched} pixel-exact matches out of {n_attempts}, warp_selected_hits={}", + "{NAME}: {named_refusals} non-warp refusals, {matched} pixel-exact matches out of {n_attempts}, warp_selected_hits={}", crate::decode::warp_selected_hits() ); } diff --git a/lanes/warp-r5e.report.md b/lanes/warp-r5e.report.md new file mode 100644 index 00000000..9a5e61d8 --- /dev/null +++ b/lanes/warp-r5e.report.md @@ -0,0 +1,41 @@ +# lane-warp r5e report — PASS (run by orchestrator inline after two builder task kills) + +PASS: pinned_warp_stream_decodes_pixel_exact 24/24 pixel-exact vs ffmpeg, green twice; +ec-av1 lib suite 217 passed / 0 failed. Fix committed f231bab. + +## Root cause (the whole r3→r5e chain) +libaom's `av1_is_interp_needed` DERIVES the interp filter (Regular) instead of reading +switchable_interp symbols when `motion_mode == WARPED_CAUSAL` — keyed on the symbol value, +not projection validity. Our single-ref path suppressed the read only for GLOBALMV +(decode.rs resolve_interp_filter call), so a warped block consumed 1–2 extra symbols. + +Where it bit: the hidden no-show altref (decode-order 13, display 23) is four 32x32 blocks — +NEWMV SIMPLE / NEARMV OBMC / NEWMV WARPED skip / NEWMV OBMC. Our symbols matched libaom's +through the first three (mvs transposed-equal), then B10's warped tail over-read and B11's +partition_w32 decoded phantom HORZ_B (5) where libaom reads NONE. The corrupted ALTREF then +leaked into shown frames 13+ through zero-mv skip compound copies (display 13 quad (1,1) is +32x32 NEAREST_NEARESTMV zero-mv skip) — class gate-blind-to-hidden-frames, verbatim. + +## Method (evidence) +- libaom `examples/inspect` (built in /tmp/libaom-build; needs IVF wrap: + `ffmpeg -i fixtures/warp-mismatch.obu -c copy x.ivf`) — ground-truth per-block + bsize/mode/mv/ref/motion_mode: /tmp/claude-1000/r5e-inspect.json. +- Our EC_AV1_TRACE decode-order frame-13 section: /tmp/claude-1000/r5e-ours-trace.log. +- Frame index mapping decode→display from inspect: display 13 = decode 16; decode 13 = + display 23 no-show. r5c/r5d's "frame 13 HORZ_B" trace was the HIDDEN frame, and the + HORZ_B itself was desync garbage, not content. + +## What else this explains +- The r5 extended partitions (HORZ_B/VERT_A/VERT_B arms) decoded desync GARBAGE on this pin — + the pin never legitimately contained them (min/max partition 32 in the gate recipe!). They + are exercised by hand only via desync; their correctness is UNPROVEN by this pin. They stay + (harmless spec surface) but need a rect-partition-enabled gate before being trusted. + DISPOSITION: deferred(rect/ab-partition gate) — the warp gate recipe pins + --enable-rect-partitions=0 --enable-ab-partitions=0. +- r5d's bh4 fix + 89122b0 coordinate fix stay (adjudicated PROVEN-RIGHT r5d). + +## Still owed on the lane (in flight / next) +- Warp gate flip: refuses-or-matches → must-decode (named_refusals == 0, warp_selected_hits + > 0); 40-seed sweep measuring now (r5e-warpgate.log). +- Full workspace gate + merge to main + push + teardown per only-main-survives. +- Debts rewrite: warp leaves the NAMED-refusal list.