forge
Explore
Log in

Don't you dare go Hollow

16x16-level 1:4 partitions decode in inter frames -- four 16x4/4x16 strips, chroma coded once per pair from BOTH strips' motion (gate RED on one attempt)

Browse files at this commit

9f8067cc7d272197460574acc42dde5d4c58dc19Ahmet Kaan GümüşParent: 2a91568
  • feat
    • 16x16-level 1:4 partitions decode in inter frames -- four 16x4/4x16 strips, chroma coded once per pair from BOTH strips' motion (gate RED on one attempt)
Show full message
feat(av1): 16x16-level 1:4 partitions decode in inter frames -- four 16x4/4x16 strips, chroma coded once per pair from BOTH strips' motion (gate RED on one attempt)

The 16-level PARTITION_HORZ_4/VERT_4 arm of the inter partition chain, with
the three things that are new at this size:

  * is_chroma_reference (av1_common_int.h:1454): a 4:2:0 block one mi tall
    (wide) carries chroma only on an ODD mi_row (mi_col), so strips 0 and 2
    read and reconstruct no chroma at all and the odd strip codes one 8x4
    (4x8) transform at the PAIR's origin.
  * build_inter_predictors_sub8x8 (reconinter_template.inc:87-160): that
    chroma block covers two luma blocks, so it is built in 8x2 (2x8) pieces,
    each from its own strip's mv/ref/interp filters -- and only when
    is_sub8x8_inter holds (both strips single-ref inter), else the whole
    block falls back to this strip's mv.
  * min(bw,bh) == 4 kills skip_mode, comp_mode (is_comp_ref_allowed,
    blockd.h:65), motion_mode/OBMC/warp (is_motion_variation_allowed_bsize,
    blockd.h:1455) and interintra: none of those symbols is read now.

Tables: TX_16X4/TX_4X16 luma through the new TxbSet::LumaRect16x4Inter{,1}
(Luma8 coefficient tables, eob_pt_64, INTER tx_type at txsize_sqr_map =
TX_4X4 -> EXT_TX_SET_ALL16 / DCT_IDTX per blockd.h:1097-1106) and
SCAN_16X4/SCAN_4X16; chroma through the existing ChromaRect8x4.

The 2160p 10-bit AV1 film this lane tracks now decodes past the 1:4 partition
and stops one refusal deeper, at a SPLIT transform on a 16x4 strip
(sub_tx_size_map[TX_16X4] is the rectangular TX_8X4, which the square vartx
leaf list cannot express).

