forge
Explore
Log in

Don't you dare go Hollow

wip(rectsplit): r2 capped at 75 turns before running gates -- SB-level split-tx per-TU path + gate rewrite (per-attempt counters), preserved by orchestrator

Browse files at this commit

ec3268ed1a578aac4f2bdf69391577b8f0cfb241Ahmet Kaan GümüşParent: 1fce295
crates/ec-av1/examples/decode_probe.rsmodified+17 -1
@@ -32,7 +32,23 @@ fn main() {
3232 Ok(frames) if frames.is_empty() => {
3333 println!("OK but EMPTY: no frames -- is {path} an IVF rather than a raw OBU stream?");
3434 }
35- Ok(frames) => println!("OK: {} frames decoded", frames.len()),
35+ Ok(frames) => {
36+ println!("OK: {} frames decoded", frames.len());
37+ // Optional second argument: write the decoded planes as raw
38+ // I420 (`ffmpeg -pix_fmt yuv420p -f rawvideo` order), so a
39+ // mismatch against ffmpeg's own decode can be located per pixel
40+ // without going through a gate.
41+ if let Some(out) = std::env::args().nth(2) {
42+ let mut raw = Vec::new();
43+ for f in &frames {
44+ for plane in [&f.y, &f.u, &f.v] {
45+ raw.extend(plane.iter().map(|&v| v as u8));
46+ }
47+ }
48+ std::fs::write(&out, raw).expect("writing the raw dump");
49+ println!("wrote {out}");
50+ }
51+ }
3652 Err(e) => println!("REFUSED: {e}"),
3753 }
3854 }
crates/ec-av1/src/decode.rsmodified+108 -17
@@ -442,6 +442,22 @@ pub(crate) fn rect_split_tx_hits() -> usize {
442442 RECT_SPLIT_TX_HITS.with(|c| c.get())
443443 }
444444
445+// The subset of [`RECT_SPLIT_TX_HITS`] that is BOTH superblock-level (one
446+// side 64) AND split past the first depth, i.e. tiled more than one unit in
447+// each axis -- the only shape with a transform unit that has neighbours on
448+// two sides inside its own strip (`row_off > 0 && col_off > 0`), and the one
449+// no gate fired before lane-rectsplit r2 (the shared counter above also
450+// counts 32x32-level and depth-1 strips, so it cannot prove this case).
451+thread_local! {
452+ static RECT_SPLIT_SB_INTERIOR_TU_HITS: std::cell::Cell<usize> =
453+ const { std::cell::Cell::new(0) };
454+}
455+
456+/// Current value of [`RECT_SPLIT_SB_INTERIOR_TU_HITS`].
457+pub(crate) fn rect_split_sb_interior_tu_hits() -> usize {
458+ RECT_SPLIT_SB_INTERIOR_TU_HITS.with(|c| c.get())
459+}
460+
445461 // How many HORZ/VERT intra strips actually predicted with filter intra
446462 // (lane-rectsplit r1) -- the case `decode_block_rect` refused by name
447463 // ("this decoder predicts square-only") until `predict_filter_intra` took
@@ -1143,12 +1159,26 @@ fn base_ctx(
11431159 // (lane-sbpart r8 root cause: `(row=1, col=0)` reads ctx 2 under the
11441160 // square table vs the real ctx 13 the rect table gives).
11451161 TxClass::TwoD => {
1162+ // lane-rectsplit r2: libaom's `av1_nz_map_ctx_offset[tx_size]`
1163+ // is a FLAT array indexed by its own `coeff_idx`, which is
1164+ // COLUMN-major (`coeff_idx = col * height + row`, the same
1165+ // packing `TX_CLASS_HORIZ` reads back as `coeff_idx >> bhl`) --
1166+ // so a `[a][b]` transcription of 32 consecutive entries per row
1167+ // holds `[col][row]`, not `[row][col]`. The square table is
1168+ // symmetric and never noticed; the two rect ones are not, and
1169+ // reading `NZ_MAP_CTX_OFFSET_32X64[2][0]` (11) where libaom
1170+ // reads offset 6 desynced the FIRST superblock-level 32x64
1171+ // strip whose corner had a coefficient below row 1 (seed 50 of
1172+ // gate (b), coefficient (row 2, col 0): ctx 11 vs the oracle's
1173+ // 6). [`base_ctx_rect`] states the same rule in display
1174+ // coordinates directly; `nz_map_ctx_offset_tables_match_the_rect_rule`
1175+ // pins the two against each other.
11461176 let table = match rect_shape {
11471177 Some((w, h)) if w < h => &cdf::NZ_MAP_CTX_OFFSET_32X64,
11481178 Some((w, h)) if w > h => &cdf::NZ_MAP_CTX_OFFSET_64X32,
11491179 _ => &cdf::NZ_MAP_CTX_OFFSET_32,
11501180 };
1151- ctx + table[row.min(4)][col.min(4)] as usize
1181+ ctx + table[col.min(4)][row.min(4)] as usize
11521182 }
11531183 TxClass::Horiz => ctx + nz_map_ctx_offset_1d(col.min(31)),
11541184 TxClass::Vert => ctx + nz_map_ctx_offset_1d(row.min(31)),
@@ -3218,12 +3248,22 @@ fn decode_rect_split(
32183248 (16, 32) => Some((TxbSet::ChromaRect32x16, &SCAN_16X32[..])),
32193249 _ => None,
32203250 };
3251+ // lane-rectsplit r2 (verifier finding): with both callers wired
3252+ // (`decode_block_rect`'s 32x16/16x32 and `decode_block_rect64`'s
3253+ // 64x32/32x64) every shape that reaches here has a table above, so this
3254+ // arm is UNREACHABLE today. It stays as the shape guard for the next
3255+ // caller -- a new strip size would otherwise hit the `expect` below and
3256+ // panic instead of refusing by name -- and so stays in
3257+ // `refusal_inventory::REFUSALS`.
32213258 if !m.skip && chroma.is_none() {
32223259 return Err(unsupported(
32233260 "a coded HORZ/VERT strip whose chroma transform has no rect coefficient tables here",
32243261 ));
32253262 }
32263263 RECT_SPLIT_TX_HITS.with(|c| c.set(c.get() + 1));
3264+ if bw.max(bh) == 64 && bw / tx > 1 && bh / tx > 1 {
3265+ RECT_SPLIT_SB_INTERIOR_TU_HITS.with(|c| c.set(c.get() + 1));
3266+ }
32273267 // LUMA: `bw/tx` x `bh/tx` square transform units, raster order.
32283268 let luma_set = txbset_for(tx, reduced_tx_set);
32293269 let luma_scan = default_scan(tx);
@@ -3485,6 +3525,13 @@ fn decode_block_rect(
34853525 // [`decode_rect_split`]. `depth_to_tx_size` of a 2:1 strip is square
34863526 // from the first step on, so `bw.min(bh) >> (depth - 1)` names it.
34873527 let tx = bw.min(bh) >> (depth - 1);
3528+ if std::env::var_os("EC_SBPART_DUMP64").is_some() {
3529+ eprintln!(
3530+ "DUMP64SPLIT mi_r={mi_r} mi_c={mi_c} px={px} py={py} bw={bw} bh={bh} \
3531+ depth={depth} tx={tx} mode={mode} uv={uv_predict_mode} skip={skip} \
3532+ angle_y={angle_delta_y}"
3533+ );
3534+ }
34883535 let modes = RectStripModes {
34893536 skip,
34903537 mode,
@@ -4007,22 +4054,34 @@ fn decode_block_rect64(
40074054 };
40084055 if depth != 0 {
40094056 TX_DEPTH_HITS.with(|c| c.set(c.get() + 1));
4010- // lane-rectsplit r1: [`decode_rect_split`] handles this shape too
4011- // (`sub_tx_size_map[TX_64X32]` is `TX_32X32`, so a depth-1 unit here
4012- // is a plain square 32x32) and its 32x32-level sibling arm in
4013- // [`decode_block_rect`] is gated pixel-exact -- but at the SUPERBLOCK
4014- // level the gate
4015- // (`a_real_aomenc_stream_with_a_split_transform_superblock_strip_decodes_pixel_exact`,
4016- // `#[ignore]`d with its measurement) still comes out ONE sample off
4017- // (seed 50, luma (171,56) ours 147 vs ffmpeg 148, inside a 64x32
4018- // strip whose transform resolved to depth 2 / TX_16X16). A refusal
4019- // this lane could not lift is not a refusal it may silently ship
4020- // wrong pixels past, so the named refusal stays until that gate is
4021- // green.
4022- return Err(unsupported(
4023- "a superblock-level HORZ/VERT strip with a split transform (per-unit rect \
4024- prediction is not ported)",
4025- ));
4057+ // lane-rectsplit r2: the superblock-level strip splits its transform
4058+ // through the very same per-unit path as its 32x32-level sibling
4059+ // (`sub_tx_size_map[TX_64X32] == TX_32X32`, square from the first
4060+ // step on, so `bw.min(bh) >> (depth - 1)` names the unit).
4061+ let tx = bw.min(bh) >> (depth - 1);
4062+ if std::env::var_os("EC_SBPART_DUMP64").is_some() {
4063+ eprintln!(
4064+ "DUMP64SPLIT mi_r={mi_r} mi_c={mi_c} px={px} py={py} bw={bw} bh={bh} \
4065+ depth={depth} tx={tx} mode={mode} uv={uv_predict_mode} skip={skip} \
4066+ angle_y={angle_delta_y}"
4067+ );
4068+ }
4069+ let modes = RectStripModes {
4070+ skip,
4071+ mode,
4072+ angle_delta_y,
4073+ uv_predict_mode,
4074+ angle_delta_uv,
4075+ alpha,
4076+ filter_intra,
4077+ smooth_neighbor,
4078+ smooth_neighbor_uv,
4079+ };
4080+ decode_rect_split(
4081+ dec, cdfs, neighbours, at, bw, bh, tx, &modes, y, u, v, base_q_idx, reduced_tx_set,
4082+ )?;
4083+ RECT_PARTITION_HITS.with(|c| c.set(c.get() + 1));
4084+ return Ok(());
40264085 }
40274086 let (tx_w, tx_h) = (bw, bh);
40284087 let (cpx, cpy) = (px / 2, py / 2);
@@ -13717,6 +13776,38 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
1371713776 mod tests {
1371813777 use super::*;
1371913778
13779+ /// lane-rectsplit r2: `av1_nz_map_ctx_offset` is packed COLUMN-major, so
13780+ /// the two rect transcriptions in [`cdf`] must be read `[col][row]`.
13781+ /// [`base_ctx_rect`] states libaom's generating rule
13782+ /// (`txb_common.h:199-209`) in display coordinates; this pins the tables
13783+ /// against it, which is what a transposed read would break.
13784+ #[test]
13785+ fn nz_map_ctx_offset_tables_match_the_rect_rule() {
13786+ for (w, h, table) in [
13787+ (32usize, 64usize, &cdf::NZ_MAP_CTX_OFFSET_32X64),
13788+ (64, 32, &cdf::NZ_MAP_CTX_OFFSET_64X32),
13789+ ] {
13790+ for row in 0..5usize {
13791+ for col in 0..5usize {
13792+ let want = if row == 0 && col == 0 {
13793+ 0
13794+ } else if w < h && row < 2 {
13795+ 11
13796+ } else if w > h && col < 2 {
13797+ 16
13798+ } else {
13799+ cdf::NZ_MAP_CTX_OFFSET_32[row][col]
13800+ };
13801+ assert_eq!(
13802+ table[col][row],
13803+ want,
13804+ "{w}x{h} nz_map offset at display (row {row}, col {col})"
13805+ );
13806+ }
13807+ }
13808+ }
13809+ }
13810+
1372013811 // `crate::tile`'s `flat_key_frame_tile`/`dc_key_frame_tile_levels`/
1372113812 // `split_dc_key_frame_tile` are not exercised here: they are synthetic
1372213813 // single-purpose writers with their own skip-context rule (keyed to
crates/ec-av1/src/refusal_inventory.rsmodified+0 -1
@@ -46,7 +46,6 @@ const REFUSALS: &[&str] = &[
4646 "a Golomb tail longer than this decoder reads",
4747 "a bit depth other than 8 with film grain applied (film_grain.rs's LUT and blend are hardcoded 8-bit)",
4848 "a bit depth other than 8 with use_superres set (superres.rs's upscale_row is hardcoded 8-bit)",
49- "a superblock-level HORZ/VERT strip with a split transform (per-unit rect prediction is not ported)",
5049 "a tx_type symbol outside its CDF's own set: {t}",
5150 "an INTER 32x32 partition type this decoder does not code (value={part32})",
5251 "a superblock-level partition type other than NONE or SPLIT (this decoder's intra tile path codes only those two at 64x64)",
crates/ec-av1/src/stream.rsmodified+107 -28
@@ -9363,6 +9363,13 @@ mod tests {
93639363 let before = crate::decode::rect_split_tx_hits();
93649364 let mut named_refusals = 0u32;
93659365 let mut matched = 0u32;
9366+ // lane-rectsplit r2 (verifier finding): the feature counter is
9367+ // sampled PER ATTEMPT and folded in only after that attempt was
9368+ // decoded AND pixel-compared. One delta across the whole sweep
9369+ // counted strips decoded by attempts that went on to hit a named
9370+ // refusal, so the gate could pass with every COMPARED stream
9371+ // containing none of the feature at all.
9372+ let mut compared_hits = 0usize;
93669373 let mut split_so_far = 0usize;
93679374 // Bounded sweep: see this gate's own doc for the seed-77 residue and
93689375 // why extending it is a diagnosis knob, not a pass/fail one.
@@ -9448,6 +9455,7 @@ mod tests {
94489455 );
94499456 let stream = out.stdout;
94509457 assert!(!stream.is_empty(), "{NAME}: aomenc wrote an empty stream (seed {seed})");
9458+ let attempt_before = crate::decode::rect_split_tx_hits();
94519459 let frames = match decode_stream(&stream) {
94529460 Err(e) => {
94539461 let msg = e.to_string();
@@ -9474,20 +9482,36 @@ mod tests {
94749482 .zip(&ffmpeg_frames[0].y)
94759483 .position(|(a, b)| a != b)
94769484 {
9485+ let diffs: Vec<usize> = frames[0]
9486+ .y
9487+ .iter()
9488+ .zip(&ffmpeg_frames[0].y)
9489+ .enumerate()
9490+ .filter(|(_, (a, b))| a != b)
9491+ .map(|(j, _)| j)
9492+ .collect();
9493+ let (x0, x1) = (
9494+ diffs.iter().map(|j| j % width).min().unwrap(),
9495+ diffs.iter().map(|j| j % width).max().unwrap(),
9496+ );
9497+ let (y0, y1) = (diffs[0] / width, diffs[diffs.len() - 1] / width);
94779498 eprintln!(
9478- "{NAME}: seed {seed} first luma mismatch at ({}, {}) ours={} ffmpeg={}",
9499+ "{NAME}: seed {seed} first luma mismatch at ({}, {}) ours={} ffmpeg={} \
9500+ -- {} mismatching samples, bbox x {x0}..={x1} y {y0}..={y1}",
94799501 i % width,
94809502 i / width,
94819503 frames[0].y[i],
9482- ffmpeg_frames[0].y[i]
9504+ ffmpeg_frames[0].y[i],
9505+ diffs.len(),
94839506 );
94849507 }
94859508 assert_eq!(frames[0].y, ffmpeg_frames[0].y, "{NAME}: luma vs ffmpeg (seed {seed})");
94869509 assert_eq!(frames[0].u, ffmpeg_frames[0].u, "{NAME}: U vs ffmpeg (seed {seed})");
94879510 assert_eq!(frames[0].v, ffmpeg_frames[0].v, "{NAME}: V vs ffmpeg (seed {seed})");
9511+ compared_hits += crate::decode::rect_split_tx_hits() - attempt_before;
94889512 matched += 1;
94899513 }
9490- let split_hits = crate::decode::rect_split_tx_hits() - before;
9514+ let split_hits = compared_hits;
94919515 assert!(
94929516 matched > 0,
94939517 "{NAME}: every attempt refused ({named_refusals} named refusals) -- gate decoded nothing"
@@ -9527,11 +9551,17 @@ mod tests {
95279551 return;
95289552 }
95299553 let (width, height) = (192usize, 128usize);
9530- let before = crate::decode::filter_intra_rect_hits();
95319554 let rect_before = crate::decode::rect_partition_hits();
95329555 let fi_square_before = crate::decode::filter_intra_hits();
95339556 let mut named_refusals = 0u32;
95349557 let mut matched = 0u32;
9558+ // lane-rectsplit r2 (verifier finding): the feature counter is
9559+ // sampled PER ATTEMPT and folded in only after that attempt was
9560+ // decoded AND pixel-compared. One delta across the whole sweep
9561+ // counted strips decoded by attempts that went on to hit a named
9562+ // refusal, so the gate could pass with every COMPARED stream
9563+ // containing none of the feature at all.
9564+ let mut compared_hits = 0usize;
95359565 let n_attempts: u32 = std::env::var("EC_RECTSPLIT_GATE_ATTEMPTS")
95369566 .ok()
95379567 .and_then(|s| s.parse().ok())
@@ -9596,13 +9626,15 @@ mod tests {
95969626 "--deltaq-mode=0",
95979627 // The point of this gate.
95989628 "--enable-filter-intra=1",
9599- // The square filter-intra gate's own way of making RD reach
9600- // for filter intra at all: with the directional/smooth/paeth
9601- // competitors off, DC_PRED + filter intra is what is left
9602- // (recipe borrowed from
9603- // `a_real_aomenc_filter_intra_stream_decodes_pixel_exact`;
9604- // without them 20/20 streams picked filter intra zero times
9605- // on a strip -- measured this round).
9629+ // NOTE (lane-rectsplit r2, verifier finding): every intra
9630+ // mode stays ON here. The square filter-intra gate reaches
9631+ // for filter intra by switching the directional/smooth/paeth
9632+ // competitors off, and this gate CANNOT: with them off
9633+ // aomenc stops picking rect partitions at all (rect
9634+ // strips 0/20 seeds, r1's table). What fires filter intra on
9635+ // a strip here is the quantiser (`--cq-level=25`), not the
9636+ // mode set -- `EC_RECTSPLIT_OFF` below is the diagnosis knob
9637+ // that re-runs the subset search.
96069638 "--enable-cfl-intra=0",
96079639 "--enable-intrabc=0",
96089640 "--obu",
@@ -9648,6 +9680,7 @@ mod tests {
96489680 );
96499681 let stream = out.stdout;
96509682 assert!(!stream.is_empty(), "{NAME}: aomenc wrote an empty stream (seed {seed})");
9683+ let attempt_before = crate::decode::filter_intra_rect_hits();
96519684 let frames = match decode_stream(&stream) {
96529685 Err(e) => {
96539686 let msg = e.to_string();
@@ -9668,20 +9701,36 @@ mod tests {
96689701 .zip(&ffmpeg_frames[0].y)
96699702 .position(|(a, b)| a != b)
96709703 {
9704+ let diffs: Vec<usize> = frames[0]
9705+ .y
9706+ .iter()
9707+ .zip(&ffmpeg_frames[0].y)
9708+ .enumerate()
9709+ .filter(|(_, (a, b))| a != b)
9710+ .map(|(j, _)| j)
9711+ .collect();
9712+ let (x0, x1) = (
9713+ diffs.iter().map(|j| j % width).min().unwrap(),
9714+ diffs.iter().map(|j| j % width).max().unwrap(),
9715+ );
9716+ let (y0, y1) = (diffs[0] / width, diffs[diffs.len() - 1] / width);
96719717 eprintln!(
9672- "{NAME}: seed {seed} first luma mismatch at ({}, {}) ours={} ffmpeg={}",
9718+ "{NAME}: seed {seed} first luma mismatch at ({}, {}) ours={} ffmpeg={} \
9719+ -- {} mismatching samples, bbox x {x0}..={x1} y {y0}..={y1}",
96739720 i % width,
96749721 i / width,
96759722 frames[0].y[i],
9676- ffmpeg_frames[0].y[i]
9723+ ffmpeg_frames[0].y[i],
9724+ diffs.len(),
96779725 );
96789726 }
96799727 assert_eq!(frames[0].y, ffmpeg_frames[0].y, "{NAME}: luma vs ffmpeg (seed {seed})");
96809728 assert_eq!(frames[0].u, ffmpeg_frames[0].u, "{NAME}: U vs ffmpeg (seed {seed})");
96819729 assert_eq!(frames[0].v, ffmpeg_frames[0].v, "{NAME}: V vs ffmpeg (seed {seed})");
9730+ compared_hits += crate::decode::filter_intra_rect_hits() - attempt_before;
96829731 matched += 1;
96839732 }
9684- let fi_hits = crate::decode::filter_intra_rect_hits() - before;
9733+ let fi_hits = compared_hits;
96859734 eprintln!(
96869735 "{NAME}: rect strips this run={}, filter-intra blocks (any shape)={}",
96879736 crate::decode::rect_partition_hits() - rect_before,
@@ -9708,17 +9757,23 @@ mod tests {
97089757 /// `--enable-tx-size-search=0` DROPPED: the 64x32/32x64 strips may then
97099758 /// carry a split transform, which [`crate::decode::decode_block_rect64`]
97109759 /// refused by name ("a superblock-level HORZ/VERT strip with a split
9711- /// transform") until this round. Same hard `rect_split_tx_hits()` delta
9712- /// assert as gate (a).
9713- /// lane-rectsplit r1 MEASURED RED, `#[ignore]`d with its number (the
9714- /// `rect64q` gate's own precedent): with the per-transform-unit port
9715- /// wired at the superblock level, seed 50 decodes one sample off --
9716- /// luma (171, 56), ours 147 vs ffmpeg 148, inside the 64x32 strip at
9717- /// mi=(8,32) whose transform resolved to depth 2 (TX_16X16). Seeds 42-49
9718- /// with depth-1 (TX_32X32) units were pixel-exact. The refusal in
9719- /// `decode_block_rect64` was therefore RESTORED rather than lifted; run
9720- /// this gate (`--ignored`) after any fix to that arm.
9721- #[ignore = "lane-rectsplit r1: measured RED, seed 50 luma (171,56) off by one; refusal kept"]
9760+ /// transform") until lane-rectsplit r2 lifted it.
9761+ ///
9762+ /// The hard assert is on [`crate::decode::rect_split_sb_interior_tu_hits`],
9763+ /// NOT the shared `rect_split_tx_hits()` gate (a) uses: that counter also
9764+ /// counts 32x32-level and depth-1 strips, whose units are all in the
9765+ /// first transform-unit row/column. Only a superblock-level strip split
9766+ /// past depth 1 has an INTERIOR unit (`row_off > 0 && col_off > 0`),
9767+ /// which is the per-unit availability rule this port exists for, and no
9768+ /// gate fired one before this round.
9769+ ///
9770+ /// This gate was `#[ignore]`d RED through r1 (seed 50 luma (171,56)).
9771+ /// Root cause, r2: not availability at all -- `av1_nz_map_ctx_offset` is
9772+ /// packed COLUMN-major, so [`crate::decode::base_ctx`] read the
9773+ /// `TX_32X64`/`TX_64X32` offset tables transposed and desynced the first
9774+ /// SB-level strip whose luma corner held a coefficient below row 1 (see
9775+ /// that function's comment). The strip's own per-unit prediction was
9776+ /// already exact.
97229777 #[test]
97239778 fn a_real_aomenc_stream_with_a_split_transform_superblock_strip_decodes_pixel_exact() {
97249779 const NAME: &str = "a_real_aomenc_stream_with_a_split_transform_superblock_strip_decodes_pixel_exact";
@@ -9735,6 +9790,13 @@ mod tests {
97359790 let before = crate::decode::rect_split_tx_hits();
97369791 let mut named_refusals = 0u32;
97379792 let mut matched = 0u32;
9793+ // lane-rectsplit r2 (verifier finding): the feature counter is
9794+ // sampled PER ATTEMPT and folded in only after that attempt was
9795+ // decoded AND pixel-compared. One delta across the whole sweep
9796+ // counted strips decoded by attempts that went on to hit a named
9797+ // refusal, so the gate could pass with every COMPARED stream
9798+ // containing none of the feature at all.
9799+ let mut compared_hits = 0usize;
97389800 let mut split_so_far = 0usize;
97399801 // Bounded sweep: see this gate's own doc for the seed-77 residue and
97409802 // why extending it is a diagnosis knob, not a pass/fail one.
@@ -9820,6 +9882,7 @@ mod tests {
98209882 );
98219883 let stream = out.stdout;
98229884 assert!(!stream.is_empty(), "{NAME}: aomenc wrote an empty stream (seed {seed})");
9885+ let attempt_before = crate::decode::rect_split_sb_interior_tu_hits();
98239886 let frames = match decode_stream(&stream) {
98249887 Err(e) => {
98259888 let msg = e.to_string();
@@ -9846,20 +9909,36 @@ mod tests {
98469909 .zip(&ffmpeg_frames[0].y)
98479910 .position(|(a, b)| a != b)
98489911 {
9912+ let diffs: Vec<usize> = frames[0]
9913+ .y
9914+ .iter()
9915+ .zip(&ffmpeg_frames[0].y)
9916+ .enumerate()
9917+ .filter(|(_, (a, b))| a != b)
9918+ .map(|(j, _)| j)
9919+ .collect();
9920+ let (x0, x1) = (
9921+ diffs.iter().map(|j| j % width).min().unwrap(),
9922+ diffs.iter().map(|j| j % width).max().unwrap(),
9923+ );
9924+ let (y0, y1) = (diffs[0] / width, diffs[diffs.len() - 1] / width);
98499925 eprintln!(
9850- "{NAME}: seed {seed} first luma mismatch at ({}, {}) ours={} ffmpeg={}",
9926+ "{NAME}: seed {seed} first luma mismatch at ({}, {}) ours={} ffmpeg={} \
9927+ -- {} mismatching samples, bbox x {x0}..={x1} y {y0}..={y1}",
98519928 i % width,
98529929 i / width,
98539930 frames[0].y[i],
9854- ffmpeg_frames[0].y[i]
9931+ ffmpeg_frames[0].y[i],
9932+ diffs.len(),
98559933 );
98569934 }
98579935 assert_eq!(frames[0].y, ffmpeg_frames[0].y, "{NAME}: luma vs ffmpeg (seed {seed})");
98589936 assert_eq!(frames[0].u, ffmpeg_frames[0].u, "{NAME}: U vs ffmpeg (seed {seed})");
98599937 assert_eq!(frames[0].v, ffmpeg_frames[0].v, "{NAME}: V vs ffmpeg (seed {seed})");
9938+ compared_hits += crate::decode::rect_split_sb_interior_tu_hits() - attempt_before;
98609939 matched += 1;
98619940 }
9862- let split_hits = crate::decode::rect_split_tx_hits() - before;
9941+ let split_hits = compared_hits;
98639942 assert!(
98649943 matched > 0,
98659944 "{NAME}: every attempt refused ({named_refusals} named refusals) -- gate decoded nothing"