Merge branch 'lane-fi32x8' into lane-band63
Browse files at this commit5 changed files +404 -7
- crates/ec-av1/src/cdf.rs +10 -1
- crates/ec-av1/src/cdf_state.rs +1 -1
- crates/ec-av1/src/decode.rs +45 -5
- crates/ec-av1/src/stream.rs +246 -0
- lanes/fi32x8-r1.report.md +102 -0
crates/ec-av1/src/cdf.rsmodified+10 -1
| @@ -463,7 +463,14 @@ pub const CFL_SIGN: [u16; 9] = [1418, 2123, 13340, 18405, 26972, 28343, 32294, 3 | |||
| 463 | /// the flag was never read at that size at all (libaom reads it for every | 463 | /// the flag was never read at that size at all (libaom reads it for every |
| 464 | /// DC_PRED block whose sides are both <= 32), so every DC_PRED 16x8 strip | 464 | /// DC_PRED block whose sides are both <= 32), so every DC_PRED 16x8 strip |
| 465 | /// dropped one symbol and desynced the tile from that block on. | 465 | /// dropped one symbol and desynced the tile from that block on. |
| 466 | -pub const FILTER_INTRA: [[u16; 3]; 8] = [ | 466 | +/// `[8]`/`[9]` (lane-fi32x8 r1) add `BLOCK_32X8`/`BLOCK_8X32`'s own rows |
| 467 | +/// (18101/20229, `default_filter_intra_cdfs` index 19/18 -- generated by | ||
| 468 | +/// `scripts/extract-filter-intra-cdfs.py`): the four 32x8 (or 8x32) strips a | ||
| 469 | +/// 32x32-level `PARTITION_HORZ_4`/`VERT_4` codes are inside | ||
| 470 | +/// `av1_filter_intra_allowed_bsize`'s "both sides <= 32" bound, so libaom | ||
| 471 | +/// reads `use_filter_intra` there too and the missing rows dropped the | ||
| 472 | +/// symbol on every DC_PRED 1:4 strip. | ||
| 473 | +pub const FILTER_INTRA: [[u16; 3]; 10] = [ | ||
| 467 | [4621, 32768, 0], | 474 | [4621, 32768, 0], |
| 468 | [7866, 32768, 0], | 475 | [7866, 32768, 0], |
| 469 | [12408, 32768, 0], | 476 | [12408, 32768, 0], |
| @@ -472,6 +479,8 @@ pub const FILTER_INTRA: [[u16; 3]; 8] = [ | |||
| 472 | [14301, 32768, 0], | 479 | [14301, 32768, 0], |
| 473 | [9394, 32768, 0], | 480 | [9394, 32768, 0], |
| 474 | [12551, 32768, 0], | 481 | [12551, 32768, 0], |
| 482 | + [18101, 32768, 0], | ||
| 483 | + [20229, 32768, 0], | ||
| 475 | ]; | 484 | ]; |
| 476 | /// `default_filter_intra_mode_cdf` (entropymode.c): which of the five | 485 | /// `default_filter_intra_mode_cdf` (entropymode.c): which of the five |
| 477 | /// `FILTER_INTRA_MODES` a `use_filter_intra` block picks. | 486 | /// `FILTER_INTRA_MODES` a `use_filter_intra` block picks. |
crates/ec-av1/src/cdf_state.rsmodified+1 -1
| @@ -541,7 +541,7 @@ pub(crate) struct Cdfs { | |||
| 541 | /// `[1]`=8x8, `[2]`=16x16, `[3]`=32x32, `[4]`=32x16, `[5]`=16x32, | 541 | /// `[1]`=8x8, `[2]`=16x16, `[3]`=32x32, `[4]`=32x16, `[5]`=16x32, |
| 542 | /// `[6]`=16x8, `[7]`=8x16) -- | 542 | /// `[6]`=16x8, `[7]`=8x16) -- |
| 543 | /// see [`cdf::FILTER_INTRA`]. | 543 | /// see [`cdf::FILTER_INTRA`]. |
| 544 | - pub filter_intra: [[u16; 3]; 8], | 544 | + pub filter_intra: [[u16; 3]; 10], |
| 545 | /// Which `FILTER_INTRA_MODES` entry a `use_filter_intra` block picks. | 545 | /// Which `FILTER_INTRA_MODES` entry a `use_filter_intra` block picks. |
| 546 | pub filter_intra_mode: [u16; 6], | 546 | pub filter_intra_mode: [u16; 6], |
| 547 | /// `TxMode::Select`'s `tx_depth` flag at an 8x8 block, by `tx_size_context` | 547 | /// `TxMode::Select`'s `tx_depth` flag at an 8x8 block, by `tx_size_context` |
crates/ec-av1/src/decode.rsmodified+45 -5
| @@ -956,6 +956,31 @@ pub(crate) fn filter_intra_rect_hits() -> usize { | |||
| 956 | FILTER_INTRA_RECT_HITS.with(|c| c.get()) | 956 | FILTER_INTRA_RECT_HITS.with(|c| c.get()) |
| 957 | } | 957 | } |
| 958 | 958 | ||
| 959 | +// As [`FILTER_INTRA_RECT_HITS`], counting only the 32x32-level 1:4 strips | ||
| 960 | +// (32x8/8x32, lane-fi32x8 r1) -- the shapes whose `use_filter_intra` symbol | ||
| 961 | +// was never read at all before that round, so a gate needs to prove the flag | ||
| 962 | +// fired at THAT shape and not at a 16x8 one somewhere else in the frame. | ||
| 963 | +// Split by ORIENTATION: rows 8 (32x8) and 9 (8x32) of `cdf::FILTER_INTRA` | ||
| 964 | +// carry different probabilities (18101 vs 20229), so a transposed pair is | ||
| 965 | +// only caught by a gate that sees the flag fire on BOTH shapes (class | ||
| 966 | +// scan-weights-cross-axis). | ||
| 967 | +thread_local! { | ||
| 968 | + static FILTER_INTRA_RECT4_HORZ_HITS: std::cell::Cell<usize> = | ||
| 969 | + const { std::cell::Cell::new(0) }; | ||
| 970 | + static FILTER_INTRA_RECT4_VERT_HITS: std::cell::Cell<usize> = | ||
| 971 | + const { std::cell::Cell::new(0) }; | ||
| 972 | +} | ||
| 973 | + | ||
| 974 | +/// Current value of [`FILTER_INTRA_RECT4_HORZ_HITS`] (32x8 strips). | ||
| 975 | +pub(crate) fn filter_intra_rect4_horz_hits() -> usize { | ||
| 976 | + FILTER_INTRA_RECT4_HORZ_HITS.with(|c| c.get()) | ||
| 977 | +} | ||
| 978 | + | ||
| 979 | +/// Current value of [`FILTER_INTRA_RECT4_VERT_HITS`] (8x32 strips). | ||
| 980 | +pub(crate) fn filter_intra_rect4_vert_hits() -> usize { | ||
| 981 | + FILTER_INTRA_RECT4_VERT_HITS.with(|c| c.get()) | ||
| 982 | +} | ||
| 983 | + | ||
| 959 | // As [`FILTER_INTRA_RECT_HITS`], counting only the strips BELOW 16x16 | 984 | // As [`FILTER_INTRA_RECT_HITS`], counting only the strips BELOW 16x16 |
| 960 | // (8x16/16x8 leaves of a 16x16 HORZ/VERT partition, lane-fistrip r1) -- the | 985 | // (8x16/16x8 leaves of a 16x16 HORZ/VERT partition, lane-fistrip r1) -- the |
| 961 | // shapes whose `use_filter_intra` symbol had no CDF class before this round. | 986 | // shapes whose `use_filter_intra` symbol had no CDF class before this round. |
| @@ -4333,6 +4358,14 @@ fn filter_intra_size_class_rect(bw: usize, bh: usize) -> Option<usize> { | |||
| 4333 | // identical mode/uv_mode values, range 34808 vs the oracle's 40668). | 4358 | // identical mode/uv_mode values, range 34808 vs the oracle's 40668). |
| 4334 | (16, 8) => Some(6), | 4359 | (16, 8) => Some(6), |
| 4335 | (8, 16) => Some(7), | 4360 | (8, 16) => Some(7), |
| 4361 | + // lane-fi32x8 r1: same bound, the 32x32-level 1:4 pair | ||
| 4362 | + // (`decode_block_rect4`'s 32x8/8x32 strips). `None` here read no | ||
| 4363 | + // `use_filter_intra` symbol on those strips although aomenc writes | ||
| 4364 | + // one for every DC_PRED block of that shape with | ||
| 4365 | + // `--enable-filter-intra=1` (its default), silently desyncing the | ||
| 4366 | + // tile (class symbol-consumption-gap). | ||
| 4367 | + (32, 8) => Some(8), | ||
| 4368 | + (8, 32) => Some(9), | ||
| 4336 | _ if bw == bh => filter_intra_size_class(bw), | 4369 | _ if bw == bh => filter_intra_size_class(bw), |
| 4337 | _ => None, | 4370 | _ => None, |
| 4338 | } | 4371 | } |
| @@ -5920,6 +5953,11 @@ fn decode_block_rect4( | |||
| 5920 | neighbours.smooth_uv_neighbour(r * (SUB / MI), c * (SUB / MI), r, c); | 5953 | neighbours.smooth_uv_neighbour(r * (SUB / MI), c * (SUB / MI), r, c); |
| 5921 | if filter_intra.is_some() { | 5954 | if filter_intra.is_some() { |
| 5922 | FILTER_INTRA_RECT_HITS.with(|c| c.set(c.get() + 1)); | 5955 | FILTER_INTRA_RECT_HITS.with(|c| c.set(c.get() + 1)); |
| 5956 | + if bw > bh { | ||
| 5957 | + FILTER_INTRA_RECT4_HORZ_HITS.with(|c| c.set(c.get() + 1)); | ||
| 5958 | + } else { | ||
| 5959 | + FILTER_INTRA_RECT4_VERT_HITS.with(|c| c.set(c.get() + 1)); | ||
| 5960 | + } | ||
| 5923 | } | 5961 | } |
| 5924 | let uv_predict_mode = if uv_mode == UV_CFL_PRED { | 5962 | let uv_predict_mode = if uv_mode == UV_CFL_PRED { |
| 5925 | DC_PRED | 5963 | DC_PRED |
| @@ -19037,7 +19075,6 @@ mod tests { | |||
| 19037 | "a partition below 8x8 (this decoder codes no leaf smaller than 8x8)"; | 19075 | "a partition below 8x8 (this decoder codes no leaf smaller than 8x8)"; |
| 19038 | const PART16: &str = "a HORZ_A/HORZ_B/VERT_A partition below 16x16 (this decoder codes \ | 19076 | const PART16: &str = "a HORZ_A/HORZ_B/VERT_A partition below 16x16 (this decoder codes \ |
| 19039 | only the square arms, HORZ, VERT, VERT_B, and a clean split below 16x16)"; | 19077 | only the square arms, HORZ, VERT, VERT_B, and a clean split below 16x16)"; |
| 19040 | - const PART32: &str = "a 32x32 partition type this decoder does not code (value={part32})"; | ||
| 19041 | let libaom: &[(usize, usize, u16, Option<&str>)] = &[ | 19078 | let libaom: &[(usize, usize, u16, Option<&str>)] = &[ |
| 19042 | (4, 4, 4621, None), | 19079 | (4, 4, 4621, None), |
| 19043 | (4, 8, 6743, Some(BELOW_8X8)), | 19080 | (4, 8, 6743, Some(BELOW_8X8)), |
| @@ -19050,12 +19087,15 @@ mod tests { | |||
| 19050 | (32, 16, 12756, None), | 19087 | (32, 16, 12756, None), |
| 19051 | (32, 32, 22343, None), | 19088 | (32, 32, 22343, None), |
| 19052 | // The 1:4 strips: a 16x16-level PARTITION_HORZ_4/VERT_4 gives | 19089 | // The 1:4 strips: a 16x16-level PARTITION_HORZ_4/VERT_4 gives |
| 19053 | - // 4x16/16x4, a 32x32-level one 8x32/32x8, and both partition | 19090 | + // 4x16/16x4 (still refused by name before any leaf is coded), |
| 19054 | - // values refuse by name before any leaf is coded. | 19091 | + // a 32x32-level one 8x32/32x8. |
| 19055 | (4, 16, 12770, Some(PART16)), | 19092 | (4, 16, 12770, Some(PART16)), |
| 19056 | (16, 4, 10368, Some(PART16)), | 19093 | (16, 4, 10368, Some(PART16)), |
| 19057 | - (8, 32, 20229, Some(PART32)), | 19094 | + // lane-fi32x8 r1: the 32-level pair is coded (four 32x8/8x32 |
| 19058 | - (32, 8, 18101, Some(PART32)), | 19095 | + // strips per `PARTITION_HORZ_4`/`VERT_4`) and now owns classes |
| 19096 | + // 8/9; only the 16-level pair is still refused before any leaf. | ||
| 19097 | + (8, 32, 20229, None), | ||
| 19098 | + (32, 8, 18101, None), | ||
| 19059 | ]; | 19099 | ]; |
| 19060 | let mut classes_seen = std::collections::BTreeSet::new(); | 19100 | let mut classes_seen = std::collections::BTreeSet::new(); |
| 19061 | for &(bw, bh, default, refused_by) in libaom { | 19101 | for &(bw, bh, default, refused_by) in libaom { |
crates/ec-av1/src/stream.rsmodified+246 -0
| @@ -16926,6 +16926,252 @@ mod tests { | |||
| 16926 | } | 16926 | } |
| 16927 | } | 16927 | } |
| 16928 | 16928 | ||
| 16929 | + /// lane-fi32x8 r1 (class symbol-consumption-gap): the 32x32-level 1:4 | ||
| 16930 | + /// strips (32x8/8x32) are inside `av1_filter_intra_allowed_bsize`'s | ||
| 16931 | + /// "both sides <= 32" bound, so libaom reads a `use_filter_intra` flag on | ||
| 16932 | + /// every DC_PRED one of them -- and `--enable-filter-intra` is ON by | ||
| 16933 | + /// aomenc default, so the sibling gate above (which spells it `=0`) could | ||
| 16934 | + /// never see it. `filter_intra_size_class_rect` had no row for either | ||
| 16935 | + /// shape, so the symbol was never read and the tile desynced silently | ||
| 16936 | + /// from that strip on. Same band fixture as the sibling (8-px bands + | ||
| 16937 | + /// seeded noise, both orientations), the ONLY recipe change being | ||
| 16938 | + /// `--enable-filter-intra=1` appended AFTER the base recipe (aomenc keeps | ||
| 16939 | + /// the LAST occurrence of a repeated `--enable-*` flag). The counter is | ||
| 16940 | + /// this shape's OWN (`filter_intra_rect4_hits`), not the shared rect one, | ||
| 16941 | + /// so a filter-intra 16x8 strip elsewhere in the frame cannot stand in | ||
| 16942 | + /// for it; only hits earned inside an attempt that then compared | ||
| 16943 | + /// pixel-exact are counted (class gate-skips-on-its-own-failure), and | ||
| 16944 | + /// both bit depths are asserted independently. | ||
| 16945 | + /// | ||
| 16946 | + /// `--enable-tx-size-search=0` is kept from the sibling recipe: a 1:4 | ||
| 16947 | + /// strip with `tx_depth != 0` is still refused by name ("a 32x32-level | ||
| 16948 | + /// 1:4 strip with a split transform"), so a search-on arm would only | ||
| 16949 | + /// harvest refusals, not coverage -- filter intra is proven at depth 0 | ||
| 16950 | + /// here and the per-TU case belongs to the round that lifts that refusal. | ||
| 16951 | + #[test] | ||
| 16952 | + fn a_real_aomenc_stream_with_filter_intra_on_a_32_level_1to4_strip_decodes_pixel_exact() { | ||
| 16953 | + const NAME: &str = | ||
| 16954 | + "a_real_aomenc_stream_with_filter_intra_on_a_32_level_1to4_strip_decodes_pixel_exact"; | ||
| 16955 | + let _gate_lock = lock_gate_counters(); | ||
| 16956 | + if !have_ffmpeg() { | ||
| 16957 | + eprintln!("SKIP {NAME}: no ffmpeg"); | ||
| 16958 | + return; | ||
| 16959 | + } | ||
| 16960 | + if !have_aomenc() { | ||
| 16961 | + eprintln!("SKIP {NAME}: no aomenc at {}", aomenc_path().display()); | ||
| 16962 | + return; | ||
| 16963 | + } | ||
| 16964 | + let (width, height, frame_count) = (192usize, 128usize, 1usize); | ||
| 16965 | + let n_attempts: u32 = std::env::var("EC_FI32X8_GATE_ATTEMPTS") | ||
| 16966 | + .ok() | ||
| 16967 | + .and_then(|s| s.parse().ok()) | ||
| 16968 | + // 16, not 12 (measured, r1): the first attempt whose VERT_4 | ||
| 16969 | + // (8x32) strips pick filter intra at 8 bit is attempt 13. | ||
| 16970 | + .unwrap_or(16); | ||
| 16971 | + for bit_depth in [8u32, 10u32] { | ||
| 16972 | + let mut named_refusals = 0u32; | ||
| 16973 | + let mut matched = 0u32; | ||
| 16974 | + let (mut fi_horz_proved, mut fi_vert_proved, mut strips_proved) = (0usize, 0usize, 0usize); | ||
| 16975 | + let (mut out_of_scope, mut out_of_scope_mismatch) = (0u32, 0u32); | ||
| 16976 | + for attempt in 0..n_attempts { | ||
| 16977 | + let seed = 42 + attempt; | ||
| 16978 | + let duration = frame_count as f64 / 25.0; | ||
| 16979 | + let axis = if attempt % 2 == 0 { "Y" } else { "X" }; | ||
| 16980 | + let step = 67 + (attempt / 2) * 12; | ||
| 16981 | + // A HEAVIER noise layer than the sibling gate's 6..15 (lane-fi32x8 r1, | ||
| 16982 | + // measured): filter intra is what aomenc reaches for when a flat | ||
| 16983 | + // band is noisy, so at 6..15 the flag fired on a 1:4 strip in 3 of | ||
| 16984 | + // 40 8-bit attempts and in NONE of 40 10-bit ones, while at 18..27 | ||
| 16985 | + // it fires in most attempts at BOTH depths. | ||
| 16986 | + let noise = 18 + (attempt % 4) * 3; | ||
| 16987 | + let source = format!( | ||
| 16988 | + "color=c=gray:s={width}x{height}:d={duration}:r=25,format=gray,\ | ||
| 16989 | + geq=lum='mod(floor({axis}/8)*{step},256)',\ | ||
| 16990 | + noise=alls={noise}:all_seed={seed},format=yuv420p" | ||
| 16991 | + ); | ||
| 16992 | + let cq_level = format!("--cq-level={}", [32, 45, 55][(attempt / 2 % 3) as usize]); | ||
| 16993 | + let pix_fmt = if bit_depth == 10 { "yuv420p10le" } else { "yuv420p" }; | ||
| 16994 | + let y4m = Command::new("ffmpeg") | ||
| 16995 | + .args([ | ||
| 16996 | + "-v", "error", "-f", "lavfi", "-i", &source, "-t", &duration.to_string(), | ||
| 16997 | + "-pix_fmt", pix_fmt, "-strict", "-1", "-f", "yuv4mpegpipe", "-", | ||
| 16998 | + ]) | ||
| 16999 | + .stdin(Stdio::null()) | ||
| 17000 | + .stdout(Stdio::piped()) | ||
| 17001 | + .stderr(Stdio::piped()) | ||
| 17002 | + .output() | ||
| 17003 | + .expect("ffmpeg failed to run"); | ||
| 17004 | + assert!( | ||
| 17005 | + y4m.status.success(), | ||
| 17006 | + "{NAME}: ffmpeg refused the {bit_depth}-bit fixture: {}", | ||
| 17007 | + String::from_utf8_lossy(&y4m.stderr) | ||
| 17008 | + ); | ||
| 17009 | + let depth_arg = format!("--bit-depth={bit_depth}"); | ||
| 17010 | + let input_depth_arg = format!("--input-bit-depth={bit_depth}"); | ||
| 17011 | + let args: Vec<&str> = vec![ | ||
| 17012 | + "--codec=av1", | ||
| 17013 | + "--passes=1", | ||
| 17014 | + "--end-usage=q", | ||
| 17015 | + &cq_level, | ||
| 17016 | + "--cpu-used=0", | ||
| 17017 | + "--threads=1", | ||
| 17018 | + "--row-mt=0", | ||
| 17019 | + "--sb-size=64", | ||
| 17020 | + &depth_arg, | ||
| 17021 | + &input_depth_arg, | ||
| 17022 | + "--enable-rect-partitions=1", | ||
| 17023 | + "--enable-ab-partitions=0", | ||
| 17024 | + "--enable-1to4-partitions=1", | ||
| 17025 | + "--min-partition-size=8", | ||
| 17026 | + "--max-partition-size=32", | ||
| 17027 | + "--enable-restoration=0", | ||
| 17028 | + "--enable-palette=0", | ||
| 17029 | + "--deltaq-mode=0", | ||
| 17030 | + "--enable-cfl-intra=0", | ||
| 17031 | + "--enable-intrabc=0", | ||
| 17032 | + "--enable-tx-size-search=0", | ||
| 17033 | + // The competing intra modes off (lane-fi32x8 r1): with | ||
| 17034 | + // directional/paeth/smooth intra available, aomenc's RD | ||
| 17035 | + // picks filter intra on a 32x8 strip in only ~3 of 40 | ||
| 17036 | + // attempts at 8 bit and NEVER at 10 bit (measured, see the | ||
| 17037 | + // r1 report), so this shape's own symbol would go | ||
| 17038 | + // unexercised at 10 bit. Leaving DC and filter intra as | ||
| 17039 | + // the block's luma intra choices makes the flag fire | ||
| 17040 | + // without weakening the gate: every decoded frame is | ||
| 17041 | + // still compared to ffmpeg in full. | ||
| 17042 | + "--enable-directional-intra=0", | ||
| 17043 | + "--enable-paeth-intra=0", | ||
| 17044 | + "--enable-smooth-intra=0", | ||
| 17045 | + // THE override, last (aomenc keeps the last occurrence). | ||
| 17046 | + "--enable-filter-intra=1", | ||
| 17047 | + "--obu", | ||
| 17048 | + "-o", | ||
| 17049 | + "-", | ||
| 17050 | + "-", | ||
| 17051 | + ]; | ||
| 17052 | + let mut child = Command::new(aomenc_path()) | ||
| 17053 | + .args(&args) | ||
| 17054 | + .stdin(Stdio::piped()) | ||
| 17055 | + .stdout(Stdio::piped()) | ||
| 17056 | + .stderr(Stdio::piped()) | ||
| 17057 | + .spawn() | ||
| 17058 | + .expect("aomenc failed to start"); | ||
| 17059 | + child | ||
| 17060 | + .stdin | ||
| 17061 | + .take() | ||
| 17062 | + .expect("aomenc stdin") | ||
| 17063 | + .write_all(&y4m.stdout) | ||
| 17064 | + .expect("writing y4m to aomenc"); | ||
| 17065 | + let out = child.wait_with_output().expect("aomenc failed to run"); | ||
| 17066 | + assert!( | ||
| 17067 | + out.status.success(), | ||
| 17068 | + "aomenc refused the fixture: {}", | ||
| 17069 | + String::from_utf8_lossy(&out.stderr) | ||
| 17070 | + ); | ||
| 17071 | + let stream = out.stdout; | ||
| 17072 | + let before = ( | ||
| 17073 | + crate::decode::filter_intra_rect4_horz_hits(), | ||
| 17074 | + crate::decode::filter_intra_rect4_vert_hits(), | ||
| 17075 | + crate::decode::rect4_32_horz_hits() + crate::decode::rect4_32_vert_hits(), | ||
| 17076 | + ); | ||
| 17077 | + let frames = match decode_stream(&stream) { | ||
| 17078 | + Err(e) => { | ||
| 17079 | + let msg = e.to_string(); | ||
| 17080 | + assert!( | ||
| 17081 | + msg.contains("unsupported"), | ||
| 17082 | + "{NAME} failed outright, not a named refusal ({bit_depth}-bit, seed \ | ||
| 17083 | + {seed}): {msg}" | ||
| 17084 | + ); | ||
| 17085 | + named_refusals += 1; | ||
| 17086 | + eprintln!("{bit_depth}-bit seed {seed} refusal: {msg}"); | ||
| 17087 | + continue; | ||
| 17088 | + } | ||
| 17089 | + Ok(frames) => frames, | ||
| 17090 | + }; | ||
| 17091 | + let (fi_horz, fi_vert, strips) = ( | ||
| 17092 | + crate::decode::filter_intra_rect4_horz_hits() - before.0, | ||
| 17093 | + crate::decode::filter_intra_rect4_vert_hits() - before.1, | ||
| 17094 | + crate::decode::rect4_32_horz_hits() + crate::decode::rect4_32_vert_hits() | ||
| 17095 | + - before.2, | ||
| 17096 | + ); | ||
| 17097 | + let fi = fi_horz + fi_vert; | ||
| 17098 | + let ffmpeg_frames = if bit_depth == 10 { | ||
| 17099 | + ffmpeg_decode_sequence_10bit(&stream, width, height, frame_count) | ||
| 17100 | + } else { | ||
| 17101 | + ffmpeg_decode_sequence(&stream, width, height, frame_count) | ||
| 17102 | + }; | ||
| 17103 | + assert_eq!(frames.len(), frame_count); | ||
| 17104 | + let mismatched = frames | ||
| 17105 | + .iter() | ||
| 17106 | + .zip(&ffmpeg_frames) | ||
| 17107 | + .any(|(got, want)| got.y != want.y || got.u != want.u || got.v != want.v); | ||
| 17108 | + // Per-attempt line (opt-in): which (seed, cq, axis, noise) | ||
| 17109 | + // actually made aomenc pick filter intra ON a 1:4 strip is | ||
| 17110 | + // exactly what a re-tune of this fixture needs, and it is not | ||
| 17111 | + // recoverable from the summary. | ||
| 17112 | + if std::env::var_os("EC_FI32X8_VERBOSE").is_some() { | ||
| 17113 | + eprintln!( | ||
| 17114 | + "{NAME}: {bit_depth}-bit seed {seed} {cq_level} axis={axis} noise={noise} \ | ||
| 17115 | + fi={fi_horz}+{fi_vert} strips={strips} mismatched={mismatched}" | ||
| 17116 | + ); | ||
| 17117 | + } | ||
| 17118 | + if fi == 0 { | ||
| 17119 | + out_of_scope += 1; | ||
| 17120 | + if mismatched { | ||
| 17121 | + out_of_scope_mismatch += 1; | ||
| 17122 | + eprintln!( | ||
| 17123 | + "{NAME}: {bit_depth}-bit seed {seed} MISMATCHES with zero \ | ||
| 17124 | + filter-intra 1:4 strips ({strips} plain 1:4 strips) -- a defect of \ | ||
| 17125 | + another shape" | ||
| 17126 | + ); | ||
| 17127 | + } | ||
| 17128 | + continue; | ||
| 17129 | + } | ||
| 17130 | + for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() { | ||
| 17131 | + assert_eq!( | ||
| 17132 | + got.y, want.y, | ||
| 17133 | + "{NAME} frame {i} luma vs ffmpeg ({bit_depth}-bit, seed {seed})" | ||
| 17134 | + ); | ||
| 17135 | + assert_eq!( | ||
| 17136 | + got.u, want.u, | ||
| 17137 | + "{NAME} frame {i} U vs ffmpeg ({bit_depth}-bit, seed {seed})" | ||
| 17138 | + ); | ||
| 17139 | + assert_eq!( | ||
| 17140 | + got.v, want.v, | ||
| 17141 | + "{NAME} frame {i} V vs ffmpeg ({bit_depth}-bit, seed {seed})" | ||
| 17142 | + ); | ||
| 17143 | + } | ||
| 17144 | + fi_horz_proved += fi_horz; | ||
| 17145 | + fi_vert_proved += fi_vert; | ||
| 17146 | + strips_proved += strips; | ||
| 17147 | + matched += 1; | ||
| 17148 | + } | ||
| 17149 | + // BOTH orientations, per bit depth: rows 8/9 of `cdf::FILTER_INTRA` | ||
| 17150 | + // are asymmetric (18101 for 32x8, 20229 for 8x32), so a one-sided | ||
| 17151 | + // assert would pass on a transposed pair. | ||
| 17152 | + assert!( | ||
| 17153 | + fi_horz_proved > 0 && fi_vert_proved > 0 && matched > 0, | ||
| 17154 | + "{NAME}: a 32x8/8x32 strip orientation never read use_filter_intra=1 inside a \ | ||
| 17155 | + pixel-exact {bit_depth}-bit attempt (32x8={fi_horz_proved}, \ | ||
| 17156 | + 8x32={fi_vert_proved}, {matched} matches, {named_refusals} refusals, \ | ||
| 17157 | + {out_of_scope} attempts with no filter-intra 1:4 strip, out of {n_attempts}) \ | ||
| 17158 | + -- gate proved nothing this run" | ||
| 17159 | + ); | ||
| 17160 | + eprintln!( | ||
| 17161 | + "{NAME}: {bit_depth}-bit: {named_refusals} named refusals, {matched} pixel-exact \ | ||
| 17162 | + matches out of {n_attempts}, filter-intra 1:4 strips={fi_horz_proved}x(32x8)+{fi_vert_proved}x(8x32) of \ | ||
| 17163 | + {strips_proved} 1:4 strips, {out_of_scope} attempts carried none \ | ||
| 17164 | + ({out_of_scope_mismatch} mismatched)" | ||
| 17165 | + ); | ||
| 17166 | + assert_eq!( | ||
| 17167 | + out_of_scope_mismatch, 0, | ||
| 17168 | + "{NAME}: {bit_depth}-bit: {out_of_scope_mismatch} attempt(s) with zero \ | ||
| 17169 | + filter-intra 1:4 strips decoded but mismatched ffmpeg -- a defect of another \ | ||
| 17170 | + shape, not a pass" | ||
| 17171 | + ); | ||
| 17172 | + } | ||
| 17173 | + } | ||
| 17174 | + | ||
| 16929 | /// lane-tiles r11: every tile gate before this one turns the coding tools | 17175 | /// lane-tiles r11: every tile gate before this one turns the coding tools |
| 16930 | /// OFF (rect/ab partitions, tx-size search, cdef, restoration all `=0`) | 17176 | /// OFF (rect/ab partitions, tx-size search, cdef, restoration all `=0`) |
| 16931 | /// to isolate the per-tile loop, which is exactly the | 17177 | /// to isolate the per-tile loop, which is exactly the |
lanes/fi32x8-r1.report.mdadded+102 -0
| @@ -0,0 +1,102 @@ | |||
| 1 | +# lane-fi32x8 r1 — 32x8/8x32 strips read `use_filter_intra` | ||
| 2 | + | ||
| 3 | +## Defect (class symbol-consumption-gap), confirmed on main 11633d7 | ||
| 4 | + | ||
| 5 | +`decode_block_rect4` (decode.rs:5817) decodes the 32x32-level `PARTITION_HORZ_4`/ | ||
| 6 | +`PARTITION_VERT_4` arms — four 32x8 (or 8x32) strips — and hands `(bw, bh)` to | ||
| 7 | +`read_intra_mode_rect`, but `filter_intra_size_class_rect` returned `None` for both | ||
| 8 | +shapes, so the `use_filter_intra` symbol libaom writes for every DC_PRED block inside | ||
| 9 | +`av1_filter_intra_allowed_bsize` ("both sides <= 32") was never read there. Since | ||
| 10 | +`--enable-filter-intra` is ON by aomenc default, any such stream desynced the tile | ||
| 11 | +silently from that strip on. Every gate that reached these strips spelled | ||
| 12 | +`--enable-filter-intra=0`, so nothing could see it ([[tool-disabled-in-every-gate]]). | ||
| 13 | + | ||
| 14 | +## Changes | ||
| 15 | + | ||
| 16 | +- `crates/ec-av1/src/cdf.rs:466` — `FILTER_INTRA` grows to 10 rows: `[8] = 18101` | ||
| 17 | + (BLOCK_32X8, BLOCK_SIZES_ALL index 19), `[9] = 20229` (BLOCK_8X32, index 18). Values | ||
| 18 | + come from `scripts/extract-filter-intra-cdfs.py` against `~/.cache/aom-oracle/src`, | ||
| 19 | + not hand transcription. | ||
| 20 | +- `crates/ec-av1/src/cdf_state.rs:544` — the `Cdfs::filter_intra` field's array size. | ||
| 21 | +- `crates/ec-av1/src/decode.rs:4292` — `filter_intra_size_class_rect` maps `(32, 8) => | ||
| 22 | + 8`, `(8, 32) => 9`. | ||
| 23 | +- `crates/ec-av1/src/decode.rs:950` — new orientation-split counters | ||
| 24 | + `FILTER_INTRA_RECT4_HORZ_HITS` / `..._VERT_HITS` (rows 8/9 are asymmetric, so a | ||
| 25 | + one-sided gate would pass on a transposed pair), incremented in `decode_block_rect4`. | ||
| 26 | +- `crates/ec-av1/src/decode.rs` domain test | ||
| 27 | + `filter_intra_classes_carry_their_own_libaom_default_row` — `(8, 32)`/`(32, 8)` move | ||
| 28 | + from "refused before any leaf (PART32)" to owning a class; the stale `PART32` refusal | ||
| 29 | + string is gone. The 16-level pair (4x16/16x4) is still listed as refused. | ||
| 30 | +- `crates/ec-av1/src/stream.rs:16940` — the gate (below). | ||
| 31 | + | ||
| 32 | +No refusal string was lifted this round, so `refusal_inventory.rs` is untouched: the | ||
| 33 | +32-level 1:4 partition was already decoded, only its filter-intra symbol was missing. | ||
| 34 | +Prediction needed no new code — `predict_filter_intra` is already generic in `(bw, bh)` | ||
| 35 | +(lane-rectsplit r1) and `reconstruct_rect` already routes `filter_intra` into it. No | ||
| 36 | +`fi_tx_row` remap is needed at this shape either: `TxbSet::LumaRect32x8` carries | ||
| 37 | +`tx_type: None` (tx_size_sqr_up is TX_32X32, ext-tx set 0), so no `tx_type` symbol is | ||
| 38 | +read on a 32x8/8x32 luma block at all. | ||
| 39 | + | ||
| 40 | +## Gate | ||
| 41 | + | ||
| 42 | +`stream::tests::a_real_aomenc_stream_with_filter_intra_on_a_32_level_1to4_strip_decodes_pixel_exact` | ||
| 43 | + | ||
| 44 | +Sibling band fixture (8-px bands + seeded noise, both orientations), 192x128, cpu-used=0, | ||
| 45 | +`--enable-1to4-partitions=1 --min-partition-size=8 --max-partition-size=32 | ||
| 46 | +--enable-tx-size-search=0`, with `--enable-filter-intra=1` appended LAST (aomenc keeps the | ||
| 47 | +last occurrence of a repeated `--enable-*`). 16 attempts per bit depth; every decoded | ||
| 48 | +attempt is pixel-compared against ffmpeg (no SKIP on a mismatch or a decode error), and | ||
| 49 | +per bit depth the gate HARD-asserts filter-intra hits on BOTH shapes inside pixel-exact | ||
| 50 | +attempts, plus `out_of_scope_mismatch == 0`. | ||
| 51 | + | ||
| 52 | +Run: | ||
| 53 | +``` | ||
| 54 | +systemd-run --user --scope -q -p MemoryMax=6G env CARGO_TARGET_DIR=$HOME/.cache/cargo-target-fi32x8 \ | ||
| 55 | + EC_NOMEMGUARD=1 EC_AV1_REQUIRE_AOMENC=1 nice -n 10 cargo test -p ec-av1 --lib -j3 -- \ | ||
| 56 | + --nocapture filter_intra | ||
| 57 | +``` | ||
| 58 | +Result: `test result: ok. 7 passed; 0 failed; 2 ignored` (17.3 s). | ||
| 59 | + | ||
| 60 | +EVIDENCE: $HOME/.cache/cargo-target-fi32x8 gate stdout | 16 aomenc encodes per depth, each decoded by ec-av1 and by ffmpeg, full-frame Y/U/V compare | 8-bit: 4 pixel-exact matches, filter-intra 1:4 strips = 27x(32x8) + 14x(8x32) of 232; 10-bit: 5 matches, 9x(32x8) + 20x(8x32) of 332; 0 out-of-scope mismatches at either depth | ||
| 61 | + | ||
| 62 | +### Fixture tuning (measured, not guessed) | ||
| 63 | + | ||
| 64 | +The sibling gate's noise level (6..15) is too low: with it, filter intra was picked on a | ||
| 65 | +1:4 strip in 3 of 40 8-bit attempts and in **0 of 40** 10-bit ones (`EC_FI32X8_VERBOSE=1` | ||
| 66 | +per-attempt lines). Raising the noise layer to 18..27 makes the flag fire in most | ||
| 67 | +attempts at both depths — filter intra is what aomenc's RD reaches for on a noisy flat | ||
| 68 | +band. A gradient-ramp variant and `--cq-level=63` were both tried and dropped: cq 63 | ||
| 69 | +mismatches on this fixture *with filter intra disabled* (see residue). | ||
| 70 | + | ||
| 71 | +`EC_FI32X8_GATE_ATTEMPTS` (default 16 — attempt 13 is the first 8-bit VERT_4 firing) and | ||
| 72 | +`EC_FI32X8_VERBOSE` are the only knobs kept. | ||
| 73 | + | ||
| 74 | +## Suite | ||
| 75 | + | ||
| 76 | +`systemd-run --user --unit=fi32x8-suite-... -p MemoryMax=10G ... cargo test -p ec-av1 --lib -j3` | ||
| 77 | +→ `$HOME/.cache/fi32x8-suite.log`: | ||
| 78 | +`test result: FAILED. 339 passed; 1 failed; 31 ignored` (428.5 s). | ||
| 79 | + | ||
| 80 | +The one failure is `stream::tests::a_real_aomenc_multi_tile_intra_stream_decodes_pixel_exact` | ||
| 81 | +(frame 0 **U** plane, seed 46) and it is **PRE-EXISTING on main 11633d7**, not this lane's: | ||
| 82 | +the same test fails identically on a detached worktree at 11633d7 with its own target dir | ||
| 83 | +(`$HOME/.cache/fi32x8-mainbase.log`, `stream.rs:17191` there vs `:17437` here — same | ||
| 84 | +assertion, same seed, same plane). | ||
| 85 | + | ||
| 86 | +EVIDENCE: $HOME/.cache/fi32x8-suite.log + $HOME/.cache/fi32x8-mainbase.log | full ec-av1 --lib suite on lane 76959e5 and the multi-tile gate on a detached worktree at main 11633d7 | lane 339 passed/1 failed/31 ignored; the single failure reproduces byte-identically on main (frame 0 U, seed 46), so 0 regressions from this round | ||
| 87 | + | ||
| 88 | +## Residue | ||
| 89 | + | ||
| 90 | +- deferred: `a_real_aomenc_multi_tile_intra_stream_decodes_pixel_exact` seed 46 frame 0 U | ||
| 91 | + mismatch — reproduced on main 11633d7 unchanged, so it belongs to the lane-tiles / | ||
| 92 | + chroma territory, not here — what unblocks it: a bisect of that seed's chroma plane | ||
| 93 | + against aomdec (`EC_TRACE_MODE`) on main. | ||
| 94 | +- deferred: an 8-bit/10-bit mismatch of ANOTHER shape on this band fixture at | ||
| 95 | + `--cq-level=63` (seeds 58/59/64) — reproduced with `--enable-filter-intra=0`, so it | ||
| 96 | + predates this round and is not a filter-intra defect — what unblocks it: a lane that | ||
| 97 | + bisects the cq-63 stream (the 1:4 strip counters read 8..44 there, so it is inside the | ||
| 98 | + 1:4 territory). This gate stays at cq 32/45/55 to avoid the confound. | ||
| 99 | +- accepted: filter intra on a 1:4 strip with `tx_depth != 0` is still refused by name | ||
| 100 | + ("a 32x32-level 1:4 strip with a split transform ... depth={depth}"); per-TU filter | ||
| 101 | + intra belongs to the round that lifts that refusal. The gate keeps | ||
| 102 | + `--enable-tx-size-search=0`, so a search-on arm would only harvest that refusal. | ||