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

5959a930a7c2470b8e584a2366496ecd218607a3Ahmet Kaan GümüşParent: 2cd82ea
  • 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).
(cherry picked from commit 2d5c425c515d1f6a8d5089cf2ec4d187e2d407fd)
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
@@ -951,6 +951,19 @@ pub(crate) fn filter_intra_rect_sub16_hits() -> usize {
951 FILTER_INTRA_RECT_SUB16_HITS.with(|c| c.get())951 FILTER_INTRA_RECT_SUB16_HITS.with(|c| c.get())
952 }952 }
953 953
954+// As [`FILTER_INTRA_RECT_SUB16_HITS`], one partition level further down:
955+// 4x8/8x4 leaves of an 8x8 HORZ/VERT (lane-fi8 r1). A gate on the sub16
956+// counter would be satisfied by a 16x8 strip and prove nothing here.
957+thread_local! {
958+ static FILTER_INTRA_RECT_SUB8_HITS: std::cell::Cell<usize> =
959+ const { std::cell::Cell::new(0) };
960+}
961+
962+/// Current value of [`FILTER_INTRA_RECT_SUB8_HITS`].
963+pub(crate) fn filter_intra_rect_sub8_hits() -> usize {
964+ FILTER_INTRA_RECT_SUB8_HITS.with(|c| c.get())
965+}
966+
954 // How many [`read_coeffs`] reads resolved a `tx_type` outside `TX_CLASS_2D`967 // How many [`read_coeffs`] reads resolved a `tx_type` outside `TX_CLASS_2D`
955 // (`V_DCT`/`H_DCT`, spec 5.11.39's `TxClass::Horiz`/`Vert`), across every968 // (`V_DCT`/`H_DCT`, spec 5.11.39's `TxClass::Horiz`/`Vert`), across every
956 // call on the current thread -- the same before/after counter pattern as969 // call on the current thread -- the same before/after counter pattern as
@@ -4149,6 +4162,15 @@ impl Neighbours {
4149 /// offered (`cfl`, `is_cfl_allowed`, spec 5.11.5), chroma-from-luma -- the4162 /// offered (`cfl`, `is_cfl_allowed`, spec 5.11.5), chroma-from-luma -- the
4150 /// third element carries that mode's `(alpha_q3_u, alpha_q3_v)`, `None` for4163 /// third element carries that mode's `(alpha_q3_u, alpha_q3_v)`, `None` for
4151 /// plain DC chroma.4164 /// plain DC chroma.
4165+/// spec 5.11.47 / libaom `av1_read_tx_type`'s `fimode_to_intradir`: which
4166+/// `intra_ext_tx_cdf` row a luma transform reads. A filter-intra block's
4167+/// `mode` is always `DC_PRED`, so the row comes from the FILTER-INTRA mode
4168+/// instead (the defect commit 1a89ed9 fixed at the square sites).
4169+fn fi_tx_row(mode: usize, filter_intra: Option<usize>) -> usize {
4170+ const FIMODE_TO_INTRADIR: [usize; 5] = [DC_PRED, V_PRED, H_PRED, D157_PRED, DC_PRED];
4171+ filter_intra.map_or(mode, |fi| FIMODE_TO_INTRADIR[fi])
4172+}
4173+
4152 /// A block-size class index into [`cdf::FILTER_INTRA`]/`Cdfs::filter_intra`,4174 /// A block-size class index into [`cdf::FILTER_INTRA`]/`Cdfs::filter_intra`,
4153 /// or `None` when `side` is past `av1_filter_intra_allowed_bsize`'s <=324175 /// or `None` when `side` is past `av1_filter_intra_allowed_bsize`'s <=32
4154 /// bound (spec `filter_intra_mode_info` never reads a symbol there).4176 /// bound (spec `filter_intra_mode_info` never reads a symbol there).
@@ -4177,6 +4199,11 @@ fn filter_intra_size_class_rect(bw: usize, bh: usize) -> Option<usize> {
4177 // identical mode/uv_mode values, range 34808 vs the oracle's 40668).4199 // identical mode/uv_mode values, range 34808 vs the oracle's 40668).
4178 (16, 8) => Some(6),4200 (16, 8) => Some(6),
4179 (8, 16) => Some(7),4201 (8, 16) => Some(7),
4202+ // lane-fi8 r1: the sub-8 rect leaves are allowed too (both sides <=
4203+ // 32), and `decode_leaf_rect8` codes them -- rows 1/2 of
4204+ // `default_filter_intra_cdfs`, NOT BLOCK_4X4's row 0.
4205+ (4, 8) => Some(8),
4206+ (8, 4) => Some(9),
4180 _ if bw == bh => filter_intra_size_class(bw),4207 _ if bw == bh => filter_intra_size_class(bw),
4181 _ => None,4208 _ => None,
4182 }4209 }
@@ -5167,7 +5194,7 @@ fn decode_block_rect(
5167 // decoder consumed one that was never there.5194 // decoder consumed one that was never there.
5168 {5195 {
5169 let around = neighbours.around_rect(at, bw, bh);5196 let around = neighbours.around_rect(at, bw, bh);
5170- let mut luma_coding = cdfs.txb(TxbSet::LumaRect32x16, mode);5197+ let mut luma_coding = cdfs.txb(TxbSet::LumaRect32x16, fi_tx_row(mode, filter_intra));
5171 let (luma_levels, luma_tx_type) = read_coeffs_rect(5198 let (luma_levels, luma_tx_type) = read_coeffs_rect(
5172 dec,5199 dec,
5173 &mut luma_coding,5200 &mut luma_coding,
@@ -5452,7 +5479,7 @@ fn decode_leaf_rect(
5452 } else {5479 } else {
5453 TxbSet::LumaRect16x8Set15480 TxbSet::LumaRect16x8Set1
5454 };5481 };
5455- let mut luma_coding = cdfs.txb(luma_set, mode);5482+ let mut luma_coding = cdfs.txb(luma_set, fi_tx_row(mode, filter_intra));
5456 let (l_levels, luma_tx_type) = read_coeffs_rect(5483 let (l_levels, luma_tx_type) = read_coeffs_rect(
5457 dec, &mut luma_coding, luma_scan, bw, bh, 0, dc_sign_ctx(around[0].2), TxType::DctDct,5484 dec, &mut luma_coding, luma_scan, bw, bh, 0, dc_sign_ctx(around[0].2), TxType::DctDct,
5458 )?;5485 )?;
@@ -6963,12 +6990,7 @@ fn read_plane(
6963 // filter-intra is on) -- caller passes the raw filter-intra mode 0..4 in6990 // filter-intra is on) -- caller passes the raw filter-intra mode 0..4 in
6964 // `filter_intra`, only meaningful for `plane_idx == 0` (chroma has no6991 // `filter_intra`, only meaningful for `plane_idx == 0` (chroma has no
6965 // filter-intra in AV1).6992 // filter-intra in AV1).
6966- const FIMODE_TO_INTRADIR: [usize; 5] = [DC_PRED, V_PRED, H_PRED, D157_PRED, DC_PRED];6993+ let tx_mode = if plane_idx == 0 { fi_tx_row(tx_mode, filter_intra) } else { tx_mode };
6967- let tx_mode = if plane_idx == 0 {
6968- filter_intra.map_or(tx_mode, |fi| FIMODE_TO_INTRADIR[fi])
6969- } else {
6970- tx_mode
6971- };
6972 let mut coding = cdfs.txb(set, tx_mode);6994 let mut coding = cdfs.txb(set, tx_mode);
6973 // Luma's `default_tx_type` is only a fallback for the sizes whose6995 // Luma's `default_tx_type` is only a fallback for the sizes whose
6974 // `TxbSet` carries no symbol at all (32-point and up), which the spec6996 // `TxbSet` carries no symbol at all (32-point and up), which the spec
@@ -7884,6 +7906,11 @@ fn read_intra_mode_sub8(
7884 left_mode: usize,7906 left_mode: usize,
7885 has_chroma: bool,7907 has_chroma: bool,
7886 enable_filter_intra: bool,7908 enable_filter_intra: bool,
7909+ // [`filter_intra_size_class_rect`] for the LEAF's own shape: 0 for a
7910+ // `BLOCK_4X4` split leaf, 8/9 for a 4x8/8x4 rect leaf. Reading the flag
7911+ // from the wrong row is the same VALUE with a different interval, so it
7912+ // desyncs a block or two later, not here (class `wrong-alphabet-same-value`).
7913+ fi_class: usize,
7887 skip_ctx: usize,7914 skip_ctx: usize,
7888 allow_intrabc: bool,7915 allow_intrabc: bool,
7889 mi_r: usize,7916 mi_r: usize,
@@ -7941,9 +7968,7 @@ fn read_intra_mode_sub8(
7941 };7968 };
7942 let mut filter_intra = None;7969 let mut filter_intra = None;
7943 if mode == DC_PRED && enable_filter_intra {7970 if mode == DC_PRED && enable_filter_intra {
7944- // `BLOCK_4X4`'s own row (class 0, `filter_intra_size_class(4)`) --7971+ let use_filter_intra = dec.symbol(&mut cdfs.filter_intra[fi_class]) != 0;
7945- // every sub-8x8 leaf here is a `BLOCK_4X4`.
7946- let use_filter_intra = dec.symbol(&mut cdfs.filter_intra[0]) != 0;
7947 if trace {7972 if trace {
7948 eprintln!("TRACE sub8 use_filter_intra value={}", use_filter_intra as i32);7973 eprintln!("TRACE sub8 use_filter_intra value={}", use_filter_intra as i32);
7949 }7974 }
@@ -8023,8 +8048,9 @@ fn decode_leaf_split4(
8023 let has_chroma = i == 3;8048 let has_chroma = i == 3;
8024 let skip_ctx = neighbours.skip_txfm_ctx(lmi.0, lmi.1);8049 let skip_ctx = neighbours.skip_txfm_ctx(lmi.0, lmi.1);
8025 let (skip, mode, angle_delta_y, chroma, filter_intra) = read_intra_mode_sub8(8050 let (skip, mode, angle_delta_y, chroma, filter_intra) = read_intra_mode_sub8(
8026- dec, cdfs, leaf_above, leaf_left, has_chroma, enable_filter_intra, skip_ctx,8051+ dec, cdfs, leaf_above, leaf_left, has_chroma, enable_filter_intra,
8027- allow_intrabc, lmi.0, lmi.1,8052+ filter_intra_size_class(4).expect("BLOCK_4X4 has its own filter_intra row"),
8053+ skip_ctx, allow_intrabc, lmi.0, lmi.1,
8028 )?;8054 )?;
8029 leaf_modes[i] = mode;8055 leaf_modes[i] = mode;
8030 leaf_skips[i] = skip;8056 leaf_skips[i] = skip;
@@ -8165,9 +8191,12 @@ fn decode_leaf_split4(
8165 /// = `{31, 30}` (width 4 above, height 8 left), not the `{31, 31}` a8191 /// = `{31, 30}` (width 4 above, height 8 left), not the `{31, 31}` a
8166 /// `BLOCK_4X4` split writes.8192 /// `BLOCK_4X4` split writes.
8167 ///8193 ///
8168-/// Filter intra on one of these leaves is refused by name: `predict_filter_intra`8194+/// Filter intra on one of these leaves is decoded (lane-fi8 r1): the flag is
8169-/// is square-only in this decoder (the same refusal the 16x16-level rect8195+/// read from `BLOCK_4X8`/`BLOCK_8X4`'s own `cdf::FILTER_INTRA` row (classes
8170-/// strips already carry).8196+/// 8/9, NOT `BLOCK_4X4`'s), the predictor is [`crate::intra::predict_filter_intra`]
8197+/// over the leaf's true `bw`x`bh` -- per 4x4 transform unit, with that unit's
8198+/// own edge, when `tx_depth` splits it -- and the coded `tx_type` row is
8199+/// [`fi_tx_row`]'s `fimode_to_intradir`, not the block's raw `DC_PRED`.
8171 #[allow(clippy::too_many_arguments)]8200 #[allow(clippy::too_many_arguments)]
8172 fn decode_leaf_rect8(8201 fn decode_leaf_rect8(
8173 dec: &mut SymbolDecoder,8202 dec: &mut SymbolDecoder,
@@ -8217,13 +8246,19 @@ fn decode_leaf_rect8(
8217 let has_chroma = i == 1;8246 let has_chroma = i == 1;
8218 let skip_ctx = neighbours.skip_txfm_ctx(lmi.0, lmi.1);8247 let skip_ctx = neighbours.skip_txfm_ctx(lmi.0, lmi.1);
8219 let (skip, mode, angle_delta_y, chroma, filter_intra) = read_intra_mode_sub8(8248 let (skip, mode, angle_delta_y, chroma, filter_intra) = read_intra_mode_sub8(
8220- dec, cdfs, leaf_above, leaf_left, has_chroma, enable_filter_intra, skip_ctx,8249+ dec, cdfs, leaf_above, leaf_left, has_chroma, enable_filter_intra,
8221- allow_intrabc, lmi.0, lmi.1,8250+ filter_intra_size_class_rect(bw, bh)
8251+ .expect("BLOCK_4X8/BLOCK_8X4 are inside av1_filter_intra_allowed_bsize"),
8252+ skip_ctx, allow_intrabc, lmi.0, lmi.1,
8222 )?;8253 )?;
8223 if filter_intra.is_some() {8254 if filter_intra.is_some() {
8224- return Err(unsupported(8255+ // lane-fi8 r1: `predict_filter_intra` walks its 4x2 patches over
8225- "filter intra on a HORZ/VERT strip (this decoder predicts square-only)",8256+ // a true `bw`x`bh` block, so a 4x8/8x4 leaf predicts through the
8226- ));8257+ // same `reconstruct_rect`/`reconstruct` calls below -- and under
8258+ // a split transform, per 4x4 unit with that unit's own edge,
8259+ // which is exactly what the depth-1 loop already does.
8260+ FILTER_INTRA_RECT_HITS.with(|c| c.set(c.get() + 1));
8261+ FILTER_INTRA_RECT_SUB8_HITS.with(|c| c.set(c.get() + 1));
8227 }8262 }
8228 // `TxMode::Select`'s `tx_depth` (spec 5.11.16) exists at a 4x8/8x48263 // `TxMode::Select`'s `tx_depth` (spec 5.11.16) exists at a 4x8/8x4
8229 // leaf too, and is read for every intra block, skipped or not. Its8264 // leaf too, and is read for every intra block, skipped or not. Its
@@ -8280,8 +8315,8 @@ fn decode_leaf_rect8(
8280 // prediction of the same mode produces.8315 // prediction of the same mode produces.
8281 let zeros = vec![0i32; 16];8316 let zeros = vec![0i32; 16];
8282 y.reconstruct(8317 y.reconstruct(
8283- tu_px, tu_py, 4, mode, angle_delta_y, tu_reach, &zeros, None, None,8318+ tu_px, tu_py, 4, mode, angle_delta_y, tu_reach, &zeros, None,
8284- smooth_neighbor,8319+ filter_intra, smooth_neighbor,
8285 );8320 );
8286 neighbours.record_mi_luma(tu_mi, 4, &zeros);8321 neighbours.record_mi_luma(tu_mi, 4, &zeros);
8287 continue;8322 continue;
@@ -8308,7 +8343,7 @@ fn decode_leaf_rect8(
8308 TX4,8343 TX4,
8309 base_q_idx,8344 base_q_idx,
8310 None,8345 None,
8311- None,8346+ filter_intra,
8312 Some(tu_skip_ctx),8347 Some(tu_skip_ctx),
8313 smooth_neighbor,8348 smooth_neighbor,
8314 )?;8349 )?;
@@ -8334,7 +8369,8 @@ fn decode_leaf_rect8(
8334 let grid = if skip {8369 let grid = if skip {
8335 let zeros = vec![0i32; bw * bh];8370 let zeros = vec![0i32; bw * bh];
8336 y.reconstruct_rect(8371 y.reconstruct_rect(
8337- px, py, bw, bh, mode, angle_delta_y, reach, &zeros, None, None, smooth_neighbor,8372+ px, py, bw, bh, mode, angle_delta_y, reach, &zeros, None, filter_intra,
8373+ smooth_neighbor,
8338 );8374 );
8339 zeros8375 zeros
8340 } else {8376 } else {
@@ -8347,7 +8383,7 @@ fn decode_leaf_rect8(
8347 } else {8383 } else {
8348 TxbSet::LumaRect4x8Set18384 TxbSet::LumaRect4x8Set1
8349 };8385 };
8350- let mut coding = cdfs.txb(set, mode);8386+ let mut coding = cdfs.txb(set, fi_tx_row(mode, filter_intra));
8351 let (levels, tx_type) = read_coeffs_rect(8387 let (levels, tx_type) = read_coeffs_rect(
8352 dec,8388 dec,
8353 &mut coding,8389 &mut coding,
@@ -8376,7 +8412,8 @@ fn decode_leaf_rect8(
8376 tx_type,8412 tx_type,
8377 );8413 );
8378 y.reconstruct_rect(8414 y.reconstruct_rect(
8379- px, py, bw, bh, mode, angle_delta_y, reach, &residual, None, None, smooth_neighbor,8415+ px, py, bw, bh, mode, angle_delta_y, reach, &residual, None, filter_intra,
8416+ smooth_neighbor,
8380 );8417 );
8381 levels8418 levels
8382 };8419 };
@@ -18552,15 +18589,13 @@ mod tests {
18552 // string that blocks the shape otherwise. Either way the row is18589 // string that blocks the shape otherwise. Either way the row is
18553 // pinned HERE, so the round that lifts one of those refusals cannot18590 // pinned HERE, so the round that lifts one of those refusals cannot
18554 // land a wrong CDF row for the shape it unlocks.18591 // land a wrong CDF row for the shape it unlocks.
18555- const BELOW_8X8: &str =
18556- "a partition below 8x8 (this decoder codes no leaf smaller than 8x8)";
18557 const PART16: &str = "a HORZ_A/HORZ_B/VERT_A partition below 16x16 (this decoder codes \18592 const PART16: &str = "a HORZ_A/HORZ_B/VERT_A partition below 16x16 (this decoder codes \
18558 only the square arms, HORZ, VERT, VERT_B, and a clean split below 16x16)";18593 only the square arms, HORZ, VERT, VERT_B, and a clean split below 16x16)";
18559 const PART32: &str = "a 32x32 partition type this decoder does not code (value={part32})";18594 const PART32: &str = "a 32x32 partition type this decoder does not code (value={part32})";
18560 let libaom: &[(usize, usize, u16, Option<&str>)] = &[18595 let libaom: &[(usize, usize, u16, Option<&str>)] = &[
18561 (4, 4, 4621, None),18596 (4, 4, 4621, None),
18562- (4, 8, 6743, Some(BELOW_8X8)),18597+ (4, 8, 6743, None),
18563- (8, 4, 5893, Some(BELOW_8X8)),18598+ (8, 4, 5893, None),
18564 (8, 8, 7866, None),18599 (8, 8, 7866, None),
18565 (8, 16, 12551, None),18600 (8, 16, 12551, None),
18566 (16, 8, 9394, None),18601 (16, 8, 9394, None),
crates/ec-av1/src/refusal_inventory.rsmodified+0 -3
@@ -66,9 +66,6 @@ const REFUSALS: &[&str] = &[
66 "an inter partition below 16x16 other than SPLIT (16x8/8x16 rect inter leaves are not coded yet)",66 "an inter partition below 16x16 other than SPLIT (16x8/8x16 rect inter leaves are not coded yet)",
67 "an intra mode this decoder does not code (round 2)",67 "an intra mode this decoder does not code (round 2)",
68 "an intra-coded HORZ/VERT strip needs rectangular intra prediction this decoder does not code yet",68 "an intra-coded HORZ/VERT strip needs rectangular intra prediction this decoder does not code yet",
69- // Lifted for the 16x8/8x16 leaf by lane-fistrip; still live one level
70- // down, at the 4x8/8x4 sub-8 leaf (lane-tx4x8's `decode_leaf_rect8`).
71- "filter intra on a HORZ/VERT strip (this decoder predicts square-only)",
72 "warp prediction with a scaled reference (superres, unimplemented)",69 "warp prediction with a scaled reference (superres, unimplemented)",
73 "an 8x8 partition leaf under a scaled reference (superres, unimplemented)",70 "an 8x8 partition leaf under a scaled reference (superres, unimplemented)",
74 ];71 ];
crates/ec-av1/src/stream.rsmodified+181 -0
@@ -11873,6 +11873,187 @@ mod tests {
11873 }11873 }
11874 }11874 }
11875 11875
11876+ /// lane-fi8 r1: the sub8 rect-leaf gate above with the tool under test
11877+ /// turned ON (`--enable-filter-intra=1`, appended AFTER the base recipe
11878+ /// -- aomenc takes the FIRST occurrence of a repeated flag, so the base
11879+ /// recipe below carries no `--enable-filter-intra` at all). A DC_PRED
11880+ /// `BLOCK_4X8`/`BLOCK_8X4` leaf carries a `use_filter_intra` flag
11881+ /// (`av1_filter_intra_allowed_bsize` is "both sides <= 32"), which this
11882+ /// decoder read from `BLOCK_4X4`'s CDF row until this round -- the same
11883+ /// VALUE, a different interval, so it desynced a block or two later
11884+ /// ([[wrong-alphabet-same-value]]) -- and then refused the prediction by
11885+ /// name. Per attempt, only runs whose [`decode::filter_intra_rect_sub8_hits`]
11886+ /// delta is nonzero AND whose three planes match ffmpeg count; the wider
11887+ /// `filter_intra_rect_hits` would be satisfied by a 16x8 strip and prove
11888+ /// nothing about these shapes. Arms cover both transform depths
11889+ /// (`--enable-tx-size-search=1`, where a leaf may split into two 4x4
11890+ /// units each predicted from the previous one's reconstruction, and `=0`,
11891+ /// one whole-leaf transform) and both bit depths.
11892+ #[test]
11893+ fn a_real_aomenc_stream_with_filter_intra_on_a_sub8_rect_leaf_decodes_pixel_exact() {
11894+ const NAME: &str =
11895+ "a_real_aomenc_stream_with_filter_intra_on_a_sub8_rect_leaf_decodes_pixel_exact";
11896+ if !have_ffmpeg() {
11897+ eprintln!("SKIP {NAME}: no ffmpeg");
11898+ return;
11899+ }
11900+ if !have_aomenc() {
11901+ let msg = format!("no aomenc at {}", aomenc_path().display());
11902+ assert!(
11903+ std::env::var_os("EC_AV1_REQUIRE_AOMENC").is_none(),
11904+ "EC_AV1_REQUIRE_AOMENC is set but {msg}"
11905+ );
11906+ eprintln!("SKIP {NAME}: {msg}");
11907+ return;
11908+ }
11909+ let (width, height) = (16usize, 16usize);
11910+ for (tx_search, bit_depth) in [("1", 8u8), ("0", 8u8), ("1", 10u8)] {
11911+ let mut refusals = Vec::new();
11912+ let mut fired_runs = 0u32;
11913+ let mut fi_leaves = 0usize;
11914+ let mut split_tx = 0usize;
11915+ for attempt in 0..80u32 {
11916+ let seed = 300 + attempt;
11917+ let cq = 6 + (attempt % 8) * 6;
11918+ let pix_fmt = if bit_depth == 10 { "yuv420p10le" } else { "yuv420p" };
11919+ let y4m = Command::new("ffmpeg")
11920+ .args([
11921+ "-v", "error", "-f", "lavfi", "-i",
11922+ &format!("testsrc2=size={width}x{height}:rate=25"),
11923+ "-vf",
11924+ &format!("noise=alls=40:allf=t:all_seed={seed},format={pix_fmt}"),
11925+ "-strict", "-1", "-t", "0.04", "-f", "yuv4mpegpipe", "-",
11926+ ])
11927+ .stdin(Stdio::null())
11928+ .stdout(Stdio::piped())
11929+ .stderr(Stdio::piped())
11930+ .output()
11931+ .expect("ffmpeg failed to run");
11932+ assert!(
11933+ y4m.status.success(),
11934+ "ffmpeg fixture: {}",
11935+ String::from_utf8_lossy(&y4m.stderr)
11936+ );
11937+ let mut child = Command::new(aomenc_path())
11938+ .args([
11939+ "--codec=av1",
11940+ "--passes=1",
11941+ "--end-usage=q",
11942+ &format!("--cq-level={cq}"),
11943+ "--cpu-used=0",
11944+ "--threads=1",
11945+ "--row-mt=0",
11946+ "--sb-size=64",
11947+ "--min-partition-size=4",
11948+ "--max-partition-size=8",
11949+ "--enable-rect-partitions=1",
11950+ "--enable-ab-partitions=0",
11951+ "--enable-1to4-partitions=0",
11952+ "--enable-palette=0",
11953+ "--enable-intrabc=0",
11954+ "--enable-restoration=0",
11955+ "--enable-cdef=0",
11956+ "--loopfilter-control=0",
11957+ "--enable-ref-frame-mvs=0",
11958+ // The tools under test, first occurrence in the
11959+ // command line (aomenc keeps the first).
11960+ "--enable-filter-intra=1",
11961+ &format!("--enable-tx-size-search={tx_search}"),
11962+ "--limit=1",
11963+ "--obu",
11964+ "-o",
11965+ "-",
11966+ "-",
11967+ ])
11968+ .args(if bit_depth == 10 {
11969+ &["--input-bit-depth=10", "--bit-depth=10"][..]
11970+ } else {
11971+ &[][..]
11972+ })
11973+ .stdin(Stdio::piped())
11974+ .stdout(Stdio::piped())
11975+ .stderr(Stdio::piped())
11976+ .spawn()
11977+ .expect("aomenc failed to start");
11978+ child
11979+ .stdin
11980+ .take()
11981+ .expect("aomenc stdin")
11982+ .write_all(&y4m.stdout)
11983+ .expect("writing y4m to aomenc");
11984+ let out = child.wait_with_output().expect("aomenc failed to run");
11985+ if !out.status.success() {
11986+ refusals.push(format!("seed={seed} cq={cq}: aomenc itself refused"));
11987+ continue;
11988+ }
11989+ let stream = out.stdout;
11990+ let fi_before = decode::filter_intra_rect_sub8_hits();
11991+ let split_before = decode::rect8_split_tx_hits();
11992+ let frames = match decode_stream(&stream) {
11993+ Ok(frames) => frames,
11994+ Err(e) => {
11995+ let msg = e.to_string();
11996+ assert!(
11997+ msg.starts_with("unsupported: "),
11998+ "decode error that is not a named refusal \
11999+ (seed={seed} cq={cq} depth={bit_depth} txs={tx_search}): {msg}"
12000+ );
12001+ refusals.push(format!("seed={seed} cq={cq}: {msg}"));
12002+ continue;
12003+ }
12004+ };
12005+ let fi = decode::filter_intra_rect_sub8_hits() - fi_before;
12006+ if fi == 0 {
12007+ refusals.push(format!(
12008+ "seed={seed} cq={cq}: decoded, but no 4x8/8x4 leaf used filter intra"
12009+ ));
12010+ continue;
12011+ }
12012+ let ffmpeg_frames = if bit_depth == 10 {
12013+ ffmpeg_decode_sequence_10bit(&stream, width, height, 1)
12014+ } else {
12015+ ffmpeg_decode_sequence(&stream, width, height, 1)
12016+ };
12017+ assert_eq!(
12018+ frames[0].y, ffmpeg_frames[0].y,
12019+ "luma vs ffmpeg (seed={seed} cq={cq} depth={bit_depth} txs={tx_search})"
12020+ );
12021+ assert_eq!(
12022+ frames[0].u, ffmpeg_frames[0].u,
12023+ "U vs ffmpeg (seed={seed} cq={cq} depth={bit_depth} txs={tx_search})"
12024+ );
12025+ assert_eq!(
12026+ frames[0].v, ffmpeg_frames[0].v,
12027+ "V vs ffmpeg (seed={seed} cq={cq} depth={bit_depth} txs={tx_search})"
12028+ );
12029+ fired_runs += 1;
12030+ fi_leaves += fi;
12031+ split_tx += decode::rect8_split_tx_hits() - split_before;
12032+ if fired_runs >= 3 {
12033+ break;
12034+ }
12035+ }
12036+ assert!(
12037+ fired_runs >= 3,
12038+ "{NAME}: fewer than 3 firing+pixel-exact runs out of 80 attempts \
12039+ (depth={bit_depth} txs={tx_search}), {fi_leaves} filter-intra sub8 leaves \
12040+ seen:\n{}",
12041+ refusals.join("\n")
12042+ );
12043+ if tx_search == "1" {
12044+ assert!(
12045+ split_tx > 0,
12046+ "{NAME}: no sub-8x8 rect leaf used a split (depth-1) transform in the \
12047+ {fired_runs} pixel-exact runs (depth={bit_depth})"
12048+ );
12049+ }
12050+ eprintln!(
12051+ "{NAME}: depth={bit_depth} txs={tx_search} {fired_runs} pixel-exact runs, \
12052+ {fi_leaves} filter-intra 4x8/8x4 leaves, split_tx={split_tx}"
12053+ );
12054+ }
12055+ }
12056+
11876 /// lane-tx4x8 r3 ([[enumerate-table-domain]], [[tool-disabled-in-every-gate]]):12057 /// lane-tx4x8 r3 ([[enumerate-table-domain]], [[tool-disabled-in-every-gate]]):
11877 /// a 16x8/8x16 intra strip whose DIRECTIONAL mode reads above-right or12058 /// a 16x8/8x16 intra strip whose DIRECTIONAL mode reads above-right or
11878 /// below-left samples. Which of those the decoder may read is12059 /// below-left samples. Which of those the decoder may read is