| 1 | |
| 2 | |
| 3 | |
| 4 | |
| 5 | |
| 6 | |
| 7 | |
| 8 | |
| 9 | |
| 10 | |
| 11 | |
| 12 | |
| 13 | |
| 14 | |
| 15 | |
| 16 | |
| 17 | |
| 18 | |
| 19 | |
| 20 | |
| 21 | |
| 22 | |
| 23 | |
| 24 | |
| 25 | |
| 26 | |
| 27 | |
| 28 | |
| 29 | |
| 30 | |
| 31 | |
| 32 | |
| 33 | |
| 34 | #[cfg(test)] |
| 35 | const NEVER_EXERCISED: &[(&str, &str)] = &[ |
| 36 | |
| 37 | |
| 38 | |
| 39 | |
| 40 | |
| 41 | |
| 42 | ( |
| 43 | "enable-intrabc", |
| 44 | "the block vector is decoded and predicted from, but every real stream's intrabc block needs the unread inter var-tx transform tree", |
| 45 | ), |
| 46 | ]; |
| 47 | |
| 48 | |
| 49 | |
| 50 | |
| 51 | |
| 52 | |
| 53 | #[cfg(test)] |
| 54 | const TOOL_UNIVERSE: &[&str] = &[ |
| 55 | "enable-1to4-partitions", |
| 56 | "enable-ab-partitions", |
| 57 | "enable-angle-delta", |
| 58 | "enable-cdef", |
| 59 | "enable-cfl-intra", |
| 60 | "enable-dist-wtd-comp", |
| 61 | "enable-dual-filter", |
| 62 | "enable-filter-intra", |
| 63 | "enable-flip-idtx", |
| 64 | "enable-global-motion", |
| 65 | "enable-interintra-comp", |
| 66 | "enable-intra-edge-filter", |
| 67 | "enable-intrabc", |
| 68 | "enable-masked-comp", |
| 69 | "enable-obmc", |
| 70 | "enable-order-hint", |
| 71 | "enable-paeth-intra", |
| 72 | "enable-palette", |
| 73 | "enable-rect-partitions", |
| 74 | "enable-rect-tx", |
| 75 | "enable-ref-frame-mvs", |
| 76 | "enable-restoration", |
| 77 | "enable-smooth-intra", |
| 78 | "enable-superres", |
| 79 | "enable-tx64", |
| 80 | "enable-warped-motion", |
| 81 | ]; |
| 82 | |
| 83 | |
| 84 | |
| 85 | |
| 86 | |
| 87 | |
| 88 | |
| 89 | |
| 90 | |
| 91 | |
| 92 | |
| 93 | |
| 94 | #[cfg(test)] |
| 95 | const NEVER_EXERCISED_8BIT: &[(&str, &str)] = &[ |
| 96 | ( |
| 97 | "enable-1to4-partitions", |
| 98 | "off in 42 gates, on in none: PARTITION_HORZ_4/VERT_4 at 64x64 needs TX_64X16 luma plus 32x8 chroma scans (lane-part32 r5)", |
| 99 | ), |
| 100 | ( |
| 101 | "enable-angle-delta", |
| 102 | "off in 36 gates, on in none: the directional-intra gates pin it off to isolate the base modes", |
| 103 | ), |
| 104 | ( |
| 105 | "enable-cfl-intra", |
| 106 | "off in 41 gates, on in none: chroma-from-luma prediction is unimplemented", |
| 107 | ), |
| 108 | ( |
| 109 | "enable-dist-wtd-comp", |
| 110 | "off in 11 gates, on in none: distance-weighted compound is unimplemented", |
| 111 | ), |
| 112 | ( |
| 113 | "enable-dual-filter", |
| 114 | "never spelled by any gate, so defaulted = unknown; no stream is proven to carry per-direction interp filters", |
| 115 | ), |
| 116 | ( |
| 117 | "enable-flip-idtx", |
| 118 | "never spelled; the flip/identity transform types are unproven by a real stream", |
| 119 | ), |
| 120 | ( |
| 121 | "enable-global-motion", |
| 122 | "off in 5 gates, on in none at 8 bits; lane-gm owns the global-warp prediction that is still missing", |
| 123 | ), |
| 124 | ( |
| 125 | "enable-intrabc", |
| 126 | "the block vector is decoded and predicted from, but every real stream's intrabc block needs the unread inter var-tx transform tree", |
| 127 | ), |
| 128 | ( |
| 129 | "enable-rect-tx", |
| 130 | "never spelled; rect transforms reach the decoder only through partition shape, never through a gate that names the tool", |
| 131 | ), |
| 132 | ( |
| 133 | "enable-ref-frame-mvs", |
| 134 | "off in 27 gates, on in none: temporal MV projection is unimplemented", |
| 135 | ), |
| 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 | ( |
| 141 | "enable-tx64", |
| 142 | "never spelled; TX_64X64 appears only where aomenc's default picks it, which is unknown per stream", |
| 143 | ), |
| 144 | ]; |
| 145 | |
| 146 | #[cfg(test)] |
| 147 | const NEVER_EXERCISED_10BIT: &[(&str, &str)] = &[ |
| 148 | |
| 149 | |
| 150 | |
| 151 | |
| 152 | |
| 153 | |
| 154 | |
| 155 | ( |
| 156 | "enable-1to4-partitions", |
| 157 | "hole at both depths, see the 8-bit list", |
| 158 | ), |
| 159 | ( |
| 160 | "enable-angle-delta", |
| 161 | "hole at both depths, see the 8-bit list", |
| 162 | ), |
| 163 | ( |
| 164 | "enable-cfl-intra", |
| 165 | "hole at both depths, see the 8-bit list", |
| 166 | ), |
| 167 | ( |
| 168 | "enable-dist-wtd-comp", |
| 169 | "hole at both depths, see the 8-bit list", |
| 170 | ), |
| 171 | ( |
| 172 | "enable-dual-filter", |
| 173 | "hole at both depths, see the 8-bit list", |
| 174 | ), |
| 175 | ( |
| 176 | "enable-flip-idtx", |
| 177 | "hole at both depths, see the 8-bit list", |
| 178 | ), |
| 179 | ( |
| 180 | "enable-global-motion", |
| 181 | "hole at both depths, see the 8-bit list", |
| 182 | ), |
| 183 | ("enable-intrabc", "hole at both depths, see the 8-bit list"), |
| 184 | ("enable-rect-tx", "hole at both depths, see the 8-bit list"), |
| 185 | ( |
| 186 | "enable-ref-frame-mvs", |
| 187 | "hole at both depths, see the 8-bit list", |
| 188 | ), |
| 189 | ( |
| 190 | "enable-restoration", |
| 191 | "8-bit only -- THE instance this split was built for: every 10-bit gate passed `--enable-restoration=0`, so the SGR box sums and the Wiener clamp were never run at 10 bits and both were wrong (lane-hbdinter, 2026-09-01). lane-hbdgates r1 WROTE the 10-bit LR gate (`a_real_aomenc_10bit_restoration_stream_decodes_pixel_exact`) and it FAILS pixel-exact on a stream where the LR filters demonstrably ran (lr_hits=2, seed 42, frame 0, Y index 122: ours 351 vs ffmpeg 350), so it is `#[ignore]`d and the hole stays open until that defect is fixed", |
| 192 | ), |
| 193 | ( |
| 194 | "enable-superres", |
| 195 | "the 10-bit superres gate drives `--superres-mode=1`, not this flag; see the 8-bit entry", |
| 196 | ), |
| 197 | ("enable-tx64", "hole at both depths, see the 8-bit list"), |
| 198 | ]; |
| 199 | |
| 200 | #[cfg(test)] |
| 201 | mod tests { |
| 202 | use super::{NEVER_EXERCISED, NEVER_EXERCISED_8BIT, NEVER_EXERCISED_10BIT, TOOL_UNIVERSE}; |
| 203 | use std::collections::{BTreeMap, BTreeSet}; |
| 204 | |
| 205 | |
| 206 | |
| 207 | |
| 208 | fn gate_bodies() -> Vec<&'static str> { |
| 209 | let src = include_str!("stream.rs"); |
| 210 | let gates: Vec<&str> = src |
| 211 | .split("\n #[") |
| 212 | |
| 213 | |
| 214 | |
| 215 | .filter(|body| !body.starts_with("ignore")) |
| 216 | |
| 217 | |
| 218 | .filter(|body| { |
| 219 | body.contains("\"--passes=1\"") |
| 220 | || body.contains("ten_bit_tool_gate(") |
| 221 | || body.contains("encode_10bit_gradients") |
| 222 | }) |
| 223 | .collect(); |
| 224 | assert!( |
| 225 | gates.len() >= 20, |
| 226 | "expected the real-aomenc gates, found {}", |
| 227 | gates.len() |
| 228 | ); |
| 229 | gates |
| 230 | } |
| 231 | |
| 232 | |
| 233 | fn flags_in(gate: &str) -> BTreeMap<String, char> { |
| 234 | let mut here = BTreeMap::new(); |
| 235 | for (i, _) in gate.match_indices("\"--enable-") { |
| 236 | let rest = &gate[i + 3..]; |
| 237 | let Some(end) = rest.find('"') else { continue }; |
| 238 | let Some((flag, value)) = rest[..end].split_once('=') else { |
| 239 | continue; |
| 240 | }; |
| 241 | let Some(value) = value.chars().next() else { |
| 242 | continue; |
| 243 | }; |
| 244 | here.insert(flag.to_owned(), value); |
| 245 | } |
| 246 | here |
| 247 | } |
| 248 | |
| 249 | |
| 250 | |
| 251 | fn tool_settings() -> (usize, BTreeMap<String, (usize, usize, usize)>) { |
| 252 | let gates = gate_bodies(); |
| 253 | |
| 254 | let mut per_tool: BTreeMap<String, (usize, usize, usize)> = BTreeMap::new(); |
| 255 | let mut names: BTreeSet<String> = BTreeSet::new(); |
| 256 | let mut seen: Vec<BTreeMap<String, char>> = Vec::new(); |
| 257 | for gate in &gates { |
| 258 | let here = flags_in(gate); |
| 259 | names.extend(here.keys().cloned()); |
| 260 | seen.push(here); |
| 261 | } |
| 262 | for name in names { |
| 263 | let off = seen.iter().filter(|g| g.get(&name) == Some(&'0')).count(); |
| 264 | let on = seen.iter().filter(|g| g.get(&name) == Some(&'1')).count(); |
| 265 | per_tool.insert(name, (off, on, gates.len() - off - on)); |
| 266 | } |
| 267 | (gates.len(), per_tool) |
| 268 | } |
| 269 | |
| 270 | #[test] |
| 271 | fn every_gate_disabling_a_tool_is_a_listed_coverage_hole() { |
| 272 | let (gate_count, per_tool) = tool_settings(); |
| 273 | |
| 274 | |
| 275 | let derived: BTreeSet<&str> = per_tool |
| 276 | .iter() |
| 277 | .filter(|&(_, &(off, on, defaulted))| off == gate_count && on == 0 && defaulted == 0) |
| 278 | .map(|(name, _)| name.as_str()) |
| 279 | .collect(); |
| 280 | |
| 281 | |
| 282 | |
| 283 | |
| 284 | |
| 285 | let exercised: BTreeSet<&str> = per_tool |
| 286 | .iter() |
| 287 | .filter(|&(_, &(_, on, _))| on > 0) |
| 288 | .map(|(name, _)| name.as_str()) |
| 289 | .collect(); |
| 290 | let listed: BTreeSet<&str> = NEVER_EXERCISED.iter().map(|&(flag, _)| flag).collect(); |
| 291 | |
| 292 | let unlisted: Vec<&&str> = derived.difference(&listed).collect(); |
| 293 | assert!( |
| 294 | unlisted.is_empty(), |
| 295 | "these aomenc tools are switched off in all {gate_count} real-aomenc gates and on in \ |
| 296 | none, so no real stream exercises them, and they are not listed in NEVER_EXERCISED: \ |
| 297 | {unlisted:?} -- either enable the tool with `=1` in its own gate or add it to the \ |
| 298 | list with a reason" |
| 299 | ); |
| 300 | let stale: Vec<&&str> = listed.intersection(&exercised).collect(); |
| 301 | assert!( |
| 302 | stale.is_empty(), |
| 303 | "NEVER_EXERCISED lists {stale:?}, but a gate now passes `=1` for them -- delete \ |
| 304 | those entries, the coverage hole is closed" |
| 305 | ); |
| 306 | } |
| 307 | |
| 308 | |
| 309 | |
| 310 | |
| 311 | #[test] |
| 312 | fn tool_settings_reads_whole_flags() { |
| 313 | let (gate_count, per_tool) = tool_settings(); |
| 314 | assert!( |
| 315 | per_tool.contains_key("enable-cdef"), |
| 316 | "expected --enable-cdef among the gate flags" |
| 317 | ); |
| 318 | for (name, &(off, on, defaulted)) in &per_tool { |
| 319 | assert!( |
| 320 | !name.is_empty() && !name.contains(['"', '=']), |
| 321 | "malformed flag {name:?}" |
| 322 | ); |
| 323 | assert_eq!( |
| 324 | off + on + defaulted, |
| 325 | gate_count, |
| 326 | "{name} counts do not cover every gate" |
| 327 | ); |
| 328 | } |
| 329 | } |
| 330 | |
| 331 | |
| 332 | |
| 333 | |
| 334 | |
| 335 | fn is_ten_bit(body: &str) -> bool { |
| 336 | body.contains("encode_10bit_gradients") |
| 337 | || body.contains("ten_bit_tool_gate(") |
| 338 | || body.contains("--bit-depth=10") |
| 339 | || body.contains("--input-bit-depth=10") |
| 340 | || body.contains("yuv420p10le") |
| 341 | } |
| 342 | |
| 343 | |
| 344 | fn enabled_at(ten_bit: bool) -> BTreeSet<String> { |
| 345 | let mut on = BTreeSet::new(); |
| 346 | for gate in gate_bodies() { |
| 347 | if is_ten_bit(gate) != ten_bit { |
| 348 | continue; |
| 349 | } |
| 350 | for (flag, value) in flags_in(gate) { |
| 351 | if value == '1' { |
| 352 | on.insert(flag); |
| 353 | } |
| 354 | } |
| 355 | } |
| 356 | on |
| 357 | } |
| 358 | |
| 359 | |
| 360 | fn never_exercised_at(ten_bit: bool) -> BTreeSet<&'static str> { |
| 361 | let on = enabled_at(ten_bit); |
| 362 | TOOL_UNIVERSE |
| 363 | .iter() |
| 364 | .copied() |
| 365 | .filter(|t| !on.contains(*t)) |
| 366 | .collect() |
| 367 | } |
| 368 | |
| 369 | fn check_depth(ten_bit: bool, listed: &[(&str, &str)]) { |
| 370 | let derived = never_exercised_at(ten_bit); |
| 371 | let listed: BTreeSet<&str> = listed.iter().map(|&(flag, _)| flag).collect(); |
| 372 | let depth = if ten_bit { "10-bit" } else { "8-bit" }; |
| 373 | let unlisted: Vec<&&str> = derived.difference(&listed).collect(); |
| 374 | assert!( |
| 375 | unlisted.is_empty(), |
| 376 | "no {depth} gate passes `=1` for {unlisted:?}, so no real {depth} stream exercises \ |
| 377 | them -- enable the tool in a {depth} gate that asserts it fired, or list it" |
| 378 | ); |
| 379 | let stale: Vec<&&str> = listed.difference(&derived).collect(); |
| 380 | assert!( |
| 381 | stale.is_empty(), |
| 382 | "the {depth} list still names {stale:?}, but a {depth} gate now passes `=1` for them \ |
| 383 | -- delete those entries, the coverage hole is closed" |
| 384 | ); |
| 385 | } |
| 386 | |
| 387 | #[test] |
| 388 | fn never_exercised_8bit_matches_the_gate_recipes() { |
| 389 | check_depth(false, NEVER_EXERCISED_8BIT); |
| 390 | } |
| 391 | |
| 392 | #[test] |
| 393 | fn never_exercised_10bit_matches_the_gate_recipes() { |
| 394 | check_depth(true, NEVER_EXERCISED_10BIT); |
| 395 | } |
| 396 | |
| 397 | |
| 398 | |
| 399 | #[test] |
| 400 | fn print_never_exercised_per_bit_depth() { |
| 401 | let ten: Vec<&str> = gate_bodies() |
| 402 | .into_iter() |
| 403 | .filter(|b| is_ten_bit(b)) |
| 404 | .collect(); |
| 405 | let total = gate_bodies().len(); |
| 406 | println!( |
| 407 | "gate_coverage: {} real-aomenc gates, {} of them 10-bit", |
| 408 | total, |
| 409 | ten.len() |
| 410 | ); |
| 411 | for (label, ten_bit) in [("8BIT", false), ("10BIT", true)] { |
| 412 | let holes = never_exercised_at(ten_bit); |
| 413 | println!( |
| 414 | "NEVER_EXERCISED_{label} ({} of {}):", |
| 415 | holes.len(), |
| 416 | TOOL_UNIVERSE.len() |
| 417 | ); |
| 418 | for flag in &holes { |
| 419 | println!(" --{flag}"); |
| 420 | } |
| 421 | } |
| 422 | } |
| 423 | } |