forge
Explore
Log in

Don't you dare go Hollow

Merge branch 'lane-sbab' (1847e97): superblock-level inter AB partitions

Browse files at this commit

959902b16883f946ad2e546c4e7ba544b7c0d609Ahmet Kaan GümüşParent: ef5fdd5199b50b
Lifts the 64-level inter AB refusal (HORZ_A/HORZ_B/VERT_A/VERT_B: two 32x32
inter squares plus one true 64x32/32x64 strip) and writes the var-tx side
bands from write_w/write_h. Conflicts resolved keeping main's newer refusal
list minus the SB-level AB entry this lane lifts, and both probe counters.

Gates: inter_ab64 / sb_level_ab / superblock_level_rect_partition /
refusal_inventory / gate_coverage / base_ctx_rect_offsets -- 16 passed.

Known vacuity (accepted, as chartered):
real_aomenc_1to4_streams_decode_pixel_exact_and_rect_vartx_leaves_fire_before_a_named_refusal
now reds on its FIRING assert only -- 0 refusals, 0 mismatches, 0 rectangular
var-tx leaves reached; the lane's earlier neighbour-band fix makes attempts
refuse earlier. Pending lane-inter16ab r7.
crates/ec-av1/examples/decode_probe.rsmodified+6 -0
@@ -72,6 +72,12 @@ fn main() {
72 "sb128_rect: edge_horz={} edge_vert={} inter_128x64={} inter_64x128={}",72 "sb128_rect: edge_horz={} edge_vert={} inter_128x64={} inter_64x128={}",
73 sb.0, sb.1, sb.2, sb.373 sb.0, sb.1, sb.2, sb.3
74 );74 );
75+ // lane-sbab r1: the superblock-level inter AB arms.
76+ let sbab = ec_av1::decode::sb_ab_inter_hits_by_arm();
77+ println!(
78+ "inter_ab64: horz_a={} horz_b={} vert_a={} vert_b={}",
79+ sbab[0], sbab[1], sbab[2], sbab[3]
80+ );
75 let ir = ec_av1::stream::inter_rect_counters();81 let ir = ec_av1::stream::inter_rect_counters();
76 println!(82 println!(
77 "inter_rect: 32x8={} 8x32={} 64x32={} 32x64={} 64x16={} 16x64={}",83 "inter_rect: 32x8={} 8x32={} 64x32={} 32x64={} 64x16={} 16x64={}",
crates/ec-av1/src/decode.rsmodified+163 -9
@@ -2500,6 +2500,22 @@ pub(crate) fn rect4_coeff_hits() -> usize {
2500 RECT4_COEFF_HITS.with(|c| c.get())2500 RECT4_COEFF_HITS.with(|c| c.get())
2501 }2501 }
2502 2502
2503+// lane-sbab r1: how many superblock-level (64x64) AB partitions fired IN AN
2504+// INTER frame, per arm, in `PARTITION_HORZ_A`, `_HORZ_B`, `_VERT_A`,
2505+// `_VERT_B` order (the intra-frame counterpart is `SB_AB_HITS`). Each arm is
2506+// two 32x32 inter squares plus one true 64x32/32x64 inter strip; the gate
2507+// asserts the arms it proves separately so a run whose RD only picked one
2508+// cannot pass as proof of the others.
2509+thread_local! {
2510+ static SB_AB_INTER_HITS: std::cell::Cell<[usize; 4]> = const { std::cell::Cell::new([0; 4]) };
2511+}
2512+
2513+/// [`SB_AB_INTER_HITS`] per arm (HORZ_A, HORZ_B, VERT_A, VERT_B at 64x64 in an
2514+/// inter frame).
2515+pub fn sb_ab_inter_hits_by_arm() -> [usize; 4] {
2516+ SB_AB_INTER_HITS.with(std::cell::Cell::get)
2517+}
2518+
2503 // lane-inter16ab r1: how many 16x16-level AB partitions fired IN AN INTER2519 // lane-inter16ab r1: how many 16x16-level AB partitions fired IN AN INTER
2504 // frame, per arm, in `PARTITION_HORZ_A`, `_HORZ_B`, `_VERT_A`, `_VERT_B`2520 // frame, per arm, in `PARTITION_HORZ_A`, `_HORZ_B`, `_VERT_A`, `_VERT_B`
2505 // order (the intra-frame counterpart is `AB16_HITS`). Each arm is two 8x82521 // order (the intra-frame counterpart is `AB16_HITS`). Each arm is two 8x8
@@ -20894,9 +20910,19 @@ fn decode_inter_block(
20894 if vartx_leaves.is_some() {20910 if vartx_leaves.is_some() {
20895 // Plane 0 is already correct per transform unit20911 // Plane 0 is already correct per transform unit
20896 // ([`Neighbours::record_mi_luma`] above); this writes everything else20912 // ([`Neighbours::record_mi_luma`] above); this writes everything else
20897- // [`Neighbours::record_rect`] would (a var-tx block is always square,20913+ // [`Neighbours::record_rect`] would.
20898- // so `write_w == write_h == side`).20914+ //
20899- neighbours.record_split_luma_rect_mi(at, side, side, mode_for_tx, uv_predict_mode, [&u_grid, &v_grid]);20915+ // lane-sbab r1: this used to pass `side, side` on the premise that "a
20916+ // var-tx block is always square". That stopped being true the moment
20917+ // the SB-level rect strips landed (lane-inter4): a 64x32 / 32x64
20918+ // strip keeps `side = SB` for syntax but is NOT square, and stamping
20919+ // its neighbour bands 64x64 wrote `above_side_mi = 64` where libaom's
20920+ // `update_partition_context` writes `partition_context_lookup[
20921+ // BLOCK_32X64]`. The next superblock row then read the partition
20922+ // context one value low (ctx 2 where aomdec says 3) and desynced.
20923+ // The true footprint is `write_w`/`write_h`, exactly as the
20924+ // non-var-tx arm below uses.
20925+ neighbours.record_split_luma_rect_mi(at, write_w, write_h, mode_for_tx, uv_predict_mode, [&u_grid, &v_grid]);
20900 } else {20926 } else {
20901 neighbours.record_rect_mi(20927 neighbours.record_rect_mi(
20902 at,20928 at,
@@ -24613,13 +24639,141 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
24613 }24639 }
24614 continue;24640 continue;
24615 }24641 }
24616- if part64 != PARTITION_SPLIT {24642+ if (PARTITION_HORZ_A..=PARTITION_VERT_B).contains(&part64) {
24617- return Err(unsupported(24643+ // lane-sbab r1: the four superblock-level AB arms on the
24618- "an inter SB-level AB partition (HORZ_A/HORZ_B/VERT_A/VERT_B; this \24644+ // INTER path -- two 32x32 inter squares plus one true
24619- decoder's inter tile path codes a superblock as NONE, SPLIT, HORZ, \24645+ // 64x32/32x64 inter strip, in libaom `decode_partition`'s own
24620- VERT, HORZ_4 or VERT_4)",24646+ // order (decodeframe.c: HORZ_A = TL, TR, bottom strip;
24621- ));24647+ // HORZ_B = top strip, BL, BR; VERT_A = TL, BL, right strip;
24648+ // VERT_B = left strip, TR, BR). Every piece is one this
24649+ // decoder already proves elsewhere: the 32x32 square is the
24650+ // `PARTITION_NONE`-under-SPLIT block below, the strip is the
24651+ // `PARTITION_HORZ`/`VERT` piece above (`inter_piece!`, which
24652+ // keeps `side = SB` for syntax/CDF and names its true
24653+ // footprint through `write_w`/`write_h`). The intra-frame
24654+ // twin of this arm is lane-part32 r4's `SB_AB_HITS` block.
24655+ SB_AB_INTER_HITS.with(|c| {
24656+ let mut h = c.get();
24657+ h[part64 - PARTITION_HORZ_A] += 1;
24658+ c.set(h);
24659+ });
24660+ // lane-part32 r5 / class visit-order-changes-availability:
24661+ // only the two VERTICAL arms visit TL, BL, TR, BR, so only
24662+ // they switch libaom's `has_tr`/`has_bl` tables.
24663+ let _vert_guard = (part64 == PARTITION_VERT_A || part64 == PARTITION_VERT_B)
24664+ .then(crate::encode::Reach::vert_ab_partition);
24665+ let (mi_row0, mi_col0) = (
24666+ sb_r as usize * SB_MI as usize,
24667+ sb_c as usize * SB_MI as usize,
24668+ );
24669+ // 32 px = 8 MI units.
24670+ let tl = (mi_row0, mi_col0);
24671+ let tr = (mi_row0, mi_col0 + 8);
24672+ let bl = (mi_row0 + 8, mi_col0);
24673+ let br = (mi_row0 + 8, mi_col0 + 8);
24674+ macro_rules! ab_strip64 {
24675+ ($mi:expr, $ww:expr, $wh:expr) => {
24676+ inter_piece!(
24677+ $mi,
24678+ SB,
24679+ TxbSet::Luma64,
24680+ TxbSet::Luma64,
24681+ TxbSet::Chroma32,
24682+ TX32,
24683+ TX32,
24684+ &scan32,
24685+ &scan32,
24686+ 3,
24687+ $ww,
24688+ $wh
24689+ )
24690+ };
24691+ }
24692+ // The 32x32 squares carry a full square residual, so unlike
24693+ // `inter_piece!` (which hardcodes `reject_residual = true`
24694+ // for its strips) they pass `false`.
24695+ macro_rules! ab_square32 {
24696+ ($mi:expr) => {
24697+ decode_inter_block(
24698+ &mut dec,
24699+ &mut cdfs,
24700+ &mut neighbours,
24701+ &mut grid,
24702+ $mi,
24703+ BLOCK,
24704+ mi_cols,
24705+ mi_rows,
24706+ &mut y,
24707+ &mut u,
24708+ &mut v,
24709+ &ref_y,
24710+ &ref_u,
24711+ &ref_v,
24712+ &ref_slots,
24713+ &sign_bias_table,
24714+ &global_motion,
24715+ base_q_idx,
24716+ TxbSet::Luma32,
24717+ TxbSet::Luma32Inter,
24718+ TxbSet::Chroma16,
24719+ TX32,
24720+ TX16,
24721+ &scan32,
24722+ &scan16,
24723+ 3,
24724+ allow_high_precision_mv,
24725+ force_integer_mv,
24726+ interp_fixed,
24727+ enable_dual_filter,
24728+ tpl_frame.as_ref(),
24729+ reference_select,
24730+ enable_masked_compound,
24731+ enable_interintra_compound,
24732+ enable_jnt_comp,
24733+ order_hint_bits,
24734+ order_hint,
24735+ ref_order_hints,
24736+ skip_mode_present,
24737+ skip_mode_frame,
24738+ switchable_motion_mode,
24739+ allow_warped_motion,
24740+ false,
24741+ BLOCK,
24742+ BLOCK,
24743+ allow_screen_content_tools,
24744+ frame_width as usize,
24745+ )?
24746+ };
24747+ }
24748+ match part64 {
24749+ PARTITION_HORZ_A => {
24750+ ab_square32!(tl);
24751+ ab_square32!(tr);
24752+ ab_strip64!(bl, 64, 32);
24753+ }
24754+ PARTITION_HORZ_B => {
24755+ ab_strip64!(tl, 64, 32);
24756+ ab_square32!(bl);
24757+ ab_square32!(br);
24758+ }
24759+ PARTITION_VERT_A => {
24760+ ab_square32!(tl);
24761+ ab_square32!(bl);
24762+ ab_strip64!(tr, 32, 64);
24763+ }
24764+ _ => {
24765+ ab_strip64!(tl, 32, 64);
24766+ ab_square32!(tr);
24767+ ab_square32!(br);
24768+ }
24769+ }
24770+ continue;
24622 }24771 }
24772+ // Every value of the 10-symbol `partition_w64` alphabet is now
24773+ // handled above except SPLIT, which falls through to the quadrant
24774+ // loop below (lane-sbab r1 took the AB four; the rect/1:4 arms
24775+ // and NONE `continue` earlier).
24776+ debug_assert_eq!(part64, PARTITION_SPLIT);
24623 24777
24624 for quadrant in 0..4 {24778 for quadrant in 0..4 {
24625 let (r32, c32) = (sb_r * 2 + quadrant / 2, sb_c * 2 + quadrant % 2);24779 let (r32, c32) = (sb_r * 2 + quadrant / 2, sb_c * 2 + quadrant % 2);
crates/ec-av1/src/refusal_inventory.rsmodified+0 -1
@@ -70,7 +70,6 @@ const REFUSALS: &[&str] = &[
70 // the 8x8 leaf's TX_4X4 2x2 grid is still refused here.70 // the 8x8 leaf's TX_4X4 2x2 grid is still refused here.
71 "an 8x8 intra leaf in an inter frame whose tx_depth splits it into 4x4 transform units",71 "an 8x8 intra leaf in an inter frame whose tx_depth splits it into 4x4 transform units",
72 "an inter frame with no key frame before it",72 "an inter frame with no key frame before it",
73- "an inter SB-level AB partition (HORZ_A/HORZ_B/VERT_A/VERT_B; this decoder's inter tile path codes a superblock as NONE, SPLIT, HORZ, VERT, HORZ_4 or VERT_4)",
74 // lane-inter16ab r1 lifted the AB half and r2 the 1:4 half (four 16x4 /73 // lane-inter16ab r1 lifted the AB half and r2 the 1:4 half (four 16x4 /
75 // 4x16 inter strips, their 8x4/4x8 chroma pair built from BOTH strips'74 // 4x16 inter strips, their 8x4/4x8 chroma pair built from BOTH strips'
76 // motion vectors -- gate75 // motion vectors -- gate
crates/ec-av1/src/stream.rsmodified+208 -0
@@ -10125,6 +10125,214 @@ mod tests {
10125 }10125 }
10126 10126
10127 10127
10128+ #[test]
10129+ // lane-sbab r1: the SUPERBLOCK-level (64x64) AB partitions on an INTER
10130+ // frame -- PARTITION_HORZ_A/_HORZ_B/_VERT_A/_VERT_B at 64x64, i.e. two
10131+ // 32x32 inter squares plus one true 64x32/32x64 inter strip, decoded in
10132+ // libaom `decode_partition`'s visit order. Every decode-order frame is
10133+ // compared Y/U/V against ffmpeg, refusals are counted and never SKIPped,
10134+ // out-of-scope mismatches fail the gate, and EACH of the four arms must
10135+ // have fired on a pixel-exact attempt (RD picking only HORZ_A is not
10136+ // proof of four). `--min-partition-size=32` keeps every AB piece at or
10137+ // above 32x32, `--max-partition-size=64` puts the AB symbol at the SB
10138+ // root, and `--enable-1to4-partitions=0` because the 64-level 1:4 pair is
10139+ // a different lane's shape.
10140+ fn a_real_aomenc_inter_sequence_with_superblock_level_ab_partitions_decodes_pixel_exact() {
10141+ const NAME: &str =
10142+ "a_real_aomenc_inter_sequence_with_superblock_level_ab_partitions_decodes_pixel_exact";
10143+ let _gate_lock = lock_gate_counters();
10144+ if !have_ffmpeg() {
10145+ eprintln!("SKIP {NAME}: no ffmpeg");
10146+ return;
10147+ }
10148+ if !have_aomenc() {
10149+ eprintln!("SKIP {NAME}: no aomenc at {}", aomenc_path().display());
10150+ return;
10151+ }
10152+ let (width, height, frame_count) = (256usize, 192usize, 6usize);
10153+ // Per arm, over both bit depths: how many pixel-exact attempts fired
10154+ // it at least once.
10155+ let mut arms_total = [0u32; 4];
10156+ for bit_depth in [8u32, 10u32] {
10157+ let (mut named_refusals, mut matched, mut out_of_scope, mut oos_mismatch) =
10158+ (0u32, 0u32, 0u32, 0u32);
10159+ let mut arms_proved = [0u32; 4];
10160+ for attempt in 0..20u32 {
10161+ // Axes measured live by the r1 sweep
10162+ // (~/.cache/sbab-tmp/sweep.sh, table in the report): two
10163+ // motion steps x two source orientations x five quantisers x
10164+ // a single-tile and a two-tile-column arm. All four arms
10165+ // appear in that table at both depths; no single (sp, shape,
10166+ // cq) point carries more than three of them, which is why the
10167+ // sweep is this wide.
10168+ let cq = [18, 26, 34, 45, 55][(attempt % 5) as usize];
10169+ let natural = attempt / 5 % 2 == 1;
10170+ let sp = if attempt / 10 % 2 == 0 { 3 } else { 8 };
10171+ // r1: a `--tile-columns=1` twin of these 20 attempts was run
10172+ // and is deliberately NOT in the gate -- its streams PANIC in
10173+ // `mc::from_switchable_symbol` (a 4th symbol out of a
10174+ // 3-symbol alphabet), the exact signature lane-inter16ab r1
10175+ // recorded for its own tiled arm and which the ledger pins to
10176+ // the below-8x8 inter leaf, not to anything this lane
10177+ // touches. Recorded as open residue in
10178+ // lanes/sbab-r1.report.md rather than turned into a SKIP or a
10179+ // weakened assert.
10180+ let tile_cols = "0";
10181+ let duration = frame_count as f64 / 25.0;
10182+ // Long-period continuous tone: the 64-level AB partitions
10183+ // need the L/T-shaped feature to span 32 px, so the sinusoid
10184+ // periods here are ~3x the 16-level gate's.
10185+ let lum = if natural {
10186+ format!("128+58*sin((Y+N*{sp})/17)+40*sin(X/29)+20*sin((X+Y)/13)")
10187+ } else {
10188+ format!("128+58*sin((X+N*{sp})/17)+40*sin(Y/29)+20*sin((X-Y)/13)")
10189+ };
10190+ let source = format!(
10191+ "color=c=gray:s={width}x{height}:d={duration}:r=25,format=gray,\
10192+ geq=lum='{lum}',format=yuv420p"
10193+ );
10194+ let pix_fmt = if bit_depth == 10 { "yuv420p10le" } else { "yuv420p" };
10195+ let y4m = Command::new("ffmpeg")
10196+ .args([
10197+ "-v", "error", "-f", "lavfi", "-i", &source, "-t", &duration.to_string(),
10198+ "-pix_fmt", pix_fmt, "-strict", "-1", "-f", "yuv4mpegpipe", "-",
10199+ ])
10200+ .stdin(Stdio::null())
10201+ .stdout(Stdio::piped())
10202+ .stderr(Stdio::piped())
10203+ .output()
10204+ .expect("ffmpeg failed to run");
10205+ assert!(
10206+ y4m.status.success(),
10207+ "{NAME}: ffmpeg refused the {bit_depth}-bit fixture: {}",
10208+ String::from_utf8_lossy(&y4m.stderr)
10209+ );
10210+ let cq_arg = format!("--cq-level={cq}");
10211+ let depth_arg = format!("--bit-depth={bit_depth}");
10212+ let input_depth_arg = format!("--input-bit-depth={bit_depth}");
10213+ let tile_arg = format!("--tile-columns={tile_cols}");
10214+ let args: Vec<&str> = vec![
10215+ "--codec=av1", "--passes=1", "--end-usage=q", &cq_arg, "--cpu-used=0",
10216+ "--threads=1", "--row-mt=0", "--sb-size=64", &depth_arg, &input_depth_arg,
10217+ "--enable-restoration=0", "--enable-palette=0", "--deltaq-mode=0",
10218+ "--enable-filter-intra=0", "--enable-cfl-intra=0", "--enable-intrabc=0",
10219+ "--lag-in-frames=0", "--kf-max-dist=9999", &tile_arg,
10220+ // Per-arm overrides go LAST: aomenc keeps the last
10221+ // occurrence of a repeated --enable-* flag.
10222+ "--enable-rect-partitions=1", "--enable-ab-partitions=1",
10223+ "--enable-1to4-partitions=0", "--min-partition-size=32",
10224+ "--max-partition-size=64",
10225+ "--obu", "-o", "-", "-",
10226+ ];
10227+ let mut child = Command::new(aomenc_path())
10228+ .args(&args)
10229+ .stdin(Stdio::piped())
10230+ .stdout(Stdio::piped())
10231+ .stderr(Stdio::piped())
10232+ .spawn()
10233+ .expect("aomenc failed to start");
10234+ child
10235+ .stdin
10236+ .take()
10237+ .expect("aomenc stdin")
10238+ .write_all(&y4m.stdout)
10239+ .expect("writing y4m to aomenc");
10240+ let out = child.wait_with_output().expect("aomenc failed to run");
10241+ assert!(
10242+ out.status.success(),
10243+ "aomenc refused the fixture: {}",
10244+ String::from_utf8_lossy(&out.stderr)
10245+ );
10246+ let stream = out.stdout;
10247+ let before = decode::sb_ab_inter_hits_by_arm();
10248+ let frames = match decode_stream(&stream) {
10249+ Err(e) => {
10250+ let msg = e.to_string();
10251+ assert!(
10252+ msg.contains("unsupported"),
10253+ "{NAME} failed outright, not a named refusal ({bit_depth}-bit, \
10254+ attempt {attempt}): {msg}"
10255+ );
10256+ named_refusals += 1;
10257+ eprintln!("{bit_depth}-bit attempt {attempt} refusal: {msg}");
10258+ continue;
10259+ }
10260+ Ok(frames) => frames,
10261+ };
10262+ let after = decode::sb_ab_inter_hits_by_arm();
10263+ let fired: Vec<usize> = (0..4).map(|a| after[a] - before[a]).collect();
10264+ let ffmpeg_frames = if bit_depth == 10 {
10265+ ffmpeg_decode_sequence_10bit(&stream, width, height, frame_count)
10266+ } else {
10267+ ffmpeg_decode_sequence(&stream, width, height, frame_count)
10268+ };
10269+ assert_eq!(frames.len(), frame_count);
10270+ let mismatched = frames
10271+ .iter()
10272+ .zip(&ffmpeg_frames)
10273+ .any(|(got, want)| got.y != want.y || got.u != want.u || got.v != want.v);
10274+ if fired.iter().sum::<usize>() == 0 {
10275+ out_of_scope += 1;
10276+ if mismatched {
10277+ oos_mismatch += 1;
10278+ eprintln!(
10279+ "{NAME}: {bit_depth}-bit attempt {attempt} MISMATCHES with zero \
10280+ 64-level inter AB partition -- another shape's defect"
10281+ );
10282+ }
10283+ continue;
10284+ }
10285+ if mismatched {
10286+ for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() {
10287+ let bad: Vec<usize> =
10288+ (0..got.y.len()).filter(|&k| got.y[k] != want.y[k]).collect();
10289+ if !bad.is_empty() {
10290+ eprintln!(
10291+ "{NAME}: attempt {attempt} {bit_depth}-bit frame {i}: {} luma \
10292+ pixels differ, first at ({}, {}), max |delta| {}",
10293+ bad.len(),
10294+ bad[0] % width,
10295+ bad[0] / width,
10296+ bad.iter()
10297+ .map(|&k| (got.y[k] as i32 - want.y[k] as i32).abs())
10298+ .max()
10299+ .unwrap_or(0)
10300+ );
10301+ }
10302+ }
10303+ }
10304+ for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() {
10305+ assert_eq!(got.y, want.y, "{NAME} frame {i} luma vs ffmpeg (attempt {attempt}, {bit_depth}-bit, arms {fired:?})");
10306+ assert_eq!(got.u, want.u, "{NAME} frame {i} U vs ffmpeg (attempt {attempt}, {bit_depth}-bit, arms {fired:?})");
10307+ assert_eq!(got.v, want.v, "{NAME} frame {i} V vs ffmpeg (attempt {attempt}, {bit_depth}-bit, arms {fired:?})");
10308+ }
10309+ for a in 0..4 {
10310+ if fired[a] > 0 {
10311+ arms_proved[a] += 1;
10312+ arms_total[a] += 1;
10313+ }
10314+ }
10315+ matched += 1;
10316+ }
10317+ eprintln!(
10318+ "{NAME} ({bit_depth}-bit): {named_refusals} named refusals, {matched} pixel-exact \
10319+ attempts carrying a 64-level inter AB partition, per-arm attempts \
10320+ HORZ_A/HORZ_B/VERT_A/VERT_B={arms_proved:?}, {out_of_scope} attempts carried \
10321+ none ({oos_mismatch} of them mismatched)"
10322+ );
10323+ assert_eq!(
10324+ oos_mismatch, 0,
10325+ "{NAME}: {oos_mismatch} attempt(s) with no 64-level inter AB partition decoded \
10326+ but mismatched ffmpeg -- a defect of another shape, not a pass"
10327+ );
10328+ }
10329+ assert!(
10330+ arms_total.iter().all(|&n| n > 0),
10331+ "{NAME}: not every 64-level inter AB arm fired on a pixel-exact attempt \
10332+ (HORZ_A/HORZ_B/VERT_A/VERT_B={arms_total:?}) -- the unfired arm(s) are unproven"
10333+ );
10334+ }
10335+
10128 #[test]10336 #[test]
10129 fn a_real_aomenc_inter_sequence_with_deblocking_decodes_pixel_exact() {10337 fn a_real_aomenc_inter_sequence_with_deblocking_decodes_pixel_exact() {
10130 if !have_ffmpeg() {10338 if !have_ffmpeg() {
lanes/sbab-r1.handoff.mdadded+112 -0
@@ -0,0 +1,112 @@
1+# lane-sbab r1 handoff — superblock-level inter AB partitions
2+
3+Branch `lane-sbab`, tip `038d1f8` (rebased onto main `cc323d0`).
4+Worktree `/home/user/Documents/Code/Rust/edith_codecs-sbab`.
5+
6+## 1. Real, not our own desync
7+
8+`EC_TRACE=1 aomdec` on `~/.cache/sbab-tmp/s_8_3_y_45.obu` (256x192, 8-bit, cq45,
9+Y-structured source, sp=3) prints, in decode-order frame 4 (an INTER frame; the
10+stream has 12 SB partition reads per frame, entries 49..60 are frame 4):
11+
12+```
13+EC_PART_VAL mi_row=16 mi_col=32 bsize=12 value=4 # PARTITION_HORZ_A at 64x64
14+EC_PART_VAL mi_row=32 mi_col=32 bsize=12 value=5 # PARTITION_HORZ_B at 64x64
15+```
16+
17+bsize=12 is BLOCK_64X64 and values 4/5 are HORZ_A/HORZ_B, so the refusal
18+"an inter SB-level AB partition" named a real stream shape. VERDICT: REAL.
19+
20+## 2. What is implemented
21+
22+`crates/ec-av1/src/decode.rs:21494`, in `decode_inter_frame_tile_with_cdfs`'s
23+64-level partition switch: the four arms in libaom `decode_partition` order
24+(`decodeframe.c`) —
25+HORZ_A = TL 32x32, TR 32x32, bottom 64x32 strip;
26+HORZ_B = top 64x32 strip, BL 32x32, BR 32x32;
27+VERT_A = TL 32x32, BL 32x32, right 32x64 strip;
28+VERT_B = left 32x64 strip, TR 32x32, BR 32x32.
29+The squares reuse the `PARTITION_NONE`-under-SPLIT `decode_inter_block` call
30+verbatim (Luma32/Luma32Inter/Chroma16, TX32/TX16, size group 3, side `BLOCK`);
31+the strips reuse `inter_piece!` (side `SB`, true footprint via `write_w`/
32+`write_h`), which lane-r14's `superblock_level_rect_partition` gate proves.
33+`Reach::vert_ab_partition` is armed for the two VERT arms only (visit order
34+TL,BL,TR,BR changes `has_tr`/`has_bl`). Per-arm counter
35+`SB_AB_INTER_HITS` / `sb_ab_inter_hits_by_arm()` (decode.rs:2222), printed by
36+`examples/decode_probe` as `inter_ab64:`.
37+
38+## 3. The defect the gate found (root cause, shared path)
39+
40+`decode.rs:19128` — `decode_inter_block`'s var-tx branch called
41+`record_split_luma_rect_mi(at, side, side, ...)` with the comment "a var-tx
42+block is always square, so write_w == write_h == side". That premise died when
43+the SB-level rect strips landed (lane-inter4): a 64x32 / 32x64 strip keeps
44+`side = SB` for syntax but is not square, so it stamped `above_side_mi = 64`
45+where libaom's `update_partition_context` writes
46+`partition_context_lookup[BLOCK_32X64]`. The superblock BELOW then computed
47+partition ctx 2 where aomdec reads 3, wrong CDF row, desync at the next symbol.
48+Fixed by passing `write_w, write_h`. Ladder evidence, frame 4 of the stream
49+above, `EC_AV1_TRACE=1` ours vs `EC_TRACE=1` aomdec (aomdec ctx prints as
50+`4*bsl+ctx` = 12+ctx):
51+
52+| mi | oracle ctx | ours before | ours after | oracle pre_rng | ours after |
53+|-----------|-----------|-------------|------------|----------------|------------|
54+| (16,48) | 3 | 2 | 3 | 49168 | 49168 |
55+| (32,0) | 0 | 0 | 0 | 53403 | 53403 (was 60557) |
56+| (32,32) | 2 | 0 | 2 | 42672 | 42672 (was 32906) |
57+
58+After the fix all 72 partition reads of the stream match the oracle in ctx,
59+value and range.
60+
61+Note this is a SHARED-path fix: it changes every var-tx inter block whose
62+footprint is not square, i.e. the SB-level HORZ/VERT/HORZ_4/VERT_4 strips too.
63+Sibling coverage is the full suite run (below), not this gate alone.
64+
65+## 4. Gate
66+
67+`a_real_aomenc_inter_sequence_with_superblock_level_ab_partitions_decodes_pixel_exact`
68+(`crates/ec-av1/src/stream.rs:8375`). 256x192, 6 frames, 20 attempts per bit
69+depth (cq 18/26/34/45/55 x two source orientations x motion step 3/8), aomenc
70+`--sb-size=64 --enable-rect-partitions=1 --enable-ab-partitions=1
71+--enable-1to4-partitions=0 --min-partition-size=32 --max-partition-size=64
72+--kf-max-dist=9999 --cpu-used=0 --threads=1 --row-mt=0`, every decode-order
73+frame compared Y/U/V vs ffmpeg, `oos_mismatch` asserted 0, all four arms
74+asserted to have fired on a pixel-exact attempt.
75+
76+```
77+(8-bit): 0 named refusals, 12 pixel-exact attempts carrying a 64-level inter AB
78+ partition, per-arm HORZ_A/HORZ_B/VERT_A/VERT_B=[6, 5, 4, 2],
79+ 8 attempts carried none (0 of them mismatched)
80+(10-bit): 0 named refusals, 4 pixel-exact attempts, per-arm=[2, 1, 3, 2],
81+ 16 attempts carried none (0 of them mismatched)
82+test result: ok. 1 passed; 0 failed; 418 filtered out; finished in 92.12s
83+```
84+
85+## 5. Refusal state
86+
87+Removed from `refusal_inventory.rs`: `"an inter SB-level AB partition
88+(HORZ_A/HORZ_B/VERT_A/VERT_B; ...)"`, with a comment naming the gate that
89+replaced it. No arm stayed unreachable — all four fired live at both depths, so
90+nothing is left refused by name here. `gate_coverage.rs` needs no change
91+(`enable-ab-partitions` was already covered).
92+
93+## 6. Open residue
94+
95+- deferred(below-8x8 inter leaf desync): a `--tile-columns=1` twin of the 20
96+ attempts PANICS in `mc::from_switchable_symbol` (`mc.rs:203`, a 4th symbol
97+ out of a 3-symbol alphabet) on 8-bit attempt 27 — the exact signature
98+ lane-inter16ab r1 recorded for its own tiled arm. Not this lane's shape; the
99+ tiled axis is excluded with that reason in the gate source rather than
100+ SKIPped. Unblocked by whoever lands the sub-8 inter leaf.
101+- The 64-level 1:4 pair (HORZ_4/VERT_4 at 64) is unrelated and already decoded;
102+ `--enable-1to4-partitions=0` here only keeps the sweep narrow.
103+
104+## 7. Exact next step
105+
106+1. Read `$HOME/.cache/sbab-suite-r1.log` (`systemd-run --user` unit
107+ `sbab-suite-r1`, armed at commit `038d1f8`): confirm N passed / 0 failed.
108+ The var-tx extent fix is repo-wide, so a red sibling there is this lane's to
109+ own, not another lane's.
110+2. If green, merge `lane-sbab` into main and delete the worktree.
111+3. Optional follow-up, not started: film check with the 0.4 s extracts — this
112+ lane never ran one.