forge
Explore
Log in

Don't you dare go Hollow

Merge branch 'lane-covbd2': gate_coverage derives default-on tools pinned off (tx-size-search, deblocking, diff-wtd, onesided, fwd-kf, directional-intra, interintra-wedge, multi-tile) per bit depth + superres-mode alias; 9 coverage tests

Browse files at this commit

e14804641b2535e50589272e6e4d698b871a34adAhmet Kaan GümüşParent: 2b7f47f32a6763
crates/ec-av1/src/gate_coverage.rsmodified+265 -8
@@ -80,6 +80,52 @@ const TOOL_UNIVERSE: &[&str] = &[
80 "enable-warped-motion",80 "enable-warped-motion",
81 ];81 ];
82 82
83+/// How a non-boolean aomenc knob reads as "the tool is on".
84+#[cfg(test)]
85+#[derive(Clone, Copy, PartialEq)]
86+enum On {
87+ /// Any non-zero value enables the tool (`--tile-columns=1`, `--loopfilter-control=1`).
88+ NonZero,
89+ /// The tool's search only runs at or below this speed (`--cpu-used`).
90+ AtMost(u32),
91+}
92+
93+/// Coding tools aomenc drives through a spelling [`TOOL_UNIVERSE`] does not
94+/// cover, listed with their aomenc default.
95+///
96+/// lane-covbd's derivation read `--enable-*` flags only, so a tool a gate pins
97+/// off through another spelling was invisible: all 49 gates that name it pass
98+/// `--enable-tx-size-search=0`, and the real-stream PANIC hiding behind that
99+/// pin was found by lane-ab16, not by this guard. `--loopfilter-control=0`,
100+/// `--tile-columns=0` and a `--cpu-used` high enough to switch a search off are
101+/// the same shape.
102+///
103+/// Each entry is `(tool, spellings, aomenc default, what counts as on)`. The
104+/// "defaulted means unknown" rule of [`NEVER_EXERCISED`] applies unchanged: a
105+/// default of `1` does not prove the encoder picked the tool for any stream, so
106+/// only a gate that spells an on-value at that bit depth retires an entry.
107+#[cfg(test)]
108+const DEFAULT_ON_TOOLS: &[(&str, &[&str], &str, On)] = &[
109+ ("enable-tx-size-search", &["enable-tx-size-search"], "1", On::NonZero),
110+ ("enable-directional-intra", &["enable-directional-intra"], "1", On::NonZero),
111+ ("enable-smooth-interintra", &["enable-smooth-interintra"], "1", On::NonZero),
112+ ("enable-interintra-wedge", &["enable-interintra-wedge"], "1", On::NonZero),
113+ ("enable-diff-wtd-comp", &["enable-diff-wtd-comp"], "1", On::NonZero),
114+ ("enable-onesided-comp", &["enable-onesided-comp"], "1", On::NonZero),
115+ ("enable-fwd-kf", &["enable-fwd-kf"], "0", On::NonZero),
116+ ("deblocking", &["loopfilter-control"], "1", On::NonZero),
117+ ("multi-tile", &["tile-columns", "tile-rows"], "0", On::NonZero),
118+ ("intrabc-search", &["cpu-used"], "0", On::AtMost(2)),
119+];
120+
121+/// Non-`--enable-*` spellings that drive a [`TOOL_UNIVERSE`] tool.
122+///
123+/// `--superres-mode=1` is how all three superres gates switch superres on;
124+/// without this map they read as an `enable-superres` hole while a real stream
125+/// exercises the tool (lane-covbd deferred exactly this).
126+#[cfg(test)]
127+const ALIASES: &[(&str, &str)] = &[("superres-mode", "enable-superres")];
128+
83 /// Coverage is per (tool x bit depth), not per tool.129 /// Coverage is per (tool x bit depth), not per tool.
84 ///130 ///
85 /// lane-hbdinter found two 10-bit-only defects (SGR box sums unscaled, Wiener131 /// lane-hbdinter found two 10-bit-only defects (SGR box sums unscaled, Wiener
@@ -133,10 +179,6 @@ const NEVER_EXERCISED_8BIT: &[(&str, &str)] = &[
133 "enable-ref-frame-mvs",179 "enable-ref-frame-mvs",
134 "off in 27 gates, on in none: temporal MV projection is unimplemented",180 "off in 27 gates, on in none: temporal MV projection is unimplemented",
135 ),181 ),
136- (
137- "enable-superres",
138- "never spelled: the three superres gates drive `--superres-mode=1` instead, so the tool IS exercised but not under this flag -- retire this entry only by renaming the check, not by assuming coverage",
139- ),
140 (182 (
141 "enable-tx64",183 "enable-tx64",
142 "never spelled; TX_64X64 appears only where aomenc's default picks it, which is unknown per stream",184 "never spelled; TX_64X64 appears only where aomenc's default picks it, which is unknown per stream",
@@ -185,16 +227,81 @@ const NEVER_EXERCISED_10BIT: &[(&str, &str)] = &[
185 "enable-ref-frame-mvs",227 "enable-ref-frame-mvs",
186 "hole at both depths, see the 8-bit list",228 "hole at both depths, see the 8-bit list",
187 ),229 ),
230+ ("enable-tx64", "hole at both depths, see the 8-bit list"),
231+];
232+
233+/// [`DEFAULT_ON_TOOLS`] entries no 8-bit gate spells on, with the reason.
234+///
235+/// Each entry is `(tool, why)`; the reason states whether the tool is pinned
236+/// OFF in every gate that names it (a hard hole -- no stream can carry it) or
237+/// merely defaulted (unknown, and unknown is not coverage).
238+#[cfg(test)]
239+const NEVER_ON_8BIT: &[(&str, &str)] = &[
240+ (
241+ "deblocking",
242+ "on in no 8-bit gate: 7 pin --loopfilter-control=0, the other 34 default (on) -- and defaulted is unknown, so no stream is proven to run the loop filter",
243+ ),
188 (244 (
189- "enable-superres",245+ "enable-diff-wtd-comp",
190- "the 10-bit superres gate drives `--superres-mode=1`, not this flag; see the 8-bit entry",246+ "on in no 8-bit gate: 6 pin =0, 35 default; difference-weighted compound masks are unproven",
247+ ),
248+ (
249+ "enable-directional-intra",
250+ "on in no 8-bit gate: pinned =0 in 32 of 41, defaulted in 9 -- the directional gates drive the modes through other flags, never this one",
251+ ),
252+ (
253+ "enable-fwd-kf",
254+ "on in no 8-bit gate: 11 pin =0, 30 default (aomenc's default is off), so forward keyframes are never coded",
255+ ),
256+ (
257+ "enable-onesided-comp",
258+ "on in no 8-bit gate: 17 pin =0, 24 default; one-sided compound prediction is unproven",
259+ ),
260+ (
261+ "enable-tx-size-search",
262+ "on in no 8-bit gate: pinned =0 in 34 of 41 -- the pin that hid a real-stream PANIC from lane-ab16 until TX_MODE_SELECT was landed by lane-txselect; its gates spell the tool through the recipe, not this flag",
263+ ),
264+];
265+
266+/// [`DEFAULT_ON_TOOLS`] entries no 10-bit gate spells on, with the reason.
267+#[cfg(test)]
268+const NEVER_ON_10BIT: &[(&str, &str)] = &[
269+ (
270+ "deblocking",
271+ "hole at both depths, see the 8-bit list (1 of the 15 10-bit gates pins =0, 14 default)",
272+ ),
273+ (
274+ "enable-diff-wtd-comp",
275+ "hole at both depths, see the 8-bit list (1 pinned off, 14 defaulted)",
276+ ),
277+ (
278+ "enable-fwd-kf",
279+ "hole at both depths, see the 8-bit list (3 pinned off, 12 defaulted)",
280+ ),
281+ (
282+ "enable-interintra-wedge",
283+ "on in no 10-bit gate: 5 pin =0, 10 default -- wedge interintra masks are exercised at 8 bits only, the shape that cost lane-hbdinter two 10-bit-only defects",
284+ ),
285+ (
286+ "enable-onesided-comp",
287+ "hole at both depths, see the 8-bit list (5 pinned off, 10 defaulted)",
288+ ),
289+ (
290+ "enable-tx-size-search",
291+ "hole at both depths, see the 8-bit list (11 of 15 pin =0)",
292+ ),
293+ (
294+ "multi-tile",
295+ "on in no 10-bit gate: all 15 leave --tile-columns/--tile-rows defaulted at 0, so every 10-bit stream is single-tile and no tile edge or per-tile CDF reset is checked at high bit depth",
191 ),296 ),
192- ("enable-tx64", "hole at both depths, see the 8-bit list"),
193 ];297 ];
194 298
195 #[cfg(test)]299 #[cfg(test)]
196 mod tests {300 mod tests {
197- use super::{NEVER_EXERCISED, NEVER_EXERCISED_8BIT, NEVER_EXERCISED_10BIT, TOOL_UNIVERSE};301+ use super::{
302+ ALIASES, DEFAULT_ON_TOOLS, NEVER_EXERCISED, NEVER_EXERCISED_8BIT, NEVER_EXERCISED_10BIT,
303+ NEVER_ON_10BIT, NEVER_ON_8BIT, On, TOOL_UNIVERSE,
304+ };
198 use std::collections::{BTreeMap, BTreeSet};305 use std::collections::{BTreeMap, BTreeSet};
199 306
200 /// Bodies of the real-aomenc gates: a `fn` body carrying the shared307 /// Bodies of the real-aomenc gates: a `fn` body carrying the shared
@@ -241,6 +348,43 @@ mod tests {
241 here348 here
242 }349 }
243 350
351+ /// Every `--flag=value` spelled inside one gate body, values kept whole
352+ /// (`--cpu-used=4`, `--tile-columns=2`), not just their first character.
353+ fn settings_in(gate: &str) -> BTreeMap<String, String> {
354+ let mut here = BTreeMap::new();
355+ for (i, _) in gate.match_indices("\"--") {
356+ let rest = &gate[i + 3..];
357+ let Some(end) = rest.find('"') else { continue };
358+ let Some((flag, value)) = rest[..end].split_once('=') else {
359+ continue;
360+ };
361+ here.insert(flag.to_owned(), value.to_owned());
362+ }
363+ here
364+ }
365+
366+ /// Whether a gate body spells one [`DEFAULT_ON_TOOLS`] entry on / off.
367+ fn default_on_state(gate: &str, spellings: &[&str], on: On) -> Option<bool> {
368+ let here = settings_in(gate);
369+ let mut state = None;
370+ for spelling in spellings {
371+ let Some(value) = here.get(*spelling) else {
372+ continue;
373+ };
374+ let Ok(value) = value.parse::<u32>() else {
375+ continue;
376+ };
377+ let is_on = match on {
378+ On::NonZero => value != 0,
379+ On::AtMost(limit) => value <= limit,
380+ };
381+ // Any spelling that says "on" wins: --tile-columns=0 --tile-rows=1
382+ // is a multi-tile stream.
383+ state = Some(state.unwrap_or(false) || is_on);
384+ }
385+ state
386+ }
387+
244 /// `--enable-*` settings per real-aomenc gate, derived from the gate388 /// `--enable-*` settings per real-aomenc gate, derived from the gate
245 /// source: `flag -> (turned off in N gates, turned on in N, defaulted in N)`.389 /// source: `flag -> (turned off in N gates, turned on in N, defaulted in N)`.
246 fn tool_settings() -> (usize, BTreeMap<String, (usize, usize, usize)>) {390 fn tool_settings() -> (usize, BTreeMap<String, (usize, usize, usize)>) {
@@ -347,6 +491,13 @@ mod tests {
347 on.insert(flag);491 on.insert(flag);
348 }492 }
349 }493 }
494+ // A tool driven by its own spelling counts as exercised.
495+ let here = settings_in(gate);
496+ for (alias, tool) in ALIASES {
497+ if here.get(*alias).is_some_and(|v| v != "0") {
498+ on.insert((*tool).to_owned());
499+ }
500+ }
350 }501 }
351 on502 on
352 }503 }
@@ -415,4 +566,110 @@ mod tests {
415 }566 }
416 }567 }
417 }568 }
569+
570+ /// [`DEFAULT_ON_TOOLS`] per depth: `tool -> (off in N gates, on in N, defaulted in N)`.
571+ fn default_on_settings(ten_bit: bool) -> (usize, BTreeMap<&'static str, (usize, usize, usize)>) {
572+ let gates: Vec<&str> = gate_bodies()
573+ .into_iter()
574+ .filter(|b| is_ten_bit(b) == ten_bit)
575+ .collect();
576+ let mut per_tool = BTreeMap::new();
577+ for &(tool, spellings, _, on) in DEFAULT_ON_TOOLS {
578+ let states: Vec<Option<bool>> = gates
579+ .iter()
580+ .map(|g| default_on_state(g, spellings, on))
581+ .collect();
582+ let turned_on = states.iter().filter(|s| **s == Some(true)).count();
583+ let turned_off = states.iter().filter(|s| **s == Some(false)).count();
584+ per_tool.insert(
585+ tool,
586+ (turned_off, turned_on, gates.len() - turned_off - turned_on),
587+ );
588+ }
589+ (gates.len(), per_tool)
590+ }
591+
592+ /// The [`DEFAULT_ON_TOOLS`] no gate of this depth positively enables.
593+ fn never_on_at(ten_bit: bool) -> BTreeSet<&'static str> {
594+ default_on_settings(ten_bit)
595+ .1
596+ .into_iter()
597+ .filter(|&(_, (_, on, _))| on == 0)
598+ .map(|(tool, _)| tool)
599+ .collect()
600+ }
601+
602+ fn check_default_on(ten_bit: bool, listed: &[(&str, &str)]) {
603+ let derived = never_on_at(ten_bit);
604+ let listed: BTreeSet<&str> = listed.iter().map(|&(tool, _)| tool).collect();
605+ let depth = if ten_bit { "10-bit" } else { "8-bit" };
606+ let unlisted: Vec<&&str> = derived.difference(&listed).collect();
607+ assert!(
608+ unlisted.is_empty(),
609+ "no {depth} gate spells an on-value for {unlisted:?}, so no real {depth} stream is \
610+ proven to carry them -- switch the tool on in a {depth} gate that asserts it fired, \
611+ or list it with a reason"
612+ );
613+ let stale: Vec<&&str> = listed.difference(&derived).collect();
614+ assert!(
615+ stale.is_empty(),
616+ "the {depth} default-on list still names {stale:?}, but a {depth} gate now switches \
617+ them on -- delete those entries, the coverage hole is closed"
618+ );
619+ }
620+
621+ #[test]
622+ fn never_on_8bit_matches_the_gate_recipes() {
623+ check_default_on(false, NEVER_ON_8BIT);
624+ }
625+
626+ #[test]
627+ fn never_on_10bit_matches_the_gate_recipes() {
628+ check_default_on(true, NEVER_ON_10BIT);
629+ }
630+
631+ /// A tool must not be pinned twice: [`TOOL_UNIVERSE`] already derives the
632+ /// `--enable-*` spellings under the `=1` rule.
633+ #[test]
634+ fn default_on_tools_do_not_duplicate_the_universe() {
635+ for &(tool, spellings, _, _) in DEFAULT_ON_TOOLS {
636+ assert!(
637+ !TOOL_UNIVERSE.contains(&tool),
638+ "{tool} is already covered by TOOL_UNIVERSE"
639+ );
640+ assert!(!spellings.is_empty(), "{tool} has no aomenc spelling");
641+ }
642+ for (alias, tool) in ALIASES {
643+ assert!(
644+ TOOL_UNIVERSE.contains(tool),
645+ "alias --{alias} names {tool}, which is not a TOOL_UNIVERSE tool"
646+ );
647+ }
648+ }
649+
650+ /// `cargo test -p ec-av1 --lib gate_coverage -- --nocapture` prints the
651+ /// default-on holes with their off/defaulted split.
652+ #[test]
653+ fn print_never_on_per_bit_depth() {
654+ for (label, ten_bit) in [("8BIT", false), ("10BIT", true)] {
655+ let (gate_count, per_tool) = default_on_settings(ten_bit);
656+ let holes = never_on_at(ten_bit);
657+ println!(
658+ "NEVER_ON_{label} ({} of {}, over {gate_count} {label} gates):",
659+ holes.len(),
660+ DEFAULT_ON_TOOLS.len()
661+ );
662+ for tool in &holes {
663+ let (off, _, defaulted) = per_tool[tool];
664+ let spellings = DEFAULT_ON_TOOLS
665+ .iter()
666+ .find(|e| e.0 == *tool)
667+ .map(|e| e.1.join(","))
668+ .unwrap_or_default();
669+ println!(
670+ " {tool} (--{spellings}): off in {off}, defaulted in {defaulted}, on in 0"
671+ );
672+ }
673+ }
674+ }
418 }675 }
lanes/covbd2-r1.report.mdadded+93 -0
@@ -0,0 +1,93 @@
1+# lane-covbd2 r1 — default-on tools and non-`--enable-*` spellings
2+
3+Branch `lane-covbd2`, rebased onto main 593de22 (charter said 06d856d; `git rebase main`
4+per COMMON, clean, gate counts moved 45/4 -> 56/15).
5+
6+## What changed (crates/ec-av1/src/gate_coverage.rs only; no gate recipe touched)
7+- `On` enum + `DEFAULT_ON_TOOLS` (10 entries, each `(tool, aomenc spelling(s), aomenc default,
8+ what counts as on)`) — the third instance of class *tool-disabled-in-every-gate*: lane-covbd's
9+ derivation read `"--enable-` only, so `--enable-tx-size-search=0` (34/41 8-bit gates),
10+ `--loopfilter-control=0`, `--tile-columns/--tile-rows` and `--cpu-used` were invisible.
11+- `ALIASES` (`superres-mode` -> `enable-superres`), applied in `enabled_at()`: the three
12+ superres gates drive `--superres-mode=1`, so `enable-superres` is now *covered* and its two
13+ entries were deleted from `NEVER_EXERCISED_8BIT`/`_10BIT` (the covbd deferral, closed).
14+- `NEVER_ON_8BIT` (6) / `NEVER_ON_10BIT` (7), each `(tool, why)`, with the off/defaulted split in
15+ the reason. Same "defaulted means unknown" rule: a default of `1` is not proof the encoder
16+ picked the tool, only an explicit on-value at that depth retires an entry.
17+- `settings_in()` (whole `--flag=value` pairs, values kept whole — `--cpu-used=4`,
18+ `--tile-columns=2`), `default_on_state()`, `default_on_settings()`, `never_on_at()`.
19+- Tests: `never_on_8bit_matches_the_gate_recipes`, `never_on_10bit_matches_the_gate_recipes`
20+ (both directions: unlisted hole fails, closed hole fails until deleted),
21+ `default_on_tools_do_not_duplicate_the_universe` (no double-pinning, every alias names a real
22+ `TOOL_UNIVERSE` tool), `print_never_on_per_bit_depth` (helper).
23+
24+## Printed lists (verbatim)
25+```
26+gate_coverage: 56 real-aomenc gates, 15 of them 10-bit
27+NEVER_EXERCISED_8BIT (11 of 26):
28+ --enable-1to4-partitions
29+ --enable-angle-delta
30+ --enable-cfl-intra
31+ --enable-dist-wtd-comp
32+ --enable-dual-filter
33+ --enable-flip-idtx
34+ --enable-global-motion
35+ --enable-intrabc
36+ --enable-rect-tx
37+ --enable-ref-frame-mvs
38+ --enable-tx64
39+NEVER_EXERCISED_10BIT (9 of 26):
40+ --enable-1to4-partitions
41+ --enable-angle-delta
42+ --enable-cfl-intra
43+ --enable-dual-filter
44+ --enable-flip-idtx
45+ --enable-intrabc
46+ --enable-rect-tx
47+ --enable-ref-frame-mvs
48+ --enable-tx64
49+NEVER_ON_8BIT (6 of 10, over 41 8BIT gates):
50+ deblocking (--loopfilter-control): off in 7, defaulted in 34, on in 0
51+ enable-diff-wtd-comp (--enable-diff-wtd-comp): off in 6, defaulted in 35, on in 0
52+ enable-directional-intra (--enable-directional-intra): off in 32, defaulted in 9, on in 0
53+ enable-fwd-kf (--enable-fwd-kf): off in 11, defaulted in 30, on in 0
54+ enable-onesided-comp (--enable-onesided-comp): off in 17, defaulted in 24, on in 0
55+ enable-tx-size-search (--enable-tx-size-search): off in 34, defaulted in 7, on in 0
56+NEVER_ON_10BIT (7 of 10, over 15 10BIT gates):
57+ deblocking (--loopfilter-control): off in 1, defaulted in 14, on in 0
58+ enable-diff-wtd-comp (--enable-diff-wtd-comp): off in 1, defaulted in 14, on in 0
59+ enable-fwd-kf (--enable-fwd-kf): off in 3, defaulted in 12, on in 0
60+ enable-interintra-wedge (--enable-interintra-wedge): off in 5, defaulted in 10, on in 0
61+ enable-onesided-comp (--enable-onesided-comp): off in 5, defaulted in 10, on in 0
62+ enable-tx-size-search (--enable-tx-size-search): off in 11, defaulted in 4, on in 0
63+ multi-tile (--tile-columns,tile-rows): off in 0, defaulted in 15, on in 0
64+```
65+Two entries of `DEFAULT_ON_TOOLS` are NOT holes and so print nowhere:
66+`enable-smooth-interintra` and `intrabc-search` (`--cpu-used<=2`, on in 51 gates) are
67+positively exercised at both depths; `multi-tile` is exercised at 8 bits only
68+(`--tile-columns=1/2`, `--tile-rows=1/2`).
69+
70+## Findings worth a lane
71+- `enable-tx-size-search` pinned off in 34/41 8-bit and 11/15 10-bit gates, on in none — the pin
72+ that hid the real-stream PANIC lane-ab16 hit; lane-txselect landed TX_MODE_SELECT but no gate
73+ spells the flag on, so the guard now says so.
74+- `multi-tile` at 10 bits: every one of the 15 10-bit gates is single-tile, so no tile edge or
75+ per-tile CDF reset is checked at high bit depth (the `enable-restoration` shape that cost
76+ lane-hbdinter two 10-bit-only defects).
77+- `deblocking`: no gate at either depth spells `--loopfilter-control=1`; 7+1 pin it to 0.
78+
79+## Tests
80+- `cargo test -p ec-av1 --lib gate_coverage -- --nocapture` -> 9 passed, 0 failed (was 5).
81+- `cargo test -p ec-av1 --lib refusal_inventory` -> 3 passed, 0 failed.
82+- EVIDENCE: crates/ec-av1/src/gate_coverage.rs | cargo test -p ec-av1 --lib gate_coverage -- --nocapture (CARGO_TARGET_DIR=~/.cache/cargo-target-covbd2) | 9/9 pass, 56 gates parsed, 15 ten-bit, lists above
83+
84+## Refusals lifted
85+None — instrumentation only, no decode behaviour changed.
86+
87+## Residue
88+- deferred: closing any NEVER_ON hole — chartered "do NOT write gates". What unblocks it: a gate
89+ at that depth spelling the on-value and asserting the feature fired; the test then fails until
90+ the entry is deleted.
91+- accepted: `--cpu-used` is modelled as one tool (`intrabc-search`, on at <=2). If another
92+ cpu-used-gated search needs its own threshold, add a second entry with its own `On::AtMost`.
93+- accepted: no repo-wide `cargo fmt`; only gate_coverage.rs is in the commit.