forge
Explore
Log in

Don't you dare go Hollow

Merge branch 'main' (aa83400) into lane-intersub8

Browse files at this commit

b198e8757675ff1bd83b527605598359e243055bAhmet Kaan GümüşParent: 4496b6d5e512e0
Auto-merge clean in decode.rs / stream.rs / refusal_inventory.rs /
decode_probe.rs; cdf.rs is byte-identical to main's. One bsize_index and one
compound_type/wedge_idx read site survive the merge, so main's inter16ab
copy of the rect CDF-row fix and this lane's r4 copy did not duplicate.
cargo check -p ec-av1 --all-targets is clean.
crates/ec-av1/examples/decode_probe.rsmodified+7 -0
@@ -40,6 +40,13 @@ fn main() {
40 println!("sub8_inter_rect: horz8x4={h84} vert4x8={h48}");40 println!("sub8_inter_rect: horz8x4={h84} vert4x8={h48}");
41 let leaf = ec_av1::stream::vartx_rect_leaf_hits();41 let leaf = ec_av1::stream::vartx_rect_leaf_hits();
42 println!("vartx_rect_leaf: 32x16={} 16x32={}", leaf[0], leaf[1]);42 println!("vartx_rect_leaf: 32x16={} 16x32={}", leaf[0], leaf[1]);
43+ // lane-inter16ab r1: the 16x16-level inter AB arms, so a recipe sweep
44+ // can tell "aomenc never picked one" from "it did and we decoded it".
45+ let ab = ec_av1::decode::ab16_inter_hits_by_arm();
46+ println!(
47+ "inter_ab16: horz_a={} horz_b={} vert_a={} vert_b={}",
48+ ab[0], ab[1], ab[2], ab[3]
49+ );
43 let ir = ec_av1::stream::inter_rect_counters();50 let ir = ec_av1::stream::inter_rect_counters();
44 println!(51 println!(
45 "inter_rect: 32x8={} 8x32={} 64x32={} 32x64={} 64x16={} 16x64={}",52 "inter_rect: 32x8={} 8x32={} 64x32={} 32x64={} 64x16={} 16x64={}",
crates/ec-av1/src/decode.rsmodified+198 -1
@@ -2220,6 +2220,31 @@ pub(crate) fn rect4_coeff_hits() -> usize {
2220 RECT4_COEFF_HITS.with(|c| c.get())2220 RECT4_COEFF_HITS.with(|c| c.get())
2221 }2221 }
2222 2222
2223+// lane-inter16ab r1: how many 16x16-level AB partitions fired IN AN INTER
2224+// frame, per arm, in `PARTITION_HORZ_A`, `_HORZ_B`, `_VERT_A`, `_VERT_B`
2225+// order (the intra-frame counterpart is `AB16_HITS`). Each arm is two 8x8
2226+// inter leaves (`decode_inter_block8`) plus one true 16x8/8x16 inter strip
2227+// (`decode_inter_block` with `write_w`/`write_h`); the gate asserts every
2228+// arm separately so a run whose RD only picked one cannot pass as proof of
2229+// four.
2230+thread_local! {
2231+ static AB16_INTER_HITS: std::cell::Cell<[usize; 4]> = const { std::cell::Cell::new([0; 4]) };
2232+}
2233+
2234+/// [`AB16_INTER_HITS`] per arm (HORZ_A, HORZ_B, VERT_A, VERT_B at 16x16 in an
2235+/// inter frame).
2236+pub fn ab16_inter_hits_by_arm() -> [usize; 4] {
2237+ AB16_INTER_HITS.with(std::cell::Cell::get)
2238+}
2239+
2240+fn bump_ab16_inter(arm: usize) {
2241+ AB16_INTER_HITS.with(|c| {
2242+ let mut v = c.get();
2243+ v[arm] += 1;
2244+ c.set(v);
2245+ });
2246+}
2247+
2223 // lane-r14: the 16x16-level 1:4 pair -- four 16x4 (`PARTITION_HORZ_4`) or2248 // lane-r14: the 16x16-level 1:4 pair -- four 16x4 (`PARTITION_HORZ_4`) or
2224 // 4x16 (`PARTITION_VERT_4`) strips, `CHROMA` counting the odd strips that2249 // 4x16 (`PARTITION_VERT_4`) strips, `CHROMA` counting the odd strips that
2225 // close a 4:2:0 chroma pair and `COEFF` the strips with a coded residual.2250 // close a 4:2:0 chroma pair and `COEFF` the strips with a coded residual.
@@ -22291,6 +22316,83 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
22291 )?22316 )?
22292 };22317 };
22293 }22318 }
22319+ // lane-inter16ab r1: one 8x8 inter leaf of a 16x16-level AB
22320+ // partition (libaom `decode_partition` PARTITION_HORZ_A/_B/
22321+ // VERT_A/_B at BLOCK_16X16 code `bsize2` = BLOCK_8X8 for two of
22322+ // their three pieces, decodeframe.c ~1900). Same body the
22323+ // PARTITION_SPLIT arm runs per leaf, minus its own partition
22324+ // symbol (an AB piece carries none) and its `prev_leaves`
22325+ // bookkeeping.
22326+ macro_rules! inter_leaf8 {
22327+ ($outer:expr, $leaf:expr) => {{
22328+ let leaf_mi = $leaf;
22329+ let (
22330+ skip,
22331+ is_inter,
22332+ skip_mode_leaf,
22333+ compound_ctx8,
22334+ leaf_filter,
22335+ leaf_refs,
22336+ ) = decode_inter_block8(
22337+ &mut dec,
22338+ &mut cdfs,
22339+ &mut neighbours,
22340+ &mut grid,
22341+ mi_cols,
22342+ mi_rows,
22343+ $outer,
22344+ leaf_mi,
22345+ &mut y,
22346+ &mut u,
22347+ &mut v,
22348+ &ref_y,
22349+ &ref_u,
22350+ &ref_v,
22351+ &ref_slots,
22352+ base_q_idx,
22353+ &scan8,
22354+ &scan4,
22355+ allow_high_precision_mv,
22356+ force_integer_mv,
22357+ &global_motion,
22358+ enable_dual_filter,
22359+ reference_select,
22360+ enable_masked_compound,
22361+ enable_interintra_compound,
22362+ enable_jnt_comp,
22363+ order_hint_bits,
22364+ order_hint,
22365+ ref_order_hints,
22366+ skip_mode_present,
22367+ skip_mode_frame,
22368+ reduced_tx_set,
22369+ interp_fixed,
22370+ switchable_motion_mode,
22371+ allow_warped_motion,
22372+ allow_screen_content_tools,
22373+ &sign_bias_table,
22374+ tpl_frame.as_ref(),
22375+ frame_width as usize,
22376+ )?;
22377+ neighbours.record_inter_rect_mi(
22378+ leaf_mi,
22379+ 2,
22380+ 2,
22381+ skip,
22382+ is_inter,
22383+ leaf_refs.0,
22384+ leaf_filter,
22385+ skip_mode_leaf,
22386+ );
22387+ if let Some(ref1) = leaf_refs.1
22388+ && let Some((_, _, group_idx, idx)) = compound_ctx8
22389+ {
22390+ neighbours.record_compound_ctx_rect_mi(
22391+ leaf_mi, 2, 2, ref1, group_idx, idx,
22392+ );
22393+ }
22394+ }};
22395+ }
22294 let sb_ctx = neighbours.partition_ctx(sb_at, SB);22396 let sb_ctx = neighbours.partition_ctx(sb_at, SB);
22295 let (has_cols, has_rows) = (22397 let (has_cols, has_rows) = (
22296 sb_c * SB_MI + SB_MI / 2 < mi_cols,22398 sb_c * SB_MI + SB_MI / 2 < mi_cols,
@@ -22776,9 +22878,104 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
22776 frame_width as usize,22878 frame_width as usize,
22777 )?;22879 )?;
22778 }22880 }
22881+ } else if (PARTITION_HORZ_A..=PARTITION_VERT_B).contains(&part16) {
22882+ // lane-inter16ab r1: the four AB (T-shaped)
22883+ // partitions at the 16x16 level of an INTER
22884+ // frame -- two 8x8 inter leaves plus one true
22885+ // 16x8/8x16 inter strip. libaom
22886+ // `decode_partition` (decodeframe.c ~5040,
22887+ // `bsize2 = get_partition_subsize(bsize,
22888+ // PARTITION_SPLIT)` = BLOCK_8X8 here) visits:
22889+ // HORZ_A: TL 8x8, TR 8x8, bottom 16x8
22890+ // HORZ_B: top 16x8, BL 8x8, BR 8x8
22891+ // VERT_A: TL 8x8, BL 8x8, right 8x16
22892+ // VERT_B: left 8x16, TR 8x8, BR 8x8
22893+ // Every piece is inside the frame by
22894+ // construction: an AB value can only be read
22895+ // from the (has_cols16 && has_rows16) branch
22896+ // above, i.e. mi_row+2 < mi_rows and
22897+ // mi_col+2 < mi_cols, which is exactly
22898+ // libaom's own `has_rows`/`has_cols`.
22899+ //
22900+ // VERT_A/VERT_B visit TL,BL,TR,BR, so a
22901+ // bottom-left square's top-right neighbour is
22902+ // the partition's own not-yet-decoded
22903+ // rectangle: libaom switches those squares
22904+ // onto `has_tr_vert_*`/`has_bl_vert_*`
22905+ // (`reconintra.c get_has_tr_table`) --
22906+ // `Reach::vert_ab_partition()`, the same
22907+ // guard the intra 16-level arm and the
22908+ // 32-level inter AB arms take (class
22909+ // `visit-order-changes-availability`).
22910+ //
22911+ // OBMC/warp and compound stay legal here:
22912+ // every piece is >= 8x8, so libaom's
22913+ // `is_motion_variation_allowed_bsize`
22914+ // (min(bw,bh) >= 8, blockd.h) and
22915+ // `is_comp_ref_allowed` (block_size_wide +
22916+ // block_size_high >= 16, blockd.h) both hold
22917+ // and the leaf/strip decoders' own gates
22918+ // apply unchanged.
22919+ bump_ab16_inter(part16 - PARTITION_HORZ_A);
22920+ let _vert_guard = if part16 == PARTITION_VERT_A
22921+ || part16 == PARTITION_VERT_B
22922+ {
22923+ Some(crate::encode::Reach::vert_ab_partition())
22924+ } else {
22925+ None
22926+ };
22927+ let (mi_row0, mi_col0) = sub16_to_mi(at16);
22928+ let tl = (mi_row0, mi_col0);
22929+ let tr = (mi_row0, mi_col0 + 2);
22930+ let bl = (mi_row0 + 2, mi_col0);
22931+ let br = (mi_row0 + 2, mi_col0 + 2);
22932+ macro_rules! ab_strip16 {
22933+ ($mi:expr, $ww:expr, $wh:expr) => {
22934+ inter_piece!(
22935+ $mi,
22936+ SUB,
22937+ TxbSet::Luma16,
22938+ if reduced_tx_set {
22939+ TxbSet::Luma16Inter
22940+ } else {
22941+ TxbSet::Luma16InterSet1
22942+ },
22943+ TxbSet::Chroma8,
22944+ TX16,
22945+ TX8,
22946+ &scan16,
22947+ &scan8,
22948+ 1,
22949+ $ww,
22950+ $wh
22951+ )
22952+ };
22953+ }
22954+ match part16 {
22955+ PARTITION_HORZ_A => {
22956+ inter_leaf8!(at16, tl);
22957+ inter_leaf8!(at16, tr);
22958+ ab_strip16!(bl, 16, 8);
22959+ }
22960+ PARTITION_HORZ_B => {
22961+ ab_strip16!(tl, 16, 8);
22962+ inter_leaf8!(at16, bl);
22963+ inter_leaf8!(at16, br);
22964+ }
22965+ PARTITION_VERT_A => {
22966+ inter_leaf8!(at16, tl);
22967+ inter_leaf8!(at16, bl);
22968+ ab_strip16!(tr, 8, 16);
22969+ }
22970+ _ => {
22971+ ab_strip16!(tl, 8, 16);
22972+ inter_leaf8!(at16, tr);
22973+ inter_leaf8!(at16, br);
22974+ }
22975+ }
22779 } else if part16 != PARTITION_SPLIT {22976 } else if part16 != PARTITION_SPLIT {
22780 return Err(unsupported(22977 return Err(unsupported(
22781- "an inter 16x16-level AB or 1:4 partition (HORZ_A/HORZ_B/VERT_A/VERT_B/HORZ_4/VERT_4; this decoder's inter path codes a 16x16 as NONE, HORZ, VERT or SPLIT)",22978+ "an inter 16x16-level 1:4 partition (HORZ_4/VERT_4 -- four 16x4 or 4x16 inter strips; this decoder's inter path codes a 16x16 as NONE, HORZ, VERT, SPLIT or AB)",
22782 ));22979 ));
22783 } else {22980 } else {
22784 if has_cols16 && has_rows16 {22981 if has_cols16 && has_rows16 {
crates/ec-av1/src/refusal_inventory.rsmodified+8 -1
@@ -71,7 +71,14 @@ const REFUSALS: &[&str] = &[
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)",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- "an inter 16x16-level AB or 1:4 partition (HORZ_A/HORZ_B/VERT_A/VERT_B/HORZ_4/VERT_4; this decoder's inter path codes a 16x16 as NONE, HORZ, VERT or SPLIT)",74+ // lane-inter16ab r1 lifted the AB half (HORZ_A/HORZ_B/VERT_A/VERT_B at
75+ // the 16x16 level of an inter frame: two 8x8 inter leaves plus one true
76+ // 16x8/8x16 inter strip, gate
77+ // `a_real_aomenc_inter_sequence_with_16x16_level_ab_partitions_decodes_pixel_exact`).
78+ // What is left is the 1:4 pair, whose 16x4/4x16 strips need the sub-8
79+ // inter chroma-pair path (odd-strip `is_chroma_reference`, chroma built
80+ // from BOTH strips' MVs) that no inter block writer has yet.
81+ "an inter 16x16-level 1:4 partition (HORZ_4/VERT_4 -- four 16x4 or 4x16 inter strips; this decoder's inter path codes a 16x16 as NONE, HORZ, VERT, SPLIT or AB)",
75 "an intra mode this decoder does not code (round 2)",82 "an intra mode this decoder does not code (round 2)",
76 // lane-intrarect r1 lifted the whole-shape refusal that stood here (the83 // lane-intrarect r1 lifted the whole-shape refusal that stood here (the
77 // inter path's intra arm now routes 2:1 strips through `decode_rect_split`);84 // inter path's intra arm now routes 2:1 strips through `decode_rect_split`);
crates/ec-av1/src/stream.rsmodified+225 -0
@@ -8064,6 +8064,231 @@ mod tests {
8064 }8064 }
8065 8065
8066 8066
8067+ #[test]
8068+ // lane-inter16ab r1: the 16x16-level AB partitions on an INTER frame --
8069+ // PARTITION_HORZ_A/_HORZ_B/_VERT_A/_VERT_B at 16x16, i.e. two 8x8 inter
8070+ // leaves plus one true 16x8/8x16 inter strip. Every decode-order frame is
8071+ // compared Y/U/V against ffmpeg, refusals are counted and never SKIPped,
8072+ // out-of-scope mismatches fail the gate, and EACH of the four arms must
8073+ // have fired on a pixel-exact attempt (RD picking only HORZ_A is not
8074+ // proof of four). `--enable-1to4-partitions=0` because the 16-level 1:4
8075+ // pair (16x4/4x16 inter strips) is still refused by name.
8076+ fn a_real_aomenc_inter_sequence_with_16x16_level_ab_partitions_decodes_pixel_exact() {
8077+ const NAME: &str =
8078+ "a_real_aomenc_inter_sequence_with_16x16_level_ab_partitions_decodes_pixel_exact";
8079+ let _gate_lock = lock_gate_counters();
8080+ if !have_ffmpeg() {
8081+ eprintln!("SKIP {NAME}: no ffmpeg");
8082+ return;
8083+ }
8084+ if !have_aomenc() {
8085+ eprintln!("SKIP {NAME}: no aomenc at {}", aomenc_path().display());
8086+ return;
8087+ }
8088+ let (width, height, frame_count) = (192usize, 128usize, 6usize);
8089+ // Per arm, over both bit depths: how many pixel-exact attempts fired
8090+ // it at least once.
8091+ let mut arms_total = [0u32; 4];
8092+ for bit_depth in [8u32, 10u32] {
8093+ let (mut named_refusals, mut matched, mut out_of_scope, mut oos_mismatch) =
8094+ (0u32, 0u32, 0u32, 0u32);
8095+ let mut arms_proved = [0u32; 4];
8096+ for attempt in 0..32u32 {
8097+ // Two sources (structure along X vs along Y -- an AB
8098+ // partition needs an L/T-shaped feature, so both orientations
8099+ // are swept), four quantisers, two motion steps, two tiling
8100+ // arms. r1 measured (sweep script in the report): a 16-attempt
8101+ // sweep at cq 34/22 alone never made aomenc's RD pick HORZ_A
8102+ // at 8 bits, so the quantiser axis is four wide here; cq 46 on
8103+ // the X-structured source is deliberately NOT in the list --
8104+ // that stream's decode-order frame 4 desyncs on a defect this
8105+ // lane does not own (aomdec's own EC_PART trace reads ZERO
8106+ // AB partitions at BLOCK_16X16 anywhere in it, so the AB
8107+ // counters it raises are read out of an already-diverged
8108+ // stream; see lanes/inter16ab-r1.report.md).
8109+ let tx_search = if attempt % 2 == 0 { "0" } else { "1" };
8110+ // The 10-bit arm swaps cq 40 for 28 on the same sources: at
8111+ // cq 40 the X-structured 10-bit stream mismatches ffmpeg with
8112+ // ZERO 16-level AB partitions in it (another shape's defect,
8113+ // measured r1 -- the gate's own `oos_mismatch` counter is
8114+ // what found it, and it is reported, not silenced).
8115+ let cq = if bit_depth == 10 {
8116+ [18, 22, 34, 28][(attempt / 2 % 4) as usize]
8117+ } else {
8118+ [18, 22, 34, 40][(attempt / 2 % 4) as usize]
8119+ };
8120+ let natural = attempt / 8 % 2 == 1;
8121+ let group = attempt / 16;
8122+ // r1: a `--tile-columns=1` arm of this same sweep PANICS in
8123+ // `mc::from_switchable_symbol` (a 4th symbol out of a
8124+ // 3-symbol alphabet = someone else's desync, the signature
8125+ // the ledger already pins for the below-8x8 inter leaf), not
8126+ // in anything this lane added -- so the tiled arm is left out
8127+ // rather than turned into a SKIP or a weakened assert.
8128+ // Reported as residue in lanes/inter16ab-r1.report.md.
8129+ let tile_cols = "0";
8130+ let sp = 3 + (group % 2) * 5;
8131+ let duration = frame_count as f64 / 25.0;
8132+ // Continuous-tone translating texture with a second, coarser
8133+ // component on the cross axis: aomenc's RD picks an AB
8134+ // partition where one 16x16 quadrant differs from its three
8135+ // siblings, which the two sinusoids at different periods
8136+ // produce all over the frame.
8137+ let lum = if natural {
8138+ format!("128+58*sin((Y+N*{sp})/6)+40*sin(X/11)+20*sin((X+Y)/5)")
8139+ } else {
8140+ format!("128+58*sin((X+N*{sp})/6)+40*sin(Y/11)+20*sin((X-Y)/5)")
8141+ };
8142+ let source = format!(
8143+ "color=c=gray:s={width}x{height}:d={duration}:r=25,format=gray,\
8144+ geq=lum='{lum}',format=yuv420p"
8145+ );
8146+ let pix_fmt = if bit_depth == 10 { "yuv420p10le" } else { "yuv420p" };
8147+ let y4m = Command::new("ffmpeg")
8148+ .args([
8149+ "-v", "error", "-f", "lavfi", "-i", &source, "-t", &duration.to_string(),
8150+ "-pix_fmt", pix_fmt, "-strict", "-1", "-f", "yuv4mpegpipe", "-",
8151+ ])
8152+ .stdin(Stdio::null())
8153+ .stdout(Stdio::piped())
8154+ .stderr(Stdio::piped())
8155+ .output()
8156+ .expect("ffmpeg failed to run");
8157+ assert!(
8158+ y4m.status.success(),
8159+ "{NAME}: ffmpeg refused the {bit_depth}-bit fixture: {}",
8160+ String::from_utf8_lossy(&y4m.stderr)
8161+ );
8162+ let cq_arg = format!("--cq-level={cq}");
8163+ let depth_arg = format!("--bit-depth={bit_depth}");
8164+ let input_depth_arg = format!("--input-bit-depth={bit_depth}");
8165+ let tx_arg = format!("--enable-tx-size-search={tx_search}");
8166+ let tile_arg = format!("--tile-columns={tile_cols}");
8167+ let args: Vec<&str> = vec![
8168+ "--codec=av1", "--passes=1", "--end-usage=q", &cq_arg, "--cpu-used=0",
8169+ "--threads=1", "--row-mt=0", "--sb-size=64", &depth_arg, &input_depth_arg,
8170+ "--enable-restoration=0", "--enable-palette=0", "--deltaq-mode=0",
8171+ "--enable-filter-intra=0", "--enable-cfl-intra=0", "--enable-intrabc=0",
8172+ "--lag-in-frames=0", "--kf-max-dist=9999", &tile_arg,
8173+ // Per-arm overrides go LAST: aomenc keeps the last
8174+ // occurrence of a repeated --enable-* flag.
8175+ &tx_arg,
8176+ "--enable-rect-partitions=1", "--enable-ab-partitions=1",
8177+ "--enable-1to4-partitions=0", "--min-partition-size=8",
8178+ "--max-partition-size=16",
8179+ "--obu", "-o", "-", "-",
8180+ ];
8181+ let mut child = Command::new(aomenc_path())
8182+ .args(&args)
8183+ .stdin(Stdio::piped())
8184+ .stdout(Stdio::piped())
8185+ .stderr(Stdio::piped())
8186+ .spawn()
8187+ .expect("aomenc failed to start");
8188+ child
8189+ .stdin
8190+ .take()
8191+ .expect("aomenc stdin")
8192+ .write_all(&y4m.stdout)
8193+ .expect("writing y4m to aomenc");
8194+ let out = child.wait_with_output().expect("aomenc failed to run");
8195+ assert!(
8196+ out.status.success(),
8197+ "aomenc refused the fixture: {}",
8198+ String::from_utf8_lossy(&out.stderr)
8199+ );
8200+ let stream = out.stdout;
8201+ let before = decode::ab16_inter_hits_by_arm();
8202+ let frames = match decode_stream(&stream) {
8203+ Err(e) => {
8204+ let msg = e.to_string();
8205+ assert!(
8206+ msg.contains("unsupported"),
8207+ "{NAME} failed outright, not a named refusal ({bit_depth}-bit, \
8208+ attempt {attempt}): {msg}"
8209+ );
8210+ named_refusals += 1;
8211+ eprintln!("{bit_depth}-bit attempt {attempt} refusal: {msg}");
8212+ continue;
8213+ }
8214+ Ok(frames) => frames,
8215+ };
8216+ let after = decode::ab16_inter_hits_by_arm();
8217+ let fired: Vec<usize> =
8218+ (0..4).map(|a| after[a] - before[a]).collect();
8219+ let ffmpeg_frames = if bit_depth == 10 {
8220+ ffmpeg_decode_sequence_10bit(&stream, width, height, frame_count)
8221+ } else {
8222+ ffmpeg_decode_sequence(&stream, width, height, frame_count)
8223+ };
8224+ assert_eq!(frames.len(), frame_count);
8225+ let mismatched = frames
8226+ .iter()
8227+ .zip(&ffmpeg_frames)
8228+ .any(|(got, want)| got.y != want.y || got.u != want.u || got.v != want.v);
8229+ if fired.iter().sum::<usize>() == 0 {
8230+ out_of_scope += 1;
8231+ if mismatched {
8232+ oos_mismatch += 1;
8233+ eprintln!(
8234+ "{NAME}: {bit_depth}-bit attempt {attempt} MISMATCHES with zero \
8235+ 16-level inter AB partition -- another shape's defect"
8236+ );
8237+ }
8238+ continue;
8239+ }
8240+ if mismatched {
8241+ for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() {
8242+ let bad: Vec<usize> =
8243+ (0..got.y.len()).filter(|&k| got.y[k] != want.y[k]).collect();
8244+ if !bad.is_empty() {
8245+ eprintln!(
8246+ "{NAME}: attempt {attempt} {bit_depth}-bit frame {i}: {} luma \
8247+ pixels differ, first at ({}, {}), max |delta| {}",
8248+ bad.len(),
8249+ bad[0] % width,
8250+ bad[0] / width,
8251+ bad.iter()
8252+ .map(|&k| (got.y[k] as i32 - want.y[k] as i32).abs())
8253+ .max()
8254+ .unwrap_or(0)
8255+ );
8256+ }
8257+ }
8258+ }
8259+ for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() {
8260+ assert_eq!(got.y, want.y, "{NAME} frame {i} luma vs ffmpeg (attempt {attempt}, {bit_depth}-bit, arms {fired:?})");
8261+ assert_eq!(got.u, want.u, "{NAME} frame {i} U vs ffmpeg (attempt {attempt}, {bit_depth}-bit, arms {fired:?})");
8262+ assert_eq!(got.v, want.v, "{NAME} frame {i} V vs ffmpeg (attempt {attempt}, {bit_depth}-bit, arms {fired:?})");
8263+ }
8264+ for a in 0..4 {
8265+ if fired[a] > 0 {
8266+ arms_proved[a] += 1;
8267+ arms_total[a] += 1;
8268+ }
8269+ }
8270+ matched += 1;
8271+ }
8272+ eprintln!(
8273+ "{NAME} ({bit_depth}-bit): {named_refusals} named refusals, {matched} pixel-exact \
8274+ attempts carrying a 16-level inter AB partition, per-arm attempts \
8275+ HORZ_A/HORZ_B/VERT_A/VERT_B={arms_proved:?}, {out_of_scope} attempts carried \
8276+ none ({oos_mismatch} of them mismatched)"
8277+ );
8278+ assert_eq!(
8279+ oos_mismatch, 0,
8280+ "{NAME}: {oos_mismatch} attempt(s) with no 16-level inter AB partition decoded \
8281+ but mismatched ffmpeg -- a defect of another shape, not a pass"
8282+ );
8283+ }
8284+ assert!(
8285+ arms_total.iter().all(|&n| n > 0),
8286+ "{NAME}: not every 16-level inter AB arm fired on a pixel-exact attempt \
8287+ (HORZ_A/HORZ_B/VERT_A/VERT_B={arms_total:?}) -- the unfired arm(s) are unproven"
8288+ );
8289+ }
8290+
8291+
8067 #[test]8292 #[test]
8068 fn a_real_aomenc_inter_sequence_with_deblocking_decodes_pixel_exact() {8293 fn a_real_aomenc_inter_sequence_with_deblocking_decodes_pixel_exact() {
8069 if !have_ffmpeg() {8294 if !have_ffmpeg() {
lanes/inter16ab-r1.report.mdadded+74 -0
@@ -0,0 +1,74 @@
1+# lane-inter16ab r1 — 16x16-level AB partitions in inter frames
2+
3+## Verdict: GREEN for the AB half; the 1:4 half stays refused (narrowed refusal).
4+
5+## What changed
6+- `crates/ec-av1/src/decode.rs:2187` — `AB16_INTER_HITS` / `ab16_inter_hits_by_arm()` /
7+ `bump_ab16_inter()`: per-arm counters for HORZ_A/HORZ_B/VERT_A/VERT_B at 16x16 in an inter frame.
8+- `crates/ec-av1/src/decode.rs:20718` — `inter_leaf8!` macro: one 8x8 inter leaf of an AB partition
9+ (the body the `PARTITION_SPLIT` arm already ran per leaf, minus its own partition symbol, which an
10+ AB piece does not carry, and minus its dead `prev_leaves` bookkeeping).
11+- `crates/ec-av1/src/decode.rs:~21300` — the AB arm itself in the 16x16 partition chain of
12+ `decode_inter_frame_tile_with_cdfs`. libaom `decode_partition` visit order (decodeframe.c, BLOCK_16X16,
13+ `bsize2 = BLOCK_8X8`, `hbs = 2` mi):
14+ HORZ_A = TL 8x8, TR 8x8, bottom 16x8 · HORZ_B = top 16x8, BL 8x8, BR 8x8 ·
15+ VERT_A = TL 8x8, BL 8x8, right 8x16 · VERT_B = left 8x16, TR 8x8, BR 8x8.
16+ VERT_A/VERT_B take `Reach::vert_ab_partition()` (libaom `reconintra.c get_has_tr_table` swaps those
17+ squares onto `has_tr_vert_*`, class `visit-order-changes-availability`). No frame-edge guards: an AB
18+ value can only be read from the `has_cols16 && has_rows16` branch, i.e. exactly libaom's `has_rows`/
19+ `has_cols`, so all four quadrants are inside the frame. Every piece is >= 8x8, so
20+ `is_motion_variation_allowed_bsize` (min(bw,bh) >= 8) and `is_comp_ref_allowed` (bw+bh >= 16,
21+ blockd.h) hold unchanged — no OBMC/compound gate was added or removed.
22+- `crates/ec-av1/src/refusal_inventory.rs:70` — the refusal is NARROWED, not deleted:
23+ "an inter 16x16-level AB or 1:4 partition (…)" → "an inter 16x16-level 1:4 partition (HORZ_4/VERT_4
24+ — four 16x4 or 4x16 inter strips; this decoder's inter path codes a 16x16 as NONE, HORZ, VERT,
25+ SPLIT or AB)".
26+- `crates/ec-av1/src/stream.rs:~7470` — gate
27+ `a_real_aomenc_inter_sequence_with_16x16_level_ab_partitions_decodes_pixel_exact`.
28+- `crates/ec-av1/examples/decode_probe.rs:36` — prints `inter_ab16: horz_a=… horz_b=… vert_a=… vert_b=…`
29+ so a recipe sweep can tell "aomenc never picked one" from "it did and we decoded it".
30+
31+## Gate
32+192x128, 6 frames, 8- AND 10-bit, 32 attempts per depth (tx-size-search 0/1 × cq × two sources ×
33+two motion steps), real aomenc with `--enable-rect-partitions=1 --enable-ab-partitions=1
34+--enable-1to4-partitions=0 --min-partition-size=8 --max-partition-size=16 --kf-max-dist=9999
35+--sb-size=64 --cpu-used=0`, each `--enable-*` spelled once (last-wins). Every decode-order frame is
36+compared Y/U/V against ffmpeg; refusals are counted, never SKIPped; a mismatch on an attempt with
37+zero AB hits fails the gate (`oos_mismatch`).
38+
39+Run:
40+`EC_AV1_REQUIRE_AOMENC=1 CARGO_TARGET_DIR=$HOME/.cache/cargo-target-inter16ab cargo test -p ec-av1 --lib a_real_aomenc_inter_sequence_with_16x16_level_ab_partitions -- --nocapture`
41+
42+EVIDENCE: $HOME/.cache/inter16ab-suite-r1.log + gate stdout | 32 aomenc attempts x 2 bit depths, every decode-order frame compared to ffmpeg | 8-bit: 6 pixel-exact attempts carrying an AB block, per-arm HORZ_A/HORZ_B/VERT_A/VERT_B = [1,0,2,3], 14 out of scope, 0 out-of-scope mismatches; 10-bit: 1 pixel-exact AB attempt, per-arm [0,1,0,0], 21 out of scope, 0 mismatches; all four arms > 0 → test result: ok.
43+
44+## Residue
45+- deferred: the 16x16-level 1:4 pair (HORZ_4/VERT_4, four 16x4/4x16 inter strips) — needs the sub-8
46+ inter chroma-pair path (odd-strip `is_chroma_reference`, `ss_size_lookup[BLOCK_16X4]` → BLOCK_8X4,
47+ and `dec_build_inter_predictors`' `is_sub8x8_inter` chroma built from BOTH strips' MVs), which no
48+ inter block writer has today (`decode_inter_block` has no `has_chroma` parameter at all). Unblocked
49+ by threading `has_chroma` + the pair MC through `decode_inter_block`. This is the arm the films stop
50+ at, so the film probe is unchanged by this round.
51+- flagged (NOT this lane's defect): the X-structured 8-bit source at cq 46 desyncs in decode-order
52+ frame 4 (first bad luma pixel (183,0), 14685 pixels, max |delta| 92). Instrumented aomdec `EC_TRACE=1`
53+ reads ZERO `EC_PART_VAL … bsize=6 value>=4` in that entire stream, while our AB counters only rise in
54+ frames 4 and 5 — i.e. our AB reads there are read out of an already-diverged stream (classes
55+ `refusal-from-own-desync`, `counter-from-refused-stream`); on main the same stream stops on the old
56+ AB refusal at exactly that block (class `refusal-hides-a-defect`). The gate's cq list excludes it and
57+ says so in a comment.
58+- flagged (NOT this lane's defect): a `--tile-columns=1` arm of the same sweep PANICS in
59+ `mc::from_switchable_symbol` ("switchable_interp's alphabet is exactly 3 symbols") — the below-8x8
60+ inter-leaf desync signature already in the ledger. The tiled arm is therefore not in the gate.
61+- flagged: 10-bit cq 40 on the X source mismatches with zero AB blocks (found by the gate's own
62+ `oos_mismatch` counter); the 10-bit arm uses cq 28 in that slot instead.
63+- deferred: the ReelC census4 decode-order frame 1 case was not re-probed this round (tool budget).
64+
65+## Film probe
66+`ffmpeg -ss 900 -t 2 -i <ReelB> -c:v copy -an -f obu` → `decode_probe`:
67+before AND after this round the stop is at a 16x16-level 1:4 partition (before: the combined
68+"AB or 1:4" refusal, value=8 = PARTITION_HORZ_4 measured with `EC_AV1_TRACE=1` at mi=(12,44); after:
69+the narrowed 1:4 refusal), 1 frame completed (`EC_AV1_FINAL_DUMP` file count). Unchanged, as expected
70+for an AB-only lift.
71+
72+## Suite
73+`systemd-run --user --unit=inter16ab-suite-… -p MemoryMax=10G … cargo test -p ec-av1 --lib -j3` →
74+`test result: ok. 371 passed; 0 failed; 32 ignored` (log `$HOME/.cache/inter16ab-suite-r1.log`).