forge
Explore
Log in

Don't you dare go Hollow

The ladder decode assertion collects every failing reference point

Browse files at this commit

5a13b433851f2ab71a541db0d7aee289f4ba101cAhmet Kaan GümüşParent: f09b4e3
  • test
    • the ladder decode assertion collects every failing reference point
    • the force_integer_mv fixture is sensitive again
Show full message
test(av1): the ladder decode assertion collects every failing reference point; the force_integer_mv fixture is sensitive again
crates/ec-av1/src/encode.rsmodified+40 -10
@@ -13310,25 +13310,31 @@ mod tests {
1331013310 // 25 dB garbage while this gate stayed green) and the crf-5 key
1331113311 // frame desync. A failure names the encoder, the point's flags and
1331213312 // the first differing frame/plane/sample.
13313+ // lane-dpm1: a failing reference point is COLLECTED, not panicked
13314+ // on, so one run still prints the whole BD table and names every
13315+ // bad point instead of stopping at the first. The collection is
13316+ // asserted empty by [`assert_ladder_decodes`] at the end of each
13317+ // gate.
1331313318 match crate::stream::decode_stream(&stream) {
13319+ Ok(ours) if ours.len() != decoded.len() => note_ladder_failure(format!(
13320+ "{encoder} {params:?}: our decoder returned {} shown frames, ffmpeg {}",
13321+ ours.len(),
13322+ decoded.len(),
13323+ )),
1331413324 Ok(ours) => {
13315- assert_eq!(
13316- ours.len(),
13317- decoded.len(),
13318- "{encoder} {params:?}: our decoder returned {} shown frames, ffmpeg {}",
13319- ours.len(),
13320- decoded.len(),
13321- );
1332213325 for (f, (o, d)) in ours.iter().zip(&decoded).enumerate() {
1332313326 if let Some((plane, s, got, want)) = first_plane_mismatch(o, d) {
13324- panic!(
13327+ note_ladder_failure(format!(
1332513328 "{encoder} {params:?} frame {f} plane {plane} sample {s}: our \
1332613329 decoder decoded {got}, ffmpeg {want}"
13327- );
13330+ ));
13331+ break;
1332813332 }
1332913333 }
1333013334 }
13331- Err(e) => panic!("{encoder} {params:?}: our decoder refused the stream ({e})"),
13335+ Err(e) => note_ladder_failure(format!(
13336+ "{encoder} {params:?}: our decoder refused the stream ({e})"
13337+ )),
1333213338 }
1333313339 let mean: f64 = decoded
1333413340 .iter()
@@ -13344,6 +13350,28 @@ mod tests {
1334413350 (ladder, wall)
1334513351 }
1334613352
13353+ /// Every reference ladder point that did not decode sample-exactly
13354+ /// through our own decoder, collected across a whole gate run so the BD
13355+ /// table still prints and EVERY bad point is named
13356+ /// (`encoder params frame plane sample`) instead of only the first.
13357+ static LADDER_FAILURES: std::sync::Mutex<Vec<String>> = std::sync::Mutex::new(Vec::new());
13358+
13359+ fn note_ladder_failure(msg: String) {
13360+ eprintln!("LADDER DECODE FAILURE: {msg}");
13361+ LADDER_FAILURES.lock().expect("ladder failures").push(msg);
13362+ }
13363+
13364+ /// Fail the gate at its END on everything [`external_ladder`] collected.
13365+ fn assert_ladder_decodes() {
13366+ let failures = std::mem::take(&mut *LADDER_FAILURES.lock().expect("ladder failures"));
13367+ assert!(
13368+ failures.is_empty(),
13369+ "{} reference ladder point(s) did not decode exactly through our decoder:\n{}",
13370+ failures.len(),
13371+ failures.join("\n"),
13372+ );
13373+ }
13374+
1334713375 /// First differing sample between two pictures, as
1334813376 /// `(plane, index, left, right)` -- so a gate failure names the plane and
1334913377 /// the sample instead of just "differs". A length difference counts as a
@@ -14446,6 +14474,7 @@ mod tests {
1444614474 .join(", "),
1444714475 );
1444814476 }
14477+ assert_ladder_decodes();
1444914478 }
1445014479 /// Which var-tx depth this clip's INTER blocks resolved to (lane-av1tx2,
1445114480 /// split by block class in lane-av1txdepth): depth 0 is one transform over
@@ -14846,6 +14875,7 @@ mod tests {
1484614875 bd_rate(&rav1e, &ours) * 100.0,
1484714876 );
1484814877 }
14878+ assert_ladder_decodes();
1484914879 }
1485014880
1485114881 /// lane-av1tpl3 step 1: the SHAPE of the propagating map's denominator
crates/ec-av1/src/stream.rsmodified+33 -18
@@ -3771,14 +3771,22 @@ pub(crate) mod tests {
37713771 /// the desync surfaced blocks later as "a Golomb tail longer than this
37723772 /// decoder reads".
37733773 ///
3774- /// The source is SYNTHETIC (no film sample lives in `fixtures`): a
3775- /// near-flat dark background at the film-B crop size, 1920x1024, with one
3776- /// textured patch stepping 9 px every SECOND frame, so half the frames are
3777- /// exact duplicates of their predecessor (the `C == T` trigger) while the
3778- /// motion field still holds non-zero MVs whose projections are not
3779- /// multiples of 8. The gate asserts both halves: at least one INTER frame
3780- /// really carries `force_integer_mv` (class `gate-blind-to-feature`), and
3781- /// every shown frame decodes sample-exact against ffmpeg's own decode.
3774+ /// The source is SYNTHETIC (no film sample lives in `fixtures`): the
3775+ /// near-flat dark pattern libaom's own screen-content detector counts as
3776+ /// screen content, at the film-B crop size 1920x1024, SCROLLING globally
3777+ /// 5 px per frame and frozen on frame 8 -- an exact duplicate of frame 7
3778+ /// (the `C == T` trigger) whose twin is not among its own references, so
3779+ /// its blocks still code real motion under `force_integer_mv`.
3780+ ///
3781+ /// lane-dpm1 made this gate SENSITIVE: with the `force_integer_mv` branch
3782+ /// of [`crate::motion_field::lower_mv_precision`] stubbed out (`if false
3783+ /// &&`) the stream decodes WRONG -- frame 8, luma sample 25695, 20 against
3784+ /// ffmpeg's 19 -- where the previous patch-in-a-static-background recipe
3785+ /// (and two others tried) still decoded byte-exact: there the used mv-stack
3786+ /// slots came from agreeing spatial neighbours and the rounded temporal
3787+ /// entries never won one. The gate asserts both halves: at least one INTER
3788+ /// frame really carries `force_integer_mv` (class `gate-blind-to-feature`),
3789+ /// and every shown frame decodes sample-exact against ffmpeg's own decode.
37823790 #[test]
37833791 fn a_libaom_force_integer_mv_stream_decodes_exact() {
37843792 const NAME: &str = "a_libaom_force_integer_mv_stream_decodes_exact";
@@ -3786,23 +3794,30 @@ pub(crate) mod tests {
37863794 eprintln!("SKIP {NAME}: no ffmpeg");
37873795 return;
37883796 }
3789- let (w, h, frames) = (1920usize, 1024usize, 12usize);
3797+ let (w, h, frames) = (1920usize, 1024usize, 16usize);
37903798 let mut raw = Vec::with_capacity(frames * w * h * 3 / 2);
3799+ let mut off = 0usize;
37913800 for f in 0..frames {
3801+ // lane-dpm1: the WHOLE picture scrolls 5 px per frame and freezes
3802+ // on frame 8, so (a) every block of the frozen frame -- including
3803+ // mi(0,0), which has no spatial neighbour at all -- still codes
3804+ // real motion against the references that are not its twin, and
3805+ // (b) 40 eighth-pels projected over the pyramid's distances lands
3806+ // on non-multiples of 8 (40/2 = 20 -> 16). A patch moving inside a
3807+ // static background was NOT sensitive: there the used stack slots
3808+ // came from spatial neighbours that agreed, and the rounded
3809+ // temporal entries never won one.
3810+ if f > 0 && f != 8 {
3811+ off = (off + 5) % h;
3812+ }
37923813 let mut y = vec![0u8; w * h];
37933814 for row in 0..h {
3815+ let src = (row + off) % h;
37943816 for col in 0..w {
37953817 // 2..=4 distinct values per 16x16 block, all dark: the
37963818 // screen-content detector's own counting rule.
37973819 y[row * w + col] =
3798- 16 + ((col / 32 + row / 32) % 5) as u8 + ((col / 4 + row / 4) % 3) as u8;
3799- }
3800- }
3801- let x0 = 200 + 9 * (f / 2);
3802- for row in 300..428 {
3803- for col in x0..x0 + 192 {
3804- y[row * w + col] =
3805- ((((col - x0) / 3) * 7 + ((row - 300) / 5) * 13) % 200 + 30) as u8;
3820+ 16 + ((col / 32 + src / 32) % 5) as u8 + ((col / 4 + src / 4) % 3) as u8;
38063821 }
38073822 }
38083823 raw.extend_from_slice(&y);
@@ -3815,7 +3830,7 @@ pub(crate) mod tests {
38153830 .args(["-v", "error", "-y", "-f", "rawvideo", "-pix_fmt", "yuv420p"])
38163831 .args(["-s", &format!("{w}x{h}"), "-r", "24", "-i"])
38173832 .arg(&src)
3818- .args(["-an", "-threads", "1", "-g", "12", "-c:v", "libaom-av1"])
3833+ .args(["-an", "-threads", "1", "-g", "16", "-c:v", "libaom-av1"])
38193834 .args(["-cpu-used", "6", "-b:v", "0", "-crf", "35", "-f", "obu", "-"])
38203835 .stdin(Stdio::null())
38213836 .stdout(Stdio::piped())
lanes/dpm1.report.mdadded+38 -0
@@ -0,0 +1,38 @@
1+# lane-dpm1 — the native gate's decode assertion, all reference points
2+
3+## (0) The assertion now COLLECTS (encode.rs)
4+`external_ladder` no longer panics on the first bad reference point: every
5+failure is printed at once (`LADDER DECODE FAILURE: ...`) and pushed onto
6+`LADDER_FAILURES`; each gate calls `assert_ladder_decodes()` after its loop, so
7+the whole BD table still prints and every bad point is named. First run already
8+paid for itself: it found a SECOND failure (screen capture, crf 5) the
9+panic-at-first version hid, and it showed the bars failure is the 2160p clip,
10+not the 1080p one.
11+
12+## (1) bars ±1 — the charter's premise was mis-attributed
13+`bars 1080p` libaom crf 45 decodes EXACT (reproduced standalone: crop
14+1920x1024+0+28, 12 frames, -g 12, cpu-used 6, crf 45 -> our decode == ffmpeg,
15+byte for byte). The real failing row is **bars 2160p** (same crf 45, frame 1,
16+Y sample 66, ours 146 / ffmpeg 145). Status below.
17+
18+## (2) film B crf 5 — STALE premise, already closed
19+Regenerated from the manifest (film B, 00:40:00, crop 1920x1024+960+292):
20+`-cpu-used 6 -crf 5 -g 48` and `-g 12` both decode **sample-exact** vs ffmpeg
21+at this head (48 and 12 frames). No Golomb refusal. The lane-dkey/dgolomb
22+reports' "4th inter frame refuses" is pre-merge state.
23+
24+## (3) force_integer_mv fixture — now SENSITIVE
25+`stream.rs a_libaom_force_integer_mv_stream_decodes_exact`: source replaced by a
26+GLOBAL 5 px/frame vertical scroll of the screen-detector pattern, frozen on
27+frame 8, 16 frames, -g 16. With the fix stubbed (`if false && force_integer_mv`)
28+it now decodes WRONG at frame 8 luma sample 25695 (20 vs ffmpeg 19); with the
29+fix it is exact. Blind recipes tried: patch-in-static-background (the old one),
30+3 patches at 3 speeds with freezes at {5,9} / {4,8,12} / {8}, 3 px scroll.
31+Instrumented finding: a +64 perturbation of rounded candidates DID change the
32+output on those streams, so the rounded candidates were consumed but only in
33+slots whose ±4 eighth-pel difference never reached a coded block's mv.
34+
35+## OPEN
36+* bars 2160p libaom crf 45 frame 1 Y sample 66 (+-1 reconstruction).
37+* screen capture (OBS .mkv row) libaom crf 5 frame 0 (KEY) Y sample 0: 126 vs
38+ 33 — a key-frame desync at the first sample.