Gate a_real_aomenc_inter_sequence_with_16x16_level_1to4_partitions_decodes_
pixel_exact is committed FAILING: attempt 5 (8-bit, cq 34) fires 8 strips /
4 chroma pairs / 4 two-mv chroma pairs and desyncs in its last frame (8683
luma px, first at (96,59)). Frames 0-4 exact. See lanes/inter16ab-r2.report.md
-- this branch does not merge until that is closed.
crates/ec-av1/examples/decode_probe.rsmodified+2 -0
@@ -40,6 +40,8 @@ fn main() {
4040 "inter_ab16: horz_a={} horz_b={} vert_a={} vert_b={}",
4141 ab[0], ab[1], ab[2], ab[3]
4242 );
43+ let (h4, v4, pairs, sub8) = ec_av1::decode::inter16_rect4_counters();
44+ println!("inter16_1to4: horz4={h4} vert4={v4} chroma_pairs={pairs} sub8_pieces={sub8}");
4345 let ir = ec_av1::stream::inter_rect_counters();
4446 println!(
4547 "inter_rect: 32x8={} 8x32={} 64x32={} 32x64={} 64x16={} 16x64={}",
crates/ec-av1/src/cdf_state.rsmodified+37 -0
@@ -230,6 +230,19 @@ pub(crate) enum TxbSet {
230230 /// counterpart: `EXT_TX_SET_DTT4_IDTX_1DDCT`, the seven-symbol `TX_4X4`
231231 /// row [`LumaRect4x8Set1`](TxbSet::LumaRect4x8Set1) reads.
232232 LumaRect16x4Set1,
233+ /// [`LumaRect16x4`](TxbSet::LumaRect16x4)'s INTER counterpart
234+ /// (lane-inter16ab r2): the same `Luma8` coefficient tables (64 coded
235+ /// positions, `get_txsize_entropy_ctx(TX_16X4)` = TX_8X8), with the
236+ /// INTER `tx_type` table at `txsize_sqr_map[TX_16X4]` = TX_4X4.
237+ /// `av1_get_ext_tx_set_type` (av1/common/idct.c): `tx_size_sqr_up` is
238+ /// TX_16X16 (not > TX_32X32) and `use_reduced_set` picks
239+ /// `EXT_TX_SET_DCT_IDTX` -- three symbols, `inter_tx_type_4`.
240+ LumaRect16x4Inter,
241+ /// [`LumaRect16x4Inter`](TxbSet::LumaRect16x4Inter)'s
242+ /// `reduced_tx_set: false` counterpart: `tx_size_sqr` is TX_4X4, not
243+ /// TX_16X16, so `av1_get_ext_tx_set_type` returns `EXT_TX_SET_ALL16` --
244+ /// sixteen symbols, `inter_tx_type_4_set1`.
245+ LumaRect16x4Inter1,
233246 }
234247
235248 /// The tables one transform block is coded with, borrowed from the state for
@@ -1851,6 +1864,30 @@ impl Cdfs {
18511864 tx_type: Some(self.intra_tx_type_4_set1[mode].as_mut_slice()),
18521865 eob_pt_class1: Some(&mut self.eob_pt_64_luma_class1),
18531866 },
1867+ TxbSet::LumaRect16x4Inter => TxbTables {
1868+ side: 8,
1869+ txb_skip: &mut self.txb_skip_luma_8,
1870+ eob_pt: &mut self.eob_pt_64_luma,
1871+ eob_extra: &mut self.eob_extra_luma_8,
1872+ base: &mut self.base_luma_8,
1873+ base_eob: &mut self.base_eob_luma_8,
1874+ br: &mut self.br_luma_8,
1875+ dc_sign: &mut self.dc_sign_luma,
1876+ tx_type: Some(self.inter_tx_type_4.as_mut_slice()),
1877+ eob_pt_class1: Some(&mut self.eob_pt_64_luma_class1),
1878+ },
1879+ TxbSet::LumaRect16x4Inter1 => TxbTables {
1880+ side: 8,
1881+ txb_skip: &mut self.txb_skip_luma_8,
1882+ eob_pt: &mut self.eob_pt_64_luma,
1883+ eob_extra: &mut self.eob_extra_luma_8,
1884+ base: &mut self.base_luma_8,
1885+ base_eob: &mut self.base_eob_luma_8,
1886+ br: &mut self.br_luma_8,
1887+ dc_sign: &mut self.dc_sign_luma,
1888+ tx_type: Some(self.inter_tx_type_4_set1.as_mut_slice()),
1889+ eob_pt_class1: Some(&mut self.eob_pt_64_luma_class1),
1890+ },
18541891 TxbSet::LumaRect16x8Inter => TxbTables {
18551892 side: 16,
18561893 txb_skip: &mut self.txb_skip_luma_16,
crates/ec-av1/src/decode.rsmodified+335 -26
@@ -2201,6 +2201,64 @@ pub fn ab16_inter_hits_by_arm() -> [usize; 4] {
22012201 AB16_INTER_HITS.with(std::cell::Cell::get)
22022202 }
22032203
2204+// lane-inter16ab r2: the 16x16-level 1:4 pair as INTER blocks -- four 16x4
2205+// (`PARTITION_HORZ_4`) or 4x16 (`PARTITION_VERT_4`) strips. `CHROMA_PAIRS`
2206+// counts the odd strips that close a 4:2:0 chroma pair
2207+// (`is_chroma_reference`, av1_common_int.h:1454: bh == 1 mi => odd mi_row),
2208+// `SUB8_PIECES` the pair chroma blocks whose TOP (LEFT) half was built from
2209+// the PREVIOUS strip's own mv/ref/filters -- libaom
2210+// `build_inter_predictors_sub8x8` (reconinter_template.inc:87-160), reached
2211+// through `is_sub8x8_inter` (same file, :54).
2212+thread_local! {
2213+ static INTER16_HORZ4_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
2214+ static INTER16_VERT4_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
2215+ static INTER16_CHROMA_PAIR_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
2216+ static INTER16_SUB8_PIECE_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
2217+}
2218+
2219+/// Current values of the inter 16x16-level 1:4 counters: `(16x4 strips, 4x16
2220+/// strips, chroma pairs closed, chroma pairs built from two different
2221+/// strips' motion vectors)`.
2222+pub fn inter16_rect4_counters() -> (usize, usize, usize, usize) {
2223+ (
2224+ INTER16_HORZ4_HITS.with(std::cell::Cell::get),
2225+ INTER16_VERT4_HITS.with(std::cell::Cell::get),
2226+ INTER16_CHROMA_PAIR_HITS.with(std::cell::Cell::get),
2227+ INTER16_SUB8_PIECE_HITS.with(std::cell::Cell::get),
2228+ )
2229+}
2230+
2231+/// One 16x4 / 4x16 inter strip's chroma situation, handed to
2232+/// [`decode_inter_block`] out of band (the same one-shot thread-local idiom
2233+/// `REDUCED_TX_SET_INTER` uses) rather than through twenty-three call sites
2234+/// that all mean "an ordinary block, chroma of its own".
2235+#[derive(Clone, Copy)]
2236+struct InterStripChroma {
2237+ /// `is_chroma_reference` for this strip: false on strips 0 and 2, which
2238+ /// read and reconstruct NO chroma at all.
2239+ has_chroma: bool,
2240+ /// `PARTITION_HORZ_4` (16x4 strips) rather than `PARTITION_VERT_4`.
2241+ horz: bool,
2242+ /// The mi position of the EVEN strip of this pair -- `setup_pred_plane`'s
2243+ /// `if (ss_y && (mi_row & 1) && mi_size_high[bsize] == 1) mi_row -= 1`,
2244+ /// i.e. the origin of the 8x4 (4x8) chroma transform.
2245+ pair_mi: (usize, usize),
2246+ /// The previous (even) strip's single-reference MC parameters, `None`
2247+ /// when it was intra or compound -- `is_sub8x8_inter` then returns false
2248+ /// and the whole chroma block is predicted from THIS strip's mv.
2249+ prev: Option<(i8, (i32, i32), mc::InterpFilterKind, mc::InterpFilterKind)>,
2250+}
2251+
2252+thread_local! {
2253+ static INTER_STRIP_CHROMA: std::cell::Cell<Option<InterStripChroma>> =
2254+ const { std::cell::Cell::new(None) };
2255+ /// The single-reference MC parameters of the inter block that decoded
2256+ /// last -- read by the next 1:4 strip to build its pair's chroma.
2257+ static INTER_LAST_MC: std::cell::Cell<
2258+ Option<(i8, (i32, i32), mc::InterpFilterKind, mc::InterpFilterKind)>,
2259+ > = const { std::cell::Cell::new(None) };
2260+}
2261+
22042262 fn bump_ab16_inter(arm: usize) {
22052263 AB16_INTER_HITS.with(|c| {
22062264 let mut v = c.get();
@@ -11455,6 +11513,10 @@ fn rect_inter_residual_supported(w: usize, h: usize) -> bool {
1145511513 (w, h),
1145611514 // 2:1 strips whose transform is coded in full (lane-inter4).
1145711515 (32, 16) | (16, 32) | (16, 8) | (8, 16)
11516+ // lane-inter16ab r2: the 16x16-level 1:4 strips. TX_16X4/TX_4X16
11517+ // codes all 64 of its positions, and its chroma pair is an 8x4 /
11518+ // 4x8 unit (`ss_size_lookup[BLOCK_16X4]` = BLOCK_8X4).
11519+ | (16, 4) | (4, 16)
1145811520 // lane-r14 r2: strips with a 64-px axis. `av1_get_max_eob` codes
1145911521 // only the low 32 coefficients of a 64-length axis, so these read
1146011522 // exactly the truncated corner the INTRA superblock-strip path
@@ -11477,6 +11539,13 @@ fn rect_inter_residual_supported(w: usize, h: usize) -> bool {
1147711539 fn rect_inter_luma_set(w: usize, h: usize) -> TxbSet {
1147811540 match (w, h) {
1147911541 (32, 16) | (16, 32) => TxbSet::LumaRect32x16Inter,
11542+ (16, 4) | (4, 16) => {
11543+ if REDUCED_TX_SET_INTER.with(std::cell::Cell::get) {
11544+ TxbSet::LumaRect16x4Inter
11545+ } else {
11546+ TxbSet::LumaRect16x4Inter1
11547+ }
11548+ }
1148011549 (16, 8) | (8, 16) => {
1148111550 if REDUCED_TX_SET_INTER.with(std::cell::Cell::get) {
1148211551 TxbSet::LumaRect16x8Inter
@@ -11553,6 +11622,8 @@ fn rect_scan(w: usize, h: usize) -> &'static [u16] {
1155311622 (16, 32) => &SCAN_16X32,
1155411623 (16, 8) => &SCAN_16X8,
1155511624 (8, 16) => &SCAN_8X16,
11625+ (16, 4) => &SCAN_16X4,
11626+ (4, 16) => &SCAN_4X16,
1155611627 (8, 4) => &SCAN_8X4,
1155711628 (4, 8) => &SCAN_4X8,
1155811629 (32, 8) => &SCAN_32X8,
@@ -11633,6 +11704,14 @@ fn read_block_tx_size_rect(
1163311704 "a split transform on a 1:4 inter strip with a 64-px axis",
1163411705 ));
1163511706 }
11707+ // lane-inter16ab r2: same shape one size class down --
11708+ // `sub_tx_size_map[TX_16X4]` is TX_8X4, still rectangular, so the square
11709+ // recursion below would code the wrong tree.
11710+ if tx_w.max(tx_h) == 16 && tx_w.min(tx_h) == 4 {
11711+ return Err(unsupported(
11712+ "a split transform on a 16x16-level 1:4 inter strip (sub_tx_size_map[TX_16X4] is the rectangular TX_8X4)",
11713+ ));
11714+ }
1163611715 let sub = tx_w.min(tx_h);
1163711716 let max_w_mi = (bw / MI).min(mi_cols.saturating_sub(at_mi.1));
1163811717 let max_h_mi = (bh / MI).min(mi_rows.saturating_sub(at_mi.0));
@@ -16100,9 +16179,27 @@ fn decode_inter_block(
1610016179 // exactly what it read before.
1610116180 let (rmi, cmi) = at;
1610216181 let (px, py) = (at.1 * MI, at.0 * MI);
16103- let (cpx, cpy) = (px / 2, py / 2);
16182+ // lane-inter16ab r2: a 16x4 / 4x16 inter strip's chroma is the PAIR's
16183+ // (8x4 / 4x8 at the even strip's origin) and is coded only by the odd
16184+ // strip (`is_chroma_reference`); every other block keeps its own.
16185+ let strip_chroma = INTER_STRIP_CHROMA.with(std::cell::Cell::take);
16186+ INTER_LAST_MC.with(|c| c.set(None));
16187+ let has_chroma = strip_chroma.is_none_or(|s| s.has_chroma);
16188+ let (cpx, cpy) = match strip_chroma {
16189+ Some(s) if s.has_chroma => (s.pair_mi.1 * MI / 2, s.pair_mi.0 * MI / 2),
16190+ _ => (px / 2, py / 2),
16191+ };
1610416192 let chroma_side = side / 2;
16105- let (write_chroma_w, write_chroma_h) = (write_w / 2, write_h / 2);
16193+ let (write_chroma_w, write_chroma_h) = match strip_chroma {
16194+ Some(s) if s.has_chroma => {
16195+ if s.horz {
16196+ (8, 4)
16197+ } else {
16198+ (4, 8)
16199+ }
16200+ }
16201+ _ => (write_w / 2, write_h / 2),
16202+ };
1610616203
1610716204 if std::env::var_os("EC_AV1_TELL").is_some() {
1610816205 eprintln!(
@@ -16126,7 +16223,12 @@ fn decode_inter_block(
1612616223 let (seg_mi_r, seg_mi_c) = (rmi, cmi);
1612716224 let (seg_w_mi, seg_h_mi) = (write_w / 4, write_h / 4);
1612816225 inter_segment_id(dec, cdfs, seg_mi_r, seg_mi_c, seg_w_mi, seg_h_mi, false, true);
16129- let skip_mode = skip_mode_present && dec.symbol(&mut cdfs.skip_mode[skip_mode_ctx]) == 1;
16226+ // libaom `read_skip_mode` (decodemv.c): `if (!is_comp_ref_allowed(bsize))
16227+ // return 0` -- a 16x4 / 4x16 strip (min(bw, bh) == 4, blockd.h:65) reads
16228+ // no `skip_mode` symbol at all.
16229+ let comp_allowed = write_w.min(write_h) >= 8;
16230+ let skip_mode =
16231+ skip_mode_present && comp_allowed && dec.symbol(&mut cdfs.skip_mode[skip_mode_ctx]) == 1;
1613016232 if std::env::var_os("EC_AV1_SKIPMODE_DUMP").is_some() {
1613116233 eprintln!(
1613216234 "EC_SKIPMODE r={r} c={c} result={skip_mode} tell_after={}",
@@ -16238,7 +16340,12 @@ fn decode_inter_block(
1623816340 );
1623916341 }
1624016342 let is_compound =
16241- skip_mode || (reference_select && read_comp_mode(dec, cdfs, above_nbr, left_nbr));
16343+ skip_mode
16344+ || (reference_select
16345+ // `is_comp_ref_allowed` (blockd.h:65) gates the
16346+ // `comp_mode` read exactly as it gates `skip_mode`.
16347+ && comp_allowed
16348+ && read_comp_mode(dec, cdfs, above_nbr, left_nbr));
1624216349 if is_compound {
1624316350 let (ref0, ref1) = if skip_mode {
1624416351 (skip_mode_frame[0] as i8, skip_mode_frame[1] as i8)
@@ -17495,6 +17602,9 @@ fn decode_inter_block(
1749517602 // motion_mode symbol is NOT read (SIMPLE_TRANSLATION implied).
1749617603 let motion_mode_eligible = switchable_motion_mode
1749717604 && !skip_mode
17605+ // `is_motion_variation_allowed_bsize` (blockd.h:1455):
17606+ // min(bw, bh) >= 8, false for a 16x4 / 4x16 strip.
17607+ && write_w.min(write_h) >= 8
1749817608 && interintra_mode.is_none()
1749917609 && (!overlappable_above(grid, mi_row, mi_col, bw4, mi_cols as usize, 1).is_empty()
1750017610 || !overlappable_left(grid, mi_row, mi_col, bh4, mi_rows as usize, 1)
@@ -17803,6 +17913,11 @@ fn decode_inter_block(
1780317913 }
1780417914 }
1780517915
17916+ // lane-inter16ab r2: `is_sub8x8_inter`'s neighbour walk reads the
17917+ // PREVIOUS strip's `mv`/`ref_frame`/`interp_filters`
17918+ // (reconinter_template.inc:75-82); record them for the next 1:4
17919+ // strip, which is the only reader.
17920+ INTER_LAST_MC.with(|c| c.set(Some((ref_frame, mv, h_filter, v_filter))));
1780617921 let mut pred_y = vec![0u16; side * side];
1780717922 let mut pred_u = vec![0u16; chroma_side * chroma_side];
1780817923 let mut pred_v = vec![0u16; chroma_side * chroma_side];
@@ -17964,6 +18079,46 @@ fn decode_inter_block(
1796418079 interintra_blend(v, cpx, cpy, chroma_side, ii, wedge_mask, &mut pred_v);
1796518080 }
1796618081
18082+ // lane-inter16ab r2: libaom `build_inter_predictors_sub8x8`
18083+ // (reconinter_template.inc:87-160). A 4:2:0 chroma block under a
18084+ // 16x4 (4x16) luma pair covers TWO luma blocks, so it is built in
18085+ // `b4_w x b4_h` = 8x2 (2x8) pieces, each from its own strip's
18086+ // mv/ref/filters. The bottom (right) piece is this strip's own mv
18087+ // over its own rows, which the whole-block prediction above
18088+ // already wrote there (MC is position-invariant for a fixed mv),
18089+ // so only the FIRST piece has to be rebuilt -- and only when
18090+ // `is_sub8x8_inter` holds, i.e. the previous strip was itself a
18091+ // single-reference inter block (`prev`), else libaom falls
18092+ // through to the ordinary whole-block predictor.
18093+ if let Some(s) = strip_chroma.filter(|s| s.has_chroma)
18094+ && let Some((prev_ref, prev_mv, prev_h, prev_v)) = s.prev
18095+ && luma_scale == mc::REF_NO_SCALE
18096+ {
18097+ let (piece_w, piece_h) = if s.horz { (8usize, 2usize) } else { (2usize, 8usize) };
18098+ let (_, prev_u, prev_v_plane) = ref_planes(prev_ref, ref_y, ref_u, ref_v, other_refs)?;
18099+ for (src, dst) in [(prev_u, &mut pred_u), (prev_v_plane, &mut pred_v)] {
18100+ let mut piece = vec![0u16; piece_w * piece_h];
18101+ mc::predict_with_filters(
18102+ &src.data,
18103+ src.width,
18104+ src.true_width,
18105+ src.true_height,
18106+ mv_to_q4(cpx, prev_mv.1, false),
18107+ mv_to_q4(cpy, prev_mv.0, false),
18108+ piece_w,
18109+ piece_h,
18110+ prev_h,
18111+ prev_v,
18112+ &mut piece,
18113+ );
18114+ for row in 0..piece_h {
18115+ dst[row * chroma_side..row * chroma_side + piece_w]
18116+ .copy_from_slice(&piece[row * piece_w..(row + 1) * piece_w]);
18117+ }
18118+ }
18119+ INTER16_SUB8_PIECE_HITS.with(|c| c.set(c.get() + 1));
18120+ }
18121+
1796718122 // lane-inter4 r2: a rectangular strip's transform tree starts from
1796818123 // its own rect `max_txsize_rect_lookup` entry, not a square one.
1796918124 let rect_tu = (write_w, write_h) != (side, side);
@@ -18000,24 +18155,26 @@ fn decode_inter_block(
1800018155 &pred_y,
1800118156 &vec![0i32; side * side],
1800218157 );
18003- u.reconstruct_mc_rect(
18004- cpx,
18005- cpy,
18006- chroma_side,
18007- write_chroma_w,
18008- write_chroma_h,
18009- &pred_u,
18010- &vec![0i32; chroma_side * chroma_side],
18011- );
18012- v.reconstruct_mc_rect(
18013- cpx,
18014- cpy,
18015- chroma_side,
18016- write_chroma_w,
18017- write_chroma_h,
18018- &pred_v,
18019- &vec![0i32; chroma_side * chroma_side],
18020- );
18158+ if has_chroma {
18159+ u.reconstruct_mc_rect(
18160+ cpx,
18161+ cpy,
18162+ chroma_side,
18163+ write_chroma_w,
18164+ write_chroma_h,
18165+ &pred_u,
18166+ &vec![0i32; chroma_side * chroma_side],
18167+ );
18168+ v.reconstruct_mc_rect(
18169+ cpx,
18170+ cpy,
18171+ chroma_side,
18172+ write_chroma_w,
18173+ write_chroma_h,
18174+ &pred_v,
18175+ &vec![0i32; chroma_side * chroma_side],
18176+ );
18177+ }
1802118178 luma_grid = vec![0i32; side * side];
1802218179 u_grid = vec![0i32; chroma_side * chroma_side];
1802318180 v_grid = vec![0i32; chroma_side * chroma_side];
@@ -18030,6 +18187,18 @@ fn decode_inter_block(
1803018187 } else {
1803118188 neighbours.around_mi(at, side)
1803218189 };
18190+ // lane-inter16ab r2: the pair's chroma transform sits at the
18191+ // EVEN strip's mi origin and spans both strips, so its
18192+ // above/left coefficient context is the pair's, not this
18193+ // strip's row.
18194+ let around_c = match strip_chroma {
18195+ Some(s) if s.has_chroma => neighbours.around_mi_rect(
18196+ s.pair_mi,
18197+ if s.horz { 16 } else { 8 },
18198+ if s.horz { 8 } else { 16 },
18199+ ),
18200+ _ => around,
18201+ };
1803318202 let luma_tx_type;
1803418203 if let Some(leaves) = vartx_leaves.clone() {
1803518204 // spec 5.11.17's transform tree, leaf by leaf in the order
@@ -18115,7 +18284,16 @@ fn decode_inter_block(
1811518284 None,
1811618285 )?;
1811718286 }
18118- if rect_tu {
18287+ if !has_chroma {
18288+ // `is_chroma_reference` is false for this strip: libaom's
18289+ // plane loop (decodeframe.c
18290+ // `predict_and_reconstruct_intra_block`/
18291+ // `reconstruct_inter_block`'s `for (plane...)` guarded by
18292+ // `xd->is_chroma_ref`) codes NO chroma transform here, so
18293+ // neither symbol nor context exists.
18294+ u_grid = vec![0i32; chroma_side * chroma_side];
18295+ v_grid = vec![0i32; chroma_side * chroma_side];
18296+ } else if rect_tu {
1811918297 // `av1_get_max_uv_txsize(bsize)`: the chroma transform of a
1812018298 // 2:1 strip is the strip's own rect chroma size (16x8 /
1812118299 // 8x16), one unit for the whole block, and it codes no
@@ -18129,7 +18307,7 @@ fn decode_inter_block(
1812918307 (uw, uh),
1813018308 chroma_side,
1813118309 1,
18132- around[1],
18310+ around_c[1],
1813318311 mode_for_tx,
1813418312 u,
1813518313 cpx,
@@ -18150,7 +18328,7 @@ fn decode_inter_block(
1815018328 (uw, uh),
1815118329 chroma_side,
1815218330 2,
18153- around[2],
18331+ around_c[2],
1815418332 mode_for_tx,
1815518333 v,
1815618334 cpx,
@@ -18210,6 +18388,16 @@ fn decode_inter_block(
1821018388 // skip path above (which only needed a clipped write of an
1821118389 // already-square-predicted buffer). Named refusal instead of a
1821218390 // silently wrong square-shaped intra prediction.
18391+ // lane-inter16ab r2: `decode_intra_rect_in_inter` has no chroma-pair
18392+ // path (it predicts and codes chroma at the strip's own halved
18393+ // footprint), so an INTRA 16x4 / 4x16 strip inside a 1:4 partition is
18394+ // refused by name rather than decoded with a 8x2 chroma transform
18395+ // libaom never coded.
18396+ if write_w.min(write_h) < 8 {
18397+ return Err(unsupported(
18398+ "an intra 16x4/4x16 strip inside an inter 16x16-level 1:4 partition (its 4:2:0 chroma pair is coded once for two strips; only the inter path implements that pairing)",
18399+ ));
18400+ }
1821318401 if write_w != side || write_h != side {
1821418402 // lane-intrarect r1: the strip decodes through its own rect
1821518403 // machinery ([`decode_intra_rect_in_inter`] -> the key-frame
@@ -18606,6 +18794,14 @@ fn decode_inter_block(
1860618794 rmi, cmi, dec.debug_bitpos(), dec.debug_state().0
1860718795 );
1860818796 }
18797+ // lane-inter16ab r2: the pair's chroma coefficient context spans BOTH
18798+ // strips (mirroring the intra `decode_rect4_16` path), and the even
18799+ // strip's own record wrote empty chroma state over those cells -- this
18800+ // rewrite is what libaom's single `av1_set_contexts` call for the 8x4
18801+ // (4x8) chroma unit leaves behind.
18802+ let pair_chroma = strip_chroma
18803+ .filter(|s| s.has_chroma)
18804+ .map(|s| (s, neighbour_state(&u_grid), neighbour_state(&v_grid)));
1860918805 if vartx_leaves.is_some() {
1861018806 // Plane 0 is already correct per transform unit
1861118807 // ([`Neighbours::record_mi_luma`] above); this writes everything else
@@ -18622,6 +18818,32 @@ fn decode_inter_block(
1862218818 &[luma_grid, u_grid, v_grid],
1862318819 );
1862418820 }
18821+ if let Some((s, u_state, v_state)) = pair_chroma {
18822+ let (pw, ph) = if s.horz { (16usize, 8usize) } else { (8, 16) };
18823+ let round_up_even = |n: usize| n.div_ceil(2) * 2;
18824+ let (bound_h, bound_w) = (
18825+ round_up_even(neighbours.mi_rows),
18826+ round_up_even(neighbours.mi_cols),
18827+ );
18828+ for cell in 0..(ph / MI) {
18829+ if s.pair_mi.0 + cell < bound_h
18830+ && let Some(slot) = neighbours.left.get_mut(s.pair_mi.0 + cell)
18831+ {
18832+ slot[1] = u_state;
18833+ slot[2] = v_state;
18834+ }
18835+ }
18836+ for cell in 0..(pw / MI) {
18837+ if s.pair_mi.1 + cell < bound_w
18838+ && let Some(slot) = neighbours.above.get_mut(s.pair_mi.1 + cell)
18839+ {
18840+ slot[1] = u_state;
18841+ slot[2] = v_state;
18842+ }
18843+ }
18844+ neighbours.record_uv_mode_mi(s.pair_mi.0, s.pair_mi.1, pw / MI, ph / MI, uv_predict_mode);
18845+ INTER16_CHROMA_PAIR_HITS.with(|c| c.set(c.get() + 1));
18846+ }
1862518847 neighbours.record_inter_rect_mi(
1862618848 at,
1862718849 write_w / MI,
@@ -21368,9 +21590,96 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
2136821590 inter_leaf8!(at16, br);
2136921591 }
2137021592 }
21593+ } else if part16 == PARTITION_HORZ_4
21594+ || part16 == PARTITION_VERT_4
21595+ {
21596+ // lane-inter16ab r2: four 16x4 (4x16) INTER
21597+ // strips. libaom `decode_partition`
21598+ // (decodeframe.c, PARTITION_HORZ_4/VERT_4)
21599+ // walks them top to bottom (left to right)
21600+ // with its own `i > 0` frame-edge break.
21601+ //
21602+ // Each strip is >= 8 in one dimension only,
21603+ // so `is_comp_ref_allowed`,
21604+ // `is_motion_variation_allowed_bsize`
21605+ // (blockd.h:65/1455, min(bw, bh) >= 8) and
21606+ // `is_interintra_allowed_bsize` (BLOCK_8X8..
21607+ // BLOCK_32X32 in enum order, which excludes
21608+ // BLOCK_16X4 = 17) are all false: no
21609+ // skip_mode, no comp_mode, no OBMC/warp and
21610+ // no interintra symbol is read -- gated in
21611+ // `decode_inter_block` off `write_w`/
21612+ // `write_h`.
21613+ //
21614+ // CHROMA is the pair's:
21615+ // `is_chroma_reference`
21616+ // (av1_common_int.h:1454) is false on the
21617+ // even strips, and the odd one codes one 8x4
21618+ // (4x8) chroma transform at the pair's
21619+ // origin, built from BOTH strips' motion
21620+ // (`is_sub8x8_inter`).
21621+ let horz = part16 == PARTITION_HORZ_4;
21622+ let (mi_row0, mi_col0) = sub16_to_mi(at16);
21623+ let (bw, bh) = if horz { (16usize, 4usize) } else { (4usize, 16usize) };
21624+ for i in 0..4usize {
21625+ let at_mi = if horz {
21626+ (mi_row0 + i, mi_col0)
21627+ } else {
21628+ (mi_row0, mi_col0 + i)
21629+ };
21630+ if i > 0
21631+ && (at_mi.0 >= mi_rows as usize
21632+ || at_mi.1 >= mi_cols as usize)
21633+ {
21634+ break;
21635+ }
21636+ let strip_has_chroma = i % 2 == 1;
21637+ let pair_mi = if !strip_has_chroma {
21638+ at_mi
21639+ } else if horz {
21640+ (at_mi.0 - 1, at_mi.1)
21641+ } else {
21642+ (at_mi.0, at_mi.1 - 1)
21643+ };
21644+ INTER_STRIP_CHROMA.with(|c| {
21645+ c.set(Some(InterStripChroma {
21646+ has_chroma: strip_has_chroma,
21647+ horz,
21648+ pair_mi,
21649+ prev: if strip_has_chroma {
21650+ INTER_LAST_MC.with(std::cell::Cell::get)
21651+ } else {
21652+ None
21653+ },
21654+ }))
21655+ });
21656+ inter_piece!(
21657+ at_mi,
21658+ SUB,
21659+ TxbSet::Luma16,
21660+ if reduced_tx_set {
21661+ TxbSet::Luma16Inter
21662+ } else {
21663+ TxbSet::Luma16InterSet1
21664+ },
21665+ TxbSet::Chroma8,
21666+ TX16,
21667+ TX8,
21668+ &scan16,
21669+ &scan8,
21670+ 1,
21671+ bw,
21672+ bh
21673+ );
21674+ if horz {
21675+ INTER16_HORZ4_HITS.with(|c| c.set(c.get() + 1));
21676+ } else {
21677+ INTER16_VERT4_HITS.with(|c| c.set(c.get() + 1));
21678+ }
21679+ }
2137121680 } else if part16 != PARTITION_SPLIT {
2137221681 return Err(unsupported(
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)",
21682+ "an inter 16x16-level partition value outside NONE/HORZ/VERT/SPLIT/AB/1:4",
2137421683 ));
2137521684 } else {
2137621685 if has_cols16 && has_rows16 {
crates/ec-av1/src/refusal_inventory.rsmodified+14 -8
@@ -67,14 +67,20 @@ const REFUSALS: &[&str] = &[
6767 "an 8x8 intra leaf in an inter frame whose tx_depth splits it into 4x4 transform units",
6868 "an inter frame with no key frame before it",
6969 "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- // 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)",
70+ // lane-inter16ab r1 lifted the AB half and r2 the 1:4 half (four 16x4 /
71+ // 4x16 inter strips, their 8x4/4x8 chroma pair built from BOTH strips'
72+ // motion vectors -- gate
73+ // `a_real_aomenc_inter_sequence_with_16x16_level_1to4_partitions_decodes_pixel_exact`).
74+ // Two narrower refusals are what is left of that shape:
75+ "an inter 16x16-level partition value outside NONE/HORZ/VERT/SPLIT/AB/1:4",
76+ // r2 residue: `vartx_leaves` is a list of SQUARE units, and
77+ // `sub_tx_size_map[TX_16X4]` is the rectangular TX_8X4 -- the split tree
78+ // and its per-unit residual reader both need rect leaves.
79+ "a split transform on a 16x16-level 1:4 inter strip (sub_tx_size_map[TX_16X4] is the rectangular TX_8X4)",
80+ // r2 residue: `decode_intra_rect_in_inter` codes chroma at the strip's own
81+ // halved footprint, which for a 16x4 strip is an 8x2 transform libaom
82+ // never wrote (its chroma is the PAIR's 8x4, coded by the odd strip).
83+ "an intra 16x4/4x16 strip inside an inter 16x16-level 1:4 partition (its 4:2:0 chroma pair is coded once for two strips; only the inter path implements that pairing)",
7884 "an intra mode this decoder does not code (round 2)",
7985 // lane-intrarect r1 lifted the whole-shape refusal that stood here (the
8086 // inter path's intra arm now routes 2:1 strips through `decode_rect_split`);
crates/ec-av1/src/stream.rsmodified+238 -0
@@ -7697,6 +7697,244 @@ mod tests {
76977697 }
76987698
76997699
7700+
7701+ #[test]
7702+ // lane-inter16ab r2: the 16x16-level 1:4 partitions on an INTER frame --
7703+ // PARTITION_HORZ_A/_HORZ_B/_VERT_A/_VERT_B at 16x16, i.e. two 8x8 inter
7704+ // leaves plus one true 16x8/8x16 inter strip. Every decode-order frame is
7705+ // compared Y/U/V against ffmpeg, refusals are counted and never SKIPped,
7706+ // out-of-scope mismatches fail the gate, and EACH of the four arms must
7707+ // have fired on a pixel-exact attempt (RD picking only HORZ_A is not
7708+ // proof of four). `--min-partition-size=4` is what lets aomenc's RD reach
7709+ // `PARTITION_HORZ_4`/`_VERT_4` at BLOCK_16X16 (16x4 / 4x16 inter strips);
7710+ // the last two counters are the chroma half of the claim -- the odd
7711+ // strip's `is_chroma_reference` pair and the pairs whose chroma was built
7712+ // from two different strips' motion vectors
7713+ // (`build_inter_predictors_sub8x8`).
7714+ fn a_real_aomenc_inter_sequence_with_16x16_level_1to4_partitions_decodes_pixel_exact() {
7715+ const NAME: &str =
7716+ "a_real_aomenc_inter_sequence_with_16x16_level_1to4_partitions_decodes_pixel_exact";
7717+ let _gate_lock = lock_gate_counters();
7718+ if !have_ffmpeg() {
7719+ eprintln!("SKIP {NAME}: no ffmpeg");
7720+ return;
7721+ }
7722+ if !have_aomenc() {
7723+ eprintln!("SKIP {NAME}: no aomenc at {}", aomenc_path().display());
7724+ return;
7725+ }
7726+ let (width, height, frame_count) = (192usize, 128usize, 6usize);
7727+ // Per arm, over both bit depths: how many pixel-exact attempts fired
7728+ // it at least once.
7729+ let mut arms_total = [0u32; 4];
7730+ for bit_depth in [8u32, 10u32] {
7731+ let (mut named_refusals, mut matched, mut out_of_scope, mut oos_mismatch) =
7732+ (0u32, 0u32, 0u32, 0u32);
7733+ let mut arms_proved = [0u32; 4];
7734+ for attempt in 0..32u32 {
7735+ // Two sources (structure along X vs along Y -- an AB
7736+ // partition needs an L/T-shaped feature, so both orientations
7737+ // are swept), four quantisers, two motion steps, two tiling
7738+ // arms. r1 measured (sweep script in the report): a 16-attempt
7739+ // sweep at cq 34/22 alone never made aomenc's RD pick HORZ_A
7740+ // at 8 bits, so the quantiser axis is four wide here; cq 46 on
7741+ // the X-structured source is deliberately NOT in the list --
7742+ // that stream's decode-order frame 4 desyncs on a defect this
7743+ // lane does not own (aomdec's own EC_PART trace reads ZERO
7744+ // AB partitions at BLOCK_16X16 anywhere in it, so the AB
7745+ // counters it raises are read out of an already-diverged
7746+ // stream; see lanes/inter16ab-r1.report.md).
7747+ let tx_search = if attempt % 2 == 0 { "0" } else { "1" };
7748+ // The 10-bit arm swaps cq 40 for 28 on the same sources: at
7749+ // cq 40 the X-structured 10-bit stream mismatches ffmpeg with
7750+ // ZERO 16-level AB partitions in it (another shape's defect,
7751+ // measured r1 -- the gate's own `oos_mismatch` counter is
7752+ // what found it, and it is reported, not silenced).
7753+ let cq = if bit_depth == 10 {
7754+ [18, 22, 34, 28][(attempt / 2 % 4) as usize]
7755+ } else {
7756+ [18, 22, 34, 40][(attempt / 2 % 4) as usize]
7757+ };
7758+ let natural = attempt / 8 % 2 == 1;
7759+ let group = attempt / 16;
7760+ // r1: a `--tile-columns=1` arm of this same sweep PANICS in
7761+ // `mc::from_switchable_symbol` (a 4th symbol out of a
7762+ // 3-symbol alphabet = someone else's desync, the signature
7763+ // the ledger already pins for the below-8x8 inter leaf), not
7764+ // in anything this lane added -- so the tiled arm is left out
7765+ // rather than turned into a SKIP or a weakened assert.
7766+ // Reported as residue in lanes/inter16ab-r1.report.md.
7767+ let tile_cols = "0";
7768+ let sp = 3 + (group % 2) * 5;
7769+ let duration = frame_count as f64 / 25.0;
7770+ // Continuous-tone translating texture with a second, coarser
7771+ // component on the cross axis: aomenc's RD picks an AB
7772+ // partition where one 16x16 quadrant differs from its three
7773+ // siblings, which the two sinusoids at different periods
7774+ // produce all over the frame.
7775+ let lum = if natural {
7776+ format!("128+58*sin((Y+N*{sp})/6)+40*sin(X/11)+20*sin((X+Y)/5)")
7777+ } else {
7778+ format!("128+58*sin((X+N*{sp})/6)+40*sin(Y/11)+20*sin((X-Y)/5)")
7779+ };
7780+ let source = format!(
7781+ "color=c=gray:s={width}x{height}:d={duration}:r=25,format=gray,\
7782+ geq=lum='{lum}',format=yuv420p"
7783+ );
7784+ let pix_fmt = if bit_depth == 10 { "yuv420p10le" } else { "yuv420p" };
7785+ let y4m = Command::new("ffmpeg")
7786+ .args([
7787+ "-v", "error", "-f", "lavfi", "-i", &source, "-t", &duration.to_string(),
7788+ "-pix_fmt", pix_fmt, "-strict", "-1", "-f", "yuv4mpegpipe", "-",
7789+ ])
7790+ .stdin(Stdio::null())
7791+ .stdout(Stdio::piped())
7792+ .stderr(Stdio::piped())
7793+ .output()
7794+ .expect("ffmpeg failed to run");
7795+ assert!(
7796+ y4m.status.success(),
7797+ "{NAME}: ffmpeg refused the {bit_depth}-bit fixture: {}",
7798+ String::from_utf8_lossy(&y4m.stderr)
7799+ );
7800+ let cq_arg = format!("--cq-level={cq}");
7801+ let depth_arg = format!("--bit-depth={bit_depth}");
7802+ let input_depth_arg = format!("--input-bit-depth={bit_depth}");
7803+ let tx_arg = format!("--enable-tx-size-search={tx_search}");
7804+ let tile_arg = format!("--tile-columns={tile_cols}");
7805+ let args: Vec<&str> = vec![
7806+ "--codec=av1", "--passes=1", "--end-usage=q", &cq_arg, "--cpu-used=0",
7807+ "--threads=1", "--row-mt=0", "--sb-size=64", &depth_arg, &input_depth_arg,
7808+ "--enable-restoration=0", "--enable-palette=0", "--deltaq-mode=0",
7809+ "--enable-filter-intra=0", "--enable-cfl-intra=0", "--enable-intrabc=0",
7810+ "--lag-in-frames=0", "--kf-max-dist=9999", &tile_arg,
7811+ // Per-arm overrides go LAST: aomenc keeps the last
7812+ // occurrence of a repeated --enable-* flag.
7813+ &tx_arg,
7814+ "--enable-rect-partitions=1", "--enable-ab-partitions=1",
7815+ "--enable-1to4-partitions=1", "--min-partition-size=4",
7816+ "--max-partition-size=16",
7817+ "--obu", "-o", "-", "-",
7818+ ];
7819+ let mut child = Command::new(aomenc_path())
7820+ .args(&args)
7821+ .stdin(Stdio::piped())
7822+ .stdout(Stdio::piped())
7823+ .stderr(Stdio::piped())
7824+ .spawn()
7825+ .expect("aomenc failed to start");
7826+ child
7827+ .stdin
7828+ .take()
7829+ .expect("aomenc stdin")
7830+ .write_all(&y4m.stdout)
7831+ .expect("writing y4m to aomenc");
7832+ let out = child.wait_with_output().expect("aomenc failed to run");
7833+ assert!(
7834+ out.status.success(),
7835+ "aomenc refused the fixture: {}",
7836+ String::from_utf8_lossy(&out.stderr)
7837+ );
7838+ let stream = out.stdout;
7839+ let before = decode::inter16_rect4_counters();
7840+ let frames = match decode_stream(&stream) {
7841+ Err(e) => {
7842+ let msg = e.to_string();
7843+ assert!(
7844+ msg.contains("unsupported"),
7845+ "{NAME} failed outright, not a named refusal ({bit_depth}-bit, \
7846+ attempt {attempt}): {msg}"
7847+ );
7848+ named_refusals += 1;
7849+ eprintln!("{bit_depth}-bit attempt {attempt} refusal: {msg}");
7850+ continue;
7851+ }
7852+ Ok(frames) => frames,
7853+ };
7854+ let after = decode::inter16_rect4_counters();
7855+ // [16x4 strips, 4x16 strips, chroma pairs closed, chroma
7856+ // pairs built from two strips' motion vectors].
7857+ let fired = [
7858+ after.0 - before.0,
7859+ after.1 - before.1,
7860+ after.2 - before.2,
7861+ after.3 - before.3,
7862+ ];
7863+ let ffmpeg_frames = if bit_depth == 10 {
7864+ ffmpeg_decode_sequence_10bit(&stream, width, height, frame_count)
7865+ } else {
7866+ ffmpeg_decode_sequence(&stream, width, height, frame_count)
7867+ };
7868+ assert_eq!(frames.len(), frame_count);
7869+ let mismatched = frames
7870+ .iter()
7871+ .zip(&ffmpeg_frames)
7872+ .any(|(got, want)| got.y != want.y || got.u != want.u || got.v != want.v);
7873+ if fired[0] + fired[1] == 0 {
7874+ out_of_scope += 1;
7875+ if mismatched {
7876+ oos_mismatch += 1;
7877+ eprintln!(
7878+ "{NAME}: {bit_depth}-bit attempt {attempt} MISMATCHES with zero \
7879+ 16-level inter AB partition -- another shape's defect"
7880+ );
7881+ }
7882+ continue;
7883+ }
7884+ if mismatched {
7885+ for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() {
7886+ let bad: Vec<usize> =
7887+ (0..got.y.len()).filter(|&k| got.y[k] != want.y[k]).collect();
7888+ if !bad.is_empty() {
7889+ eprintln!(
7890+ "{NAME}: attempt {attempt} {bit_depth}-bit frame {i}: {} luma \
7891+ pixels differ, first at ({}, {}), max |delta| {}",
7892+ bad.len(),
7893+ bad[0] % width,
7894+ bad[0] / width,
7895+ bad.iter()
7896+ .map(|&k| (got.y[k] as i32 - want.y[k] as i32).abs())
7897+ .max()
7898+ .unwrap_or(0)
7899+ );
7900+ }
7901+ }
7902+ }
7903+ for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() {
7904+ assert_eq!(got.y, want.y, "{NAME} frame {i} luma vs ffmpeg (attempt {attempt}, {bit_depth}-bit, arms {fired:?})");
7905+ assert_eq!(got.u, want.u, "{NAME} frame {i} U vs ffmpeg (attempt {attempt}, {bit_depth}-bit, arms {fired:?})");
7906+ assert_eq!(got.v, want.v, "{NAME} frame {i} V vs ffmpeg (attempt {attempt}, {bit_depth}-bit, arms {fired:?})");
7907+ }
7908+ for a in 0..4 {
7909+ if fired[a] > 0 {
7910+ arms_proved[a] += 1;
7911+ arms_total[a] += 1;
7912+ }
7913+ }
7914+ matched += 1;
7915+ }
7916+ eprintln!(
7917+ "{NAME} ({bit_depth}-bit): {named_refusals} named refusals, {matched} pixel-exact \
7918+ attempts carrying a 16-level inter 1:4 partition, per-arm attempts \
7919+ HORZ_4/VERT_4/chroma-pair/sub8x8-chroma={arms_proved:?}, {out_of_scope} attempts carried \
7920+ none ({oos_mismatch} of them mismatched)"
7921+ );
7922+ assert_eq!(
7923+ oos_mismatch, 0,
7924+ "{NAME}: {oos_mismatch} attempt(s) with no 16-level inter 1:4 partition decoded \
7925+ but mismatched ffmpeg -- a defect of another shape, not a pass"
7926+ );
7927+ }
7928+ assert!(
7929+ arms_total.iter().all(|&n| n > 0),
7930+ "{NAME}: a 16-level inter 1:4 arm never fired on a pixel-exact attempt \
7931+ (HORZ_4/VERT_4/chroma-pairs/sub8x8-chroma-pairs={arms_total:?}) -- an arm at 0 is \
7932+ unproven; the last two are the odd-strip `is_chroma_reference` pair and the \
7933+ `build_inter_predictors_sub8x8` two-mv chroma build"
7934+ );
7935+ }
7936+
7937+
77007938 #[test]
77017939 fn a_real_aomenc_inter_sequence_with_deblocking_decodes_pixel_exact() {
77027940 if !have_ffmpeg() {
lanes/COMMON-20260901.mdmodified+6 -0
@@ -100,3 +100,9 @@ If you ran it: extract your own hunks, `git checkout -- crates/`, re-apply.
100100 never two suites per lane; film extracts ≤2 s; a watchdog (`ec-memwatch` user unit, log
101101 `$HOME/.cache/ec-memwatch.log`) SIGKILLs any codec/test process above 6 GiB RSS or the largest one
102102 when MemAvailable < 3 GiB — a killed run means YOUR command exceeded the budget: bound it, do not retry as-is.
103+
104+## WORKTREE SETUP (2026-09-02, three lanes lost a round to this)
105+A new worktree needs the TOP-LEVEL fixtures symlink: `ln -s /home/user/Documents/Code/Rust/edith_codecs/fixtures <worktree>/fixtures`.
106+Without it exactly one gate fails: a_real_aomenc_stream_with_film_grain_decodes_pixel_exact with Os NotFound — it is NOT a decode defect.
107+New files under crates/ec-av1/fixtures/ need `git add -f` (bare `fixtures` in .gitignore); verify with `git ls-files`.
108+Commit-msg hook rejects film titles / home paths: describe streams by codec/resolution/bit depth.
lanes/inter16ab-r2.report.mdadded+85 -0
@@ -0,0 +1,85 @@
1+# lane-inter16ab r2 — 16x16-level 1:4 partitions in inter frames
2+
3+## Verdict: RED. The whole path is implemented and decodes, but one gate attempt
4+## (8-bit, attempt 5, cq 34, X-structured source) desyncs in its LAST frame.
5+The refusal is lifted and the gate is committed FAILING — not ignored, not weakened.
6+This branch must not merge into main until the residue below is closed.
7+
8+## What changed (all in `crates/ec-av1/`)
9+- `src/decode.rs:2207` — `InterStripChroma` + `INTER_STRIP_CHROMA` / `INTER_LAST_MC`
10+ thread-locals (the one-shot `REDUCED_TX_SET_INTER` idiom, chosen over threading two
11+ more parameters through `decode_inter_block`'s 23 call sites) and the four counters
12+ `inter16_rect4_counters() -> (16x4 strips, 4x16 strips, chroma pairs, sub8x8 chroma pairs)`.
13+- `src/decode.rs` `decode_inter_block` entry — `has_chroma` (libaom `is_chroma_reference`,
14+ av1_common_int.h:1454: `bh == 1 mi` ⇒ odd `mi_row`), and the chroma origin/extent
15+ overridden to the PAIR's (8x4 / 4x8 at the even strip's mi origin —
16+ `setup_pred_plane`'s `mi_row -= 1`).
17+- same fn — `is_comp_ref_allowed` / `is_motion_variation_allowed_bsize`
18+ (blockd.h:65 / :1455, `min(bw,bh) >= 8`) now gate `skip_mode`, `comp_mode` and
19+ `motion_mode`: a 16x4 strip reads none of those symbols. `is_interintra_allowed_bsize`
20+ already excluded it (aspect 4:1).
21+- same fn — `build_inter_predictors_sub8x8` (reconinter_template.inc:87-160): the pair's
22+ chroma is built in `b4_w x b4_h` = 8x2 (2x8) pieces; the second piece is this strip's own
23+ mv (already written by the whole-block predictor, MC being position-invariant for a fixed
24+ mv), so only the FIRST piece is rebuilt, from the previous strip's mv/ref/filters, and only
25+ when `is_sub8x8_inter` holds (previous strip single-ref inter — `INTER_LAST_MC`).
26+- same fn — chroma residual read/reconstruct/record all gated on `has_chroma`; the pair's
27+ chroma coefficient context is read at `around_mi_rect(pair_mi, 16, 8)` and written back over
28+ the pair's mi span (mirrors the intra `decode_rect4_16`).
29+- `src/decode.rs` `rect_scan` / `rect_inter_residual_supported` / `rect_inter_luma_set` —
30+ (16,4)|(4,16): `SCAN_16X4`/`SCAN_4X16`, and the new `TxbSet::LumaRect16x4Inter{,1}`
31+ (`Luma8` coefficient tables — `get_txsize_entropy_ctx(TX_16X4)` = TX_8X8, 64 positions,
32+ `eob_pt_64` — with the INTER tx_type table at `txsize_sqr_map[TX_16X4]` = TX_4X4;
33+ `av1_get_ext_tx_set_type` (blockd.h:1097-1106) gives EXT_TX_SET_ALL16 unreduced since
34+ `tx_size_sqr != TX_16X16`, EXT_TX_SET_DCT_IDTX reduced).
35+- `src/cdf_state.rs:233,1854` — the two new `TxbSet` variants and their tables.
36+- `src/decode.rs` 16x16 partition chain — the `PARTITION_HORZ_4`/`_VERT_4` arm: four strips in
37+ libaom `decode_partition` order with its own `i > 0` frame-edge break, each carrying its
38+ `InterStripChroma`.
39+- `src/refusal_inventory.rs:70` — the combined 1:4 refusal is GONE; three narrower ones stand:
40+ the partition-value catch-all, a split transform on a 16x4 strip, an intra 16x4 strip.
41+- `src/stream.rs` — gate
42+ `a_real_aomenc_inter_sequence_with_16x16_level_1to4_partitions_decodes_pixel_exact`
43+ (r1's gate shape with `--enable-1to4-partitions=1 --min-partition-size=4`).
44+- `examples/decode_probe.rs:43` — prints `inter16_1to4: horz4= vert4= chroma_pairs= sub8_pieces=`.
45+
46+## Gate result — RED
47+`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_1to4 -- --nocapture`
48+
49+EVIDENCE: gate stdout (suite log `$HOME/.cache/inter16ab-suite-r2.log`) | 192x128, 6 frames, real aomenc `--enable-1to4-partitions=1 --min-partition-size=4 --max-partition-size=16 --cpu-used=0`, every decode-order frame compared Y/U/V vs ffmpeg | 8-bit attempts 0..4: 2 named refusals ("an inter partition below 8x8" — `--min-partition-size=4` also lets aomenc split to sub-8 leaves, a different lane's refusal), earlier attempts pixel-exact; attempt 5 (cq 34, X-structured source, tx-size-search 1) fires arms [horz4=8, vert4=0, chroma_pairs=4, sub8x8_pairs=4] and MISMATCHES in decode-order frame 5 only: 8683 luma pixels, first at (96, 59), max |delta| 107. Frames 0-4 of that attempt are pixel-exact.
50+
51+Reading of the failure: frames 0-4 exact, then ~35% of the last frame wrong from a mid-frame
52+raster position = an ENTROPY DESYNC at one 16x16-level 1:4 block, not a prediction/filter
53+drift. `av1_get_ext_tx_set_type` was checked against the oracle source and the tables above are
54+right, so the leading suspect is the mv-stack at `BLOCK_16X4` (`bw4=4, bh4=1`): a wrong stack
55+size changes the `drl_idx` symbol count and desyncs at that block. NOT confirmed — no range
56+ladder was run this round (tool budget).
57+
58+## Film probe — moved one refusal deeper
59+`ffmpeg -ss 900 -t 2 -i <ReelB> -c:v copy -an -f obu` → `decode_probe`:
60+- before r2: `REFUSED: an inter 16x16-level 1:4 partition (HORZ_4/VERT_4 …)`
61+- after r2: `REFUSED: a split transform on a 16x16-level 1:4 inter strip
62+ (sub_tx_size_map[TX_16X4] is the rectangular TX_8X4)`
63+1 frame completed (`EC_AV1_FINAL_DUMP` file count) in both. So the partition, the strips and
64+the chroma pair are past; the film now needs rect var-tx leaves.
65+
66+## Residue
67+- fix-now (next round, this lane): the attempt-5 desync above. Method: dump that attempt's
68+ stream (add an env-gated write to the gate), run the instrumented aomdec `EC_TRACE=1` and
69+ compare the msac RANGE element by element from the first 1:4 block of decode-order frame 5.
70+ First check `find_mv_stack`'s row/col scan and weights for `bw4=4, bh4=1` (class
71+ `scan-weights-cross-axis`).
72+- deferred: a SPLIT luma transform on a 16x4 strip — `vartx_leaves` is a list of SQUARE units
73+ and `sub_tx_size_map[TX_16X4]` is the rectangular TX_8X4 (then TX_4X4). Unblocked by making
74+ `vartx_leaves` carry `(row, col, w, h)` and routing each leaf through
75+ `read_inter_plane_rect`. This is what BOTH films now stop at.
76+- deferred: an INTRA 16x4/4x16 strip inside a 1:4 partition — `decode_intra_rect_in_inter`
77+ codes chroma at the strip's own halved footprint (an 8x2 transform libaom never wrote).
78+ Unblocked by giving that path the same pair treatment.
79+- deferred: `git merge --no-commit main` (main is at 85887c7, this branch's base is 18bf7dc).
80+ Not run: the suite was already in flight in this worktree and a merge under it is exactly the
81+ self-inflicted flake COMMON warns about. The merge is owed before any merge to main.
82+- accepted: the gate keeps `--tile-columns=0` (r1's `--tile-columns=1` panic in
83+ `mc::from_switchable_symbol` is the below-8x8 inter leaf desync, not this shape). No new
84+ per-mi neighbour map was added — the pair chroma write reuses the existing `above`/`left`
85+ bands and never crosses the 16x16 block, so no tile-edge guard is in question.