diff --git a/crates/ec-av1/src/decode.rs b/crates/ec-av1/src/decode.rs index b76ea5b2..c9c2926f 100644 --- a/crates/ec-av1/src/decode.rs +++ b/crates/ec-av1/src/decode.rs @@ -726,6 +726,35 @@ pub(crate) fn deblock_hits() -> usize { DEBLOCK_HITS.with(|c| c.get()) } +// lane-defon r1: how many COMPOUND_REFERENCE blocks read a +// `UNIDIR_COMP_REFERENCE` pair (both references on the same temporal side, +// spec 5.11.25 `comp_reference_type == 0`) -- the gate's proof that a +// stream built with `--enable-onesided-comp=1` really exercised the +// `uni_comp_ref` alphabet rather than only bidirectional pairs. +thread_local! { + static UNI_COMP_HITS: std::cell::Cell = + const { std::cell::Cell::new(0) }; +} + +/// Current value of [`UNI_COMP_HITS`]. +pub(crate) fn uni_comp_hits() -> usize { + UNI_COMP_HITS.with(|c| c.get()) +} + +// lane-defon r1: how many blocks blended through a `COMPOUND_DIFFWTD` mask +// (`mc::diffwtd_mask`) -- the narrower half of `MASKED_COMPOUND_HITS`, the +// gate's proof that `--enable-diff-wtd-comp=1` reached the difference-weighted +// blend and not only the wedge arm. +thread_local! { + static DIFFWTD_HITS: std::cell::Cell = + const { std::cell::Cell::new(0) }; +} + +/// Current value of [`DIFFWTD_HITS`]. +pub(crate) fn diffwtd_hits() -> usize { + DIFFWTD_HITS.with(|c| c.get()) +} + // How many [`read_tx_size`] reads resolved a `tx_depth` strictly less than // the block's own side, across every call on the current thread -- the same // before/after counter pattern as [`FILTER_INTRA_HITS`], proving a stream @@ -10745,6 +10774,7 @@ fn read_compound_ref_frames( let type_ctx = comp_reference_type_ctx(above, left); let unidir = dec.symbol(&mut cdfs.comp_ref_type[type_ctx]) == 0; if unidir { + UNI_COMP_HITS.with(|c| c.set(c.get() + 1)); // uni_comp_ref (p0): forward vs. backward -- av1_get_pred_context_- // uni_comp_ref_p is single_ref_p1's own forward/backward vote. let bit = dec.symbol(&mut cdfs.uni_comp_ref[single_ref_p1_ctx(a, a1, l, l1)][0]); @@ -11766,6 +11796,7 @@ fn decode_inter_block( // either way, only the mask source differs. let mask_y: Option<&[u8]> = if let Some(mask_type) = diffwtd_mask_type { diffwtd_mask_y = vec![0u8; side * side]; + DIFFWTD_HITS.with(|c| c.set(c.get() + 1)); mc::diffwtd_mask(&inter0_y, &inter1_y, mask_type == 1, &mut diffwtd_mask_y); Some(diffwtd_mask_y.as_slice()) } else { @@ -13662,6 +13693,7 @@ fn decode_inter_block8( let mut diffwtd_mask_y = Vec::new(); let mask_y: Option<&[u8]> = if let Some(mask_type) = diffwtd_mask_type { diffwtd_mask_y = vec![0u8; SIDE * SIDE]; + DIFFWTD_HITS.with(|c| c.set(c.get() + 1)); mc::diffwtd_mask(&inter0_y, &inter1_y, mask_type == 1, &mut diffwtd_mask_y); Some(diffwtd_mask_y.as_slice()) } else { diff --git a/crates/ec-av1/src/gate_coverage.rs b/crates/ec-av1/src/gate_coverage.rs index 49f3a6c3..a426cd7e 100644 --- a/crates/ec-av1/src/gate_coverage.rs +++ b/crates/ec-av1/src/gate_coverage.rs @@ -237,42 +237,18 @@ const NEVER_EXERCISED_10BIT: &[(&str, &str)] = &[ /// merely defaulted (unknown, and unknown is not coverage). #[cfg(test)] const NEVER_ON_8BIT: &[(&str, &str)] = &[ - ( - "deblocking", - "on in no 8-bit gate: 7 pin --loopfilter-control=0, the other 34 default (on) -- and defaulted is unknown, so no stream is proven to run the loop filter", - ), - ( - "enable-diff-wtd-comp", - "on in no 8-bit gate: 6 pin =0, 35 default; difference-weighted compound masks are unproven", - ), - ( - "enable-directional-intra", - "on in no 8-bit gate: pinned =0 in 32 of 41, defaulted in 9 -- the directional gates drive the modes through other flags, never this one", - ), ( "enable-fwd-kf", - "on in no 8-bit gate: 11 pin =0, 30 default (aomenc's default is off), so forward keyframes are never coded", - ), - ( - "enable-onesided-comp", - "on in no 8-bit gate: 17 pin =0, 24 default; one-sided compound prediction is unproven", - ), - ( - "enable-tx-size-search", - "on in no 8-bit gate: pinned =0 in 34 of 41 -- the pin that hid a real-stream PANIC from lane-ab16 until TX_MODE_SELECT was landed by lane-txselect; its gates spell the tool through the recipe, not this flag", + "on in no 8-bit gate: 12 pin =0, 33 default (aomenc's default is off), so forward keyframes are never coded -- lane-defon r1 left this one open: it needs --fwd-kf-dist plus a decoder counter for a KEY frame with show_frame == 0, neither of which exists yet", ), ]; /// [`DEFAULT_ON_TOOLS`] entries no 10-bit gate spells on, with the reason. #[cfg(test)] const NEVER_ON_10BIT: &[(&str, &str)] = &[ - ( - "deblocking", - "hole at both depths, see the 8-bit list (1 of the 15 10-bit gates pins =0, 14 default)", - ), ( "enable-diff-wtd-comp", - "hole at both depths, see the 8-bit list (1 pinned off, 14 defaulted)", + "on in no 10-bit gate: 1 pinned off, 14 defaulted -- lane-defon r1 closed the 8-bit hole on the masked-compound gate (diffwtd_hits), but that gate has no 10-bit sibling", ), ( "enable-fwd-kf", @@ -284,11 +260,7 @@ const NEVER_ON_10BIT: &[(&str, &str)] = &[ ), ( "enable-onesided-comp", - "hole at both depths, see the 8-bit list (5 pinned off, 10 defaulted)", - ), - ( - "enable-tx-size-search", - "hole at both depths, see the 8-bit list (11 of 15 pin =0)", + "on in no 10-bit gate: 5 pinned off, 10 defaulted -- lane-defon r1 closed the 8-bit hole on the interintra gate (uni_comp_hits); the 10-bit compound gates pin it off", ), ( "multi-tile", @@ -471,6 +443,19 @@ mod tests { /// helper, an explicit `--bit-depth=10`/`--input-bit-depth=10`, or a /// `yuv420p10le` fixture handed to aomenc. Everything else is aomenc's /// 8-bit default. + /// lane-defon r1: a gate helper parameterised on `bit_depth` builds BOTH + /// an 8-bit and a 10-bit stream from one recipe, so its flags cover both + /// depths -- classifying it by the 10-bit strings inside its conditional + /// alone hid `--enable-tx-size-search=1` from the 8-bit list. + fn covers_both_depths(body: &str) -> bool { + body.contains("if bit_depth == 10") + } + + /// Whether a gate body drives a stream at this depth. + fn covers_depth(body: &str, ten_bit: bool) -> bool { + covers_both_depths(body) || is_ten_bit(body) == ten_bit + } + fn is_ten_bit(body: &str) -> bool { body.contains("encode_10bit_gradients") || body.contains("ten_bit_tool_gate(") @@ -483,7 +468,7 @@ mod tests { fn enabled_at(ten_bit: bool) -> BTreeSet { let mut on = BTreeSet::new(); for gate in gate_bodies() { - if is_ten_bit(gate) != ten_bit { + if !covers_depth(gate, ten_bit) { continue; } for (flag, value) in flags_in(gate) { @@ -571,7 +556,7 @@ mod tests { fn default_on_settings(ten_bit: bool) -> (usize, BTreeMap<&'static str, (usize, usize, usize)>) { let gates: Vec<&str> = gate_bodies() .into_iter() - .filter(|b| is_ten_bit(b) == ten_bit) + .filter(|b| covers_depth(b, ten_bit)) .collect(); let mut per_tool = BTreeMap::new(); for &(tool, spellings, _, on) in DEFAULT_ON_TOOLS { diff --git a/crates/ec-av1/src/stream.rs b/crates/ec-av1/src/stream.rs index 4a5b1519..f4d6ab2e 100644 --- a/crates/ec-av1/src/stream.rs +++ b/crates/ec-av1/src/stream.rs @@ -2408,6 +2408,9 @@ mod tests { ); let mut child = Command::new(aomenc_path()) .args([ + // lane-defon r1: explicit on-value (aomenc keeps the FIRST + // occurrence, so overrides go before the base list). + "--loopfilter-control=1", "--codec=av1", "--passes=1", "--end-usage=q", @@ -3241,6 +3244,9 @@ mod tests { ); let mut child = Command::new(aomenc_path()) .args([ + // lane-defon r1: explicit on-value (aomenc keeps the FIRST + // occurrence, so overrides go before the base list). + "--loopfilter-control=1", "--codec=av1", "--passes=1", "--end-usage=q", @@ -3572,6 +3578,9 @@ mod tests { let mut child = Command::new(aomenc_path()) .args(depth_args) .args([ + // lane-defon r1: explicit on-value (aomenc keeps the FIRST + // occurrence, so overrides go before the base list). + "--enable-tx-size-search=1", "--codec=av1", "--passes=1", "--end-usage=q", @@ -4041,6 +4050,9 @@ mod tests { ); let mut child = Command::new(aomenc_path()) .args([ + // lane-defon r1: explicit on-value (aomenc keeps the FIRST + // occurrence, so overrides go before the base list). + "--enable-directional-intra=1", "--codec=av1", "--passes=1", "--end-usage=q", @@ -4152,6 +4164,7 @@ mod tests { /// level of the inter partition tree -- `min_part` is aomenc's /// `--min-partition-size`, and `hits`/`what` name the counter that proves /// the arm under test really fired. + #[track_caller] fn inter_sb_none_gate( name: &str, ten_bit: bool, @@ -4448,6 +4461,9 @@ mod tests { ); let mut child = Command::new(aomenc_path()) .args([ + // lane-defon r1: explicit on-value (aomenc keeps the FIRST + // occurrence, so overrides go before the base list). + "--loopfilter-control=1", "--codec=av1", "--passes=1", "--end-usage=q", @@ -6689,7 +6705,7 @@ mod tests { "--tune-content=default", "--enable-masked-comp=0", "--enable-interintra-comp=1", - "--enable-onesided-comp=0", + "--enable-onesided-comp=1", "--enable-interintra-wedge=0", "--enable-smooth-interintra=1", "--enable-rect-partitions=0", @@ -6802,9 +6818,18 @@ mod tests { "{NAME}: {matched} matches but zero interintra blocks fired -- the gate decodes \ these streams without ever taking interintra, so it proves nothing" ); + // lane-defon r1: `--enable-onesided-comp=1` is spelled on this + // recipe, so a UNIDIR_COMP_REFERENCE pair must actually have been + // read -- otherwise the on-value proves nothing. + assert!( + crate::decode::uni_comp_hits() > 0, + "{NAME}: {matched} matches but zero UNIDIR_COMP_REFERENCE pairs read -- \ + --enable-onesided-comp=1 never reached the uni_comp_ref alphabet" + ); eprintln!( - "{NAME}: {named_refusals} other-capability refusals, {matched} pixel-exact matches out of {n_attempts}, interintra_hits={}", - crate::decode::interintra_hits() + "{NAME}: {named_refusals} other-capability refusals, {matched} pixel-exact matches out of {n_attempts}, interintra_hits={} uni_comp_hits={}", + crate::decode::interintra_hits(), + crate::decode::uni_comp_hits() ); } @@ -8075,6 +8100,9 @@ mod tests { String::from_utf8_lossy(&y4m.stderr) ); let args: Vec<&str> = vec![ + // lane-defon r1: explicit on-value (aomenc keeps the FIRST + // occurrence, so overrides go before the base list). + "--enable-diff-wtd-comp=1", "--codec=av1", "--passes=1", "--end-usage=q", @@ -8230,6 +8258,13 @@ mod tests { "{NAME}: zero masked-compound blocks fired ({matched} matches, {named_refusals} \ other refusals out of {n_attempts}) -- gate proved nothing this run" ); + // lane-defon r1: `--enable-diff-wtd-comp=1` is now spelled on this + // recipe, so the DIFFWTD half of MASKED_COMPOUND_HITS must fire. + assert!( + crate::decode::diffwtd_hits() > 0, + "{NAME}: zero COMPOUND_DIFFWTD blends ({matched} matches, {named_refusals} \ + other refusals out of {n_attempts}) -- --enable-diff-wtd-comp=1 proved nothing" + ); // r3: wedge_hits() is soft-skipped, not hard-asserted -- the recipe // search (dist-wtd-comp=0 + diagonal mandelbrot content) is not // proven to fire wedge on every run; charter's fallback is to land diff --git a/lanes/defon-r1.report.md b/lanes/defon-r1.report.md new file mode 100644 index 00000000..14cd8f00 --- /dev/null +++ b/lanes/defon-r1.report.md @@ -0,0 +1,64 @@ +# lane-defon r1 — NEVER_ON holes his default-encoded films exercise + +Branch `lane-defon` off main 61c6a5b (no rebase needed, main unchanged during the round). +Premise re-measured with `cargo test -p ec-av1 --lib gate_coverage -- --nocapture` at 61c6a5b: +NEVER_ON_8BIT 6/10, NEVER_ON_10BIT 7/10 (lists identical to lanes/covbd2-r1.report.md). +`aomenc --help` (oracle build) confirms `--loopfilter-control` takes 0/1/2/3 and that +`1 = Enable loopfilter for all frames (default)`. + +## Tool -> gate -> counter -> result + +| tool (on-value spelled) | gate | counter hard-asserted | result | +|---|---|---|---| +| `--loopfilter-control=1` (8-bit) | `a_real_aomenc_intra_stream_with_deblocking_decodes_pixel_exact` | `decode::deblock_hits()` advanced (pre-existing assert) | PASS 1.10s | +| `--loopfilter-control=1` (8-bit) | `a_real_aomenc_inter_sequence_with_deblocking_decodes_pixel_exact` | `deblock_hits()` (pre-existing) | PASS 2.36s | +| `--loopfilter-control=1` (10-bit) | `a_real_aomenc_10bit_inter_sequence_decodes_pixel_exact` | `deblock_hits()` (pre-existing) | PASS 2.84s | +| `--enable-tx-size-search=1` (8-bit + 10-bit, one shared helper `tx_select_inter_gate`) | `a_real_aomenc_inter_sequence_with_tx_select_decodes_pixel_exact` and `..._10bit` | `txfm_split_hits()` per attempt (pre-existing) | PASS 2.14s / 1.79s | +| `--enable-directional-intra=1` (8-bit) | `a_real_aomenc_stream_with_directional_chroma_decodes_pixel_exact` | `directional_uv_hits()` (pre-existing) | PASS 5.69s | +| `--enable-diff-wtd-comp=1` (8-bit) | `a_real_aomenc_stream_with_masked_compound_decodes_pixel_exact` | NEW `decode::diffwtd_hits()` > 0 | PASS 344s, 80/80 pixel-exact, masked_compound_hits=7898 wedge_hits=4254 | +| `--enable-onesided-comp=1` (8-bit, flipped from `=0`) | `a_real_aomenc_stream_with_interintra_decodes_pixel_exact` | NEW `decode::uni_comp_hits()` > 0 | see suite totals below (first run aborted on an environmental `aomdec: PermissionDenied` while another lane rewrote `~/.cache/aom-oracle/build/aomdec` at 23:56) | + +## What changed +- `crates/ec-av1/src/decode.rs` — two new per-attempt counters: `UNI_COMP_HITS` incremented in the + `if unidir {` arm of the compound-reference reader (spec 5.11.25 `comp_reference_type == 0`), and + `DIFFWTD_HITS` incremented at both `mc::diffwtd_mask(...)` call sites (the blend, not the symbol + read that `MASKED_COMPOUND_HITS` already counts). +- `crates/ec-av1/src/stream.rs` — six explicit on-values inserted BEFORE `"--codec=av1"` in their + gate's arg list (aomenc keeps the FIRST occurrence of a repeated flag), one `=0 -> =1` flip on the + interintra gate, two new hard asserts (`diffwtd_hits() > 0`, `uni_comp_hits() > 0`), and + `#[track_caller]` on `inter_sb_none_gate` so its body stops gluing onto the directional-chroma + gate's chunk (gate_coverage splits on `"\n #["`, so an attribute-less helper mislabels the gate + above it 10-bit). +- `crates/ec-av1/src/gate_coverage.rs` — `covers_both_depths()`/`covers_depth()`: a helper + parameterised on `bit_depth` builds BOTH an 8-bit and a 10-bit stream from one recipe, so its flags + count at both depths; classifying it by the 10-bit strings inside its own conditional hid + `--enable-tx-size-search=1` from the 8-bit list. `NEVER_ON_8BIT` 6 -> 1 entry, `NEVER_ON_10BIT` + 7 -> 5 entries. + +## Coverage after (verbatim) +``` +NEVER_ON_8BIT (1 of 10, over 45 8BIT gates): + enable-fwd-kf (--enable-fwd-kf): off in 12, defaulted in 33, on in 0 +NEVER_ON_10BIT (5 of 10, over 15 10BIT gates): + enable-diff-wtd-comp (--enable-diff-wtd-comp): off in 1, defaulted in 14, on in 0 + enable-fwd-kf (--enable-fwd-kf): off in 3, defaulted in 12, on in 0 + enable-interintra-wedge (--enable-interintra-wedge): off in 5, defaulted in 10, on in 0 + enable-onesided-comp (--enable-onesided-comp): off in 5, defaulted in 10, on in 0 + multi-tile (--tile-columns,tile-rows): off in 0, defaulted in 15, on in 0 +``` +`cargo test -p ec-av1 --lib -- gate_coverage refusal_inventory` -> 12 passed, 0 failed. + +## Refusals lifted +None — no decode behaviour changed; this round only makes existing gates drive the tools explicitly +and proves they fired. + +## Residue +- deferred: `enable-fwd-kf` at both depths — needs `--fwd-kf-dist=N` on a lagged recipe AND a decoder + counter for a KEY frame with `show_frame == 0`; no such counter exists (`grep show_frame` + decode.rs finds no site). What unblocks it: adding that counter at the frame-header read plus one + lagged gate. +- deferred: `enable-diff-wtd-comp`, `enable-onesided-comp`, `enable-interintra-wedge` at 10 bits — + the three 10-bit compound gates pin all three off in their recipes, so closing them means either a + 10-bit sibling of the 8-bit masked-compound/interintra gates or flipping those pins and re-proving + the pixel compare. What unblocks it: one round with a 10-bit compound recipe. +- accepted: `multi-tile` at 10 bits (covbd2's finding, not in this charter).