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
463463 /// the flag was never read at that size at all (libaom reads it for every
464464 /// DC_PRED block whose sides are both <= 32), so every DC_PRED 16x8 strip
465465 /// 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] = [
467474 [4621, 32768, 0],
468475 [7866, 32768, 0],
469476 [12408, 32768, 0],
@@ -472,6 +479,8 @@ pub const FILTER_INTRA: [[u16; 3]; 8] = [
472479 [14301, 32768, 0],
473480 [9394, 32768, 0],
474481 [12551, 32768, 0],
482+ [6743, 32768, 0],
483+ [5893, 32768, 0],
475484 ];
476485 /// `default_filter_intra_mode_cdf` (entropymode.c): which of the five
477486 /// `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 {
535535 pub dv_comp: [MvComponentCdfs; 2],
536536 /// The `use_filter_intra` flag, indexed by block-size class (`[0]`=4x4,
537537 /// `[1]`=8x8, `[2]`=16x16, `[3]`=32x32, `[4]`=32x16, `[5]`=16x32,
538- /// `[6]`=16x8, `[7]`=8x16) --
538+ /// `[6]`=16x8, `[7]`=8x16, `[8]`=4x8, `[9]`=8x4) --
539539 /// see [`cdf::FILTER_INTRA`].
540- pub filter_intra: [[u16; 3]; 8],
540+ pub filter_intra: [[u16; 3]; 10],
541541 /// Which `FILTER_INTRA_MODES` entry a `use_filter_intra` block picks.
542542 pub filter_intra_mode: [u16; 6],
543543 /// `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 {
886886 FILTER_INTRA_RECT_SUB16_HITS.with(|c| c.get())
887887 }
888888
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+
889902 // How many [`read_coeffs`] reads resolved a `tx_type` outside `TX_CLASS_2D`
890903 // (`V_DCT`/`H_DCT`, spec 5.11.39's `TxClass::Horiz`/`Vert`), across every
891904 // call on the current thread -- the same before/after counter pattern as
@@ -3949,6 +3962,15 @@ impl Neighbours {
39493962 /// offered (`cfl`, `is_cfl_allowed`, spec 5.11.5), chroma-from-luma -- the
39503963 /// third element carries that mode's `(alpha_q3_u, alpha_q3_v)`, `None` for
39513964 /// 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+
39523974 /// A block-size class index into [`cdf::FILTER_INTRA`]/`Cdfs::filter_intra`,
39533975 /// or `None` when `side` is past `av1_filter_intra_allowed_bsize`'s <=32
39543976 /// 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> {
39773999 // identical mode/uv_mode values, range 34808 vs the oracle's 40668).
39784000 (16, 8) => Some(6),
39794001 (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),
39804007 _ if bw == bh => filter_intra_size_class(bw),
39814008 _ => None,
39824009 }
@@ -4964,7 +4991,7 @@ fn decode_block_rect(
49644991 // decoder consumed one that was never there.
49654992 {
49664993 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));
49684995 let (luma_levels, luma_tx_type) = read_coeffs_rect(
49694996 dec,
49704997 &mut luma_coding,
@@ -5245,7 +5272,7 @@ fn decode_leaf_rect(
52455272 } else {
52465273 TxbSet::LumaRect16x8Set1
52475274 };
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));
52495276 let (l_levels, luma_tx_type) = read_coeffs_rect(
52505277 dec, &mut luma_coding, luma_scan, bw, bh, 0, dc_sign_ctx(around[0].2), TxType::DctDct,
52515278 )?;
@@ -6745,12 +6772,7 @@ fn read_plane(
67456772 // filter-intra is on) -- caller passes the raw filter-intra mode 0..4 in
67466773 // `filter_intra`, only meaningful for `plane_idx == 0` (chroma has no
67476774 // filter-intra in AV1).
6748- const FIMODE_TO_INTRADIR: [usize; 5] = [DC_PRED, V_PRED, H_PRED, D157_PRED, DC_PRED];
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- };
6775+ let tx_mode = if plane_idx == 0 { fi_tx_row(tx_mode, filter_intra) } else { tx_mode };
67546776 let mut coding = cdfs.txb(set, tx_mode);
67556777 // Luma's `default_tx_type` is only a fallback for the sizes whose
67566778 // `TxbSet` carries no symbol at all (32-point and up), which the spec
@@ -7661,6 +7683,11 @@ fn read_intra_mode_sub8(
76617683 left_mode: usize,
76627684 has_chroma: bool,
76637685 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,
76647691 skip_ctx: usize,
76657692 allow_intrabc: bool,
76667693 mi_r: usize,
@@ -7718,9 +7745,7 @@ fn read_intra_mode_sub8(
77187745 };
77197746 let mut filter_intra = None;
77207747 if mode == DC_PRED && enable_filter_intra {
7721- // `BLOCK_4X4`'s own row (class 0, `filter_intra_size_class(4)`) --
7722- // every sub-8x8 leaf here is a `BLOCK_4X4`.
7723- let use_filter_intra = dec.symbol(&mut cdfs.filter_intra[0]) != 0;
7748+ let use_filter_intra = dec.symbol(&mut cdfs.filter_intra[fi_class]) != 0;
77247749 if trace {
77257750 eprintln!("TRACE sub8 use_filter_intra value={}", use_filter_intra as i32);
77267751 }
@@ -7800,8 +7825,9 @@ fn decode_leaf_split4(
78007825 let has_chroma = i == 3;
78017826 let skip_ctx = neighbours.skip_txfm_ctx(lmi.0, lmi.1);
78027827 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,
7804- allow_intrabc, lmi.0, lmi.1,
7828+ dec, cdfs, leaf_above, leaf_left, has_chroma, enable_filter_intra,
7829+ filter_intra_size_class(4).expect("BLOCK_4X4 has its own filter_intra row"),
7830+ skip_ctx, allow_intrabc, lmi.0, lmi.1,
78057831 )?;
78067832 leaf_modes[i] = mode;
78077833 leaf_skips[i] = skip;
@@ -7942,9 +7968,12 @@ fn decode_leaf_split4(
79427968 /// = `{31, 30}` (width 4 above, height 8 left), not the `{31, 31}` a
79437969 /// `BLOCK_4X4` split writes.
79447970 ///
7945-/// Filter intra on one of these leaves is refused by name: `predict_filter_intra`
7946-/// is square-only in this decoder (the same refusal the 16x16-level rect
7947-/// strips already carry).
7971+/// Filter intra on one of these leaves is decoded (lane-fi8 r1): the flag is
7972+/// read from `BLOCK_4X8`/`BLOCK_8X4`'s own `cdf::FILTER_INTRA` row (classes
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`.
79487977 #[allow(clippy::too_many_arguments)]
79497978 fn decode_leaf_rect8(
79507979 dec: &mut SymbolDecoder,
@@ -7994,13 +8023,19 @@ fn decode_leaf_rect8(
79948023 let has_chroma = i == 1;
79958024 let skip_ctx = neighbours.skip_txfm_ctx(lmi.0, lmi.1);
79968025 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,
7998- allow_intrabc, lmi.0, lmi.1,
8026+ dec, cdfs, leaf_above, leaf_left, has_chroma, enable_filter_intra,
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,
79998030 )?;
80008031 if filter_intra.is_some() {
8001- return Err(unsupported(
8002- "filter intra on a HORZ/VERT strip (this decoder predicts square-only)",
8003- ));
8032+ // lane-fi8 r1: `predict_filter_intra` walks its 4x2 patches over
8033+ // a true `bw`x`bh` block, so a 4x8/8x4 leaf predicts through the
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));
80048039 }
80058040 // `TxMode::Select`'s `tx_depth` (spec 5.11.16) exists at a 4x8/8x4
80068041 // leaf too, and is read for every intra block, skipped or not. Its
@@ -8057,8 +8092,8 @@ fn decode_leaf_rect8(
80578092 // prediction of the same mode produces.
80588093 let zeros = vec![0i32; 16];
80598094 y.reconstruct(
8060- tu_px, tu_py, 4, mode, angle_delta_y, tu_reach, &zeros, None, None,
8061- smooth_neighbor,
8095+ tu_px, tu_py, 4, mode, angle_delta_y, tu_reach, &zeros, None,
8096+ filter_intra, smooth_neighbor,
80628097 );
80638098 neighbours.record_mi_luma(tu_mi, 4, &zeros);
80648099 continue;
@@ -8085,7 +8120,7 @@ fn decode_leaf_rect8(
80858120 TX4,
80868121 base_q_idx,
80878122 None,
8088- None,
8123+ filter_intra,
80898124 Some(tu_skip_ctx),
80908125 smooth_neighbor,
80918126 )?;
@@ -8111,7 +8146,8 @@ fn decode_leaf_rect8(
81118146 let grid = if skip {
81128147 let zeros = vec![0i32; bw * bh];
81138148 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,
81158151 );
81168152 zeros
81178153 } else {
@@ -8124,7 +8160,7 @@ fn decode_leaf_rect8(
81248160 } else {
81258161 TxbSet::LumaRect4x8Set1
81268162 };
8127- let mut coding = cdfs.txb(set, mode);
8163+ let mut coding = cdfs.txb(set, fi_tx_row(mode, filter_intra));
81288164 let (levels, tx_type) = read_coeffs_rect(
81298165 dec,
81308166 &mut coding,
@@ -8153,7 +8189,8 @@ fn decode_leaf_rect8(
81538189 tx_type,
81548190 );
81558191 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,
81578194 );
81588195 levels
81598196 };
@@ -18293,15 +18330,13 @@ mod tests {
1829318330 // string that blocks the shape otherwise. Either way the row is
1829418331 // pinned HERE, so the round that lifts one of those refusals cannot
1829518332 // 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)";
1829818333 const PART16: &str = "a HORZ_A/HORZ_B/VERT_A partition below 16x16 (this decoder codes \
1829918334 only the square arms, HORZ, VERT, VERT_B, and a clean split below 16x16)";
1830018335 const PART32: &str = "a 32x32 partition type this decoder does not code (value={part32})";
1830118336 let libaom: &[(usize, usize, u16, Option<&str>)] = &[
1830218337 (4, 4, 4621, None),
18303- (4, 8, 6743, Some(BELOW_8X8)),
18304- (8, 4, 5893, Some(BELOW_8X8)),
18338+ (4, 8, 6743, None),
18339+ (8, 4, 5893, None),
1830518340 (8, 8, 7866, None),
1830618341 (8, 16, 12551, None),
1830718342 (16, 8, 9394, None),
crates/ec-av1/src/refusal_inventory.rsmodified+0 -3
@@ -67,9 +67,6 @@ const REFUSALS: &[&str] = &[
6767 "an inter partition below 16x16 other than SPLIT (16x8/8x16 rect inter leaves are not coded yet)",
6868 "an intra mode this decoder does not code (round 2)",
6969 "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)",
7370 "warp prediction with a scaled reference (superres, unimplemented)",
7471 "an 8x8 partition leaf under a scaled reference (superres, unimplemented)",
7572 ];
crates/ec-av1/src/stream.rsmodified+181 -0
@@ -10871,6 +10871,187 @@ mod tests {
1087110871 }
1087210872 }
1087310873
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+
1087411055 /// lane-tx4x8 r3 ([[enumerate-table-domain]], [[tool-disabled-in-every-gate]]):
1087511056 /// a 16x8/8x16 intra strip whose DIRECTIONAL mode reads above-right or
1087611057 /// below-left samples. Which of those the decoder may read is