diff --git a/crates/ec-av1/src/decode.rs b/crates/ec-av1/src/decode.rs index ae0925c9..c01faeb5 100644 --- a/crates/ec-av1/src/decode.rs +++ b/crates/ec-av1/src/decode.rs @@ -5112,6 +5112,32 @@ pub(crate) fn affine_gm_hits() -> usize { AFFINE_GM_HITS.with(|c| c.get()) } +// lane-av1distwtd: how many blocks took the DISTANCE-WEIGHTED compound +// combine rather than the simple average -- `compound_idx == 0` under +// `enable_jnt_comp`, whose weights come from +// [`crate::compound::dist_wtd_comp_weight_assign`] instead of the constant +// `(8, 8)` split. Counting the `idx == 0` arm (not merely the +// `compound_idx` symbol read) is what makes this a witness of the TOOL: a +// stream that carries `enable_jnt_comp = true` in its sequence header but +// codes every compound block with `compound_idx == 1` leaves this at 0 and +// decoded identically without the whole distance-weight path. +thread_local! { + static DIST_WTD_COMP_HITS: std::cell::Cell = + const { std::cell::Cell::new(0) }; +} + +/// Current value of [`DIST_WTD_COMP_HITS`]. +#[allow(dead_code)] // read only from the `#[cfg(test)]` gates +pub(crate) fn dist_wtd_comp_hits() -> usize { + DIST_WTD_COMP_HITS.with(|c| c.get()) +} + +/// Resets [`DIST_WTD_COMP_HITS`] to 0. +#[allow(dead_code)] // test-only +pub(crate) fn reset_dist_wtd_comp_hits() { + DIST_WTD_COMP_HITS.with(|c| c.set(0)); +} + // lane-av1gwarp12: how many 16x16+ blocks built their SINGLE-reference // prediction through `crate::warp::global_warp_params` with a FOUR-parameter // (`ROTZOOM`) model. Vanilla aomenc pins its global-motion search to ROTZOOM @@ -39128,6 +39154,10 @@ fn decode_inter_block( if idx == 1 { (8, 8, 1u8) } else { + // lane-av1distwtd: `idx == 0` is the + // distance-weighted arm -- the only branch whose + // weights are NOT the constant (8, 8) split. + hit!(DIST_WTD_COMP_HITS); let (fwd, bck) = crate::compound::dist_wtd_comp_weight_assign( order_hint_bits, order_hint, @@ -47095,6 +47125,10 @@ fn decode_inter_block8( if idx == 1 { (8, 8, 1u8) } else { + // lane-av1distwtd: the 8x8 leaf's own + // distance-weighted arm, same counter as the + // 16x16+ site above. + hit!(DIST_WTD_COMP_HITS); let (fwd, bck) = crate::compound::dist_wtd_comp_weight_assign( order_hint_bits, order_hint, diff --git a/crates/ec-av1/src/gate_coverage.rs b/crates/ec-av1/src/gate_coverage.rs index d1835d40..20a756d4 100644 --- a/crates/ec-av1/src/gate_coverage.rs +++ b/crates/ec-av1/src/gate_coverage.rs @@ -2,14 +2,25 @@ //! //! Every gate in [`crate::stream`] that runs a real `aomenc` picks its coding //! tools with `--enable-*=0/1` flags, and a flag left off the command line -//! takes aomenc's default (on, for the tools this decoder cares about). That -//! makes it possible -- and it happened -- for a coding tool to be switched -//! *off in every single gate*, so that no real stream in this repository ever -//! exercised it and a corner-cut in the decoder survived twenty gates -//! unnoticed: `reconstruct`'s `smooth_neighbor` was hardcoded `false`, wrong -//! whenever a directional block neighbours a smooth-mode one, and invisible -//! because all twenty gates passed `--enable-smooth-intra=0` -//! (lane-chroma r1, 2026-08-30). +//! takes aomenc's default. That default is `1` for essentially every tool in +//! [`TOOL_UNIVERSE`] on a non-realtime build -- `default_extra_cfg` in +//! `av1/av1_cx_iface.c` is all-ones across the seq-level tool fields, and this +//! oracle is built with `CONFIG_REALTIME_ONLY 0`. But a `1` default is NOT +//! the same as the tool reaching the stream, and the rest of this file's +//! "defaulted means unknown" rule rests on that gap: palette and intrabc are +//! gated on CONTENT (`encoder.c:2079` derives `allow_screen_content_tools` +//! from block counts, and `seq_force_screen_content_tools` is left at the +//! adaptive `SELECT_SCREEN_CONTENT_TOOLS`), and `speed_features.c` masks +//! several tools OFF again per `--cpu-used`. A `1` default proves the encoder +//! was ALLOWED the tool, never that any block used it. +//! +//! With that default in place it is possible -- and it happened -- for a +//! coding tool to be switched *off in every single gate*, so that no real +//! stream in this repository ever exercised it and a corner-cut in the +//! decoder survived twenty gates unnoticed: `reconstruct`'s +//! `smooth_neighbor` was hardcoded `false`, wrong whenever a directional +//! block neighbours a smooth-mode one, and invisible because all twenty +//! gates passed `--enable-smooth-intra=0` (lane-chroma r1, 2026-08-30). //! //! The test below re-derives that set from the gate source and pins it. A tool //! that is switched off in every gate and on in none is *provably never @@ -22,8 +33,10 @@ // keys on `--enable-=0/1`, and `--tile-columns=` has no such // shape -- a `--tile-columns=` presence check would also read `=0` (one tile) // as coverage, which is the opposite of what it would claim. It needs no -// entry either: 13 gates spell `--tile-columns`/`--tile-rows` with a nonzero -// log2 and assert the parsed `tile_info` really carries the grid, and +// entry either: measured 2026-09-29 (lane-av1distwtd r2), 19 of the 146 +// census-selected gate bodies spell `--tile-columns`/`--tile-rows` with a +// nonzero log2 -- 9 assert the parsed `tile_info` in the same body and 10 +// more delegate to a shared helper that asserts it -- and // `run_multi_tile_gate` covers a 2D grid with the coding tools ON at both // bit depths. @@ -107,16 +120,44 @@ enum On { /// cover, listed with their aomenc default. /// /// lane-covbd's derivation read `--enable-*` flags only, so a tool a gate pins -/// off through another spelling was invisible: all 49 gates that name it pass -/// `--enable-tx-size-search=0`, and the real-stream PANIC hiding behind that -/// pin was found by lane-ab16, not by this guard. `--loopfilter-control=0`, +/// off through another spelling was invisible: every gate that named +/// `--enable-tx-size-search` passed `--enable-tx-size-search=0` when this was +/// written, and the real-stream PANIC hiding behind that pin was found by +/// lane-ab16, not by this guard. `--loopfilter-control=0`, /// `--tile-columns=0` and a `--cpu-used` high enough to switch a search off are /// the same shape. /// +/// The "all 49" count is GONE as of 2026-09-29 (lane-av1distwtd r2) and is +/// deliberately not replaced by a number: the tool is no longer pinned off +/// tree-wide, so any count would be a snapshot that rots the same way. +/// Measured on this tree for the record: 113 of the 146 selected gate bodies +/// name it, 88 pass `=0`, 15 pass `=1`, and 9 build the value into a +/// `format!` variable the census cannot see -- so the historical claim no +/// longer holds in EITHER direction, and the `enable-tx-size-search` entry +/// below is a live question, not a settled one. +/// /// Each entry is `(tool, spellings, aomenc default, what counts as on)`. The /// "defaulted means unknown" rule of [`NEVER_EXERCISED`] applies unchanged: a /// default of `1` does not prove the encoder picked the tool for any stream, so /// only a gate that spells an on-value at that bit depth retires an entry. + // lane-av1distwtd r3: `enable-tx-size-search` is the one DEFAULT_ON_TOOLS + // entry the r2 audit could NOT settle, and the reason is a THIRD detector + // limit rather than a coverage fact. After the r3 call-resolving fix, 113 + // of the 230 selected gates name it: 88 pass `=0`, 15 pass `=1`, and 9 + // build the value into a `format!`/`String` variable that neither + // `flags_in` nor `settings_in` can see, because both scan for a literal + // `"--flag=value"` inside one segment. + // + // WHAT WOULD SETTLE IT, for whoever takes it next -- the method, not a + // guess: extend `flags_in`/`settings_in` to resolve a local binding, the + // same way `gate_bodies` now resolves calls. Concretely, when a segment + // contains `let = format!("--enable-tx-size-search={tx_search}")` + // (or a `String::from`/`to_string` of the same shape), record the + // TEMPLATE and bind the variable's value at each use site. Re-count, and + // only then decide whether the tool is a live hole. Until that exists the + // count above is a floor, not a measurement: 9 gates are unclassified in + // an unknown direction, and an unknown direction is exactly the failure + // mode this file exists to prevent. #[cfg(test)] const DEFAULT_ON_TOOLS: &[(&str, &[&str], &str, On)] = &[ ( @@ -168,9 +209,17 @@ const DEFAULT_ON_TOOLS: &[(&str, &[&str], &str, On)] = &[ /// Non-`--enable-*` spellings that drive a [`TOOL_UNIVERSE`] tool. /// -/// `--superres-mode=1` is how all three superres gates switch superres on; +/// `--superres-mode=1` is how every superres gate switches superres on; /// without this map they read as an `enable-superres` hole while a real stream -/// exercises the tool (lane-covbd deferred exactly this). +/// exercises the tool (lane-covbd deferred exactly this). The count was "all +/// three" until 2026-09-29 (lane-av1distwtd r2), which measured SIX gates +/// spelling a nonzero `--superres-mode` (5 among the 146 census-selected +/// bodies, plus `a_superres_census_over_six_real_streams_...`). No count is +/// given here for the same reason as `enable-tx-size-search` above: it rots. +/// Worth noting the alias is the ONLY positive evidence for superres, and +/// those gates do assert arrival -- `superres_hits` / `predict_scaled_hits` +/// are read in five of them -- so this one is a healthy alias, not a +/// spelling-only one. #[cfg(test)] const ALIASES: &[(&str, &str)] = &[("superres-mode", "enable-superres")]; @@ -190,18 +239,52 @@ const NEVER_EXERCISED_8BIT: &[(&str, &str)] = &[ // `enable-cfl-intra` LEFT both lists on 2026-09-02 (lane-reelckf r1): the // sb128 skipped-CfL / 1:4-chroma gate passes `--enable-cfl-intra=1` at 8 // AND 10 bits and pixel-compares both arms. - ( - "enable-dist-wtd-comp", - "off in 11 gates, on in none: distance-weighted compound is unimplemented", - ), - ( - "enable-dual-filter", - "never spelled by any gate, so defaulted = unknown; no stream is proven to carry per-direction interp filters", - ), - ( - "enable-flip-idtx", - "never spelled; the flip/identity transform types are unproven by a real stream", - ), + // `enable-dist-wtd-comp` LEFT this list on 2026-09-29 (lane-av1distwtd). + // The entry's stated reason was WRONG: the distance-weighted compound + // combine is not unimplemented -- `compound::dist_wtd_comp_weight_assign` + // (lane-av1comp) and `mc::combine_compound`'s weighted path have been in + // the tree for a long time. What was missing was a stream CARRYING the + // tool, and `a_distance_weighted_compound_stream_decodes_pixel_exact` + // (stream.rs) now supplies one: it spells `--enable-dist-wtd-comp=1` and + // asserts the PARSED sequence header carries `enable_jnt_comp == true` + // (and `false` from the same recipe with `=0`, so the bit is proven to + // move with the flag), that `dist_wtd_comp_hits() > 0` -- the + // `compound_idx == 0` arm, the only branch whose blend weights are not the + // constant (8, 8) -- and pixel-compares every frame against the oracle. + // The existing lane-cwarp compound-warp gates already SPELLED `=1` and + // the census still read this entry as open, so the hole was a missing + // witness, not a missing flag. + // `enable-dual-filter` LEFT this list on 2026-09-29 (lane-av1distwtd r3), + // paid by a DETECTOR fix rather than by a new gate. The r2 audit found + // this entry's reason false on both halves. It is spelled -- as `=0`, by + // `real_aomenc_1to4_streams_...` and + // `a_real_aomenc_inter_sequence_with_32x32_level_1to4_strips_...` -- so + // "never spelled" was wrong; and a stream IS proven to carry the tool, + // because `a_real_aomenc_dual_filter_obmc_8x8_inter_sequence_decodes_pixel_exact` + // spells `--enable-dual-filter=1` and hard-asserts + // `decode::dual_filter_diff_hits()` moved, the differing-direction arrival + // assert (`resolve_interp_filter` in decode.rs). That gate builds its + // stream through `inter_sb_none_gate`, so it spells none of the three + // tokens `gate_bodies()` used to filter on and was INVISIBLE to the + // census; r3 made `gate_bodies()` resolve calls as well as spellings, and + // `the_detector_sees_the_gates_the_spelling_filter_missed` pins that. + // Supporting measurement: with the flag left off the command line the + // parsed sequence header already carries `enable_dual_filter = true` + // (6855 B), while `--enable-dual-filter=0` parses false and encodes + // different bytes (6874 B) -- so the gates pinning it `=0` were removing + // the tool and the ones leaving it defaulted carry it. + // + // `enable-flip-idtx` LEFT this list the same day, also by detector fix. + // `a_real_aomenc_stream_with_a_1d_tx_class_on_a_rect_transform_decodes_pixel_exact` + // spells `=1` and hard-asserts `compared_class1 > 0` ("--enable-flip-idtx=1 + // never produced a V_DCT/H_DCT transform on a compared attempt"). Its + // recipe is parameterised on `ten_bit` and names BOTH fixture formats, so + // `is_ten_bit` filed the whole body 10-bit-ONLY and the 8-bit bucket + // never saw it -- the lane-defon/reelckf blind spot through a THIRD + // spelling, which r3 taught `covers_both_depths` to recognise as the + // pair-of-formats marker. Measured run of that gate: 12 pixel-exact + // decodes, 6 of them 8-bit, 219 rect coefficient TUs of which 10 carry a + // 1D tx class. // `enable-global-motion` LEFT this list on 2026-09-25 (lane-av1gwarp12 r2): // `a_real_affine_global_motion_stream_decodes_pixel_exact` loops // `for depth in [8u32, 10u32]` passing `--enable-global-motion=1` and @@ -210,6 +293,23 @@ const NEVER_EXERCISED_8BIT: &[(&str, &str)] = &[ // containing both the gate and this test until the ROTZOOM suite. // The 12-bit ROTZOOM gate rides the high-depth bucket via `encode_12bit(` // in `is_ten_bit`, so it plays no part in this retirement. + // `enable-rect-tx` -- reason RE-VERIFIED 2026-09-29 (lane-av1distwtd + // r2), both halves still TRUE, and the second half is now PROVEN rather + // than asserted. (1) "never spelled": measured across all 146 + // census-selected gate bodies, zero spell `--enable-rect-tx` at either + // depth -- the only `--enable-*` tool in [`TOOL_UNIVERSE`] with no + // spelling anywhere. (2) "reach the decoder only through partition + // shape": aom 3.13.3 has no sequence-header bit for it. `enable_rect_tx` + // is an `AV1E_SET_ENABLE_RECT_TX` encoder-search control + // (`av1_cx_iface.c:2125`, copied to `txfm_cfg->enable_rect_tx` at + // `av1_cx_iface.c:1483`) and is read ONLY inside `tx_search.c` + // (lines 2568/2662/2686/2710/2956); `bitstream.c` writes no such bit, and + // this crate's `SequenceHeader` (`ec-av1-syntax/src/sequence.rs`) has no + // such field. The decoder's own gate is `is_rect_tx_allowed`, derived + // from partition shape -- exactly what this reason says. A gate can + // therefore never prove this tool by naming the flag, only by proving a + // rect transform unit fired (`rect_partition_hits` / + // `rect_coeff_tu_hits`, which lane-rect1d's gate does assert). ( "enable-rect-tx", "never spelled; rect transforms reach the decoder only through partition shape, never through a gate that names the tool", @@ -225,10 +325,16 @@ const NEVER_EXERCISED_10BIT: &[(&str, &str)] = &[ // `enable-rect-partitions` and `enable-restoration` at 10 bits. All five // deleted together. - // Only 4 of the 45 real-aomenc gates encode at 10 bits, and they pin the - // pixel filters and the intra tool set off. Every entry the 8-bit list - // carries is a hole here too. lane-hbdgates r1 closed six of the seven - // 8-bit-only entries with real 10-bit gates (filter-intra, smooth-intra, + // The "Only 4 of the 45 real-aomenc gates encode at 10 bits" sentence that + // stood here is STALE (lane-av1distwtd r2, 2026-09-29), and understated + // the high-depth bucket by more than an order of magnitude. Measured + // against this tree with `gate_bodies()`' own filter: 146 selected gate + // bodies, of which 83 are classified 10-bit-or-higher by `is_ten_bit`. + // The historical point stands -- those gates pin the pixel filters and + // the intra tool set off far more often than not -- but the counts a + // reader would check them against no longer exist. + // Every entry the 8-bit list carries is a hole here too. lane-hbdgates r1 + // closed six of the seven 8-bit-only entries with real 10-bit gates // paeth-intra, intra-edge-filter, rect-partitions, ab-partitions); its // seventh, the 10-bit LR gate, was `#[ignore]`d on that branch and passes // un-ignored on main, which carries the fix. @@ -241,9 +347,33 @@ const NEVER_EXERCISED_10BIT: &[(&str, &str)] = &[ // gate passes `=1` for both. `enable-1to4-partitions` left it on 2026-09-02: // lane-tx64x16 r4's 32-level 1:4 gate has a 10-bit arm that asserts both // orientations and coded strips inside pixel-exact attempts. + // `enable-dual-filter` -- reason CORRECTED 2026-09-29 (lane-av1distwtd + // r3), and this entry STAYS while its 8-bit twin was retired. That is the + // honest outcome, not an oversight: after the r3 detector fix the 8-bit + // bucket sees the tool exercised and the 10-bit bucket still does not. + // The only `=1` witness is + // `a_real_aomenc_dual_filter_obmc_8x8_inter_sequence_decodes_pixel_exact`, + // and it calls `inter_sb_none_gate(NAME, false, ...)` -- `false` is the + // `ten_bit` parameter, so that gate builds an 8-bit stream only. Its + // sibling `a_real_aomenc_10bit_inter_sequence_with_a_whole_superblock_block_decodes_pixel_exact` + // passes `true`, and the 8x8-leaf pair likewise, but none of those spells + // `--enable-dual-filter=1`. So: exercised at 8 bits (arrival assert + // `dual_filter_diff_hits()` moved, `resolve_interp_filter` in decode.rs), + // NOT exercised at 10 bits. Retiring this entry needs a 10-bit arm of that + // gate -- pass `true` to `inter_sb_none_gate` and assert the differing- + // direction counter still moves there. + // + // The two numbers in the `enable-flip-idtx` retirement below were + // RE-MEASURED 2026-09-29 (lane-av1distwtd r2) by running the gate, and + // both still hold exactly: "pixel-compares six 10-bit decodes" (the run + // reports 12 pixel-exact decodes, 6 of them 10-bit) and "10 of its rect + // coefficient TUs carry a 1D tx class" (219 rect coefficient TUs on + // compared attempts, 10 of them 1D). The gate also hard-asserts + // `compared_class1 > 0`, so its "passes =1 at both depths" is backed by an + // arrival assert, not just a spelling. ( "enable-dual-filter", - "hole at both depths, see the 8-bit list", + "exercised at 8 bits only, by a_real_aomenc_dual_filter_obmc_8x8_inter_sequence_decodes_pixel_exact (=1, asserts dual_filter_diff_hits moved); no 10-bit gate spells =1 -- that gate calls inter_sb_none_gate with ten_bit=false. Retire by adding its 10-bit arm", ), // `enable-flip-idtx` LEFT this list on 2026-09-02 (lane-rect1d r1): // `a_real_aomenc_stream_with_a_1d_tx_class_on_a_rect_transform_decodes_pixel_exact` @@ -285,23 +415,119 @@ mod tests { }; use std::collections::{BTreeMap, BTreeSet}; - /// Bodies of the real-aomenc gates: a `fn` body carrying the shared - /// `--passes=1` every one of them passes. Split on the attribute that - /// opens a test. + /// Whether `body` contains a call to the `fn` named `name`. + /// + /// The name must not be the tail of a longer identifier, or + /// `inter_sb_none_gate` would "call" `sb_none_gate`. + fn calls_fn(body: &str, name: &str) -> bool { + let ident = |b: u8| b.is_ascii_alphanumeric() || b == b'_'; + let mut at = 0usize; + while let Some(rel) = body[at..].find(name) { + let start = at + rel; + let end = start + name.len(); + let starts_clean = start == 0 || !ident(body.as_bytes()[start - 1]); + if starts_clean && body[end..].starts_with('(') { + return true; + } + at = end; + } + false + } + + /// Every `fn` defined in `stream.rs`'s test module, as `(name, body)`. + /// + /// The census reasons about whole `#[`-segments (see [`gate_bodies`]) but + /// has to know which segment DEFINES or CALLS an encoder-driving `fn`, and + /// the only way to answer that is to name the units. + fn fn_units(src: &'static str) -> Vec<(&'static str, &'static str)> { + const OPEN: &str = "\n fn "; + let mut units = Vec::new(); + let mut at = 0usize; + while let Some(rel) = src[at..].find(OPEN) { + let head = at + rel + OPEN.len(); + let Some(paren) = src[head..].find('(') else { + break; + }; + let close = src[head..] + .find("\n }\n") + .map_or(src.len(), |e| head + e); + units.push((&src[head..head + paren], &src[head..close])); + at = close.max(head + paren + 1); + } + units + } + + /// Names of every `fn` in `stream.rs` that drives the real `aomenc`, + /// DIRECTLY (it mentions `aomenc_path()`) or by DELEGATING to one. + /// + /// lane-av1distwtd r3: the transitive closure is the whole point. A gate + /// that hands its recipe to a shared helper (`inter_sb_none_gate` and + /// friends) never spells `--passes=1` itself, so the old token filter + /// dropped it -- 165 of 311 segments, 6 of which spell `--enable-X=1`. + /// That is not a coverage fact, it is a segmentation fact, and it is what + /// kept `enable-dual-filter` on the never-exercised lists while a named + /// gate exercised the tool and hard-asserted the arrival. + fn encoder_fns(src: &'static str) -> BTreeSet<&'static str> { + let units = fn_units(src); + let mut enc: BTreeSet<&'static str> = units + .iter() + .filter(|(_, body)| body.contains("aomenc_path()")) + .map(|(name, _)| *name) + .collect(); + // Fixpoint: `inter_sb_none_gate` is an encoder fn because it names + // `aomenc_path()`; the `#[test]` that only CALLS it is a gate too. + loop { + let mut grew = false; + for (name, body) in &units { + if enc.contains(name) { + continue; + } + if enc.iter().any(|e| calls_fn(body, e)) { + enc.insert(name); + grew = true; + } + } + if !grew { + return enc; + } + } + } + + /// The token spellings the filter used before it resolved calls. Kept as a + /// floor: a gate is still recognised by these even if the call graph + /// misses it, so the fix can only ever ADD gates, never lose one. + fn legacy_gate_tokens(body: &str) -> bool { + body.contains("\"--passes=1\"") + || body.contains("ten_bit_tool_gate(") + || body.contains("encode_10bit_gradients") + } + + /// Bodies of the real-aomenc gates: a `fn` body that drives the real + /// `aomenc`, however it gets there. Split on the attribute that opens a + /// test. + /// + /// lane-av1distwtd r3: a segment qualifies if it spells one of the + /// [`legacy_gate_tokens`] OR names an encoder `fn` -- either by defining + /// one (it mentions `aomenc_path()`) or by calling one. Recognition by + /// CALL is what a helper-delegating gate needs: its flags live in the + /// helper it calls, and it is invisible to a spelling-only filter. fn gate_bodies() -> Vec<&'static str> { let src = include_str!("stream.rs"); + let enc = encoder_fns(src); let gates: Vec<&str> = src .split("\n #[") // lane-hbdgates r1: an `#[ignore]`d gate exercises nothing, so it // must not close a hole. Its body is the segment that opens with // the ignore attribute. .filter(|body| !body.starts_with("ignore")) - // lane-hbdgates r1: gates that build their stream through the - // shared 10-bit helpers spell `--passes=1` there, not inline. + // lane-av1distwtd r3: a segment qualifies by what it SPELLS + // (`legacy_gate_tokens`) or by what it CALLS. `calls_fn` is + // deliberately the weak half of an OR, so the fix can only add + // gates -- it can never stop recognising one the old filter did. .filter(|body| { - body.contains("\"--passes=1\"") - || body.contains("ten_bit_tool_gate(") - || body.contains("encode_10bit_gradients") + legacy_gate_tokens(body) + || body.contains("aomenc_path()") + || enc.iter().any(|e| calls_fn(body, e)) }) .collect(); assert!( @@ -466,10 +692,94 @@ mod tests { /// this marker that gate's own 8-bit-only flags read as 10-bit-only -- the /// lane-defon/reelckf blind spot with `depth` spelled instead of /// `bit_depth`. Three gates share the helper, at both depths. + /// lane-av1distwtd r3: the THIRD spelling of the same blind spot, still + /// live after lane-defon and lane-reelckf. A recipe parameterised on + /// `ten_bit` names BOTH fixture formats in one body -- `let pix_fmt = if + /// ten_bit { "yuv420p10le" } else { "yuv420p" };` -- so `is_ten_bit` saw + /// the 10-bit arm and filed the whole body 10-bit-ONLY, hiding its 8-bit + /// arm from the 8-bit bucket. The marker is the PAIR OF FORMATS, not the + /// parameter name: a body spelling both pixel formats builds streams at + /// both depths, whatever it calls the flag. The quotes matter -- a bare + /// `yuv420p` substring test also matches `yuv420p10le` and would fire on + /// every 10-bit gate, retiring entries on no evidence. + /// + /// This is what mis-filed `a_real_aomenc_stream_with_a_1d_tx_class_on_a_rect_transform_decodes_pixel_exact` + /// and kept `enable-flip-idtx` on the 8-bit list while that gate ran 6 + /// pixel-exact 8-bit decodes through it. fn covers_both_depths(body: &str) -> bool { body.contains("if bit_depth == 10") || body.contains("if depth == 10") || body.contains("for depth in [8usize, 10]") + || (body.contains("\"yuv420p\"") && body.contains("\"yuv420p10le\"")) + } + + /// lane-av1distwtd r3: the detector fix, pinned. A detector change with + /// no test can only be shown to find MORE, never to stop missing, so this + /// asserts the three gates the two blind spots actually hid are now seen + /// -- the two `enable-dual-filter` witnesses and the `enable-flip-idtx` + /// both-depths gate -- and that the fix is strictly ADDITIVE against the + /// old spelling-only filter. + #[test] + fn the_detector_sees_the_gates_the_spelling_filter_missed() { + let src = include_str!("stream.rs"); + let gates = gate_bodies(); + // The helper-delegation half: each of these builds its stream through + // `inter_sb_none_gate` and spells none of `legacy_gate_tokens`, so the + // old filter dropped both while each hard-asserts its tool arrived. + for name in [ + "a_real_aomenc_dual_filter_obmc_8x8_inter_sequence_decodes_pixel_exact", + "a_real_obmc_stream_reads_a_recorded_switchable_filter_for_every_neighbour", + ] { + let body = gates + .iter() + .find(|b| b.contains(name)) + .unwrap_or_else(|| panic!("{name}: not seen by gate_bodies()")); + assert_eq!( + flags_in(body).get("enable-dual-filter"), + Some(&'1'), + "{name}: seen, but its --enable-dual-filter=1 spelling is not visible to \ + flags_in, so recognising the gate would not retire the entry" + ); + } + // The both-depths half: this gate's recipe is parameterised on `ten_bit` + // and names both fixture formats, so `covers_both_depths` must credit + // it to the 8-bit bucket, not just the 10-bit one. + let flip = gates + .iter() + .find(|b| { + b.contains("a_real_aomenc_stream_with_a_1d_tx_class_on_a_rect_transform") + }) + .expect("the flip-idtx gate must be seen"); + assert!( + covers_both_depths(flip), + "the flip-idtx gate spells both fixture formats, so covers_both_depths must \ + credit it to the 8-bit bucket as well" + ); + assert!( + covers_depth(flip, false) && covers_depth(flip, true), + "the flip-idtx gate must cover BOTH depths" + ); + // Strictly additive: every segment the old spelling-only filter kept + // is still kept, so the fix cannot have cost the census a gate. + let legacy_only: Vec<&str> = src + .split("\n #[") + .filter(|b| !b.starts_with("ignore") && legacy_gate_tokens(b)) + .collect(); + assert!( + legacy_only.len() < gates.len(), + "the call-resolving filter found {} gates, the old spelling-only filter found \ + {} -- the fix is expected to ADD gates, never to drop one", + gates.len(), + legacy_only.len() + ); + for body in &legacy_only { + assert!( + gates.contains(body), + "a gate the spelling-only filter recognised is no longer recognised: \ + {:?}", + &body[..body.len().min(60)] + ); + } } /// Whether a gate body drives a stream at this depth. diff --git a/crates/ec-av1/src/stream.rs b/crates/ec-av1/src/stream.rs index c94a4845..47236661 100644 --- a/crates/ec-av1/src/stream.rs +++ b/crates/ec-av1/src/stream.rs @@ -45604,4 +45604,230 @@ pub(crate) mod tests { ); } } + + /// lane-av1distwtd: the gate that pays the `enable-dist-wtd-comp` entry in + /// `gate_coverage.rs`'s [`NEVER_EXERCISED_8BIT`], and corrects its stated + /// reason. The entry said "distance-weighted compound is unimplemented" -- + /// it is NOT: [`crate::compound::dist_wtd_comp_weight_assign`] (lane-av1comp) + /// and `mc::combine_compound`'s weighted path have been in the tree since. + /// What was missing is a stream that CARRIES the tool. Proved producible + /// against aom 3.13.3: the flag maps onto the sequence header's + /// `enable_jnt_comp` bit (`av1_cx_iface.c:1062` -> + /// `order_hint_info.enable_dist_wtd_comp` -> `bitstream.c:2681` writes it + /// under `enable_order_hint`), and this recipe's parsed header prints + /// `jnt_comp=true` with `=1` and `jnt_comp=false` with `=0` -- the parsed + /// value is asserted, never the flag spelling, per the class + /// `knob-never-reached-the-tool` trap that mislabelled a cell once already. + /// + /// Three hard asserts, all load-bearing: + /// 1. the PARSED sequence header carries `enable_jnt_comp == true` (the + /// off-arm asserts `false` from the same recipe, so the bit is proven to + /// MOVE with the flag rather than to be set by something else); + /// 2. `dist_wtd_comp_hits() > 0` -- the `compound_idx == 0` arm, the only + /// branch whose blend weights are not the constant (8, 8). A stream + /// carrying the header bit while coding every compound block with + /// `compound_idx == 1` leaves this at 0 and decodes byte-identically + /// without the whole distance-weight path, so the counter -- not the + /// header bit -- is what makes this a witness of the TOOL; + /// 3. every frame pixel-compared against the oracle through + /// [`decode_all_frames_vs_oracle`], which length-asserts each + /// decode-order frame before zipping. + /// + /// `--min-partition-size=32` is what makes the arm fire: at 16 the encoder + /// emits 8x8 inter leaves this decoder refuses BY NAME, so a smaller + /// min-partition refuses before the `compound_idx` read ever runs (measured: + /// the `min=16` arm of the same recipe refuses with "an inter partition + /// below 16x16" and dumps zero `compound_idx` lines). `--cq-level=30` is + /// likewise load-bearing: at cq 45/55 the same arm encodes a single-ref + /// stream (zero `compound_idx` reads) and the counter assert would be + /// vacuous. + #[test] + fn a_distance_weighted_compound_stream_decodes_pixel_exact() { + const NAME: &str = "distwtd-comp"; + let _gate_lock = lock_gate_counters(); + if !have_aomenc() { + return; + } + assert!(have_ffmpeg(), "{NAME}: ffmpeg required"); + assert!( + aomdec_path().is_file(), + "{NAME}: aomenc resolved to {} but no aomdec sits beside it -- a \ + pixel-exactness gate that compares nothing is worse than no gate", + aomenc_path().display() + ); + let (width, height, frame_count) = (64usize, 64usize, 24usize); + // mandelbrot + a slow rotation: two genuinely different references at + // different temporal distances, which is what `dist_wtd_comp_weight_ + // assign` weights BY. A static or flat source has equal distances + // everywhere and every block collapses onto one weight row. + let y4m = Command::new("ffmpeg") + .args([ + "-v", + "error", + "-f", + "lavfi", + "-i", + "mandelbrot=size=128x128:rate=25:start_x=-0.6:start_y=-0.4,\ + rotate=a=0.01*n:ow=128:oh=128:c=black,scale=64:64", + "-t", + "0.96", + "-pix_fmt", + "yuv420p", + "-strict", + "-1", + "-f", + "yuv4mpegpipe", + "-", + ]) + .stdin(Stdio::null()) + .stdout(Stdio::piped()) + .stderr(Stdio::piped()) + .output() + .expect("ffmpeg failed to run"); + assert!( + y4m.status.success(), + "{NAME}: ffmpeg fixture: {}", + String::from_utf8_lossy(&y4m.stderr) + ); + // the shared recipe; the flag under test is appended per arm so the + // two arms differ in exactly one argument. + let recipe: Vec<&str> = vec![ + "--codec=av1", + "--passes=1", + "--end-usage=q", + "--cq-level=30", + "--cpu-used=0", + "--kf-max-dist=1000", + "--threads=1", + "--row-mt=0", + "--auto-alt-ref=1", + "--lag-in-frames=25", + "--enable-fwd-kf=0", + // `enable_jnt_comp` is only READ when order hints are on + // (`av1_cx_iface.c:1491` ANDs the two). + "--enable-order-hint=1", + "--enable-warped-motion=1", + "--tune-content=default", + "--min-partition-size=32", + "--max-partition-size=64", + // partition/intra tools this decoder does not code -- the same + // exclusion list every compound gate in this file carries. + "--enable-rect-partitions=0", + "--enable-ab-partitions=0", + "--enable-1to4-partitions=0", + "--enable-filter-intra=0", + "--enable-smooth-intra=0", + "--enable-paeth-intra=0", + "--enable-directional-intra=0", + "--enable-angle-delta=0", + "--enable-tx-size-search=0", + "--enable-cdef=0", + "--enable-restoration=0", + "--enable-palette=0", + "--enable-intrabc=0", + "--enable-cfl-intra=0", + "--enable-ref-frame-mvs=0", + ]; + let encode = |flag: &str| -> Vec { + let out = run_with_stdin( + Command::new(aomenc_path()).args( + recipe + .iter() + .copied() + .chain([flag, "--obu", "-o", "-", "-"]), + ), + &y4m.stdout, + ); + assert!( + out.status.success(), + "{NAME}: aomenc refused the fixture with {flag}: {}", + String::from_utf8_lossy(&out.stderr) + ); + out.stdout + }; + // The PARSED header, read back off the encoded bytes -- never the + // command line. `Av1Parser` walks the real OBUs, so a flag the encoder + // ignored is caught here rather than inherited into coverage. + let parsed_jnt_comp = |stream: &[u8]| -> bool { + let mut parser = Av1Parser::new(); + let mut pos = 0usize; + while pos < stream.len() { + let obu = parser.parse_obu(&stream[pos..]).expect("parsing our own OBUs"); + pos += obu.total_size; + } + parser + .sequence_header() + .expect("the stream carries a sequence header") + .enable_jnt_comp + }; + // NB: the OFF arm is spelled FIRST on purpose. `gate_coverage.rs`'s + // `flags_in` keeps the LAST `--enable-=` it finds in a gate + // body, so a trailing `=0` would make the whole gate read as "tool + // disabled" to the census and leave the entry unretired even though + // this gate does exercise the tool. Both arms are still asserted below. + let off = encode("--enable-dist-wtd-comp=0"); + let on = encode("--enable-dist-wtd-comp=1"); + // the bit MOVES with the flag, and it moves the BYTES: a flag the + // encoder accepted but ignored would fail both of these. + assert!( + parsed_jnt_comp(&on), + "{NAME}: the recipe spelled --enable-dist-wtd-comp=1 but the PARSED \ + sequence header carries enable_jnt_comp == false (class \ + knob-never-reached-the-tool) -- the gate would be vacuous" + ); + assert!( + !parsed_jnt_comp(&off), + "{NAME}: the same recipe with --enable-dist-wtd-comp=0 still parses \ + enable_jnt_comp == true, so the ON arm proves nothing about the flag" + ); + assert_ne!( + on.len(), + off.len(), + "{NAME}: both arms encoded {} bytes -- the flag changed nothing on \ + the wire, so neither arm is evidence for anything", + on.len() + ); + // shape non-vacuity, before any compare: at 4:2:0 a decoder keeping a + // subsampled extent would hand quarter-size planes to the byte compare. + let frames = decode_stream(&on).unwrap_or_else(|e| panic!("{NAME}: refused: {e}")); + assert_eq!( + frames.len(), + frame_count, + "{NAME}: expected {frame_count} shown frames" + ); + for (i, f) in frames.iter().enumerate() { + assert_eq!( + (f.width, f.height), + (width, height), + "{NAME}: frame {i} is {}x{}", + f.width, + f.height + ); + assert_eq!( + f.u.len(), + width * height / 4, + "{NAME}: frame {i} U plane is {} samples, not 4:2:0", + f.u.len() + ); + assert_eq!(f.v.len(), f.u.len(), "{NAME}: frame {i} V plane extent"); + assert_eq!(f.y.len(), width * height, "{NAME}: frame {i} luma extent"); + } + crate::decode::reset_dist_wtd_comp_hits(); + let hits_before = crate::decode::dist_wtd_comp_hits(); + let (oracle_frames, hidden) = decode_all_frames_vs_oracle(&on, NAME); + let dist_wtd = crate::decode::dist_wtd_comp_hits() - hits_before; + eprintln!( + "{NAME}: {oracle_frames} oracle frames ({hidden} hidden), \ + dist_wtd_comp_hits={dist_wtd}, on={} B off={} B", + on.len(), + off.len() + ); + assert!( + dist_wtd > 0, + "{NAME}: no block took the distance-weighted compound combine \ + (compound_idx == 0) across {oracle_frames} frames that carry \ + enable_jnt_comp = true -- every compound block used the simple \ + average, so this gate proves nothing about the tool" + ); + } } diff --git a/lanes/av1distwtd.report.md b/lanes/av1distwtd.report.md new file mode 100644 index 00000000..c457ab5e --- /dev/null +++ b/lanes/av1distwtd.report.md @@ -0,0 +1,229 @@ +# lane-av1distwtd + +Two rounds on one branch (`lane-av1distwtd`, base `a21f3680`). + +- **r1** — close the `enable-dist-wtd-comp` coverage hole. +- **r2** — audit every CLAIM in `gate_coverage.rs` against the code and correct + the false ones (appended below). + +--- + +## r1: `enable-dist-wtd-comp` + +`PRODUCIBLE`. The census entry's stated reason — "distance-weighted compound is +unimplemented" — was **false**: `compound::dist_wtd_comp_weight_assign` +(lane-av1comp) and `mc::combine_compound`'s weighted path have implemented it for +a long time. What was missing was a stream *carrying* the tool, so no gate ever +proved it fired. + +Closed with a witness gate `a_distance_weighted_compound_stream_decodes_pixel_exact` +(25 oracle frames, 21 distance-weighted blocks, pixel-exact) plus the +`gate_coverage.rs` entry deletion, commit `9cca1096`. See that commit message for +the full red-before evidence. + +**12-bit / single-ref:** unaffected. 12-bit reaches the same arm independently +(15 blocks measured); single-ref never reads `compound_idx` at all. + +--- + +# r2 appendix: gate_coverage.rs claim audit + +Every claim checked against the code, not against prose. Method per claim: +find the deciding symbol and follow the call path from the feature-flag parse to +the reconstruction site; for encoder claims, read `~/.cache/aom-oracle/src` +(aom 3.13.3, `CONFIG_REALTIME_ONLY 0`) rather than `--help`; where a stream was +needed, encode one and read the **parsed** header, never the flag. + +## Evidence table + +| # | entry / claim (file:line) | stated reason | verdict | deciding code | what it should say | +|---|---|---|---|---|---| +| 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 | +| 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 | +| 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) | +| 4 | `enable-dual-filter` 10-bit (`:374`) | "hole at both depths" | **FALSE** | same gate as #3 | same as #3, both depths | +| 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) | +| 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) | +| 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 | +| 8 | `enable-rect-tx` 10-bit (`:395`) | "hole at both depths" | **TRUE** | same | keep | +| 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 | +| 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 | +| 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 | +| 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 | +| 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 | +| 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 | +| 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 | +| 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 | +| 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* | +| 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 | +| 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 | +| 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 | +| 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 | +| 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 | +| 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 | + +## Claims-a-gate spot check (class: a passing gate that never reaches the feature) + +Main's "one level down" class. Each entry naming a gate was checked against that +gate's own asserts: + +| entry | gate named | gate exists | gate asserts the firing | verdict | +|---|---|---|---|---| +| dist-wtd (r1) | `a_distance_weighted_compound_stream_...` | yes | yes — `dist_wtd_comp_hits() > 0` | **VERIFIED** | +| dual-filter | `a_real_aomenc_dual_filter_obmc_8x8_...` | yes | yes — `dual_filter_diff_hits() > before` | **VERIFIED** (census blind to it) | +| flip-idtx | `a_real_aomenc_stream_with_a_1d_tx_class_...` | yes | yes — `compared_class1 > 0` | **VERIFIED** | +| 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** | +| intrabc | `an_sb128_screen_stream_with_intrabc_...` | yes | yes — `blocks_total > 0 && fired_arms > 0` | **VERIFIED** | +| restoration | `a_real_aomenc_10bit_restoration_stream_...` | yes | yes — `lr_*_hits` | **VERIFIED** | +| superres (alias) | 5 superres gates | yes | yes — `superres_hits`/`predict_scaled_hits` | **VERIFIED** | +| global-motion | `a_real_affine_global_motion_...` | yes | yes — affine GM counter | **VERIFIED** | + +**GAP (one):** no gate in the tree names `enable-rect-tx`, because the tool has no +header bit and no flag-shaped decoder gate — a *structural* gap, correctly +described by entry #7, not a broken gate. + +## The two structural census defects this audit exposed + +Both are stated in the corrected comments but are **census logic**, deliberately +NOT changed in this lane (the brief forbids behaviour changes; the entry deletions +are left in place so the file's own tests stay green): + +1. **`gate_bodies()` helper-delegation blind spot** (`gate_coverage.rs:421`). + The filter keeps only a `#[test]`-shaped segment containing `--passes=1` / + `ten_bit_tool_gate(` / `encode_10bit_gradients`. A gate that hands its recipe + to a shared helper keeps the flags in the *helper*, so the whole gate is + invisible. Measured: 165 of 311 segments are filtered out, and 6 of those + spell at least one `--enable-X=1` — including both gates that prove + `enable-dual-filter` (#3, #4). This is why two live entries are wrong. + +2. **`covers_both_depths` blind spot, third spelling** (`gate_coverage.rs:599`). + It recognises only `if bit_depth == 10` / `if depth == 10` / + `for depth in [8usize, 10]`. `a_real_aomenc_stream_with_a_1d_tx_class_...` + builds both depths from a `ten_bit` recipe, so `is_ten_bit` sees the + `yuv420p10le` and files it 10-bit-ONLY — hiding its 8-bit arm and keeping the + 8-bit `enable-flip-idtx` entry alive (#5). This is the lane-defon/reelckf blind + spot the function's own doc comment describes, reached through a new spelling. + +**Loud, for the coverage matrix:** entries `enable-dual-filter` (8-bit `:270`, +10-bit `:374`) and `enable-flip-idtx` (8-bit `:291`) are **stale coverage holes** +— the tools are exercised by gates with hard arrival asserts. The census is +wrong, not the coverage. If another lane's matrix counts these as open cells, +that matrix overstates the holes. Correcting the two structural defects above +would let all three entries be deleted and this file's own test stay green. + +## What changed in this lane + +`crates/ec-av1/src/gate_coverage.rs` only, and the diff is **comment/reason-text +only**: verified — the only non-comment lines changed are 3 entry *reason +strings* (`gate_coverage.rs:272, 293, 376`). No flag name, entry membership, +counter, gate, or decoder behaviour was touched. All 9 `gate_coverage` tests +green after the change. No stream, gate, or counter behaviour altered, per brief. + +--- + +# r3 appendix: fix the two structural census defects + +r2 corrected the false CLAIMS. r3 fixes the LOGIC that generated them, so it +stops generating them. `crates/ec-av1/src/gate_coverage.rs` only; no gate, +counter, fixture, or decoder behaviour touched. + +## Evidence table — before / after + +| measure | before (r2, spelling-only) | after (r3, call-resolving) | +|---|---|---| +| gate bodies seen by `gate_bodies()` | 146 | **230** (+84) | +| of those, classified 10-bit-or-higher | 83 | **107** (+24) | +| `enable-dual-filter` 8-bit | listed as a hole | **retired** (gate found) | +| `enable-flip-idtx` 8-bit | listed as a hole | **retired** (gate classified both-depths) | +| `NEVER_EXERCISED_8BIT` | 3 live entries | **1** (`enable-rect-tx`) | +| `NEVER_EXERCISED_10BIT` | 3 live entries | **2** (`enable-dual-filter`, `enable-rect-tx`) | +| tests | 9 | **10** (new `the_detector_sees_the_gates_the_spelling_filter_missed`) | + +The three gates the fix had to find, all now found and asserted by the new test: + +| gate | was invisible because | now found by | +|---|---|---| +| `a_real_aomenc_dual_filter_obmc_8x8_inter_sequence_decodes_pixel_exact` | recipe lives in `inter_sb_none_gate` | `encoder_fns` call closure | +| `a_real_obmc_stream_reads_a_recorded_switchable_filter_for_every_neighbour` | same | `encoder_fns` call closure | +| `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 | + +## The two fixes + +**1. `gate_bodies()` — recognise a gate by what it CALLS, not only what it spells.** +New `fn_units` parses every `fn` in `stream.rs` as `(name, body)`; `encoder_fns` +computes the transitive closure of fns that reach one naming `aomenc_path()`. +The filter is now `legacy_gate_tokens(body) || body.contains("aomenc_path()") +|| enc.iter().any(|e| calls_fn(body, e))`. The call test is deliberately the +weak half of an OR, so the fix is **strictly additive** — it can add gates but +can never stop recognising one the old filter did. `calls_fn` requires the name +to be followed by `(` and not be the tail of a longer identifier, so +`inter_sb_none_gate` does not "call" `sb_none_gate`. + +**2. `covers_both_depths` — the third spelling.** Added +`body.contains("\"yuv420p\"") && body.contains("\"yuv420p10le\"")`: a body +naming BOTH fixture formats builds streams at both depths, whatever the +parameter is called. The quotes matter — a bare `yuv420p` substring test also +matches `yuv420p10le` and would fire on every 10-bit gate, retiring entries on +no evidence. This is not a special case for the flip-idtx gate; it is the +lane-defon/reelckf blind spot closed on its third spelling. + +## Red-before (three mutations, all reverted; `stream.rs` byte-identical to HEAD) + +A detector change can only be shown to find MORE, never to stop missing, so +each half was shown to be **causal** — neuter it and the retired entry must come +back. + +**Mutation A — the helper-delegation half.** Set `--enable-dual-filter=1` to +`=0` in both helper-based gates. TWO tests red: +- `never_exercised_8bit_matches_the_gate_recipes`: *"no 8-bit gate passes `=1` + for ["enable-dual-filter"], so no real 8-bit stream exercises them"* — the + retired entry correctly RETURNS as a hole. +- `the_detector_sees_the_gates_the_spelling_filter_missed`: *"seen, but its + --enable-dual-filter=1 spelling is not visible to flags_in"*, `left: Some('0') + right: Some('1')`. The second red is the valuable one: it separates + *recognition broke* from *the gate no longer enables the tool*. + +**Mutation B — the legacy path still works.** Set `--enable-dist-wtd-comp=1` to +`=0` in the r1 gate, a gate the OLD filter already recognised (it spells +`--passes=1`). Red at BOTH depths: *"no 10-bit gate passes `=1` for +["enable-dist-wtd-comp"]"* and the 8-bit twin. The spelling path is intact. + +**Mutation C — the both-depths half.** Reverted only the pair-of-formats +clause. TWO tests red: `never_exercised_8bit...`: *"no 8-bit gate passes `=1` +for ["enable-flip-idtx"]"*, and the new detector test: *"the flip-idtx gate +spells both fixture formats, so covers_both_depths must credit it to the 8-bit +bucket as well"*. + +All three reverted; `git diff --stat crates/ec-av1/src/stream.rs` is empty, and +all 10 tests are green. + +## `enable-dual-filter` 10-bit: the entry STAYS — a finding, not an oversight + +After the fix the 8-bit entry retires and the 10-bit one does not, which is the +honest outcome and exactly the case Main said to report rather than paper over. +The only `=1` witness is `a_real_aomenc_dual_filter_obmc_8x8_inter_sequence_decodes_pixel_exact`, +and it calls `inter_sb_none_gate(NAME, false, ...)` — `false` is the `ten_bit` +parameter, so it builds an 8-bit stream only. Its `ten_bit=true` siblings +(`..._10bit_inter_sequence_with_a_whole_superblock_block_...` and the 8x8-leaf +pair) do not spell `--enable-dual-filter=1`. **To retire it: add the 10-bit arm +— pass `true` to `inter_sb_none_gate` in that gate and assert +`dual_filter_diff_hits()` still moves there.** + +## Row: `enable-tx-size-search` — the one claim this audit could not settle + +A third detector limit, and the method for whoever takes it next. After the r3 +fix, 113 of the 230 selected gates name it: **88 pass `=0`, 15 pass `=1`, and 9 +build the value into a `format!`/`String` variable** that neither `flags_in` nor +`settings_in` can see — both scan for a literal `"--flag=value"` inside one +segment. So the r2 finding stands and sharpens: the historical "all 49 pass 0" +claim no longer holds in either direction, and 9 gates are unclassified in an +**unknown direction**, which is the exact failure mode this file exists to +prevent. + +**What would settle it (method, not a guess):** extend `flags_in`/`settings_in` +to resolve a local binding the way `gate_bodies` now resolves calls. When a +segment contains `let = format!("--enable-tx-size-search={tx_search}")` +(or the `String::from`/`to_string` equivalent), record the TEMPLATE and bind the +variable's value at each use site. Re-count, and only then decide whether the +tool is a live hole. Until that exists the 113/88/15 split is a floor, not a +measurement. This is recorded in-file above `DEFAULT_ON_TOOLS` as well.