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() {
32 Ok(frames) if frames.is_empty() => {32 Ok(frames) if frames.is_empty() => {
33 println!("OK but EMPTY: no frames -- is {path} an IVF rather than a raw OBU stream?");33 println!("OK but EMPTY: no frames -- is {path} an IVF rather than a raw OBU stream?");
34 }34 }
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+ }
36 Err(e) => println!("REFUSED: {e}"),52 Err(e) => println!("REFUSED: {e}"),
37 }53 }
38 }54 }
crates/ec-av1/src/decode.rsmodified+108 -17
@@ -442,6 +442,22 @@ pub(crate) fn rect_split_tx_hits() -> usize {
442 RECT_SPLIT_TX_HITS.with(|c| c.get())442 RECT_SPLIT_TX_HITS.with(|c| c.get())
443 }443 }
444 444
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+
445 // How many HORZ/VERT intra strips actually predicted with filter intra461 // How many HORZ/VERT intra strips actually predicted with filter intra
446 // (lane-rectsplit r1) -- the case `decode_block_rect` refused by name462 // (lane-rectsplit r1) -- the case `decode_block_rect` refused by name
447 // ("this decoder predicts square-only") until `predict_filter_intra` took463 // ("this decoder predicts square-only") until `predict_filter_intra` took
@@ -1143,12 +1159,26 @@ fn base_ctx(
1143 // (lane-sbpart r8 root cause: `(row=1, col=0)` reads ctx 2 under the1159 // (lane-sbpart r8 root cause: `(row=1, col=0)` reads ctx 2 under the
1144 // square table vs the real ctx 13 the rect table gives).1160 // square table vs the real ctx 13 the rect table gives).
1145 TxClass::TwoD => {1161 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.
1146 let table = match rect_shape {1176 let table = match rect_shape {
1147 Some((w, h)) if w < h => &cdf::NZ_MAP_CTX_OFFSET_32X64,1177 Some((w, h)) if w < h => &cdf::NZ_MAP_CTX_OFFSET_32X64,
1148 Some((w, h)) if w > h => &cdf::NZ_MAP_CTX_OFFSET_64X32,1178 Some((w, h)) if w > h => &cdf::NZ_MAP_CTX_OFFSET_64X32,
1149 _ => &cdf::NZ_MAP_CTX_OFFSET_32,1179 _ => &cdf::NZ_MAP_CTX_OFFSET_32,
1150 };1180 };
1151- ctx + table[row.min(4)][col.min(4)] as usize1181+ ctx + table[col.min(4)][row.min(4)] as usize
1152 }1182 }
1153 TxClass::Horiz => ctx + nz_map_ctx_offset_1d(col.min(31)),1183 TxClass::Horiz => ctx + nz_map_ctx_offset_1d(col.min(31)),
1154 TxClass::Vert => ctx + nz_map_ctx_offset_1d(row.min(31)),1184 TxClass::Vert => ctx + nz_map_ctx_offset_1d(row.min(31)),
@@ -3218,12 +3248,22 @@ fn decode_rect_split(
3218 (16, 32) => Some((TxbSet::ChromaRect32x16, &SCAN_16X32[..])),3248 (16, 32) => Some((TxbSet::ChromaRect32x16, &SCAN_16X32[..])),
3219 _ => None,3249 _ => None,
3220 };3250 };
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`.
3221 if !m.skip && chroma.is_none() {3258 if !m.skip && chroma.is_none() {
3222 return Err(unsupported(3259 return Err(unsupported(
3223 "a coded HORZ/VERT strip whose chroma transform has no rect coefficient tables here",3260 "a coded HORZ/VERT strip whose chroma transform has no rect coefficient tables here",
3224 ));3261 ));
3225 }3262 }
3226 RECT_SPLIT_TX_HITS.with(|c| c.set(c.get() + 1));3263 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+ }
3227 // LUMA: `bw/tx` x `bh/tx` square transform units, raster order.3267 // LUMA: `bw/tx` x `bh/tx` square transform units, raster order.
3228 let luma_set = txbset_for(tx, reduced_tx_set);3268 let luma_set = txbset_for(tx, reduced_tx_set);
3229 let luma_scan = default_scan(tx);3269 let luma_scan = default_scan(tx);
@@ -3485,6 +3525,13 @@ fn decode_block_rect(
3485 // [`decode_rect_split`]. `depth_to_tx_size` of a 2:1 strip is square3525 // [`decode_rect_split`]. `depth_to_tx_size` of a 2:1 strip is square
3486 // from the first step on, so `bw.min(bh) >> (depth - 1)` names it.3526 // from the first step on, so `bw.min(bh) >> (depth - 1)` names it.
3487 let tx = bw.min(bh) >> (depth - 1);3527 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+ }
3488 let modes = RectStripModes {3535 let modes = RectStripModes {
3489 skip,3536 skip,
3490 mode,3537 mode,
@@ -4007,22 +4054,34 @@ fn decode_block_rect64(
4007 };4054 };
4008 if depth != 0 {4055 if depth != 0 {
4009 TX_DEPTH_HITS.with(|c| c.set(c.get() + 1));4056 TX_DEPTH_HITS.with(|c| c.set(c.get() + 1));
4010- // lane-rectsplit r1: [`decode_rect_split`] handles this shape too4057+ // lane-rectsplit r2: the superblock-level strip splits its transform
4011- // (`sub_tx_size_map[TX_64X32]` is `TX_32X32`, so a depth-1 unit here4058+ // through the very same per-unit path as its 32x32-level sibling
4012- // is a plain square 32x32) and its 32x32-level sibling arm in4059+ // (`sub_tx_size_map[TX_64X32] == TX_32X32`, square from the first
4013- // [`decode_block_rect`] is gated pixel-exact -- but at the SUPERBLOCK4060+ // step on, so `bw.min(bh) >> (depth - 1)` names the unit).
4014- // level the gate4061+ let tx = bw.min(bh) >> (depth - 1);
4015- // (`a_real_aomenc_stream_with_a_split_transform_superblock_strip_decodes_pixel_exact`,4062+ if std::env::var_os("EC_SBPART_DUMP64").is_some() {
4016- // `#[ignore]`d with its measurement) still comes out ONE sample off4063+ eprintln!(
4017- // (seed 50, luma (171,56) ours 147 vs ffmpeg 148, inside a 64x324064+ "DUMP64SPLIT mi_r={mi_r} mi_c={mi_c} px={px} py={py} bw={bw} bh={bh} \
4018- // strip whose transform resolved to depth 2 / TX_16X16). A refusal4065+ depth={depth} tx={tx} mode={mode} uv={uv_predict_mode} skip={skip} \
4019- // this lane could not lift is not a refusal it may silently ship4066+ angle_y={angle_delta_y}"
4020- // wrong pixels past, so the named refusal stays until that gate is4067+ );
4021- // green.4068+ }
4022- return Err(unsupported(4069+ let modes = RectStripModes {
4023- "a superblock-level HORZ/VERT strip with a split transform (per-unit rect \4070+ skip,
4024- prediction is not ported)",4071+ mode,
4025- ));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(());
4026 }4085 }
4027 let (tx_w, tx_h) = (bw, bh);4086 let (tx_w, tx_h) = (bw, bh);
4028 let (cpx, cpy) = (px / 2, py / 2);4087 let (cpx, cpy) = (px / 2, py / 2);
@@ -13717,6 +13776,38 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
13717 mod tests {13776 mod tests {
13718 use super::*;13777 use super::*;
13719 13778
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+
13720 // `crate::tile`'s `flat_key_frame_tile`/`dc_key_frame_tile_levels`/13811 // `crate::tile`'s `flat_key_frame_tile`/`dc_key_frame_tile_levels`/
13721 // `split_dc_key_frame_tile` are not exercised here: they are synthetic13812 // `split_dc_key_frame_tile` are not exercised here: they are synthetic
13722 // single-purpose writers with their own skip-context rule (keyed to13813 // 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] = &[
46 "a Golomb tail longer than this decoder reads",46 "a Golomb tail longer than this decoder reads",
47 "a bit depth other than 8 with film grain applied (film_grain.rs's LUT and blend are hardcoded 8-bit)",47 "a bit depth other than 8 with film grain applied (film_grain.rs's LUT and blend are hardcoded 8-bit)",
48 "a bit depth other than 8 with use_superres set (superres.rs's upscale_row is hardcoded 8-bit)",48 "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)",
50 "a tx_type symbol outside its CDF's own set: {t}",49 "a tx_type symbol outside its CDF's own set: {t}",
51 "an INTER 32x32 partition type this decoder does not code (value={part32})",50 "an INTER 32x32 partition type this decoder does not code (value={part32})",
52 "a superblock-level partition type other than NONE or SPLIT (this decoder's intra tile path codes only those two at 64x64)",51 "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 {
9363 let before = crate::decode::rect_split_tx_hits();9363 let before = crate::decode::rect_split_tx_hits();
9364 let mut named_refusals = 0u32;9364 let mut named_refusals = 0u32;
9365 let mut matched = 0u32;9365 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;
9366 let mut split_so_far = 0usize;9373 let mut split_so_far = 0usize;
9367 // Bounded sweep: see this gate's own doc for the seed-77 residue and9374 // Bounded sweep: see this gate's own doc for the seed-77 residue and
9368 // why extending it is a diagnosis knob, not a pass/fail one.9375 // why extending it is a diagnosis knob, not a pass/fail one.
@@ -9448,6 +9455,7 @@ mod tests {
9448 );9455 );
9449 let stream = out.stdout;9456 let stream = out.stdout;
9450 assert!(!stream.is_empty(), "{NAME}: aomenc wrote an empty stream (seed {seed})");9457 assert!(!stream.is_empty(), "{NAME}: aomenc wrote an empty stream (seed {seed})");
9458+ let attempt_before = crate::decode::rect_split_tx_hits();
9451 let frames = match decode_stream(&stream) {9459 let frames = match decode_stream(&stream) {
9452 Err(e) => {9460 Err(e) => {
9453 let msg = e.to_string();9461 let msg = e.to_string();
@@ -9474,20 +9482,36 @@ mod tests {
9474 .zip(&ffmpeg_frames[0].y)9482 .zip(&ffmpeg_frames[0].y)
9475 .position(|(a, b)| a != b)9483 .position(|(a, b)| a != b)
9476 {9484 {
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);
9477 eprintln!(9498 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}",
9479 i % width,9501 i % width,
9480 i / width,9502 i / width,
9481 frames[0].y[i],9503 frames[0].y[i],
9482- ffmpeg_frames[0].y[i]9504+ ffmpeg_frames[0].y[i],
9505+ diffs.len(),
9483 );9506 );
9484 }9507 }
9485 assert_eq!(frames[0].y, ffmpeg_frames[0].y, "{NAME}: luma vs ffmpeg (seed {seed})");9508 assert_eq!(frames[0].y, ffmpeg_frames[0].y, "{NAME}: luma vs ffmpeg (seed {seed})");
9486 assert_eq!(frames[0].u, ffmpeg_frames[0].u, "{NAME}: U vs ffmpeg (seed {seed})");9509 assert_eq!(frames[0].u, ffmpeg_frames[0].u, "{NAME}: U vs ffmpeg (seed {seed})");
9487 assert_eq!(frames[0].v, ffmpeg_frames[0].v, "{NAME}: V vs ffmpeg (seed {seed})");9510 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;
9488 matched += 1;9512 matched += 1;
9489 }9513 }
9490- let split_hits = crate::decode::rect_split_tx_hits() - before;9514+ let split_hits = compared_hits;
9491 assert!(9515 assert!(
9492 matched > 0,9516 matched > 0,
9493 "{NAME}: every attempt refused ({named_refusals} named refusals) -- gate decoded nothing"9517 "{NAME}: every attempt refused ({named_refusals} named refusals) -- gate decoded nothing"
@@ -9527,11 +9551,17 @@ mod tests {
9527 return;9551 return;
9528 }9552 }
9529 let (width, height) = (192usize, 128usize);9553 let (width, height) = (192usize, 128usize);
9530- let before = crate::decode::filter_intra_rect_hits();
9531 let rect_before = crate::decode::rect_partition_hits();9554 let rect_before = crate::decode::rect_partition_hits();
9532 let fi_square_before = crate::decode::filter_intra_hits();9555 let fi_square_before = crate::decode::filter_intra_hits();
9533 let mut named_refusals = 0u32;9556 let mut named_refusals = 0u32;
9534 let mut matched = 0u32;9557 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;
9535 let n_attempts: u32 = std::env::var("EC_RECTSPLIT_GATE_ATTEMPTS")9565 let n_attempts: u32 = std::env::var("EC_RECTSPLIT_GATE_ATTEMPTS")
9536 .ok()9566 .ok()
9537 .and_then(|s| s.parse().ok())9567 .and_then(|s| s.parse().ok())
@@ -9596,13 +9626,15 @@ mod tests {
9596 "--deltaq-mode=0",9626 "--deltaq-mode=0",
9597 // The point of this gate.9627 // The point of this gate.
9598 "--enable-filter-intra=1",9628 "--enable-filter-intra=1",
9599- // The square filter-intra gate's own way of making RD reach9629+ // NOTE (lane-rectsplit r2, verifier finding): every intra
9600- // for filter intra at all: with the directional/smooth/paeth9630+ // mode stays ON here. The square filter-intra gate reaches
9601- // competitors off, DC_PRED + filter intra is what is left9631+ // for filter intra by switching the directional/smooth/paeth
9602- // (recipe borrowed from9632+ // competitors off, and this gate CANNOT: with them off
9603- // `a_real_aomenc_filter_intra_stream_decodes_pixel_exact`;9633+ // aomenc stops picking rect partitions at all (rect
9604- // without them 20/20 streams picked filter intra zero times9634+ // strips 0/20 seeds, r1's table). What fires filter intra on
9605- // on a strip -- measured this round).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.
9606 "--enable-cfl-intra=0",9638 "--enable-cfl-intra=0",
9607 "--enable-intrabc=0",9639 "--enable-intrabc=0",
9608 "--obu",9640 "--obu",
@@ -9648,6 +9680,7 @@ mod tests {
9648 );9680 );
9649 let stream = out.stdout;9681 let stream = out.stdout;
9650 assert!(!stream.is_empty(), "{NAME}: aomenc wrote an empty stream (seed {seed})");9682 assert!(!stream.is_empty(), "{NAME}: aomenc wrote an empty stream (seed {seed})");
9683+ let attempt_before = crate::decode::filter_intra_rect_hits();
9651 let frames = match decode_stream(&stream) {9684 let frames = match decode_stream(&stream) {
9652 Err(e) => {9685 Err(e) => {
9653 let msg = e.to_string();9686 let msg = e.to_string();
@@ -9668,20 +9701,36 @@ mod tests {
9668 .zip(&ffmpeg_frames[0].y)9701 .zip(&ffmpeg_frames[0].y)
9669 .position(|(a, b)| a != b)9702 .position(|(a, b)| a != b)
9670 {9703 {
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);
9671 eprintln!(9717 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}",
9673 i % width,9720 i % width,
9674 i / width,9721 i / width,
9675 frames[0].y[i],9722 frames[0].y[i],
9676- ffmpeg_frames[0].y[i]9723+ ffmpeg_frames[0].y[i],
9724+ diffs.len(),
9677 );9725 );
9678 }9726 }
9679 assert_eq!(frames[0].y, ffmpeg_frames[0].y, "{NAME}: luma vs ffmpeg (seed {seed})");9727 assert_eq!(frames[0].y, ffmpeg_frames[0].y, "{NAME}: luma vs ffmpeg (seed {seed})");
9680 assert_eq!(frames[0].u, ffmpeg_frames[0].u, "{NAME}: U vs ffmpeg (seed {seed})");9728 assert_eq!(frames[0].u, ffmpeg_frames[0].u, "{NAME}: U vs ffmpeg (seed {seed})");
9681 assert_eq!(frames[0].v, ffmpeg_frames[0].v, "{NAME}: V vs ffmpeg (seed {seed})");9729 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;
9682 matched += 1;9731 matched += 1;
9683 }9732 }
9684- let fi_hits = crate::decode::filter_intra_rect_hits() - before;9733+ let fi_hits = compared_hits;
9685 eprintln!(9734 eprintln!(
9686 "{NAME}: rect strips this run={}, filter-intra blocks (any shape)={}",9735 "{NAME}: rect strips this run={}, filter-intra blocks (any shape)={}",
9687 crate::decode::rect_partition_hits() - rect_before,9736 crate::decode::rect_partition_hits() - rect_before,
@@ -9708,17 +9757,23 @@ mod tests {
9708 /// `--enable-tx-size-search=0` DROPPED: the 64x32/32x64 strips may then9757 /// `--enable-tx-size-search=0` DROPPED: the 64x32/32x64 strips may then
9709 /// carry a split transform, which [`crate::decode::decode_block_rect64`]9758 /// carry a split transform, which [`crate::decode::decode_block_rect64`]
9710 /// refused by name ("a superblock-level HORZ/VERT strip with a split9759 /// refused by name ("a superblock-level HORZ/VERT strip with a split
9711- /// transform") until this round. Same hard `rect_split_tx_hits()` delta9760+ /// transform") until lane-rectsplit r2 lifted it.
9712- /// assert as gate (a).9761+ ///
9713- /// lane-rectsplit r1 MEASURED RED, `#[ignore]`d with its number (the9762+ /// The hard assert is on [`crate::decode::rect_split_sb_interior_tu_hits`],
9714- /// `rect64q` gate's own precedent): with the per-transform-unit port9763+ /// NOT the shared `rect_split_tx_hits()` gate (a) uses: that counter also
9715- /// wired at the superblock level, seed 50 decodes one sample off --9764+ /// counts 32x32-level and depth-1 strips, whose units are all in the
9716- /// luma (171, 56), ours 147 vs ffmpeg 148, inside the 64x32 strip at9765+ /// first transform-unit row/column. Only a superblock-level strip split
9717- /// mi=(8,32) whose transform resolved to depth 2 (TX_16X16). Seeds 42-499766+ /// past depth 1 has an INTERIOR unit (`row_off > 0 && col_off > 0`),
9718- /// with depth-1 (TX_32X32) units were pixel-exact. The refusal in9767+ /// which is the per-unit availability rule this port exists for, and no
9719- /// `decode_block_rect64` was therefore RESTORED rather than lifted; run9768+ /// gate fired one before this round.
9720- /// this gate (`--ignored`) after any fix to that arm.9769+ ///
9721- #[ignore = "lane-rectsplit r1: measured RED, seed 50 luma (171,56) off by one; refusal kept"]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.
9722 #[test]9777 #[test]
9723 fn a_real_aomenc_stream_with_a_split_transform_superblock_strip_decodes_pixel_exact() {9778 fn a_real_aomenc_stream_with_a_split_transform_superblock_strip_decodes_pixel_exact() {
9724 const NAME: &str = "a_real_aomenc_stream_with_a_split_transform_superblock_strip_decodes_pixel_exact";9779 const NAME: &str = "a_real_aomenc_stream_with_a_split_transform_superblock_strip_decodes_pixel_exact";
@@ -9735,6 +9790,13 @@ mod tests {
9735 let before = crate::decode::rect_split_tx_hits();9790 let before = crate::decode::rect_split_tx_hits();
9736 let mut named_refusals = 0u32;9791 let mut named_refusals = 0u32;
9737 let mut matched = 0u32;9792 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;
9738 let mut split_so_far = 0usize;9800 let mut split_so_far = 0usize;
9739 // Bounded sweep: see this gate's own doc for the seed-77 residue and9801 // Bounded sweep: see this gate's own doc for the seed-77 residue and
9740 // why extending it is a diagnosis knob, not a pass/fail one.9802 // why extending it is a diagnosis knob, not a pass/fail one.
@@ -9820,6 +9882,7 @@ mod tests {
9820 );9882 );
9821 let stream = out.stdout;9883 let stream = out.stdout;
9822 assert!(!stream.is_empty(), "{NAME}: aomenc wrote an empty stream (seed {seed})");9884 assert!(!stream.is_empty(), "{NAME}: aomenc wrote an empty stream (seed {seed})");
9885+ let attempt_before = crate::decode::rect_split_sb_interior_tu_hits();
9823 let frames = match decode_stream(&stream) {9886 let frames = match decode_stream(&stream) {
9824 Err(e) => {9887 Err(e) => {
9825 let msg = e.to_string();9888 let msg = e.to_string();
@@ -9846,20 +9909,36 @@ mod tests {
9846 .zip(&ffmpeg_frames[0].y)9909 .zip(&ffmpeg_frames[0].y)
9847 .position(|(a, b)| a != b)9910 .position(|(a, b)| a != b)
9848 {9911 {
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);
9849 eprintln!(9925 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}",
9851 i % width,9928 i % width,
9852 i / width,9929 i / width,
9853 frames[0].y[i],9930 frames[0].y[i],
9854- ffmpeg_frames[0].y[i]9931+ ffmpeg_frames[0].y[i],
9932+ diffs.len(),
9855 );9933 );
9856 }9934 }
9857 assert_eq!(frames[0].y, ffmpeg_frames[0].y, "{NAME}: luma vs ffmpeg (seed {seed})");9935 assert_eq!(frames[0].y, ffmpeg_frames[0].y, "{NAME}: luma vs ffmpeg (seed {seed})");
9858 assert_eq!(frames[0].u, ffmpeg_frames[0].u, "{NAME}: U vs ffmpeg (seed {seed})");9936 assert_eq!(frames[0].u, ffmpeg_frames[0].u, "{NAME}: U vs ffmpeg (seed {seed})");
9859 assert_eq!(frames[0].v, ffmpeg_frames[0].v, "{NAME}: V vs ffmpeg (seed {seed})");9937 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;
9860 matched += 1;9939 matched += 1;
9861 }9940 }
9862- let split_hits = crate::decode::rect_split_tx_hits() - before;9941+ let split_hits = compared_hits;
9863 assert!(9942 assert!(
9864 matched > 0,9943 matched > 0,
9865 "{NAME}: every attempt refused ({named_refusals} named refusals) -- gate decoded nothing"9944 "{NAME}: every attempt refused ({named_refusals} named refusals) -- gate decoded nothing"