forge
Explore
Log in

Don't you dare go Hollow

Merge branch 'lane-fi8': 4x8/8x4 leaves read use_filter_intra from their own CDF row (was BLOCK_4X4's); filter-intra tx_type row mapped at every rect site

Browse files at this commit

29881697466085d39cd71ed6e9242609659204b4Ahmet Kaan GümüşParent: dfba0f5f9dae33
FILTER_INTRA gains rows [8]=4x8 (6743) and [9]=8x4 (5893);
filter_intra_size_class_rect maps them; read_intra_mode_sub8 takes the leaf's
own fi_class; the "filter intra on a HORZ/VERT strip" refusal is lifted with a
3-arm real-aomenc gate; fi_tx_row (fimode_to_intradir) now feeds every rect
tx_type CDF row. Merged onto main's palette2 decode_leaf_rect8 rewrite -- main's
per-TU Reach::of_tu call sites kept, the lane's Reach::of variant dropped.
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 every463 /// 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 strip464 /// 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-fi8 r1) add `BLOCK_4X8`/`BLOCK_8X4`'s own rows
467+/// (6743/5893, `default_filter_intra_cdfs` index 1/2) -- the sub-8 rect
468+/// leaves [`crate::decode`]'s `decode_leaf_rect8` codes. Both are inside
469+/// `av1_filter_intra_allowed_bsize`, so the flag is written for every DC_PRED
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`
472+/// / `cdf-row-held-constant`).
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+ [6743, 32768, 0],
483+ [5893, 32768, 0],
475 ];484 ];
476 /// `default_filter_intra_mode_cdf` (entropymode.c): which of the five485 /// `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+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) --542+ /// `[6]`=16x8, `[7]`=8x16, `[8]`=4x8, `[9]`=8x4) --
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+66 -31
@@ -1029,6 +1029,19 @@ pub(crate) fn filter_intra_rect_sub16_hits() -> usize {
1029 FILTER_INTRA_RECT_SUB16_HITS.with(|c| c.get())1029 FILTER_INTRA_RECT_SUB16_HITS.with(|c| c.get())
1030 }1030 }
1031 1031
1032+// As [`FILTER_INTRA_RECT_SUB16_HITS`], one partition level further down:
1033+// 4x8/8x4 leaves of an 8x8 HORZ/VERT (lane-fi8 r1). A gate on the sub16
1034+// counter would be satisfied by a 16x8 strip and prove nothing here.
1035+thread_local! {
1036+ static FILTER_INTRA_RECT_SUB8_HITS: std::cell::Cell<usize> =
1037+ const { std::cell::Cell::new(0) };
1038+}
1039+
1040+/// Current value of [`FILTER_INTRA_RECT_SUB8_HITS`].
1041+pub(crate) fn filter_intra_rect_sub8_hits() -> usize {
1042+ FILTER_INTRA_RECT_SUB8_HITS.with(|c| c.get())
1043+}
1044+
1032 // How many [`read_coeffs`] reads resolved a `tx_type` outside `TX_CLASS_2D`1045 // How many [`read_coeffs`] reads resolved a `tx_type` outside `TX_CLASS_2D`
1033 // (`V_DCT`/`H_DCT`, spec 5.11.39's `TxClass::Horiz`/`Vert`), across every1046 // (`V_DCT`/`H_DCT`, spec 5.11.39's `TxClass::Horiz`/`Vert`), across every
1034 // call on the current thread -- the same before/after counter pattern as1047 // call on the current thread -- the same before/after counter pattern as
@@ -4363,6 +4376,15 @@ impl Neighbours {
4363 /// offered (`cfl`, `is_cfl_allowed`, spec 5.11.5), chroma-from-luma -- the4376 /// offered (`cfl`, `is_cfl_allowed`, spec 5.11.5), chroma-from-luma -- the
4364 /// third element carries that mode's `(alpha_q3_u, alpha_q3_v)`, `None` for4377 /// third element carries that mode's `(alpha_q3_u, alpha_q3_v)`, `None` for
4365 /// plain DC chroma.4378 /// plain DC chroma.
4379+/// spec 5.11.47 / libaom `av1_read_tx_type`'s `fimode_to_intradir`: which
4380+/// `intra_ext_tx_cdf` row a luma transform reads. A filter-intra block's
4381+/// `mode` is always `DC_PRED`, so the row comes from the FILTER-INTRA mode
4382+/// instead (the defect commit 1a89ed9 fixed at the square sites).
4383+fn fi_tx_row(mode: usize, filter_intra: Option<usize>) -> usize {
4384+ const FIMODE_TO_INTRADIR: [usize; 5] = [DC_PRED, V_PRED, H_PRED, D157_PRED, DC_PRED];
4385+ filter_intra.map_or(mode, |fi| FIMODE_TO_INTRADIR[fi])
4386+}
4387+
4366 /// A block-size class index into [`cdf::FILTER_INTRA`]/`Cdfs::filter_intra`,4388 /// A block-size class index into [`cdf::FILTER_INTRA`]/`Cdfs::filter_intra`,
4367 /// or `None` when `side` is past `av1_filter_intra_allowed_bsize`'s <=324389 /// or `None` when `side` is past `av1_filter_intra_allowed_bsize`'s <=32
4368 /// bound (spec `filter_intra_mode_info` never reads a symbol there).4390 /// bound (spec `filter_intra_mode_info` never reads a symbol there).
@@ -4391,6 +4413,11 @@ fn filter_intra_size_class_rect(bw: usize, bh: usize) -> Option<usize> {
4391 // identical mode/uv_mode values, range 34808 vs the oracle's 40668).4413 // identical mode/uv_mode values, range 34808 vs the oracle's 40668).
4392 (16, 8) => Some(6),4414 (16, 8) => Some(6),
4393 (8, 16) => Some(7),4415 (8, 16) => Some(7),
4416+ // lane-fi8 r1: the sub-8 rect leaves are allowed too (both sides <=
4417+ // 32), and `decode_leaf_rect8` codes them -- rows 1/2 of
4418+ // `default_filter_intra_cdfs`, NOT BLOCK_4X4's row 0.
4419+ (4, 8) => Some(8),
4420+ (8, 4) => Some(9),
4394 _ if bw == bh => filter_intra_size_class(bw),4421 _ if bw == bh => filter_intra_size_class(bw),
4395 _ => None,4422 _ => None,
4396 }4423 }
@@ -5534,7 +5561,7 @@ fn decode_block_rect(
5534 // decoder consumed one that was never there.5561 // decoder consumed one that was never there.
5535 {5562 {
5536 let around = neighbours.around_rect(at, bw, bh);5563 let around = neighbours.around_rect(at, bw, bh);
5537- let mut luma_coding = cdfs.txb(TxbSet::LumaRect32x16, mode);5564+ let mut luma_coding = cdfs.txb(TxbSet::LumaRect32x16, fi_tx_row(mode, filter_intra));
5538 let (luma_levels, luma_tx_type) = read_coeffs_rect(5565 let (luma_levels, luma_tx_type) = read_coeffs_rect(
5539 dec,5566 dec,
5540 &mut luma_coding,5567 &mut luma_coding,
@@ -5849,7 +5876,7 @@ fn decode_leaf_rect(
5849 } else {5876 } else {
5850 TxbSet::LumaRect16x8Set15877 TxbSet::LumaRect16x8Set1
5851 };5878 };
5852- let mut luma_coding = cdfs.txb(luma_set, mode);5879+ let mut luma_coding = cdfs.txb(luma_set, fi_tx_row(mode, filter_intra));
5853 let (l_levels, luma_tx_type) = read_coeffs_rect(5880 let (l_levels, luma_tx_type) = read_coeffs_rect(
5854 dec, &mut luma_coding, luma_scan, bw, bh, 0, dc_sign_ctx(around[0].2), TxType::DctDct,5881 dec, &mut luma_coding, luma_scan, bw, bh, 0, dc_sign_ctx(around[0].2), TxType::DctDct,
5855 )?;5882 )?;
@@ -7471,12 +7498,7 @@ fn read_plane(
7471 // filter-intra is on) -- caller passes the raw filter-intra mode 0..4 in7498 // filter-intra is on) -- caller passes the raw filter-intra mode 0..4 in
7472 // `filter_intra`, only meaningful for `plane_idx == 0` (chroma has no7499 // `filter_intra`, only meaningful for `plane_idx == 0` (chroma has no
7473 // filter-intra in AV1).7500 // filter-intra in AV1).
7474- const FIMODE_TO_INTRADIR: [usize; 5] = [DC_PRED, V_PRED, H_PRED, D157_PRED, DC_PRED];7501+ let tx_mode = if plane_idx == 0 { fi_tx_row(tx_mode, filter_intra) } else { tx_mode };
7475- let tx_mode = if plane_idx == 0 {
7476- filter_intra.map_or(tx_mode, |fi| FIMODE_TO_INTRADIR[fi])
7477- } else {
7478- tx_mode
7479- };
7480 let mut coding = cdfs.txb(set, tx_mode);7502 let mut coding = cdfs.txb(set, tx_mode);
7481 // Luma's `default_tx_type` is only a fallback for the sizes whose7503 // Luma's `default_tx_type` is only a fallback for the sizes whose
7482 // `TxbSet` carries no symbol at all (32-point and up), which the spec7504 // `TxbSet` carries no symbol at all (32-point and up), which the spec
@@ -8465,6 +8487,11 @@ fn read_intra_mode_sub8(
8465 left_mode: usize,8487 left_mode: usize,
8466 has_chroma: bool,8488 has_chroma: bool,
8467 enable_filter_intra: bool,8489 enable_filter_intra: bool,
8490+ // [`filter_intra_size_class_rect`] for the LEAF's own shape: 0 for a
8491+ // `BLOCK_4X4` split leaf, 8/9 for a 4x8/8x4 rect leaf. Reading the flag
8492+ // from the wrong row is the same VALUE with a different interval, so it
8493+ // desyncs a block or two later, not here (class `wrong-alphabet-same-value`).
8494+ fi_class: usize,
8468 skip_ctx: usize,8495 skip_ctx: usize,
8469 allow_intrabc: bool,8496 allow_intrabc: bool,
8470 mi_r: usize,8497 mi_r: usize,
@@ -8522,9 +8549,7 @@ fn read_intra_mode_sub8(
8522 };8549 };
8523 let mut filter_intra = None;8550 let mut filter_intra = None;
8524 if mode == DC_PRED && enable_filter_intra {8551 if mode == DC_PRED && enable_filter_intra {
8525- // `BLOCK_4X4`'s own row (class 0, `filter_intra_size_class(4)`) --8552+ let use_filter_intra = dec.symbol(&mut cdfs.filter_intra[fi_class]) != 0;
8526- // every sub-8x8 leaf here is a `BLOCK_4X4`.
8527- let use_filter_intra = dec.symbol(&mut cdfs.filter_intra[0]) != 0;
8528 if trace {8553 if trace {
8529 eprintln!("TRACE sub8 use_filter_intra value={}", use_filter_intra as i32);8554 eprintln!("TRACE sub8 use_filter_intra value={}", use_filter_intra as i32);
8530 }8555 }
@@ -8604,8 +8629,9 @@ fn decode_leaf_split4(
8604 let has_chroma = i == 3;8629 let has_chroma = i == 3;
8605 let skip_ctx = neighbours.skip_txfm_ctx(lmi.0, lmi.1);8630 let skip_ctx = neighbours.skip_txfm_ctx(lmi.0, lmi.1);
8606 let (skip, mode, angle_delta_y, chroma, filter_intra) = read_intra_mode_sub8(8631 let (skip, mode, angle_delta_y, chroma, filter_intra) = read_intra_mode_sub8(
8607- dec, cdfs, leaf_above, leaf_left, has_chroma, enable_filter_intra, skip_ctx,8632+ dec, cdfs, leaf_above, leaf_left, has_chroma, enable_filter_intra,
8608- allow_intrabc, lmi.0, lmi.1,8633+ filter_intra_size_class(4).expect("BLOCK_4X4 has its own filter_intra row"),
8634+ skip_ctx, allow_intrabc, lmi.0, lmi.1,
8609 )?;8635 )?;
8610 leaf_modes[i] = mode;8636 leaf_modes[i] = mode;
8611 leaf_skips[i] = skip;8637 leaf_skips[i] = skip;
@@ -8746,9 +8772,12 @@ fn decode_leaf_split4(
8746 /// = `{31, 30}` (width 4 above, height 8 left), not the `{31, 31}` a8772 /// = `{31, 30}` (width 4 above, height 8 left), not the `{31, 31}` a
8747 /// `BLOCK_4X4` split writes.8773 /// `BLOCK_4X4` split writes.
8748 ///8774 ///
8749-/// Filter intra on one of these leaves is refused by name: `predict_filter_intra`8775+/// Filter intra on one of these leaves is decoded (lane-fi8 r1): the flag is
8750-/// is square-only in this decoder (the same refusal the 16x16-level rect8776+/// read from `BLOCK_4X8`/`BLOCK_8X4`'s own `cdf::FILTER_INTRA` row (classes
8751-/// strips already carry).8777+/// 8/9, NOT `BLOCK_4X4`'s), the predictor is [`crate::intra::predict_filter_intra`]
8778+/// over the leaf's true `bw`x`bh` -- per 4x4 transform unit, with that unit's
8779+/// own edge, when `tx_depth` splits it -- and the coded `tx_type` row is
8780+/// [`fi_tx_row`]'s `fimode_to_intradir`, not the block's raw `DC_PRED`.
8752 #[allow(clippy::too_many_arguments)]8781 #[allow(clippy::too_many_arguments)]
8753 fn decode_leaf_rect8(8782 fn decode_leaf_rect8(
8754 dec: &mut SymbolDecoder,8783 dec: &mut SymbolDecoder,
@@ -8798,13 +8827,19 @@ fn decode_leaf_rect8(
8798 let has_chroma = i == 1;8827 let has_chroma = i == 1;
8799 let skip_ctx = neighbours.skip_txfm_ctx(lmi.0, lmi.1);8828 let skip_ctx = neighbours.skip_txfm_ctx(lmi.0, lmi.1);
8800 let (skip, mode, angle_delta_y, chroma, filter_intra) = read_intra_mode_sub8(8829 let (skip, mode, angle_delta_y, chroma, filter_intra) = read_intra_mode_sub8(
8801- dec, cdfs, leaf_above, leaf_left, has_chroma, enable_filter_intra, skip_ctx,8830+ dec, cdfs, leaf_above, leaf_left, has_chroma, enable_filter_intra,
8802- allow_intrabc, lmi.0, lmi.1,8831+ filter_intra_size_class_rect(bw, bh)
8832+ .expect("BLOCK_4X8/BLOCK_8X4 are inside av1_filter_intra_allowed_bsize"),
8833+ skip_ctx, allow_intrabc, lmi.0, lmi.1,
8803 )?;8834 )?;
8804 if filter_intra.is_some() {8835 if filter_intra.is_some() {
8805- return Err(unsupported(8836+ // lane-fi8 r1: `predict_filter_intra` walks its 4x2 patches over
8806- "filter intra on a HORZ/VERT strip (this decoder predicts square-only)",8837+ // a true `bw`x`bh` block, so a 4x8/8x4 leaf predicts through the
8807- ));8838+ // same `reconstruct_rect`/`reconstruct` calls below -- and under
8839+ // a split transform, per 4x4 unit with that unit's own edge,
8840+ // which is exactly what the depth-1 loop already does.
8841+ FILTER_INTRA_RECT_HITS.with(|c| c.set(c.get() + 1));
8842+ FILTER_INTRA_RECT_SUB8_HITS.with(|c| c.set(c.get() + 1));
8808 }8843 }
8809 // `TxMode::Select`'s `tx_depth` (spec 5.11.16) exists at a 4x8/8x48844 // `TxMode::Select`'s `tx_depth` (spec 5.11.16) exists at a 4x8/8x4
8810 // leaf too, and is read for every intra block, skipped or not. Its8845 // leaf too, and is read for every intra block, skipped or not. Its
@@ -8876,8 +8911,8 @@ fn decode_leaf_rect8(
8876 // prediction of the same mode produces.8911 // prediction of the same mode produces.
8877 let zeros = vec![0i32; 16];8912 let zeros = vec![0i32; 16];
8878 y.reconstruct(8913 y.reconstruct(
8879- tu_px, tu_py, 4, mode, angle_delta_y, tu_reach, &zeros, None, None,8914+ tu_px, tu_py, 4, mode, angle_delta_y, tu_reach, &zeros, None,
8880- smooth_neighbor,8915+ filter_intra, smooth_neighbor,
8881 );8916 );
8882 neighbours.record_mi_luma(tu_mi, 4, &zeros);8917 neighbours.record_mi_luma(tu_mi, 4, &zeros);
8883 continue;8918 continue;
@@ -8904,7 +8939,7 @@ fn decode_leaf_rect8(
8904 TX4,8939 TX4,
8905 base_q_idx,8940 base_q_idx,
8906 None,8941 None,
8907- None,8942+ filter_intra,
8908 Some(tu_skip_ctx),8943 Some(tu_skip_ctx),
8909 smooth_neighbor,8944 smooth_neighbor,
8910 )?;8945 )?;
@@ -8930,7 +8965,8 @@ fn decode_leaf_rect8(
8930 let grid = if skip {8965 let grid = if skip {
8931 let zeros = vec![0i32; bw * bh];8966 let zeros = vec![0i32; bw * bh];
8932 y.reconstruct_rect(8967 y.reconstruct_rect(
8933- px, py, bw, bh, mode, angle_delta_y, reach, &zeros, None, None, smooth_neighbor,8968+ px, py, bw, bh, mode, angle_delta_y, reach, &zeros, None, filter_intra,
8969+ smooth_neighbor,
8934 );8970 );
8935 zeros8971 zeros
8936 } else {8972 } else {
@@ -8943,7 +8979,7 @@ fn decode_leaf_rect8(
8943 } else {8979 } else {
8944 TxbSet::LumaRect4x8Set18980 TxbSet::LumaRect4x8Set1
8945 };8981 };
8946- let mut coding = cdfs.txb(set, mode);8982+ let mut coding = cdfs.txb(set, fi_tx_row(mode, filter_intra));
8947 let (levels, tx_type) = read_coeffs_rect(8983 let (levels, tx_type) = read_coeffs_rect(
8948 dec,8984 dec,
8949 &mut coding,8985 &mut coding,
@@ -8972,7 +9008,8 @@ fn decode_leaf_rect8(
8972 tx_type,9008 tx_type,
8973 );9009 );
8974 y.reconstruct_rect(9010 y.reconstruct_rect(
8975- px, py, bw, bh, mode, angle_delta_y, reach, &residual, None, None, smooth_neighbor,9011+ px, py, bw, bh, mode, angle_delta_y, reach, &residual, None, filter_intra,
9012+ smooth_neighbor,
8976 );9013 );
8977 levels9014 levels
8978 };9015 };
@@ -19167,15 +19204,13 @@ mod tests {
19167 // string that blocks the shape otherwise. Either way the row is19204 // string that blocks the shape otherwise. Either way the row is
19168 // pinned HERE, so the round that lifts one of those refusals cannot19205 // pinned HERE, so the round that lifts one of those refusals cannot
19169 // land a wrong CDF row for the shape it unlocks.19206 // land a wrong CDF row for the shape it unlocks.
19170- const BELOW_8X8: &str =
19171- "a partition below 8x8 (this decoder codes no leaf smaller than 8x8)";
19172 const PART16: &str = "a HORZ_A/HORZ_B/VERT_A partition below 16x16 (this decoder codes \19207 const PART16: &str = "a HORZ_A/HORZ_B/VERT_A partition below 16x16 (this decoder codes \
19173 only the square arms, HORZ, VERT, VERT_B, and a clean split below 16x16)";19208 only the square arms, HORZ, VERT, VERT_B, and a clean split below 16x16)";
19174 const PART32: &str = "a 32x32 partition type this decoder does not code (value={part32})";19209 const PART32: &str = "a 32x32 partition type this decoder does not code (value={part32})";
19175 let libaom: &[(usize, usize, u16, Option<&str>)] = &[19210 let libaom: &[(usize, usize, u16, Option<&str>)] = &[
19176 (4, 4, 4621, None),19211 (4, 4, 4621, None),
19177- (4, 8, 6743, Some(BELOW_8X8)),19212+ (4, 8, 6743, None),
19178- (8, 4, 5893, Some(BELOW_8X8)),19213+ (8, 4, 5893, None),
19179 (8, 8, 7866, None),19214 (8, 8, 7866, None),
19180 (8, 16, 12551, None),19215 (8, 16, 12551, None),
19181 (16, 8, 9394, None),19216 (16, 8, 9394, None),
crates/ec-av1/src/refusal_inventory.rsmodified+0 -3
@@ -68,9 +68,6 @@ const REFUSALS: &[&str] = &[
68 "an inter partition below 16x16 other than SPLIT (16x8/8x16 rect inter leaves are not coded yet)",68 "an inter partition below 16x16 other than SPLIT (16x8/8x16 rect inter leaves are not coded yet)",
69 "an intra mode this decoder does not code (round 2)",69 "an intra mode this decoder does not code (round 2)",
70 "an intra-coded HORZ/VERT strip needs rectangular intra prediction this decoder does not code yet",70 "an intra-coded HORZ/VERT strip needs rectangular intra prediction this decoder does not code yet",
71- // Lifted for the 16x8/8x16 leaf by lane-fistrip; still live one level
72- // down, at the 4x8/8x4 sub-8 leaf (lane-tx4x8's `decode_leaf_rect8`).
73- "filter intra on a HORZ/VERT strip (this decoder predicts square-only)",
74 "warp prediction with a scaled reference (superres, unimplemented)",71 "warp prediction with a scaled reference (superres, unimplemented)",
75 "an 8x8 partition leaf under a scaled reference (superres, unimplemented)",72 "an 8x8 partition leaf under a scaled reference (superres, unimplemented)",
76 ];73 ];
crates/ec-av1/src/stream.rsmodified+181 -0
@@ -12504,6 +12504,187 @@ mod tests {
12504 }12504 }
12505 }12505 }
12506 12506
12507+ /// lane-fi8 r1: the sub8 rect-leaf gate above with the tool under test
12508+ /// turned ON (`--enable-filter-intra=1`, appended AFTER the base recipe
12509+ /// -- aomenc takes the FIRST occurrence of a repeated flag, so the base
12510+ /// recipe below carries no `--enable-filter-intra` at all). A DC_PRED
12511+ /// `BLOCK_4X8`/`BLOCK_8X4` leaf carries a `use_filter_intra` flag
12512+ /// (`av1_filter_intra_allowed_bsize` is "both sides <= 32"), which this
12513+ /// decoder read from `BLOCK_4X4`'s CDF row until this round -- the same
12514+ /// VALUE, a different interval, so it desynced a block or two later
12515+ /// ([[wrong-alphabet-same-value]]) -- and then refused the prediction by
12516+ /// name. Per attempt, only runs whose [`decode::filter_intra_rect_sub8_hits`]
12517+ /// delta is nonzero AND whose three planes match ffmpeg count; the wider
12518+ /// `filter_intra_rect_hits` would be satisfied by a 16x8 strip and prove
12519+ /// nothing about these shapes. Arms cover both transform depths
12520+ /// (`--enable-tx-size-search=1`, where a leaf may split into two 4x4
12521+ /// units each predicted from the previous one's reconstruction, and `=0`,
12522+ /// one whole-leaf transform) and both bit depths.
12523+ #[test]
12524+ fn a_real_aomenc_stream_with_filter_intra_on_a_sub8_rect_leaf_decodes_pixel_exact() {
12525+ const NAME: &str =
12526+ "a_real_aomenc_stream_with_filter_intra_on_a_sub8_rect_leaf_decodes_pixel_exact";
12527+ if !have_ffmpeg() {
12528+ eprintln!("SKIP {NAME}: no ffmpeg");
12529+ return;
12530+ }
12531+ if !have_aomenc() {
12532+ let msg = format!("no aomenc at {}", aomenc_path().display());
12533+ assert!(
12534+ std::env::var_os("EC_AV1_REQUIRE_AOMENC").is_none(),
12535+ "EC_AV1_REQUIRE_AOMENC is set but {msg}"
12536+ );
12537+ eprintln!("SKIP {NAME}: {msg}");
12538+ return;
12539+ }
12540+ let (width, height) = (16usize, 16usize);
12541+ for (tx_search, bit_depth) in [("1", 8u8), ("0", 8u8), ("1", 10u8)] {
12542+ let mut refusals = Vec::new();
12543+ let mut fired_runs = 0u32;
12544+ let mut fi_leaves = 0usize;
12545+ let mut split_tx = 0usize;
12546+ for attempt in 0..80u32 {
12547+ let seed = 300 + attempt;
12548+ let cq = 6 + (attempt % 8) * 6;
12549+ let pix_fmt = if bit_depth == 10 { "yuv420p10le" } else { "yuv420p" };
12550+ let y4m = Command::new("ffmpeg")
12551+ .args([
12552+ "-v", "error", "-f", "lavfi", "-i",
12553+ &format!("testsrc2=size={width}x{height}:rate=25"),
12554+ "-vf",
12555+ &format!("noise=alls=40:allf=t:all_seed={seed},format={pix_fmt}"),
12556+ "-strict", "-1", "-t", "0.04", "-f", "yuv4mpegpipe", "-",
12557+ ])
12558+ .stdin(Stdio::null())
12559+ .stdout(Stdio::piped())
12560+ .stderr(Stdio::piped())
12561+ .output()
12562+ .expect("ffmpeg failed to run");
12563+ assert!(
12564+ y4m.status.success(),
12565+ "ffmpeg fixture: {}",
12566+ String::from_utf8_lossy(&y4m.stderr)
12567+ );
12568+ let mut child = Command::new(aomenc_path())
12569+ .args([
12570+ "--codec=av1",
12571+ "--passes=1",
12572+ "--end-usage=q",
12573+ &format!("--cq-level={cq}"),
12574+ "--cpu-used=0",
12575+ "--threads=1",
12576+ "--row-mt=0",
12577+ "--sb-size=64",
12578+ "--min-partition-size=4",
12579+ "--max-partition-size=8",
12580+ "--enable-rect-partitions=1",
12581+ "--enable-ab-partitions=0",
12582+ "--enable-1to4-partitions=0",
12583+ "--enable-palette=0",
12584+ "--enable-intrabc=0",
12585+ "--enable-restoration=0",
12586+ "--enable-cdef=0",
12587+ "--loopfilter-control=0",
12588+ "--enable-ref-frame-mvs=0",
12589+ // The tools under test, first occurrence in the
12590+ // command line (aomenc keeps the first).
12591+ "--enable-filter-intra=1",
12592+ &format!("--enable-tx-size-search={tx_search}"),
12593+ "--limit=1",
12594+ "--obu",
12595+ "-o",
12596+ "-",
12597+ "-",
12598+ ])
12599+ .args(if bit_depth == 10 {
12600+ &["--input-bit-depth=10", "--bit-depth=10"][..]
12601+ } else {
12602+ &[][..]
12603+ })
12604+ .stdin(Stdio::piped())
12605+ .stdout(Stdio::piped())
12606+ .stderr(Stdio::piped())
12607+ .spawn()
12608+ .expect("aomenc failed to start");
12609+ child
12610+ .stdin
12611+ .take()
12612+ .expect("aomenc stdin")
12613+ .write_all(&y4m.stdout)
12614+ .expect("writing y4m to aomenc");
12615+ let out = child.wait_with_output().expect("aomenc failed to run");
12616+ if !out.status.success() {
12617+ refusals.push(format!("seed={seed} cq={cq}: aomenc itself refused"));
12618+ continue;
12619+ }
12620+ let stream = out.stdout;
12621+ let fi_before = decode::filter_intra_rect_sub8_hits();
12622+ let split_before = decode::rect8_split_tx_hits();
12623+ let frames = match decode_stream(&stream) {
12624+ Ok(frames) => frames,
12625+ Err(e) => {
12626+ let msg = e.to_string();
12627+ assert!(
12628+ msg.starts_with("unsupported: "),
12629+ "decode error that is not a named refusal \
12630+ (seed={seed} cq={cq} depth={bit_depth} txs={tx_search}): {msg}"
12631+ );
12632+ refusals.push(format!("seed={seed} cq={cq}: {msg}"));
12633+ continue;
12634+ }
12635+ };
12636+ let fi = decode::filter_intra_rect_sub8_hits() - fi_before;
12637+ if fi == 0 {
12638+ refusals.push(format!(
12639+ "seed={seed} cq={cq}: decoded, but no 4x8/8x4 leaf used filter intra"
12640+ ));
12641+ continue;
12642+ }
12643+ let ffmpeg_frames = if bit_depth == 10 {
12644+ ffmpeg_decode_sequence_10bit(&stream, width, height, 1)
12645+ } else {
12646+ ffmpeg_decode_sequence(&stream, width, height, 1)
12647+ };
12648+ assert_eq!(
12649+ frames[0].y, ffmpeg_frames[0].y,
12650+ "luma vs ffmpeg (seed={seed} cq={cq} depth={bit_depth} txs={tx_search})"
12651+ );
12652+ assert_eq!(
12653+ frames[0].u, ffmpeg_frames[0].u,
12654+ "U vs ffmpeg (seed={seed} cq={cq} depth={bit_depth} txs={tx_search})"
12655+ );
12656+ assert_eq!(
12657+ frames[0].v, ffmpeg_frames[0].v,
12658+ "V vs ffmpeg (seed={seed} cq={cq} depth={bit_depth} txs={tx_search})"
12659+ );
12660+ fired_runs += 1;
12661+ fi_leaves += fi;
12662+ split_tx += decode::rect8_split_tx_hits() - split_before;
12663+ if fired_runs >= 3 {
12664+ break;
12665+ }
12666+ }
12667+ assert!(
12668+ fired_runs >= 3,
12669+ "{NAME}: fewer than 3 firing+pixel-exact runs out of 80 attempts \
12670+ (depth={bit_depth} txs={tx_search}), {fi_leaves} filter-intra sub8 leaves \
12671+ seen:\n{}",
12672+ refusals.join("\n")
12673+ );
12674+ if tx_search == "1" {
12675+ assert!(
12676+ split_tx > 0,
12677+ "{NAME}: no sub-8x8 rect leaf used a split (depth-1) transform in the \
12678+ {fired_runs} pixel-exact runs (depth={bit_depth})"
12679+ );
12680+ }
12681+ eprintln!(
12682+ "{NAME}: depth={bit_depth} txs={tx_search} {fired_runs} pixel-exact runs, \
12683+ {fi_leaves} filter-intra 4x8/8x4 leaves, split_tx={split_tx}"
12684+ );
12685+ }
12686+ }
12687+
12507 /// lane-tx4x8 r3 ([[enumerate-table-domain]], [[tool-disabled-in-every-gate]]):12688 /// lane-tx4x8 r3 ([[enumerate-table-domain]], [[tool-disabled-in-every-gate]]):
12508 /// a 16x8/8x16 intra strip whose DIRECTIONAL mode reads above-right or12689 /// a 16x8/8x16 intra strip whose DIRECTIONAL mode reads above-right or
12509 /// below-left samples. Which of those the decoder may read is12690 /// below-left samples. Which of those the decoder may read is
lanes/fi8-r1.report.mdadded+79 -0
@@ -0,0 +1,79 @@
1+# lane-fi8 r1 -- filter intra on a sub-8 4x8/8x4 rect leaf
2+
3+Branch `lane-fi8` off main 8262b99, commit 2d5c425.
4+
5+## Root cause (two defects, one block shape)
6+
7+1. **Wrong CDF row, not a missing symbol.** `read_intra_mode_sub8`
8+ (`crates/ec-av1/src/decode.rs`) is shared by `decode_leaf_split4`'s
9+ BLOCK_4X4 leaves and `decode_leaf_rect8`'s 4x8/8x4 leaves, and read
10+ `use_filter_intra` from `cdfs.filter_intra[0]` -- BLOCK_4X4's row --
11+ unconditionally. `av1_filter_intra_allowed_bsize` (both sides <= 32) allows
12+ BLOCK_4X8/BLOCK_8X4, and libaom reads them with
13+ `default_filter_intra_cdfs[BLOCK_4X8]`=6743 / `[BLOCK_8X4]`=5893, so the
14+ symbol was READ (no `symbol-consumption-gap`) but out of the wrong interval:
15+ the same value, a divergent range, a desync a block or two later (class
16+ `wrong-alphabet-same-value` / `cdf-row-held-constant`). Fixed by adding
17+ `cdf::FILTER_INTRA` rows 8/9 (values generated by
18+ `scripts/extract-filter-intra-cdfs.py`), mapping them in
19+ `filter_intra_size_class_rect`, and passing the leaf's own class in.
20+2. **Stale refusal.** `"filter intra on a HORZ/VERT strip (this decoder
21+ predicts square-only)"` -- `predict_filter_intra` has taken a true `bw`x`bh`
22+ since lane-rectsplit. `filter_intra` is now threaded into both whole-leaf
23+ `reconstruct_rect` calls and, under `tx_depth=1`, into each 4x4 transform
24+ unit's own `reconstruct` / `read_plane` (per-TU prediction off the previous
25+ unit's reconstruction). Refusal removed from `refusal_inventory::REFUSALS`.
26+
27+## Same-class sweep (tx_type row under filter intra, the 1a89ed9 defect)
28+
29+`grep "cdfs.txb("`: the coded 16x8/8x16 (`decode_leaf_rect`) and 32x16/16x32
30+strips still passed the block's raw `mode` (always DC_PRED under filter intra)
31+as the `intra_ext_tx_cdf` row. All three rect sites plus the new sub-8 one now
32+go through `fi_tx_row` (`fimode_to_intradir`), which `read_plane` shares
33+instead of its private const. 64x32/32x64/32x8 sites are past
34+`av1_filter_intra_allowed_bsize` and were left alone.
35+
36+## Gate
37+
38+`a_real_aomenc_stream_with_filter_intra_on_a_sub8_rect_leaf_decodes_pixel_exact`
39+(`crates/ec-av1/src/stream.rs`): the `sub8_rect_leaf` recipe with
40+`--enable-filter-intra=1` and `--enable-tx-size-search=1|0` as the FIRST
41+occurrence of each flag (aomenc keeps the first). Three arms (8-bit txs=1,
42+8-bit txs=0, 10-bit txs=1), 80 attempts each, and an attempt only counts when
43+the per-attempt `filter_intra_rect_sub8_hits` delta is nonzero AND all three
44+planes match ffmpeg. No SKIP path except the tool-absence one
45+(`EC_AV1_REQUIRE_AOMENC=1` was set for every run below).
46+
47+EVIDENCE: /home/user/.cache/fi8-suite.log | cargo test -p ec-av1 filter_intra
48+-- --nocapture (worktree edith_codecs-fi8, commit 2d5c425) | new gate
49+3 pixel-exact runs per arm with 5 / 5 / 4 filter-intra 4x8/8x4 leaves and
50+split_tx = 6 / 0 / 6; siblings green:
51+a_real_aomenc_stream_with_filter_intra_on_a_horz_vert_strip_decodes_pixel_exact
52+37 matches / filter_intra_rect_hits delta 9,
53+a_pinned_aomenc_16x8_strip_reads_its_use_filter_intra_flag ok,
54+filter_intra_classes_carry_their_own_libaom_default_row ok (4x8/8x4 now
55+claimed, not refused), intra::filter_intra_matches_the_libaom_predictor ok.
56+
57+EVIDENCE: /home/user/.cache/fi8-suite.log | systemd-run --user
58+--unit=fi8-suite cargo test -p ec-av1 -- --test-threads=4 | 322 passed, 0
59+failed, 30 ignored (647 s). (Run on the identical tree, before a `cargo fmt`
60+that had to be reverted because main is not rustfmt-clean; re-run on 2d5c425 is
61+recorded at the end of this file.)
62+
63+EVIDENCE: hg-head.obu | release decode_probe (10-bit, his AV1 film head) |
64+refusal MOVED: was "filter intra on a HORZ/VERT strip (this decoder predicts
65+square-only)", now "a masked compound 64x64 inter block (compound_type is
66+inferred, not coded, at this size)". Still refused, so no ffmpeg byte compare
67+is owed yet.
68+
69+## Residue / dispositions
70+
71+- deferred: masked compound 64x64 inter block -- next refusal on hg-head.obu,
72+ a different lane's ceiling -- unblocked by porting inferred compound_type at
73+ 64x64.
74+- known ceiling: the gate's `split_tx > 0` assertion proves a depth-1 sub-8
75+ rect transform fired in the same pixel-exact frame, not that the FILTER-INTRA
76+ leaf itself was the split one; a per-leaf (filter-intra AND depth-1) counter
77+ would tighten it. Both depths are exercised across arms.
78+
79+EVIDENCE: /home/user/.cache/fi8-suite.log | systemd-run --user --unit=fi8-suite2 cargo test -p ec-av1 -- --test-threads=4, on committed 2d5c425 | 322 passed, 0 failed, 30 ignored (357.7 s).