diff --git a/crates/ec-av1/examples/decode_probe.rs b/crates/ec-av1/examples/decode_probe.rs index 95b81ba7..5f16d35e 100644 --- a/crates/ec-av1/examples/decode_probe.rs +++ b/crates/ec-av1/examples/decode_probe.rs @@ -47,6 +47,7 @@ fn main() { ec_av1::stream::rect64_corner_tu_hits(1) ); println!("leaf8_intrabc_hits: {}", ec_av1::stream::leaf8_intrabc_hits()); + println!("intrabc_hits: {}", ec_av1::stream::intrabc_hits()); let (rtu, rsplit, robmc) = ec_av1::stream::rect_inter_tu_counters(); println!("rect_inter: tu={rtu} txsplit={rsplit} obmc_leaf={robmc}"); println!("sub8_inter_split: groups={}", ec_av1::decode::sub8_inter_split_hits()); diff --git a/crates/ec-av1/src/decode.rs b/crates/ec-av1/src/decode.rs index 023dbbbe..8ba409de 100644 --- a/crates/ec-av1/src/decode.rs +++ b/crates/ec-av1/src/decode.rs @@ -3583,7 +3583,10 @@ thread_local! { /// [`decode_block`] off the call stack (same idiom as [`PALETTE_PRED`], /// which the alternative -- a tenth tuple member through every caller -- /// already avoids). Always `.take()`n by the block that reads it. - /// How many blocks decoded `use_intrabc == 1` -- the gate's hit counter. + /// How many blocks read `use_intrabc == 1` and took the DV path -- the + /// gate's hit counter. Bumped on the READ, before the rect-strip refusal + /// returns too, so it counts reads, not reconstructions (a refused block + /// is never reconstructed). static INTRABC_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; } // The `tx_type` the last plane-0 [`read_plane`] actually coded, kept so diff --git a/crates/ec-av1/src/gate_coverage.rs b/crates/ec-av1/src/gate_coverage.rs index c3421c0a..087cfb69 100644 --- a/crates/ec-av1/src/gate_coverage.rs +++ b/crates/ec-av1/src/gate_coverage.rs @@ -49,6 +49,13 @@ const NEVER_EXERCISED: &[(&str, &str)] = &[ // `a_real_aomenc_screen_key_frame_reads_use_intrabc_on_rect_strips` // spells `--enable-intrabc=1` and decodes three such 8-bit streams whole- // frame pixel-exact against ffmpeg, with the block counter asserted > 0. + // Re-verified 2026-09-17 (lane-av1-intrabc) at main f715d70c: 185 rect + // `use_intrabc` symbols read, and 5 blocks took the DV path -- 4 of them + // DECODED whole-frame pixel-exact across 4 arms (7 frames compared, 0 + // mismatches). The fifth is the testsrc2 rectangle-strip arm, which reads + // the symbol and then refuses by name (the `intrabc_hits` bump happens on + // the READ), so "5 blocks decoded" would overcount: 4 decoded + 1 refused, + // exactly the single `refused == 1` the gate asserts. ]; /// The `--enable-*` tools this decoder cares about, whether or not any gate @@ -204,11 +211,17 @@ const NEVER_EXERCISED_10BIT: &[(&str, &str)] = &[ // lane-cwarp's 10-bit comp // flip/identity/1D transform types are proven to reach a real 10-bit stream // this decoder reconstructs exactly (10 of its rect coefficient TUs carry a // 1D tx class). - // `enable-intrabc` LEFT this 10-bit list on 2026-09-02 (lane-kf900 r6): - // `a_real_aomenc_rect_strip_palette_decodes_pixel_exact`'s new - // `smptebars-screen-txs-cq40/cq55` arms spell `--enable-intrabc=1` and are - // decoded and pixel-compared at 10 bit as well as 8, so the tool reaches a - // real 10-bit stream this decoder reconstructs exactly. + // `enable-intrabc` LEFT this 10-bit list on 2026-09-02 (lane-kf900 r6). + // The entry it first rested on was a flag spelling -- the palette gate's + // `smptebars-screen-txs-cq40/cq55` arms pass `--enable-intrabc=1` -- and + // lane-av1-intrabc MEASURED that those arms decode ZERO intrabc blocks at + // both depths, so they retired the entry without a stream carrying the + // tool (class `tool-disabled-in-every-gate`, the same defect this list + // exists for). The closing evidence is now + // `an_sb128_screen_stream_with_intrabc_decodes_pixel_exact`: its sb128 + // screen recipes run at 10 bits and hard-assert a decoded intrabc block + // per depth (4-6 per arm), every frame pixel-compared against ffmpeg's own + // 10-bit decode. ("enable-rect-tx", "hole at both depths, see the 8-bit list"), ]; @@ -407,8 +420,16 @@ mod tests { /// that loops `for depth in [8usize, 10]` builds BOTH streams from one /// recipe, but its `yuv420p10le` arm made `is_ten_bit` classify it as /// 10-bit only, hiding `--enable-cfl-intra=1` from the 8-bit list. + /// lane-av1-intrabc r1: the shared recipe helper + /// `screen_intrabc_stream_at_depth` is parameterised on `depth` and sits in + /// the segment that opens at the PRECEDING gate's `#[test]`, so without + /// 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. fn covers_both_depths(body: &str) -> bool { - body.contains("if bit_depth == 10") || body.contains("for depth in [8usize, 10]") + body.contains("if bit_depth == 10") + || body.contains("if depth == 10") + || body.contains("for depth in [8usize, 10]") } /// 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 8ff94030..da227e8a 100644 --- a/crates/ec-av1/src/stream.rs +++ b/crates/ec-av1/src/stream.rs @@ -177,6 +177,16 @@ pub fn leaf8_intrabc_hits() -> usize { crate::decode::leaf8_intrabc_hits() } +/// Blocks whose `use_intrabc` symbol came out 1 and took the DV path, at ANY +/// shape -- the engagement counter the intrabc gates assert on. It counts +/// "read a `use_intrabc` DV", not "reconstructed": a block the rect-strip +/// reader REFUSES for an unported shape bumps it too (the symbol and the DV +/// are parsed before the refusal). [`leaf8_intrabc_hits`] is its 8x8-leaf +/// subset. +pub fn intrabc_hits() -> usize { + crate::decode::intrabc_hits() +} + /// lane-sb128c r8: the 128 root's INTRA (key-frame) rect arm -- (128x64 /// blocks, 64x128 blocks, blocks per resolved intra `tx_depth` 0/1/2). pub fn intra_sb128_counters() -> (usize, usize, [usize; 3]) { @@ -5968,13 +5978,32 @@ pub(crate) mod tests { square_only: bool, extra: &[&str], ) -> Vec { + screen_intrabc_stream_at_depth(src, cq, txs, tiled, square_only, 8, extra) + } + + /// [`screen_intrabc_stream_with`] at an explicit bit depth (8 or 10): the + /// lavfi source is rendered straight to that depth's yuv4mpegpipe pixel + /// format and aomenc is told to encode at the matching + /// `--bit-depth`/`--input-bit-depth`, so a 10-bit arm produces a genuine + /// high-bit-depth stream rather than an 8-bit one in disguise. + fn screen_intrabc_stream_at_depth( + src: &str, + cq: &str, + txs: &str, + tiled: bool, + square_only: bool, + depth: usize, + extra: &[&str], + ) -> Vec { + assert!(depth == 8 || depth == 10, "unsupported bit depth {depth}"); + let pix_fmt = if depth == 10 { "yuv420p10le" } else { "yuv420p" }; let mut ff = Command::new("ffmpeg"); ff.args(["-v", "error", "-f", "lavfi", "-i", src, "-t", "0.2"]); if tiled { ff.args(["-vf", "tile=2x2"]); } let out = ff - .args(["-pix_fmt", "yuv420p", "-strict", "-1", "-f", "yuv4mpegpipe", "-"]) + .args(["-pix_fmt", pix_fmt, "-strict", "-1", "-f", "yuv4mpegpipe", "-"]) .stdin(Stdio::null()) .stdout(Stdio::piped()) .stderr(Stdio::piped()) @@ -5983,10 +6012,9 @@ pub(crate) mod tests { assert!(out.status.success(), "ffmpeg failed for {src}"); let y4m = out.stdout; let mut child = Command::new(aomenc_path()) + .args(["--codec=av1"]) + .args([format!("--bit-depth={depth}"), format!("--input-bit-depth={depth}")]) .args([ - "--codec=av1", - "--bit-depth=8", - "--input-bit-depth=8", "--passes=1", "--end-usage=q", "--cpu-used=0", @@ -6079,6 +6107,17 @@ pub(crate) mod tests { /// [`crate::decode::read_intrabc_dv`] hardcoded 64. Every arm is compared /// to ffmpeg and the decoded-intrabc-block counter is asserted non-zero, /// so a stream that stopped using intrabc could not make this vacuous. + /// + /// lane-av1-intrabc (2026-09-17): the four recipes now run at 10 bits as + /// well, and both depths must SHOW the engagement -- `blocks_at_depth` + /// below hard-asserts a decoded intrabc block per depth. The 10-bit + /// coverage the guard records for `enable-intrabc` used to rest on a gate + /// that only SPELLED `--enable-intrabc=1`: measured (same round), all five + /// arms of `a_real_aomenc_rect_strip_palette_decodes_pixel_exact` decode + /// ZERO intrabc blocks at BOTH depths, so the spelling proved nothing and + /// the entry was one encoder-RD change away from being vacuous again + /// (class `tool-disabled-in-every-gate`). An arm here that stops engaging + /// intrabc now fails this gate instead of retiring the entry unproven. #[test] fn an_sb128_screen_stream_with_intrabc_decodes_pixel_exact() { const NAME: &str = "an_sb128_screen_stream_with_intrabc_decodes_pixel_exact"; @@ -6089,40 +6128,52 @@ pub(crate) mod tests { let (width, height) = (256usize, 192usize); let _guard = lock_gate_counters(); let (mut blocks_total, mut frames_compared) = (0usize, 0u32); - for txs in ["0", "1"] { - for cq in ["30", "45"] { - let arm = format!("sb128 txs={txs} cq={cq}"); - let stream = screen_intrabc_stream_with( - "smptebars=size=128x96:rate=25", - cq, - txs, - true, - true, - &["--sb-size=128"], - ); - let (sb128, intrabc_frames) = sb128_and_intrabc_frames(&stream); - assert!( - sb128 && intrabc_frames > 0, - "{NAME}: {arm} no longer codes sb128 + allow_intrabc" - ); - crate::decode::reset_intrabc_hits(); - let frames = decode_stream(&stream).unwrap_or_else(|e| panic!("{NAME}: {arm}: {e}")); - let blocks = crate::decode::intrabc_hits(); - blocks_total += blocks; - let theirs = ffmpeg_decode_sequence(&stream, width, height, frames.len()); - assert_eq!(frames.len(), theirs.len(), "{NAME}: {arm} frame count"); - for (i, (ours, ref_frame)) in frames.iter().zip(theirs.iter()).enumerate() { + let mut blocks_at_depth = [0usize; 2]; + for depth in [8usize, 10] { + for txs in ["0", "1"] { + for cq in ["30", "45"] { + let arm = format!("sb128 {depth}-bit txs={txs} cq={cq}"); + let stream = screen_intrabc_stream_at_depth( + "smptebars=size=128x96:rate=25", + cq, + txs, + true, + true, + depth, + &["--sb-size=128"], + ); + let (sb128, intrabc_frames) = sb128_and_intrabc_frames(&stream); assert!( - ours.y == ref_frame.y && ours.u == ref_frame.u && ours.v == ref_frame.v, - "{NAME}: {arm} frame {i} does not match ffmpeg" + sb128 && intrabc_frames > 0, + "{NAME}: {arm} no longer codes sb128 + allow_intrabc" + ); + crate::decode::reset_intrabc_hits(); + let frames = + decode_stream(&stream).unwrap_or_else(|e| panic!("{NAME}: {arm}: {e}")); + let blocks = crate::decode::intrabc_hits(); + blocks_total += blocks; + blocks_at_depth[usize::from(depth == 10)] += blocks; + let theirs = if depth == 10 { + ffmpeg_decode_sequence_10bit(&stream, width, height, frames.len()) + } else { + ffmpeg_decode_sequence(&stream, width, height, frames.len()) + }; + assert_eq!(frames.len(), theirs.len(), "{NAME}: {arm} frame count"); + for (i, (ours, ref_frame)) in frames.iter().zip(theirs.iter()).enumerate() { + assert!( + ours.y == ref_frame.y + && ours.u == ref_frame.u + && ours.v == ref_frame.v, + "{NAME}: {arm} frame {i} does not match ffmpeg" + ); + frames_compared += 1; + } + eprintln!( + "{NAME}: {arm} intrabc_frames={intrabc_frames} intrabc_blocks={blocks} \ + DECODED {} frame(s) exact", + frames.len() ); - frames_compared += 1; } - eprintln!( - "{NAME}: {arm} intrabc_frames={intrabc_frames} intrabc_blocks={blocks} \ - DECODED {} frame(s) exact", - frames.len() - ); } } assert!(frames_compared > 0, "{NAME}: no frame was compared"); @@ -6130,6 +6181,13 @@ pub(crate) mod tests { blocks_total > 0, "{NAME}: gate is vacuous -- no arm decoded a single intrabc block" ); + assert!( + blocks_at_depth[0] > 0 && blocks_at_depth[1] > 0, + "{NAME}: 8-bit={} 10-bit={} -- an arm at that depth no longer decodes an intrabc \ + block, so `enable-intrabc` coverage there would rest on the flag spelling alone", + blocks_at_depth[0], + blocks_at_depth[1] + ); } /// lane-t900 r33, CENSUS for "a sub-8x8 leaf that uses intrabc". diff --git a/lanes/av1-intrabc-r1.report.md b/lanes/av1-intrabc-r1.report.md new file mode 100644 index 00000000..5781fc4f --- /dev/null +++ b/lanes/av1-intrabc-r1.report.md @@ -0,0 +1,97 @@ +# lane-av1-intrabc r1 — the fifth gate-integrity entry closes with an engagement counter, not a flag + +Branch `lane-av1-intrabc`, base `f715d70c`. Closes the last clause of +`debt|gate-integrity|ec-av1: five aomenc coding tools …` (deleted from +`~/.omp/agent/debts/DEBTS-home-user-Documents-Code-Rust-edith_codecs.md`). + +## What the debt premise got wrong at HEAD + +`--enable-intrabc` is NOT off in all real-aomenc gates at `f715d70c`. lane-kf900 r6/r7 and +lane-t900 r31-r34 landed between 2026-09-02 and HEAD: + +- `stream::tests::a_real_aomenc_screen_key_frame_reads_use_intrabc_on_rect_strips` — + `--enable-intrabc=1`, assert `rect_intrabc_reads > 0 && intrabc_hits > 0 && leaf8_intrabc_hits > 0`, + one named refusal expected (rect-strip intrabc). +- `stream::tests::an_sb128_screen_stream_with_intrabc_decodes_pixel_exact` +- `stream::tests::an_intrabc_block_under_tx_mode_select_decodes_pixel_exact` +- `stream::tests::a_sub8_leaf_census_over_intrabc_screen_streams_measures_the_sub8_refusal` + and `an_intrabc_vartx_census_measures_the_mixed_leaf_refusal` (censuses). + +Re-run at HEAD (all pass, one command, `--nocapture`): + + cargo test -p ec-av1 --release --lib -- --nocapture --test-threads=1 intrabc + -> 7 passed; 0 failed; 1 ignored. `a_real_aomenc_screen_key_frame_reads_use_intrabc_on_rect_strips`: + 185 rect use_intrabc symbol(s) read, 5 intrabc block(s) decoded across 4 arm(s), + 1 refused by name, 7 frames compared, 3 out of scope (0 mismatched), 1 intrabc block at an 8x8 leaf. + +## The real hole this round found and closed: the 10-bit entry rested on a SPELLING + +`gate_coverage.rs`'s 10-bit `enable-intrabc` closure cited +`a_real_aomenc_rect_strip_palette_decodes_pixel_exact`'s `smptebars-screen-txs-cq40/cq55` arms, which +merely pass `--enable-intrabc=1`. Measured with a temporary per-arm delta print: those arms decode +**0** intrabc blocks at both depths (all 5 arms × 2 depths), i.e. the entry was retired by a flag on a +command line — the exact defect the guard exists for. + +Fix: `screen_intrabc_stream_at_depth` (depth-aware twin of `screen_intrabc_stream_with`) + +`an_sb128_screen_stream_with_intrabc_decodes_pixel_exact` now runs its four sb128 screen recipes at +8 AND 10 bits and hard-asserts a decoded intrabc block per depth (`blocks_at_depth[0] > 0 && +blocks_at_depth[1] > 0`), every frame pixel-compared against ffmpeg's own decode at that depth +(`ffmpeg_decode_sequence_10bit` at 10 bits). Observed: + + sb128 8-bit txs=0/1 × cq=30/45: intrabc_frames=1, intrabc_blocks=4/4/5/4, exact + sb128 10-bit txs=0/1 × cq=30/45: intrabc_frames=1, intrabc_blocks=4/4/6/5, exact + +Engagement is encoder-side too: libaom resets `allow_intrabc` when no block selected intrabc +(encodeframe.c:2335-2337), so a frame header that keeps `allow_intrabc=1` proves the encoder picked +it; the gate asserts `intrabc_frames > 0` off the parsed header as well. + +`gate_coverage.rs` comments updated: the 8-bit paragraph records the re-verified counts; the 10-bit +paragraph records that the palette-gate citation was a measured zero-engagement spelling and names +the new closing witness. Case closed in report. + +`decode::intrabc_hits()` is now exposed as `ec_av1::stream::intrabc_hits()` and printed by +`examples/decode_probe.rs`, so the standalone pair below prints the counter. + +## Standalone command pair (prints engagement + comparison) + +Fixture (outside git, `~/.cache/intrabc-fixture/`): + + ffmpeg -v error -f lavfi -i 'smptebars=size=128x96:rate=25' -t 0.2 -vf tile=2x2 \ + -pix_fmt yuv420p10le -strict -1 -f yuv4mpegpipe - \ + | ~/.cache/aom-oracle/build/aomenc --codec=av1 --bit-depth=10 --input-bit-depth=10 --passes=1 \ + --end-usage=q --cpu-used=0 --lag-in-frames=0 --kf-max-dist=1 --limit=1 --threads=1 \ + --tile-columns=0 --min-partition-size=8 --max-partition-size=32 --sb-size=64 \ + --tune-content=screen --enable-intrabc=1 --enable-palette=0 --cq-level=30 \ + --enable-tx-size-search=1 --enable-rect-partitions=0 --enable-1to4-partitions=0 --sb-size=128 \ + --obu -o sb128-10bit-cq30.obu - + +Engagement + result: + + EC_PROBE_HDR=1 cargo run --release --example decode_probe -- sb128-10bit-cq30.obu + -> HDR 0: type=Key … screen_tools=true intrabc=true … tx_mode=Select + OK: 1 frames decoded, 256x192 ; intrabc_hits: 6 + cargo run --release --example dump_yuv -- sb128-10bit-cq30.obu ours + ffmpeg -v error -i sb128-10bit-cq30.obu -pix_fmt yuv420p10le -f rawvideo ref.yuv + cmp ours.f0.yuv ref.yuv -> BYTE-EXACT-10BIT + sha256 de0d83756d22e422b19413e9e1c20325b9bd68fe2f27aae872da2d4736f6a007 (both files) + +The arbiter agrees, and the oracle's own decoder accepts the stream +(`aomdec --i420 --output-bit-depth=10 --md5`: md5 `f1b7222466d15d1dda3e25fdbd8577fe`). + +## Refusals — genuine capability gaps, all pinned + +- `intra block copy on a HORZ/VERT/1:4 rect intra strip (reconstruction is not ported at this shape)` — + the reader consumes the symbol and refuses by name; gate asserts exactly one such refusal + (`a_real_aomenc_screen_key_frame_reads_use_intrabc_on_rect_strips`, `refused == 1`). +- sub-8x8 leaf intrabc and intrabc var-tx mixed-leaf shapes have their own censuses that assert the + premise is reached before reading anything into the refusal firing. Current run: var-tx census + decoded 5 intrabc blocks through the var-tx tree, 0 mixed-leaf resolutions, 4 frames exact. + No bug localized; no arm with a decoded intrabc block mismatched ffmpeg (0 mismatches). + +## Gates run + + EC_AV1_REQUIRE_AOMENC=1 cargo test -p ec-av1 --release --lib -- --nocapture --test-threads=1 intrabc + -> 7 passed / 0 failed / 1 ignored + cargo test -p ec-av1 --release --lib -- --exact gate_coverage::tests::never_exercised_8bit_matches_the_gate_recipes gate_coverage::tests::never_exercised_10bit_matches_the_gate_recipes + -> ok (derived hole set unchanged: 8-bit 5 holes, 10-bit 2; `enable-intrabc` in neither) + cargo check -p ec-av1 --all-targets -> 0 warnings