Merge branch 'lane-fixdet': the gate fixtures were never reproducible
Browse files at this commit3 changed files +258 -44
- crates/ec-av1/src/stream.rs +96 -44
- lanes/fixdet-r1.charter.md +72 -0
- lanes/fixdet-r1.report.md +90 -0
crates/ec-av1/src/stream.rsmodified+96 -44
| @@ -903,6 +903,74 @@ mod tests { | ||
| 903 | 903 | } |
| 904 | 904 | } |
| 905 | 905 | |
| 906 | + /// Builds a `gradients` lavfi source string with colours derived from | |
| 907 | + /// `seed`, not left to the filter's own default. | |
| 908 | + /// | |
| 909 | + /// Measured (lane-fixdet r1): ffmpeg's `gradients` source IGNORES its | |
| 910 | + /// `seed=` parameter for colour selection -- five encodes of an | |
| 911 | + /// identical command line (same `seed=`, same everything) produced five | |
| 912 | + /// different fixtures, because the unset `c0..c9` stops are randomized | |
| 913 | + /// from something other than that seed. Every one of this file's ~20 | |
| 914 | + /// gate fixtures built a `gradients` source this way, so none of them | |
| 915 | + /// had a reproducible input: a pin captured from one run could not be | |
| 916 | + /// regenerated, and "attempt N failed" was as likely to be a different | |
| 917 | + /// fixture as a different decode outcome. | |
| 918 | + /// | |
| 919 | + /// Freezing the colours outright (as the earliest four gates below do, | |
| 920 | + /// hand-picking `c0=red:c1=blue:c2=green`) fixes reproducibility but | |
| 921 | + /// throws away the per-attempt content variety the sweep gates need to | |
| 922 | + /// make features (OBMC, warp, wedge, ...) fire at all -- this repo's own | |
| 923 | + /// `sampler-decorrelated-gate` class. So: derive `c0..c3` deterministically | |
| 924 | + /// FROM the seed with a plain integer hash, and keep passing `seed=` | |
| 925 | + /// itself too, so a future ffmpeg that actually honours it only adds | |
| 926 | + /// more variety, never removes the determinism this buys. | |
| 927 | + fn gradients_source(seed: u32, width: usize, height: usize, tail: &str) -> String { | |
| 928 | + fn hash_color(seed: u32, salt: u32) -> String { | |
| 929 | + let h = seed | |
| 930 | + .wrapping_mul(2_654_435_761) | |
| 931 | + .wrapping_add(salt.wrapping_mul(0x9E37_79B9)) | |
| 932 | + ^ (seed.rotate_left(13)); | |
| 933 | + format!("0x{:06x}", h & 0x00ff_ffff) | |
| 934 | + } | |
| 935 | + let (c0, c1, c2, c3) = ( | |
| 936 | + hash_color(seed, 0), | |
| 937 | + hash_color(seed, 1), | |
| 938 | + hash_color(seed, 2), | |
| 939 | + hash_color(seed, 3), | |
| 940 | + ); | |
| 941 | + format!("gradients=size={width}x{height}:c0={c0}:c1={c1}:c2={c2}:c3={c3}:seed={seed}:{tail}") | |
| 942 | + } | |
| 943 | + | |
| 944 | + /// The determinism guard: same seed twice must byte-match ffmpeg's own | |
| 945 | + /// output; different seeds must not. Regresses this fix if it ever | |
| 946 | + /// breaks. | |
| 947 | + #[test] | |
| 948 | + fn gradients_source_is_reproducible_per_seed() { | |
| 949 | + if !have_ffmpeg() { | |
| 950 | + eprintln!("SKIP gradients_source_is_reproducible_per_seed: no ffmpeg"); | |
| 951 | + return; | |
| 952 | + } | |
| 953 | + fn render_hash(lavfi: &str) -> Vec<u8> { | |
| 954 | + let out = Command::new("ffmpeg") | |
| 955 | + .args([ | |
| 956 | + "-v", "error", "-f", "lavfi", "-i", lavfi, "-frames:v", "1", "-f", "rawvideo", | |
| 957 | + "-", | |
| 958 | + ]) | |
| 959 | + .stdin(Stdio::null()) | |
| 960 | + .stdout(Stdio::piped()) | |
| 961 | + .stderr(Stdio::piped()) | |
| 962 | + .output() | |
| 963 | + .expect("ffmpeg failed to run"); | |
| 964 | + assert!(out.status.success(), "ffmpeg refused {lavfi}"); | |
| 965 | + out.stdout | |
| 966 | + } | |
| 967 | + let a1 = render_hash(&gradients_source(42, 64, 64, "duration=0.04:rate=25")); | |
| 968 | + let a2 = render_hash(&gradients_source(43, 64, 64, "duration=0.04:rate=25")); | |
| 969 | + let a3 = render_hash(&gradients_source(42, 64, 64, "duration=0.04:rate=25")); | |
| 970 | + assert_eq!(a1, a3, "same seed must reproduce byte-identical output"); | |
| 971 | + assert_ne!(a1, a2, "different seeds must not collide"); | |
| 972 | + } | |
| 973 | + | |
| 906 | 974 | /// Encodes a real libaom-av1 stream (via ffmpeg's own encoder, not this |
| 907 | 975 | /// crate's) with the same reduced-partition flags lane-av1adst's r6 |
| 908 | 976 | /// probe found still select `ADST_ADST`/`ADST_DCT`/`DCT_ADST` on |
| @@ -988,17 +1056,13 @@ mod tests { | ||
| 988 | 1056 | eprintln!("SKIP a_real_libaom_stream_with_adst_decodes_end_to_end: no ffmpeg"); |
| 989 | 1057 | return; |
| 990 | 1058 | } |
| 991 | - let configs: [(&str, usize, usize, u32); 2] = [ | |
| 992 | - ("testsrc2=size=64x64:rate=1", 64, 64, 15), | |
| 993 | - ( | |
| 994 | - "gradients=size=64x64:c0=red:c1=blue:c2=green:rate=1", | |
| 995 | - 64, | |
| 996 | - 64, | |
| 997 | - 15, | |
| 998 | - ), | |
| 1059 | + let configs: [(String, usize, usize, u32); 2] = [ | |
| 1060 | + ("testsrc2=size=64x64:rate=1".to_string(), 64, 64, 15), | |
| 1061 | + (gradients_source(42, 64, 64, "rate=1"), 64, 64, 15), | |
| 999 | 1062 | ]; |
| 1000 | 1063 | let mut verdicts = Vec::new(); |
| 1001 | 1064 | for (lavfi, width, height, crf) in configs { |
| 1065 | + let lavfi = lavfi.as_str(); | |
| 1002 | 1066 | let Some(stream) = libaom_encode(lavfi, width, height, crf) else { |
| 1003 | 1067 | verdicts.push(format!("{lavfi}: ffmpeg itself refused to encode")); |
| 1004 | 1068 | continue; |
| @@ -1052,7 +1116,7 @@ mod tests { | ||
| 1052 | 1116 | } |
| 1053 | 1117 | let (width, height) = (64, 64); |
| 1054 | 1118 | let stream = libaom_encode_with( |
| 1055 | - "gradients=size=64x64:c0=red:c1=blue:c2=green:rate=1:seed=42", | |
| 1119 | + &gradients_source(42, width, height, "rate=1"), | |
| 1056 | 1120 | width, |
| 1057 | 1121 | height, |
| 1058 | 1122 | 15, |
| @@ -1098,7 +1162,7 @@ mod tests { | ||
| 1098 | 1162 | } |
| 1099 | 1163 | let (width, height) = (32, 32); |
| 1100 | 1164 | let stream = libaom_encode_with( |
| 1101 | - "gradients=size=32x32:c0=red:c1=blue:c2=green:rate=1:seed=42", | |
| 1165 | + &gradients_source(42, width, height, "rate=1"), | |
| 1102 | 1166 | width, |
| 1103 | 1167 | height, |
| 1104 | 1168 | 15, |
| @@ -1142,7 +1206,7 @@ mod tests { | ||
| 1142 | 1206 | } |
| 1143 | 1207 | let (width, height) = (64, 64); |
| 1144 | 1208 | let stream = libaom_encode_with( |
| 1145 | - "gradients=size=64x64:c0=red:c1=blue:c2=green:rate=1:seed=42", | |
| 1209 | + &gradients_source(42, width, height, "rate=1"), | |
| 1146 | 1210 | width, |
| 1147 | 1211 | height, |
| 1148 | 1212 | 30, |
| @@ -1265,7 +1329,7 @@ mod tests { | ||
| 1265 | 1329 | .ok() |
| 1266 | 1330 | .and_then(|v| v.parse().ok()) |
| 1267 | 1331 | .unwrap_or(42); |
| 1268 | - let fi_source = format!("gradients=size=64x64:seed={fi_seed}:duration=0.04:rate=25"); | |
| 1332 | + let fi_source = gradients_source(fi_seed, 64, 64, "duration=0.04:rate=25"); | |
| 1269 | 1333 | let fi_cq = std::env::var("EC_FI_CQ").unwrap_or_else(|_| "40".to_string()); |
| 1270 | 1334 | let fi_cq_arg = format!("--cq-level={fi_cq}"); |
| 1271 | 1335 | let y4m = Command::new("ffmpeg") |
| @@ -1391,20 +1455,11 @@ mod tests { | ||
| 1391 | 1455 | return; |
| 1392 | 1456 | } |
| 1393 | 1457 | let (width, height) = (64usize, 64usize); |
| 1458 | + let source = gradients_source(42, width, height, "duration=0.04:rate=25"); | |
| 1394 | 1459 | let y4m = Command::new("ffmpeg") |
| 1395 | - .args([ | |
| 1396 | - "-v", | |
| 1397 | - "error", | |
| 1398 | - "-f", | |
| 1399 | - "lavfi", | |
| 1400 | - "-i", | |
| 1401 | - "gradients=size=64x64:seed=42:duration=0.04:rate=25", | |
| 1402 | - "-pix_fmt", | |
| 1403 | - "yuv420p", | |
| 1404 | - "-f", | |
| 1405 | - "yuv4mpegpipe", | |
| 1406 | - "-", | |
| 1407 | - ]) | |
| 1460 | + .args(["-v", "error", "-f", "lavfi", "-i"]) | |
| 1461 | + .arg(&source) | |
| 1462 | + .args(["-pix_fmt", "yuv420p", "-f", "yuv4mpegpipe", "-"]) | |
| 1408 | 1463 | .stdin(Stdio::null()) |
| 1409 | 1464 | .stdout(Stdio::piped()) |
| 1410 | 1465 | .stderr(Stdio::piped()) |
| @@ -1827,14 +1882,11 @@ mod tests { | ||
| 1827 | 1882 | return; |
| 1828 | 1883 | } |
| 1829 | 1884 | let (width, height, frame_count) = (64usize, 64usize, 4usize); |
| 1885 | + let source = gradients_source(42, width, height, "duration=0.16:rate=25"); | |
| 1830 | 1886 | let y4m = Command::new("ffmpeg") |
| 1887 | + .args(["-v", "error", "-f", "lavfi", "-i"]) | |
| 1888 | + .arg(&source) | |
| 1831 | 1889 | .args([ |
| 1832 | - "-v", | |
| 1833 | - "error", | |
| 1834 | - "-f", | |
| 1835 | - "lavfi", | |
| 1836 | - "-i", | |
| 1837 | - "gradients=size=64x64:seed=42:duration=0.16:rate=25", | |
| 1838 | 1890 | "-pix_fmt", |
| 1839 | 1891 | "yuv420p", |
| 1840 | 1892 | "-f", |
| @@ -1991,7 +2043,7 @@ mod tests { | ||
| 1991 | 2043 | let mut refusals = Vec::new(); |
| 1992 | 2044 | for attempt in 0..8u32 { |
| 1993 | 2045 | let seed = 42 + attempt; |
| 1994 | - let source = format!("gradients=size=64x64:seed={seed}:duration=0.16:rate=25"); | |
| 2046 | + let source = gradients_source(seed, 64, 64, "duration=0.16:rate=25"); | |
| 1995 | 2047 | let y4m = Command::new("ffmpeg") |
| 1996 | 2048 | .args([ |
| 1997 | 2049 | "-v", |
| @@ -2349,7 +2401,7 @@ mod tests { | ||
| 2349 | 2401 | // this recipe's own choosing, not a decoder bug. |
| 2350 | 2402 | for attempt in 0..120u32 { |
| 2351 | 2403 | let seed = 42 + attempt % 40; |
| 2352 | - let source = format!("gradients=size=64x64:seed={seed}:duration=0.32:rate=25"); | |
| 2404 | + let source = gradients_source(seed, 64, 64, "duration=0.32:rate=25"); | |
| 2353 | 2405 | let y4m = Command::new("ffmpeg") |
| 2354 | 2406 | .args([ |
| 2355 | 2407 | "-v", |
| @@ -2561,7 +2613,7 @@ mod tests { | ||
| 2561 | 2613 | let seed = 42 + attempt % 40; |
| 2562 | 2614 | let duration = frame_count as f64 / 25.0; |
| 2563 | 2615 | let source = |
| 2564 | - format!("gradients=size={width}x{height}:seed={seed}:duration={duration}:rate=25"); | |
| 2616 | + gradients_source(seed, width, height, &format!("duration={duration}:rate=25")); | |
| 2565 | 2617 | let y4m = Command::new("ffmpeg") |
| 2566 | 2618 | .args([ |
| 2567 | 2619 | "-v", |
| @@ -2745,7 +2797,7 @@ mod tests { | ||
| 2745 | 2797 | let seed = 42 + attempt % 40; |
| 2746 | 2798 | let duration = frame_count as f64 / 25.0; |
| 2747 | 2799 | let source = |
| 2748 | - format!("gradients=size={width}x{height}:seed={seed}:duration={duration}:rate=25"); | |
| 2800 | + gradients_source(seed, width, height, &format!("duration={duration}:rate=25")); | |
| 2749 | 2801 | let y4m = Command::new("ffmpeg") |
| 2750 | 2802 | .args([ |
| 2751 | 2803 | "-v", |
| @@ -2960,7 +3012,7 @@ mod tests { | ||
| 2960 | 3012 | let seed = 42 + attempt % 40; |
| 2961 | 3013 | let duration = frame_count as f64 / 25.0; |
| 2962 | 3014 | let source = |
| 2963 | - format!("gradients=size={width}x{height}:seed={seed}:duration={duration}:rate=25"); | |
| 3015 | + gradients_source(seed, width, height, &format!("duration={duration}:rate=25")); | |
| 2964 | 3016 | let y4m = Command::new("ffmpeg") |
| 2965 | 3017 | .args([ |
| 2966 | 3018 | "-v", |
| @@ -3136,7 +3188,7 @@ mod tests { | ||
| 3136 | 3188 | let seed = 42 + attempt % 40; |
| 3137 | 3189 | let duration = frame_count as f64 / 25.0; |
| 3138 | 3190 | let source = |
| 3139 | - format!("gradients=size={width}x{height}:seed={seed}:duration={duration}:rate=25"); | |
| 3191 | + gradients_source(seed, width, height, &format!("duration={duration}:rate=25")); | |
| 3140 | 3192 | let y4m = Command::new("ffmpeg") |
| 3141 | 3193 | .args([ |
| 3142 | 3194 | "-v", |
| @@ -3317,7 +3369,7 @@ mod tests { | ||
| 3317 | 3369 | // EC_AV1_OBMC8_SOURCE overrides the lavfi source so a firing recipe |
| 3318 | 3370 | // can be searched for without a rebuild. |
| 3319 | 3371 | let source = std::env::var("EC_AV1_OBMC8_SOURCE").unwrap_or_else(|_| { |
| 3320 | - format!("gradients=size={width}x{height}:seed={seed}:duration={duration}:rate=25") | |
| 3372 | + gradients_source(seed, width, height, &format!("duration={duration}:rate=25")) | |
| 3321 | 3373 | }); |
| 3322 | 3374 | // A source supplied through EC_AV1_OBMC8_SOURCE need not carry its |
| 3323 | 3375 | // own `duration=`; `-t` is the bound that always holds. Without it |
| @@ -3493,7 +3545,7 @@ mod tests { | ||
| 3493 | 3545 | let seed = 42 + attempt; |
| 3494 | 3546 | let duration = frame_count as f64 / 25.0; |
| 3495 | 3547 | let source = |
| 3496 | - format!("gradients=size={width}x{height}:seed={seed}:duration={duration}:rate=25"); | |
| 3548 | + gradients_source(seed, width, height, &format!("duration={duration}:rate=25")); | |
| 3497 | 3549 | let y4m = Command::new("ffmpeg") |
| 3498 | 3550 | .args([ |
| 3499 | 3551 | "-v", |
| @@ -3662,7 +3714,7 @@ mod tests { | ||
| 3662 | 3714 | let seed = 42 + attempt; |
| 3663 | 3715 | let duration = frame_count as f64 / 25.0; |
| 3664 | 3716 | let source = |
| 3665 | - format!("gradients=size={width}x{height}:seed={seed}:duration={duration}:rate=25"); | |
| 3717 | + gradients_source(seed, width, height, &format!("duration={duration}:rate=25")); | |
| 3666 | 3718 | let y4m = Command::new("ffmpeg") |
| 3667 | 3719 | .args([ |
| 3668 | 3720 | "-v", |
| @@ -3838,7 +3890,7 @@ mod tests { | ||
| 3838 | 3890 | let seed = 42 + attempt; |
| 3839 | 3891 | let duration = frame_count as f64 / 25.0; |
| 3840 | 3892 | let source = if attempt % 2 == 0 { |
| 3841 | - format!("gradients=size={width}x{height}:seed={seed}:duration={duration}:rate=25") | |
| 3893 | + gradients_source(seed, width, height, &format!("duration={duration}:rate=25")) | |
| 3842 | 3894 | } else { |
| 3843 | 3895 | // `end_pts` does NOT bound mandelbrot (it generated 300+ |
| 3844 | 3896 | // frames and hung the gate for an hour); `-t` below is the |
| @@ -4041,7 +4093,7 @@ mod tests { | ||
| 4041 | 4093 | let seed = 42 + attempt; |
| 4042 | 4094 | let duration = frame_count as f64 / 25.0; |
| 4043 | 4095 | let source = |
| 4044 | - format!("gradients=size={width}x{height}:seed={seed}:duration={duration}:rate=25"); | |
| 4096 | + gradients_source(seed, width, height, &format!("duration={duration}:rate=25")); | |
| 4045 | 4097 | let y4m = Command::new("ffmpeg") |
| 4046 | 4098 | .args([ |
| 4047 | 4099 | "-v", |
| @@ -4242,7 +4294,7 @@ mod tests { | ||
| 4242 | 4294 | let seed = 42 + attempt; |
| 4243 | 4295 | let duration = frame_count as f64 / 25.0; |
| 4244 | 4296 | let source = |
| 4245 | - format!("gradients=size={width}x{height}:seed={seed}:duration={duration}:rate=25"); | |
| 4297 | + gradients_source(seed, width, height, &format!("duration={duration}:rate=25")); | |
| 4246 | 4298 | let y4m = Command::new("ffmpeg") |
| 4247 | 4299 | .args([ |
| 4248 | 4300 | "-v", |
| @@ -4841,7 +4893,7 @@ mod tests { | ||
| 4841 | 4893 | let seed = seed_base + attempt; |
| 4842 | 4894 | let duration = frame_count as f64 / 25.0; |
| 4843 | 4895 | let source = |
| 4844 | - format!("gradients=size={width}x{height}:seed={seed}:duration={duration}:rate=25"); | |
| 4896 | + gradients_source(seed, width, height, &format!("duration={duration}:rate=25")); | |
| 4845 | 4897 | let y4m = Command::new("ffmpeg") |
| 4846 | 4898 | .args([ |
| 4847 | 4899 | "-v", |
lanes/fixdet-r1.charter.mdadded+72 -0
| @@ -0,0 +1,72 @@ | ||
| 1 | +# lane-fixdet r1 charter — the gate fixtures are not reproducible | |
| 2 | + | |
| 3 | +## Where you are | |
| 4 | +Worktree /home/user/Documents/Code/Rust/edith_codecs-fixdet, branch | |
| 5 | +lane-fixdet @ main. | |
| 6 | +Build/test ONLY: | |
| 7 | + `env CARGO_TARGET_DIR=$HOME/.cache/cargo-target-fixdet CARGO_BUILD_JOBS=4 nice -n 19 cargo test -p ec-av1 --release --lib <name> -- --nocapture` | |
| 8 | +FOREGROUND, EC_AV1_REQUIRE_AOMENC=1 on gates. Never push. Never touch the main | |
| 9 | +checkout or the sibling -rectwire2 worktree. WIP COMMIT after every green step. | |
| 10 | + | |
| 11 | +## The measurement (already done — do not repeat it, build on it) | |
| 12 | +ffmpeg's `gradients` lavfi source IGNORES its `seed` parameter for colour | |
| 13 | +selection. Hashing its output five times with an identical command line: | |
| 14 | + | |
| 15 | + e981f6da916b400a 2451ed66cdf1c114 13c53f4382ab72a1 | |
| 16 | + f9ac6e84c77489ff dcffa3d8caa39e78 | |
| 17 | + | |
| 18 | +Five runs, five different fixtures. Twenty gate sites in | |
| 19 | +`crates/ec-av1/src/stream.rs` build their fixture this way, so those gates have | |
| 20 | +never had a reproducible input. | |
| 21 | + | |
| 22 | +Two consequences, both measured: | |
| 23 | +- `a_real_aomenc_filter_intra_stream_decodes_pixel_exact` fails about 1 run in | |
| 24 | + 15 even in isolation with the encoder pinned to one thread. The encoder is | |
| 25 | + NOT the source of that: hashing aomenc's output six times over a FIXED y4m | |
| 26 | + gives the same bytes every time. The fixture is the variable. | |
| 27 | +- Every "attempt-selection flake" attributed to aomenc's RD search deserves | |
| 28 | + re-examination. Some of those were the SOURCE changing under the gate. | |
| 29 | + | |
| 30 | +Naming a seed that does nothing is worse than having no seed: it advertises | |
| 31 | +reproducibility the gate does not have, and a pin captured from such a run | |
| 32 | +cannot be regenerated. | |
| 33 | + | |
| 34 | +## The fix | |
| 35 | +`gradients` IS deterministic once the colours are given explicitly — verified, | |
| 36 | +three identical hashes. But the gates need per-attempt VARIETY too: they sweep | |
| 37 | +`seed` across attempts precisely to sample different content, and freezing the | |
| 38 | +colours would make every attempt identical and quietly destroy the sampling | |
| 39 | +that makes features fire (this repo has a `sampler-decorrelated-gate` class | |
| 40 | +already). | |
| 41 | + | |
| 42 | +So derive the colours FROM the seed. Verified working: seeds 42, 43, 42 gave | |
| 43 | +hashes c25eb1d4d042, 5097b017faf7, c25eb1d4d042 — different seeds differ, the | |
| 44 | +same seed reproduces exactly. | |
| 45 | + | |
| 46 | +1. Write ONE helper in `stream.rs`, e.g. | |
| 47 | + `fn gradients_source(seed: u32, w: usize, h: usize, duration: f64) -> String`, | |
| 48 | + that maps the seed deterministically to `c0`..`c3` (and keeps passing | |
| 49 | + `seed` so any future ffmpeg that honours it still varies). Document WHY in | |
| 50 | + a comment: the seed alone does not make this source reproducible. | |
| 51 | +2. Route all 20 sites through it. Keep each site's existing width/height/ | |
| 52 | + duration/rate; this is a determinism fix, not a content change. | |
| 53 | +3. Prove it: a test that builds the same source string twice for one seed and | |
| 54 | + runs ffmpeg on both, asserting byte-identical output, and that two | |
| 55 | + different seeds differ. That test is the guard against this regressing. | |
| 56 | + | |
| 57 | +## Then re-measure what the fix changes | |
| 58 | +- Run `a_real_aomenc_filter_intra_stream_decodes_pixel_exact` 20 times. It was | |
| 59 | + 14/15 before. Report the new number honestly, whatever it is. | |
| 60 | +- Run the free-partition gate 3 times and report whether its refusal/match | |
| 61 | + counts are now stable run-to-run. If they are, say so; if they still move, | |
| 62 | + aomenc attempt selection is real on top of this and the report should say | |
| 63 | + that too, with the numbers. | |
| 64 | +- If a gate now fails CONSISTENTLY, that is a genuine decoder defect this | |
| 65 | + nondeterminism was hiding. Do NOT paper over it: pin it with | |
| 66 | + EC_AV1_GATE_DUMP, name it in the report, and refuse-by-name rather than | |
| 67 | + guess-fix. | |
| 68 | + | |
| 69 | +## Done criteria | |
| 70 | +Full lib suite 231 passed / 0 failed. All 20 sites through the helper. The | |
| 71 | +determinism test in place. REPORT `lanes/fixdet-r1.report.md`, VERDICT on the | |
| 72 | +FIRST line, with the before/after flake rates as measured counts. |
lanes/fixdet-r1.report.mdadded+90 -0
| @@ -0,0 +1,90 @@ | ||
| 1 | +# lane-fixdet r1 report | |
| 2 | + | |
| 3 | +VERDICT: FIXED — all 20 `gradients` gate sites now route through a seed-derived-colour helper, the determinism guard test is green, filter_intra went from 14/15 to 20/20, the free-partition gate's counts are now byte-stable run-to-run, and the full lib suite stays 232/0 (231 pre-existing + the new guard test). No gate now fails consistently; no decoder defect was uncovered by removing this nondeterminism. | |
| 4 | + | |
| 5 | +## What changed | |
| 6 | +`crates/ec-av1/src/stream.rs`: | |
| 7 | +- New `gradients_source(seed, width, height, tail) -> String` (right before | |
| 8 | + `libaom_encode`), hashing `seed` into four `0xRRGGBB` colours for | |
| 9 | + `c0..c3` with a plain integer mix (`wrapping_mul`/`rotate_left`), and | |
| 10 | + still passing `seed=` itself through in case a future ffmpeg honours it. | |
| 11 | + Doc comment states why: `gradients` ignores `seed=` for its own colour | |
| 12 | + choice, so an unset `c0..c9` stop is randomized from something else, | |
| 13 | + and pinning colours to fixed literals (as the 4 earliest gates already | |
| 14 | + did) would kill the per-attempt content variety the sweep gates need to | |
| 15 | + make features fire. | |
| 16 | +- New guard test `gradients_source_is_reproducible_per_seed`: renders raw | |
| 17 | + video for seed 42 twice and seed 43 once, asserts the two seed-42 runs | |
| 18 | + are byte-identical and seed-43 differs. This is the regression fence. | |
| 19 | +- All 20 `gradients=size=...` call sites (4 that hand-pinned | |
| 20 | + `c0=red:c1=blue:c2=green`, plus 16 that built the string with only | |
| 21 | + `seed=` and no colours at all) rewritten to call the helper, keeping | |
| 22 | + each site's original width/height/duration/rate exactly. Two of them | |
| 23 | + built the `-i` argument inline in a `Command::new("ffmpeg").args([...])` | |
| 24 | + array of `&str` literals; those became `.args([...]).arg(&source)` | |
| 25 | + since the helper returns an owned `String`. One (`a_real_libaom_stream_with_adst_decodes_end_to_end`) | |
| 26 | + held both fixtures in a `[(&str, ...); 2]` array; retyped to | |
| 27 | + `[(String, ...); 2]`. | |
| 28 | + | |
| 29 | +## Re-measurement | |
| 30 | + | |
| 31 | +### filter_intra gate — was 14/15, isolated | |
| 32 | +20 runs of `a_real_aomenc_filter_intra_stream_decodes_pixel_exact` in | |
| 33 | +isolation (`cargo test ... a_real_aomenc_filter_intra_stream_decodes_pixel_exact`), | |
| 34 | +each a fresh process: | |
| 35 | + | |
| 36 | + 20 passed / 0 failed out of 20 | |
| 37 | + | |
| 38 | +Every one of the 20 runs printed `test result: ok. 1 passed`. The ~1-in-15 | |
| 39 | +flake measured in the charter is gone. | |
| 40 | + | |
| 41 | +### free-partition gate — 3 runs, isolated | |
| 42 | +`a_real_aomenc_stream_with_free_partitions_decodes_pixel_exact`, 3 fresh | |
| 43 | +processes: | |
| 44 | + | |
| 45 | + run 1: 33 named refusals, 7 pixel-exact matches out of 40, rect_partition_hits=9 rect_coeff_hits=0 extended_partition_hits=0 partab_hits=2 | |
| 46 | + run 2: 33 named refusals, 7 pixel-exact matches out of 40, rect_partition_hits=9 rect_coeff_hits=0 extended_partition_hits=0 partab_hits=2 | |
| 47 | + run 3: 33 named refusals, 7 pixel-exact matches out of 40, rect_partition_hits=9 rect_coeff_hits=0 extended_partition_hits=0 partab_hits=2 | |
| 48 | + | |
| 49 | +Every field is now byte-identical across all 3 runs: refusal count, | |
| 50 | +match count, and every named hit counter. The gate's counts ARE stable | |
| 51 | +now — the fixture-side nondeterminism this lane targeted is closed for | |
| 52 | +this gate. | |
| 53 | + | |
| 54 | +One honest caveat: the same test, run as part of the full 232-test suite | |
| 55 | +(reported below) printed different numbers that same session | |
| 56 | +(`rect_partition_hits=18 ... partab_hits=4`, exactly double the isolated | |
| 57 | +run's counts, with the same 7/40 match rate and 33 named refusals). | |
| 58 | +That is consistent with the gate accumulating into a process-global | |
| 59 | +counter shared with another in-suite test on the same fixture family | |
| 60 | +(cross-test interference), not with residual fixture nondeterminism — | |
| 61 | +the isolated, filtered runs above (which exclude every other test) are | |
| 62 | +the correct measurement of THIS gate's own stability, and they are flat | |
| 63 | +across all 3. Flagging it rather than papering over it: `deferred: | |
| 64 | +double-counted rect_partition_hits/partab_hits when this gate runs | |
| 65 | +alongside its siblings in the full suite — likely a shared static | |
| 66 | +counter not scoped per-test — unblocked by grepping RECT_PARTITION_HITS/ | |
| 67 | +PARTAB_HITS for a missing per-test reset; not a fixdet-r1 scope item, | |
| 68 | +filed here as found, not investigated further this round.` | |
| 69 | + | |
| 70 | +### Full lib suite | |
| 71 | +`cargo test -p ec-av1 --release --lib` with `EC_AV1_REQUIRE_AOMENC=1`: | |
| 72 | + | |
| 73 | + test result: ok. 232 passed; 0 failed; 17 ignored; 0 measured; 0 filtered out; finished in 68.15s | |
| 74 | + | |
| 75 | +231 pre-existing + 1 new (`gradients_source_is_reproducible_per_seed`). | |
| 76 | +0 failures. No gate failed consistently in this run, so this lane did not | |
| 77 | +uncover a genuine decoder defect that the fixture nondeterminism had been | |
| 78 | +hiding — the report's "pin it with EC_AV1_GATE_DUMP and refuse by name" | |
| 79 | +branch does not apply this round. | |
| 80 | + | |
| 81 | +## Deferred | |
| 82 | +- `deferred: rect_partition_hits/partab_hits double-counted when the | |
| 83 | + free-partition gate runs inside the full suite vs isolated — cross-test | |
| 84 | + counter-sharing, not a fixture-determinism defect — unblocked by | |
| 85 | + auditing the counter's storage (static vs per-call) — accepted as | |
| 86 | + out-of-scope for fixdet-r1, no fix attempted this round.` | |
| 87 | + | |
| 88 | +## Files touched | |
| 89 | +- `crates/ec-av1/src/stream.rs` — `gradients_source` helper, guard test, | |
| 90 | + 20 call sites rewired. |