Merge branch 'lane-fi32x8': 32x8/8x32 strips read use_filter_intra (rows were missing; aomenc default on)
Browse files at this commit5 changed files +405 -8
- crates/ec-av1/src/cdf.rs +10 -1
- crates/ec-av1/src/cdf_state.rs +2 -2
- 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
| @@ -470,7 +470,14 @@ pub const CFL_SIGN: [u16; 9] = [1418, 2123, 13340, 18405, 26972, 28343, 32294, 3 | |||
| 470 | /// one of them; before this round that read took `BLOCK_4X4`'s row (class 0), | 470 | /// one of them; before this round that read took `BLOCK_4X4`'s row (class 0), |
| 471 | /// the same value with a different interval (class `wrong-alphabet-same-value` | 471 | /// the same value with a different interval (class `wrong-alphabet-same-value` |
| 472 | /// / `cdf-row-held-constant`). | 472 | /// / `cdf-row-held-constant`). |
| 473 | -pub const FILTER_INTRA: [[u16; 3]; 10] = [ | 473 | +/// `[10]`/`[11]` (lane-fi32x8 r1) add `BLOCK_32X8`/`BLOCK_8X32`'s own rows |
| 474 | +/// (18101/20229, `default_filter_intra_cdfs` index 19/18 -- generated by | ||
| 475 | +/// `scripts/extract-filter-intra-cdfs.py`): the four 32x8 (or 8x32) strips a | ||
| 476 | +/// 32x32-level `PARTITION_HORZ_4`/`VERT_4` codes are inside | ||
| 477 | +/// `av1_filter_intra_allowed_bsize`'s "both sides <= 32" bound, so libaom | ||
| 478 | +/// reads `use_filter_intra` there too and the missing rows dropped the | ||
| 479 | +/// symbol on every DC_PRED 1:4 strip. | ||
| 480 | +pub const FILTER_INTRA: [[u16; 3]; 12] = [ | ||
| 474 | [4621, 32768, 0], | 481 | [4621, 32768, 0], |
| 475 | [7866, 32768, 0], | 482 | [7866, 32768, 0], |
| 476 | [12408, 32768, 0], | 483 | [12408, 32768, 0], |
| @@ -481,6 +488,8 @@ pub const FILTER_INTRA: [[u16; 3]; 10] = [ | |||
| 481 | [12551, 32768, 0], | 488 | [12551, 32768, 0], |
| 482 | [6743, 32768, 0], | 489 | [6743, 32768, 0], |
| 483 | [5893, 32768, 0], | 490 | [5893, 32768, 0], |
| 491 | + [18101, 32768, 0], | ||
| 492 | + [20229, 32768, 0], | ||
| 484 | ]; | 493 | ]; |
| 485 | /// `default_filter_intra_mode_cdf` (entropymode.c): which of the five | 494 | /// `default_filter_intra_mode_cdf` (entropymode.c): which of the five |
| 486 | /// `FILTER_INTRA_MODES` a `use_filter_intra` block picks. | 495 | /// `FILTER_INTRA_MODES` a `use_filter_intra` block picks. |
crates/ec-av1/src/cdf_state.rsmodified+2 -2
| @@ -539,9 +539,9 @@ pub(crate) struct Cdfs { | |||
| 539 | pub dv_comp: [MvComponentCdfs; 2], | 539 | pub dv_comp: [MvComponentCdfs; 2], |
| 540 | /// The `use_filter_intra` flag, indexed by block-size class (`[0]`=4x4, | 540 | /// The `use_filter_intra` flag, indexed by block-size class (`[0]`=4x4, |
| 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, `[8]`=4x8, `[9]`=8x4) -- | 542 | + /// `[6]`=16x8, `[7]`=8x16, `[8]`=4x8, `[9]`=8x4, `[10]`=32x8, `[11]`=8x32) -- |
| 543 | /// see [`cdf::FILTER_INTRA`]. | 543 | /// see [`cdf::FILTER_INTRA`]. |
| 544 | - pub filter_intra: [[u16; 3]; 10], | 544 | + pub filter_intra: [[u16; 3]; 12], |
| 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
| @@ -1029,6 +1029,31 @@ pub(crate) fn filter_intra_rect_hits() -> usize { | |||
| 1029 | FILTER_INTRA_RECT_HITS.with(|c| c.get()) | 1029 | FILTER_INTRA_RECT_HITS.with(|c| c.get()) |
| 1030 | } | 1030 | } |
| 1031 | 1031 | ||
| 1032 | +// As [`FILTER_INTRA_RECT_HITS`], counting only the 32x32-level 1:4 strips | ||
| 1033 | +// (32x8/8x32, lane-fi32x8 r1) -- the shapes whose `use_filter_intra` symbol | ||
| 1034 | +// was never read at all before that round, so a gate needs to prove the flag | ||
| 1035 | +// fired at THAT shape and not at a 16x8 one somewhere else in the frame. | ||
| 1036 | +// Split by ORIENTATION: rows 8 (32x8) and 9 (8x32) of `cdf::FILTER_INTRA` | ||
| 1037 | +// carry different probabilities (18101 vs 20229), so a transposed pair is | ||
| 1038 | +// only caught by a gate that sees the flag fire on BOTH shapes (class | ||
| 1039 | +// scan-weights-cross-axis). | ||
| 1040 | +thread_local! { | ||
| 1041 | + static FILTER_INTRA_RECT4_HORZ_HITS: std::cell::Cell<usize> = | ||
| 1042 | + const { std::cell::Cell::new(0) }; | ||
| 1043 | + static FILTER_INTRA_RECT4_VERT_HITS: std::cell::Cell<usize> = | ||
| 1044 | + const { std::cell::Cell::new(0) }; | ||
| 1045 | +} | ||
| 1046 | + | ||
| 1047 | +/// Current value of [`FILTER_INTRA_RECT4_HORZ_HITS`] (32x8 strips). | ||
| 1048 | +pub(crate) fn filter_intra_rect4_horz_hits() -> usize { | ||
| 1049 | + FILTER_INTRA_RECT4_HORZ_HITS.with(|c| c.get()) | ||
| 1050 | +} | ||
| 1051 | + | ||
| 1052 | +/// Current value of [`FILTER_INTRA_RECT4_VERT_HITS`] (8x32 strips). | ||
| 1053 | +pub(crate) fn filter_intra_rect4_vert_hits() -> usize { | ||
| 1054 | + FILTER_INTRA_RECT4_VERT_HITS.with(|c| c.get()) | ||
| 1055 | +} | ||
| 1056 | + | ||
| 1032 | // As [`FILTER_INTRA_RECT_HITS`], counting only the strips BELOW 16x16 | 1057 | // As [`FILTER_INTRA_RECT_HITS`], counting only the strips BELOW 16x16 |
| 1033 | // (8x16/16x8 leaves of a 16x16 HORZ/VERT partition, lane-fistrip r1) -- the | 1058 | // (8x16/16x8 leaves of a 16x16 HORZ/VERT partition, lane-fistrip r1) -- the |
| 1034 | // shapes whose `use_filter_intra` symbol had no CDF class before this round. | 1059 | // shapes whose `use_filter_intra` symbol had no CDF class before this round. |
| @@ -4433,6 +4458,14 @@ fn filter_intra_size_class_rect(bw: usize, bh: usize) -> Option<usize> { | |||
| 4433 | // `default_filter_intra_cdfs`, NOT BLOCK_4X4's row 0. | 4458 | // `default_filter_intra_cdfs`, NOT BLOCK_4X4's row 0. |
| 4434 | (4, 8) => Some(8), | 4459 | (4, 8) => Some(8), |
| 4435 | (8, 4) => Some(9), | 4460 | (8, 4) => Some(9), |
| 4461 | + // lane-fi32x8 r1: same bound, the 32x32-level 1:4 pair | ||
| 4462 | + // (`decode_block_rect4`'s 32x8/8x32 strips). `None` here read no | ||
| 4463 | + // `use_filter_intra` symbol on those strips although aomenc writes | ||
| 4464 | + // one for every DC_PRED block of that shape with | ||
| 4465 | + // `--enable-filter-intra=1` (its default), silently desyncing the | ||
| 4466 | + // tile (class symbol-consumption-gap). | ||
| 4467 | + (32, 8) => Some(10), | ||
| 4468 | + (8, 32) => Some(11), | ||
| 4436 | _ if bw == bh => filter_intra_size_class(bw), | 4469 | _ if bw == bh => filter_intra_size_class(bw), |
| 4437 | _ => None, | 4470 | _ => None, |
| 4438 | } | 4471 | } |
| @@ -6053,6 +6086,11 @@ fn decode_block_rect4( | |||
| 6053 | neighbours.smooth_uv_neighbour(r * (SUB / MI), c * (SUB / MI), r, c); | 6086 | neighbours.smooth_uv_neighbour(r * (SUB / MI), c * (SUB / MI), r, c); |
| 6054 | if filter_intra.is_some() { | 6087 | if filter_intra.is_some() { |
| 6055 | FILTER_INTRA_RECT_HITS.with(|c| c.set(c.get() + 1)); | 6088 | FILTER_INTRA_RECT_HITS.with(|c| c.set(c.get() + 1)); |
| 6089 | + if bw > bh { | ||
| 6090 | + FILTER_INTRA_RECT4_HORZ_HITS.with(|c| c.set(c.get() + 1)); | ||
| 6091 | + } else { | ||
| 6092 | + FILTER_INTRA_RECT4_VERT_HITS.with(|c| c.set(c.get() + 1)); | ||
| 6093 | + } | ||
| 6056 | } | 6094 | } |
| 6057 | let uv_predict_mode = if uv_mode == UV_CFL_PRED { | 6095 | let uv_predict_mode = if uv_mode == UV_CFL_PRED { |
| 6058 | DC_PRED | 6096 | DC_PRED |
| @@ -19223,7 +19261,6 @@ mod tests { | |||
| 19223 | // land a wrong CDF row for the shape it unlocks. | 19261 | // land a wrong CDF row for the shape it unlocks. |
| 19224 | const PART16: &str = "a HORZ_A/HORZ_B/VERT_A partition below 16x16 (this decoder codes \ | 19262 | const PART16: &str = "a HORZ_A/HORZ_B/VERT_A partition below 16x16 (this decoder codes \ |
| 19225 | only the square arms, HORZ, VERT, VERT_B, and a clean split below 16x16)"; | 19263 | only the square arms, HORZ, VERT, VERT_B, and a clean split below 16x16)"; |
| 19226 | - const PART32: &str = "a 32x32 partition type this decoder does not code (value={part32})"; | ||
| 19227 | let libaom: &[(usize, usize, u16, Option<&str>)] = &[ | 19264 | let libaom: &[(usize, usize, u16, Option<&str>)] = &[ |
| 19228 | (4, 4, 4621, None), | 19265 | (4, 4, 4621, None), |
| 19229 | (4, 8, 6743, None), | 19266 | (4, 8, 6743, None), |
| @@ -19236,12 +19273,15 @@ mod tests { | |||
| 19236 | (32, 16, 12756, None), | 19273 | (32, 16, 12756, None), |
| 19237 | (32, 32, 22343, None), | 19274 | (32, 32, 22343, None), |
| 19238 | // The 1:4 strips: a 16x16-level PARTITION_HORZ_4/VERT_4 gives | 19275 | // The 1:4 strips: a 16x16-level PARTITION_HORZ_4/VERT_4 gives |
| 19239 | - // 4x16/16x4, a 32x32-level one 8x32/32x8, and both partition | 19276 | + // 4x16/16x4 (still refused by name before any leaf is coded), |
| 19240 | - // values refuse by name before any leaf is coded. | 19277 | + // a 32x32-level one 8x32/32x8. |
| 19241 | (4, 16, 12770, Some(PART16)), | 19278 | (4, 16, 12770, Some(PART16)), |
| 19242 | (16, 4, 10368, Some(PART16)), | 19279 | (16, 4, 10368, Some(PART16)), |
| 19243 | - (8, 32, 20229, Some(PART32)), | 19280 | + // lane-fi32x8 r1: the 32-level pair is coded (four 32x8/8x32 |
| 19244 | - (32, 8, 18101, Some(PART32)), | 19281 | + // strips per `PARTITION_HORZ_4`/`VERT_4`) and now owns classes |
| 19282 | + // 10/11; only the 16-level pair is still refused before any leaf. | ||
| 19283 | + (8, 32, 20229, None), | ||
| 19284 | + (32, 8, 18101, None), | ||
| 19245 | ]; | 19285 | ]; |
| 19246 | let mut classes_seen = std::collections::BTreeSet::new(); | 19286 | let mut classes_seen = std::collections::BTreeSet::new(); |
| 19247 | for &(bw, bh, default, refused_by) in libaom { | 19287 | for &(bw, bh, default, refused_by) in libaom { |
crates/ec-av1/src/stream.rsmodified+246 -0
| @@ -17600,6 +17600,252 @@ mod tests { | |||
| 17600 | } | 17600 | } |
| 17601 | } | 17601 | } |
| 17602 | 17602 | ||
| 17603 | + /// lane-fi32x8 r1 (class symbol-consumption-gap): the 32x32-level 1:4 | ||
| 17604 | + /// strips (32x8/8x32) are inside `av1_filter_intra_allowed_bsize`'s | ||
| 17605 | + /// "both sides <= 32" bound, so libaom reads a `use_filter_intra` flag on | ||
| 17606 | + /// every DC_PRED one of them -- and `--enable-filter-intra` is ON by | ||
| 17607 | + /// aomenc default, so the sibling gate above (which spells it `=0`) could | ||
| 17608 | + /// never see it. `filter_intra_size_class_rect` had no row for either | ||
| 17609 | + /// shape, so the symbol was never read and the tile desynced silently | ||
| 17610 | + /// from that strip on. Same band fixture as the sibling (8-px bands + | ||
| 17611 | + /// seeded noise, both orientations), the ONLY recipe change being | ||
| 17612 | + /// `--enable-filter-intra=1` appended AFTER the base recipe (aomenc keeps | ||
| 17613 | + /// the LAST occurrence of a repeated `--enable-*` flag). The counter is | ||
| 17614 | + /// this shape's OWN (`filter_intra_rect4_hits`), not the shared rect one, | ||
| 17615 | + /// so a filter-intra 16x8 strip elsewhere in the frame cannot stand in | ||
| 17616 | + /// for it; only hits earned inside an attempt that then compared | ||
| 17617 | + /// pixel-exact are counted (class gate-skips-on-its-own-failure), and | ||
| 17618 | + /// both bit depths are asserted independently. | ||
| 17619 | + /// | ||
| 17620 | + /// `--enable-tx-size-search=0` is kept from the sibling recipe: a 1:4 | ||
| 17621 | + /// strip with `tx_depth != 0` is still refused by name ("a 32x32-level | ||
| 17622 | + /// 1:4 strip with a split transform"), so a search-on arm would only | ||
| 17623 | + /// harvest refusals, not coverage -- filter intra is proven at depth 0 | ||
| 17624 | + /// here and the per-TU case belongs to the round that lifts that refusal. | ||
| 17625 | + #[test] | ||
| 17626 | + fn a_real_aomenc_stream_with_filter_intra_on_a_32_level_1to4_strip_decodes_pixel_exact() { | ||
| 17627 | + const NAME: &str = | ||
| 17628 | + "a_real_aomenc_stream_with_filter_intra_on_a_32_level_1to4_strip_decodes_pixel_exact"; | ||
| 17629 | + let _gate_lock = lock_gate_counters(); | ||
| 17630 | + if !have_ffmpeg() { | ||
| 17631 | + eprintln!("SKIP {NAME}: no ffmpeg"); | ||
| 17632 | + return; | ||
| 17633 | + } | ||
| 17634 | + if !have_aomenc() { | ||
| 17635 | + eprintln!("SKIP {NAME}: no aomenc at {}", aomenc_path().display()); | ||
| 17636 | + return; | ||
| 17637 | + } | ||
| 17638 | + let (width, height, frame_count) = (192usize, 128usize, 1usize); | ||
| 17639 | + let n_attempts: u32 = std::env::var("EC_FI32X8_GATE_ATTEMPTS") | ||
| 17640 | + .ok() | ||
| 17641 | + .and_then(|s| s.parse().ok()) | ||
| 17642 | + // 16, not 12 (measured, r1): the first attempt whose VERT_4 | ||
| 17643 | + // (8x32) strips pick filter intra at 8 bit is attempt 13. | ||
| 17644 | + .unwrap_or(16); | ||
| 17645 | + for bit_depth in [8u32, 10u32] { | ||
| 17646 | + let mut named_refusals = 0u32; | ||
| 17647 | + let mut matched = 0u32; | ||
| 17648 | + let (mut fi_horz_proved, mut fi_vert_proved, mut strips_proved) = (0usize, 0usize, 0usize); | ||
| 17649 | + let (mut out_of_scope, mut out_of_scope_mismatch) = (0u32, 0u32); | ||
| 17650 | + for attempt in 0..n_attempts { | ||
| 17651 | + let seed = 42 + attempt; | ||
| 17652 | + let duration = frame_count as f64 / 25.0; | ||
| 17653 | + let axis = if attempt % 2 == 0 { "Y" } else { "X" }; | ||
| 17654 | + let step = 67 + (attempt / 2) * 12; | ||
| 17655 | + // A HEAVIER noise layer than the sibling gate's 6..15 (lane-fi32x8 r1, | ||
| 17656 | + // measured): filter intra is what aomenc reaches for when a flat | ||
| 17657 | + // band is noisy, so at 6..15 the flag fired on a 1:4 strip in 3 of | ||
| 17658 | + // 40 8-bit attempts and in NONE of 40 10-bit ones, while at 18..27 | ||
| 17659 | + // it fires in most attempts at BOTH depths. | ||
| 17660 | + let noise = 18 + (attempt % 4) * 3; | ||
| 17661 | + let source = format!( | ||
| 17662 | + "color=c=gray:s={width}x{height}:d={duration}:r=25,format=gray,\ | ||
| 17663 | + geq=lum='mod(floor({axis}/8)*{step},256)',\ | ||
| 17664 | + noise=alls={noise}:all_seed={seed},format=yuv420p" | ||
| 17665 | + ); | ||
| 17666 | + let cq_level = format!("--cq-level={}", [32, 45, 55][(attempt / 2 % 3) as usize]); | ||
| 17667 | + let pix_fmt = if bit_depth == 10 { "yuv420p10le" } else { "yuv420p" }; | ||
| 17668 | + let y4m = Command::new("ffmpeg") | ||
| 17669 | + .args([ | ||
| 17670 | + "-v", "error", "-f", "lavfi", "-i", &source, "-t", &duration.to_string(), | ||
| 17671 | + "-pix_fmt", pix_fmt, "-strict", "-1", "-f", "yuv4mpegpipe", "-", | ||
| 17672 | + ]) | ||
| 17673 | + .stdin(Stdio::null()) | ||
| 17674 | + .stdout(Stdio::piped()) | ||
| 17675 | + .stderr(Stdio::piped()) | ||
| 17676 | + .output() | ||
| 17677 | + .expect("ffmpeg failed to run"); | ||
| 17678 | + assert!( | ||
| 17679 | + y4m.status.success(), | ||
| 17680 | + "{NAME}: ffmpeg refused the {bit_depth}-bit fixture: {}", | ||
| 17681 | + String::from_utf8_lossy(&y4m.stderr) | ||
| 17682 | + ); | ||
| 17683 | + let depth_arg = format!("--bit-depth={bit_depth}"); | ||
| 17684 | + let input_depth_arg = format!("--input-bit-depth={bit_depth}"); | ||
| 17685 | + let args: Vec<&str> = vec![ | ||
| 17686 | + "--codec=av1", | ||
| 17687 | + "--passes=1", | ||
| 17688 | + "--end-usage=q", | ||
| 17689 | + &cq_level, | ||
| 17690 | + "--cpu-used=0", | ||
| 17691 | + "--threads=1", | ||
| 17692 | + "--row-mt=0", | ||
| 17693 | + "--sb-size=64", | ||
| 17694 | + &depth_arg, | ||
| 17695 | + &input_depth_arg, | ||
| 17696 | + "--enable-rect-partitions=1", | ||
| 17697 | + "--enable-ab-partitions=0", | ||
| 17698 | + "--enable-1to4-partitions=1", | ||
| 17699 | + "--min-partition-size=8", | ||
| 17700 | + "--max-partition-size=32", | ||
| 17701 | + "--enable-restoration=0", | ||
| 17702 | + "--enable-palette=0", | ||
| 17703 | + "--deltaq-mode=0", | ||
| 17704 | + "--enable-cfl-intra=0", | ||
| 17705 | + "--enable-intrabc=0", | ||
| 17706 | + "--enable-tx-size-search=0", | ||
| 17707 | + // The competing intra modes off (lane-fi32x8 r1): with | ||
| 17708 | + // directional/paeth/smooth intra available, aomenc's RD | ||
| 17709 | + // picks filter intra on a 32x8 strip in only ~3 of 40 | ||
| 17710 | + // attempts at 8 bit and NEVER at 10 bit (measured, see the | ||
| 17711 | + // r1 report), so this shape's own symbol would go | ||
| 17712 | + // unexercised at 10 bit. Leaving DC and filter intra as | ||
| 17713 | + // the block's luma intra choices makes the flag fire | ||
| 17714 | + // without weakening the gate: every decoded frame is | ||
| 17715 | + // still compared to ffmpeg in full. | ||
| 17716 | + "--enable-directional-intra=0", | ||
| 17717 | + "--enable-paeth-intra=0", | ||
| 17718 | + "--enable-smooth-intra=0", | ||
| 17719 | + // THE override, last (aomenc keeps the last occurrence). | ||
| 17720 | + "--enable-filter-intra=1", | ||
| 17721 | + "--obu", | ||
| 17722 | + "-o", | ||
| 17723 | + "-", | ||
| 17724 | + "-", | ||
| 17725 | + ]; | ||
| 17726 | + let mut child = Command::new(aomenc_path()) | ||
| 17727 | + .args(&args) | ||
| 17728 | + .stdin(Stdio::piped()) | ||
| 17729 | + .stdout(Stdio::piped()) | ||
| 17730 | + .stderr(Stdio::piped()) | ||
| 17731 | + .spawn() | ||
| 17732 | + .expect("aomenc failed to start"); | ||
| 17733 | + child | ||
| 17734 | + .stdin | ||
| 17735 | + .take() | ||
| 17736 | + .expect("aomenc stdin") | ||
| 17737 | + .write_all(&y4m.stdout) | ||
| 17738 | + .expect("writing y4m to aomenc"); | ||
| 17739 | + let out = child.wait_with_output().expect("aomenc failed to run"); | ||
| 17740 | + assert!( | ||
| 17741 | + out.status.success(), | ||
| 17742 | + "aomenc refused the fixture: {}", | ||
| 17743 | + String::from_utf8_lossy(&out.stderr) | ||
| 17744 | + ); | ||
| 17745 | + let stream = out.stdout; | ||
| 17746 | + let before = ( | ||
| 17747 | + crate::decode::filter_intra_rect4_horz_hits(), | ||
| 17748 | + crate::decode::filter_intra_rect4_vert_hits(), | ||
| 17749 | + crate::decode::rect4_32_horz_hits() + crate::decode::rect4_32_vert_hits(), | ||
| 17750 | + ); | ||
| 17751 | + let frames = match decode_stream(&stream) { | ||
| 17752 | + Err(e) => { | ||
| 17753 | + let msg = e.to_string(); | ||
| 17754 | + assert!( | ||
| 17755 | + msg.contains("unsupported"), | ||
| 17756 | + "{NAME} failed outright, not a named refusal ({bit_depth}-bit, seed \ | ||
| 17757 | + {seed}): {msg}" | ||
| 17758 | + ); | ||
| 17759 | + named_refusals += 1; | ||
| 17760 | + eprintln!("{bit_depth}-bit seed {seed} refusal: {msg}"); | ||
| 17761 | + continue; | ||
| 17762 | + } | ||
| 17763 | + Ok(frames) => frames, | ||
| 17764 | + }; | ||
| 17765 | + let (fi_horz, fi_vert, strips) = ( | ||
| 17766 | + crate::decode::filter_intra_rect4_horz_hits() - before.0, | ||
| 17767 | + crate::decode::filter_intra_rect4_vert_hits() - before.1, | ||
| 17768 | + crate::decode::rect4_32_horz_hits() + crate::decode::rect4_32_vert_hits() | ||
| 17769 | + - before.2, | ||
| 17770 | + ); | ||
| 17771 | + let fi = fi_horz + fi_vert; | ||
| 17772 | + let ffmpeg_frames = if bit_depth == 10 { | ||
| 17773 | + ffmpeg_decode_sequence_10bit(&stream, width, height, frame_count) | ||
| 17774 | + } else { | ||
| 17775 | + ffmpeg_decode_sequence(&stream, width, height, frame_count) | ||
| 17776 | + }; | ||
| 17777 | + assert_eq!(frames.len(), frame_count); | ||
| 17778 | + let mismatched = frames | ||
| 17779 | + .iter() | ||
| 17780 | + .zip(&ffmpeg_frames) | ||
| 17781 | + .any(|(got, want)| got.y != want.y || got.u != want.u || got.v != want.v); | ||
| 17782 | + // Per-attempt line (opt-in): which (seed, cq, axis, noise) | ||
| 17783 | + // actually made aomenc pick filter intra ON a 1:4 strip is | ||
| 17784 | + // exactly what a re-tune of this fixture needs, and it is not | ||
| 17785 | + // recoverable from the summary. | ||
| 17786 | + if std::env::var_os("EC_FI32X8_VERBOSE").is_some() { | ||
| 17787 | + eprintln!( | ||
| 17788 | + "{NAME}: {bit_depth}-bit seed {seed} {cq_level} axis={axis} noise={noise} \ | ||
| 17789 | + fi={fi_horz}+{fi_vert} strips={strips} mismatched={mismatched}" | ||
| 17790 | + ); | ||
| 17791 | + } | ||
| 17792 | + if fi == 0 { | ||
| 17793 | + out_of_scope += 1; | ||
| 17794 | + if mismatched { | ||
| 17795 | + out_of_scope_mismatch += 1; | ||
| 17796 | + eprintln!( | ||
| 17797 | + "{NAME}: {bit_depth}-bit seed {seed} MISMATCHES with zero \ | ||
| 17798 | + filter-intra 1:4 strips ({strips} plain 1:4 strips) -- a defect of \ | ||
| 17799 | + another shape" | ||
| 17800 | + ); | ||
| 17801 | + } | ||
| 17802 | + continue; | ||
| 17803 | + } | ||
| 17804 | + for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() { | ||
| 17805 | + assert_eq!( | ||
| 17806 | + got.y, want.y, | ||
| 17807 | + "{NAME} frame {i} luma vs ffmpeg ({bit_depth}-bit, seed {seed})" | ||
| 17808 | + ); | ||
| 17809 | + assert_eq!( | ||
| 17810 | + got.u, want.u, | ||
| 17811 | + "{NAME} frame {i} U vs ffmpeg ({bit_depth}-bit, seed {seed})" | ||
| 17812 | + ); | ||
| 17813 | + assert_eq!( | ||
| 17814 | + got.v, want.v, | ||
| 17815 | + "{NAME} frame {i} V vs ffmpeg ({bit_depth}-bit, seed {seed})" | ||
| 17816 | + ); | ||
| 17817 | + } | ||
| 17818 | + fi_horz_proved += fi_horz; | ||
| 17819 | + fi_vert_proved += fi_vert; | ||
| 17820 | + strips_proved += strips; | ||
| 17821 | + matched += 1; | ||
| 17822 | + } | ||
| 17823 | + // BOTH orientations, per bit depth: rows 8/9 of `cdf::FILTER_INTRA` | ||
| 17824 | + // are asymmetric (18101 for 32x8, 20229 for 8x32), so a one-sided | ||
| 17825 | + // assert would pass on a transposed pair. | ||
| 17826 | + assert!( | ||
| 17827 | + fi_horz_proved > 0 && fi_vert_proved > 0 && matched > 0, | ||
| 17828 | + "{NAME}: a 32x8/8x32 strip orientation never read use_filter_intra=1 inside a \ | ||
| 17829 | + pixel-exact {bit_depth}-bit attempt (32x8={fi_horz_proved}, \ | ||
| 17830 | + 8x32={fi_vert_proved}, {matched} matches, {named_refusals} refusals, \ | ||
| 17831 | + {out_of_scope} attempts with no filter-intra 1:4 strip, out of {n_attempts}) \ | ||
| 17832 | + -- gate proved nothing this run" | ||
| 17833 | + ); | ||
| 17834 | + eprintln!( | ||
| 17835 | + "{NAME}: {bit_depth}-bit: {named_refusals} named refusals, {matched} pixel-exact \ | ||
| 17836 | + matches out of {n_attempts}, filter-intra 1:4 strips={fi_horz_proved}x(32x8)+{fi_vert_proved}x(8x32) of \ | ||
| 17837 | + {strips_proved} 1:4 strips, {out_of_scope} attempts carried none \ | ||
| 17838 | + ({out_of_scope_mismatch} mismatched)" | ||
| 17839 | + ); | ||
| 17840 | + assert_eq!( | ||
| 17841 | + out_of_scope_mismatch, 0, | ||
| 17842 | + "{NAME}: {bit_depth}-bit: {out_of_scope_mismatch} attempt(s) with zero \ | ||
| 17843 | + filter-intra 1:4 strips decoded but mismatched ffmpeg -- a defect of another \ | ||
| 17844 | + shape, not a pass" | ||
| 17845 | + ); | ||
| 17846 | + } | ||
| 17847 | + } | ||
| 17848 | + | ||
| 17603 | /// lane-tiles r11: every tile gate before this one turns the coding tools | 17849 | /// lane-tiles r11: every tile gate before this one turns the coding tools |
| 17604 | /// OFF (rect/ab partitions, tx-size search, cdef, restoration all `=0`) | 17850 | /// OFF (rect/ab partitions, tx-size search, cdef, restoration all `=0`) |
| 17605 | /// to isolate the per-tile loop, which is exactly the | 17851 | /// 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. | ||