testcut P2 ec-h265: restore ffmpeg_decodes_bit_exactly_at_every_shape (hang mutant not killed by fast suite)
Browse files at this commitb49be85b12237d03a93deb867fab5c56d73bf4feParent: ddcb8615 changed files +125 -5
- crates/ec-h265/tests/it/conformance.rs +86 -0
- lanes/testcut/p2-h265.md +8 -5
- lanes/testcut/p2h265-evidence/res-R2-F.tsv +3 -0
- lanes/testcut/p2h265-evidence/res-R2-T.tsv +3 -0
- lanes/testcut/p2h265-tools/recheck2.sh +25 -0
crates/ec-h265/tests/it/conformance.rsmodified+86 -0
| @@ -482,6 +482,92 @@ fn transform_skip_decodes_bit_exactly() { | ||
| 482 | 482 | assert!(quality > 30.0, "{name}: PSNR {quality:.2} dB at QP 22"); |
| 483 | 483 | } |
| 484 | 484 | } |
| 485 | +#[test] | |
| 486 | +fn ffmpeg_decodes_bit_exactly_at_every_shape() { | |
| 487 | + if !have_ffmpeg() { | |
| 488 | + eprintln!("skipping: ffmpeg not installed"); | |
| 489 | + return; | |
| 490 | + } | |
| 491 | + // 1920x1080 needs the conformance window on the bottom (1088 coded rows are | |
| 492 | + // not used: 1080 is a multiple of 8, but 64x64 CTBs still overhang), 1916 | |
| 493 | + // needs it on the right, 130x66 exercises a partial CTB in both directions. | |
| 494 | + // Both tree sizes are coded: the default is 32, and 64 is still offered. | |
| 495 | + for &(w, h, ctb) in &[ | |
| 496 | + (64u32, 64u32, None), | |
| 497 | + (130, 66, None), | |
| 498 | + (1916, 1080, None), | |
| 499 | + (352, 288, None), | |
| 500 | + (1916, 1080, Some(64)), | |
| 501 | + (130, 66, Some(64)), | |
| 502 | + ] { | |
| 503 | + let (source, coded) = encode(w, h, 27, ctb); | |
| 504 | + let name = format!( | |
| 505 | + "shape-{w}x{h}-ctb{}", | |
| 506 | + ctb.map_or("default".to_string(), |c| c.to_string()) | |
| 507 | + ); | |
| 508 | + let path = write_au(&name, &coded); | |
| 509 | + let decoded = match ffmpeg_decode(&path) { | |
| 510 | + Ok(bytes) => bytes, | |
| 511 | + Err(e) => panic!("{name}: ffmpeg failed: {e}"), | |
| 512 | + }; | |
| 513 | + let recon = planes_of(coded.recon.as_ref().expect("recon kept")); | |
| 514 | + assert_eq!( | |
| 515 | + decoded.len(), | |
| 516 | + recon.len(), | |
| 517 | + "{name}: decoded {} bytes, reconstruction {} bytes", | |
| 518 | + decoded.len(), | |
| 519 | + recon.len() | |
| 520 | + ); | |
| 521 | + let mismatches = decoded.iter().zip(&recon).filter(|(a, b)| a != b).count(); | |
| 522 | + if mismatches != 0 { | |
| 523 | + // Which plane and where: a luma-only divergence is the transform | |
| 524 | + // tree, a chroma-only one is the flags that ride on it. | |
| 525 | + let luma = (w * h) as usize; | |
| 526 | + let chroma = luma / 4; | |
| 527 | + let first = decoded | |
| 528 | + .iter() | |
| 529 | + .zip(&recon) | |
| 530 | + .position(|(a, b)| a != b) | |
| 531 | + .unwrap(); | |
| 532 | + let count = |range: std::ops::Range<usize>| { | |
| 533 | + decoded[range.clone()] | |
| 534 | + .iter() | |
| 535 | + .zip(&recon[range]) | |
| 536 | + .filter(|(a, b)| a != b) | |
| 537 | + .count() | |
| 538 | + }; | |
| 539 | + let mut map = String::new(); | |
| 540 | + for by in (0..h as usize).step_by(16) { | |
| 541 | + for bx in (0..w as usize).step_by(16) { | |
| 542 | + let mut c = 0; | |
| 543 | + for row in by..by + 16 { | |
| 544 | + for col in bx..bx + 16 { | |
| 545 | + let i = row * w as usize + col; | |
| 546 | + if decoded[i] != recon[i] { | |
| 547 | + c += 1; | |
| 548 | + } | |
| 549 | + } | |
| 550 | + } | |
| 551 | + map.push_str(&format!("{c:4}")); | |
| 552 | + } | |
| 553 | + map.push('\n'); | |
| 554 | + } | |
| 555 | + eprintln!("luma 16x16 mismatch map:\n{map}"); | |
| 556 | + panic!( | |
| 557 | + "{name}: {mismatches} samples differ -- Y {}, Cb {}, Cr {}, first at {first} \ | |
| 558 | + ({}, {})", | |
| 559 | + count(0..luma), | |
| 560 | + count(luma..luma + chroma), | |
| 561 | + count(luma + chroma..luma + 2 * chroma), | |
| 562 | + first % w as usize, | |
| 563 | + first / w as usize, | |
| 564 | + ); | |
| 565 | + } | |
| 566 | + // And the encode is worth something: PSNR against the source. | |
| 567 | + let quality = psnr(&planes_of(&source), &recon); | |
| 568 | + assert!(quality > 30.0, "{name}: PSNR {quality:.2} dB at QP 27"); | |
| 569 | + } | |
| 570 | +} | |
| 485 | 571 | |
| 486 | 572 | /// A 64x64 coding unit predicts and transforms in four 32x32 blocks under one |
| 487 | 573 | /// luma mode, with the transform split inferred rather than signalled |
lanes/testcut/p2-h265.mdmodified+8 -5
| @@ -1,6 +1,6 @@ | ||
| 1 | 1 | # testcut Phase 2: ec-h265 lane (testcut-p2-h265) |
| 2 | 2 | |
| 3 | -Status: DONE (second attempt, host b, lane `testcut-p2-h265-s1`). Deleted 4 tests, about 364 s of release runtime saved (per rest.tsv times: 143.0 + 54.7 + 119.2 + 47.8). | |
| 3 | +Status: DONE (second attempt, host b, lanes `testcut-p2-h265-s1`, `-s2`). Deleted 3 tests, about 317 s of release runtime saved (per rest.tsv times: 143.0 + 54.7 + 119.2). ffmpeg_decodes_bit_exactly_at_every_shape was restored after the recheck below. | |
| 4 | 4 | |
| 5 | 5 | ## Method and why the first attempt was invalid |
| 6 | 6 | The earlier "kills" were timeouts: mutation runs used the debug profile, so the unmutated pixel run took 915 s against a 429 s timeout. This run uses `--release` everywhere, builds each mutant first (`--no-run`, separate build timeout), and sets the test timeout to 2.5 x the measured unmutated baseline of the same command on the same host (`run1.sh`, `fast.sh`, `mutrun.py`). Mutants are applied by index from `mutants.json`, 10 seeded (seed 2026) mutants per candidate from U(T) functions (noisy: functions T covers). A kill counts only if the test failed (rc=100, tests ran); timeouts do not count. Fast stage: `--profile fast --release`, fail-fast; unmutated fast baseline was 168 passed / 14 skipped, 0 failures, so nothing had to be excluded. Fixtures: `EC_REQUIRE_FIXTURES=1` everywhere; baselines passed with the test started. |
| @@ -13,7 +13,7 @@ Validity checks: baseline logs show `PASS` for exactly the one test; SURVIVED ro | ||
| 13 | 13 | | ec-h265 | pixel_pipeline_runs_over_conformance_streams | 142.99 | pseudo (prints only) | 223 | 10 | 10 | 0 | - | - | DELETED (kills nothing; baseline 48 s, timeout 125 s) | |
| 14 | 14 | | ec-h265 | cu_syntax_sweep_over_conformance_streams | 54.75 | pseudo (prints table only) | 171 | 10 | 9 | 1 (wpp.rs:494:27 `-` to `/`) | 0 | 0 | DELETED (the one kill is also killed by the fast suite) | |
| 15 | 15 | | ec-h265 | motion_derivation_is_deterministic_over_conformance_streams | 119.18 | candidate | 148 | 10 | 9 | 1 | 0 | 0 | DELETED (fast suite kills the T-kill) | |
| 16 | -| ec-h265 | ffmpeg_decodes_bit_exactly_at_every_shape | 47.80 | candidate | 57 | 10 | 5 | 5 (2 real, 3 hang-timeouts) | 0 | 0 | DELETED (both real kills die in the fast suite; the hang mutants hang T and the fast suite alike, ctu.rs:429 rechecked at 600 s/1200 s) | | |
| 16 | +| ec-h265 | ffmpeg_decodes_bit_exactly_at_every_shape | 47.80 | candidate | 57 | 10 | 5 | 5 (2 failing, 3 hang-timeouts; hangs reconfirmed on a quiet host, load 0.9) | 1 (ctu.rs:429:13 `+` to `-` in code_quadtree: T hangs, fast suite also hangs, no real failure) | not run | KEEP (K'=1 unresolved; the other 4 T-kills are real fast-suite failures) | | |
| 17 | 17 | | ec-h265 | noisy_near_black_lands_within_five_percent | 41.17 | candidate | 84 | 10 | 3 | 7 | 1 (ctu.rs:534:29 `+` to `-` in save_meta: T fails, fast suite hangs past 1200 s) | not run | KEEP (the only fast-suite outcome is a hang, not a failure; K' step not run) | |
| 18 | 18 | | ec-h265 | conformance_pictures_match_the_sei_hash | 85.08 | protected | | | | | | | protected | |
| 19 | 19 | | ec-h265 | rext_conformance_pictures_match_the_sei_hash | 83.30 | protected | | | | | | | protected | |
| @@ -25,9 +25,12 @@ Validity checks: baseline logs show `PASS` for exactly the one test; SURVIVED ro | ||
| 25 | 25 | Release baselines measured on b: pixel 48 s, cu_syntax 21 s, noisy 39 s, motion 40 s, ffmpeg 23 s (the rest.tsv times are from a different run mix). Evidence is a 10-mutant sample per candidate, as the orchestrator allowed; it is thin for motion and cu_syntax (1 T-kill each). |
| 26 | 26 | |
| 27 | 27 | ## Summary |
| 28 | -1. Tests deleted: pixel_pipeline_runs_over_conformance_streams, cu_syntax_sweep_over_conformance_streams, motion_derivation_is_deterministic_over_conformance_streams, ffmpeg_decodes_bit_exactly_at_every_shape (helpers `Row`, `sweep` and unused imports removed). | |
| 29 | -2. Seconds saved: about 364 s (rest.tsv times). | |
| 30 | -3. Kept with evidence: noisy_near_black_lands_within_five_percent (K=1, hang-only fast outcome). Protected: 6 tests. | |
| 28 | +1. Tests deleted: pixel_pipeline_runs_over_conformance_streams, cu_syntax_sweep_over_conformance_streams, motion_derivation_is_deterministic_over_conformance_streams (helpers `Row`, `sweep` and unused imports removed). | |
| 29 | +2. Seconds saved: about 317 s (rest.tsv times). | |
| 30 | +3. Kept with evidence: noisy_near_black_lands_within_five_percent (K=1, hang-only fast outcome) and ffmpeg_decodes_bit_exactly_at_every_shape (K'=1, hang-only). Protected: 6 tests. | |
| 31 | 31 | 4. Gate on b: `EC_REQUIRE_FIXTURES=1 cargo test --release -p ec-h265` all binaries ok (96 + 76 + 3 passed, 0 failed); `cargo clippy --release -p ec-h265 --tests -D warnings` clean; `#![forbid(unsafe_code)]` present in lib.rs. |
| 32 | 32 | 5. `.config/nextest.toml` still names ffmpeg_decodes_bit_exactly_at_every_shape in the fast filter; harmless, left. `inter_placeholder_runs_over_pb_slices` was not heavy and is kept. |
| 33 | 33 | Tools: `lanes/testcut/p2h265-tools/{run1.sh,fast.sh,recheck.sh,gate.sh,mutrun.py}`. Per-mutant rows: `lanes/testcut/p2h265-evidence/res-*.tsv`. |
| 34 | + | |
| 35 | +Note: samples were 10 mutants per candidate. Evidence for motion_derivation and cu_syntax_sweep is thin (1 T-kill each, both also killed by the fast suite). | |
| 36 | +Recheck (lane -s2, quiet host, load 0.9, T baseline 22 s, timeout 63 s): all 3 ffmpeg hang mutants still hang in T alone (real kills under the lane rules). Fast profile: residual.rs:609 and residual.rs:430 fail with rc=100 (killed); ctu.rs:429 hangs past 2.5 x the 54 s fast baseline (and past 1200 s earlier), so it is not killed by the fast suite. The test was restored byte-for-byte from before the deletion (conformance.rs), so the gate result above for the remaining code still applies. |
lanes/testcut/p2h265-evidence/res-R2-F.tsvadded+3 -0
| @@ -0,0 +1,3 @@ | ||
| 1 | +crates/ec-h265/src/residual.rs:609:42: replace + with - in residual_header KILLED rc=100 ran=81 timeout=False | |
| 2 | +crates/ec-h265/src/ctu.rs:429:13: replace + with - in CtuEncoder<'a>::code_quadtree KILLED rc=-1 ran=0 timeout=True | |
| 3 | +crates/ec-h265/src/residual.rs:430:64: replace >> with << in rdoq KILLED rc=100 ran=86 timeout=False |
lanes/testcut/p2h265-evidence/res-R2-T.tsvadded+3 -0
| @@ -0,0 +1,3 @@ | ||
| 1 | +crates/ec-h265/src/residual.rs:609:42: replace + with - in residual_header KILLED rc=-1 ran=0 timeout=True | |
| 2 | +crates/ec-h265/src/ctu.rs:429:13: replace + with - in CtuEncoder<'a>::code_quadtree KILLED rc=-1 ran=0 timeout=True | |
| 3 | +crates/ec-h265/src/residual.rs:430:64: replace >> with << in rdoq KILLED rc=-1 ran=0 timeout=True |
lanes/testcut/p2h265-tools/recheck2.shadded+25 -0
| @@ -0,0 +1,25 @@ | ||
| 1 | +#!/usr/bin/env bash | |
| 2 | +# Recheck the 3 ffmpeg T-timeout mutants on a quiet host: T alone (2.5x measured baseline), then fast profile. | |
| 3 | +set -uo pipefail | |
| 4 | +export EC_REQUIRE_FIXTURES=1 | |
| 5 | +TOOLS=$PWD/lanes/testcut/p2h265-tools | |
| 6 | +OUT=$(dirname "$PWD")/out | |
| 7 | +echo "load: $(cat /proc/loadavg)" | |
| 8 | +F="test(/(^|::)ffmpeg_decodes_bit_exactly_at_every_shape\$/)" | |
| 9 | +cargo nextest run --release -p ec-h265 -E "$F" --no-run >/dev/null 2>&1 | |
| 10 | +S=$(date +%s); cargo nextest run --release -p ec-h265 -E "$F" > "$OUT/b2.log" 2>&1; echo "T baseline rc=$? $(( $(date +%s)-S ))s" | |
| 11 | +cat > "$OUT/names.json" <<'J' | |
| 12 | +["crates/ec-h265/src/residual.rs:609:42: replace + with - in residual_header","crates/ec-h265/src/ctu.rs:429:13: replace + with - in CtuEncoder<'a>::code_quadtree","crates/ec-h265/src/residual.rs:430:64: replace >> with << in rdoq"] | |
| 13 | +J | |
| 14 | +python3 "$TOOLS/mutrun.py" "$OUT" "$OUT/names.json" R2-T 63 "$F" | |
| 15 | +python3 - <<'P' | |
| 16 | +import json,os | |
| 17 | +o=os.environ.get("OUT") | |
| 18 | +P | |
| 19 | +awk -F'\t' '$2=="KILLED"{print $1}' "$OUT/res-R2-T.tsv" > "$OUT/k2.txt" | |
| 20 | +python3 -c "import json,sys;json.dump([l.rstrip('\n') for l in open(sys.argv[1]) if l.strip()],open(sys.argv[2],'w'))" "$OUT/k2.txt" "$OUT/k2.json" | |
| 21 | +cargo nextest run --release -p ec-h265 --profile fast --no-run >/dev/null 2>&1 | |
| 22 | +S=$(date +%s); cargo nextest run --release -p ec-h265 --profile fast --no-fail-fast > "$OUT/fb2.log" 2>&1; SECS=$(( $(date +%s)-S )); echo "fast baseline rc=$? ${SECS}s" | |
| 23 | +FAILFAST=1 python3 "$TOOLS/mutrun.py" "$OUT" "$OUT/k2.json" R2-F $(( SECS*5/2+5 )) "all()" --profile fast | |
| 24 | +cut -f1,2,3 "$OUT"/res-R2-*.tsv | cut -c1-200 | |
| 25 | +echo R2_DONE |