forge
Explore
Log in

Don't you dare go Hollow

stream: add the 10-bit dual-filter arm the 10-bit census hole named

Browse files at this commit

e83a66d770bde9deb6d20ca077e9d85da695ea7cAhmet Kaan GümüşParent: 143cdf9
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.rsmodified+89 -3
@@ -17413,14 +17413,17 @@ pub(crate) mod tests {
17413 // lane-interp3 r1: sequence length -- a compound block needs several17413 // lane-interp3 r1: sequence length -- a compound block needs several
17414 // already-coded references, which a 4-frame sequence never has.17414 // already-coded references, which a 4-frame sequence never has.
17415 frame_count: usize,17415 frame_count: usize,
17416- ) {17416+ // lane-av1dualfilter10: the encoded stream, so a caller can assert on
17417+ // the PARSED sequence header (bit depth, `enable_dual_filter`) rather
17418+ // than on the flag it asked for. Empty on the SKIP paths below.
17419+ ) -> Vec<u8> {
17417 if !have_ffmpeg() {17420 if !have_ffmpeg() {
17418 eprintln!("SKIP {name}: no ffmpeg");17421 eprintln!("SKIP {name}: no ffmpeg");
17419- return;17422+ return Vec::new();
17420 }17423 }
17421 if !have_aomenc() {17424 if !have_aomenc() {
17422 eprintln!("SKIP {name}: no aomenc at {}", aomenc_path().display());17425 eprintln!("SKIP {name}: no aomenc at {}", aomenc_path().display());
17423- return;17426+ return Vec::new();
17424 }17427 }
17425 let height = 64usize;17428 let height = 64usize;
17426 let duration = format!("{:.2}", frame_count as f64 / 25.0);17429 let duration = format!("{:.2}", frame_count as f64 / 25.0);
@@ -17543,6 +17546,7 @@ pub(crate) mod tests {
17543 );17546 );
17544 }17547 }
17545 }17548 }
17549+ stream
17546 }17550 }
17547 17551
17548 #[test]17552 #[test]
@@ -17692,6 +17696,88 @@ pub(crate) mod tests {
17692 );17696 );
17693 }17697 }
17694 17698
17699+ /// lane-av1dualfilter10: the 10-bit arm of the dual-filter witness.
17700+ ///
17701+ /// `NEVER_EXERCISED_10BIT` kept `enable-dual-filter` listed after the
17702+ /// 8-bit entry was retired (lane-av1distwtd r3, gate_coverage.rs), and
17703+ /// the reason was structural, not incidental: the only `=1` witness,
17704+ /// `a_real_aomenc_dual_filter_obmc_8x8_inter_sequence_decodes_pixel_exact`,
17705+ /// calls `inter_sb_none_gate(NAME, false, ...)` -- and that `false` IS the
17706+ /// `ten_bit` parameter, so it built an 8-bit stream. Its `ten_bit = true`
17707+ /// siblings build 10-bit streams but spell no dual-filter flag. This is
17708+ /// that missing arm.
17709+ ///
17710+ /// What makes it a witness and not a spelling: the header is read back
17711+ /// from the ENCODED stream (`enable_dual_filter` and `bit_depth` both come
17712+ /// from `Av1Parser`, never from the flag or the fixture name), and the
17713+ /// arrival assert is a DELTA on `decode::dual_filter_diff_hits()` taken
17714+ /// around this arm alone. A stream that merely parsed would not move the
17715+ /// counter; the counter moves only when `resolve_interp_filter` reads two
17716+ /// DIFFERENT directions for one block, which is the property the entry
17717+ /// was claiming no real stream carried.
17718+ #[test]
17719+ fn a_real_aomenc_10bit_dual_filter_obmc_8x8_inter_sequence_decodes_pixel_exact() {
17720+ const NAME: &str =
17721+ "a_real_aomenc_10bit_dual_filter_obmc_8x8_inter_sequence_decodes_pixel_exact";
17722+ if !have_ffmpeg() || !have_aomenc() {
17723+ eprintln!("SKIP {NAME}: no ffmpeg/aomenc");
17724+ return;
17725+ }
17726+ let before_dual = decode::dual_filter_diff_hits();
17727+ let stream = inter_sb_none_gate(
17728+ NAME,
17729+ // `ten_bit`: this is the whole difference from the 8-bit witness.
17730+ true,
17731+ "8",
17732+ "16",
17733+ decode::compound8_filter_hits,
17734+ "a compound 8x8 leaf reading its own switchable interp_filter",
17735+ &[
17736+ "--enable-dual-filter=1",
17737+ "--enable-obmc=1",
17738+ "--enable-warped-motion=1",
17739+ "--enable-onesided-comp=1",
17740+ ],
17741+ 64,
17742+ std::env::var("EC_INTERP3_FRAMES")
17743+ .ok()
17744+ .and_then(|v| v.parse().ok())
17745+ .unwrap_or(16),
17746+ );
17747+ // The ARRIVAL assert comes first on purpose. `dual_filter_diff_hits()`
17748+ // moves only inside `resolve_interp_filter` when the header bit is set
17749+ // AND the block's two directions differ, so pinning it =0 reds HERE,
17750+ // on the tool failing to arrive -- not on some shape or pixel assert
17751+ // downstream of it. The two header asserts below corroborate it from
17752+ // the encoded bytes; they are not what carries the proof.
17753+ assert!(
17754+ decode::dual_filter_diff_hits() > before_dual,
17755+ "{NAME}: no block read two DIFFERENT dual-filter directions in the 10-bit stream \
17756+ -- --enable-dual-filter=1 did not arrive or aomenc declined it"
17757+ );
17758+ // Both facts from the PARSED header, not from what we asked for: a
17759+ // gate that trusted `--bit-depth=10` would pass on a stream aomenc
17760+ // silently coded at 8, which is the vacuity this asserts against.
17761+ let mut probe = Av1Parser::new();
17762+ let mut pos = 0usize;
17763+ while pos < stream.len() && probe.sequence_header().is_none() {
17764+ let obu = probe.parse_obu(&stream[pos..]).unwrap();
17765+ pos += obu.total_size;
17766+ }
17767+ let seq = probe
17768+ .sequence_header()
17769+ .expect("stream has a sequence header OBU");
17770+ assert_eq!(
17771+ seq.color_config.bit_depth, 10,
17772+ "{NAME}: aomenc did not write a 10-bit sequence header"
17773+ );
17774+ assert!(
17775+ seq.enable_dual_filter,
17776+ "{NAME}: the parsed sequence header says enable_dual_filter = false, so this \
17777+ stream cannot carry per-direction interp filters however the pixels compare"
17778+ );
17779+ }
17780+
17695 #[test]17781 #[test]
17696 fn a_real_aomenc_inter_sequence_with_an_8x8_leaf_split_decodes_pixel_exact() {17782 fn a_real_aomenc_inter_sequence_with_an_8x8_leaf_split_decodes_pixel_exact() {
17697 inter_sb_none_gate(17783 inter_sb_none_gate(
lanes/av1dualfilter10.report.mdadded+116 -0
@@ -0,0 +1,116 @@
1+# lane-av1dualfilter10 — 10-bit `enable-dual-filter` witness
2+
3+Base: `1aaf7e0b` (lane-av1distwtd, the census detector fix). Branch: `lane-av1dualfilter10`.
4+Touches `crates/ec-av1/src/stream.rs` (tests only). `gate_coverage.rs` is NOT edited.
5+
6+## What the census left open
7+
8+`NEVER_EXERCISED_10BIT` still carried `enable-dual-filter`, and the reason it carried was
9+structural, not incidental:
10+
11+- the only `=1` witness is `a_real_aomenc_dual_filter_obmc_8x8_inter_sequence_decodes_pixel_exact`
12+- that gate calls `inter_sb_none_gate(NAME, false, ...)` and that `false` IS the `ten_bit`
13+ parameter of the helper, so it builds an **8-bit** stream
14+- the helper's `ten_bit = true` siblings build 10-bit streams but spell no dual-filter flag
15+
16+So the tool was proven at 8 bits and unproven at 10. This lane adds the missing arm.
17+
18+## The change (stream.rs only)
19+
20+1. `inter_sb_none_gate` now returns `Vec<u8>` — the encoded stream — so a caller can assert on
21+ the **parsed** sequence header rather than on the flag it asked for. SKIP paths return an
22+ empty vec. All six existing callers ignore the value; none needed edits.
23+2. New gate `a_real_aomenc_10bit_dual_filter_obmc_8x8_inter_sequence_decodes_pixel_exact`
24+ (`stream.rs:17719`), the 10-bit twin of the 8-bit witness: same recipe, same four
25+ `--enable-*` flags including `--enable-dual-filter=1`, `ten_bit = true`, same compound-8x8
26+ arrival counter, same 16-frame sequence, same 64-wide frame.
27+
28+### What makes it a witness rather than a spelling
29+
30+Three independent facts, in this assert order:
31+
32+1. **arrival, first** — `decode::dual_filter_diff_hits() > before_dual`, a DELTA taken around
33+ this arm alone. The counter increments only inside `resolve_interp_filter`
34+ (`decode.rs:35136`) and only when the header bit is set *and* the block's two directions
35+ differ. Deliberately asserted before the header checks so the mutation below reds on the
36+ arrival, not on a shape/pixel assert downstream.
37+2. **10-bit from the parsed header** — `seq.color_config.bit_depth == 10` read through
38+ `Av1Parser` on the encoded bytes. Not the filename, not the flag, not the fixture name.
39+3. **the tool is in the header** — `seq.enable_dual_filter` true, same parse.
40+
41+`inter_sb_none_gate` also pixel-compares every frame against ffmpeg's own 10-bit decode
42+(`ffmpeg_decode_sequence_10bit`), so the arm is pixel-exact end to end, not merely parseable.
43+
44+## Red-before (in the right direction)
45+
46+Mutation: `--enable-dual-filter=1` -> `=0` in the 10-bit arm only.
47+
48+```
49+panicked at crates/ec-av1/src/stream.rs:17753:
50+a_real_aomenc_10bit_dual_filter_obmc_8x8_inter_sequence_decodes_pixel_exact:
51+no block read two DIFFERENT dual-filter directions in the 10-bit stream --
52+--enable-dual-filter=1 did not arrive or aomenc declined it
53+```
54+
55+The **arrival** assert, as required. First attempt had the header asserts first and reds on
56+`the parsed sequence header says enable_dual_filter = false` — correct but the wrong assert,
57+so the block was reordered and the red re-proven. Reverted after; both arms green:
58+
59+```
60+test stream::tests::a_real_aomenc_10bit_dual_filter_obmc_8x8_inter_sequence_decodes_pixel_exact ... ok
61+test stream::tests::a_real_aomenc_dual_filter_obmc_8x8_inter_sequence_decodes_pixel_exact ... ok
62+2 passed; 0 failed
63+```
64+
65+Sibling `inter_sb_none_gate` callers re-run green (whole-superblock 8/10-bit, 8x8-leaf-split
66+8/10-bit, across-tile-columns: 3 passed, 0 failed).
67+
68+## Census effect (measured, not claimed)
69+
70+`cargo test -p ec-av1 --lib gate_coverage`, run on this branch:
71+
72+```
73+the 10-bit list still names ["enable-dual-filter"], but a 10-bit gate now passes `=1` for
74+them -- delete those entries, the coverage hole is closed <- FAILS, correctly
75+
76+gate_coverage: 231 real-aomenc gates, 108 of them 10-bit
77+NEVER_EXERCISED_8BIT (1 of 26): --enable-rect-tx
78+NEVER_EXERCISED_10BIT (1 of 26): --enable-rect-tx
79+NEVER_ON_8BIT (0 of 10, over 192 8BIT gates)
80+NEVER_ON_10BIT (0 of 10, over 110 10BIT gates)
81+```
82+
83+That single red is the deliverable's receipt, and it is why this lane stops here:
84+
85+**`gate_coverage.rs:374-377`, `NEVER_EXERCISED_10BIT` — `enable-dual-filter`** is now
86+retirable. Its reason string ("no 10-bit gate spells `=1` -- that gate calls
87+`inter_sb_none_gate` with `ten_bit=false`") is exactly what this lane closed. Deletion is the
88+census owner's call; the merge owner sequences it. `enable-rect-tx` stays in both lists
89+(its premise is PROVEN: aom has no sequence-header bit for it, `enable_rect_tx` is read only
90+in `tx_search.c`).
91+
92+Gate counts moved 230 -> 231 and 107 -> 108 10-bit (the new arm), from lane-av1distwtd's
93+before-numbers of 146 -> 230 gates / 83 -> 107 at the detector fix.
94+
95+## Third detector limit, cited for report agreement (NOT fixed here)
96+
97+`--enable-tx-size-search` is built into a `format!`/`String` variable in a number of gates, so
98+`flags_in` — which matches the literal `"--enable-` — cannot see it. Any count of "gates
99+naming it" is therefore a FLOOR. lane-av1distwtd measured 113 of 230 naming it (88 `=0`,
100+15 `=1`, 9 invisible via `format!`); my independent recount on this branch (now 231 gates,
101+so not directly comparable) gives 116 segments spelling the literal (94 `=0`, 21 `=1`) plus
102+15 more that name the tool only inside a `format!`. Same class, same direction, magnitudes
103+differ only with the extra gate. Method: the method is the `format!` construction itself —
104+`args.push(format!("--enable-tx-size-search={}", ...))` leaves no `"--enable-` literal for
105+`match_indices` to find, so a census that wants a measurement rather than a floor has to
106+resolve the helper's `String` before counting, or match on the flag name without the leading
107+`"` and then classify the value from the format argument. Open question, not a fix.
108+
109+## Verification actually run
110+
111+- `cargo build -p ec-av1 --tests` clean.
112+- new gate green, both arms green, mutation red on the arrival assert, mutation reverted
113+ (grep confirms 4 `--enable-dual-filter=1` sites: 3926, 17668, 17736 — plus the two `=0`
114+ sites 18414/18680 untouched).
115+- sibling `inter_sb_none_gate` gates green.
116+- `gate_coverage` 10-bit test red for the intended reason; all other 9 green.