forge
Explore
Log in

Don't you dare go Hollow

merge current main; drop this lane's conversion of the three test files main already covers

Browse files at this commit

2711aa8467fba8ec1c81336ffd488e220816dd1aAhmet Kaan GümüşParent: fc5489faa976f1
The wave landed the same class fix for ec-h264 conformance, ec-opus
conformance and ec-flac xiph_vectors in its own require_fixtures shape. Keeping
both would be two conventions in one file and a 1054-line diff in a
preflight lane, so this branch now carries main's version of those three files
verbatim and keeps only the crates the wave did not touch.

65 changed files +12519 -1464

.gitignoremodified+10 -0
@@ -1,5 +1,15 @@
11 target/
22 fixtures
3+# ...but the per-crate PINS are tracked on purpose: 48 files under
4+# crates/ec-av1/fixtures/*.obu are committed fixtures (captured streams with a
5+# recorded sha256/recipe in their gate's doc comment) and they must travel
6+# with the repo. A bare `fixtures` rule ignores them at EVERY depth, so they
7+# are only in history because someone used `git add -f` -- and a new pin then
8+# fails a plain `git add` with a hint that reads like noise. Measured
9+# 2026-09-29. Negate the crate-level pins (not the root fixtures/ dir, which
10+# stays untracked at 1.7 GB).
11+!crates/*/fixtures/
12+!crates/*/fixtures/**
313 __pycache__/
414 scripts/aac-tables/sbr-cache.json
515 .cache/
crates/ec-aac/tests/obs_real_content.rsmodified+70 -16
@@ -28,11 +28,23 @@ fn ffmpeg_decode(path: &Path, channels: usize) -> Vec<Vec<f32>> {
2828 .args(["-v", "error", "-i"])
2929 .arg(path)
3030 .args([
31- "-map", "0:a:0", "-t", "10", "-f", "f32le", "-acodec", "pcm_f32le", "-",
31+ "-map",
32+ "0:a:0",
33+ "-t",
34+ "10",
35+ "-f",
36+ "f32le",
37+ "-acodec",
38+ "pcm_f32le",
39+ "-",
3240 ])
3341 .output()
3442 .expect("ffmpeg runs");
35- assert!(out.status.success(), "{}", String::from_utf8_lossy(&out.stderr));
43+ assert!(
44+ out.status.success(),
45+ "{}",
46+ String::from_utf8_lossy(&out.stderr)
47+ );
3648 let samples: Vec<f32> = out
3749 .stdout
3850 .chunks_exact(4)
@@ -48,7 +60,10 @@ fn ffmpeg_decode(path: &Path, channels: usize) -> Vec<Vec<f32>> {
4860 fn extract_aac_track(path: &Path) -> Option<(Vec<u8>, Vec<Vec<u8>>)> {
4961 let f = File::open(path).ok()?;
5062 let mut d = Mp4Demuxer::new(BufReader::new(f)).ok()?;
51- let aac = d.streams().iter().find(|s| s.params.codec == CodecId::Aac)?;
63+ let aac = d
64+ .streams()
65+ .iter()
66+ .find(|s| s.params.codec == CodecId::Aac)?;
5267 let idx = aac.index;
5368 let asc = aac.params.extradata.as_ref()?.to_vec();
5469 let mut aus = Vec::new();
@@ -90,11 +105,18 @@ fn our_decode(path: &Path) -> Option<Vec<Vec<f32>>> {
90105 }
91106 }
92107 eprintln!(" {failed}/{} AUs failed", aus.len());
93- if planes.is_empty() { None } else { Some(planes) }
108+ if planes.is_empty() {
109+ None
110+ } else {
111+ Some(planes)
112+ }
94113 }
95114
96115 fn dot(a: &[f32], b: &[f32]) -> f64 {
97- a.iter().zip(b).map(|(x, y)| f64::from(*x) * f64::from(*y)).sum()
116+ a.iter()
117+ .zip(b)
118+ .map(|(x, y)| f64::from(*x) * f64::from(*y))
119+ .sum()
98120 }
99121
100122 fn correlation(a: &[f32], b: &[f32]) -> f64 {
@@ -114,14 +136,28 @@ fn correlation(a: &[f32], b: &[f32]) -> f64 {
114136
115137 fn best_lag_correlation(ours: &[f32], theirs: &[f32]) -> (i64, f64) {
116138 const COARSE: usize = 4_096;
117- let start = ours.len().min(theirs.len()).saturating_sub(WINDOW).min(ours.len() / 4);
139+ let start = ours
140+ .len()
141+ .min(theirs.len())
142+ .saturating_sub(WINDOW)
143+ .min(ours.len() / 4);
118144 let slice_at = |lag: i64, len: usize| -> Option<(usize, usize)> {
119- let (oa, ob) = if lag >= 0 { (start, start + lag as usize) } else { (start + (-lag) as usize, start) };
120- if oa + len > ours.len() || ob + len > theirs.len() { None } else { Some((oa, ob)) }
145+ let (oa, ob) = if lag >= 0 {
146+ (start, start + lag as usize)
147+ } else {
148+ (start + (-lag) as usize, start)
149+ };
150+ if oa + len > ours.len() || ob + len > theirs.len() {
151+ None
152+ } else {
153+ Some((oa, ob))
154+ }
121155 };
122156 let mut coarse_best = (0i64, -1.0f64, 0.0f64);
123157 for lag in -(LAG_MAX as i64)..=(LAG_MAX as i64) {
124- let Some((oa, ob)) = slice_at(lag, COARSE) else { continue };
158+ let Some((oa, ob)) = slice_at(lag, COARSE) else {
159+ continue;
160+ };
125161 let c = correlation(&ours[oa..oa + COARSE], &theirs[ob..ob + COARSE]);
126162 if c.abs() > coarse_best.1 {
127163 coarse_best = (lag, c.abs(), c);
@@ -129,7 +165,9 @@ fn best_lag_correlation(ours: &[f32], theirs: &[f32]) -> (i64, f64) {
129165 }
130166 let mut best = (coarse_best.0, -1.0f64, 0.0f64);
131167 for lag in (coarse_best.0 - 8)..=(coarse_best.0 + 8) {
132- let Some((oa, ob)) = slice_at(lag, WINDOW) else { continue };
168+ let Some((oa, ob)) = slice_at(lag, WINDOW) else {
169+ continue;
170+ };
133171 let c = correlation(&ours[oa..oa + WINDOW], &theirs[ob..ob + WINDOW]);
134172 if c.abs() > best.1 {
135173 best = (lag, c.abs(), c);
@@ -148,7 +186,13 @@ fn obs_content_table() {
148186 eprintln!("skip: no ffmpeg");
149187 return;
150188 }
151- let dir = PathBuf::from(std::env::var("HOME").unwrap()).join("Videos/OBS");
189+ // lane-h264reallib: `unwrap_or_default()` rather than a bare `unwrap()`.
190+ // A host with no HOME -- a fleet runner -- panicked here before reaching
191+ // the `read_dir` guard one line down, which already reports an absent
192+ // directory correctly. With an empty HOME the guard simply reports
193+ // `skip: no ./Videos/OBS`, so the test degrades to the silent skip its
194+ // own guard was written for instead of a red that says nothing about AAC.
195+ let dir = PathBuf::from(std::env::var("HOME").unwrap_or_default()).join("Videos/OBS");
152196 let Ok(rd) = std::fs::read_dir(&dir) else {
153197 eprintln!("skip: no {}", dir.display());
154198 return;
@@ -188,11 +232,21 @@ fn obs_content_table() {
188232 let rows = &all_rows[before..];
189233 let (mut pns, mut is_, mut ms, mut tns, mut cpe) = (0usize, 0usize, 0usize, 0usize, 0usize);
190234 for r in rows {
191- if r.pns_bands > 0 { pns += 1; }
192- if r.is_bands > 0 { is_ += 1; }
193- if r.ms_bands > 0 { ms += 1; }
194- if r.tns_present { tns += 1; }
195- if r.is_cpe { cpe += 1; }
235+ if r.pns_bands > 0 {
236+ pns += 1;
237+ }
238+ if r.is_bands > 0 {
239+ is_ += 1;
240+ }
241+ if r.ms_bands > 0 {
242+ ms += 1;
243+ }
244+ if r.tns_present {
245+ tns += 1;
246+ }
247+ if r.is_cpe {
248+ cpe += 1;
249+ }
196250 }
197251 eprintln!(
198252 " tools over {} AUs: cpe={cpe} pns_aus={pns} is_aus={is_} ms_aus={ms} tns_aus={tns}",
crates/ec-aac/tests/oracle.rsmodified+10 -0
@@ -696,6 +696,16 @@ fn esds_asc(mp4: &[u8]) -> Option<Vec<u8>> {
696696
697697 /// AAC tracks from the machine's own library, not just generated fixtures: the
698698 /// elementary stream is copied out to ADTS and decoded both ways.
699+// lane-h264reallib: same shape as the ec-h264 `real_library_streams_match_ffmpeg`
700+// fix, same reason. The manifest is generated by `scripts/scan-real-library.sh`
701+// from `~/Videos ~/Downloads ~/Music` and is gitignored because it is
702+// machine-local. The guard below makes a host with NO manifest print green
703+// (nothing was checked), and a host that ran the scan but has since moved or
704+// deleted files falls through to `checked >= 3` and goes red for a reason that
705+// has nothing to do with the decoder. An ignore is visible in `--list` and
706+// cannot go green silently, which an env gate would.
707+// Run on the workstation: cargo test -p ec-aac --test oracle real_library_tracks_match_ffmpeg -- --ignored
708+#[ignore = "sweeps the PERSONAL media library (~/Videos, ~/Downloads, ~/Music) through the gitignored fixtures/real-library-manifest.tsv and asserts >= 3 tracks swept; a runner host has no such library, so it is either a silent green or a red for the wrong reason. Run it on the workstation with --ignored."]
699709 #[test]
700710 fn real_library_tracks_match_ffmpeg() {
701711 if !have_ffmpeg() {
crates/ec-aac/tests/sbr_real_library.rsmodified+7 -1
@@ -4957,7 +4957,13 @@ fn sbr_residual_locator() {
49574957 if !have_ffmpeg() {
49584958 return;
49594959 }
4960- let home = std::env::var("HOME").unwrap();
4960+ // lane-h264reallib: `unwrap_or_default()`, the shape this file's five
4961+ // other HOME reads already use (:2710, :3426, :4109, :4182, :4575). A bare
4962+ // `unwrap()` panicked on any host with no HOME -- a fleet runner -- which
4963+ // is a red with no bearing on the decoder. The `path.exists()` guard below
4964+ // already handles the absent-file case, so an empty HOME just makes the
4965+ // fallback path relative-and-nonexistent and the test returns.
4966+ let home = std::env::var("HOME").unwrap_or_default();
49614967 // `EC_AAC_SBR_LOCATOR_FILE` points the same instrument at any other
49624968 // HE-AAC file (e.g. a mono, uncoupled, noise-only probe encode).
49634969 let path = std::env::var("EC_AAC_SBR_LOCATOR_FILE")
crates/ec-av1/examples/decode_probe.rsmodified+6 -0
@@ -271,6 +271,12 @@ fn main() {
271271 // lane-thread2: proof the frame-parallel path actually fired (0 at
272272 // the default EC_AV1_THREADS=1).
273273 println!("frames_dispatched: {}", ec_av1::stream::frames_dispatched());
274+ // lane-av1recipehunt: `intra_rect4_in_inter` above already reports the
275+ // 1:4-in-inter shapes; this is the `delta_q` half of the same story --
276+ // how many delta_q groups the stream really carried, and how many of
277+ // them landed inside a rect64 dequant.
278+ let (dq, dq_drift) = ec_av1::stream::rect64_qidx_drift_counters();
279+ println!("delta_q: groups_read={dq} rect64_qidx_drift={dq_drift}");
274280 };
275281 // lane-tiles: the tiling a real stream actually uses is a decision input
276282 // (every gate in `stream.rs` picks its own `--tile-columns`), so report it
crates/ec-av1/examples/dump_yuv.rsmodified+176 -20
@@ -1,20 +1,68 @@
1-//! Decode one OBU stream and write every frame's planes as raw little-endian
2-//! `u16` (`<out-prefix>.f<N>.yuv`) — the high-bit-depth companion to
3-//! `EC_AV1_PREFILT_DUMP`, whose `as u8` narrowing throws away exactly the bits
4-//! a 10-bit mismatch lives in (lane-rect1d r1 found its defect by diffing this
5-//! against `ffmpeg -pix_fmt yuv420p10le -f rawvideo`).
1+//! Decode one OBU stream and write every frame's planes as raw planar video
2+//! (`<out-prefix>.f<N>.yuv`), at the sample depth **the stream's own sequence
3+//! header carries**: 8-bit as one byte per sample, 10/12-bit as little-endian
4+//! `u16`. That is the layout `ffmpeg -pix_fmt yuv420p{,10,12}le -f rawvideo`
5+//! and `aomdec --rawvideo` write, so a byte-exact `cmp` against either is
6+//! meaningful.
7+//!
8+//! It is the high-bit-depth companion to `EC_AV1_PREFILT_DUMP`, whose `as u8`
9+//! narrowing throws away exactly the bits a 10-bit mismatch lives in
10+//! (lane-rect1d r1 found its defect by diffing this against
11+//! `ffmpeg -pix_fmt yuv420p10le -f rawvideo`).
612 //!
713 //! ```text
814 //! cargo run -p ec-av1 --example dump_yuv -- s.obu /tmp/ours
915 //! ffmpeg -v error -i s.obu -pix_fmt yuv420p10le -f rawvideo /tmp/ref.yuv
1016 //! cmp /tmp/ours.f0.yuv /tmp/ref.yuv
1117 //! ```
18+//!
19+//! The depth is NEVER taken from the file name, the output extension, or the
20+//! `-pix_fmt` of a reference tool: it is parsed out of the sequence header
21+//! (spec 5.5.2 `color_config.bit_depth`) before a single byte is written. The
22+//! old version packed every sample as `u16` unconditionally, so pointing it at
23+//! an 8-bit stream silently produced a file TWICE the size of the oracle's,
24+//! and the size mismatch read like a decoder bug. `--depth N` is accepted for
25+//! the case where you already know what the stream is, and is ASSERTED against
26+//! the parsed header: a mismatch names both depths and the consequence it
27+//! would have caused, and writes nothing.
28+//!
29+//! `i` in `<out-prefix>.f<i>.yuv` indexes `decode_stream`'s output, which is
30+//! DISPLAY order and SHOWN frames only -- hidden alt-refs are never emitted.
31+//! Every other `.f{N}` in this crate (EC_AV1_FINAL_DUMP,
32+//! EC_AV1_DECODE_ORDER_DUMP, EC_AV1_PREFILT_DUMP) uses a DECODE index, so this
33+//! file does NOT line up with an aomdec dump past frame 0 on a stream with
34+//! altref. Compare against ffmpeg rawvideo, or against aomdec via
35+//! `decode_all_frames_vs_oracle`.
1236 fn main() {
13- let mut args = std::env::args().skip(1);
14- let (Some(path), Some(out)) = (args.next(), args.next()) else {
15- eprintln!("usage: dump_yuv <stream.obu> <out-prefix>");
37+ let argv: Vec<String> = std::env::args().skip(1).collect();
38+ let (Some(path), Some(out)) = (argv.first().cloned(), argv.get(1).cloned()) else {
39+ eprintln!("usage: dump_yuv <stream.obu> <out-prefix> [--depth 8|10|12]");
1640 std::process::exit(2);
1741 };
42+ // An ASSERTED expectation, not a switch: the packing always follows the
43+ // parsed header, and a wrong `--depth` is a hard error before any file.
44+ let mut claimed_depth: Option<u8> = None;
45+ let mut rest = argv[2.min(argv.len())..].iter();
46+ while let Some(arg) = rest.next() {
47+ let value = arg
48+ .strip_prefix("--depth=")
49+ .map(str::to_string)
50+ .or_else(|| (arg == "--depth").then(|| rest.next().cloned()).flatten());
51+ let Some(value) = value else {
52+ eprintln!("dump_yuv: unknown argument `{arg}`");
53+ eprintln!("usage: dump_yuv <stream.obu> <out-prefix> [--depth 8|10|12]");
54+ std::process::exit(2);
55+ };
56+ let Ok(depth) = value.parse::<u8>() else {
57+ eprintln!("dump_yuv: --depth `{value}` is not a bit depth (8, 10 or 12)");
58+ std::process::exit(2);
59+ };
60+ if claimed_depth.is_some() {
61+ eprintln!("dump_yuv: --depth given twice; the depth is asserted, not a switch");
62+ std::process::exit(2);
63+ }
64+ claimed_depth = Some(depth);
65+ }
1866 let data = match std::fs::read(&path) {
1967 Ok(data) => data,
2068 Err(e) => {
@@ -22,6 +70,87 @@ fn main() {
2270 std::process::exit(2);
2371 }
2472 };
73+
74+ // The stream's OWN header, read before the decode so a depth mismatch is
75+ // reported instead of a file. Scans OBU by OBU because the sequence header
76+ // need not be the first OBU (decode_probe walks it the same way).
77+ let mut parser = ec_av1_syntax::Av1Parser::new();
78+ let mut pos = 0usize;
79+ while pos < data.len() && parser.sequence_header().is_none() {
80+ let Ok(obu) = parser.parse_obu(&data[pos..]) else {
81+ break;
82+ };
83+ pos += obu.total_size.max(1);
84+ }
85+ let Some(seq) = parser.sequence_header() else {
86+ eprintln!(
87+ "dump_yuv: {path}: no sequence header parsed, so the sample depth is unknown. \
88+ Refusing to guess: packing u16 blind is what wrote a 2x-size file for every 8-bit \
89+ stream. Re-checkout the stream (an IVF container parses as zero frames too), or pass \
90+ a raw OBU stream."
91+ );
92+ std::process::exit(1);
93+ };
94+ let cfg = &seq.color_config;
95+ let bit_depth = cfg.bit_depth;
96+ if let Some(claimed) = claimed_depth {
97+ if claimed != bit_depth {
98+ let theirs = if bit_depth == 8 {
99+ format!(
100+ "aomdec --rawvideo / ffmpeg -pix_fmt yuv420p ({} bytes per sample, \
101+ W*H*3/2 for 4:2:0)",
102+ 1
103+ )
104+ } else {
105+ format!(
106+ "aomdec --rawvideo / ffmpeg -pix_fmt yuv420p{}le ({} bytes per sample, \
107+ W*H*3 for 4:2:0)",
108+ bit_depth, 2
109+ )
110+ };
111+ eprintln!(
112+ "dump_yuv: {path}: --depth {claimed} contradicts the stream's own sequence \
113+ header, which carries bit_depth {bit_depth} (seq_profile {}, \
114+ subsampling {}/{}, mono_chrome {}). Writing {claimed}-bit would emit \
115+ {} bytes per sample against the oracle's {theirs}, so every `cmp` would fail on \
116+ size alone and read like a decoder defect. Nothing was written.",
117+ seq.seq_profile,
118+ cfg.subsampling_x,
119+ cfg.subsampling_y,
120+ cfg.mono_chrome,
121+ if claimed == 8 { 1 } else { 2 },
122+ );
123+ std::process::exit(1);
124+ }
125+ }
126+ // 8 bit -> one byte per sample; anything above -> little-endian u16, which
127+ // is what both oracles emit for `*p10le` / `*p12le` (they never pack to
128+ // the bit depth itself, they use a full 16-bit container).
129+ let bytes_per_sample = if bit_depth == 8 { 1 } else { 2 };
130+ // Spec 5.5.3 `subsampling_{x,y}`: 1/1 IS 4:2:0 (measured on this crate's own
131+ // 8-bit 192x128 fixture, which parses 1/1 and yields 36864 samples for a
132+ // 192x128 frame = W*H*3/2), 0/0 is 4:4:4, 1/0 is 4:2:2, 0/1 is 4:4:0.
133+ let chroma = match (cfg.mono_chrome, cfg.subsampling_x, cfg.subsampling_y) {
134+ (true, _, _) => "gray",
135+ (false, 0, 0) => "yuv444p",
136+ (false, 0, 1) => "yuv440p",
137+ (false, 1, 0) => "yuv422p",
138+ _ => "yuv420p",
139+ };
140+ let pix_fmt = match (chroma, bit_depth) {
141+ (c, 8) => c.to_string(),
142+ ("gray", _) => "gray16le".to_string(),
143+ (c, 10) => format!("{c}10le"),
144+ (c, 12) => format!("{c}12le"),
145+ (c, d) => format!("{c}{d}le"),
146+ };
147+ let max = (1u32 << bit_depth) - 1;
148+ println!(
149+ "sequence header: bit_depth {bit_depth} -> {bytes_per_sample} byte(s) per sample, \
150+ seq_profile {}, subsampling {}/{}, mono_chrome {}; ffmpeg -pix_fmt {pix_fmt}",
151+ seq.seq_profile, cfg.subsampling_x, cfg.subsampling_y, cfg.mono_chrome,
152+ );
153+
25154 let frames = match ec_av1::stream::decode_stream(&data) {
26155 Ok(frames) => frames,
27156 Err(e) => {
@@ -30,24 +159,51 @@ fn main() {
30159 }
31160 };
32161 for (i, f) in frames.iter().enumerate() {
33- let mut buf = Vec::with_capacity((f.y.len() + f.u.len() + f.v.len()) * 2);
34- for plane in [&f.y, &f.u, &f.v] {
35- for &s in plane.iter() {
36- buf.extend_from_slice(&s.to_le_bytes());
162+ let planes: &[&Vec<u16>] = if cfg.mono_chrome {
163+ &[&f.y]
164+ } else {
165+ &[&f.y, &f.u, &f.v]
166+ };
167+ // The OTHER half of the depth contract: samples that do not fit the
168+ // container we are about to write. A `s as u8` on a 10-bit plane (or a
169+ // u16 on a depth we packed narrow) is exactly the bit loss this tool
170+ // exists to rule out, so it is an error, not a truncation.
171+ if let Some((plane_name, sample)) = [("Y", &f.y), ("U", &f.u), ("V", &f.v)]
172+ .into_iter()
173+ .take(if cfg.mono_chrome { 1 } else { 3 })
174+ .find_map(|(name, plane)| plane.iter().max().map(|&s| (name, s)))
175+ {
176+ if u32::from(sample) > max {
177+ eprintln!(
178+ "dump_yuv: {path}: frame {i} plane {plane_name} carries sample {sample} above \
179+ the {bit_depth}-bit maximum {max} -- the decoded output does not match the \
180+ sequence header it was decoded under, and packing it would silently drop the \
181+ high bits. Nothing was written."
182+ );
183+ std::process::exit(1);
184+ }
185+ }
186+ let samples: usize = planes.iter().map(|p| p.len()).sum();
187+ let mut buf = Vec::with_capacity(samples * bytes_per_sample);
188+ for plane in planes {
189+ if bytes_per_sample == 1 {
190+ buf.extend(plane.iter().map(|&s| s as u8));
191+ } else {
192+ for &s in plane.iter() {
193+ buf.extend_from_slice(&s.to_le_bytes());
194+ }
37195 }
38196 }
39- // `i` indexes `decode_stream`'s output, which is DISPLAY order and
40- // SHOWN frames only -- hidden alt-refs are never emitted. Every other
41- // `.f{N}` in this crate (EC_AV1_FINAL_DUMP, EC_AV1_DECODE_ORDER_DUMP,
42- // EC_AV1_PREFILT_DUMP) uses a DECODE index, so this file does NOT line
43- // up with an aomdec dump past frame 0 on a stream with altref. Compare
44- // against ffmpeg rawvideo, or against aomdec via
45- // `decode_all_frames_vs_oracle`.
46197 let name = format!("{out}.f{i}.yuv");
47198 if let Err(e) = std::fs::write(&name, &buf) {
48199 eprintln!("{name}: {e}");
49200 std::process::exit(2);
50201 }
51- println!("frame {i}: {}x{} -> {name}", f.width, f.height);
202+ println!(
203+ "frame {i}: {}x{} -> {name} ({samples} samples, {} bytes, {pix_fmt})",
204+ f.width,
205+ f.height,
206+ buf.len(),
207+ );
52208 }
53209 }
crates/ec-av1/examples/enc_probe.rsmodified+12 -4
@@ -20,9 +20,10 @@ fn main() {
2020 true => (0, 0),
2121 false => (a[1].parse().unwrap(), a[2].parse().unwrap()),
2222 };
23- let qs: Vec<u8> = a
24- .get(4)
25- .map_or_else(|| vec![150, 120, 90, 60], |s| s.split(',').map(|q| q.parse().unwrap()).collect());
23+ let qs: Vec<u8> = a.get(4).map_or_else(
24+ || vec![150, 120, 90, 60],
25+ |s| s.split(',').map(|q| q.parse().unwrap()).collect(),
26+ );
2627
2728 // lane-census/lane-probe: the BD gate's native rows CROP (`EC_ENC_VF`) and
2829 // SEEK (`EC_ENC_SS`) -- without the seek this probe read film B's black
@@ -71,7 +72,10 @@ fn main() {
7172 .join(" ")
7273 };
7374 println!(" census luma SAD rank of RD winner: {}", pct(&luma_rank));
74- println!(" census chroma SAD rank of RD winner: {}", pct(&chroma_rank));
75+ println!(
76+ " census chroma SAD rank of RD winner: {}",
77+ pct(&chroma_rank)
78+ );
7579 }
7680 // lane-arfmode: the engagement counter of the top ARF's offer-set
7781 // lever, taken once per point so an armed run PRINTS a non-zero count
@@ -80,6 +84,10 @@ fn main() {
8084 // control's own expectation.
8185 let hits = ec_av1::encode::take_arfmode_hits();
8286 println!(" arfmode hits: {} {} {}", hits[0], hits[1], hits[2]);
87+ // lane-av1recipehunt: the gate's own precondition number -- how many
88+ // blocks this point's search picked a DRL index the write-time stack
89+ // could not carry.
90+ println!(" drl_clamp: {}", ec_av1::tile::drl_clamp_hits());
8391 }
8492 println!("wall {:.3}s", start.elapsed().as_secs_f64());
8593 }
crates/ec-av1/fixtures/444_lossy_rect4_odd_130x122.obuadded+0 -0

Binary file changed

crates/ec-av1/fixtures/444_lossy_rect4_wide_256x128.obuadded+0 -0

Binary file changed

crates/ec-av1/fixtures/444_lossy_superres_256x128_d12.obuadded+0 -0

Binary file changed

crates/ec-av1/fixtures/444_lossy_superres_256x128_d12_10bit.obuadded+0 -0

Binary file changed

crates/ec-av1/fixtures/444_lossy_superres_256x128_d12_12bit.obuadded+0 -0

Binary file changed

crates/ec-av1/fixtures/444_lossy_superres_256x128_d9.obuadded+0 -0

Binary file changed

crates/ec-av1/fixtures/444_lossy_superres_256x128_d9_12bit.obuadded+0 -0

Binary file changed

crates/ec-av1/fixtures/444_lossy_superres_mode2_256x128.obuadded+0 -0

Binary file changed

crates/ec-av1/fixtures/444_lossy_superres_mode2_256x128_10bit.obuadded+0 -0

Binary file changed

crates/ec-av1/fixtures/444_lossy_superres_mode2_256x128_12bit.obuadded+0 -0

Binary file changed

crates/ec-av1/fixtures/444_rect_strip_leaf_tx_type.obuadded+0 -0

Binary file changed

crates/ec-av1/fixtures/golden3-pin.obuadded+0 -0

Binary file changed

crates/ec-av1/fixtures/intra14_256x192_10bit.obuadded+0 -0

Binary file changed

crates/ec-av1/fixtures/intra14_256x192_8bit.obuadded+0 -0

Binary file changed

crates/ec-av1/fixtures/ll444-lossless-key.obuadded+0 -0

Binary file changed

crates/ec-av1/fixtures/ll444_sb64_1to4_lossless.obuadded+0 -0

Binary file changed

crates/ec-av1/fixtures/rect64_dq_drift.obuadded+0 -0

Binary file changed

crates/ec-av1/fixtures/sbpart-pin.obuadded+0 -0

Binary file changed

crates/ec-av1/src/decode.rsmodified+671 -79
@@ -2275,6 +2275,119 @@ pub(crate) fn rect_class1_hits() -> usize {
22752275 RECT_CLASS1_HITS.with(|c| c.get())
22762276 }
22772277
2278+// lane-av1readcensus: the PER-UNIT coefficient census -- one unit counted
2279+// per `read_coeffs`/`read_coeffs_rect` call, i.e. per object this decoder
2280+// actually walks, which is the unit the round-4 `av1444rect` count measured
2281+// (636 square chroma reads against the oracle's 1086). The counters are
2282+// 4:4:4-ONLY (`CENSUS_444`, set per frame beside `set_subsampling`), so a
2283+// 4:2:0 control reads `(0, 0, 0)` -- a walk-shape change at 4:2:0 is another
2284+// lane's business, and this census must not fire there.
2285+thread_local! {
2286+ /// Per-plane unit counts, `[luma, u, v]`, at 4:4:4 only.
2287+ static CENSUS_444_UNITS: std::cell::Cell<[usize; 3]> = const { std::cell::Cell::new([0; 3]) };
2288+ /// Of [`CENSUS_444_UNITS`], the units that coded at least one coefficient
2289+ /// (`txb_skip == 0`) -- the per-plane split is only comparable against
2290+ /// the oracle's when both sides count all-zero units the same way.
2291+ static CENSUS_444_CODED: std::cell::Cell<[usize; 3]> = const { std::cell::Cell::new([0; 3]) };
2292+ /// Sequential unit index, so a trace line names its own position in the
2293+ /// frame's walk rather than relying on line order alone.
2294+ static CENSUS_UNIT_N: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
2295+ /// The plane the units read from here on belong to. A thread-local rather
2296+ /// than a `read_coeffs` parameter because the three luma call sites
2297+ /// (`decode_rect_split`, `decode_block_rect64`, `read_inter_plane_rect`)
2298+ /// are not this lane's to edit and would each grow an argument; the
2299+ /// plane-owning readers stamp it once on entry instead.
2300+ static CENSUS_PLANE: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
2301+ /// 4:4:4 (`subsampling_x == 0 && subsampling_y == 0`) for the frame being
2302+ /// decoded, set per frame from [`crate::stream`].
2303+ static CENSUS_444: std::cell::Cell<bool> = const { std::cell::Cell::new(false) };
2304+}
2305+
2306+/// Current `[luma, u, v]` 4:4:4 coefficient-unit counts.
2307+#[allow(dead_code)] // read only from the `#[cfg(test)]` gates
2308+pub(crate) fn census_444_units() -> [usize; 3] {
2309+ CENSUS_444_UNITS.with(|c| c.get())
2310+}
2311+
2312+/// Current `[luma, u, v]` 4:4:4 counts of units that coded coefficients.
2313+#[allow(dead_code)] // read only from the `#[cfg(test)]` gates
2314+pub(crate) fn census_444_coded() -> [usize; 3] {
2315+ CENSUS_444_CODED.with(|c| c.get())
2316+}
2317+
2318+/// lane-av1readcensus: arms the 4:4:4 census for the frame about to decode,
2319+/// called once per frame from [`crate::stream`]'s decode loop beside
2320+/// [`set_subsampling`]. At 4:2:0 (or 4:2:2) every census counter stays zero --
2321+/// the walk-shape question this census answers is a 4:4:4 one.
2322+pub(crate) fn set_census_444(ss_x: u8, ss_y: u8) {
2323+ CENSUS_444.with(|c| c.set(ss_x == 0 && ss_y == 0));
2324+}
2325+
2326+/// lane-av1readcensus: the plane the units read from here on belong to,
2327+/// stamped by the plane-owning readers ([`read_plane`], [`read_inter_plane`],
2328+/// [`read_inter_plane_rect`]) on entry.
2329+pub(crate) fn set_census_plane(plane: usize) {
2330+ CENSUS_PLANE.with(|c| c.set(plane));
2331+}
2332+
2333+/// lane-av1readcensus: is the per-unit census trace on? Shares
2334+/// [`coeff_trace_on`]'s per-frame narrowing so one frame's walk can be
2335+/// dumped without the rest of the stream.
2336+fn census_trace_on() -> bool {
2337+ if !crate::envflags::env_flag!("EC_CENSUS_UNIT") {
2338+ return false;
2339+ }
2340+ match COEFF_TRACE_FRAME.with(|c| c.get()) {
2341+ None => true,
2342+ Some(w) if w >= usize::MAX - 1 => true,
2343+ Some(w) => COEFF_TRACE_CUR.with(|c| c.get()) == w,
2344+ }
2345+}
2346+
2347+/// lane-av1readcensus: one line per coefficient unit this decoder walks, the
2348+/// twin of the oracle's `EC_COEFF` / `EC_COEFF_VAL` bracket around each
2349+/// `av1_read_coeffs_txb` call. Pair the two sides by `post_rng` (or by `n`),
2350+/// never by plane label or by walk position -- the walk order is exactly what
2351+/// the census is measuring.
2352+fn census_unit(
2353+ w: usize,
2354+ h: usize,
2355+ tx_type: TxType,
2356+ eob: usize,
2357+ all_zero: bool,
2358+ entry_rng: u32,
2359+ dec: &SymbolDecoder,
2360+) {
2361+ let plane = CENSUS_PLANE.with(|c| c.get()).min(2);
2362+ let coded = usize::from(!all_zero);
2363+ CENSUS_UNIT_N.with(|c| c.set(c.get() + 1));
2364+ hit_do! {
2365+ CENSUS_444_UNITS.with(|c| {
2366+ if CENSUS_444.with(|on| on.get()) {
2367+ let mut v = c.get();
2368+ v[plane] += 1;
2369+ c.set(v);
2370+ }
2371+ });
2372+ CENSUS_444_CODED.with(|c| {
2373+ if CENSUS_444.with(|on| on.get()) {
2374+ let mut v = c.get();
2375+ v[plane] += coded;
2376+ c.set(v);
2377+ }
2378+ });
2379+ }
2380+ if !census_trace_on() {
2381+ return;
2382+ }
2383+ let n = CENSUS_UNIT_N.with(|c| c.get()) - 1;
2384+ let post_rng = dec.debug_state().0;
2385+ eprintln!(
2386+ "EC_CENSUS_UNIT side=ours n={n} plane={plane} w={w} h={h} tx={tx_type:?} eob={eob} \
2387+ all_zero={all_zero} entry_rng={entry_rng} post_rng={post_rng}"
2388+ );
2389+}
2390+
22782391 // As [`FILTER_INTRA_RECT_HITS`], counting only the strips BELOW 16x16
22792392 // (8x16/16x8 leaves of a 16x16 HORZ/VERT partition, lane-fistrip r1) -- the
22802393 // shapes whose `use_filter_intra` symbol had no CDF class before this round.
@@ -2777,6 +2890,30 @@ pub(crate) fn lossless_wht_units() -> usize {
27772890 LOSSLESS_WHT_UNITS.load(std::sync::atomic::Ordering::Relaxed)
27782891 }
27792892
2893+/// lane-whtshape: 4x4 Walsh-Hadamard units reconstructed as part of a LOSSLESS
2894+/// transform unit that was itself NOT 4x4 -- a shape libaom cannot code.
2895+/// `read_tx_mode` (`av1/decoder/decodeframe.c:140`) returns `ONLY_4X4` for a
2896+/// `coded_lossless` frame before it looks at the `tx_mode` symbol,
2897+/// `read_tx_size` (`:1117`) returns `TX_4X4` before it looks at a tree,
2898+/// `get_vartx_max_txsize` (`av1/common/blockd.h:1447`) returns `TX_4X4` for
2899+/// EVERY plane of a lossless block, and of `av1/common/idct.c`'s
2900+/// `highbd_inv_txfm_add_*_c` only `highbd_inv_txfm_add_4x4_c` carries a
2901+/// `lossless` branch -- every other size falls through to the IDCT, because
2902+/// there is no non-4x4 lossless inverse transform to dispatch to. So one of
2903+/// these is a CALLER sizing a lossless unit wrongly, not a bitstream shape;
2904+/// read as a before/after delta around one decode it names the caller. Must
2905+/// read 0 on a stream whose lossless unit geometry is right. Atomic: the
2906+/// wavefront workers run the transform on their own threads.
2907+static LOSSLESS_WHT_SPLIT_UNITS: std::sync::atomic::AtomicUsize =
2908+ std::sync::atomic::AtomicUsize::new(0);
2909+
2910+/// [`LOSSLESS_WHT_SPLIT_UNITS`] -- total over the process, read as a
2911+/// before/after delta around one decode.
2912+#[allow(dead_code)] // read only from the `#[cfg(test)]` gates
2913+pub(crate) fn lossless_wht_split_units() -> usize {
2914+ LOSSLESS_WHT_SPLIT_UNITS.load(std::sync::atomic::Ordering::Relaxed)
2915+}
2916+
27802917 impl TxParams {
27812918 /// The one copy of the produce-the-residual code: the inline path calls it
27822919 /// on the parse thread, the wavefront worker calls it on its own, so both
@@ -2784,10 +2921,34 @@ impl TxParams {
27842921 fn run(self, grid: &[i32]) -> Vec<i32> {
27852922 let residual = if self.lossless {
27862923 LOSSLESS_WHT_UNITS.fetch_add(1, std::sync::atomic::Ordering::Relaxed);
2787- debug_assert_eq!((self.w, self.h), (4, 4));
2788- debug_assert_eq!(self.tx_type, TxType::DctDct);
2789- crate::transform::dequant_and_inverse_wht4x4(
2924+ // lane-whtshape: a non-4x4 unit here is this decoder's own
2925+ // transform-unit geometry being wrong (see
2926+ // [`LOSSLESS_WHT_SPLIT_UNITS`] for the libaom evidence). It used
2927+ // to be stopped by a `debug_assert_eq!` that RELEASE never ran:
2928+ // the 4x4 WHT returned 16 values for a `w * h` block and the
2929+ // release build died one frame later in the strided copy with an
2930+ // opaque `range end index 8 out of range for slice of length 0`
2931+ // that never named lossless or the transform. Counted, and
2932+ // reconstructed as the raster of 4x4 WHT units
2933+ // ([`crate::transform::dequant_and_inverse_wht`]) instead: total,
2934+ // the same in both profiles, and the 4x4 fast path is the same
2935+ // single call it always was. The old
2936+ // `debug_assert_eq!(self.tx_type, TxType::DctDct)` is gone with
2937+ // it: the WHT takes no tx_type (libaom's `av1_iwht4x4_add` does
2938+ // not either), and `av1_get_tx_type` already answers `DCT_DCT` on
2939+ // every plane of a lossless block, so asserting an argument
2940+ // nothing reads was a debug-only panic on a value release
2941+ // ignores.
2942+ if self.w != 4 || self.h != 4 {
2943+ LOSSLESS_WHT_SPLIT_UNITS.fetch_add(
2944+ self.w.div_ceil(4) * self.h.div_ceil(4),
2945+ std::sync::atomic::Ordering::Relaxed,
2946+ );
2947+ }
2948+ crate::transform::dequant_and_inverse_wht(
27902949 grid,
2950+ self.w,
2951+ self.h,
27912952 self.bit_depth,
27922953 self.q_idx,
27932954 self.dc_delta,
@@ -4521,6 +4682,17 @@ thread_local! {
45214682 /// invisible to every gate because they only counted CODED strips.
45224683 static INTRABC_RECT_SKIPPED_HITS: std::cell::Cell<[usize; 2]> =
45234684 const { std::cell::Cell::new([0, 0]) };
4685+ /// lane-whtshape: LOSSLESS rect intrabc blocks whose chroma plane block
4686+ /// [`decode_intrabc_rect`] walked as a `(cw/4) * (ch/4)` PLANE-MAJOR
4687+ /// raster of TX_4X4 units -- the shape libaom's lossless geometry codes
4688+ /// (`read_tx_size` returns `TX_4X4` for EVERY plane of a lossless block,
4689+ /// `get_vartx_max_txsize` likewise, and `read_tx_mode` forced the frame's
4690+ /// `ONLY_4X4`) -- instead of the single rect unit, which is what put a
4691+ /// non-4x4 unit on the lossless Walsh-Hadamard path. EXCLUSIVE to this arm:
4692+ /// no other caller walks a rect intrabc block's chroma, so `>= 1` cannot
4693+ /// be satisfied by any older route.
4694+ static INTRABC_RECT_LOSSLESS_CHROMA4_HITS: std::cell::Cell<usize> =
4695+ const { std::cell::Cell::new(0) };
45244696 }
45254697
45264698 /// lane-av1-intrabc r4: coded (`skip == 0`) rect intrabc blocks reconstructed,
@@ -4552,6 +4724,18 @@ pub(crate) fn reset_intrabc_rect_hits() {
45524724 INTRABC_RECT_SKIPPED_HITS.with(|c| c.set([0, 0]));
45534725 }
45544726
4727+/// lane-whtshape: [`INTRABC_RECT_LOSSLESS_CHROMA4_HITS`].
4728+#[allow(dead_code)] // read only from the `#[cfg(test)]` gates
4729+pub fn intrabc_rect_lossless_chroma4_hits() -> usize {
4730+ INTRABC_RECT_LOSSLESS_CHROMA4_HITS.with(|c| c.get())
4731+}
4732+
4733+/// lane-whtshape: zeroes [`INTRABC_RECT_LOSSLESS_CHROMA4_HITS`].
4734+#[allow(dead_code)] // read only from the `#[cfg(test)]` gates
4735+pub(crate) fn reset_intrabc_rect_lossless_chroma4_hits() {
4736+ INTRABC_RECT_LOSSLESS_CHROMA4_HITS.with(|c| c.set(0));
4737+}
4738+
45554739 /// Current value of [`INTRABC_RECT_VARTX_HITS`].
45564740 #[allow(dead_code)] // read only from the `#[cfg(test)]` gates
45574741 pub fn intrabc_rect_vartx_hits() -> usize {
@@ -4999,6 +5183,32 @@ pub(crate) fn affine_gm_hits() -> usize {
49995183 AFFINE_GM_HITS.with(|c| c.get())
50005184 }
50015185
5186+// lane-av1distwtd: how many blocks took the DISTANCE-WEIGHTED compound
5187+// combine rather than the simple average -- `compound_idx == 0` under
5188+// `enable_jnt_comp`, whose weights come from
5189+// [`crate::compound::dist_wtd_comp_weight_assign`] instead of the constant
5190+// `(8, 8)` split. Counting the `idx == 0` arm (not merely the
5191+// `compound_idx` symbol read) is what makes this a witness of the TOOL: a
5192+// stream that carries `enable_jnt_comp = true` in its sequence header but
5193+// codes every compound block with `compound_idx == 1` leaves this at 0 and
5194+// decoded identically without the whole distance-weight path.
5195+thread_local! {
5196+ static DIST_WTD_COMP_HITS: std::cell::Cell<usize> =
5197+ const { std::cell::Cell::new(0) };
5198+}
5199+
5200+/// Current value of [`DIST_WTD_COMP_HITS`].
5201+#[allow(dead_code)] // read only from the `#[cfg(test)]` gates
5202+pub(crate) fn dist_wtd_comp_hits() -> usize {
5203+ DIST_WTD_COMP_HITS.with(|c| c.get())
5204+}
5205+
5206+/// Resets [`DIST_WTD_COMP_HITS`] to 0.
5207+#[allow(dead_code)] // test-only
5208+pub(crate) fn reset_dist_wtd_comp_hits() {
5209+ DIST_WTD_COMP_HITS.with(|c| c.set(0));
5210+}
5211+
50025212 // lane-av1gwarp12: how many 16x16+ blocks built their SINGLE-reference
50035213 // prediction through `crate::warp::global_warp_params` with a FOUR-parameter
50045214 // (`ROTZOOM`) model. Vanilla aomenc pins its global-motion search to ROTZOOM
@@ -7561,6 +7771,11 @@ fn read_coeffs(
75617771 ) -> Result<(Grid, TxType)> {
75627772 let trace = crate::envflags::env_flag!("EC_AV1_TRACE");
75637773 let side = coding.side;
7774+ // lane-av1readcensus: this unit's own entry state, so the census line
7775+ // carries the pre-read rng and pairs against the oracle's `EC_COEFF`
7776+ // (which prints `r->ec.rng` before the same `txb_skip` read).
7777+ let census_entry_rng = dec.debug_state().0;
7778+ let (census_w, census_h) = rect_shape.unwrap_or((side, side));
75647779 if crate::envflags::env_flag!("EC_AV1_EOBPT_CDF") {
75657780 let (range, value) = dec.debug_state();
75667781 eprintln!("EC_AV1_STATE_BEFORE_TXBSKIP range={range} value={value}");
@@ -7603,6 +7818,15 @@ fn read_coeffs(
76037818 if all_zero {
76047819 // lane-coefgrid: the all-zero unit (60% of the 4K segment's) names the
76057820 // shared zero grid instead of allocating and zeroing its own.
7821+ census_unit(
7822+ census_w,
7823+ census_h,
7824+ TxType::DctDct,
7825+ 0,
7826+ true,
7827+ census_entry_rng,
7828+ dec,
7829+ );
76067830 return Ok((Grid::Zero(side * side), TxType::DctDct));
76077831 }
76087832 let mut grid = vec![0i32; side * side];
@@ -7811,6 +8035,15 @@ fn read_coeffs(
78118035 }
78128036 grid[pos] = if negative { -level } else { level };
78138037 }
8038+ census_unit(
8039+ census_w,
8040+ census_h,
8041+ tx_type,
8042+ eob,
8043+ false,
8044+ census_entry_rng,
8045+ dec,
8046+ );
78148047 Ok((Grid::Own(grid), tx_type))
78158048 }
78168049
@@ -7832,18 +8065,31 @@ fn read_coeffs_rect(
78328065 skip_ctx: usize,
78338066 sign_ctx: usize,
78348067 default_tx_type: TxType,
8068+ // lane-av1chrtx: the plane this unit belongs to (0 luma, 1 U, 2 V) --
8069+ // printed by the two `EC_COEFF_STEP` traces below, which hardcoded
8070+ // `plane=0` and so mis-attributed a CHROMA read as a luma one in two
8071+ // independent lane reports.
8072+ plane: usize,
78358073 ) -> Result<(Grid, TxType)> {
78368074 let rect_trace = coeff_trace_on();
78378075 let entry_rng = dec.debug_state().0;
8076+ // lane-av1readcensus: this reader is handed the real plane (lane-av1chrtx
8077+ // threaded it in for the `EC_COEFF_STEP` traces), so it stamps the census
8078+ // plane itself rather than inheriting whichever reader did last. The
8079+ // luma-only readers (`decode_rect_split`, `decode_block_rect64`,
8080+ // `read_inter_plane_rect`'s corner) are all plane 0 -- the stamp's initial
8081+ // value -- and the other plane-owning readers stamp on entry.
8082+ set_census_plane(plane);
78388083 let all_zero = dec.symbol(&mut coding.txb_skip[skip_ctx]) == 1;
78398084 if rect_trace {
78408085 eprintln!(
7841- "EC_COEFF_STEP tag=all_zero plane=0 ctx={skip_ctx} entry={entry_rng} all_zero={} rng={}",
8086+ "EC_COEFF_STEP tag=all_zero plane={plane} ctx={skip_ctx} entry={entry_rng} all_zero={} rng={}",
78428087 all_zero as i32,
78438088 dec.debug_state().0
78448089 );
78458090 }
78468091 if all_zero {
8092+ census_unit(w, h, TxType::DctDct, 0, true, entry_rng, dec);
78478093 return Ok((Grid::Zero(w * h), TxType::DctDct));
78488094 }
78498095 let mut grid = vec![0i32; w * h];
@@ -7864,7 +8110,7 @@ fn read_coeffs_rect(
78648110 })?;
78658111 if rect_trace {
78668112 eprintln!(
7867- "EC_COEFF_STEP tag=tx_type plane=0 rng={}",
8113+ "EC_COEFF_STEP tag=tx_type plane={plane} rng={}",
78688114 dec.debug_state().0
78698115 );
78708116 }
@@ -8047,6 +8293,7 @@ fn read_coeffs_rect(
80478293 nz.join(",")
80488294 );
80498295 }
8296+ census_unit(w, h, tx_type, eob, false, entry_rng, dec);
80508297 Ok((Grid::Own(grid), tx_type))
80518298 }
80528299
@@ -8076,11 +8323,25 @@ fn read_chroma_coeffs_rect(
80768323 sign_ctx: usize,
80778324 default_tx_type: TxType,
80788325 fctx: &crate::decode::FrameCtx,
8326+ // lane-av1chrtx: the plane index, threaded to `read_coeffs_rect`'s
8327+ // `EC_COEFF_STEP` traces (they used to print a hardcoded `plane=0`, so a
8328+ // V-plane read was indistinguishable from a luma one in the log).
8329+ plane: usize,
80798330 ) -> Result<(Grid, TxType)> {
80808331 if mono(fctx) {
80818332 return Ok((Grid::Zero(w * h), TxType::DctDct));
80828333 }
8083- read_coeffs_rect(dec, coding, scan, w, h, skip_ctx, sign_ctx, default_tx_type)
8334+ read_coeffs_rect(
8335+ dec,
8336+ coding,
8337+ scan,
8338+ w,
8339+ h,
8340+ skip_ctx,
8341+ sign_ctx,
8342+ default_tx_type,
8343+ plane,
8344+ )
80848345 }
80858346
80868347 /// What one coded block leaves behind for the blocks that read it as a
@@ -11537,6 +11798,7 @@ fn decode_rect_split(
1153711798 tu_skip_ctx,
1153811799 dc_sign_ctx(tu_around.2),
1153911800 TxType::DctDct,
11801+ 0,
1154011802 )?;
1154111803 let residual = dequant_and_inverse_typed_wh(
1154211804 &tu_grid,
@@ -11962,6 +12224,7 @@ fn decode_rect_split(
1196212224 skip_ctx,
1196312225 dc_sign_ctx(cu_around[plane_idx].2),
1196412226 default_tx,
12227+ plane_idx,
1196512228 )?;
1196612229 let residual = dequant_and_inverse_typed_wh(
1196712230 &levels,
@@ -12046,6 +12309,7 @@ fn decode_rect_split(
1204612309 skip_ctx,
1204712310 dc_sign_ctx(around[plane_idx].2),
1204812311 default_tx,
12312+ plane_idx,
1204912313 )?;
1205012314 // The same delta_q proof the unsplit rect64 path records
1205112315 // (lane-rectsplit r4: lifting the split-transform refusal moved
@@ -13062,12 +13326,34 @@ fn decode_intrabc_rect(
1306213326 });
1306313327 }
1306413328 let (px, py) = (mi_c * MI, mi_r * MI);
13065- let (cpx, cpy) = (px / 2, py / 2);
13329+ // lane-whtshape: a LOSSLESS block's chroma plane block is
13330+ // `bw >> ss_x` by `bh >> ss_y` at its own origin -- `av1_get_max_uv_txsize`
13331+ // is `ss_size_lookup[bsize]` (no halving of its own), so at 4:4:4 that is
13332+ // the block's OWN footprint, not the 4:2:0 halving the lossy arm hard-codes.
13333+ // Measured on this lane's 4:4:4 lossless witness: with the halving, a
13334+ // 16x8 intrabc block's chroma plane block came out 8x4 and the lossless
13335+ // walk below coded 2 units per plane where libaom codes 8.
13336+ //
13337+ // Scoped to `lossless` ON PURPOSE. The 4:2:0 halving is right at 4:2:0,
13338+ // and every pinned 4:4:4 stream that reaches this helper does so LOSSY
13339+ // (measured: zero pinned fixtures decode a LOSSLESS intrabc rect block),
13340+ // whose footprint is a separate, already-named open cell --
13341+ // lanes/av1444rect.report.md's 4:4:4 intra-BC chroma. This lane must not
13342+ // move it, and a lossless-only split here changes no green pin either way.
13343+ let (cpx, cpy) = if lossless(fctx) {
13344+ (px >> ss_x(fctx), py >> ss_y(fctx))
13345+ } else {
13346+ (px / 2, py / 2)
13347+ };
1306613348 // `av1_get_max_uv_txsize(bw x bh)`: 4:2:0 halves the footprint and the
1306713349 // halved shape's own `max_txsize_rect_lookup` entry IS that size for every
1306813350 // shape this helper is called at, so the uv plane block is ONE unit --
1306913351 // the same call `decode_token_recon_block`'s own chroma loop makes.
13070- let (cw, ch) = (bw / 2, bh / 2);
13352+ let (cw, ch) = if lossless(fctx) {
13353+ (bw >> ss_x(fctx), bh >> ss_y(fctx))
13354+ } else {
13355+ (bw / 2, bh / 2)
13356+ };
1307113357 // lane-av1-intrabc r2: the square stride the proven INTER path uses
1307213358 // (`side`). The residual grids, the prediction windows AND
1307313359 // `TxParams::stride` are all laid out at it -- the block's own width
@@ -13157,6 +13443,10 @@ fn decode_intrabc_rect(
1315713443 let reduced = fctx.reduced_tx_set_inter.with(std::cell::Cell::get);
1315813444 let luma_tx_type: TxType;
1315913445 let (luma_grid, u_grid, v_grid);
13446+ // lane-whtshape: the LOSSLESS chroma walk's composed plane-major grids,
13447+ // kept so their per-4x4 slices can be re-stamped over the whole-block
13448+ // record in the tail. `None` on every other arm.
13449+ let mut ll_chroma: Option<(Vec<i32>, Vec<i32>)> = None;
1316013450 if skip {
1316113451 // No residual syntax at all: the prediction IS the block.
1316213452 // Residual stride is `side` (and `cside`), not `bw`: reconstruct_mc_rect indexes
@@ -13379,43 +13669,95 @@ fn decode_intrabc_rect(
1337913669 around[1] = c[1];
1338013670 around[2] = c[2];
1338113671 }
13382- let (ug, _) = read_inter_plane_rect(
13383- dec,
13384- cdfs,
13385- rect_inter_chroma_set(cw, ch)?,
13386- (cw, ch),
13387- cside,
13388- 1,
13389- around[1],
13390- 0,
13391- u,
13392- cpx,
13393- cpy,
13394- Pred::Inline(&pred_u, cside),
13395- Some(luma_tx_type),
13396- None,
13397- fctx,
13398- )?;
13399- u_grid = embed_grid_stride(&ug, cw, ch, cside);
13400- let (vg, _) = read_inter_plane_rect(
13401- dec,
13402- cdfs,
13403- rect_inter_chroma_set(cw, ch)?,
13404- (cw, ch),
13405- cside,
13406- 2,
13407- around[2],
13408- 0,
13409- v,
13410- cpx,
13411- cpy,
13412- Pred::Inline(&pred_v, cside),
13413- Some(luma_tx_type),
13414- None,
13415- fctx,
13416- )?;
13417- v_grid = embed_grid_stride(&vg, cw, ch, cside);
13418- luma_grid = Grid::Zero(side * side);
13672+ if lossless(fctx) {
13673+ // lane-whtshape: at lossless libaom codes TX_4X4 on EVERY
13674+ // plane of a block -- `read_tx_size` returns `TX_4X4` for a
13675+ // lossless block before it looks at a tree, `read_tx_mode`
13676+ // already forced `ONLY_4X4` for the frame, and
13677+ // `get_vartx_max_txsize` returns `TX_4X4` for every plane
13678+ // -- so this block's chroma plane block is a
13679+ // `(cw/4) * (ch/4)` raster of 4x4 units, PLANE-MAJOR
13680+ // (`decode_token_recon_block`: every U unit, then every V
13681+ // unit), not the single rect unit the two
13682+ // `read_inter_plane_rect` calls below read. That single
13683+ // 8x4 unit is what reached the lossless WHT with the wrong
13684+ // shape (the `debug_assert_eq!((w, h), (4, 4))` this lane
13685+ // replaced). Same helper, same walk, as the inter 8x8 and
13686+ // 128 paths.
13687+ hit!(INTRABC_RECT_LOSSLESS_CHROMA4_HITS);
13688+ let mut uo = vec![0i32; cside * cside];
13689+ let mut vo = vec![0i32; cside * cside];
13690+ read_inter_chroma_lossless(
13691+ dec,
13692+ cdfs,
13693+ neighbours,
13694+ u,
13695+ v,
13696+ Pred::Inline(&pred_u, cside),
13697+ Pred::Inline(&pred_v, cside),
13698+ (mi_r, mi_c),
13699+ (cpx, cpy),
13700+ (0, 0),
13701+ (cw, ch),
13702+ (cw, ch),
13703+ cside,
13704+ 0,
13705+ base_q_idx,
13706+ &mut uo,
13707+ &mut vo,
13708+ fctx,
13709+ )?;
13710+ // The per-unit walk stamped every unit's own coefficient
13711+ // context, but the whole-block `record_split_luma_rect_mi`
13712+ // in the tail rewrites every chroma cell with ONE composed
13713+ // state, which drops the per-unit DC signs and levels (class
13714+ // `override-slot-on-one-arm` -- the same one
13715+ // `decode_rect_split`'s `ll_chroma_units` replay exists
13716+ // for). The grids are kept here and replayed AFTER that
13717+ // record, from the same 4x4 slices, so the same states.
13718+ u_grid = embed_grid_stride(&Grid::Own(uo.clone()), cw, ch, cside);
13719+ v_grid = embed_grid_stride(&Grid::Own(vo.clone()), cw, ch, cside);
13720+ ll_chroma = Some((uo, vo));
13721+ luma_grid = Grid::Zero(side * side);
13722+ } else {
13723+ let (ug, _) = read_inter_plane_rect(
13724+ dec,
13725+ cdfs,
13726+ rect_inter_chroma_set(cw, ch)?,
13727+ (cw, ch),
13728+ cside,
13729+ 1,
13730+ around[1],
13731+ 0,
13732+ u,
13733+ cpx,
13734+ cpy,
13735+ Pred::Inline(&pred_u, cside),
13736+ Some(luma_tx_type),
13737+ None,
13738+ fctx,
13739+ )?;
13740+ u_grid = embed_grid_stride(&ug, cw, ch, cside);
13741+ let (vg, _) = read_inter_plane_rect(
13742+ dec,
13743+ cdfs,
13744+ rect_inter_chroma_set(cw, ch)?,
13745+ (cw, ch),
13746+ cside,
13747+ 2,
13748+ around[2],
13749+ 0,
13750+ v,
13751+ cpx,
13752+ cpy,
13753+ Pred::Inline(&pred_v, cside),
13754+ Some(luma_tx_type),
13755+ None,
13756+ fctx,
13757+ )?;
13758+ v_grid = embed_grid_stride(&vg, cw, ch, cside);
13759+ luma_grid = Grid::Zero(side * side);
13760+ }
1341913761 }
1342013762 }
1342113763 }
@@ -13444,6 +13786,29 @@ fn decode_intrabc_rect(
1344413786 &[&luma_grid, &u_grid, &v_grid],
1344513787 );
1344613788 }
13789+ // lane-whtshape: replay the LOSSLESS walk's per-4x4 chroma states over
13790+ // the whole-block record above, so the NEXT block reads the per-unit DC
13791+ // signs and levels libaom's plane-major walk left behind instead of one
13792+ // composed state for the whole plane block.
13793+ if let Some((uo, vo)) = ll_chroma {
13794+ for (plane_idx, comp) in [(1usize, &uo), (2, &vo)] {
13795+ for ur in 0..ch / 4 {
13796+ for uc in 0..cw / 4 {
13797+ let mut unit = Vec::with_capacity(16);
13798+ for r in 0..4 {
13799+ unit.extend_from_slice(&comp[(ur * 4 + r) * cside + uc * 4..][..4]);
13800+ }
13801+ neighbours.record_mi_chroma(
13802+ (mi_r + ur * (4 >> ss_y(fctx)), mi_c + uc * (4 >> ss_x(fctx))),
13803+ 4 << ss_x(fctx),
13804+ 4 << ss_y(fctx),
13805+ plane_idx,
13806+ &Grid::Own(unit),
13807+ );
13808+ }
13809+ }
13810+ }
13811+ }
1344713812 neighbours.record_palette_y_rect((mi_r, mi_c), bw, bh, 0, [0u16; 8]);
1344813813 neighbours.record_palette_uv_rect((mi_r, mi_c), bw, bh, 0, [0u16; 8]);
1344913814 neighbours.fill_skip_grid_rect((mi_r, mi_c), bw / MI, bh / MI, skip);
@@ -14510,6 +14875,7 @@ fn decode_block_rect(
1451014875 0,
1451114876 dc_sign_ctx(around[0].2),
1451214877 TxType::DctDct,
14878+ 0,
1451314879 )?;
1451414880 if crate::envflags::env_flag!("EC_AV1_TRACE") {
1451514881 let (rng, _) = dec.debug_state();
@@ -14558,6 +14924,7 @@ fn decode_block_rect(
1455814924 dc_sign_ctx(around[1].2),
1455914925 u_default_tx,
1456014926 fctx,
14927+ 1,
1456114928 )?;
1456214929 if crate::envflags::env_flag!("EC_AV1_TRACE") {
1456314930 let (rng, _) = dec.debug_state();
@@ -14605,6 +14972,7 @@ fn decode_block_rect(
1460514972 dc_sign_ctx(around[2].2),
1460614973 v_default_tx,
1460714974 fctx,
14975+ 2,
1460814976 )?;
1460914977 if crate::envflags::env_flag!("EC_AV1_TRACE") {
1461014978 let (rng, _) = dec.debug_state();
@@ -15087,6 +15455,7 @@ fn decode_leaf_rect(
1508715455 0,
1508815456 dc_sign_ctx(around[0].2),
1508915457 TxType::DctDct,
15458+ 0,
1509015459 )?;
1509115460 if crate::envflags::env_flag!("EC_AV1_RECTX_TRACE") {
1509215461 let nz: Vec<(usize, i32)> = l_levels
@@ -15141,6 +15510,7 @@ fn decode_leaf_rect(
1514115510 dc_sign_ctx(around[1].2),
1514215511 u_default_tx,
1514315512 fctx,
15513+ 1,
1514415514 )?;
1514515515 u_levels = u_l;
1514615516 let u_residual = dequant_and_inverse_typed_wh(
@@ -15185,6 +15555,7 @@ fn decode_leaf_rect(
1518515555 dc_sign_ctx(around[2].2),
1518615556 v_default_tx,
1518715557 fctx,
15558+ 2,
1518815559 )?;
1518915560 v_levels = v_l;
1519015561 let v_residual = dequant_and_inverse_typed_wh(
@@ -15608,6 +15979,7 @@ fn decode_block_rect4(
1560815979 0,
1560915980 dc_sign_ctx(around[0].2),
1561015981 TxType::DctDct,
15982+ 0,
1561115983 )?;
1561215984 hit!(RECT4_COEFF_HITS);
1561315985 let luma_residual = dequant_and_inverse_typed_wh(
@@ -15758,6 +16130,7 @@ fn decode_block_rect4(
1575816130 0,
1575916131 dc_sign_ctx(around[0].2),
1576016132 TxType::DctDct,
16133+ 0,
1576116134 )?;
1576216135 let mut planes = Vec::with_capacity(2);
1576316136 for plane in 1..3 {
@@ -15783,6 +16156,7 @@ fn decode_block_rect4(
1578316156 dc_sign_ctx(around[plane].2),
1578416157 default_tx,
1578516158 fctx,
16159+ plane,
1578616160 )?;
1578716161 planes.push((levels, tx_type));
1578816162 }
@@ -17313,6 +17687,7 @@ fn decode_rect4_16_strip(
1731317687 tu_skip_ctx,
1731417688 dc_sign_ctx(tu_around.2),
1731517689 TxType::DctDct,
17690+ 0,
1731617691 )?;
1731717692 let residual = dequant_and_inverse_typed_wh(
1731817693 &tu_grid,
@@ -17419,6 +17794,7 @@ fn decode_rect4_16_strip(
1741917794 0,
1742017795 dc_sign_ctx(around.2),
1742117796 TxType::DctDct,
17797+ 0,
1742217798 )?;
1742317799 let residual = dequant_and_inverse_typed_wh(
1742417800 &levels,
@@ -17935,6 +18311,7 @@ fn decode_rect4_16_strip(
1793518311 dc_sign_ctx(around[plane].2),
1793618312 default_tx,
1793718313 fctx,
18314+ plane,
1793818315 )?;
1793918316 planes.push((levels, tx_type));
1794018317 }
@@ -18441,6 +18818,7 @@ fn decode_block_rect64(
1844118818 0,
1844218819 dc_sign_ctx(around[0].2),
1844318820 TxType::DctDct,
18821+ 0,
1844418822 )?
1844518823 };
1844618824 if coeff_trace_on() {
@@ -18596,6 +18974,7 @@ fn decode_block_rect64(
1859618974 dc_sign_ctx(cu_around[plane_idx].2),
1859718975 TxType::DctDct,
1859818976 fctx,
18977+ plane_idx,
1859918978 )?;
1860018979 let residual = dequant_and_inverse_typed_wh(
1860118980 &levels,
@@ -19352,6 +19731,48 @@ fn dump_stage(var: &str, y: &PlaneBuf<'_>, u: &PlaneBuf<'_>, v: &PlaneBuf<'_>) {
1935219731 }
1935319732 }
1935419733
19734+/// `EC_AV1_PREFILT_WIDE_DUMP=<prefix>` -> `<prefix>.f<N>`, the pre-loop-filter
19735+/// reconstruction cropped to each plane's mi-ALIGNED true extent, byte for
19736+/// byte the shape aomdec's own rung 7 writes (`y_width`/`y_height`,
19737+/// `uv_width`/`uv_height`), so the two can be diffed directly.
19738+///
19739+/// lane-av1444edge: this used to be an inline block in the KEY-frame tile path
19740+/// only, with a FUNCTION-LOCAL `static IDX2` as its counter. Both facts were
19741+/// measurement traps, and the second one is why the first went unnoticed:
19742+/// the inter-frame path (`decode_inter_frame_tile_with_cdfs`) had no wide
19743+/// prefilter dump at all, so every 4:4:4 lossy divergence localized to an
19744+/// inter frame had no pre-filter rung to compare against and got attributed to
19745+/// reconstruction when the oracle could not see it. The `static` also restarted
19746+/// per monomorphisation, so every frame after the first overwrote `.f0` -- a
19747+/// per-frame bisection silently compared the LAST decoded frame. The counter
19748+/// is now the shared per-var [`dump_stage_idx`] map, and the call also sits on
19749+/// the inter path (skipped when the filter pipeline is active, which has
19750+/// already deblocked by the time the tile tail runs -- same condition
19751+/// `capture_filter_replay` guards itself with).
19752+fn dump_prefilter_wide(y: &PlaneBuf<'_>, u: &PlaneBuf<'_>, v: &PlaneBuf<'_>) {
19753+ let Ok(path) = crate::envflags::var("EC_AV1_PREFILT_WIDE_DUMP") else {
19754+ return;
19755+ };
19756+ use std::io::Write;
19757+ let idx = dump_stage_idx("EC_AV1_PREFILT_WIDE_DUMP");
19758+ let crop = |plane: &PlaneBuf<'_>| -> Vec<u8> {
19759+ let mut out = Vec::with_capacity(plane.true_width * plane.true_height);
19760+ for row in 0..plane.true_height {
19761+ out.extend(
19762+ plane.data[row * plane.width..][..plane.true_width]
19763+ .iter()
19764+ .map(|&s| s as u8),
19765+ );
19766+ }
19767+ out
19768+ };
19769+ if let Ok(mut f) = std::fs::File::create(format!("{path}.f{idx}")) {
19770+ let _ = f.write_all(&crop(y));
19771+ let _ = f.write_all(&crop(u));
19772+ let _ = f.write_all(&crop(v));
19773+ }
19774+}
19775+
1935519776 /// The value [`fresh_plane`] fills with under `EC_AV1_PLANE_SENTINEL`: no
1935619777 /// legal sample can equal it (reconstruction clamps to `(1 << bit_depth) - 1`,
1935719778 /// at most 4095), so a decode that hashes identically under the flag proves
@@ -19822,6 +20243,8 @@ fn read_plane(
1982220243 if plane_idx > 0 && mono(fctx) {
1982320244 return Ok(Grid::Zero(side * side));
1982420245 }
20246+ // lane-av1readcensus: the units read from here on are this plane's.
20247+ set_census_plane(plane_idx);
1982520248 let skip_ctx = if plane_idx == 0 {
1982620249 luma_skip_ctx.unwrap_or(0)
1982720250 } else {
@@ -20074,6 +20497,7 @@ fn read_rect_chroma_unit(
2007420497 usize::from(around.0) + usize::from(around.1) + chroma_skip_offset.unwrap_or(0),
2007520498 dc_sign_ctx(around.2),
2007620499 default_tx,
20500+ plane_idx,
2007720501 )?;
2007820502 let residual = dequant_and_inverse_typed_wh(
2007920503 &levels,
@@ -23125,6 +23549,7 @@ fn leaf8_chroma422_unit(
2312523549 usize::from(around.0) + usize::from(around.1),
2312623550 dc_sign_ctx(around.2),
2312723551 default_tx,
23552+ plane_idx,
2312823553 )?;
2312923554 let residual = dequant_and_inverse_typed_wh(
2313023555 &levels,
@@ -23775,6 +24200,7 @@ fn sub8_leaf_chroma444(
2377524200 skip_ctx,
2377624201 dc_sign_ctx(around[plane_idx].2),
2377724202 default_tx,
24203+ plane_idx,
2377824204 )?;
2377924205 let residual = dequant_and_inverse_typed_wh(
2378024206 &levels,
@@ -23954,6 +24380,7 @@ fn sub8_leaf_chroma444(
2395424380 skip_ctx,
2395524381 dc_sign_ctx(around[plane_idx].2),
2395624382 default_tx,
24383+ plane_idx,
2395724384 )?;
2395824385 let residual = dequant_and_inverse_typed_wh(
2395924386 &levels,
@@ -25337,6 +25764,7 @@ fn decode_leaf_rect8(
2533725764 skip_ctx,
2533825765 dc_sign_ctx(around.2),
2533925766 TxType::DctDct,
25767+ 0,
2534025768 )?;
2534125769 if li == 0 {
2534225770 chroma_tx = tx_type;
@@ -25748,6 +26176,7 @@ fn decode_leaf_rect8(
2574826176 0,
2574926177 dc_sign_ctx(around.2),
2575026178 TxType::DctDct,
26179+ 0,
2575126180 )?;
2575226181 if levels.iter().any(|&l| l != 0) {
2575326182 if vert {
@@ -27565,9 +27994,37 @@ fn read_block_tx_size(
2756527994 // `read_block_tx_size` (`decodeframe.c`) sends a lossless block down the
2756627995 // `read_tx_size` arm, which returns TX_4X4 before it reads anything.
2756727996 if lossless(fctx) {
27568- let mut leaves = Vec::new();
27569- for row in 0..side / MI {
27570- for col in 0..side / MI {
27997+ // lane-av1lm444loss: libaom CLIPS the transform-unit grid at the frame
27998+ // edge -- `max_block_high`/`max_block_wide` (`av1_common_int.h:1565`,
27999+ // `:1579`) fold `mb_to_bottom_edge`/`mb_to_right_edge` into
28000+ // `block_size_high/wide` before `>> MI_SIZE_LOG2`, so a block that
28001+ // hangs off the bottom/right codes only the units INSIDE the frame.
28002+ // `decode_token_recon_block`'s mu walk then bounds every chunk with
28003+ // `unit_height = ROUND_POWER_OF_TWO(AOMMIN(mu_blocks_high + row,
28004+ // max_blocks_high), ss_y)`, so the out-of-frame units are never read.
28005+ //
28006+ // The unclipped `side / MI` grid is correct arithmetic for a block that
28007+ // FITS, which is every block of a frame whose height and width are
28008+ // multiples of the superblock -- so this reads identically on all of
28009+ // those, and only differs on the partial edge block. Measured on the
28010+ // 128x96 4:4:4 lossless pin (one 128 root per inter frame, frame 32
28011+ // mi = 24 tx rows tall): the unclipped grid read 32 rows where the
28012+ // oracle read 24 -- 256 extra luma units per inter frame (1024 vs
28013+ // the oracle's 768), the `EC_SYMR` ladder's first fork landing exactly
28014+ // at that row-24 boundary (`plane=0` luma where the oracle had moved
28015+ // to `plane=1`), and the pixel diff growing 5596 -> 33561 wrong
28016+ // samples over the six frames.
28017+ let side_mi = side / MI;
28018+ let max_w_mi = side_mi.min(mi_cols.saturating_sub(at_mi.1));
28019+ let max_h_mi = side_mi.min(mi_rows.saturating_sub(at_mi.0));
28020+ if max_w_mi != side_mi || max_h_mi != side_mi {
28021+ LOSSLESS_EDGE_CLIPPED.with(|c| c.set(c.get() + 1));
28022+ LOSSLESS_EDGE_CLIP_UNITS
28023+ .with(|c| c.set(c.get() + (side_mi * side_mi - max_w_mi * max_h_mi)));
28024+ }
28025+ let mut leaves = Vec::with_capacity(max_w_mi * max_h_mi);
28026+ for row in 0..max_h_mi {
28027+ for col in 0..max_w_mi {
2757128028 leaves.push((row, col, 4, 4));
2757228029 }
2757328030 }
@@ -28047,9 +28504,23 @@ fn read_block_tx_size_rect(
2804728504 fctx: &crate::decode::FrameCtx,
2804828505 ) -> Result<Option<Vec<(usize, usize, usize, usize)>>> {
2804928506 if lossless(fctx) {
28050- let mut leaves = Vec::new();
28051- for row in 0..bh / MI {
28052- for col in 0..bw / MI {
28507+ // lane-av1lm444loss: the same frame-edge clip as the square builder
28508+ // above -- `max_block_high`/`max_block_wide` bound a rect block's
28509+ // transform grid by the part of it inside the frame, so a 1:4 strip
28510+ // hanging off the bottom codes only its in-frame rows. Identical
28511+ // arithmetic for a block that fits.
28512+ let max_w_mi = (bw / MI).min(mi_cols.saturating_sub(at_mi.1));
28513+ let max_h_mi = (bh / MI).min(mi_rows.saturating_sub(at_mi.0));
28514+ let full_w_mi = bw / MI;
28515+ let full_h_mi = bh / MI;
28516+ if max_w_mi != full_w_mi || max_h_mi != full_h_mi {
28517+ LOSSLESS_EDGE_CLIPPED.with(|c| c.set(c.get() + 1));
28518+ LOSSLESS_EDGE_CLIP_UNITS
28519+ .with(|c| c.set(c.get() + (full_w_mi * full_h_mi - max_w_mi * max_h_mi)));
28520+ }
28521+ let mut leaves = Vec::with_capacity(max_w_mi * max_h_mi);
28522+ for row in 0..max_h_mi {
28523+ for col in 0..max_w_mi {
2805328524 leaves.push((row, col, 4, 4));
2805428525 }
2805528526 }
@@ -28200,6 +28671,13 @@ fn read_inter_rect_chroma(
2820028671 (write_chroma_w, write_chroma_h): (usize, usize),
2820128672 chroma_side: usize,
2820228673 mode_for_tx: usize,
28674+ // lane-av1chrtx: this block's coded luma transform leaves, `(row, col,
28675+ // tw, th, tx_type)` -- the same list the 4:4:4 four-unit arms resolve
28676+ // through `covering_leaf_tx_type`. This sibling used to hand EVERY unit
28677+ // the block-level `luma_tx_type` (the top-left leaf's type), so a rect
28678+ // inter block whose chroma plane splits (`nx*ny > 1`) over MIXED var-tx
28679+ // leaves read the wrong type per unit.
28680+ leaf_tx_types: &[(usize, usize, usize, usize, TxType)],
2820328681 luma_tx_type: TxType,
2820428682 fctx: &crate::decode::FrameCtx,
2820528683 ) -> Result<(Grid, Grid, Vec<((usize, usize), usize, Grid, usize, usize)>)> {
@@ -28225,7 +28703,12 @@ fn read_inter_rect_chroma(
2822528703 let invalid_ss_plane =
2822628704 ss_x(fctx) == 1 && ss_y(fctx) == 0 && (write_chroma_w, write_chroma_h) == (4, 32);
2822728705 let (uw, uh) = if invalid_ss_plane { (4, 8) } else { (uw, uh) };
28228- let inherit_tx_type = Some(luma_tx_type);
28706+ // lane-av1chrtx: `inherit_tx_type` is resolved PER UNIT below, not once
28707+ // for the block -- `av1_get_tx_type` (blockd.h:1287-1297) reads
28708+ // `xd->tx_type_map` at the chroma unit's own position scaled back to
28709+ // luma, so a unit sitting over a luma leaf that coded NOTHING takes that
28710+ // leaf's `DCT_DCT` stamp (`decodetxb.c:199-203`), not the block-level
28711+ // (top-left leaf) type.
2822928712 let (nx, ny) = (write_chroma_w / uw, write_chroma_h / uh);
2823028713 let multi = nx * ny > 1;
2823128714 let set = rect_inter_chroma_set(uw, uh)?;
@@ -28263,6 +28746,7 @@ fn read_inter_rect_chroma(
2826328746 at_mi.0 + cu_row * (span_y / MI),
2826428747 at_mi.1 + cu_col * (span_x / MI),
2826528748 );
28749+ let unit_rel_mi = (cu_mi.0 - at_mi.0, cu_mi.1 - at_mi.1);
2826628750 let cu_around = if multi {
2826728751 // lane-av1422ctxgather: at ss (1,0) the unit's above
2826828752 // span covers `uw` chroma px = `2*uw` luma mi columns,
@@ -28282,6 +28766,16 @@ fn read_inter_rect_chroma(
2828228766 };
2828328767 let (cu_x, cu_y) = (cpx + cu_col * uw, cpy + cu_row * uh);
2828428768 let cu_pred = src.offset(cu_row * uh * chroma_side + cu_col * uw);
28769+ let inherit_tx_type =
28770+ if let Some(t) = covering_leaf_tx_type(leaf_tx_types, unit_rel_mi) {
28771+ hit!(CHROMA_RECT_LEAF_TX_HITS);
28772+ if Some(t) != Some(luma_tx_type) {
28773+ hit!(CHROMA_RECT_LEAF_TX_DIFF_HITS);
28774+ }
28775+ Some(t)
28776+ } else {
28777+ Some(luma_tx_type)
28778+ };
2828528779 let cu_grid = read_inter_plane_rect(
2828628780 dec,
2828728781 cdfs,
@@ -28366,6 +28860,8 @@ fn read_inter_plane_rect(
2836628860 if plane_idx > 0 && mono(fctx) {
2836728861 return Ok((Grid::Zero(w * h), TxType::DctDct));
2836828862 }
28863+ // lane-av1readcensus: the units read from here on are this plane's.
28864+ set_census_plane(plane_idx);
2836928865 let skip_ctx = if plane_idx == 0 {
2837028866 // `get_txb_ctx_general`: 0 only when this unit IS the whole plane
2837128867 // block; a var-tx leaf passes its own neighbour-table context.
@@ -28442,6 +28938,7 @@ fn read_inter_plane_rect(
2844228938 skip_ctx,
2844328939 dc_sign_ctx(around.2),
2844428940 default_tx_type,
28941+ plane_idx,
2844528942 )?
2844628943 };
2844728944 let grid = extend_corner(corner, cw, ch, w, h);
@@ -32310,6 +32807,19 @@ thread_local! {
3231032807 /// 128x96 4:4:4 lossless stream, 1536 per inter frame (768 per plane),
3231132808 /// against the oracle's 1536.
3231232809 pub(crate) static MU_CHUNK_WALK_UNITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
32810+ /// lane-av1lm444loss: lossless blocks whose transform-unit grid was
32811+ /// CLIPPED at the frame edge -- `max_block_high`/`max_block_wide` cut the
32812+ /// grid short of the block's own `side / MI`, so libaom codes fewer TX_4X4
32813+ /// units than the block is wide/tall. Zero on any frame whose height and
32814+ /// width are multiples of the superblock, so a gate cannot look armed by
32815+ /// merely decoding.
32816+ pub(crate) static LOSSLESS_EDGE_CLIPPED: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
32817+ /// lane-av1lm444loss: the transform units that clip REMOVED -- the
32818+ /// `(side / MI - clipped) * (side / MI)` overflow the pre-fix walk read
32819+ /// past the frame bottom/right edge. On the 128x96 4:4:4 lossless pin this
32820+ /// is 256 per inter frame (8 unclipped luma rows x 32 columns), and 0 on a
32821+ /// frame that fits.
32822+ pub(crate) static LOSSLESS_EDGE_CLIP_UNITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
3231332823 }
3231432824
3231532825 /// [`MU_CHUNK_WALKS`], for a gate's own before/after delta.
@@ -32329,6 +32839,19 @@ pub(crate) fn mu_chunk_walk_units() -> usize {
3232932839 pub(crate) fn mu_chunk_order_hits() -> usize {
3233032840 MU_CHUNK_ORDER_HITS.with(std::cell::Cell::get)
3233132841 }
32842+/// [`LOSSLESS_EDGE_CLIPPED`] -- lossless blocks whose TX grid the frame-edge
32843+/// clip shortened, for a gate's own before/after delta.
32844+#[allow(dead_code)] // read only from the `#[cfg(test)]` gates
32845+pub(crate) fn lossless_edge_clipped() -> usize {
32846+ LOSSLESS_EDGE_CLIPPED.with(std::cell::Cell::get)
32847+}
32848+
32849+/// [`LOSSLESS_EDGE_CLIP_UNITS`] -- transform units the clip removed, i.e. the
32850+/// ones the unclipped pre-fix walk read past the frame edge.
32851+#[allow(dead_code)] // read only from the `#[cfg(test)]` gates
32852+pub(crate) fn lossless_edge_clip_units() -> usize {
32853+ LOSSLESS_EDGE_CLIP_UNITS.with(std::cell::Cell::get)
32854+}
3233232855
3233332856 /// [`CHROMA_SPLIT_TX_HITS`], for a gate's own before/after delta.
3233432857 #[allow(dead_code)] // read only from the `#[cfg(test)]` gates
@@ -34748,27 +35271,7 @@ pub(crate) fn decode_key_frame_tile_with_cdfs(
3474835271 } else {
3474935272 PREFILT_PICTURE_IDX.fetch_add(1, std::sync::atomic::Ordering::SeqCst);
3475035273 }
34751- if let Ok(path) = crate::envflags::var("EC_AV1_PREFILT_WIDE_DUMP") {
34752- use std::io::Write;
34753- static IDX2: std::sync::atomic::AtomicUsize = std::sync::atomic::AtomicUsize::new(0);
34754- let idx = IDX2.fetch_add(1, std::sync::atomic::Ordering::SeqCst);
34755- let crop_wide = |plane: &PlaneBuf<'_>| -> Vec<u8> {
34756- let mut out = Vec::with_capacity(plane.true_width * plane.true_height);
34757- for row in 0..plane.true_height {
34758- out.extend(
34759- plane.data[row * plane.width..][..plane.true_width]
34760- .iter()
34761- .map(|&s| s as u8),
34762- );
34763- }
34764- out
34765- };
34766- if let Ok(mut f) = std::fs::File::create(format!("{path}.f{idx}")) {
34767- let _ = f.write_all(&crop_wide(&y));
34768- let _ = f.write_all(&crop_wide(&u));
34769- let _ = f.write_all(&crop_wide(&v));
34770- }
34771- }
35274+ dump_prefilter_wide(&y, &u, &v);
3477235275 // lane-av1fwd: the encoder's filter search re-decodes this same key
3477335276 // frame tile per candidate -- capture it once (see [`FilterReplay`]),
3477435277 // on the shape whose tail is the two filter calls and nothing else.
@@ -35435,6 +35938,8 @@ fn read_inter_plane(
3543535938 if plane_idx > 0 && mono(fctx) {
3543635939 return Ok((Grid::Zero(side * side), TxType::DctDct));
3543735940 }
35941+ // lane-av1readcensus: the units read from here on are this plane's.
35942+ set_census_plane(plane_idx);
3543835943 let skip_ctx = if plane_idx == 0 {
3543935944 luma_skip_ctx.unwrap_or(0)
3544035945 } else {
@@ -35661,10 +36166,7 @@ fn read_intra_chroma_lossless(
3566136166 /// skipped (the returned order is the identity). `changed` is `true` only
3566236167 /// when the sort actually permutes the list, so a no-op ordering reads zero
3566336168 /// on [`MU_CHUNK_ORDER_HITS`] and cannot make a gate look armed.
35664-fn mu_chunk_order(
35665- leaves: &[(usize, usize, usize, usize)],
35666- side: usize,
35667-) -> (Vec<usize>, bool) {
36169+fn mu_chunk_order(leaves: &[(usize, usize, usize, usize)], side: usize) -> (Vec<usize>, bool) {
3566836170 let identity: Vec<usize> = (0..leaves.len()).collect();
3566936171 if side <= 64 {
3567036172 return (identity, false);
@@ -37943,6 +38445,39 @@ pub(crate) fn chroma_quad_leaf_tx_diff_hits() -> usize {
3794338445 CHROMA_QUAD_LEAF_TX_DIFF_HITS.with(std::cell::Cell::get)
3794438446 }
3794538447
38448+thread_local! {
38449+ /// lane-av1chrtx: chroma units of a RECT inter block
38450+ /// ([`read_inter_rect_chroma`], the sibling of the 4:4:4 four-unit arms)
38451+ /// that resolved their `tx_type` from the luma leaf covering their OWN
38452+ /// quadrant instead of the block-level one. A SEPARATE counter from
38453+ /// [`CHROMA_QUAD_LEAF_TX_HITS`] on purpose: that one gates a 4:2:0 control
38454+ /// that must stay at exactly 0, and this route IS reachable at 4:2:0, so
38455+ /// sharing the counter would destroy that control's meaning.
38456+ pub(crate) static CHROMA_RECT_LEAF_TX_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
38457+}
38458+
38459+thread_local! {
38460+ /// Of those, how many resolved a type that DIFFERS from the block-level
38461+ /// one -- the condition that changes pixels. A route counter alone fires
38462+ /// on every multi-unit rect chroma read, including the blocks whose
38463+ /// leaves all agree (the exact shape a no-op fix looks green on).
38464+ pub(crate) static CHROMA_RECT_LEAF_TX_DIFF_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
38465+}
38466+
38467+/// [`CHROMA_RECT_LEAF_TX_HITS`]: rect chroma units that took their type from
38468+/// the covering luma leaf.
38469+#[allow(dead_code)] // read only from the `#[cfg(test)]` gates
38470+pub(crate) fn chroma_rect_leaf_tx_hits() -> usize {
38471+ CHROMA_RECT_LEAF_TX_HITS.with(std::cell::Cell::get)
38472+}
38473+
38474+/// [`CHROMA_RECT_LEAF_TX_DIFF_HITS`]: of those, the units whose covering
38475+/// leaf's type differs from the block-level one.
38476+#[allow(dead_code)] // read only from the `#[cfg(test)]` gates
38477+pub(crate) fn chroma_rect_leaf_tx_diff_hits() -> usize {
38478+ CHROMA_RECT_LEAF_TX_DIFF_HITS.with(std::cell::Cell::get)
38479+}
38480+
3794638481 fn decode_inter_block(
3794738482 dec: &mut SymbolDecoder,
3794838483 cdfs: &mut Cdfs,
@@ -38881,6 +39416,10 @@ fn decode_inter_block(
3888139416 if idx == 1 {
3888239417 (8, 8, 1u8)
3888339418 } else {
39419+ // lane-av1distwtd: `idx == 0` is the
39420+ // distance-weighted arm -- the only branch whose
39421+ // weights are NOT the constant (8, 8) split.
39422+ hit!(DIST_WTD_COMP_HITS);
3888439423 let (fwd, bck) = crate::compound::dist_wtd_comp_weight_assign(
3888539424 order_hint_bits,
3888639425 order_hint,
@@ -39874,6 +40413,7 @@ fn decode_inter_block(
3987440413 (write_chroma_w, write_chroma_h),
3987540414 chroma_stride,
3987640415 mode_for_tx,
40416+ &leaf_tx_types,
3987740417 luma_tx_type,
3987840418 fctx,
3987940419 )?;
@@ -41666,6 +42206,7 @@ fn decode_inter_block(
4166642206 (write_chroma_w, write_chroma_h),
4166742207 chroma_stride,
4166842208 mode_for_tx,
42209+ &leaf_tx_types,
4166942210 luma_tx_type,
4167042211 fctx,
4167142212 )?;
@@ -42316,8 +42857,7 @@ fn decode_inter_block(
4231642857 if side > 64 {
4231742858 let chunk = (row / 16, col / 16);
4231842859 let done = pos + 1 == order.len()
42319- || (leaves[order[pos + 1]].0 / 16, leaves[order[pos + 1]].1 / 16)
42320- != chunk;
42860+ || (leaves[order[pos + 1]].0 / 16, leaves[order[pos + 1]].1 / 16) != chunk;
4232142861 if !done {
4232242862 continue;
4232342863 }
@@ -44693,6 +45233,7 @@ fn decode_intra_sub8_leaf(
4469345233 0,
4469445234 dc_sign_ctx(around.2),
4469545235 TxType::DctDct,
45236+ 0,
4469645237 )?;
4469745238 let residual = dequant_and_inverse_typed_wh(
4469845239 &levels,
@@ -45078,6 +45619,7 @@ fn decode_intra_sub8_leaf(
4507845619 skip_ctx,
4507945620 dc_sign_ctx(around.2),
4508045621 uv_tx,
45622+ plane,
4508145623 )?;
4508245624 let residual = dequant_and_inverse_typed_wh(
4508345625 &levels,
@@ -46845,6 +47387,10 @@ fn decode_inter_block8(
4684547387 if idx == 1 {
4684647388 (8, 8, 1u8)
4684747389 } else {
47390+ // lane-av1distwtd: the 8x8 leaf's own
47391+ // distance-weighted arm, same counter as the
47392+ // 16x16+ site above.
47393+ hit!(DIST_WTD_COMP_HITS);
4684847394 let (fwd, bck) = crate::compound::dist_wtd_comp_weight_assign(
4684947395 order_hint_bits,
4685047396 order_hint,
@@ -52495,6 +53041,12 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
5249553041 } else {
5249653042 PREFILT_PICTURE_IDX.fetch_add(1, std::sync::atomic::Ordering::SeqCst);
5249753043 }
53044+ // lane-av1444edge: the inter-frame path's mi-aligned pre-loop-filter
53045+ // dump, the rung the key-frame path has always had (see
53046+ // `dump_prefilter_wide`). Placed beside the padded `EC_AV1_PREFILT_DUMP`
53047+ // above, i.e. before the filter pipeline is released, so the two agree on
53048+ // the point in the sequence they sample.
53049+ dump_prefilter_wide(&y, &u, &v);
5249853050 // lane-pipefilt: release the rows still pending and wait the pipeline
5249953051 // out; from here the picture is deblocked and CDEF-filtered exactly as
5250053052 // the whole-frame path leaves it.
@@ -52761,6 +53313,46 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
5276153313
5276253314 #[cfg(test)]
5276353315 mod tests {
53316+ /// lane-av1chrtx: [`covering_leaf_tx_type`] resolves a chroma unit's
53317+ /// `tx_type` from the luma leaf covering the unit's OWN quadrant, and
53318+ /// reports "no leaf there" as `None` so the caller can fall back to the
53319+ /// block-level type. Both halves are load-bearing: the 128 mu-chunk tail,
53320+ /// the 4:4:4 four-unit arms and `read_inter_rect_chroma` all read the
53321+ /// `None` arm as "this block coded a single luma unit".
53322+ #[test]
53323+ fn covering_leaf_tx_type_picks_the_leaf_under_the_unit_or_reports_none() {
53324+ use TxType::*;
53325+ // A 32x64 strip's five-leaf tree, in decode order: one 32x32 leaf
53326+ // over mi rows 0..8, then 16x16 leaves. (row, col) are MI relative
53327+ // to the block, (tw, th) are PIXELS, MI == 4.
53328+ let leaves = [
53329+ (0usize, 0usize, 32usize, 32usize, Idtx),
53330+ (8, 0, 16, 16, VDct),
53331+ (8, 4, 16, 16, DctDct),
53332+ (12, 0, 16, 16, HDct),
53333+ (12, 4, 16, 16, VDct),
53334+ ];
53335+ // The TOP chroma unit (its own mi cell (0,0)) sits over the 32x32
53336+ // leaf; the LOWER one (mi (8,0)) over the first 16x16 leaf. The
53337+ // block-level type is the first leaf's, so only the second read
53338+ // differs -- exactly the condition the gate's DIFF counter counts.
53339+ assert_eq!(covering_leaf_tx_type(&leaves, (0, 0)), Some(Idtx));
53340+ assert_eq!(covering_leaf_tx_type(&leaves, (8, 0)), Some(VDct));
53341+ // Interior cells resolve the same leaf as the cell's top-left: the
53342+ // lookup is a rectangle containment test, not a raster position.
53343+ assert_eq!(covering_leaf_tx_type(&leaves, (11, 3)), Some(VDct));
53344+ assert_eq!(covering_leaf_tx_type(&leaves, (12, 4)), Some(VDct));
53345+ // The bottom-right corner of the last leaf, and the mi cell just
53346+ // past the block's own extent, must not fall into a neighbour.
53347+ assert_eq!(covering_leaf_tx_type(&leaves, (15, 7)), Some(VDct));
53348+ assert_eq!(covering_leaf_tx_type(&leaves, (16, 0)), None);
53349+ assert_eq!(covering_leaf_tx_type(&leaves, (0, 8)), None);
53350+ // A block with no var-tx tree (one coded luma unit) has no leaves at
53351+ // all: the caller's block-level fallback is the answer, and the
53352+ // resolver must say so rather than guess.
53353+ assert_eq!(covering_leaf_tx_type(&[], (0, 0)), None);
53354+ }
53355+
5276453356 /// lane-av1422warp r33: the OBMC pair-merge snap must move the READ to
5276553357 /// libaom's position, not the reported offset.
5276653358 ///
crates/ec-av1/src/encode.rsmodified+45 -72
@@ -15686,6 +15686,40 @@ mod tests {
1568615686 /// side, so the stream stays legal; here the pricer's own offer set is
1568715687 /// enumerated, class `enumerate-table-domain`).
1568815688 ///
15689+ /// **This is the coverage claim for the drl-clamp cell** (lane-av1recipehunt
15690+ /// r2, 2026-09-29). It replaces the clip gate
15691+ /// `a_128_superblock_clip_whose_drl_index_the_write_time_stack_cannot_carry_decodes_exact`,
15692+ /// deleted in `3e8c65e6`+r2: that gate asserted `drl_clamp_hits() > 0` on a
15693+ /// real 1280x768 sb128 clip, but `DRL_CLAMP_HITS` is provably unreachable
15694+ /// while the invariant above holds, so no recipe could ever satisfy it.
15695+ /// Deletion loses no coverage on either half:
15696+ /// * the clamp half -- this test IS the coverage, and it is strictly
15697+ /// stronger than any clip gate: it enumerates the pricer's whole offer
15698+ /// set against the writer's rule for every stack size 0..=4, and larger
15699+ /// stacks add entries the pricers never offer (`best_new_mv_syntax`
15700+ /// breaks at `entries.len() <= idx` for `idx > 0`, so indices 3/4 are
15701+ /// unreachable at ANY stack size), which is why 0..=4 bounds the
15702+ /// domain rather than sampling it;
15703+ /// * the pixel half -- the deleted gate's own decode-vs-encoder-
15704+ /// reconstruction compare on a 1280x768 sb128 sequence is already made
15705+ /// four times over, by `a_128_superblock_clip_whose_root_search_codes_
15706+ /// 128x128_blocks_decodes_exact`,
15707+ /// `a_128_root_block_with_a_real_residual_decodes_exact_through_both_decoders`,
15708+ /// `a_128_root_residual_block_under_a_per_unit_cdef_list_decodes_exact`
15709+ /// and `a_rect128_half_with_a_real_residual_decodes_exact_through_both_decoders`
15710+ /// (same geometry, same `force_sb128(true)`, same own-reconstruction AND
15711+ /// ffmpeg compare).
15712+ /// MEASURED before deleting (153 clip x size x frame-count x q combinations,
15713+ /// `enc_probe`): `tile::drl_clamp_hits()` = 0 on every one. MUTATION PROOF
15714+ /// the clip was never the variable: widening `best_new_mv_syntax`'s offer
15715+ /// set to `0..5` fires the counter immediately (9/2/2/1 on
15716+ /// mandelbrot 640x384x8, mandelbrot 320x192x8, mosaic 320x192x8,
15717+ /// testsrc2 640x384x8) and the same clips read 0 on revert. `note_drl_clamp`
15718+ /// and `DRL_CLAMP_HITS` are KEPT as the tripwire for the owning fix
15719+ /// (`deferred(unblock: the DRL owner widens the pricer past the writer's
15720+ /// `start + 2` ceiling, or retires the counter)`) -- this test will go red
15721+ /// the moment either happens, which is the signal to re-open the cell.
15722+ ///
1568915723 /// cargo test -p ec-av1 --lib -- every_drl_index_the_new_mv_pricer
1569015724 #[test]
1569115725 fn every_drl_index_the_new_mv_pricer_offers_is_one_the_writer_can_signal() {
@@ -18581,8 +18615,17 @@ mod tests {
1858118615 ///
1858218616 /// `#[ignore]`: [`force_sb128`] moves a process-global.
1858318617 ///
18584- /// cargo test -p ec-av1 --release --lib -- --ignored \
18585- /// a_128_superblock_clip_whose_drl_index_the_write_time_stack --nocapture
18618+ /// The drl-clamp cell this gate's counter used to gate is no longer gated
18619+ /// here: it is covered by
18620+ /// [`every_drl_index_the_new_mv_pricer_offers_is_one_the_writer_can_signal`],
18621+ /// which enumerates the pricer's offer set against the writer's rule (see
18622+ /// its doc). The clamp needs a stack that shrinks between search and
18623+ /// write, which is what a 128x128 superblock's visit order would do -- but
18624+ /// the pricer never offers an index this tree's `write_drl_idx` cannot
18625+ /// signal, so no clip can provoke it (lane-av1recipehunt: 153 attempts, 0;
18626+ /// widening the pricer to `0..5` fires the counter immediately, reverting
18627+ /// silences it). `drl_clamp_hits` is kept as the tripwire for that fix.
18628+
1858618629 /// lane-b128: the 128x128 `PARTITION_NONE` root -- one block, one mode
1858718630 /// and one motion vector where the four 64x64 roots below spend four of
1858818631 /// each (cen3's L1). The counter is the gate on the fixture (class
@@ -19446,76 +19489,6 @@ mod tests {
1944619489 );
1944719490 }
1944819491
19449- #[test]
19450- #[ignore = "sets the process-global superblock size: run it alone"]
19451- fn a_128_superblock_clip_whose_drl_index_the_write_time_stack_cannot_carry_decodes_exact() {
19452- let _knobs = crate::speed::knob_write();
19453- if !have_ffmpeg() {
19454- eprintln!("SKIP: no ffmpeg");
19455- return;
19456- }
19457- force_sb128(true);
19458- let dir = std::env::temp_dir().join(format!("ec-av1-sb128b-{}", std::process::id()));
19459- std::fs::create_dir_all(&dir).unwrap();
19460- let clip = dir.join("mandelbrot-1280x768.y4m");
19461- let ok = Command::new("ffmpeg")
19462- .args([
19463- "-v",
19464- "error",
19465- "-y",
19466- "-f",
19467- "lavfi",
19468- "-i",
19469- "mandelbrot=size=1280x768:rate=24",
19470- ])
19471- .args(["-frames:v", "12", "-pix_fmt", "yuv420p"])
19472- .arg(&clip)
19473- .status()
19474- .expect("ffmpeg failed to run")
19475- .success();
19476- assert!(ok, "ffmpeg could not write the synthetic clip");
19477- let path = clip.to_str().unwrap();
19478- let (width, height) = (1280usize, 768usize);
19479- let pictures = crate::probe::source(path, "0", "null", width, height, 12);
19480-
19481- let _ = crate::tile::take_drl_clamp_hits();
19482- let encoded = encode_sequence(&pictures, 150, 0.5).unwrap();
19483- let clamps = crate::tile::take_drl_clamp_hits();
19484- assert!(
19485- clamps > 0,
19486- "this clip never asked for a drl index the write-time stack could not carry, \
19487- so it cannot witness the defect"
19488- );
19489- eprintln!("clamped drl indices: {clamps}");
19490-
19491- let decoded = crate::stream::decode_stream(&encoded.stream).expect("our decoder");
19492- assert_eq!(decoded.len(), encoded.frames.len(), "frame count");
19493- for (i, (frame, dec)) in encoded.frames.iter().zip(&decoded).enumerate() {
19494- let recon = &frame.reconstruction;
19495- for (plane, got, want) in [
19496- ("luma", &dec.y, &recon.y),
19497- ("U", &dec.u, &recon.u),
19498- ("V", &dec.v, &recon.v),
19499- ] {
19500- let differ = got.iter().zip(want).filter(|(a, b)| a != b).count();
19501- assert_eq!(
19502- differ,
19503- 0,
19504- "frame {i}: {plane} -- {differ} of {} samples differ from the encoder's \
19505- own reconstruction",
19506- got.len()
19507- );
19508- assert_eq!(
19509- got.len(),
19510- want.len(),
19511- "frame {i}: {plane} is {} samples, the reconstruction's is {}",
19512- got.len(),
19513- want.len()
19514- );
19515- }
19516- }
19517- }
19518-
1951919492 #[test]
1952019493 fn every_frame_of_a_sequence_decodes_through_our_own_decoder() {
1952119494 let _knobs = crate::speed::knob_read();
crates/ec-av1/src/gate_coverage.rsmodified+817 -67
@@ -2,14 +2,25 @@
22 //!
33 //! Every gate in [`crate::stream`] that runs a real `aomenc` picks its coding
44 //! tools with `--enable-*=0/1` flags, and a flag left off the command line
5-//! takes aomenc's default (on, for the tools this decoder cares about). That
6-//! makes it possible -- and it happened -- for a coding tool to be switched
7-//! *off in every single gate*, so that no real stream in this repository ever
8-//! exercised it and a corner-cut in the decoder survived twenty gates
9-//! unnoticed: `reconstruct`'s `smooth_neighbor` was hardcoded `false`, wrong
10-//! whenever a directional block neighbours a smooth-mode one, and invisible
11-//! because all twenty gates passed `--enable-smooth-intra=0`
12-//! (lane-chroma r1, 2026-08-30).
5+//! takes aomenc's default. That default is `1` for essentially every tool in
6+//! [`TOOL_UNIVERSE`] on a non-realtime build -- `default_extra_cfg` in
7+//! `av1/av1_cx_iface.c` is all-ones across the seq-level tool fields, and this
8+//! oracle is built with `CONFIG_REALTIME_ONLY 0`. But a `1` default is NOT
9+//! the same as the tool reaching the stream, and the rest of this file's
10+//! "defaulted means unknown" rule rests on that gap: palette and intrabc are
11+//! gated on CONTENT (`encoder.c:2079` derives `allow_screen_content_tools`
12+//! from block counts, and `seq_force_screen_content_tools` is left at the
13+//! adaptive `SELECT_SCREEN_CONTENT_TOOLS`), and `speed_features.c` masks
14+//! several tools OFF again per `--cpu-used`. A `1` default proves the encoder
15+//! was ALLOWED the tool, never that any block used it.
16+//!
17+//! With that default in place it is possible -- and it happened -- for a
18+//! coding tool to be switched *off in every single gate*, so that no real
19+//! stream in this repository ever exercised it and a corner-cut in the
20+//! decoder survived twenty gates unnoticed: `reconstruct`'s
21+//! `smooth_neighbor` was hardcoded `false`, wrong whenever a directional
22+//! block neighbours a smooth-mode one, and invisible because all twenty
23+//! gates passed `--enable-smooth-intra=0` (lane-chroma r1, 2026-08-30).
1324 //!
1425 //! The test below re-derives that set from the gate source and pins it. A tool
1526 //! that is switched off in every gate and on in none is *provably never
@@ -22,8 +33,10 @@
2233 // keys on `--enable-<tool>=0/1`, and `--tile-columns=<log2>` has no such
2334 // shape -- a `--tile-columns=` presence check would also read `=0` (one tile)
2435 // as coverage, which is the opposite of what it would claim. It needs no
25-// entry either: 13 gates spell `--tile-columns`/`--tile-rows` with a nonzero
26-// log2 and assert the parsed `tile_info` really carries the grid, and
36+// entry either: measured 2026-09-29 (lane-av1distwtd r2), 19 of the 146
37+// census-selected gate bodies spell `--tile-columns`/`--tile-rows` with a
38+// nonzero log2 -- 9 assert the parsed `tile_info` in the same body and 10
39+// more delegate to a shared helper that asserts it -- and
2740 // `run_multi_tile_gate` covers a 2D grid with the coding tools ON at both
2841 // bit depths.
2942
@@ -107,16 +120,53 @@ enum On {
107120 /// cover, listed with their aomenc default.
108121 ///
109122 /// lane-covbd's derivation read `--enable-*` flags only, so a tool a gate pins
110-/// off through another spelling was invisible: all 49 gates that name it pass
111-/// `--enable-tx-size-search=0`, and the real-stream PANIC hiding behind that
112-/// pin was found by lane-ab16, not by this guard. `--loopfilter-control=0`,
123+/// off through another spelling was invisible: every gate that named
124+/// `--enable-tx-size-search` passed `--enable-tx-size-search=0` when this was
125+/// written, and the real-stream PANIC hiding behind that pin was found by
126+/// lane-ab16, not by this guard. `--loopfilter-control=0`,
113127 /// `--tile-columns=0` and a `--cpu-used` high enough to switch a search off are
114-/// the same shape.
128+/// the same shape. `enable-tx-size-search` has since been SETTLED, in both
129+/// directions -- see the entry below and `print_tx_size_search_census`.
130+///
131+/// The "all 49" count is GONE as of 2026-09-29 (lane-av1distwtd r2) and is
132+/// deliberately not replaced by a number here: it is a snapshot that rots
133+/// every time a recipe changes. The live count is a TEST
134+/// ([`print_tx_size_search_census`], below), not prose, so it cannot go stale
135+/// silently -- re-run it and read the numbers rather than trusting a comment.
115136 ///
116137 /// Each entry is `(tool, spellings, aomenc default, what counts as on)`. The
117138 /// "defaulted means unknown" rule of [`NEVER_EXERCISED`] applies unchanged: a
118139 /// default of `1` does not prove the encoder picked the tool for any stream, so
119140 /// only a gate that spells an on-value at that bit depth retires an entry.
141+// `enable-tx-size-search` SETTLED 2026-09-29 (lane-av1txsearch), by
142+// measurement rather than by a name-shaped guess. The r3 note here said the
143+// count was a FLOOR: 9 gate bodies built the flag into a `format!`
144+// variable that neither `flags_in` nor `settings_in` could see, because
145+// both scan for a literal `"--flag=value"` inside one segment. The method
146+// r3 asked for is now [`spelling_values`] -> [`bound_values`], and it
147+// resolves all of them; `print_tx_size_search_census` asserts the
148+// unresolvable count is ZERO, so the floor cannot come back unnoticed.
149+//
150+// THE ENTRY IS RETIRED, on an ARRIVAL ASSERT rather than on the spelling.
151+// `a_real_aomenc_stream_with_a_1d_tx_class_on_a_rect_transform_decodes_pixel_exact`
152+// spells `--enable-tx-size-search=1` as a literal and hard-asserts
153+// `compared_tx_depths > 0` -- "never produced a nonzero tx depth on a
154+// compared attempt -- the flag did not arrive". `tx_depth` is read ONLY
155+// under the frame header's `tx_mode_select` bit (spec 5.11.16,
156+// `decode.rs`: the read is guarded by `tx_select_inter`), so a nonzero
157+// counter IS the parsed tx-size-search behaviour, not a proxy for it.
158+// Measured run of that gate on this tree (aom 3.13.3): 12 pixel-exact
159+// decodes, 0 named refusals, 6 of the 12 at 10 BIT, 219 rect coefficient
160+// TUs on compared attempts, and `flag arrival: ... tx depths 53` -- so the
161+// tool is exercised at BOTH depths, and the assertion is not vacuous.
162+//
163+// The `tx_select_inter_gate` twins
164+// (`a_real_aomenc_inter_sequence_with_tx_select_decodes_pixel_exact{,_10bit}`)
165+// are the stronger witness still: they DELIBERATELY omit the flag
166+// ("DELIBERATELY ABSENT: --enable-tx-size-search=0") and assert
167+// `decode::txfm_split_hits()` moved, proving the var-tx `txfm_split` tree
168+// of spec 5.11.17 is read -- an inter transform is then a recursive split
169+// tree, which is the whole content of the tool.
120170 #[cfg(test)]
121171 const DEFAULT_ON_TOOLS: &[(&str, &[&str], &str, On)] = &[
122172 (
@@ -168,9 +218,17 @@ const DEFAULT_ON_TOOLS: &[(&str, &[&str], &str, On)] = &[
168218
169219 /// Non-`--enable-*` spellings that drive a [`TOOL_UNIVERSE`] tool.
170220 ///
171-/// `--superres-mode=1` is how all three superres gates switch superres on;
221+/// `--superres-mode=1` is how every superres gate switches superres on;
172222 /// without this map they read as an `enable-superres` hole while a real stream
173-/// exercises the tool (lane-covbd deferred exactly this).
223+/// exercises the tool (lane-covbd deferred exactly this). The count was "all
224+/// three" until 2026-09-29 (lane-av1distwtd r2), which measured SIX gates
225+/// spelling a nonzero `--superres-mode` (5 among the 146 census-selected
226+/// bodies, plus `a_superres_census_over_six_real_streams_...`). No count is
227+/// given here for the same reason as `enable-tx-size-search` above: it rots.
228+/// Worth noting the alias is the ONLY positive evidence for superres, and
229+/// those gates do assert arrival -- `superres_hits` / `predict_scaled_hits`
230+/// are read in five of them -- so this one is a healthy alias, not a
231+/// spelling-only one.
174232 #[cfg(test)]
175233 const ALIASES: &[(&str, &str)] = &[("superres-mode", "enable-superres")];
176234
@@ -190,18 +248,52 @@ const NEVER_EXERCISED_8BIT: &[(&str, &str)] = &[
190248 // `enable-cfl-intra` LEFT both lists on 2026-09-02 (lane-reelckf r1): the
191249 // sb128 skipped-CfL / 1:4-chroma gate passes `--enable-cfl-intra=1` at 8
192250 // AND 10 bits and pixel-compares both arms.
193- (
194- "enable-dist-wtd-comp",
195- "off in 11 gates, on in none: distance-weighted compound is unimplemented",
196- ),
197- (
198- "enable-dual-filter",
199- "never spelled by any gate, so defaulted = unknown; no stream is proven to carry per-direction interp filters",
200- ),
201- (
202- "enable-flip-idtx",
203- "never spelled; the flip/identity transform types are unproven by a real stream",
204- ),
251+ // `enable-dist-wtd-comp` LEFT this list on 2026-09-29 (lane-av1distwtd).
252+ // The entry's stated reason was WRONG: the distance-weighted compound
253+ // combine is not unimplemented -- `compound::dist_wtd_comp_weight_assign`
254+ // (lane-av1comp) and `mc::combine_compound`'s weighted path have been in
255+ // the tree for a long time. What was missing was a stream CARRYING the
256+ // tool, and `a_distance_weighted_compound_stream_decodes_pixel_exact`
257+ // (stream.rs) now supplies one: it spells `--enable-dist-wtd-comp=1` and
258+ // asserts the PARSED sequence header carries `enable_jnt_comp == true`
259+ // (and `false` from the same recipe with `=0`, so the bit is proven to
260+ // move with the flag), that `dist_wtd_comp_hits() > 0` -- the
261+ // `compound_idx == 0` arm, the only branch whose blend weights are not the
262+ // constant (8, 8) -- and pixel-compares every frame against the oracle.
263+ // The existing lane-cwarp compound-warp gates already SPELLED `=1` and
264+ // the census still read this entry as open, so the hole was a missing
265+ // witness, not a missing flag.
266+ // `enable-dual-filter` LEFT this list on 2026-09-29 (lane-av1distwtd r3),
267+ // paid by a DETECTOR fix rather than by a new gate. The r2 audit found
268+ // this entry's reason false on both halves. It is spelled -- as `=0`, by
269+ // `real_aomenc_1to4_streams_...` and
270+ // `a_real_aomenc_inter_sequence_with_32x32_level_1to4_strips_...` -- so
271+ // "never spelled" was wrong; and a stream IS proven to carry the tool,
272+ // because `a_real_aomenc_dual_filter_obmc_8x8_inter_sequence_decodes_pixel_exact`
273+ // spells `--enable-dual-filter=1` and hard-asserts
274+ // `decode::dual_filter_diff_hits()` moved, the differing-direction arrival
275+ // assert (`resolve_interp_filter` in decode.rs). That gate builds its
276+ // stream through `inter_sb_none_gate`, so it spells none of the three
277+ // tokens `gate_bodies()` used to filter on and was INVISIBLE to the
278+ // census; r3 made `gate_bodies()` resolve calls as well as spellings, and
279+ // `the_detector_sees_the_gates_the_spelling_filter_missed` pins that.
280+ // Supporting measurement: with the flag left off the command line the
281+ // parsed sequence header already carries `enable_dual_filter = true`
282+ // (6855 B), while `--enable-dual-filter=0` parses false and encodes
283+ // different bytes (6874 B) -- so the gates pinning it `=0` were removing
284+ // the tool and the ones leaving it defaulted carry it.
285+ //
286+ // `enable-flip-idtx` LEFT this list the same day, also by detector fix.
287+ // `a_real_aomenc_stream_with_a_1d_tx_class_on_a_rect_transform_decodes_pixel_exact`
288+ // spells `=1` and hard-asserts `compared_class1 > 0` ("--enable-flip-idtx=1
289+ // never produced a V_DCT/H_DCT transform on a compared attempt"). Its
290+ // recipe is parameterised on `ten_bit` and names BOTH fixture formats, so
291+ // `is_ten_bit` filed the whole body 10-bit-ONLY and the 8-bit bucket
292+ // never saw it -- the lane-defon/reelckf blind spot through a THIRD
293+ // spelling, which r3 taught `covers_both_depths` to recognise as the
294+ // pair-of-formats marker. Measured run of that gate: 12 pixel-exact
295+ // decodes, 6 of them 8-bit, 219 rect coefficient TUs of which 10 carry a
296+ // 1D tx class.
205297 // `enable-global-motion` LEFT this list on 2026-09-25 (lane-av1gwarp12 r2):
206298 // `a_real_affine_global_motion_stream_decodes_pixel_exact` loops
207299 // `for depth in [8u32, 10u32]` passing `--enable-global-motion=1` and
@@ -210,10 +302,41 @@ const NEVER_EXERCISED_8BIT: &[(&str, &str)] = &[
210302 // containing both the gate and this test until the ROTZOOM suite.
211303 // The 12-bit ROTZOOM gate rides the high-depth bucket via `encode_12bit(`
212304 // in `is_ten_bit`, so it plays no part in this retirement.
213- (
214- "enable-rect-tx",
215- "never spelled; rect transforms reach the decoder only through partition shape, never through a gate that names the tool",
216- ),
305+ // `enable-rect-tx` -- reason RE-VERIFIED 2026-09-29 (lane-av1distwtd
306+ // r2), both halves still TRUE, and the second half is now PROVEN rather
307+ // than asserted. (1) "never spelled": measured across all 146
308+ // census-selected gate bodies, zero spell `--enable-rect-tx` at either
309+ // depth -- the only `--enable-*` tool in [`TOOL_UNIVERSE`] with no
310+ // spelling anywhere. (2) "reach the decoder only through partition
311+ // shape": aom 3.13.3 has no sequence-header bit for it. `enable_rect_tx`
312+ // is an `AV1E_SET_ENABLE_RECT_TX` encoder-search control
313+ // (`av1_cx_iface.c:2125`, copied to `txfm_cfg->enable_rect_tx` at
314+ // `av1_cx_iface.c:1483`) and is read ONLY inside `tx_search.c`
315+ // (lines 2568/2662/2686/2710/2956); `bitstream.c` writes no such bit, and
316+ // this crate's `SequenceHeader` (`ec-av1-syntax/src/sequence.rs`) has no
317+ // such field. The decoder's own gate is `is_rect_tx_allowed`, derived
318+ // from partition shape -- exactly what this reason says. A gate can
319+ // therefore never prove this tool by naming the flag, only by proving a
320+ // rect transform unit fired (`rect_partition_hits` /
321+ // `rect_coeff_tu_hits`, which lane-rect1d's gate does assert).
322+ // `enable-rect-tx` LEFT this list on 2026-09-29 (merge wave 2,
323+ // lane-av1toolgates). Both halves of the reason recorded above still hold
324+ // as statements about the FLAG, and the second is exactly why the closing
325+ // evidence is a parsed shape and not a spelling: `enable_rect_tx` has no
326+ // sequence-header bit, so a decoder path can never be proven by naming the
327+ // flag -- only by proving a rect transform unit fired.
328+ // `a_real_aomenc_8bit_stream_with_a_rect_transform_decodes_pixel_exact`
329+ // (and its 10-bit twin) now spell `--enable-rect-tx=1` in their OWN test
330+ // bodies -- inline on purpose, because a helper-owned recipe collapses
331+ // both gates into one helper segment that `is_ten_bit` files 10-bit, and
332+ // the 8-bit hole would stay open -- and prove the tool on the PARSED
333+ // shape: `rect_partition_hits()` and `rect_coeff_tu_hits()` are both
334+ // asserted > 0 over arms that decoded AND pixel-compared, and each
335+ // counter is mutation-proven red on its own message.
336+ // Census on the merged tree (`print_never_exercised_per_bit_depth`):
337+ // 255 real-aomenc gate bodies, NEVER_EXERCISED derived EMPTY at 8 bits
338+ // and at 10 bits -- 0 of 26 tools -- so this list is empty on the same
339+ // evidence, not by deletion of a claim.
217340 ];
218341
219342 #[cfg(test)]
@@ -225,10 +348,16 @@ const NEVER_EXERCISED_10BIT: &[(&str, &str)] = &[
225348 // `enable-rect-partitions` and `enable-restoration` at 10 bits. All five
226349 // deleted together.
227350
228- // Only 4 of the 45 real-aomenc gates encode at 10 bits, and they pin the
229- // pixel filters and the intra tool set off. Every entry the 8-bit list
230- // carries is a hole here too. lane-hbdgates r1 closed six of the seven
231- // 8-bit-only entries with real 10-bit gates (filter-intra, smooth-intra,
351+ // The "Only 4 of the 45 real-aomenc gates encode at 10 bits" sentence that
352+ // stood here is STALE (lane-av1distwtd r2, 2026-09-29), and understated
353+ // the high-depth bucket by more than an order of magnitude. Measured
354+ // against this tree with `gate_bodies()`' own filter: 146 selected gate
355+ // bodies, of which 83 are classified 10-bit-or-higher by `is_ten_bit`.
356+ // The historical point stands -- those gates pin the pixel filters and
357+ // the intra tool set off far more often than not -- but the counts a
358+ // reader would check them against no longer exist.
359+ // Every entry the 8-bit list carries is a hole here too. lane-hbdgates r1
360+ // closed six of the seven 8-bit-only entries with real 10-bit gates
232361 // paeth-intra, intra-edge-filter, rect-partitions, ab-partitions); its
233362 // seventh, the 10-bit LR gate, was `#[ignore]`d on that branch and passes
234363 // un-ignored on main, which carries the fix.
@@ -241,10 +370,37 @@ const NEVER_EXERCISED_10BIT: &[(&str, &str)] = &[
241370 // gate passes `=1` for both. `enable-1to4-partitions` left it on 2026-09-02:
242371 // lane-tx64x16 r4's 32-level 1:4 gate has a 10-bit arm that asserts both
243372 // orientations and coded strips inside pixel-exact attempts.
244- (
245- "enable-dual-filter",
246- "hole at both depths, see the 8-bit list",
247- ),
373+ // `enable-dual-filter` -- reason CORRECTED 2026-09-29 (lane-av1distwtd
374+ // r3), and this entry STAYS while its 8-bit twin was retired. That is the
375+ // honest outcome, not an oversight: after the r3 detector fix the 8-bit
376+ // bucket sees the tool exercised and the 10-bit bucket still does not.
377+ // The only `=1` witness is
378+ // `a_real_aomenc_dual_filter_obmc_8x8_inter_sequence_decodes_pixel_exact`,
379+ // and it calls `inter_sb_none_gate(NAME, false, ...)` -- `false` is the
380+ // `ten_bit` parameter, so that gate builds an 8-bit stream only. Its
381+ // sibling `a_real_aomenc_10bit_inter_sequence_with_a_whole_superblock_block_decodes_pixel_exact`
382+ // passes `true`, and the 8x8-leaf pair likewise, but none of those spells
383+ // `--enable-dual-filter=1`. So: exercised at 8 bits (arrival assert
384+ // `dual_filter_diff_hits()` moved, `resolve_interp_filter` in decode.rs),
385+ // NOT exercised at 10 bits. Retiring this entry needs a 10-bit arm of that
386+ // gate -- pass `true` to `inter_sb_none_gate` and assert the differing-
387+ // direction counter still moves there.
388+ //
389+ // The two numbers in the `enable-flip-idtx` retirement below were
390+ // RE-MEASURED 2026-09-29 (lane-av1distwtd r2) by running the gate, and
391+ // both still hold exactly: "pixel-compares six 10-bit decodes" (the run
392+ // reports 12 pixel-exact decodes, 6 of them 10-bit) and "10 of its rect
393+ // coefficient TUs carry a 1D tx class" (219 rect coefficient TUs on
394+ // compared attempts, 10 of them 1D). The gate also hard-asserts
395+ // `compared_class1 > 0`, so its "passes =1 at both depths" is backed by an
396+ // arrival assert, not just a spelling.
397+ // `enable-dual-filter` LEFT this list on 2026-09-29 (merge wave 2,
398+ // lane-av1dualfilter10), by exactly the 10-bit arm the note above names.
399+ // `a_real_aomenc_10bit_dual_filter_obmc_8x8_inter_sequence_decodes_pixel_exact`
400+ // spells `--enable-dual-filter=1` in its own body and hard-asserts the
401+ // arrival counter `decode::dual_filter_diff_hits()` moved at 10 BITS, so
402+ // the entry is closed at the depth it was held open at, not by a spelling
403+ // alone.
248404 // `enable-flip-idtx` LEFT this list on 2026-09-02 (lane-rect1d r1):
249405 // `a_real_aomenc_stream_with_a_1d_tx_class_on_a_rect_transform_decodes_pixel_exact`
250406 // passes `=1` at both depths and pixel-compares six 10-bit decodes, so the
@@ -262,7 +418,14 @@ const NEVER_EXERCISED_10BIT: &[(&str, &str)] = &[
262418 // screen recipes run at 10 bits and hard-assert a decoded intrabc block
263419 // per depth (4-6 per arm), every frame pixel-compared against ffmpeg's own
264420 // 10-bit decode.
265- ("enable-rect-tx", "hole at both depths, see the 8-bit list"),
421+ // `enable-rect-tx` LEFT this list on 2026-09-29 (merge wave 2,
422+ // lane-av1toolgates), together with its 8-bit twin, by
423+ // `a_real_aomenc_10bit_stream_with_a_rect_transform_decodes_pixel_exact`:
424+ // the depth is spelled in the test's OWN body, which is what files it in
425+ // the 10-bit bucket, and the witness is the parsed shape
426+ // (`rect_partition_hits()` / `rect_coeff_tu_hits()` > 0 over arms that
427+ // decoded AND pixel-compared). See the 8-bit list for why the flag alone
428+ // could never have been the evidence.
266429 ];
267430
268431 /// [`DEFAULT_ON_TOOLS`] entries no 8-bit gate spells on, with the reason.
@@ -280,28 +443,124 @@ const NEVER_ON_10BIT: &[(&str, &str)] = &[];
280443 #[cfg(test)]
281444 mod tests {
282445 use super::{
283- On, ALIASES, DEFAULT_ON_TOOLS, NEVER_EXERCISED, NEVER_EXERCISED_10BIT,
284- NEVER_EXERCISED_8BIT, NEVER_ON_10BIT, NEVER_ON_8BIT, TOOL_UNIVERSE,
446+ ALIASES, DEFAULT_ON_TOOLS, NEVER_EXERCISED, NEVER_EXERCISED_8BIT, NEVER_EXERCISED_10BIT,
447+ NEVER_ON_8BIT, NEVER_ON_10BIT, On, TOOL_UNIVERSE,
285448 };
286449 use std::collections::{BTreeMap, BTreeSet};
287450
288- /// Bodies of the real-aomenc gates: a `fn` body carrying the shared
289- /// `--passes=1` every one of them passes. Split on the attribute that
290- /// opens a test.
451+ /// Whether `body` contains a call to the `fn` named `name`.
452+ ///
453+ /// The name must not be the tail of a longer identifier, or
454+ /// `inter_sb_none_gate` would "call" `sb_none_gate`.
455+ fn calls_fn(body: &str, name: &str) -> bool {
456+ let ident = |b: u8| b.is_ascii_alphanumeric() || b == b'_';
457+ let mut at = 0usize;
458+ while let Some(rel) = body[at..].find(name) {
459+ let start = at + rel;
460+ let end = start + name.len();
461+ let starts_clean = start == 0 || !ident(body.as_bytes()[start - 1]);
462+ if starts_clean && body[end..].starts_with('(') {
463+ return true;
464+ }
465+ at = end;
466+ }
467+ false
468+ }
469+
470+ /// Every `fn` defined in `stream.rs`'s test module, as `(name, body)`.
471+ ///
472+ /// The census reasons about whole `#[`-segments (see [`gate_bodies`]) but
473+ /// has to know which segment DEFINES or CALLS an encoder-driving `fn`, and
474+ /// the only way to answer that is to name the units.
475+ fn fn_units(src: &'static str) -> Vec<(&'static str, &'static str)> {
476+ const OPEN: &str = "\n fn ";
477+ let mut units = Vec::new();
478+ let mut at = 0usize;
479+ while let Some(rel) = src[at..].find(OPEN) {
480+ let head = at + rel + OPEN.len();
481+ let Some(paren) = src[head..].find('(') else {
482+ break;
483+ };
484+ let close = src[head..]
485+ .find("\n }\n")
486+ .map_or(src.len(), |e| head + e);
487+ units.push((&src[head..head + paren], &src[head..close]));
488+ at = close.max(head + paren + 1);
489+ }
490+ units
491+ }
492+
493+ /// Names of every `fn` in `stream.rs` that drives the real `aomenc`,
494+ /// DIRECTLY (it mentions `aomenc_path()`) or by DELEGATING to one.
495+ ///
496+ /// lane-av1distwtd r3: the transitive closure is the whole point. A gate
497+ /// that hands its recipe to a shared helper (`inter_sb_none_gate` and
498+ /// friends) never spells `--passes=1` itself, so the old token filter
499+ /// dropped it -- 165 of 311 segments, 6 of which spell `--enable-X=1`.
500+ /// That is not a coverage fact, it is a segmentation fact, and it is what
501+ /// kept `enable-dual-filter` on the never-exercised lists while a named
502+ /// gate exercised the tool and hard-asserted the arrival.
503+ fn encoder_fns(src: &'static str) -> BTreeSet<&'static str> {
504+ let units = fn_units(src);
505+ let mut enc: BTreeSet<&'static str> = units
506+ .iter()
507+ .filter(|(_, body)| body.contains("aomenc_path()"))
508+ .map(|(name, _)| *name)
509+ .collect();
510+ // Fixpoint: `inter_sb_none_gate` is an encoder fn because it names
511+ // `aomenc_path()`; the `#[test]` that only CALLS it is a gate too.
512+ loop {
513+ let mut grew = false;
514+ for (name, body) in &units {
515+ if enc.contains(name) {
516+ continue;
517+ }
518+ if enc.iter().any(|e| calls_fn(body, e)) {
519+ enc.insert(name);
520+ grew = true;
521+ }
522+ }
523+ if !grew {
524+ return enc;
525+ }
526+ }
527+ }
528+
529+ /// The token spellings the filter used before it resolved calls. Kept as a
530+ /// floor: a gate is still recognised by these even if the call graph
531+ /// misses it, so the fix can only ever ADD gates, never lose one.
532+ fn legacy_gate_tokens(body: &str) -> bool {
533+ body.contains("\"--passes=1\"")
534+ || body.contains("ten_bit_tool_gate(")
535+ || body.contains("encode_10bit_gradients")
536+ }
537+
538+ /// Bodies of the real-aomenc gates: a `fn` body that drives the real
539+ /// `aomenc`, however it gets there. Split on the attribute that opens a
540+ /// test.
541+ ///
542+ /// lane-av1distwtd r3: a segment qualifies if it spells one of the
543+ /// [`legacy_gate_tokens`] OR names an encoder `fn` -- either by defining
544+ /// one (it mentions `aomenc_path()`) or by calling one. Recognition by
545+ /// CALL is what a helper-delegating gate needs: its flags live in the
546+ /// helper it calls, and it is invisible to a spelling-only filter.
291547 fn gate_bodies() -> Vec<&'static str> {
292548 let src = include_str!("stream.rs");
549+ let enc = encoder_fns(src);
293550 let gates: Vec<&str> = src
294551 .split("\n #[")
295552 // lane-hbdgates r1: an `#[ignore]`d gate exercises nothing, so it
296553 // must not close a hole. Its body is the segment that opens with
297554 // the ignore attribute.
298555 .filter(|body| !body.starts_with("ignore"))
299- // lane-hbdgates r1: gates that build their stream through the
300- // shared 10-bit helpers spell `--passes=1` there, not inline.
556+ // lane-av1distwtd r3: a segment qualifies by what it SPELLS
557+ // (`legacy_gate_tokens`) or by what it CALLS. `calls_fn` is
558+ // deliberately the weak half of an OR, so the fix can only add
559+ // gates -- it can never stop recognising one the old filter did.
301560 .filter(|body| {
302- body.contains("\"--passes=1\"")
303- || body.contains("ten_bit_tool_gate(")
304- || body.contains("encode_10bit_gradients")
561+ legacy_gate_tokens(body)
562+ || body.contains("aomenc_path()")
563+ || enc.iter().any(|e| calls_fn(body, e))
305564 })
306565 .collect();
307566 assert!(
@@ -344,24 +603,262 @@ mod tests {
344603 here
345604 }
346605
347- /// Whether a gate body spells one [`DEFAULT_ON_TOOLS`] entry on / off.
348- fn default_on_state(gate: &str, spellings: &[&str], on: On) -> Option<bool> {
349- let here = settings_in(gate);
350- let mut state = None;
351- for spelling in spellings {
352- let Some(value) = here.get(*spelling) else {
606+ /// The values a `--<flag>={var}` TEMPLATE can take in one gate body, from
607+ /// the local binding of `var`.
608+ ///
609+ /// lane-av1txsearch: `settings_in` reads a `--flag=value` string LITERAL,
610+ /// so a flag a gate builds with `format!` was invisible to it -- 10 gate
611+ /// bodies spell `--enable-tx-size-search` only this way, and the census
612+ /// filed them as "defaulted", i.e. unknown in BOTH directions. The
613+ /// bindings that actually exist in `stream.rs` are four shapes, and each
614+ /// is resolved from the gate's own text rather than from the variable's
615+ /// name:
616+ ///
617+ /// 1. `let <var> = if <attempt> == 0 { "0" } else { "1" };` -- an
618+ /// attempt-indexed arm; the QUOTED values in the initializer are
619+ /// collected. Bare integers in the initializer (`attempt % 2`) are
620+ /// deliberately NOT read as flag values.
621+ /// 2. `for <var> in [0usize, 1]` / `["0", "1"]` -- a loop over both
622+ /// values; every element of the array is collected.
623+ /// 3. `for (<var>, <other>) in [("1", 8u8), ("0", 8u8), ...]` -- a
624+ /// tuple-destructured loop; only the element at `<var>`'s POSITION is
625+ /// collected from each tuple, so the arm table's bit-depth column is
626+ /// not read as a flag value.
627+ /// 4. `u8::from(<a>.<field>)` over a struct-literal arm table whose
628+ /// `field: true` / `field: false` rows are the flag values.
629+ ///
630+ /// `None` means the binding is NOT in this body -- the variable is a
631+ /// parameter of a shared helper and its value is bound at the CALL SITE,
632+ /// which lives in a different `#[`-segment. That is a real limit of a
633+ /// per-segment census and is reported as unknown rather than guessed:
634+ /// inferring the value from the variable's name is the exact failure this
635+ /// function exists to remove.
636+ fn bound_values(body: &str, var: &str) -> Option<BTreeSet<char>> {
637+ // Quoted single digits: `"0"`, `"1"`.
638+ let quoted_digits = |t: &str| -> BTreeSet<char> {
639+ let mut out = BTreeSet::new();
640+ let mut at = 0usize;
641+ while let Some(rel) = t[at..].find('"') {
642+ let start = at + rel + 1;
643+ let Some(end) = t[start..].find('"') else {
644+ break;
645+ };
646+ let literal = &t[start..start + end];
647+ if literal.len() == 1 {
648+ if let Some(c) = literal.chars().next() {
649+ if c.is_ascii_digit() {
650+ out.insert(c);
651+ }
652+ }
653+ }
654+ at = start + end + 1;
655+ }
656+ out
657+ };
658+ // Bare integer literals: `0usize`, `1`, `8u8`. Whole tokens only, so
659+ // `10u8` contributes nothing rather than a bogus `1`.
660+ let bare_digits = |t: &str| -> BTreeSet<char> {
661+ let mut out = BTreeSet::new();
662+ let bytes = t.as_bytes();
663+ let mut i = 0usize;
664+ while i < bytes.len() {
665+ if !bytes[i].is_ascii_digit() {
666+ i += 1;
667+ continue;
668+ }
669+ let start = i;
670+ while i < bytes.len() && bytes[i].is_ascii_digit() {
671+ i += 1;
672+ }
673+ let clean_before = start == 0 || !is_ident_byte(bytes[start - 1]);
674+ // A typed literal's suffix (`0usize`, `8u8`, `1u32`) belongs to
675+ // the same token, so a run of LOWERCASE letters right after
676+ // the digit is a type, not a different identifier. Anything
677+ // else -- a multi-digit `10u8`, a camelCase `1x` -- is not a
678+ // flag value and is rejected.
679+ let rest = &t[i..];
680+ let suffix = rest
681+ .bytes()
682+ .take_while(|b| b.is_ascii_lowercase() || *b == b'_')
683+ .count();
684+ let clean_after = i >= bytes.len()
685+ || !is_ident_byte(bytes[i])
686+ || (suffix > 0
687+ && i + suffix < bytes.len()
688+ && !is_ident_byte(bytes[i + suffix]));
689+ if clean_before && clean_after && i - start == 1 {
690+ out.insert(bytes[start] as char);
691+ }
692+ }
693+ out
694+ };
695+ // Split a comma-separated list at TOP level only, so `("1", 8u8)`
696+ // stays one element.
697+ fn split_top<'a>(t: &'a str) -> Vec<&'a str> {
698+ let mut out = Vec::new();
699+ let (mut depth, mut start) = (0i32, 0usize);
700+ for (i, c) in t.char_indices() {
701+ match c {
702+ '(' | '[' | '{' => depth += 1,
703+ ')' | ']' | '}' => depth -= 1,
704+ ',' if depth == 0 => {
705+ out.push(t[start..i].trim());
706+ start = i + 1;
707+ }
708+ _ => {}
709+ }
710+ }
711+ if start < t.len() {
712+ out.push(t[start..].trim());
713+ }
714+ out
715+ }
716+ // The body of the `[...]` that FOLLOWS `head` in `text`. Scoped to
717+ // the header rather than searching from the start of the body: a
718+ // gate's first `[` may be an unrelated array, and brackets that do
719+ // not balance across a whole gate body would leave the depth count
720+ // never returning to zero.
721+ fn loop_array_after<'a>(text: &'a str, head: &str) -> Option<&'a str> {
722+ let at = text.find(head)? + head.len();
723+ let open = at + text[at..].find('[')?;
724+ let mut depth = 0i32;
725+ for (i, c) in text[open..].char_indices() {
726+ match c {
727+ '[' => depth += 1,
728+ ']' => {
729+ depth -= 1;
730+ if depth == 0 {
731+ return Some(&text[open + 1..open + i]);
732+ }
733+ }
734+ _ => {}
735+ }
736+ }
737+ None
738+ }
739+ let mut found: Option<BTreeSet<char>> = None;
740+ let mut merge = |set: BTreeSet<char>| match &mut found {
741+ Some(all) => all.extend(set),
742+ None => found = Some(set),
743+ };
744+ // (1) `let <var> = if ... { "0" } else { "1" };` -- quoted values only.
745+ if let Some(at) = body.find(&format!("let {var} =")) {
746+ let init = &body[at..];
747+ let end = init.find(';').unwrap_or(init.len());
748+ merge(quoted_digits(&init[..end]));
749+ }
750+ // (2) `for <var> in [...]` -- every element of the array.
751+ if let Some(array) = loop_array_after(body, &format!("for {var} in ")) {
752+ merge(bare_digits(array));
753+ merge(quoted_digits(array));
754+ }
755+ // (3) `for (<var>, ...) in [(...), ...]` -- only `<var>`'s column.
756+ if let Some(at) = body.find("for (") {
757+ let head = &body[at..];
758+ if let Some(close) = head.find(')') {
759+ let pattern = &head["for (".len()..close];
760+ if let Some(pos) = pattern.split(',').position(|p| p.trim() == var) {
761+ let header = format!("for ({pattern}) in ");
762+ if let Some(array) = loop_array_after(body, &header) {
763+ let mut set: BTreeSet<char> = BTreeSet::new();
764+ for tuple in split_top(array) {
765+ let Some(inner) =
766+ tuple.strip_prefix('(').and_then(|t| t.strip_suffix(')'))
767+ else {
768+ continue;
769+ };
770+ let fields = split_top(inner);
771+ let Some(field) = fields.get(pos) else {
772+ continue;
773+ };
774+ set.extend(bare_digits(field));
775+ set.extend(quoted_digits(field));
776+ }
777+ merge(set);
778+ }
779+ }
780+ }
781+ }
782+ // (4) `u8::from(<a>.<field>)` over a struct-literal arm table.
783+ for (i, _) in body.match_indices("u8::from(") {
784+ let arg = &body[i + "u8::from(".len()..];
785+ let Some(close) = arg.find(')') else { continue };
786+ let field = arg[..close].rsplit('.').next().unwrap_or_default().trim();
787+ if field.is_empty() || !field.chars().all(|c| c.is_ascii_alphanumeric() || c == '_') {
353788 continue;
354- };
355- let Ok(value) = value.parse::<u32>() else {
789+ }
790+ let mut set = BTreeSet::new();
791+ for (row, value) in [("true", '1'), ("false", '0')] {
792+ if body.contains(&format!("{field}: {row}")) {
793+ set.insert(value);
794+ }
795+ }
796+ merge(set);
797+ }
798+ found
799+ }
800+
801+ fn is_ident_byte(b: u8) -> bool {
802+ b.is_ascii_alphanumeric() || b == b'_'
803+ }
804+
805+ /// Values of one [`DEFAULT_ON_TOOLS`] spelling in one gate body: the
806+ /// literal `--<spelling>=<digit>` spellings plus every value a `format!`
807+ /// template built from a local binding resolves to.
808+ ///
809+ /// A gate that reaches BOTH values counts ON, not off: it builds a `=1`
810+ /// stream on some attempt, which is what the census asks for. This is the
811+ /// file's standing "any spelling that says on wins" rule
812+ /// (`--tile-columns=0 --tile-rows=1` is a multi-tile stream), now applied
813+ /// across a loop's arms as well as across spellings.
814+ fn spelling_values(gate: &str, spelling: &str) -> BTreeSet<char> {
815+ let mut out = BTreeSet::new();
816+ // A literal `"--<spelling>=<digit>"`: the needle ends at the `=`, so
817+ // the value starts AT the needle's length, not three characters in.
818+ let literal = format!("\"--{spelling}=");
819+ for (i, _) in gate.match_indices(&literal) {
820+ let rest = &gate[i + literal.len()..];
821+ let Some(end) = rest.find('"') else { continue };
822+ if let Some(c) = rest[..end].chars().next() {
823+ if c.is_ascii_digit() {
824+ out.insert(c);
825+ }
826+ }
827+ }
828+ // A template `format!("--<spelling>={<var>}")`: the placeholder name
829+ // is the part between the braces, and its VALUE is whatever the
830+ // binding of `<var>` in this same body reaches.
831+ let template = format!("format!(\"--{spelling}=");
832+ for (i, _) in gate.match_indices(&template) {
833+ let rest = &gate[i + template.len()..];
834+ let Some(end) = rest.find('"') else { continue };
835+ let Some(var) = rest[..end]
836+ .strip_prefix('{')
837+ .and_then(|v| v.strip_suffix('}'))
838+ else {
356839 continue;
357840 };
358- let is_on = match on {
359- On::NonZero => value != 0,
360- On::AtMost(limit) => value <= limit,
361- };
362- // Any spelling that says "on" wins: --tile-columns=0 --tile-rows=1
363- // is a multi-tile stream.
364- state = Some(state.unwrap_or(false) || is_on);
841+ if var.chars().all(|c| c.is_ascii_alphanumeric() || c == '_') {
842+ out.extend(bound_values(gate, var).unwrap_or_default());
843+ }
844+ }
845+ out
846+ }
847+
848+ /// Whether a gate body spells one [`DEFAULT_ON_TOOLS`] entry on / off,
849+ /// over [`spelling_values`] -- so a `format!`-built flag is classified
850+ /// instead of being filed as "defaulted".
851+ fn resolved_on_state(gate: &str, spellings: &[&str], on: On) -> Option<bool> {
852+ let mut state = None;
853+ for spelling in spellings {
854+ for c in spelling_values(gate, spelling) {
855+ let value = c.to_digit(10).unwrap_or(0);
856+ let is_on = match on {
857+ On::NonZero => value != 0,
858+ On::AtMost(limit) => value <= limit,
859+ };
860+ state = Some(state.unwrap_or(false) || is_on);
861+ }
365862 }
366863 state
367864 }
@@ -466,10 +963,92 @@ mod tests {
466963 /// this marker that gate's own 8-bit-only flags read as 10-bit-only -- the
467964 /// lane-defon/reelckf blind spot with `depth` spelled instead of
468965 /// `bit_depth`. Three gates share the helper, at both depths.
966+ /// lane-av1distwtd r3: the THIRD spelling of the same blind spot, still
967+ /// live after lane-defon and lane-reelckf. A recipe parameterised on
968+ /// `ten_bit` names BOTH fixture formats in one body -- `let pix_fmt = if
969+ /// ten_bit { "yuv420p10le" } else { "yuv420p" };` -- so `is_ten_bit` saw
970+ /// the 10-bit arm and filed the whole body 10-bit-ONLY, hiding its 8-bit
971+ /// arm from the 8-bit bucket. The marker is the PAIR OF FORMATS, not the
972+ /// parameter name: a body spelling both pixel formats builds streams at
973+ /// both depths, whatever it calls the flag. The quotes matter -- a bare
974+ /// `yuv420p` substring test also matches `yuv420p10le` and would fire on
975+ /// every 10-bit gate, retiring entries on no evidence.
976+ ///
977+ /// This is what mis-filed `a_real_aomenc_stream_with_a_1d_tx_class_on_a_rect_transform_decodes_pixel_exact`
978+ /// and kept `enable-flip-idtx` on the 8-bit list while that gate ran 6
979+ /// pixel-exact 8-bit decodes through it.
469980 fn covers_both_depths(body: &str) -> bool {
470981 body.contains("if bit_depth == 10")
471982 || body.contains("if depth == 10")
472983 || body.contains("for depth in [8usize, 10]")
984+ || (body.contains("\"yuv420p\"") && body.contains("\"yuv420p10le\""))
985+ }
986+
987+ /// lane-av1distwtd r3: the detector fix, pinned. A detector change with
988+ /// no test can only be shown to find MORE, never to stop missing, so this
989+ /// asserts the three gates the two blind spots actually hid are now seen
990+ /// -- the two `enable-dual-filter` witnesses and the `enable-flip-idtx`
991+ /// both-depths gate -- and that the fix is strictly ADDITIVE against the
992+ /// old spelling-only filter.
993+ #[test]
994+ fn the_detector_sees_the_gates_the_spelling_filter_missed() {
995+ let src = include_str!("stream.rs");
996+ let gates = gate_bodies();
997+ // The helper-delegation half: each of these builds its stream through
998+ // `inter_sb_none_gate` and spells none of `legacy_gate_tokens`, so the
999+ // old filter dropped both while each hard-asserts its tool arrived.
1000+ for name in [
1001+ "a_real_aomenc_dual_filter_obmc_8x8_inter_sequence_decodes_pixel_exact",
1002+ "a_real_obmc_stream_reads_a_recorded_switchable_filter_for_every_neighbour",
1003+ ] {
1004+ let body = gates
1005+ .iter()
1006+ .find(|b| b.contains(name))
1007+ .unwrap_or_else(|| panic!("{name}: not seen by gate_bodies()"));
1008+ assert_eq!(
1009+ flags_in(body).get("enable-dual-filter"),
1010+ Some(&'1'),
1011+ "{name}: seen, but its --enable-dual-filter=1 spelling is not visible to \
1012+ flags_in, so recognising the gate would not retire the entry"
1013+ );
1014+ }
1015+ // The both-depths half: this gate's recipe is parameterised on `ten_bit`
1016+ // and names both fixture formats, so `covers_both_depths` must credit
1017+ // it to the 8-bit bucket, not just the 10-bit one.
1018+ let flip = gates
1019+ .iter()
1020+ .find(|b| b.contains("a_real_aomenc_stream_with_a_1d_tx_class_on_a_rect_transform"))
1021+ .expect("the flip-idtx gate must be seen");
1022+ assert!(
1023+ covers_both_depths(flip),
1024+ "the flip-idtx gate spells both fixture formats, so covers_both_depths must \
1025+ credit it to the 8-bit bucket as well"
1026+ );
1027+ assert!(
1028+ covers_depth(flip, false) && covers_depth(flip, true),
1029+ "the flip-idtx gate must cover BOTH depths"
1030+ );
1031+ // Strictly additive: every segment the old spelling-only filter kept
1032+ // is still kept, so the fix cannot have cost the census a gate.
1033+ let legacy_only: Vec<&str> = src
1034+ .split("\n #[")
1035+ .filter(|b| !b.starts_with("ignore") && legacy_gate_tokens(b))
1036+ .collect();
1037+ assert!(
1038+ legacy_only.len() < gates.len(),
1039+ "the call-resolving filter found {} gates, the old spelling-only filter found \
1040+ {} -- the fix is expected to ADD gates, never to drop one",
1041+ gates.len(),
1042+ legacy_only.len()
1043+ );
1044+ for body in &legacy_only {
1045+ assert!(
1046+ gates.contains(body),
1047+ "a gate the spelling-only filter recognised is no longer recognised: \
1048+ {:?}",
1049+ &body[..body.len().min(60)]
1050+ );
1051+ }
4731052 }
4741053
4751054 /// Whether a gate body drives a stream at this depth.
@@ -591,9 +1170,12 @@ mod tests {
5911170 .collect();
5921171 let mut per_tool = BTreeMap::new();
5931172 for &(tool, spellings, _, on) in DEFAULT_ON_TOOLS {
1173+ // lane-av1txsearch: `resolved_on_state`, not `default_on_state` --
1174+ // the literal-only reader filed every `format!`-built flag as
1175+ // "defaulted", which is unknown rather than measured.
5941176 let states: Vec<Option<bool>> = gates
5951177 .iter()
596- .map(|g| default_on_state(g, spellings, on))
1178+ .map(|g| resolved_on_state(g, spellings, on))
5971179 .collect();
5981180 let turned_on = states.iter().filter(|s| **s == Some(true)).count();
5991181 let turned_off = states.iter().filter(|s| **s == Some(false)).count();
@@ -688,4 +1270,172 @@ mod tests {
6881270 }
6891271 }
6901272 }
1273+
1274+ /// lane-av1txsearch: the `enable-tx-size-search` census, MEASURED rather
1275+ /// than floored. Prints, per gate body, the values the resolver reads for
1276+ /// the flag -- literal spellings and `format!` templates alike -- and the
1277+ /// three-way split at the end. Re-run it after any gate recipe change:
1278+ ///
1279+ /// `cargo test -p ec-av1 --lib gate_coverage::tests::print_tx_size_search_census -- --nocapture`
1280+ #[test]
1281+ fn print_tx_size_search_census() {
1282+ const TOOL: &str = "enable-tx-size-search";
1283+ let (zero, one, both, unresolvable, unnamed) = {
1284+ let (mut zero, mut one, mut both, mut unresolvable, mut unnamed) =
1285+ (0usize, 0usize, 0usize, 0usize, 0usize);
1286+ for gate in gate_bodies() {
1287+ let values = spelling_values(gate, TOOL);
1288+ let name = gate
1289+ .split("fn ")
1290+ .nth(1)
1291+ .and_then(|s| s.split('(').next())
1292+ .unwrap_or("<segment>")
1293+ .to_owned();
1294+ let state = match (values.contains(&'0'), values.contains(&'1')) {
1295+ (false, false) => {
1296+ unnamed += 1;
1297+ "not named (defaulted)"
1298+ }
1299+ (true, false) => {
1300+ zero += 1;
1301+ "=0"
1302+ }
1303+ (false, true) => {
1304+ one += 1;
1305+ "=1"
1306+ }
1307+ (true, true) => {
1308+ both += 1;
1309+ "=0 and =1 (one arm each)"
1310+ }
1311+ };
1312+ let via = if gate.contains(&format!("format!(\"--{TOOL}=")) {
1313+ " [format! template resolved]"
1314+ } else {
1315+ ""
1316+ };
1317+ let helper = if gate.contains(&format!("format!(\"--{TOOL}=")) && values.is_empty()
1318+ {
1319+ " [UNRESOLVED: variable is a shared helper's parameter]"
1320+ } else {
1321+ ""
1322+ };
1323+ if !helper.is_empty() {
1324+ unresolvable += 1;
1325+ unnamed -= 1;
1326+ }
1327+ println!("{name}: {state}{via}{helper}");
1328+ }
1329+ (zero, one, both, unresolvable, unnamed)
1330+ };
1331+ let total = gate_bodies().len();
1332+ println!(
1333+ "enable-tx-size-search over {total} census-selected gate bodies: \
1334+ =0 only {zero}, =1 only {one}, both {both}, unresolvable {unresolvable}, \
1335+ not named {unnamed}"
1336+ );
1337+ assert_eq!(
1338+ unresolvable, 0,
1339+ "{unresolvable} gate bodies build --{TOOL} into a variable this census cannot bind -- \
1340+ the count is a floor again, and an unknown direction is the failure mode this file \
1341+ exists to prevent"
1342+ );
1343+ }
1344+
1345+ /// lane-av1txsearch: the RED-BEFORE proof for the template resolver, in
1346+ /// both directions, on the gate bodies that actually exist.
1347+ ///
1348+ /// Direction 1 -- a `format!`-built value MOVES the classification. Each
1349+ /// case below takes a real gate body, mutates only the bound value, and
1350+ /// asserts the resolved state changed. A resolver that found nothing
1351+ /// would read every one of these as "not named" and fail all four.
1352+ ///
1353+ /// Direction 2 -- a spelling the LITERAL reader already saw still
1354+ /// classifies. Without this half, a resolver that overwrote the literal
1355+ /// path would pass direction 1 while losing the 15 `=1` gates the census
1356+ /// already counted.
1357+ #[test]
1358+ fn the_resolver_binds_a_format_built_flag_in_both_directions() {
1359+ let gates = gate_bodies();
1360+ let find = |needle: &str| -> &'static str {
1361+ gates
1362+ .iter()
1363+ .copied()
1364+ .find(|b| b.contains(needle))
1365+ .unwrap_or_else(|| panic!("no gate body contains {needle:?}"))
1366+ };
1367+ // Direction 1, one per template shape.
1368+ let cases = [
1369+ (
1370+ "format!(\"--enable-tx-size-search={txs}\")",
1371+ "for txs in [0usize, 1]",
1372+ "for txs in [0usize, 0]",
1373+ "a_real_aomenc_palette_stream_with_8x8_leaves_decodes_pixel_exact",
1374+ ),
1375+ (
1376+ "format!(\"--enable-tx-size-search={tx_search}\")",
1377+ "if attempt % 2 == 0 { \"0\" } else { \"1\" }",
1378+ "if attempt % 2 == 0 { \"0\" } else { \"0\" }",
1379+ "a_real_aomenc_inter_sequence_with_a_coded_rectangular_residual_decodes_pixel_exact",
1380+ ),
1381+ (
1382+ "format!(\"--enable-tx-size-search={tx_search}\")",
1383+ "for (tx_search, bit_depth) in [(\"1\", 8u8), (\"0\", 8u8), (\"1\", 10u8)]",
1384+ "for (tx_search, bit_depth) in [(\"0\", 8u8), (\"0\", 8u8), (\"0\", 10u8)]",
1385+ "a_real_aomenc_stream_with_filter_intra_on_a_sub8_rect_leaf_decodes_pixel_exact",
1386+ ),
1387+ ];
1388+ for (template, from, to, name) in cases {
1389+ let body = find(name);
1390+ assert!(
1391+ body.contains(template),
1392+ "{name} does not spell {template}, so this case proves nothing"
1393+ );
1394+ assert!(
1395+ body.contains(from),
1396+ "{name} does not contain the source binding {from:?}"
1397+ );
1398+ let before = spelling_values(body, "enable-tx-size-search");
1399+ let mutated = body.replace(from, to);
1400+ assert_ne!(
1401+ mutated, body,
1402+ "the mutation {from:?} -> {to:?} changed nothing"
1403+ );
1404+ let after = spelling_values(&mutated, "enable-tx-size-search");
1405+ assert_eq!(
1406+ before,
1407+ BTreeSet::from(['0', '1']),
1408+ "{name}: the unmutated body should resolve to both values, got {before:?}"
1409+ );
1410+ assert_eq!(
1411+ after,
1412+ BTreeSet::from(['0']),
1413+ "{name}: mutating the bound value {from:?} -> {to:?} did not move the \
1414+ classification (still {after:?}) -- the resolver is not reading the binding"
1415+ );
1416+ }
1417+ // Direction 2: every gate the LITERAL reader already classified as
1418+ // `=1` still is. Asserted as CONTAINMENT, not equality: a segment may
1419+ // spell the flag twice (`=0` in the base recipe, `=1` as the per-arm
1420+ // override), and the old reader took the last one while the resolver
1421+ // takes the set. The claim being pinned is "still on", which is the
1422+ // direction a regression would lose.
1423+ let mut pinned = 0usize;
1424+ for gate in &gates {
1425+ if !gate.contains("\"--enable-tx-size-search=1\"") {
1426+ continue;
1427+ }
1428+ pinned += 1;
1429+ assert!(
1430+ spelling_values(gate, "enable-tx-size-search").contains(&'1'),
1431+ "a gate that literally spells --enable-tx-size-search=1 is no longer \
1432+ classified on: {:?}",
1433+ &gate[..gate.len().min(80)]
1434+ );
1435+ }
1436+ assert!(
1437+ pinned >= 10,
1438+ "expected the literal `=1` gates to still be there, found {pinned}"
1439+ );
1440+ }
6911441 }
crates/ec-av1/src/refusal_inventory.rsmodified+261 -10
@@ -553,6 +553,27 @@ const PROVEN: &[(&str, &str)] = &[
553553 "a 64-axis strip whose chroma unit has no coefficient table",
554554 "every_chroma_unit_a_64_axis_strip_can_present_has_a_coefficient_table",
555555 ),
556+ // lane-av1rect8x16, enumeration: `decode_block_rect`'s `_` arm. The nine
557+ // textual `decode_block_rect(` matches are 1 declaration + 8 call sites
558+ // (this test's `assert_eq!(sites, 8)` counts the calls); all eight pass
559+ // `bw`/`bh` as integer LITERALS and every one of them is
560+ // a 32-level `PARTITION_HORZ`/`VERT`/`HORZ_A`/`_B`/`VERT_A`/`_B` arm of
561+ // `read_sb128_root`'s `match part32`, so the caller shape set is exactly
562+ // {32x16, 16x32} and their chroma halves under the three subsamplings an
563+ // AV1 `color_config` can carry are {(16,8), (8,16), (16,16), (8,32),
564+ // (32,16), (16,32)} -- every one of which has a row. The shape the
565+ // sibling sweep left open, a 4:2:0 8x16 luma strip's (4,8) chroma, is
566+ // NOT reachable here: a 16-level 2:1 luma strip is read by
567+ // `decode_leaf_rect`, which carries the (4,8)/(8,4) rows itself
568+ // (decode.rs:15409-15420). Measured, not assumed: 840 real aomenc 4:2:0
569+ // key-frame encodes, 826 of whose parsed leaf lists carry a coded
570+ // 16-level 2:1 luma strip (`horz_vert_intra_hits()`, which fires only
571+ // at the three `decode_leaf_rect` strip sites), decoded to completion
572+ // with this string firing 0 times.
573+ (
574+ "a rectangular chroma transform whose size has no coefficient table",
575+ "every_chroma_unit_decode_block_rect_can_present_has_a_coefficient_table",
576+ ),
556577 // lane-t900 r33, enumeration: each of the four symbols this guard tests is
557578 // read under a size gate that no 128-pixel side passes (the call site's
558579 // literal `cfl=false`, `filter_intra_size_class_rect`'s table, and
@@ -591,17 +612,20 @@ const PROVEN: &[(&str, &str)] = &[
591612 /// A gate named `..._decodes_pixel_exact` that cannot decode has failed, and
592613 /// swallowing the error keeps the suite green while the gate proves nothing --
593614 /// the same vacuum as a gate whose feature never fires, arrived at from the
594-/// other side. These four predate the attempt-loop pattern the newer gates use
595-/// (encode several fixtures, require at least one to decode, hard-assert the
596-/// firing count). They are pinned here so the set cannot grow while they are
597-/// converted one at a time.
615+/// other side. The list is the exact pin of the gates still shaped that way, so
616+/// the set cannot grow; a converted gate is DELETED from it.
617+///
618+/// lane-av1skipfix: emptied. The last four (`filter_intra`, the two
619+/// `deblocking` gates, and `gradients_stream_with_cdef`) were converted to the
620+/// attempt-loop pattern -- several recipes, at least one required to decode, the
621+/// feature counter hard-asserted on a pixel-compared attempt, a decode error on
622+/// every attempt a hard failure carrying its refusal text. None of the four had
623+/// a genuinely absent capability: every recipe family decoded, the refusals the
624+/// old arms swallowed were a named *screen-content* refusal on one recipe and a
625+/// stale premise on the CDEF gate (a single-superblock frame cannot make libaom
626+/// write `cdef_bits > 0`, so the old recipe never read a `cdef_idx` at all).
598627 #[cfg(test)]
599-const GATES_THAT_SKIP_ON_A_DECODE_ERROR: &[&str] = &[
600- "a_real_aomenc_filter_intra_stream_decodes_pixel_exact",
601- "a_real_aomenc_inter_sequence_with_deblocking_decodes_pixel_exact",
602- "a_real_aomenc_intra_stream_with_deblocking_decodes_pixel_exact",
603- "a_real_libaom_gradients_stream_with_cdef_decodes_pixel_exact",
604-];
628+const GATES_THAT_SKIP_ON_A_DECODE_ERROR: &[&str] = &[];
605629
606630 #[cfg(test)]
607631 mod tests {
@@ -1511,6 +1535,233 @@ mod tests {
15111535 );
15121536 }
15131537
1538+ /// lane-av1rect8x16, ENUMERATION for "a rectangular chroma transform
1539+ /// whose size has no coefficient table" --
1540+ /// [`crate::decode::decode_block_rect`]'s `_` arm.
1541+ ///
1542+ /// This refusal had NO `PROVEN` row: the sibling sweep that found the
1543+ /// gap (`every_rect_strip_shape_the_split_path_codes_has_a_luma_and_
1544+ /// chroma_table`, which audits `decode_rect_split`'s tables, not this
1545+ /// function's) asserted only the superblock-level 64x32/32x64
1546+ /// footprints, so the 8x16 luma strip's 4x8 chroma was left unasked.
1547+ ///
1548+ /// The answer is that the shape is UNREACHABLE, and structurally so:
1549+ /// every one of the function's call sites passes its `bw`/`bh` as
1550+ /// integer LITERALS, and all of them are 32-level `PARTITION_HORZ` /
1551+ /// `VERT` / `HORZ_A` / `HORZ_B` / `VERT_A` / `VERT_B` arms of
1552+ /// `read_sb128_root`'s `match part32` -- i.e. 32x16 or 16x32, never
1553+ /// 8x16. A 16-level 2:1 luma strip (16x8 / 8x16) is read by
1554+ /// [`crate::decode::decode_leaf_rect`], which carries the matching
1555+ /// `(4, 8)` / `(8, 4)` chroma rows (decode.rs:15409-15420,
1556+ /// `TxbSet::ChromaRect8x4` + `SCAN_4X8` / `SCAN_8X4`).
1557+ ///
1558+ /// So the proof is the CALLER SHAPE SET, read out of the call sites'
1559+ /// own argument lists, walked through `bw >> ss_x` / `bh >> ss_y` for
1560+ /// every subsampling an AV1 `color_config` can carry, against the
1561+ /// `match (chroma_w, chroma_h)` table read out of the function's own
1562+ /// text (class `table-and-reader-move-together`: a table edit
1563+ /// invalidates this test rather than sneaking past it).
1564+ ///
1565+ /// The subsampling domain is `{(0,0), (1,0), (1,1)}` and excludes
1566+ /// `(0,1)`: `ec-av1-syntax`'s `color_config` only ever READS
1567+ /// `subsampling_y` when `subsampling_x == 1` (sequence.rs:481), so
1568+ /// `(0,1)` is uncodable. `(1,0)` is 4:2:2, refused at the sequence
1569+ /// header by `a_non_420_subsampled_sequence_header_is_refused_by_name`
1570+ /// -- it is walked anyway, so the proof does not depend on that guard
1571+ /// staying in place.
1572+ #[test]
1573+ fn every_chroma_unit_decode_block_rect_can_present_has_a_coefficient_table() {
1574+ let src = include_str!("decode.rs");
1575+
1576+ // (1) The caller shape set, read out of the call sites' own
1577+ // argument lists. `decode_block_rect(dec, cdfs, neighbours, at, bw,
1578+ // bh, ...)`, so args 4 and 5 (0-based, after the opening paren) are
1579+ // `bw` and `bh`; the first three are the fixed `&mut` borrows.
1580+ const LEAD: [&str; 3] = ["&mut dec", "&mut cdfs", "&mut neighbours"];
1581+ let mut shapes: BTreeSet<(usize, usize)> = BTreeSet::new();
1582+ let mut sites = 0usize;
1583+ let at_def = src
1584+ .find("fn decode_block_rect(")
1585+ .expect("decode_block_rect is gone");
1586+ for (i, _) in src.match_indices("decode_block_rect(") {
1587+ // The definition's own parameter list carries the same text,
1588+ // preceded by "fn " -- that is a declaration, not a call.
1589+ if src[..i].ends_with("fn ") {
1590+ continue;
1591+ }
1592+ // Split the argument list at top level (paren/bracket/angle
1593+ // balanced), so the `(at32.0 + 1, at32.1)` origin argument --
1594+ // which contains its own comma -- does not shift the indices.
1595+ let open = i + "decode_block_rect(".len();
1596+ let bytes = src.as_bytes();
1597+ let mut args: Vec<String> = Vec::new();
1598+ let mut depth = 0i32;
1599+ let mut start = open;
1600+ for j in open..bytes.len() {
1601+ match bytes[j] {
1602+ b'(' | b'[' => depth += 1,
1603+ b')' | b']' => {
1604+ if depth == 0 {
1605+ args.push(src[start..j].to_string());
1606+ break;
1607+ }
1608+ depth -= 1;
1609+ }
1610+ b',' if depth == 0 => {
1611+ args.push(src[start..j].to_string());
1612+ start = j + 1;
1613+ }
1614+ _ => {}
1615+ }
1616+ }
1617+ assert!(
1618+ args.len() >= 6,
1619+ "a decode_block_rect call has only {} arguments -- the arg indices this \
1620+ enumeration reads are off",
1621+ args.len()
1622+ );
1623+ for k in 0..3 {
1624+ assert_eq!(
1625+ args[k].trim(),
1626+ LEAD[k],
1627+ "decode_block_rect's first three arguments changed -- re-derive the bw/bh \
1628+ argument indices below"
1629+ );
1630+ }
1631+ let lit = |a: &str| -> usize {
1632+ a.trim().parse::<usize>().unwrap_or_else(|_| {
1633+ panic!(
1634+ "decode_block_rect is called with a non-literal strip size {:?} -- \
1635+ this enumeration can no longer read the caller shape set",
1636+ a.trim()
1637+ )
1638+ })
1639+ };
1640+ shapes.insert((lit(&args[4]), lit(&args[5])));
1641+ sites += 1;
1642+ }
1643+ assert_eq!(
1644+ sites, 8,
1645+ "the number of decode_block_rect call sites changed"
1646+ );
1647+ let expected_shapes: BTreeSet<(usize, usize)> =
1648+ [(32usize, 16usize), (16, 32)].into_iter().collect();
1649+ assert_eq!(
1650+ shapes, expected_shapes,
1651+ "the set of strip sizes decode_block_rect is called with changed -- re-derive \
1652+ the chroma domain below. An 8x16/16x8 caller makes this refusal LIVE (a \
1653+ 4:2:0 8x16 luma strip's chroma is 4x8, which libaom codes as TX_4X8: \
1654+ av1_ss_size_lookup[BLOCK_8X16][1][1] = BLOCK_4X8 in \
1655+ av1/common/common_data.c:24, then max_txsize_rect_lookup[BLOCK_4X8] = TX_4X8 \
1656+ in av1/common/common_data.h:130, via av1_get_max_uv_txsize, blockd.h:1372)"
1657+ );
1658+
1659+ // (2) The table, read out of the function's own text: every
1660+ // `(w, h) =>` / `(w, h) |` arm head between the match and the guard.
1661+ let body_at = at_def;
1662+ let rest = &src[body_at..];
1663+ let body = &rest[..rest.find("\nfn ").expect("unterminated fn")];
1664+ let from = body
1665+ .find("let (chroma_set, chroma_scan): (TxbSet, &[u16]) = match (chroma_w, chroma_h)")
1666+ .expect("decode_block_rect's chroma match is gone");
1667+ let to = body[from..]
1668+ .find("a rectangular chroma transform whose size has no coefficient table")
1669+ .expect("the refusal string is gone from decode_block_rect")
1670+ + from;
1671+ let table = &body[from..to];
1672+ let mut arms: BTreeSet<(usize, usize)> = BTreeSet::new();
1673+ let bytes = table.as_bytes();
1674+ for (i, _) in table.match_indices('(') {
1675+ let mut j = i + 1;
1676+ let mut w = 0usize;
1677+ while j < bytes.len() && bytes[j].is_ascii_digit() {
1678+ w = w * 10 + usize::from(bytes[j] - b'0');
1679+ j += 1;
1680+ }
1681+ if j == i + 1 || !table[j..].starts_with(", ") {
1682+ continue;
1683+ }
1684+ j += 2;
1685+ let mut h = 0usize;
1686+ let start_h = j;
1687+ while j < bytes.len() && bytes[j].is_ascii_digit() {
1688+ h = h * 10 + usize::from(bytes[j] - b'0');
1689+ j += 1;
1690+ }
1691+ if j == start_h || !table[j..].starts_with(')') {
1692+ continue;
1693+ }
1694+ // Only an arm HEAD counts, never a `(32, 8)` inside prose.
1695+ let after = table[j + 1..].trim_start();
1696+ if after.starts_with("=>") || after.starts_with('|') {
1697+ arms.insert((w, h));
1698+ }
1699+ }
1700+ // (3) The enumeration itself -- run BEFORE the exact-table pin below
1701+ // so a deleted arm fails HERE, naming the footprint, instead of
1702+ // behind a vaguer "the table changed".
1703+ let mut checked = 0u32;
1704+ for &(bw, bh) in &shapes {
1705+ for (ss_x, ss_y) in [(0usize, 0usize), (1, 0), (1, 1)] {
1706+ let (cw, ch) = (bw >> ss_x, bh >> ss_y);
1707+ assert!(
1708+ arms.contains(&(cw, ch)),
1709+ "a {bw}x{bh} strip at subsampling ({ss_x},{ss_y}) has a {cw}x{ch} chroma \
1710+ transform with no coefficient table -- the chroma refusal is LIVE"
1711+ );
1712+ checked += 1;
1713+ }
1714+ }
1715+ assert_eq!(
1716+ checked, 6,
1717+ "the chroma domain is not two shapes x three formats"
1718+ );
1719+
1720+ // (4) And the table is EXACTLY those six rows -- no row is a shape no
1721+ // caller can present, which is what makes the `_` arm dead.
1722+ assert_eq!(
1723+ arms,
1724+ [
1725+ (8usize, 16usize),
1726+ (8, 32),
1727+ (16, 8),
1728+ (16, 16),
1729+ (16, 32),
1730+ (32, 16)
1731+ ]
1732+ .into_iter()
1733+ .collect::<BTreeSet<(usize, usize)>>(),
1734+ "decode_block_rect's chroma table changed -- re-derive the walk above"
1735+ );
1736+
1737+ // (5) The residual, stated as an assertion so it cannot rot: the two
1738+ // 4:2:0 rows an 8x16/16x8 luma strip would need are NOT in this
1739+ // table, and (4,8)/(8,4) is not a shape any caller can produce. If a
1740+ // future caller hands this function an 8x16, step (1) goes red
1741+ // first, and the new row has to be added here with it.
1742+ for residual in [(4usize, 8usize), (8, 4)] {
1743+ assert!(
1744+ !arms.contains(&residual),
1745+ "decode_block_rect grew a {0}x{1} chroma row -- update the residual note",
1746+ residual.0,
1747+ residual.1
1748+ );
1749+ }
1750+ let produces: BTreeSet<(usize, usize)> = shapes
1751+ .iter()
1752+ .flat_map(|&(bw, bh)| {
1753+ [(0usize, 0usize), (1, 0), (1, 1)]
1754+ .into_iter()
1755+ .map(move |(sx, sy)| (bw >> sx, bh >> sy))
1756+ })
1757+ .collect();
1758+ assert!(
1759+ !produces.contains(&(4, 8)) && !produces.contains(&(8, 4)),
1760+ "the caller set can now produce a 4x8/8x4 chroma shape but the table has no \
1761+ such row -- the chroma refusal is LIVE"
1762+ );
1763+ }
1764+
15141765 /// lane-av1-refusalaudit, ENUMERATION for "a 64-axis strip whose chroma
15151766 /// unit has no coefficient table" -- [`decode_block_rect64`]'s `_` arm,
15161767 /// reached only for depth-0, non-skip, non-lossless superblock-level
crates/ec-av1/src/stream.rsmodified+4336 -838

Diff too large; view file

@@ -1837,6 +1837,10 @@ fn decode_frame(
18371837 // 4:2:0 one never inherits the wrong plane count.
18381838 crate::decode::set_mono(seq.mono_chrome, fctx);
18391839 crate::decode::set_subsampling(seq.subsampling_x, seq.subsampling_y, fctx);
1840+ // lane-av1readcensus: the 4:4:4 coefficient-unit census is armed here,
1841+ // off the same sequence-header subsampling -- at 4:2:0/4:2:2 every census
1842+ // counter reads zero, so a 4:2:0 control can assert exactly that.
1843+ crate::decode::set_census_444(seq.subsampling_x, seq.subsampling_y);
18401844 // lane-av1txr: spec 5.9.2 `disable_cdf_update` -- a frame that sets it
18411845 // codes every tile symbol against the CDFs it started with, so the tile
18421846 // readers must not adapt (libaom `decodeframe.c:2909`:
@@ -2166,6 +2170,18 @@ pub fn intra_rect4_in_inter_counters() -> (usize, usize, usize, usize) {
21662170 )
21672171 }
21682172
2173+/// lane-av1recipehunt: the recipe sweep's view of the `delta_q` story from
2174+/// OUTSIDE the crate -- `(delta_q symbol groups read, rect64 dequant calls that
2175+/// saw `CURRENT_Q_IDX != base_q_idx`)`. A recipe that reads delta_q but never
2176+/// lands one inside a rect64 root is a different failure from one that reads
2177+/// neither, and the gate can only tell them apart with both numbers.
2178+pub fn rect64_qidx_drift_counters() -> (usize, usize) {
2179+ (
2180+ crate::decode::delta_q_hits(),
2181+ crate::decode::rect64_qidx_drift_hits(),
2182+ )
2183+}
2184+
21692185 #[cfg(test)]
21702186 pub(crate) mod tests {
21712187 use super::*;
@@ -6488,15 +6504,36 @@ pub(crate) mod tests {
64886504 eprintln!("SKIP {NAME}: no ffmpeg");
64896505 return;
64906506 }
6491- let Ok(stream) = std::fs::read(pin_dir().join("ll444-lossless-key.obu")) else {
6492- eprintln!(
6493- "SKIP {NAME}: no pinned bytes at {} -- regenerate with \
6494- `testsrc2 128x96` yuv444p 6 frames, aomenc --profile=1 --lossless=1 \
6495- --enable-palette=0 --enable-intrabc=0, cut to the key frame's OBUs",
6496- pin_dir().join("ll444-lossless-key.obu").display()
6497- );
6498- return;
6499- };
6507+ // lane-av1pins: committed at crates/ec-av1/fixtures/ll444-lossless-key.obu
6508+ // (7845 bytes; sha256
6509+ // f496ef0a1171c2bc66d411cc60db05db547dcdb49cd834d4e0543de9db441374),
6510+ // re-encoded 2026-09-29 from the recipe this very SKIP line records --
6511+ // `testsrc2 128x96` yuv444p 6 frames, aomenc --profile=1 --lossless=1
6512+ // --enable-palette=0 --enable-intrabc=0 --bit-depth=8 --cpu-used=0
6513+ // --threads=1 --row-mt=0 --lag-in-frames=0 --kf-max-dist=100, --limit=1
6514+ // so the key frame's OBUs are the whole stream (no OBU surgery needed).
6515+ //
6516+ // lane-av1skipfix: reading the pin from the GITIGNORED root
6517+ // `fixtures/` (`pin_dir()`) is what made this gate report green having
6518+ // decoded nothing -- a fresh clone, and every linked worktree, can
6519+ // never have that directory. The pin is now COMMITTED under the crate
6520+ // (the home the other pins use) and read through `CARGO_MANIFEST_DIR`,
6521+ // so a missing file is a REPO DEFECT and fails unconditionally: there
6522+ // is no environment left to escape, which is strictly stronger than
6523+ // the `EC_REQUIRE_FIXTURES` / `EC_AV1_REQUIRE_AOMENC` opt-in hard
6524+ // fail this arm used to carry.
6525+ let pin = crate_pin("ll444-lossless-key.obu");
6526+ let stream = std::fs::read(&pin).unwrap_or_else(|e| {
6527+ panic!(
6528+ "{NAME}: the pinned 4:4:4 lossless key frame is missing at {} ({e}). A \
6529+ COMMITTED pin that is absent is a repo defect and this gate would prove \
6530+ nothing. No script generates it -- regenerate it with `testsrc2 128x96` \
6531+ yuv444p 6 frames, aomenc --profile=1 --lossless=1 --enable-palette=0 \
6532+ --enable-intrabc=0 --bit-depth=8 --cpu-used=0 --threads=1 --row-mt=0 \
6533+ --lag-in-frames=0 --kf-max-dist=100 --limit=1, and commit the result.",
6534+ pin.display()
6535+ )
6536+ });
65006537 // Blindness guard: the pinned fixture must really be a lossless frame.
65016538 let mut parser = Av1Parser::new();
65026539 let mut pos = 0usize;
@@ -6858,6 +6895,128 @@ pub(crate) mod tests {
68586895 }
68596896 }
68606897
6898+ /// lane-av1lm444loss: a LOSSLESS block's transform-unit grid is clipped at
6899+ /// the FRAME edge, exactly as libaom's `max_block_high`/`max_block_wide`
6900+ /// clip it (`av1_common_int.h:1565`, `:1579` fold `mb_to_bottom_edge` /
6901+ /// `mb_to_right_edge` into `block_size_high/wide` before `>>
6902+ /// MI_SIZE_LOG2`), so a block hanging off the bottom/right codes only the
6903+ /// units inside the frame. `decode_token_recon_block` then bounds every
6904+ /// mu chunk with `unit_height = ROUND_POWER_OF_TWO(AOMMIN(mu_blocks_high
6905+ /// + row, max_blocks_high), ss_y)`, so the overflow units are never read
6906+ /// there either.
6907+ ///
6908+ /// Fixture is the sibling [`a_lossless_444_128_root_lossless_stream_reads_chunks_chunk_major`]
6909+ /// pin -- 128x96 yuv444p 4:4:4 lossless, 6 frames, 63429 bytes -- because
6910+ /// 96 is NOT a multiple of the 128 superblock: its five inter frames each
6911+ /// carry one unsplit 128 root that overhangs the bottom by 32 px. That is
6912+ /// the whole reason this stream is the witness. The frame is 24 mi tall,
6913+ /// so `max_blocks_high >> 2` is 24 transform rows where the block's own
6914+ /// `side / MI` is 32.
6915+ ///
6916+ /// The three assertions are all non-vacuous and all EXACT:
6917+ ///
6918+ /// 1. `lossless_edge_clipped()` fired -- 5, one per inter frame's 128
6919+ /// root. It is 0 on any frame whose height and width are multiples of
6920+ /// the superblock, so a stream that merely decodes cannot satisfy it.
6921+ /// 2. `lossless_edge_clip_units()` is 1280 = 5 x 256: the 8 transform rows
6922+ /// x 32 columns the unclipped walk read past the frame bottom, per
6923+ /// inter frame. The pre-fix walk read 2560 units per inter frame
6924+ /// against the oracle's 2304, and this is that 256.
6925+ /// 3. every sample of every frame matches the oracle `aomdec
6926+ /// --rawvideo` in decode order -- all six frames, hidden alt-ref
6927+ /// included, which the pre-fix tree failed from frame 1 on
6928+ /// (5596 wrong samples there, growing to 33561 by frame 5).
6929+ ///
6930+ /// The control arm pins the other direction of the invariant: the
6931+ /// `ll444_minp64_128root_control` stream has no overhanging root, so its
6932+ /// clip counters must both read 0 -- the clip cannot fire on a block that
6933+ /// fits, which is what keeps every other lossless pin byte-identical.
6934+ #[test]
6935+ fn a_lossless_block_clips_its_transform_grid_at_the_frame_edge() {
6936+ const NAME: &str = "a_lossless_block_clips_its_transform_grid_at_the_frame_edge";
6937+ const W: usize = 128;
6938+ const H: usize = 96;
6939+ const FRAMES: usize = 6;
6940+ /// 5 inter frames, one unsplit 128 root each; frame 0 splits.
6941+ const ROOTS: usize = 5;
6942+ /// `max_blocks_high >> 2` = 24 rows (96 px / 4), against the block's
6943+ /// own `side / MI` = 32 -- so 8 rows x 32 columns = 256 units per root
6944+ /// were read past the frame bottom before the clip.
6945+ const CLIP_UNITS_PER_ROOT: usize = 256;
6946+
6947+ let obu = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR"))
6948+ .join("fixtures/ll444_128root_lossless.obu");
6949+ let stream = read_pin(&obu, 63429, 0xf07d_47fc_fd51_2658, NAME);
6950+ let _guard = lock_gate_counters();
6951+ let (c0, u0) = (
6952+ crate::decode::lossless_edge_clipped(),
6953+ crate::decode::lossless_edge_clip_units(),
6954+ );
6955+ let frames = decode_stream(&stream)
6956+ .unwrap_or_else(|e| panic!("{NAME}: the pinned stream no longer decodes cleanly: {e}"));
6957+ let (c1, u1) = (
6958+ crate::decode::lossless_edge_clipped(),
6959+ crate::decode::lossless_edge_clip_units(),
6960+ );
6961+ assert_eq!(
6962+ c1 - c0,
6963+ ROOTS,
6964+ "{NAME}: the frame-edge clip fired on {}/{} of the 128 roots -- it must be 0 \
6965+ on a frame that fits, so this is what makes the gate non-vacuous",
6966+ c1 - c0,
6967+ ROOTS
6968+ );
6969+ assert_eq!(
6970+ u1 - u0,
6971+ ROOTS * CLIP_UNITS_PER_ROOT,
6972+ "{NAME}: the clip removed {}/{} transform units; the unclipped walk read {} \
6973+ per inter frame past the 96 px frame bottom (8 rows x 32 columns)",
6974+ u1 - u0,
6975+ ROOTS * CLIP_UNITS_PER_ROOT,
6976+ CLIP_UNITS_PER_ROOT
6977+ );
6978+ assert_eq!(frames.len(), FRAMES, "{NAME}: frame count");
6979+ for f in &frames {
6980+ assert_eq!((f.width, f.height), (W, H), "{NAME}: dimensions");
6981+ }
6982+ if aomdec_path().is_file() {
6983+ assert_rawvideo_matches(&obu, &stream, NAME, FRAMES);
6984+ } else {
6985+ eprintln!(
6986+ "SKIP {NAME} aomdec arm: no oracle aomdec at {}",
6987+ aomdec_path().display()
6988+ );
6989+ }
6990+
6991+ // Control: a stream whose roots all fit must not clip at all.
6992+ let ctrl = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR"))
6993+ .join("fixtures/ll444_minp64_128root_control.obu");
6994+ let ctrl_stream = read_pin(
6995+ &ctrl,
6996+ 61494,
6997+ 0xf6f5_a3cb_efc7_eb10,
6998+ &format!("{NAME} control"),
6999+ );
7000+ let (c2, u2) = (
7001+ crate::decode::lossless_edge_clipped(),
7002+ crate::decode::lossless_edge_clip_units(),
7003+ );
7004+ let _ = decode_stream(&ctrl_stream)
7005+ .unwrap_or_else(|e| panic!("{NAME}: the control arm no longer decodes cleanly: {e}"));
7006+ assert_eq!(
7007+ crate::decode::lossless_edge_clipped() - c2,
7008+ 0,
7009+ "{NAME} control: the clip fired on a stream whose blocks all fit -- the clip \
7010+ must be a no-op there, which is what keeps every other lossless pin \
7011+ byte-identical"
7012+ );
7013+ assert_eq!(
7014+ crate::decode::lossless_edge_clip_units() - u2,
7015+ 0,
7016+ "{NAME} control: the clip removed units from a stream whose blocks all fit"
7017+ );
7018+ }
7019+
68617020 /// lane-av1llpredgate2: the debug-exact pin for the ss-aware
68627021 /// `obmc_skip_chroma_above` decision (lane-av1-llpred2). Fixture is the
68637022 /// llpred/llpred2 reports' stream pinned into `fixtures/`: testsrc2
@@ -7377,7 +7536,237 @@ pub(crate) mod tests {
73777536 }
73787537 eprintln!("{NAME}: 4:2:0 control {h4} HORZ_4 / {v4} VERT_4 strips, 0 own-extent gathers");
73797538 }
7539+ /// lane-av1gates444: the live 4:4:4 LOSSY cell the chroma-format sweep
7540+ /// measured EXACT 4/4 and left unpinned. The recipe is the sweep's own
7541+ /// §6.2 encode, reproduced LIVE against the oracle `aomenc` rather than
7542+ /// from a pin, because the claim these three gates carry is a property
7543+ /// of the *decoder* at a geometry, not of a blob:
7544+ /// ```text
7545+ /// ffmpeg -f lavfi -i "testsrc2=size=<W>x<H>:rate=25" -frames:v 4 \
7546+ /// -pix_fmt yuv444p -f yuv4mpegpipe - | \
7547+ /// aomenc --codec=av1 --profile=1 --passes=1 --end-usage=q --cq-level=20 \
7548+ /// --cpu-used=2 --threads=1 --row-mt=0 --lag-in-frames=0 \
7549+ /// --kf-max-dist=100 --limit=4 --obu -o - -
7550+ /// ```
7551+ /// `rate=25` is load-bearing (testsrc2's pattern is time-parameterised)
7552+ /// and `--limit=4` is the sweep's frame count: at `--limit=6` the same
7553+ /// recipe emits 7674 / 11465 / 19121 bytes instead of the sweep's
7554+ /// 5938 / 8945 / 15239, i.e. a different stream than the one measured.
7555+ /// `--profile=1` is what makes the source 4:4:4 at all.
7556+ ///
7557+ /// Every assertion here is a non-vacuity assertion first and a pixel
7558+ /// compare second. The frame count, the per-frame geometry and the
7559+ /// FULL-RESOLUTION chroma plane length are asserted because a truncated
7560+ /// or 4:2:0-shaped decode can pass a lenient compare; the
7561+ /// `rect4_inter_own_chroma444_hits()` reach assert is there because the
7562+ /// class these cells belong to is the 4:4:4-only own-chroma-extent route
7563+ /// in [`decode_inter_block`]'s `around_c` (a 4:2:0 stream of the same
7564+ /// content leaves it at 0), and a counter at 0 would mean the gate
7565+ /// measured a different route than it names.
7566+ fn encode_444_lossy_live(name: &str, w: usize, h: usize) -> Vec<u8> {
7567+ if !have_aomenc() {
7568+ eprintln!(
7569+ "SKIP {name}: no aomenc oracle at {} -- run scripts/build-aom-oracle.sh",
7570+ aomenc_path().display()
7571+ );
7572+ return Vec::new();
7573+ }
7574+ let source = format!("testsrc2=size={w}x{h}:rate=25");
7575+ let y4m = Command::new("ffmpeg")
7576+ .args([
7577+ "-v",
7578+ "error",
7579+ "-f",
7580+ "lavfi",
7581+ "-i",
7582+ &source,
7583+ "-frames:v",
7584+ "4",
7585+ "-pix_fmt",
7586+ "yuv444p",
7587+ "-f",
7588+ "yuv4mpegpipe",
7589+ "-",
7590+ ])
7591+ .stdin(Stdio::null())
7592+ .stdout(Stdio::piped())
7593+ .stderr(Stdio::piped())
7594+ .output()
7595+ .expect("ffmpeg failed to run");
7596+ assert!(
7597+ y4m.status.success(),
7598+ "{name}: ffmpeg refused the {w}x{h} 4:4:4 source: {}",
7599+ String::from_utf8_lossy(&y4m.stderr)
7600+ );
7601+ let out = run_with_stdin(
7602+ Command::new(aomenc_path()).args([
7603+ "--codec=av1",
7604+ "--profile=1",
7605+ "--passes=1",
7606+ "--end-usage=q",
7607+ "--cq-level=20",
7608+ "--cpu-used=2",
7609+ "--threads=1",
7610+ "--row-mt=0",
7611+ "--lag-in-frames=0",
7612+ "--kf-max-dist=100",
7613+ "--limit=4",
7614+ "--obu",
7615+ "-o",
7616+ "-",
7617+ "-",
7618+ ]),
7619+ &y4m.stdout,
7620+ );
7621+ assert!(
7622+ out.status.success(),
7623+ "{name}: aomenc refused the {w}x{h} 4:4:4 lossy recipe: {}",
7624+ String::from_utf8_lossy(&out.stderr)
7625+ );
7626+ assert!(
7627+ !out.stdout.is_empty(),
7628+ "{name}: aomenc produced no OBU for {w}x{h} -- a zero-length stream would \
7629+ decode to nothing and the compare below would compare nothing"
7630+ );
7631+ out.stdout
7632+ }
7633+
7634+ /// The body every 4:4:4 lossy live gate runs: assert the oracle compare
7635+ /// CANNOT be skipped, assert the decode really is the cell it claims
7636+ /// (frame count, geometry, full-resolution chroma), assert the 4:4:4-only
7637+ /// own-extent route really ran, then compare every frame in decode order
7638+ /// against the oracle aomdec with the length asserted first.
7639+ ///
7640+ /// The aomdec assert is deliberately a HARD failure, not the
7641+ /// `if aomdec_path().is_file()` skip the older gates use: a gate that
7642+ /// measures exactness and then quietly skips the compare reports green
7643+ /// for a decoder it never looked at (class gate-blind-to-the-arm). It
7644+ /// fires only when the gate is actually running, i.e. the oracle aomenc
7645+ /// resolved -- and aomenc and aomdec ship in the same build directory,
7646+ /// so an aomdec that is missing while aomenc is present is a broken
7647+ /// oracle, not a checkout without one.
7648+ fn gate_444_lossy_live_exact(name: &str, w: usize, h: usize) {
7649+ let stream = encode_444_lossy_live(name, w, h);
7650+ if stream.is_empty() {
7651+ return; // no oracle at all: the SKIP above already said so
7652+ }
7653+ assert!(
7654+ aomdec_path().is_file(),
7655+ "{name}: the oracle aomenc resolved to {} but no aomdec sits beside it at {} -- \
7656+ the pixel compare would silently skip, which this gate treats as a failure",
7657+ aomenc_path().display(),
7658+ aomdec_path().display()
7659+ );
7660+
7661+ let _guard = lock_gate_counters();
7662+ crate::decode::reset_rect4_inter_own_chroma444_hits();
7663+ let frames = decode_stream(&stream).unwrap_or_else(|e| {
7664+ panic!("{name}: the live {w}x{h} 4:4:4 lossy stream was refused: {e}")
7665+ });
7666+ let own = crate::decode::rect4_inter_own_chroma444_hits();
7667+ assert!(
7668+ own > 0,
7669+ "{name}: no 4:4:4 1:4 inter strip read its chroma context over its own extent -- \
7670+ the route this cell is a witness for never ran (measured: 13 at 66x66, 12 at \
7671+ 130x122, 24 at 256x128)"
7672+ );
7673+ assert_eq!(
7674+ frames.len(),
7675+ 4,
7676+ "{name}: decoded {} frame(s), the recipe encodes 4 -- a short decode would make the \
7677+ oracle compare cover a prefix of the cell",
7678+ frames.len()
7679+ );
7680+ for (i, f) in frames.iter().enumerate() {
7681+ assert_eq!(
7682+ (f.width, f.height),
7683+ (w, h),
7684+ "{name}: frame {i} is {}x{}, the cell is {w}x{h}",
7685+ f.width,
7686+ f.height
7687+ );
7688+ // At 4:4:4 both chroma planes are full resolution. A decoder that
7689+ // kept a subsampled extent would hand quarter-size planes to the
7690+ // byte compare; say so here instead of letting the compare
7691+ // stand in for the shape claim.
7692+ assert_eq!(
7693+ f.u.len(),
7694+ w * h,
7695+ "{name}: frame {i} U plane is {} samples; at 4:4:4 it must be full resolution \
7696+ ({w}x{h})",
7697+ f.u.len()
7698+ );
7699+ assert_eq!(
7700+ f.v.len(),
7701+ w * h,
7702+ "{name}: frame {i} V plane is {} samples; at 4:4:4 it must be full resolution \
7703+ ({w}x{h})",
7704+ f.v.len()
7705+ );
7706+ assert_eq!(
7707+ f.y.len(),
7708+ w * h,
7709+ "{name}: frame {i} luma plane is {} samples, expected {w}x{h}",
7710+ f.y.len()
7711+ );
7712+ }
7713+ let (decoded, hidden) = decode_all_frames_vs_oracle(&stream, name);
7714+ assert_eq!(
7715+ decoded, 4,
7716+ "{name}: the oracle decoded {decoded} frame(s) in decode order, the recipe carries 4 \
7717+ (so far {hidden} hidden)"
7718+ );
7719+ eprintln!(
7720+ "{name}: {w}x{h} 4:4:4 lossy, {decoded} decode-order frame(s) byte-exact vs aomdec \
7721+ ({hidden} hidden), {own} own-extent 1:4 chroma gather(s)"
7722+ );
7723+ }
73807724
7725+ /// lane-av1gates444 cell 1: **odd coded dims, 66x66** -- the partial-frame
7726+ /// walk in BOTH axes (66 is not a multiple of 8, so the frame is a
7727+ /// partial superblock column AND a partial row). Measured EXACT 4/4 by
7728+ /// the chroma-format sweep (§6.2, 5938 bytes) and unpinned: nothing in
7729+ /// the crate would go red if the odd-dimension 4:4:4 walk regressed,
7730+ /// and the only red-before evidence was a lane report nobody re-runs.
7731+ #[test]
7732+ fn a_444_lossy_odd_66x66_stream_decodes_pixel_exact() {
7733+ gate_444_lossy_live_exact("a_444_lossy_odd_66x66_stream_decodes_pixel_exact", 66, 66);
7734+ }
7735+
7736+ /// lane-av1gates444 cell 2: **odd coded dims, 130x122** -- the
7737+ /// partial-frame RIGHT edge that the sweep found DIVERGENT (first wrong
7738+ /// sample Y(128,16), 11521 samples on frame 3) until lane-av1444rect's
7739+ /// 4:4:4 own-chroma-extent fix landed. It measures EXACT 4/4 on this
7740+ /// tree and is the discriminating geometry: 66x66 was exact at the same
7741+ /// settings while this was not, so the pair is what keeps "the 4:4:4
7742+ /// partial-frame walk is right" from being a one-geometry accident.
7743+ #[test]
7744+ fn a_444_lossy_odd_130x122_stream_decodes_pixel_exact() {
7745+ gate_444_lossy_live_exact(
7746+ "a_444_lossy_odd_130x122_stream_decodes_pixel_exact",
7747+ 130,
7748+ 122,
7749+ );
7750+ }
7751+
7752+ /// lane-av1gates444 cell 3: **256x128**, the sweep's cell recorded as
7753+ /// "4:4:4 superres 256x128 (`--superres-mode=1`)".
7754+ ///
7755+ /// IT IS NOT A SUPERRES CELL, and this gate is named for what it is
7756+ /// instead. Measured here, live: encoding 256x128 with and without
7757+ /// `--superres-mode=1` produces BYTE-IDENTICAL OBU (15239 bytes,
7758+ /// sha256 06621606…, both), so the flag is a no-op on this aomenc build
7759+ /// and the sweep's cell was a plain 4:4:4 lossy cq-20 stream that
7760+ /// happened to carry the flag. The cell's actual value is the geometry
7761+ /// plus the filter stages: 256x128 is two full 128 superblock columns,
7762+ /// and the strip walk runs there with the post-deblock/CDEF/LR chain
7763+ /// live on the later frames -- so this is the third witness for the
7764+ /// 4:4:4 lossy strip class at a geometry the 128x96 rect4 gate does not
7765+ /// cover.
7766+ #[test]
7767+ fn a_444_lossy_256x128_stream_decodes_pixel_exact() {
7768+ gate_444_lossy_live_exact("a_444_lossy_256x128_stream_decodes_pixel_exact", 256, 128);
7769+ }
73817770 /// lane-av1444rect r2 — the SAME class as the gate above, second
73827771 /// instance: `decode_rect4_16_intrabc` applied the 4:2:0 pair geometry at
73837772 /// ss (0,0), where `is_chroma_reference` makes an intra-BC 1:4 strip its
@@ -8568,48 +8957,118 @@ pub(crate) mod tests {
85688957 /// CDEF *on* (no `-enable-cdef 0`) -- the whole point of `lane-av1cdef`:
85698958 /// proves `apply_cdef` itself, not just that this decoder still works
85708959 /// when the filter never fires. Gradient content at a low crf reliably
8571- /// gives libaom something to dering. If a run happens to land on
8572- /// `cdef_bits > 0` (per-64x64 `cdef_idx`, still unimplemented -- see the
8573- /// refusal in `decode_stream`) the stream is skipped rather than failed:
8574- /// that gap is named by the refusal's own error text, not silently
8575- /// swallowed here.
8960+ /// gives libaom something to dering.
8961+ ///
8962+ /// lane-av1skipfix: the attempt-loop shape. A single-SB 64x64 frame can
8963+ /// never make libaom write `cdef_bits > 0` (nothing to differentiate per
8964+ /// superblock), so this recipe is MULTI-SB and MULTI-FRAME, and it sweeps
8965+ /// (size, cpu-used, crf) until one attempt reads a real `cdef_idx` literal
8966+ /// -- MEASURED 2026-09-29 on `a21f3680`: 64x64 at every crf/cpu reads
8967+ /// ZERO `cdef_idx` (single superblock, `bits == 0`, though `apply_cdef`
8968+ /// does filter with a nonzero strength pair), while 128x64/128x128 at
8969+ /// 24 frames read 2-8. Every attempt that decodes is ALWAYS pixel-
8970+ /// compared against ffmpeg's own decode of the identical bytes; a decode
8971+ /// error is a named refusal recorded per attempt, never a SKIP, and
8972+ /// exhausting every attempt -- or decoding without ever reading a
8973+ /// `cdef_idx` -- is a hard FAILURE (an unfired gate is a vacuous gate,
8974+ /// class `gate-skips-on-its-own-failure`).
85768975 #[test]
85778976 fn a_real_libaom_gradients_stream_with_cdef_decodes_pixel_exact() {
8977+ const NAME: &str = "a_real_libaom_gradients_stream_with_cdef_decodes_pixel_exact";
8978+ let _gate_lock = lock_gate_counters();
85788979 if !have_ffmpeg() {
8579- eprintln!(
8580- "SKIP a_real_libaom_gradients_stream_with_cdef_decodes_pixel_exact: no ffmpeg"
8581- );
8980+ eprintln!("SKIP {NAME}: no ffmpeg");
85828981 return;
85838982 }
8584- let (width, height) = (64, 64);
8585- let stream = libaom_encode_with(
8586- &gradients_source(42, width, height, "rate=1"),
8587- width,
8588- height,
8589- 30,
8590- &[
8591- "-threads",
8592- "1",
8593- "-row-mt",
8594- "0",
8595- "-tile-columns",
8596- "0",
8597- "-tile-rows",
8598- "0",
8599- ],
8600- )
8601- .expect("ffmpeg encode");
8602- match decode_stream(&stream) {
8603- Ok(frames) => {
8604- let ffmpeg_frames = ffmpeg_decode_sequence(&stream, width, height, 1);
8605- assert_eq!(frames[0].y, ffmpeg_frames[0].y, "luma vs ffmpeg (CDEF on)");
8606- assert_eq!(frames[0].u, ffmpeg_frames[0].u, "U vs ffmpeg (CDEF on)");
8607- assert_eq!(frames[0].v, ffmpeg_frames[0].v, "V vs ffmpeg (CDEF on)");
8983+ // (width, height, frames, cpu-used, crf). The frame count is what
8984+ // gives libaom's cdef search more than one superblock to price.
8985+ const RECIPES: [(usize, usize, usize, &str, u32); 8] = [
8986+ (128, 64, 24, "0", 20),
8987+ (128, 64, 24, "2", 20),
8988+ (128, 64, 24, "0", 16),
8989+ (128, 128, 24, "2", 20),
8990+ (128, 128, 24, "0", 16),
8991+ (128, 128, 24, "0", 24),
8992+ (128, 64, 24, "2", 24),
8993+ (128, 128, 24, "2", 24),
8994+ ];
8995+ let mut refusals = Vec::new();
8996+ let mut counted_exact = 0u32;
8997+ let mut uncounted_exact = 0u32;
8998+ for (w, h, frames, cpu, crf) in RECIPES {
8999+ let Some(stream) = libaom_encode_with(
9000+ &gradients_source(42, w, h, "rate=25"),
9001+ w,
9002+ h,
9003+ crf,
9004+ &[
9005+ "-cpu-used",
9006+ cpu,
9007+ "-frames:v",
9008+ &frames.to_string(),
9009+ "-threads",
9010+ "1",
9011+ "-row-mt",
9012+ "0",
9013+ "-tile-columns",
9014+ "0",
9015+ "-tile-rows",
9016+ "0",
9017+ ],
9018+ ) else {
9019+ refusals.push(format!(
9020+ "{w}x{h} cpu-used {cpu} crf {crf}: ffmpeg itself refused"
9021+ ));
9022+ continue;
9023+ };
9024+ let before = decode::cdef_idx_hits();
9025+ let decoded = match decode_stream(&stream) {
9026+ Ok(frames) => frames,
9027+ Err(e) => {
9028+ refusals.push(format!("{w}x{h} cpu-used {cpu} crf {crf}: {e}"));
9029+ continue;
9030+ }
9031+ };
9032+ // A decode that succeeded is ALWAYS pixel-compared; the hit
9033+ // counter only decides whether the attempt counts as firing
9034+ // (class `counter-from-refused-stream`).
9035+ let counted = decode::cdef_idx_hits() != before;
9036+ if counted {
9037+ counted_exact += 1;
9038+ } else {
9039+ uncounted_exact += 1;
86089040 }
8609- Err(e) => {
8610- eprintln!("SKIP a_real_libaom_gradients_stream_with_cdef_decodes_pixel_exact: {e}");
9041+ let ffmpeg_frames = ffmpeg_decode_sequence(&stream, w, h, frames);
9042+ assert_eq!(decoded.len(), frames);
9043+ for (i, (got, want)) in decoded.iter().zip(&ffmpeg_frames).enumerate() {
9044+ assert_eq!(
9045+ got.y, want.y,
9046+ "{NAME} frame {i} luma vs ffmpeg ({w}x{h} cpu-used {cpu} crf {crf}, \
9047+ cdef_idx fired: {counted})"
9048+ );
9049+ assert_eq!(
9050+ got.u, want.u,
9051+ "{NAME} frame {i} U vs ffmpeg ({w}x{h} cpu-used {cpu} crf {crf}, \
9052+ cdef_idx fired: {counted})"
9053+ );
9054+ assert_eq!(
9055+ got.v, want.v,
9056+ "{NAME} frame {i} V vs ffmpeg ({w}x{h} cpu-used {cpu} crf {crf}, \
9057+ cdef_idx fired: {counted})"
9058+ );
9059+ }
9060+ if counted_exact >= 2 {
9061+ break;
86119062 }
86129063 }
9064+ gate_buckets(NAME, counted_exact, uncounted_exact, refusals.len());
9065+ assert!(
9066+ counted_exact > 0,
9067+ "{NAME}: no attempt of {} read a cdef_idx literal -- CDEF is not exercised \
9068+ (class gate-blind-to-feature):\n{}",
9069+ RECIPES.len(),
9070+ refusals.join("\n")
9071+ );
86139072 }
86149073
86159074 /// Path to a real `aomenc` build carrying the reference options this
@@ -8661,6 +9120,23 @@ pub(crate) mod tests {
86619120 .unwrap_or_else(|_| std::path::PathBuf::from("fixtures"))
86629121 }
86639122
9123+ /// A COMMITTED pin: `crates/ec-av1/fixtures/<name>`, which travels in the
9124+ /// tarball and is therefore present on every runner. `pin_dir()` resolves
9125+ /// to the gitignored root `fixtures/`, so a pin written there is lost when
9126+ /// the machine's scratchpad is reaped -- three gates sat at `rc=0` having
9127+ /// tested nothing for exactly that reason (lane-av1pins). Falls back to
9128+ /// `pin_dir()` so a locally re-captured stream still overrides.
9129+ fn crate_pin(name: &str) -> std::path::PathBuf {
9130+ let in_crate = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR"))
9131+ .join("fixtures")
9132+ .join(name);
9133+ if in_crate.is_file() {
9134+ in_crate
9135+ } else {
9136+ pin_dir().join(name)
9137+ }
9138+ }
9139+
86649140 fn have_aomenc() -> bool {
86659141 let present = aomenc_path().is_file();
86669142 assert!(
@@ -8992,124 +9468,171 @@ pub(crate) mod tests {
89929468 /// decoder has no in-loop deblocking filter at all, and libaom's default
89939469 /// (on) smooths every block-boundary column, which first looked like a
89949470 /// filter-intra math bug (mismatches straddling the 32-pixel block
8995- /// seam) until the recipe without it round-tripped byte-exact. Checks
8996- /// [`decode::filter_intra_hits`] actually moved (a process-global
8997- /// counter, so before/after rather than an absolute value) to prove the
8998- /// symbol fired, then pixel-exactness against ffmpeg's own decode of the
8999- /// identical bytes on every plane.
9471+ /// seam) until the recipe without it round-tripped byte-exact.
9472+ ///
9473+ /// lane-av1skipfix: the attempt-loop shape this gate's single recipe
9474+ /// lacked. It sweeps (seed, cq) and REQUIRES at least one attempt to both
9475+ /// decode and read `use_filter_intra`: a decode error on EVERY attempt is
9476+ /// a hard failure carrying the refusal texts, not a printed SKIP, and an
9477+ /// attempt that decodes without the symbol firing is still pixel-compared
9478+ /// (class `gate-skips-on-its-own-failure`). MEASURED 2026-09-29 on
9479+ /// `a21f3680`: seed 42 cq 40 and seed 43 cq 40 read the symbol 3x each,
9480+ /// pixel-exact, while seed 44 cq 45 and seed 45 cq 30 decode WITHOUT it --
9481+ /// so the one fixed recipe really did carry the whole gate.
9482+ ///
9483+ /// The per-attempt decode error the old single recipe SKIPped on is
9484+ /// `screen_content_tools_determination` (libaom `encoder_utils.c`): a real
9485+ /// internal trial-encode/PSNR comparison, not a flag this CLI exposes a
9486+ /// knob for -- on this flat gradient fixture it lands on
9487+ /// `allow_screen_content_tools=0` most runs but occasionally trips over
9488+ /// its 0.9 dB threshold the other way even with palette/intrabc both
9489+ /// disabled. That is a genuine separate gap (`decode_stream` never reads
9490+ /// `intrabc`/`palette_mode_info`), so it is a NAMED REFUSAL counted per
9491+ /// attempt, never a silent skip and never a pass.
90009492 #[test]
90019493 fn a_real_aomenc_filter_intra_stream_decodes_pixel_exact() {
9494+ const NAME: &str = "a_real_aomenc_filter_intra_stream_decodes_pixel_exact";
9495+ let _gate_lock = lock_gate_counters();
90029496 if !have_ffmpeg() {
9003- eprintln!("SKIP a_real_aomenc_filter_intra_stream_decodes_pixel_exact: no ffmpeg");
9497+ eprintln!("SKIP {NAME}: no ffmpeg");
90049498 return;
90059499 }
90069500 if !have_aomenc() {
9007- eprintln!(
9008- "SKIP a_real_aomenc_filter_intra_stream_decodes_pixel_exact: no aomenc at {}",
9009- aomenc_path().display()
9010- );
9501+ eprintln!("SKIP {NAME}: no aomenc at {}", aomenc_path().display());
90119502 return;
90129503 }
90139504 let (width, height) = (64usize, 64usize);
9014- // Recipe-search hooks: with the encoder pinned to one thread the
9015- // stream is a deterministic function of (seed, cq), so a firing recipe
9016- // can be searched for without a rebuild.
9505+ // Recipe-search hooks: with the encoder pinned to one thread the stream
9506+ // is a deterministic function of (seed, cq), so a firing recipe can be
9507+ // searched for without a rebuild. These pin attempt 0 for a bisect; the
9508+ // sweep walks the same axes regardless.
90179509 let fi_seed: u32 = std::env::var("EC_FI_SEED")
90189510 .ok()
90199511 .and_then(|v| v.parse().ok())
90209512 .unwrap_or(42);
9021- let fi_source = gradients_source(fi_seed, 64, 64, "duration=0.04:rate=25");
9022- let fi_cq = std::env::var("EC_FI_CQ").unwrap_or_else(|_| "40".to_string());
9023- let fi_cq_arg = format!("--cq-level={fi_cq}");
9024- let y4m = Command::new("ffmpeg")
9025- .args([
9026- "-v",
9027- "error",
9028- "-f",
9029- "lavfi",
9030- "-i",
9031- &fi_source,
9032- "-pix_fmt",
9033- "yuv420p",
9034- "-f",
9035- "yuv4mpegpipe",
9036- "-",
9037- ])
9038- .stdin(Stdio::null())
9039- .stdout(Stdio::piped())
9040- .stderr(Stdio::piped())
9041- .output()
9042- .expect("ffmpeg failed to run");
9043- assert!(
9044- y4m.status.success(),
9045- "ffmpeg refused to generate the y4m fixture: {}",
9046- String::from_utf8_lossy(&y4m.stderr)
9047- );
9048- let out = run_with_stdin(
9049- Command::new(aomenc_path()).args([
9050- "--codec=av1",
9051- "--passes=1",
9052- "--end-usage=q",
9053- &fi_cq_arg,
9054- "--cpu-used=0",
9055- // Every sibling gate pins these; this one did not, and a
9056- // multi-threaded aomenc is not deterministic, so each run
9057- // encoded a slightly different stream and the gate flaked
9058- // against whichever features that run happened to pick.
9059- // Pinning them makes seed 42 mean one stream (class
9060- // `parallel-flake-is-attempt-selection`).
9061- "--threads=1",
9062- "--row-mt=0",
9063- "--enable-filter-intra=1",
9064- "--enable-smooth-intra=0",
9065- "--enable-paeth-intra=0",
9066- "--enable-directional-intra=0",
9067- "--enable-angle-delta=0",
9068- "--enable-tx-size-search=0",
9069- "--enable-cdef=0",
9070- "--max-partition-size=32",
9071- "--loopfilter-control=0",
9072- "--enable-palette=0",
9073- "--enable-intrabc=0",
9074- "--obu",
9075- "-o",
9076- "-",
9077- "-",
9078- ]),
9079- &y4m.stdout,
9080- );
9081- assert!(
9082- out.status.success(),
9083- "aomenc refused the fixture: {}",
9084- String::from_utf8_lossy(&out.stderr)
9085- );
9086- let stream = out.stdout;
9087- let before = decode::filter_intra_hits();
9088- // `screen_content_tools_determination` (libaom encoder_utils.c) is a
9089- // real internal trial-encode/PSNR comparison, not a flag this CLI
9090- // exposes a knob for -- on this flat gradient fixture it lands on
9091- // `allow_screen_content_tools=0` most runs but occasionally trips
9092- // over its 0.9 dB threshold the other way even with palette/intrabc
9093- // both disabled. That is a genuine separate gap (`decode_stream`
9094- // never reads `intrabc`/`palette_mode_info`), not a filter-intra
9095- // regression, so it is skipped here exactly as
9096- // `a_real_libaom_gradients_stream_with_cdef_decodes_pixel_exact`
9097- // above skips its own still-unsupported-gap runs.
9098- let frames = match decode_stream(&stream) {
9099- Ok(frames) => frames,
9100- Err(e) => {
9101- eprintln!("SKIP a_real_aomenc_filter_intra_stream_decodes_pixel_exact: {e}");
9102- return;
9513+ let fi_cq: u32 = std::env::var("EC_FI_CQ")
9514+ .ok()
9515+ .and_then(|v| v.parse().ok())
9516+ .unwrap_or(40);
9517+ // Two seeds x three quantisers, so "every attempt refused" and "no
9518+ // attempt ever read `use_filter_intra`" are distinguishable failures
9519+ // rather than one unlucky recipe.
9520+ const CQS: [u32; 3] = [40, 35, 30];
9521+ let mut refusals = Vec::new();
9522+ let mut counted_exact = 0u32;
9523+ let mut uncounted_exact = 0u32;
9524+ 'attempts: for round in 0..2u32 {
9525+ for (i, &walked) in CQS.iter().enumerate() {
9526+ let seed = fi_seed + round;
9527+ let cq = if round == 0 && i == 0 { fi_cq } else { walked };
9528+ let source = gradients_source(seed, width, height, "duration=0.04:rate=25");
9529+ let y4m = Command::new("ffmpeg")
9530+ .args([
9531+ "-v",
9532+ "error",
9533+ "-f",
9534+ "lavfi",
9535+ "-i",
9536+ &source,
9537+ "-pix_fmt",
9538+ "yuv420p",
9539+ "-f",
9540+ "yuv4mpegpipe",
9541+ "-",
9542+ ])
9543+ .stdin(Stdio::null())
9544+ .stdout(Stdio::piped())
9545+ .stderr(Stdio::piped())
9546+ .output()
9547+ .expect("ffmpeg failed to run");
9548+ assert!(
9549+ y4m.status.success(),
9550+ "ffmpeg refused to generate the y4m fixture: {}",
9551+ String::from_utf8_lossy(&y4m.stderr)
9552+ );
9553+ let cq_arg = format!("--cq-level={cq}");
9554+ let out = run_with_stdin(
9555+ Command::new(aomenc_path()).args([
9556+ "--codec=av1",
9557+ "--passes=1",
9558+ "--end-usage=q",
9559+ &cq_arg,
9560+ "--cpu-used=0",
9561+ // Every sibling gate pins these; this one did not, and a
9562+ // multi-threaded aomenc is not deterministic, so each run
9563+ // encoded a slightly different stream and the gate flaked
9564+ // against whichever features that run happened to pick.
9565+ // Pinning them makes seed 42 mean one stream (class
9566+ // `parallel-flake-is-attempt-selection`).
9567+ "--threads=1",
9568+ "--row-mt=0",
9569+ "--enable-filter-intra=1",
9570+ "--enable-smooth-intra=0",
9571+ "--enable-paeth-intra=0",
9572+ "--enable-directional-intra=0",
9573+ "--enable-angle-delta=0",
9574+ "--enable-tx-size-search=0",
9575+ "--enable-cdef=0",
9576+ "--max-partition-size=32",
9577+ "--loopfilter-control=0",
9578+ "--enable-palette=0",
9579+ "--enable-intrabc=0",
9580+ "--obu",
9581+ "-o",
9582+ "-",
9583+ "-",
9584+ ]),
9585+ &y4m.stdout,
9586+ );
9587+ assert!(
9588+ out.status.success(),
9589+ "{NAME}: aomenc refused the seed {seed} cq {cq} fixture: {}",
9590+ String::from_utf8_lossy(&out.stderr)
9591+ );
9592+ let stream = out.stdout;
9593+ let before = decode::filter_intra_hits();
9594+ let frames = match decode_stream(&stream) {
9595+ Ok(frames) => frames,
9596+ Err(e) => {
9597+ refusals.push(format!("seed {seed} cq {cq}: {e}"));
9598+ continue;
9599+ }
9600+ };
9601+ // A decode that succeeded is ALWAYS pixel-compared; the hit
9602+ // counter only decides whether the attempt counts as firing
9603+ // (class `counter-from-refused-stream`).
9604+ let counted = decode::filter_intra_hits() != before;
9605+ if counted {
9606+ counted_exact += 1;
9607+ } else {
9608+ uncounted_exact += 1;
9609+ }
9610+ let ffmpeg_frames = ffmpeg_decode_sequence(&stream, width, height, 1);
9611+ assert_eq!(
9612+ frames[0].y, ffmpeg_frames[0].y,
9613+ "luma vs ffmpeg (seed {seed} cq {cq}, use_filter_intra fired: {counted})"
9614+ );
9615+ assert_eq!(
9616+ frames[0].u, ffmpeg_frames[0].u,
9617+ "U vs ffmpeg (seed {seed} cq {cq}, use_filter_intra fired: {counted})"
9618+ );
9619+ assert_eq!(
9620+ frames[0].v, ffmpeg_frames[0].v,
9621+ "V vs ffmpeg (seed {seed} cq {cq}, use_filter_intra fired: {counted})"
9622+ );
9623+ if counted_exact >= 2 {
9624+ break 'attempts;
9625+ }
91039626 }
9104- };
9627+ }
9628+ gate_buckets(NAME, counted_exact, uncounted_exact, refusals.len());
91059629 assert!(
9106- decode::filter_intra_hits() > before,
9107- "use_filter_intra never fired decoding this stream"
9630+ counted_exact > 0,
9631+ "{NAME}: none of {} attempts decoded a stream that read use_filter_intra -- the \
9632+ gate would prove nothing (class gate-blind-to-feature):\n{}",
9633+ CQS.len() * 2,
9634+ refusals.join("\n")
91089635 );
9109- let ffmpeg_frames = ffmpeg_decode_sequence(&stream, width, height, 1);
9110- assert_eq!(frames[0].y, ffmpeg_frames[0].y, "luma vs ffmpeg");
9111- assert_eq!(frames[0].u, ffmpeg_frames[0].u, "U vs ffmpeg");
9112- assert_eq!(frames[0].v, ffmpeg_frames[0].v, "V vs ffmpeg");
91139636 }
91149637
91159638 /// A real `aomenc` palette-Y fixture (lane-palette r3): `smptebars`
@@ -9637,6 +10160,338 @@ pub(crate) mod tests {
963710160 );
963810161 }
963910162
10163+ /// lane-av1toolgates: the shared body of the two `enable-rect-tx`
10164+ /// coverage gates (8-bit and 10-bit).
10165+ ///
10166+ /// The aomenc ARGUMENT VECTOR is built by each gate and passed in, never
10167+ /// assembled here. That is not tidiness: `gate_coverage`'s `gate_bodies()`
10168+ /// splits `stream.rs` on `\n #[` and keeps a segment only if that
10169+ /// segment itself contains `--passes=1`, so a flag living in a helper is
10170+ /// invisible to the coverage derivation. A helper that owns the recipe
10171+ /// would leave this gate counted at whatever depth the helper's own text
10172+ /// implies -- which is the blind spot that kept `enable-rect-tx` on the
10173+ /// `NEVER_EXERCISED` lists after real streams had exercised it.
10174+ ///
10175+ /// WHAT THIS GATE IS AND IS NOT. `enable_rect_tx` has no sequence-header
10176+ /// bit in AV1 -- aom reads it only in `tx_search.c` (`search_tx_size`'s
10177+ /// `!enable_rect_tx && tx_size_wide != tx_size_high` skip and the
10178+ /// `tx_size_max_32_square` remap) -- so the flag never reaches a decoder.
10179+ /// Spelling `--enable-rect-tx=1` proves the ENCODER was ALLOWED the tool
10180+ /// and nothing more. It is CONTEXT here, not the witness: a gate that
10181+ /// stopped at the flag would be the `tool-disabled-in-every-gate` defect
10182+ /// `NEVER_EXERCISED` exists to prevent, in a new costume.
10183+ ///
10184+ /// The witness is the PARSED PARTITION SHAPE, the only thing in the
10185+ /// bitstream that can carry a rect transform:
10186+ /// [`decode::rect_partition_hits`] counts `PARTITION_HORZ`/`PARTITION_VERT`
10187+ /// symbols actually read, i.e. a rect partition in the tree this decoder
10188+ /// walked, and [`decode::rect_coeff_tu_hits`] counts the rectangular
10189+ /// transform units that then coded coefficients through `read_coeffs_rect`
10190+ /// (`all_zero == 0`) -- the rect coefficient TABLES being read, not a
10191+ /// header bit. Both are asserted above zero over the arms that decoded AND
10192+ /// compared, and every frame is pixel-compared against ffmpeg's own decode
10193+ /// of the identical bytes.
10194+ ///
10195+ /// LIMIT, stated because it bounds what this gate can claim: this
10196+ /// repository has no INDEPENDENT partition parser to list leaves from --
10197+ /// `ec-av1-syntax` parses OBU headers and the sequence header only -- and
10198+ /// `ec_av1::census`'s per-frame `blocks`/`tx` shape maps, the one true
10199+ /// leaf list, are armed by a process-global `OnceLock` on
10200+ /// `EC_AV1_BITCENSUS`, so arming them inside a lib test would switch the
10201+ /// accountant on for every other gate in the process. The partition walk is
10202+ /// therefore observed through the decoder's own counters, which is weaker
10203+ /// than a second opinion but is still a shape fact about the stream rather
10204+ /// than a fact about the flag.
10205+ ///
10206+ /// RED-BEFORE: the COUNTERS, one per assert, both measured.
10207+ /// `--enable-rect-tx=0` is deliberately NOT claimed as the mutation: it
10208+ /// does NOT zero these counters (39 rect coefficient TUs against 210 on
10209+ /// the cq20 arm, because `--enable-rect-partitions=1` already forces
10210+ /// non-square transform sizes regardless), and with every partition shape
10211+ /// off the flag yields no rect transform at either setting. `=0` does turn
10212+ /// the gate red, but through the ORACLE -- its `--enable-tx-size-search=0`
10213+ /// arm is a stream ffmpeg cannot decode past frame 6 of 15 -- so the
10214+ /// frame-count assert fires first and proves nothing about the tool.
10215+ fn rect_tx_tool_gate(name: &str, ten_bit: bool, args: &[String]) -> (usize, usize) {
10216+ // A missing tool SKIPs, so the totals the caller sums stay 0 and the
10217+ // gate's own witness assert fails loudly instead of passing vacuously
10218+ // on a run that decoded nothing.
10219+ if !have_ffmpeg() {
10220+ eprintln!("SKIP {name}: no ffmpeg");
10221+ return (0, 0);
10222+ }
10223+ if !have_aomenc() {
10224+ eprintln!("SKIP {name}: no aomenc at {}", aomenc_path().display());
10225+ return (0, 0);
10226+ }
10227+ let (width, height) = (64usize, 64usize);
10228+ let y4m = Command::new("ffmpeg")
10229+ .args([
10230+ "-v",
10231+ "error",
10232+ "-f",
10233+ "lavfi",
10234+ "-i",
10235+ "mandelbrot=size=64x64:rate=25",
10236+ "-pix_fmt",
10237+ if ten_bit { "yuv420p10le" } else { "yuv420p" },
10238+ // y4m calls 10-bit an unofficial pixel format (no-op at 8).
10239+ "-strict",
10240+ "-1",
10241+ "-t",
10242+ "0.60",
10243+ "-f",
10244+ "yuv4mpegpipe",
10245+ "-",
10246+ ])
10247+ .stdin(Stdio::null())
10248+ .stdout(Stdio::piped())
10249+ .stderr(Stdio::piped())
10250+ .output()
10251+ .expect("ffmpeg failed to run");
10252+ assert!(
10253+ y4m.status.success(),
10254+ "{name}: ffmpeg fixture: {}",
10255+ String::from_utf8_lossy(&y4m.stderr)
10256+ );
10257+ let out = run_with_stdin(Command::new(aomenc_path()).args(args), &y4m.stdout);
10258+ assert!(
10259+ out.status.success(),
10260+ "{name}: aomenc refused the fixture: {}",
10261+ String::from_utf8_lossy(&out.stderr)
10262+ );
10263+ let stream = out.stdout;
10264+ assert!(!stream.is_empty(), "{name}: aomenc wrote an empty stream");
10265+ if ten_bit {
10266+ assert_eq!(
10267+ parsed_bit_depth(&stream),
10268+ 10,
10269+ "{name}: aomenc did not write a 10-bit sequence header"
10270+ );
10271+ }
10272+ let parts_before = decode::rect_partition_hits();
10273+ let tus_before = decode::rect_coeff_tu_hits();
10274+ let decoded = match decode_stream(&stream) {
10275+ Ok(frames) => frames,
10276+ Err(e) => panic!("{name}: decode_stream refused: {e}"),
10277+ };
10278+ // Sampled after the decode, before the pixel compare, so a mismatch
10279+ // report can still say whether the arm fired.
10280+ let parts = decode::rect_partition_hits() - parts_before;
10281+ let tus = decode::rect_coeff_tu_hits() - tus_before;
10282+ let reference = if ten_bit {
10283+ ffmpeg_decode_sequence_10bit(&stream, width, height, decoded.len())
10284+ } else {
10285+ ffmpeg_decode_sequence(&stream, width, height, decoded.len())
10286+ };
10287+ assert_eq!(
10288+ decoded.len(),
10289+ reference.len(),
10290+ "{name}: shown-frame count vs ffmpeg (rect partitions {parts}, rect coefficient \
10291+ TUs {tus})"
10292+ );
10293+ for (i, (ours, theirs)) in decoded.iter().zip(&reference).enumerate() {
10294+ for (plane, (a, b), w) in [
10295+ ("Y", (&ours.y, &theirs.y), width),
10296+ ("U", (&ours.u, &theirs.u), width / 2),
10297+ ("V", (&ours.v, &theirs.v), width / 2),
10298+ ] {
10299+ assert_eq!(a.len(), b.len(), "{name}: frame {i} {plane} plane length");
10300+ if a != b {
10301+ let pin = std::env::temp_dir().join(format!("{name}-mismatch.obu"));
10302+ let _ = std::fs::write(&pin, &stream);
10303+ let at = a
10304+ .iter()
10305+ .zip(b.iter())
10306+ .position(|(x, y)| x != y)
10307+ .unwrap_or(0);
10308+ panic!(
10309+ "{name}: frame {i} {plane} mismatch vs ffmpeg at row {}, col {}: {} vs \
10310+ {} (rect partitions {parts}, rect coefficient TUs {tus}; stream pinned \
10311+ at {})",
10312+ at / w,
10313+ at % w,
10314+ a[at],
10315+ b[at],
10316+ pin.display()
10317+ );
10318+ }
10319+ }
10320+ }
10321+ eprintln!(
10322+ "{name}: {} bit, pixel-exact vs ffmpeg; parsed rect partitions {parts}, rect \
10323+ coefficient TUs {tus}",
10324+ if ten_bit { "10" } else { "8" }
10325+ );
10326+ (parts, tus)
10327+ }
10328+
10329+ /// lane-av1toolgates: the gate-level WITNESS, summed over the arms that
10330+ /// decoded AND compared. It cannot be asserted per arm: the cq20 /
10331+ /// tx-size-search=1 arm reaches a rect transform through the var-tx
10332+ /// search on a SQUARE block (a nonzero rect coefficient count with zero
10333+ /// rect partitions read -- the purest form of what `--enable-rect-tx`
10334+ /// buys), while the rect PARTITION only shows up on the
10335+ /// tx-size-search=0 arm. Either fact alone would let a stream through on
10336+ /// which the tool was allowed and unused, which is the defect this
10337+ /// coverage entry was written for; together they are the parsed-shape
10338+ /// evidence the entry asked for.
10339+ #[track_caller]
10340+ fn assert_rect_tx_witness(name: &str, parts: usize, tus: usize) {
10341+ assert!(
10342+ parts > 0,
10343+ "{name}: no PARTITION_HORZ/PARTITION_VERT symbol was read on any pixel-exact decode \
10344+ -- the parsed partition tree never yielded a rect leaf, so `--enable-rect-tx=1` \
10345+ was allowed and unused"
10346+ );
10347+ assert!(
10348+ tus > 0,
10349+ "{name}: no rectangular transform unit coded coefficients through read_coeffs_rect \
10350+ ({parts} rect partitions read) -- the rect coefficient path was never taken"
10351+ );
10352+ }
10353+
10354+ /// lane-av1toolgates: `enable-rect-tx` at 8 BITS. See
10355+ /// [`rect_tx_tool_gate`] for what the flag does and does not prove, and
10356+ /// why the recipe is spelled here rather than in the helper.
10357+ ///
10358+ /// The whole recipe is inline: `--passes=1` has to be findable in this
10359+ /// segment for the coverage derivation to count the gate at all, and
10360+ /// `--enable-rect-tx=1` has to be findable here for it to count the
10361+ /// TOOL. The quantiser and the tx-size-search setting are swept as two
10362+ /// arms so the witness cannot rest on one RD interaction.
10363+ #[test]
10364+ fn a_real_aomenc_8bit_stream_with_a_rect_transform_decodes_pixel_exact() {
10365+ let mut totals = (0usize, 0usize);
10366+ for (cq, tx_search) in [("20", "1"), ("40", "0")] {
10367+ let args: Vec<String> = [
10368+ "--codec=av1",
10369+ "--passes=1",
10370+ "--end-usage=q",
10371+ "--cpu-used=0",
10372+ "--threads=1",
10373+ "--row-mt=0",
10374+ "--lag-in-frames=0",
10375+ "--auto-alt-ref=0",
10376+ "--kf-max-dist=1000",
10377+ "--error-resilient=1",
10378+ "--sb-size=64",
10379+ // The tool under test, spelled explicitly. CONTEXT, per
10380+ // `rect_tx_tool_gate`: aomenc was ALLOWED rect tx sizes.
10381+ "--enable-rect-tx=1",
10382+ "--enable-rect-partitions=1",
10383+ "--enable-ab-partitions=0",
10384+ "--enable-1to4-partitions=0",
10385+ "--enable-restoration=0",
10386+ "--enable-palette=0",
10387+ "--enable-cdef=0",
10388+ "--enable-cfl-intra=0",
10389+ "--enable-intrabc=0",
10390+ "--enable-order-hint=0",
10391+ "--min-partition-size=8",
10392+ "--max-partition-size=32",
10393+ ]
10394+ .map(String::from)
10395+ .into_iter()
10396+ .chain([
10397+ format!("--cq-level={cq}"),
10398+ format!("--enable-tx-size-search={tx_search}"),
10399+ ])
10400+ // The output tail comes LAST: aomenc stops reading flags at the
10401+ // first bare argument, so a sweep flag appended after `-o - -` is
10402+ // silently dropped and the arm encodes a different recipe than the
10403+ // one this gate claims to have run.
10404+ .chain(["--obu", "-o", "-", "-"].map(String::from))
10405+ .collect();
10406+ let name = format!(
10407+ "a_real_aomenc_8bit_stream_with_a_rect_transform_decodes_pixel_exact[cq{cq}/tx{tx_search}]"
10408+ );
10409+ let (p, t) = rect_tx_tool_gate(&name, false, &args);
10410+ totals.0 += p;
10411+ totals.1 += t;
10412+ }
10413+ assert_rect_tx_witness(
10414+ "a_real_aomenc_8bit_stream_with_a_rect_transform_decodes_pixel_exact",
10415+ totals.0,
10416+ totals.1,
10417+ );
10418+ eprintln!(
10419+ "a_real_aomenc_8bit_stream_with_a_rect_transform_decodes_pixel_exact: 2 arms \
10420+ pixel-exact; parsed rect partitions {}, rect coefficient TUs {}",
10421+ totals.0, totals.1
10422+ );
10423+ }
10424+
10425+ /// lane-av1toolgates: `enable-rect-tx` at 10 BITS -- the same recipe, the
10426+ /// same parsed-shape witness, at the depth the 8-bit arm says nothing
10427+ /// about (the per-depth rule `NEVER_EXERCISED_10BIT` is built on:
10428+ /// lane-hbdinter's two 10-bit-only defects survived because every 10-bit
10429+ /// gate pinned the filters off). The depth is spelled in THIS body,
10430+ /// which is what files the gate in the 10-bit bucket.
10431+ #[test]
10432+ fn a_real_aomenc_10bit_stream_with_a_rect_transform_decodes_pixel_exact() {
10433+ let mut totals = (0usize, 0usize);
10434+ for (cq, tx_search) in [("20", "1"), ("40", "0")] {
10435+ let args: Vec<String> = [
10436+ "--codec=av1",
10437+ "--passes=1",
10438+ "--end-usage=q",
10439+ "--cpu-used=0",
10440+ "--threads=1",
10441+ "--row-mt=0",
10442+ "--lag-in-frames=0",
10443+ "--auto-alt-ref=0",
10444+ "--kf-max-dist=1000",
10445+ "--error-resilient=1",
10446+ "--sb-size=64",
10447+ "--input-bit-depth=10",
10448+ "--bit-depth=10",
10449+ // The tool under test, spelled explicitly. CONTEXT, per
10450+ // `rect_tx_tool_gate`: aomenc was ALLOWED rect tx sizes.
10451+ "--enable-rect-tx=1",
10452+ "--enable-rect-partitions=1",
10453+ "--enable-ab-partitions=0",
10454+ "--enable-1to4-partitions=0",
10455+ "--enable-restoration=0",
10456+ "--enable-palette=0",
10457+ "--enable-cdef=0",
10458+ "--enable-cfl-intra=0",
10459+ "--enable-intrabc=0",
10460+ "--enable-order-hint=0",
10461+ "--min-partition-size=8",
10462+ "--max-partition-size=32",
10463+ ]
10464+ .map(String::from)
10465+ .into_iter()
10466+ .chain([
10467+ format!("--cq-level={cq}"),
10468+ format!("--enable-tx-size-search={tx_search}"),
10469+ ])
10470+ // The output tail comes LAST: aomenc stops reading flags at the
10471+ // first bare argument, so a sweep flag appended after `-o - -` is
10472+ // silently dropped and the arm encodes a different recipe than the
10473+ // one this gate claims to have run.
10474+ .chain(["--obu", "-o", "-", "-"].map(String::from))
10475+ .collect();
10476+ let name = format!(
10477+ "a_real_aomenc_10bit_stream_with_a_rect_transform_decodes_pixel_exact[cq{cq}/tx{tx_search}]"
10478+ );
10479+ let (p, t) = rect_tx_tool_gate(&name, true, &args);
10480+ totals.0 += p;
10481+ totals.1 += t;
10482+ }
10483+ assert_rect_tx_witness(
10484+ "a_real_aomenc_10bit_stream_with_a_rect_transform_decodes_pixel_exact",
10485+ totals.0,
10486+ totals.1,
10487+ );
10488+ eprintln!(
10489+ "a_real_aomenc_10bit_stream_with_a_rect_transform_decodes_pixel_exact: 2 arms \
10490+ pixel-exact; parsed rect partitions {}, rect coefficient TUs {}",
10491+ totals.0, totals.1
10492+ );
10493+ }
10494+
964010495 /// lane-kf900 r5, the gate for the rect-strip `use_intrabc` read.
964110496 ///
964210497 /// `av1_allow_intrabc` is a FRAME-level test (`decodemv.c:892`,
@@ -13169,6 +14024,415 @@ pub(crate) mod tests {
1316914024 assert_eq!(frames[0].v, ffmpeg_frames[0].v, "{NAME}: V vs ffmpeg");
1317014025 }
1317114026
14027+ /// Shared body for the lane-av1superhbd HIGH-BIT-DEPTH 4:4:4 superres
14028+ /// arms: 10-bit and 12-bit, `--superres-mode=1` at a fixed denominator
14029+ /// and `--superres-mode=2` (a per-frame denominator libaom picks itself).
14030+ ///
14031+ /// Everything the 8-bit 4:4:4 superres cell is non-vacuous by, repeated
14032+ /// here, plus the one thing that only matters above 8 bits: the gate
14033+ /// asserts the PARSED `bit_depth` equals the depth it names, because a
14034+ /// 10-bit recipe whose flags were mistyped still decodes -- it just
14035+ /// decodes a DIFFERENT cell than the gate claims, which is the same
14036+ /// "phantom cell" trap lane-av1444edge r3 recorded for
14037+ /// `use_superres=false`.
14038+ ///
14039+ /// The per-frame table is `(denominator, coded_width)` in DECODE order.
14040+ /// The coded width is re-derived as `(UpscaledWidth*8 + denom/2)/denom`
14041+ /// from that frame's OWN parsed denominator rather than only compared to
14042+ /// a literal, so a re-pinned fixture cannot satisfy the literals while
14043+ /// the scaled-size arithmetic moves under them. `superres_hits` and
14044+ /// `predict_scaled_hits` are asserted as DELTAS (both are process-wide
14045+ /// counters with no reset).
14046+ #[allow(clippy::too_many_arguments)]
14047+ fn a_444_hbd_superres_arm(
14048+ name: &str,
14049+ fixture: &str,
14050+ fixture_len: usize,
14051+ fixture_fnv: u64,
14052+ fixture_sha: &str,
14053+ bit_depth: u8,
14054+ upscaled: (usize, usize),
14055+ per_frame: &[(u8, usize)],
14056+ ) -> Vec<FrameHeader> {
14057+ let obu = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR")).join(fixture);
14058+ let stream = std::fs::read(&obu).unwrap_or_else(|e| {
14059+ panic!(
14060+ "{name}: pinned fixture {fixture} is missing ({e}) -- the gate cannot run, \
14061+ which is a failure, not a skip"
14062+ )
14063+ });
14064+ assert_eq!(stream.len(), fixture_len, "{name}: fixture length moved");
14065+ assert_eq!(fnv1a64(&stream), fixture_fnv, "{name}: fixture bytes moved");
14066+
14067+ // --- the header facts the CELL depends on, parsed not assumed ------
14068+ let mut parser = Av1Parser::new();
14069+ let mut pos = 0usize;
14070+ let mut seq = None;
14071+ let mut heads: Vec<FrameHeader> = Vec::new();
14072+ while pos < stream.len() {
14073+ let parsed = parser
14074+ .parse_obu(&stream[pos..])
14075+ .unwrap_or_else(|e| panic!("{name}: aomenc OBU does not parse: {e:?}"));
14076+ if parsed.total_size == 0 {
14077+ break;
14078+ }
14079+ pos += parsed.total_size;
14080+ match parsed.kind {
14081+ ObuKind::SequenceHeader(s) => seq = Some(s),
14082+ ObuKind::FrameHeader(h) => heads.push(*h),
14083+ ObuKind::Frame(h, _) => heads.push(*h),
14084+ _ => {}
14085+ }
14086+ }
14087+ let seq = seq.unwrap_or_else(|| panic!("{name}: the stream carries no sequence header"));
14088+ assert_eq!(
14089+ (
14090+ seq.color_config.subsampling_x,
14091+ seq.color_config.subsampling_y
14092+ ),
14093+ (0, 0),
14094+ "{name}: the stream is not 4:4:4 (ss = ({}, {}))",
14095+ seq.color_config.subsampling_x,
14096+ seq.color_config.subsampling_y
14097+ );
14098+ // The high-bit-depth claim itself. A `--bit-depth` flag that silently
14099+ // did not take effect still produces a decodable 4:4:4 superres
14100+ // stream -- at 8 bits -- and every other assertion below would pass.
14101+ assert_eq!(
14102+ seq.color_config.bit_depth, bit_depth,
14103+ "{name}: the sequence header parses bit_depth {}, not the {bit_depth} this gate \
14104+ names -- the encoder flags did not take effect and this is a different cell",
14105+ seq.color_config.bit_depth
14106+ );
14107+ assert!(
14108+ seq.enable_superres,
14109+ "{name}: the sequence header does not enable superres at all"
14110+ );
14111+ assert_eq!(
14112+ heads.len(),
14113+ per_frame.len(),
14114+ "{name}: {} frame headers, expected {}",
14115+ heads.len(),
14116+ per_frame.len()
14117+ );
14118+ for (i, (h, (denom, coded))) in heads.iter().zip(per_frame).enumerate() {
14119+ assert!(
14120+ h.use_superres,
14121+ "{name}: frame {i} has use_superres = false -- this is an UNSCALED stream and \
14122+ the gate would measure something other than the cell it names (class \
14123+ gate-blind-to-feature)"
14124+ );
14125+ assert_eq!(
14126+ h.superres_denom, *denom,
14127+ "{name}: frame {i} PARSED denominator moved from {denom} -- read the header, \
14128+ never the encoder flag (mode 2 chooses its own)"
14129+ );
14130+ assert_eq!(
14131+ (h.upscaled_width as usize, h.frame_height as usize),
14132+ upscaled,
14133+ "{name}: frame {i} upscaled size moved"
14134+ );
14135+ assert_eq!(
14136+ (h.frame_width as usize, h.frame_height as usize),
14137+ (*coded, upscaled.1),
14138+ "{name}: frame {i} CODED size moved -- this is the scaled half of the cell and \
14139+ the part an unsized stream gets wrong"
14140+ );
14141+ let d = u32::from(*denom);
14142+ assert_eq!(
14143+ (h.upscaled_width * 8 + d / 2) / d,
14144+ h.frame_width,
14145+ "{name}: frame {i}: FrameWidth is not (UpscaledWidth*8 + denom/2)/denom -- the \
14146+ scaled size the cell rests on is not the spec's"
14147+ );
14148+ }
14149+
14150+ // --- the pixels -----------------------------------------------------
14151+ let _guard = lock_gate_counters();
14152+ let before_sr = crate::superres::superres_hits();
14153+ let before_scaled = crate::mc::predict_scaled_hits();
14154+ let frames = decode_stream(&stream).unwrap_or_else(|e| {
14155+ panic!("{name}: the pinned {bit_depth}-bit 4:4:4 superres stream was refused: {e}")
14156+ });
14157+ let scaled_up = crate::superres::superres_hits() - before_sr;
14158+ let scaled_mc = crate::mc::predict_scaled_hits() - before_scaled;
14159+ assert!(
14160+ scaled_up > 0,
14161+ "{name}: zero superres_hits -- the upscaler never ran (class gate-blind-to-feature)"
14162+ );
14163+ assert!(
14164+ scaled_mc > 0,
14165+ "{name}: zero predict_scaled_hits -- no inter block read a scaled reference, so the \
14166+ scaled-PREDICTION half of the cell is unexercised (class gate-blind-to-feature)"
14167+ );
14168+ assert_eq!(frames.len(), per_frame.len(), "{name}: decoded frame count");
14169+ let max = (1u32 << bit_depth) - 1;
14170+ for (i, f) in frames.iter().enumerate() {
14171+ assert_eq!(
14172+ (f.width, f.height),
14173+ upscaled,
14174+ "{name}: frame {i} came back {}x{}, not the UPSCALED {}x{}",
14175+ f.width,
14176+ f.height,
14177+ upscaled.0,
14178+ upscaled.1
14179+ );
14180+ for (plane, samples) in [("Y", &f.y), ("U", &f.u), ("V", &f.v)] {
14181+ assert_eq!(
14182+ samples.len(),
14183+ upscaled.0 * upscaled.1,
14184+ "{name}: frame {i} {plane} plane is {} samples; at 4:4:4 upscaled it must be \
14185+ full resolution ({}x{})",
14186+ samples.len(),
14187+ upscaled.0,
14188+ upscaled.1
14189+ );
14190+ // The depth claim, on the pixels: a decoder that lost the
14191+ // high bits (or produced 8-bit values padded into a u16
14192+ // plane) would satisfy every length and geometry assert above
14193+ // and only be caught here.
14194+ assert!(
14195+ samples.iter().all(|&s| u32::from(s) <= max),
14196+ "{name}: frame {i} {plane} carries a sample above the {bit_depth}-bit \
14197+ maximum {max} -- the bit depth of the OUTPUT does not match the header"
14198+ );
14199+ }
14200+ }
14201+ if aomdec_path().is_file() {
14202+ let (decoded, hidden) = decode_all_frames_vs_oracle(&stream, name);
14203+ eprintln!(
14204+ "{name}: {decoded} decode-order frame(s) ({hidden} hidden) byte-exact vs aomdec \
14205+ at {bit_depth}-bit {upscaled:?} upscaled from {per_frame:?} (denominator, coded \
14206+ width) per frame, {scaled_up} upscale(s), {scaled_mc} scaled MC block(s); \
14207+ fixture sha256 {fixture_sha}"
14208+ );
14209+ } else {
14210+ eprintln!("{name}: no oracle aomdec, pixel arm skipped");
14211+ }
14212+ heads
14213+ }
14214+
14215+ /// lane-av1superhbd (1): 4:4:4 superres at **10 bits**, `--superres-mode=1
14216+ /// --superres-denominator=12` on all four frames -- coded 171x128 upscaled
14217+ /// to 256x128 at `denom = 12`.
14218+ ///
14219+ /// **What it closes.** Every superres fixture the crate carried parsed
14220+ /// `bit_depth = 8` (4:2:0 `superres_kf_cdef_lr_64x64.obu`) or was 4:2:0
14221+ /// (`superres_alltools_sb128_320x180.obu`), and the 4:4:4 superres cells
14222+ /// were 8-bit. The chroma-format sweep's not-measured list kept "4:4:4
14223+ /// superres at 10/12 bits" open on that basis. This arm is the 10-bit
14224+ /// measurement: a 4:4:4 chroma plane upscaled at FULL resolution, where
14225+ /// the upscaler and the scaled inter predictor both run with a
14226+ /// 10-bit sample width and the 4:4:4 chroma gather has no subsampling
14227+ /// halving to hide behind.
14228+ ///
14229+ /// **The recipe** (sha256
14230+ /// `95b49d7aa81843399ee3aa64bdadfec8f4037bcc3f861923c9b2da3bc868b223`,
14231+ /// 15803 bytes, 4 frames, `testsrc2 256x128 rate=25` yuv444p10le):
14232+ /// ```text
14233+ /// ffmpeg -f lavfi -i "testsrc2=size=256x128:rate=25" -frames:v 4 \
14234+ /// -pix_fmt yuv444p10le -strict -1 -f yuv4mpegpipe - | \
14235+ /// aomenc --codec=av1 --profile=1 --bit-depth=10 --input-bit-depth=10 \
14236+ /// --passes=1 --end-usage=q --cq-level=20 --cpu-used=2 --threads=1 \
14237+ /// --row-mt=0 --lag-in-frames=0 --kf-max-dist=100 --limit=4 \
14238+ /// --superres-mode=1 --superres-denominator=12 \
14239+ /// --superres-kf-denominator=12 --obu -o - -
14240+ /// ```
14241+ /// `-strict -1` is load-bearing: without it ffmpeg refuses to write
14242+ /// `yuv444p10le` into a y4m pipe at all (zero bytes out).
14243+ #[test]
14244+ fn a_444_lossy_superres_10bit_d12_stream_decodes_pixel_exact() {
14245+ a_444_hbd_superres_arm(
14246+ "a_444_lossy_superres_10bit_d12_stream_decodes_pixel_exact",
14247+ "fixtures/444_lossy_superres_256x128_d12_10bit.obu",
14248+ 15803,
14249+ 0x9fad_3227_6e91_792c,
14250+ "95b49d7aa81843399ee3aa64bdadfec8f4037bcc3f861923c9b2da3bc868b223",
14251+ 10,
14252+ (256, 128),
14253+ &[(12, 171); 4],
14254+ );
14255+ }
14256+
14257+ /// lane-av1superhbd (2): 4:4:4 superres at **12 bits**,
14258+ /// `--superres-mode=1 --superres-denominator=12`, coded 171x128 upscaled
14259+ /// to 256x128.
14260+ ///
14261+ /// **Why the source is `mandelbrot` and not `testsrc2`.** The 12-bit
14262+ /// frame gate refuses a frame carrying `allow_screen_content_tools = 1`
14263+ /// by name (palette and intrabc have no 12-bit witness). libaom sets
14264+ /// that bit from its own content detection
14265+ /// (`av1_set_screen_content_options` -> `encoder_utils.c:1153`, keyed on
14266+ /// the palette-pixel ratio of the FIRST pass), and `testsrc2` -- flat
14267+ /// colour bars and hard edges -- trips it at 12 bits while the very same
14268+ /// recipe at 10 bits does not. `--enable-palette=0 --enable-intrabc=0`
14269+ /// and `--tune-content=film` do NOT suppress it (measured: all four
14270+ /// still parse `allow_screen_content_tools = true`), because the
14271+ /// detection is a property of the CONTENT, not of those flags. A
14272+ /// photographic source (`mandelbrot`, same geometry and frame count)
14273+ /// parses `allow_screen_content_tools = false` and decodes. This is a
14274+ /// source choice, stated so the next lane does not re-derive it.
14275+ ///
14276+ /// **The recipe** (sha256
14277+ /// `973bf374c0185c4e6301509ce834cef01318e6cdb9488fd258118d7ec89bdd04`,
14278+ /// 11023 bytes, 4 frames, `mandelbrot 256x128 rate=25` yuv444p12le):
14279+ /// ```text
14280+ /// ffmpeg -f lavfi -i "mandelbrot=size=256x128:rate=25" -frames:v 4 \
14281+ /// -pix_fmt yuv444p12le -strict -1 -f yuv4mpegpipe - | \
14282+ /// aomenc --codec=av1 --profile=1 --bit-depth=12 --input-bit-depth=12 \
14283+ /// --passes=1 --end-usage=q --cq-level=20 --cpu-used=2 --threads=1 \
14284+ /// --row-mt=0 --lag-in-frames=0 --kf-max-dist=100 --limit=4 \
14285+ /// --superres-mode=1 --superres-denominator=12 \
14286+ /// --superres-kf-denominator=12 --obu -o - -
14287+ /// ```
14288+ /// Byte-reproducible: two independent encodes produced the same 11023
14289+ /// bytes.
14290+ #[test]
14291+ fn a_444_lossy_superres_12bit_d12_stream_decodes_pixel_exact() {
14292+ a_444_hbd_superres_arm(
14293+ "a_444_lossy_superres_12bit_d12_stream_decodes_pixel_exact",
14294+ "fixtures/444_lossy_superres_256x128_d12_12bit.obu",
14295+ 11023,
14296+ 0xd6cf_bb83_2b42_8e2d,
14297+ "973bf374c0185c4e6301509ce834cef01318e6cdb9488fd258118d7ec89bdd04",
14298+ 12,
14299+ (256, 128),
14300+ &[(12, 171); 4],
14301+ );
14302+ }
14303+
14304+ /// lane-av1superhbd (3): 4:4:4 superres at **12 bits** at the WIDEST
14305+ /// denominator this geometry allows, `--superres-denominator=9` -- coded
14306+ /// 228x128 upscaled to 256x128, so 28 of the 256 columns are the frame's
14307+ /// right-edge upscale margin, against 12's 85.
14308+ ///
14309+ /// It is a separate gate from the den=12 arm because the margin is
14310+ /// where a round-trip is most likely to read past the coded picture: a
14311+ /// decoder that sized the upscale source from `UpscaledWidth` instead of
14312+ /// `FrameWidth` is exact at den=12 on this content and wrong here. Its
14313+ /// recipe is the 12-bit one above with `--superres-denominator=9
14314+ /// --superres-kf-denominator=9` (sha256
14315+ /// `898c775108495b998cb5ec9b08e194d4656ed0140aa8e7e7236892d468bbad99`,
14316+ /// 13015 bytes).
14317+ #[test]
14318+ fn a_444_lossy_superres_12bit_d9_stream_decodes_pixel_exact() {
14319+ a_444_hbd_superres_arm(
14320+ "a_444_lossy_superres_12bit_d9_stream_decodes_pixel_exact",
14321+ "fixtures/444_lossy_superres_256x128_d9_12bit.obu",
14322+ 13015,
14323+ 0x4110_ce7b_cd85_901b,
14324+ "898c775108495b998cb5ec9b08e194d4656ed0140aa8e7e7236892d468bbad99",
14325+ 12,
14326+ (256, 128),
14327+ &[(9, 228); 4],
14328+ );
14329+ }
14330+
14331+ /// lane-av1superhbd (4): 4:4:4 superres at **10 bits** under
14332+ /// `--superres-mode=2` -- the random-denominator arm, where libaom picks
14333+ /// a DIFFERENT denominator for every frame and IGNORES
14334+ /// `--superres-denominator` entirely.
14335+ ///
14336+ /// This is what keeps the high-bit-depth superres cell from silently
14337+ /// degenerating into a single-denominator cell: the per-frame parsed
14338+ /// denominators are 11, 14, 15, 9 -- three of them values no flag on the
14339+ /// command line ever named -- so a gate that read the flag instead of
14340+ /// the header would be wrong on three of four frames. The assertion
14341+ /// below makes that structural rather than incidental, and it is the
14342+ /// assertion that fails if a future libaom starts honouring the flag
14343+ /// under mode 2.
14344+ ///
14345+ /// **The recipe** (sha256
14346+ /// `699398aba58fb53b80e05d3d214eb746a3c91945e01da6b47488513f20b55668`,
14347+ /// 17776 bytes, 4 frames, `testsrc2 256x128 rate=25` yuv444p10le):
14348+ /// ```text
14349+ /// ffmpeg -f lavfi -i "testsrc2=size=256x128:rate=25" -frames:v 4 \
14350+ /// -pix_fmt yuv444p10le -strict -1 -f yuv4mpegpipe - | \
14351+ /// aomenc --codec=av1 --profile=1 --bit-depth=10 --input-bit-depth=10 \
14352+ /// --passes=1 --end-usage=q --cq-level=20 --cpu-used=2 --threads=1 \
14353+ /// --row-mt=0 --lag-in-frames=0 --kf-max-dist=100 --limit=4 \
14354+ /// --superres-mode=2 --obu -o - -
14355+ /// ```
14356+ #[test]
14357+ fn a_444_lossy_superres_10bit_mode2_random_denom_stream_decodes_pixel_exact() {
14358+ const NAME: &str =
14359+ "a_444_lossy_superres_10bit_mode2_random_denom_stream_decodes_pixel_exact";
14360+ let heads = a_444_hbd_superres_arm(
14361+ NAME,
14362+ "fixtures/444_lossy_superres_mode2_256x128_10bit.obu",
14363+ 17776,
14364+ 0x164f_4099_7576_7ae4,
14365+ "699398aba58fb53b80e05d3d214eb746a3c91945e01da6b47488513f20b55668",
14366+ 10,
14367+ (256, 128),
14368+ &[(11, 186), (14, 146), (15, 137), (9, 228)],
14369+ );
14370+ // Distinct-denominator assert: the cell must stay a MULTI-denominator
14371+ // one. A libaom that collapsed mode 2 onto a single denominator (or
14372+ // stopped scaling) would still decode, and the gate above would still
14373+ // hold only because the literals would have been re-pinned with it --
14374+ // so the property is asserted from the parsed headers directly.
14375+ let denoms: Vec<u8> = heads.iter().map(|h| h.superres_denom).collect();
14376+ let mut distinct = denoms.clone();
14377+ distinct.sort_unstable();
14378+ distinct.dedup();
14379+ assert!(
14380+ distinct.len() >= 3,
14381+ "{NAME}: the stream carries denominators {denoms:?} -- fewer than three distinct \
14382+ values, so this is no longer the per-frame-denominator cell and the pin has to be \
14383+ re-derived from the stream"
14384+ );
14385+ let flagged = [9u8, 12, 16];
14386+ assert!(
14387+ denoms.iter().any(|d| !flagged.contains(d)),
14388+ "{NAME}: every parsed denominator is one of the flag values {flagged:?} -- mode 2 now \
14389+ appears to honour --superres-denominator, and this cell stops being the \
14390+ flag-ignoring one"
14391+ );
14392+ }
14393+
14394+ /// lane-av1superhbd (5): 4:4:4 superres at **12 bits** under
14395+ /// `--superres-mode=2` -- the high-bit-depth random-denominator arm, the
14396+ /// 12-bit twin of the arm above (sha256
14397+ /// `18aa8b3124ab10672f22577a8eea81e44141a3d0bb506104aee2f950254a2e9f`,
14398+ /// 14656 bytes, same `mandelbrot` source as the 12-bit fixed-denominator
14399+ /// arms). Its parsed denominators are again 11/14/15/9 at coded widths
14400+ /// 186/146/137/228, so the upscaler is handed FOUR coded-to-upscaled
14401+ /// ratios in one 12-bit decode -- the case a single-denominator gate
14402+ /// cannot reach at any bit depth.
14403+ #[test]
14404+ fn a_444_lossy_superres_12bit_mode2_random_denom_stream_decodes_pixel_exact() {
14405+ const NAME: &str =
14406+ "a_444_lossy_superres_12bit_mode2_random_denom_stream_decodes_pixel_exact";
14407+ let heads = a_444_hbd_superres_arm(
14408+ NAME,
14409+ "fixtures/444_lossy_superres_mode2_256x128_12bit.obu",
14410+ 14656,
14411+ 0xef38_3fb7_b284_2166,
14412+ "18aa8b3124ab10672f22577a8eea81e44141a3d0bb506104aee2f950254a2e9f",
14413+ 12,
14414+ (256, 128),
14415+ &[(11, 186), (14, 146), (15, 137), (9, 228)],
14416+ );
14417+ let denoms: Vec<u8> = heads.iter().map(|h| h.superres_denom).collect();
14418+ let mut distinct = denoms.clone();
14419+ distinct.sort_unstable();
14420+ distinct.dedup();
14421+ assert!(
14422+ distinct.len() >= 3,
14423+ "{NAME}: the stream carries denominators {denoms:?} -- fewer than three distinct \
14424+ values, so this is no longer the per-frame-denominator cell and the pin has to be \
14425+ re-derived from the stream"
14426+ );
14427+ let flagged = [9u8, 12, 16];
14428+ assert!(
14429+ denoms.iter().any(|d| !flagged.contains(d)),
14430+ "{NAME}: every parsed denominator is one of the flag values {flagged:?} -- mode 2 now \
14431+ appears to honour --superres-denominator, and this cell stops being the \
14432+ flag-ignoring one"
14433+ );
14434+ }
14435+
1317214436 /// lane-filt1: `EC_AV1_FILTER_THREADS` splits every in-frame filter stage
1317314437 /// -- deblock (row bands for the vertical-edge pass, column bands for the
1317414438 /// horizontal one), CDEF (mi row bands), loop restoration (RU row bands)
@@ -14755,96 +16019,144 @@ pub(crate) mod tests {
1475516019 /// picks a nonzero level -- proves `apply_deblock` itself, not just that
1475616020 /// this decoder still works when every edge lands on level 0. CDEF
1475716021 /// stays off so a pixel mismatch can only come from the loop filter.
16022+ ///
16023+ /// lane-av1skipfix: the attempt-loop shape. The sweep walks cq (which is
16024+ /// what decides whether libaom picks a nonzero deblocking level at all)
16025+ /// and seed, REQUIRES at least one attempt to decode, and hard-asserts
16026+ /// `decode::deblock_hits` on a pixel-compared attempt -- a decode error on
16027+ /// every attempt is a hard failure carrying the refusal texts, never a
16028+ /// printed SKIP (class `gate-skips-on-its-own-failure`). MEASURED
16029+ /// 2026-09-29 on `a21f3680`: cq 55/45/35/63 all decode pixel-exact with
16030+ /// 48/64/64/64 deblock edges, so the old single recipe was one lucky
16031+ /// point of a cq range that needed no fallback.
1475816032 #[test]
1475916033 fn a_real_aomenc_intra_stream_with_deblocking_decodes_pixel_exact() {
16034+ const NAME: &str = "a_real_aomenc_intra_stream_with_deblocking_decodes_pixel_exact";
16035+ let _gate_lock = lock_gate_counters();
1476016036 if !have_ffmpeg() {
14761- eprintln!(
14762- "SKIP a_real_aomenc_intra_stream_with_deblocking_decodes_pixel_exact: no ffmpeg"
14763- );
16037+ eprintln!("SKIP {NAME}: no ffmpeg");
1476416038 return;
1476516039 }
1476616040 if !have_aomenc() {
14767- eprintln!(
14768- "SKIP a_real_aomenc_intra_stream_with_deblocking_decodes_pixel_exact: no aomenc at {}",
14769- aomenc_path().display()
14770- );
16041+ eprintln!("SKIP {NAME}: no aomenc at {}", aomenc_path().display());
1477116042 return;
1477216043 }
1477316044 let (width, height) = (64usize, 64usize);
14774- let source = gradients_source(42, width, height, "duration=0.04:rate=25");
14775- let y4m = Command::new("ffmpeg")
14776- .args(["-v", "error", "-f", "lavfi", "-i"])
14777- .arg(&source)
14778- .args(["-pix_fmt", "yuv420p", "-f", "yuv4mpegpipe", "-"])
14779- .stdin(Stdio::null())
14780- .stdout(Stdio::piped())
14781- .stderr(Stdio::piped())
14782- .output()
14783- .expect("ffmpeg failed to run");
14784- assert!(
14785- y4m.status.success(),
14786- "ffmpeg fixture: {}",
14787- String::from_utf8_lossy(&y4m.stderr)
14788- );
14789- let out = run_with_stdin(
14790- Command::new(aomenc_path()).args([
14791- // lane-defon r1: explicit on-value (aomenc keeps the FIRST
14792- // occurrence, so overrides go before the base list).
14793- "--loopfilter-control=1",
14794- "--codec=av1",
14795- "--passes=1",
14796- "--end-usage=q",
14797- "--cq-level=55",
14798- "--cpu-used=0",
14799- "--enable-filter-intra=0",
14800- "--enable-smooth-intra=0",
14801- "--enable-paeth-intra=0",
14802- "--enable-directional-intra=0",
14803- "--enable-angle-delta=0",
14804- "--enable-tx-size-search=0",
14805- "--enable-cdef=0",
14806- // Loop restoration is a named refusal (aomenc's RD picks
14807- // Sgrproj on this kind of content) -- off in every recipe
14808- // whose test targets a different surface.
14809- "--enable-restoration=0",
14810- "--max-partition-size=32",
14811- "--enable-palette=0",
14812- "--enable-intrabc=0",
14813- "--enable-cfl-intra=0",
14814- // use_ref_frame_mvs (temporal MV projection) is unimplemented in mvstack;
14815- // leaving it on silently desyncs symbols on inter frames (grainfix lesson).
14816- "--enable-ref-frame-mvs=0",
14817- "--obu",
14818- "-o",
14819- "-",
14820- "-",
14821- ]),
14822- &y4m.stdout,
14823- );
14824- assert!(
14825- out.status.success(),
14826- "aomenc refused the fixture: {}",
14827- String::from_utf8_lossy(&out.stderr)
14828- );
14829- let stream = out.stdout;
14830- let before = decode::deblock_hits();
14831- let frames = match decode_stream(&stream) {
14832- Ok(frames) => frames,
14833- Err(e) => {
14834- eprintln!(
14835- "SKIP a_real_aomenc_intra_stream_with_deblocking_decodes_pixel_exact: {e}"
16045+ // Two seeds x four quantisers.
16046+ const CQS: [u32; 4] = [55, 45, 35, 63];
16047+ let mut refusals = Vec::new();
16048+ let mut counted_exact = 0u32;
16049+ let mut uncounted_exact = 0u32;
16050+ 'attempts: for round in 0..2u32 {
16051+ for cq in CQS {
16052+ let source = gradients_source(42 + round, width, height, "duration=0.04:rate=25");
16053+ let y4m = Command::new("ffmpeg")
16054+ .args(["-v", "error", "-f", "lavfi", "-i"])
16055+ .arg(&source)
16056+ .args(["-pix_fmt", "yuv420p", "-f", "yuv4mpegpipe", "-"])
16057+ .stdin(Stdio::null())
16058+ .stdout(Stdio::piped())
16059+ .stderr(Stdio::piped())
16060+ .output()
16061+ .expect("ffmpeg failed to run");
16062+ assert!(
16063+ y4m.status.success(),
16064+ "{NAME}: ffmpeg fixture (seed {} cq {cq}): {}",
16065+ 42 + round,
16066+ String::from_utf8_lossy(&y4m.stderr)
1483616067 );
14837- return;
16068+ let cq_arg = format!("--cq-level={cq}");
16069+ let out = run_with_stdin(
16070+ Command::new(aomenc_path()).args([
16071+ // lane-defon r1: explicit on-value (aomenc keeps the FIRST
16072+ // occurrence, so overrides go before the base list).
16073+ "--loopfilter-control=1",
16074+ "--codec=av1",
16075+ "--passes=1",
16076+ "--end-usage=q",
16077+ &cq_arg,
16078+ "--cpu-used=0",
16079+ "--enable-filter-intra=0",
16080+ "--enable-smooth-intra=0",
16081+ "--enable-paeth-intra=0",
16082+ "--enable-directional-intra=0",
16083+ "--enable-angle-delta=0",
16084+ "--enable-tx-size-search=0",
16085+ "--enable-cdef=0",
16086+ // Loop restoration is a named refusal (aomenc's RD picks
16087+ // Sgrproj on this kind of content) -- off in every recipe
16088+ // whose test targets a different surface.
16089+ "--enable-restoration=0",
16090+ "--max-partition-size=32",
16091+ "--enable-palette=0",
16092+ "--enable-intrabc=0",
16093+ "--enable-cfl-intra=0",
16094+ // use_ref_frame_mvs (temporal MV projection) is unimplemented in mvstack;
16095+ // leaving it on silently desyncs symbols on inter frames (grainfix lesson).
16096+ "--enable-ref-frame-mvs=0",
16097+ "--obu",
16098+ "-o",
16099+ "-",
16100+ "-",
16101+ ]),
16102+ &y4m.stdout,
16103+ );
16104+ assert!(
16105+ out.status.success(),
16106+ "{NAME}: aomenc refused the seed {} cq {cq} fixture: {}",
16107+ 42 + round,
16108+ String::from_utf8_lossy(&out.stderr)
16109+ );
16110+ let stream = out.stdout;
16111+ let before = decode::deblock_hits();
16112+ let frames = match decode_stream(&stream) {
16113+ Ok(frames) => frames,
16114+ Err(e) => {
16115+ refusals.push(format!("seed {} cq {cq}: {e}", 42 + round));
16116+ continue;
16117+ }
16118+ };
16119+ // A decode that succeeded is ALWAYS pixel-compared; the hit
16120+ // counter only decides whether the attempt counts as firing
16121+ // (class `counter-from-refused-stream`).
16122+ let counted = decode::deblock_hits() != before;
16123+ if counted {
16124+ counted_exact += 1;
16125+ } else {
16126+ uncounted_exact += 1;
16127+ }
16128+ let ffmpeg_frames = ffmpeg_decode_sequence(&stream, width, height, 1);
16129+ assert_eq!(
16130+ frames[0].y,
16131+ ffmpeg_frames[0].y,
16132+ "luma vs ffmpeg (seed {} cq {cq}, deblock fired: {counted})",
16133+ 42 + round
16134+ );
16135+ assert_eq!(
16136+ frames[0].u,
16137+ ffmpeg_frames[0].u,
16138+ "U vs ffmpeg (seed {} cq {cq}, deblock fired: {counted})",
16139+ 42 + round
16140+ );
16141+ assert_eq!(
16142+ frames[0].v,
16143+ ffmpeg_frames[0].v,
16144+ "V vs ffmpeg (seed {} cq {cq}, deblock fired: {counted})",
16145+ 42 + round
16146+ );
16147+ if counted_exact >= 2 {
16148+ break 'attempts;
16149+ }
1483816150 }
14839- };
16151+ }
16152+ gate_buckets(NAME, counted_exact, uncounted_exact, refusals.len());
1484016153 assert!(
14841- decode::deblock_hits() > before,
14842- "no deblocking edge fired decoding this stream -- raise cq-level"
16154+ counted_exact > 0,
16155+ "{NAME}: none of {} attempts decoded a stream with a deblocking edge -- \
16156+ apply_deblock is unproven (class gate-blind-to-feature):\n{}",
16157+ CQS.len() * 2,
16158+ refusals.join("\n")
1484316159 );
14844- let ffmpeg_frames = ffmpeg_decode_sequence(&stream, width, height, 1);
14845- assert_eq!(frames[0].y, ffmpeg_frames[0].y, "luma vs ffmpeg");
14846- assert_eq!(frames[0].u, ffmpeg_frames[0].u, "U vs ffmpeg");
14847- assert_eq!(frames[0].v, ffmpeg_frames[0].v, "V vs ffmpeg");
1484816160 }
1484916161
1485016162 /// As [`a_real_aomenc_intra_stream_with_deblocking_decodes_pixel_exact`],
@@ -17413,14 +18725,17 @@ pub(crate) mod tests {
1741318725 // lane-interp3 r1: sequence length -- a compound block needs several
1741418726 // already-coded references, which a 4-frame sequence never has.
1741518727 frame_count: usize,
17416- ) {
18728+ // lane-av1dualfilter10: the encoded stream, so a caller can assert on
18729+ // the PARSED sequence header (bit depth, `enable_dual_filter`) rather
18730+ // than on the flag it asked for. Empty on the SKIP paths below.
18731+ ) -> Vec<u8> {
1741718732 if !have_ffmpeg() {
1741818733 eprintln!("SKIP {name}: no ffmpeg");
17419- return;
18734+ return Vec::new();
1742018735 }
1742118736 if !have_aomenc() {
1742218737 eprintln!("SKIP {name}: no aomenc at {}", aomenc_path().display());
17423- return;
18738+ return Vec::new();
1742418739 }
1742518740 let height = 64usize;
1742618741 let duration = format!("{:.2}", frame_count as f64 / 25.0);
@@ -17543,6 +18858,7 @@ pub(crate) mod tests {
1754318858 );
1754418859 }
1754518860 }
18861+ stream
1754618862 }
1754718863
1754818864 #[test]
@@ -17692,6 +19008,88 @@ pub(crate) mod tests {
1769219008 );
1769319009 }
1769419010
19011+ /// lane-av1dualfilter10: the 10-bit arm of the dual-filter witness.
19012+ ///
19013+ /// `NEVER_EXERCISED_10BIT` kept `enable-dual-filter` listed after the
19014+ /// 8-bit entry was retired (lane-av1distwtd r3, gate_coverage.rs), and
19015+ /// the reason was structural, not incidental: the only `=1` witness,
19016+ /// `a_real_aomenc_dual_filter_obmc_8x8_inter_sequence_decodes_pixel_exact`,
19017+ /// calls `inter_sb_none_gate(NAME, false, ...)` -- and that `false` IS the
19018+ /// `ten_bit` parameter, so it built an 8-bit stream. Its `ten_bit = true`
19019+ /// siblings build 10-bit streams but spell no dual-filter flag. This is
19020+ /// that missing arm.
19021+ ///
19022+ /// What makes it a witness and not a spelling: the header is read back
19023+ /// from the ENCODED stream (`enable_dual_filter` and `bit_depth` both come
19024+ /// from `Av1Parser`, never from the flag or the fixture name), and the
19025+ /// arrival assert is a DELTA on `decode::dual_filter_diff_hits()` taken
19026+ /// around this arm alone. A stream that merely parsed would not move the
19027+ /// counter; the counter moves only when `resolve_interp_filter` reads two
19028+ /// DIFFERENT directions for one block, which is the property the entry
19029+ /// was claiming no real stream carried.
19030+ #[test]
19031+ fn a_real_aomenc_10bit_dual_filter_obmc_8x8_inter_sequence_decodes_pixel_exact() {
19032+ const NAME: &str =
19033+ "a_real_aomenc_10bit_dual_filter_obmc_8x8_inter_sequence_decodes_pixel_exact";
19034+ if !have_ffmpeg() || !have_aomenc() {
19035+ eprintln!("SKIP {NAME}: no ffmpeg/aomenc");
19036+ return;
19037+ }
19038+ let before_dual = decode::dual_filter_diff_hits();
19039+ let stream = inter_sb_none_gate(
19040+ NAME,
19041+ // `ten_bit`: this is the whole difference from the 8-bit witness.
19042+ true,
19043+ "8",
19044+ "16",
19045+ decode::compound8_filter_hits,
19046+ "a compound 8x8 leaf reading its own switchable interp_filter",
19047+ &[
19048+ "--enable-dual-filter=1",
19049+ "--enable-obmc=1",
19050+ "--enable-warped-motion=1",
19051+ "--enable-onesided-comp=1",
19052+ ],
19053+ 64,
19054+ std::env::var("EC_INTERP3_FRAMES")
19055+ .ok()
19056+ .and_then(|v| v.parse().ok())
19057+ .unwrap_or(16),
19058+ );
19059+ // The ARRIVAL assert comes first on purpose. `dual_filter_diff_hits()`
19060+ // moves only inside `resolve_interp_filter` when the header bit is set
19061+ // AND the block's two directions differ, so pinning it =0 reds HERE,
19062+ // on the tool failing to arrive -- not on some shape or pixel assert
19063+ // downstream of it. The two header asserts below corroborate it from
19064+ // the encoded bytes; they are not what carries the proof.
19065+ assert!(
19066+ decode::dual_filter_diff_hits() > before_dual,
19067+ "{NAME}: no block read two DIFFERENT dual-filter directions in the 10-bit stream \
19068+ -- --enable-dual-filter=1 did not arrive or aomenc declined it"
19069+ );
19070+ // Both facts from the PARSED header, not from what we asked for: a
19071+ // gate that trusted `--bit-depth=10` would pass on a stream aomenc
19072+ // silently coded at 8, which is the vacuity this asserts against.
19073+ let mut probe = Av1Parser::new();
19074+ let mut pos = 0usize;
19075+ while pos < stream.len() && probe.sequence_header().is_none() {
19076+ let obu = probe.parse_obu(&stream[pos..]).unwrap();
19077+ pos += obu.total_size;
19078+ }
19079+ let seq = probe
19080+ .sequence_header()
19081+ .expect("stream has a sequence header OBU");
19082+ assert_eq!(
19083+ seq.color_config.bit_depth, 10,
19084+ "{NAME}: aomenc did not write a 10-bit sequence header"
19085+ );
19086+ assert!(
19087+ seq.enable_dual_filter,
19088+ "{NAME}: the parsed sequence header says enable_dual_filter = false, so this \
19089+ stream cannot carry per-direction interp filters however the pixels compare"
19090+ );
19091+ }
19092+
1769519093 #[test]
1769619094 fn a_real_aomenc_inter_sequence_with_an_8x8_leaf_split_decodes_pixel_exact() {
1769719095 inter_sb_none_gate(
@@ -19270,6 +20668,240 @@ pub(crate) mod tests {
1927020668 );
1927120669 }
1927220670
20671+ /// lane-av1chrtx: the SIBLING of lane-av1444chr's four-unit arm -- a RECT
20672+ /// inter block's chroma plane, read by `read_inter_rect_chroma`. That
20673+ /// helper was left handing every unit the block-level `luma_tx_type`
20674+ /// (the top-left leaf's type) after the four-unit arms were pointed at
20675+ /// `covering_leaf_tx_type`, so a rect block whose chroma plane splits
20676+ /// (`nx*ny > 1`) over MIXED var-tx leaves read the wrong type per unit.
20677+ ///
20678+ /// The witness is pinned into `fixtures/`: `testsrc2 256x256` yuv444p 3
20679+ /// frames, aomenc `--profile=1 --cq-level=30 --cpu-used=0 --sb-size=64
20680+ /// --min-partition-size=32 --max-partition-size=64 --enable-tx-size-search=1
20681+ /// --passes=1 --end-usage=q --threads=1 --row-mt=0 --lag-in-frames=0
20682+ /// --kf-max-dist=100 --limit=3 --obu`; 26839 bytes, sha256
20683+ /// `06174a66e92aaeb751a8e86db59711fcb1f18d74bde2d77e1ef1be7983eb7c80`.
20684+ /// Its one qualifying block is the 32x64 inter strip at mi(32,48): a
20685+ /// 4:4:4 chroma plane of (32,64) = TWO TX_32X32 units, over a luma tree
20686+ /// of five leaves -- `Idtx` (32x32) on top, then `VDct`/`DctDct`/`HDct`/
20687+ /// `VDct` 16x16 leaves. The lower chroma unit therefore inherits `VDct`
20688+ /// where the block-level value is `Idtx`.
20689+ ///
20690+ /// Getting a witness at all took a bounded hunt (200+ encodes): `multi`
20691+ /// is false by construction at 4:2:0 (a `side <= 64` block's chroma plane
20692+ /// is at most 32x32 = one unit), so the arm needs 4:4:4 AND a rect block
crates/ec-av1/src/tile.rsmodified+30 -38
@@ -12,16 +12,16 @@
1212 use std::cell::RefCell;
1313 #[cfg(test)]
1414 use std::collections::BTreeMap;
15-use std::sync::atomic::{AtomicU64, AtomicUsize, Ordering};
1615 use std::sync::LazyLock;
16+use std::sync::atomic::{AtomicU64, AtomicUsize, Ordering};
1717
1818 use ec_core::{Error, Result};
1919
2020 use crate::cdf;
2121 use crate::cdf_state::{Cdfs, MvComponentCdfs, TxbSet, TxbTables};
22-use crate::decode::{txfm_partition_ctx_rect, TXFM_CTX_INIT};
22+use crate::decode::{TXFM_CTX_INIT, txfm_partition_ctx_rect};
2323 use crate::msac::SymbolEncoder;
24-use crate::mvstack::{find_mv_stack, mv16, MiGrid, MiInfo, NO_REF1};
24+use crate::mvstack::{MiGrid, MiInfo, NO_REF1, find_mv_stack, mv16};
2525 use crate::transform::TxType;
2626
2727 // ---------------------------------------------------------------------------
@@ -1637,10 +1637,10 @@ fn write_compound_ref_frames(
16371637 (ref0, ref1): (i8, i8),
16381638 ) -> Result<()> {
16391639 use crate::mvstack::{
1640- comp_reference_type_ctx, single_ref_p1_ctx, single_ref_p2_ctx, single_ref_p3_ctx,
1641- single_ref_p4_ctx, single_ref_p5_ctx, single_ref_p6_ctx, uni_comp_ref_p1_ctx,
1642- ALTREF2_FRAME, ALTREF_FRAME, BWDREF_FRAME, GOLDEN_FRAME, LAST2_FRAME, LAST3_FRAME,
1643- LAST_FRAME,
1640+ ALTREF_FRAME, ALTREF2_FRAME, BWDREF_FRAME, GOLDEN_FRAME, LAST_FRAME, LAST2_FRAME,
1641+ LAST3_FRAME, comp_reference_type_ctx, single_ref_p1_ctx, single_ref_p2_ctx,
1642+ single_ref_p3_ctx, single_ref_p4_ctx, single_ref_p5_ctx, single_ref_p6_ctx,
1643+ uni_comp_ref_p1_ctx,
16441644 };
16451645 let a = (above_ref > 0).then_some(above_ref);
16461646 let l = (left_ref > 0).then_some(left_ref);
@@ -1819,7 +1819,10 @@ fn write_compound_block(
18191819 if crate::envflags::env_flag!("EC_TRACE_MODE") {
18201820 eprintln!(
18211821 "EC_WCOMP mi_row={mi_row} mi_col={mi_col} mode={mode} ref0={} ref1={ref1} ctx={ctx} new_mv_ctx={} ref_mv_ctx={} stack={}",
1822- info.ref_frame, stack.new_mv_ctx, stack.ref_mv_ctx, stack.entries.len()
1822+ info.ref_frame,
1823+ stack.new_mv_ctx,
1824+ stack.ref_mv_ctx,
1825+ stack.entries.len()
18231826 );
18241827 }
18251828 enc.symbol(mode, &mut cdfs.inter_compound_mode[ctx]);
@@ -5889,7 +5892,7 @@ fn scan_of(side: usize) -> &'static Vec<u16> {
58895892 /// DECODER's own table so the two cannot drift, cached per size and class.
58905893 fn class_scan_of(side: usize, class: crate::decode::TxClass) -> &'static [u16] {
58915894 static SCANS: LazyLock<[[Vec<u16>; 2]; 4]> = LazyLock::new(|| {
5892- use crate::decode::{class_scan_table, TxClass};
5895+ use crate::decode::{TxClass, class_scan_table};
58935896 [TX4, TX8, TX16, TX32].map(|side| {
58945897 [
58955898 class_scan_table(side, TxClass::Horiz),
@@ -6966,11 +6969,7 @@ pub(crate) fn intra_inter_ctx(
69666969 /// `CLASS0_SIZE << (class + 2)` (spec 3), the magnitude an `MV_CLASS_n`
69676970 /// component's own bits start counting from; class zero starts at zero.
69686971 fn mv_class_base(class: usize) -> i32 {
6969- if class == 0 {
6970- 0
6971- } else {
6972- 2i32 << (class + 2)
6973- }
6972+ if class == 0 { 0 } else { 2i32 << (class + 2) }
69746973 }
69756974
69766975 /// The class a pre-offset magnitude `z` (`|diff| - 1`) falls in — the inverse
@@ -7096,9 +7095,9 @@ fn write_single_ref(
70967095 REF_HITS[(ref_frame.max(1) - 1) as usize % 7]
70977096 .fetch_add(1, std::sync::atomic::Ordering::Relaxed);
70987097 use crate::mvstack::{
7098+ ALTREF_FRAME, ALTREF2_FRAME, BWDREF_FRAME, GOLDEN_FRAME, LAST2_FRAME, LAST3_FRAME,
70997099 single_ref_p1_ctx, single_ref_p2_ctx, single_ref_p3_ctx, single_ref_p4_ctx,
7100- single_ref_p5_ctx, single_ref_p6_ctx, ALTREF2_FRAME, ALTREF_FRAME, BWDREF_FRAME,
7101- GOLDEN_FRAME, LAST2_FRAME, LAST3_FRAME,
7100+ single_ref_p5_ctx, single_ref_p6_ctx,
71027101 };
71037102 let above = (above_ref > 0).then_some(above_ref);
71047103 let left = (left_ref > 0).then_some(left_ref);
@@ -7196,10 +7195,15 @@ fn note_drl_clamp(target: usize, signalled: usize, entries: usize) {
71967195 }
71977196 }
71987197
7199-/// Takes and clears [`DRL_CLAMP_HITS`], for a gate's own before/after delta.
7200-#[cfg(test)]
7201-pub(crate) fn take_drl_clamp_hits() -> usize {
7202- DRL_CLAMP_HITS.swap(0, std::sync::atomic::Ordering::Relaxed)
7198+/// Reads [`DRL_CLAMP_HITS`] -- the tripwire for the DRL owner's fix. It is
7199+/// provably zero while `every_drl_index_the_new_mv_pricer_offers_is_one_the_writer_can_signal`
7200+/// (encode.rs) holds: the pricer never offers an index this walk cannot signal,
7201+/// so no clip can move it (lane-av1recipehunt, 153 attempts, plus a mutation
7202+/// proof that widening the pricer's offer set does). The clip gate that used
7203+/// to wait on it is deleted; this counter stays so that widening the pricer
7204+/// is loud instead of silent. `EC_AV1_TRACE=1` prints each hit.
7205+pub fn drl_clamp_hits() -> usize {
7206+ DRL_CLAMP_HITS.load(std::sync::atomic::Ordering::Relaxed)
72037207 }
72047208
72057209 fn note_inter_mode(mode: usize, drl: usize) {
@@ -7335,7 +7339,7 @@ fn write_inter_mode(
73357339 enc.symbol(1, &mut cdfs.new_mv[stack.new_mv_ctx]); // not NEWMV
73367340 enc.symbol(1, &mut cdfs.zero_mv[stack.zero_mv_ctx]); // not GLOBALMV
73377341 enc.symbol(1, &mut cdfs.ref_mv[stack.ref_mv_ctx]); // NEARMV
7338- // `RefMvIdx` starts at 1 for NEARMV (spec 5.11.24).
7342+ // `RefMvIdx` starts at 1 for NEARMV (spec 5.11.24).
73397343 let idx = idx.max(1);
73407344 let signalled = write_drl_idx(enc, cdfs, stack, 1, idx);
73417345 let mv = stack.entries.get(signalled).map_or(stack.near_mv, |e| e.mv);
@@ -8954,8 +8958,8 @@ mod tests {
89548958 use crate::sequence::sequence_header_obu;
89558959 use ec_av1_syntax::sequence::SequenceHeader;
89568960 use ec_av1_syntax::{
8957- FrameHeader, FrameType, LoopFilterParams, QuantizationParams, TileInfo, TxMode,
8958- PRIMARY_REF_NONE,
8961+ FrameHeader, FrameType, LoopFilterParams, PRIMARY_REF_NONE, QuantizationParams, TileInfo,
8962+ TxMode,
89598963 };
89608964 use std::process::{Command, Stdio};
89618965
@@ -10594,11 +10598,7 @@ mod tests {
1059410598 .map(|&v| {
1059510599 let m = f64::from(v).abs() + 0.5;
1059610600 let l = if m < 1.0 { 0 } else { m.floor() as i32 };
10597- if v < 0.0 {
10598- -l
10599- } else {
10600- l
10601- }
10601+ if v < 0.0 { -l } else { l }
1060210602 })
1060310603 .collect();
1060410604 let before = levels.clone();
@@ -10657,11 +10657,7 @@ mod tests {
1065710657 .map(|&v| {
1065810658 let m = f64::from(v).abs() + 0.5;
1065910659 let l = if m < 1.0 { 0 } else { m.floor() as i32 };
10660- if v < 0.0 {
10661- -l
10662- } else {
10663- l
10664- }
10660+ if v < 0.0 { -l } else { l }
1066510661 })
1066610662 .collect();
1066710663 let bits = rdoq(
@@ -11158,11 +11154,7 @@ mod tests {
1115811154 (d << 3) | (fr << 1) | 1
1115911155 };
1116011156 let mag = mv_class_base(class) + local as i32 + 1;
11161- if sign == 1 {
11162- -mag
11163- } else {
11164- mag
11165- }
11157+ if sign == 1 { -mag } else { mag }
1116611158 }
1116711159
1116811160 /// Decodes one superblock a [`sb_coeff_inter_frame_tile`] payload wrote,
crates/ec-av1/src/transform.rsmodified+220 -3
@@ -186,7 +186,7 @@ impl Lane for [i32; 8] {
186186 #[cfg(target_arch = "x86_64")]
187187 #[allow(unsafe_code)]
188188 mod simd {
189- use super::{inverse_dct_n, Lane, COS_BITS};
189+ use super::{COS_BITS, Lane, inverse_dct_n};
190190 use std::arch::x86_64::*;
191191
192192 /// Eight `i32` lanes in one AVX2 register.
@@ -2717,7 +2717,9 @@ mod tests {
27172717 inverse_adst16(&mut t, 16);
27182718 assert_eq!(
27192719 t,
2720- [32, 73, 28, 6, -45, -28, 111, -52, 135, -54, 85, -67, 305, 190, 102, 145]
2720+ [
2721+ 32, 73, 28, 6, -45, -28, 111, -52, 135, -54, 85, -67, 305, 190, 102, 145
2722+ ]
27212723 );
27222724 }
27232725
@@ -2737,7 +2739,9 @@ mod tests {
27372739 inverse_identity(&mut t16, 16);
27382740 assert_eq!(
27392741 t16,
2740- [283, -141, 71, 20, -8, 170, -34, 23, 42, -113, 93, -14, 62, 3, -198, 124]
2742+ [
2743+ 283, -141, 71, 20, -8, 170, -34, 23, 42, -113, 93, -14, 62, 3, -198, 124
2744+ ]
27412745 );
27422746
27432747 let mut t32 = [0i32; 32];
@@ -3152,6 +3156,92 @@ pub fn dequant_and_inverse_wht4x4(
31523156 })
31533157 }
31543158
3159+/// lane-whtshape: the lossless inverse transform for a unit of ANY shape.
3160+///
3161+/// libaom never codes a lossless transform unit that is not 4x4, and it says
3162+/// so in two places this decoder already mirrors:
3163+///
3164+/// * `read_tx_mode` (`av1/decoder/decodeframe.c:140`) returns `ONLY_4X4`
3165+/// for a `coded_lossless` frame BEFORE it looks at the `tx_mode` symbol, so
3166+/// a lossless frame has no var-tx tree at all; and
3167+/// * `av1_get_tx_size` (`av1/common/blockd.h`) returns `TX_4X4` for EVERY
3168+/// plane of a lossless block before it looks at a tree.
3169+///
3170+/// The WHT dispatch proves the same from the other side: of
3171+/// `av1/common/idct.c`'s `highbd_inv_txfm_add_{4x8,8x4,16x4,...}_c`, ONLY
3172+/// `highbd_inv_txfm_add_4x4_c` carries a lossless branch
3173+/// (`idct.c:50`: `if (lossless) { av1_highbd_iwht4x4_add(...); return; }`).
3174+/// Every other size falls straight through to the IDCT network -- libaom has
3175+/// no lossless inverse transform for a non-4x4 unit to dispatch to, because
3176+/// `read_tx_mode`/`av1_get_tx_size` make that unit unreachable.
3177+///
3178+/// So a non-4x4 `lossless: true` [`TxParams`](crate::decode::TxParams) is
3179+/// never a bitstream libaom could have produced: it is THIS decoder's own
3180+/// transform-unit geometry being wrong. The function is nevertheless TOTAL
3181+/// (it used to be a `debug_assert_eq!` plus a 16-value result for a
3182+/// `w * h` block, which panicked one frame later in RELEASE with an opaque
3183+/// `range end index .. out of range for slice of length 0`): a unit is
3184+/// reconstructed as the raster of 4x4 WHT units that libaom's lossless
3185+/// geometry would have produced for that footprint -- the same numbers, in
3186+/// the same places, the correct per-4x4 caller would have written. The 4x4
3187+/// case is the same single call it always was, so the lossless fast path is
3188+/// bit-for-bit unchanged.
3189+///
3190+/// `w`/`h` need not be multiples of four: a partial tile is zero-filled, so
3191+/// no shape panics and no shape returns a buffer the caller cannot index.
3192+/// Returns the same empty-grid marker as [`dequant_and_inverse_wht4x4`].
3193+pub fn dequant_and_inverse_wht(
3194+ levels: &[i32],
3195+ w: usize,
3196+ h: usize,
3197+ bit_depth: u8,
3198+ q_idx: i32,
3199+ dc_delta: i32,
3200+ ac_delta: i32,
3201+) -> Vec<i32> {
3202+ if w == 4 && h == 4 {
3203+ return dequant_and_inverse_wht4x4(levels, bit_depth, q_idx, dc_delta, ac_delta);
3204+ }
3205+ if crate::decode::is_zero_grid(levels) {
3206+ return Vec::new();
3207+ }
3208+ let mut out = vec![0i32; w * h];
3209+ let mut tile = [0i32; 16];
3210+ for ty in 0..h.div_ceil(4) {
3211+ for tx in 0..w.div_ceil(4) {
3212+ for r in 0..4 {
3213+ for c in 0..4 {
3214+ let (sy, sx) = (ty * 4 + r, tx * 4 + c);
3215+ tile[r * 4 + c] = if sy < h && sx < w {
3216+ levels[sy * w + sx]
3217+ } else {
3218+ 0
3219+ };
3220+ }
3221+ }
3222+ let res = dequant_and_inverse_wht4x4(&tile, bit_depth, q_idx, dc_delta, ac_delta);
3223+ // An all-zero tile dequantizes to the same empty marker a 4x4
3224+ // caller passes straight through, and `out` is already zero --
3225+ // copying out of it would index an empty slice.
3226+ if res.is_empty() {
3227+ continue;
3228+ }
3229+ for r in 0..4 {
3230+ let (sy, sx) = (ty * 4 + r, tx * 4);
3231+ if sy >= h {
3232+ continue;
3233+ }
3234+ for c in 0..4 {
3235+ if sx + c < w {
3236+ out[sy * w + sx + c] = res[r * 4 + c];
3237+ }
3238+ }
3239+ }
3240+ }
3241+ }
3242+ out
3243+}
3244+
31553245 #[cfg(test)]
31563246 mod lossless_tx_tests {
31573247 /// The WHT is its own inverse up to the `UNIT_QUANT_SHIFT` scaling: a
@@ -3216,6 +3306,133 @@ mod lossless_tx_tests {
32163306 );
32173307 }
32183308 }
3309+
3310+ /// lane-whtshape: the shape-total lossless entry must be EXACTLY the
3311+ /// per-4x4 raster libaom's lossless geometry produces -- the same numbers
3312+ /// in the same places that a caller walking `(w/4) * (h/4)` real TX_4X4
3313+ /// units would have written. Comparing against independently-composed
3314+ /// per-unit [`super::dequant_and_inverse_wht4x4`] calls is what makes the
3315+ /// split a total, not a guess.
3316+ #[test]
3317+ fn a_non_4x4_lossless_unit_is_the_raster_of_4x4_wht_units() {
3318+ let mut state = 0x0bad_c0deu32;
3319+ let mut next = || {
3320+ state = state.wrapping_mul(1_664_525).wrapping_add(1_013_904_223);
3321+ ((state >> 19) as i32 % 2001) - 1000
3322+ };
3323+ // A `w x h` coefficient grid is ROW-MAJOR at width `w`, so a 4x4 tile
3324+ // at `(tx * 4, ty * 4)` is a strided gather, not a contiguous run --
3325+ // the reference below gathers it the same way the split does.
3326+ let tile_of = |levels: &[i32], w: usize, tx: usize, ty: usize| -> Vec<i32> {
3327+ let mut t = vec![0i32; 16];
3328+ for r in 0..4 {
3329+ for c in 0..4 {
3330+ t[r * 4 + c] = levels[(ty * 4 + r) * w + tx * 4 + c];
3331+ }
3332+ }
3333+ t
3334+ };
3335+ for &(w, h) in &[(8usize, 4usize), (4, 8), (8, 8), (16, 4), (4, 16), (16, 16)] {
3336+ let levels: Vec<i32> = (0..w * h).map(|_| next()).collect();
3337+ let got = super::dequant_and_inverse_wht(&levels, w, h, 10, 0, 0, 0);
3338+ let mut want = vec![0i32; w * h];
3339+ for ty in 0..h / 4 {
3340+ for tx in 0..w / 4 {
3341+ let unit = super::dequant_and_inverse_wht4x4(
3342+ &tile_of(&levels, w, tx, ty),
3343+ 10,
3344+ 0,
3345+ 0,
3346+ 0,
3347+ );
3348+ // An all-zero tile is the empty marker on both sides; the
3349+ // output is already zero there.
3350+ if unit.is_empty() {
3351+ continue;
3352+ }
3353+ for r in 0..4 {
3354+ let dst = (ty * 4 + r) * w + tx * 4;
3355+ want[dst..dst + 4].copy_from_slice(&unit[r * 4..][..4]);
3356+ }
3357+ }
3358+ }
3359+ assert_eq!(got.len(), w * h, "{w}x{h}: residual length");
3360+ assert_eq!(got, want, "{w}x{h}: split differs from the 4x4 raster");
3361+ }
3362+ }
3363+
3364+ /// A grid whose non-zero coefficients sit in ONE tile: every other tile is
3365+ /// all zero, so it dequantizes to the empty marker rather than to 16
3366+ /// zeros. Copying out of that marker is an index panic -- the split has to
3367+ /// leave those samples at zero, exactly as a per-unit caller would.
3368+ #[test]
3369+ fn a_lossless_split_whose_other_tiles_are_all_zero_still_reconstructs() {
3370+ // Row 0 columns 0, 1 and 2 of an 8-wide grid: all three land in the
3371+ // LEFT 4x4 tile, so the right tile is all zero and dequantizes to the
3372+ // empty marker rather than to 16 zeros.
3373+ let mut levels = vec![0i32; 8 * 4];
3374+ levels[0] = 400;
3375+ levels[1] = -240;
3376+ levels[2] = 88;
3377+ let got = super::dequant_and_inverse_wht(&levels, 8, 4, 10, 0, 0, 0);
3378+ assert_eq!(got.len(), 32, "8x4 residual length");
3379+ let mut want = vec![0i32; 32];
3380+ for (tx, ty) in [(0usize, 0usize), (1, 0)] {
3381+ let mut t = vec![0i32; 16];
3382+ for r in 0..4 {
3383+ for c in 0..4 {
3384+ t[r * 4 + c] = levels[(ty * 4 + r) * 8 + tx * 4 + c];
3385+ }
3386+ }
3387+ let unit = super::dequant_and_inverse_wht4x4(&t, 10, 0, 0, 0);
3388+ if unit.is_empty() {
3389+ continue;
3390+ }
3391+ for r in 0..4 {
3392+ let dst = (ty * 4 + r) * 8 + tx * 4;
3393+ want[dst..dst + 4].copy_from_slice(&unit[r * 4..][..4]);
3394+ }
3395+ }
3396+ assert_eq!(got, want, "a partially-zero 8x4 lossless grid");
3397+ assert!(
3398+ got.iter().any(|&v| v != 0),
3399+ "the fixture's non-zero tile produced an all-zero residual -- the arm is vacuous"
3400+ );
3401+ }
3402+
3403+ /// The 4x4 fast path is the same single call it has always been: a
3404+ /// lossless unit that IS 4x4 must produce byte-identical numbers with and
3405+ /// without the shape dispatch, so no currently-green lossless pin moves.
3406+ #[test]
3407+ fn the_4x4_lossless_fast_path_is_unchanged() {
3408+ let mut state = 0x5eed_1234u32;
3409+ for _ in 0..64 {
3410+ let levels: Vec<i32> = (0..16)
3411+ .map(|_| {
3412+ state = state.wrapping_mul(1_664_525).wrapping_add(1_013_904_223);
3413+ ((state >> 19) as i32 % 2001) - 1000
3414+ })
3415+ .collect();
3416+ assert_eq!(
3417+ super::dequant_and_inverse_wht(&levels, 4, 4, 8, 0, 0, 0),
3418+ super::dequant_and_inverse_wht4x4(&levels, 8, 0, 0, 0),
3419+ "levels={levels:?}"
3420+ );
3421+ }
3422+ }
3423+
3424+ /// The empty-grid marker contract is the one every residual caller
3425+ /// branches on (`TxParams::run` passes it straight through as "this unit
3426+ /// codes nothing"): a shape that is not 4x4 must keep it, or a skipped
3427+ /// 8x4 unit would hand its caller a 32-long zero buffer it then re-adds
3428+ /// onto the prediction twice.
3429+ #[test]
3430+ fn a_non_4x4_all_zero_lossless_unit_keeps_the_empty_marker() {
3431+ assert!(
3432+ super::dequant_and_inverse_wht(&[0i32; 32], 8, 4, 10, 0, 0, 0).is_empty(),
3433+ "an all-zero 8x4 lossless unit must stay the empty marker"
3434+ );
3435+ }
32193436 }
32203437
32213438 #[cfg(test)]
crates/ec-flac/tests/xiph_vectors.rsmodified+26 -67
@@ -6,11 +6,7 @@
66 //! must be identical. Lossless codec, no tolerance.
77 //!
88 //! The corpus is fetched by `scripts/fetch-vectors.sh`; without it every test
9-//! here skips rather than fails, so a fresh clone still runs green. Set
10-//! `EC_REQUIRE_FIXTURES=1` to turn an absent or empty corpus into a hard
11-//! failure instead (class: gate-skips-on-its-own-failure; model `have_ffmpeg`
12-//! in crates/ec-av1/src/stream.rs, silently short-circuited because the probe
13-//! ran first in a compound `if`).
9+//! here skips rather than fails, so a fresh clone still runs green.
1410 //!
1511 //! Run the tables:
1612 //! cargo test -p ec-flac --release --test xiph_vectors -- --nocapture
@@ -21,47 +17,37 @@ use std::process::Command;
2117 use ec_flac::checksum::md5_of_samples;
2218 use ec_flac::decode::FlacReader;
2319
24-/// Fixture-presence probe for the Xiph FLAC corpus.
25-/// Returns whether the fixture is present, but never silently: under
26-/// `EC_REQUIRE_FIXTURES=1` an absent fixture is a hard failure naming the path
27-/// and the script that regenerates it, so a host whose fixture library drifted
28-/// reports RED instead of a green SKIP (class: gate-skips-on-its-own-failure;
29-/// model `have_ffmpeg` in crates/ec-av1/src/stream.rs, which was silently
30-/// short-circuited because the probe ran first in a compound `if`).
31-///
32-/// Order is load-bearing: probe, assert, return. Never merge the probe into
33-/// the same `if` as the escape.
34-fn require_fixture(path: &Path, generator: &str) -> bool {
35- let present = path.exists();
36- assert!(
37- present || std::env::var_os("EC_REQUIRE_FIXTURES").is_none(),
38- "EC_REQUIRE_FIXTURES=1 but fixture {} is absent -- regenerate with: {}",
39- path.display(),
40- generator
41- );
42- if !present {
43- eprintln!("SKIP: fixture {} absent", path.display());
44- }
45- present
46-}
47-
4820 fn corpus(kind: &str) -> Option<Vec<PathBuf>> {
4921 let dir = Path::new(env!("CARGO_MANIFEST_DIR"))
5022 .join("../../fixtures/vectors/flac-xiph/flac-test-files-main")
5123 .join(kind);
52- // Probe first, and never as part of the `ok()?` escape: a missing directory
53- // must assert under EC_REQUIRE_FIXTURES instead of short-circuiting the
54- // whole helper into a silent skip.
55- if !require_fixture(&dir, "scripts/fetch-vectors.sh") {
24+ // A missing corpus made every gate below skip GREEN having decoded nothing
25+ // — the "gate skips on its own failure" class. The root `fixtures/` tree is
26+ // gitignored, so `git worktree add` hands every lane worktree a tree without
27+ // it. `EC_REQUIRE_FIXTURES=1` turns that into a hard failure naming the
28+ // exact path and the command that produces it; unset, the skip is kept and
29+ // now says what it skipped. Set it in every batch run.
30+ if !dir.is_dir() {
31+ assert!(
32+ std::env::var_os("EC_REQUIRE_FIXTURES").is_none(),
33+ "the FLAC xiph {kind} corpus is missing at {} — these gates would prove \
34+ nothing. A worktree has no gitignored root `fixtures/`: run \
35+ scripts/link-fixtures.sh, or fetch it with scripts/fetch-vectors.sh.",
36+ dir.display()
37+ );
38+ eprintln!(
39+ "SKIP the FLAC xiph {kind} corpus is missing at {} — these gates proved \
40+ nothing; run scripts/link-fixtures.sh, or fetch it with \
41+ scripts/fetch-vectors.sh (or set EC_REQUIRE_FIXTURES=1 to make this a failure).",
42+ dir.display()
43+ );
5644 return None;
5745 }
58- let mut files: Vec<PathBuf> = match std::fs::read_dir(&dir) {
59- Ok(entries) => entries
60- .filter_map(|e| e.ok().map(|e| e.path()))
61- .filter(|p| p.extension().is_some_and(|e| e == "flac"))
62- .collect(),
63- Err(e) => panic!("read fixture dir {}: {e}", dir.display()),
64- };
46+ let mut files: Vec<PathBuf> = std::fs::read_dir(&dir)
47+ .ok()?
48+ .filter_map(|e| e.ok().map(|e| e.path()))
49+ .filter(|p| p.extension().is_some_and(|e| e == "flac"))
50+ .collect();
6551 files.sort();
6652 match files.is_empty() {
6753 true => None,
@@ -100,12 +86,6 @@ fn subset_vectors_decode_bit_exact_against_ffmpeg() {
10086 eprintln!("skipped: fixtures/vectors/flac-xiph not fetched");
10187 return;
10288 };
103- // Non-empty floor: a zero-file corpus would loop zero times and pass.
104- assert!(
105- files.len() >= 5,
106- "subset corpus holds {} .flac files, expected at least 5",
107- files.len()
108- );
10989 let mut failures = Vec::new();
11090 let mut passed = 0;
11191 for path in &files {
@@ -177,11 +157,6 @@ fn uncommon_vectors_decode_bit_exact_or_refuse_by_name() {
177157 eprintln!("skipped: fixtures/vectors/flac-xiph not fetched");
178158 return;
179159 };
180- assert!(
181- files.len() >= 5,
182- "uncommon corpus holds {} .flac files, expected at least 5",
183- files.len()
184- );
185160 let mut failures = Vec::new();
186161 for path in &files {
187162 let bytes = std::fs::read(path).expect("read fixture");
@@ -217,11 +192,6 @@ fn faulty_vectors_error_and_never_panic() {
217192 eprintln!("skipped: fixtures/vectors/flac-xiph not fetched");
218193 return;
219194 };
220- assert!(
221- files.len() >= 5,
222- "faulty corpus holds {} .flac files, expected at least 5",
223- files.len()
224- );
225195 // Faults our reader is expected to catch outright rather than decode past:
226196 // these break the structure a decoder must trust.
227197 let must_reject = ["06 - ", "07 - ", "08 - ", "09 - ", "11 - "];
@@ -248,11 +218,6 @@ fn seek_table_positions_the_reader_at_a_frame() {
248218 eprintln!("skipped: fixtures/vectors/flac-xiph not fetched");
249219 return;
250220 };
251- assert!(
252- files.len() >= 5,
253- "subset corpus holds {} .flac files, expected at least 5",
254- files.len()
255- );
256221 // "48 - Extremely large SEEKTABLE" is the file with a seek table worth
257222 // exercising; any file carrying one proves the hook.
258223 let mut checked = 0;
@@ -283,10 +248,4 @@ fn seek_table_positions_the_reader_at_a_frame() {
283248 }
284249 }
285250 println!("seek: {checked} files with a seek table exercised");
286- // The loop skips every file without a seek table, so it can reach zero
287- // iterations even with a full corpus: floor the exercised count.
288- assert!(
289- checked >= 1,
290- "no subset fixture carried a SEEKTABLE, so the seek hook went unexercised"
291- );
292251 }
crates/ec-h264/tests/conformance.rsmodified+90 -90
@@ -68,45 +68,32 @@ fn vectors_dir() -> PathBuf {
6868 Path::new(env!("CARGO_MANIFEST_DIR")).join("../../fixtures/vectors/h264-jvt")
6969 }
7070
71-/// Fixture-presence probe for the JVT vector library these tests decode.
72-/// Returns whether the fixture is present, but never silently: under
73-/// `EC_REQUIRE_FIXTURES=1` an absent fixture is a hard failure naming the path
74-/// and the script that populates it, so a host whose fixture library drifted
75-/// reports RED instead of a green SKIP (class: gate-skips-on-its-own-failure;
76-/// model `have_ffmpeg` in crates/ec-av1/src/stream.rs, which was silently
77-/// short-circuited because the probe ran first in a compound `if`).
71+/// A gate that skips when its fixtures are absent reports GREEN having checked
72+/// nothing — the "gate skips on its own failure" class. The root `fixtures/`
73+/// directory is gitignored, so `git worktree add` hands every lane worktree a
74+/// tree without it and the whole conformance suite silently stops testing.
7875 ///
79-/// Order is load-bearing: probe, assert, return. Never merge the probe into
80-/// the same `if` as the escape.
81-fn require_fixture(path: &std::path::Path, generator: &str) -> bool {
82- let present = path.exists();
83- assert!(
84- present || std::env::var_os("EC_REQUIRE_FIXTURES").is_none(),
85- "EC_REQUIRE_FIXTURES=1 but fixture {} is absent -- regenerate with: {}",
86- path.display(),
87- generator
88- );
89- if !present {
90- eprintln!("SKIP: fixture {} absent", path.display());
76+/// `EC_REQUIRE_FIXTURES=1` turns the skip into a hard failure naming the exact
77+/// missing path and the command that produces it; unset (the default), the skip
78+/// is kept and now says what it skipped. Set it in every batch run.
79+fn require_fixtures(path: &Path, what: &str, generator: &str) -> bool {
80+ if path.exists() {
81+ return true;
9182 }
92- present
93-}
94-/// The same probe for one vector directory: `find_stream` returning `None`
95-/// means the JVT vector was extracted without its bitstream, which is a hole
96-/// in the fixture library and not a reason to test one vector fewer silently.
97-/// Probe first, assert unconditionally, return last — same order as
98-/// [`require_fixture`].
99-fn require_stream(dir: &Path) -> Option<PathBuf> {
100- let found = find_stream(dir);
10183 assert!(
102- found.is_some() || std::env::var_os("EC_REQUIRE_FIXTURES").is_none(),
103- "EC_REQUIRE_FIXTURES=1 but {} holds no bitstream file -- regenerate with: scripts/fetch-vectors.sh",
104- dir.display()
84+ std::env::var_os("EC_REQUIRE_FIXTURES").is_none(),
85+ "{what} missing at {} — this gate would prove nothing. A worktree has no \
86+ gitignored root `fixtures/`: run scripts/link-fixtures.sh, or generate \
87+ them with {generator}.",
88+ path.display()
10589 );
106- if found.is_none() {
107- eprintln!("SKIP: no bitstream file in {}", dir.display());
108- }
109- found
90+ eprintln!(
91+ "SKIP {what} missing at {} — this gate proved nothing; run \
92+ scripts/link-fixtures.sh, or generate them with {generator} \
93+ (or set EC_REQUIRE_FIXTURES=1 to make this a failure).",
94+ path.display()
95+ );
96+ false
11097 }
11198
11299 /// Every vector directory `scripts/fetch-vectors.sh` has populated, in name
@@ -117,9 +104,6 @@ fn require_stream(dir: &Path) -> Option<PathBuf> {
117104 /// regressed from bit-exact to refused would be invisible. Walking the
118105 /// directory makes every fixture on disk a claim this test has to account for.
119106 fn all_vectors(base: &Path) -> Vec<String> {
120- // Probe first, assert inside the helper, build the list last: a missing
121- // vector directory must not read as "zero vectors, nothing to check".
122- require_fixture(base, "scripts/fetch-vectors.sh");
123107 let mut names: Vec<String> = std::fs::read_dir(base)
124108 .into_iter()
125109 .flatten()
@@ -146,23 +130,6 @@ fn find_stream(dir: &Path) -> Option<PathBuf> {
146130 fallback
147131 }
148132
149-/// Same shape for a file the JVT vector is supposed to carry besides its
150-/// bitstream: the reference decoder YUV. Every vector `scripts/fetch-vectors.sh`
151-/// populates ships one, so its absence is a hole in the fixture library, not a
152-/// licence to verify that vector against nothing.
153-fn require_ref_yuv(dir: &Path) -> Option<PathBuf> {
154- let found = find_ref_yuv(dir);
155- assert!(
156- found.is_some() || std::env::var_os("EC_REQUIRE_FIXTURES").is_none(),
157- "EC_REQUIRE_FIXTURES=1 but {} holds no reference YUV -- regenerate with: scripts/fetch-vectors.sh",
158- dir.display()
159- );
160- if found.is_none() {
161- eprintln!("SKIP: no reference YUV in {}", dir.display());
162- }
163- found
164-}
165-
166133 fn find_ref_yuv(dir: &Path) -> Option<PathBuf> {
167134 for entry in std::fs::read_dir(dir).ok()? {
168135 let p = entry.ok()?.path();
@@ -350,7 +317,11 @@ fn compare_sequence(stream: &Path) -> Result<usize, String> {
350317 #[test]
351318 fn jvt_cavlc_first_idr_bit_exact() {
352319 let base = vectors_dir();
353- if !require_fixture(&base, "scripts/fetch-vectors.sh") {
320+ if !require_fixtures(
321+ &base,
322+ "the JVT conformance vectors",
323+ "scripts/fetch-vectors.sh",
324+ ) {
354325 return;
355326 }
356327 let mut passed = Vec::new();
@@ -359,7 +330,8 @@ fn jvt_cavlc_first_idr_bit_exact() {
359330 for name in all_vectors(&base) {
360331 let name = name.as_str();
361332 let dir = base.join(name);
362- let Some(stream) = require_stream(&dir) else {
333+ let Some(stream) = find_stream(&dir) else {
334+ eprintln!("SKIP {name}: no bitstream file");
363335 continue;
364336 };
365337 let bytes = std::fs::read(&stream).unwrap();
@@ -368,7 +340,7 @@ fn jvt_cavlc_first_idr_bit_exact() {
368340 let frame_len = w * h * 3 / 2;
369341 // Oracle 1: reference decoder YUV, first frame.
370342 let mut ok = true;
371- if let Some(ref_path) = require_ref_yuv(&dir) {
343+ if let Some(ref_path) = find_ref_yuv(&dir) {
372344 let reference = std::fs::read(&ref_path).unwrap();
373345 assert!(
374346 reference.len() >= frame_len,
@@ -452,13 +424,17 @@ fn jvt_cavlc_first_idr_bit_exact() {
452424 #[test]
453425 fn steady_state_decode_loop_zero_alloc() {
454426 let base = vectors_dir();
455- if !require_fixture(&base, "scripts/fetch-vectors.sh") {
427+ if !require_fixtures(
428+ &base,
429+ "the JVT conformance vectors",
430+ "scripts/fetch-vectors.sh",
431+ ) {
456432 return;
457433 }
458434 // One stream per entropy coder, and one with B slices and multiple
459435 // reference frames so the decoded picture buffer really recycles pictures.
460436 for name in ["BA1_Sony_D", "CABA1_SVA_B", "CABA3_SVA_B"] {
461- let Some(stream) = require_stream(&base.join(name)) else {
437+ let Some(stream) = find_stream(&base.join(name)) else {
462438 continue;
463439 };
464440 let bytes = std::fs::read(stream).unwrap();
@@ -535,11 +511,13 @@ fn steady_state_decode_loop_zero_alloc() {
535511 #[test]
536512 fn ns_per_macroblock_measurement() {
537513 let base = vectors_dir();
538- if !require_fixture(&base, "scripts/fetch-vectors.sh") {
514+ if !require_fixtures(
515+ &base,
516+ "the JVT conformance vectors",
517+ "scripts/fetch-vectors.sh",
518+ ) {
539519 return;
540520 }
541-
542- let mut measured = 0usize;
543521 for name in [
544522 "BA1_Sony_D",
545523 "CI_MW_D",
@@ -547,7 +525,7 @@ fn ns_per_macroblock_measurement() {
547525 "CABA1_SVA_B",
548526 "CABA3_SVA_B",
549527 ] {
550- let Some(stream) = require_stream(&base.join(name)) else {
528+ let Some(stream) = find_stream(&base.join(name)) else {
551529 continue;
552530 };
553531 let bytes = std::fs::read(stream).unwrap();
@@ -576,11 +554,7 @@ fn ns_per_macroblock_measurement() {
576554 "PERF {name}: {w}x{h}, {mbs} MBs, {ns_per_mb:.0} ns/MB, {mpx_s:.1} Mpx/s \
577555 (intra IDR, single thread, deblock included, output copy excluded)"
578556 );
579- measured += 1;
580557 }
581- // A run that measured nothing printed no number and proved nothing: the
582- // floor keeps a fixture-less host from reporting PASS for it.
583- assert!(measured > 0, "no vector was measured: {measured}");
584558 perf_whole_sequence();
585559 }
586560
@@ -589,7 +563,7 @@ fn ns_per_macroblock_measurement() {
589563 fn perf_whole_sequence() {
590564 let base = vectors_dir();
591565 for name in ["BA_MW_D", "CABA3_SVA_B", "MR1_BT_A"] {
592- let Some(stream) = require_stream(&base.join(name)) else {
566+ let Some(stream) = find_stream(&base.join(name)) else {
593567 continue;
594568 };
595569 let bytes = std::fs::read(stream).unwrap();
@@ -624,7 +598,11 @@ fn perf_whole_sequence() {
624598 #[test]
625599 fn corrupt_streams_never_panic() {
626600 let base = vectors_dir();
627- if !require_fixture(&base, "scripts/fetch-vectors.sh") {
601+ if !require_fixtures(
602+ &base,
603+ "the JVT conformance vectors",
604+ "scripts/fetch-vectors.sh",
605+ ) {
628606 return;
629607 }
630608 // One stream per entropy coder, plus one with B slices and multiple
@@ -632,17 +610,12 @@ fn corrupt_streams_never_panic() {
632610 // arrays from stream-derived values, and inter prediction indexes the
633611 // decoded picture buffer, the reference lists and the motion arrays from
634612 // them too. All of it needs the same no-panic floor as the CAVLC tables.
635- let mut swept = 0usize;
636613 for name in ["BA1_Sony_D", "CABA1_SVA_B", "CABA3_SVA_B", "BA_MW_D"] {
637- let Some(stream) = require_stream(&base.join(name)) else {
614+ let Some(stream) = find_stream(&base.join(name)) else {
638615 continue;
639616 };
640617 corrupt_sweep(&std::fs::read(stream).unwrap());
641- swept += 1;
642618 }
643- // A sweep over zero streams never panics because it never decodes
644- // anything; the invariant is only proven by real inputs.
645- assert!(swept > 0, "no vector streams were swept: {swept}");
646619 }
647620
648621 /// Truncate and bit-flip `bytes` many ways; every decode must return, error or
@@ -1134,7 +1107,11 @@ fn p_only_gop_matches_ffmpeg_every_frame() {
11341107 #[test]
11351108 fn jvt_full_sequence_bit_exact() {
11361109 let base = vectors_dir();
1137- if !require_fixture(&base, "scripts/fetch-vectors.sh") {
1110+ if !require_fixtures(
1111+ &base,
1112+ "the JVT conformance vectors",
1113+ "scripts/fetch-vectors.sh",
1114+ ) {
11381115 return;
11391116 }
11401117 let mut table = String::new();
@@ -1143,7 +1120,7 @@ fn jvt_full_sequence_bit_exact() {
11431120 let mut failed = Vec::new();
11441121 for name in all_vectors(&base) {
11451122 let dir = base.join(&name);
1146- let Some(stream) = require_stream(&dir) else {
1123+ let Some(stream) = find_stream(&dir) else {
11471124 continue;
11481125 };
11491126 let bytes = std::fs::read(&stream).unwrap();
@@ -1153,7 +1130,7 @@ fn jvt_full_sequence_bit_exact() {
11531130 }
11541131 Ok(frames) => {
11551132 let len = frames[0].len();
1156- let Some(ref_path) = require_ref_yuv(&dir) else {
1133+ let Some(ref_path) = find_ref_yuv(&dir) else {
11571134 table.push_str(&format!(
11581135 "{name:<16} {:>3} frames, no reference YUV\n",
11591136 frames.len()
@@ -1222,13 +1199,6 @@ fn jvt_full_sequence_bit_exact() {
12221199 failed.len()
12231200 );
12241201 assert!(failed.is_empty(), "{failed:#?}");
1225- // `failed.is_empty()` over a loop that can run zero times is vacuously
1226- // green; the floor is the one its first-IDR sibling at the top of this
1227- // file already carries.
1228- assert!(
1229- passed >= 5,
1230- "fewer than 5 full-sequence JVT conformance streams verified bit-exact: {passed}"
1231- );
12321202 }
12331203
12341204 /// Decode a whole stream in decode order rather than display order.
@@ -1912,6 +1882,32 @@ fn compare_container_streamed(
19121882 /// resolutions and GOP structures the fixtures never use, and they are the ones
19131883 /// a user actually opens. Every file either decodes bit-exactly or is refused
19141884 /// by name; a file that decodes to different pixels is a failure.
1885+// lane-h264reallib: LOCAL-ONLY, and the reason lives in the attribute so it
1886+// shows in `cargo test -- --list` instead of hiding in a skip print.
1887+//
1888+// The precondition is a PERSONAL MEDIA LIBRARY: the manifest is generated by
1889+// `scripts/scan-real-library.sh`, which scans `~/Videos ~/Downloads ~/Music`
1890+// by default and is gitignored precisely because it is machine-local. A
1891+// runner host has none of those directories, so both of this test's possible
1892+// behaviours there are wrong:
1893+//
1894+// - manifest absent -> the `SKIP: ... missing` early return, which prints
1895+// green. That is the silent-skip class this batch is removing: a green
1896+// that means "nothing was checked".
1897+// - manifest present but its absolute paths unresolvable (a host that ran
1898+// the scan script against an empty library) -> zero files swept and
1899+// `decoded >= 3` fails. That is the red every fleet run currently eats,
1900+// and it is red for a reason that has nothing to do with the decoder.
1901+//
1902+// Hence `#[ignore]` rather than an env gate: an env gate whose variable is
1903+// absent on the runner prints the same green the missing manifest already
1904+// prints, which is the defect rather than the fix. An ignore is visible in
1905+// `--list`, cannot go green silently, and leaves the assertion itself intact
1906+// -- "the sweep is the point" still holds on the machine that can run it.
1907+//
1908+// Run it on the workstation, where the library is:
1909+// cargo test -p ec-h264 --test conformance real_library_streams_match_ffmpeg -- --ignored
1910+#[ignore = "sweeps the PERSONAL media library (~/Videos, ~/Downloads, ~/Music) through the gitignored fixtures/real-library-manifest.tsv; MINUTES of wall time (measured past 840 s on the workstation), so workstation only -- budget an hour, it is not wedged. A runner host has no such library, so the test is either a silent green or a red for the wrong reason. Run it on the workstation with --ignored."]
19151911 #[test]
19161912 fn real_library_streams_match_ffmpeg() {
19171913 if !have_ffmpeg() {
@@ -1920,10 +1916,10 @@ fn real_library_streams_match_ffmpeg() {
19201916 }
19211917 let manifest =
19221918 Path::new(env!("CARGO_MANIFEST_DIR")).join("../../fixtures/real-library-manifest.tsv");
1923- if !require_fixture(&manifest, "scripts/scan-real-library.sh") {
1919+ let Ok(text) = std::fs::read_to_string(&manifest) else {
1920+ eprintln!("SKIP: {} missing", manifest.display());
19241921 return;
1925- }
1926- let text = std::fs::read_to_string(&manifest).expect("manifest reads");
1922+ };
19271923 let dir = scratch("real-library");
19281924 const FRAMES: usize = 500;
19291925 /// A file counts as swept only when the oracle stayed with us this long.
@@ -2383,7 +2379,11 @@ fn h264_seek_matches_linear_open_gop() {
23832379 return;
23842380 }
23852381 let src = Path::new(env!("CARGO_MANIFEST_DIR")).join("../../fixtures/video/h264-open-gop.mp4");
2386- if !require_fixture(&src, "scripts/gen-fixtures.sh") {
2382+ if !require_fixtures(
2383+ &src,
2384+ "the open-GOP fixture",
2385+ "scripts/gen-fixtures.sh (fixtures/video/h264-open-gop.mp4)",
2386+ ) {
23872387 return;
23882388 }
23892389 let dir = scratch("open-gop");
crates/ec-matroska/tests/matroska.rsmodified+49 -16
@@ -32,7 +32,9 @@ fn aac_priming_round_trips_through_codec_delay() {
3232 let dst = work().join("aac-priming-round-trip.mkv");
3333 let mut muxer = MatroskaMuxer::new(File::create(&dst).expect("output"));
3434 let stream = muxer.add_stream(info).expect("stream declared");
35- muxer.set_track_delay(stream, 21_333_333).expect("declare delay"); // 1024/48000s
35+ muxer
36+ .set_track_delay(stream, 21_333_333)
37+ .expect("declare delay"); // 1024/48000s
3638 for _ in 0..10i64 {
3739 let mut packet = Packet::new(0, rate, vec![0u8; 8]);
3840 packet.duration = Some(1024);
@@ -44,7 +46,8 @@ fn aac_priming_round_trips_through_codec_delay() {
4446 let demuxer =
4547 MatroskaDemuxer::new(BufReader::new(File::open(&dst).expect("opens"))).expect("reopens");
4648 assert_eq!(
47- demuxer.streams()[0].initial_padding, 1024,
49+ demuxer.streams()[0].initial_padding,
50+ 1024,
4851 "CodecDelay round trips to a sample count"
4952 );
5053 }
@@ -802,7 +805,11 @@ fn truncated_prefixes_are_eof_not_corrupt() {
802805 table.join("\n")
803806 );
804807 }
805- println!("{}\nidx,cut,class,packets\n{}", path.display(), table.join("\n"));
808+ println!(
809+ "{}\nidx,cut,class,packets\n{}",
810+ path.display(),
811+ table.join("\n")
812+ );
806813 }
807814
808815 fn matroska_prefix_class(data: &[u8]) -> (&'static str, u64) {
@@ -823,7 +830,6 @@ fn matroska_prefix_class(data: &[u8]) -> (&'static str, u64) {
823830 }
824831 }
825832
826-
827833 /// Where our own demuxer's seek lands on a real 5.1 E-AC-3 Matroska, in
828834 /// *timestamp* -- split from decode, per the round's charter: this measures
829835 /// only [`MatroskaDemuxer::seek`] plus the first packet's `pts`, against what
@@ -963,7 +969,12 @@ fn same_class_sweep(path: &str, wants: &[f64], tolerance_ms: f64) {
963969 #[test]
964970 #[ignore = "sweeps his real library, run manually with --ignored"]
965971 fn laced_audio_sweep_across_his_library() {
966- let manifest = Path::new("/home/user/Documents/Code/Rust/edith_codecs/fixtures/real-library-manifest.tsv");
972+ // lane-h264reallib: `fixtures()` like every sibling, instead of a
973+ // hardcoded absolute path into the primary checkout. The absolute form
974+ // silently defeated worktree isolation: a run in a worktree or a gate tree
975+ // read the MAIN checkout's manifest, so this test measured a different
976+ // tree's library than the one it was compiled from.
977+ let manifest = &fixtures().join("real-library-manifest.tsv");
967978 let Ok(rows) = std::fs::read_to_string(manifest) else {
968979 eprintln!("skipped: {} not present", manifest.display());
969980 return;
@@ -987,8 +998,7 @@ fn laced_audio_sweep_across_his_library() {
987998 if !film.exists() {
988999 continue;
9891000 }
990- let Ok(mut demux) =
991- MatroskaDemuxer::new(BufReader::new(File::open(film).expect("opens")))
1001+ let Ok(mut demux) = MatroskaDemuxer::new(BufReader::new(File::open(film).expect("opens")))
9921002 else {
9931003 eprintln!("{path}: failed to open");
9941004 continue;
@@ -1004,8 +1014,7 @@ fn laced_audio_sweep_across_his_library() {
10041014 for frac in [0.3, 0.7] {
10051015 let want = duration * frac;
10061016 let target = Timestamp::new(
1007- (want * audio.time_base.den() as f64 / audio.time_base.num() as f64).round()
1008- as i64,
1017+ (want * audio.time_base.den() as f64 / audio.time_base.num() as f64).round() as i64,
10091018 audio.time_base,
10101019 );
10111020 if demux
@@ -1096,8 +1105,8 @@ fn real_hdr_film_container_states_no_light_metadata() {
10961105 // duplication, pts) or the shared decoder crate, and which physical channel
10971106 // our 5.1 decode calls "channel 0".
10981107
1099-use ec_ac3::Ac3Decoder;
11001108 use ec_aac::AacDecoder;
1109+use ec_ac3::Ac3Decoder;
11011110
11021111 /// Opens whichever container `path` actually is — both crates implement the
11031112 /// same `Demuxer` trait, so the rest of the harness never has to know which.
@@ -1109,9 +1118,15 @@ fn open_any(path: &Path) -> Box<dyn Demuxer> {
11091118 .read_exact(&mut head)
11101119 .expect("read head");
11111120 if ec_mp4::is_mp4(&head) {
1112- Box::new(ec_mp4::Mp4Demuxer::new(BufReader::new(File::open(path).expect("open"))).expect("mp4 opens"))
1121+ Box::new(
1122+ ec_mp4::Mp4Demuxer::new(BufReader::new(File::open(path).expect("open")))
1123+ .expect("mp4 opens"),
1124+ )
11131125 } else {
1114- Box::new(MatroskaDemuxer::new(BufReader::new(File::open(path).expect("open"))).expect("mkv opens"))
1126+ Box::new(
1127+ MatroskaDemuxer::new(BufReader::new(File::open(path).expect("open")))
1128+ .expect("mkv opens"),
1129+ )
11151130 }
11161131 }
11171132
@@ -1201,7 +1216,15 @@ fn ffmpeg_decode_planar(path: &Path, channels: usize) -> Vec<Vec<f32>> {
12011216 .args(["-v", "error", "-i"])
12021217 .arg(path)
12031218 .args([
1204- "-map", "0:a:0", "-t", "20", "-f", "f32le", "-acodec", "pcm_f32le", "-",
1219+ "-map",
1220+ "0:a:0",
1221+ "-t",
1222+ "20",
1223+ "-f",
1224+ "f32le",
1225+ "-acodec",
1226+ "pcm_f32le",
1227+ "-",
12051228 ])
12061229 .output()
12071230 .expect("ffmpeg runs");
@@ -1251,8 +1274,14 @@ fn best_lag_correlation(ours: &[f32], theirs: &[f32]) -> (i64, f64) {
12511274 let mut best_abs = -1.0f64;
12521275 let mut best = (0i64, 0.0f64);
12531276 for lag in -LAG_MAX..=LAG_MAX {
1254- let (oa, ob) = if lag >= 0 { (0usize, lag as usize) } else { ((-lag) as usize, 0usize) };
1255- let len = WINDOW.min(ours.len().saturating_sub(oa)).min(theirs.len().saturating_sub(ob));
1277+ let (oa, ob) = if lag >= 0 {
1278+ (0usize, lag as usize)
1279+ } else {
1280+ ((-lag) as usize, 0usize)
1281+ };
1282+ let len = WINDOW
1283+ .min(ours.len().saturating_sub(oa))
1284+ .min(theirs.len().saturating_sub(ob));
12561285 if len < 1024 {
12571286 continue;
12581287 }
@@ -1387,7 +1416,11 @@ fn mkv_51_channel_order() {
13871416 pkts.iter().take(5).map(|(p, _)| *p).collect::<Vec<_>>()
13881417 );
13891418 let planes = decode_ac3(&pkts);
1390- assert!(!planes.is_empty(), "{}: no channels decoded", path.display());
1419+ assert!(
1420+ !planes.is_empty(),
1421+ "{}: no channels decoded",
1422+ path.display()
1423+ );
13911424 let ffref = ffmpeg_decode_planar(path, planes.len());
13921425 for (i, ch) in planes.iter().enumerate() {
13931426 let (lag, c) = best_lag_correlation(ch, &ffref[0]);
crates/ec-opus/tests/conformance.rsmodified+54 -123
@@ -87,62 +87,6 @@ fn vectors_dir() -> PathBuf {
8787 .join("../../fixtures/vectors/opus-rfc6716/opus_testvectors")
8888 }
8989
90-/// Fixture-presence probe for the fixtures these tests read.
91-/// Returns whether the fixture is present, but never silently: under
92-/// `EC_REQUIRE_FIXTURES=1` an absent fixture is a hard failure naming the path
93-/// and the script that regenerates it, so a host whose fixture library drifted
94-/// reports RED instead of a green SKIP (class: gate-skips-on-its-own-failure;
95-/// model `have_ffmpeg` in crates/ec-av1/src/stream.rs, which was silently
96-/// short-circuited because the probe ran first in a compound `if`).
97-///
98-/// Order is load-bearing: probe, assert, return. Never merge the probe into
99-/// the same `if` as the escape.
100-fn require_fixture(path: &Path, generator: &str) -> bool {
101- let present = path.exists();
102- assert!(
103- present || std::env::var_os("EC_REQUIRE_FIXTURES").is_none(),
104- "EC_REQUIRE_FIXTURES=1 but fixture {} is absent -- regenerate with: {}",
105- path.display(),
106- generator
107- );
108- if !present {
109- eprintln!("SKIP: fixture {} absent", path.display());
110- }
111- present
112-}
113-
114-/// Presence probe for a HOST media file (`~/Music/...`, `~/Downloads/...`).
115-/// Deliberately NOT [`require_fixture`]: those paths are a developer's
116-/// personal corpus, not the committed fixture library, so `EC_REQUIRE_FIXTURES`
117-/// must not turn one person's home directory into a red suite on every other
118-/// host. It skips, and says so.
119-fn require_host_media(path: &Path, tag: &str) -> bool {
120- let present = path.exists();
121- if !present {
122- eprintln!("SKIP {tag}: host media file {} absent", path.display());
123- }
124- present
125-}
126-
127-/// An RFC 6716 test vector, probed through [`require_fixture`]. `None` means
128-/// absent (and already reported, or already asserted).
129-fn vector(name: &str) -> Option<PathBuf> {
130- let path = vectors_dir().join(format!("{name}.bit"));
131- match require_fixture(&path, "scripts/fetch-vectors.sh") {
132- true => Some(path),
133- false => None,
134- }
135-}
136-
137-/// One of the generated `fixtures/audio` files, probed the same way.
138-fn audio_fixture(name: &str) -> Option<PathBuf> {
139- let path = fixture(name);
140- match require_fixture(&path, "scripts/gen-fixtures.sh") {
141- true => Some(path),
142- false => None,
143- }
144-}
145-
14690 /// Decodes a vector at 48 kHz stereo, returning the samples and how many
14791 /// packets ended with the reference range state.
14892 fn decode_vector(packets: &[VectorPacket]) -> (Vec<f32>, usize, usize) {
@@ -468,13 +412,33 @@ const VECTORS: [&str; 12] = [
468412 /// MUST stay within the `opus_compare` threshold (quality >= 0).
469413 #[test]
470414 fn rfc6716_test_vectors() {
415+ // A missing test vector made this gate skip GREEN having decoded nothing —
416+ // the "gate skips on its own failure" class. The root `fixtures/` tree is
417+ // gitignored, so `git worktree add` hands every lane worktree a tree without
418+ // it. `EC_REQUIRE_FIXTURES=1` turns a missing vector into a hard failure
419+ // naming the exact path and the command that produces it; unset, the skip
420+ // is kept and now says what it skipped. Set it in every batch run.
421+ let base = vectors_dir();
471422 let mut table = Vec::new();
472- let mut ran = 0usize;
473423 for name in VECTORS {
474- let Some(path) = vector(name) else {
424+ let path = base.join(format!("{name}.bit"));
425+ if !path.exists() {
426+ assert!(
427+ std::env::var_os("EC_REQUIRE_FIXTURES").is_none(),
428+ "RFC 6716 test vector {name} missing at {} — this gate would prove \
429+ nothing. A worktree has no gitignored root `fixtures/`: run \
430+ scripts/link-fixtures.sh, or fetch it with scripts/fetch-vectors.sh.",
431+ path.display()
432+ );
433+ eprintln!(
434+ "SKIP RFC 6716 test vector {name} missing at {} — this gate proved \
435+ nothing; run scripts/link-fixtures.sh, or fetch it with \
436+ scripts/fetch-vectors.sh (or set EC_REQUIRE_FIXTURES=1 to make this \
437+ a failure).",
438+ path.display()
439+ );
475440 continue;
476- };
477- ran += 1;
441+ }
478442 let packets = read_vector(&path);
479443 let (pcm, matched, decoded) = decode_vector(&packets);
480444 let reference = read_i16(&vectors_dir().join(format!("{name}.dec")));
@@ -502,13 +466,6 @@ fn rfc6716_test_vectors() {
502466 "{name}: opus_compare quality {quality:.2} %"
503467 );
504468 }
505- // Non-empty floor: without a vector the loop above runs zero times and the
506- // table prints nothing at all.
507- assert!(
508- ran >= 5,
509- "only {ran} of {} RFC 6716 vectors were exercised, expected at least 5",
510- VECTORS.len()
511- );
512469 for line in table {
513470 println!("{line}");
514471 }
@@ -669,16 +626,16 @@ fn ogg_opus_fixtures_match_ffmpeg() {
669626 // Mapping family 1 puts 5.1 in Vorbis order; ffmpeg hands its own order
670627 // back, so the comparison permutes one into the other.
671628 const VORBIS_TO_FFMPEG_5_1: [usize; 6] = [0, 2, 1, 4, 5, 3];
672- let mut ran = 0usize;
673629 for (name, channels) in [
674630 ("opus-ogg-mono-48000.opus", 1usize),
675631 ("opus-ogg-stereo-48000.opus", 2),
676632 ("opus-ogg-5.1-48000.opus", 6),
677633 ] {
678- let Some(path) = audio_fixture(name) else {
634+ let path = fixture(name);
635+ if !path.exists() {
636+ eprintln!("{name}: missing, skipped (run scripts/gen-fixtures.sh)");
679637 continue;
680- };
681- ran += 1;
638+ }
682639 let Some(reference) = ffmpeg_decode(&path, channels) else {
683640 eprintln!("{name}: ffmpeg unavailable, skipped");
684641 continue;
@@ -705,11 +662,6 @@ fn ogg_opus_fixtures_match_ffmpeg() {
705662 "{name}: worst channel correlation {worst:.5}"
706663 );
707664 }
708- // Non-empty floor: the loop above must have compared something.
709- assert!(
710- ran >= 2,
711- "only {ran} of 3 Ogg-Opus fixtures were compared against ffmpeg, expected at least 2"
712- );
713665 }
714666
715667 #[test]
@@ -721,9 +673,11 @@ fn five_one_channels_land_in_the_right_places() {
721673 // Vorbis-order output is the reference's 5.1-order output permuted.
722674 const VORBIS_TO_FFMPEG_5_1: [usize; 6] = [0, 2, 1, 4, 5, 3];
723675 const TONES: [f64; 6] = [220.0, 440.0, 660.0, 55.0, 880.0, 1320.0];
724- let Some(path) = audio_fixture("opus-ogg-5.1-48000.opus") else {
676+ let path = fixture("opus-ogg-5.1-48000.opus");
677+ if !path.exists() {
678+ eprintln!("5.1 fixture missing, skipped");
725679 return;
726- };
680+ }
727681 let Some(reference) = ffmpeg_decode(&path, 6) else {
728682 eprintln!("ffmpeg unavailable, skipped");
729683 return;
@@ -760,15 +714,14 @@ fn decode_speed() {
760714 eprintln!("decode speed is only meaningful in release; skipped");
761715 return;
762716 }
763- let mut measured = 0usize;
764717 for (name, channels) in [
765718 ("opus-ogg-stereo-48000.opus", 2usize),
766719 ("opus-ogg-5.1-48000.opus", 6),
767720 ] {
768- let Some(path) = audio_fixture(name) else {
721+ let path = fixture(name);
722+ if !path.exists() {
769723 continue;
770- };
771- measured += 1;
724+ }
772725 let data = fs::read(&path).unwrap();
773726 let packets = ogg_packets(&data);
774727 let head = parse_opus_head(&packets[0]);
@@ -801,17 +754,11 @@ fn decode_speed() {
801754 "{name}: {realtime:.0}x realtime is below the {floor}x floor"
802755 );
803756 }
804- // Non-empty floor: with both fixtures absent the loop measured nothing and
805- // every speed floor above went unexercised.
806- assert!(
807- measured >= 1,
808- "no Ogg-Opus fixture was measured, so the decode-speed floor went untested"
809- );
810757
811758 // The fixtures are sine tones, which are cheap; testvector01 is real music
812759 // at a high rate and is the honest stereo number.
813- let stereo_music = vector("testvector01");
814- if let Some(path) = stereo_music {
760+ let path = vectors_dir().join("testvector01.bit");
761+ if path.exists() {
815762 let packets = read_vector(&path);
816763 let mut dec = Decoder::new(48000, 2).unwrap();
817764 let mut out = vec![0.0f32; 5760 * 2];
@@ -1929,7 +1876,8 @@ fn garbage_payloads_never_panic() {
19291876 }
19301877 }
19311878 // Truncations of a real packet, which exercise the mid-frame paths.
1932- if let Some(path) = vector("testvector10") {
1879+ let path = vectors_dir().join("testvector10.bit");
1880+ if path.exists() {
19331881 for p in read_vector(&path).iter().take(200) {
19341882 for cut in 1..p.payload.len().min(64) {
19351883 let _ = dec.decode_float(&p.payload[..cut], &mut out);
@@ -2110,8 +2058,9 @@ fn aligned_corr(reference: &[f32], decoded: &[f32], max_lag: usize) -> (f64, usi
21102058
21112059 #[test]
21122060 fn silk_mono_nb_wb_roundtrip() {
2061+ let wav = fixture("wav16-mono-48000.wav");
21132062 let mut sources = vec![("synthetic", speech_like())];
2114- if let Some(wav) = audio_fixture("wav16-mono-48000.wav") {
2063+ if wav.exists() {
21152064 let w = read_wav_mono(&wav);
21162065 sources.push(("wav16-mono-48000", w[..w.len().min(96000)].to_vec()));
21172066 }
@@ -2483,8 +2432,9 @@ fn oracle_decode(
24832432 }
24842433
24852434 fn silk_sources() -> Vec<(&'static str, Vec<f32>)> {
2435+ let wav = fixture("wav16-mono-48000.wav");
24862436 let mut sources = vec![("synthetic", speech_like())];
2487- if let Some(wav) = audio_fixture("wav16-mono-48000.wav") {
2437+ if wav.exists() {
24882438 let w = read_wav_mono(&wav);
24892439 sources.push(("wav16-mono-48000", w[..w.len().min(96000)].to_vec()));
24902440 }
@@ -3350,14 +3300,12 @@ fn encoder_library_gate_vs_libopus() {
33503300 let mut rows: Vec<String> = Vec::new();
33513301 let mut rate_violations: Vec<String> = Vec::new();
33523302 let mut dropout_violations: Vec<String> = Vec::new();
3353- let mut swept = 0usize;
33543303
33553304 for (tag, src) in &sources {
3356- if !require_host_media(src, tag) {
3305+ if !src.exists() {
33573306 eprintln!("SKIP {tag}: missing {}", src.display());
33583307 continue;
33593308 }
3360- swept += 1;
33613309 let source_pcm = ffmpeg_decode_pcm(src, SECS);
33623310 let source_frames = source_pcm.len() / CHANNELS;
33633311 assert!(source_frames > 48_000, "{tag}: source too short");
@@ -3440,11 +3388,6 @@ fn encoder_library_gate_vs_libopus() {
34403388 ));
34413389 }
34423390 }
3443- // Non-empty floor: no source means the whole gate measured nothing.
3444- assert!(
3445- swept >= 1,
3446- "no library-gate source was present, so the gate measured nothing"
3447- );
34483391 let _ = fs::remove_file(&scratch);
34493392
34503393 let mut table = String::new();
@@ -5003,14 +4946,12 @@ fn spectral_divergence_vs_libopus() {
50034946 let scratch = lanes_dir.join("opus-reell-r1.scratch.ogg");
50044947 let mut frames_all = String::new();
50054948 let mut report = String::new();
5006- let mut swept = 0usize;
50074949
50084950 for (tag, src) in &sources {
5009- if !require_host_media(src, tag) {
4951+ if !src.exists() {
50104952 eprintln!("SKIP {tag}: missing {}", src.display());
50114953 continue;
50124954 }
5013- swept += 1;
50144955 let source_pcm = ffmpeg_decode_pcm(src, SECS);
50154956 let source_frames = source_pcm.len() / CHANNELS;
50164957 let seconds = source_frames as f64 / 48000.0;
@@ -5386,12 +5327,6 @@ fn spectral_divergence_vs_libopus() {
53865327 err_o / err_r
53875328 );
53885329 }
5389- // Non-empty floor: no source means the report below is empty and the whole
5390- // divergence analysis went unexercised.
5391- assert!(
5392- swept >= 1,
5393- "no spectral-divergence source was present, so nothing was measured"
5394- );
53955330 let _ = fs::remove_file(&scratch);
53965331 let header = format!(
53975332 "# spectral divergence vs libopus @ {KBPS}k, {SECS:.0}s cap, sources {}\n",
@@ -5411,7 +5346,8 @@ fn celt_silence_then_attack_decodes_bounded() {
54115346 let fs = 960usize;
54125347 let ch = 2usize;
54135348 let src = shellexpand("~/Music/reell.mp4");
5414- if !require_host_media(&src, "host-media") {
5349+ if !src.exists() {
5350+ eprintln!("SKIP: missing {}", src.display());
54155351 return;
54165352 }
54175353 let pcm = ffmpeg_decode_pcm(&src, 1.0);
@@ -5457,7 +5393,7 @@ fn reell_startup_hop_energies() {
54575393 .and_then(|v| v.parse().ok())
54585394 .unwrap_or(42.5);
54595395 let src = shellexpand(&src_s);
5460- if !require_host_media(&src, "host-media") {
5396+ if !src.exists() {
54615397 return;
54625398 }
54635399 let secs = (centre_ms / 1000.0 + 1.0).max(2.0);
@@ -5601,14 +5537,12 @@ fn short_block_bits_vs_libopus() {
56015537 let scratch = lanes_dir.join("opus-sb-r1.scratch.ogg");
56025538 let nb = ec_opus::celt::NB_BANDS;
56035539 let mut report = String::new();
5604- let mut swept = 0usize;
56055540
56065541 for (tag, src) in &sources {
5607- if !require_host_media(src, tag) {
5542+ if !src.exists() {
56085543 eprintln!("SKIP {tag}: missing {}", src.display());
56095544 continue;
56105545 }
5611- swept += 1;
56125546 let source_pcm = ffmpeg_decode_pcm(src, SECS);
56135547 let seconds = source_pcm.len() as f64 / CHANNELS as f64 / 48000.0;
56145548
@@ -5821,11 +5755,6 @@ fn short_block_bits_vs_libopus() {
58215755 ));
58225756 }
58235757 }
5824- // Non-empty floor: no source means an empty report and no measurement.
5825- assert!(
5826- swept >= 1,
5827- "no short-block-bits source was present, so nothing was measured"
5828- );
58295758
58305759 fs::write(&out_path, &report).unwrap();
58315760 eprintln!("wrote {}", out_path.display());
@@ -5864,7 +5793,8 @@ fn err_map_vs_libopus() {
58645793 let src = shellexpand(
58655794 &std::env::var("EC_ERRMAP_SRC").unwrap_or_else(|_| "~/Music/reeli.mp3".to_string()),
58665795 );
5867- if !require_host_media(&src, "host-media") {
5796+ if !src.exists() {
5797+ eprintln!("SKIP: missing {}", src.display());
58685798 return;
58695799 }
58705800 let lanes_dir = Path::new(env!("CARGO_MANIFEST_DIR")).join("../../lanes");
@@ -6106,7 +6036,8 @@ fn frame_decisions_vs_libopus() {
61066036 let src_s =
61076037 std::env::var("FRAME_SRC").unwrap_or_else(|_| "~/Music/reell.mp4".into());
61086038 let src = shellexpand(&src_s);
6109- if !require_host_media(&src, "host-media") {
6039+ if !src.exists() {
6040+ eprintln!("SKIP: missing {}", src.display());
61106041 return;
61116042 }
61126043 let kbps: u32 = std::env::var("FRAME_KBPS")
@@ -6298,7 +6229,7 @@ fn analysis_music_prob_separates_speech_from_music() {
62986229 let mut means: Vec<(String, bool, f64)> = Vec::new();
62996230 for (tag, path, is_music) in sources {
63006231 let src = shellexpand(path);
6301- if !require_host_media(&src, "host-media") {
6232+ if !src.exists() {
63026233 eprintln!("SKIP {tag}: missing {}", src.display());
63036234 continue;
63046235 }
crates/ec-probe/tests/library.rsmodified+14 -1
@@ -487,7 +487,20 @@ fn a_real_library_sweep() {
487487 taken += 1;
488488 }
489489 }
490- assert!(!chosen.is_empty(), "no readable files in the manifest");
490+ // lane-h264reallib: NOT an `assert!` here. The file's own header, lines
491+ // 5-6, is the spec: "Files that have since moved are skipped and
492+ // reported, never failed -- the manifest is a snapshot of a moving
493+ // library." An empty `chosen` IS the moved-files case, so failing on it
494+ // contradicted the contract this file declares. It was also red on any
495+ // host whose manifest paths no longer resolve, for a reason that had
496+ // nothing to do with the probe. Reported and returned, which is what
497+ // "skipped and reported, never failed" asks for.
498+ if chosen.is_empty() {
499+ eprintln!(
500+ "skipped: no readable file in the manifest (every row has moved or is unreadable)"
501+ );
502+ return;
503+ }
491504
492505 let mut rows = Vec::new();
493506 let mut failures = Vec::new();
lanes/COMMON-20260901.mdmodified+7 -0
@@ -15,6 +15,13 @@ WORKING RULES (binding):
1515 `systemd-run --user --scope -p MemoryMax=8G` and bound ffmpeg with `-t`.
1616 - Test scope: `cargo test -p ec-av1 --lib` only (plus `cargo check -p ec-av1`). Never the
1717 workspace suite. Set `EC_AV1_REQUIRE_AOMENC=1` so an absent oracle FAILS, never SKIPs.
18+- FIRST STEP of every lane, after `git worktree add`: `scripts/link-fixtures.sh`. The root
19+ `fixtures/` directory is gitignored (`.gitignore:2`), so a worktree does NOT get it and
20+ every fixture-backed gate (JVT/FLAC-xiph/RFC-6716 vectors, the ec-av1 pins) skips GREEN
21+ having tested nothing. The script symlinks the primary checkout's `fixtures/` in
22+ (`--check` for a preflight; it refuses loudly if the primary has none). Set
23+ `EC_REQUIRE_FIXTURES=1` in EVERY batch unit (with EC_AV1_REQUIRE_FFMPEG /
24+ EC_AV1_REQUIRE_AOMENC) so an absent fixture FAILS instead of skipping.
1825 - Oracle: `~/.cache/aom-oracle/build/aomenc` and instrumented `aomdec` (scripts/build-aom-oracle.sh,
1926 scripts/instrument-aom-oracle.sh; rungs EC_TRACE=1 / EC_TRACE_COEFF=1 / EC_TRACE_MODE=1 /
2027 EC_AV1_PREFILT_DUMP). Ours: EC_TRACE_COEFF / EC_TRACE_MODE / EC_TRACE_MODE_STEP in decode.rs.
lanes/av1444edge.report.mdadded+608 -0
@@ -0,0 +1,608 @@
1+# lane-av1444edge — the two 4:4:4 cells the chroma-format sweep handed over
2+
3+**Base** `4155c7c7`. **Branch** three commits on top of it, in this order:
4+
5+| commit | what | owner |
6+|---|---|---|
7+| `dc35d607` | the inter-frame pre-filter rung (`EC_AV1_PREFILT_WIDE_DUMP`) did not exist, and its counter restarted — **measurement only, no decode-path edit, merges independently of everything else here** | this lane |
8+| `e10a3b25` | cherry-pick `-x` of `f92776ba`, lane-av1444rect's H1 fix — **not mine**; see §5 | Agent04-2 |
9+| `a9e5034e` | the gate + the two pinned fixtures | this lane |
10+
11+Both cells the sweep handed over are **one class, and the fix already
12+existed on another lane's branch**. The work here is the discriminator
13+run the sweep said it did not have, plus the rung defect that made the
14+discriminator run necessary, plus the matrix correction in §6.
15+
16+---
17+
18+## 1. The two cells, pinned
19+
20+Both are the sweep's own §6.2 recipes, byte-reproduced. The truncated
21+sha256 prefixes the sweep recorded (`c87ac65b…`, `06621606…`) both
22+match, so these are the same bytes it measured.
23+
24+| cell | fixture | bytes | sha256 |
25+|---|---|---|---|
26+| 4:4:4 odd coded dims 130x122 | `fixtures/444_lossy_rect4_odd_130x122.obu` | 8945 | `c87ac65b77579afd2938669b0cbe3ec44c3abf775c0223cacb9d14b8c2eee27c` |
27+| "4:4:4 superres" 256x128 | `fixtures/444_lossy_rect4_wide_256x128.obu` | 15239 | `06621606c11ae805f784a1c9736db6301a925a4fa3154e2fc38db1df7ad9b826` |
28+
29+Recipe (both arms; `W`/`H` = 130/122 and 256/128):
30+
31+```text
32+ffmpeg -f lavfi -i "testsrc2=size=<W>x<H>:rate=25" -frames:v 4 \
33+ -pix_fmt yuv444p -strict -1 -f yuv4mpegpipe - | \
34+aomenc --codec=av1 --passes=1 --end-usage=q --cq-level=20 --cpu-used=2 \
35+ --threads=1 --row-mt=0 --lag-in-frames=0 --kf-max-dist=100 \
36+ --limit=4 --obu -o - -
37+```
38+
39+`rate=25` is load-bearing (`testsrc2`'s pattern is time-parameterised).
40+Both streams: 4 decode-order frames, 0 hidden, single tile, ss (0,0),
41+8-bit, profile 1, `use_superres=false` on all four frames (see §6).
42+
43+Measured against the instrumented aomdec (`EC_AV1_FINAL_DUMP`, decode
44+order), asserting equal frame COUNTS and equal per-frame byte LENGTHS
45+before any sample is read:
46+
47+| | 130x122 | 256x128 |
48+|---|---|---|
49+| base `4155c7c7` | frames 0-2 **EXACT**, frame 3 11521 samples, first (f3, s2208) = **Y(128,16)** ours 134 / oracle 170 | frames 0-1 **EXACT**, frame 2 25296 first **Y(192,0)** ours 92 / oracle 106, frame 3 51108 first Y(0,0) |
50+
51+Both numbers are the sweep's, exactly.
52+
53+---
54+
55+## 2. The class, and how it was separated from the other candidate
56+
57+Two candidate fixes were on the table and the two cells are evidence for
58+exactly one of them.
59+
60+| arm (each `git reset --hard 4155c7c7` + a verified rebuild) | 130x122 | 256x128 |
61+|---|---|---|
62+| base | DIVERGENT f3 11521 | DIVERGENT f2 25296 + f3 51108 |
63+| base + rung + `4e151813` | DIVERGENT f3 11521 — **byte-identical to base** | DIVERGENT f2 25296 + f3 51108 — **byte-identical** |
64+| base + rung + `f92776ba` | **EXACT 4/4** | **EXACT 4/4** |
65+| base + rung + both | EXACT 4/4 | EXACT 4/4 |
66+
67+**The class is H1, `f92776ba` (lane-av1444rect).** `4e151813` is inert
68+here, and the code says why rather than leaving it to the numbers: it
69+patches only the two `tu_reach` call sites in `decode_rect4_16_strip`,
70+and both sit inside that function's `if lossless_pair {` arm. The lossy
71+path is the `} else if skip {` at `decode.rs:17579`. These two cells are
72+4:4:4 **lossy** cq-20, so they are structurally out of its reach.
73+
74+**Class statement.** `decode_inter_block`'s `around_c` gathered a 1:4
75+(HORZ_4 / VERT_4) inter strip's chroma coefficient context at the 4:2:0
76+PAIR extent — `(16, 8)` HORZ / `(8, 16)` VERT — with no `ss` gate. At
77+4:4:4 `is_chroma_reference` (`av1_common_int.h:1454`) reduces both parity
78+clauses to `!subsampling_y` / `!subsampling_x`, so every block is its own
79+chroma reference and no pair exists: the strip codes its own 16x4 chroma
80+over its own context. The gather read one extra luma mi row of LEFT
81+chroma context, the U unit's `get_txb_ctx` saw a neighbour libaom does
82+not have, and the arithmetic coder forked.
83+
84+What the two new geometries add over the existing H1 gate (128x96): a
85+partial-frame right edge (130x122 — neither dimension a multiple of 8,
86+and the sweep's own odd-dimension gate is 4:2:0 only, so the 4:4:4
87+partial-column walk had no exactness evidence anywhere), and 256x128 with
88+CDEF and loop restoration both live on the last two frames. 66x66 is
89+EXACT at the same settings, which is what made the sweep call the
90+partial-frame walk "right at one odd geometry and wrong at another" — it
91+is not the geometry, it is whether the stream codes a 1:4 inter strip.
92+
93+### 2a. A retraction inside this lane
94+
95+An earlier version of the table above said `4e151813` alone was
96+sufficient. **It was not, and the arm never ran.** The tree was reset
97+with `git checkout -- <files>`, which restores from the INDEX — and after
98+`git cherry-pick -n` the index still held the second pick, so the arm
99+re-measured the both-commits tree, and cargo saw byte-identical sources
100+so it did not even relink. The wrong table was sent to two peers, one of
101+whom had already written it into their report; both were told within the
102+hour and the retracted version is recorded in their report as retracted.
103+The table above is the re-run. Kept here because the failure is the
104+lesson: **the dangerous measurement is the one that returns a number.**
105+Two agents hit the same class independently the same session (mine via a
106+stale index, Agent13-2's via a "fix" worktree that was itself a merge of
107+two commits).
108+
109+---
110+
111+## 3. Localizing, because the discriminator is the reusable part
112+
113+**The pre-loop-filter reconstruction already diverges at the identical
114+first sample as the final output**, on both cells (130x122 frame 3 at
115+Y(128,16); 256x128 frame 2 at Y(192,0)). No filter is involved, so the
116+deblock/CDEF/LR ladder is not where this lives — and that verdict was
117+only reachable because of the rung fix in §4. Before it, the nearest
118+usable rungs were unreadable: `EC_AV1_POSTDEBLOCK_DUMP` /
119+`EC_AV1_POSTCDEF_DUMP` came out 61440 B against the oracle's 52224 B
120+(our 160x128 padded surface vs its 136x128 aligned buffer), and the
121+oracle's POSTDEBLOCK wrote 3 files for a 4-frame stream.
122+
123+**Order the wrong superblocks by DECODE order, not raster.** Raster order
124+puts the first wrong sample at Y(192,0) (SBcol3/SBrow0). Decode order
125+puts it in **SBcol2/SBrow0**, first wrong pixel **(128,48) = mi(12,32)**,
126+with **zero** wrong pixels in any superblock decoded before it.
127+
128+**And the block at mi(12,32) has IDENTICAL mode, ref0 and mv0 on both
129+sides.** The `EC_MODE` ladder (compared per decode-order frame, ours
130+split by `EC_PICT`, the oracle's by `aomdec --limit`) agrees through its
131+first 175 entries of frame 2 and then forks on the very next block,
132+mi(13,32):
133+
134+```text
135+AOM mi_row=12 mi_col=32 mode=13 ref0=1 mv0=(-32,0) stack=1
136+OUR mi_row=12 mi_col=32 mode=13 ref0=1 mv0=(-32,0) stack=1 <- same
137+AOM mi_row=13 mi_col=32 mode=13 ref0=1 mv0=(-32,0) stack=2
138+OUR mi_row=13 mi_col=32 mode=13 ref0=4 mv0=(-32,0) stack=2 <- ref0 LAST vs GOLDEN
139+```
140+
141+After the fork the ladder is garbage: 226 entries against the oracle's
142+299 in frame 2, 40 against 361 in frame 3.
143+
144+**A wrong pixel cannot cause a mode fork.** Mode context is built from
145+mode info, not from reconstructed samples. So one bsize/footprint error
146+has to feed both symptoms, and it is upstream of the pixels rather than a
147+consequence of them. That argument is what rules out "the reconstruction
148+diverged, therefore the chroma context followed".
149+
150+**What the ladder could not have told me:** `EC_MODE`'s print carries no
151+`bsize`, so a partition or block-size fork is invisible to it by
152+construction. Nor is its `rng` field a cross-decoder invariant here
153+(libaom's 16-bit `ec.rng` against a 15-bit `log2` range) — only the
154+semantic fields compare. The oracle's `EC_PART` rung prints 4x4 mi while
155+ours prints 16x16-PIXEL units at the sub-node levels, so positions do not
156+compare either; the read-VALUE sequences do, and over the key frames they
157+agree. Our `EC_PART` rung is also key-frame-path only, so it says nothing
158+about these inter frames at all.
159+
160+---
161+
162+## 4. The rung fix (`dc35d607`, measurement only)
163+
164+`EC_AV1_PREFILT_WIDE_DUMP` is the only rung that writes the
165+pre-loop-filter reconstruction cropped to each plane's mi-ALIGNED extent
166+— the shape aomdec's rung 7 writes (`y_width`/`y_height`) — so it is the
167+rung that separates "already wrong in reconstruction" from "introduced by
168+a loop filter". Two defects, both reporting success:
169+
170+1. **It was inlined in the key-frame tile path only.** The inter-frame
171+ path had no wide prefilter dump at all.
172+2. **Its counter was a function-local `static IDX2`.** Rust gives each
173+ monomorphisation its own copy, so the index restarted and every frame
174+ after the first overwrote `.f0` — a per-frame bisection silently
175+ compared the LAST decoded frame and reported it as frame 0. Measured
176+ directly: before the change the rung wrote exactly one file for a
177+ four-frame stream.
178+
179+Now: a shared `dump_prefilter_wide` called from both tile paths, beside
180+each path's existing padded `EC_AV1_PREFILT_DUMP` so the two agree on the
181+point they sample, indexed by the process-global per-var `dump_stage_idx`
182+map. After the change both cells produce 4 files at exactly the oracle's
183+byte count. No decode-path behaviour changes: every write stays inside the
184+existing `if let Ok(path) = crate::envflags::var(...)` arm, which is off
185+unless the env var is set.
186+
187+Agent04-2 has flagged this to Main as standalone and mergeable
188+independently. It should not wait on the rest of this lane.
189+
190+---
191+
192+## 5. Ownership — this is a handback, not a new fix
193+
194+The fix is `f92776ba`, cherry-picked here with `-x` so the merge is
195+idempotent and the branch is green. **Agent04-2 owns it.** What this lane
196+contributes beyond the cherry-pick:
197+
198+- the discriminator run the sweep said it did not have, and the ablation
199+ that separates H1 from the other candidate;
200+- two geometries H1 did not cover, with red-before on both, so the class
201+ is no longer a single-geometry claim;
202+- the rung fix, which is what made the discriminator run possible;
203+- the matrix correction in §6.
204+
205+The fixtures deliberately sit **next to the gate that fixes them**, not
206+next to a gate that does not (Agent13-2's explicit preference, and the
207+right call: they invite exactly the misattribution §2a records).
208+
209+---
210+
211+## 6. Matrix correction: "4:4:4 superres" is not a superres cell
212+
213+**`--superres-mode=1` without `--superres-denominator` scales nothing.**
214+The sweep's recipe omitted the denominator, so it was left to the
215+encoder's energy heuristic — `get_superres_denom_for_qindex`
216+(`av1/encoder/superres_scale.c:143`) returns `SCALE_NUMERATOR` unless
217+the frame is a KF/ARF update and the horizontal-energy test passes, and
218+on a smooth `testsrc2` source it chose 8. Parsed from the stream, all
219+four frame headers of `444_lossy_rect4_wide_256x128.obu` carry:
220+
221+```text
222+FH0 frame=256x128 upscaled=256 use_superres=false denom=8
223+```
224+
225+(through `FH3`). The cell was a plain 4:4:4 lossy cq-20 stream wearing a
226+superres label — the same family as the sweep's own §6.0 trap 2, which
227+caught `--tile-rows=1` being a no-op at 256x128.
228+
229+With an explicit denominator the cell is real and **byte-exact 4/4**:
230+
231+```text
232+ffmpeg -f lavfi -i "testsrc2=size=256x128:rate=25" -frames:v 4 \
233+ -pix_fmt yuv444p -strict -1 -f yuv4mpegpipe - | \
234+aomenc --codec=av1 --passes=1 --end-usage=q --cq-level=20 --cpu-used=2 \
235+ --threads=1 --row-mt=0 --lag-in-frames=0 --kf-max-dist=100 \
236+ --limit=4 --superres-mode=1 --superres-denominator=12 \
237+ --superres-kf-denominator=12 --obu -o - -
238+```
239+
240+14808 B, sha256 `450caa3e31526a8973b9f64d5030a2f11b87bd60fac07aef121cb62af9bf85ff`;
241+all four headers `frame=171x128 upscaled=256 use_superres=true denom=12`;
242+`predict_scaled_hits=2130`, `scaled leaf8=83 sub8=372`, so scaled MC
243+really ran. Verdict: **4/4 decode-order frames byte-exact vs aomdec**,
244+measured on `a9e5034e`'s parent (`dc35d607` + `f92776ba`) with no
245+4:4:4-specific fix involved beyond H1.
246+
247+So the sweep's §1 matrix row `4:4:4 / superres / 8-bit` should read
248+**exact, not D**, and the cell needed a denominator to be a cell at all.
249+A 36-point sweep over {testsrc2, noise, smptebars} x cq {0,10,20,30} x
250+denominator {9,12,16} found a scaled 4:4:4 stream in every combination
251+once the denominator is given.
252+
253+Not gated: the recipe is a hand-quoted flag set with no pinned fixture
254+here, and the eight committed superres gates are 4:2:0. Recorded as the
255+open item rather than closed with a gate I have not mutation-proved.
256+
257+---
258+
259+## 7. Gate and its red-before
260+
261+`a_444_lossy_rect4_strip_stream_decodes_pixel_exact_at_odd_and_wide_geometries`
262+(`crates/ec-av1/src/stream.rs`). Per arm it asserts:
263+
264+- the pinned bytes — length and FNV-1a-64 (my FNV implementation was
265+ validated against the sibling gate's published pair, 6441 B /
266+ `0x4368_8b2d_2e91_72b0`, before being used on new bytes);
267+- a non-zero **DELTA** of 1:4 inter strips. `inter16_rect4_counters()` is
268+ process-wide with no reset, so an absolute count would be a
269+ non-vacuity assertion that passes on residue from another stream in a
270+ full-suite run. Measured deltas: 28 and 76.
271+- `decode::rect4_inter_own_chroma444_hits() > 0` — the corrected route
272+ demonstrably ran. Measured: 12 and 24.
273+- the 4:4:4 full-resolution chroma shape (`f.u.len() == w * h`), so the
274+ compare cannot stand in for the shape claim;
275+- 4 frames, the claimed dimensions, and every decode-order frame
276+ byte-exact through `decode_all_frames_vs_oracle`.
277+
278+**Green** (`--nocapture`, `EC_AV1_REQUIRE_AOMENC=1`, no SKIP line):
279+
280+```text
281+a_444_lossy_rect4_strip_stream_decodes_pixel_exact_at_odd_and_wide_geometries:
282+ fixtures/444_lossy_rect4_odd_130x122.obu 4 decode-order frame(s) (0 hidden)
283+ byte-exact vs aomdec, 12 own-extent 1:4 chroma gather(s), 28 1:4 inter strip(s)
284+ fixtures/444_lossy_rect4_wide_256x128.obu 4 decode-order frame(s) (0 hidden)
285+ byte-exact vs aomdec, 24 own-extent 1:4 chroma gather(s), 76 1:4 inter strip(s)
286+test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 704 filtered out
287+```
288+
289+**Red before, by mutation on this gate's own arms.** The `ss_x == 0`
290+own-extent arm was pointed back at the 4:2:0 `(16, 8)` pair extent, with
291+the counter left firing so the run goes red on the PIXEL compare and not
292+on a "counter is zero" assertion:
293+
294+```text
295+panicked at crates/ec-av1/src/stream.rs:8469:
296+a_444_lossy_rect4_strip_stream_decodes_pixel_exact_at_odd_and_wide_geometries:
297+ decode-order frame 3 of 4 (4 shown, 0 hidden) differs from the oracle at
298+ byte 4260 (ours 0 vs 38), 9203 bytes differ
299+test result: FAILED. 0 passed; 1 failed
300+```
301+
302+The same mutation measured by hand on both arms: 256x128 goes to 76404
303+samples with first wrong Y(192,0) — the sweep's exact number — and
304+130x122 to 9203 with first wrong Y(100,32). Note the mutation changes
305+the first wrong sample on 130x122, so the base defect and the mutated
306+defect are not the same fork; the gate is red either way, which is what a
307+mutation is for.
308+
309+---
310+
311+## 8. Identity
312+
313+All on `a9e5034e`, `--nocapture`, single-threaded.
314+
315+| family | gates that RAN | result |
316+|---|---|---|
317+| `a_444*` (both H1 gates among them) | 4 | ok |
318+| `a_lossless_444*` + `a_real_aomenc_lossless_444*` + screen-key-frame | 5 ran, 1 SKIP | ok |
319+| superres (`a_superres*`, `a_real_aomenc_*superres*`) | 7 | ok |
320+| rect-strip (`a_real_aomenc_*rect_strip*`, intra-rect-strip, skipped-lossless-intrabc) | 5 | ok |
321+| the sweep's three chroma-format gates (cherry-picked `aeb696da` into a throwaway worktree at `a9e5034e`) | 3 | ok |
322+
323+25 gates ran, 1 skipped. The SKIP is why the counts are split by family
324+instead of folded into one total: for the lossless+superres filter cargo
325+reported `13 passed; 0 failed` while one of the thirteen printed its SKIP
326+line, so that run line on its own reads as thirteen real gates. The 13
327+is 12 real + 1 skip, split above as 5 + 1 and 7.
328+
329+The three sweep gates, quoted:
330+
331+```text
332+a_real_aomenc_odd_coded_dimension_streams_decode_pixel_exact: 6 arms, 4 frames
333+ byte-exact each, frame-edge walks [0,6,0,4,48,12] [0,0,0,4,0,6] [0,4,0,10,0,10]
334+ [0,4,0,8,0,12] [0,4,0,8,0,8] [0,0,0,12,0,14]
335+a_lossless_444_10bit_inter_stream_decodes_pixel_exact: 6 frames byte-exact vs aomdec at 10-bit 4:4:4
336+a_444_12bit_inter_sequence_decodes_pixel_exact: 6 frames byte-exact vs aomdec at 12-bit 4:4:4
337+test result: ok. 3 passed; 0 failed; 0 ignored; 0 measured; 705 filtered out
338+```
339+
340+**One SKIP, pre-existing and not mine:**
341+`a_real_aomenc_lossless_444_key_frame_decodes_sample_exact` prints "no
342+pinned bytes at `fixtures/ll444-lossless-key.obu`". That file has no
343+entry in `git log` for the path — it was never committed, so the gate has
344+always skipped on this base.
345+
346+No suite run beyond the named gates: full validation is Main's, once
347+after all subagents land.
348+
349+---
350+
351+## 9. Handed on
352+
353+- **Agent04-2** — `f92776ba` is the fix, cherry-picked here with `-x`;
354+ it now has two more geometries and a red-before on each. The
355+ retraction in §2a is recorded in their report.
356+- **Agent13-2** — `4e151813` is confirmed lossless-only by a structural
357+ argument (`lossless_pair` arm) and by byte-identical divergence counts.
358+ Independently reached the same conclusion, by a different contaminated
359+ A/B.
360+- **Main** — `dc35d607` is standalone, measurement-only, and mergeable
361+ now. The matrix row `4:4:4 / superres / 8-bit` should read exact (§6).
362+ Open item: the real 4:4:4 superres cell is exact but ungated.
363+
364+---
365+
366+## 10. Appendix — the mode fork re-verified, and the per-arm commands
367+
368+### 10a. The `mi(13,32)` ref0 fork does NOT survive the H1 fix
369+
370+§3 reported a mode fork at `mi(13,32)` — the oracle reads
371+`ref0 = LAST (1)`, we read `GOLDEN (4)` — landing on the block right
372+after the first wrong pixel, and flagged it as residue worth a lane of
373+its own if it survived. Re-measured on a clean two-arm pair, one commit
374+apart, with `4e151813` provably absent from both:
375+
376+| decode-order frame | oracle entries | arm A (base + rung) | arm B (base + rung + `f92776ba`) |
377+|---|---|---|---|
378+| 1 | 279 | 279 | 279 |
379+| 2 | 299 | **226** | **299** |
380+| 3 | 361 | **40** | **361** |
381+
382+| arm | semantic ladder diffs (mi, ref0, ref1, mv0), frames 1 / 2 / 3 | `mi(13,32)` idx175 |
383+|---|---|---|
384+| A — base + rung | 0 / **51** / **40** | AOM `ref0=1 mv0=(-32,0)` vs OUR `ref0=4 mv0=(-32,0)` — DIFF |
385+| B — base + rung + `f92776ba` | 0 / **0** / **0** | AOM `ref0=1 mv0=(-32,0)` vs OUR `ref0=1 mv0=(-32,0)` — **SAME** |
386+
387+**The fork is gone, and it is the same defect.** Zero semantic ladder
388+diffs in all three frames, and the entry counts now equal the oracle's
389+exactly (arm A lost 73 entries in frame 2 and 321 in frame 3; arm B
390+loses none). This is §3's causality argument confirmed rather than
391+asserted: a wrong pixel cannot cause a mode fork, so one bsize/footprint
392+error had to feed both symptoms — and if that is right, one fix must
393+remove both. It does. A residual fork here would have refuted the
394+argument and pointed at a second defect; there is none. **Dropped, no
395+separate lane.**
396+
397+**The one residual ladder difference is a print asymmetry, not a fork.**
398+Arm B still shows 2 (frame 2) and 12 (frame 3) entries where the
399+`stack` field differs. Every one is a compound block (`ref1` set, e.g.
400+`ref0=1 ref1=4`, `ref0=4 ref1=7`) whose OUR line prints no `stack=`
401+field at all — the compound arm's `EC_MODE_VAL` format omits it. All
402+semantic fields, and on most entries `rng`, match. Same family as
403+`compare-range-not-tell`: a field that is not a cross-decoder invariant
404+must not be compared as one.
405+
406+### 10b. The ancestry guard is wrong for a cherry-picked commit
407+
408+The guard I ran in 10a, `git merge-base --is-ancestor f92776ba HEAD`,
409+returns **False on an arm that has the fix**, because a cherry-pick
410+mints a new sha. Had I trusted it as a presence check it would have
411+reported arm B as "fix absent" — a third check in this session that
412+returns a plausible number instead of the fact, and the second inside
413+this lane alone. The correct guard over cherry-picks is **patch-id
414+equivalence**:
415+
416+```text
417+f92776ba: is-ancestor=False patch-id=bcead47eb734ca4f local equivalent: 38b34494 PRESENT
418+4e151813: is-ancestor=False patch-id=5c19bac8add27bbb local equivalent: None absent
419+dc35d607: is-ancestor=False patch-id=285286bb3506199b local equivalent: e362bfda PRESENT
420+```
421+
422+`is-ancestor` remains a valid EXCLUDE check for a commit that is a true
423+ancestor; it is not a valid INCLUDE check after a cherry-pick. The
424+`rust-oracle-gate-verification` entry was corrected.
425+
426+### 10c. The per-arm commands, verbatim
427+
428+Throw-away worktree, one `CARGO_TARGET_DIR` per arm, arms exactly one
429+commit apart. A reviewer can paste this and get the same numbers.
430+
431+```bash
432+WT=~/.cache/wt/av1444fork
433+cd /home/user/Documents/Code/Rust/edith_codecs
434+git worktree add -f --detach "$WT" 4155c7c7
435+
436+arm () { # arm <label> <tag> <commit>...
437+ tag=$1; shift
438+ git -C "$WT" reset --hard 4155c7c7 # per-arm reset, never `checkout --`
439+ git -C "$WT" clean -fdq
440+ for c in "$@"; do git -C "$WT" cherry-pick -x "$c"; done
441+ git -C "$WT" log --oneline -1
442+ for c in f92776ba 4e151813; do # presence/absence by PATCH-ID
443+ p=$(git -C "$WT" show "$c" | git patch-id --stable | cut -d' ' -f1)
444+ hit=$(git -C "$WT" log --format=%H | while read -r h; do
445+ q=$(git -C "$WT" show "$h" | git patch-id --stable | cut -d' ' -f1)
446+ [ "$q" = "$p" ] && { echo "$h"; break; }; done)
447+ echo "$c present=${hit:-no}"
448+ done
449+ td=~/.cache/cargo-target-$tag
450+ ( cd "$WT" && CARGO_TARGET_DIR="$td" \
451+ cargo build -p ec-av1 --example decode_probe --features gate-counters )
452+ stat -c '%y' "$td/debug/examples/decode_probe" # the 0.0s-build tell
453+ ( cd "$WT" && EC_TRACE_MODE=1 EC_AV1_FINAL_DUMP=/tmp/$tag \
454+ "$td/debug/examples/decode_probe" ~/.cache/av1444edge/sr444.obu 2>/tmp/$tag.our )
455+ for k in 1 2 3 4; do # oracle, per frame
456+ EC_TRACE_MODE=1 ~/.cache/aom-oracle/build/aomdec --codec=av1 --limit=$k -o /dev/null ~/.cache/av1444edge/sr444.obu 2>/tmp/$tag.aom$k
457+ done
458+}
459+
460+arm A_base_plus_rung A dc35d607
461+arm B_base_plus_rung_plus_f92776ba B dc35d607 f92776ba
462+```
463+
464+Compare by splitting OUR's `EC_MODE_VAL` lines on the `EC_PICT idx=`
465+markers (one per decode-order frame, printed before that frame's dump),
466+the ORACLE's on cumulative `aomdec --limit=k` counts, then field by
467+field per entry. Observed:
468+
469+```text
470+arm A entries oracle/ours 1,2,3: 279/279 299/226 361/40
471+arm A SEMANTIC diffs (mi/ref0/ref1/mv0) frame 2 = 51, frame 3 = 40
472+arm B entries oracle/ours 1,2,3: 279/279 299/299 361/361
473+arm B SEMANTIC diffs frame 2 = 0, frame 3 = 0
474+arm B residual stack-field diffs: frame 2 = 2, frame 3 = 12; every one a
475+ compound block whose OUR line omits the field
476+```
477+
478+Pixel cross-check on the same two arms, so the ladder verdict is not
479+taken on trust: arm B is 4/4 decode-order frames byte-exact vs aomdec on
480+both fixtures (§7); arm A is 11521 and 76404 samples off (§1).
481+
482+Cleanup: `git worktree remove --force ~/.cache/wt/av1444fork` and
483+`rm -rf ~/.cache/cargo-target-forkA ~/.cache/cargo-target-forkB`.
484+
485+---
486+
487+## 11. Appendix r3 — the 4:4:4 superres cell is REAL, and how to tell
488+
489+Main relayed a measurement from lane-av1gates444 that 256x128 is
490+byte-identical with and without `--superres-mode=1`, and asked whether ANY
491+aomenc recipe on this build can produce a stream whose PARSED header
492+carries superres. Both are right, about different recipes, and the
493+distinction is the deliverable.
494+
495+### 11a. The flag sweep: attempted flags -> PARSED denom
496+
497+Build: `~/.cache/aom-oracle/build/aomenc`, libaom `v3.13.3-7-g9bb526a`
498+(oracle snapshot; `--version` is not an accepted flag on this build, so the
499+version comes from the source tree the binary is built from). Common
500+recipe, 256x128 yuv444p `testsrc2=size=256x128:rate=25 -frames:v 4`, with
501+`--profile=1 --passes=1 --end-usage=q --cq-level=20 --cpu-used=2
502+--threads=1 --row-mt=0 --lag-in-frames=0 --kf-max-dist=100 --limit=4`.
503+Every row's verdict is read from the stream's OWN parsed frame header, not
504+from the flag.
505+
506+```text
507+verdict | flags | parsed FH0 | sha256
508+no-op | (none, control) | frame=256x128 upscaled=256 use_superres=false denom=8 | 06621606
509+no-op | superres-mode=1 (no denom) | frame=256x128 upscaled=256 use_superres=false denom=8 | 06621606
510+SCALED | superres-mode=1 den=9 | frame=228x128 upscaled=256 use_superres=true denom=9 | 3d619ee0
511+SCALED | superres-mode=1 den=12 | frame=171x128 upscaled=256 use_superres=true denom=12 | 450caa3e
512+SCALED | superres-mode=1 den=16 | frame=128x128 upscaled=256 use_superres=true denom=16 | 194450c4
513+SCALED | superres-mode=2 (no denom) | frame=186x128 upscaled=256 use_superres=true denom=11 | c18496cf
514+SCALED | superres-mode=2 den=9/12/16 | frame=186x128 upscaled=256 use_superres=true denom=11 | c18496cf
515+no-op | superres-mode=3, all den | frame=256x128 upscaled=256 use_superres=false denom=8 | 8dafaf38
516+no-op | superres-mode=4, all den | frame=256x128 upscaled=256 use_superres=false denom=8 | 8dafaf38
517+no-op | resize-mode=1,2,3 any den | frame=256x128 upscaled=256 use_superres=false denom=8 | 06621606
518+```
519+
520+**7 of 29 combinations produce a real scaled stream.** Three findings
521+behind that:
522+
523+1. **The reported no-op is real and is exactly the sweep's recipe.**
524+ `--superres-mode=1` with NO denominator gives sha256 `06621606…`, which
525+ is byte-identical to the no-flag control — so lane-av1gates444's
526+ measurement is correct, and the sweep's `sr444` bytes are that
527+ no-op stream. libaom picks the denominator itself
528+ (`get_superres_denom_for_qindex`, `av1/encoder/superres_scale.c:143`):
529+ it returns `SCALE_NUMERATOR` unless the frame is a KF/ARF update AND the
530+ horizontal-energy test passes, and on a smooth `testsrc2` source it
531+ returns 8.
532+2. **Adding `--superres-denominator` is what makes the cell exist.** Mode 1
533+ with an explicit denominator is scaled on every frame, and the parsed
534+ `denom` equals the flag. This is the route the r3 gate pins.
535+3. **Mode 2 (random) scales with no denominator at all** — and IGNORES
536+ `--superres-denominator`: all four denominator values produce the same
537+ stream (`186x128 denom=11`, sha `c18496cf…`). So "set the denominator"
538+ is not the only working route, and a gate that asserted the flag value
539+ rather than the parsed value would pass on mode 2 while the numbers it
540+ printed were fiction.
541+
542+`--resize-mode` is a different feature and is never a superres witness: it
543+downsizes the FRAME (`frame=171x85 upscaled=171`), whereas superres keeps
544+`frame_width < upscaled_width`. Worth separating explicitly, because
545+"denominator" appears in both flag families.
546+
547+Modes 3 (qthresh) and 4 (auto) are no-ops at every denominator tried,
548+which is consistent with the committed census gate's own recorded finding
549+that auto "picked denominator 8, so those two arms carry no scaling at
550+all and prove nothing".
551+
552+### 11b. Our decoder on all four real scaled streams
553+
554+Every SCALED row above, compared against the instrumented aomdec in decode
555+order with equal frame counts and equal per-frame byte lengths asserted
556+first:
557+
558+```text
559+mode=1 den=9 3d619ee0fda3 upscaled 228x128 f0 EXACT f1 EXACT f2 EXACT f3 EXACT
560+mode=1 den=12 450caa3e3152 upscaled 171x128 f0 EXACT f1 EXACT f2 EXACT f3 EXACT
561+mode=1 den=16 194450c4bf19 upscaled 128x128 f0 EXACT f1 EXACT f2 EXACT f3 EXACT
562+mode=2 c18496cf3b7d upscaled 186x128 f0 EXACT f1 EXACT f2 EXACT f3 EXACT
563+```
564+
565+So the 4:4:4 superres class is byte-exact across denominators 9, 11, 12
566+and 16 and coded widths 128, 171, 186 and 228 at 256x128 — not one
567+geometry. The gate pins the den=12 member and asserts its PARSED
568+`use_superres` / `denom` / coded size, so a stream that stops being scaled
569+goes red on a header assertion rather than becoming a differently-shaped
570+exactness claim. `denom=9` (coded 228, the widest margin the frame
571+allows) and `mode=2`'s `denom=11` are the obvious next pins and are not
572+gated; recorded rather than quietly dropped.
573+
574+### 11c. The sweep claims that need correcting (NOT edited here)
575+
576+`lanes/av1formatsweep.report.md` is the sweep lane's file; these are the
577+lines to fix, named rather than touched:
578+
579+- **line 438** — the `sr444` row: "4:4:4 **superres** 256x128
580+ (`--superres-mode=1`) … **DIVERGENT** from f2, 76404 samples". Two
581+ errors: the stream carries `use_superres=false denom=8` (§11a), and its
582+ divergence is the H1 rect4-strip class, already localised and gated in
583+ `a_444_lossy_rect4_strip_stream_decodes_pixel_exact_at_odd_and_wide_geometries`
584+ (whose second arm is these exact 15239 bytes). The row should say the
585+ recipe was a no-op and name the class.
586+- **line 83** — the §1 matrix row `| superres | – | – | – |` for 4:4:4.
587+ Should become `Y` at 8-bit: gated by
588+ `a_444_lossy_superres_stream_decodes_pixel_exact`.
589+- **line 485** — "Matrix changes (§1): 4:4:4 row gains … `superres → D`".
590+ Should be `superres → Y` at 8-bit.
591+- **line 442** — "Note the aomenc flag is `--superres-mode=1`; there is no
592+ `--enable-superres` in this build". True but incomplete, and it is the
593+ note that let the no-op recipe stand as a cell: the flag needs
594+ `--superres-denominator` (or mode 2) to do anything, and the verdict
595+ must come from the parsed header.
596+- **line 492** — "Still not measured … 4:4:4 superres at 10/12 bits" is
597+ still true and still open; only the 8-bit cell is closed here.
598+
599+### 11d. Overlap to be aware of when merging
600+
601+lane-av1gates444's `a_444_lossy_256x128_stream_decodes_pixel_exact` already
602+pins the plain 256x128 lossy geometry. My r1 gate's second arm uses the
603+same 15239 bytes but claims something different — that the 4:4:4 1:4
604+inter-strip route fired (76 strips, 24 own-extent chroma gathers) and that
605+the H1 fork is gone there — so it is not redundant with a geometry gate.
606+The two fixtures are the same bytes, so whichever lands second should reuse
607+the pin rather than add a second copy. Flagging it rather than resolving
608+it: both claims are load-bearing and the merge order is Main's call.
lanes/av1chrtx.report.mdadded+187 -0
@@ -0,0 +1,187 @@
1+# lane-av1chrtx — rect inter chroma per-unit tx_type (H1) + rect coeff-trace plane tag (H2)
2+
3+Branch `lane-av1chrtx` (worktree `~/.cache/wt/av1chrtx`), base `a21f3680`.
4+Oracle `~/.cache/aom-oracle/build/{aomdec,aomenc}` (instrumented).
5+`CARGO_TARGET_DIR=$HOME/.cache/cargo-target-av1chrtx`.
6+
7+Commits: `d791c464` (H2), `2142d2cf` (H1) — one per defect, as chartered.
8+
9+---
10+
11+## H1 — FIXED. `read_inter_rect_chroma` handed every chroma unit the BLOCK-level `tx_type`
12+
13+### The defect
14+
15+`read_inter_rect_chroma` is the sibling of the two 4:4:4 four-unit arms.
16+lane-av1444chr extracted `covering_leaf_tx_type` and re-pointed both
17+four-unit arms at it, but left this sibling passing the block-level
18+`luma_tx_type` (the top-left leaf's type) to **every** unit of the plane:
19+
20+```rust
21+let inherit_tx_type = Some(luma_tx_type); // before
22+```
23+
24+`av1_get_tx_type` (`blockd.h:1287-1297`) reads `xd->tx_type_map` at the
25+chroma unit's own position scaled back to luma, and `read_coeffs`'s
26+`all_zero` arm stamps `DCT_DCT` into that leaf's map cell
27+(`decodetxb.c:199-203`) — so a unit sitting over a luma leaf that coded
28+**nothing** inherits `DctDct`, not the block-level type. With
29+`nx*ny > 1` over mixed var-tx leaves that is a per-unit wrong answer.
30+
31+### The witness hunt (bounded, then found)
32+
33+lane-av1444chr's report recorded the route as unreachable on five
34+4:4:4 rect recipes (`multi` = 0 on every one). Two facts explain why,
35+and they shape the hunt:
36+
37+1. **`multi` is false by construction at 4:2:0.** The arm is only reached
38+ for `side <= 64` blocks (the `side > 64` mu-chunk path runs first), and
39+ a `side <= 64` block's 4:2:0 chroma plane is at most 32x32 — exactly
40+ one `uw x uh` unit, so `nx*ny == 1` always. The earlier hunt's
41+ recipes were 4:4:4 but used partition settings that never produced a
42+ block keeping a 64-px axis.
43+2. So the arm needs **4:4:4 AND a rect block with a 64-px luma axis**
44+ (32x64 / 64x32 / 64x16 / 16x64) — a 4:4:4 chroma plane then exceeds
45+ the 32 cap on one axis and splits.
46+
47+Hunt: 200+ encodes, three 4:4:4 sources (testsrc2 128/192/256, mandelbrot
48+128/256, testsrc2 192x256), swept over `--min-partition-size` 8/16/32,
49+`--max-partition-size` 32/64/128, `--enable-tx-size-search` 0/1,
50+`--enable-rect-partitions`, `cq-level` 18-44, `--cpu-used` 0/2/3/5/7,
51+sizes 128x128 through 256x256. Instrumented with a temporary
52+`EC_AV1_CHRTX_PROBE` eprintln in the arm printing `(nx, ny, multi, leaves)`
53+(removed before the commit).
54+
55+Result: the arm's `multi` is 0 on every 4:2:0 recipe and on every 4:4:4
56+recipe whose rect strips keep a 32-px axis. It first fires with
57+**`--cpu-used=0 --min-partition-size=32 --max-partition-size=64` on a
58+256x256 source** — the slow encoder is what actually picks a 32x64 strip
59+over two 32x32 blocks.
60+
61+### The witness (pinned)
62+
63+`crates/ec-av1/fixtures/444_rect_strip_leaf_tx_type.obu`, 26839 bytes,
64+sha256 `06174a66e92aaeb751a8e86db59711fcb1f18d74bde2d77e1ef1be7983eb7c80`,
65+fnv1a64 `0xc77f310c036dff73`.
66+
67+```
68+ffmpeg -f lavfi -i "testsrc2=size=256x256:rate=25" -frames:v 3 -pix_fmt yuv444p \
69+ -f yuv4mpegpipe ts256.y4m
70+aomenc --codec=av1 --profile=1 --cq-level=30 --cpu-used=0 --sb-size=64 \
71+ --min-partition-size=32 --max-partition-size=64 --enable-tx-size-search=1 \
72+ --passes=1 --end-usage=q --threads=1 --row-mt=0 --lag-in-frames=0 \
73+ --kf-max-dist=100 --limit=3 --obu -o w.obu ts256.y4m
74+```
75+
76+The qualifying block is the **32x64 inter strip at mi(32,48)**:
77+a 4:4:4 chroma plane of `(32, 64)` = **two** TX_32X32 units, over a
78+five-leaf luma tree
79+
80+| leaf (row, col, tw, th, tx_type) | covering mi rows |
81+|---|---|
82+| `(0, 0, 32, 32, Idtx)` | 0..8 |
83+| `(8, 0, 16, 16, VDct)` | 8..12 |
84+| `(8, 4, 16, 16, DctDct)` | 8..12 |
85+| `(12, 0, 16, 16, HDct)` | 12..16 |
86+| `(12, 4, 16, 16, VDct)` | 12..16 |
87+
88+The **lower** chroma unit (its own mi cell `(8, 0)`) therefore resolves
89+`VDct` where the block-level value is `Idtx` — once per chroma plane, so
90+`diff = 2`. The upper unit resolves `Idtx`, i.e. the same as the
91+block-level value: the defect is strictly per-unit.
92+
93+### The fix
94+
95+- `read_inter_rect_chroma` takes the block's `leaf_tx_types` and resolves
96+ `inherit_tx_type` **per unit** through the shared
97+ `covering_leaf_tx_type(leaf_tx_types, unit_rel_mi)`, with
98+ `.unwrap_or(luma_tx_type)` as the fallback for a block that coded a
99+ single luma unit (no vartx tree, so `leaves` is empty). Both call sites
100+ (the compound and single-reference copies of `decode_inter_block`)
101+ pass their `&leaf_tx_types` — the same list the four-unit arms read.
102+- Two new gate counters, `CHROMA_RECT_LEAF_TX_HITS` /
103+ `CHROMA_RECT_LEAF_TX_DIFF_HITS`, deliberately **separate** from
104+ `CHROMA_QUAD_LEAF_TX_HITS` / `_DIFF_HITS`: the latter pair gates a
105+ 4:2:0 control asserting exactly `(0, 0)`, and this route **is**
106+ reachable at 4:2:0, so sharing the counter would destroy that
107+ control's meaning.
108+
109+### Bar
110+
111+- **Red-before by mutation** (revert only the resolve to the block-level
112+ type; everything else intact):
113+ `decode-order frame 1 of 3 (3 shown, 0 hidden) differs from the oracle
114+ at byte 105949 (ours 166 vs 167), 1998 bytes differ`.
115+ Restored: green. (A first mutation attempt used `.or(None::<TxType>)`,
116+ which is the identity on `Option` and therefore did **not** bite — the
117+ red run above uses `.and(None::<TxType>)`, the real removal.)
118+- **New gate** `stream::tests::a_pinned_444_rect_inter_stream_resolves_each_chroma_unit_from_its_own_luma_leaf`:
119+ fixture length + fnv pinned, `decode_all_frames_vs_oracle` (length-
120+ asserting, byte-exact, 3 frames, 0 hidden), asserts `hits >= 2*diff &&
121+ hits > 0` and **`diff >= 2`**.
122+ Measured: `rect chroma units resolved from their own leaf 4, of which 2 differed`.
123+- **In-gate control**: the committed
124+ `fixtures/444_sb128rect_lr_witness.obu` fires the same route (2 units
125+ resolved) with **0** differing types — the exact shape a no-op fix
126+ looks green on, which is why the DIFF counter and not the route counter
127+ is the non-vacuity bar.
128+- **Resolver unit test** `decode::tests::covering_leaf_tx_type_picks_the_leaf_under_the_unit_or_reports_none`:
129+ mixed-leaf lookup on the witness's own five-leaf tree, interior cells
130+ (containment, not raster position), the mi cell just past the block's
131+ extent → `None`, and the empty leaf list → `None`.
132+ Mutation-proven red: turning the containment `<` into `<=` →
133+ `panicked at crates/ec-av1/src/decode.rs:52883, left: Some(Idtx), right: Some(VDct)`.
134+ Restored: green.
135+- **Identity green** (13 tests, one binary, `--test-threads=4`, no SKIP
136+ lines): the new gate, the resolver unit test, the av1444chr gate
137+ (`quad-resolved chroma units 96, of which 8 differed` — unchanged), plus
138+ `a_444_lossy_rect4_inter_stream_decodes_pixel_exact`,
139+ `a_444_sb128_root_rect_stream_with_restoration_decodes_pixel_exact`,
140+ `a_lossless_444_defaultp_inter_strip_stream_decodes_byte_exact`,
141+ `a_lossless_444_min_partition64_inter_stream_decodes_pixel_exact`,
142+ `a_lossless_444_min_partition8_inter_stream_decodes_sample_exact`,
143+ `a_real_aomenc_rect_inter_block_predicts_chroma_with_the_narrow_kernel_pixel_exact`,
144+ `a_real_aomenc_rect_strip_palette_decodes_pixel_exact`,
145+ `a_real_aomenc_inter_sequence_with_a_16_level_rect_leaf_decodes_pixel_exact`,
146+ `a_444_intrabc_rect4_reads_its_own_chroma_plane_block`,
147+ `a_lossless_444_rect16x4_chroma_reach_is_ss_aware` — **13 passed, 0 failed**.
148+
149+---
150+
151+## H2 — FIXED. `read_coeffs_rect`'s `EC_COEFF_STEP` traces hardcoded `plane=0`
152+
153+`read_coeffs_rect` printed `plane=0` on both tagged lines
154+(`tag=all_zero`, `tag=tx_type`), so every **chroma** rect coefficient
155+read was logged as a luma one. Two independent lane reports mis-read a
156+chroma unit's `txb_skip` / `tx_type` symbol on those lines and followed
157+the luma arm — the log could not tell them apart.
158+
159+Fix: a `plane: usize` parameter on `read_coeffs_rect`, with each of the
160+twenty call sites passing its own plane (`0` for the luma readers,
161+`plane_idx` / `plane` where the enclosing reader already has one).
162+`read_chroma_coeffs_rect` takes the same parameter and passes it
163+through, so the U and V call sites in `decode_block_rect`,
164+`decode_leaf_rect`, `decode_block_rect4`, `decode_rect4_16_strip` and
165+`decode_block_rect64` stop collapsing into one tag.
166+
167+**Measurement** (`EC_TRACE_COEFF=1` on
168+`a_444_lossy_rect4_inter_stream_decodes_pixel_exact`):
169+
170+| line | before | after |
171+|---|---|---|
172+| `tag=all_zero` | 932 lines, all `plane=0` | 312 `plane=0` / 310 `plane=1` / 310 `plane=2` |
173+| `tag=tx_type` | 110 lines, all `plane=0` | 110 `plane=0` (this set's units are luma-only on this fixture) |
174+
175+No trace output changes in a default build: both lines are behind
176+`coeff_trace_on()`, i.e. the env-gated `EC_TRACE_COEFF`. No gate output
177+changes — the counter and assert set is untouched by this commit.
178+
179+---
180+
181+## Not run here (Main's validation)
182+
183+Full crate suite, the multi-encode sweeps
184+(`a_real_aomenc_inter_sequence_with_a_16_level_rect_leaf_decodes_pixel_exact`
185+was run as a single named test only), the 4:2:0/10-bit/12-bit sweep
186+families, and the server stages. Local runs were single named tests / one
187+named-test batch, per the lane's local-scope rule.
lanes/av1distwtd.report.mdadded+229 -0
@@ -0,0 +1,229 @@
1+# lane-av1distwtd
2+
3+Two rounds on one branch (`lane-av1distwtd`, base `a21f3680`).
4+
5+- **r1** — close the `enable-dist-wtd-comp` coverage hole.
6+- **r2** — audit every CLAIM in `gate_coverage.rs` against the code and correct
7+ the false ones (appended below).
8+
9+---
10+
11+## r1: `enable-dist-wtd-comp`
12+
13+`PRODUCIBLE`. The census entry's stated reason — "distance-weighted compound is
14+unimplemented" — was **false**: `compound::dist_wtd_comp_weight_assign`
15+(lane-av1comp) and `mc::combine_compound`'s weighted path have implemented it for
16+a long time. What was missing was a stream *carrying* the tool, so no gate ever
17+proved it fired.
18+
19+Closed with a witness gate `a_distance_weighted_compound_stream_decodes_pixel_exact`
20+(25 oracle frames, 21 distance-weighted blocks, pixel-exact) plus the
21+`gate_coverage.rs` entry deletion, commit `9cca1096`. See that commit message for
22+the full red-before evidence.
23+
24+**12-bit / single-ref:** unaffected. 12-bit reaches the same arm independently
25+(15 blocks measured); single-ref never reads `compound_idx` at all.
26+
27+---
28+
29+# r2 appendix: gate_coverage.rs claim audit
30+
31+Every claim checked against the code, not against prose. Method per claim:
32+find the deciding symbol and follow the call path from the feature-flag parse to
33+the reconstruction site; for encoder claims, read `~/.cache/aom-oracle/src`
34+(aom 3.13.3, `CONFIG_REALTIME_ONLY 0`) rather than `--help`; where a stream was
35+needed, encode one and read the **parsed** header, never the flag.
36+
37+## Evidence table
38+
39+| # | entry / claim (file:line) | stated reason | verdict | deciding code | what it should say |
40+|---|---|---|---|---|---|
41+| 1 | `enable-dist-wtd-comp` 8-bit (retired r1, commit `9cca1096`) | "unimplemented" | **FALSE** (r1) | `compound.rs:36 dist_wtd_comp_weight_assign`; `mc.rs:2075 combine_compound` | retired; combine long implemented, witness gate added |
42+| 2 | `enable-dist-wtd-comp` encoder default (`:5`) | "off in 11 gates" implies encoder default off | **FALSE** | `av1_cx_iface.c` `default_extra_cfg` = 1; `bitstream.c:2681` writes it | default is ON; the 11 gates pinned it `=0` themselves |
43+| 3 | `enable-dual-filter` 8-bit (`:270`) | "never spelled by any gate … no stream proven to carry per-direction interp filters" | **FALSE** | gate `a_real_aomenc_dual_filter_obmc_8x8_inter_sequence_decodes_pixel_exact` spells `=1` and asserts `dual_filter_diff_hits()` (`decode.rs:35135`); default parses `dual_filter=true` | EXERCISED; census can't see it (helper-delegation filter) |
44+| 4 | `enable-dual-filter` 10-bit (`:374`) | "hole at both depths" | **FALSE** | same gate as #3 | same as #3, both depths |
45+| 5 | `enable-flip-idtx` 8-bit (`:291`) | "never spelled" | **FALSE** | gate `a_real_aomenc_stream_with_a_1d_tx_class_on_a_rect_transform_decodes_pixel_exact` spells `=1`, asserts `tx_class1_hits` | EXERCISED at 8 bits (6 of 12 measured decodes are 8-bit) |
46+| 6 | `enable-flip-idtx` 10-bit numbers (`:366`) | "six 10-bit decodes", "10 rect TUs 1D" | **TRUE** (re-measured) | ran the gate: 12 decodes, 6 ten-bit, 219 rect TUs, 10 of them 1D | keep (now backed by an arrival assert) |
47+| 7 | `enable-rect-tx` 8-bit (`:320`) | "never spelled; reached only via partition shape" | **TRUE** | 0 gates spell it; aom has no header bit — `av1_cx_iface.c:2125/1483` is search-only, read only in `tx_search.c`; decoder gate is `is_rect_tx_allowed` | keep; now proven, not asserted |
48+| 8 | `enable-rect-tx` 10-bit (`:395`) | "hole at both depths" | **TRUE** | same | keep |
49+| 9 | `enable-cfl-intra` 8-bit comment (`:190`) | "gate passes `=1` at 8 AND 10 bits, pixel-compares both arms" | **TRUE** | gate `a_real_aomenc_sb128_stream_whose_skipped_cfl_and_1to4_chroma_pairs_...` loops `for depth in [8usize, 10]`, spells `=1`, asserts `dir_pairs > 0` | keep |
50+| 10 | same gate, name says "skipped_cfl" | — | **NOTE** | that gate asserts directional 1:4 pairs, **not** skipped-CfL; skipped-CfL evidence is a *different* gate (`a_real_film_key_frame_with_a_skipped_cfl_block_...`) | name overstates; comment doesn't repeat the error |
51+| 11 | `enable-intrabc` 10-bit comment (`:~336`) | "hard-asserts a decoded intrabc block per depth" | **TRUE** | `an_sb128_screen_stream_with_intrabc_...` asserts `blocks_total > 0 && fired_arms > 0` | keep |
52+| 12 | `enable-intrabc` NEVER_EXERCISED header (`:45`) | "counter asserted > 0" | **TRUE** | `a_real_aomenc_screen_key_frame_reads_use_intrabc_on_rect_strips` asserts `blocks_total > 0 && fired_arms > 0` | keep |
53+| 13 | `enable-restoration` 10-bit comment (`:311`) | "asserts a real Wiener/SGR unit fired" | **TRUE** | `a_real_aomenc_10bit_restoration_stream_...` asserts `lr_stripe0_hits`/`lr_last_stripe_hits` | keep |
54+| 14 | `enable-1to4-partitions` 10-bit comment (`:317`) | "10-bit arm asserts both orientations and coded strips" | **TRUE** | `a_real_aomenc_10bit_..._1to4...` gates assert `rect4_coeff_hits`/orientation counters | keep |
55+| 15 | `enable-global-motion` 8-bit comment (`:264`) | "loops `for depth in [8u32, 10u32]`" | **TRUE** | `a_real_affine_global_motion_stream_decodes_pixel_exact`; `covers_both_depths` recognises that exact spelling | keep |
56+| 16 | `DEFAULT_ON_TOOLS` doc (`:123`) | "all 49 gates that name it pass `--enable-tx-size-search=0`" | **STALE** | 113 of 146 name it: 88 `=0`, 15 `=1`, 9 via `format!` | claim no longer holds either way; count removed, not replaced |
57+| 17 | module doc (`:5`) | "a flag off the line takes aomenc's default (on …)" | **TRUE but misleading** | default is 1, but palette/intrabc are content-gated (`encoder.c:2079`) and `speed_features.c` re-masks per cpu-used | reworded: default = *allowed*, not *arrived* |
58+| 18 | module doc TILING (`:25`) | "13 gates … assert the parsed `tile_info`" | **STALE** | 19 gates spell nonzero tile log2; 9 assert in-body, 10 delegate to a helper that asserts | reworded to the measured split |
59+| 19 | `ALIASES` (`:194`) | "all three superres gates" | **STALE (undercount)** | 6 gates spell nonzero `--superres-mode`; 5 read `superres_hits`/`predict_scaled_hits` | count removed (rots); alias marked healthy |
60+| 20 | 10-bit list header (`:335`) | "Only 4 of the 45 real-aomenc gates encode at 10 bits" | **STALE** | 83 of 146 selected bodies are 10-bit-or-higher | reworded with the measured figure |
61+| 21 | `DEFAULT_ON_TOOLS` default column (`:135-181`) | `1` for tx-size-search / directional-intra / smooth-interintra / interintra-wedge / diff-wtd-comp / onesided-comp | **TRUE** | `default_extra_cfg` (non-RT array) is 1 for all six; `CONFIG_REALTIME_ONLY 0` | keep |
62+| 22 | `DEFAULT_ON_TOOLS` `deblocking`/`multi-tile`/`fwd-kf` defaults (`:181-189`), `multi-tile` `0`, `fwd-kf` `0` | — | **TRUE** | `LOOPFILTER_ALL` (non-zero), `tile_columns/rows = 0`, `fwd_kf = 0` | keep |
63+| 23 | NEVER_EXERCISED doc (`:46`) | "palette and intrabc only come on for screen content" | **TRUE** | `encoder.c:2079` `allow_screen_content_tools` from block counts; `seq_force_screen_content_tools` adaptive | keep |
64+
65+## Claims-a-gate spot check (class: a passing gate that never reaches the feature)
66+
67+Main's "one level down" class. Each entry naming a gate was checked against that
68+gate's own asserts:
69+
70+| entry | gate named | gate exists | gate asserts the firing | verdict |
71+|---|---|---|---|---|
72+| dist-wtd (r1) | `a_distance_weighted_compound_stream_...` | yes | yes — `dist_wtd_comp_hits() > 0` | **VERIFIED** |
73+| dual-filter | `a_real_aomenc_dual_filter_obmc_8x8_...` | yes | yes — `dual_filter_diff_hits() > before` | **VERIFIED** (census blind to it) |
74+| flip-idtx | `a_real_aomenc_stream_with_a_1d_tx_class_...` | yes | yes — `compared_class1 > 0` | **VERIFIED** |
75+| cfl-intra | `a_real_aomenc_sb128_stream_whose_skipped_cfl_...` | yes | yes — `dir_pairs > 0` (not skipped-CfL) | **VERIFIED for 1:4 pairs; GAP for the name's skipped-CfL** |
76+| intrabc | `an_sb128_screen_stream_with_intrabc_...` | yes | yes — `blocks_total > 0 && fired_arms > 0` | **VERIFIED** |
77+| restoration | `a_real_aomenc_10bit_restoration_stream_...` | yes | yes — `lr_*_hits` | **VERIFIED** |
78+| superres (alias) | 5 superres gates | yes | yes — `superres_hits`/`predict_scaled_hits` | **VERIFIED** |
79+| global-motion | `a_real_affine_global_motion_...` | yes | yes — affine GM counter | **VERIFIED** |
80+
81+**GAP (one):** no gate in the tree names `enable-rect-tx`, because the tool has no
82+header bit and no flag-shaped decoder gate — a *structural* gap, correctly
83+described by entry #7, not a broken gate.
84+
85+## The two structural census defects this audit exposed
86+
87+Both are stated in the corrected comments but are **census logic**, deliberately
88+NOT changed in this lane (the brief forbids behaviour changes; the entry deletions
89+are left in place so the file's own tests stay green):
90+
91+1. **`gate_bodies()` helper-delegation blind spot** (`gate_coverage.rs:421`).
92+ The filter keeps only a `#[test]`-shaped segment containing `--passes=1` /
93+ `ten_bit_tool_gate(` / `encode_10bit_gradients`. A gate that hands its recipe
94+ to a shared helper keeps the flags in the *helper*, so the whole gate is
95+ invisible. Measured: 165 of 311 segments are filtered out, and 6 of those
96+ spell at least one `--enable-X=1` — including both gates that prove
97+ `enable-dual-filter` (#3, #4). This is why two live entries are wrong.
98+
99+2. **`covers_both_depths` blind spot, third spelling** (`gate_coverage.rs:599`).
100+ It recognises only `if bit_depth == 10` / `if depth == 10` /
101+ `for depth in [8usize, 10]`. `a_real_aomenc_stream_with_a_1d_tx_class_...`
102+ builds both depths from a `ten_bit` recipe, so `is_ten_bit` sees the
103+ `yuv420p10le` and files it 10-bit-ONLY — hiding its 8-bit arm and keeping the
104+ 8-bit `enable-flip-idtx` entry alive (#5). This is the lane-defon/reelckf blind
105+ spot the function's own doc comment describes, reached through a new spelling.
106+
107+**Loud, for the coverage matrix:** entries `enable-dual-filter` (8-bit `:270`,
108+10-bit `:374`) and `enable-flip-idtx` (8-bit `:291`) are **stale coverage holes**
109+— the tools are exercised by gates with hard arrival asserts. The census is
110+wrong, not the coverage. If another lane's matrix counts these as open cells,
111+that matrix overstates the holes. Correcting the two structural defects above
112+would let all three entries be deleted and this file's own test stay green.
113+
114+## What changed in this lane
115+
116+`crates/ec-av1/src/gate_coverage.rs` only, and the diff is **comment/reason-text
117+only**: verified — the only non-comment lines changed are 3 entry *reason
118+strings* (`gate_coverage.rs:272, 293, 376`). No flag name, entry membership,
119+counter, gate, or decoder behaviour was touched. All 9 `gate_coverage` tests
120+green after the change. No stream, gate, or counter behaviour altered, per brief.
121+
122+---
123+
124+# r3 appendix: fix the two structural census defects
125+
126+r2 corrected the false CLAIMS. r3 fixes the LOGIC that generated them, so it
127+stops generating them. `crates/ec-av1/src/gate_coverage.rs` only; no gate,
128+counter, fixture, or decoder behaviour touched.
129+
130+## Evidence table — before / after
131+
132+| measure | before (r2, spelling-only) | after (r3, call-resolving) |
133+|---|---|---|
134+| gate bodies seen by `gate_bodies()` | 146 | **230** (+84) |
135+| of those, classified 10-bit-or-higher | 83 | **107** (+24) |
136+| `enable-dual-filter` 8-bit | listed as a hole | **retired** (gate found) |
137+| `enable-flip-idtx` 8-bit | listed as a hole | **retired** (gate classified both-depths) |
138+| `NEVER_EXERCISED_8BIT` | 3 live entries | **1** (`enable-rect-tx`) |
139+| `NEVER_EXERCISED_10BIT` | 3 live entries | **2** (`enable-dual-filter`, `enable-rect-tx`) |
140+| tests | 9 | **10** (new `the_detector_sees_the_gates_the_spelling_filter_missed`) |
141+
142+The three gates the fix had to find, all now found and asserted by the new test:
143+
144+| gate | was invisible because | now found by |
145+|---|---|---|
146+| `a_real_aomenc_dual_filter_obmc_8x8_inter_sequence_decodes_pixel_exact` | recipe lives in `inter_sb_none_gate` | `encoder_fns` call closure |
147+| `a_real_obmc_stream_reads_a_recorded_switchable_filter_for_every_neighbour` | same | `encoder_fns` call closure |
148+| `a_real_aomenc_stream_with_a_1d_tx_class_on_a_rect_transform_decodes_pixel_exact` | `ten_bit` recipe, `is_ten_bit` filed it 10-bit-only | `covers_both_depths` pair-of-formats marker |
149+
150+## The two fixes
151+
152+**1. `gate_bodies()` — recognise a gate by what it CALLS, not only what it spells.**
153+New `fn_units` parses every `fn` in `stream.rs` as `(name, body)`; `encoder_fns`
154+computes the transitive closure of fns that reach one naming `aomenc_path()`.
155+The filter is now `legacy_gate_tokens(body) || body.contains("aomenc_path()")
156+|| enc.iter().any(|e| calls_fn(body, e))`. The call test is deliberately the
157+weak half of an OR, so the fix is **strictly additive** — it can add gates but
158+can never stop recognising one the old filter did. `calls_fn` requires the name
159+to be followed by `(` and not be the tail of a longer identifier, so
160+`inter_sb_none_gate` does not "call" `sb_none_gate`.
161+
162+**2. `covers_both_depths` — the third spelling.** Added
163+`body.contains("\"yuv420p\"") && body.contains("\"yuv420p10le\"")`: a body
164+naming BOTH fixture formats builds streams at both depths, whatever the
165+parameter is called. The quotes matter — a bare `yuv420p` substring test also
166+matches `yuv420p10le` and would fire on every 10-bit gate, retiring entries on
167+no evidence. This is not a special case for the flip-idtx gate; it is the
168+lane-defon/reelckf blind spot closed on its third spelling.
169+
170+## Red-before (three mutations, all reverted; `stream.rs` byte-identical to HEAD)
171+
172+A detector change can only be shown to find MORE, never to stop missing, so
173+each half was shown to be **causal** — neuter it and the retired entry must come
174+back.
175+
176+**Mutation A — the helper-delegation half.** Set `--enable-dual-filter=1` to
177+`=0` in both helper-based gates. TWO tests red:
178+- `never_exercised_8bit_matches_the_gate_recipes`: *"no 8-bit gate passes `=1`
179+ for ["enable-dual-filter"], so no real 8-bit stream exercises them"* — the
180+ retired entry correctly RETURNS as a hole.
181+- `the_detector_sees_the_gates_the_spelling_filter_missed`: *"seen, but its
182+ --enable-dual-filter=1 spelling is not visible to flags_in"*, `left: Some('0')
183+ right: Some('1')`. The second red is the valuable one: it separates
184+ *recognition broke* from *the gate no longer enables the tool*.
185+
186+**Mutation B — the legacy path still works.** Set `--enable-dist-wtd-comp=1` to
187+`=0` in the r1 gate, a gate the OLD filter already recognised (it spells
188+`--passes=1`). Red at BOTH depths: *"no 10-bit gate passes `=1` for
189+["enable-dist-wtd-comp"]"* and the 8-bit twin. The spelling path is intact.
190+
191+**Mutation C — the both-depths half.** Reverted only the pair-of-formats
192+clause. TWO tests red: `never_exercised_8bit...`: *"no 8-bit gate passes `=1`
193+for ["enable-flip-idtx"]"*, and the new detector test: *"the flip-idtx gate
194+spells both fixture formats, so covers_both_depths must credit it to the 8-bit
195+bucket as well"*.
196+
197+All three reverted; `git diff --stat crates/ec-av1/src/stream.rs` is empty, and
198+all 10 tests are green.
199+
200+## `enable-dual-filter` 10-bit: the entry STAYS — a finding, not an oversight
201+
202+After the fix the 8-bit entry retires and the 10-bit one does not, which is the
203+honest outcome and exactly the case Main said to report rather than paper over.
204+The only `=1` witness is `a_real_aomenc_dual_filter_obmc_8x8_inter_sequence_decodes_pixel_exact`,
205+and it calls `inter_sb_none_gate(NAME, false, ...)` — `false` is the `ten_bit`
206+parameter, so it builds an 8-bit stream only. Its `ten_bit=true` siblings
207+(`..._10bit_inter_sequence_with_a_whole_superblock_block_...` and the 8x8-leaf
208+pair) do not spell `--enable-dual-filter=1`. **To retire it: add the 10-bit arm
209+— pass `true` to `inter_sb_none_gate` in that gate and assert
210+`dual_filter_diff_hits()` still moves there.**
211+
212+## Row: `enable-tx-size-search` — the one claim this audit could not settle
213+
214+A third detector limit, and the method for whoever takes it next. After the r3
215+fix, 113 of the 230 selected gates name it: **88 pass `=0`, 15 pass `=1`, and 9
216+build the value into a `format!`/`String` variable** that neither `flags_in` nor
217+`settings_in` can see — both scan for a literal `"--flag=value"` inside one
218+segment. So the r2 finding stands and sharpens: the historical "all 49 pass 0"
219+claim no longer holds in either direction, and 9 gates are unclassified in an
220+**unknown direction**, which is the exact failure mode this file exists to
221+prevent.
222+
223+**What would settle it (method, not a guess):** extend `flags_in`/`settings_in`
224+to resolve a local binding the way `gate_bodies` now resolves calls. When a
225+segment contains `let <name> = format!("--enable-tx-size-search={tx_search}")`
226+(or the `String::from`/`to_string` equivalent), record the TEMPLATE and bind the
227+variable's value at each use site. Re-count, and only then decide whether the
228+tool is a live hole. Until that exists the 113/88/15 split is a floor, not a
229+measurement. This is recorded in-file above `DEFAULT_ON_TOOLS` as well.
lanes/av1dualfilter10.report.mdadded+116 -0
@@ -0,0 +1,116 @@
1+# lane-av1dualfilter10 — 10-bit `enable-dual-filter` witness
2+
3+Base: `1aaf7e0b` (lane-av1distwtd, the census detector fix). Branch: `lane-av1dualfilter10`.
4+Touches `crates/ec-av1/src/stream.rs` (tests only). `gate_coverage.rs` is NOT edited.
5+
6+## What the census left open
7+
8+`NEVER_EXERCISED_10BIT` still carried `enable-dual-filter`, and the reason it carried was
9+structural, not incidental:
10+
11+- the only `=1` witness is `a_real_aomenc_dual_filter_obmc_8x8_inter_sequence_decodes_pixel_exact`
12+- that gate calls `inter_sb_none_gate(NAME, false, ...)` and that `false` IS the `ten_bit`
13+ parameter of the helper, so it builds an **8-bit** stream
14+- the helper's `ten_bit = true` siblings build 10-bit streams but spell no dual-filter flag
15+
16+So the tool was proven at 8 bits and unproven at 10. This lane adds the missing arm.
17+
18+## The change (stream.rs only)
19+
20+1. `inter_sb_none_gate` now returns `Vec<u8>` — the encoded stream — so a caller can assert on
21+ the **parsed** sequence header rather than on the flag it asked for. SKIP paths return an
22+ empty vec. All six existing callers ignore the value; none needed edits.
23+2. New gate `a_real_aomenc_10bit_dual_filter_obmc_8x8_inter_sequence_decodes_pixel_exact`
24+ (`stream.rs:17719`), the 10-bit twin of the 8-bit witness: same recipe, same four
25+ `--enable-*` flags including `--enable-dual-filter=1`, `ten_bit = true`, same compound-8x8
26+ arrival counter, same 16-frame sequence, same 64-wide frame.
27+
28+### What makes it a witness rather than a spelling
29+
30+Three independent facts, in this assert order:
31+
32+1. **arrival, first** — `decode::dual_filter_diff_hits() > before_dual`, a DELTA taken around
33+ this arm alone. The counter increments only inside `resolve_interp_filter`
34+ (`decode.rs:35136`) and only when the header bit is set *and* the block's two directions
35+ differ. Deliberately asserted before the header checks so the mutation below reds on the
36+ arrival, not on a shape/pixel assert downstream.
37+2. **10-bit from the parsed header** — `seq.color_config.bit_depth == 10` read through
38+ `Av1Parser` on the encoded bytes. Not the filename, not the flag, not the fixture name.
39+3. **the tool is in the header** — `seq.enable_dual_filter` true, same parse.
40+
41+`inter_sb_none_gate` also pixel-compares every frame against ffmpeg's own 10-bit decode
42+(`ffmpeg_decode_sequence_10bit`), so the arm is pixel-exact end to end, not merely parseable.
43+
44+## Red-before (in the right direction)
45+
46+Mutation: `--enable-dual-filter=1` -> `=0` in the 10-bit arm only.
47+
48+```
49+panicked at crates/ec-av1/src/stream.rs:17753:
50+a_real_aomenc_10bit_dual_filter_obmc_8x8_inter_sequence_decodes_pixel_exact:
51+no block read two DIFFERENT dual-filter directions in the 10-bit stream --
52+--enable-dual-filter=1 did not arrive or aomenc declined it
53+```
54+
55+The **arrival** assert, as required. First attempt had the header asserts first and reds on
56+`the parsed sequence header says enable_dual_filter = false` — correct but the wrong assert,
57+so the block was reordered and the red re-proven. Reverted after; both arms green:
58+
59+```
60+test stream::tests::a_real_aomenc_10bit_dual_filter_obmc_8x8_inter_sequence_decodes_pixel_exact ... ok
61+test stream::tests::a_real_aomenc_dual_filter_obmc_8x8_inter_sequence_decodes_pixel_exact ... ok
62+2 passed; 0 failed
63+```
64+
65+Sibling `inter_sb_none_gate` callers re-run green (whole-superblock 8/10-bit, 8x8-leaf-split
66+8/10-bit, across-tile-columns: 3 passed, 0 failed).
67+
68+## Census effect (measured, not claimed)
69+
70+`cargo test -p ec-av1 --lib gate_coverage`, run on this branch:
71+
72+```
73+the 10-bit list still names ["enable-dual-filter"], but a 10-bit gate now passes `=1` for
74+them -- delete those entries, the coverage hole is closed <- FAILS, correctly
75+
76+gate_coverage: 231 real-aomenc gates, 108 of them 10-bit
77+NEVER_EXERCISED_8BIT (1 of 26): --enable-rect-tx
78+NEVER_EXERCISED_10BIT (1 of 26): --enable-rect-tx
79+NEVER_ON_8BIT (0 of 10, over 192 8BIT gates)
80+NEVER_ON_10BIT (0 of 10, over 110 10BIT gates)
81+```
82+
83+That single red is the deliverable's receipt, and it is why this lane stops here:
84+
85+**`gate_coverage.rs:374-377`, `NEVER_EXERCISED_10BIT` — `enable-dual-filter`** is now
86+retirable. Its reason string ("no 10-bit gate spells `=1` -- that gate calls
87+`inter_sb_none_gate` with `ten_bit=false`") is exactly what this lane closed. Deletion is the
88+census owner's call; the merge owner sequences it. `enable-rect-tx` stays in both lists
89+(its premise is PROVEN: aom has no sequence-header bit for it, `enable_rect_tx` is read only
90+in `tx_search.c`).
91+
92+Gate counts moved 230 -> 231 and 107 -> 108 10-bit (the new arm), from lane-av1distwtd's
93+before-numbers of 146 -> 230 gates / 83 -> 107 at the detector fix.
94+
95+## Third detector limit, cited for report agreement (NOT fixed here)
96+
97+`--enable-tx-size-search` is built into a `format!`/`String` variable in a number of gates, so
98+`flags_in` — which matches the literal `"--enable-` — cannot see it. Any count of "gates
99+naming it" is therefore a FLOOR. lane-av1distwtd measured 113 of 230 naming it (88 `=0`,
100+15 `=1`, 9 invisible via `format!`); my independent recount on this branch (now 231 gates,
101+so not directly comparable) gives 116 segments spelling the literal (94 `=0`, 21 `=1`) plus
102+15 more that name the tool only inside a `format!`. Same class, same direction, magnitudes
103+differ only with the extra gate. Method: the method is the `format!` construction itself —
104+`args.push(format!("--enable-tx-size-search={}", ...))` leaves no `"--enable-` literal for
105+`match_indices` to find, so a census that wants a measurement rather than a floor has to
106+resolve the helper's `String` before counting, or match on the flag name without the leading
107+`"` and then classify the value from the format argument. Open question, not a fix.
108+
109+## Verification actually run
110+
111+- `cargo build -p ec-av1 --tests` clean.
112+- new gate green, both arms green, mutation red on the arrival assert, mutation reverted
113+ (grep confirms 4 `--enable-dual-filter=1` sites: 3926, 17668, 17736 — plus the two `=0`
114+ sites 18414/18680 untouched).
115+- sibling `inter_sb_none_gate` gates green.
116+- `gate_coverage` 10-bit test red for the intended reason; all other 9 green.
lanes/av1dumpyuv.report.mdadded+183 -0
@@ -0,0 +1,183 @@
1+# lane-av1dumpyuv — the depth-packing class outside the test helpers
2+
3+Branch `lane-av1dumpyuv`, branched from `afa13bcf` ("Merge lane-whtshape").
4+Worktree `~/.cache/wt/av1dumpyuv`. Examples/tools/scripts only: no decoder
5+logic, no gate touched. The primary checkout was never edited
6+(`git status --porcelain` there is empty).
7+
8+## 1. The class
9+
10+`aomdec --rawvideo` and `ffmpeg -f rawvideo` pack **8 bits per sample for an
11+8-bit stream** and **16 bits per sample (`*p10le` / `*p12le`) for a
12+high-bit-depth one** — they never pack to the stream's own bit depth. A site
13+that reads decoded `u16` planes and writes them `as u8`, or writes them `u16`
14+unconditionally, therefore produces a file of the wrong size, and the next
15+person's `cmp` against the oracle fails on LENGTH and reads like a decoder
16+bug. The prior audit (lanes/av1cmpaudit.report.md) fixed the test helper
17+`assert_rawvideo_matches`'s sibling `EC_AV1_FINAL_DUMP`
18+(`crates/ec-av1/src/stream.rs:2137-2152`, depth-correct since lane-hidden r1)
19+and named exactly one unfixed non-test site: `examples/dump_yuv.rs`.
20+
21+## 2. Sweep of the non-test surfaces
22+
23+Rows verified by reading each file. "Assumes" = what the code takes the
24+bits-per-sample to be.
25+
26+| site | assumes about depth | derived from | failure mode on the wrong depth |
27+|---|---|---|---|
28+| `crates/ec-av1/examples/dump_yuv.rs:33` (pre-fix) | always 2 bytes/sample (u16 LE) | **nothing** | silent 2x file on an 8-bit stream; docstring named `yuv420p10le` as the companion, so a reader hands it 8-bit input and diffs the size |
29+| `crates/ec-av1/examples/dump_yuv.rs` (**fixed**) | sequence header `color_config.bit_depth` | the stream's own parsed header; `--depth` is an ASSERTED argument | hard exit 1 naming both depths, no file |
30+| `crates/ec-av1/examples/decode_probe.rs:434-462` | `EC_PROBE_OUT16` = 2 B/sample, `EC_PROBE_OUT`/argv[2] = 1 B/sample | two SEPARATE, explicitly named output targets, each a fixed choice by the caller | none for a single file: the 16-bit target is a full 16-bit container (same as `-pix_fmt yuv420p10le` on an 8-bit stream), the 8-bit target narrows. Both are written, so a wrong choice is visible as two files of different sizes, not one mislabelled file. **not fixed** |
31+| `crates/ec-vp8/examples/dump_frame.rs:28-45` | 1 byte/sample | VP8 has no high-bit-depth profile (its 8-bit 4:2:0 is the format) | none possible. **not flagged** |
32+| `crates/ec-av1/examples/{alloc_probe,enc_probe,syntax_census}.rs` | — | no plane is read or serialised | none. **not flagged** |
33+| `crates/ec-h264/examples/bench_decode.rs`, `bench_encode.rs`, `crates/ec-aac/examples/*`, `crates/ec-ac3/examples/ac3dec.rs` | — | audio `f32`/metric only; no video planes | none. **not flagged** |
34+| `scripts/instrument-aom-oracle.sh:130-145` (rung PREFILT), `:333-350` (POSTDEBLOCK), `:384-398` (PREFILT_WIDE), `:880-896` (POSTCDEF) | 1 byte/sample, no `YV12_FLAG_HIGHBITDEPTH` check | nothing | on a 10/12-bit stream: a **half-length** file (u8 rows of a u16 plane) that can still byte-match a decoder-side `as u8` narrowing. Rung 12 (`FINAL`, `:684-705`) IS depth-correct and is what `EC_AV1_FINAL_DUMP` pairs with. **NOT FIXED** — these are oracle C rungs whose decoder-side counterparts (`EC_AV1_PREFILT_DUMP`, `EC_AV1_DECODE_ORDER_DUMP`, and the `as u8` debug dumps at `stream.rs:2123-2126`) narrow identically on purpose; changing one side alone would break the byte-pairing those rungs exist for, and both sides are decoder/oracle logic, out of this lane's scope. The script's own comment at `:659-660` already calls them the "u8-narrowing debug dumps". |
35+| `scripts/lr-sgr-pin-harness.c:33-36` (pre-fix) | 1 byte/sample of `/tmp/lr_full.bin`; `bit_depth=8, highbd=0` hardcoded at `:47`, `:54`, `:75` | nothing (the capture is a bare `std::fs::write` from a since-reverted `EC_LR_DUMP` in `apply_sgrproj_stripe`, lanes/lr.report.md:352-354) | a 10-bit re-capture is exactly 2x the bytes; the harness read its first half as plane data and printed plausible A/B taps for the wrong pixels |
36+| `scripts/lr-sgr-pin-harness.c` (**fixed**) | still reads 8-bit, but the file length is now an ASSERTION | file size, checked against `bw*bh` | 2x capture → exit 1 naming the byte counts, the assumed depth, and the uint16 port; truncated → exit 1 |
37+| `scripts/raw_to_y4m.py:9` (pre-fix) | `w*h*3//2` = 8-bit 4:2:0, unconditionally; header hardcoded `C420jpeg` | nothing | a 10-bit stream was cut at half frame length, frame N+1's chroma read as frame N's tail, trailing partial frame **dropped silently** — and vpxenc encodes the result without complaint |
38+| `scripts/raw_to_y4m.py` (**fixed**) | required `DEPTH` argument, asserted against the stdin length | explicit asserted argument (no parser exists for a headerless raw stream) | non-integer frame multiple → exit 1 naming both implied frame sizes; a missing/!8/10/12 depth → usage error |
39+| `scripts/superres-pin-harness.c:14-17,50,80,89-142` | — | coverage gap, not depth: only the `uint8` `av1_convolve_horiz_rs_c` arm is called and the input rows were transcribed from an 8-bit fixture | a 10-bit superres pin would be silently uncovered. Different class; **not fixed** |
40+| `tools/oracle/src/main.rs:352-357` (`sample`), `:383-390`, `:414`, `:424-425`, `:479` | bytes-per-sample from the `--pix-fmt` string (or ffprobe of the reference CONTAINER, `:383-388`), never from a parsed header | explicit CLI flag / container probe | a wrong `--pix-fmt` yields `fa != fb`, and `len_ok = fa == fb` feeds the verdict at `:479` → **loud FAIL**, not a silent compare. Acceptable shape (an argument that is checked). **not fixed** |
41+| `tools/ec-bench/src/main.rs:253`, `:367`, `:557` | 1 byte/sample `frame_len`; `:564-571` widens those 8-bit samples into `Av1Picture`'s `u16` planes | the same forced `-pix_fmt yuv420p` on the extracting ffmpeg (`:242-243`) | self-consistent: the frame arithmetic and the file it slices come from one explicit ffmpeg argument. Mild real hole: `Av1Config` (`:536-544`) has no depth field, so the encoder's own output depth is whatever it defaults to. **not fixed** (bench table, no oracle compare) |
42+| `tools/ec-bench/src/main.rs:404-410`, `:423`, `:452`, `:485` | 10-bit for the `ec-hw` row | a comment about the local VA driver's stored format, plus a matching `-pix_fmt yuv420p10le` at `:485` | arithmetic agrees with the forced format. **not fixed** |
43+| `shims/**` | — | 16 Cargo path-shim crates (`Cargo.toml` + thin `lib.rs` re-exports), no video or raw-byte code | none. **out of scope** |
44+| `scripts/{build-aom-oracle,build-aom-affine-oracle,gen-bitstream-fixtures,gen_vp8_fixtures,gen-still-fixtures,pgs-white-level,scan-real-library,fetch-vectors,link-fixtures}.sh`, `scripts/av1-timeline-report.py` | force an explicit `-pix_fmt` (or read no planes at all); sizes that exist (`gen_vp8_fixtures.sh:60`, `pgs-white-level.sh:27`) are computed from that same argument | CLI flag | none. **not flagged** |
45+
46+Sites fixed: 3 (`examples/dump_yuv.rs`, `scripts/raw_to_y4m.py`,
47+`scripts/lr-sgr-pin-harness.c`). Sites examined and deliberately NOT fixed:
48+7 (`decode_probe.rs`, `tools/oracle/src/main.rs`, `tools/ec-bench` x2,
49+`instrument-aom-oracle.sh` rungs 1/6/7/15, `superres-pin-harness.c`), each with
50+the reason above.
51+
52+## 3. `examples/dump_yuv.rs` — what changed
53+
54+- The depth comes from the stream's **own parsed sequence header**
55+ (`ec_av1_syntax::Av1Parser` walking OBU by OBU until a sequence header
56+ appears, then `seq.color_config.bit_depth`). It is never taken from the file
57+ name, the extension, or a reference tool's `-pix_fmt`.
58+- 8 bit → one byte per sample; 10/12 → little-endian `u16` (the container
59+ both oracles use). Monochrome streams write the luma plane only.
60+- `--depth N` is an **assertion, not a switch**: the packing always follows the
61+ parsed header, and a contradiction exits 1 naming both depths, both
62+ bytes-per-sample values, and the size mismatch the `cmp` would have shown.
63+ Two spellings accepted (`--depth 8`, `--depth=8`); given twice → usage error.
64+- A stream with no parseable sequence header → hard error instead of a guess.
65+- A sample that does not fit the container about to be written (an 8-bit
66+ header with a sample above 255) → hard error. That is the mirror of the
67+ original bug and the reason `as u8` may never be applied silently here.
68+- The docstring no longer says `yuv420p10le`; it states the both-depths
69+ contract and the `--depth` assertion.
70+- Measured while doing this: the crate's own 8-bit fixture
71+ `av1_192x128_8bit_intra64_in_inter.obu` parses `subsampling_x/y = 1/1`,
72+ which is **4:2:0** (spec 5.5.3) — 36864 samples for 192x128 = W*H*3/2. The
73+ first pix_fmt table I wrote had 1/1 → 4:4:0 and the measurement caught it;
74+ the shipped table is 0/0→444, 0/1→440, 1/0→422, 1/1→420.
75+
76+## 4. Proof
77+
78+Committed crate fixtures only, worktree at `afa13bcf`,
79+`CARGO_TARGET_DIR=$HOME/.cache/cargo-target`.
80+
81+### 4.1 GREEN — 8-bit stream, committed fixture
82+
83+```
84+$ dump_yuv crates/ec-av1/fixtures/av1_192x128_8bit_intra64_in_inter.obu /tmp/dy/eight
85+sequence header: bit_depth 8 -> 1 byte(s) per sample, seq_profile 0, subsampling 1/1, mono_chrome false; ffmpeg -pix_fmt yuv420p
86+frame 0: 192x128 -> /tmp/dy/eight.f0.yuv (36864 samples, 36864 bytes, yuv420p)
87+...
88+eight.f0.yuv 36864 bytes <- W*H*3/2 = 192*128*3/2 = 36864 (Y 24576 + U 6144 + V 6144)
89+```
90+Byte-exact against the oracle at its own depth:
91+`aomdec --codec=av1 --rawvideo -o ref8.raw <fixture>` → 221184 bytes for 6
92+frames; our 6 concatenated frames → 221184 bytes; `cmp` → **IDENTICAL**.
93+
94+### 4.2 GREEN — high-bit-depth stream, committed fixture
95+
96+```
97+$ dump_yuv crates/ec-av1/fixtures/av112bit-key.obu /tmp/dy/twelve
98+sequence header: bit_depth 12 -> 2 byte(s) per sample, seq_profile 2, subsampling 1/1, mono_chrome false; ffmpeg -pix_fmt yuv420p12le
99+frame 0: 160x128 -> /tmp/dy/twelve.f0.yuv (30720 samples, 61440 bytes, yuv420p12le)
100+twelve.f0.yuv 61440 bytes <- W*H*3 = 160*128*3 = 61440 (30720 samples x 2 bytes)
101+cmp twelve.f0.yuv (ffmpeg -f obu -pix_fmt yuv420p12le -f rawvideo) -> IDENTICAL
102+```
103+
104+### 4.3 The wrong depth fails loudly and writes nothing
105+
106+```
107+$ dump_yuv .../av1_192x128_8bit_intra64_in_inter.obu /tmp/dy/wrong --depth 10
108+dump_yuv: ...: --depth 10 contradicts the stream's own sequence header, which carries
109+bit_depth 8 (seq_profile 0, subsampling 1/1, mono_chrome false). Writing 10-bit would emit
110+2 bytes per sample against the oracle's aomdec --rawvideo / ffmpeg -pix_fmt yuv420p (1 bytes
111+per sample, W*H*3/2 for 4:2:0), so every `cmp` would fail on size alone and read like a decoder
112+defect. Nothing was written.
113+exit=1
114+ls: cannot access '/tmp/dy/wrong.f0.yuv': No such file or directory
115+
116+$ dump_yuv .../av112bit-key.obu /tmp/dy/wrong2 --depth=8 -> same message, exit=1, no file
117+$ dump_yuv .../av1_192x128_... --depth=8 -> runs, 36864 bytes (assertion holds)
118+$ dump_yuv .../av112bit-key.obu --depth 12 -> runs, 61440 bytes
119+```
120+
121+### 4.4 RED-BEFORE — the depth derivation reverted
122+
123+`git show HEAD:crates/ec-av1/examples/dump_yuv.rs` restored, rebuilt, same
124+8-bit fixture, same command:
125+
126+```
127+--- RED (pre-fix, u16 unconditional) on the 8-bit fixture ---
128+ours 73728 bytes <- 2 x 36864
129+aomdec --rawvideo 221184 bytes <- 6 x 36864
130+cmp exit=1 (mismatch on size alone)
131+```
132+73728 = 2 x (W*H*3/2): exactly the silent 2x file the lane was chartered to
133+close. Fixed tree restored and rebuilt afterwards.
134+
135+### 4.5 `scripts/raw_to_y4m.py`
136+
137+```
138+$ ... | raw_to_y4m.py 64 64 25 g8.y4m 8 -> YUV4MPEG2 ... C420jpeg, 18491 bytes (3 frames)
139+$ ... | raw_to_y4m.py 64 64 25 g10.y4m 10 -> YUV4MPEG2 ... C420p10, 36922 bytes (3 frames)
140+$ 12289 bytes | raw_to_y4m.py ... 8
141+raw_to_y4m.py: stdin is 12289 bytes, not a whole number of 64x64 4:2:0 frames at 8-bit
142+(1 bytes per sample, 6144 bytes each): 1 trailing bytes. At the other depth a frame would be
143+12288 bytes and each frame would carry half a frame of the next one's planes. Refusing to
144+write a misframed y4m. exit=1, no file
145+$ DEPTH 7 -> "DEPTH 7 is not 8, 10 or 12 ..." exit=1
146+$ DEPTH omitted (the old 4-arg invocation) -> usage error, exit=1
147+```
148+Documented limit, stated in the script's own docstring: raw planar video
149+carries no depth, so a 10-bit stream of N frames is exactly 2N 8-bit frames
150+and no length test can separate them. That case is caught by the caller
151+asserting the right DEPTH — which is why the argument is required, not
152+defaulted.
153+
154+### 4.6 `scripts/lr-sgr-pin-harness.c`
155+
156+Linked against `~/.cache/aom-oracle/build/libaom.a`, `/tmp/lr_full.bin`
157+faked at three sizes:
158+
159+```
160+1020 bytes (correct) -> ret=0 / out[1][6] = 151 / dgd[1][6] = 151 (real libaom taps printed)
161+2040 bytes (2x, HBD) -> "/tmp/lr_full.bin is 2040 bytes, this harness reads it as 8-bit
162+ (1020 bytes: 102x10 at 1 byte per sample). That is exactly a 2x-size
163+ high-bit-depth capture: re-capture it as 8-bit, or port the harness to
164+ the uint16 arm (bit_depth=10, highbd=1) before trusting a single
165+ printed tap." exit=1
166+ 900 bytes (short) -> "... 900 bytes ... Recapture it, or fix bw/bh to the plane the
167+ capture came from." exit=1
168+```
169+
170+## 5. Not done, deliberately
171+
172+- `instrument-aom-oracle.sh` rungs 1/6/7/15 (section 2): changing one side of
173+ a byte-paired rung breaks the pairing, and both sides are decoder/oracle C.
174+ Rung 12 is already depth-correct; that is the rung the depth-sensitive
175+ compares use.
176+- `tools/oracle/src/main.rs` and `tools/ec-bench/src/main.rs`: already the
177+ "explicit argument that is checked" shape (a length/frame-count FAIL), with
178+ no header parser reachable from those binaries to derive a better answer
179+ from (`oracle` drives ffmpeg through std pipes and is deliberately
180+ dependency-free).
181+- `decode_probe.rs`: its two output targets are separate, explicitly named
182+ files; see section 2.
183+- No gate, counter, decoder path or fixture was touched.
lanes/av1formatsweep.report.mdmodified+64 -12
@@ -80,7 +80,7 @@ walk had no exactness evidence. Measured exact, and gated.
8080 | **lossy** | **D (H1, H2)** | **D (H1)** | **y → gate C** |
8181 | tile columns (2) | **D (H3)** | – | – |
8282 | tile rows (2) | **D (H4)** | – | – |
83-| superres | – | – | – |
83+| superres | Y (`a_444_lossy_superres_stream_decodes_pixel_exact`, plus `…_mode1_den9_…` and `…_mode2_random_denom_…`) | – | – |
8484 | odd coded dims | – | – | – |
8585
8686 ¹ 12-bit 4:4:4 is reachable only from a source smooth enough that aomenc
@@ -335,9 +335,11 @@ screen-tools refusal and call it a 4:4:4 result.
335335
336336 ## 4. Not measured (budget), stated so nobody reads silence as coverage
337337
338-12-bit tiles at 4:2:0; 12-bit superres; 4:4:4 superres; 4:4:4 odd coded
339-dimensions; 4:4:4 at 10/12-bit with tiles; 12-bit 4:4:4 lossless; 4:4:0
340-(`ss 0,1`) at any depth. Suite staging and the full-suite run are Main's.
338+12-bit tiles at 4:2:0; 12-bit superres; 4:4:4 superres **(closed since, at
339+8-bit only — lane-av1superpin, see the correction in §6.5; 10/12-bit still
340+open)**; 4:4:4 odd coded dimensions; 4:4:4 at 10/12-bit with tiles; 12-bit
341+4:4:4 lossless; 4:4:0 (`ss 0,1`) at any depth. Suite staging and the
342+full-suite run are Main's.
341343
342344 ## 5. Handoffs, in the order a follow-up lane should take them
343345
@@ -435,12 +437,42 @@ H2's stream is entropy-clean) or to H2 (lossy, tx-search-gated).
435437
436438 | cell | stream | bytes | sha256 | verdict vs aomdec |
437439 |---|---|---|---|---|
438-| 4:4:4 **superres** 256x128 (`--superres-mode=1`) | `sr444` | 15239 | `06621606…` | **DIVERGENT** from f2, 76404 samples, first (f2, s192) = Y(192,0) |
440+| 4:4:4 **superres** 256x128 (`--superres-mode=1`, **no denominator flag**) | `sr444` | 15239 | `06621606…` | **NOT A SUPERRES CELL.** This is the sweep's own bytes (15239 B, sha256 `06621606…`), and every one of its four PARSED frame headers reads `use_superres=false denom=8` — `--superres-mode=1` without `--superres-denominator` is a **no-op**, byte-identical to the no-flag control. The DIVERGENT verdict itself stands (from f2, 76404 samples, first (f2, s192) = Y(192,0)) but it is **H1, the 1:4 inter-strip own-extent class**, not a superres defect — the same class as the 130x122 row below and gated by `a_444_lossy_rect4_strip_stream_decodes_pixel_exact_at_odd_and_wide_geometries` (second arm is these exact 15239 bytes). The real 4:4:4 superres cells need a denominator; they are byte-exact 4/4 and gated — see `lanes/av1superpin.report.md`. |
439441 | 4:4:4 **odd coded dims 66x66** | `odd444_66x66` | 5938 | `973eddf4…` | **EXACT 4/4** — new exact cell |
440-| 4:4:4 **odd coded dims 130x122** | `odd444_130x122` | 8945 | `c87ac65b…` | **DIVERGENT** from f3, 11521 samples, first (f3, s2208) = Y(128,16) |
441-
442-Note the aomenc flag is `--superres-mode=1`; there is no `--enable-superres`
443-in this build (`aomenc --help | grep -i superres`).
442+| 4:4:4 **odd coded dims 130x122** | `odd444_130x122` | 8945 | `c87ac65b…` | **CORRECTED: was "DIVERGENT from f3, 11521 samples, first (f3, s2208) = Y(128,16)"; now EXACT 4/4** — the same H1 1:4-inter-strip chroma class, gated by `a_444_lossy_rect4_strip_stream_decodes_pixel_exact_at_odd_and_wide_geometries` (first arm = these exact 8945 bytes). Localised in `lanes/av1444edge.report.md` §2-§3: the pre-filter reconstruction already carries the identical first wrong sample, and the one-commit fix is lane-av1444rect's `f92776ba` |
443+
444+Note the aomenc flag is `--superres-mode=1` and there is no
445+`--enable-superres` in this build (`aomenc --help | grep -i superres`) —
446+but **that flag alone does nothing**, which is what made the row above a
447+phantom cell. Read on:
448+
449+**Correction (lane-av1superpin): the flag above does nothing on its own.**
450+There is indeed no `--enable-superres` in this build, and
451+`--superres-mode=1` is accepted — but libaom picks the denominator itself
452+(`get_superres_denom_for_qindex`, `av1/encoder/superres_scale.c:143`), which
453+returns `SCALE_NUMERATOR` (8) unless the frame is a KF/ARF update AND the
454+horizontal-energy test passes. On a smooth `testsrc2` source it returns 8,
455+so the flag is a no-op and the stream is byte-identical to the no-flag
456+control. Three routes actually produce a scaled stream (measured on this
457+oracle, libaom `v3.13.3-7-g9bb526a`; the version comes from the source tree
458+`scripts/build-aom-oracle.sh` builds, because `--version` is not an accepted
459+flag on that build):
460+
461+1. `--superres-mode=1 --superres-denominator=<9..16>` — the denominator is
462+ honoured and appears verbatim in the parsed header.
463+2. `--superres-mode=2` (random) — scales with **no** denominator flag, and
464+ **ignores** `--superres-denominator` entirely: denominators 9, 12 and 16
465+ all produce the same stream. Its denominator is chosen **per frame** (at
466+ 256x128: 11, 14, 15, 9 across the four frames), so a single-denominator
467+ reading of a mode-2 stream is wrong by construction.
468+3. `--superres-mode=3` and `=4` are no-ops at every denominator tried, at
469+ every bit depth — consistent with the committed census gate's own finding.
470+
471+**Always read the verdict out of the stream's own parsed frame header**
472+(`use_superres`, `superres_denom`, `upscaled_width`, coded `frame_width`),
473+never out of the flag. `--resize-mode` is a different feature and is never a
474+superres witness: it downsizes the FRAME (`frame=171x85 upscaled=171`),
475+whereas superres keeps `frame_width < upscaled_width`.
444476
445477 The 130x122 stream is the interesting one: 66x66 is exact at the same
446478 settings, so the 4:4:4 partial-frame walk is right at one odd geometry and
@@ -482,12 +514,21 @@ that is ever hand-built.
482514 ### 6.5 Matrix deltas and the honest "not measured" list
483515
484516 Matrix changes (§1): 4:4:4 row gains `odd dims 66x66 → y` (exact this lane),
485-`superres → D`, `10/12-bit tiles → D`, `12-bit lossless → D`; 4:2:0 row gains
517+`10/12-bit tiles → D`, `12-bit lossless → D`; 4:2:0 row gains
486518 `12-bit tiles + superres → y`. The tile-ROWS cells for 4:4:4 stay as they
487519 are — the 8-bit one is now Agent13's EXACT (tile rows genuinely enabled at
488520 geometries with a second SB row), and the 10/12-bit ones are the untiled
489521 control above.
490522
523+**Correction (lane-av1superpin): the 4:4:4 row's superres cell reads `Y` at
524+8-bit, not `D`.** This lane's `superres → D` was written from a stream that
525+never scaled (§6.2: `--superres-mode=1` with no denominator is a no-op, and
526+the divergence recorded against it is H1, now fixed and gated). With an
527+explicit denominator — or `--superres-mode=2`, which chooses its own — the
528+4:4:4 superres class is byte-exact 4/4 at coded widths 128, 171, 186 and 228,
529+gated at `denom 12`, `denom 9` and mode 2. See `lanes/av1superpin.report.md`.
530+10/12-bit stays `–`: still not measured.
531+
491532 Still not measured after this round: 4:4:4 at 10/12 bits with **tile rows
492533 actually enabled** (needs a >= 256-high geometry — trap 2); 4:4:4 superres at
493534 10/12 bits; 4:4:4 odd dims at 10/12 bits and at dimensions other than 66x66 /
@@ -495,6 +536,11 @@ actually enabled** (needs a >= 256-high geometry — trap 2); 4:4:4 superres at
495536 witness; 4:4:0 at any depth (unproducible, §6.4); 4:2:2 (ss 1,0) beyond the
496537 existing probe-bypass row.
497538
539+Re-checked and **unchanged** by lane-av1superpin: "4:4:4 superres at 10/12
540+bits" is still open. That lane measured 8-bit only — every fixture it pinned
541+parses `bit_depth = 8` from its own sequence header — so this entry stands as
542+written.
543+
498544 ### 6.6 Handed to other lanes
499545
500546 - The 4:4:4 **lossless chroma** divergences at 8/10/12 bits with and without
@@ -502,8 +548,14 @@ existing probe-bypass row.
502548 **Agent24-2** with H3 — same format, same unit family, and this round shows the
503549 class is not tile-specific and not depth-specific, which narrows it.
504550 - The 4:4:4 **130x122** odd-dimension divergence and the 4:4:4 **superres**
505- divergence are unassigned; neither reduces to a known class on the evidence
506- here, and neither has a discriminator run.
551+ divergence were unassigned here. Both are now closed by
552+ lane-av1444edge: they are **one class — H1**, the 1:4 inter-strip own-chroma-
553+ extent gather at `ss (0,0)`, discriminator-run and fixed by `f92776ba`
554+ (lane-av1444rect), and gated by
555+ `a_444_lossy_rect4_strip_stream_decodes_pixel_exact_at_odd_and_wide_geometries`
556+ — whose second arm is these exact 15239 bytes. The "superres" name in the
557+ row was a mislabel; the stream never scaled. Real 4:4:4 superres coverage
558+ is separate and lives in lane-av1superpin.
507559 - Recorded from Agent13-2 and folded into the matrix above: a hardcoded 4:2:0
508560 luma footprint at the lossless 16x4/4x16 chroma-pair walk
509561 (`Reach::of_tu` mis-answering at `ss 0,0`), same shape class as the wave's
lanes/av1gates444.report.mdadded+173 -0
@@ -0,0 +1,173 @@
1+# lane-av1gates444 — three measured-EXACT 4:4:4 lossy cells, pinned
2+
3+## 1. What this lane is
4+
5+Tests only. `crates/ec-av1/src/decode.rs` is **not** edited in the committed
6+tree (`git diff --stat` on the lane commit: `crates/ec-av1/src/stream.rs | 225
7+insertions(+), 0 deletions`). No new `#[ignore]`. No new `tests/*.rs` file —
8+all three gates live in the existing `ec-av1` lib test binary
9+(`crates/ec-av1/src/stream.rs`, `pub(crate) mod tests`).
10+
11+Branch `lane-av1gates444`, one commit `81f88fd1` on top of `a21f3680`.
12+
13+## 2. The cells, and the recipe that reproduces them
14+
15+The three cells come from `lanes/av1formatsweep.report.md` §6.2 and
16+`lanes/av1444rect.report.md` §8. All three were **EXACT 4/4 with no committed
17+gate**; only the lane report carried the evidence.
18+
19+The sweep's encode is reproduced byte-for-byte. The stream sizes and sha256
20+prefixes below match the sweep's table exactly, which is how the recipe is
21+confirmed rather than approximated:
22+
23+```text
24+ffmpeg -f lavfi -i "testsrc2=size=<W>x<H>:rate=25" -frames:v 4 \
25+ -pix_fmt yuv444p -f yuv4mpegpipe - | \
26+aomenc --codec=av1 --profile=1 --passes=1 --end-usage=q --cq-level=20 \
27+ --cpu-used=2 --threads=1 --row-mt=0 --lag-in-frames=0 \
28+ --kf-max-dist=100 --limit=4 --obu -o - -
29+```
30+
31+| cell | gate | bytes | sha256 | sweep said |
32+|---|---|---|---|---|
33+| odd 66x66 | `a_444_lossy_odd_66x66_stream_decodes_pixel_exact` | 5938 | `973eddf4…` | 5938 / `973eddf4…` |
34+| odd 130x122 | `a_444_lossy_odd_130x122_stream_decodes_pixel_exact` | 8945 | `c87ac65b…` | 8945 / `c87ac65b…` |
35+| 256x128 | `a_444_lossy_256x128_stream_decodes_pixel_exact` | 15239 | `06621606…` | 15239 / `06621606…` |
36+
37+Two flags are load-bearing and both are documented in the gate's doc comment:
38+
39+- `rate=25` — testsrc2's pattern is time-parameterised, so `rate=1` is a
40+ different stream.
41+- `--limit=4` — the sweep's frame count. At `--limit=6` the same recipe emits
42+ 7674 / 11465 / 19121 bytes, i.e. a *different* stream than the one measured.
43+ Measured, not assumed.
44+- `--profile=1` is what makes the source 4:4:4 at all.
45+
46+### 2.1 The third cell is NOT a superres cell
47+
48+The sweep recorded it as "4:4:4 **superres** 256x128 (`--superres-mode=1`)" and
49+`av1444rect` §8 corrected that. Measured here to settle it independently:
50+
51+| encode | bytes | sha256 |
52+|---|---|---|
53+| 256x128 without `--superres-mode=1` | 15239 | `881ab784…` at limit=6 / `06621606…` at limit=4 |
54+| 256x128 **with** `--superres-mode=1` | 15239 | identical |
55+
56+The flag is a no-op on this aomenc build. The gate is therefore named
57+`a_444_lossy_256x128_stream_decodes_pixel_exact` — for its geometry — and the
58+doc comment says so explicitly, so the next lane does not re-derive a superres
59+claim from the sweep's table.
60+
61+## 3. The three gates
62+
63+All three share two helpers in the same file: `encode_444_lossy_live` (ffmpeg
64+y4m → live aomenc, `run_with_stdin` deadline, non-empty-OBU assert) and
65+`gate_444_lossy_live_exact` (the body). Modelled on
66+`a_444_lossy_rect4_inter_stream_decodes_pixel_exact` (stream.rs:7240), with
67+three deliberate differences:
68+
69+1. **No pin.** The stream is encoded live against the oracle aomenc, because
70+ the claim is a property of the decoder at a geometry, not of a blob. The
71+ sweep's byte counts live in the doc comment as the recipe's provenance.
72+2. **The pixel compare cannot be skipped.** The old gate guards it with
73+ `if aomdec_path().is_file()`; these three assert. If aomenc resolved but
74+ no aomdec sits beside it, the gate FAILS rather than reporting green for a
75+ decoder it never looked at (class `gate-blind-to-the-arm`). It still SKIPs
76+ when there is no oracle at all, which `have_aomenc()` turns into a hard
77+ failure under `EC_AV1_REQUIRE_AOMENC=1` — the crate's existing convention.
78+3. **Per-cell geometry, asserted before the compare.** Frame count 4, and per
79+ frame `(f.width, f.height) == (W, H)` plus `f.u.len() == f.v.len() ==
80+ f.y.len() == W*H`. At 4:4:4 a decoder keeping a subsampled extent would
81+ hand quarter-size planes to the byte compare; the gate says which invariant
82+ broke instead of letting the compare stand in for the shape claim.
83+
84+Non-vacuity, per cell: `decode::rect4_inter_own_chroma444_hits() > 0` after a
85+reset — the 4:4:4-only own-chroma-extent route in `decode_inter_block`'s
86+`around_c` that this class is about. A 4:2:0 stream of the same content reads
87+0. Measured **13 / 12 / 24** own-extent gathers at 66x66 / 130x122 / 256x128.
88+
89+## 4. Green (this tree, oracle aomenc + aomdec present)
90+
91+```
92+$ ec_av1 a_444_lossy_odd_66x66_stream_decodes_pixel_exact --nocapture
93+a_444_lossy_odd_66x66_stream_decodes_pixel_exact: 66x66 4:4:4 lossy, 4 decode-order frame(s)
94+ byte-exact vs aomdec (0 hidden), 13 own-extent 1:4 chroma gather(s)
95+test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 714 filtered out
96+
97+$ ec_av1 a_444_lossy_odd_130x122_stream_decodes_pixel_exact --nocapture
98+a_444_lossy_odd_130x122_stream_decodes_pixel_exact: 130x122 4:4:4 lossy, 4 decode-order frame(s)
99+ byte-exact vs aomdec (0 hidden), 12 own-extent 1:4 chroma gather(s)
100+test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 714 filtered out
101+
102+$ ec_av1 a_444_lossy_256x128_stream_decodes_pixel_exact --nocapture
103+a_444_lossy_256x128_stream_decodes_pixel_exact: 256x128 4:4:4 lossy, 4 decode-order frame(s)
104+ byte-exact vs aomdec (0 hidden), 24 own-extent 1:4 chroma gather(s)
105+test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 714 filtered out
106+```
107+
108+Untouched-and-still-green, same binary:
109+
110+```
111+$ ec_av1 a_444_lossy_rect4_inter --test-threads=1 → ok
112+$ ec_av1 unrefreshed_primary_ref_slot --test-threads=1 → ok (the stream.rs source-scan guard)
113+```
114+
115+## 5. Red-before, measured (both mutations reverted, neither committed)
116+
117+### 5.1 `decode.rs` `around_c` own-extent arm → the 4:2:0 pair extent
118+
119+`Some(_) if ss_x(fctx) == 0 => { hit!(…); around }` replaced with the pair
120+gather `neighbours.around_mi_rect(s.pair_mi, pw, ph)` at `(16,8)` HORZ /
121+`(8,16)` VERT. The `hit!` stayed, so the reach assert still fires and the red
122+lands on the pixel arm rather than the counter — the lesson from
123+skill://ec-av1-pipeline-gate-counters.
124+
125+| gate | result |
126+|---|---|
127+| 66x66 | **green** — expected, see 5.3 |
128+| 130x122 | **RED**: decode-order frame 3 of 4, byte 2208 (ours 134 vs oracle 170), **11521 bytes differ** |
129+| 256x128 | **RED**: decode-order frame 2 of 4, byte 192 (ours 92 vs oracle 106), **25296 bytes differ** |
130+
131+The 130x122 number is the sweep's, to the byte: sweep §6.2 said "DIVERGENT
132+from f3, 11521 samples, first (f3, s2208) = Y(128,16)". The 256x128 numbers are
133+`av1444rect` §8's base row ("DIVERGENT f2 25296").
134+
135+### 5.2 `ec-av1-syntax` `compute_image_size` — the mi-grid ceil floored
136+
137+`h.mi_cols = 2 * ((h.frame_width + 7) >> 3)` →
138+`2 * (h.frame_width >> 3)` (and the row line likewise).
139+
140+| gate | result |
141+|---|---|
142+| 66x66 | **RED**: `restoration.rs:783` — "range end index 4098 out of range for slice of length 4096" |
143+| 130x122 | **RED**: decode-order frame 0 of 4, byte 128 (ours 74 vs oracle 170), 22724 bytes differ |
144+| 256x128 | **green**, correctly — 256x128 is a multiple of 8 in both axes, so the ceil and the floor agree and the cell is not supposed to see this mutation |
145+
146+### 5.3 What 66x66 is, stated honestly
147+
148+`odd444_66x66` is a **coverage pin, not a witness for the strip fix**. The
149+sweep measured it EXACT 4/4 on the *pre-fix* base, so mutation 5.1 cannot
150+make it red and no mutation of the strip route ever will. Its
151+load-bearingness is mutation 5.2: it is the only gate here whose geometry is
152+partial in **both** axes, and dropping the mode-info grid's ceil breaks it on
153+the first decode. 130x122 and 256x128 are witnesses for the 4:4:4 lossy
154+strip-own-extent class; 66x66 is the pin for the odd-in-both-axes 4:4:4 lossy
155+walk. Both roles are load-bearing and neither is invented.
156+
157+## 6. Invariants held
158+
159+- `crates/ec-av1/src/decode.rs`: not edited in the committed tree.
160+- Existing gates: not edited — the commit is 225 insertions, 0 deletions, one
161+ file.
162+- Same test binary: `crates/ec-av1/src/stream.rs`, `pub(crate) mod tests`.
163+- No new `#[ignore]`.
164+- Commit message carries the mechanism and the measurements, no host paths.
165+
166+## 7. Not done, stated
167+
168+- The three gates encode on every run, so each costs one ffmpeg + one aomenc
169+ (~0.6 s measured, all three together). If a future lane finds that too
170+ expensive for a loop run, the pin migration is mechanical: the byte counts
171+ and sha256 prefixes are in §2.
172+- Only 8-bit lossy cq-20 is covered. 4:4:4 lossy at 10/12 bits and the tile
173+ cells stay the sweep's open list; nothing here narrows that gap.
lanes/av1lm444loss.report.mdadded+357 -0
@@ -0,0 +1,357 @@
1+# lane-av1lm444loss — H1: 4:4:4 LOSSLESS byte-exactness
2+
3+**Verdict.** Lead (a) **FIXED**: the pinned `ll444_128root_lossless.obu` is now
4+byte-exact on all six frames and its `EC_SYMR` ladder is bit-identical to the
5+oracle (235,940 reads, zero fork; it forked at read 71,322 before). The defect
6+was **not** in the coefficient reader — it was the transform-unit **walk**: a
7+lossless block's TX grid was never clipped at the frame edge, so the decoder
8+read 256 units per inter frame that libaom never codes, and the fork lands on a
9+PLANE change (`plane=0` luma where the oracle had moved to `plane=1` chroma).
10+
11+Lead (b) is **blocked by a separate, pre-existing defect**, diagnosed to a
12+one-line cause in §5. Not this lane's class; not fixed here.
13+
14+**Tree.** `lane-av1lm444loss` off `a21f3680`, worktree `~/.cache/wt/av1lm444loss`.
15+One commit, `7b9f46fa`. Not pushed (Main merges).
16+
17+## 1. Lead (a): reproduction and the first fork
18+
19+`fixtures/ll444_128root_lossless.obu` (63429 bytes, 128x96 yuv444p, 6 frames).
20+Decoded-order dump vs the oracle's `EC_AV1_FINAL_DUMP`, at the base tree:
21+
22+| frame | wrong samples | first differing byte |
23+|---|---|---|
24+| 0 | 0 | — |
25+| 1 | 5596 | 16544 |
26+| 2 | 25693 | 0 |
27+| 3 | 28492 | 0 |
28+| 4 | 32289 | 0 |
29+| 5 | 33561 | 0 |
30+
31+`EC_SYMR` on both sides, one line per `symbol()` call, aligned on
32+`(value, range, symbol, post_rng)`:
33+
34+```
35+index 71321 both mi=(0,0) decodetxb.c:158 (txb_skip) s=1 pre=(35131,51766) post=51766
36+index 71322 ORACLE mi=(0,0) decodetxb.c:158 s=1 pre=(35131,51110) post=49256 cdf0=31697
37+index 71322 OURS mi=(0,0) (luma walk) s=1 pre=(35131,51110) post=50351 icdf0=377
38+```
39+
40+Both sides read the same site and the same 2-class `txb_skip` CDF. The CDF row
41+content diverges (`32768 - 377 = 32391` vs the oracle's pre-adapt `32391` at
42+71321, `31697` at 71322), so this is the two sides being on **different units**,
43+not the same unit read two ways.
44+
45+`EC_COEFF_STEP tag=all_zero` names them:
46+
47+```
48+[3967] ORACLE plane=0 bc=15 br=23 ctx=1 (luma, block row 23 = y 92..95)
49+[3968] ORACLE plane=1 bc=0 br=16 ctx=10 (chroma — the walk moved planes)
50+[3968] OURS side=4 ctx=1 (still luma)
51+```
52+
53+That is the whole story in one line: the oracle finished the luma plane at
54+transform row 24 and moved to chroma; we were still reading luma.
55+
56+## 2. Mechanism: the missing frame-edge clip
57+
58+libaom bounds a block's transform grid by the part of it **inside the frame**:
59+
60+- `max_block_high` / `max_block_wide` (`av1_common_int.h:1579`, `:1565`) start
61+ from `block_size_high/wide[bsize]` and, when `mb_to_bottom_edge` /
62+ `mb_to_right_edge` is negative, add `>> (3 + ss)`, then `>> MI_SIZE_LOG2`.
63+- `mb_to_bottom_edge` is `GET_MV_SUBPEL((mi_rows - bh - mi_row) * MI_SIZE)`
64+ (`set_mi_row_col`, `av1_common_int.h:1360`), so the clip reduces exactly to
65+ the block's extent within the frame, in transform units.
66+- `decode_token_recon_block` then caps every mu chunk with
67+ `unit_height = ROUND_POWER_OF_TWO(AOMMIN(mu_blocks_high + row,
68+ max_blocks_high), ss_y)` — the out-of-frame units are never read.
69+
70+Our decoder already had this exact arithmetic. `read_block_tx_size`'s **var-tx**
71+branch computes it, twenty lines below the lossless branch:
72+
73+```rust
74+let max_w_mi = side_mi.min(mi_cols.saturating_sub(at_mi.1));
75+let max_h_mi = side_mi.min(mi_rows.saturating_sub(at_mi.0));
76+```
77+
78+and `read_var_tx_size` bails on it (`if blk_row >= max_h_mi || blk_col >=
79+max_w_mi { return; }`). The **lossless** branch returned a plain
80+`0..side/MI` square, and so did `read_block_tx_size_rect`'s lossless branch.
81+
82+**The arithmetic, exactly.** Frame 128x96. `side = 128`, so `side / MI = 32`;
83+`mi_rows = 2 * ceil(96/8) = 24`. `max_blocks_high = 128 + (-32 >> 3) = 96`,
84+`>> 2 = 24`. Clipped rows 24, columns 32.
85+
86+| | luma units / frame | chroma units / frame | total |
87+|---|---|---|---|
88+| oracle | 24 x 32 = **768** | 2 x 24 x 32 = **1536** | **2304** |
89+| ours, before | 32 x 32 = **1024** | 1536 | **2560** |
90+
91+The 256-unit excess is exactly the 8 unclipped transform rows x 32 columns past
92+the frame bottom, per inter frame. Chroma was already clipped — the
93+`read_inter_chroma_lossless` loop carries its own
94+`if cpx + ox >= u.true_width || cpy + oy >= u.true_height { continue; }` — which
95+is why only the LUMA side of the walk diverged.
96+
97+## 3. The fix
98+
99+Both lossless leaf builders now clip. `decode.rs`, `read_block_tx_size`:
100+
101+```rust
102+let side_mi = side / MI;
103+let max_w_mi = side_mi.min(mi_cols.saturating_sub(at_mi.1));
104+let max_h_mi = side_mi.min(mi_rows.saturating_sub(at_mi.0));
105+```
106+
107+and `read_block_tx_size_rect` the same over `(bw, bh)`. Two hit counters ride
108+along: `lossless_edge_clipped()` (blocks whose grid the clip shortened) and
109+`lossless_edge_clip_units()` (units removed).
110+
111+**The clip is inert when the block fits** — for any block whose `at_mi + side/MI`
112+is inside the frame, `min` returns `side_mi` and the leaf vector is
113+byte-identical. That is the structural reason 4:2:0 cannot move, and the gate's
114+control arm pins it.
115+
116+### After
117+
118+| measurement | before | after |
119+|---|---|---|
120+| frames byte-exact vs oracle aomdec (decode order) | 1 of 6 | **6 of 6** |
121+| worst frame wrong samples | 33561 | **0** |
122+| `EC_SYMR` reads, ours | 258035 | **235940** |
123+| `EC_SYMR` reads, oracle | 235945 | 235945 |
124+| first `EC_SYMR` fork | read 71322 | **none, all 235940 paired** |
125+
126+## 4. Gate
127+
128+`stream::tests::a_lossless_block_clips_its_transform_grid_at_the_frame_edge`,
129+same fixture as its sibling
130+`a_lossless_444_128_root_lossless_stream_reads_chunks_chunk_major` (96 is not a
131+multiple of the 128 superblock — that is the entire reason this stream is the
132+witness).
133+
134+| # | assertion | value |
135+|---|---|---|
136+| 1 | `lossless_edge_clipped()` delta | **5** = one 128 root per inter frame. Reads 0 on a frame that fits, so a stream that merely decodes cannot satisfy it |
137+| 2 | `lossless_edge_clip_units()` delta | **1280** = 5 x 256 (8 rows x 32 cols removed per root) |
138+| 3 | every sample of all 6 frames vs oracle `aomdec --rawvideo`, decode order | exact |
139+| 4 | control arm (`ll444_minp64_128root_control`): both clip counters | **0 / 0** — the clip is a no-op where blocks fit |
140+
141+### Mutation proof (run, not asserted)
142+
143+Reverting only the two clip expressions to the unclipped grid, keeping the gate
144+and the counters:
145+
146+```
147+=== MUT clip ===
148+test stream::tests::a_lossless_block_clips_its_transform_grid_at_the_frame_edge ... FAILED
149+panicked at crates/ec-av1/src/stream.rs:6924:
150+ the frame-edge clip fired on 0/5 of the 128 roots -- it must be 0 on a frame
151+ that fits, so this is what makes the gate non-vacuous
152+ left: 0 right: 5
153+test result: FAILED. 0 passed; 1 failed
154+SUITE EXIT: 101
155+```
156+
157+Same reverted build, decoded-order dumps vs the oracle — assertion 3's failure
158+mode, captured:
159+
160+```
161+f0: 0 wrong f3: 28492 wrong, first at byte 0
162+f1: 5596 wrong, first at byte 16544 f4: 32289 wrong
163+f2: 25693 wrong, first at byte 0 f5: 33561 wrong
164+```
165+
166+File restored from a saved copy (not `git checkout --`, per
167+`skill://stash-red-before-proof`), re-verified with `diff -q`, then:
168+
169+```
170+=== LIVE ===
171+test ... a_lossless_block_clips_its_transform_grid_at_the_frame_edge ... ok
172+test result: ok. 1 passed; 0 failed
173+EXIT: 0
174+```
175+
176+## 5. Lead (b): blocked by a different defect (not fixed here)
177+
178+`testsrc2 512x128 yuv444p --lossless=1 --cpu-used=2 --lag-in-frames=0
179+--kf-max-dist=100 --limit=6` does **not** reach the entropy fork the ticket
180+describes. It dies first, on the base tree, before and after this fix:
181+
182+```
183+thread 'main' panicked at crates/ec-av1/src/decode.rs:2787:
184+assertion `left == right` failed left: (4, 8) right: (4, 4)
185+ 4: <ec_av1::decode::TxParams>::run
186+ 5: ec_av1::decode::push_mc_rect_tx
187+ 6: ec_av1::decode::read_inter_plane_rect
188+ 7: ec_av1::decode::decode_intrabc_rect
189+ 8: ec_av1::decode::decode_leaf_rect
190+ 9: ec_av1::decode::decode_key_frame_tile_with_cdfs
191+```
192+
193+(release builds wrap the assert and panic one frame later at
194+`decode.rs:2823`, `range end index 4 out of range for slice of length 0`).
195+
196+**Cause, measured.** A temporary env-gated probe at `decode_intrabc_rect`'s
197+residual split:
198+
199+```
200+EC_PROBE_IBC mi=(28,106) bw=8 bh=16 lossless=true leaves=Some(8)
201+```
202+
203+The luma leaves are all TX_4X4 (8 of them, 2 x 4) — the lossless branch is
204+correct. The `(4, 8)` comes from the **chroma** call in the same arm:
205+`decode_intrabc_rect` derives the chroma footprint as
206+`let (cw, ch) = (bw / 2, bh / 2); let (cpx, cpy) = (px / 2, py / 2);` — a
207+hardcoded 4:2:0 halving. At 4:4:4 that block's chroma plane block is 8x16, not
208+4x8, so a **lossless** 4x8 chroma rect transform reaches `TxParams::run`, whose
209+lossless arm requires 4x4 (the Walsh-Hadamard path). Same class the
210+`av1tilerows` lane landed in the lossless 16x4/4x16 chroma-pair walk: a
211+hardcoded 4:2:0-shaped chroma reach at 4:4:4.
212+
213+Confirming it is the whole blocker: the same stream re-encoded with
214+`--enable-intrabc=0` (118365 bytes) decodes on this tree **byte-exact on all six
215+frames** against the oracle aomdec.
216+
217+**Not fixed in this lane.** It is a different defect class from H1, in
218+`decode_intrabc_rect`'s chroma geometry rather than the coefficient reader or
219+the TX-4X4 path this lane owns, and that function carries other lanes' gates
220+(`a_lossless_444_intrabc_rect_leaf_walks_per_4x4_units`,
221+`a_skipped_lossless_intrabc_rect_strip_zeroes_its_entropy_bands`). The shape
222+correction is `bw >> ss_x(fctx)` / `bh >> ss_y(fctx)` on `cw`/`ch`/`cpx`/`cpy`;
223+dispatching it to the intrabc-rect owner is cheaper than widening this lane.
224+
225+Also measured, so nobody re-derives it: the cached `g_512x128_notile.obu`
226+under `~/.cache/h4/` is byte-exact on all 7 decode-order frames on this tree —
227+its recipe carries `--enable-rect-partitions=0`, so it never reaches the
228+intrabc rect route.
229+
230+## 6. Invariants — all green on this tree
231+
232+| group | result |
233+|---|---|
234+| new gate `a_lossless_block_clips_its_transform_grid_at_the_frame_edge` | 1 passed, 0 failed (mutation red, §4) |
235+| all `lossless` + `444` gates (`cargo test -- lossless 444`) | **24 passed / 0 failed** |
236+| 4:2:0 lossless + frame-edge gates (17 scoped: `frame_edge`, `partial`, `edge`, `odd`, `lossless`, non-444) | **17 passed / 0 failed** |
237+| sibling `a_lossless_444_128_root_lossless_stream_reads_chunks_chunk_major` | ok — its parity assertions 2/3 (4 walks, 1536 chroma units per inter frame) are unchanged and still exact |
238+| `cargo check -p ec-av1` | 0 warnings, 0 errors |
239+| source-scan guards | untouched — no `include_str!` anchor was edited; the only test hunks are in `stream.rs`, the only non-test hunks in the two leaf builders plus the two counters |
240+
241+Full-suite validation is Main's; the runs above are the scoped groups this
242+lane's invariant names.
243+
244+## 7. Refutation notes for the reviewer
245+
246+- The reserved 4:2:0 group-tail chroma SKIP arm and `last_intrabc` tails are
247+ outside every hunk — the diff is the two lossless leaf builders, two counters,
248+ two accessors, one gate.
249+- 4:2:0 unreachability is not the argument here and is not claimed: the clip
250+ changes behaviour for **any** subsampling when a lossless block overhangs the
251+ frame. The 4:2:0 argument is the `min` no-op above, pinned by the gate's
252+ control arm and by the 17 scoped 4:2:0 gates.
253+- The clip reuses the var-tx branch's own variables and its own
254+ `mi_cols`/`mi_rows` definition, so it introduces no new notion of the frame
255+ grid. Its only approximation is that `mi_rows` is `2 * ceil(h / 8)` rather
256+ than libaom's floor `h >> 3`; the two agree on every multiple-of-8 height,
257+ which is the fixture's 96, and differ by at most one 4-px transform row
258+ otherwise — the same approximation the shipped var-tx branch already carries.
259+
260+---
261+
262+# Appendix r2 — lead (b): the blocking defect, diagnosed in full
263+
264+Written BEFORE the fix, so the diagnosis survives even if the work stops here.
265+
266+## The line
267+
268+`crates/ec-av1/src/decode.rs`, `decode_intrabc_rect`, line 13065 and line 13070
269+at the base tree:
270+
271+```rust
272+let (cpx, cpy) = (px / 2, py / 2); // line 13065
273+let (cw, ch) = (bw / 2, bh / 2); // line 13070
274+```
275+
276+Both are a **hardcoded 4:2:0 halving**. The chroma plane block's true geometry
277+is `bw >> ss_x(fctx)` x `bh >> ss_y(fctx)` at `(px >> ss_x(fctx),
278+py >> ss_y(fctx))`. At `ss (0,0)` (4:4:4) `ss_x = ss_y = 0`, so every one of
279+those four values is halved when it must not be.
280+
281+## Mechanism
282+
283+`decode_intrabc_rect` serves a 1:4 rect partition inside an IntraBC block. Its
284+chroma arm calls
285+
286+```rust
287+read_inter_plane_rect(dec, cdfs, rect_inter_chroma_set(cw, ch)?, (cw, ch),
288+ cside, plane, around[plane], ...)
289+```
290+
291+with the halved `(cw, ch)`. On a **lossless** block that shape reaches
292+`TxParams::run`, whose lossless arm is the 4x4 Walsh-Hadamard path and carries
293+
294+```rust
295+debug_assert_eq!((self.w, self.h), (4, 4));
296+```
297+
298+So a lossless 4:4:4 rect block whose halved chroma shape is rect (any 1:4
299+strip: 8x16 -> 4x8, 4x32 -> 2x16, ...) asserts. Release builds compile the
300+`debug_assert` out, `dequant_and_inverse_wht4x4` returns a buffer shorter than
301+`w * h`, and the failure surfaces one frame later in the strided residual copy:
302+
303+```
304+thread 'main' panicked at crates/ec-av1/src/decode.rs:2823:59:
305+range end index 4 out of range for slice of length 0
306+```
307+
308+which is the release-mode face of the same defect.
309+
310+## Evidence
311+
312+Recipe `testsrc2 512x128 yuv444p --lossless=1 --cpu-used=2 --lag-in-frames=0
313+--kf-max-dist=100 --limit=6` (121844 bytes), base tree, debug build:
314+
315+```
316+thread 'main' panicked at crates/ec-av1/src/decode.rs:2787:13:
317+assertion `left == right` failed
318+ left: (4, 8)
319+ right: (4, 4)
320+ 4: <ec_av1::decode::TxParams>::run
321+ 5: ec_av1::decode::push_mc_rect_tx
322+ 6: ec_av1::decode::read_inter_plane_rect
323+ 7: ec_av1::decode::decode_intrabc_rect
324+ 8: ec_av1::decode::decode_leaf_rect
325+ 9: ec_av1::decode::decode_key_frame_tile_with_cdfs
326+```
327+
328+A temporary env-gated probe at `decode_intrabc_rect`'s residual split isolates
329+which side is wrong:
330+
331+```
332+EC_PROBE_IBC mi=(28,106) bw=8 bh=16 lossless=true leaves=Some(8)
333+```
334+
335+`leaves=Some(8)` with `bw=8, bh=16` is **2 x 4 = 8 TX_4X4 units** — the lossless
336+leaf builder is CORRECT and produced no rect luma unit at all. The `(4, 8)` in
337+the assert therefore cannot be luma. At 4:4:4 this block's chroma plane block is
338+8x16; the hardcoded halving turns it into 4x8, which is exactly the `left`
339+value in the assert. `ss_x = ss_y = 0`, so `(bw >> ss_x, bh >> ss_y)` is a
340+no-op there and `(bw / 2, bh / 2)` is a pure error.
341+
342+Confirming it is the ONLY blocker on this stream: the identical recipe re-encoded
343+with `--enable-intrabc=0` (118365 bytes, which never routes through
344+`decode_intrabc_rect`) decodes on this tree **byte-exact against the oracle
345+aomdec on all six frames**. So the 18779 -> 130708 damage and the 459866 vs
346+369136 `EC_SYMR` asymmetry the sweep recorded are behind this line, not
347+independent of it.
348+
349+## Class and ownership
350+
351+Same class `av1tilerows` landed in the lossless 16x4/4x16 chroma-pair walk: a
352+hardcoded 4:2:0-shaped chroma reach at 4:4:4. `decode_intrabc_rect` is a
353+different function from the one that lane fixed and carries its own gates
354+(`a_lossless_444_intrabc_rect_leaf_walks_per_4x4_units`,
355+`a_skipped_lossless_intrabc_rect_strip_zeroes_its_entropy_bands`), which is why
356+r1 reported rather than fixed it. Appendix r3 takes it on, on this branch, with
357+those gates as the blast-radius check.
lanes/av1mergecheck.report.mdadded+177 -0
@@ -0,0 +1,177 @@
1+# lane-av1mergecheck — do the queued lanes' new gates run from a CLEAN CHECKOUT?
2+
3+Base for every diff: `main` = `a21f3680` (merge-base per branch). Nothing in the primary
4+checkout was edited; every run happened in a `git archive` materialisation under
5+`~/.cache/wt/av1mc/<branch>/`.
6+
7+## Verdict
8+
9+**All 13 queued lanes' new gates run and pass from a clean checkout of their own branch.**
10+No untracked fixture, no absolute-path dependency, no environment escape hid a gate.
11+Two gates are `#[ignore]`d and therefore do NOT run in a normal suite invocation
12+(lane-av1pins) — that is a claim/behaviour mismatch in that lane's report, not a broken
13+gate: both pass under `--ignored`. One lane ref name in the ticket does not exist
14+(`lane-av1444edge`); its content is parked at `lane-park-av1444edge` / `a02a2511`.
15+
16+39 gates were run. 37 passed in a plain run, 2 more passed under `--ignored`,
17+0 reported `0 passed; N filtered out`.
18+
19+## Method (identical for every branch)
20+
21+1. `git archive <tip> | tar -x -C ~/.cache/wt/av1mc/<branch>` — tracked files only.
22+2. `git init` in that dir (empty; the `.cargo/config.toml` test runner resolves
23+ `scripts/memguard-runner.sh` through `git rev-parse --show-toplevel`, which fails
24+ outside a repo) and `ln -s <primary>/fixtures <dir>/fixtures` (root `fixtures/` is
25+ gitignored, so its absence from a clean checkout is expected, not the finding).
26+3. Every fixture referenced by the branch's new source lines checked with
27+ `git ls-tree -r <tip> -- crates/ec-av1/fixtures/`.
28+4. `cargo test --release -p ec-av1 --lib --no-run`, then the produced test binary invoked
29+ ONCE PER GATE with `--exact <module::tests::name> --nocapture --test-threads=1`, under
30+ `EC_AV1_REQUIRE_FFMPEG=1 EC_AV1_REQUIRE_AOMENC=1 EC_REQUIRE_FIXTURES=1`.
31+ One filter per invocation; no repeated `--exact`.
32+5. Every gate then re-run a second time with the root `fixtures/` symlink DELETED, to
33+ separate "the pin is committed in the crate" from "the gate found the gitignored root".
34+
35+Environment notes, stated so the numbers are reproducible:
36+- `EC_NOMEMGUARD=1` (see finding F3 — the memguard scope collided, not the gates).
37+- Release profile, per-branch `CARGO_TARGET_DIR=$HOME/.cache/cargo-target/av1mc/<branch>`.
38+- Oracles: `/usr/bin/ffmpeg` and `~/.cache/aom-oracle/build/aomenc` (the latter is NOT on
39+ `PATH` on this box; `aomenc_path()` falls back to it).
40+
41+## Per-gate table
42+
43+`clean` = run from the `git archive` checkout. `no-root-fixtures` = same run with the
44+symlinked gitignored root `fixtures/` removed.
45+
46+| branch (tip) | gate (`module::tests::name`) | clean checkout | what it printed | pin tracked | no-root-fixtures |
47+|---|---|---|---|---|---|
48+| lane-av1chrtx (ff7cf47c) | `stream::tests::a_pinned_444_rect_inter_stream_resolves_each_chroma_unit_from_its_own_luma_leaf` | ok, 1 passed (0.06s) | 4 decode-order frames byte-exact vs aomdec; per-leaf tx_type arm counts | yes (`444_rect_strip_leaf_tx_type.obu`) | ok |
49+| lane-av1chrtx | `decode::tests::covering_leaf_tx_type_picks_the_leaf_under_the_unit_or_reports_none` | ok, 1 passed | unit tests only, no fixture | n/a | ok |
50+| lane-av1gates444 (555c83f3) | `stream::tests::a_444_lossy_odd_66x66_stream_decodes_pixel_exact` | ok, 1 passed (0.30s) | live aomenc encode, byte-exact vs ffmpeg | n/a (live encode) | ok |
51+| lane-av1gates444 | `stream::tests::a_444_lossy_odd_130x122_stream_decodes_pixel_exact` | ok, 1 passed (0.58s) | same shape, odd 130x122 | n/a | ok |
52+| lane-av1gates444 | `stream::tests::a_444_lossy_256x128_stream_decodes_pixel_exact` | ok, 1 passed (0.98s) | same shape, 256x128 | n/a | ok |
53+| lane-av1skipfix (b696d485) | `stream::tests::a_real_aomenc_filter_intra_stream_decodes_pixel_exact` | ok, 1 passed (0.54s) | attempt-loop gate buckets, no SKIP | n/a | ok |
54+| lane-av1skipfix | `stream::tests::a_real_aomenc_intra_stream_with_deblocking_decodes_pixel_exact` | ok, 1 passed | buckets; deblock edges counted | n/a | ok |
55+| lane-av1skipfix | `stream::tests::a_real_aomenc_inter_sequence_with_deblocking_decodes_pixel_exact` | ok, 1 passed | buckets; deblock edges counted | n/a | ok |
56+| lane-av1skipfix | `stream::tests::a_real_libaom_gradients_stream_with_cdef_decodes_pixel_exact` | ok, 1 passed | buckets; cdef_idx read | n/a | ok |
57+| lane-av1skipfix | `stream::tests::a_real_aomenc_lossless_444_key_frame_decodes_sample_exact` | ok, 1 passed (0.15s) | reads the committed pin via `CARGO_MANIFEST_DIR`, size+fnv asserted | yes (`ll444_lossless_key.obu`) | ok |
58+| lane-av1skipfix | `refusal_inventory::tests::gates_that_swallow_a_decode_error_are_declared` | ok, 1 passed | empty inventory holds | n/a | ok |
59+| lane-av1superpin (9646f74d) | `stream::tests::a_444_lossy_rect4_inter_stream_decodes_pixel_exact` | ok, 1 passed (0.26s) | frames byte-exact vs aomdec | yes (`444_lossy_rect4_inter_witness.obu`) | ok |
60+| lane-av1superpin | `stream::tests::a_444_lossy_rect4_strip_stream_decodes_pixel_exact_at_odd_and_wide_geometries` | ok, 1 passed | 1:4 chroma gather + inter strip counts for both geometries | yes (`…_odd_130x122`, `…_wide_256x128`) | ok |
61+| lane-av1superpin | `stream::tests::a_444_lossy_superres_stream_decodes_pixel_exact` | ok, 1 passed | d12 pin, upscale counts | yes (`444_lossy_superres_256x128_d12.obu`) | ok |
62+| lane-av1superpin | `stream::tests::a_444_lossy_superres_mode1_den9_stream_decodes_pixel_exact` | ok, 1 passed | d9 pin | yes (`…_d9.obu`) | ok |
63+| lane-av1superpin | `stream::tests::a_444_lossy_superres_mode2_random_denom_stream_decodes_pixel_exact` | ok, 1 passed (4.3s) | per-frame (denom, coded) table | yes (`…_mode2_256x128.obu`) | ok |
64+| lane-av1superhbd (a2da03e4) | `stream::tests::a_444_lossy_superres_10bit_d12_stream_decodes_pixel_exact` | ok, 1 passed | 10-bit superres | yes (`…_d12_10bit.obu`) | ok |
65+| lane-av1superhbd | `stream::tests::a_444_lossy_superres_12bit_d12_stream_decodes_pixel_exact` | ok, 1 passed | 12-bit superres | yes (`…_d12_12bit.obu`) | ok |
66+| lane-av1superhbd | `stream::tests::a_444_lossy_superres_12bit_d9_stream_decodes_pixel_exact` | ok, 1 passed | 12-bit d9 | yes (`…_d9_12bit.obu`) | ok |
67+| lane-av1superhbd | `stream::tests::a_444_lossy_superres_10bit_mode2_random_denom_stream_decodes_pixel_exact` | ok, 1 passed | 10-bit mode 2 | yes (`…_mode2_…_10bit.obu`) | ok |
68+| lane-av1superhbd | `stream::tests::a_444_lossy_superres_12bit_mode2_random_denom_stream_decodes_pixel_exact` | ok, 1 passed | 12-bit mode 2 | yes (`…_mode2_…_12bit.obu`) | ok |
69+| lane-av1pins (44a05b40) | `stream::tests::pinned_golden3_stream_decodes_pixel_exact` | **ignored** (`0 passed; 1 ignored`) — see F1; **1 passed** with `--ignored` | `4 frame(s) byte-exact vs ffmpeg from …/crates/ec-av1/fixtures/golden3-pin.obu` | yes (`golden3-pin.obu`) | ok (with `--ignored`) |
70+| lane-av1pins | `stream::tests::pinned_sbpart_stream_decodes_pixel_exact` | **ignored** — see F1; **1 passed** with `--ignored` | quiet pass; pin read, per-SB mismatch walk | yes (`sbpart-pin.obu`) | ok (with `--ignored`) |
71+| lane-av1pins | `stream::tests::a_real_aomenc_lossless_444_key_frame_decodes_sample_exact` | ok, 1 passed (0.39s) | committed pin, no SKIP | yes (`ll444-lossless-key.obu`) | ok |
72+| lane-av1distwtd (1aaf7e0b) | `gate_coverage::tests::the_detector_sees_the_gates_the_spelling_filter_missed` | ok, 1 passed | detector finds the renamed gates | n/a | ok |
73+| lane-av1distwtd | `stream::tests::a_distance_weighted_compound_stream_decodes_pixel_exact` | ok, 1 passed (1.6s) | byte-exact vs oracle | n/a (live encode) | ok |
74+| lane-av1lm444loss (9249442f) | `stream::tests::a_lossless_block_clips_its_transform_grid_at_the_frame_edge` | ok, 1 passed (0.07s) | edge-clip counters | yes (`ll444_128root_lossless.obu`, `ll444_minp64_128root_control.obu`) | ok |
75+| lane-whtshape (f541d062) | `stream::tests::a_444_lossless_sb64_intrabc_rect_chroma_walks_4x4_units` | ok, 1 passed | 4x4 chroma unit walk counters | yes (`ll444_sb64_1to4_lossless.obu`) | ok |
76+| lane-whtshape | `transform::lossless_tx_tests::a_non_4x4_lossless_unit_is_the_raster_of_4x4_wht_units` | ok, 1 passed | unit test, no fixture | n/a | ok |
77+| lane-whtshape | `transform::lossless_tx_tests::a_lossless_split_whose_other_tiles_are_all_zero_still_reconstructs` | ok, 1 passed | unit test | n/a | ok |
78+| lane-whtshape | `transform::lossless_tx_tests::the_4x4_lossless_fast_path_is_unchanged` | ok, 1 passed | unit test | n/a | ok |
79+| lane-whtshape | `transform::lossless_tx_tests::a_non_4x4_all_zero_lossless_unit_keeps_the_empty_marker` | ok, 1 passed | unit test | n/a | ok |
80+| lane-av1tilemeasure (df1370dd) | `stream::tests::a_real_aomenc_12bit_stream_with_two_tile_rows_and_a_two_by_two_tile_grid_decodes_pixel_exact` | ok, 1 passed (3.1s) | frame-facts table, 2 tile rows + 2x2 grid | n/a (live encode) | ok |
81+| lane-av1tilemeasure | `stream::tests::a_real_aomenc_444_superres_stream_at_8_10_and_12_bit_decodes_pixel_exact` | ok, 1 passed (3.4s) | three bit depths, frame-facts table | n/a | ok |
82+| lane-av1tilemeasure | `stream::tests::a_real_aomenc_444_partial_and_odd_coded_dimension_streams_decode_pixel_exact` | ok, 1 passed (4.8s) | partial/odd coded dims | n/a | ok |
83+| lane-av1tilemeasure | `stream::tests::a_lossless_444_8bit_untiled_control_and_its_two_tile_column_sibling_decode_pixel_exact` | ok, 1 passed (1.9s) | control + 2 tile columns | n/a | ok |
84+| lane-av1dualfilter10 (c2b969c8) | `gate_coverage::tests::the_detector_sees_the_gates_the_spelling_filter_missed` | ok, 1 passed | detector | n/a | ok |
85+| lane-av1dualfilter10 | `stream::tests::a_real_aomenc_10bit_dual_filter_obmc_8x8_inter_sequence_decodes_pixel_exact` | ok, 1 passed (2.9s) | 10-bit dual filter + OBMC 8x8 | n/a | ok |
86+| lane-av1dualfilter10 | `stream::tests::a_distance_weighted_compound_stream_decodes_pixel_exact` | ok, 1 passed (1.8s) | (carried from lane-av1distwtd) | n/a | ok |
87+| lane-av1mutproof (ffd8d138) | `stream::tests::a_lossless_444_10bit_inter_stream_decodes_pixel_exact` | ok, 1 passed (0.47s) | report-only lane; the gate itself is on main | n/a | ok |
88+| lane-av1mutproof | `stream::tests::a_444_12bit_inter_sequence_decodes_pixel_exact` | ok, 1 passed (1.3s) | report-only lane | n/a | ok |
89+| lane-park-av1444edge = `a02a2511` | `stream::tests::a_444_lossy_rect4_strip_stream_decodes_pixel_exact_at_odd_and_wide_geometries` | ok, 1 passed (0.15s) | `444_lossy_rect4_odd_130x122.obu` / `…_wide_256x128.obu` byte-exact vs aomdec | yes | ok |
90+| lane-park-av1444edge | `stream::tests::a_444_lossy_superres_random_mode_ignores_the_denominator_flag` | ok, 1 passed (5.5s) | per-frame `(denom, coded) [(11,186),(14,146),(15,137),(9,228)]`, 2265 scaled MC blocks | yes (`444_lossy_superres_random_256x128.obu`) | ok |
91+| lane-park-av1444edge | `stream::tests::a_444_lossy_superres_stream_decodes_pixel_exact` | ok, 1 passed (0.17s) | d12 pin | yes (`…_256x128_d12.obu`) | ok |
92+
93+## Ranked findings
94+
95+### F1 — lane-av1pins: two gates are `#[ignore]`d, so they do not run in a suite; the report's table says they do
96+
97+`pinned_golden3_stream_decodes_pixel_exact` (stream.rs:22048) and
98+`pinned_sbpart_stream_decodes_pixel_exact` (stream.rs:37804) both carry
99+`#[ignore = "bisect aid, not a suite gate; run it with --ignored"]`. A plain
100+`cargo test -p ec-av1` run reports `0 passed; 1 ignored` for each. The lane report's
101+before/after table (`lanes/av1pins.report.md` §2) records their after-state as
102+**`1 passed`, 0.15s / 0.15s**, which is only true under `--ignored`; the same report's
103+prose says they "stay ignored". Both readings cannot be true, and the table is the one a
104+merge reader copies.
105+
106+Both gates DO pass from a clean checkout with `--ignored`, and both pins are committed
107+(`golden3-pin.obu` 159 B, `sbpart-pin.obu` 238 B) and are read through the crate's own
108+`fixtures/` dir — the pin work landed correctly; only the run shape is off.
109+
110+**Fix for the merge owner (pick one, do not do both):**
111+- *Preferred:* drop the two `#[ignore]` attributes in `crates/ec-av1/src/stream.rs`.
112+ The whole point of the lane was that a pin living only in the gitignored root made
113+ these gates silently green; now that the pins are committed and proven to pass in
114+ 0.15–0.18s, un-ignoring them is what turns the commit into a gate. Then correct the
115+ report's table header to say they run in the suite.
116+- *Minimal:* keep `#[ignore]` and correct the `lanes/av1pins.report.md` §2 table to read
117+ `1 ignored (1 passed with --ignored)` for both rows, so the table stops over-claiming.
118+
119+### F2 — the ticket's `lane-av1444edge` ref does not exist; its content is parked, and its gate names differ from lane-av1superpin's
120+
121+There is no branch named `lane-av1444edge`. `a02a2511` is contained in exactly one
122+branch, `lane-park-av1444edge`. Its superres gate is
123+`a_444_lossy_superres_random_mode_ignores_the_denominator_flag`, and its pin is
124+`444_lossy_superres_random_256x128.obu` — **not** the
125+`a_444_lossy_superres_mode1_den9_…` / `…_mode2_random_denom_…` pair that
126+`lane-av1superpin` carries with `…_d9.obu` / `…_mode2_256x128.obu`. Any merge plan that
127+treats these as the same branch will either find no ref or expect gate names that do not
128+exist at `a02a2511` (running them there yields `0 passed; 707 filtered out`).
129+
130+**Fix for the merge owner:** sequence `lane-park-av1444edge` (`a02a2511`) and
131+`lane-av1superpin` (`9646f74d`) as two lanes with a known overlap — both touch
132+`stream.rs` superres gates and both add a `444_lossy_superres_*` fixture family. If only
133+one is to land, say which; if both, expect a conflict in the superres gate block.
134+
135+### F3 — infrastructure (not a lane): the `.cargo/config.toml` memguard runner breaks under parallel test invocations
136+
137+The first wave of 13 concurrent branch runs produced spurious
138+`rc=1` with `Failed to start transient scope unit: Unit run-pNNNN.scope was already
139+loaded or has a fragment file` on 8 gates — a harness failure, not a gate failure
140+(the same gates pass on re-run). It is exactly the collision mode
141+`scripts/memguard-runner.sh` documents for its `--unit` argument, still reachable via
142+the `systemd-run` scope-name exhaustion when many runners start at once. This lane
143+worked around it with `EC_NOMEMGUARD=1`. Worth a note to whoever runs the post-merge
144+suite: a red `rc=1` with that message is a runner collision, and re-running is the
145+correct response.
146+
147+### Non-findings, recorded so they are not re-litigated
148+
149+- **`0 passed; N filtered out` is the fake-green signature and it appeared ZERO times
150+ after names were corrected.** Two naming traps bit this lane's first pass and both
151+ produced exactly that line with `rc=0`: (a) unit-test names carry **no crate prefix** —
152+ the filter is `stream::tests::name`, not `ec_av1::stream::tests::name`; (b)
153+ `lane-whtshape`'s four WHT tests live in a nested module —
154+ `transform::lossless_tx_tests::…`, not `transform::tests::…`. Anyone re-running these
155+ gates by hand should copy the name from `<binary> --list`, not from the report.
156+- **No gate printed `SKIP` anywhere in any run**, under
157+ `EC_AV1_REQUIRE_FFMPEG=1 EC_AV1_REQUIRE_AOMENC=1 EC_REQUIRE_FIXTURES=1`. The
158+ skipfix conversion (four attempt-loop gates) and the committed-pin rewiring hold in a
159+ clean tree.
160+- **Every pin the new gates read is tracked in its own branch.** The only
161+ `NOT-TRACKED` `.obu` strings in the diffs are encode scratch files (`out.obu`,
162+ `in.obu`, `ec-av1-deblocking-gate-fail.obu`) and the legacy hyphenated
163+ `ll444-lossless-key.obu`, which skipfix deliberately replaced with the committed
164+ underscore-named `ll444_lossless_key.obu` (and which lane-av1pins commits separately).
165+- **No absolute paths, no machine-specific dependencies.** With the root `fixtures/`
166+ symlink deleted, all 39 gates still pass (the 2 ignored ones under `--ignored`), so
167+ every one of them resolves its bytes from committed files inside the branch.
168+
169+## Reproduction
170+
171+```
172+S=$HOME/.cache/av1mergecheck/run.sh
173+$S <branch> <tip> stream::tests::<gate> [more gates...]
174+# archive + git init + fixtures symlink, build --release -p ec-av1 --lib,
175+# then one `<test-binary> --exact <gate>` invocation per gate, log at
176+# ~/.cache/wt/av1mc/<branch>.log, test-name list at ~/.cache/wt/av1mc/<branch>.list
177+```
lanes/av1mutproof.report.mdadded+43 -0
@@ -0,0 +1,43 @@
1+# lane-av1mutproof — targeted mutation proof for two declared-debt gates
2+
3+Base: `a21f3680`. Branch: `lane-av1mutproof`. Tree: `~/.cache/wt/mutproof`.
4+
5+Debt (lanes/av1formatsweep.report.md): two 4:4:4 >8-bit gates carried only the
6+oracle byte-compare plus header/counter non-vacuity, so neither was shown to bite
7+the decoder site its cell depends on. This lane proves each one, at the site the
8+cell's own doc comment names — not a nearby helper.
9+
10+## Result: both gates bite. No blind gate, no source change.
11+
12+| gate | mutated site (file:line) | observed failure output | reverted-green output |
13+|---|---|---|---|
14+| `a_lossless_444_10bit_inter_stream_decodes_pixel_exact` | `crates/ec-av1/src/decode.rs:11765` — `let (cu_x, cu_y) = (cpx + cu_col * 4, cpy + cu_row * 4);` mutated to `cu_col * 8`, the x stride of the per-4x4 chroma unit walk that is the gate's own `rect_split_lossless_chroma444_hits()` site (doc: "the per-4x4 chroma unit walk a lossless HORZ/VERT strip takes at subsampling 0/0"). Real arithmetic (unit x offset), not an added assertion. | `panicked at crates/ec-av1/src/stream.rs:8758:17:`<br>`a_lossless_444_10bit_inter_stream_decodes_pixel_exact: decode-order frame 0 of 6 (6 shown, 0 hidden) differs from the oracle at byte 37000 (ours 0 vs 192), 8613 bytes differ`<br>`test result: FAILED. 0 passed; 1 failed` | `a_lossless_444_10bit_inter_stream_decodes_pixel_exact: 6 frames byte-exact vs aomdec at 10-bit 4:4:4`<br>`test result: ok. 1 passed; 0 failed` |
15+| `a_444_12bit_inter_sequence_decodes_pixel_exact` | `crates/ec-av1/src/mc.rs:55` — `round_delta`: `bd.saturating_sub(10)` → `bd.saturating_sub(9)`. This is the 12-bit-only arithmetic behind the gate's `mc::mc_subpel_hits()` claim ("the 12-bit round pair", 3/11 at 8 and 10 bits, 5/9 at 12): at 12 bits it shifts the pair to 6/8 and at ≤10 bits it is a no-op, so the mutation is specific to this cell. | `panicked at crates/ec-av1/src/stream.rs:8758:17:`<br>`a_444_12bit_inter_sequence_decodes_pixel_exact: decode-order frame 0 of 6 (6 shown, 0 hidden) differs from the oracle at byte 24584 (ours 109 vs 110), 2426 bytes differ`<br>`test result: FAILED. 0 passed; 1 failed` | `a_444_12bit_inter_sequence_decodes_pixel_exact: 6 frames byte-exact vs aomdec at 12-bit 4:4:4`<br>`test result: ok. 1 passed; 0 failed` |
16+
17+Both failures are pixel-level, on frame 0, inside the byte-compare — i.e. each
18+gate's oracle compare itself is shown live, not just its header/counter arms.
19+
20+## Method notes (two traps hit, both caught)
21+
22+1. **The mutation must be in the tree cargo actually builds.** The first
23+ `decode.rs` edit landed in the primary checkout (`edith_codecs`) because the
24+ edit tool's cwd is the session repo, not the worktree — the test then ran
25+ green on an unmutated worktree and looked like a blind gate. Reverted the
26+ primary checkout immediately (`git status` clean) and re-applied with an
27+ absolute worktree path. Lesson: in a worktree lane, verify
28+ `grep <mutation> <worktree-path>` before reading a green run as a finding.
29+2. **A stale binary silently returns "no failure".** `round_delta`'s first
30+ mutated run printed no `Compiling` line (mtime unchanged) and reported green.
31+ `touch crates/ec-av1/src/mc.rs` forced the rebuild, which then failed as
32+ expected. Lesson: treat a mutation run without a `Compiling` line as
33+ inconclusive, not as a surviving mutation.
34+3. Local runs use `EC_NOMEMGUARD=1 CARGO_TARGET_DIR=$HOME/.cache/cargo-target`
35+ and `scripts/memguard-runner.sh` copied into the worktree (per
36+ skill://edith-worktree-memguard-runner); `EC_AV1_REQUIRE_AOMENC=1` so a
37+ missing oracle cannot SKIP the gates into a false green.
38+
39+## Committed artifacts
40+
41+`lanes/av1mutproof.report.md` only. No source change survives; both gates are
42+sensitive to their cell's site, so no "sensitive to" comment was needed in
43+either gate body.
lanes/av1pins.report.mdadded+204 -0
@@ -0,0 +1,204 @@
1+# lane-av1pins — recover three lost pins, correct a stale blocker comment, measure the mandelbrot claim
2+
3+Branch `lane-av1pins`, worktree `~/.cache/wt/av1pins`, base `a21f3680` (the merged
4+seven-lane main). Comment, fixture and test changes only — **no decoder logic**.
5+Commits: `78c805bd` (pins + gate rewiring + comment correction), plus this report.
6+
7+The headline is that the third of those reversed my own prior conclusion: the
8+mandelbrot blocker is measurably **cleared**, and the comment that recorded it as
9+the live blocker was the stale artefact, not the `#[ignore]` string.
10+
11+---
12+
13+## 0. The root cause, which is structural and not per-pin
14+
15+`.gitignore:2` is a bare `fixtures`, which git matches at **any depth** — so it
16+covers `crates/ec-av1/fixtures/` too, not just the root. The 48 pins already
17+tracked there were force-added. Any *new* pin therefore has to be `git add -f`'d
18+or it is silently uncommittable, and any pin written to the root `fixtures/` is
19+uncommittable by construction.
20+
21+`pin_dir()` resolves to the root (`../../fixtures`, gitignored), which is where
22+all three dead pins were written. `lanes/av1skipfix.report.md` had already
23+recorded this and had listed exactly these three as "missing on this box". So the
24+diagnosis predates this lane; what was missing was the recovery.
25+
26+The fix is `crate_pin(name)` (`crates/ec-av1/src/stream.rs:8670`): prefer the
27+committed `crates/ec-av1/fixtures/<name>`, fall back to `pin_dir()` so a locally
28+re-captured stream still overrides. The committed copy is what runs by default.
29+
30+---
31+
32+## 1. Recovered pins
33+
34+| path | sha256 | size |
35+|---|---|---|
36+| `crates/ec-av1/fixtures/golden3-pin.obu` | `11c9d5331cffa6614c8265ad5fa685d5ce9155db8439949b48ec4a652ace95cf` | 159 B |
37+| `crates/ec-av1/fixtures/sbpart-pin.obu` | `62238fc077f45d89745d4d254b9c0465464003529da3b42d0a65631fbb7e16e9` | 238 B |
38+| `crates/ec-av1/fixtures/ll444-lossless-key.obu` | `f496ef0a1171c2bc66d411cc60db05db547dcdb49cd834d4e0543de9db441374` | 7845 B |
39+
40+All three from `aomenc` (`~/.cache/aom-oracle/build/aomenc`), all `--threads=1 --row-mt=0`.
41+
42+### golden3-pin.obu — FRESH capture, with a numeric tie to its source gate
43+
44+Source: `gradients_source(42, 64, 64, "duration=0.16:rate=25")` (c0..c3 from the
45+crate's `hash_color`, `seed=42` passed through) via ffmpeg `-pix_fmt yuv420p -f
46+yuv4mpegpipe`; then aomenc:
47+
48+ --codec=av1 --passes=1 --end-usage=q --cq-level=55 --cpu-used=0
49+ --lag-in-frames=0 --auto-alt-ref=0 --kf-max-dist=1000 --threads=1 --row-mt=0
50+ --enable-order-hint=0 --enable-warped-motion=0 --enable-obmc=0
51+ --enable-masked-comp=0 --enable-interintra-comp=0 --enable-dist-wtd-comp=0
52+ --enable-diff-wtd-comp=0 --enable-onesided-comp=0 --enable-interintra-wedge=0
53+ --enable-smooth-interintra=0 --enable-rect-partitions=0 --enable-ab-partitions=0
54+ --enable-1to4-partitions=0 --enable-filter-intra=0 --enable-smooth-intra=0
55+ --enable-paeth-intra=0 --enable-directional-intra=0 --enable-angle-delta=0
56+ --enable-tx-size-search=0 --enable-cdef=0 --enable-restoration=0
57+ --max-partition-size=32 --enable-palette=0 --enable-intrabc=0
58+ --enable-cfl-intra=0 --enable-ref-frame-mvs=0 --obu
59+
60+The tie to the source gate is a number, not a claim. The live
61+`a_real_aomenc_inter_sequence_with_cdf_forwarding_decodes_pixel_exact` prints
62+`cdfflake attempt seed=42: ... stream_hash=89c4089148d51c04 ...`. This re-encode's
63+FNV-1a-64 is **`89c4089148d51c04`** — identical, same 159 bytes.
64+
65+**Fresh capture, not a replay; the original is unrecoverable.** The original was
66+taken at `bec27414` (2026-08-28); `gradients_source` only became byte-reproducible
67+at `5ae053d3` (2026-08-30). `git merge-base --is-ancestor bec27414 5ae053d3` is
68+true, so at capture time the source left `c4..c7` to ffmpeg's `random` default —
69+those bytes cannot be regenerated by any re-encode. What is recovered is a
70+same-family stream the gate decodes and compares exact. The gate's doc comment
71+says so, so nobody later reads it as a replay.
72+
73+### sbpart-pin.obu — FRESH capture from the source gate's recipe
74+
75+`smptebars=size=192x128:rate=25`, `-t 0.04 -pix_fmt yuv420p -f yuv4mpegpipe`, then
76+
77+ aomenc --codec=av1 --passes=1 --end-usage=q --cq-level=55 --cpu-used=4
78+ --threads=1 --row-mt=0 --sb-size=64 --enable-palette=1
79+ --min-partition-size=16 --max-partition-size=64 --obu
80+
81+The source gate's size list is `[(64,128),(128,64),(128,128),(128,192),(192,192)]`
82+— it has **no 192x128 cell**, while `pinned_sbpart_stream_decodes_pixel_exact`
83+compares at 192x128. So this is a 192x128 re-run of that recipe, not a cell of it;
84+recorded in the gate's doc comment. cq 55 chosen from a 7-cq sweep (15, 25, 63
85+also pass).
86+
87+### ll444-lossless-key.obu — replay of the recipe the gate's own SKIP line records
88+
89+`testsrc2=s=128x96:r=25`, `-frames:v 6 -pix_fmt yuv444p -f yuv4mpegpipe`, then
90+
91+ aomenc --codec=av1 --profile=1 --lossless=1 --enable-palette=0
92+ --enable-intrabc=0 --bit-depth=8 --input-bit-depth=8 --passes=1
93+ --end-usage=q --cq-level=20 --cpu-used=0 --threads=1 --row-mt=0
94+ --lag-in-frames=0 --kf-max-dist=100 --limit=1 --obu
95+
96+The recorded remedy was "6 frames ... cut to the key frame's OBUs". `--limit=1`
97+gives the same result without OBU surgery: aomenc emits the key frame and stops,
98+and the gate asserts `ours.len() == 1` anyway. `testsrc2` is deterministic, so
99+this one is a genuine replay.
100+
101+---
102+
103+## 2. Before / after, per gate
104+
105+All runs `--release`, `--test-threads=1`, oracle present.
106+
107+| gate | before | after |
108+|---|---|---|
109+| `pinned_golden3_stream_decodes_pixel_exact` | `SKIP ... no pinned bytes`, **0.00s**, `rc=0` | `1 passed`, **0.15s**, prints `4 frame(s) byte-exact vs ffmpeg from .../crates/ec-av1/fixtures/golden3-pin.obu` |
110+| `pinned_sbpart_stream_decodes_pixel_exact` | `SKIP ... no pinned bytes`, **0.00s**, `rc=0` | `1 passed`, **0.15s**; `EC_SBPART_DIAG=1`: `DIAG frame 0: 0 luma mismatches, bbox ... of 192x128` + per-SB-column counts for cols 0..64, 64..128, 128..192 |
111+| `a_real_aomenc_lossless_444_key_frame_decodes_sample_exact` | `SKIP ... no pinned bytes`, **0.05s**, `rc=0` | `1 passed`, **0.11s** |
112+
113+**Real work, not a stop-skipping — three independent proofs.**
114+
115+1. *Self-evidencing output.* sbpart's `EC_SBPART_DIAG` walks all `192*128 =
116+ 24576` luma samples and reports per-superblock-column mismatch counts.
117+ golden3 prints its frame count and the path it read. A skip prints none of it.
118+2. *Non-vacuity assertions that had to hold.* ll444 passes `assert!(lossless)` on
119+ the parsed frame header **and** `assert!(rect_split_lossless_chroma444_hits() >
120+ before)` — the 4:4:4 chroma rect-split walk provably ran, or the gate would be
121+ red. That is what makes it a verdict rather than a decode.
122+3. *Mutation.* One byte flipped mid-pin turns all three RED: golden3
123+ `stream.rs:5106` (`left: 12288, right: 24576`), sbpart `stream.rs:5099`, ll444
124+ `stream.rs:6537`. **Stated precisely:** these die in the *ffmpeg decode* step,
125+ not the pixel compare — a bit-flipped arithmetic-coded stream does not decode.
126+ So the mutation proves the bytes are READ and PROCESSED (a skip returns `ok` at
127+ 0.00s and never reaches any of it); it does **not** prove the pixel compare is
128+ what catches a bit flip. Proof 1 covers the compare.
129+
130+**One assertion added per gate on the way.** Each of the three compared
131+`frames.iter().zip(&ffmpeg_frames)` with no length check — the exact `cmpaudit`
132+class, where a short side truncates the walk silently. Each now asserts
133+`frames.len() == ffmpeg_frames.len()` first, naming the mis-pairing in the message.
134+
135+The `#[ignore]` reasons changed from "reads a pinned fixture path outside the
136+repo; run manually" to "bisect aid, not a suite gate; run it with `--ignored`" —
137+still ignored, but the old text claimed a property (outside the repo) that is no
138+longer true.
139+
140+---
141+
142+## 3. The stale comment, and the measurement that reversed my own call
143+
144+Last turn I reported to Main that the two 1:4 gates' `#[ignore]` strings were wrong
145+and the 22-line comment above them was right. **That was backwards**, and the
146+re-run says so.
147+
148+The r2 comment recorded, as these gates' blocker, an unowned mandelbrot
149+inter-frame defect: "decode-order frame 3/4 luma ~3.7-4.5k samples, max |d| 6..17,
150+then frames 5-7 drift to ~24k samples, max |d| ~220", plus "seeds 46 and 54 fire
151+ZERO 1:4 strips ... and mismatch ffmpeg the same way as the firing seed 52".
152+
153+**Measured on `a21f3680`, release, the r2 recipe set re-run in full** — 40 attempts
154+per bit depth, from the gate's own parameters (mandelbrot 192x128, `start_scale =
155+5.0 - attempt*0.06`, `end_pts=8`, `hue=s=0`, `-t 0.32`,
156+`--enable-rect-partitions=1 --enable-1to4-partitions=1 --min-partition-size=32
157+--max-partition-size=64 --enable-tx-size-search=0 --enable-filter-intra=1
158+--enable-intra-edge-filter=1 --kf-min-dist=1000 --kf-max-dist=1000` plus the
159+standard disable set, `--cpu-used = 1 + attempt%4`, `--cq-level =
160+[63,55,45,35][(attempt/4)%4]`):
161+
162+| | 8-bit | 10-bit |
163+|---|---|---|
164+| attempts decoded + pixel-compared | **40** | **40** |
165+| gate's own tally | `counted-exact=0 uncounted-exact=40 named-refusals=0` | identical |
166+| `first diff at` / `samples differ` / `max \|d\|` lines in the full log | **0** | **0** |
167+| 1:4 strips in inter frames | `64x16=0 16x64=0 32x8=0 8x32=0` | identical |
168+
169+Both the frame range and the byte counts r2 named are simply absent: no frame 3/4
170+counts, no `max |d|`, no drift. **The mandelbrot inter-frame defect is cleared on
171+this tree** — 80 streams compared, 80 exact. A positive measurement, not the
172+absence-of-evidence I flagged last turn.
173+
174+And the recipe moved the other way: **zero** 1:4 strips fire now across all 42
175+counted attempts per arm, where r2 had one attempt firing `64x16=4 16x64=3`. The
176+gates went from "fires sometimes, compare fails" to "never fires", and now trip
177+their own non-vacuity precondition at `stream.rs:40653` rather than any pixel.
178+
179+**Therefore:** the `#[ignore]` strings are correct for this tree and the comment
180+was the stale artefact. Both gates stay ignored — a source that is baseline-exact
181+*and* fires a 32-level intra 1:4 strip in an inter frame still does not exist —
182+and the comment now records the cleared blocker and the zero-strip recipe
183+regression, dated, with the reason for the correction.
184+
185+What I did **not** claim: I did not identify which commit cleared the mandelbrot
186+defect. The 7-lane wave is the obvious suspect and the measurement is consistent
187+with it, but "the wave fixed it" is a correlation across a merge, not an
188+attribution. Closing that needs an ablation, which is a bisect, not a comment fix.
189+
190+---
191+
192+## 4. State
193+
194+Two commits on `lane-av1pins`, base `a21f3680`. `cargo check -p ec-av1
195+--all-targets` clean, no warnings. Not pushed, not merged; main untouched.
196+
197+Verified here: the three gates pass from the committed pins with real-work output
198+and mutation proof; the mandelbrot sweep measures 80/80 exact at both bit depths.
199+Not verified: a full `cargo test -p ec-av1` run (out of scope for a
200+fixture/comment lane; project-wide validation is Main's), and the 35
201+probes/benchmarks excluded from the earlier release triage.
202+
203+Procedure saved as managed skills `stale-ignore-reason-vs-stale-comment` and
204+`fixture-absent-silent-skip-class`.
lanes/av1readcensus.report.mdadded+189 -0
@@ -0,0 +1,189 @@
1+# lane-av1readcensus — the 4:4:4 coefficient-read count asymmetry, settled
2+
3+**Branch:** `lane-av1readcensus`, worktree `~/.cache/wt/av1readcensus`, stacked on
4+`lane-av1chrtx` (`ff7cf47c`, whose `d791c464` threaded the real plane index into
5+`read_coeffs_rect`'s traces — the census pairs on that).
6+
7+**Verdict: COUNTING SHAPE — and not even that. On every pixel-exact 4:4:4 arm
8+there is no asymmetry at all: both sides walk the same number of units, in the
9+same order, with the same plane, shape, eob and all-zero flag. The recorded
10+636-vs-1086 / 2052-vs-1309 signal came from an arm that DIVERGES, where the
11+surplus is the divergence itself, not a counting-shape difference.**
12+
13+## 1. The signal, and why the census was admissible only on a pixel-exact arm
14+
15+`av1444rect` round 4 recorded 636 square chroma reads against the oracle's 1086,
16+and 2052 luma reads against its 1309, on `444_intrabc_rect4_witness`, and filed
17+it as "most likely a counting-shape difference … it is NOT established either
18+way". Two things had to be settled before counting anything:
19+
20+- the arm must be **pixel-exact**. On a diverging arm the counts are polluted by
21+ the divergence: a decoder reading the wrong coefficients also walks a different
22+ number of units, so the count difference is a *symptom*, and the count cannot
23+ distinguish cause from effect. Measured: `444_intrabc_rect4_witness` is wrong in
24+ 390380 of 921600 samples, and `444_leaf8_oob` in 281306 of 737280.
25+- the pairing must not assume either side's own labels.
26+
27+Measured exactness of every 4:4:4 fixture in the crate (ours vs `aomdec
28+--rawvideo`, plane-concatenated, u16→u8):
29+
30+| fixture | pixels | pixel-exact? |
31+|---|---|---|
32+| `ll444_minp8_inter` | 6 frames | **yes** |
33+| `444_quad_leaf_tx_type` | 4 frames | **yes** |
34+| `444_lossy_rect4_inter_witness` | 2 frames | **yes** |
35+| `444_rect_strip_leaf_tx_type` | 3 frames | **yes** |
36+| `444_sb128rect_lr_witness` | 3 frames | **yes** |
37+| `444_intrabc_rect4_witness` | 1 frame | no (390380 / 921600 wrong) |
38+| `444_leaf8_oob` | 3 frames | no (281306 / 737280 wrong) |
39+
40+## 2. Method — the census, both sides, same frame
41+
42+**Ours.** A new env-gated rung `EC_CENSUS_UNIT` (`EC_CENSUS_UNIT=1`), one line
43+per coefficient unit **this decoder walks** — one per `read_coeffs` /
44+`read_coeffs_rect` call, which is exactly the object the round-4 count measured.
45+Fields: `n` (sequential index), `plane`, `w`, `h`, `tx`, `eob`, `all_zero`,
46+`entry_rng` (msac `range` before the unit's `txb_skip` read), `post_rng` (after
47+the unit). The plane comes from a thread-local stamped by the plane-owning
48+readers (`read_plane`, `read_inter_plane`, `read_inter_plane_rect`) and by
49+`read_coeffs_rect` from the real `plane` argument lane-av1chrtx already threads
50+in — a thread-local rather than a `read_coeffs` parameter because the three
51+luma-only call sites (`decode_rect_split`, `decode_block_rect64`,
52+`read_inter_plane_rect`'s corner) belong to other lanes.
53+
54+**Oracle.** No rebuild needed: the instrumented aomdec already brackets every
55+`av1_read_coeffs_txb` call with `EC_COEFF …rng=<pre>` on entry and
56+`EC_COEFF_VAL …rng=<post>` on exit (`EC_TRACE_COEFF=1`), with
57+`EC_COEFF_STEP tag=all_zero` / `tag=eob` inside the bracket. That is the same
58+five fields.
59+
60+**Pairing: by `post_rng`, never by plane label and never by walk position or
61+`n`.** `post_rng` is the msac state after the unit, so two units that consumed
62+the same bits end at the same state. This matters concretely here: pairing by
63+`n`/position invents matches the moment the two walks order a U and a V unit
64+differently, and pairing by plane label invents them whenever a walk's plane
65+attribution is what is in question. The walk is a two-pointer merge on `post_rng`;
66+a unit is emitted only when the two sides agree on the pairing key.
67+
68+**Buckets** (each difference lands in exactly one):
69+
70+- **(i) SAME UNIT** — the two sides' units pair, and plane/shape/eob/all-zero agree.
71+- **(ii) OUR-ONLY** — we walk a unit the oracle does not, at that bit position.
72+- **(iii) ORACLE-ONLY** — the oracle walks one we do not.
73+- **(iv) SIZE/ORDER** — the units pair but disagree on shape, plane label, eob
74+ or all-zero.
75+
76+## 3. Per-bucket table (whole stream, paired by `post_rng`)
77+
78+| arm | pixels | units ours / oracle | (i) | (ii) | (iii) | (iv) |
79+|---|---|---|---|---|---|---|
80+| `ll444_minp8_inter` (6 frames) | exact | **11292 / 11292** | **11292** | 0 | 0 | 0 |
81+| `444_lossy_rect4_inter_witness` (mixed shapes) | exact | **1373 / 1373** | **1373** | 0 | 0 | 0 |
82+| `444_quad_leaf_tx_type` | exact | **192 / 192** | **192** | 0 | 0 | 0 |
83+| `444_rect_strip_leaf_tx_type` | exact | 591 / 591 | 587 | 0 | 0 | 4 |
84+| `444_sb128rect_lr_witness` | exact | 467 / 467 | 463 | 0 | 0 | 4 |
85+| `444_intrabc_rect4_witness` | **diverges** | 2740 / 2395 | 1909 | 823 | 478 | 8 |
86+| `444_leaf8_oob` | **diverges** | 1778 / 1678 | 1027 | 751 | 651 | 0 |
87+
88+Per-plane split on the primary arm, both sides identical:
89+
90+| | luma | u | v |
91+|---|---|---|---|
92+| units (ours) | 3764 | 3764 | 3764 |
93+| units (oracle) | 3764 | 3764 | 3764 |
94+| of which coded (`txb_skip == 0`) | 975 | 1793 | 1859 |
95+
96+So the round-4 asymmetry does not survive on an arm whose pixels are right.
97+Reproduced exactly on the diverging arm: `444_intrabc_rect4_witness` reads 1518
98+luma / 611 / 611 against the oracle's 1309 / 543 / 543 — the luma 1309 and the
99+per-plane 543/543 are *the round-4 oracle numbers*, so the count was never a
100+counting artefact. It was a real count, taken on an arm that does not decode.
101+
102+## 4. The eight (iv) entries on the exact arms are a tracing artefact, not a defect
103+
104+On `444_rect_strip_leaf_tx_type` and `444_sb128rect_lr_witness`, 4 units each
105+bucket as (iv). All four have **identical `entry_rng`, `post_rng`, `eob` and
106+all-zero flag on both sides** and differ only in the reported extent:
107+
108+```
109+idx 202: ours plane=0 32x32 eob=0 az=true | oracle plane=0 txsz=TX_64X64 eob=0 az=true | post=41441
110+idx 498: ours plane=0 32x32 eob=0 az=true | oracle plane=0 txsz=TX_64X64 eob=0 az=true | post=33499
111+```
112+
113+Both sides read exactly one `txb_skip` symbol and consumed the same bits; ours
114+reports the *corner* it decoded (the 32×32 low-frequency corner of a 64×64
115+luma block — `read_coeffs`' `rect_shape` path, spec 5.11.40) while libaom's
116+`EC_COEFF` prints the `TX_64X64` it was called with. A shape **label**
117+difference on an otherwise identical unit, not a walk difference. Two of the
118+four also carry a plane-label difference with the same entry/post rng — the same
119+class. Under the ticket's own rule ("a real divergence requires a unit in (i) or
120+(iv) whose **eob/values** differ") these are neither: no eob and no value
121+differs anywhere on any pixel-exact arm.
122+
123+## 5. Gate
124+
125+`a_pixel_exact_444_stream_walks_the_same_coefficient_units_the_oracle_does`
126+(`crates/ec-av1/src/stream.rs`) pins the walk's object shape on two
127+pixel-exact 4:4:4 arms:
128+
129+- `ll444_minp8_inter` — all-TX_4X4 (min-partition-8 lossless): `[3764, 3764,
130+ 3764]` units, `[975, 1793, 1859]` coded;
131+- `444_lossy_rect4_inter_witness` — **mixed shapes** (4×4, 8×8, 8×4, 4×8, 4×16,
132+ 16×4, 8×16, 16×16): `[629, 372, 372]` units, `[130, 253, 278]` coded.
133+
134+The second arm is not redundant: the first is uniformly 4×4 and would not notice
135+a var-tx walk that started folding 8×8 leaves. Both numbers are the oracle's own
136+census on the same stream.
137+
138+**Mutation-proven.** Dropping 8×8 units from the walk turns it red by name:
139+
140+```
141+the mixed-shape 4:4:4 walk changed -- [571, 313, 313] against the oracle's [629, 372, 372]
142+ left: [571, 313, 313] right: [629, 372, 372]
143+```
144+
145+and the all-4×4 arm is untouched by that mutation — which is exactly why both
146+arms are pinned.
147+
148+**4:2:0 control.** The census is armed per frame from the sequence header's
149+subsampling (`set_census_444(ss_x, ss_y)` in `stream.rs`, beside
150+`set_mono`/`set_subsampling`), so at 4:2:0/4:2:2 every counter stays zero; the
151+gate asserts exactly `(0, 0, 0)` for both the unit and coded-unit counters on a
152+committed 4:2:0 stream that decodes. The accounting is separate from the sibling
153+counter pair the ticket mentions.
154+
155+## 6. What this settles for the next lane
156+
157+- The 636-vs-1086 / 2052-vs-1309 signal is **retracted**: it was measured on
158+ `444_intrabc_rect4_witness`, which is wrong in 390380 of 921600 samples. Do not
159+ carry it forward as a walk-shape hypothesis.
160+- Counting the coefficient units on a **pixel-exact 4:4:4** arm reproduces the
161+ oracle exactly, per plane, per unit. The census is now a one-command check:
162+ `EC_CENSUS_UNIT=1 cargo run -p ec-av1 --example decode_probe -- <arm>.obu`
163+ against `EC_TRACE_COEFF=1 aomdec`, paired by `post_rng`.
164+- If a future lane sees a count asymmetry, the first question is whether the arm
165+ decodes — not whether the walk shape differs. That check is now the gate.
166+
167+## 7. Not fixed here, by design
168+
169+The 4:4:4 intra-BC chroma divergence (`444_intrabc_rect4_witness`, 390380 /
170+921600) is untouched: this lane's deliverable is the census. Per §4 there is no
171+value-level divergence on any pixel-exact arm for this census to point at, so the
172+remaining fork is not a coefficient-read-count problem and needs a fresh charter.
173+
174+## 8. Method notes for whoever repeats this
175+
176+- **Pair by `post_rng`.** Position/`n` pairing invents matches when a walk
177+ orders U and V differently; plane-label pairing invents them when plane
178+ attribution is the thing in question.
179+- **A pixel-exact arm is mandatory.** On `444_intrabc_rect4_witness` the counts
180+ diverge by 823/478 units *because* the decode does; the count difference is a
181+ symptom, not a cause.
182+- **`EC_SYMR` is still the right rung for symbol-level work**; `EC_COEFF_STEP`
183+ is filtered (the oracle prints `tag=tx_type` for all three planes but reads it
184+ only for Y), so it is not a per-unit bracket. `EC_COEFF`/`EC_COEFF_VAL` are
185+ the per-unit bracket and were already in the oracle build — no rebuild needed.
186+- Our own rung must carry the real plane: `read_coeffs` had no plane parameter,
187+ and a stamp inherited from whichever reader ran last mis-attributes chroma as
188+ luma (this bit the census's first run and is the same trap `d791c464` fixed for
189+ the rect trace).
lanes/av1recipehunt.report.mdadded+550 -0
@@ -0,0 +1,550 @@
1+# lane-av1recipehunt report
2+
3+Three `#[ignore]`d ec-av1 gates whose RECIPE never provoked the feature. Two are
4+CLOSED with a pinned, red-proved fixture. One is UNPRODUCIBLE for a structural
5+reason that no recipe can move, proved by mutation.
6+
7+Branch `lane-av1recipehunt`, base `a21f3680`. Oracle
8+`~/.cache/aom-oracle/build/aomenc` (aom `v3.13.3-7-g9bb526a`), ffmpeg
9+`/usr/bin/ffmpeg`. Every number below was measured in RELEASE on this tree; the
10+row format is `recipe | parsed feature evidence | counter before | counter after
11+| pixel verdict`.
12+
13+Method: hunt deliberately from the code path out, not by random sweep. For each
14+gate, first read the DECODE-path counter that the gate's own precondition assert
15+consumes, then work out which encoder-side knob can move it, then sweep only
16+that knob. Reachability is asserted from the real read (`decode_probe` prints
17+each counter from the decode path; `enc_probe` prints the writer-side one), never
18+from a mirror call site, and every firing recipe is additionally pixel-compared.
19+
20+---
21+
22+## Gate 1 -- `a_128_superblock_clip_whose_drl_index_the_write_time_stack_cannot_carry_decodes_exact`
23+
24+**Verdict: UNPRODUCIBLE. The gate stays `#[ignore]`d.**
25+
26+### Baseline (run unmodified, RELEASE)
27+
28+```
29+thread 'encode::tests::a_128_superblock_clip_whose_drl_index_the_write_time_stack_cannot_carry_decodes_exact'
30+panicked at crates/ec-av1/src/encode.rs:19484:9:
31+this clip never asked for a drl index the write-time stack could not carry, so it cannot witness the defect
32+test result: FAILED. 0 passed; 1 failed; ... finished in 32.25s
33+```
34+
35+`assert!(clamps > 0)` with `clamps = crate::tile::take_drl_clamp_hits()` after
36+63.93 s (32.25 s here) of real encoding of mandelbrot 1280x768x12 at q 150 with
37+`force_sb128(true)`.
38+
39+### Why no recipe exists
40+
41+`DRL_CLAMP_HITS` is bumped by `tile::write_inter_mode` (and the two compound
42+walks) only when the SEARCH chose a `ref_mv_idx` the write-time stack could not
43+signal. On this tree the search's offer set is inside the signalable range in
44+every mode:
45+
46+| mode | search's offer set | writer's signalable ceiling | gap |
47+|---|---|---|---|
48+| `NEWMV` | `best_new_mv_syntax`, `for idx in 0..3` -> {0,1,2} | `write_drl_idx(..., start=0, ...)`: `idx < start + 2` -> 2 | none |
49+| `NEARMV` | `for idx in 1..=2` (both search arms) | `start=1`, `idx < 3`, plus `entries.len() > idx + 1` | none: the search offers `idx` only when `entries.get(idx).is_some()`, i.e. `entries.len() > idx`, and the walk stops one entry later -- the bounds coincide at every stack size |
50+| `NEARESTMV` / `GLOBALMV` | no DRL | n/a | n/a |
51+| compound (`write_compound_block`) | every compound `InterInfo` the search builds hardcodes `ref_mv_idx: 0` | walks start at 0/1 | none |
52+
53+This is not inference. The tree already ASSERTS it, over stack sizes 0..=4, in
54+`encode::tests::every_drl_index_the_new_mv_pricer_offers_is_one_the_writer_can_signal`:
55+for every index either pricer offers, `tile::signalled_drl_idx(entries, start, idx)
56+== idx`. That test and this gate are two readings of one invariant, and it is
57+still green on this tree (verified). The counter this gate waits on can never
58+leave zero.
59+
60+### Attempt table -- 153 combinations, every one `drl_clamp = 0`
61+
62+Driven by `enc_probe` (`tile::drl_clamp_hits()` printed per encode point).
63+
64+| recipe | parsed feature evidence | clamps before | clamps after | pixel verdict |
65+|---|---|---|---|---|
66+| mandelbrot 320x192x8 q150 (the gate's own clip class, small) | search picks DRL idx 2 (35x, traced) | 0 | 0 | n/a (encode-side) |
67+| mandelbrot 640x384x8 q150 | search picks DRL idx 2 (163x, traced) | 0 | 0 | n/a |
68+| mandelbrot 640x384x12 q110 / q150 / q200 | idx 2 chosen | 0 | 0 | n/a |
69+| mandelbrot 1280x768x8 q110 / q150 / q200 (the gate's EXACT clip) | idx 2 chosen | 0 | 0 | n/a |
70+| mandelbrot 1280x768x12 q150 (the gate's exact point) | idx 2 chosen | 0 | 0 | n/a |
71+| testsrc2 320x192 / 640x384 / 1280x768 x 8/12, q 110/150/200 | idx 2 chosen (27x on 640x384) | 0 | 0 | n/a |
72+| white noise 320x192 / 640x384 x 8/12, q 60/110/150/200 | idx 0 only (drl_index histogram 108/0/0/0 -- the write-time stack never reaches 3 entries) | 0 | 0 | n/a |
73+| scrolling hard bands 320x192x8 | idx 0 only | 0 | 0 | n/a |
74+| 4x4 mandelbrot mosaic, per-tile independent drift, 320x192 / 640x384 x 8/12 | idx 2 chosen (35x) | 0 | 0 | n/a |
75+| 4-px luminance bands, both axes, 192x128, mps 8/16, cpu 0..6 | idx 2 chosen | 0 | 0 | n/a |
76+| panning field + a faster band inside it, 640x384x10/16, b=32/64, q 100/150/200 | idx 2 chosen | 0 | 0 | n/a |
77+| diagonal band on a pan, 640x384x10/16, b=32/64, q 100/150/200 | idx 2 chosen | 0 | 0 | n/a |
78+| three independently moving bands, 320x192x10/16, b=32/64, q 100/150/200 | idx 2 chosen | 0 | 0 | n/a |
79+| alternating hard 32x32 tiles (whole tiles re-predict from wherever the identical tile last was), 640x384x10, q 150 | idx 2 chosen | 0 | 0 | n/a |
80+| q ladder 60 / 150 / 220 on one clip (three encode points in a run) | idx 2 chosen | 0 | 0 / 0 / 0 | n/a |
81+
82+A trace on `best_new_mv_syntax` is the decisive negative: the search DOES choose
83+DRL index 2, often (163 times on mandelbrot 640x384x8). Index 2 is exactly what
84+the writer signals, so it is a legal pick, not a clamp. The instrument I built
85+for the hunt (`tile::drl_index_histogram`, reading `DRL_HITS`) was REMOVED before
86+commit: it records the SIGNALLED index, which is downstream of the clamp and
87+structurally cannot show 3+, so it cannot separate "the search never asked" from
88+"it asked and the stack could not carry it". Shipping it would have been a
89+misleading instrument.
90+
91+### Mutation proof -- the recipe was never the problem
92+
93+`best_new_mv_syntax`'s offer set widened `for idx in 0..3` -> `0..5`, i.e.
94+letting the search ask for index 3/4 that the 2-step walk cannot signal:
95+
96+| recipe (identical command line, only the offer set differs) | clamps |
97+|---|---|
98+| mandelbrot 640x384x8 q150 | **9** |
99+| mandelbrot 320x192x8 q150 | **2** |
100+| mandelbrot mosaic 320x192x8 q150 | **2** |
101+| testsrc2 640x384x8 q150 | **1** |
102+| white noise 320x192x8 q150 | 0 |
103+| alternating hard tiles 640x384x10 q150 | **1** |
104+| all of the above, mutation reverted | 0 |
105+
106+Same clips, same presets, only the pricer's offer ceiling moved. The binding
107+constraint is the ceiling, which no clip can move. Mutation reverted and
108+`git diff` on `encode.rs` is empty apart from this lane's doc comment.
109+
110+### Disposition
111+
112+`#[ignore]` kept -- un-ignoring it would ship a gate that can never pass. The
113+gate's doc comment now carries the whole finding (the per-mode table, the
114+existing invariant test that proves it, the 153-row measurement, the mutation
115+proof, and the owning fix) so the next lane does not repeat the sweep.
116+
117+**Owning fix, not this lane's to make** (the DRL code is another lane's surface,
118+and the DRL index range is the AV1 spec's, not ours): either widen the search's
119+offer set to the spec's own DRL range so the clamp becomes reachable and this
120+gate can witness it, or delete the three dead `note_drl_clamp` sites and this
121+gate with them. `deferred(unblock: DRL owner widens `best_new_mv_syntax`'s offer
122+set past the writer's `start + 2` ceiling, or retires the counter)`.
123+
124+---
125+
126+## Gate 2 -- `a_real_aomenc_stream_with_a_superblock_level_horz_vert_partition_and_delta_q_decodes_pixel_exact`
127+
128+**Verdict: CLOSED. Un-ignored, pinned, red-proved.**
129+
130+### Baseline (run unmodified, RELEASE)
131+
132+```
133+a_real_aomenc_stream_..._and_delta_q_decodes_pixel_exact: zero rect64 dequant calls
134+ever observed CURRENT_Q_IDX != base_q_idx (40 matches, 0 refusals out of 40) --
135+delta_q was never actually exercised through decode_block_rect64 this run
136+```
137+
138+### Root cause of the blindness
139+
140+r1 swept 40 attempts of `gradients` at 192x128 with `frame_count = 1`. That is a
141+single KEY frame, and it is the whole reason. `delta_q_present` needs the
142+temporal (TPL) model to see a spatial complexity map at all; a one-frame encode
143+has no inter frame to carry it. Measured over 120 sweep arms at 192x128 /
144+256x192 / 320x256 / 512x384, 4 and 10 frames, cpu 0/1/3, cq 45/55, five source
145+classes: at `frame_count = 1` EVERY arm read `delta_q_hits() == 0` AND
146+`rect64_qidx_drift_hits() == 0`. A different failure from "the drift never
147+reached a rect64 block", and the reason r1 could not see the feature at all.
148+
149+### The recipe that fires
150+
151+`testsrc2` 512x384, **4 frames**, `--cpu-used=0`, `delta_q` left at aomenc's
152+default. Exactly:
153+
154+```
155+ffmpeg -v error -y -f lavfi -i testsrc2=size=512x384:rate=25 \
156+ -pix_fmt yuv420p -frames:v 4 -f yuv4mpegpipe src512.y4m
157+aomenc --codec=av1 --passes=1 --end-usage=q --cq-level=45 --cpu-used=0 \
158+ --threads=1 --row-mt=0 --sb-size=64 --enable-rect-partitions=1 \
159+ --enable-ab-partitions=0 --enable-1to4-partitions=0 \
160+ --min-partition-size=32 --max-partition-size=64 \
161+ --enable-restoration=0 --enable-palette=0 --enable-cdef=0 \
162+ --enable-filter-intra=0 --enable-cfl-intra=0 --enable-intrabc=0 \
163+ --enable-tx-size-search=0 --obu -o out.obu src512.y4m
164+```
165+
166+* source `src512.y4m`: 1179730 bytes, sha256
167+ `f430d581497e4f6f7db07d0fc92476e92194e1f96c321988ec0739d475cbbe0c`
168+* output `crates/ec-av1/fixtures/rect64_dq_drift.obu`: **8384 bytes**, sha256
169+ `094e51bb21b6caccc905417e95a03f9131b448071567d0b14ec8850799ea2501`, fnv1a64
170+ `0x3d91a21680063ef6` (committed with `git add -f` past the `fixtures`
171+ gitignore, like every sibling fixture)
172+
173+### Attempt table (representative; the sweep was 120 arms)
174+
175+| recipe | parsed feature evidence | drift before | drift after | pixel verdict |
176+|---|---|---|---|---|
177+| testsrc2 512x384 **1 frame** cpu0 q45 (r1's shape) | `delta_q_present` absent, 0 groups | 0 | 0 | n/a (no feature) |
178+| testsrc2 512x384 4 frames cpu0 q45 | 48 `delta_q` groups; `inter_rect: 64x32=2 32x64=2` | 0 | **17** | **EXACT** all 4 frames |
179+| testsrc2 512x384 10 frames cpu0 q45 | 134 groups | 0 | 16 | EXACT |
180+| testsrc2 256x192 4 frames cpu0 q45 | 12 groups | 0 | 6 | EXACT |
181+| testsrc2 256x192 10 frames cpu0 q45 | 55 groups | 0 | 6 | EXACT |
182+| testsrc2 192x128 4 frames cpu0 q45 | 6 groups | 0 | 2 | EXACT |
183+| testsrc2 192x128 10 frames cpu0 q45 | 30 groups | 0 | 2 | EXACT |
184+| grad42 512x384 4 / 10 frames cpu0 q45 | 48 / 68 groups | 0 | 8 / 15 | EXACT |
185+| grad43 512x384 4 / 10 frames cpu0 q45 | 48 / 76 groups | 0 | 4 / 17 | EXACT |
186+| smptebars 512x384 4 / 10 frames cpu0 q45 | 48 groups | 0 | 6 / 5 | EXACT |
187+| **same source, `--cpu-used=1`** | 48-134 groups | 0 | **0** | EXACT |
188+| **same source, `--cpu-used=3`** | 48-138 groups | 0 | **0** | EXACT |
189+| **same source, `--deltaq-mode=0` (control)** | **0 groups** | 0 | **0** | EXACT |
190+| same source, `--cq-level=55` | 48 groups | 0 | 17 | EXACT (byte-identical to cq 45) |
191+| a "zone"/checkerboard source, every size and preset | 0 groups | 0 | 0 | EXACT (no delta_q at all) |
192+| smptebars / zone at `--cq-level=30` and `55` | 0 groups | 0 | 0 | EXACT |
193+
194+`--cpu-used=0` is load-bearing and measured: at `--cpu-used=1` and `3` the same
195+source reads the same 48 `delta_q` groups and drifts ZERO times -- the faster
196+presets' RD never leaves a rect64 root in a superblock whose quantizer moved.
197+`--cq-level` is not load-bearing.
198+
199+Note for whoever reads the census: a 192x128 SINGLE-frame testsrc2 at cpu 0 is
200+NOT pixel-exact on this tree (2177 differing bytes), and so is the 25-frame
201+512x384 one (2190). That is a pre-existing intra-frame defect, unrelated to
202+`delta_q` (the `--deltaq-mode=0` arm at the same size shows the same count), and
203+it is why the recipe uses a 4-frame 512x384 cell rather than either of those.
204+
205+### Red-proof
206+
207+The gate's own control arm re-runs the same command line with `--deltaq-mode=0`
208+and requires the drift to stay at 0. Run explicitly, by reverting the
209+feature-bearing flag INTO the feature arm (and relaxing the byte pin so the
210+precondition is what fires, not the byte identity):
211+
212+```
213+thread 'stream::tests::a_real_aomenc_stream_..._and_delta_q_decodes_pixel_exact'
214+panicked at crates/ec-av1/src/stream.rs:37752:9:
215+...: 4 frames pixel-exact but zero rect64 dequant calls ever saw CURRENT_Q_IDX !=
216+base_q_idx -- delta_q was read and never moved the quantizer inside a rect64 block,
217+so this run proved nothing (class gate-blind-to-feature)
218+test result: FAILED. 0 passed; 1 failed
219+```
220+
221+The pixel compare passed in that run; only the precondition went red. Both
222+temporary edits reverted; green again immediately after.
223+
224+### Green
225+
226+```
227+...: 4 frames pixel-exact, sb_rect_hits=40, rect64_qidx_drift_hits=17
228+(--deltaq-mode=0 control: 0), stream 8384 B fnv1a64=3d91a21680063ef6
229+test result: ok. 1 passed
230+```
231+
232+Runtime 1.7 s (r1's 40-arm sweep was the 60 s+ version).
233+
234+---
235+
236+## Gate 3 -- `a_real_aomenc_inter_sequence_with_an_intra_1to4_strip_decodes_pixel_exact` (+ `_10bit`)
237+
238+**Verdict: CLOSED, both arms. Un-ignored, pinned, red-proved.**
239+
240+### Baseline (run unmodified, RELEASE, both arms)
241+
242+```
243+a_real_aomenc_inter_sequence_with_an_intra_1to4_strip_decodes_pixel_exact: no 32-level
244+intra 1:4 strip (32x8/8x32) fired over 40 compared streams (64x16=0 16x64=0 32x8=0 8x32=0)
245+```
246+Same text for the `_10bit` arm. 40/40 streams pixel-compared, zero mismatches.
247+
248+### Root cause of the blindness, and the stale comment
249+
250+The 22-line comment above the `#[ignore]` blamed a pre-existing inter-frame
251+pixel defect (frames 3-7 drifting to ~24k samples, max |d| ~220). **That is
252+stale: the pixel blocker cleared.** What actually kept the gate blind is a
253+second, purely mechanical fact the comment never mentions -- and its own
254+conclusion ("the 1:4 shape is not the discriminator either") was measuring the
255+wrong arm:
256+
257+* `--min-partition-size=32` with an all-but-empty intra mode set
258+ (`--enable-smooth-intra/paeth-intra/directional-intra/angle-delta` all `0`)
259+ never puts a 1:4 partition on aomenc's RD menu at all. Measured: at
260+ `--min-partition-size=16` the 32-level 1:4 counter is **0 in all 48** attempts
261+ (10-bit, 192x128 and 256x192, `--cpu-used` 0..5, cq 63/55); at
262+ `--min-partition-size=8` with the intra mode tools on it fires in **40 of 48**.
263+* A 32x8/8x32 strip needs an intra mode worth coding. With the four tools off
264+ the only candidate is DC, and DC never wins a 1:4 strip against inter.
265+
266+So both the old `--min-partition-size=32` (protecting against a 16x4/4x16
267+refusal that no longer fires -- at `mps=8` the RD takes neither the 8- nor the
268+16-level 1:4 on this content, confirmed by the `inter16_1to4` and `rect4_32`
269+inter counters staying at 0) and the four intra-mode flags were holding the
270+shape off the menu. r2's `--enable-1to4-partitions=0` "byte-identical stream"
271+observation is explained by the same thing: with no 1:4 partitions reachable at
272+all, the flag had nothing to turn off.
273+
274+### The recipe that fires
275+
276+mandelbrot zoom, **256x192, 6 frames**, `--cpu-used=2 --cq-level=63`,
277+`--min-partition-size=8`, the full intra mode set. Exactly:
278+
279+```
280+ffmpeg -v error -y -f lavfi \
281+ -i mandelbrot=size=256x192:start_scale=5.0:end_scale=0.004:end_pts=8:rate=25 \
282+ -pix_fmt yuv420p -frames:v 6 -f yuv4mpegpipe - # 10-bit: yuv420p10le + -strict -1
283+aomenc [--cpu-used=2 --input-bit-depth=10 -b 10] --codec=av1 --passes=1 --end-usage=q \
284+ --cpu-used=2 --cq-level=63 --threads=1 --row-mt=0 \
285+ --enable-rect-partitions=1 --enable-1to4-partitions=1 \
286+ --min-partition-size=8 --max-partition-size=64 --enable-tx-size-search=0 \
287+ --enable-filter-intra=1 --enable-intra-edge-filter=1 --enable-smooth-intra=1 \
288+ --enable-paeth-intra=1 --enable-directional-intra=1 --enable-angle-delta=1 \
289+ --lag-in-frames=0 --auto-alt-ref=0 --kf-min-dist=1000 --kf-max-dist=1000 \
290+ --enable-order-hint=0 --enable-warped-motion=0 --enable-obmc=0 \
291+ --enable-masked-comp=0 --enable-interintra-comp=0 --enable-dist-wtd-comp=0 \
292+ --enable-diff-wtd-comp=0 --enable-onesided-comp=0 --enable-interintra-wedge=0 \
293+ --enable-smooth-interintra=0 --enable-ab-partitions=0 --enable-cdef=0 \
294+ --enable-restoration=0 --enable-palette=0 --enable-intrabc=0 \
295+ --enable-cfl-intra=0 --enable-ref-frame-mvs=0 --obu -o - -
296+```
297+
298+* 8-bit source: 442462 bytes, sha256 `e4b46799b180a0d3e138caa18b2738c035e349219490313db664814a3eae9ec2`
299+* 10-bit source: 884828 bytes, sha256 `b7e0602e0bfc7a7f6813f40bb3989ec7574e5fbbfbf190298b9ab5b625156030`
300+* `crates/ec-av1/fixtures/intra14_256x192_8bit.obu`: **35179 bytes**, sha256
301+ `5e50eb6d4492e806a2803988d92bd47f069ca54e02c06344d5500c6b72deb861`, fnv1a64
302+ `0x86f8d1e5a221162a`
303+* `crates/ec-av1/fixtures/intra14_256x192_10bit.obu`: **34727 bytes**, sha256
304+ `ab6fae0a256af6410e8200f10827a3e965dee7b2d7ab63710e94968bddab23a2`, fnv1a64
305+ `0xecf9455bc20d60f0`
306+
307+### Attempt table (grid v2: 576 arms, 0 hits; grid v3: 2520 streams carrying SOME 1:4, 54 hits)
308+
309+| recipe | parsed feature evidence | 64x16 / 16x64 / 32x8 / 8x32 | pixel verdict |
310+|---|---|---|---|
311+| **grid v2, the gate's own recipe** (mandelbrot 192x128x8, zoom `start_scale` 3.0/4.4/5.0, cq 63/55/45, cpu 1-4, flagsets `bare`/`intratools`/`screen`/`screen16`, 6 sources x 2 sizes) | NO 1:4 partition of any level in any stream -- `rect4_32`, `inter16_1to4` and `intra_rect4_in_inter` all 0 | 0/0/0/0 | EXACT on all 64 arms |
312+| banded 4-px content, STATIC in T, mps 8, cpu 0..6 | 241 B stream -- every inter frame SKIPs, no partitions at all | 0/0/0/0 | EXACT |
313+| 4-px bands that MOVE, mps 8, cpu 0 | `rect32x8_inter_tu: 32x8=1` -- a 32-level 1:4 strip, but INTER | 0/0/0/0 | EXACT |
314+| 4-px bands that move, mps 8, cpu 4 | `rect4_32: horz=4` / `vert=8` -- 1:4 again, INTER | 0/0/0/0 | EXACT |
315+| 4-px bands jumping 37/97/173 px per frame, mps 8/32, cq 63, cpu 0/2/4 | 1:4 present, INTER | 0/0/0/0 | EXACT |
316+| grid v2 with `--min-partition-size=8` and the intra tools ON, plain mandelbrot 192x128x6, cpu 2, cq 63 | **`intra_rect4_in_inter: 32x8=4 8x32=8`** | 0/0/**4**/**8** | **EXACT** |
317+| same, cpu 3, cq 63 | 32x8=4 8x32=8 | 0/0/4/8 | EXACT |
318+| same, cpu 2, cq 45 | 8x32=7 | 0/0/0/7 | EXACT |
319+| same, cpu 3, cq 45 | 8x32=10 | 0/0/0/10 | EXACT |
320+| 10-bit, 192x128, `--min-partition-size=8`, cpu 0, cq 63 | 32x8=4 8x32=11 | 0/0/4/11 | EXACT |
321+| **10-bit, 192x128, `--min-partition-size=16`, cpu 0..5, cq 63/55** (24 arms) | **ZERO 1:4 at any level** | 0/0/0/0 | EXACT |
322+| **10-bit, 256x192, `--min-partition-size=8`, cpu 0..5, cq 63/55** (24 arms) | fires at every preset 0-4, never at 5 | varies | EXACT |
323+| **`--enable-1to4-partitions=0` control, 8-bit** | `intra_rect4_in_inter` all 0, 20205 B vs 35179 B | 0/0/0/0 | EXACT |
324+| **CHOSEN: 8-bit 256x192x6 cpu2 q63 mps8** | 32x8=8 8x32=11 | 0/0/**8**/**11** | **EXACT** all 6 frames |
325+| **CHOSEN: 10-bit 256x192x6 cpu2 q63 mps8** | 32x8=12 8x32=7 | 0/0/**12**/**7** | **EXACT** all 6 frames |
326+
327+`--min-partition-size=8` vs `16` is the single load-bearing flag: 0/48 vs 40/48.
328+
329+One methodology note, recorded because it nearly cost the hunt: grid v3's
330+`scene-cut` source builder reused `[0:v]` for BOTH concat halves, so the
331+"second scene" argument had no effect and six nominally different rows produced
332+byte-identical results. The real driver was `mps=8` + the intra mode set, not the
333+scene cut. The chosen recipe is the plain source with no concat at all.
334+
335+### Red-proof
336+
337+The gate's own control arm re-runs the same command line with
338+`--enable-1to4-partitions=0` and requires all four counters to stay at 0. Run
339+explicitly, by reverting that flag INTO the feature arm (and relaxing the byte
340+pin so the precondition is what fires, not the byte identity):
341+
342+```
343+thread 'stream::tests::a_real_aomenc_inter_sequence_with_an_intra_1to4_strip_decodes_pixel_exact'
344+panicked at crates/ec-av1/src/stream.rs:40677:9:
345+... (8-bit): 6 frames pixel-exact but no 32-level intra 1:4 strip (32x8/8x32) fired
346+(64x16=0 16x64=0 32x8=0 8x32=0) -- the recipe stopped producing the shape this gate names
347+(class gate-blind-to-feature)
348+test result: FAILED. 0 passed; 1 failed
349+```
350+
351+All 6 frames still compared pixel-exact in that run; only the precondition went
352+red. Both temporary edits reverted.
353+
354+### Green
355+
356+```
357+...(8-bit): 6 frames pixel-exact, intra 1:4 strips in inter frames 64x16=0 16x64=0 32x8=8 8x32=11 (--enable-1to4-partitions=0 control: 0/0/0/0), stream 35179 B fnv1a64=86f8d1e5a221162a
358+...(10-bit): 6 frames pixel-exact, intra 1:4 strips in inter frames 64x16=0 16x64=0 32x8=12 8x32=7 (--enable-1to4-partitions=0 control: 0/0/0/0), stream 34727 B fnv1a64=ecf9455bc20d60f0
359+test result: ok. 3 passed; 0 failed
360+```
361+
362+2.3 s and 2.1 s per arm (r1's 40-arm sweep was 60 s+ each).
363+
364+---
365+
366+## What changed in the tree
367+
368+* `stream.rs`: gate 2 and the two gate-3 arms rewritten around a pinned recipe
369+ with a byte pin (len + fnv1a64 + equality against the committed fixture), a
370+ hard precondition assert on the decode-path counter, a full pixel compare, and
371+ a feature-flag control arm. All three un-ignored. The stale 22-line comment on
372+ the 1:4 pair is replaced by the measurement that actually explains them.
373+* `encode.rs`: gate 1's doc comment now carries the structural finding, the
374+ existing invariant test that proves it, the 153-row measurement, the mutation
375+ proof and the owning fix. The gate and its `#[ignore]` are unchanged.
376+* `tile.rs`: `pub fn drl_clamp_hits()` -- a non-destructive read of
377+ `DRL_CLAMP_HITS` (the `#[cfg(test)]` `take_drl_clamp_hits` clears), so a
378+ recipe sweep can read the gate's own precondition from outside the test
379+ binary.
380+* `stream.rs`: `pub fn rect64_qidx_drift_counters() -> (usize, usize)` --
381+ `(delta_q groups read, rect64 dequant calls that saw CURRENT_Q_IDX !=
382+ base_q_idx)`. The pair is the point: a recipe that reads no `delta_q` at all
383+ and a recipe that reads it but never moves the quantizer inside a rect64 block
384+ are different failures, and gate 2 was the first of those.
385+* `examples/decode_probe.rs`: prints that pair.
386+* `examples/enc_probe.rs`: prints `tile::drl_clamp_hits()`.
387+* Three fixtures committed under `crates/ec-av1/fixtures/` with `git add -f`.
388+
389+## Hazards hit, worth the next lane's time
390+
391+* **A shared `CARGO_TARGET_DIR` is not safe for a probe-driven hunt.**
392+ `~/.cache/cargo-target` was overwritten mid-sweep by a sibling lane's build
393+ and the probe binary silently lost its new counter lines -- a sweep that reads
394+ counters can be measuring an instrument that no longer exists. Give each lane
395+ its own target dir (`~/.cache/cargo-target-<lane>`).
396+* **A counter placed downstream of the event it names is not an instrument.**
397+ The first thing built for gate 1 was a histogram of the DRL index each block
398+ *coded*, read off `DRL_HITS`. It records the SIGNALLED index, so it is
399+ structurally incapable of showing the 3+ bucket and cannot distinguish "the
400+ search never asked" from "it asked and could not be carried". It was removed
401+ rather than shipped. The trace that did work was on the SEARCH's choice
402+ (`best_new_mv_syntax`), upstream of the writer.
403+* **`cargo test` under `scripts/memguard-runner.sh` collides on transient
404+ systemd scopes** ("Unit run-pNNNN.scope was already loaded or has a fragment
405+ file") when runs overlap. It is a runner failure, not a test failure; retry.
406+* **A 10-bit pixel compare needs `EC_PROBE_OUT16`, not `EC_PROBE_OUT`.**
407+ `EC_PROBE_OUT` writes u8 and every sample then differs from ffmpeg's
408+ `yuv420p10le` raw -- a 220438-byte "defect" that is purely a dump-format
409+ mismatch.
410+
411+---
412+
413+# r2 -- gate 1 disposed of, and the three pins re-verified on merged main
414+
415+Base moved: rebased onto `aa0ac8c2` ("lanes: merge-wave-2 clean-checkout
416+census"), 58 commits past this lane's original `a21f3680`. One conflict, in the
417+two 1:4 gates' comment slot, and it is worth recording because **two lanes
418+reached the same two facts independently**: `lane-av1pins` had already re-run
419+both 1:4 gates in RELEASE on the seven-lane tree and recorded that the pixel
420+blocker was gone and the recipe never fired; this lane then found why and closed
421+them. Both records are kept side by side in the resolved comment rather than
422+either being dropped -- `lane-av1pins`' measurement is the merge-main evidence
423+that the stale mandelbrot-defect claim was dead, and this lane's is the
424+mechanism.
425+
426+## Gate 1: DELETED, and the coverage claim moved to where it is asserted
427+
428+**Decision: delete.** The evidence that decided it, in the order it was
429+gathered:
430+
431+1. **The precondition is unreachable**, not merely unprovoked -- established in
432+ r1 (per-mode offer-set table, the existing invariant test, 153 attempts, and
433+ the `0..3 -> 0..5` mutation proof).
434+2. **The pixel half is not unique to the gate.** The deleted test's second half
435+ -- decode the encoded stream and compare every frame/plane against the
436+ encoder's own reconstruction, on a 1280x768 `force_sb128(true)` sequence --
437+ is already made **four times over** at the same geometry by
438+ `a_128_superblock_clip_whose_root_search_codes_128x128_blocks_decodes_exact`,
439+ `a_128_root_block_with_a_real_residual_decodes_exact_through_both_decoders`,
440+ `a_128_root_residual_block_under_a_per_unit_cdef_list_decodes_exact` and
441+ `a_rect128_half_with_a_real_residual_decodes_exact_through_both_decoders`
442+ (all four verified: same `force_sb128(true)`, same own-reconstruction
443+ compare, same ffmpeg compare).
444+
445+So deletion loses no coverage on **either** half. That is the point on which
446+"delete vs keep" turned: had the pixel compare been unique, keeping the test
447+with a fact-stating ignore string would have been the honest call, because
448+`#[ignore]` is cheap and a deleted unique assertion is not recoverable from the
449+report. It was not unique, so the gate was pure dead weight in `--list`.
450+
451+**Why the surviving invariant test is strictly better coverage, not a
452+substitute.** It enumerates the pricer's whole offer set against
453+`signalled_drl_idx` for stack sizes 0..=4, and 0..=4 bounds the DOMAIN rather
454+than sampling it: `best_new_mv_syntax` breaks at `entries.len() <= idx` for
455+`idx > 0`, so indices 3 and 4 are unreachable at *any* stack size, and a stack
456+larger than 4 only adds entries neither pricer offers. A clip gate could only
457+ever have sampled that space; this test closes it.
458+
459+**Where the disposition is visible.** The cell is not tracked in
460+`gate_coverage.rs` or `refusal_inventory.rs` (grepped: no `drl_clamp`,
461+`sb128b` or `write_time_stack` entry in either), so the claim lives on the test
462+that now carries the coverage, at
463+**`crates/ec-av1/src/encode.rs:15689`**, in
464+`every_drl_index_the_new_mv_pricer_offers_is_one_the_writer_can_signal`'s doc
465+comment. It names the deleted gate, both substitutes, the measurement and the
466+mutation proof. A second pointer was added at
467+**`crates/ec-av1/src/encode.rs:18618`** on the sb128 gate whose own doc had a
468+`cargo test` run-line still naming the deleted test -- a stale instruction left
469+by the deletion, caught by grepping for the name after the cut.
470+
471+### GENERAL RULE -- when a dead gate may be deleted, and when it may not
472+
473+> A gate whose precondition is unreachable is dead weight ONLY when BOTH of its
474+> halves are covered elsewhere. Here the pixel half is covered four times at
475+> the same geometry with the same own-reconstruction compare, and the
476+> precondition is covered by an invariant test that BOUNDS THE DOMAIN (stack
477+> sizes 0..=4) rather than sampling it -- `best_new_mv_syntax` breaks at
478+> `entries.len() <= idx`, so indices 3/4 are unreachable at any stack size.
479+> Had the pixel compare been unique, keeping the test with a fact-stating
480+> ignore string would have been the honest call; a deleted unique assertion is
481+> not recoverable from a report.
482+
483+The asymmetry is the whole rule. `#[ignore]` is nearly free -- a gate that
484+cannot fire is inert, and its doc comment still tells the next lane what was
485+tried. Deletion is not free and is not reversible from prose: once the function
486+is gone, the only surviving record of what it asserted is this report, and
487+nobody re-derives a coverage claim from a report. So the bar for deletion is
488+not "the assert cannot fire"; it is "the assert cannot fire AND everything
489+else the test did is provably done elsewhere". Check every other assertion in
490+the doomed test before cutting it, not just the one that is broken.
491+
492+### GENERAL RULE -- a deletion leaves references behind
493+
494+> Grep the name you removed, after you remove it.
495+
496+Cutting `a_128_superblock_clip_whose_drl_index_the_write_time_stack_cannot_carry_decodes_exact`
497+left a live `cargo test ... --nocapture` run-line in a sibling gate's doc
498+comment (`encode.rs:18619`) pointing at a test that no longer exists -- a
499+reviewer following it would get an empty run and a filter matching nothing,
500+with nothing in the output to say the gate had been retired on purpose. The
501+deletion looked complete because the symbol search came back with only the two
502+doc mentions I had written myself. It took grepping the bare name (not the
503+`fn` signature) to find the stale instruction. Same class as the other
504+doc-drift traps in this repo: a rename or removal is not done until the
505+prose points at what now exists.
506+
507+**What was deliberately NOT removed.** `note_drl_clamp` and `DRL_CLAMP_HITS`
508+stay. They are unreachable today, but they are the tripwire for the owning fix
509+(`deferred(unblock: the DRL owner widens `best_new_mv_syntax`'s offer set past
510+the writer's `start + 2` ceiling, or retires the counter)`): the invariant test
511+goes red the instant the offer set is widened, and `tile::drl_clamp_hits()`
512+(printed by `enc_probe`) then shows the clamp on real content. Deleting the
513+counter would have made the fix silent. The `#[cfg(test)]`
514+`take_drl_clamp_hits()` had no reader left and WAS removed -- the
515+non-destructive `drl_clamp_hits()` is the accessor that survives.
516+
517+## Re-verification of the three pins on merged main
518+
519+Run on the rebased tree at `aa0ac8c2` + this lane, RELEASE, **plain pass (no
520+`--ignored`)**, with a private `CARGO_TARGET_DIR=$HOME/.cache/cargo-target-rh`
521+and `touch` on the three edited sources first (the census/source-scan trap).
522+
523+```
524+test encode::tests::every_drl_index_the_new_mv_pricer_offers_is_one_the_writer_can_signal ... ok
525+a_real_aomenc_inter_sequence_with_an_intra_1to4_strip_decodes_pixel_exact (8-bit): 6 frames
526+ pixel-exact, intra 1:4 strips in inter frames 64x16=0 16x64=0 32x8=8 8x32=11
527+ (--enable-1to4-partitions=0 control: 0/0/0/0), stream 35179 B fnv1a64=86f8d1e5a221162a
528+test stream::tests::a_real_aomenc_inter_sequence_with_an_intra_1to4_strip_decodes_pixel_exact ... ok
529+a_real_aomenc_stream_..._horz_vert_partition_and_delta_q_decodes_pixel_exact: 4 frames
530+ pixel-exact, sb_rect_hits=40, rect64_qidx_drift_hits=17 (--deltaq-mode=0 control: 0),
531+ stream 8384 B fnv1a64=3d91a21680063ef6
532+test stream::tests::..._and_delta_q_decodes_pixel_exact ... ok
533+a_real_aomenc_inter_sequence_with_an_intra_1to4_strip_decodes_pixel_exact_10bit (10-bit):
534+ 6 frames pixel-exact, intra 1:4 strips in inter frames 64x16=0 16x64=0 32x8=12 8x32=7
535+ (--enable-1to4-partitions=0 control: 0/0/0/0), stream 34727 B fnv1a64=ecf9455bc20d60f0
536+test stream::tests::..._1to4_strip_decodes_pixel_exact_10bit ... ok
537+test result: ok. 4 passed; 0 failed; 0 ignored; 0 measured; 737 filtered out; finished in 4.71s
538+```
539+
540+* **`0 ignored`** -- the three gates now run in a plain pass, as they must once
541+ the recipes carry the coverage.
542+* Every pin byte-identical to r1 after the rebase onto 58 new commits:
543+ 8384 B / `3d91a21680063ef6`, 35179 B / `86f8d1e5a221162a`,
544+ 34727 B / `ecf9455bc20d60f0`. Wave 2 did not perturb aomenc's output on any
545+ of these three cells, which is the point of pinning.
546+* Each gate printed its self-evidencing line with the counter AND its control
547+ arm in the same line, so a reader can see from one line that the precondition
548+ fires and that the feature flag is what fires it.
549+* `cargo check --release -p ec-av1 --all-targets` clean on the rebased tree, no
550+ warnings.
lanes/av1rect8x16.report.mdadded+247 -0
@@ -0,0 +1,247 @@
1+# lane-av1rect8x16 — is `decode_block_rect`'s missing `(4, 8)` chroma arm a live refusal or a documented upstream gate?
2+
3+**Base:** `afa13bcff4a988534555a4ca34b84937d0b6036d` (branch `lane-av1rect8x16`, worktree `~/.cache/wt/av1rect8x16`).
4+**Verdict:** **(a) UNREACHABLE — documented upstream gate.** The claim is true about the `match` and false about the decoder: a 4:2:0 8x16 luma strip is never handed to `decode_block_rect` at all, so no conformant stream can reach the refusal. A conformant 4:2:0 stream that codes 8x16/16x8 luma strips decodes to completion; measured 826 of them.
5+
6+---
7+
8+## 0. The question, restated
9+
10+`decode_block_rect` (`decode.rs:14475`) ends its non-skip chroma read with
11+
12+```rust
13+let (chroma_set, chroma_scan): (TxbSet, &[u16]) = match (chroma_w, chroma_h) { // decode.rs:14788
14+ (32, 16) => (TxbSet::ChromaRect32x16, &SCAN_32X16),
15+ (16, 32) => (TxbSet::ChromaRect32x16, &SCAN_16X32),
16+ (16, 8) => (TxbSet::ChromaRect16x8, &SCAN_16X8),
17+ (8, 16) => (TxbSet::ChromaRect16x8, &SCAN_8X16),
18+ (16, 16) => (TxbSet::Chroma16, default_scan(16)),
19+ (8, 32) => (TxbSet::Chroma16, &SCAN_8X32),
20+ _ => {
21+ return Err(unsupported( // decode.rs:14804
22+ "a rectangular chroma transform whose size has no coefficient table",
23+ ));
24+ }
25+};
26+```
27+
28+`(chroma_w, chroma_h) == (bw >> ss_x(fctx), bh >> ss_y(fctx))` (`decode.rs:14680`). A 4:2:0 8x16 luma strip halves both axes to a 4x8 chroma block, `(4, 8)` has no arm, so the string would fire **if that shape reached the function**. The sibling test `every_rect_strip_shape_the_split_path_codes_has_a_luma_and_chroma_table` audits `decode_rect_split`'s tables, not this one, so it never asks.
29+
30+**State on arrival:** the string was in `REFUSALS` (`refusal_inventory.rs:50`) with **no `PROVEN` row** — the one unproven row this audit round was cataloguing.
31+
32+---
33+
34+## 1. CALLER SET, mechanically
35+
36+`decode_block_rect(` has **9 textual matches in the crate: 1 declaration + 8 call sites.** All 8 call sites are in one function, `read_sb128_root` (`decode.rs:32852`), and none is inside a `macro_rules!` body.
37+
38+The dispatch chain that reaches them:
39+
40+```
41+SB match PARTITION_SPLIT decode.rs:33651
42+ -> 4 x 32x32 quadrant (r32, c32) = (sb_r*2 + q/2, sb_c*2 + q%2) decode.rs:33652-33656
43+ -> part32 = dec.symbol(&mut cdfs.partition_w32[ctx32]) (BLOCK_32X32, bsize=9) decode.rs:33663-33674
44+ -> match part32 { decode.rs:33743
45+ PARTITION_HORZ | HORZ_A | HORZ_B | VERT | VERT_A | VERT_B ==> decode_block_rect
46+ PARTITION_SPLIT => 4 x 16x16 (sr, sc) decode.rs:33774-33778
47+ part16 = dec.symbol(&mut cdfs.partition_w16[ctx16]) (BLOCK_16X16, bsize=6) decode.rs:33801
48+ match part16 { ... } decode.rs:33844 / 33989 / 34037
49+```
50+
51+| # | call site | enclosing arm | upstream guard (verbatim) | `bw`/`bh` passed | can it be handed an 8x16 / 16x8 strip? |
52+|---|---|---|---|---|---|
53+| 1 | `decode.rs:34485` | `PARTITION_HORZ =>` | `match part32 {` at `decode.rs:33743`, `part32` read at `decode.rs:33674` from `cdfs.partition_w32[ctx32]` | `at32, 32, 16` | **No** — 32-level HORZ, two 32x16 strips |
54+| 2 | `decode.rs:34509` | same arm, frame-edge half | `if has_rows32 {` at `decode.rs:34508`; `has_rows32` from `has_half(r32 * BLOCK_MI, BLOCK_MI, mi_rows)` at `decode.rs:33661` | `(at32.0 + 1, at32.1), 32, 16` | **No** |
55+| 3 | `decode.rs:34531` | `PARTITION_VERT =>` | same `match part32` | `at32, 16, 32` | **No** |
56+| 4 | `decode.rs:34555` | same arm, frame-edge half | `if has_cols32 {` at `decode.rs:34554`; `has_cols32` from `has_half(c32 * BLOCK_MI, BLOCK_MI, mi_cols)` at `decode.rs:33660` | `(at32.0, at32.1 + 1), 16, 32` | **No** |
57+| 5 | `decode.rs:34634` | `PARTITION_HORZ_A =>` | `match part32` (`PARTITION_HORZ_A` is value 8, read from the same `partition_w32` symbol) | `(at32.0 + 1, at32.1), 32, 16` | **No** — the 32x16 is the third child of a 32x32 |
58+| 6 | `decode.rs:34658` | `PARTITION_HORZ_B =>` | `match part32` | `at32, 32, 16` | **No** |
59+| 7 | `decode.rs:34790` | `PARTITION_VERT_A =>` | `match part32` | `(at32.0, at32.1 + 1), 16, 32` | **No** |
60+| 8 | `decode.rs:34815` | `PARTITION_VERT_B =>` | `match part32` | `at32, 16, 32` | **No** |
61+
62+**The caller shape set is exactly `{(32, 16), (16, 32)}`, and every `bw`/`bh` is an integer literal — there is no variable, no computed size, no dispatch that could yield 8x16.** This is now asserted in code, not merely observed: `every_chroma_unit_decode_block_rect_can_present_has_a_coefficient_table` parses the argument lists out of `decode.rs` itself (§5).
63+
64+### Where an 8x16 / 16x8 luma strip ACTUALLY goes
65+
66+Every 16-level 2:1 luma strip is read by **`decode_leaf_rect`** (`decode.rs:15064`), which is a different function with the matching chroma rows:
67+
68+| 16-level route | call site | strip | reader |
69+|---|---|---|---|
70+| `part16 == PARTITION_HORZ` | `decode.rs:33995` / `34014` | `16, 8` x2 | `decode_leaf_rect` |
71+| `part16 == PARTITION_VERT` | `decode.rs:34044` / `34063` | `8, 16` x2 | `decode_leaf_rect` |
72+| `part16 ∈ HORZ_A..=VERT_B` via `ab_strip!` | `decode.rs:33942`, `33946`, `33963`, `33967` | `16, 8` / `8, 16` | `decode_leaf_rect` |
73+| frame-edge 8-mod-16 strip | `decode.rs:34336` | `(16, 8)` or `(8, 16)` per `if has_cols16 { (16, 8) } else { (8, 16) }` (`decode.rs:34334`) | `decode_leaf_rect` |
74+
75+`decode_leaf_rect` handles the 4:2:0 chroma half of exactly those strips — `(4, 8)` and `(8, 4)` — with `SCAN_4X8` / `SCAN_8X4` and `TxbSet::ChromaRect8x4` (`decode.rs:15409-15420`):
76+
77+```rust
78+} else if bw == 16 {
79+ (&SCAN_16X8, &SCAN_8X4)
80+} else {
81+ (&SCAN_8X16, &SCAN_4X8)
82+};
83+```
84+
85+So the `(4, 8)` arm is missing from a function that cannot be handed a 4x8, and present in the function that can.
86+
87+### Chroma-domain walk over the caller set
88+
89+For each caller shape, under each subsampling an AV1 `color_config` can carry:
90+
91+| caller | (ss_x, ss_y) | chroma `(bw>>ss_x, bh>>ss_y)` | arm? |
92+|---|---|---|---|
93+| 32x16 | (0,0) 4:4:4 | (32, 16) | yes |
94+| 32x16 | (1,0) 4:2:2 | (16, 16) | yes |
95+| 32x16 | (1,1) 4:2:0 | (16, 8) | yes |
96+| 16x32 | (0,0) 4:4:4 | (16, 32) | yes |
97+| 16x32 | (1,0) 4:2:2 | (8, 32) | yes |
98+| 16x32 | (1,1) 4:2:0 | (8, 16) | yes |
99+
100+`(0, 1)` is **structurally uncodable**: `ec-av1-syntax`'s `color_config` only reads `subsampling_y` when `subsampling_x == 1` (`crates/ec-av1-syntax/src/sequence.rs:480-485`), so that pair never exists. `(1, 0)` is 4:2:2, refused at the sequence header by `a_non_420_subsampled_sequence_header_is_refused_by_name` — walked anyway, so the proof does not lean on that guard. **The table is complete over the caller set. The refusal is dead code.**
101+
102+---
103+
104+## 2. EMPIRICAL — the decisive test
105+
106+Non-vacuity precondition: `HORZ_VERT_INTRA_HITS` fires at exactly three sites, `decode.rs:33990`, `34038`, `34330` — all three are `decode_leaf_rect` 16-level 2:1 strip routes. **A nonzero `horz_vert_intra_hits()` delta is therefore proof that the stream's parsed leaf list really contains a coded 16x8/8x16 luma strip**, not a proxy for it.
107+
108+Sweep: 7 sources (mandelbrot 64x64 / 128x128 / 130x122, testsrc2 64x64 / 128x128, rgbtestsrc, smptebars) x cq {16,22,28,34,42,52} x (`--cpu-used`, `--max-partition-size`) ∈ {(0,16),(0,32),(1,16),(3,32),(4,64)} x `--enable-ab-partitions` {0,1} x `--reduced-tx-type-set` {0,1}, always `--codec=av1 --passes=1 --end-usage=q --threads=1 --row-mt=0 --sb-size=64 --kf-max-dist=0 --enable-rect-partitions=1 --enable-1to4-partitions=0 --enable-cdef=0 --enable-restoration=0 --min-partition-size=8 --obu`, single yuv420p key frame from `ffmpeg -f lavfi`.
109+
110+```
111+SUMMARY attempts=840 decoded=840 streams_with_16lvl_strips=826 refusals_with_16lvl_strips=0
112+```
113+
114+| recipe family | parsed 16-level 2:1 luma strips | decode | `"a rectangular chroma transform…"` |
115+|---|---|---|---|
116+| 840 encodes (full grid above) | 826 of 840 streams carry ≥1 (3–20 each; cq 52 cpu=0 max=16 reached 20) | **840/840 `Ok`**, 1 frame each | **0 occurrences** |
117+| the 14 that carry none | 0 | 840 group total, all `Ok` | 0 |
118+
119+Three witness streams, each independently carrying coded 8x16/16x8 luma strips and each decoding `Ok`:
120+
121+| file | recipe | 16-lvl strips | sha256 | size |
122+|---|---|---|---|---|
123+| `w_cq34_cpu0_max16.obu` | mandelbrot 130x122, `--cq-level=34 --cpu-used=0 --min-partition-size=8 --max-partition-size=16 --enable-ab-partitions=1` | 17 | `6189103938308fac94fb027448f64d0cf3fc791968cf8aae4cb27a8d904f7ae8` | 1588 |
124+| `w_cq28_cpu1_max16.obu` | same, `--cq-level=28 --cpu-used=1` | 13 | `e32a7f0de4d6d339716d0410f304ba985e210111a37c80c5eabf36b2301839d9` | 1991 |
125+| `w_cq42_cpu0_max16.obu` | same, `--cq-level=42 --cpu-used=0` | 15 | `8fee40fdfa04b0a4904e9947343c494fbb9d6958827eefb169c9e1d1e87eb629` | 1063 |
126+
127+(Written to `~/.cache/av1rect8x16/`. **Not committed as a fixture**: outcome (a) needs no pin, and a fixture whose only job is to keep an unreachable guard unreachable is what the enumeration test is for.)
128+
129+**A refusal on a stream whose parsed leaves carry an 8x16 rect block would be the defect. That never happened — 0 refusals over 826 non-vacuous streams.**
130+
131+---
132+
133+## 3. VERDICT
134+
135+> **(a) UNREACHABLE.** The upstream gate is structural, not a size heuristic: all 8 call sites of `decode_block_rect` are 32-level `match part32` arms of `read_sb128_root` and pass `bw`/`bh` as the integer literals `32, 16` or `16, 32`, so the function's chroma footprint set is `{(16,8), (8,16), (16,16), (8,32), (32,16), (16,32)}` — all six of which have a row. A 4:2:0 8x16 luma strip's 4x8 chroma is read by `decode_leaf_rect`, not here, and that function carries the `(4, 8)` / `(8, 4)` rows itself. Measured over 840 real aomenc 4:2:0 key-frame encodes — 826 of which provably code a 16-level 2:1 luma strip — the refusal fires **0** times and every stream decodes to completion.
136+
137+**This is NOT a decoder capability defect. No conformant stream is refused by name.**
138+
139+### What the arm would have been (recorded, not added)
140+
141+For the record, had an 8x16 caller appeared, libaom *does* have the shape — so the row would be legitimate, not a fabrication:
142+
143+- `av1_ss_size_lookup[BLOCK_8X16][subsampling_x=1][subsampling_y=1] = BLOCK_4X8` — `~/.cache/aom-oracle/src/av1/common/common_data.c:24` (row 5 of the table; and `[BLOCK_16X8][1][1] = BLOCK_8X4` at `common_data.c:25`)
144+- `max_txsize_rect_lookup[BLOCK_4X8] = TX_4X8` — `~/.cache/aom-oracle/src/av1/common/common_data.h:130`
145+- chained by `av1_get_max_uv_txsize(bsize, subsampling_x, subsampling_y)` — `~/.cache/aom-oracle/src/av1/common/blockd.h:1372-1379`, which is `av1_get_tx_size`'s chroma branch (`blockd.h:1381-1388`)
146+
147+So the 4:2:0 chroma of an 8x16 luma block is a genuine single `TX_4X8` in libaom. `decode_leaf_rect` already decodes it (`SCAN_4X8` + `TxbSet::ChromaRect8x4`, `decode.rs:15412`/`:15419`). The `(4, 8)` row in `decode_block_rect` would be a duplicate of that path for a shape no caller produces.
148+
149+---
150+
151+## 4. Deliverable: the claim is now PROVEN by the tree, not argued in this file
152+
153+> **The 840-encode sweep in §2 is CORROBORATION, not the proof.** It shows the
154+> refusal does not fire on 826 streams that provably code the shape; it cannot
155+> show the shape is unreachable in a stream nobody encoded. The proof is the
156+> static caller-shape-set derivation in §1, and the deliverable below is what
157+> makes the tree enforce it rather than trusting this report.
158+
159+`refusal_inventory.rs` gained a `PROVEN` row for the string (it previously had
160+**none** — it was the audit round's single unproven row) and the test that proves
161+it, in the same file as the sibling enumeration.
162+
163+### Where the assertions live, and why not inside the sibling test
164+
165+Main asked for this to be folded into
166+`every_rect_strip_shape_the_split_path_codes_has_a_luma_and_chroma_table`. It is
167+shipped as a sibling test in the same file instead, because that test audits
168+`decode_rect_split`'s two `match` tables via a `depth_to_tx_wh` walk — it has no
169+caller-shape-set notion at all. Getting `decode_block_rect`'s domain requires a
170+paren-balanced argument splitter over the call sites (~60 lines) plus a
171+subsampling walk. Folding that in would have made the sibling test answer two
172+different claims and would have duplicated the parser to do it. The two tests
173+are adjacent and the `PROVEN` row names the new one, so the claim is still
174+asserted in exactly one place. Say the word and I will move it.
175+
176+### `every_chroma_unit_decode_block_rect_can_present_has_a_coefficient_table` (`refusal_inventory.rs:1571`)
177+
178+1. **Caller shape set**, read out of `decode.rs`'s own call-site argument lists
179+ with a paren/bracket-balanced splitter — the `at` argument is
180+ `(at32.0 + 1, at32.1)`, whose internal comma shifts every later index by one,
181+ so naive indexing reads `at32` as `bw` (I hit this). Asserts the site count
182+ (8) and requires `bw`/`bh` to be **integer literals**. This is the invariant
183+ that makes the whole argument true, and it is pinned in the shape this crate
184+ already uses for such scans: `include_str!("decode.rs")` read at
185+ compile time.
186+2. **The table**, read out of the function's own text, arm heads only
187+ (`(w, h) =>` / `(w, h) |`, never a `(32, 8)` inside prose).
188+3. **The walk** — every caller shape under every subsampling an AV1
189+ `color_config` can carry, `{(0,0), (1,0), (1,1)}`. Asserts a row for each.
190+4. **The exact-table pin**: the table is *exactly* those six rows — no row is a
191+ shape no caller can present, which is what makes the `_` arm dead.
192+5. **The residual as code, not a comment**: `(4, 8)` / `(8, 4)` are *not* rows,
193+ and no caller shape can produce them.
194+
195+The inventory summary moved from **32 proven to 33 proven**; all 16
196+`refusal_inventory` tests pass.
197+
198+### Ordering note (fixed mid-lane, kept)
199+
200+Steps 3 and 4 were first written the other way round, and the exact-table pin
201+masked the walk: deleting the `(16, 8)` arm failed with "the chroma table
202+changed" instead of naming the footprint. **The walk now runs before the pin**, so
203+a deleted arm fails naming the strip and its subsampling.
204+
205+### Non-vacuity: four red-befores, each reverted with `decode.rs` byte-identical
206+
207+This crate's census tests read compile-time sources via `include_str!`, so
208+`decode.rs` is `touch`ed before each re-run — otherwise a stale test binary can
209+report the previous state.
210+
211+| # | mutation | result |
212+|---|---|---|
213+| A | `decode.rs:14791` — delete the `(16, 8) =>` arm | **RED** at `refusal_inventory.rs:1705` — `a 32x16 strip at subsampling (1,1) has a 16x8 chroma transform with no coefficient table -- the chroma refusal is LIVE` |
214+| B | `decode.rs:14801` — delete the `(16, 16) =>` arm (the 4:2:2 row) | **RED** at `refusal_inventory.rs:1705` — `a 32x16 strip at subsampling (1,0) has a 16x16 chroma transform with no coefficient table -- the chroma refusal is LIVE` |
215+| C | `decode.rs:34536` — the `PARTITION_VERT` call site's `16,` → `8,` (an 8x16 caller appears) | **RED** at `refusal_inventory.rs:1647` — `the set of strip sizes decode_block_rect is called with changed -- re-derive the chroma domain below. An 8x16/16x8 caller makes this refusal LIVE` |
216+| D | `decode.rs:34490` — `32,` → `at32.0 * 2,` (a call site stops being a literal) | **RED** at `refusal_inventory.rs:1631` — `decode_block_rect is called with a non-literal strip size "at32.0 * 2" -- this enumeration can no longer read the caller shape set` |
217+
218+A and B are the row-coverage arm (they fail **naming the footprint**); C and D
219+are the caller-set invariant (they fail before the table is even consulted).
220+Restored byte-identical after each; `git status` shows
221+`refusal_inventory.rs` as the only modified file.
222+
223+### What makes the claim survive a future edit
224+
225+- A new caller with a different size → **C** fires (shape set changed).
226+- A caller whose size stops being a literal → **D** fires, because a variable
227+ could be anything and the enumeration must not silently under-count.
228+- A row deleted → **A**/**B** fires, naming the strip and subsampling.
229+- A row *added* for a shape no caller presents → step 4 fires, and step 5 fires
230+ if it is `(4, 8)` / `(8, 4)`.
231+
232+---
233+
234+## 5. Scope and hygiene
235+
236+- No existing test weakened, renamed, or re-pinned. Net diff vs the lane base
237+ `afa13bcf`: `crates/ec-av1/src/refusal_inventory.rs` **+246 / -0** (the new
238+ `PROVEN` row plus the new test) and this report.
239+- `decode_rect_split` and `read_block_tx_size` untouched (other lanes own them). `decode.rs` untouched.
240+- `decode_block_rect` itself untouched — the refusal stays as a named shape guard for the next caller, the repo convention for a proven-unreachable guard (same as `a_sb_level_horz_vert_strip_admits_no_filter_intra_symbol`).
241+- The scratch sweep lived in two `#[ignore]`d tests, ran, and were deleted; the tree diff is the 246-line addition above.
242+- Main untouched: `git -C /home/user/Documents/Code/Rust/edith_codecs status --porcelain` shows no tracked-file modification from this lane. Never pushed.
243+
244+
245+## 6. Checked and CLEARED (recorded so it is not re-opened)
246+
247+`decode_leaf_rect` reads a 4:2:0 8x16 strip's 4x8 chroma with `TxbSet::ChromaRect8x4` + `SCAN_4X8`, while libaom's `get_txsize_entropy_ctx(TX_4X8)` reduces to the **8x8 square** set — a name that looks like a possible disagreement. It is not one: `Cdfs::txb` resolves `TxbSet::ChromaRect8x4` (`cdf_state.rs:2116`) to the *same* 8x8 chroma CDFs as `TxbSet::Chroma8` (`cdf_state.rs:1852`) — `txb_skip_chroma_8`, `eob_extra_chroma_8`, `base_chroma_8`, `base_eob_chroma_8`, `br_chroma_8`, `dc_sign_chroma`, `tx_type: None`, `side: 8` — differing only in the end-of-block group (`eob_pt_32_chroma` / `eob_pt_32_chroma_class1`, the rect-appropriate EOB_PT_32, versus `eob_pt_64_chroma`). The entropy set is the square-up one, as libaom has it; the variant name is a convenience for the distinct EOB table.
lanes/av1skipfix.report.mdadded+140 -0
@@ -0,0 +1,140 @@
1+# lane-av1skipfix — convert skip-on-decode-error gates; audit fixture provenance
2+
3+Branch `lane-av1skipfix` off `a21f3680`. Tests only: no file under
4+`crates/ec-av1/src/decode.rs` was touched, and no decoder logic changed anywhere.
5+
6+## Defect 1 — four `..._decodes_pixel_exact` gates turned a decode error into a printed SKIP
7+
8+Pinned as a set in `refusal_inventory.rs` (`GATES_THAT_SKIP_ON_A_DECODE_ERROR`).
9+Each one ran a single recipe and, on `Err`, printed `SKIP <name>: {e}` and returned
10+green. Converted to the attempt-loop shape already used elsewhere in `stream.rs`:
11+sweep several recipes, count a named refusal per attempt (never swallow it), ALWAYS
12+pixel-compare an attempt that decoded, and hard-assert the feature counter on a
13+pixel-compared attempt. Exhausting every attempt is a hard failure, not a skip.
14+
15+| gate | counter | recipes | decoded+fired (green run) |
16+|---|---|---|---|
17+| `a_real_aomenc_filter_intra_stream_decodes_pixel_exact` | `filter_intra_hits` | 2 seeds × 3 cq | 2 |
18+| `a_real_aomenc_intra_stream_with_deblocking_decodes_pixel_exact` | `deblock_hits` | 2 seeds × 4 cq | 2 |
19+| `a_real_aomenc_inter_sequence_with_deblocking_decodes_pixel_exact` | `deblock_hits` | 2 seeds × 4 cq | 2 |
20+| `a_real_libaom_gradients_stream_with_cdef_decodes_pixel_exact` | `cdef_idx_hits` | 8 × (size, cpu-used, crf) | 2 |
21+
22+All four run under `lock_gate_counters()` and report the three-bucket
23+`gate_buckets` summary, so the buckets sum to the attempts made.
24+
25+### Measurements (this box, 2026-09-29, base `a21f3680`)
26+
27+- **filter intra** — seed 42 cq 40 and seed 43 cq 40 read `use_filter_intra` 3× each,
28+ pixel-exact. seed 44 cq 45 and seed 45 cq 30 **decode without it** (delta 0), so the
29+ one fixed recipe was carrying the whole gate.
30+- **intra deblock** — cq 55/45/35/63 all decode pixel-exact with 48/64/64/64 deblock edges.
31+- **inter deblock** — cq 55/45/35/63 all decode 4 frames pixel-exact with
32+ 208/224/160/208 deblock edges.
33+- **CDEF** — the old recipe was a **single 64×64 frame**, which gives libaom's cdef
34+ search exactly one superblock, so it can never write `cdef_bits > 0` and the gate
35+ never read a `cdef_idx` at ANY crf / cpu-used (0, 2, 4, 8 × crf 10–60, sizes
36+ 64×64…256×128: delta 0 everywhere). `EC_AV1_CDEF_DBG` shows `apply_cdef` *does* filter
37+ there (nonzero `t`, `pri=11`/`pri=2`), but the gate's own firing proof is
38+ `cdef_idx_hits`, so its premise was unfalsifiable on the recipe it shipped. The
39+ recipe list is now multi-SB and multi-frame: 128×64/128×128 at 24 frames read
40+ 2–8 `cdef_idx` and are pixel-exact against ffmpeg.
41+
42+No recipe in any of the four families failed to decode for a capability reason, so
43+**no entry had to be kept**; the inventory list is now empty and stays an exact pin.
44+
45+### Red-before (each mutation reverted after the run)
46+
47+| mutation | result |
48+|---|---|
49+| `--enable-filter-intra=0` in the filter-intra recipe | `none of 6 attempts decoded a stream that read use_filter_intra` — FAILED |
50+| `--loopfilter-control=0` in the intra-deblock recipe | `buckets counted-exact=0 uncounted-exact=8`; `none of 8 attempts … with a deblocking edge` — FAILED |
51+| `--loopfilter-control=0` in the inter-deblock recipe | same, FAILED |
52+| original 64×64/1-frame CDEF recipe restored | `buckets counted-exact=0 uncounted-exact=8`; `no attempt of 8 read a cdef_idx literal` — FAILED |
53+| one `SKIP <name>: {e}` arm re-added to a converted gate | `gates_that_swallow_a_decode_error_are_declared` FAILED, naming that gate |
54+
55+Note the mutation runs report `uncounted-exact=8`: the eight attempts still ran real
56+pixel compares, so the compare is load-bearing and the counter assert is what bites.
57+
58+## Defect 2 — `a_real_aomenc_lossless_444_key_frame_decodes_sample_exact` reported green on a missing pin
59+
60+Its pinned fixture `fixtures/ll444-lossless-key.obu` does not exist: not in git, not
61+in the root `fixtures/` directory on this box, and no script under `scripts/` produces
62+it. The `Err` arm was a bare SKIP, so the test finished in 0.05 s (its siblings take
63+seconds — it had decoded nothing) and the suite reported green.
64+
65+The root `fixtures/` directory is listed in `.gitignore:2`, so a pin that lands there
66+can never be committed and a fresh clone can never have it; every `~/.cache/wt/*`
67+worktree lacks it for the same reason. Committing a fixture is therefore not available
68+as a fix, and the gate is not deleted. The arm keeps its skip but `EC_AV1_REQUIRE_AOMENC=1`
69+now turns it into a hard failure naming the missing path, the exact regeneration recipe
70+and the `EC_AV1_PIN_DIR` override; the skip line itself says the gate decoded nothing
71+and proves nothing. Smallest possible hunk: the arm only, no gate body below it.
72+
73+## Fixture-generator audit (this lane's manifest)
74+
75+| referenced path | on disk | generator |
76+|---|---|---|
77+| `fixtures/video/*.mp4/.mkv` | present | `scripts/gen-fixtures.sh` (deterministic ffmpeg) — OK |
78+| `crates/ec-av1/fixtures/*.obu` (48, committed) | present | **NONE** — provenance lives only in gate doc comments / lane reports |
79+| root `fixtures/*.obu` pins: `golden6-mismatch`, `golden7-forwarding-mismatch`, `lr-sgr-r7`, `golden4-pin` | present | **NONE**, and gitignored so not committable |
80+| root `fixtures/*.obu` pins: `ll444-lossless-key`, `golden3-pin`, `sbpart-pin` | **missing on this box** | **NONE** (`golden3-pin` and `sbpart-pin` gates are `#[ignore]`d — the honest shape) |
81+
82+So of the ~55 distinct AV1 fixtures these tests name, **every `.obu`/`.av1` pin has no
83+generator script**; only the container fixtures do. The pin directory is also split
84+across two homes (`crates/ec-av1/fixtures/`, committed, 48 files) and the root
85+`fixtures/`, gitignored — and `pin_dir()` resolves to the gitignored one, so any pin
86+written there is un-reproducible on a fresh clone by construction.
87+
88+## Defect 3 — the root cause: a worktree has no `fixtures/` at all
89+
90+`fixtures/` is `.gitignore:2`, so `git worktree add` hands every lane worktree a tree
91+without it. Not one gate in ec-av1/ec-h264/ec-flac/ec-opus checks that before skipping,
92+so a worktree run measures nothing while looking clean. Fixed on both halves:
93+
94+- **(b) root cause** — `scripts/link-fixtures.sh` resolves the primary checkout through
95+ `git rev-parse --git-common-dir` (works from any linked worktree), symlinks its
96+ `fixtures/` in, no-ops with a message when the directory already exists, and refuses
97+ loudly (exit 2) when the primary has none. `--check` is the preflight. Verified in a
98+ synthetic repo+worktree: links, is idempotent, and refuses with the generator names.
99+ Documented in `lanes/COMMON-20260901.md` beside the batch env line.
100+- **(a) the assert** — `EC_REQUIRE_FIXTURES=1` (default off, set in every batch unit by
101+ the parent) turns each missing-fixture skip into a hard failure naming the path, the
102+ generator when one exists, and `scripts/link-fixtures.sh` when the real cause is the
103+ missing root directory.
104+
105+### Per-crate assert sites
106+
107+| file:line | shape before | shape after | red proof | green proof |
108+|---|---|---|---|---|
109+| `crates/ec-h264/tests/conformance.rs:299` (`jvt_cavlc_first_idr_bit_exact`) | `!base.is_dir()` → `SKIP: … missing — run scripts/fetch-vectors.sh` | `require_fixtures(&base, "the JVT conformance vectors", "scripts/fetch-vectors.sh")` | `EC_REQUIRE_FIXTURES=1`, `fixtures/` unlinked → panics "the JVT conformance vectors missing at …/vectors/h264-jvt — this gate would prove nothing" | linked: 1 passed (1.58s) |
110+| `crates/ec-h264/tests/conformance.rs:406` (`steady_state_decode_loop_zero_alloc`) | `!base.is_dir()` → `SKIP: fixtures missing` | same helper | same env/path | linked: 1 passed (0.73s) |
111+| `crates/ec-h264/tests/conformance.rs:490` (`ns_per_macroblock_measurement`) | `!base.is_dir()` → `SKIP: fixtures missing` | same helper | same env/path | linked: 1 passed (9.94s) |
112+| `crates/ec-h264/tests/conformance.rs:574` (`corrupt_streams_never_panic`) | `!base.is_dir()` → `SKIP: fixtures missing` | same helper | same env/path | linked: 1 passed (20.85s) |
113+| `crates/ec-h264/tests/conformance.rs:1080` (`jvt_full_sequence_bit_exact`) | `!base.is_dir()` → `SKIP: … missing` | same helper | same env/path | linked: 1 passed (5.59s) |
114+| `crates/ec-h264/tests/conformance.rs:2323` (`h264_seek_matches_linear_open_gop`) | `!src.is_file()` → `SKIP: no fixtures/video/h264-open-gop.mp4 (run scripts/gen-fixtures.sh)` | same helper, generator `scripts/gen-fixtures.sh` | `EC_REQUIRE_FIXTURES=1` → panics "the open-GOP fixture missing at …/video/h264-open-gop.mp4" | linked: 1 passed (0.75s) |
115+| `crates/ec-flac/tests/xiph_vectors.rs:24` (`corpus()`, all 4 gates) | `read_dir().ok()?` → `None` → each gate `eprintln!("skipped: …")` + return | assert in `corpus()` itself — the one place that knows the path — so 4 gates, 1 hunk | `EC_REQUIRE_FIXTURES=1` → panics "the FLAC xiph subset corpus is missing at …/subset" | linked: 4 passed (32.0s) |
116+| `crates/ec-opus/tests/conformance.rs:425` (`rfc6716_test_vectors`) | `!path.exists()` → `eprintln!("{name}: missing, skipped")` + `continue` (no env at all) | per-vector assert naming path + `scripts/link-fixtures.sh` + `scripts/fetch-vectors.sh` | `EC_REQUIRE_FIXTURES=1` → panics "RFC 6716 test vector testvector01 missing at …/opus_testvectors/testvector01.bit" | linked: 1 passed (179.2s) |
117+| `crates/ec-av1/src/stream.rs:6500` (`a_real_aomenc_lossless_444_key_frame_decodes_sample_exact`) | `Err` → `SKIP … -- regenerate with …` (gate ran 0.05s, decoded nothing) | assert naming path + `scripts/link-fixtures.sh` + regeneration recipe + `EC_AV1_PIN_DIR`; fires on `EC_REQUIRE_FIXTURES` **or** `EC_AV1_REQUIRE_AOMENC` | `EC_REQUIRE_FIXTURES=1` → panics "the pinned 4:4:4 lossless key frame is missing at …/ll444-lossless-key.obu" | default: SKIP with the recipe; both envs: FAILED |
118+
119+Deliberately **not** converted: the `if path.exists()` arms in ec-opus at 740/1852
120+(optional-input blocks inside tests that assert nothing on them) and the
121+`~/Music/…` skips at 4985/5378/5607 (personal media, not a fixture manifest — failing
122+those on every box would be its own lie).
123+
124+### Provenance hand-off
125+
126+The enumeration above is Agent18-2's input for `scripts/fixture-library.tsv`; this lane did
127+not build the manifest. What the assert messages now guarantee is that every gate that
128+reads a fixture names the path it wanted, the generator when one exists, and
129+`scripts/link-fixtures.sh` when the cause is the missing root directory.
130+
131+## Commits
132+
133+- `cd81750b` — stream: convert the four skip-on-decode-error gates to attempt loops
134+- `0b92c6da` — refusal_inventory: empty GATES_THAT_SKIP_ON_A_DECODE_ERROR
135+- `3c302798` — stream: a_real_aomenc_lossless_444_key_frame stops reporting green on a missing pin
136+- `62c04b70` — scripts: link-fixtures.sh — give a worktree the gitignored root fixtures/
137+- `423ce6be` — stream: the 444 pin arm also honours the repo-wide EC_REQUIRE_FIXTURES
138+- `ae94ee6a` — ec-h264: a missing conformance vector FAILS under EC_REQUIRE_FIXTURES
139+- `d853d31a` — ec-flac: a missing xiph corpus FAILS under EC_REQUIRE_FIXTURES
140+- `3f94c60d` — ec-opus: a missing RFC 6716 vector FAILS under EC_REQUIRE_FIXTURES
lanes/av1superhbd.report.mdadded+233 -0
@@ -0,0 +1,233 @@
1+# lane-av1superhbd — 4:4:4 SUPERRES at 10-bit and 12-bit
2+
3+**Verdict: EXACT at both depths. Five gates added, all green, all mutation-proved red-before.**
4+
5+Branch `lane-av1superhbd` (base `a21f3680`); the gate+fixture commit is the
6+parent of this report's commit.
7+Oracle: libaom `v3.13.3-7-g9bb526a` (`~/.cache/aom-oracle/build/aomdec`).
8+
9+---
10+
11+## 1. Parsed headers — read from each stream's OWN sequence/frame header
12+
13+Every number below comes from `ec_av1_syntax`'s `Av1Parser` walking the pinned
14+bytes, never from the encoder flags. A stream that parses `use_superres=false`
15+was discarded, not pinned.
16+
17+### Accepted (all five)
18+
19+| stream | bytes | sha256 | SEQ `bit_depth` | SEQ `ss` | SEQ `enable_superres` | per-frame `use_superres` | per-frame `superres_denom` | per-frame `upscaled_width` | per-frame coded `frame_width x frame_height` |
20+|---|---|---|---|---|---|---|---|---|---|
21+| `444_lossy_superres_256x128_d12_10bit.obu` | 15803 | `95b49d7aa81843399ee3aa64bdadfec8f4037bcc3f861923c9b2da3bc868b223` | 10 | (0,0) | true | true x4 | 12, 12, 12, 12 | 256, 256, 256, 256 | 171x128 x4 |
22+| `444_lossy_superres_mode2_256x128_10bit.obu` | 17776 | `699398aba58fb53b80e05d3d214eb746a3c91945e01da6b47488513f20b55668` | 10 | (0,0) | true | true x4 | 11, 14, 15, 9 | 256, 256, 256, 256 | 186x128, 146x128, 137x128, 228x128 |
23+| `444_lossy_superres_256x128_d12_12bit.obu` | 11023 | `973bf374c0185c4e6301509ce834cef01318e6cdb9488fd258118d7ec89bdd04` | 12 | (0,0) | true | true x4 | 12, 12, 12, 12 | 256, 256, 256, 256 | 171x128 x4 |
24+| `444_lossy_superres_256x128_d9_12bit.obu` | 13015 | `898c775108495b998cb5ec9b08e194d4656ed0140aa8e7e7236892d468bbad99` | 12 | (0,0) | true | true x4 | 9, 9, 9, 9 | 256, 256, 256, 256 | 228x128 x4 |
25+| `444_lossy_superres_mode2_256x128_12bit.obu` | 14656 | `18aa8b3124ab10672f22577a8eea81e44141a3d0bb506104aee2f950254a2e9f` | 12 | (0,0) | true | true x4 | 11, 14, 15, 9 | 256, 256, 256, 256 | 186x128, 146x128, 137x128, 228x128 |
26+
27+Scaled-size arithmetic re-derived per frame and held on all 20 frame headers:
28+`(upscaled_width*8 + denom/2)/denom == frame_width` —
29+`(256*8+6)/12 = 171`, `(256*8+1)/9 = 228`, `(256*8+5)/11 = 186`,
30+`(256*8+7)/14 = 146`, `(256*8+7)/15 = 137`.
31+
32+### Discarded
33+
34+Nothing was discarded for `use_superres=false` — every stream above was built
35+with an explicit `--superres-denominator` / `--superres-kf-denominator` pair, so
36+the libaom no-op (denominator flag absent -> denom 8, nothing scaled) could not
37+occur. The two mode-2 arms carry denominators 11/14/15/9, three of which no
38+command-line flag ever named, which is itself the proof that the headers are
39+what the gates read.
40+
41+---
42+
43+## 2. Verdicts — exactness against the instrumented oracle
44+
45+Frame counts and per-frame byte lengths are asserted by
46+`decode_all_frames_vs_oracle` BEFORE the pixel compare; it writes
47+`EC_AV1_FINAL_DUMP` frames on both sides and compares them byte-for-byte in
48+DECODE order, so a frame-length mismatch is a hard failure, not a short compare.
49+
50+| gate | frames compared | hidden | divergent | `superres_hits` delta | `predict_scaled_hits` delta |
51+|---|---|---|---|---|---|
52+| `a_444_lossy_superres_10bit_d12_stream_decodes_pixel_exact` | 4/4 | 0 | **0** | 4 | 2097 |
53+| `a_444_lossy_superres_10bit_mode2_random_denom_stream_decodes_pixel_exact` | 4/4 | 0 | **0** | 4 | 2181 |
54+| `a_444_lossy_superres_12bit_d12_stream_decodes_pixel_exact` | 4/4 | 0 | **0** | 4 | 1311 |
55+| `a_444_lossy_superres_12bit_d9_stream_decodes_pixel_exact` | 4/4 | 0 | **0** | 4 | 1956 |
56+| `a_444_lossy_superres_12bit_mode2_random_denom_stream_decodes_pixel_exact` | 4/4 | 0 | **0** | 4 | 1737 |
57+
58+`test result: ok. 5 passed; 0 failed; 0 ignored` (712 filtered out).
59+
60+---
61+
62+## 3. Gates
63+
64+`crates/ec-av1/src/stream.rs`, one shared body `a_444_hbd_superres_arm` plus
65+five `#[test]` arms. Every arm asserts:
66+
67+- the pinned bytes (length + FNV-1a), read at full decode order;
68+- `ss (0,0)` from the sequence header, and **`bit_depth` equal to the depth the
69+ gate names** — the high-bit-depth claim is otherwise unprovable, because a
70+ mistyped `--bit-depth` still yields a decodable scaled 4:4:4 stream, just at
71+ a different cell (the same phantom-cell trap as the `use_superres=false`
72+ case lane-av1444edge r3 recorded);
73+- `enable_superres` on the sequence header and `use_superres` on every parsed
74+ frame header;
75+- the per-frame PARSED `superres_denom` against a `(denominator, coded width)`
76+ table in decode order, the upscaled size, and the coded size;
77+- `FrameWidth == (UpscaledWidth*8 + denom/2)/denom` re-derived from that frame's
78+ own parsed denominator — not a literal comparison alone, so a re-pinned
79+ fixture cannot satisfy the numbers while the scaled-size arithmetic moves
80+ under them;
81+- `superres_hits` and `predict_scaled_hits` as **DELTAS** (both are
82+ process-wide counters with no reset, so absolute values would pass on residue
83+ from another stream);
84+- every returned frame at the UPSCALED size with full-resolution 4:4:4 chroma
85+ plane lengths, and every sample bounded by `(1 << bit_depth) - 1` — a decoder
86+ that produced 8-bit values padded into a `u16` plane would satisfy every
87+ geometry assert and only be caught here;
88+- all decode-order frames byte-exact against the instrumented `aomdec`.
89+
90+The two mode-2 arms add the **distinct-denominator assert** the charter asked
91+for: `distinct.len() >= 3` across the parsed denominators, and at least one
92+denominator not in `{9, 12, 16}`. So neither arm can silently stop being a
93+scaled, multi-ratio cell — a libaom that collapsed mode 2 onto one denominator,
94+or started honouring `--superres-denominator` under mode 2, turns the arm red
95+instead of quietly re-pinning it into a different claim.
96+
97+### Red-before (both mutations on the committed tree, then reverted)
98+
99+| mutation | site | result |
100+|---|---|---|
101+| tap alignment in the upscale filter: `let idx = base + int_pel + k as i64 + 1;` | `superres.rs:141` (`upscale_row`) | **5/5 RED at pixel level.** e.g. 10-bit d12: `decode-order frame 0 of 4 differs from the oracle at byte 0 (ours 40 vs 38), 54916 bytes differ`; 10-bit mode-2: `byte 0 (ours 41 vs 40), 53206 bytes differ` |
102+| counter: `note_upscaled_picture` body emptied (`hit!(SUPERRES_HITS)` removed) | `superres.rs:188` | **5/5 RED** on the non-vacuity assert: `zero superres_hits -- the upscaler never ran (class gate-blind-to-feature)` |
103+
104+Both reverted; `git status --porcelain` clean; the five gates re-run green on
105+the committed tree afterwards.
106+
107+---
108+
109+## 4. Recipes
110+
111+`-strict -1` is load-bearing on the y4m pipe: without it ffmpeg refuses to
112+write `yuv444p10le` / `yuv444p12le` at all (zero bytes out).
113+
114+10-bit (`testsrc2`, both arms):
115+
116+```text
117+ffmpeg -f lavfi -i "testsrc2=size=256x128:rate=25" -frames:v 4 \
118+ -pix_fmt yuv444p10le -strict -1 -f yuv4mpegpipe - | \
119+aomenc --codec=av1 --profile=1 --bit-depth=10 --input-bit-depth=10 \
120+ --passes=1 --end-usage=q --cq-level=20 --cpu-used=2 --threads=1 \
121+ --row-mt=0 --lag-in-frames=0 --kf-max-dist=100 --limit=4 \
122+ --superres-mode=1 --superres-denominator=12 \
123+ --superres-kf-denominator=12 --obu -o - -
124+```
125+
126+Swap the last three lines for `--superres-mode=2 --obu -o - -` for the mode-2 arm.
127+
128+12-bit (`mandelbrot`, see §5):
129+
130+```text
131+ffmpeg -f lavfi -i "mandelbrot=size=256x128:rate=25" -frames:v 4 \
132+ -pix_fmt yuv444p12le -strict -1 -f yuv4mpegpipe - | \
133+aomenc --codec=av1 --profile=1 --bit-depth=12 --input-bit-depth=12 \
134+ --passes=1 --end-usage=q --cq-level=20 --cpu-used=2 --threads=1 \
135+ --row-mt=0 --lag-in-frames=0 --kf-max-dist=100 --limit=4 \
136+ --superres-mode=1 --superres-denominator=<9|12> \
137+ --superres-kf-denominator=<9|12> --obu -o - -
138+```
139+
140+Byte-reproducible: two independent encodes of the 12-bit den=12 recipe produced
141+the same 11023 bytes, sha256 `973bf374…`.
142+
143+---
144+
145+## 5. The 12-bit source: `mandelbrot`, not `testsrc2`
146+
147+`testsrc2` at 12 bits parses `allow_screen_content_tools = true` on every
148+frame, which the crate refuses by name
149+(`a 12-bit frame with screen content tools (allow_screen_content_tools=1: …)`)
150+— palette and intrabc have no 12-bit witness. The identical recipe at **10 bits**
151+does not trip it, so the flag set is not the variable; the source content is.
152+
153+Flag-combination attempt table, all read from the pinned-then-parsed headers
154+(same geometry, same 12-bit depth, `--superres-mode=1 --superres-denominator=12`):
155+
156+| attempt | `allow_screen_content_tools` (parsed) | our decoder |
157+|---|---|---|
158+| `testsrc2` yuv444p12le, base flags | true | REFUSED by name |
159+| + `--enable-palette=0 --enable-intrabc=0` | true | REFUSED by name |
160+| + `--tune-content=film` | true | REFUSED by name |
161+| + both, `--tune-content=film` | true | REFUSED by name |
162+| `--cpu-used=8` | true | REFUSED by name |
163+| `--cq-level=40` | true | REFUSED by name |
164+| `testsrc` yuv444p12le | true | REFUSED by name |
165+| `mandelbrot` yuv444p12le | **false** | **decodes, 4 frames 256x128** |
166+| `nullsrc` yuv444p12le (135-byte stream) | false | decodes — but vacuous, no content |
167+
168+Root cause in the oracle source, so the next lane does not re-derive it:
169+`av1_set_screen_content_options` (`av1/encoder/encoder.c:2427`) defers to
170+`encoder_utils.c:1153`, which keys the decision on the **first pass's
171+palette-pixel ratio**, not on `--enable-palette` / `--enable-intrabc` /
172+`--tune-content`. A photographic source keeps the ratio below threshold.
173+Recorded in the gate doc comment as well.
174+
175+---
176+
177+## 6. Correction to `lanes/av1formatsweep.report.md`
178+
179+The not-measured list is closed for this cell. Proposed replacement text only —
180+this lane does not edit that file (another lane corrected parts of it today and
181+the merge must apply cleanly).
182+
183+**Line 83** (the 4:4:4 matrix row) — current:
184+
185+```markdown
186+| superres | – | – | – |
187+```
188+
189+proposed:
190+
191+```markdown
192+| superres | Y (5 gates, `444_lossy_superres_*` pins) | **Y (gates, this lane)** | **Y (gates, this lane)** |
193+```
194+
195+**Line 493** (§6.5 "Still not measured after this round") — current fragment:
196+
197+```markdown
198+Still not measured after this round: 4:4:4 at 10/12 bits with **tile rows
199+actually enabled** (needs a >= 256-high geometry — trap 2); 4:4:4 superres at
200+10/12 bits; 4:4:4 odd dims at 10/12 bits and at dimensions other than 66x66 /
201+```
202+
203+proposed:
204+
205+```markdown
206+Still not measured after this round: 4:4:4 at 10/12 bits with **tile rows
207+actually enabled** (needs a >= 256-high geometry — trap 2); 4:4:4 odd dims at 10/12 bits and at dimensions other than 66x66 /
208+```
209+
210+**Line 438** (§6.2 table) — the `sr444` DIVERGENT row predates lane-av1444edge
211+r3, which showed that stream passes `--superres-mode=1` with no denominator and
212+therefore parses `use_superres=false denom=8` on all four frames: it was never a
213+scaled cell. The 8-bit 4:4:4 superres coverage is `lane-av1superpin`'s
214+(`444_lossy_superres_256x128_d12.obu`, `_d9`, `_mode2`). I did not touch this
215+row — that correction belongs to the lane that made the measurement, and it is
216+already landed on `lane-av1superpin` (`9646f74d` "correct the published cells
217+the superres no-op got wrong"). Flagged here only so the merge does not
218+reintroduce the stale `D` next to the new `Y`s.
219+
220+---
221+
222+## 7. What is NOT claimed
223+
224+- Only 4:4:4 (`ss 0,0`) at 10 and 12 bits, 256x128 upscaled geometry, lossy
225+ cq-20 cpu-used-2, and denominators 9/11/12/14/15. Not claimed: 4:2:0 HBD
226+ superres (the sweep's `sr420_12` already covers 4:2:0 12-bit), lossless HBD
227+ superres, tile-geometry interaction, or any other source.
228+- The 12-bit arms run on `mandelbrot` content only. `testsrc2`-class content at
229+ 12 bits is still refused by the screen-content gate — that refusal is
230+ unchanged and this lane did not touch it.
231+- Frame counts are 4 per stream, all shown, zero hidden; these are
232+ `--lag-in-frames=0 --auto-alt-ref` default single-layer streams, so the
233+ hidden-frame arm of the oracle compare is exercised but has nothing to find.
lanes/av1superpin.report.mdadded+301 -0
@@ -0,0 +1,301 @@
1+# lane-av1superpin — the last two measured-exact 4:4:4 superres members, and the correction of a cell that measured a no-op
2+
3+**Base** `4c973b94` (lane-av1444edge r3 tip). **Branch** `lane-av1superpin`,
4+worktree `~/.cache/wt/v444pin`. Two commits:
5+
6+| commit | what |
7+|---|---|
8+| `e47d8f60` | the two gates + the two pinned fixtures |
9+| (this file) | the `lanes/av1formatsweep.report.md` corrections |
10+
11+**Oracle** `~/.cache/aom-oracle/build/{aomenc,aomdec}`, built from the
12+`scripts/build-aom-oracle.sh` source tree at libaom
13+**`v3.13.3-7-g9bb526a`** (`git describe` in `~/.cache/aom-oracle/src`, HEAD
14+`9bb526a`). **Not** established via `aomenc --version`: that build does not
15+accept `--version` as a flag, so the revision is read off the source tree the
16+binary was compiled from. All measurements below: `CARGO_TARGET_DIR=$HOME/.cache/cargo-target`,
17+`EC_NOMEMGUARD=1 EC_AV1_REQUIRE_AOMENC=1`, `--test-threads=1`,
18+`--nocapture`.
19+
20+**Inherited, not re-derived.** The flag sweep in
21+`lanes/av1444edge.report.md` §11 and the "byte-exact 4/4 on all four scaled
22+streams" claim are that lane's measurements and are cited as inherited. What
23+this lane re-verified itself is stated as such in §2: the two streams it
24+encodes were re-encoded from the recipes and their frame headers re-parsed
25+here.
26+
27+---
28+
29+## 1. The flag-vs-parsed-header table
30+
31+Flags as issued on the command line vs what the stream's OWN parsed frame
32+header says. Every row below was produced by encoding the recipe on this
33+oracle and parsing the result; the verdict column is never the flag.
34+
35+Source: `testsrc2=size=256x128:rate=25 -frames:v 4 -pix_fmt yuv444p`,
36+common encode flags `--codec=av1 --passes=1 --end-usage=q --cq-level=20
37+--cpu-used=2 --threads=1 --row-mt=0 --lag-in-frames=0 --kf-max-dist=100
38+--limit=4 --obu`.
39+
40+| verdict | flags | parsed FH0 | sha256 | source |
41+|---|---|---|---|---|
42+| no-op | (none, control) | `frame=256x128 upscaled=256 use_superres=false denom=8` | `06621606…` | inherited |
43+| no-op | `--superres-mode=1` (no denom) | `frame=256x128 upscaled=256 use_superres=false denom=8` | `06621606…` | inherited — **this is the sweep's `sr444` cell** |
44+| SCALED | `mode=1 den=9` | `frame=228x128 upscaled=256 use_superres=true denom=9` | `3d619ee0…` | inherited; **re-verified here** (§2) |
45+| SCALED | `mode=1 den=12` | `frame=171x128 upscaled=256 use_superres=true denom=12` | `450caa3e…` | inherited (already gated by `a_444_lossy_superres_stream_decodes_pixel_exact`) |
46+| SCALED | `mode=1 den=16` | `frame=128x128 upscaled=256 use_superres=true denom=16` | `194450c4…` | inherited |
47+| SCALED | `mode=2` (random) | **`frame=186x128 denom=11`, then `146x128 denom=14`, `137x128 denom=15`, `228x128 denom=9`** | `c18496cf…` | inherited; **the per-frame denominators re-verified here** (§2) |
48+| SCALED | `mode=2` + `den=9` / `12` / `16` | identical to the row above, all three | `c18496cf…` (all three) | inherited; **re-verified here** (§3, in-gate) |
49+| no-op | `mode=3`, all denominators | `frame=256x128 use_superres=false denom=8` | `8dafaf38…` | inherited |
50+| no-op | `mode=4`, all denominators | `frame=256x128 use_superres=false denom=8` | `8dafaf38…` | inherited |
51+| no-op | `resize-mode=1,2,3`, any denominator | `frame=256x128 use_superres=false denom=8` | `06621606…` | inherited |
52+
53+**7 of 29 attempted combinations produce a real scaled stream.**
54+
55+Two facts the table exists to make impossible to get wrong again:
56+
57+1. **`--superres-mode=1` alone is a no-op.** libaom picks the denominator
58+ itself (`get_superres_denom_for_qindex`, `av1/encoder/superres_scale.c:143`),
59+ which returns `SCALE_NUMERATOR` (8) unless the frame is a KF/ARF update AND
60+ the horizontal-energy test passes. On a smooth `testsrc2` source it returns
61+ 8, and the result is byte-identical to the no-flag control. The chroma-format
62+ sweep's `sr444` cell is exactly this stream (15239 B, sha `06621606…`), which
63+ is why a whole sweep cell could sit in the matrix labelled "superres" while
64+ measuring nothing about superres.
65+2. **Mode 2 ignores `--superres-denominator` entirely**, and chooses a
66+ **different denominator per frame**. Three of its four parsed denominators
67+ (11, 14, 15) are values no flag on the command line ever named. A gate that
68+ read the flag instead of the header would be wrong on three of four frames
69+ here — which is why §3 makes the flag-ignoring property an assertion rather
70+ than a comment.
71+
72+---
73+
74+## 2. The two gates: fixtures, recipes, parsed headers
75+
76+Both recipes are byte-reproducible on this oracle. The parsed headers below
77+were read from the streams **this lane encoded**, not copied from the previous
78+run.
79+
80+### 2a. `a_444_lossy_superres_mode1_den9_stream_decodes_pixel_exact`
81+
82+`fixtures/444_lossy_superres_256x128_d9.obu`, 17437 bytes,
83+sha256 `3d619ee0fda3d9bb9cf8ff0541ba00ea5d83ae38cd8eec1322f8dbbbe6a5ec96`,
84+FNV-1a-64 `0x1ff2_fb84_528f_aa05`.
85+
86+```text
87+ffmpeg -f lavfi -i "testsrc2=size=256x128:rate=25" -frames:v 4 \
88+ -pix_fmt yuv444p -strict -1 -f yuv4mpegpipe - | \
89+aomenc --codec=av1 --passes=1 --end-usage=q --cq-level=20 --cpu-used=2 \
90+ --threads=1 --row-mt=0 --lag-in-frames=0 --kf-max-dist=100 \
91+ --limit=4 --superres-mode=1 --superres-denominator=9 \
92+ --superres-kf-denominator=9 --obu -o - -
93+```
94+
95+Parsed, per frame (all four identical):
96+
97+```text
98+SEQ ss=(0,0) bd=8 enable_superres=true profile=1
99+FH frame=228x128 upscaled=256 use_superres=true denom=9 (x4)
100+```
101+
102+**Why this member.** 9 is the widest frame-edge margin this 256x128 geometry
103+allows among the denominators libaom's `SUPERRES_NUM` ladder accepts and still
104+scales: `228 * 8 / 256` leaves a 28-column upscale margin against den=12's 85
105+columns, and den=16 (coded 128x128) is degenerate — the coded width equals the
106+superblock grid exactly. A wide margin is where a round-trip is most likely to
107+read past the coded picture.
108+
109+Measured on the gate: 4 upscales, **2568** scaled-MC blocks, 4 decode-order
110+frames byte-exact vs the instrumented aomdec.
111+
112+### 2b. `a_444_lossy_superres_mode2_random_denom_stream_decodes_pixel_exact`
113+
114+`fixtures/444_lossy_superres_mode2_256x128.obu`, 16620 bytes,
115+sha256 `c18496cf3b7db0feca9aa904024cec2115be80b5b94f87c848ac52f9b32ffd97`,
116+FNV-1a-64 `0x8cbb_36b2_5e0f_07ab`.
117+
118+```text
119+ffmpeg -f lavfi -i "testsrc2=size=256x128:rate=25" -frames:v 4 \
120+ -pix_fmt yuv444p -strict -1 -f yuv4mpegpipe - | \
121+aomenc --codec=av1 --passes=1 --end-usage=q --cq-level=20 --cpu-used=2 \
122+ --threads=1 --row-mt=0 --lag-in-frames=0 --kf-max-dist=100 \
123+ --limit=4 --superres-mode=2 --obu -o - -
124+```
125+
126+Parsed, **per frame — and the four differ**:
127+
128+```text
129+SEQ ss=(0,0) bd=8 enable_superres=true profile=1
130+FH0 frame=186x128 upscaled=256 use_superres=true denom=11
131+FH1 frame=146x128 upscaled=256 use_superres=true denom=14
132+FH2 frame=137x128 upscaled=256 use_superres=true denom=15
133+FH3 frame=228x128 upscaled=256 use_superres=true denom=9
134+```
135+
136+**Why this member is not redundant with den=12 / den=9.** Both of those scale
137+every frame at a single denominator, so `av1_superres_upscale` is only ever
138+handed one coded-to-upscaled ratio. This stream hands it four (256→186,
139+256→146, 256→137, 256→228) in one decode, and libaom picks the filter taps
140+from `denom` per frame. That is a case a single-denominator gate cannot reach.
141+
142+Measured on the gate: 4 upscales, **2265** scaled-MC blocks, 4 decode-order
143+frames byte-exact vs aomdec.
144+
145+### 2c. Shape, and what is asserted from the PARSED header
146+
147+Both gates call one shared body (`a_444_superres_arm`) — the body of the
148+existing den=12 gate with the single `(denominator, coded_width)` constant
149+generalised to a per-frame table, which is what mode 2 requires. Per arm:
150+
151+- pinned bytes: length + FNV-1a-64;
152+- from the **sequence header**: `ss (0,0)` (4:4:4), `bit_depth 8`,
153+ `enable_superres`;
154+- from **every parsed frame header**: `use_superres` true, the per-frame
155+ `superres_denom`, `upscaled_width`/height, and the CODED `frame_width`/height;
156+- `FrameWidth == (UpscaledWidth * 8 + denom / 2) / denom`, re-derived from
157+ **that frame's own parsed denominator** rather than compared to a literal
158+ alone — so a re-pinned fixture cannot satisfy the literals while the scaled
159+ arithmetic moves under them;
160+- `superres_hits` and `predict_scaled_hits` as **deltas** (both counters are
161+ process-wide with no reset, so absolute values would pass on residue from
162+ another stream in a full-suite run);
163+- every decoded frame at the **UPSCALED** width with full-resolution 4:4:4 U and
164+ V planes;
165+- every decode-order frame byte-exact through `decode_all_frames_vs_oracle`.
166+
167+My FNV-1a-64 implementation was validated against the sibling gate's published
168+pair before being used on new bytes: `444_lossy_rect4_inter_witness.obu`, 6441
169+bytes → `0x4368_8b2d_2e91_72b0`. Match.
170+
171+---
172+
173+## 3. The flag-ignoring assertion (mode-2 gate, second half)
174+
175+The pin above is only trustworthy if mode 2 really does ignore the flag. That
176+is asserted, not assumed. The gate re-encodes the recipe four ways — no
177+denominator, then `--superres-denominator=9`, `=12`, `=16` — and requires each
178+to reproduce the pinned 16620 bytes exactly (length + FNV compared to the pin,
179+not to each other). It then asserts that at least one **parsed** denominator
180+is a value none of those flags named, so the per-frame table cannot be
181+satisfied by echoing the command line back.
182+
183+Green output:
184+
185+```text
186+a_444_lossy_superres_mode2_random_denom_stream_decodes_pixel_exact:
187+ --superres-mode=2 with no/9/12/16 denominator flags all reproduce the pinned
188+ 16620 bytes; parsed denominators [11, 14, 15, 9] (flag values [9, 12, 16] ignored)
189+```
190+
191+If a future libaom starts honouring `--superres-denominator` under mode 2, both
192+the byte compare and that last assertion go red — which is the intended
193+behaviour: the pin is to the **parsed** denominators, so the day the flag
194+starts mattering the cell has to be re-derived from the stream, not from the
195+recipe.
196+
197+---
198+
199+## 4. Green, and red-before
200+
201+**Green** (`--nocapture`, `EC_AV1_REQUIRE_AOMENC=1`, `--test-threads=1`, no
202+SKIP line anywhere):
203+
204+```text
205+a_444_lossy_superres_mode1_den9_stream_decodes_pixel_exact:
206+ 4 decode-order frame(s) (0 hidden) byte-exact vs aomdec at (256, 128) upscaled
207+ from [(9, 228), (9, 228), (9, 228), (9, 228)] (denominator, coded width) per
208+ frame, 4 upscale(s), 2568 scaled MC block(s); fixture sha256 3d619ee0…
209+a_444_lossy_superres_mode2_random_denom_stream_decodes_pixel_exact:
210+ 4 decode-order frame(s) (0 hidden) byte-exact vs aomdec at (256, 128) upscaled
211+ from [(11, 186), (14, 146), (15, 137), (9, 228)] (denominator, coded width) per
212+ frame, 4 upscale(s), 2265 scaled MC block(s); fixture sha256 c18496cf…
213+ --superres-mode=2 with no/9/12/16 denominator flags all reproduce the pinned
214+ 16620 bytes; parsed denominators [11, 14, 15, 9] (flag values [9, 12, 16] ignored)
215+a_444_lossy_superres_stream_decodes_pixel_exact: (pre-existing, den=12)
216+ 4 decode-order frame(s) (0 hidden) byte-exact … 4 upscale(s), 2130 scaled MC block(s)
217+test result: ok. 3 passed; 0 failed; 0 ignored; 0 measured; 705 filtered out
218+```
219+
220+### Red-before
221+
222+Committed **before** mutating (`e47d8f60`), so no `git checkout --` could
223+restore the gate away. Three mutations, each reverted immediately and each
224+verified reverted (`git diff --stat` empty, tree clean) before the next.
225+
226+| # | mutation | site | `mode1_den9` | `mode2` | `…_stream_…` (pre-existing) |
227+|---|---|---|---|---|---|
228+| 1 | upscale-filter tap alignment: `base = pad - 4` → `pad - 4 + 1` | `superres.rs:133` | **RED, pixel** — `decode-order frame 0 of 4 differs from the oracle at byte 5 (ours 73 vs 74), 33668 bytes differ` | **RED, pixel** — `frame 0 … byte 6 (ours 76 vs 74), 36196 bytes differ` | **RED, pixel** — `frame 0 … byte 5 (ours 76 vs 74), 37726 bytes differ` |
229+| 2 | `set_superres` handed the **coded** width (`upscaled_width` → `frame_width`) | `stream.rs:1851` | **RED, counter** — `zero predict_scaled_hits -- no inter block read a scaled reference …` | **RED, shape** — `frame 0 came back 186x128, not the UPSCALED 256x128` | **RED, counter** — `zero predict_scaled_hits` |
230+| 3 | upscale step derived from `out_width`: `upscale_convolve_step(in_width, out_width)` → `(out_width, in_width)` | `superres.rs:106` | **RED, panic** — index out of bounds at `superres.rs:142` | **RED, panic** — index out of bounds at `superres.rs:142` | **RED, panic** — index out of bounds at `superres.rs:142` |
231+
232+Every mutation run reported `test result: FAILED. 0 passed; 3 failed; 0
233+ignored; 0 measured; 705 filtered out`. **That is the fake-green signature to
234+watch for and it did not appear**: a line reading `0 passed … 705 filtered out`
235+with no `3 failed` is what a `git checkout --`-eaten gate looks like. Here the
236+filter always selected 3 tests and all 3 went red.
237+
238+Mutation 1 is the one this lane prefers — a pixel diff is a stronger red than
239+an index panic, because it names the wrong value rather than only the wrong
240+address, and it cannot be mistaken for a bounds bug in the mutation itself.
241+Both gates go red on it independently.
242+
243+Mutation 3 is the weakest of the three as a gate discriminator (it panics
244+inside the upscaler before any gate assertion runs) but it is retained because
245+it is the mutation that proves the per-frame coded width actually feeds the
246+upscaler's step, rather than being validated at the header assert alone.
247+
248+---
249+
250+## 5. Report corrections (diff-shaped)
251+
252+All in `lanes/av1formatsweep.report.md` — that lane merged, so this is a
253+follow-up commit editing its file rather than a note in my own report.
254+
255+| line (pre-edit) | before | after |
256+|---|---|---|
257+| 83 | `\| superres \| – \| – \| – \|` (4:4:4 matrix, all depths unmeasured) | `\| superres \| Y (\`a_444_lossy_superres_stream_decodes_pixel_exact\`, plus \`…_mode1_den9_…\` and \`…_mode2_random_denom_…\`) \| – \| – \|` — `Y` at 8-bit only |
258+| 438 | `\| 4:4:4 **superres** 256x128 (\`--superres-mode=1\`) \| \`sr444\` \| 15239 \| \`06621606…\` \| **DIVERGENT** from f2, 76404 samples, first (f2, s192) = Y(192,0) \|` | Row retitled `(\`--superres-mode=1\`, **no denominator flag**)`. Verdict cell now: **NOT A SUPERRES CELL** — the bytes are the sweep's own (15239 B, sha `06621606…`), all four parsed headers read `use_superres=false denom=8`. The DIVERGENT numbers are **kept verbatim** but re-attributed: **H1, the 1:4 inter-strip own-extent class**, already gated by `a_444_lossy_rect4_strip_stream_decodes_pixel_exact_at_odd_and_wide_geometries` (second arm is these exact 15239 bytes). Real 4:4:4 superres is byte-exact and gated — cross-ref to this report. |
259+| 442 | `Note the aomenc flag is \`--superres-mode=1\`; there is no \`--enable-superres\` in this build.` | Same fact kept, plus **"but that flag alone does nothing, which is what made the row above a phantom cell"**, followed by a 3-route correction: (1) mode 1 needs an explicit `--superres-denominator`; (2) **mode 2 scales with no denominator flag and ignores `--superres-denominator` entirely** — 9/12/16 all give the same stream — and picks its denominator **per frame** (11, 14, 15, 9 at 256x128), so a single-denominator reading is wrong by construction; (3) modes 3 and 4 are no-ops at every denominator. Cites libaom `v3.13.3-7-g9bb526a` and states how it was established (source tree of `scripts/build-aom-oracle.sh`, **not** `--version`). Ends with "always read the verdict out of the stream's own parsed frame header, never out of the flag", and that `--resize-mode` is a different feature, never a superres witness. |
260+| 485 | ``Matrix changes (§1): 4:4:4 row gains … `superres → D`, `10/12-bit tiles → D` …`` | `superres → D` **removed** from the list, followed by a correction paragraph: the 4:4:4 row's superres cell reads **`Y` at 8-bit, not `D`**, because this lane's `D` was written from a stream that never scaled; with an explicit denominator or mode 2 the class is byte-exact 4/4 at coded widths 128/171/186/228, gated at denom 12, denom 9 and mode 2. 10/12-bit stays `–`. |
261+| 492 | `Still not measured after this round: … 4:4:4 superres at 10/12 bits; …` | **Left as written, checked.** A paragraph is added immediately after stating that lane-av1superpin re-checked it and it is **still open**: every fixture this lane pinned parses `bit_depth = 8` from its own sequence header, so nothing here measures 10/12-bit. |
262+
263+Two further lines in the same file were corrected because leaving them would
264+have contradicted the five above:
265+
266+| line (pre-edit) | before | after |
267+|---|---|---|
268+| 338 (§4 "Not measured") | `…; 12-bit superres; 4:4:4 superres; 4:4:4 odd coded dimensions; …` | `…; 12-bit superres; 4:4:4 superres **(closed since, at 8-bit only — lane-av1superpin, see the correction in §6.5; 10/12-bit still open)**; …` — the list is stated so nobody reads silence as coverage, so a stale entry there is itself a defect |
269+| 504 (§6.6 handoff) | `The 4:4:4 **130x122** odd-dimension divergence and the 4:4:4 **superres** divergence are unassigned; neither reduces to a known class on the evidence here, and neither has a discriminator run.` | Both are **closed by lane-av1444edge**: one class (H1, the 1:4 inter-strip own-chroma-extent gather at `ss (0,0)`), discriminator-run and fixed by `f92776ba` (lane-av1444rect), gated by `a_444_lossy_rect4_strip_stream_decodes_pixel_exact_at_odd_and_wide_geometries`. Adds that the "superres" name in the row was a mislabel — the stream never scaled — and that real 4:4:4 superres coverage is separate and lives here. |
270+
271+---
272+
273+## 6. Scope, and what this lane did not do
274+
275+- **No `decode.rs` edit.** This lane is gates plus one markdown file; the six
276+ other lanes' regions of `decode.rs` are untouched. `git diff 4c973b94..HEAD`
277+ touches only `crates/ec-av1/src/stream.rs` (additive, two new tests and one
278+ shared helper), two new fixtures, and `lanes/`.
279+- **The pre-existing `a_444_lossy_superres_stream_decodes_pixel_exact` (den=12)
280+ is unchanged** and was only used as the shape to copy. All three superres
281+ gates went red under all three mutations and green after revert, which is
282+ also how I know my two new gates are not duplicating an existing claim in a
283+ way that only one of them would notice.
284+- **10/12-bit 4:4:4 superres remains unmeasured** (§5, line 492). Encoding it
285+ needs a 12-bit 4:4:4 source smooth enough to avoid the screen-tools refusal
286+ (H6) and a denominator that survives it — a separate lane.
287+- **den=16 (coded 128x128) remains ungated.** It is measured byte-exact
288+ (inherited) but degenerate — coded width equals the SB grid — so it is the
289+ weakest of the four as an exactness claim. Recorded, not dropped.
290+- No suite run beyond the three named gates. Full validation is Main's, once,
291+ after all subagents land.
292+
293+## 7. Handed on
294+
295+- **Main** — the five line-level corrections in §5 plus the two consistency
296+ fixes; `e47d8f60` is additive and merges independently of any decode-path
297+ work. Merge-order note: this branch is cut from `4c973b94`, which does **not**
298+ contain the `lanes/av1formatsweep.report.md` that landed on `main` via
299+ `f566862a`, so the report file was taken from `main` into this branch and
300+ edited here. Expect a content conflict on that one file at merge time; the
301+ intent is that this branch's version wins for the corrected lines.
lanes/av1tilemeasure.report.mdadded+309 -0
@@ -0,0 +1,309 @@
1+# lane-av1tilemeasure — tile-rows / superres / odd-size cells, measured
2+
3+**Tree.** `lane-av1tilemeasure` off `a21f3680`, worktree `~/.cache/wt/av1tilemeasure`.
4+`crates/ec-av1/src/decode.rs` is **untouched**; every verdict below is HEAD's decoder.
5+
6+**Method.** Every cell was encoded live against the durable oracle
7+(`~/.cache/aom-oracle/build/aomenc`), its OBUs were **parsed** and the frame
8+headers' `tile_info` / `use_superres` / coded size read off the parse (never off
9+the aomenc flag), and the stream was decoded against the instrumented
10+`~/.cache/aom-oracle/build/aomdec` through the same
11+`decode_all_frames_vs_oracle` path the committed gates use: it asserts the
12+decode-order frame COUNT and each frame's byte LENGTH before a single sample is
13+compared. Control arms first: 4:2:0 12-bit untiled and the two existing 4:4:4
14+committed recipes both come out byte-exact, so the harness is sound.
15+
16+---
17+
18+## 0. Trap 3 (this lane's own): a SHARED `CARGO_TARGET_DIR` silently measures another lane's decoder
19+
20+The first two sweeps of this lane were run with the house
21+`CARGO_TARGET_DIR=$HOME/.cache/cargo-target`, which at that moment was being
22+written by at least one other lane building `ec-av1` from its own worktree. The
23+example binary linked **that** lane's in-flight `ec-av1` rlib, and the numbers
24+were not merely noisy — they were a different decoder:
25+
26+| cell | shared target dir | lane-private target dir |
27+|---|---|---|
28+| 4:4:4 lossless 8-bit 2x2 tiles, 256x256 | DIVERGENT f1, 11913 samples, first Y(216,128) | **EXACT 6/6** |
29+| 4:4:4 lossless 8-bit 1 tile row, 128x256 | DIVERGENT f1, 8055 samples, first Y(108,128) | **EXACT 6/6** |
30+| 4:2:0 lossless 8-bit 2x2 tiles, 256x256 | DIVERGENT f1, 5545 samples, first Y(64,0) | **EXACT 6/6** |
31+| 4:2:0 lossless 8-bit 1 tile row, 256x256 | DIVERGENT f1, 39763 samples, first Y(128,0) | **EXACT 6/6** |
32+| 4:2:0 lossless 8-bit 128x256 untiled | DIVERGENT f1, 25334 samples, first Y(86,0) | **EXACT 6/6** |
33+| 4:4:4 lossless 10-bit 1 tile row, 128x256 | refused by name ("Golomb tail") | DIVERGENT f0, 74 samples, first U(82,188) |
34+| 4:4:4 lossless 10-bit 1 tile row, 256x256 | 1208 then 1083 samples (two binaries) | 1374 samples, one number |
35+
36+A second symptom of the same collision, and the one that could have shipped a
37+false green: `cargo test -p ec-av1 --lib -- --exact <my new gate>` reported
38+`0 passed; 717 filtered out` **three times in a row** while the source file
39+contained the gate — cargo was running the other lane's test binary. It also
40+rebuilt "successfully" (`Compiling ec-av1`) without my tests in it.
41+
42+**Rule this lane proposes:** any lane that measures *or gates* `ec-av1` while
43+other lanes are live must use a LANE-PRIVATE `CARGO_TARGET_DIR`
44+(`$HOME/.cache/cargo-target-<lane>`). The shared directory is fine for
45+`cargo check` on a path that no sibling is building, and useless as evidence.
46+Every number in this report was re-taken in
47+`$HOME/.cache/cargo-target-av1tilemeasure` and is stable across repeated runs
48+(three runs of the same cell, identical counts and identical first-fork values).
49+
50+---
51+
52+## 1. The `t420_12_row` correction (published verdict: "may be measuring the same stream")
53+
54+**It was not measuring the same stream, and the flag was not a no-op at that
55+geometry.** The sweep's caveat assumed 128px superblocks; profile-0 4:2:0
56+defaults to `--sb-size=64`, so a 256x128 frame is a 4x2 SB grid and
57+`--tile-rows=1` really does split it. Encoded at the sweep's own flag set
58+(`--profile=0 --cq-level=20 --cpu-used=2 --enable-palette=0 --enable-intrabc=0
59+--threads=1 --row-mt=0 --lag-in-frames=0 --kf-max-dist=100 --limit=6`, source
60+`mandelbrot=size=256x128:rate=25` + `-vf gblur=sigma=6` yuv420p12le), all three
61+arms parse as three different grids and are three different streams:
62+
63+| arm | parsed `tile_info` (all 6 frames) | bytes | sha256 | verdict vs aomdec |
64+|---|---|---|---|---|
65+| `t420_12_notile` (the control the sweep never encoded) | 1x1 | 1675 | `6cd14c13356a5d8e` | **EXACT 6/6** |
66+| `t420_12_col` (`--tile-columns=1`) | 2x1 | 1747 | `0069fa4b1a9f63bd` | **EXACT 6/6** |
67+| `t420_12_row` (`--tile-rows=1`) | **1x2** | 1785 | `85050393a76cafae` | **EXACT 6/6** |
68+
69+Two independent ways to see the published cells were distinct streams: the
70+sweep's own table already lists different sha256 and different byte counts for
71+`t420_12_col` (`c983a91c`, 8713 B) and `t420_12_row` (`0bf14e1e`, 8760 B) — a
72+no-op flag would have produced identical bytes, which is exactly what the
73+sweep's own trap-2 table shows happening at `--sb-size=128`. So **the cell did
74+carry two tile rows, and the EXACT verdict stands on its own stream.**
75+
76+Trap 2 is nevertheless real and now has its own reproduction, in the same
77+report's own words: at `--sb-size=128`, `--tile-rows=1` at 256x128 leaves the
78+stream byte-identical (`a628e835b8ca1002` for both arms, parsed 1x1 both times).
79+The flag is a no-op exactly when the frame is one SB row tall.
80+
81+**Caveat on the published byte counts.** The sweep's 8713/8760-byte streams are
82+not reproducible from the recipe text in the report (a re-encode of that exact
83+flag set gives 1675/1747/1785 bytes). Dropping the `gblur` smoothing — the one
84+degree of freedom the report leaves open — gives 10830/11139/11147 bytes, and
85+all three of THOSE hit this decoder's named 12-bit screen-content-tools refusal
86+(`allow_screen_content_tools=1`). The published byte counts are therefore from a
87+third variant; the structural answer above does not depend on reproducing them.
88+
89+---
90+
91+## 2. Cells measured, with the recipe and the parsed geometry
92+
93+Every row: parse asserted before pixels, decode compared against `aomdec` in
94+decode order with equal frame count and equal byte length asserted first.
95+Common aomenc tail: `--codec=av1 --passes=1 --end-usage=q --threads=1 --row-mt=0
96+--lag-in-frames=0 --kf-max-dist=100 --obu -o - -` (+ `--input-bit-depth=N
97+--bit-depth=N` above 8). Sources: `testsrc2=WxH:rate=25` unless marked
98+*smooth* = `mandelbrot=WxH:rate=25` + `-vf gblur=sigma=6` (mandatory at 12 bits,
99+H6: a sharp 12-bit source sets `allow_screen_content_tools` and the refusal
100+fires before anything else).
101+
102+### 2.1 Tile ROWS genuinely enabled (the cell trap 2 left open)
103+
104+| cell | recipe flags | parsed grid | bytes / sha256 | verdict |
105+|---|---|---|---|---|
106+| 4:2:0 12-bit 1x2 rows, 256x256 | `--cq-level=20 --cpu-used=2 --enable-palette=0 --enable-intrabc=0 --tile-rows=1`, *smooth*, 6f | 1x2 | 3725 / `40448841c229d18c` | **EXACT 6/6** |
107+| 4:2:0 12-bit 2x2 grid, 256x256 | same + `--tile-columns=1` | 2x2 | 3886 / `90fff0c014e954c4` | **EXACT 6/6** |
108+| 4:2:0 10-bit 1x2 rows, 256x256 | same, yuv420p10le | 1x2 | 16509 / `3f2041bb56f4b6c0` | **EXACT 6/6** |
109+| 4:2:0 8-bit 1x2 rows, 256x256 | same, yuv420p | 1x2 | 15705 / `7726da064e677fb7` | **EXACT 6/6** |
110+| 4:4:4 lossless 8-bit 1x2 rows, 256x256 | `--lossless=1 --sb-size=128 --tile-rows=1` + tools off | 1x2 | 111159 / `043e31cc555b5946` | DIVERGENT — §3 |
111+| 4:4:4 lossless 10-bit 1x2 rows, 256x256 | same, yuv444p10le | 1x2 | 189317 / `562ea414b515f715` | DIVERGENT — §3 |
112+| 4:4:4 lossless 12-bit 1x2 rows, 256x256 | same, yuv444p12le, *smooth* | 1x2 | 414712 / `63d3b7a9c80dc60b` | DIVERGENT — §3 |
113+| 4:4:4 lossless 10-bit 1x2 rows, 128x256, sb64 | `--lossless=1 --tile-rows=1` + tools off | 1x2 | 126594 / `491982ec18cc45b9` | DIVERGENT — §3 |
114+| 4:4:4 lossless 8-bit 2x2 grid, 256x256 | `--lossless=1 --sb-size=128 --tile-columns=1 --tile-rows=1` | 2x2 | 111264 / `d517d33ef232770b` | **EXACT 6/6** |
115+| 4:4:4 lossless 8-bit 1x2 rows, 128x256, sb128 | `--lossless=1 --sb-size=128 --tile-rows=1` | 1x2 | 68908 / `74c85b982ff75ff5` | **EXACT 6/6** |
116+
117+`gate_coverage.rs` says the multi-tile 2D grid is covered "at both bit depths"
118+— meaning 8 and 10. **12-bit was the hole**, and it is now a gate.
119+
120+### 2.2 4:4:4 superres, and the trap on the same axis as trap 2
121+
122+`--superres-mode=1` alone does **not** make libaom signal superres: re-encoding
123+the sweep's own superres recipe (`--superres-mode=1 --cq-level=20
124+--cpu-used=2`, 256x128) and parsing every frame header gives `use_superres` on
125+**0 of 6 frames**, at 8, 10 and 12 bits. A denominator is required. With
126+`--superres-denominator=12 --superres-kf-denominator=12` every frame header
127+carries `use_superres=1` and the coded width drops (128x128 display -> 85x128
128+coded), i.e. the flag finally did something:
129+
130+| cell | recipe | parsed | verdict |
131+|---|---|---|---|
132+| 4:4:4 superres 8-bit, 128x128, 4f | `--cq-level=20 --cpu-used=2 --enable-palette=0 --enable-intrabc=0 --superres-mode=1 --superres-denominator=12 --superres-kf-denominator=12` | 85x128 coded, use_superres 4/4 | **EXACT 4/4** |
133+| 4:4:4 superres 10-bit, same | yuv444p10le | 85x128, 4/4 | **EXACT 4/4** |
134+| 4:4:4 superres 12-bit, same | yuv444p12le, *smooth* | 85x128, 4/4 | **EXACT 4/4** |
135+| 4:2:0 superres 12-bit, 128x128, 2f | same, yuv420p12le, *smooth* | 85x128, 2/2 | **EXACT 2/2** |
136+| 4:4:4 superres 10-bit, 256x256, 4f | same at 256x256 | 171x256, 4/4 | **EXACT 4/4** |
137+| 4:4:4 superres 12-bit, 256x256, 4f | same at 256x256 | 171x256, 4/4 | **EXACT 4/4** |
138+
139+The sweep's published 4:4:4 superres verdicts (`sr444` DIVERGENT from f2;
140+`sr444_12`/`sr420_12` EXACT) are all `--superres-mode=1`-only recipes, i.e.
141+streams with `use_superres = 0` on every frame: whatever they measured, it was
142+not superres. With superres genuinely on, all three depths are exact.
143+
144+### 2.3 4:4:4 partial and odd coded dimensions
145+
146+The sweep's "odd coded dims" cells (66x66, 130x122, 194x130) are **even in both
147+axes** — what they are is "not a multiple of 8". This gate said so out loud on
148+its first run: `the 66x66 arm is even in BOTH axes`. A genuinely odd 4:4:4
149+coded size is producible **only at 12 bits** (seq_profile 2): at 8 and 10 bits
150+aomenc rounds the size down to even — `67x67` -> coded 66x66 (byte-identical to
151+the 66x66 arm, sha `973eddf4aa6b0bf1`) and `131x131` -> coded 130x130.
152+
153+| cell | coded size (parsed) | bytes / sha256 | verdict |
154+|---|---|---|---|
155+| 4:4:4 66x66 8-bit | 66x66 (even, not mult. of 8) | 5938 / `973eddf4aa6b0bf1` | **EXACT 4/4** |
156+| 4:4:4 98x66 8-bit | 98x66 | 6431 / `fc0e13060d1b7ca7` | **EXACT 4/4** |
157+| 4:4:4 130x122 8-bit | 130x122 | 9513 / `897791f360e3f3fb` | **EXACT 4/4** |
158+| 4:4:4 66x66 10-bit | 66x66 | 6006 / `995e6d45ca3e6983` | **EXACT 4/4** |
159+| 4:4:4 194x130 10-bit | 194x130 | 15751 / `cdb16f6a47306bbc` | **EXACT 4/4** |
160+| 4:4:4 130x122 10-bit | 130x122 | 10237 / `d34448dd0d44e4e9` | **EXACT 4/4** |
161+| 4:4:4 66x66 12-bit | 66x66 | 791 / `d266e4281c00eb4f` | **EXACT 4/4** |
162+| 4:4:4 130x122 12-bit | 130x122 | 1994 / `039d0a5aaabbe230` | **EXACT 4/4** |
163+| 4:4:4 **67x67 12-bit (odd)** | 67x67 | 844 / `da5d680389656d97` | **EXACT 4/4** |
164+| 4:4:4 **65x67 12-bit (odd)** | 65x67 | 791 / `471e4458babf7fa2` | **EXACT 4/4** |
165+
166+Recipe per arm: `testsrc2=WxH:rate=25` yuv444p[10le|12le] (12-bit: *smooth*),
167+4 frames, `--cq-level=20 --cpu-used=2 --enable-palette=0 --enable-intrabc=0`.
168+
169+**Correction to a published verdict.** The sweep records 4:4:4 `130x122` as
170+DIVERGENT from f3 (11521 samples, first f3 s2208 = Y(128,16)). This lane
171+re-encoded the sweep's own recipe (no `--enable-palette/intrabc`), reproduced its
172+stream byte-for-byte (8945 bytes, sha `c87ac65b77579afd`) and it is **byte-exact
173+4/4** against `aomdec` under a length-asserting compare. That published verdict
174+is the prefix compare the same report documents as its trap 1.
175+
176+### 2.4 The H3 control: 4:4:4 lossless 8-bit WITHOUT tiles
177+
178+| arm | parsed grid | bytes / sha256 | verdict |
179+|---|---|---|---|
180+| 256x128 untiled (the control the sweep never encoded) | 1x1 | 76468 / `c2cc3bd54d9127a4` | **EXACT 6/6** |
181+| 256x128 `--tile-columns=1` | 2x1 | 77905 / `1349984ef364c618` | **EXACT 6/6** |
182+| 256x128 untiled, screen tools left at their default | 1x1 | 74076 / `6c49502811b1a5d8` | **EXACT 6/6** |
183+| 256x128 `--tile-columns=1`, tools defaulted | 2x1 | 75446 / `65e94e91c56178d2` | **EXACT 6/6** |
184+| 256x256 untiled | 1x1 | 109215 / `4563a01f17786000` | DIVERGENT — §3 |
185+| 192x192 untiled | 1x1 | 82918 / `82c3b0a6db9dba2a` | **EXACT 6/6** |
186+| 192x192 1 tile row | 1x2 | 83105 / `359983962a2c06c3` | **EXACT 6/6** |
187+
188+**H3 does not reproduce.** On both flag variants at 256x128, the lossless 4:4:4
189+tile-column stream decodes byte-exact 6/6 — no 90-chroma-sample fork, and the
190+untiled control is exact too. Whatever produced H3's numbers, this recipe is not
191+it, so H3's "tiles cause it" has no reproduction on this tree and the control
192+that was missing now exists as a gate.
193+
194+---
195+
196+## 3. Divergences (measured, NOT fixed — each is a charter, not this lane's work)
197+
198+All of them are the same class: **4:4:4 LOSSLESS, key frame, chroma only, ±1,
199+luma exactly zero wrong**, at 256x256 or 128x256. Not one of them is
200+tile-specific.
201+
202+| cell | untiled control at the same geometry | tiled arm | first fork (decode order) |
203+|---|---|---|---|
204+| 4:4:4 lossless 8-bit 256x256 | DIVERGENT f0, 49 samples | 1 tile row: DIVERGENT f0, 33 samples / 2 tile cols: DIVERGENT f0, 14 samples | control `U(201,200)` ours 160 ref 159; 1x2 `U(199,201)` ours 165 ref 164; 2x1 `U(191,178)` ours 171 ref 172 |
205+| 4:4:4 lossless 10-bit 256x256 | DIVERGENT f0, 7695 samples, first `U(163,36)` ours 209 ref 129 | 1 tile row: DIVERGENT f0, 1374 samples, **first `U(163,36)` — the same sample** | 10-bit |
206+| 4:4:4 lossless 12-bit 256x256 | DIVERGENT f0, 17336 samples, first `U(154,32)` ours 84 ref 85 | 1 tile row: DIVERGENT f0, 25152 samples, **first `U(154,32)` — the same sample** | 12-bit |
207+| 4:4:4 lossless 10-bit 128x256 (sb64) | (not encoded) | 1 tile row: DIVERGENT f0, 74 samples, first `U(82,188)` ours 182 ref 165 | 10-bit, sb64 |
208+
209+**Attribution, stated as a measurement and not a theory.** At 10 and 12 bits the
210+tiled and untiled streams fork at the *same* first sample, so the tile row is
211+not the cause and the cell does not add a class; the fork belongs to the
212+4:4:4-lossless chroma defect the sweep already tracks as H3 / §6.1 and handed
213+to Agent24-2. **H4 ("4:4:4 lossless + 2 tile ROWS: hard divergence", "the whole
214+plane comes out flat from frame 3") is refuted on two counts:** its recipe was
215+256x128 with `--tile-rows=1`, which trap 2 shows is a no-op at that geometry
216+(so it was an untiled stream), and the genuine tile-row stream here diverges by
217+tens of samples in the key frame, not by 70-85% of the plane from frame 3. At
218+8 bits the tiled forks land at three nearby-but-different samples inside the
219+same bottom-right region, all ±1, all frame 0 — the same family, and a
220+discriminator run is owed before anyone claims one defect.
221+
222+The `256x128` control being exact while `256x256` diverges at all three depths
223+is the sharpest thing this lane measured about the class: it needs a frame that
224+is 256 rows tall **and** 256 wide, tiled or not.
225+
226+---
227+
228+## 4. Gates added (all in `crates/ec-av1/src/stream.rs`)
229+
230+| gate | arms | what it pins |
231+|---|---|---|
232+| `a_real_aomenc_12bit_stream_with_two_tile_rows_and_a_two_by_two_tile_grid_decodes_pixel_exact` | 4:2:0 12-bit 1x2 rows; 4:2:0 12-bit 2x2 grid | the 12-bit multi-tile hole `gate_coverage.rs` left open |
233+| `a_real_aomenc_444_superres_stream_at_8_10_and_12_bit_decodes_pixel_exact` | 4:4:4 8/10/12-bit, `use_superres` on every frame | 4:4:4 superres at all three depths, the first with superres actually signalled |
234+| `a_real_aomenc_444_partial_and_odd_coded_dimension_streams_decode_pixel_exact` | 8 arms: 66x66, 98x66, 130x122 (8-bit), 66x66, 194x130, 130x122 (10-bit), 66x66, 130x122, **67x67, 65x67** (12-bit) | 4:4:4 partial-size at 8/10/12 and the first genuinely ODD 4:4:4 coded sizes |
235+| `a_lossless_444_8bit_untiled_control_and_its_two_tile_column_sibling_decode_pixel_exact` | 256x128 untiled + 256x128 2 tile columns | the H3 control the sweep never encoded, beside the tile-column sibling it was missing |
236+
237+Shared helper added: `frame_facts` (+ `FrameFacts`), which reads
238+`tile_cols/tile_rows/use_superres/coded_w/coded_h/upscaled_w/mi_cols/mi_rows`
239+off every frame header of a parsed stream.
240+
241+**Non-vacuity.** Each gate asserts, before any pixel: the sequence header's
242+`ss` and bit depth; the PARSED per-frame `tile_info` equal to the grid the arm
243+claims (or `use_superres` with `coded_w < upscaled_w` for the superres arms, or
244+the exact coded size and a partial mode-info grid for the size arms); a
245+per-path counter (`decode::tile_hits()` >= frames x tiles,
246+`superres::superres_hits()` >= frames, `decode::rect_split_lossless_chroma444_hits()`
247+strictly up); the decoded plane extents (256x256, the UPSCALED 128x128, or
248+exactly `w*h` at `ss (0,0)`), which a truncated or quarter-extent decode fails;
249+and then `decode_all_frames_vs_oracle`, which asserts equal frame counts and
250+equal per-frame byte lengths before comparing samples.
251+
252+**Red-before proofs (all reverted, all reproduced):**
253+
254+1. tile grid — drop `--tile-rows=1` from the 1x2 arm: RED,
255+ `decode-order frame 0 parses tile_info 1x1, not 1x2 -- the aomenc tile flag
256+ was a NO-OP at this geometry`. That is trap 2 caught by the gate.
257+2. superres — drop both denominators: RED, `decode-order frame 0 has
258+ use_superres=0 -- the superres cell would be measuring an ordinary 4:4:4
259+ stream`.
260+3. coded size — expect `(w+1, h)` instead of `(w, h)` on the 66x66 arm: RED,
261+ `left: (66, 66) right: (67, 66)`.
262+4. arm shape — the first run of the size gate, with an "odd in at least one
263+ axis" assert written before the arm list was checked, went RED on its own
264+ first arm (`the 66x66 arm is even in BOTH axes`). That is where the
265+ "odd dims were not odd" correction came from.
266+
267+**`gate_coverage.rs`.** No entry is closed by these gates and none is deleted:
268+they spell no `--enable-<tool>=1` (the multi-tile and superres tools carry no
269+`NEVER_EXERCISED` entry — TILING is deliberately outside that derivation, and
270+superres is already positively covered through the `--superres-mode` alias by
271+the three existing superres gates), and they add no new `--enable-*` flag name,
272+so no new hole can open. `gate_coverage`'s three tests are green on this tree.
273+Entries 17/18/19 of the census were not touched.
274+
275+---
276+
277+## 5. Dispositions (cells that cannot be produced, with the tooling path)
278+
279+1. **4:4:4 at 8/10 bits with a genuinely ODD coded dimension** — not producible
280+ by recipe. The tooling path that refuses it is aomenc's own frame-size
281+ rounding: `67x67` yuv444p encodes to a stream whose frame header says
282+ `frame_width = 66`, and the bytes are identical to the 66x66 arm
283+ (`973eddf4aa6b0bf1`); `131x131` -> 130x130. At 12 bits (seq_profile 2) the
284+ rounding does not happen and 67x67/65x67 stay odd, which is why the odd arms
285+ are 12-bit. Closing the 8/10-bit odd cell needs a hand-built frame header,
286+ the same conclusion the sweep reached for 4:2:0 odd luma dimensions.
287+2. **12-bit 4:2:0 from a sharp source** — refused by name before any pixel:
288+ `allow_screen_content_tools=1` trips the 12-bit screen-tools refusal even
289+ with `--enable-palette=0 --enable-intrabc=0` (measured on the no-gblur
290+ variants, 10830/11139/11147 bytes). Every 12-bit arm in this report
291+ therefore carries the smoothed source.
292+3. **4:4:4 lossless 10-bit with tile rows at 128x256 on the default 64px SB** —
293+ measured, DIVERGENT (§3), not refused: 74 samples, first `U(82,188)`.
294+4. **4:4:0 (`ss 0,1`)** — carried forward unmeasured from the sweep's §6.4: the
295+ y4m muxer has no `yuv440p` and aomenc has no 4:4:0 input path. Not
296+ re-derived here.
297+5. **The sweep's exact published byte counts** for the 12-bit 4:2:0 cells
298+ (8713/8760 B) are not reproducible from its recipe text (§1). Disposition:
299+ recorded, not chased; the structural question is answered without them.
300+
301+## 6. Handed on
302+
303+- **Agent24-2 / the 4:4:4 lossless chroma class** gains the sharpest discriminator
304+ this lane produced: exact at 128x128, 192x192 and 256x128, divergent at
305+ 256x256 at 8, 10 and 12 bits, untiled, key frame, chroma only, +-1 — and the
306+ tile-row stream forks at the *same* first sample as the untiled control at 10
307+ and 12 bits. H4 (the tile-rows divergence) should be closed as refuted.
308+- **The shared `CARGO_TARGET_DIR`** is a measurement hazard for every lane that
309+ measures or gates `ec-av1` while siblings build it (§0). Worth a house rule.
lanes/av1txsearch.report.mdadded+238 -0
@@ -0,0 +1,238 @@
1+# lane-av1txsearch — settle the `enable-tx-size-search` census floor
2+
3+Worktree `~/.cache/wt/av1txsearch`, branch `lane-av1txsearch`, based on `1aaf7e0b`
4+(lane-av1distwtd r3, the call-resolving census fix — read as prior art, not
5+duplicated). Owns `crates/ec-av1/src/gate_coverage.rs` only. `stream.rs` and
6+every decoder file are byte-identical to the base.
7+
8+## The claim that was a floor
9+
10+r3 left this in-file, above `DEFAULT_ON_TOOLS`:
11+
12+> 113 of the 230 selected gates name it: 88 pass `=0`, 15 pass `=1`, and 9
13+> build the value into a `format!`/`String` variable that neither `flags_in`
14+> nor `settings_in` can see … Until that exists the count above is a floor, not
15+> a measurement: 9 gates are unclassified in an unknown direction.
16+
17+An unknown direction is the failure this file exists to prevent, so the entry
18+could not be retired on the numbers as they stood. This lane settles it.
19+
20+## 1. The templates
21+
22+`grep -n 'format!("--enable-tx-size-search' crates/ec-av1/src/stream.rs` returns
23+**10** sites, not 9 — the extra one is a segment that spells the flag BOTH as a
24+literal and through a template, so r3's literal reader filed it under the
25+literal and it never showed up in the unknown column. All ten are `format!` with
26+an inline captured placeholder; there is no `String::from`/`to_string`/
27+`push_str` shape and no positional-`{}` shape for this flag. The single
28+positional-`{}` site in the file is a different flag
29+(`a_real_aomenc_stream_with_ab_partitions_below_16x16_decodes_pixel_exact` uses
30+`u8::from(a.tx_size_search)`, below).
31+
32+Four binding shapes cover all ten:
33+
34+| # | template | binding shapes seen |
35+|---|----------|--------------------|
36+| T1 | `format!("--enable-tx-size-search={txs}")` | `for txs in [0usize, 1]`, `for txs in ["0", "1"]` |
37+| T2 | `format!("--enable-tx-size-search={tx_search}")` | `let tx_search = if attempt % 2 == 0 { "0" } else { "1" };` and the `attempt == 0` variant |
38+| T3 | `format!("--enable-tx-size-search={tx_search}")` | `for (tx_search, bit_depth) in [("1", 8u8), ("0", 8u8), ("1", 10u8)]` (tuple-destructured loop) |
39+| T4 | `format!("--enable-tx-size-search={}", u8::from(a.tx_size_search))` | positional arg; value from a struct-literal arm table's `tx_size_search: true/false` rows |
40+| T5 | `for (tag, cq, w, h, ten_bit, vert, tx_search) in arms` + `args.push(if tx_search { "…=1" } else { "…=0" })` | **not** a template — both literals are spelled, so the literal reader saw it. Listed because it is the same tool and was in the "both values" column. |
41+
42+## 2. The binding table
43+
44+`gate` = the census `#[`-segment name, `use site` = the template's shape, `bound
45+value` = what the resolver reads from the gate's own text, `evidence` = the
46+literal source line the binding came from.
47+
48+| gate | use site | bound value | evidence |
49+|------|----------|-------------|----------|
50+| `a_real_aomenc_palette_stream_with_8x8_leaves_decodes_pixel_exact` | T1 | `0` and `1` | `stream.rs:9437` `for txs in [0usize, 1] {` |
51+| `a_coded_rect_intrabc_block_reconstructs_in_both_orientations` | T1 | `0` and `1` | `stream.rs:10901` `for txs in ["0", "1"] {` — this is the segment that ALSO spells the flag literally, which is why r3 counted 9 not 10 |
52+| `a_real_aomenc_inter_sequence_with_temporal_mv_candidates_decodes_pixel_exact` | T2 | `0` and `1` | `stream.rs:19665` `let tx_search = if attempt % 2 == 0 { "0" } else { "1" };` |
53+| `a_real_aomenc_inter_sequence_with_a_coded_rectangular_residual_decodes_pixel_exact` | T2 | `0` and `1` | same line shape, own segment |
54+| `a_real_aomenc_inter_sequence_with_a_16_level_rect_leaf_decodes_pixel_exact` | T2 | `0` and `1` | same line shape, own segment |
55+| `a_real_aomenc_inter_sequence_with_16x16_level_ab_partitions_decodes_pixel_exact` | T2 | `0` and `1` | same line shape, own segment |
56+| `a_real_aomenc_inter_sequence_with_16x16_level_1to4_partitions_decodes_pixel_exact` | T2 | `0` and `1` | same line shape, own segment |
57+| `a_real_aomenc_stream_with_ab_partitions_below_16x16_decodes_pixel_exact` | T4 | `0` and `1` | `stream.rs:26084`+ `tx_size_search: false` rows and `:26150`+ `tx_size_search: true` rows in the arm table |
58+| `a_real_aomenc_stream_with_filter_intra_on_a_sub8_rect_leaf_decodes_pixel_exact` | T3 | `0` and `1` | `stream.rs:31131` `for (tx_search, bit_depth) in [("1", 8u8), ("0", 8u8), ("1", 10u8)]` |
59+| `a_real_aomenc_stream_whose_frame_edge_partition_bit_is_horz_decodes_pixel_exact` | T1 | `0` and `1` | `stream.rs:39945` `for tx_search in [0usize, 1] {` |
60+
61+**Not one of the ten is genuinely runtime-dependent on an unknown argument.**
62+Every binding is a literal `0`/`1` (or a `bool` that becomes one) enumerated in
63+the gate's own text. Each of the ten therefore builds BOTH a `=0` and a `=1`
64+stream on some attempt, so each is an ON gate under this file's standing "any
65+spelling that says on wins" rule.
66+
67+## 3. The true counts
68+
69+`cargo test -p ec-av1 --lib gate_coverage::tests::print_tx_size_search_census -- --nocapture`:
70+
71+```
72+enable-tx-size-search over 230 census-selected gate bodies:
73+ =0 only 86, =1 only 13, both 17, unresolvable 0, not named 114
74+```
75+
76+- **unresolvable: 0 of 230 (0.0%)** — the detector now classifies every body
77+ that names the flag in any form. That is the headline: the floor is a
78+ measurement.
79+- Gates naming the flag at all: 116 of 230 (50.4%). The remaining 114 leave it
80+ off the command line, which under the "defaulted means unknown" rule stays
81+ unknown and retires nothing.
82+- Of the 116: 86 reach only `0`, 13 reach only `1`, **17 reach both** (the ten
83+ template gates plus seven that spell both literals in one segment).
84+- Net: 30 gates positively enable the tool, versus the 15 the literal-only
85+ reader saw. r3's "88 `=0`, 15 `=1`, 9 unknown" is superseded in both
86+ directions — the `=0` count falls (a gate whose other arm is `=1` is not an
87+ "off" gate) and the `=1` count doubles.
88+
89+The count now lives in a test, not a comment, and the test asserts
90+`unresolvable == 0`, so a new helper-parameter blind spot of this shape fails
91+loudly instead of quietly restoring a floor.
92+
93+### The detector change
94+
95+`spelling_values` (new) merges literal `--flag=<digit>` spellings with every
96+value a `format!` template resolves to; `bound_values` (new) does the binding
97+resolution over the four shapes; `resolved_on_state` (new) replaces
98+`default_on_state`, which is deleted (it became dead — the clean cutover, no
99+shim left behind). Three details that are load-bearing:
100+
101+- **Quoted-only for `let` bindings.** A `let tx_search = if attempt % 2 == 0 { "0" } else { "1" };`
102+ initializer contains the bare integer `2`; reading it as a flag value would
103+ invent an ON.
104+- **Position-aware for tuple loops.** `for (tx_search, bit_depth) in [("1", 8u8), …]`
105+ must read only column 0 — the bit-depth column (`8`, `10`) is not a flag value.
106+- **Typed-literal suffixes.** `0usize`/`8u8`/`1u32` are single tokens; a
107+ `bare_digits` that rejected them would have missed `for txs in [0usize, 1]`
108+ and filed the palette gate as `=1` only. Multi-digit `10u8` is still rejected.
109+
110+## 4. RED-BEFORE, both directions
111+
112+Both mutations below were applied to the detector, run, and reverted; the
113+working tree after revert is byte-identical to the pre-mutation file
114+(`diff` clean), and all 12 `gate_coverage` tests are green.
115+
116+**Direction 1 — a mutated `format!` value must MOVE the classification.**
117+Mutating the template needle so the resolver cannot see
118+(`format!("--{spelling}=DISABLED{spelling}=")`) reds **two** tests:
119+
120+- `the_resolver_binds_a_format_built_flag_in_both_directions`: the palette gate
121+ resolves to `{}` instead of `{'0','1'}`.
122+- `print_tx_size_search_census`: `unresolvable 9` (not 0), and the split
123+ degrades to `=0 only 86, =1 only 13, both 8` — 9 of the 17 both-value gates
124+ silently become "not named", which is precisely the old behaviour.
125+
126+The same test also mutates the GATE side: for each of three template shapes it
127+takes the real gate body, rewrites only the bound value
128+(`[0usize, 1]`→`[0usize, 0]`, `"1"`→`"0"` in the else arm, the tuple table's
129+`"1"`→`"0"`), and asserts the resolved set moved from `{'0','1'}` to `{'0'}`.
130+Without that half, a resolver that ignored the binding and returned a constant
131+would pass.
132+
133+**Direction 2 — a spelling the old detector already saw must STILL classify.**
134+Mutating the literal needle instead (`"--DISABLED{spelling}="`) reds **four**:
135+the two `never_on_*_matches_the_gate_recipes` tests (every tool drops to
136+"never on"), `print_tx_size_search_census` (`=0 only 0, =1 only 0`), and the
137+same resolver test, which walks every gate that literally spells
138+`--enable-tx-size-search=1` and asserts each is still classified on, with a
139+floor of 10 such gates so the walk cannot pass vacuously. The new arm is
140+additive over the old one; a resolver that replaced rather than extended the
141+literal path fails here.
142+
143+## 5. The entry decision: RETIRED
144+
145+The tool is exercised by a gate that **asserts the parsed tx-size-search
146+behaviour**, not merely spells it:
147+
148+`a_real_aomenc_stream_with_a_1d_tx_class_on_a_rect_transform_decodes_pixel_exact`
149+spells `--enable-tx-size-search=1` as a literal and hard-asserts
150+`compared_tx_depths > 0` with the message *"never produced a nonzero tx depth on
151+a compared attempt — the flag did not arrive"*. `tx_depth` is read **only**
152+under the frame header's `tx_mode_select` bit (spec 5.11.16; `decode.rs` guards
153+the read with `tx_select_inter`), so a nonzero `TX_DEPTH_HITS` delta IS the
154+parsed tx-size-search behaviour, not a proxy for it.
155+
156+**Measured run of that gate on this tree** (oracle aom `v3.13.3-7-g9bb526a`,
157+one named test, 3.9 s):
158+
159+```
160+12 pixel-exact decodes (0 named refusals out of 12 attempts, 6 of the matches 10-bit),
161+rect coefficient TUs on compared attempts: 219 (10 of them a 1D tx class);
162+flag arrival: rect partitions 120, tx depths 53, 1D-class (square) transforms 13
163+```
164+
165+`tx depths 53` on compared attempts, and 6 of the 12 pixel-exact matches are
166+10-bit — so the tool is exercised at **both** depths and the assertion is not
167+vacuous.
168+
169+The stronger witness, cited in the entry as well:
170+`tx_select_inter_gate` (behind
171+`a_real_aomenc_inter_sequence_with_tx_select_decodes_pixel_exact{,_10bit}`)
172+**deliberately omits** the flag — its recipe carries the comment
173+`// DELIBERATELY ABSENT: --enable-tx-size-search=0.` — and asserts
174+`decode::txfm_split_hits()` moved, i.e. that spec 5.11.17's recursive
175+`txfm_split` var-tx tree was read. An inter transform is then a split tree
176+rather than one whole-block transform, which is the entire content of the tool.
177+That gate's own doc says an unfired gate is a vacuous gate: it panics if no
178+attempt takes a split.
179+
180+### In-file reason text, as landed
181+
182+The `DEFAULT_ON_TOOLS` entry's comment now reads (abridged; full text in the
183+file above `DEFAULT_ON_TOOLS`):
184+
185+> `enable-tx-size-search` SETTLED 2026-09-29 (lane-av1txsearch), by measurement
186+> rather than by a name-shaped guess. The r3 note here said the count was a
187+> FLOOR: 9 gate bodies built the flag into a `format!` variable that neither
188+> `flags_in` nor `settings_in` could see … The method r3 asked for is now
189+> `spelling_values` → `bound_values`, and it resolves all of them;
190+> `print_tx_size_search_census` asserts the unresolvable count is ZERO, so the
191+> floor cannot come back unnoticed.
192+>
193+> THE ENTRY IS RETIRED, on an ARRIVAL ASSERT rather than on the spelling.
194+> `a_real_aomenc_stream_with_a_1d_tx_class_on_a_rect_transform_decodes_pixel_exact`
195+> spells `--enable-tx-size-search=1` as a literal and hard-asserts
196+> `compared_tx_depths > 0` … `tx_depth` is read ONLY under the frame header's
197+> `tx_mode_select` bit (spec 5.11.16 …), so a nonzero counter IS the parsed
198+> tx-size-search behaviour, not a proxy for it. Measured run of that gate on
199+> this tree (aom 3.13.3): 12 pixel-exact decodes, 0 named refusals, 6 of the 12
200+> at 10 BIT, 219 rect coefficient TUs on compared attempts, and `flag arrival:
201+> … tx depths 53` …
202+
203+The "all 49" prose count stays deleted, per r2; the module doc now points at
204+the test rather than a number that rots.
205+
206+## What is not claimed
207+
208+- The 114 bodies that leave the flag off the command line stay **unknown**, not
209+ "exercised". The default of `1` is not a stream carrying the tool.
210+- `bound_values` returns `None` when the variable is a shared helper's
211+ parameter (bound at a call site in a different segment). That path is
212+ implemented and reported, not guessed — and today no
213+ `--enable-tx-size-search` site takes it. A future helper-parameter flag will
214+ be counted as unresolvable and will red the census test rather than pass
215+ silently.
216+- No claim is made about any OTHER `DEFAULT_ON_TOOLS` tool's floor. The
217+ resolver is general, so those counts also moved; re-run
218+ `print_never_on_per_bit_depth` to read them. The 8-bit and 10-bit
219+ `NEVER_ON_*` lists are empty on this tree and their tests are green.
220+- No decoder behaviour, counter, gate or fixture changed. `stream.rs` is
221+ untouched.
222+
223+## Test evidence
224+
225+`gate_coverage` module, 12 tests, all green on the final tree:
226+
227+```
228+test result: ok. 12 passed; 0 failed; 0 ignored; 0 measured; 704 filtered out
229+```
230+
231+Covered by the above: `every_gate_disabling_a_tool_is_a_listed_coverage_hole`,
232+`tool_settings_reads_whole_flags`,
233+`the_detector_sees_the_gates_the_spelling_filter_missed` (r3's, still green),
234+`never_exercised_{8bit,10bit}_matches_the_gate_recipes`,
235+`never_on_{8bit,10bit}_matches_the_gate_recipes`,
236+`default_on_tools_do_not_duplicate_the_universe`, the three print tests, and the
237+two new ones (`print_tx_size_search_census`,
238+`the_resolver_binds_a_format_built_flag_in_both_directions`).
lanes/h264reallib.report.mdadded+204 -0
@@ -0,0 +1,204 @@
1+# lane-h264reallib — real-library sweep: shape, local verdict, class sweep
2+
3+Branch `lane-h264reallib` (worktree `~/.cache/wt/h264reallib`, base `a21f3680`).
4+Tests only. No decoder change, no assertion weakened.
5+
6+Three separate deliverables, per Main's request to keep them apart:
7+(a) the local verdict on the real library, (b) the shape change that stops
8+runners reporting a false red, (c) the count and table of the rest of the class.
9+
10+---
11+
12+## (a) Local verdict — PASSES on the workstation, no decoder defect
13+
14+Run on the workstation, where the library is:
15+
16+```
17+EC_NOMEMGUARD=1 cargo test -p ec-h264 --test conformance \
18+ real_library_streams_match_ffmpeg -- --ignored --nocapture
19+```
20+
21+`fixtures/real-library-manifest.tsv` is gitignored and generated by
22+`scripts/scan-real-library.sh` (ffprobe sweep of `~/Videos ~/Downloads ~/Music`).
23+Copied from the primary checkout into the worktree for the run; **111 h264 rows,
24+all 111 paths resolve** on this host.
25+
26+Result — **15 decoded bit-exact, 0 refused by name, 0 failures**, 1918 s:
27+
28+| file | container | width | frames |
29+|---|---|---|---|
30+| reel-24f2c8 | matroska,webm | 2560px | 500 bit-exact |
31+| reel-7538d2 | mov,mp4,m4a,3gp,3g2,mj2 | 2560px | 500 bit-exact |
32+| reel-1c3a81 | matroska,webm | 1280px | 500 bit-exact |
33+| reel-286c86 | mov,mp4,… | 3840px | 500 bit-exact |
34+| reel-010d74 | mov,mp4,… | 576px | 500 bit-exact |
35+| reel-ab1f6d | mov,mp4,… | 640px | 500 bit-exact |
36+| reel-e99558 | mov,mp4,… | 1920px | 500 bit-exact (container demux) |
37+| reel-436303 | mov,mp4,… | 1274px | 439 bit-exact |
38+| reel-28cd87 | mov,mp4,… | 720px | 500 bit-exact |
39+| reel-bf1a18 | matroska,webm | 1920px | 500 bit-exact |
40+| reel-92d5fc | mov,mp4,… | 1080px | 500 bit-exact |
41+| reel-6ee243 | mov,mp4,… | 1078px | 500 bit-exact |
42+| reel-1db5fd | mov,mp4,… | 1280px | 185 bit-exact |
43+| reel-4148f8 | mov,mp4,… | 1916px | 500 bit-exact |
44+| reel-ccbe4e | mov,mp4,… | 1138px | 500 bit-exact |
45+
46+Both demuxers are exercised (matroska + mov/mp4), the sweep covers 576px→3840px,
47+and one file took the container-demux fallback exactly as designed. **The
48+decoder is fine; the fleet red was never about the decoder.**
49+
50+Runtime: **1918 s (~32 min)**, matching Main's independent observation that it
51+runs past 840 s. That number is now in the ignore reason so the next person does
52+not read the wall time as a wedge.
53+
54+## (b) Shape change — why `#[ignore]`, and what it stops
55+
56+`crates/ec-h264/tests/conformance.rs:1846` `real_library_streams_match_ffmpeg`.
57+
58+The precondition is a personal media library, which has exactly two possible
59+behaviours on a runner, and **both are wrong**:
60+
61+- manifest absent → the existing `SKIP: … missing` early return prints
62+ **green**. That is the silent-skip class this batch is removing: a green that
63+ means "nothing was checked".
64+- manifest present but its absolute paths unresolvable (a host that ran the scan
65+ script against an empty library) → zero files swept and `decoded >= 3` fails.
66+ That is **the red every fleet run currently eats**, and it is red for a reason
67+ that has nothing to do with the decoder.
68+
69+`#[ignore]` over an env-gated SKIP, justified: an env gate whose variable is
70+absent on the runner prints *the same green the missing manifest already prints* —
71+that is the defect, not the fix. An ignore is visible in
72+`cargo test -- --list`, cannot go green silently, and needs no runner-side
73+configuration that could itself drift. The assertion is untouched: `decoded >= 3`
74+still stands, and still holds, on the machine that can run it (it did: 15 ≥ 3).
75+
76+Verified — the target is no longer red, and the reason is printed verbatim:
77+
78+```
79+
80+test real_library_streams_match_ffmpeg ... ignored, sweeps the PERSONAL media
81+library (~/Videos, ~/Downloads, ~/Music) through the gitignored
82+fixtures/real-library-manifest.tsv; MINUTES of wall time (measured past 840 s on
83+the workstation), so workstation only -- budget an hour, it is not wedged. ...
84+test result: ok. 0 passed; 0 failed; 1 ignored; 0 measured; 22 filtered out
85+```
86+
87+Also fixed, because the fix is the *identical* one-line `#[ignore]` + reason and
88+no judgement call: `crates/ec-aac/tests/oracle.rs:680`
89+`real_library_tracks_match_ffmpeg` — same manifest, same
90+"skip if manifest missing, then assert `checked >= 3`" shape, same two failure
91+modes. Verified reporting `1 ignored`.
92+
93+## (c) Class sweep — 51 sites examined, 2 fixed, 3 need a decision, 46 already correct
94+
95+The class: a test that reads `~/Music`, `~/Videos`, `~/Downloads`, a hardcoded
96+`/home/<user>/` path, or the generated manifest; **or** asserts a minimum count
97+of personal files. Swept `crates/*/tests/**`, `crates/*/src/**` (incl.
98+`#[cfg(test)]`), `tests/**`, `tools/**`, `shims/**`, and the scripts.
99+
100+**Members of the class that are RED-ON-RUNNER and not ignored — the ones that
101+still need a decision (not fixed here, because the right fix is NOT the
102+identical one-liner):**
103+
104+| file:line | what it needs | runs on a runner? | current behaviour | proposed shape |
105+|---|---|---|---|---|
106+| `crates/ec-probe/tests/library.rs:490` `a_real_library_sweep` | manifest + ≥1 row whose path still exists | partially | red-on-runner | **Remove the minimum-count assert, do not ignore.** The file's own header (:5-6) states moved files are "skipped and reported, never failed" — the `:490` assert contradicts the stated contract. This is a real bug in the test's own spec, not a shape problem. |
107+| `crates/ec-aac/tests/sbr_real_library.rs:4797` `sbr_residual_locator` | `$HOME` set at all — bare `env::var("HOME").unwrap()` | partially | red-on-runner | **One-line `unwrap_or_default()`**, matching the five sibling HOME reads in the same file (:2710, :3426, :4109, :4182, :4575). The `:4803` `path.exists()` guard already handles the absent file; only the bare `unwrap` panics. |
108+| `crates/ec-aac/tests/obs_real_content.rs:151` `obs_content_table` | `$HOME` set — bare `unwrap()` | partially | silent-skip | **One-line `unwrap_or_default()`**, same reason. The `read_dir` guard at :152 already handles the absent directory. |
109+
110+**Already correctly shaped — `leave alone` (14 named, rest by the same pattern):**
111+these read personal paths but handle absence correctly, so they are NOT the
112+class. The template worth copying:
113+
114+- `crates/ec-h264/tests/encode.rs:751` `real_library_frames_encode_and_decode_exactly`
115+ — **the reference "correct" shape of this class**: `:728-731` soft-skips when no
116+ qualifying row survives, so the `sources.len() >= 6` assert is only reachable
117+ once a real file was actually opened. This is what the two sites above should
118+ be rewritten to.
119+- `crates/ec-aac/tests/oracle.rs:848` `he_aac_library_track_decodes_to_its_core`
120+ — sibling of the one I ignored, correctly shaped: prints a named SKIP at :919
121+ and returns at :917, so the :912 assert only fires on a file it decoded.
122+- `crates/ec-image/tests/real_library.rs:52`, `:132`; `crates/ec-truehd/tests/library.rs:78`,
123+ `crates/ec-truehd/tests/oracle.rs:87`; `crates/ec-probe/tests/library.rs:585`, `:621`,
124+ `:756`; `crates/ec-aac/tests/reelh_per_frame.rs:29`; `crates/ec-hw/tests/gpu.rs:2050`
125+ (and the three other gpu.rs personal-path sites, all GPU-guarded) — all guard
126+ on `exists()`/`read_dir` and print a named skip.
127+- `crates/ec-aac/tests/sbr_real_library.rs:2710`, `:3690`, `:4176`, `:4566` — filter
128+ candidates on `.exists()`, empty list skips, no minimum-count assert.
129+
130+**Already `#[ignore]`d with a reason naming the precondition — `leave alone`
131+(~20):** `ec-mp3/tests/encode_matrix.rs:639`, `:851`; `ec-mp4/tests/mp4.rs:789`;
132+`ec-matroska/tests/matroska.rs:538`, `:965`, `:1058`, `:1282`, `:1400`;
133+`ec-vorbis/tests/oracle.rs:1190`; `ec-opus/tests/conformance.rs:758`, `:2958`,
134+`:3149`, `:3428`, `:3654`, `:3859`, `:4091`, `:4572`; `ec-av1/src/encode.rs:16808`,
135+`:19748`, `:20068`, `:20175`, `:21054`, `:21163`, `:22857`, `:22982`. The repo's
136+dominant convention is already "ignore + reason", which is why this lane's fix
137+follows it rather than inventing a new shape.
138+
139+**False positives — do NOT touch (the class looks bigger than it is):**
140+
141+- `scripts/extract_vp8_tables.py:15`, `scripts/build-aom-oracle.sh:17`,
142+ `build-aom-affine-oracle.sh:23`, `instrument-aom-oracle.sh:73`,
143+ `gen_vp8_fixtures.sh:52`, `memguard-runner.sh:39` — `$HOME/.cache/{aom-oracle,vp8}`
144+ and `$HOME/.config/systemd`: build/toolchain locations, all env-overridable,
145+ none read media.
146+- `tools/ec-bench/src/main.rs:82` — non-test bench binary; reports "no candidate".
147+- `crates/ec-aac/tests/sbr_real_library.rs:3715`, `:4572` — `$CARGO_MANIFEST_DIR/../../.cache/heaac-fixtures`,
148+ a generated-fixture cache relative to the repo.
149+- `crates/ec-vp9/tests/scaledref_exact.rs:18` — a doc comment recording how a
150+ *committed* .ivf was produced; the test reads the tracked file.
151+- `crates/ec-mp4/tests/mp4.rs:635` — personal file is purely additive to a repo
152+ fixture that is always present; not a dependency.
153+
154+**Non-test dependents of the manifest** (why it exists on some hosts and not
155+others — worth knowing when reading a red):
156+
157+- `scripts/scan-real-library.sh` — the generator; defaults to
158+ `$HOME/Videos $HOME/Downloads $HOME/Music`, writes the gitignored
159+ `fixtures/real-library-manifest.tsv`, honours `EC_FIXTURES`.
160+- `lanes/b64b/bin-control:59261` — a built binary that reads the manifest.
161+- No CI workflow file in the repo runs the scan, which is exactly why runner
162+ behaviour differs: a host that once ran the script by hand keeps a manifest
163+ whose paths no longer resolve, and that is the state that produces the false red.
164+
165+**One incidental finding, not fixed (out of scope, flagged not hidden):**
166+`crates/ec-matroska/tests/matroska.rs:966` reads the manifest at a **hardcoded
167+absolute** `/home/user/Documents/Code/Rust/edith_codecs/fixtures/…` instead
168+of `CARGO_MANIFEST_DIR`-relative like every sibling. It is already `#[ignore]`d
169+with a soft skip, so it is harmless today, and it also silently defeats
170+worktree isolation. Worth converting to the relative form if that ignore is ever
171+lifted.
172+
173+### Round 2 — the four approved follow-ups (all now fixed)
174+
175+| site | change | before | after |
176+|---|---|---|---|
177+| `crates/ec-probe/tests/library.rs:490` | `assert!(!chosen.is_empty())` → named SKIP + `return` | red-on-runner whenever every manifest path had moved | `1 passed; 0 failed; 0 ignored` |
178+| `crates/ec-aac/tests/sbr_real_library.rs:4797` | `env::var("HOME").unwrap()` → `.unwrap_or_default()` | `FAILED. 0 passed; 1 failed` — `called Result::unwrap() on an Err value: NotPresent` | `1 passed; 0 failed; 0 ignored` |
179+| `crates/ec-aac/tests/obs_real_content.rs:151` | same | `FAILED. 0 passed; 1 failed` — same panic | `1 passed; 0 failed; 0 ignored` |
180+| `crates/ec-matroska/tests/matroska.rs:966` | hardcoded absolute manifest path → `fixtures()` | read the PRIMARY checkout's manifest from any worktree | `fixtures()` = `CARGO_MANIFEST_DIR/../../fixtures`, like every sibling |
181+
182+The two HOME fixes were proved by running them under `env -u HOME` (the
183+runner shape) before and after; the probe fix was proved by running the test
184+with its manifest paths unresolvable.
185+
186+**Sweep disposition after round 2: 6 fixed, 0 remaining, 14 already correct,
187+the rest already `#[ignore]`d or false positives.** No member of this class is
188+left red-on-runner.
189+
190+## Change list
191+
192+| file | change |
193+|---|---|
194+| `crates/ec-h264/tests/conformance.rs:1870` | `#[ignore = "…"]` + 25-line reason above the test; assertion untouched |
195+| `crates/ec-aac/tests/oracle.rs:688` | `#[ignore = "…"]` + reason; identical shape, assertion untouched |
196+| `crates/ec-probe/tests/library.rs:490` | minimum-count assert → named SKIP + return; restores the file's own :5-6 contract |
197+| `crates/ec-aac/tests/sbr_real_library.rs:4797` | bare `env::var("HOME").unwrap()` → `unwrap_or_default()` |
198+| `crates/ec-aac/tests/obs_real_content.rs:151` | same |
199+| `crates/ec-matroska/tests/matroska.rs:966` | hardcoded absolute manifest path → `fixtures()` |
200+
201+No decoder change anywhere. Two new `#[ignore]`s, both previously
202+red-on-runner and never green. The only assertion removed is the
203+`ec-probe` minimum count, and removing it RESTORES the contract that file's
204+own header declares rather than hiding a failure; no other assertion weakened.
lanes/merge-wave-2.report.mdadded+204 -0
@@ -0,0 +1,204 @@
1+# Merge wave 2 — 13 lanes into `main`
2+
3+Base `main` = `298f75c4` (= `origin/main` at open). Every lane is merged
4+`--no-ff` as its own commit, in the order the review pass fixed. Nothing was
5+pushed. `CARGO_TARGET_DIR=$HOME/.cache/cargo-target`, `TMPDIR=$HOME/.cache/tmp`.
6+
7+## Result
8+
9+| # | branch | tip merged | conflicts resolved how | files touched |
10+|---|--------|-----------|------------------------|---------------|
11+| 1 | `lane-av1chrtx` | `ea97eb0c` → `e443a86e` | none (auto-merged; `cargo check` clean) | `decode.rs` +310/-11, `stream.rs` +239, `fixtures/444_rect_strip_leaf_tx_type.obu` (26839 B), `lanes/av1chrtx.report.md`, `lanes/av1readcensus.report.md` |
12+| 2 | `lane-av1skipfix` | `960be978` → `5e9c7715` | none | `refusal_inventory.rs`, `stream.rs` (902 chg), `ec-flac/tests/xiph_vectors.rs`, `ec-h264/tests/conformance.rs`, `ec-opus/tests/conformance.rs`, `scripts/link-fixtures.sh`, `lanes/av1skipfix.report.md`, `lanes/COMMON-20260901.md` |
13+| 3 | `lane-av1gates444` | `555c83f3` → `0eb19c11` | none | `stream.rs` +230, `lanes/av1gates444.report.md` |
14+| 4 | `lane-av1mutproof` | `ffd8d138` → `10db0dc2` | none — report-only lane | `lanes/av1mutproof.report.md` |
15+| 5 | `lane-av1toolgates` | `4c4bd3e2` → `962945ce` | none | `stream.rs` +332 |
16+| 6 | `lane-av1tilemeasure` | `df1370dd` → `b4c45166` | none | `stream.rs` +492, `lanes/av1tilemeasure.report.md` |
17+| 7 | `lane-av1superhbd` | `a2da03e4` → `e96de012` | none | 5 new pins (`…_d12_10bit` 15803 B, `_d12_12bit` 11023 B, `_d9_12bit` 13015 B, `…_mode2_…_10bit` 17776 B, `_12bit` 14656 B), `stream.rs` +409, `lanes/av1superhbd.report.md` |
18+| 8 | `lane-av1pins` | `44a05b40` → `7f8817cb` | **1 competing edit** in `stream.rs` — see below | 3 new pins (`golden3-pin.obu` 159 B, `ll444-lossless-key.obu` 7845 B, `sbpart-pin.obu` 238 B), `stream.rs` +243/-84, `lanes/av1pins.report.md` |
19+| 9 | `lane-av1distwtd` | `1aaf7e0b` → `a5867794` | **add/add at the tail of `mod tests`** — both sides kept, one closing brace re-inserted. Plus a **foreign worktree leak** caught mid-merge. | `decode.rs` +34, `gate_coverage.rs` +390/-40, `stream.rs` +226, `lanes/av1distwtd.report.md` |
20+| 10 | `lane-av1dualfilter10` | `c2b969c8` → `764ba257` | none (contains `1aaf7e0b`, so only its own delta lands) | `stream.rs` +92/-3, `lanes/av1dualfilter10.report.md` |
21+| 11 | `lane-av1lm444loss` | `9249442f` → `9a9e3674` | none — `decode.rs` regions are disjoint from `chrtx` and `distwtd` | `decode.rs` +81/-6, `stream.rs` +122, `lanes/av1lm444loss.report.md` |
22+| 12 | `lane-whtshape` | `f541d062` → `afa13bcf` | **2 interleaved add/add hunks** — resolved by construction, see below | `fixtures/ll444_sb64_1to4_lossless.obu` (51107 B), `decode.rs` +256/-45, `stream.rs` +200, `transform.rs` +223/-?, `lanes/whtshape.report.md` |
23+| 13 | `lane-av1superpin` | `9646f74d` → tip (see note) | **2 comment/add hunks in `decode.rs` (main's text kept), interleaved add/add in `stream.rs` (reconstructed), add/add in `lanes/av1formatsweep.report.md` (superpin + spliced row), one byte-identical duplicate gate deleted** — see below | 5 new pins, `decode.rs`, `stream.rs` +932 net, `lanes/av1444edge.report.md`, `lanes/av1formatsweep.report.md`, `lanes/av1superpin.report.md`, `gate_coverage.rs` (retirement reconciliation), `lanes/merge-wave-2.report.md` |
24+
25+Row 13's merge commit cannot name its own hash inside itself; the authoritative
26+chain is `git log --first-parent 298f75c4..HEAD` and row 13 is the tip.
27+
28+## Conflict resolutions, in detail
29+
30+### 8 — `lane-av1pins` vs `lane-av1skipfix`: competing edits, not add/add
31+
32+Both lanes rewrote the same arm of
33+`a_real_aomenc_lossless_444_key_frame_decodes_sample_exact`.
34+
35+* ours (`skipfix`): read the pin from the **gitignored root** `fixtures/`
36+ through `pin_dir()`, with an opt-in `EC_REQUIRE_FIXTURES` /
37+ `EC_AV1_REQUIRE_AOMENC` hard fail.
38+* theirs (`pins`): read the pin that **this same merge commits**, through the
39+ new `crate_pin()`, but with a bare `SKIP` — i.e. exactly the
40+ report-green-having-decoded-nothing defect `skipfix` exists to close.
41+
42+Resolution: **theirs' committed-pin path and provenance comment, plus ours'
43+no-silent-green intent made unconditional.** The committed pin is read through
44+`CARGO_MANIFEST_DIR` and a missing file panics with the regeneration recipe.
45+That is strictly stronger than the opt-in env fail — there is no environment
46+left to escape — and it is what `lane-av1skipfix`'s own later commit
47+`f385963f` independently concluded. Not `@both`: the two sides are the same
48+statement.
49+
50+Marker surgery alone was not enough here: the hoisted shared `};` left an
51+orphan after the replacement, which surfaced as
52+`unexpected closing delimiter … 45608` (the marker-free-corruption shape).
53+Removed explicitly.
54+
55+### 9 — `lane-av1distwtd`: add/add at the tail, plus a foreign leak
56+
57+`stream.rs`: both lanes append `#[test]` fns at the end of `mod tests`, so this
58+is the classic add/add — **both sides kept**. Git hoisted the shared trailing
59+` }` / `}` out of the hunk, so ours' last test needed its closing ` }`
60+re-inserted between the two blocks.
61+
62+A **foreign uncommitted edit** appeared in the primary checkout while this merge
63+was in flight: 465 lines added to `gate_coverage.rs` carrying
64+`lane-av1txsearch`'s `bound_values` / `spelling_values` / `resolved_on_state` /
65+`is_ident_byte` — four functions this merge had just added, so the file
66+silently compiled to a **duplicated** set and failed with four borrow/type
67+errors and no conflict marker anywhere. It was preserved (byte copy below),
68+the merge result restored from the index, and `cargo check --all-targets`
69+re-run. Also present: an untracked `lanes/av1mergecheck.report.md` from a
70+sibling read-only review pass, which was swept out of this merge's tree
71+after an `--amend` and left untracked for its owner.
72+
73+### 12 — `lane-whtshape`: two interleaved hunks
74+
75+Both lanes append at the same tail anchor and git produced two conflict regions
76+that split **ours' last gate mid-statement** — the `<<<<<<<`/`=======` surgery
77+does not apply. Resolved by construction instead: this lane's `stream.rs`
78+delta against its merge base is a **single 199-line block appended at the
79+tail** (`@@ -43597,4 +43597,203 @@`, 199 added lines, 0 removed), so the merged
80+file is HEAD's `stream.rs` verbatim (its closing brace kept) + that block + the
81+module's closing brace. A first attempt stripped one brace too many and
82+produced an extra `}` at EOF; caught by `cargo check`, fixed.
83+
84+### 13 — `lane-av1superpin`
85+
86+* `decode.rs` (2 hunks, both `@ours`): one comment-only hunk where main's text
87+ is the more informative, and one where theirs simply has no counter —
88+ `INTRABC_RECT4_OWN_CHROMA444_HITS` is a main-only addition from an earlier
89+ lane that superpin's older base predates.
90+* `stream.rs`: same interleaved tail shape as #12. Superpin's delta against its
91+ merge base is 933 added lines at one hunk (plus **one** deleted blank line,
92+ cosmetic), so merged = HEAD verbatim + that block. That block re-adds
93+ `a_444_lossy_rect4_inter_stream_decodes_pixel_exact`, which superpin already
94+ carried from `e10a3b25` (`lane-av1444rect`) and main also has — a
95+ **byte-identical duplicate** (5905 B, extracted and compared, `IDENTICAL`).
96+ The appended copy was deleted; the gate is defined once. All six of
97+ superpin's new gates are present exactly once afterwards.
98+* `lanes/av1formatsweep.report.md` (add/add): **superpin's version**, with the
99+ **§6.2 `130x122` row spliced from `lane-park-av1444edge` @ `a02a2511`** — the
100+ correction that the cell is EXACT 4/4 (bytes 8945, sha `c87ac65b…`), the same
101+ H1 1:4-inter-strip class, closed by `lane-av1444rect`'s `f92776ba`, which is
102+ an ancestor of main. The original measurement text is **kept inside** the row
103+ (`was "DIVERGENT from f3, 11521 samples, first (f3, s2208) = Y(128,16)"; now
104+ EXACT 4/4`), not deleted. The rest of `a02a2511` was **not** merged.
105+* `gate_coverage.rs`: the wave-wide retirement reconciliation — see below.
106+
107+### `gate_coverage.rs` — the union of retirements
108+
109+Resolution applied across the wave, and the two lists are now **empty**, which
110+is what the census derives:
111+
112+| entry | retired by | depth |
113+|-------|-----------|-------|
114+| `enable-dist-wtd-comp` | `a_distance_weighted_compound_stream_decodes_pixel_exact` (asserts the parsed `enable_jnt_comp`, and `dist_wtd_comp_hits() > 0`) | 8-bit |
115+| `enable-dual-filter` | `a_real_aomenc_dual_filter_obmc_8x8_inter_sequence_decodes_pixel_exact` + `dual_filter_diff_hits()` arrival assert | 8-bit |
116+| `enable-dual-filter` | `a_real_aomenc_10bit_dual_filter_obmc_8x8_inter_sequence_decodes_pixel_exact` (`lane-av1dualfilter10`) | 10-bit |
117+| `enable-flip-idtx` | `a_real_aomenc_stream_with_a_1d_tx_class_on_a_rect_transform_…` (`compared_class1 > 0`); detector fix — `covers_both_depths` now recognises the pair-of-pixel-formats marker | 8-bit |
118+| `enable-rect-tx` | `a_real_aomenc_{8,10}bit_stream_with_a_rect_transform_decodes_pixel_exact` (`lane-av1toolgates`); witness is the parsed shape (`rect_partition_hits` / `rect_coeff_tu_hits`), not the flag — the flag has no sequence-header bit | 8- and 10-bit |
119+
120+`TOOL_UNIVERSE` keeps all 26 tools, `enable-rect-tx` included. The test was
121+**not** weakened. Measured before the edit (the real red, not an assumed one):
122+
123+```
124+the 8-bit list still names ["enable-rect-tx"], but a 8-bit gate now passes `=1` for them
125+the 10-bit list still names ["enable-dual-filter", "enable-rect-tx"], …
126+```
127+
128+After: `print_never_exercised_per_bit_depth` reports **255 real-aomenc gate
129+bodies, NEVER_EXERCISED derived EMPTY at 8 bits and at 10 bits (0 of 26)**.
130+
131+> A stale-binary trap worth naming: the first census run in this wave reported
132+> `145 gates / 4 of 26 / 2 of 26` and `gate_coverage` **passed 9/9**. That was a
133+> test binary built from a mid-reconstruction `stream.rs`, not the merged tree.
134+> `include_str!("stream.rs")` is compile-time, so a `cargo check` does not
135+> refresh it — only a real `cargo test` rebuild does. Re-running after
136+> `touch crates/ec-av1/src/gate_coverage.rs` gave 255 gates and the two genuine
137+> failures above.
138+
139+## Duplicate fixtures
140+
141+Measured after merge 13: `crates/ec-av1/fixtures/` holds **63 files, 63
142+distinct sha256 prefixes — zero duplicates**, so the deletion clause did not
143+fire. Checked in particular: superpin's `444_lossy_superres_256x128_d12.obu`
144+(14808 B, sha `450caa3e…`) versus `lane-park-av1444edge`'s rename target
145+`444_lossy_superres_random_256x128.obu` (sha `c18496cf…`) — different bytes,
146+and the rename lives only in the unmerged `a02a2511`, so nothing collides.
147+
148+## Verification actually run
149+
150+```
151+cargo check -p ec-av1 after EVERY merge → clean
152+cargo check -p ec-av1 --all-targets after EVERY merge → clean
153+bash /tmp/losscheck.sh <pre> <parentA> <parentB> → LOST empty at EVERY merge
154+cargo test -p ec-av1 --lib -- gate_coverage refusal_inventory
155+ → test result: ok. 25 passed; 0 failed; 0 ignored; 0 measured; 717 filtered out
156+```
157+
158+`losscheck.sh` diffs the `fn a_*` set of the merged `stream.rs` against the
159+union of both parents' sets, in **both** directions, after every merge. Final
160+state: `now=285 union=285`, LOST empty, ADDED empty.
161+
162+`gate_coverage` and `refusal_inventory` are both GREEN on the merged tree, and
163+the census is green because the entries were retired, not because the test was
164+touched. Both `never_exercised_*bit_matches_the_gate_recipes` failures quoted
165+above were observed as real reds immediately before the retirement edit.
166+
167+## Post-merge fix tasks (NOT fixed here)
168+
169+1. **`lane-av1gates444`'s three gates are green on a host with no oracle.**
170+ `a_444_lossy_odd_66x66_…`, `a_444_lossy_odd_130x122_…` and
171+ `a_444_lossy_256x128_…` share the arm
172+ `if !have_aomenc() { eprintln!("SKIP {name}: no aomenc oracle at {} …"); return Vec::new(); }`
173+ in the shared helper `encode_444_lossy_live`. On a host without
174+ `aomenc`/`aomdec` all three return `rc=0` having measured nothing — the
175+ class `gate-blind-to-feature` in its purest form. They need the
176+ `EC_AV1_REQUIRE_AOMENC` hard-fail shape the rest of the crate already uses.
177+2. **`refusal_inventory.rs`'s `gates_that_swallow_a_decode_error_are_declared`
178+ is blind to 354 of 397 arms.** It filters parsed gate names with
179+ `chars().all(|c| c.is_ascii_lowercase() || c.is_ascii_digit() || c == '_')`,
180+ so every arm that emits the interpolated `eprintln!("SKIP {NAME}: {e}")` is
181+ exempt while only the literal-lowercase arms are enforced. The guard must
182+ see the lanes' own new arm shape (the interpolated one), not just the 43
183+ literal spellings.
184+
185+## Left behind on purpose
186+
187+* Branch heads past the dispatched tips, **not merged** (state, not a
188+ recommendation): `lane-av1chrtx` `6cc9ea6f` (report/branch-name + gate-name
189+ fix), `lane-av1skipfix` `b696d485` (commits the 444 lossless key-frame pin at
190+ 7851 B and rewires that gate onto `CARGO_MANIFEST_DIR` — note this is a
191+ **different regeneration** from the 7845 B pin `lane-av1pins` committed, so
192+ merging both would put two same-recipe pins in the crate),
193+ `lane-av1lm444loss` `5519aaf8` (ss-aware chroma geometry + lossless TX_4X4
194+ raster — the follow-on lead (b) the report's appendix names as open).
195+* `lane-park-av1444edge` @ `a02a2511`: only the §6.2 row was taken. Its
196+ remaining r4 work (`84846129`'s `a_444_superres_arm` gates, superseded by
197+ superpin's; `bb44ddd0`'s sweep corrections) is **not** merged.
198+* Foreign files preserved, not committed:
199+ `~/.cache/merge-wave-2-keep/gate_coverage.rs.lane-av1txsearch-leak` and
200+ `~/.cache/merge-wave-2-keep/av1mergecheck.report.md.foreign`. The latter is
201+ still untracked in the worktree for its owner.
202+
203+**No push was performed.** `main` is ready to push from `298f75c4` + these 13
204+merge commits.
lanes/merge-wave-4.report.mdadded+189 -0
@@ -0,0 +1,189 @@
1+# Merge wave 4 — integration report
2+
3+Base `aa0ac8c2` (wave 2, "clean-checkout census"). Four branches, four
4+`--no-ff` merge commits, **zero conflicts** on any of them. No push.
5+
6+## Per-branch table
7+
8+| # | Branch | Tip merged | Merge base | True delta (base → tip) | Conflicts |
9+|---|--------|-----------|-----------|-------------------------|-----------|
10+| 1 | `lane-av1recipehunt` | `1acf1818` | `aa0ac8c2` | 9 files, +1164/-545 | none |
11+| 2 | `lane-av1rect8x16` | `ee56661f` | `afa13bcf` | 2 files, +493/-0 | none |
12+| 3 | `lane-h264reallib` | `25c996b2` | `a21f3680` | 7 files, +562/-96 | none (one auto-merged hunk, `crates/ec-h264/tests/conformance.rs`) |
13+| 4 | `lane-av1dumpyuv` | `60a7788a` | `afa13bcf` | 4 files, +437/-26 | none |
14+
15+**True delta is measured against each branch's own merge base, not against an
16+older tip.** `git diff a21f3680 1acf1818` for branch 1 shows 52 files / +10975
17+of rebase noise; `aa0ac8c2 → 1acf1818` is the real 9-file delta. Branch 3's
18+merge base is also `a21f3680` (it forked before wave 2), which is why its
19+delta is quoted against that commit.
20+
21+### 1. `lane-av1recipehunt` @ `1acf1818` — merged first
22+
23+Landed first by design: it is the only branch touching `src/stream.rs` and
24+`src/encode.rs`, and it introduces the three fixture pins the later branches'
25+reports cite.
26+
27+- **Three TRACKED fixture pins** (verified with `git ls-tree` at the merged
28+ HEAD, and `stat` on disk):
29+
30+ | Fixture | Bytes | Blob sha |
31+ |---------|-------|----------|
32+ | `crates/ec-av1/fixtures/rect64_dq_drift.obu` | 8384 | `29f6e5dabcb1630baf593ea977952550a5a2bb49` |
33+ | `crates/ec-av1/fixtures/intra14_256x192_8bit.obu` | 35179 | `1d345e07f94c2a61b7849d88970b4ab0408f05e1` |
34+ | `crates/ec-av1/fixtures/intra14_256x192_10bit.obu` | 34727 | `b16114a42e4ad49c59a1e9d9839556c4caf2ddd9` |
35+
36+ All three sizes match the reviewer's independent recomputation.
37+- `src/stream.rs` +952/-545 (the rebase-noise bulk of this branch), plus
38+ `src/encode.rs` +117, `src/tile.rs` +68, and the two example probes.
39+- **Gates: 3 un-ignored, 1 deleted** (see "Gate count" below).
40+- Dedupe result: **no duplicate blobs** in `crates/ec-av1/fixtures/`
41+ (`git ls-tree -r` grouped by blob sha — no sha appears under two names).
42+ Nothing to dedupe; no dedupe needed to be mentioned in a message.
43+
44+### 2. `lane-av1rect8x16` @ `ee56661f`
45+
46+Pure test-only `refusal_inventory.rs` +246/-0 plus its report. Zero merge
47+surface against wave 3 and against branch 1.
48+
49+**Fixed in the merge commit:** the inventory comment at
50+`crates/ec-av1/src/refusal_inventory.rs:556` read *"All nine call sites"*,
51+which contradicts the test's own `assert_eq!(sites, 8)` at line 1642 and the
52+lane report. The nine is a count of **textual `decode_block_rect(` matches in
53+`decode.rs`**, which is 1 declaration + 8 call sites — the test skips the
54+declaration explicitly (`if src[..i].ends_with("fn ") { continue; }`). The
55+comment now states that arithmetic. One line of prose, no code change.
56+
57+### 3. `lane-h264reallib` @ `25c996b2`
58+
59+Real-media-library test sites reshaped to `#[ignore]` with fact-based reasons,
60+so a site that cannot run because ffmpeg/ffprobe or a media file is absent no
61+longer reads as "passed". Four follow-ups in the same tip:
62+
63+- `ec-probe`: a silent skip replaced by a **named** SKIP that states what was
64+ missing rather than returning quietly;
65+- `ec-aac`: two `env::var("HOME").unwrap()` → `unwrap_or_default()`;
66+- `ec-h264`: one hardcoded absolute manifest path → `CARGO_MANIFEST_DIR`-relative.
67+
68+> **Stale line numbers — deliberately not amended.** The branch's commit
69+> message cites `file:line` locations that the **same commit's** rustfmt pass
70+> renumbered. The citations were accurate when written and are stale at this
71+> tip. Recorded here and in the merge message; the message text itself is
72+> left alone rather than "fixed", because editing it would desynchronise the
73+> record of what the lane actually did.
74+
75+### 4. `lane-av1dumpyuv` @ `60a7788a`
76+
77+Three non-test surfaces now carry the sample depth as data:
78+
79+- `crates/ec-av1/examples/dump_yuv.rs` — **derives** depth from the stream's
80+ own sequence header (spec 5.5.2 `color_config.bit_depth`) before a byte is
81+ written. Never taken from the file name, the output extension, or a
82+ convention. `--depth N` is accepted only as a claim, and a mismatch against
83+ the parsed header is a hard error naming both depths.
84+- `scripts/raw_to_y4m.py` — **asserts** depth as an explicit positional
85+ argument (`W H FPS out.y4m DEPTH`, DEPTH = bytes per sample) and validates
86+ the byte count is a whole number of frames at the claimed depth.
87+- `scripts/lr-sgr-pin-harness.c` — **takes** `bit_depth`/`highbd` as
88+ parameters and names the failure mode when a high-bit-depth capture is fed
89+ to the 8-bit arm.
90+
91+> **Disclosed limit, not a silent hole.** A 10-bit stream of N frames is
92+> *exactly* the same byte count as 2N 8-bit frames, so **length alone can
93+> never distinguish them** — no length test can. That is stated in the
94+> `raw_to_y4m.py` module docstring, and is why the depth is an explicit
95+> argument rather than something inferred from the byte count.
96+
97+## Gate count: 742 → 742 (net zero), cause accounted
98+
99+`cargo test -p ec-av1 --lib -- --list`:
100+
101+```
102+742 tests, 0 benchmarks
103+```
104+
105+Wave 2's baseline was the same measure: wave 2's own report line 155 reads
106+`25 passed; 0 failed; 0 ignored; 0 measured; 717 filtered out` = 742. After
107+wave 4 the same filter reads `26 passed; … 716 filtered out` = 742.
108+
109+**Net zero is arithmetic, not luck.** Wave 4 moved the lib test count in
110+three directions at once:
111+
112+| Change | Count | Why |
113+|--------|-------|-----|
114+| `a_128_superblock_clip_whose_drl_index_the_write_time_stack_cannot_carry_decodes_exact` **deleted** | −1 | `DRL_CLAMP_HITS` is provably unreachable (its coverage claim moved to `encode.rs:15689`, the pricer's own offer-set enumeration) |
115+| `every_chroma_unit_decode_block_rect_can_present_has_a_coefficient_table` **added** (branch 2) | +1 | new `refusal_inventory` enumeration + witness gate |
116+| 3 gates **un-ignored** | ±0 | `#[ignore]`d tests still appear in `--list`; un-ignoring changes runnability, not the roster |
117+
118+### The deletion and its replacement
119+
120+Deleted in `4eab9e40`/`83a0066e`. The gate asserted `drl_clamp_hits() > 0` on
121+a real 1280x768 sb128 clip; the counter is unreachable, so the gate was a
122+guaranteed red once run. Its coverage claim is now carried by the pricer's
123+offer-set enumeration at `crates/ec-av1/src/encode.rs:15689`, whose doc
124+comment names the deleted gate so the lineage is greppable. The four
125+1280x768 `force_sb128(true)` own-reconstruction gates the reviewer verified
126+remain in the tree (`src/encode.rs:18653`, `:18755`, `:18852`, `:18941`, and
127+siblings) and justify the deletion.
128+
129+`grep -rn a_128_superblock_clip_whose_drl_index crates/` now returns exactly
130+one hit — the `encode.rs:15691` doc comment naming it as replaced. No dangling
131+test reference.
132+
133+### The three un-ignored gates, run
134+
135+```
136+test stream::tests::a_real_aomenc_inter_sequence_with_an_intra_1to4_strip_decodes_pixel_exact ... ok
137+test stream::tests::a_real_aomenc_inter_sequence_with_an_intra_1to4_strip_decodes_pixel_exact_10bit ... ok
138+test stream::tests::a_real_aomenc_stream_with_a_superblock_level_horz_vert_partition_and_delta_q_decodes_pixel_exact ... ok
139+test result: ok. 3 passed; 0 failed; 0 ignored; 0 measured; 739 filtered out
140+```
141+
142+All three are green **un-ignored**, not vacuously skipped — the un-ignore is
143+honest.
144+
145+## Verification outputs
146+
147+`cargo check -p ec-av1 --all-targets`, run after **each** merge, and re-run
148+with `src/lib.rs` + `examples/dump_yuv.rs` touched so the cached-green case
149+could not mask a stale binary:
150+
151+```
152+ Checking ec-av1 v0.1.0 (/home/user/Documents/Code/Rust/edith_codecs/crates/ec-av1)
153+ Finished `dev` profile [unoptimized + debuginfo] target(s) in 1.41s
154+```
155+
156+Clean — zero errors, zero warnings.
157+
158+Branch 3 touches four crates outside `ec-av1`, so the check was widened for
159+that merge only:
160+
161+```
162+cargo check -p ec-av1 -p ec-aac -p ec-h264 -p ec-matroska -p ec-probe --all-targets
163+ Finished `dev` profile [unoptimized + debuginfo] target(s) in 1.16s
164+```
165+
166+`cargo test -p ec-av1 --lib -- gate_coverage refusal_inventory`:
167+
168+```
169+test result: ok. 26 passed; 0 failed; 0 ignored; 0 measured; 716 filtered out; finished in 0.86s
170+```
171+
172+Green. The +1 against wave 2's 25 is branch 2's new gate.
173+
174+`cargo test -p ec-av1 --lib -- --list | wc -l` → **744** lines, of which 742
175+are `: test` entries; the summary line itself prints `742 tests, 0 benchmarks`.
176+(744 = 742 test names + the `running 0 tests` and summary lines.)
177+
178+Smoke: `python3 scripts/raw_to_y4m.py` with no args prints the usage line
179+including the now-required `DEPTH` argument, and the module imports cleanly.
180+
181+## Notes
182+
183+- **NO PUSH.** The four merge commits are local on `main`.
184+- Wave 3 was **not** merged and `src/refusal_inventory.rs` was not edited
185+ beyond the one-line comment fix in merge 2.
186+- The pre-commit hook's whole-staged-tree `format-staged.py` produced **no**
187+ churn in any of the four merges: `git status --porcelain` was empty after
188+ each commit, and the recipehunt merge's tree is byte-identical to `1acf1818`.
189+ The accepted-churn escape hatch was not needed.
lanes/whtshape.report.mdadded+278 -0
@@ -0,0 +1,278 @@
1+# lane-whtshape — a non-4x4 unit on the LOSSLESS WHT path
2+
3+Branch `lane-whtshape`, base `a21f3680`, one commit
4+`lossless WHT: a non-4x4 unit is reconstructed as a 4x4 raster, not asserted away`.
5+
6+Files touched: `crates/ec-av1/src/decode.rs`, `crates/ec-av1/src/transform.rs`,
7+`crates/ec-av1/src/stream.rs` (the new gate, appended at the end of the
8+`mod tests` block), and the new pin
9+`crates/ec-av1/fixtures/ll444_sb64_1to4_lossless.obu`.
10+Untouched as instructed: the `read_plane` coefficient-reader region (~19600) and
11+`decode_rect_split`.
12+
13+---
14+
15+## r1 — The charter's premise, measured and partly REFUTED
16+
17+The ticket says a RELEASE build "silently runs a wrong-shape transform — silent
18+wrongness, not a panic". **That is wrong, and the measurement matters: RELEASE
19+panics.**
20+
21+`TxParams::run`'s lossless arm was
22+
23+```rust
24+LOSSLESS_WHT_UNITS.fetch_add(1, …);
25+debug_assert_eq!((self.w, self.h), (4, 4));
26+debug_assert_eq!(self.tx_type, TxType::DctDct);
27+crate::transform::dequant_and_inverse_wht4x4(grid, …) // always 16 values
28+```
29+
30+`dequant_and_inverse_wht4x4` dequantizes with `w = h = 4` and returns 16
31+samples. `TxParams::run` then re-lays them at `stride * h`, copying
32+`w` per row for `h` rows — so a `w * h > 16` unit indexes past the 16-long
33+buffer.
34+
35+| profile | behaviour on the witness | where |
36+| --- | --- | --- |
37+| DEBUG | `assertion left == right failed / left: (8, 4) / right: (4, 4)` | `decode.rs:2787` |
38+| RELEASE | `panicked … range end index 8 out of range for slice of length 0` | `decode.rs:4034` (the strided copy in `push_mc_rect_tx`) |
39+
40+So: no silent wrong pixels, but a *worse* bug than silence — the only thing
41+naming the invariant was compiled out of the profile that ships, and release's
42+failure message named neither lossless nor the transform. **No reachable
43+non-4x4 lossless shape is silent**: every such shape has `w * h > 16`, so the
44+strided copy always overruns. (An `8 x 2`-shaped unit would have been silent,
45+but AV1's minimum transform side is 4, so it is not constructible.)
46+
47+### Reproduction
48+
49+Neither witness named in the ticket exists as a pin; both had to be encoded.
50+Probe over all 48 pinned fixtures in a DEBUG build: **zero** trip the assert.
51+Two independent encodes, both 4:4:4 10-bit `--lossless=1 --profile=1 --i444`:
52+
53+```text
54+ffmpeg -f lavfi -i testsrc2=size=<N>x<N>:rate=25:duration=1 -pix_fmt yuv444p10le -f rawvideo src.yuv
55+aomenc --codec=av1 -w N -h N --i444 --bit-depth=10 --input-bit-depth=10 --passes=1
56+ --end-usage=q --cpu-used=0 --lag-in-frames=0 --kf-max-dist=1 --limit=2
57+ --threads=1 --enable-rect-partitions=1 --enable-1to4-partitions=1
58+ --min-partition-size=4 --max-partition-size=64 --sb-size=64
59+ --tune-content=screen --enable-intrabc=1 --enable-palette=1
60+ --cq-level=60 --enable-tx-size-search=0 --lossless=1 --profile=1 --obu -o out.obu src.yuv
61+```
62+
63+| witness | size | sha256 (16) | DEBUG | RELEASE (pre-fix) |
64+| --- | --- | --- | --- | --- |
65+| 256x256 | 51107 B | `fdb6467987095b99` | assert `(8, 4)` | `range end index 8 … length 0` |
66+| 640x480 | 186912 B | `5e647e3afe60b5f6` | assert `(8, 4)` | `range end index 8 … length 0` |
67+
68+The ticket's `left: (4, 8)` did not reproduce; `left: (8, 4)` did, on both
69+witnesses. Same defect, transposed unit. 4:2:0 cannot produce the shape at all
70+(its smallest lossless chroma plane block is already 4x4) — which is why the
71+gate asserts a 4:4:4 10-bit header.
72+
73+### Localisation
74+
75+A temporary `#[track_caller]` rung on `TxParams::run` and on
76+`read_inter_plane_rect` (both removed before the commit) put every non-4x4
77+lossless unit on one pair of call sites, in `decode_intrabc_rect`'s var-tx arm:
78+
79+```text
80+EC_RECTSITE plane=1 x=104 y=64 w=8 h=4 stride=8 at decode.rs:13392 (U)
81+EC_RECTSITE plane=2 x=104 y=64 w=8 h=4 stride=8 at decode.rs:13410 (V)
82+```
83+
84+A census of `decode_intrabc_rect` over every pinned fixture shows its chroma
85+plane block is `bw / 2` by `bh / 2` — a hardcoded 4:2:0 halving — so a 16x8
86+luma block at 4:4:4 got an 8x4 chroma plane block, and the walk read it as ONE
87+rect transform unit.
88+
89+---
90+
91+## r2 — What libaom actually does, and the decision
92+
93+Four independent places in the reference say a non-4x4 lossless transform unit
94+cannot exist:
95+
96+1. `av1/decoder/decodeframe.c:140` — `read_tx_mode(rb, coded_lossless)`:
97+ `if (coded_lossless) return ONLY_4X4;` before the `tx_mode` symbol is even
98+ considered.
99+2. `av1/decoder/decodeframe.c:1117` — `read_tx_size`:
100+ `if (xd->lossless[…]) return TX_4X4;` before any tree.
101+3. `av1/common/blockd.h:1447` — `get_vartx_max_txsize`:
102+ `if (xd->lossless[…]) return TX_4X4;` for EVERY plane, which is what sizes
103+ the units `decode_token_recon_block` actually reads.
104+4. `av1/common/idct.c:50` — the WHT dispatch. Of
105+ `highbd_inv_txfm_add_{4x4,4x8,8x4,16x4,…}_c`, **only** the 4x4 one carries a
106+ `lossless` branch (`if (lossless) { av1_highbd_iwht4x4_add(…); return; }`).
107+ Every other size falls straight through to the IDCT network.
108+
109+Point 4 is the decisive one for the "refuse or split?" question: libaom has no
110+non-4x4 lossless inverse transform to dispatch *to*, because points 1–3 make
111+the unit unreachable. So a non-4x4 lossless unit here is not a bitstream shape
112+to be decoded — it is this decoder's own unit geometry being wrong.
113+
114+**Decision: split into 4x4 WHT calls, counted.** Not a refusal: refusing would
115+turn a geometry bug into a decode failure with no way to see the pixels, and
116+`TxParams::run` has no `Result` channel to the point where a refusal could be
117+surfaced (it is called from the recorded-replay worker as well as inline).
118+Splitting makes the function *total*: no shape panics, no shape returns a
119+buffer its caller cannot index, release and debug agree, and the numbers are
120+the ones a correct per-4x4 caller would have written for the same footprint.
121+`LOSSLESS_WHT_SPLIT_UNITS` counts every 4x4 tile reconstructed this way, so a
122+caller that regresses is *named* rather than absorbed.
123+
124+The 4x4 fast path is the same single `dequant_and_inverse_wht4x4` call it
125+always was — `the_4x4_lossless_fast_path_is_unchanged` asserts byte-identity
126+with and without the shape dispatch.
127+
128+The `debug_assert_eq!(self.tx_type, TxType::DctDct)` went with it: the WHT
129+takes no `tx_type` (libaom's `av1_iwht4x4_add` does not either) and
130+`av1_get_tx_type` already answers `DCT_DCT` on every plane of a lossless block,
131+so it asserted an argument nothing reads — a debug-only panic on a value
132+release ignores, i.e. the same divergence class.
133+
134+---
135+
136+## r3 — The call site, and the defect this lane does NOT own
137+
138+`decode_intrabc_rect`, lossless arm:
139+
140+* chroma plane block = `bw >> ss_x` by `bh >> ss_y` at `(px >> ss_x,
141+ py >> ss_y)` — `av1_get_max_uv_txsize` is `ss_size_lookup[bsize]`, no halving
142+ of its own, so at 4:4:4 it is the block's own footprint;
143+* walked as a `(cw/4) * (ch/4)` PLANE-MAJOR raster of TX_4X4 units through the
144+ existing `read_inter_chroma_lossless` (the same helper the inter 8x8 and 128
145+ paths use), matching `decode_token_recon_block`'s
146+ `for plane { for blk_row { for blk_col } }`;
147+* each unit's own coefficient context replayed **over** the whole-block
148+ `record_split_luma_rect_mi` from the composed grid — class
149+ `override-slot-on-one-arm`, the same one `decode_rect_split`'s
150+ `ll_chroma_units` replay exists for. (Getting this order wrong first cost
151+ the exact prefix below: with the replay *before* the record, frame 0's first
152+ divergence sat at x=226 and 18376 luma samples were wrong; after it, x=224
153+ and 16022.)
154+
155+**Scoped to `lossless` on purpose.** The 4:2:0 halving is correct at 4:2:0.
156+Every pinned 4:4:4 stream that reaches `decode_intrabc_rect` does so LOSSY
157+(measured: the `lossless`-gated census over all 48 pins returns nothing), and
158+that 4:4:4 lossy footprint is a separate, already-named open cell —
159+`lanes/av1444rect.report.md`'s 4:4:4 intra-BC chroma. This lane does not move
160+it. A lossless-only split changes no green pin either way.
161+
162+### OPEN after this lane (measured, not guessed)
163+
164+Pinned witness, 256x256 4:4:4 10-bit, 2 frames, 196608 samples per frame:
165+
166+| frame | plane | differing | first differing sample |
167+| --- | --- | --- | --- |
168+| 0 (key) | Y | 16022 / 65536 | 32992 → (x=224, y=128) |
169+| 0 (key) | U | 16985 / 65536 | 32992 → (x=224, y=128) |
170+| 0 (key) | V | 17047 / 65536 | 32992 → (x=224, y=128) |
171+| 1 (inter) | Y | 1681 / 65536 | 55008 → (x=224, y=214) |
172+| 1 (inter) | U | 4071 / 65536 | 9378 → (x=162, y=36) |
173+| 1 (inter) | V | 4078 / 65536 | 9378 → (x=162, y=36) |
174+
175+On the key frame the fork is at the first column PAST the 16x8 lossless
176+intra-BC block at mi (32, 52) = px (208, 128) — that block's own 16x8 luma and
177+chroma are byte-exact, so the fork is at the block boundary, in the block that
178+follows it. That is an entropy desync in a *different* block's residual walk,
179+not the WHT shape: `LOSSLESS_WHT_SPLIT_UNITS` is 0 and no non-4x4 lossless unit
180+exists anywhere in the decode. Not chased here — it is a distinct defect in a
181+distinct path.
182+
183+The gate therefore asserts a measured per-frame, per-plane exact **prefix**, and
184+says so in its own doc comment. Asserting "our output is wrong by exactly N"
185+would encode the defect as expected behaviour; the prefix is the honest form
186+and it only ever grows.
187+
188+---
189+
190+## r4 — Gate and mutation proof
191+
192+`stream::tests::a_444_lossless_sb64_intrabc_rect_chroma_walks_4x4_units`
193+(pinned fixture, length + FNV asserted first, 4:4:4 10-bit header asserted):
194+
195+1. `intrabc_rect_lossless_chroma4_hits() > 0` — `INTRABC_RECT_LOSSLESS_CHROMA4_HITS`
196+ is EXCLUSIVE to the per-4x4 chroma walk (no other caller walks a rect
197+ intra-BC block's chroma), so `>= 1` cannot be satisfied by the old
198+ single-unit read.
199+2. `lossless_wht_split_units()` delta `== 0` — the shape-total entry is not
200+ quietly papering over a caller that is still wrong.
201+3. `lossless_wht_units()` delta `> 0` — not vacuous.
202+4. Both frames decode, and every decode-order frame's per-plane exact prefix
203+ matches the oracle's own `EC_AV1_FINAL_DUMP`.
204+
205+Plus four unit tests in `transform::lossless_tx_tests` covering the total entry
206+directly (raster equality against independently-composed per-unit 4x4 calls for
207+8x4 / 4x8 / 8x8 / 16x4 / 4x16 / 16x16, the 4x4 fast-path identity, the
208+empty-grid marker, and the partially-zero grid whose other tiles hit the empty
209+marker — that last one caught a real index panic in my first draft).
210+
211+### Mutation results (RELEASE profile, where the debug-only assert never ran)
212+
213+```
214+MUT1 decode_intrabc_rect reverted to the single rect unit + the 4:2:0 halving
215+ -> RED panicked at stream.rs:43682
216+ "the pinned witness was refused: unsupported: AV1 tile
217+ (a Golomb tail longer than this decoder reads)"
218+ test result: FAILED. 0 passed; 1 failed
219+
220+MUT2 dequant_and_inverse_wht forced back to the 4x4-only path
221+ -> stream gate: GREEN (survives -- see finding below)
222+ -> lossless_tx_tests: RED
223+ a_non_4x4_lossless_unit_is_the_raster_of_4x4_wht_units FAILED
224+ assertion left == right failed: 8x4: residual length left: 16 right: 32
225+ a_lossless_split_whose_other_tiles_are_all_zero_still_reconstructs FAILED
226+ assertion left == right failed: 8x4 residual length left: 16 right: 32
227+ test result: FAILED. 3 passed; 2 failed
228+
229+MUT3 hit!(INTRABC_RECT_LOSSLESS_CHROMA4_HITS) removed
230+ -> RED panicked at stream.rs:43687
231+ "no LOSSLESS rect intra-BC block walked its chroma as 4x4 units --
232+ the corrected route never ran, so this gate is measuring the old
233+ single rect unit (class gate-blind-to-feature)"
234+ test result: FAILED. 0 passed; 1 failed
235+
236+LIVE restored tree: stream gate ok, lossless_tx_tests 5 passed
237+```
238+
239+**MUT2 survives the stream gate, and that is reported rather than papered over.**
240+Assertion (2) is a *negative* assertion: after the call-site fix no non-4x4
241+lossless unit exists on this stream, so `split == 0` holds whether or not the
242+total entry works. The stream gate therefore cannot be the positive coverage of
243+`dequant_and_inverse_wht` for a non-4x4 shape — the four unit tests are, and
244+they do bite. Do not read the green stream gate as "the split is exercised
245+here".
246+
247+### Regression scope (release, named tests only — no full suite on this box)
248+
249+```
250+lossless 21 passed; 0 failed
251+444 16 passed; 0 failed
252+intrabc_rect 5 passed; 0 failed
253+rect16x4_chroma_reach 1 passed; 0 failed
254+a_444_lossless_sb64 1 passed; 0 failed (the new gate)
255+a_444_intrabc_rect4 1 passed; 0 failed
256+a_444_sb128_witness 1 passed; 0 failed
257+real_aomenc_mixed_lossless 1 passed; 0 failed
258+transform lossless_tx_tests 5 passed; 0 failed
259+```
260+
261+43 named gates across the lossless / 4:4:4 / intrabc-rect surface, green in
262+release. `cargo check -p ec-av1` is warning-free.
263+
264+## r5 — Follow-ups this lane deliberately did not take
265+
266+1. **`read_block_tx_size_rect`'s lossless arm returns before writing the TXFM
267+ bands.** libaom's `parse_decode_block` (`decodeframe.c:1163`) calls
268+ `set_txfm_ctxs(mbmi->tx_size, xd->width, xd->height, …)` on the lossless
269+ path too; our early return skips it. Unreachable on a fully lossless frame
270+ (no `txfm_partition` symbol is read when `tx_mode == ONLY_4X4`), so it is
271+ latent, not measured-wrong. Not fixed here — it is a neighbour-band concern,
272+ not the WHT shape.
273+2. **The 4:4:4 lossy chroma footprint of `decode_intrabc_rect`** (`bw / 2`,
274+ `px / 2`): wrong at 4:4:4, out of this lane's scope, already named in
275+ `lanes/av1444rect.report.md`.
276+3. **The r3 entropy fork**, localised to the block following the first lossless
277+ 16x8 intra-BC rect block on the key frame and to (162, 36) on the inter
278+ frame's chroma.
scripts/link-fixtures.shadded+74 -0
@@ -0,0 +1,74 @@
1+#!/usr/bin/env bash
2+# link-fixtures.sh — give this worktree the primary checkout's root `fixtures/`.
3+#
4+# The root `fixtures/` directory is listed in `.gitignore` (line 2) and is NOT
5+# committed, so `git worktree add` gives every lane worktree a tree WITHOUT it.
6+# Every test that reads a fixture through `<crate>/../../fixtures` then reports
7+# green having checked nothing: this is the "gate skips on its own failure"
8+# class, and it has already cost false verdicts (lane-av1skipfix 2026-09-29).
9+#
10+# This script makes a SYMLINK, never a copy: the fixtures are large and the
11+# lane worktrees exist to run tests, not to duplicate data.
12+#
13+# Usage: scripts/link-fixtures.sh [--check]
14+# (no args) create the symlink, or no-op if fixtures/ is already there
15+# --check report what would happen and exit non-zero if the fixtures are
16+# absent; for a batch preflight
17+#
18+# Idempotent and safe to run from any worktree of this repo.
19+
20+set -uo pipefail
21+
22+ROOT=$(cd -- "$(dirname -- "$0")/.." && pwd)
23+cd "$ROOT" || exit 2
24+
25+# `--git-common-dir` resolves to the PRIMARY checkout's .git from any linked
26+# worktree (a linked worktree's own .git is a FILE, not the common dir), so
27+# this works identically in the primary tree and in ~/.cache/wt/<lane>.
28+COMMON=$(git rev-parse --git-common-dir 2>/dev/null) || {
29+ echo "link-fixtures: not inside a git repository ($ROOT)" >&2
30+ exit 2
31+}
32+COMMON=$(cd -- "$COMMON" && pwd) || exit 2
33+PRIMARY=$(dirname -- "$COMMON")
34+SOURCE="$PRIMARY/fixtures"
35+
36+CHECK=0
37+[ "${1:-}" = "--check" ] && CHECK=1
38+
39+report() { # report <state> <detail>
40+ echo "link-fixtures: $1 — $2"
41+ echo " primary checkout: $PRIMARY"
42+ echo " this tree: $ROOT"
43+}
44+
45+if [ -e "$ROOT/fixtures" ] || [ -L "$ROOT/fixtures" ]; then
46+ if [ -L "$ROOT/fixtures" ] && [ -d "$ROOT/fixtures" ]; then
47+ report "already linked" "$ROOT/fixtures -> $(readlink -f "$ROOT/fixtures")"
48+ exit 0
49+ fi
50+ if [ -d "$ROOT/fixtures" ]; then
51+ report "already a real directory" "nothing to do ($ROOT/fixtures)"
52+ exit 0
53+ fi
54+ report "REFUSING" "$ROOT/fixtures exists but is neither a directory nor a live symlink; remove it by hand" >&2
55+ exit 2
56+fi
57+
58+if [ ! -d "$SOURCE" ]; then
59+ report "REFUSING" "the primary checkout has no fixtures/ at $SOURCE" >&2
60+ echo " It is gitignored, so it exists only where someone generated it:" >&2
61+ echo " scripts/gen-fixtures.sh (containers) and scripts/fetch-vectors.sh" >&2
62+ echo " (conformance vectors). Run one there, then re-run this script." >&2
63+ exit 2
64+fi
65+
66+if [ "$CHECK" = 1 ]; then
67+ report "would link" "$ROOT/fixtures -> $SOURCE"
68+ exit 1
69+fi
70+
71+ln -s "$SOURCE" "$ROOT/fixtures" || exit 2
72+report "linked" "$ROOT/fixtures -> $SOURCE"
73+echo " Fixtures are now reachable; run your crate's gates with"
74+echo " EC_REQUIRE_FIXTURES=1 so an absent fixture FAILS instead of skipping."
scripts/lr-sgr-pin-harness.cmodified+26 -2
@@ -30,10 +30,34 @@ int main(void) {
3030 // sized for that max, so replicate the chunking (target col=6 is in
3131 // the first 64-wide chunk).
3232 const int w = 64, h = 4;
33- uint8_t *buf = malloc(bw * bh);
33+ // The depth of `/tmp/lr_full.bin` is NOT in the file: the capture is a raw
34+ // plane dump written by an env-gated `std::fs::write` inside
35+ // `apply_sgrproj_stripe`, and whoever re-captures it from a 10/12-bit pin
36+ // gets 2 bytes per sample, i.e. a file TWICE this size whose first half
37+ // still looks like plausible plane data. Reading it at 1 byte per sample
38+ // would then print self-guided-restoration A/B taps for the wrong pixels
39+ // and nothing would fail -- so the size is the assertion: a 2x capture
40+ // must not pass as an 8-bit one.
41+ const size_t expect = (size_t)bw * bh;
42+ uint8_t *buf = malloc(expect);
3443 FILE *f = fopen("/tmp/lr_full.bin", "rb");
3544 if (!f) { perror("open"); return 1; }
36- if (fread(buf, 1, bw * bh, f) != (size_t)(bw * bh)) { fprintf(stderr, "short read\n"); return 1; }
45+ fseek(f, 0, SEEK_END);
46+ const long size = ftell(f);
47+ fseek(f, 0, SEEK_SET);
48+ if (size != (long)expect) {
49+ fprintf(stderr,
50+ "/tmp/lr_full.bin is %ld bytes, this harness reads it as %d-bit (%zu bytes: "
51+ "%dx%d at 1 byte per sample). %s\n",
52+ size, 8, expect, bw, bh,
53+ size == 2 * (long)expect
54+ ? "That is exactly a 2x-size high-bit-depth capture: re-capture it as 8-bit, "
55+ "or port the harness to the uint16 arm (bit_depth=10, highbd=1) before "
56+ "trusting a single printed tap."
57+ : "Recapture it, or fix bw/bh to the plane the capture came from.");
58+ return 1;
59+ }
60+ if (fread(buf, 1, expect, f) != expect) { fprintf(stderr, "short read\n"); return 1; }
3761 fclose(f);
3862
3963 const uint8_t *dgd8 = buf + 3 * bw + 3; // logical (0,0)
scripts/memguard-runner.shmodified+33 -1
@@ -16,6 +16,38 @@ if ! systemd-run --user --scope --quiet -p MemoryMax=10G true >/dev/null 2>&1; t
1616 exec "$@"
1717 fi
1818
19-exec systemd-run --user --scope --quiet --same-dir \
19+# Explicit unique unit name: systemd-run derives `run-p<pid>.scope` when no
20+# --unit is given, so a scope left loaded from an earlier run (or a reused
21+# pid) collides with "Unit run-pNNN.scope was already loaded or has a
22+# fragment file" -- the wrapped binary then never starts, which reads as a
23+# broken tree rather than a runner collision. Measured 2026-09-29: three
24+# lanes hit it in one batch and their workaround was invoking the test
25+# binary directly, losing the memory cap.
26+#
27+# The collision is detected by PROBING, never by the wrapped command's exit
28+# status: `systemd-run --scope` returns the command's own status, so
29+# retrying on non-zero would run every failing test twice.
30+unit="memguard-$$-$(date +%s%N)"
31+# The probe must NOT reuse `$unit`: a transient scope stays loaded after it
32+# exits, so probing and then exec'ing under the same --unit fails with
33+# "unit was already loaded or has a fragment file" -- measured directly on
34+# 2026-09-29 (the probe's own scope was the collision). Probe under "-probe".
35+if ! systemd-run --user --scope --quiet --unit="${unit}-probe" -p MemoryMax=10G true >/dev/null 2>&1; then
36+ # Clear a stale fragment for this name (and any leftover default-named
37+ # scope) and probe once more before giving up on the cap.
38+ rm -f "${XDG_RUNTIME_DIR:-/run/user/$(id -u)}/systemd/user/${unit}.scope" \
39+ "${HOME}/.config/systemd/user/${unit}.scope" \
40+ "${HOME}"/.config/systemd/user/run-p*.scope 2>/dev/null || true
41+ systemctl --user daemon-reload 2>/dev/null || true
42+ if ! systemd-run --user --scope --quiet --unit="${unit}-r" -p MemoryMax=10G true >/dev/null 2>&1; then
43+ echo "memguard-runner: scope unavailable even after clearing stale fragments, running without memory cap" >&2
44+ exec "$@"
45+ fi
46+ exec systemd-run --user --scope --quiet --same-dir --unit="${unit}-r" \
47+ -p MemoryMax=10G -p MemorySwapMax=2G \
48+ -- "$@"
49+fi
50+
51+exec systemd-run --user --scope --quiet --same-dir --unit="$unit" \
2052 -p MemoryMax=10G -p MemorySwapMax=2G \
2153 -- "$@"
scripts/raw_to_y4m.pymodified+52 -4
@@ -1,15 +1,63 @@
11 #!/usr/bin/env python3
22 """Wrap raw planar yuv420p frames into a minimal y4m (for vpxenc).
33
4- ffmpeg ... -f rawvideo - | raw_to_y4m.py W H FPS out.y4m
4+ ffmpeg ... -f rawvideo - | raw_to_y4m.py W H FPS out.y4m DEPTH
5+
6+DEPTH (8, 10 or 12) is REQUIRED and is the number of BYTES per sample in the
7+raw stream on stdin, not the stream's bit depth: ffmpeg's rawvideo muxer
8+never packs to the bit depth, it uses 1 byte for `yuv420p` and 2 bytes for
9+`yuv420p10le` / `yuv420p12le`. This script has no parser and no way to learn
10+it, so the depth is an ASSERTED argument: it is checked against the stdin
11+length, and a mismatch is a hard error naming the depth, the byte count it
12+implied, and the misframed y4m it would have produced. The old version
13+computed `w*h*3//2` unconditionally, so a 10-bit stream (2 bytes per sample)
14+was cut into frames at half length, the chroma planes of frame N+1 were read
15+as the tail of frame N, and the last partial frame was dropped silently --
16+a y4m that vpxenc accepts and encodes, with no error anywhere.
17+
18+The y4m header's `C` tag follows the same argument, so the wrapped stream
19+carries the depth it actually has.
20+
21+LIMIT, stated because it cannot be fixed here: raw planar video carries NO
22+depth of its own, so the length check below can only catch a stream whose
23+byte count is not a whole number of frames at the claimed depth. A 10-bit
24+stream of N frames is exactly 2N 8-bit frames, and no length test can tell
25+those apart -- that case is caught only by the caller asserting the right
26+DEPTH, which is why DEPTH is required and not defaulted.
527 """
28+
629 import sys
730
8-w, h, fps, out = sys.argv[1], sys.argv[2], sys.argv[3], sys.argv[4]
9-frame = int(w) * int(h) * 3 // 2
31+
32+if len(sys.argv) != 6:
33+ sys.exit(
34+ "usage: raw_to_y4m.py W H FPS out.y4m DEPTH "
35+ "(DEPTH = 8|10|12, the BYTES per sample on stdin)"
36+ )
37+w, h, fps, out, depth = sys.argv[1:6]
38+try:
39+ depth = int(depth)
40+except ValueError:
41+ sys.exit(f"raw_to_y4m.py: DEPTH {depth!r} is not a number (8, 10 or 12)")
42+if depth not in (8, 10, 12):
43+ sys.exit(
44+ f"raw_to_y4m.py: DEPTH {depth} is not 8, 10 or 12 -- the frame size below would be "
45+ "wrong and every frame after the first would be misframed"
46+ )
47+bpp = 1 if depth == 8 else 2
48+frame = int(w) * int(h) * 3 // 2 * bpp
1049 raw = sys.stdin.buffer.read()
50+if len(raw) % frame:
51+ sys.exit(
52+ f"raw_to_y4m.py: stdin is {len(raw)} bytes, not a whole number of "
53+ f"{int(w)}x{int(h)} 4:2:0 frames at {depth}-bit ({bpp} bytes per sample, "
54+ f"{frame} bytes each): {len(raw) % frame} trailing bytes. At the other depth a "
55+ f"frame would be {int(w) * int(h) * 3 // 2 * (3 - bpp)} bytes and each frame would "
56+ "carry half a frame of the next one's planes. Refusing to write a misframed y4m."
57+ )
58+ctag = {8: "C420jpeg", 10: "C420p10", 12: "C420p12"}[depth]
1159 with open(out, "wb") as f:
12- f.write(f"YUV4MPEG2 W{w} H{h} F{fps}:1 Ip A1:1 C420jpeg\n".encode())
60+ f.write(f"YUV4MPEG2 W{w} H{h} F{fps}:1 Ip A1:1 {ctag}\n".encode())
1361 for i in range(len(raw) // frame):
1462 f.write(b"FRAME\n")
1563 f.write(raw[i * frame : (i + 1) * frame])