From e83a66d770bde9deb6d20ca077e9d85da695ea7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Tue, 29 Sep 2026 04:08:02 +0300 Subject: [PATCH] stream: add the 10-bit dual-filter arm the 10-bit census hole named a_real_aomenc_10bit_dual_filter_obmc_8x8_inter_sequence_decodes_pixel_exact runs the 8-bit dual-filter witness's recipe at ten_bit = true, so a real 10-bit stream carries per-direction interp filters instead of the tool going unproven at that depth. inter_sb_none_gate now returns the encoded stream so the arm can assert the PARSED sequence header: bit_depth == 10 and enable_dual_filter, both read through Av1Parser. The arrival assert (dual_filter_diff_hits delta) comes first on purpose -- setting the flag to =0 reds there, on the tool failing to arrive, not on a shape assert. Reverted after proving it; both arms green. --- crates/ec-av1/src/stream.rs | 92 ++++++++++++++++++++++++- lanes/av1dualfilter10.report.md | 116 ++++++++++++++++++++++++++++++++ 2 files changed, 205 insertions(+), 3 deletions(-) create mode 100644 lanes/av1dualfilter10.report.md diff --git a/crates/ec-av1/src/stream.rs b/crates/ec-av1/src/stream.rs index 61c25576..8c43e25d 100644 --- a/crates/ec-av1/src/stream.rs +++ b/crates/ec-av1/src/stream.rs @@ -17413,14 +17413,17 @@ pub(crate) mod tests { // lane-interp3 r1: sequence length -- a compound block needs several // already-coded references, which a 4-frame sequence never has. frame_count: usize, - ) { + // lane-av1dualfilter10: the encoded stream, so a caller can assert on + // the PARSED sequence header (bit depth, `enable_dual_filter`) rather + // than on the flag it asked for. Empty on the SKIP paths below. + ) -> Vec { if !have_ffmpeg() { eprintln!("SKIP {name}: no ffmpeg"); - return; + return Vec::new(); } if !have_aomenc() { eprintln!("SKIP {name}: no aomenc at {}", aomenc_path().display()); - return; + return Vec::new(); } let height = 64usize; let duration = format!("{:.2}", frame_count as f64 / 25.0); @@ -17543,6 +17546,7 @@ pub(crate) mod tests { ); } } + stream } #[test] @@ -17692,6 +17696,88 @@ pub(crate) mod tests { ); } + /// lane-av1dualfilter10: the 10-bit arm of the dual-filter witness. + /// + /// `NEVER_EXERCISED_10BIT` kept `enable-dual-filter` listed after the + /// 8-bit entry was retired (lane-av1distwtd r3, gate_coverage.rs), and + /// the reason was structural, not incidental: the only `=1` witness, + /// `a_real_aomenc_dual_filter_obmc_8x8_inter_sequence_decodes_pixel_exact`, + /// calls `inter_sb_none_gate(NAME, false, ...)` -- and that `false` IS the + /// `ten_bit` parameter, so it built an 8-bit stream. Its `ten_bit = true` + /// siblings build 10-bit streams but spell no dual-filter flag. This is + /// that missing arm. + /// + /// What makes it a witness and not a spelling: the header is read back + /// from the ENCODED stream (`enable_dual_filter` and `bit_depth` both come + /// from `Av1Parser`, never from the flag or the fixture name), and the + /// arrival assert is a DELTA on `decode::dual_filter_diff_hits()` taken + /// around this arm alone. A stream that merely parsed would not move the + /// counter; the counter moves only when `resolve_interp_filter` reads two + /// DIFFERENT directions for one block, which is the property the entry + /// was claiming no real stream carried. + #[test] + fn a_real_aomenc_10bit_dual_filter_obmc_8x8_inter_sequence_decodes_pixel_exact() { + const NAME: &str = + "a_real_aomenc_10bit_dual_filter_obmc_8x8_inter_sequence_decodes_pixel_exact"; + if !have_ffmpeg() || !have_aomenc() { + eprintln!("SKIP {NAME}: no ffmpeg/aomenc"); + return; + } + let before_dual = decode::dual_filter_diff_hits(); + let stream = inter_sb_none_gate( + NAME, + // `ten_bit`: this is the whole difference from the 8-bit witness. + true, + "8", + "16", + decode::compound8_filter_hits, + "a compound 8x8 leaf reading its own switchable interp_filter", + &[ + "--enable-dual-filter=1", + "--enable-obmc=1", + "--enable-warped-motion=1", + "--enable-onesided-comp=1", + ], + 64, + std::env::var("EC_INTERP3_FRAMES") + .ok() + .and_then(|v| v.parse().ok()) + .unwrap_or(16), + ); + // The ARRIVAL assert comes first on purpose. `dual_filter_diff_hits()` + // moves only inside `resolve_interp_filter` when the header bit is set + // AND the block's two directions differ, so pinning it =0 reds HERE, + // on the tool failing to arrive -- not on some shape or pixel assert + // downstream of it. The two header asserts below corroborate it from + // the encoded bytes; they are not what carries the proof. + assert!( + decode::dual_filter_diff_hits() > before_dual, + "{NAME}: no block read two DIFFERENT dual-filter directions in the 10-bit stream \ + -- --enable-dual-filter=1 did not arrive or aomenc declined it" + ); + // Both facts from the PARSED header, not from what we asked for: a + // gate that trusted `--bit-depth=10` would pass on a stream aomenc + // silently coded at 8, which is the vacuity this asserts against. + let mut probe = Av1Parser::new(); + let mut pos = 0usize; + while pos < stream.len() && probe.sequence_header().is_none() { + let obu = probe.parse_obu(&stream[pos..]).unwrap(); + pos += obu.total_size; + } + let seq = probe + .sequence_header() + .expect("stream has a sequence header OBU"); + assert_eq!( + seq.color_config.bit_depth, 10, + "{NAME}: aomenc did not write a 10-bit sequence header" + ); + assert!( + seq.enable_dual_filter, + "{NAME}: the parsed sequence header says enable_dual_filter = false, so this \ + stream cannot carry per-direction interp filters however the pixels compare" + ); + } + #[test] fn a_real_aomenc_inter_sequence_with_an_8x8_leaf_split_decodes_pixel_exact() { inter_sb_none_gate( diff --git a/lanes/av1dualfilter10.report.md b/lanes/av1dualfilter10.report.md new file mode 100644 index 00000000..529254f3 --- /dev/null +++ b/lanes/av1dualfilter10.report.md @@ -0,0 +1,116 @@ +# lane-av1dualfilter10 — 10-bit `enable-dual-filter` witness + +Base: `1aaf7e0b` (lane-av1distwtd, the census detector fix). Branch: `lane-av1dualfilter10`. +Touches `crates/ec-av1/src/stream.rs` (tests only). `gate_coverage.rs` is NOT edited. + +## What the census left open + +`NEVER_EXERCISED_10BIT` still carried `enable-dual-filter`, and the reason it carried was +structural, not incidental: + +- the only `=1` witness is `a_real_aomenc_dual_filter_obmc_8x8_inter_sequence_decodes_pixel_exact` +- that gate calls `inter_sb_none_gate(NAME, false, ...)` and that `false` IS the `ten_bit` + parameter of the helper, so it builds an **8-bit** stream +- the helper's `ten_bit = true` siblings build 10-bit streams but spell no dual-filter flag + +So the tool was proven at 8 bits and unproven at 10. This lane adds the missing arm. + +## The change (stream.rs only) + +1. `inter_sb_none_gate` now returns `Vec` — the encoded stream — so a caller can assert on + the **parsed** sequence header rather than on the flag it asked for. SKIP paths return an + empty vec. All six existing callers ignore the value; none needed edits. +2. New gate `a_real_aomenc_10bit_dual_filter_obmc_8x8_inter_sequence_decodes_pixel_exact` + (`stream.rs:17719`), the 10-bit twin of the 8-bit witness: same recipe, same four + `--enable-*` flags including `--enable-dual-filter=1`, `ten_bit = true`, same compound-8x8 + arrival counter, same 16-frame sequence, same 64-wide frame. + +### What makes it a witness rather than a spelling + +Three independent facts, in this assert order: + +1. **arrival, first** — `decode::dual_filter_diff_hits() > before_dual`, a DELTA taken around + this arm alone. The counter increments only inside `resolve_interp_filter` + (`decode.rs:35136`) and only when the header bit is set *and* the block's two directions + differ. Deliberately asserted before the header checks so the mutation below reds on the + arrival, not on a shape/pixel assert downstream. +2. **10-bit from the parsed header** — `seq.color_config.bit_depth == 10` read through + `Av1Parser` on the encoded bytes. Not the filename, not the flag, not the fixture name. +3. **the tool is in the header** — `seq.enable_dual_filter` true, same parse. + +`inter_sb_none_gate` also pixel-compares every frame against ffmpeg's own 10-bit decode +(`ffmpeg_decode_sequence_10bit`), so the arm is pixel-exact end to end, not merely parseable. + +## Red-before (in the right direction) + +Mutation: `--enable-dual-filter=1` -> `=0` in the 10-bit arm only. + +``` +panicked at crates/ec-av1/src/stream.rs:17753: +a_real_aomenc_10bit_dual_filter_obmc_8x8_inter_sequence_decodes_pixel_exact: +no block read two DIFFERENT dual-filter directions in the 10-bit stream -- +--enable-dual-filter=1 did not arrive or aomenc declined it +``` + +The **arrival** assert, as required. First attempt had the header asserts first and reds on +`the parsed sequence header says enable_dual_filter = false` — correct but the wrong assert, +so the block was reordered and the red re-proven. Reverted after; both arms green: + +``` +test stream::tests::a_real_aomenc_10bit_dual_filter_obmc_8x8_inter_sequence_decodes_pixel_exact ... ok +test stream::tests::a_real_aomenc_dual_filter_obmc_8x8_inter_sequence_decodes_pixel_exact ... ok +2 passed; 0 failed +``` + +Sibling `inter_sb_none_gate` callers re-run green (whole-superblock 8/10-bit, 8x8-leaf-split +8/10-bit, across-tile-columns: 3 passed, 0 failed). + +## Census effect (measured, not claimed) + +`cargo test -p ec-av1 --lib gate_coverage`, run on this branch: + +``` +the 10-bit list still names ["enable-dual-filter"], but a 10-bit gate now passes `=1` for +them -- delete those entries, the coverage hole is closed <- FAILS, correctly + +gate_coverage: 231 real-aomenc gates, 108 of them 10-bit +NEVER_EXERCISED_8BIT (1 of 26): --enable-rect-tx +NEVER_EXERCISED_10BIT (1 of 26): --enable-rect-tx +NEVER_ON_8BIT (0 of 10, over 192 8BIT gates) +NEVER_ON_10BIT (0 of 10, over 110 10BIT gates) +``` + +That single red is the deliverable's receipt, and it is why this lane stops here: + +**`gate_coverage.rs:374-377`, `NEVER_EXERCISED_10BIT` — `enable-dual-filter`** is now +retirable. Its reason string ("no 10-bit gate spells `=1` -- that gate calls +`inter_sb_none_gate` with `ten_bit=false`") is exactly what this lane closed. Deletion is the +census owner's call; the merge owner sequences it. `enable-rect-tx` stays in both lists +(its premise is PROVEN: aom has no sequence-header bit for it, `enable_rect_tx` is read only +in `tx_search.c`). + +Gate counts moved 230 -> 231 and 107 -> 108 10-bit (the new arm), from lane-av1distwtd's +before-numbers of 146 -> 230 gates / 83 -> 107 at the detector fix. + +## Third detector limit, cited for report agreement (NOT fixed here) + +`--enable-tx-size-search` is built into a `format!`/`String` variable in a number of gates, so +`flags_in` — which matches the literal `"--enable-` — cannot see it. Any count of "gates +naming it" is therefore a FLOOR. lane-av1distwtd measured 113 of 230 naming it (88 `=0`, +15 `=1`, 9 invisible via `format!`); my independent recount on this branch (now 231 gates, +so not directly comparable) gives 116 segments spelling the literal (94 `=0`, 21 `=1`) plus +15 more that name the tool only inside a `format!`. Same class, same direction, magnitudes +differ only with the extra gate. Method: the method is the `format!` construction itself — +`args.push(format!("--enable-tx-size-search={}", ...))` leaves no `"--enable-` literal for +`match_indices` to find, so a census that wants a measurement rather than a floor has to +resolve the helper's `String` before counting, or match on the flag name without the leading +`"` and then classify the value from the format argument. Open question, not a fix. + +## Verification actually run + +- `cargo build -p ec-av1 --tests` clean. +- new gate green, both arms green, mutation red on the arrival assert, mutation reverted + (grep confirms 4 `--enable-dual-filter=1` sites: 3926, 17668, 17736 — plus the two `=0` + sites 18414/18680 untouched). +- sibling `inter_sb_none_gate` gates green. +- `gate_coverage` 10-bit test red for the intended reason; all other 9 green.