diff --git a/crates/ec-av1/fixtures/filter_intra_8x16_strip_seed49.obu b/crates/ec-av1/fixtures/filter_intra_8x16_strip_seed49.obu new file mode 100644 index 0000000000000000000000000000000000000000..59a823ff271b21a1b17e4b2445392e9a8cb4933e GIT binary patch literal 95 zcmV-l0HFU80165K000BE|MUOk0Wwbz0E~bLAp!{*GPGX31J6G&jxuz3vqaU)o~rvf zM_cyp8G0ckX)Zf{f48&)&n~~BbRBI?$@t-Whf9U0M BDenLP literal 0 HcmV?d00001 diff --git a/crates/ec-av1/src/cdf.rs b/crates/ec-av1/src/cdf.rs index 7b2a2f58..5f3ed88c 100644 --- a/crates/ec-av1/src/cdf.rs +++ b/crates/ec-av1/src/cdf.rs @@ -421,13 +421,21 @@ pub const CFL_SIGN: [u16; 9] = [1418, 2123, 13340, 18405, 26972, 28343, 32294, 3 /// (12756/14301, `default_filter_intra_cdfs` index 8/7) -- the two rect /// strips `PARTITION_HORZ`/`PARTITION_VERT` decode, each with its own /// distinct default probability from every square class above. -pub const FILTER_INTRA: [[u16; 3]; 6] = [ +/// `[6]`/`[7]` (lane-fistrip r1) add `BLOCK_8X16`/`BLOCK_16X8`'s rows +/// (12551/9394, `default_filter_intra_cdfs` index 4/5) -- the strips a +/// 16x16 `PARTITION_HORZ`/`PARTITION_VERT` splits into. Both are inside +/// `av1_filter_intra_allowed_bsize`'s <=32 bound, so aomenc writes a +/// `use_filter_intra` flag on every DC_PRED one of them; before this round +/// no class existed for them and the symbol was never read at all. +pub const FILTER_INTRA: [[u16; 3]; 8] = [ [4621, 32768, 0], [7866, 32768, 0], [12408, 32768, 0], [22343, 32768, 0], [12756, 32768, 0], [14301, 32768, 0], + [12551, 32768, 0], + [9394, 32768, 0], ]; /// `default_filter_intra_mode_cdf` (entropymode.c): which of the five /// `FILTER_INTRA_MODES` a `use_filter_intra` block picks. diff --git a/crates/ec-av1/src/cdf_state.rs b/crates/ec-av1/src/cdf_state.rs index cd587b45..b1ef73a8 100644 --- a/crates/ec-av1/src/cdf_state.rs +++ b/crates/ec-av1/src/cdf_state.rs @@ -457,9 +457,9 @@ pub(crate) struct Cdfs { /// [`Self::dv_joint`]'s per-component half. pub dv_comp: [MvComponentCdfs; 2], /// The `use_filter_intra` flag, indexed by block-size class (`[0]`=4x4, - /// `[1]`=8x8, `[2]`=16x16, `[3]`=32x32, `[4]`=32x16, `[5]`=16x32) -- + /// `[1]`=8x8, `[2]`=16x16, `[3]`=32x32, `[4]`=32x16, `[5]`=16x32, `[6]`=8x16, `[7]`=16x8) -- /// see [`cdf::FILTER_INTRA`]. - pub filter_intra: [[u16; 3]; 6], + pub filter_intra: [[u16; 3]; 8], /// Which `FILTER_INTRA_MODES` entry a `use_filter_intra` block picks. pub filter_intra_mode: [u16; 6], /// `TxMode::Select`'s `tx_depth` flag at an 8x8 block, by `tx_size_context` diff --git a/crates/ec-av1/src/decode.rs b/crates/ec-av1/src/decode.rs index b76ea5b2..2e47b4d7 100644 --- a/crates/ec-av1/src/decode.rs +++ b/crates/ec-av1/src/decode.rs @@ -869,6 +869,21 @@ pub(crate) fn filter_intra_rect_hits() -> usize { FILTER_INTRA_RECT_HITS.with(|c| c.get()) } +// As [`FILTER_INTRA_RECT_HITS`], counting only the strips BELOW 16x16 +// (8x16/16x8 leaves of a 16x16 HORZ/VERT partition, lane-fistrip r1) -- the +// shapes whose `use_filter_intra` symbol had no CDF class before this round. +// A gate asserting the wider counter would be satisfied by a 32x16 strip and +// prove nothing about the new shapes. +thread_local! { + static FILTER_INTRA_RECT_SUB16_HITS: std::cell::Cell = + const { std::cell::Cell::new(0) }; +} + +/// Current value of [`FILTER_INTRA_RECT_SUB16_HITS`]. +pub(crate) fn filter_intra_rect_sub16_hits() -> usize { + FILTER_INTRA_RECT_SUB16_HITS.with(|c| c.get()) +} + // How many [`read_coeffs`] reads resolved a `tx_type` outside `TX_CLASS_2D` // (`V_DCT`/`H_DCT`, spec 5.11.39's `TxClass::Horiz`/`Vert`), across every // 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 { match (bw, bh) { (32, 16) => Some(4), (16, 32) => Some(5), + // lane-fistrip r1: `av1_filter_intra_allowed_bsize` is + // `block_size_wide <= 32 && block_size_high <= 32`, which the 16x16 + // level's own 8x16/16x8 strips satisfy -- returning `None` here did + // not refuse them, it silently SKIPPED a symbol aomenc writes + // (class `symbol-consumption-gap`). + (8, 16) => Some(6), + (16, 8) => Some(7), _ if bw == bh => filter_intra_size_class(bw), _ => None, } @@ -4657,9 +4679,12 @@ fn decode_leaf_rect( leaf_mi.1, )?; if filter_intra.is_some() { - return Err(unsupported( - "filter intra on a HORZ/VERT strip (this decoder predicts square-only)", - )); + // lane-fistrip r1: `predict_filter_intra` already walks its 4x2 + // patches over a true `bw`x`bh` block (lane-rectsplit r1), so an + // 8x16/16x8 strip predicts through the same call `reconstruct_rect` + // below already makes; this refusal was square-only prose. + FILTER_INTRA_RECT_HITS.with(|c| c.set(c.get() + 1)); + FILTER_INTRA_RECT_SUB16_HITS.with(|c| c.set(c.get() + 1)); } let uv_predict_mode = if uv_mode == UV_CFL_PRED { DC_PRED } else { uv_mode }; let depth = if tx_select { @@ -16288,6 +16313,78 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( #[cfg(test)] mod tests { + + /// lane-fistrip r1 (class `enumerate-the-table-domain`): every block + /// shape this decoder can hand [`filter_intra_size_class_rect`], against + /// `av1_filter_intra_allowed_bsize` (`block_size_wide <= 32 && + /// block_size_high <= 32`) and `default_filter_intra_cdfs` + /// (entropymode.c) row by row. A class that exists must carry ITS OWN + /// bsize's default probability -- a wrong row is a silently different + /// symbol, not a decode error. The shapes with no class are listed here + /// with their reason so the residue is pinned rather than implied. + #[test] + fn filter_intra_classes_carry_their_own_libaom_default_row() { + // `default_filter_intra_cdfs[bsize]`, BLOCK_SIZES_ALL order, as + // (width, height, default) for the shapes <= 32 on both axes. + let libaom: &[(usize, usize, u16)] = &[ + (4, 4, 4621), + (4, 8, 6743), + (8, 4, 5893), + (8, 8, 7866), + (8, 16, 12551), + (16, 8, 9394), + (16, 16, 12408), + (16, 32, 14301), + (32, 16, 12756), + (32, 32, 22343), + (4, 16, 16384), + (16, 4, 16384), + (8, 32, 16384), + (32, 8, 16384), + ]; + // The shapes this decoder's partition tree can actually reach today + // (squares 4..32 plus the 16x16- and 32x32-level HORZ/VERT strips). + let reachable = [ + (4, 4), + (8, 8), + (16, 16), + (32, 32), + (32, 16), + (16, 32), + (8, 16), + (16, 8), + ]; + for &(bw, bh, default) in libaom { + let class = filter_intra_size_class_rect(bw, bh); + if reachable.contains(&(bw, bh)) { + let class = class.unwrap_or_else(|| { + panic!("{bw}x{bh} is inside av1_filter_intra_allowed_bsize and reachable, \ + but has no CDF class -- its use_filter_intra symbol is never read") + }); + assert_eq!( + crate::cdf::FILTER_INTRA[class][0], + default, + "{bw}x{bh} (class {class}) must carry default_filter_intra_cdfs' own row" + ); + } else { + // 4x8/8x4/4x16/16x4/8x32/32x8: sub-8x8 leaves and the 1:4 + // strips, neither of which this decoder codes yet (their + // partition levels refuse by name first), so no class exists. + assert!( + class.is_none(), + "{bw}x{bh} gained a class without a decode path to use it" + ); + } + } + // Past the bound on either axis: no symbol at all (spec + // `filter_intra_mode_info` never reads one). + for (bw, bh) in [(64, 64), (64, 32), (32, 64)] { + assert!( + filter_intra_size_class_rect(bw, bh).is_none(), + "{bw}x{bh} is past av1_filter_intra_allowed_bsize's <=32 bound" + ); + } + } use super::*; /// lane-rectsplit r2: `av1_nz_map_ctx_offset` is packed COLUMN-major, so diff --git a/crates/ec-av1/src/refusal_inventory.rs b/crates/ec-av1/src/refusal_inventory.rs index 82bc3b66..3fbd1b3f 100644 --- a/crates/ec-av1/src/refusal_inventory.rs +++ b/crates/ec-av1/src/refusal_inventory.rs @@ -73,7 +73,6 @@ const REFUSALS: &[&str] = &[ "an inter partition below 16x16 other than SPLIT (16x8/8x16 rect inter leaves are not coded yet)", "an intra mode this decoder does not code (round 2)", "an intra-coded HORZ/VERT strip needs rectangular intra prediction this decoder does not code yet", - "filter intra on a HORZ/VERT strip (this decoder predicts square-only)", "warp prediction with a scaled reference (superres, unimplemented)", "an 8x8 partition leaf under a scaled reference (superres, unimplemented)", ]; diff --git a/crates/ec-av1/src/stream.rs b/crates/ec-av1/src/stream.rs index 402bf861..44361fe3 100644 --- a/crates/ec-av1/src/stream.rs +++ b/crates/ec-av1/src/stream.rs @@ -8437,7 +8437,16 @@ mod tests { let mut other_refusals = Vec::new(); for attempt in 0..n_attempts { let seed = 42 + attempt; - let source = gradients_source(seed, width, height, "duration=0.04:rate=25"); + // Diagnosis knob: which content makes RD pick an 8x16/16x8 strip + // AND filter intra on it is a search (see lanes/fistrip-r1.report.md). + let source = match std::env::var("EC_FISTRIP_SRC").unwrap_or_default().as_str() { + "bars" => format!("smptebars=size={width}x{height}:duration=0.04:rate=25"), + "src2" => format!("testsrc2=size={width}x{height}:duration=0.04:rate=25"), + "noise" => format!( + "nullsrc=size={width}x{height}:duration=0.04:rate=25,geq=random(1)*255:128:128" + ), + _ => gradients_source(seed, width, height, "duration=0.04:rate=25"), + }; let y4m = Command::new("ffmpeg") .args(["-v", "error", "-f", "lavfi", "-i"]) .arg(&source) @@ -12769,6 +12778,294 @@ mod tests { ); } + /// lane-fistrip r1, the 10-bit arm of the strip gate (his films are + /// yuv420p10le). Same ceiling as its 8-bit twin -- kept `#[ignore]`d + /// with the measurement rather than weakened: MEASURED over seeds + /// 42..61 the 8x16/16x8 strips aomenc writes filter intra on are + /// `skip=0`, which `decode_leaf_rect` refuses, so + /// `filter_intra_rect_sub16_hits` never reaches a pixel compare. + #[ignore = "blocked on the coded (non-skip) rect strip below 16x16 refusal -- see doc"] + #[test] + fn a_real_aomenc_10bit_filter_intra_on_a_sub16_strip_decodes_pixel_exact() { + const NAME: &str = "a_real_aomenc_10bit_filter_intra_on_a_sub16_strip_decodes_pixel_exact"; + let _gate_lock = lock_gate_counters(); + if !have_ffmpeg() { + eprintln!("SKIP {NAME}: no ffmpeg"); + return; + } + if !have_aomenc() { + eprintln!("SKIP {NAME}: no aomenc at {}", aomenc_path().display()); + return; + } + let seeds: Vec = (42..62).collect(); + ten_bit_tool_gate( + NAME, + 192, + 128, + 1, + &[ + "--limit=1", + "--cq-level=25", + "--cpu-used=0", + "--threads=1", + "--row-mt=0", + "--sb-size=64", + "--enable-rect-partitions=1", + "--enable-ab-partitions=0", + "--enable-1to4-partitions=0", + "--min-partition-size=8", + "--max-partition-size=32", + "--enable-restoration=0", + "--enable-palette=0", + "--deltaq-mode=0", + "--enable-filter-intra=1", + "--enable-cfl-intra=0", + "--enable-intrabc=0", + ], + &seeds, + &[( + "filter_intra_rect_sub16_hits", + crate::decode::filter_intra_rect_sub16_hits as fn() -> usize, + )], + ); + } + + /// lane-fistrip r1, the pinned half of this lane's proof: one real + /// `aomenc` stream (recipe below, byte-reproducible -- md5 + /// ac3a64773e5454ee9b5d8650507063cd, hashed twice) whose key frame + /// carries four `BLOCK_16X8` DC_PRED leaves, one of which sets + /// `use_filter_intra`. `av1_filter_intra_allowed_bsize` allows 16x8, so + /// aomenc writes that flag; before this round `filter_intra_size_class_rect` + /// had no row for the shape, the symbol was never read, and the tile + /// desynced ON THAT BLOCK -- observable as a DIFFERENT named refusal + /// ("a HORZ/VERT intra strip below 16x16 with a split transform", a + /// `tx_depth` read out of a desynced stream) instead of this one. + /// + /// The stream cannot be pixel-compared yet: the 16x8 strip that carries + /// the flag is `skip=0`, and a coded rect strip below 16x16 has no + /// residual path here (its own refusal, another lane's ceiling). What + /// this test pins is the SYMBOL: the flag is read, the counter fires + /// once, and the decode stops at the coded-strip ceiling rather than + /// wandering off a desynced stream. + /// + /// Fixture recipe (`crates/ec-av1/fixtures/filter_intra_8x16_strip_seed49.obu`): + /// `ffmpeg -f lavfi -i gradients=size=192x128:c0=0x986ae1:c1=0xd3e49a: + /// c2=0x0b1e53:c3=0x42980c:seed=49:duration=0.04:rate=25 -pix_fmt yuv420p` + /// into `aomenc --codec=av1 --passes=1 --end-usage=q --cq-level=25 + /// --cpu-used=0 --threads=1 --row-mt=0 --sb-size=64 + /// --enable-rect-partitions=1 --enable-ab-partitions=0 + /// --enable-1to4-partitions=0 --min-partition-size=8 + /// --max-partition-size=32 --enable-restoration=0 --enable-palette=0 + /// --deltaq-mode=0 --enable-filter-intra=1 --enable-cfl-intra=0 + /// --enable-intrabc=0 --obu`. + #[test] + fn a_pinned_aomenc_16x8_strip_reads_its_use_filter_intra_flag() { + const NAME: &str = "a_pinned_aomenc_16x8_strip_reads_its_use_filter_intra_flag"; + let _gate_lock = lock_gate_counters(); + let path = std::path::Path::new(env!("CARGO_MANIFEST_DIR")) + .join("fixtures/filter_intra_8x16_strip_seed49.obu"); + let stream = std::fs::read(&path) + .unwrap_or_else(|e| panic!("{NAME}: reading {}: {e}", path.display())); + let before = crate::decode::filter_intra_rect_sub16_hits(); + let err = decode_stream(&stream).expect_err( + "{NAME}: this stream's 16x8 filter-intra strip is skip=0, which this decoder \ + still refuses -- a clean decode means the coded-strip ceiling moved and this \ + test should become a pixel compare", + ); + let hits = crate::decode::filter_intra_rect_sub16_hits() - before; + assert_eq!( + hits, 1, + "{NAME}: expected exactly one 16x8 strip to read use_filter_intra=1 (aomdec's own \ + EC_TRACE_MODE shows four BLOCK_16X8 DC_PRED leaves here); got {hits}" + ); + let msg = err.to_string(); + assert!( + msg.contains("a coded (non-skip) HORZ/VERT rect strip below 16x16"), + "{NAME}: decode must reach the coded-strip ceiling ON that block, not wander off a \ + desynced stream; got: {msg}" + ); + } + + /// lane-fistrip r1: the filter-intra strip gate above, one partition + /// level DOWN (`--min-partition-size=8`, so a 16x16 HORZ/VERT splits + /// into 8x16/16x8 leaves). `av1_filter_intra_allowed_bsize` is + /// `wide <= 32 && high <= 32`, which both of those satisfy, so aomenc + /// writes a `use_filter_intra` flag on every DC_PRED one of them -- + /// `filter_intra_size_class_rect` had no row for either shape and + /// [`crate::decode::read_intra_mode_rect`] therefore never READ that + /// symbol (class `symbol-consumption-gap`, a silent desync rather than + /// a refusal). Hard-asserts + /// [`crate::decode::filter_intra_rect_sub16_hits`], not the wider + /// `filter_intra_rect_hits`: a 32x16 strip firing filter intra would + /// satisfy that one and prove nothing about the new shapes. + /// MEASURED THIS ROUND (lane-fistrip r1), which is why it is `#[ignore]`d + /// rather than green: over 200 seeds at cq 25 aomenc put filter intra on + /// an 8x16/16x8 strip TWICE, and both times that strip was `skip=0`, so + /// the attempt refused at the coded-rect-strip-below-16x16 ceiling before + /// any pixel compare (177 pixel-exact matches, 23 refusals, compared + /// sub16 delta 0, all-attempt delta 2). Un-ignore this the round that + /// ceiling lifts; the symbol itself is pinned by + /// [`a_pinned_aomenc_16x8_strip_reads_its_use_filter_intra_flag`]. + #[ignore = "blocked on the coded (non-skip) rect strip below 16x16 refusal -- see doc"] + #[test] + fn a_real_aomenc_stream_with_filter_intra_on_a_sub16_horz_vert_strip_decodes_pixel_exact() { + const NAME: &str = + "a_real_aomenc_stream_with_filter_intra_on_a_sub16_horz_vert_strip_decodes_pixel_exact"; + let _gate_lock = lock_gate_counters(); + if !have_ffmpeg() { + eprintln!("SKIP {NAME}: no ffmpeg"); + return; + } + if !have_aomenc() { + eprintln!("SKIP {NAME}: no aomenc at {}", aomenc_path().display()); + return; + } + let (width, height) = (192usize, 128usize); + let mut named_refusals = 0u32; + let mut matched = 0u32; + let mut compared_hits = 0usize; + let n_attempts: u32 = std::env::var("EC_FISTRIP_GATE_ATTEMPTS") + .ok() + .and_then(|s| s.parse().ok()) + .unwrap_or(40); + let cq = format!( + "--cq-level={}", + std::env::var("EC_FISTRIP_CQ").unwrap_or_else(|_| "25".into()) + ); + // Diagnosis: the counter over EVERY attempt, refused ones included -- + // a filter-intra 8x16 strip inside an attempt that later refused + // (non-skip, split transform) fires this but never reaches + // `compared_hits`, and the two numbers differing is what says the + // recipe reaches the feature but this decoder's other ceilings hide + // it. + let all_before = crate::decode::filter_intra_rect_sub16_hits(); + for attempt in 0..n_attempts { + let seed = 42 + attempt; + let source = gradients_source(seed, width, height, "duration=0.04:rate=25"); + let y4m = Command::new("ffmpeg") + .args([ + "-v", "error", "-f", "lavfi", "-i", &source, "-pix_fmt", "yuv420p", "-f", + "yuv4mpegpipe", "-", + ]) + .stdin(Stdio::null()) + .stdout(Stdio::piped()) + .stderr(Stdio::piped()) + .output() + .expect("ffmpeg failed to run"); + assert!( + y4m.status.success(), + "ffmpeg fixture: {}", + String::from_utf8_lossy(&y4m.stderr) + ); + let args: Vec<&str> = vec![ + "--codec=av1", + "--passes=1", + "--end-usage=q", + &cq, + "--cpu-used=0", + "--threads=1", + "--row-mt=0", + "--sb-size=64", + "--enable-rect-partitions=1", + "--enable-ab-partitions=0", + "--enable-1to4-partitions=0", + // The point of this gate: one level below the 32x16/16x32 + // strips the sibling gate covers. + "--min-partition-size=8", + "--max-partition-size=32", + "--enable-restoration=0", + "--enable-palette=0", + "--deltaq-mode=0", + "--enable-filter-intra=1", + "--enable-cfl-intra=0", + "--enable-intrabc=0", + "--obu", + "-o", + "-", + "-", + ]; + // Diagnosis knob only (default: every intra mode on) -- the same + // subset search the 32x16/16x32 sibling gate carries. + let mut args = args; + let off = std::env::var("EC_FISTRIP_OFF").unwrap_or_default(); + for tool in off.split(',').filter(|t| !t.is_empty()) { + args.push(match tool { + "smooth" => "--enable-smooth-intra=0", + "paeth" => "--enable-paeth-intra=0", + "dir" => "--enable-directional-intra=0", + "angle" => "--enable-angle-delta=0", + other => panic!("unknown EC_FISTRIP_OFF entry {other}"), + }); + } + let mut child = Command::new(aomenc_path()) + .args(&args) + .stdin(Stdio::piped()) + .stdout(Stdio::piped()) + .stderr(Stdio::piped()) + .spawn() + .expect("aomenc failed to start"); + child + .stdin + .take() + .expect("aomenc stdin") + .write_all(&y4m.stdout) + .expect("writing y4m to aomenc"); + let out = child.wait_with_output().expect("aomenc failed to run"); + assert!( + out.status.success(), + "aomenc refused the fixture: {}", + String::from_utf8_lossy(&out.stderr) + ); + let stream = out.stdout; + assert!(!stream.is_empty(), "{NAME}: aomenc wrote an empty stream (seed {seed})"); + let attempt_before = crate::decode::filter_intra_rect_sub16_hits(); + let frames = match decode_stream(&stream) { + Err(e) => { + let msg = e.to_string(); + assert!( + msg.contains("unsupported"), + "{NAME} failed outright, not a named refusal (seed {seed}): {msg}" + ); + // Diagnosis: a refused attempt that DID fire the feature + // says which other ceiling of this decoder hides it. + eprintln!( + "{NAME}: seed {seed} refused with sub16 filter-intra delta {}: {msg}", + crate::decode::filter_intra_rect_sub16_hits() - attempt_before + ); + named_refusals += 1; + continue; + } + Ok(frames) => frames, + }; + let ffmpeg_frames = ffmpeg_decode_sequence(&stream, width, height, 1); + assert_eq!(frames.len(), 1, "{NAME}: expected one frame (seed {seed})"); + assert_eq!(frames[0].y, ffmpeg_frames[0].y, "{NAME}: luma vs ffmpeg (seed {seed})"); + assert_eq!(frames[0].u, ffmpeg_frames[0].u, "{NAME}: U vs ffmpeg (seed {seed})"); + assert_eq!(frames[0].v, ffmpeg_frames[0].v, "{NAME}: V vs ffmpeg (seed {seed})"); + compared_hits += crate::decode::filter_intra_rect_sub16_hits() - attempt_before; + matched += 1; + } + eprintln!( + "{NAME}: filter_intra_rect_sub16_hits over ALL attempts (refused included) = {}", + crate::decode::filter_intra_rect_sub16_hits() - all_before + ); + assert!( + matched > 0, + "{NAME}: every attempt refused ({named_refusals} named refusals) -- gate decoded nothing" + ); + assert!( + compared_hits > 0, + "{NAME}: no 8x16/16x8 strip used filter intra ({matched} pixel-exact matches, \ + {named_refusals} refusals out of {n_attempts}) -- gate proved nothing this run" + ); + eprintln!( + "{NAME}: {matched} pixel-exact matches, {named_refusals} named refusals, \ + filter_intra_rect_sub16_hits delta={compared_hits} (all attempts including \ + refused: {}) out of {n_attempts} attempts", + crate::decode::filter_intra_rect_sub16_hits() - all_before + ); + } + /// lane-rectsplit r1 gate (b): [`a_real_aomenc_stream_with_a_superblock_level_horz_vert_partition_decodes_pixel_exact`]'s /// own recipe (`--sb-size=64`, `--min/max-partition-size=32/64`, so every /// SB-level decision is genuinely NONE/SPLIT/HORZ/VERT) with its diff --git a/lanes/fistrip-r1.report.md b/lanes/fistrip-r1.report.md new file mode 100644 index 00000000..2d9c5efe --- /dev/null +++ b/lanes/fistrip-r1.report.md @@ -0,0 +1,128 @@ +# lane-fistrip r1 — filter intra on a rect strip + +Branch `lane-fistrip` off main `df5d630`. Worktree +`/home/user/Documents/Code/Rust/edith_codecs-fistrip`, +`CARGO_TARGET_DIR=$HOME/.cache/cargo-target-fistrip`. + +## Charter premise: stale, corrected by measurement + +The charter said `predict_filter_intra` is square-only. It is not: lane-rectsplit r1 +already gave it `bw`x`bh` (`crates/ec-av1/src/intra.rs:773`), and 32x16/16x32 strips +already predict filter intra with a real-aomenc gate +(`a_real_aomenc_stream_with_filter_intra_on_a_horz_vert_strip_decodes_pixel_exact`). + +The real defect one level down was a **symbol-consumption gap**, not a prediction gap: +`filter_intra_size_class_rect` (`decode.rs:3491`) returned `None` for 8x16/16x8, so +`read_intra_mode_rect` never read the `use_filter_intra` flag that +`av1_filter_intra_allowed_bsize` (`wide <= 32 && high <= 32`, oracle +`av1/common/reconintra.h`) makes aomenc write on every DC_PRED 8x16/16x8 leaf. The +`decode_leaf_rect` refusal "filter intra on a HORZ/VERT strip (this decoder predicts +square-only)" (old `decode.rs:4661`) was DEAD CODE behind that `None` — it never fired; +the tile desynced silently instead. + +Film stops measured on main `df5d630` (release `decode_probe`), BEFORE any change: +- `hghead.obu` (ReelB 0.4 s head): `a partition below 8x8 (this decoder codes no + leaf smaller than 8x8)` — earlier than filter intra, as the charter suspected, so the + film is not this lane's gate. +- `reelb5.obu`: `a superblock-level HORZ/VERT strip with a split transform (per-unit rect + prediction is not ported)`. + +## Changed + +- `crates/ec-av1/src/cdf.rs:424` — `FILTER_INTRA` grows to 8 rows: `[6]`=8x16 (12551), + `[7]`=16x8 (9394), `default_filter_intra_cdfs` index 4/5 (oracle + `av1/common/entropymode.c:821`). +- `crates/ec-av1/src/cdf_state.rs:462` — the field's type/doc follow. +- `crates/ec-av1/src/decode.rs:3491` — `filter_intra_size_class_rect` maps + `(8,16)`/`(16,8)` to those rows, so the symbol is READ where aomenc writes it. +- `crates/ec-av1/src/decode.rs` (`decode_leaf_rect`) — the dead square-only refusal + replaced by the counters; the strip predicts through the `reconstruct_rect` call that + was already there. +- `crates/ec-av1/src/decode.rs` — new `FILTER_INTRA_RECT_SUB16_HITS` / + `filter_intra_rect_sub16_hits()`: a gate asserting the wider `filter_intra_rect_hits` + would be satisfied by a 32x16 strip and prove nothing about the new shapes. +- `crates/ec-av1/src/refusal_inventory.rs` — the square-only line removed. +- `crates/ec-av1/src/decode.rs` tests — `filter_intra_classes_carry_their_own_libaom_default_row` + enumerates every shape inside `av1_filter_intra_allowed_bsize` against + `default_filter_intra_cdfs` row by row and pins the shapes still without a class + (4x8/8x4/4x16/16x4/8x32/32x8 — their partition levels refuse first). +- `crates/ec-av1/src/stream.rs` — `a_pinned_aomenc_16x8_strip_reads_its_use_filter_intra_flag` + (green) plus the pixel gate + `a_real_aomenc_stream_with_filter_intra_on_a_sub16_horz_vert_strip_decodes_pixel_exact` + (`#[ignore]`d with its measurement, see below). +- `crates/ec-av1/fixtures/filter_intra_8x16_strip_seed49.obu` — the pinned stream + (md5 `ac3a64773e5454ee9b5d8650507063cd`, hashed twice from the same recipe; `.gitignore` + ignores `fixtures`, so it is committed with `git add -f`). + +## Gate status — honest + +The charter's gate (`..._on_a_rect_strip_decodes_pixel_exact`) is written and **cannot be +green on this tree**, so it ships `#[ignore]`d carrying its measurement rather than +weakened: over **200 aomenc streams** (seeds 42..241, cq 25, `--min-partition-size=8 +--max-partition-size=32 --enable-filter-intra=1`) aomenc put filter intra on an 8x16/16x8 +strip exactly **twice**, and **both** strips were `skip=0`, which +`decode_leaf_rect` still refuses ("a coded (non-skip) HORZ/VERT rect strip below 16x16"). +Sweeps that found nothing better: cq {15,20,25,30,34,40,45,55}; content +{gradients, testsrc2, smptebars-style, geq noise}; intra-tool subsets +{none, smooth+paeth off, smooth+paeth+dir+angle off} — the last kills filter intra +entirely. Flag-arrival note (coordinator correction, aomenc keeps the LAST repeated +`--enable-*`): this gate spells every flag once and appends the `EC_FISTRIP_OFF` +diagnosis overrides AFTER the base recipe, and arrival of `--enable-filter-intra=1` is +proven decoder-side by the counters, not by the command line. + +10-bit arm (`a_real_aomenc_10bit_filter_intra_on_a_sub16_strip_decodes_pixel_exact`, +`ten_bit_tool_gate`, seeds 42..61, same recipe): **16/20 attempts decode pixel-exact at +10 bits** with the new CDF rows in place (no regression), and the same seed 49 refuses at +the coded-strip ceiling -- `filter_intra_rect_sub16_hits` never reaches a compare, so this +arm is `#[ignore]`d with its measurement too. + +What IS proven, green, and pinned: the symbol read. On the pinned stream aomdec's own +`EC_TRACE_MODE` shows four `BLOCK_16X8` (`bsize=5`) DC_PRED leaves; our decoder now reads +`use_filter_intra` on them, fires the counter once, and stops at the coded-strip ceiling +ON that block. Before the fix the same stream refused with a DIFFERENT string — "a +HORZ/VERT intra strip below 16x16 with a split transform" — a `tx_depth` read out of an +already-desynced stream, which is the desync this round removes. + +EVIDENCE: `crates/ec-av1/fixtures/filter_intra_8x16_strip_seed49.obu` | pre-fix release +`decode_probe` on main df5d630 vs post-fix `cargo test -p ec-av1 --lib +a_pinned_aomenc_16x8_strip_reads_its_use_filter_intra_flag` | refusal string moves +"split transform" -> "coded (non-skip) rect strip below 16x16", +`filter_intra_rect_sub16_hits` delta 0 -> 1 +EVIDENCE: oracle `EC_TRACE_MODE=1 aomdec` on that fixture | grep `bsize=` | 4x BLOCK_16X8 +DC_PRED leaves (`skip=0`), 6x 16x16, 4x 32x16-class, 20x 32x32 + +## Residue + +- deferred: pixel-exact gate for filter intra on 8x16/16x8 — blocked on the "coded + (non-skip) HORZ/VERT rect strip below 16x16" refusal (needs TX_16X8/TX_8X16 luma plus + 8x4/4x8 chroma coefficient tables) — un-ignore the gate the round that lands. +- deferred: the 10-bit pixel arm rides the same ceiling as the 8-bit one. +- deferred: 8x32/32x8 (HORZ_4/VERT_4) and 4x8/8x4 (sub-8x8) filter-intra classes — their + partition levels refuse before the mode read; the domain test pins them as absent. +- accepted: the capability claim "filter intra on a superblock-level HORZ/VERT strip + (never expected -- av1_filter_intra_allowed_bsize caps at 32x32)" stays; 64x32/32x64 + are past the <=32 bound on one axis, verified in the same domain test. + +## Film probes after the fix (release `decode_probe`, this branch) + +- `hghead.obu`: `a partition below 8x8 (this decoder codes no leaf smaller than 8x8)` (unchanged) +- `reelb5.obu`: `a superblock-level HORZ/VERT strip with a split transform (per-unit rect + prediction is not ported)` (unchanged) + +Both films stop before any 8x16/16x8 filter-intra strip, so this lane moves neither +frontier; it removes a silent desync that would have bitten once those two lift. + +## Suite totals + +`EC_AV1_REQUIRE_AOMENC=1 cargo test -p ec-av1 --lib` (log `$HOME/.cache/fistrip-suite.log`, +826 s): **300 passed, 1 failed, 29 ignored**. + +The one failure is PRE-EXISTING on main `df5d630` and not this lane's: +`decode::tests::nz_map_ctx_offset_tables_match_the_rect_rule` — "32x64 nz_map offset at +display (row 0, col 2): left 6, right 11", the known rectsplit-r4 `table[col][row]` vs +`[row][col]` convention clash already in the ledger. This lane touched neither +`NZ_MAP_CTX_OFFSET_*` nor `base_ctx_rect`. + +New/changed tests, all green: `filter_intra_classes_carry_their_own_libaom_default_row`, +`a_pinned_aomenc_16x8_strip_reads_its_use_filter_intra_flag`; the two pixel arms are among +the 29 ignored, each carrying its measurement in its doc.