forge
Explore
Log in

Don't you dare go Hollow

8x16/16x8 strips never read their use_filter_intra flag -- av1_filter_intra_allowed_bsize allows both, filter_intra_size_class_rect had no CDF row, so the symbol was silently skipped and the tile desynced on that block

Browse files at this commit

b2b0cafe557488ca04cc81475302c7f5bc8cb24fAhmet Kaan GümüşParent: 01c42f6
  • fix
    • 8x16/16x8 strips never read their use_filter_intra flag -- av1_filter_intra_allowed_bsize allows both, filter_intra_size_class_rect had no CDF row, so the symbol was silently skipped and the tile desynced on that block
    • adds default_filter_intra_cdfs rows 4/5 (12551/9394), a domain test over every allowed shape, a pinned real-aomenc fixture proving the read, and the pixel gate (8- and 10-bit) ignored with its measurement (2/200 seeds fire, both on skip=0 strips the coded-rect-strip-below-16x16 refusal still blocks)
Show full message
fix(av1): 8x16/16x8 strips never read their use_filter_intra flag -- av1_filter_intra_allowed_bsize allows both, filter_intra_size_class_rect had no CDF row, so the symbol was silently skipped and the tile desynced on that block; adds default_filter_intra_cdfs rows 4/5 (12551/9394), a domain test over every allowed shape, a pinned real-aomenc fixture proving the read, and the pixel gate (8- and 10-bit) ignored with its measurement (2/200 seeds fire, both on skip=0 strips the coded-rect-strip-below-16x16 refusal still blocks)
crates/ec-av1/fixtures/filter_intra_8x16_strip_seed49.obuadded+0 -0

Binary file changed

