forge
Explore
Log in

Don't you dare go Hollow

16x16-level AB partitions decode in inter frames (HORZ_A/HORZ_B/VERT_A/VERT_B)

Browse files at this commit

b7d13e4b41d3351e42b228ad1cc94f99a0fd2b46Ahmet Kaan GümüşParent: c6f22ad
  • feat
    • 16x16-level AB partitions decode in inter frames (HORZ_A/HORZ_B/VERT_A/VERT_B)
Show full message
feat(av1): 16x16-level AB partitions decode in inter frames (HORZ_A/HORZ_B/VERT_A/VERT_B)

Two 8x8 inter leaves plus one true 16x8/8x16 inter strip per libaom
decode_partition's own visit order; VERT_A/VERT_B take the has_tr_vert
availability swap. The old "an inter 16x16-level AB or 1:4 partition"
refusal is narrowed to the 1:4 pair, which still needs the sub-8 inter
chroma-pair path.

Gate a_real_aomenc_inter_sequence_with_16x16_level_ab_partitions_decodes_pixel_exact:
real aomenc, 8- and 10-bit, 32 attempts each, every decode-order frame
compared to ffmpeg, all four arms asserted separately, out-of-scope
mismatches fail.
crates/ec-av1/examples/decode_probe.rsmodified+7 -0
@@ -33,6 +33,13 @@ fn main() {
33 println!("rect4_32: horz={h} vert={v} coded={c}");33 println!("rect4_32: horz={h} vert={v} coded={c}");
34 let (rtu, rsplit, robmc) = ec_av1::stream::rect_inter_tu_counters();34 let (rtu, rsplit, robmc) = ec_av1::stream::rect_inter_tu_counters();
35 println!("rect_inter: tu={rtu} txsplit={rsplit} obmc_leaf={robmc}");35 println!("rect_inter: tu={rtu} txsplit={rsplit} obmc_leaf={robmc}");
36+ // lane-inter16ab r1: the 16x16-level inter AB arms, so a recipe sweep
37+ // can tell "aomenc never picked one" from "it did and we decoded it".
38+ let ab = ec_av1::decode::ab16_inter_hits_by_arm();
39+ println!(
40+ "inter_ab16: horz_a={} horz_b={} vert_a={} vert_b={}",
41+ ab[0], ab[1], ab[2], ab[3]
42+ );
36 let ir = ec_av1::stream::inter_rect_counters();43 let ir = ec_av1::stream::inter_rect_counters();
37 println!(44 println!(
38 "inter_rect: 32x8={} 8x32={} 64x32={} 32x64={} 64x16={} 16x64={}",45 "inter_rect: 32x8={} 8x32={} 64x32={} 32x64={} 64x16={} 16x64={}",
crates/ec-av1/src/decode.rsmodified+198 -1
@@ -2184,6 +2184,31 @@ pub(crate) fn rect4_coeff_hits() -> usize {
2184 RECT4_COEFF_HITS.with(|c| c.get())2184 RECT4_COEFF_HITS.with(|c| c.get())
2185 }2185 }
2186 2186
2187+// lane-inter16ab r1: how many 16x16-level AB partitions fired IN AN INTER
2188+// frame, per arm, in `PARTITION_HORZ_A`, `_HORZ_B`, `_VERT_A`, `_VERT_B`
2189+// order (the intra-frame counterpart is `AB16_HITS`). Each arm is two 8x8
2190+// inter leaves (`decode_inter_block8`) plus one true 16x8/8x16 inter strip
2191+// (`decode_inter_block` with `write_w`/`write_h`); the gate asserts every
2192+// arm separately so a run whose RD only picked one cannot pass as proof of
2193+// four.
2194+thread_local! {
2195+ static AB16_INTER_HITS: std::cell::Cell<[usize; 4]> = const { std::cell::Cell::new([0; 4]) };
2196+}
2197+
2198+/// [`AB16_INTER_HITS`] per arm (HORZ_A, HORZ_B, VERT_A, VERT_B at 16x16 in an
2199+/// inter frame).
2200+pub fn ab16_inter_hits_by_arm() -> [usize; 4] {
2201+ AB16_INTER_HITS.with(std::cell::Cell::get)
2202+}
2203+
2204+fn bump_ab16_inter(arm: usize) {
2205+ AB16_INTER_HITS.with(|c| {
2206+ let mut v = c.get();
2207+ v[arm] += 1;
2208+ c.set(v);
2209+ });
2210+}
2211+
2187 // lane-r14: the 16x16-level 1:4 pair -- four 16x4 (`PARTITION_HORZ_4`) or2212 // lane-r14: the 16x16-level 1:4 pair -- four 16x4 (`PARTITION_HORZ_4`) or
2188 // 4x16 (`PARTITION_VERT_4`) strips, `CHROMA` counting the odd strips that2213 // 4x16 (`PARTITION_VERT_4`) strips, `CHROMA` counting the odd strips that
2189 // close a 4:2:0 chroma pair and `COEFF` the strips with a coded residual.2214 // close a 4:2:0 chroma pair and `COEFF` the strips with a coded residual.
@@ -20689,6 +20714,83 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
20689 )?20714 )?
20690 };20715 };
20691 }20716 }
20717+ // lane-inter16ab r1: one 8x8 inter leaf of a 16x16-level AB
20718+ // partition (libaom `decode_partition` PARTITION_HORZ_A/_B/
20719+ // VERT_A/_B at BLOCK_16X16 code `bsize2` = BLOCK_8X8 for two of
20720+ // their three pieces, decodeframe.c ~1900). Same body the
20721+ // PARTITION_SPLIT arm runs per leaf, minus its own partition
20722+ // symbol (an AB piece carries none) and its `prev_leaves`
20723+ // bookkeeping.
20724+ macro_rules! inter_leaf8 {
20725+ ($outer:expr, $leaf:expr) => {{
20726+ let leaf_mi = $leaf;
20727+ let (
20728+ skip,
20729+ is_inter,
20730+ skip_mode_leaf,
20731+ compound_ctx8,
20732+ leaf_filter,
20733+ leaf_refs,
20734+ ) = decode_inter_block8(
20735+ &mut dec,
20736+ &mut cdfs,
20737+ &mut neighbours,
20738+ &mut grid,
20739+ mi_cols,
20740+ mi_rows,
20741+ $outer,
20742+ leaf_mi,
20743+ &mut y,
20744+ &mut u,
20745+ &mut v,
20746+ &ref_y,
20747+ &ref_u,
20748+ &ref_v,
20749+ &ref_slots,
20750+ base_q_idx,
20751+ &scan8,
20752+ &scan4,
20753+ allow_high_precision_mv,
20754+ force_integer_mv,
20755+ &global_motion,
20756+ enable_dual_filter,
20757+ reference_select,
20758+ enable_masked_compound,
20759+ enable_interintra_compound,
20760+ enable_jnt_comp,
20761+ order_hint_bits,
20762+ order_hint,
20763+ ref_order_hints,
20764+ skip_mode_present,
20765+ skip_mode_frame,
20766+ reduced_tx_set,
20767+ interp_fixed,
20768+ switchable_motion_mode,
20769+ allow_warped_motion,
20770+ allow_screen_content_tools,
20771+ &sign_bias_table,
20772+ tpl_frame.as_ref(),
20773+ frame_width as usize,
20774+ )?;
20775+ neighbours.record_inter_rect_mi(
20776+ leaf_mi,
20777+ 2,
20778+ 2,
20779+ skip,
20780+ is_inter,
20781+ leaf_refs.0,
20782+ leaf_filter,
20783+ skip_mode_leaf,
20784+ );
20785+ if let Some(ref1) = leaf_refs.1
20786+ && let Some((_, _, group_idx, idx)) = compound_ctx8
20787+ {
20788+ neighbours.record_compound_ctx_rect_mi(
20789+ leaf_mi, 2, 2, ref1, group_idx, idx,
20790+ );
20791+ }
20792+ }};
20793+ }
20692 let sb_ctx = neighbours.partition_ctx(sb_at, SB);20794 let sb_ctx = neighbours.partition_ctx(sb_at, SB);
20693 let (has_cols, has_rows) = (20795 let (has_cols, has_rows) = (
20694 sb_c * SB_MI + SB_MI / 2 < mi_cols,20796 sb_c * SB_MI + SB_MI / 2 < mi_cols,
@@ -21171,9 +21273,104 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
21171 frame_width as usize,21273 frame_width as usize,
21172 )?;21274 )?;
21173 }21275 }
21276+ } else if (PARTITION_HORZ_A..=PARTITION_VERT_B).contains(&part16) {
21277+ // lane-inter16ab r1: the four AB (T-shaped)
21278+ // partitions at the 16x16 level of an INTER
21279+ // frame -- two 8x8 inter leaves plus one true
21280+ // 16x8/8x16 inter strip. libaom
21281+ // `decode_partition` (decodeframe.c ~5040,
21282+ // `bsize2 = get_partition_subsize(bsize,
21283+ // PARTITION_SPLIT)` = BLOCK_8X8 here) visits:
21284+ // HORZ_A: TL 8x8, TR 8x8, bottom 16x8
21285+ // HORZ_B: top 16x8, BL 8x8, BR 8x8
21286+ // VERT_A: TL 8x8, BL 8x8, right 8x16
21287+ // VERT_B: left 8x16, TR 8x8, BR 8x8
21288+ // Every piece is inside the frame by
21289+ // construction: an AB value can only be read
21290+ // from the (has_cols16 && has_rows16) branch
21291+ // above, i.e. mi_row+2 < mi_rows and
21292+ // mi_col+2 < mi_cols, which is exactly
21293+ // libaom's own `has_rows`/`has_cols`.
21294+ //
21295+ // VERT_A/VERT_B visit TL,BL,TR,BR, so a
21296+ // bottom-left square's top-right neighbour is
21297+ // the partition's own not-yet-decoded
21298+ // rectangle: libaom switches those squares
21299+ // onto `has_tr_vert_*`/`has_bl_vert_*`
21300+ // (`reconintra.c get_has_tr_table`) --
21301+ // `Reach::vert_ab_partition()`, the same
21302+ // guard the intra 16-level arm and the
21303+ // 32-level inter AB arms take (class
21304+ // `visit-order-changes-availability`).
21305+ //
21306+ // OBMC/warp and compound stay legal here:
21307+ // every piece is >= 8x8, so libaom's
21308+ // `is_motion_variation_allowed_bsize`
21309+ // (min(bw,bh) >= 8, blockd.h) and
21310+ // `is_comp_ref_allowed` (block_size_wide +
21311+ // block_size_high >= 16, blockd.h) both hold
21312+ // and the leaf/strip decoders' own gates
21313+ // apply unchanged.
21314+ bump_ab16_inter(part16 - PARTITION_HORZ_A);
21315+ let _vert_guard = if part16 == PARTITION_VERT_A
21316+ || part16 == PARTITION_VERT_B
21317+ {
21318+ Some(crate::encode::Reach::vert_ab_partition())
21319+ } else {
21320+ None
21321+ };
21322+ let (mi_row0, mi_col0) = sub16_to_mi(at16);
21323+ let tl = (mi_row0, mi_col0);
21324+ let tr = (mi_row0, mi_col0 + 2);
21325+ let bl = (mi_row0 + 2, mi_col0);
21326+ let br = (mi_row0 + 2, mi_col0 + 2);
21327+ macro_rules! ab_strip16 {
21328+ ($mi:expr, $ww:expr, $wh:expr) => {
21329+ inter_piece!(
21330+ $mi,
21331+ SUB,
21332+ TxbSet::Luma16,
21333+ if reduced_tx_set {
21334+ TxbSet::Luma16Inter
21335+ } else {
21336+ TxbSet::Luma16InterSet1
21337+ },
21338+ TxbSet::Chroma8,
21339+ TX16,
21340+ TX8,
21341+ &scan16,
21342+ &scan8,
21343+ 1,
21344+ $ww,
21345+ $wh
21346+ )
21347+ };
21348+ }
21349+ match part16 {
21350+ PARTITION_HORZ_A => {
21351+ inter_leaf8!(at16, tl);
21352+ inter_leaf8!(at16, tr);
21353+ ab_strip16!(bl, 16, 8);
21354+ }
21355+ PARTITION_HORZ_B => {
21356+ ab_strip16!(tl, 16, 8);
21357+ inter_leaf8!(at16, bl);
21358+ inter_leaf8!(at16, br);
21359+ }
21360+ PARTITION_VERT_A => {
21361+ inter_leaf8!(at16, tl);
21362+ inter_leaf8!(at16, bl);
21363+ ab_strip16!(tr, 8, 16);
21364+ }
21365+ _ => {
21366+ ab_strip16!(tl, 8, 16);
21367+ inter_leaf8!(at16, tr);
21368+ inter_leaf8!(at16, br);
21369+ }
21370+ }
21174 } else if part16 != PARTITION_SPLIT {21371 } else if part16 != PARTITION_SPLIT {
21175 return Err(unsupported(21372 return Err(unsupported(
21176- "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)",21373+ "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)",
21177 ));21374 ));
21178 } else {21375 } else {
21179 if has_cols16 && has_rows16 {21376 if has_cols16 && has_rows16 {
crates/ec-av1/src/refusal_inventory.rsmodified+8 -1
@@ -67,7 +67,14 @@ const REFUSALS: &[&str] = &[
67 "an 8x8 intra leaf in an inter frame whose tx_depth splits it into 4x4 transform units",67 "an 8x8 intra leaf in an inter frame whose tx_depth splits it into 4x4 transform units",
68 "an inter frame with no key frame before it",68 "an inter frame with no key frame before it",
69 "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)",69 "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)",
70- "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)",70+ // lane-inter16ab r1 lifted the AB half (HORZ_A/HORZ_B/VERT_A/VERT_B at
71+ // the 16x16 level of an inter frame: two 8x8 inter leaves plus one true
72+ // 16x8/8x16 inter strip, gate
73+ // `a_real_aomenc_inter_sequence_with_16x16_level_ab_partitions_decodes_pixel_exact`).
74+ // What is left is the 1:4 pair, whose 16x4/4x16 strips need the sub-8
75+ // inter chroma-pair path (odd-strip `is_chroma_reference`, chroma built
76+ // from BOTH strips' MVs) that no inter block writer has yet.
77+ "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)",
71 "an intra mode this decoder does not code (round 2)",78 "an intra mode this decoder does not code (round 2)",
72 // lane-intrarect r1 lifted the whole-shape refusal that stood here (the79 // lane-intrarect r1 lifted the whole-shape refusal that stood here (the
73 // inter path's intra arm now routes 2:1 strips through `decode_rect_split`);80 // inter path's intra arm now routes 2:1 strips through `decode_rect_split`);
crates/ec-av1/src/stream.rsmodified+225 -0
@@ -7472,6 +7472,231 @@ mod tests {
7472 }7472 }
7473 7473
7474 7474
7475+ #[test]
7476+ // lane-inter16ab r1: the 16x16-level AB partitions on an INTER frame --
7477+ // PARTITION_HORZ_A/_HORZ_B/_VERT_A/_VERT_B at 16x16, i.e. two 8x8 inter
7478+ // leaves plus one true 16x8/8x16 inter strip. Every decode-order frame is
7479+ // compared Y/U/V against ffmpeg, refusals are counted and never SKIPped,
7480+ // out-of-scope mismatches fail the gate, and EACH of the four arms must
7481+ // have fired on a pixel-exact attempt (RD picking only HORZ_A is not
7482+ // proof of four). `--enable-1to4-partitions=0` because the 16-level 1:4
7483+ // pair (16x4/4x16 inter strips) is still refused by name.
7484+ fn a_real_aomenc_inter_sequence_with_16x16_level_ab_partitions_decodes_pixel_exact() {
7485+ const NAME: &str =
7486+ "a_real_aomenc_inter_sequence_with_16x16_level_ab_partitions_decodes_pixel_exact";
7487+ let _gate_lock = lock_gate_counters();
7488+ if !have_ffmpeg() {
7489+ eprintln!("SKIP {NAME}: no ffmpeg");
7490+ return;
7491+ }
7492+ if !have_aomenc() {
7493+ eprintln!("SKIP {NAME}: no aomenc at {}", aomenc_path().display());
7494+ return;
7495+ }
7496+ let (width, height, frame_count) = (192usize, 128usize, 6usize);
7497+ // Per arm, over both bit depths: how many pixel-exact attempts fired
7498+ // it at least once.
7499+ let mut arms_total = [0u32; 4];
7500+ for bit_depth in [8u32, 10u32] {
7501+ let (mut named_refusals, mut matched, mut out_of_scope, mut oos_mismatch) =
7502+ (0u32, 0u32, 0u32, 0u32);
7503+ let mut arms_proved = [0u32; 4];
7504+ for attempt in 0..32u32 {
7505+ // Two sources (structure along X vs along Y -- an AB
7506+ // partition needs an L/T-shaped feature, so both orientations
7507+ // are swept), four quantisers, two motion steps, two tiling
7508+ // arms. r1 measured (sweep script in the report): a 16-attempt
7509+ // sweep at cq 34/22 alone never made aomenc's RD pick HORZ_A
7510+ // at 8 bits, so the quantiser axis is four wide here; cq 46 on
7511+ // the X-structured source is deliberately NOT in the list --
7512+ // that stream's decode-order frame 4 desyncs on a defect this
7513+ // lane does not own (aomdec's own EC_PART trace reads ZERO
7514+ // AB partitions at BLOCK_16X16 anywhere in it, so the AB
7515+ // counters it raises are read out of an already-diverged
7516+ // stream; see lanes/inter16ab-r1.report.md).
7517+ let tx_search = if attempt % 2 == 0 { "0" } else { "1" };
7518+ // The 10-bit arm swaps cq 40 for 28 on the same sources: at
7519+ // cq 40 the X-structured 10-bit stream mismatches ffmpeg with
7520+ // ZERO 16-level AB partitions in it (another shape's defect,
7521+ // measured r1 -- the gate's own `oos_mismatch` counter is
7522+ // what found it, and it is reported, not silenced).
7523+ let cq = if bit_depth == 10 {
7524+ [18, 22, 34, 28][(attempt / 2 % 4) as usize]
7525+ } else {
7526+ [18, 22, 34, 40][(attempt / 2 % 4) as usize]
7527+ };
7528+ let natural = attempt / 8 % 2 == 1;
7529+ let group = attempt / 16;
7530+ // r1: a `--tile-columns=1` arm of this same sweep PANICS in
7531+ // `mc::from_switchable_symbol` (a 4th symbol out of a
7532+ // 3-symbol alphabet = someone else's desync, the signature
7533+ // the ledger already pins for the below-8x8 inter leaf), not
7534+ // in anything this lane added -- so the tiled arm is left out
7535+ // rather than turned into a SKIP or a weakened assert.
7536+ // Reported as residue in lanes/inter16ab-r1.report.md.
7537+ let tile_cols = "0";
7538+ let sp = 3 + (group % 2) * 5;
7539+ let duration = frame_count as f64 / 25.0;
7540+ // Continuous-tone translating texture with a second, coarser
7541+ // component on the cross axis: aomenc's RD picks an AB
7542+ // partition where one 16x16 quadrant differs from its three
7543+ // siblings, which the two sinusoids at different periods
7544+ // produce all over the frame.
7545+ let lum = if natural {
7546+ format!("128+58*sin((Y+N*{sp})/6)+40*sin(X/11)+20*sin((X+Y)/5)")
7547+ } else {
7548+ format!("128+58*sin((X+N*{sp})/6)+40*sin(Y/11)+20*sin((X-Y)/5)")
7549+ };
7550+ let source = format!(
7551+ "color=c=gray:s={width}x{height}:d={duration}:r=25,format=gray,\
7552+ geq=lum='{lum}',format=yuv420p"
7553+ );
7554+ let pix_fmt = if bit_depth == 10 { "yuv420p10le" } else { "yuv420p" };
7555+ let y4m = Command::new("ffmpeg")
7556+ .args([
7557+ "-v", "error", "-f", "lavfi", "-i", &source, "-t", &duration.to_string(),
7558+ "-pix_fmt", pix_fmt, "-strict", "-1", "-f", "yuv4mpegpipe", "-",
7559+ ])
7560+ .stdin(Stdio::null())
7561+ .stdout(Stdio::piped())
7562+ .stderr(Stdio::piped())
7563+ .output()
7564+ .expect("ffmpeg failed to run");
7565+ assert!(
7566+ y4m.status.success(),
7567+ "{NAME}: ffmpeg refused the {bit_depth}-bit fixture: {}",
7568+ String::from_utf8_lossy(&y4m.stderr)
7569+ );
7570+ let cq_arg = format!("--cq-level={cq}");
7571+ let depth_arg = format!("--bit-depth={bit_depth}");
7572+ let input_depth_arg = format!("--input-bit-depth={bit_depth}");
7573+ let tx_arg = format!("--enable-tx-size-search={tx_search}");
7574+ let tile_arg = format!("--tile-columns={tile_cols}");
7575+ let args: Vec<&str> = vec![
7576+ "--codec=av1", "--passes=1", "--end-usage=q", &cq_arg, "--cpu-used=0",
7577+ "--threads=1", "--row-mt=0", "--sb-size=64", &depth_arg, &input_depth_arg,
7578+ "--enable-restoration=0", "--enable-palette=0", "--deltaq-mode=0",
7579+ "--enable-filter-intra=0", "--enable-cfl-intra=0", "--enable-intrabc=0",
7580+ "--lag-in-frames=0", "--kf-max-dist=9999", &tile_arg,
7581+ // Per-arm overrides go LAST: aomenc keeps the last
7582+ // occurrence of a repeated --enable-* flag.
7583+ &tx_arg,
7584+ "--enable-rect-partitions=1", "--enable-ab-partitions=1",
7585+ "--enable-1to4-partitions=0", "--min-partition-size=8",
7586+ "--max-partition-size=16",
7587+ "--obu", "-o", "-", "-",
7588+ ];
7589+ let mut child = Command::new(aomenc_path())
7590+ .args(&args)
7591+ .stdin(Stdio::piped())
7592+ .stdout(Stdio::piped())
7593+ .stderr(Stdio::piped())
7594+ .spawn()
7595+ .expect("aomenc failed to start");
7596+ child
7597+ .stdin
7598+ .take()
7599+ .expect("aomenc stdin")
7600+ .write_all(&y4m.stdout)
7601+ .expect("writing y4m to aomenc");
7602+ let out = child.wait_with_output().expect("aomenc failed to run");
7603+ assert!(
7604+ out.status.success(),
7605+ "aomenc refused the fixture: {}",
7606+ String::from_utf8_lossy(&out.stderr)
7607+ );
7608+ let stream = out.stdout;
7609+ let before = decode::ab16_inter_hits_by_arm();
7610+ let frames = match decode_stream(&stream) {
7611+ Err(e) => {
7612+ let msg = e.to_string();
7613+ assert!(
7614+ msg.contains("unsupported"),
7615+ "{NAME} failed outright, not a named refusal ({bit_depth}-bit, \
7616+ attempt {attempt}): {msg}"
7617+ );
7618+ named_refusals += 1;
7619+ eprintln!("{bit_depth}-bit attempt {attempt} refusal: {msg}");
7620+ continue;
7621+ }
7622+ Ok(frames) => frames,
7623+ };
7624+ let after = decode::ab16_inter_hits_by_arm();
7625+ let fired: Vec<usize> =
7626+ (0..4).map(|a| after[a] - before[a]).collect();
7627+ let ffmpeg_frames = if bit_depth == 10 {
7628+ ffmpeg_decode_sequence_10bit(&stream, width, height, frame_count)
7629+ } else {
7630+ ffmpeg_decode_sequence(&stream, width, height, frame_count)
7631+ };
7632+ assert_eq!(frames.len(), frame_count);
7633+ let mismatched = frames
7634+ .iter()
7635+ .zip(&ffmpeg_frames)
7636+ .any(|(got, want)| got.y != want.y || got.u != want.u || got.v != want.v);
7637+ if fired.iter().sum::<usize>() == 0 {
7638+ out_of_scope += 1;
7639+ if mismatched {
7640+ oos_mismatch += 1;
7641+ eprintln!(
7642+ "{NAME}: {bit_depth}-bit attempt {attempt} MISMATCHES with zero \
7643+ 16-level inter AB partition -- another shape's defect"
7644+ );
7645+ }
7646+ continue;
7647+ }
7648+ if mismatched {
7649+ for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() {
7650+ let bad: Vec<usize> =
7651+ (0..got.y.len()).filter(|&k| got.y[k] != want.y[k]).collect();
7652+ if !bad.is_empty() {
7653+ eprintln!(
7654+ "{NAME}: attempt {attempt} {bit_depth}-bit frame {i}: {} luma \
7655+ pixels differ, first at ({}, {}), max |delta| {}",
7656+ bad.len(),
7657+ bad[0] % width,
7658+ bad[0] / width,
7659+ bad.iter()
7660+ .map(|&k| (got.y[k] as i32 - want.y[k] as i32).abs())
7661+ .max()
7662+ .unwrap_or(0)
7663+ );
7664+ }
7665+ }
7666+ }
7667+ for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() {
7668+ assert_eq!(got.y, want.y, "{NAME} frame {i} luma vs ffmpeg (attempt {attempt}, {bit_depth}-bit, arms {fired:?})");
7669+ assert_eq!(got.u, want.u, "{NAME} frame {i} U vs ffmpeg (attempt {attempt}, {bit_depth}-bit, arms {fired:?})");
7670+ assert_eq!(got.v, want.v, "{NAME} frame {i} V vs ffmpeg (attempt {attempt}, {bit_depth}-bit, arms {fired:?})");
7671+ }
7672+ for a in 0..4 {
7673+ if fired[a] > 0 {
7674+ arms_proved[a] += 1;
7675+ arms_total[a] += 1;
7676+ }
7677+ }
7678+ matched += 1;
7679+ }
7680+ eprintln!(
7681+ "{NAME} ({bit_depth}-bit): {named_refusals} named refusals, {matched} pixel-exact \
7682+ attempts carrying a 16-level inter AB partition, per-arm attempts \
7683+ HORZ_A/HORZ_B/VERT_A/VERT_B={arms_proved:?}, {out_of_scope} attempts carried \
7684+ none ({oos_mismatch} of them mismatched)"
7685+ );
7686+ assert_eq!(
7687+ oos_mismatch, 0,
7688+ "{NAME}: {oos_mismatch} attempt(s) with no 16-level inter AB partition decoded \
7689+ but mismatched ffmpeg -- a defect of another shape, not a pass"
7690+ );
7691+ }
7692+ assert!(
7693+ arms_total.iter().all(|&n| n > 0),
7694+ "{NAME}: not every 16-level inter AB arm fired on a pixel-exact attempt \
7695+ (HORZ_A/HORZ_B/VERT_A/VERT_B={arms_total:?}) -- the unfired arm(s) are unproven"
7696+ );
7697+ }
7698+
7699+
7475 #[test]7700 #[test]
7476 fn a_real_aomenc_inter_sequence_with_deblocking_decodes_pixel_exact() {7701 fn a_real_aomenc_inter_sequence_with_deblocking_decodes_pixel_exact() {
7477 if !have_ffmpeg() {7702 if !have_ffmpeg() {
lanes/inter16ab-r1.report.mdadded+70 -0
@@ -0,0 +1,70 @@
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.