forge
Explore
Log in

Don't you dare go Hollow

Sub-8 rect leaves read use_filter_intra from BLOCK_4X4's CDF row and then refused the prediction -- 4x8/8x4 now decode filter intra pixel-exact

Browse files at this commit

5a2f5efe3a0771ac7ca43d57bdf63c19a7b75ff6Ahmet Kaan GümüşParent: e3ed88c
  • fix
    • sub-8 rect leaves read use_filter_intra from BLOCK_4X4's CDF row and then refused the prediction -- 4x8/8x4 now decode filter intra pixel-exact
Show full message
fix(av1): sub-8 rect leaves read use_filter_intra from BLOCK_4X4's CDF row and then refused the prediction -- 4x8/8x4 now decode filter intra pixel-exact

`read_intra_mode_sub8` is shared by the 4x4 split leaves and lane-tx4x8's
4x8/8x4 rect leaves, and hardcoded `cdfs.filter_intra[0]` (BLOCK_4X4's row).
`av1_filter_intra_allowed_bsize` allows BLOCK_4X8/BLOCK_8X4, so aomenc writes
the flag for every DC_PRED one of them and libaom reads it with
`default_filter_intra_cdfs[BLOCK_4X8]/[BLOCK_8X4]` (6743/5893): the same symbol
VALUE out of a different interval, a desync a block or two later
(wrong-alphabet-same-value). `cdf::FILTER_INTRA` gains those two rows (classes
8/9, generated by scripts/extract-filter-intra-cdfs.py and pinned by the domain
test, whose 4x8/8x4 entries lose their now-stale BELOW_8X8 refusal), the class
comes from `filter_intra_size_class_rect`, and the caller passes its leaf's own
shape.

Prediction: the refusal ("filter intra on a HORZ/VERT strip (this decoder
predicts square-only)") was stale prose -- `predict_filter_intra` has taken a
true bw x bh since lane-rectsplit -- so `filter_intra` is threaded into both
whole-leaf `reconstruct_rect` calls and, under `tx_depth=1`, into each 4x4
transform unit's own `reconstruct`/`read_plane` (each predicted from the
previous unit's reconstruction). The refusal leaves refusal_inventory.

Sweep of the same class as 1a89ed9 (tx_type row under filter intra): the coded
16x8/8x16 and 32x16/16x32 strips also passed the block's raw DC_PRED `mode` to
`cdfs.txb`; all three sites now go through the new `fi_tx_row`
(`fimode_to_intradir`), which `read_plane` shares.

GATE: a_real_aomenc_stream_with_filter_intra_on_a_sub8_rect_leaf_decodes_pixel_exact
-- real aomenc, filter-intra ON as the first occurrence of the flag, three arms
(8-bit tx-size-search=1/0, 10-bit =1), per attempt a nonzero
filter_intra_rect_sub8_hits delta AND all three planes compared against ffmpeg;
3 firing pixel-exact runs per arm (5/5/4 filter-intra 4x8/8x4 leaves).
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
@@ -535,9 +535,9 @@ pub(crate) struct Cdfs {
535 pub dv_comp: [MvComponentCdfs; 2],535 pub dv_comp: [MvComponentCdfs; 2],
536 /// The `use_filter_intra` flag, indexed by block-size class (`[0]`=4x4,536 /// The `use_filter_intra` flag, indexed by block-size class (`[0]`=4x4,
537 /// `[1]`=8x8, `[2]`=16x16, `[3]`=32x32, `[4]`=32x16, `[5]`=16x32,537 /// `[1]`=8x8, `[2]`=16x16, `[3]`=32x32, `[4]`=32x16, `[5]`=16x32,
538- /// `[6]`=16x8, `[7]`=8x16) --538+ /// `[6]`=16x8, `[7]`=8x16, `[8]`=4x8, `[9]`=8x4) --
539 /// see [`cdf::FILTER_INTRA`].539 /// see [`cdf::FILTER_INTRA`].
540- pub filter_intra: [[u16; 3]; 8],540+ pub filter_intra: [[u16; 3]; 10],
541 /// Which `FILTER_INTRA_MODES` entry a `use_filter_intra` block picks.541 /// Which `FILTER_INTRA_MODES` entry a `use_filter_intra` block picks.
542 pub filter_intra_mode: [u16; 6],542 pub filter_intra_mode: [u16; 6],
543 /// `TxMode::Select`'s `tx_depth` flag at an 8x8 block, by `tx_size_context`543 /// `TxMode::Select`'s `tx_depth` flag at an 8x8 block, by `tx_size_context`
crates/ec-av1/src/decode.rsmodified+66 -31
@@ -886,6 +886,19 @@ pub(crate) fn filter_intra_rect_sub16_hits() -> usize {
886 FILTER_INTRA_RECT_SUB16_HITS.with(|c| c.get())886 FILTER_INTRA_RECT_SUB16_HITS.with(|c| c.get())
887 }887 }
888 888
889+// As [`FILTER_INTRA_RECT_SUB16_HITS`], one partition level further down:
890+// 4x8/8x4 leaves of an 8x8 HORZ/VERT (lane-fi8 r1). A gate on the sub16
891+// counter would be satisfied by a 16x8 strip and prove nothing here.
892+thread_local! {
893+ static FILTER_INTRA_RECT_SUB8_HITS: std::cell::Cell<usize> =
894+ const { std::cell::Cell::new(0) };
895+}
896+
897+/// Current value of [`FILTER_INTRA_RECT_SUB8_HITS`].
898+pub(crate) fn filter_intra_rect_sub8_hits() -> usize {
899+ FILTER_INTRA_RECT_SUB8_HITS.with(|c| c.get())
900+}
901+
889 // How many [`read_coeffs`] reads resolved a `tx_type` outside `TX_CLASS_2D`902 // How many [`read_coeffs`] reads resolved a `tx_type` outside `TX_CLASS_2D`
890 // (`V_DCT`/`H_DCT`, spec 5.11.39's `TxClass::Horiz`/`Vert`), across every903 // (`V_DCT`/`H_DCT`, spec 5.11.39's `TxClass::Horiz`/`Vert`), across every
891 // call on the current thread -- the same before/after counter pattern as904 // call on the current thread -- the same before/after counter pattern as
@@ -3949,6 +3962,15 @@ impl Neighbours {
3949 /// offered (`cfl`, `is_cfl_allowed`, spec 5.11.5), chroma-from-luma -- the3962 /// offered (`cfl`, `is_cfl_allowed`, spec 5.11.5), chroma-from-luma -- the
3950 /// third element carries that mode's `(alpha_q3_u, alpha_q3_v)`, `None` for3963 /// third element carries that mode's `(alpha_q3_u, alpha_q3_v)`, `None` for
3951 /// plain DC chroma.3964 /// plain DC chroma.
3965+/// spec 5.11.47 / libaom `av1_read_tx_type`'s `fimode_to_intradir`: which
3966+/// `intra_ext_tx_cdf` row a luma transform reads. A filter-intra block's
3967+/// `mode` is always `DC_PRED`, so the row comes from the FILTER-INTRA mode
3968+/// instead (the defect commit 1a89ed9 fixed at the square sites).
3969+fn fi_tx_row(mode: usize, filter_intra: Option<usize>) -> usize {
3970+ const FIMODE_TO_INTRADIR: [usize; 5] = [DC_PRED, V_PRED, H_PRED, D157_PRED, DC_PRED];
3971+ filter_intra.map_or(mode, |fi| FIMODE_TO_INTRADIR[fi])
3972+}
3973+
3952 /// A block-size class index into [`cdf::FILTER_INTRA`]/`Cdfs::filter_intra`,3974 /// A block-size class index into [`cdf::FILTER_INTRA`]/`Cdfs::filter_intra`,
3953 /// or `None` when `side` is past `av1_filter_intra_allowed_bsize`'s <=323975 /// or `None` when `side` is past `av1_filter_intra_allowed_bsize`'s <=32
3954 /// bound (spec `filter_intra_mode_info` never reads a symbol there).3976 /// bound (spec `filter_intra_mode_info` never reads a symbol there).
@@ -3977,6 +3999,11 @@ fn filter_intra_size_class_rect(bw: usize, bh: usize) -> Option<usize> {
3977 // identical mode/uv_mode values, range 34808 vs the oracle's 40668).3999 // identical mode/uv_mode values, range 34808 vs the oracle's 40668).
3978 (16, 8) => Some(6),4000 (16, 8) => Some(6),
3979 (8, 16) => Some(7),4001 (8, 16) => Some(7),
4002+ // lane-fi8 r1: the sub-8 rect leaves are allowed too (both sides <=
4003+ // 32), and `decode_leaf_rect8` codes them -- rows 1/2 of
4004+ // `default_filter_intra_cdfs`, NOT BLOCK_4X4's row 0.
4005+ (4, 8) => Some(8),
4006+ (8, 4) => Some(9),
3980 _ if bw == bh => filter_intra_size_class(bw),4007 _ if bw == bh => filter_intra_size_class(bw),
3981 _ => None,4008 _ => None,
3982 }4009 }
@@ -4964,7 +4991,7 @@ fn decode_block_rect(
4964 // decoder consumed one that was never there.4991 // decoder consumed one that was never there.
4965 {4992 {
4966 let around = neighbours.around_rect(at, bw, bh);4993 let around = neighbours.around_rect(at, bw, bh);
4967- let mut luma_coding = cdfs.txb(TxbSet::LumaRect32x16, mode);4994+ let mut luma_coding = cdfs.txb(TxbSet::LumaRect32x16, fi_tx_row(mode, filter_intra));
4968 let (luma_levels, luma_tx_type) = read_coeffs_rect(4995 let (luma_levels, luma_tx_type) = read_coeffs_rect(
4969 dec,4996 dec,
4970 &mut luma_coding,4997 &mut luma_coding,
@@ -5245,7 +5272,7 @@ fn decode_leaf_rect(
5245 } else {5272 } else {
5246 TxbSet::LumaRect16x8Set15273 TxbSet::LumaRect16x8Set1
5247 };5274 };
5248- let mut luma_coding = cdfs.txb(luma_set, mode);5275+ let mut luma_coding = cdfs.txb(luma_set, fi_tx_row(mode, filter_intra));
5249 let (l_levels, luma_tx_type) = read_coeffs_rect(5276 let (l_levels, luma_tx_type) = read_coeffs_rect(
5250 dec, &mut luma_coding, luma_scan, bw, bh, 0, dc_sign_ctx(around[0].2), TxType::DctDct,5277 dec, &mut luma_coding, luma_scan, bw, bh, 0, dc_sign_ctx(around[0].2), TxType::DctDct,
5251 )?;5278 )?;
@@ -6745,12 +6772,7 @@ fn read_plane(
6745 // filter-intra is on) -- caller passes the raw filter-intra mode 0..4 in6772 // filter-intra is on) -- caller passes the raw filter-intra mode 0..4 in
6746 // `filter_intra`, only meaningful for `plane_idx == 0` (chroma has no6773 // `filter_intra`, only meaningful for `plane_idx == 0` (chroma has no
6747 // filter-intra in AV1).6774 // filter-intra in AV1).
6748- const FIMODE_TO_INTRADIR: [usize; 5] = [DC_PRED, V_PRED, H_PRED, D157_PRED, DC_PRED];6775+ let tx_mode = if plane_idx == 0 { fi_tx_row(tx_mode, filter_intra) } else { tx_mode };
6749- let tx_mode = if plane_idx == 0 {
6750- filter_intra.map_or(tx_mode, |fi| FIMODE_TO_INTRADIR[fi])
6751- } else {
6752- tx_mode
6753- };
6754 let mut coding = cdfs.txb(set, tx_mode);6776 let mut coding = cdfs.txb(set, tx_mode);
6755 // Luma's `default_tx_type` is only a fallback for the sizes whose6777 // Luma's `default_tx_type` is only a fallback for the sizes whose
6756 // `TxbSet` carries no symbol at all (32-point and up), which the spec6778 // `TxbSet` carries no symbol at all (32-point and up), which the spec
@@ -7661,6 +7683,11 @@ fn read_intra_mode_sub8(
7661 left_mode: usize,7683 left_mode: usize,
7662 has_chroma: bool,7684 has_chroma: bool,
7663 enable_filter_intra: bool,7685 enable_filter_intra: bool,
7686+ // [`filter_intra_size_class_rect`] for the LEAF's own shape: 0 for a
7687+ // `BLOCK_4X4` split leaf, 8/9 for a 4x8/8x4 rect leaf. Reading the flag
7688+ // from the wrong row is the same VALUE with a different interval, so it
7689+ // desyncs a block or two later, not here (class `wrong-alphabet-same-value`).
7690+ fi_class: usize,
7664 skip_ctx: usize,7691 skip_ctx: usize,
7665 allow_intrabc: bool,7692 allow_intrabc: bool,
7666 mi_r: usize,7693 mi_r: usize,
@@ -7718,9 +7745,7 @@ fn read_intra_mode_sub8(
7718 };7745 };
7719 let mut filter_intra = None;7746 let mut filter_intra = None;
7720 if mode == DC_PRED && enable_filter_intra {7747 if mode == DC_PRED && enable_filter_intra {
7721- // `BLOCK_4X4`'s own row (class 0, `filter_intra_size_class(4)`) --7748+ let use_filter_intra = dec.symbol(&mut cdfs.filter_intra[fi_class]) != 0;
7722- // every sub-8x8 leaf here is a `BLOCK_4X4`.
7723- let use_filter_intra = dec.symbol(&mut cdfs.filter_intra[0]) != 0;
7724 if trace {7749 if trace {
7725 eprintln!("TRACE sub8 use_filter_intra value={}", use_filter_intra as i32);7750 eprintln!("TRACE sub8 use_filter_intra value={}", use_filter_intra as i32);
7726 }7751 }
@@ -7800,8 +7825,9 @@ fn decode_leaf_split4(
7800 let has_chroma = i == 3;7825 let has_chroma = i == 3;
7801 let skip_ctx = neighbours.skip_txfm_ctx(lmi.0, lmi.1);7826 let skip_ctx = neighbours.skip_txfm_ctx(lmi.0, lmi.1);
7802 let (skip, mode, angle_delta_y, chroma, filter_intra) = read_intra_mode_sub8(7827 let (skip, mode, angle_delta_y, chroma, filter_intra) = read_intra_mode_sub8(
7803- dec, cdfs, leaf_above, leaf_left, has_chroma, enable_filter_intra, skip_ctx,7828+ dec, cdfs, leaf_above, leaf_left, has_chroma, enable_filter_intra,
7804- allow_intrabc, lmi.0, lmi.1,7829+ filter_intra_size_class(4).expect("BLOCK_4X4 has its own filter_intra row"),
7830+ skip_ctx, allow_intrabc, lmi.0, lmi.1,
7805 )?;7831 )?;
7806 leaf_modes[i] = mode;7832 leaf_modes[i] = mode;
7807 leaf_skips[i] = skip;7833 leaf_skips[i] = skip;
@@ -7942,9 +7968,12 @@ fn decode_leaf_split4(
7942 /// = `{31, 30}` (width 4 above, height 8 left), not the `{31, 31}` a7968 /// = `{31, 30}` (width 4 above, height 8 left), not the `{31, 31}` a
7943 /// `BLOCK_4X4` split writes.7969 /// `BLOCK_4X4` split writes.
7944 ///7970 ///
7945-/// Filter intra on one of these leaves is refused by name: `predict_filter_intra`7971+/// Filter intra on one of these leaves is decoded (lane-fi8 r1): the flag is
7946-/// is square-only in this decoder (the same refusal the 16x16-level rect7972+/// read from `BLOCK_4X8`/`BLOCK_8X4`'s own `cdf::FILTER_INTRA` row (classes
7947-/// strips already carry).7973+/// 8/9, NOT `BLOCK_4X4`'s), the predictor is [`crate::intra::predict_filter_intra`]
7974+/// over the leaf's true `bw`x`bh` -- per 4x4 transform unit, with that unit's
7975+/// own edge, when `tx_depth` splits it -- and the coded `tx_type` row is
7976+/// [`fi_tx_row`]'s `fimode_to_intradir`, not the block's raw `DC_PRED`.
7948 #[allow(clippy::too_many_arguments)]7977 #[allow(clippy::too_many_arguments)]
7949 fn decode_leaf_rect8(7978 fn decode_leaf_rect8(
7950 dec: &mut SymbolDecoder,7979 dec: &mut SymbolDecoder,
@@ -7994,13 +8023,19 @@ fn decode_leaf_rect8(
7994 let has_chroma = i == 1;8023 let has_chroma = i == 1;
7995 let skip_ctx = neighbours.skip_txfm_ctx(lmi.0, lmi.1);8024 let skip_ctx = neighbours.skip_txfm_ctx(lmi.0, lmi.1);
7996 let (skip, mode, angle_delta_y, chroma, filter_intra) = read_intra_mode_sub8(8025 let (skip, mode, angle_delta_y, chroma, filter_intra) = read_intra_mode_sub8(
7997- dec, cdfs, leaf_above, leaf_left, has_chroma, enable_filter_intra, skip_ctx,8026+ dec, cdfs, leaf_above, leaf_left, has_chroma, enable_filter_intra,
7998- allow_intrabc, lmi.0, lmi.1,8027+ filter_intra_size_class_rect(bw, bh)
8028+ .expect("BLOCK_4X8/BLOCK_8X4 are inside av1_filter_intra_allowed_bsize"),
8029+ skip_ctx, allow_intrabc, lmi.0, lmi.1,
7999 )?;8030 )?;
8000 if filter_intra.is_some() {8031 if filter_intra.is_some() {
8001- return Err(unsupported(8032+ // lane-fi8 r1: `predict_filter_intra` walks its 4x2 patches over
8002- "filter intra on a HORZ/VERT strip (this decoder predicts square-only)",8033+ // a true `bw`x`bh` block, so a 4x8/8x4 leaf predicts through the
8003- ));8034+ // same `reconstruct_rect`/`reconstruct` calls below -- and under
8035+ // a split transform, per 4x4 unit with that unit's own edge,
8036+ // which is exactly what the depth-1 loop already does.
8037+ FILTER_INTRA_RECT_HITS.with(|c| c.set(c.get() + 1));
8038+ FILTER_INTRA_RECT_SUB8_HITS.with(|c| c.set(c.get() + 1));
8004 }8039 }
8005 // `TxMode::Select`'s `tx_depth` (spec 5.11.16) exists at a 4x8/8x48040 // `TxMode::Select`'s `tx_depth` (spec 5.11.16) exists at a 4x8/8x4
8006 // leaf too, and is read for every intra block, skipped or not. Its8041 // leaf too, and is read for every intra block, skipped or not. Its
@@ -8057,8 +8092,8 @@ fn decode_leaf_rect8(
8057 // prediction of the same mode produces.8092 // prediction of the same mode produces.
8058 let zeros = vec![0i32; 16];8093 let zeros = vec![0i32; 16];
8059 y.reconstruct(8094 y.reconstruct(
8060- tu_px, tu_py, 4, mode, angle_delta_y, tu_reach, &zeros, None, None,8095+ tu_px, tu_py, 4, mode, angle_delta_y, tu_reach, &zeros, None,
8061- smooth_neighbor,8096+ filter_intra, smooth_neighbor,
8062 );8097 );
8063 neighbours.record_mi_luma(tu_mi, 4, &zeros);8098 neighbours.record_mi_luma(tu_mi, 4, &zeros);
8064 continue;8099 continue;
@@ -8085,7 +8120,7 @@ fn decode_leaf_rect8(
8085 TX4,8120 TX4,
8086 base_q_idx,8121 base_q_idx,
8087 None,8122 None,
8088- None,8123+ filter_intra,
8089 Some(tu_skip_ctx),8124 Some(tu_skip_ctx),
8090 smooth_neighbor,8125 smooth_neighbor,
8091 )?;8126 )?;
@@ -8111,7 +8146,8 @@ fn decode_leaf_rect8(
8111 let grid = if skip {8146 let grid = if skip {
8112 let zeros = vec![0i32; bw * bh];8147 let zeros = vec![0i32; bw * bh];
8113 y.reconstruct_rect(8148 y.reconstruct_rect(
8114- px, py, bw, bh, mode, angle_delta_y, reach, &zeros, None, None, smooth_neighbor,8149+ px, py, bw, bh, mode, angle_delta_y, reach, &zeros, None, filter_intra,
8150+ smooth_neighbor,
8115 );8151 );
8116 zeros8152 zeros
8117 } else {8153 } else {
@@ -8124,7 +8160,7 @@ fn decode_leaf_rect8(
8124 } else {8160 } else {
8125 TxbSet::LumaRect4x8Set18161 TxbSet::LumaRect4x8Set1
8126 };8162 };
8127- let mut coding = cdfs.txb(set, mode);8163+ let mut coding = cdfs.txb(set, fi_tx_row(mode, filter_intra));
8128 let (levels, tx_type) = read_coeffs_rect(8164 let (levels, tx_type) = read_coeffs_rect(
8129 dec,8165 dec,
8130 &mut coding,8166 &mut coding,
@@ -8153,7 +8189,8 @@ fn decode_leaf_rect8(
8153 tx_type,8189 tx_type,
8154 );8190 );
8155 y.reconstruct_rect(8191 y.reconstruct_rect(
8156- px, py, bw, bh, mode, angle_delta_y, reach, &residual, None, None, smooth_neighbor,8192+ px, py, bw, bh, mode, angle_delta_y, reach, &residual, None, filter_intra,
8193+ smooth_neighbor,
8157 );8194 );
8158 levels8195 levels
8159 };8196 };
@@ -18293,15 +18330,13 @@ mod tests {
18293 // string that blocks the shape otherwise. Either way the row is18330 // string that blocks the shape otherwise. Either way the row is
18294 // pinned HERE, so the round that lifts one of those refusals cannot18331 // pinned HERE, so the round that lifts one of those refusals cannot
18295 // land a wrong CDF row for the shape it unlocks.18332 // land a wrong CDF row for the shape it unlocks.
18296- const BELOW_8X8: &str =
18297- "a partition below 8x8 (this decoder codes no leaf smaller than 8x8)";
18298 const PART16: &str = "a HORZ_A/HORZ_B/VERT_A partition below 16x16 (this decoder codes \18333 const PART16: &str = "a HORZ_A/HORZ_B/VERT_A partition below 16x16 (this decoder codes \
18299 only the square arms, HORZ, VERT, VERT_B, and a clean split below 16x16)";18334 only the square arms, HORZ, VERT, VERT_B, and a clean split below 16x16)";
18300 const PART32: &str = "a 32x32 partition type this decoder does not code (value={part32})";18335 const PART32: &str = "a 32x32 partition type this decoder does not code (value={part32})";
18301 let libaom: &[(usize, usize, u16, Option<&str>)] = &[18336 let libaom: &[(usize, usize, u16, Option<&str>)] = &[
18302 (4, 4, 4621, None),18337 (4, 4, 4621, None),
18303- (4, 8, 6743, Some(BELOW_8X8)),18338+ (4, 8, 6743, None),
18304- (8, 4, 5893, Some(BELOW_8X8)),18339+ (8, 4, 5893, None),
18305 (8, 8, 7866, None),18340 (8, 8, 7866, None),
18306 (8, 16, 12551, None),18341 (8, 16, 12551, None),
18307 (16, 8, 9394, None),18342 (16, 8, 9394, None),
crates/ec-av1/src/refusal_inventory.rsmodified+0 -3
@@ -67,9 +67,6 @@ const REFUSALS: &[&str] = &[
67 "an inter partition below 16x16 other than SPLIT (16x8/8x16 rect inter leaves are not coded yet)",67 "an inter partition below 16x16 other than SPLIT (16x8/8x16 rect inter leaves are not coded yet)",
68 "an intra mode this decoder does not code (round 2)",68 "an intra mode this decoder does not code (round 2)",
69 "an intra-coded HORZ/VERT strip needs rectangular intra prediction this decoder does not code yet",69 "an intra-coded HORZ/VERT strip needs rectangular intra prediction this decoder does not code yet",
70- // Lifted for the 16x8/8x16 leaf by lane-fistrip; still live one level
71- // down, at the 4x8/8x4 sub-8 leaf (lane-tx4x8's `decode_leaf_rect8`).
72- "filter intra on a HORZ/VERT strip (this decoder predicts square-only)",
73 "warp prediction with a scaled reference (superres, unimplemented)",70 "warp prediction with a scaled reference (superres, unimplemented)",
74 "an 8x8 partition leaf under a scaled reference (superres, unimplemented)",71 "an 8x8 partition leaf under a scaled reference (superres, unimplemented)",
75 ];72 ];
crates/ec-av1/src/stream.rsmodified+181 -0
@@ -10871,6 +10871,187 @@ mod tests {
10871 }10871 }
10872 }10872 }
10873 10873
10874+ /// lane-fi8 r1: the sub8 rect-leaf gate above with the tool under test
10875+ /// turned ON (`--enable-filter-intra=1`, appended AFTER the base recipe
10876+ /// -- aomenc takes the FIRST occurrence of a repeated flag, so the base
10877+ /// recipe below carries no `--enable-filter-intra` at all). A DC_PRED
10878+ /// `BLOCK_4X8`/`BLOCK_8X4` leaf carries a `use_filter_intra` flag
10879+ /// (`av1_filter_intra_allowed_bsize` is "both sides <= 32"), which this
10880+ /// decoder read from `BLOCK_4X4`'s CDF row until this round -- the same
10881+ /// VALUE, a different interval, so it desynced a block or two later
10882+ /// ([[wrong-alphabet-same-value]]) -- and then refused the prediction by
10883+ /// name. Per attempt, only runs whose [`decode::filter_intra_rect_sub8_hits`]
10884+ /// delta is nonzero AND whose three planes match ffmpeg count; the wider
10885+ /// `filter_intra_rect_hits` would be satisfied by a 16x8 strip and prove
10886+ /// nothing about these shapes. Arms cover both transform depths
10887+ /// (`--enable-tx-size-search=1`, where a leaf may split into two 4x4
10888+ /// units each predicted from the previous one's reconstruction, and `=0`,
10889+ /// one whole-leaf transform) and both bit depths.
10890+ #[test]
10891+ fn a_real_aomenc_stream_with_filter_intra_on_a_sub8_rect_leaf_decodes_pixel_exact() {
10892+ const NAME: &str =
10893+ "a_real_aomenc_stream_with_filter_intra_on_a_sub8_rect_leaf_decodes_pixel_exact";
10894+ if !have_ffmpeg() {
10895+ eprintln!("SKIP {NAME}: no ffmpeg");
10896+ return;
10897+ }
10898+ if !have_aomenc() {
10899+ let msg = format!("no aomenc at {}", aomenc_path().display());
10900+ assert!(
10901+ std::env::var_os("EC_AV1_REQUIRE_AOMENC").is_none(),
10902+ "EC_AV1_REQUIRE_AOMENC is set but {msg}"
10903+ );
10904+ eprintln!("SKIP {NAME}: {msg}");
10905+ return;
10906+ }
10907+ let (width, height) = (16usize, 16usize);
10908+ for (tx_search, bit_depth) in [("1", 8u8), ("0", 8u8), ("1", 10u8)] {
10909+ let mut refusals = Vec::new();
10910+ let mut fired_runs = 0u32;
10911+ let mut fi_leaves = 0usize;
10912+ let mut split_tx = 0usize;
10913+ for attempt in 0..80u32 {
10914+ let seed = 300 + attempt;
10915+ let cq = 6 + (attempt % 8) * 6;
10916+ let pix_fmt = if bit_depth == 10 { "yuv420p10le" } else { "yuv420p" };
10917+ let y4m = Command::new("ffmpeg")
10918+ .args([
10919+ "-v", "error", "-f", "lavfi", "-i",
10920+ &format!("testsrc2=size={width}x{height}:rate=25"),
10921+ "-vf",
10922+ &format!("noise=alls=40:allf=t:all_seed={seed},format={pix_fmt}"),
10923+ "-strict", "-1", "-t", "0.04", "-f", "yuv4mpegpipe", "-",
10924+ ])
10925+ .stdin(Stdio::null())
10926+ .stdout(Stdio::piped())
10927+ .stderr(Stdio::piped())
10928+ .output()
10929+ .expect("ffmpeg failed to run");
10930+ assert!(
10931+ y4m.status.success(),
10932+ "ffmpeg fixture: {}",
10933+ String::from_utf8_lossy(&y4m.stderr)
10934+ );
10935+ let mut child = Command::new(aomenc_path())
10936+ .args([
10937+ "--codec=av1",
10938+ "--passes=1",
10939+ "--end-usage=q",
10940+ &format!("--cq-level={cq}"),
10941+ "--cpu-used=0",
10942+ "--threads=1",
10943+ "--row-mt=0",
10944+ "--sb-size=64",
10945+ "--min-partition-size=4",
10946+ "--max-partition-size=8",
10947+ "--enable-rect-partitions=1",
10948+ "--enable-ab-partitions=0",
10949+ "--enable-1to4-partitions=0",
10950+ "--enable-palette=0",
10951+ "--enable-intrabc=0",
10952+ "--enable-restoration=0",
10953+ "--enable-cdef=0",
10954+ "--loopfilter-control=0",
10955+ "--enable-ref-frame-mvs=0",
10956+ // The tools under test, first occurrence in the
10957+ // command line (aomenc keeps the first).
10958+ "--enable-filter-intra=1",
10959+ &format!("--enable-tx-size-search={tx_search}"),
10960+ "--limit=1",
10961+ "--obu",
10962+ "-o",
10963+ "-",
10964+ "-",
10965+ ])
10966+ .args(if bit_depth == 10 {
10967+ &["--input-bit-depth=10", "--bit-depth=10"][..]
10968+ } else {
10969+ &[][..]
10970+ })
10971+ .stdin(Stdio::piped())
10972+ .stdout(Stdio::piped())
10973+ .stderr(Stdio::piped())
10974+ .spawn()
10975+ .expect("aomenc failed to start");
10976+ child
10977+ .stdin
10978+ .take()
10979+ .expect("aomenc stdin")
10980+ .write_all(&y4m.stdout)
10981+ .expect("writing y4m to aomenc");
10982+ let out = child.wait_with_output().expect("aomenc failed to run");
10983+ if !out.status.success() {
10984+ refusals.push(format!("seed={seed} cq={cq}: aomenc itself refused"));
10985+ continue;
10986+ }
10987+ let stream = out.stdout;
10988+ let fi_before = decode::filter_intra_rect_sub8_hits();
10989+ let split_before = decode::rect8_split_tx_hits();
10990+ let frames = match decode_stream(&stream) {
10991+ Ok(frames) => frames,
10992+ Err(e) => {
10993+ let msg = e.to_string();
10994+ assert!(
10995+ msg.starts_with("unsupported: "),
10996+ "decode error that is not a named refusal \
10997+ (seed={seed} cq={cq} depth={bit_depth} txs={tx_search}): {msg}"
10998+ );
10999+ refusals.push(format!("seed={seed} cq={cq}: {msg}"));
11000+ continue;
11001+ }
11002+ };
11003+ let fi = decode::filter_intra_rect_sub8_hits() - fi_before;
11004+ if fi == 0 {
11005+ refusals.push(format!(
11006+ "seed={seed} cq={cq}: decoded, but no 4x8/8x4 leaf used filter intra"
11007+ ));
11008+ continue;
11009+ }
11010+ let ffmpeg_frames = if bit_depth == 10 {
11011+ ffmpeg_decode_sequence_10bit(&stream, width, height, 1)
11012+ } else {
11013+ ffmpeg_decode_sequence(&stream, width, height, 1)
11014+ };
11015+ assert_eq!(
11016+ frames[0].y, ffmpeg_frames[0].y,
11017+ "luma vs ffmpeg (seed={seed} cq={cq} depth={bit_depth} txs={tx_search})"
11018+ );
11019+ assert_eq!(
11020+ frames[0].u, ffmpeg_frames[0].u,
11021+ "U vs ffmpeg (seed={seed} cq={cq} depth={bit_depth} txs={tx_search})"
11022+ );
11023+ assert_eq!(
11024+ frames[0].v, ffmpeg_frames[0].v,
11025+ "V vs ffmpeg (seed={seed} cq={cq} depth={bit_depth} txs={tx_search})"
11026+ );
11027+ fired_runs += 1;
11028+ fi_leaves += fi;
11029+ split_tx += decode::rect8_split_tx_hits() - split_before;
11030+ if fired_runs >= 3 {
11031+ break;
11032+ }
11033+ }
11034+ assert!(
11035+ fired_runs >= 3,
11036+ "{NAME}: fewer than 3 firing+pixel-exact runs out of 80 attempts \
11037+ (depth={bit_depth} txs={tx_search}), {fi_leaves} filter-intra sub8 leaves \
11038+ seen:\n{}",
11039+ refusals.join("\n")
11040+ );
11041+ if tx_search == "1" {
11042+ assert!(
11043+ split_tx > 0,
11044+ "{NAME}: no sub-8x8 rect leaf used a split (depth-1) transform in the \
11045+ {fired_runs} pixel-exact runs (depth={bit_depth})"
11046+ );
11047+ }
11048+ eprintln!(
11049+ "{NAME}: depth={bit_depth} txs={tx_search} {fired_runs} pixel-exact runs, \
11050+ {fi_leaves} filter-intra 4x8/8x4 leaves, split_tx={split_tx}"
11051+ );
11052+ }
11053+ }
11054+
10874 /// lane-tx4x8 r3 ([[enumerate-table-domain]], [[tool-disabled-in-every-gate]]):11055 /// lane-tx4x8 r3 ([[enumerate-table-domain]], [[tool-disabled-in-every-gate]]):
10875 /// a 16x8/8x16 intra strip whose DIRECTIONAL mode reads above-right or11056 /// a 16x8/8x16 intra strip whose DIRECTIONAL mode reads above-right or
10876 /// below-left samples. Which of those the decoder may read is11057 /// below-left samples. Which of those the decoder may read is