crates/ec-av1/src/cdf.rsmodified+9 -1
@@ -421,13 +421,21 @@ pub const CFL_SIGN: [u16; 9] = [1418, 2123, 13340, 18405, 26972, 28343, 32294, 3
421421 /// (12756/14301, `default_filter_intra_cdfs` index 8/7) -- the two rect
422422 /// strips `PARTITION_HORZ`/`PARTITION_VERT` decode, each with its own
423423 /// distinct default probability from every square class above.
424-pub const FILTER_INTRA: [[u16; 3]; 6] = [
424+/// `[6]`/`[7]` (lane-fistrip r1) add `BLOCK_8X16`/`BLOCK_16X8`'s rows
425+/// (12551/9394, `default_filter_intra_cdfs` index 4/5) -- the strips a
426+/// 16x16 `PARTITION_HORZ`/`PARTITION_VERT` splits into. Both are inside
427+/// `av1_filter_intra_allowed_bsize`'s <=32 bound, so aomenc writes a
428+/// `use_filter_intra` flag on every DC_PRED one of them; before this round
429+/// no class existed for them and the symbol was never read at all.
430+pub const FILTER_INTRA: [[u16; 3]; 8] = [
425431 [4621, 32768, 0],
426432 [7866, 32768, 0],
427433 [12408, 32768, 0],
428434 [22343, 32768, 0],
429435 [12756, 32768, 0],
430436 [14301, 32768, 0],
437+ [12551, 32768, 0],
438+ [9394, 32768, 0],
431439 ];
432440 /// `default_filter_intra_mode_cdf` (entropymode.c): which of the five
433441 /// `FILTER_INTRA_MODES` a `use_filter_intra` block picks.
crates/ec-av1/src/cdf_state.rsmodified+2 -2
@@ -457,9 +457,9 @@ pub(crate) struct Cdfs {
457457 /// [`Self::dv_joint`]'s per-component half.
458458 pub dv_comp: [MvComponentCdfs; 2],
459459 /// The `use_filter_intra` flag, indexed by block-size class (`[0]`=4x4,
460- /// `[1]`=8x8, `[2]`=16x16, `[3]`=32x32, `[4]`=32x16, `[5]`=16x32) --
460+ /// `[1]`=8x8, `[2]`=16x16, `[3]`=32x32, `[4]`=32x16, `[5]`=16x32, `[6]`=8x16, `[7]`=16x8) --
461461 /// see [`cdf::FILTER_INTRA`].
462- pub filter_intra: [[u16; 3]; 6],
462+ pub filter_intra: [[u16; 3]; 8],
463463 /// Which `FILTER_INTRA_MODES` entry a `use_filter_intra` block picks.
464464 pub filter_intra_mode: [u16; 6],
465465 /// `TxMode::Select`'s `tx_depth` flag at an 8x8 block, by `tx_size_context`
crates/ec-av1/src/decode.rsmodified+100 -3
@@ -869,6 +869,21 @@ pub(crate) fn filter_intra_rect_hits() -> usize {
869869 FILTER_INTRA_RECT_HITS.with(|c| c.get())
870870 }
871871
872+// As [`FILTER_INTRA_RECT_HITS`], counting only the strips BELOW 16x16
873+// (8x16/16x8 leaves of a 16x16 HORZ/VERT partition, lane-fistrip r1) -- the
874+// shapes whose `use_filter_intra` symbol had no CDF class before this round.
875+// A gate asserting the wider counter would be satisfied by a 32x16 strip and
876+// prove nothing about the new shapes.
877+thread_local! {
878+ static FILTER_INTRA_RECT_SUB16_HITS: std::cell::Cell<usize> =
879+ const { std::cell::Cell::new(0) };
880+}
881+
882+/// Current value of [`FILTER_INTRA_RECT_SUB16_HITS`].
883+pub(crate) fn filter_intra_rect_sub16_hits() -> usize {
884+ FILTER_INTRA_RECT_SUB16_HITS.with(|c| c.get())
885+}
886+
872887 // How many [`read_coeffs`] reads resolved a `tx_type` outside `TX_CLASS_2D`
873888 // (`V_DCT`/`H_DCT`, spec 5.11.39's `TxClass::Horiz`/`Vert`), across every
874889 // call on the current thread -- the same before/after counter pattern as
@@ -3477,6 +3492,13 @@ fn filter_intra_size_class_rect(bw: usize, bh: usize) -> Option<usize> {
34773492 match (bw, bh) {
34783493 (32, 16) => Some(4),
34793494 (16, 32) => Some(5),
3495+ // lane-fistrip r1: `av1_filter_intra_allowed_bsize` is
3496+ // `block_size_wide <= 32 && block_size_high <= 32`, which the 16x16
3497+ // level's own 8x16/16x8 strips satisfy -- returning `None` here did
3498+ // not refuse them, it silently SKIPPED a symbol aomenc writes
3499+ // (class `symbol-consumption-gap`).
3500+ (8, 16) => Some(6),
3501+ (16, 8) => Some(7),
34803502 _ if bw == bh => filter_intra_size_class(bw),
34813503 _ => None,
34823504 }
@@ -4657,9 +4679,12 @@ fn decode_leaf_rect(
46574679 leaf_mi.1,
46584680 )?;
46594681 if filter_intra.is_some() {
4660- return Err(unsupported(
4661- "filter intra on a HORZ/VERT strip (this decoder predicts square-only)",
4662- ));
4682+ // lane-fistrip r1: `predict_filter_intra` already walks its 4x2
4683+ // patches over a true `bw`x`bh` block (lane-rectsplit r1), so an
4684+ // 8x16/16x8 strip predicts through the same call `reconstruct_rect`
4685+ // below already makes; this refusal was square-only prose.
4686+ FILTER_INTRA_RECT_HITS.with(|c| c.set(c.get() + 1));
4687+ FILTER_INTRA_RECT_SUB16_HITS.with(|c| c.set(c.get() + 1));
46634688 }
46644689 let uv_predict_mode = if uv_mode == UV_CFL_PRED { DC_PRED } else { uv_mode };
46654690 let depth = if tx_select {
@@ -16288,6 +16313,78 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
1628816313
1628916314 #[cfg(test)]
1629016315 mod tests {
16316+
16317+ /// lane-fistrip r1 (class `enumerate-the-table-domain`): every block
16318+ /// shape this decoder can hand [`filter_intra_size_class_rect`], against
16319+ /// `av1_filter_intra_allowed_bsize` (`block_size_wide <= 32 &&
16320+ /// block_size_high <= 32`) and `default_filter_intra_cdfs`
16321+ /// (entropymode.c) row by row. A class that exists must carry ITS OWN
16322+ /// bsize's default probability -- a wrong row is a silently different
16323+ /// symbol, not a decode error. The shapes with no class are listed here
16324+ /// with their reason so the residue is pinned rather than implied.
16325+ #[test]
16326+ fn filter_intra_classes_carry_their_own_libaom_default_row() {
16327+ // `default_filter_intra_cdfs[bsize]`, BLOCK_SIZES_ALL order, as
16328+ // (width, height, default) for the shapes <= 32 on both axes.
16329+ let libaom: &[(usize, usize, u16)] = &[
16330+ (4, 4, 4621),
16331+ (4, 8, 6743),
16332+ (8, 4, 5893),
16333+ (8, 8, 7866),
16334+ (8, 16, 12551),
16335+ (16, 8, 9394),
16336+ (16, 16, 12408),
16337+ (16, 32, 14301),
16338+ (32, 16, 12756),
16339+ (32, 32, 22343),
16340+ (4, 16, 16384),
16341+ (16, 4, 16384),
16342+ (8, 32, 16384),
16343+ (32, 8, 16384),
16344+ ];
16345+ // The shapes this decoder's partition tree can actually reach today
16346+ // (squares 4..32 plus the 16x16- and 32x32-level HORZ/VERT strips).
16347+ let reachable = [
16348+ (4, 4),
16349+ (8, 8),
16350+ (16, 16),
16351+ (32, 32),
16352+ (32, 16),
16353+ (16, 32),
16354+ (8, 16),
16355+ (16, 8),
16356+ ];
16357+ for &(bw, bh, default) in libaom {
16358+ let class = filter_intra_size_class_rect(bw, bh);
16359+ if reachable.contains(&(bw, bh)) {
16360+ let class = class.unwrap_or_else(|| {
16361+ panic!("{bw}x{bh} is inside av1_filter_intra_allowed_bsize and reachable, \
16362+ but has no CDF class -- its use_filter_intra symbol is never read")
16363+ });
16364+ assert_eq!(
16365+ crate::cdf::FILTER_INTRA[class][0],
16366+ default,
16367+ "{bw}x{bh} (class {class}) must carry default_filter_intra_cdfs' own row"
16368+ );
16369+ } else {
16370+ // 4x8/8x4/4x16/16x4/8x32/32x8: sub-8x8 leaves and the 1:4
16371+ // strips, neither of which this decoder codes yet (their
16372+ // partition levels refuse by name first), so no class exists.
16373+ assert!(
16374+ class.is_none(),
16375+ "{bw}x{bh} gained a class without a decode path to use it"
16376+ );
16377+ }
16378+ }
16379+ // Past the bound on either axis: no symbol at all (spec
16380+ // `filter_intra_mode_info` never reads one).
16381+ for (bw, bh) in [(64, 64), (64, 32), (32, 64)] {
16382+ assert!(
16383+ filter_intra_size_class_rect(bw, bh).is_none(),
16384+ "{bw}x{bh} is past av1_filter_intra_allowed_bsize's <=32 bound"
16385+ );
16386+ }
16387+ }
1629116388 use super::*;
1629216389
1629316390 /// lane-rectsplit r2: `av1_nz_map_ctx_offset` is packed COLUMN-major, so
crates/ec-av1/src/refusal_inventory.rsmodified+0 -1
@@ -73,7 +73,6 @@ const REFUSALS: &[&str] = &[
7373 "an inter partition below 16x16 other than SPLIT (16x8/8x16 rect inter leaves are not coded yet)",
7474 "an intra mode this decoder does not code (round 2)",
7575 "an intra-coded HORZ/VERT strip needs rectangular intra prediction this decoder does not code yet",
76- "filter intra on a HORZ/VERT strip (this decoder predicts square-only)",
7776 "warp prediction with a scaled reference (superres, unimplemented)",
7877 "an 8x8 partition leaf under a scaled reference (superres, unimplemented)",
7978 ];
crates/ec-av1/src/stream.rsmodified+298 -1
@@ -8437,7 +8437,16 @@ mod tests {
84378437 let mut other_refusals = Vec::new();
84388438 for attempt in 0..n_attempts {
84398439 let seed = 42 + attempt;
8440- let source = gradients_source(seed, width, height, "duration=0.04:rate=25");
8440+ // Diagnosis knob: which content makes RD pick an 8x16/16x8 strip
8441+ // AND filter intra on it is a search (see lanes/fistrip-r1.report.md).
8442+ let source = match std::env::var("EC_FISTRIP_SRC").unwrap_or_default().as_str() {
8443+ "bars" => format!("smptebars=size={width}x{height}:duration=0.04:rate=25"),
8444+ "src2" => format!("testsrc2=size={width}x{height}:duration=0.04:rate=25"),
8445+ "noise" => format!(
8446+ "nullsrc=size={width}x{height}:duration=0.04:rate=25,geq=random(1)*255:128:128"
8447+ ),
8448+ _ => gradients_source(seed, width, height, "duration=0.04:rate=25"),
8449+ };
84418450 let y4m = Command::new("ffmpeg")
84428451 .args(["-v", "error", "-f", "lavfi", "-i"])
84438452 .arg(&source)
@@ -12769,6 +12778,294 @@ mod tests {
1276912778 );
1277012779 }
1277112780
12781+ /// lane-fistrip r1, the 10-bit arm of the strip gate (his films are
12782+ /// yuv420p10le). Same ceiling as its 8-bit twin -- kept `#[ignore]`d
12783+ /// with the measurement rather than weakened: MEASURED over seeds
12784+ /// 42..61 the 8x16/16x8 strips aomenc writes filter intra on are
12785+ /// `skip=0`, which `decode_leaf_rect` refuses, so
12786+ /// `filter_intra_rect_sub16_hits` never reaches a pixel compare.
12787+ #[ignore = "blocked on the coded (non-skip) rect strip below 16x16 refusal -- see doc"]
12788+ #[test]
12789+ fn a_real_aomenc_10bit_filter_intra_on_a_sub16_strip_decodes_pixel_exact() {
12790+ const NAME: &str = "a_real_aomenc_10bit_filter_intra_on_a_sub16_strip_decodes_pixel_exact";
12791+ let _gate_lock = lock_gate_counters();
12792+ if !have_ffmpeg() {
12793+ eprintln!("SKIP {NAME}: no ffmpeg");
12794+ return;
12795+ }
12796+ if !have_aomenc() {
12797+ eprintln!("SKIP {NAME}: no aomenc at {}", aomenc_path().display());
12798+ return;
12799+ }
12800+ let seeds: Vec<u32> = (42..62).collect();
12801+ ten_bit_tool_gate(
12802+ NAME,
12803+ 192,
12804+ 128,
12805+ 1,
12806+ &[
12807+ "--limit=1",
12808+ "--cq-level=25",
12809+ "--cpu-used=0",
12810+ "--threads=1",
12811+ "--row-mt=0",
12812+ "--sb-size=64",
12813+ "--enable-rect-partitions=1",
12814+ "--enable-ab-partitions=0",
12815+ "--enable-1to4-partitions=0",
12816+ "--min-partition-size=8",
12817+ "--max-partition-size=32",
12818+ "--enable-restoration=0",
12819+ "--enable-palette=0",
12820+ "--deltaq-mode=0",
12821+ "--enable-filter-intra=1",
12822+ "--enable-cfl-intra=0",
12823+ "--enable-intrabc=0",
12824+ ],
12825+ &seeds,
12826+ &[(
12827+ "filter_intra_rect_sub16_hits",
12828+ crate::decode::filter_intra_rect_sub16_hits as fn() -> usize,
12829+ )],
12830+ );
12831+ }
12832+
12833+ /// lane-fistrip r1, the pinned half of this lane's proof: one real
12834+ /// `aomenc` stream (recipe below, byte-reproducible -- md5
12835+ /// ac3a64773e5454ee9b5d8650507063cd, hashed twice) whose key frame
12836+ /// carries four `BLOCK_16X8` DC_PRED leaves, one of which sets
12837+ /// `use_filter_intra`. `av1_filter_intra_allowed_bsize` allows 16x8, so
12838+ /// aomenc writes that flag; before this round `filter_intra_size_class_rect`
12839+ /// had no row for the shape, the symbol was never read, and the tile
12840+ /// desynced ON THAT BLOCK -- observable as a DIFFERENT named refusal
12841+ /// ("a HORZ/VERT intra strip below 16x16 with a split transform", a
12842+ /// `tx_depth` read out of a desynced stream) instead of this one.
12843+ ///
12844+ /// The stream cannot be pixel-compared yet: the 16x8 strip that carries
12845+ /// the flag is `skip=0`, and a coded rect strip below 16x16 has no
12846+ /// residual path here (its own refusal, another lane's ceiling). What
12847+ /// this test pins is the SYMBOL: the flag is read, the counter fires
12848+ /// once, and the decode stops at the coded-strip ceiling rather than
12849+ /// wandering off a desynced stream.
12850+ ///
12851+ /// Fixture recipe (`crates/ec-av1/fixtures/filter_intra_8x16_strip_seed49.obu`):
12852+ /// `ffmpeg -f lavfi -i gradients=size=192x128:c0=0x986ae1:c1=0xd3e49a:
12853+ /// c2=0x0b1e53:c3=0x42980c:seed=49:duration=0.04:rate=25 -pix_fmt yuv420p`
12854+ /// into `aomenc --codec=av1 --passes=1 --end-usage=q --cq-level=25
12855+ /// --cpu-used=0 --threads=1 --row-mt=0 --sb-size=64
12856+ /// --enable-rect-partitions=1 --enable-ab-partitions=0
12857+ /// --enable-1to4-partitions=0 --min-partition-size=8
12858+ /// --max-partition-size=32 --enable-restoration=0 --enable-palette=0
12859+ /// --deltaq-mode=0 --enable-filter-intra=1 --enable-cfl-intra=0
12860+ /// --enable-intrabc=0 --obu`.
12861+ #[test]
12862+ fn a_pinned_aomenc_16x8_strip_reads_its_use_filter_intra_flag() {
12863+ const NAME: &str = "a_pinned_aomenc_16x8_strip_reads_its_use_filter_intra_flag";
12864+ let _gate_lock = lock_gate_counters();
12865+ let path = std::path::Path::new(env!("CARGO_MANIFEST_DIR"))
12866+ .join("fixtures/filter_intra_8x16_strip_seed49.obu");
12867+ let stream = std::fs::read(&path)
12868+ .unwrap_or_else(|e| panic!("{NAME}: reading {}: {e}", path.display()));
12869+ let before = crate::decode::filter_intra_rect_sub16_hits();
12870+ let err = decode_stream(&stream).expect_err(
12871+ "{NAME}: this stream's 16x8 filter-intra strip is skip=0, which this decoder \
12872+ still refuses -- a clean decode means the coded-strip ceiling moved and this \
12873+ test should become a pixel compare",
12874+ );
12875+ let hits = crate::decode::filter_intra_rect_sub16_hits() - before;
12876+ assert_eq!(
12877+ hits, 1,
12878+ "{NAME}: expected exactly one 16x8 strip to read use_filter_intra=1 (aomdec's own \
12879+ EC_TRACE_MODE shows four BLOCK_16X8 DC_PRED leaves here); got {hits}"
12880+ );
12881+ let msg = err.to_string();
12882+ assert!(
12883+ msg.contains("a coded (non-skip) HORZ/VERT rect strip below 16x16"),
12884+ "{NAME}: decode must reach the coded-strip ceiling ON that block, not wander off a \
12885+ desynced stream; got: {msg}"
12886+ );
12887+ }
12888+
12889+ /// lane-fistrip r1: the filter-intra strip gate above, one partition
12890+ /// level DOWN (`--min-partition-size=8`, so a 16x16 HORZ/VERT splits
12891+ /// into 8x16/16x8 leaves). `av1_filter_intra_allowed_bsize` is
12892+ /// `wide <= 32 && high <= 32`, which both of those satisfy, so aomenc
12893+ /// writes a `use_filter_intra` flag on every DC_PRED one of them --
12894+ /// `filter_intra_size_class_rect` had no row for either shape and
12895+ /// [`crate::decode::read_intra_mode_rect`] therefore never READ that
12896+ /// symbol (class `symbol-consumption-gap`, a silent desync rather than
12897+ /// a refusal). Hard-asserts
12898+ /// [`crate::decode::filter_intra_rect_sub16_hits`], not the wider
12899+ /// `filter_intra_rect_hits`: a 32x16 strip firing filter intra would
12900+ /// satisfy that one and prove nothing about the new shapes.
12901+ /// MEASURED THIS ROUND (lane-fistrip r1), which is why it is `#[ignore]`d
12902+ /// rather than green: over 200 seeds at cq 25 aomenc put filter intra on
12903+ /// an 8x16/16x8 strip TWICE, and both times that strip was `skip=0`, so
12904+ /// the attempt refused at the coded-rect-strip-below-16x16 ceiling before
12905+ /// any pixel compare (177 pixel-exact matches, 23 refusals, compared
12906+ /// sub16 delta 0, all-attempt delta 2). Un-ignore this the round that
12907+ /// ceiling lifts; the symbol itself is pinned by
12908+ /// [`a_pinned_aomenc_16x8_strip_reads_its_use_filter_intra_flag`].
12909+ #[ignore = "blocked on the coded (non-skip) rect strip below 16x16 refusal -- see doc"]
12910+ #[test]
12911+ fn a_real_aomenc_stream_with_filter_intra_on_a_sub16_horz_vert_strip_decodes_pixel_exact() {
12912+ const NAME: &str =
12913+ "a_real_aomenc_stream_with_filter_intra_on_a_sub16_horz_vert_strip_decodes_pixel_exact";
12914+ let _gate_lock = lock_gate_counters();
12915+ if !have_ffmpeg() {
12916+ eprintln!("SKIP {NAME}: no ffmpeg");
12917+ return;
12918+ }
12919+ if !have_aomenc() {
12920+ eprintln!("SKIP {NAME}: no aomenc at {}", aomenc_path().display());
12921+ return;
12922+ }
12923+ let (width, height) = (192usize, 128usize);
12924+ let mut named_refusals = 0u32;
12925+ let mut matched = 0u32;
12926+ let mut compared_hits = 0usize;
12927+ let n_attempts: u32 = std::env::var("EC_FISTRIP_GATE_ATTEMPTS")
12928+ .ok()
12929+ .and_then(|s| s.parse().ok())
12930+ .unwrap_or(40);
12931+ let cq = format!(
12932+ "--cq-level={}",
12933+ std::env::var("EC_FISTRIP_CQ").unwrap_or_else(|_| "25".into())
12934+ );
12935+ // Diagnosis: the counter over EVERY attempt, refused ones included --
12936+ // a filter-intra 8x16 strip inside an attempt that later refused
12937+ // (non-skip, split transform) fires this but never reaches
12938+ // `compared_hits`, and the two numbers differing is what says the
12939+ // recipe reaches the feature but this decoder's other ceilings hide
12940+ // it.
12941+ let all_before = crate::decode::filter_intra_rect_sub16_hits();
12942+ for attempt in 0..n_attempts {
12943+ let seed = 42 + attempt;
12944+ let source = gradients_source(seed, width, height, "duration=0.04:rate=25");
12945+ let y4m = Command::new("ffmpeg")
12946+ .args([
12947+ "-v", "error", "-f", "lavfi", "-i", &source, "-pix_fmt", "yuv420p", "-f",
12948+ "yuv4mpegpipe", "-",
12949+ ])
12950+ .stdin(Stdio::null())
12951+ .stdout(Stdio::piped())
12952+ .stderr(Stdio::piped())
12953+ .output()
12954+ .expect("ffmpeg failed to run");
12955+ assert!(
12956+ y4m.status.success(),
12957+ "ffmpeg fixture: {}",
12958+ String::from_utf8_lossy(&y4m.stderr)
12959+ );
12960+ let args: Vec<&str> = vec![
12961+ "--codec=av1",
12962+ "--passes=1",
12963+ "--end-usage=q",
12964+ &cq,
12965+ "--cpu-used=0",
12966+ "--threads=1",
12967+ "--row-mt=0",
12968+ "--sb-size=64",
12969+ "--enable-rect-partitions=1",
12970+ "--enable-ab-partitions=0",
12971+ "--enable-1to4-partitions=0",
12972+ // The point of this gate: one level below the 32x16/16x32
12973+ // strips the sibling gate covers.
12974+ "--min-partition-size=8",
12975+ "--max-partition-size=32",
12976+ "--enable-restoration=0",
12977+ "--enable-palette=0",
12978+ "--deltaq-mode=0",
12979+ "--enable-filter-intra=1",
12980+ "--enable-cfl-intra=0",
12981+ "--enable-intrabc=0",
12982+ "--obu",
12983+ "-o",
12984+ "-",
12985+ "-",
12986+ ];
12987+ // Diagnosis knob only (default: every intra mode on) -- the same
12988+ // subset search the 32x16/16x32 sibling gate carries.
12989+ let mut args = args;
12990+ let off = std::env::var("EC_FISTRIP_OFF").unwrap_or_default();
12991+ for tool in off.split(',').filter(|t| !t.is_empty()) {
12992+ args.push(match tool {
12993+ "smooth" => "--enable-smooth-intra=0",
12994+ "paeth" => "--enable-paeth-intra=0",
12995+ "dir" => "--enable-directional-intra=0",
12996+ "angle" => "--enable-angle-delta=0",
12997+ other => panic!("unknown EC_FISTRIP_OFF entry {other}"),
12998+ });
12999+ }
13000+ let mut child = Command::new(aomenc_path())
13001+ .args(&args)
13002+ .stdin(Stdio::piped())
13003+ .stdout(Stdio::piped())
13004+ .stderr(Stdio::piped())
13005+ .spawn()
13006+ .expect("aomenc failed to start");
13007+ child
13008+ .stdin
13009+ .take()
13010+ .expect("aomenc stdin")
13011+ .write_all(&y4m.stdout)
13012+ .expect("writing y4m to aomenc");
13013+ let out = child.wait_with_output().expect("aomenc failed to run");
13014+ assert!(
13015+ out.status.success(),
13016+ "aomenc refused the fixture: {}",
13017+ String::from_utf8_lossy(&out.stderr)
13018+ );
13019+ let stream = out.stdout;
13020+ assert!(!stream.is_empty(), "{NAME}: aomenc wrote an empty stream (seed {seed})");
13021+ let attempt_before = crate::decode::filter_intra_rect_sub16_hits();
13022+ let frames = match decode_stream(&stream) {
13023+ Err(e) => {
13024+ let msg = e.to_string();
13025+ assert!(
13026+ msg.contains("unsupported"),
13027+ "{NAME} failed outright, not a named refusal (seed {seed}): {msg}"
13028+ );
13029+ // Diagnosis: a refused attempt that DID fire the feature
13030+ // says which other ceiling of this decoder hides it.
13031+ eprintln!(
13032+ "{NAME}: seed {seed} refused with sub16 filter-intra delta {}: {msg}",
13033+ crate::decode::filter_intra_rect_sub16_hits() - attempt_before
13034+ );
13035+ named_refusals += 1;
13036+ continue;
13037+ }
13038+ Ok(frames) => frames,
13039+ };
13040+ let ffmpeg_frames = ffmpeg_decode_sequence(&stream, width, height, 1);
13041+ assert_eq!(frames.len(), 1, "{NAME}: expected one frame (seed {seed})");
13042+ assert_eq!(frames[0].y, ffmpeg_frames[0].y, "{NAME}: luma vs ffmpeg (seed {seed})");
13043+ assert_eq!(frames[0].u, ffmpeg_frames[0].u, "{NAME}: U vs ffmpeg (seed {seed})");
13044+ assert_eq!(frames[0].v, ffmpeg_frames[0].v, "{NAME}: V vs ffmpeg (seed {seed})");
13045+ compared_hits += crate::decode::filter_intra_rect_sub16_hits() - attempt_before;
13046+ matched += 1;
13047+ }
13048+ eprintln!(
13049+ "{NAME}: filter_intra_rect_sub16_hits over ALL attempts (refused included) = {}",
13050+ crate::decode::filter_intra_rect_sub16_hits() - all_before
13051+ );
13052+ assert!(
13053+ matched > 0,
13054+ "{NAME}: every attempt refused ({named_refusals} named refusals) -- gate decoded nothing"
13055+ );
13056+ assert!(
13057+ compared_hits > 0,
13058+ "{NAME}: no 8x16/16x8 strip used filter intra ({matched} pixel-exact matches, \
13059+ {named_refusals} refusals out of {n_attempts}) -- gate proved nothing this run"
13060+ );
13061+ eprintln!(
13062+ "{NAME}: {matched} pixel-exact matches, {named_refusals} named refusals, \
13063+ filter_intra_rect_sub16_hits delta={compared_hits} (all attempts including \
13064+ refused: {}) out of {n_attempts} attempts",
13065+ crate::decode::filter_intra_rect_sub16_hits() - all_before
13066+ );
13067+ }
13068+
1277213069 /// lane-rectsplit r1 gate (b): [`a_real_aomenc_stream_with_a_superblock_level_horz_vert_partition_decodes_pixel_exact`]'s
1277313070 /// own recipe (`--sb-size=64`, `--min/max-partition-size=32/64`, so every
1277413071 /// SB-level decision is genuinely NONE/SPLIT/HORZ/VERT) with its
lanes/fistrip-r1.report.mdadded+128 -0
@@ -0,0 +1,128 @@
1+# lane-fistrip r1 — filter intra on a rect strip
2+
3+Branch `lane-fistrip` off main `df5d630`. Worktree
4+`/home/user/Documents/Code/Rust/edith_codecs-fistrip`,
5+`CARGO_TARGET_DIR=$HOME/.cache/cargo-target-fistrip`.
6+
7+## Charter premise: stale, corrected by measurement
8+
9+The charter said `predict_filter_intra` is square-only. It is not: lane-rectsplit r1
10+already gave it `bw`x`bh` (`crates/ec-av1/src/intra.rs:773`), and 32x16/16x32 strips
11+already predict filter intra with a real-aomenc gate
12+(`a_real_aomenc_stream_with_filter_intra_on_a_horz_vert_strip_decodes_pixel_exact`).
13+
14+The real defect one level down was a **symbol-consumption gap**, not a prediction gap:
15+`filter_intra_size_class_rect` (`decode.rs:3491`) returned `None` for 8x16/16x8, so
16+`read_intra_mode_rect` never read the `use_filter_intra` flag that
17+`av1_filter_intra_allowed_bsize` (`wide <= 32 && high <= 32`, oracle
18+`av1/common/reconintra.h`) makes aomenc write on every DC_PRED 8x16/16x8 leaf. The
19+`decode_leaf_rect` refusal "filter intra on a HORZ/VERT strip (this decoder predicts
20+square-only)" (old `decode.rs:4661`) was DEAD CODE behind that `None` — it never fired;
21+the tile desynced silently instead.
22+
23+Film stops measured on main `df5d630` (release `decode_probe`), BEFORE any change:
24+- `hghead.obu` (ReelB 0.4 s head): `a partition below 8x8 (this decoder codes no
25+ leaf smaller than 8x8)` — earlier than filter intra, as the charter suspected, so the
26+ film is not this lane's gate.
27+- `reelb5.obu`: `a superblock-level HORZ/VERT strip with a split transform (per-unit rect
28+ prediction is not ported)`.
29+
30+## Changed
31+
32+- `crates/ec-av1/src/cdf.rs:424` — `FILTER_INTRA` grows to 8 rows: `[6]`=8x16 (12551),
33+ `[7]`=16x8 (9394), `default_filter_intra_cdfs` index 4/5 (oracle
34+ `av1/common/entropymode.c:821`).
35+- `crates/ec-av1/src/cdf_state.rs:462` — the field's type/doc follow.
36+- `crates/ec-av1/src/decode.rs:3491` — `filter_intra_size_class_rect` maps
37+ `(8,16)`/`(16,8)` to those rows, so the symbol is READ where aomenc writes it.
38+- `crates/ec-av1/src/decode.rs` (`decode_leaf_rect`) — the dead square-only refusal
39+ replaced by the counters; the strip predicts through the `reconstruct_rect` call that
40+ was already there.
41+- `crates/ec-av1/src/decode.rs` — new `FILTER_INTRA_RECT_SUB16_HITS` /
42+ `filter_intra_rect_sub16_hits()`: a gate asserting the wider `filter_intra_rect_hits`
43+ would be satisfied by a 32x16 strip and prove nothing about the new shapes.
44+- `crates/ec-av1/src/refusal_inventory.rs` — the square-only line removed.
45+- `crates/ec-av1/src/decode.rs` tests — `filter_intra_classes_carry_their_own_libaom_default_row`
46+ enumerates every shape inside `av1_filter_intra_allowed_bsize` against
47+ `default_filter_intra_cdfs` row by row and pins the shapes still without a class
48+ (4x8/8x4/4x16/16x4/8x32/32x8 — their partition levels refuse first).
49+- `crates/ec-av1/src/stream.rs` — `a_pinned_aomenc_16x8_strip_reads_its_use_filter_intra_flag`
50+ (green) plus the pixel gate
51+ `a_real_aomenc_stream_with_filter_intra_on_a_sub16_horz_vert_strip_decodes_pixel_exact`
52+ (`#[ignore]`d with its measurement, see below).
53+- `crates/ec-av1/fixtures/filter_intra_8x16_strip_seed49.obu` — the pinned stream
54+ (md5 `ac3a64773e5454ee9b5d8650507063cd`, hashed twice from the same recipe; `.gitignore`
55+ ignores `fixtures`, so it is committed with `git add -f`).
56+
57+## Gate status — honest
58+
59+The charter's gate (`..._on_a_rect_strip_decodes_pixel_exact`) is written and **cannot be
60+green on this tree**, so it ships `#[ignore]`d carrying its measurement rather than
61+weakened: over **200 aomenc streams** (seeds 42..241, cq 25, `--min-partition-size=8
62+--max-partition-size=32 --enable-filter-intra=1`) aomenc put filter intra on an 8x16/16x8
63+strip exactly **twice**, and **both** strips were `skip=0`, which
64+`decode_leaf_rect` still refuses ("a coded (non-skip) HORZ/VERT rect strip below 16x16").
65+Sweeps that found nothing better: cq {15,20,25,30,34,40,45,55}; content
66+{gradients, testsrc2, smptebars-style, geq noise}; intra-tool subsets
67+{none, smooth+paeth off, smooth+paeth+dir+angle off} — the last kills filter intra
68+entirely. Flag-arrival note (coordinator correction, aomenc keeps the LAST repeated
69+`--enable-*`): this gate spells every flag once and appends the `EC_FISTRIP_OFF`
70+diagnosis overrides AFTER the base recipe, and arrival of `--enable-filter-intra=1` is
71+proven decoder-side by the counters, not by the command line.
72+
73+10-bit arm (`a_real_aomenc_10bit_filter_intra_on_a_sub16_strip_decodes_pixel_exact`,
74+`ten_bit_tool_gate`, seeds 42..61, same recipe): **16/20 attempts decode pixel-exact at
75+10 bits** with the new CDF rows in place (no regression), and the same seed 49 refuses at
76+the coded-strip ceiling -- `filter_intra_rect_sub16_hits` never reaches a compare, so this
77+arm is `#[ignore]`d with its measurement too.
78+
79+What IS proven, green, and pinned: the symbol read. On the pinned stream aomdec's own
80+`EC_TRACE_MODE` shows four `BLOCK_16X8` (`bsize=5`) DC_PRED leaves; our decoder now reads
81+`use_filter_intra` on them, fires the counter once, and stops at the coded-strip ceiling
82+ON that block. Before the fix the same stream refused with a DIFFERENT string — "a
83+HORZ/VERT intra strip below 16x16 with a split transform" — a `tx_depth` read out of an
84+already-desynced stream, which is the desync this round removes.
85+
86+EVIDENCE: `crates/ec-av1/fixtures/filter_intra_8x16_strip_seed49.obu` | pre-fix release
87+`decode_probe` on main df5d630 vs post-fix `cargo test -p ec-av1 --lib
88+a_pinned_aomenc_16x8_strip_reads_its_use_filter_intra_flag` | refusal string moves
89+"split transform" -> "coded (non-skip) rect strip below 16x16",
90+`filter_intra_rect_sub16_hits` delta 0 -> 1
91+EVIDENCE: oracle `EC_TRACE_MODE=1 aomdec` on that fixture | grep `bsize=` | 4x BLOCK_16X8
92+DC_PRED leaves (`skip=0`), 6x 16x16, 4x 32x16-class, 20x 32x32
93+
94+## Residue
95+
96+- deferred: pixel-exact gate for filter intra on 8x16/16x8 — blocked on the "coded
97+ (non-skip) HORZ/VERT rect strip below 16x16" refusal (needs TX_16X8/TX_8X16 luma plus
98+ 8x4/4x8 chroma coefficient tables) — un-ignore the gate the round that lands.
99+- deferred: the 10-bit pixel arm rides the same ceiling as the 8-bit one.
100+- deferred: 8x32/32x8 (HORZ_4/VERT_4) and 4x8/8x4 (sub-8x8) filter-intra classes — their
101+ partition levels refuse before the mode read; the domain test pins them as absent.
102+- accepted: the capability claim "filter intra on a superblock-level HORZ/VERT strip
103+ (never expected -- av1_filter_intra_allowed_bsize caps at 32x32)" stays; 64x32/32x64
104+ are past the <=32 bound on one axis, verified in the same domain test.
105+
106+## Film probes after the fix (release `decode_probe`, this branch)
107+
108+- `hghead.obu`: `a partition below 8x8 (this decoder codes no leaf smaller than 8x8)` (unchanged)
109+- `reelb5.obu`: `a superblock-level HORZ/VERT strip with a split transform (per-unit rect
110+ prediction is not ported)` (unchanged)
111+
112+Both films stop before any 8x16/16x8 filter-intra strip, so this lane moves neither
113+frontier; it removes a silent desync that would have bitten once those two lift.
114+
115+## Suite totals
116+
117+`EC_AV1_REQUIRE_AOMENC=1 cargo test -p ec-av1 --lib` (log `$HOME/.cache/fistrip-suite.log`,
118+826 s): **300 passed, 1 failed, 29 ignored**.
119+
120+The one failure is PRE-EXISTING on main `df5d630` and not this lane's:
121+`decode::tests::nz_map_ctx_offset_tables_match_the_rect_rule` — "32x64 nz_map offset at
122+display (row 0, col 2): left 6, right 11", the known rectsplit-r4 `table[col][row]` vs
123+`[row][col]` convention clash already in the ledger. This lane touched neither
124+`NZ_MAP_CTX_OFFSET_*` nor `base_ctx_rect`.
125+
126+New/changed tests, all green: `filter_intra_classes_carry_their_own_libaom_default_row`,
127+`a_pinned_aomenc_16x8_strip_reads_its_use_filter_intra_flag`; the two pixel arms are among
128+the 29 ignored, each carrying its measurement in its doc.