forge
Explore
Log in

Don't you dare go Hollow

wip(av1): sub-8x8 inter PARTITION_SPLIT arm (four BLOCK_4X4 inter sub-blocks, sub8x8 chroma) -- oracle EC_PART_VAL proves the shape is real (bsize=3 value=1/2/3 on inter frames); gate RED at one late frame, HORZ/VERT below 8x8 still refused under a narrowed string

Browse files at this commit

1a797623ed02fa3ad4c44849fcce04ef9f91d903Ahmet Kaan GümüşParent: 9ae16b3
crates/ec-av1/src/decode.rsmodified+428 -1
@@ -2503,6 +2503,9 @@ pub(crate) fn tx_class1_hits() -> usize {
2503 // coincidentally landing on `PARTITION_NONE`.2503 // coincidentally landing on `PARTITION_NONE`.
2504 thread_local! {2504 thread_local! {
2505 static SUB8_SPLIT_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };2505 static SUB8_SPLIT_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
2506+ /// How many 8x8 groups an INTER frame split into four BLOCK_4X4 inter
2507+ /// sub-blocks (lane-intersub8).
2508+ static SUB8_INTER_SPLIT_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
2506 }2509 }
2507 2510
2508 /// Current value of [`SUB8_SPLIT_HITS`].2511 /// Current value of [`SUB8_SPLIT_HITS`].
@@ -2510,6 +2513,11 @@ pub(crate) fn sub8_split_hits() -> usize {
2510 SUB8_SPLIT_HITS.with(|c| c.get())2513 SUB8_SPLIT_HITS.with(|c| c.get())
2511 }2514 }
2512 2515
2516+/// Current value of [`SUB8_INTER_SPLIT_HITS`].
2517+pub(crate) fn sub8_inter_split_hits() -> usize {
2518+ SUB8_INTER_SPLIT_HITS.with(|c| c.get())
2519+}
2520+
2513 // How many 4x8 / 8x4 leaves (lane-tx4x8's `PARTITION_VERT`/`PARTITION_HORZ`2521 // How many 4x8 / 8x4 leaves (lane-tx4x8's `PARTITION_VERT`/`PARTITION_HORZ`
2514 // of an 8x8 block) this thread's decode reconstructed with REAL coefficients2522 // of an 8x8 block) this thread's decode reconstructed with REAL coefficients
2515 // -- a skipped leaf exercises the prediction and the mi bookkeeping but never2523 // -- a skipped leaf exercises the prediction and the mi bookkeeping but never
@@ -18873,6 +18881,393 @@ fn decode_inter_block(
18873 Ok(())18881 Ok(())
18874 }18882 }
18875 18883
18884+/// Decodes one 8x8 group that an inter frame's `partition_w8` symbol split
18885+/// into four `BLOCK_4X4` inter blocks (lane-intersub8: `PARTITION_SPLIT`
18886+/// below 8x8 -- traced live against the oracle `aomdec`'s own `EC_PART_VAL`,
18887+/// which reads `bsize=3 value=3` on real inter frames, so the refusal this
18888+/// replaces was NOT our own desync).
18889+///
18890+/// The inter counterpart of [`decode_leaf_split4`], and a `BLOCK_4X4`-only
18891+/// cut of [`decode_inter_block8`]: at `min(bw, bh) < 8` libaom switches off
18892+/// half the inter syntax, and every one of those is a symbol NOT read here
18893+/// (`decodemv.c` / `blockd.h`, oracle tree):
18894+/// * `skip_mode`: `read_skip_mode` returns 0 without a symbol when
18895+/// `!is_comp_ref_allowed(bsize)` (`AOMMIN(bw, bh) >= 8`, blockd.h).
18896+/// * `comp_mode`: `read_block_reference_mode` returns `SINGLE_REFERENCE` on
18897+/// the same predicate, so a sub-8x8 block is always single-reference.
18898+/// * `interintra`: `is_interintra_allowed_bsize` starts at `BLOCK_8X8`.
18899+/// * `motion_mode` / `obmc`: `motion_mode_allowed` returns
18900+/// `SIMPLE_TRANSLATION` for `block_size_wide < 8 || block_size_high < 8`,
18901+/// and `is_global_mv_block`'s own size term fails, so no warp either.
18902+/// * tx size: `block_signals_txsize(bsize)` is `bsize > BLOCK_4X4`
18903+/// (blockd.h:1027), so a `BLOCK_4X4` reads neither `tx_depth` nor a
18904+/// `txfm_partition` bit even in `TX_MODE_SELECT` -- the transform is
18905+/// `max_txsize_rect_lookup[BLOCK_4X4]` = `TX_4X4`
18906+/// (`decodeframe.c:1164-1177`).
18907+///
18908+/// Chroma is coded ONCE for the whole 8x8 group, on the last sub-block
18909+/// (`is_chroma_reference`: `(mi_row & 1) && (mi_col & 1)` in 4:2:0), as one
18910+/// `TX_4X4` unit per plane -- same rule and same neighbour-context tail as
18911+/// [`decode_leaf_split4`]. Its PREDICTION is the sub8x8 one
18912+/// (`dec_build_inter_predictors`'s `is_sub8x8` branch, `decodeframe.c`; spec
18913+/// 7.11.3.1's `candRow`/`candCol` loop): four 2x2 chroma pieces, each built
18914+/// from its own luma sub-block's reference, motion vector and interpolation
18915+/// filters, never from the last sub-block's mv alone.
18916+#[allow(clippy::too_many_arguments)]
18917+fn decode_inter_sub8_split4(
18918+ dec: &mut SymbolDecoder,
18919+ cdfs: &mut Cdfs,
18920+ neighbours: &mut Neighbours,
18921+ grid: &mut MiGrid,
18922+ group_mi: (usize, usize),
18923+ mi_cols: u32,
18924+ mi_rows: u32,
18925+ y: &mut PlaneBuf,
18926+ u: &mut PlaneBuf,
18927+ v: &mut PlaneBuf,
18928+ ref_y: &PlaneBuf,
18929+ ref_u: &PlaneBuf,
18930+ ref_v: &PlaneBuf,
18931+ other_refs: &RefSlots,
18932+ sign_bias_table: &SignBiasTable,
18933+ global_motion: &[ec_av1_syntax::WarpParams; 7],
18934+ base_q_idx: u8,
18935+ scan4: &[u16],
18936+ allow_high_precision_mv: bool,
18937+ force_integer_mv: bool,
18938+ interp_fixed: Option<mc::InterpFilterKind>,
18939+ enable_dual_filter: bool,
18940+ tpl_frame: Option<&TplFrameArgs>,
18941+ reduced_tx_set: bool,
18942+ frame_width: usize,
18943+) -> Result<()> {
18944+ const LAST_FRAME: i8 = 1;
18945+ const B4: usize = 4;
18946+ SUB8_INTER_SPLIT_HITS.with(|c| c.set(c.get() + 1));
18947+ let (gr, gc) = group_mi;
18948+ let (gpx, gpy) = (gc * MI, gr * MI);
18949+ let (cpx, cpy) = (gpx / 2, gpy / 2);
18950+ // Per-sub-block state the group's chroma prediction needs (spec
18951+ // 7.11.3.1's candRow/candCol loop reads each sub-block's OWN mv/ref/
18952+ // filters), indexed `dr * 2 + dc`.
18953+ let mut piece: [Option<(i8, (i32, i32), mc::InterpFilterKind, mc::InterpFilterKind)>; 4] =
18954+ [None; 4];
18955+ let mut first_tx_type = TxType::DctDct;
18956+ let mut last_skip = true;
18957+ for i in 0..4usize {
18958+ let (dr, dc) = (i / 2, i % 2);
18959+ let lmi = (gr + dr, gc + dc);
18960+ if lmi.0 >= mi_rows as usize || lmi.1 >= mi_cols as usize {
18961+ continue;
18962+ }
18963+ let (rmi, cmi) = lmi;
18964+ let (px, py) = (cmi * MI, rmi * MI);
18965+ inter_segment_id(dec, cdfs, rmi, cmi, 1, 1, false, true);
18966+ // No `skip_mode` symbol: `is_comp_ref_allowed(BLOCK_4X4)` is false.
18967+ let skip_ctx = usize::from(neighbours.above_skip[cmi]) + usize::from(neighbours.left_skip[rmi]);
18968+ let skip = dec.symbol(&mut cdfs.skip[skip_ctx]) == 1;
18969+ inter_segment_id(dec, cdfs, rmi, cmi, 1, 1, skip, false);
18970+ maybe_read_cdef_idx(dec, rmi, cmi, skip);
18971+ maybe_read_delta_q(dec, cdfs, rmi, cmi, false, skip);
18972+ maybe_read_delta_lf(dec, cdfs, rmi, cmi, false, skip);
18973+ let (has_above, has_left) = (
18974+ rmi > neighbours.tile_row0_mi,
18975+ cmi > neighbours.tile_col0_mi,
18976+ );
18977+ let ii_ctx = intra_inter_ctx(
18978+ has_above,
18979+ has_left,
18980+ neighbours.above_inter[cmi],
18981+ neighbours.left_inter[rmi],
18982+ );
18983+ let is_inter = dec.symbol(&mut cdfs.intra_inter[ii_ctx]) == 1;
18984+ if !is_inter {
18985+ return Err(unsupported(
18986+ "an intra 4x4 block inside an inter frame's sub-8x8 split (this decoder codes \
18987+ only inter 4x4 sub-blocks there)",
18988+ ));
18989+ }
18990+ let ref_frame = read_single_ref(
18991+ dec,
18992+ cdfs,
18993+ neighbours.above_ref[cmi],
18994+ neighbours.above_ref1[cmi],
18995+ neighbours.left_ref[rmi],
18996+ neighbours.left_ref1[rmi],
18997+ );
18998+ let (sref_y, sref_u, sref_v) = ref_planes(ref_frame, ref_y, ref_u, ref_v, other_refs)?;
18999+ if mc::scale_factor(sref_y.width, frame_width) != mc::REF_NO_SCALE {
19000+ return Err(unsupported(
19001+ "a sub-8x8 inter block under a scaled reference (superres, unimplemented)",
19002+ ));
19003+ }
19004+ let gm_table = build_gm_mv_table(
19005+ global_motion,
19006+ rmi,
19007+ cmi,
19008+ 1,
19009+ 1,
19010+ allow_high_precision_mv,
19011+ force_integer_mv,
19012+ );
19013+ let tpl = tpl_frame.map(|t| crate::mvstack::TplArgs {
19014+ field: t.field,
19015+ cur_offset_0: crate::motion_field::get_relative_dist(
19016+ t.order_hint_bits,
19017+ t.order_hint,
19018+ t.ref_order_hints[(ref_frame - LAST_FRAME) as usize],
19019+ ),
19020+ allow_high_precision_mv,
19021+ });
19022+ let stack = crate::mvstack::find_mv_stack_with_sign_bias(
19023+ grid,
19024+ rmi,
19025+ cmi,
19026+ 1,
19027+ 1,
19028+ ref_frame,
19029+ mi_cols as usize,
19030+ mi_rows as usize,
19031+ sign_bias_table,
19032+ &gm_table,
19033+ tpl,
19034+ );
19035+ let not_new = dec.symbol(&mut cdfs.new_mv[stack.new_mv_ctx]) == 1;
19036+ let mut is_globalmv = false;
19037+ let (mv, is_new_mv) = if !not_new {
19038+ let mut idx = 0usize;
19039+ while idx < 2 && stack.entries.len() > idx + 1 {
19040+ if dec.symbol(&mut cdfs.drl_mode[stack.drl_ctx[idx]]) == 0 {
19041+ break;
19042+ }
19043+ idx += 1;
19044+ }
19045+ let base_mv = stack.entries.get(idx).map_or(stack.pred_mv, |e| e.mv);
19046+ (
19047+ read_mv(
19048+ dec,
19049+ &mut cdfs.mv_comp,
19050+ &mut cdfs.mv_joint,
19051+ base_mv,
19052+ allow_high_precision_mv,
19053+ force_integer_mv,
19054+ ),
19055+ true,
19056+ )
19057+ } else {
19058+ let not_zero = dec.symbol(&mut cdfs.zero_mv[stack.zero_mv_ctx]) == 1;
19059+ is_globalmv = !not_zero;
19060+ let mv = if !not_zero {
19061+ gm_table[(ref_frame - LAST_FRAME) as usize]
19062+ } else {
19063+ let nearest = dec.symbol(&mut cdfs.ref_mv[stack.ref_mv_ctx]) == 0;
19064+ if nearest {
19065+ stack.nearest_mv
19066+ } else {
19067+ let mut idx = 1usize;
19068+ while idx < 3 && stack.entries.len() > idx + 1 {
19069+ if dec.symbol(&mut cdfs.drl_mode[stack.drl_ctx[idx]]) == 0 {
19070+ break;
19071+ }
19072+ idx += 1;
19073+ }
19074+ stack.entries.get(idx).map_or(stack.near_mv, |e| e.mv)
19075+ }
19076+ };
19077+ (mv, false)
19078+ };
19079+ // No `interintra` and no `motion_mode`/`obmc` symbol below 8x8 (see
19080+ // this function's own doc); `read_mb_interp_filter` still runs.
19081+ let gm_ref = &global_motion[(ref_frame - LAST_FRAME) as usize];
19082+ let above_filter_ctx = if neighbours.above_ref[cmi] == ref_frame
19083+ || neighbours.above_ref1[cmi] == Some(ref_frame)
19084+ {
19085+ neighbours.above_filter[cmi]
19086+ } else {
19087+ [3, 3]
19088+ };
19089+ let left_filter_ctx = if neighbours.left_ref[rmi] == ref_frame
19090+ || neighbours.left_ref1[rmi] == Some(ref_frame)
19091+ {
19092+ neighbours.left_filter[rmi]
19093+ } else {
19094+ [3, 3]
19095+ };
19096+ let gm_nontrans = is_globalmv && gm_ref.model != ec_av1_syntax::WarpModel::Translation;
19097+ let (h_filter, v_filter, resolved_filter) = resolve_interp_filter(
19098+ dec,
19099+ cdfs,
19100+ interp_fixed,
19101+ enable_dual_filter,
19102+ gm_nontrans,
19103+ above_filter_ctx,
19104+ left_filter_ctx,
19105+ false,
19106+ );
19107+ if std::env::var_os("EC_TRACE_MODE").is_some() {
19108+ eprintln!(
19109+ "EC_MODE_VAL4 mi_row={rmi} mi_col={cmi} newmv={is_new_mv} globalmv={is_globalmv} \
19110+ ref0={ref_frame} mv0=({},{}) stack={} rng={}",
19111+ mv.0,
19112+ mv.1,
19113+ stack.entries.len(),
19114+ dec.debug_state().0
19115+ );
19116+ }
19117+ grid.set(
19118+ rmi,
19119+ cmi,
19120+ MiInfo {
19121+ is_inter: true,
19122+ ref_frame,
19123+ ref_frame1: None,
19124+ mv1: None,
19125+ mv,
19126+ is_new_mv,
19127+ size: 1,
19128+ size_h: 1,
19129+ is_global_mv0: false,
19130+ is_global_mv1: false,
19131+ },
19132+ );
19133+ piece[i] = Some((ref_frame, mv, h_filter, v_filter));
19134+ let mut pred_y = vec![0u16; B4 * B4];
19135+ mc::predict_with_filters(
19136+ &sref_y.data,
19137+ sref_y.width,
19138+ sref_y.true_width,
19139+ sref_y.true_height,
19140+ mv_to_q4(px, mv.1, true),
19141+ mv_to_q4(py, mv.0, true),
19142+ B4,
19143+ B4,
19144+ h_filter,
19145+ v_filter,
19146+ &mut pred_y,
19147+ );
19148+ // `BLOCK_4X4` never signals a transform size, so the luma unit is the
19149+ // whole block and `get_txb_ctx` takes its `plane_bsize ==
19150+ // txsize_to_bsize[tx_size]` branch (`txb_skip_ctx = 0`, which
19151+ // `read_inter_plane`'s `plane_idx == 0` arm already assumes).
19152+ if skip {
19153+ y.reconstruct_mc(px, py, B4, &pred_y, &vec![0i32; B4 * B4]);
19154+ neighbours.record_mi_luma_rect(lmi, B4, B4, &vec![0i32; B4 * B4]);
19155+ } else {
19156+ let around = neighbours.around_mi(lmi, B4);
19157+ let (luma_grid, tx_type) = read_inter_plane(
19158+ dec,
19159+ cdfs,
19160+ if reduced_tx_set {
19161+ TxbSet::Luma4Inter
19162+ } else {
19163+ TxbSet::Luma4InterSet1
19164+ },
19165+ scan4,
19166+ 0,
19167+ around[0],
19168+ 0,
19169+ y,
19170+ px,
19171+ py,
19172+ B4,
19173+ base_q_idx,
19174+ &pred_y,
19175+ None,
19176+ None,
19177+ )?;
19178+ if i == 0 {
19179+ // `av1_get_tx_type`: an inter block's chroma inherits the
19180+ // tx_type of the CO-LOCATED luma position, which for the
19181+ // group's one chroma unit is luma (0, 0) -- the FIRST
19182+ // sub-block, not the last.
19183+ first_tx_type = tx_type;
19184+ }
19185+ neighbours.record_mi_luma_rect(lmi, B4, B4, &luma_grid);
19186+ }
19187+ neighbours.record_mode_mi(rmi, cmi, 1, 1, DC_PRED);
19188+ neighbours.record_inter_rect_mi(lmi, 1, 1, skip, true, ref_frame, resolved_filter, false);
19189+ neighbours.fill_skip_grid_rect(lmi, 1, 1, skip);
19190+ neighbours.fill_lf_grid_rect(lmi, 1, 1, B4 as u8, B4 as u8, ref_frame.max(LAST_FRAME));
19191+ last_skip = skip;
19192+ }
19193+ // Chroma, once for the whole group, on the last sub-block's own `skip`
19194+ // flag -- prediction from all four sub-blocks (2x2 pieces), residual as
19195+ // one TX_4X4 unit per plane.
19196+ let mut pred_u = vec![0u16; B4 * B4];
19197+ let mut pred_v = vec![0u16; B4 * B4];
19198+ for i in 0..4usize {
19199+ let (dr, dc) = (i / 2, i % 2);
19200+ let Some((ref_frame, mv, h_filter, v_filter)) = piece[i] else {
19201+ continue;
19202+ };
19203+ let (_, sref_u, sref_v) = ref_planes(ref_frame, ref_y, ref_u, ref_v, other_refs)?;
19204+ let (ox, oy) = (cpx + dc * 2, cpy + dr * 2);
19205+ for (plane, dst) in [(sref_u, &mut pred_u), (sref_v, &mut pred_v)] {
19206+ let mut buf = vec![0u16; 4];
19207+ mc::predict_with_filters(
19208+ &plane.data,
19209+ plane.width,
19210+ plane.true_width,
19211+ plane.true_height,
19212+ mv_to_q4(ox, mv.1, false),
19213+ mv_to_q4(oy, mv.0, false),
19214+ 2,
19215+ 2,
19216+ h_filter,
19217+ v_filter,
19218+ &mut buf,
19219+ );
19220+ for row in 0..2 {
19221+ for col in 0..2 {
19222+ dst[(dr * 2 + row) * B4 + dc * 2 + col] = buf[row * 2 + col];
19223+ }
19224+ }
19225+ }
19226+ }
19227+ let (u_grid, v_grid) = if last_skip {
19228+ u.reconstruct_mc(cpx, cpy, B4, &pred_u, &vec![0i32; B4 * B4]);
19229+ v.reconstruct_mc(cpx, cpy, B4, &pred_v, &vec![0i32; B4 * B4]);
19230+ (vec![0i32; B4 * B4], vec![0i32; B4 * B4])
19231+ } else {
19232+ let around = neighbours.around_mi(group_mi, 8);
19233+ let ug = read_inter_plane(
19234+ dec, cdfs, TxbSet::Chroma4, scan4, 1, around[1], 0, u, cpx, cpy, B4, base_q_idx,
19235+ &pred_u, Some(first_tx_type), None,
19236+ )?
19237+ .0;
19238+ let vg = read_inter_plane(
19239+ dec, cdfs, TxbSet::Chroma4, scan4, 2, around[2], 0, v, cpx, cpy, B4, base_q_idx,
19240+ &pred_v, Some(first_tx_type), None,
19241+ )?
19242+ .0;
19243+ (ug, vg)
19244+ };
19245+ neighbours.record_uv_mode_mi(gr, gc, 2, 2, DC_PRED);
19246+ // Same two neighbour tails [`decode_leaf_split4`] runs: the partition
19247+ // context of a `BLOCK_4X4` subsize (`partition_context_lookup` bit 0 = 1,
19248+ // reached by `side_mi = 4` here) and the group's chroma coefficient state.
19249+ for cell in 0..2usize {
19250+ neighbours.left_side_mi[gr + cell] = 4;
19251+ neighbours.above_side_mi[gc + cell] = 4;
19252+ }
19253+ let round_up_even = |n: usize| n.div_ceil(2) * 2;
19254+ let bound_h = round_up_even(neighbours.mi_rows);
19255+ let bound_w = round_up_even(neighbours.mi_cols);
19256+ let u_state = neighbour_state(&u_grid);
19257+ let v_state = neighbour_state(&v_grid);
19258+ for cell in 0..2usize {
19259+ if cell < 2usize.min(bound_h.saturating_sub(gr)) {
19260+ neighbours.left[gr + cell][1] = u_state;
19261+ neighbours.left[gr + cell][2] = v_state;
19262+ }
19263+ if cell < 2usize.min(bound_w.saturating_sub(gc)) {
19264+ neighbours.above[gc + cell][1] = u_state;
19265+ neighbours.above[gc + cell][2] = v_state;
19266+ }
19267+ }
19268+ Ok(())
19269+}
19270+
18876 /// Decodes one 8x8 leaf of a straddling 16x16 inter-frame block19271 /// Decodes one 8x8 leaf of a straddling 16x16 inter-frame block
18877 /// (lane-av1inter8), mirroring [`crate::tile::write_inter_frame_leaf8`]'s19272 /// (lane-av1inter8), mirroring [`crate::tile::write_inter_frame_leaf8`]'s
18878 /// exact symbol order: its own skip flag, intra/inter choice and (when19273 /// exact symbol order: its own skip flag, intra/inter choice and (when
@@ -21441,9 +21836,41 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
21441 let leaf_mi = (mr as usize, mc as usize);21836 let leaf_mi = (mr as usize, mc as usize);
21442 let leaf_ctx = neighbours.partition_ctx_mi(leaf_mi, 8);21837 let leaf_ctx = neighbours.partition_ctx_mi(leaf_mi, 8);
21443 let part8 = dec.symbol(&mut cdfs.partition_w8[leaf_ctx]);21838 let part8 = dec.symbol(&mut cdfs.partition_w8[leaf_ctx]);
21839+ if part8 == PARTITION_SPLIT {
21840+ // lane-intersub8: four BLOCK_4X4 inter
21841+ // sub-blocks, chroma once per 8x8.
21842+ decode_inter_sub8_split4(
21843+ &mut dec,
21844+ &mut cdfs,
21845+ &mut neighbours,
21846+ &mut grid,
21847+ leaf_mi,
21848+ mi_cols,
21849+ mi_rows,
21850+ &mut y,
21851+ &mut u,
21852+ &mut v,
21853+ &ref_y,
21854+ &ref_u,
21855+ &ref_v,
21856+ &ref_slots,
21857+ &sign_bias_table,
21858+ &global_motion,
21859+ base_q_idx,
21860+ &scan4,
21861+ allow_high_precision_mv,
21862+ force_integer_mv,
21863+ interp_fixed,
21864+ enable_dual_filter,
21865+ tpl_frame.as_ref(),
21866+ reduced_tx_set,
21867+ frame_width as usize,
21868+ )?;
21869+ continue;
21870+ }
21444 if part8 != PARTITION_NONE {21871 if part8 != PARTITION_NONE {
21445 return Err(unsupported(21872 return Err(unsupported(
21446- "an inter partition below 8x8 (this decoder codes no inter leaf smaller than 8x8; lane-sub8 scoped to intra)",21873+ "an inter 8x8 HORZ/VERT partition (8x4/4x8 inter leaves; the 4x4 SPLIT arm decodes, but a rectangular sub-8x8 inter transform is unimplemented)",
21447 ));21874 ));
21448 }21875 }
21449 let (21876 let (
crates/ec-av1/src/refusal_inventory.rsmodified+3 -1
@@ -33,7 +33,9 @@ const REFUSALS: &[&str] = &[
33 "a nonzero angle delta on an 8x8 intra leaf in an inter frame (no gate reaches this leaf with one; the >=16x16 arm decodes deltas)",33 "a nonzero angle delta on an 8x8 intra leaf in an inter frame (no gate reaches this leaf with one; the >=16x16 arm decodes deltas)",
34 "a coded HORZ/VERT strip whose chroma transform has no rect coefficient tables here",34 "a coded HORZ/VERT strip whose chroma transform has no rect coefficient tables here",
35 "a split intra strip whose transform unit is {tx_w}x{tx_h} (no luma coefficient tables for that shape here)",35 "a split intra strip whose transform unit is {tx_w}x{tx_h} (no luma coefficient tables for that shape here)",
36- "an inter partition below 8x8 (this decoder codes no inter leaf smaller than 8x8; lane-sub8 scoped to intra)",36+ "an inter 8x8 HORZ/VERT partition (8x4/4x8 inter leaves; the 4x4 SPLIT arm decodes, but a rectangular sub-8x8 inter transform is unimplemented)",
37+ "an intra 4x4 block inside an inter frame's sub-8x8 split (this decoder codes only inter 4x4 sub-blocks there)",
38+ "a sub-8x8 inter block under a scaled reference (superres, unimplemented)",
37 "a 1:4 rect strip that actually uses a palette (reconstruction is not ported at this shape)",39 "a 1:4 rect strip that actually uses a palette (reconstruction is not ported at this shape)",
38 "a 16x16 block whose true edge cuts through both axes needs a rectangular transform this decoder does not code yet",40 "a 16x16 block whose true edge cuts through both axes needs a rectangular transform this decoder does not code yet",
39 "a 16x16 inter block whose true edge cuts through both axes needs a rectangular transform this decoder does not code yet",41 "a 16x16 inter block whose true edge cuts through both axes needs a rectangular transform this decoder does not code yet",
crates/ec-av1/src/stream.rsmodified+151 -0
@@ -7212,6 +7212,157 @@ mod tests {
7212 }7212 }
7213 }7213 }
7214 7214
7215+ /// lane-intersub8: `PARTITION_SPLIT` below 8x8 on an INTER frame -- four
7216+ /// `BLOCK_4X4` inter sub-blocks with one shared 4x4 chroma unit per plane,
7217+ /// predicted the sub8x8 way (2x2 chroma piece per luma sub-block mv,
7218+ /// `dec_build_inter_predictors`' `is_sub8x8` branch). Reality of the shape
7219+ /// was established BEFORE the code (class refusal-from-own-desync): the
7220+ /// oracle `aomdec`'s `EC_TRACE` prints `EC_PART_VAL ... bsize=3 value=3`
7221+ /// on this recipe's inter frames.
7222+ ///
7223+ /// `--enable-rect-partitions=0` because the 8x4/4x8 sub-8x8 leaves are
7224+ /// still refused (a rectangular sub-8x8 inter transform is unimplemented);
7225+ /// with rect on, aomenc picks HORZ/VERT below 8x8 far more often than
7226+ /// SPLIT and no attempt reaches a split group.
7227+ #[test]
7228+ fn a_real_aomenc_inter_sequence_with_a_sub8x8_inter_split_decodes_pixel_exact() {
7229+ const NAME: &str =
7230+ "a_real_aomenc_inter_sequence_with_a_sub8x8_inter_split_decodes_pixel_exact";
7231+ let _gate_lock = lock_gate_counters();
7232+ if !have_ffmpeg() {
7233+ eprintln!("SKIP {NAME}: no ffmpeg");
7234+ return;
7235+ }
7236+ if !have_aomenc() {
7237+ eprintln!("SKIP {NAME}: no aomenc at {}", aomenc_path().display());
7238+ return;
7239+ }
7240+ let (width, height, frame_count) = (192usize, 128usize, 6usize);
7241+ let mut fired = 0u32;
7242+ let mut refusals: Vec<String> = Vec::new();
7243+ let mut out_of_scope_mismatch = 0u32;
7244+ for bit_depth in [8u32, 10u32] {
7245+ for attempt in 0..8u32 {
7246+ let cq = [8, 12][(attempt % 2) as usize];
7247+ let sp = 3 + (attempt / 2) * 3;
7248+ let duration = frame_count as f64 / 25.0;
7249+ let source = format!(
7250+ "color=c=gray:s={width}x{height}:d={duration}:r=25,format=gray,\
7251+ geq=lum='128+58*sin((X+N*{sp})/6)+18*sin(Y/23)',format=yuv420p"
7252+ );
7253+ let pix_fmt = if bit_depth == 10 { "yuv420p10le" } else { "yuv420p" };
7254+ let y4m = Command::new("ffmpeg")
7255+ .args([
7256+ "-v", "error", "-f", "lavfi", "-i", &source, "-t", &duration.to_string(),
7257+ "-pix_fmt", pix_fmt, "-strict", "-1", "-f", "yuv4mpegpipe", "-",
7258+ ])
7259+ .stdin(Stdio::null())
7260+ .stdout(Stdio::piped())
7261+ .stderr(Stdio::piped())
7262+ .output()
7263+ .expect("ffmpeg failed to run");
7264+ assert!(
7265+ y4m.status.success(),
7266+ "{NAME}: ffmpeg refused the fixture: {}",
7267+ String::from_utf8_lossy(&y4m.stderr)
7268+ );
7269+ let cq_arg = format!("--cq-level={cq}");
7270+ let depth_arg = format!("--bit-depth={bit_depth}");
7271+ let input_depth_arg = format!("--input-bit-depth={bit_depth}");
7272+ let args: Vec<&str> = vec![
7273+ "--codec=av1", "--passes=1", "--end-usage=q", &cq_arg, "--cpu-used=0",
7274+ "--threads=1", "--row-mt=0", "--sb-size=64", &depth_arg, &input_depth_arg,
7275+ "--enable-restoration=0", "--enable-palette=0", "--deltaq-mode=0",
7276+ "--enable-filter-intra=0", "--enable-cfl-intra=0", "--enable-intrabc=0",
7277+ "--lag-in-frames=0", "--enable-obmc=0", "--enable-tx-size-search=1",
7278+ // Per-arm overrides last (aomenc keeps the LAST occurrence).
7279+ "--enable-rect-partitions=0", "--enable-ab-partitions=0",
7280+ "--enable-1to4-partitions=0", "--min-partition-size=4",
7281+ "--max-partition-size=16",
7282+ "--obu", "-o", "-", "-",
7283+ ];
7284+ let mut child = Command::new(aomenc_path())
7285+ .args(&args)
7286+ .stdin(Stdio::piped())
7287+ .stdout(Stdio::piped())
7288+ .stderr(Stdio::piped())
7289+ .spawn()
7290+ .expect("aomenc failed to start");
7291+ child
7292+ .stdin
7293+ .take()
7294+ .expect("aomenc stdin")
7295+ .write_all(&y4m.stdout)
7296+ .expect("writing y4m to aomenc");
7297+ let out = child.wait_with_output().expect("aomenc failed to run");
7298+ assert!(
7299+ out.status.success(),
7300+ "{NAME}: aomenc refused the fixture: {}",
7301+ String::from_utf8_lossy(&out.stderr)
7302+ );
7303+ let stream = out.stdout;
7304+ let before = decode::sub8_inter_split_hits();
7305+ let frames = match decode_stream(&stream) {
7306+ Err(e) => {
7307+ let msg = e.to_string();
7308+ assert!(
7309+ msg.contains("unsupported"),
7310+ "{NAME} failed outright, not a named refusal ({bit_depth}-bit, \
7311+ attempt {attempt}): {msg}"
7312+ );
7313+ refusals.push(format!("{bit_depth}-bit attempt {attempt}: {msg}"));
7314+ continue;
7315+ }
7316+ Ok(frames) => frames,
7317+ };
7318+ let groups = decode::sub8_inter_split_hits() - before;
7319+ let ffmpeg_frames = if bit_depth == 10 {
7320+ ffmpeg_decode_sequence_10bit(&stream, width, height, frame_count)
7321+ } else {
7322+ ffmpeg_decode_sequence(&stream, width, height, frame_count)
7323+ };
7324+ assert_eq!(frames.len(), frame_count);
7325+ let mismatched = frames
7326+ .iter()
7327+ .zip(&ffmpeg_frames)
7328+ .any(|(got, want)| got.y != want.y || got.u != want.u || got.v != want.v);
7329+ if groups == 0 {
7330+ // Out of scope: no sub-8x8 inter split in this attempt.
7331+ if mismatched {
7332+ out_of_scope_mismatch += 1;
7333+ eprintln!(
7334+ "{NAME}: {bit_depth}-bit attempt {attempt} MISMATCHES with zero \
7335+ sub-8x8 inter split group -- another shape's defect"
7336+ );
7337+ }
7338+ refusals.push(format!(
7339+ "{bit_depth}-bit attempt {attempt}: decoded, but no sub-8x8 inter split"
7340+ ));
7341+ continue;
7342+ }
7343+ for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() {
7344+ assert_eq!(
7345+ got.y, want.y,
7346+ "luma frame {i} ({bit_depth}-bit attempt {attempt}, {groups} sub-8x8 \
7347+ inter split groups)"
7348+ );
7349+ assert_eq!(got.u, want.u, "U frame {i} ({bit_depth}-bit attempt {attempt})");
7350+ assert_eq!(got.v, want.v, "V frame {i} ({bit_depth}-bit attempt {attempt})");
7351+ }
7352+ fired += 1;
7353+ }
7354+ }
7355+ assert_eq!(
7356+ out_of_scope_mismatch, 0,
7357+ "{NAME}: attempts mismatched with no sub-8x8 inter split group"
7358+ );
7359+ assert!(
7360+ fired >= 2,
7361+ "{NAME}: fewer than 2 firing+pixel-exact attempts:\n{}",
7362+ refusals.join("\n")
7363+ );
7364+ }
7365+
7215 #[test]7366 #[test]
7216 // lane-inter4 r3: the 16x16-level rect INTER leaf -- PARTITION_HORZ /7367 // lane-inter4 r3: the 16x16-level rect INTER leaf -- PARTITION_HORZ /
7217 // PARTITION_VERT at 16x16 on an inter frame, i.e. two 16x8 / 8x16 inter7368 // PARTITION_VERT at 16x16 on an inter frame, i.e. two 16x8 / 8x16 inter
lanes/COMMON-20260901.mdmodified+6 -0
@@ -100,3 +100,9 @@ If you ran it: extract your own hunks, `git checkout -- crates/`, re-apply.
100 never two suites per lane; film extracts ≤2 s; a watchdog (`ec-memwatch` user unit, log100 never two suites per lane; film extracts ≤2 s; a watchdog (`ec-memwatch` user unit, log
101 `$HOME/.cache/ec-memwatch.log`) SIGKILLs any codec/test process above 6 GiB RSS or the largest one101 `$HOME/.cache/ec-memwatch.log`) SIGKILLs any codec/test process above 6 GiB RSS or the largest one
102 when MemAvailable < 3 GiB — a killed run means YOUR command exceeded the budget: bound it, do not retry as-is.102 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/intersub8-r1.handoff.mdadded+64 -0
@@ -0,0 +1,64 @@
1+# lane-intersub8 r1 — HANDOFF (RED, code committed, gate red)
2+
3+## 1. The refusal is REAL, not our desync (settled, do not re-litigate)
4+`aomenc` genuinely writes sub-8x8 partitions on INTER frames.
5+Recipe (192x128, 6 frames, gray ramp `128+58*sin((X+N*8)/6)+18*sin(Y/23)`, cq 8,
6+`--min-partition-size=4 --max-partition-size=16 --enable-rect-partitions=1
7+--enable-ab-partitions=0 --enable-1to4-partitions=0 --enable-obmc=0
8+--enable-tx-size-search=1 --sb-size=64 --lag-in-frames=0`), oracle:
9+`EC_TRACE=1 ~/.cache/aom-oracle/build/aomdec --rawvideo -o /dev/null u8_8.obu 2>ec.log`
10+`EC_PART_VAL bsize=3` histogram: **v0=68 NONE, v1=28 HORZ, v2=49 VERT, v3=3 SPLIT**.
11+So 8x4/4x8 dominate; 4x4 SPLIT is rare. `--enable-rect-partitions=0` removes
12+HORZ/VERT below 8x8 and still yields SPLIT groups (2 per stream at cq 8).
13+
14+Side fact worth a sweep: the SAME trace shows `bsize=6 value=6/7` (VERT_A/VERT_B at
15+16x16) even though `--enable-ab-partitions=0` was on the command line — that is what
16+the "inter 16x16-level AB or 1:4 partition" refusal fires on for recipes with
17+`--min-partition-size=4`. Either the flag is not honoured at that size or the
18+refusal is itself hallucinated; lane-inter16ab should check with this trace.
19+
20+## 2. What landed (compiles, `cargo check` clean)
21+* `crates/ec-av1/src/decode.rs` `decode_inter_sub8_split4` (new fn, above
22+ `decode_inter_block8`): four `BLOCK_4X4` inter sub-blocks of one 8x8 group.
23+ Symbols deliberately NOT read below 8x8, with libaom citations in the doc
24+ comment: `skip_mode` / `comp_mode` (`is_comp_ref_allowed`, blockd.h),
25+ `interintra` (`is_interintra_allowed_bsize`), `motion_mode`/`obmc`
26+ (`motion_mode_allowed`), tx size (`block_signals_txsize`, blockd.h:1027 —
27+ `bsize > BLOCK_4X4`, so `BLOCK_4X4` reads NO tx symbol even in TX_MODE_SELECT,
28+ decodeframe.c:1164-1177). Chroma once per 8x8 on the last sub-block, 4x4 TX,
29+ prediction = four 2x2 chroma pieces each from its own sub-block's mv/ref/filters
30+ (`dec_build_inter_predictors` is_sub8x8; spec 7.11.3.1). Chroma tx_type inherits
31+ the FIRST sub-block's luma tx_type (`av1_get_tx_type` co-located luma 0,0).
32+* call site: `decode.rs` ~21834, `part8 == PARTITION_SPLIT` dispatches; HORZ/VERT
33+ now refuse under a NARROWED string (rect sub-8x8 inter transform unimplemented).
34+* counter `SUB8_INTER_SPLIT_HITS` / `decode::sub8_inter_split_hits()`.
35+* `refusal_inventory.rs`: old string replaced by the 3 new ones.
36+* gate `stream.rs::a_real_aomenc_inter_sequence_with_a_sub8x8_inter_split_decodes_pixel_exact`.
37+
38+## 3. Gate result: RED (two separate failures)
39+`cargo test -p ec-av1 --lib sub8x8_inter_split`
40+* 8-bit attempt 0 (cq 8, sp 3): **MISMATCHES with ZERO sub-8x8 inter split groups**
41+ → a defect this lane did not introduce and does not own (out-of-scope arm).
42+ Suspect: the oracle's 2 `bsize=3 value=3` in that stream are on the KEY frame
43+ (intra `decode_leaf_split4`), i.e. a pre-existing intra sub-8x8 defect on this
44+ recipe, OR our partition read desyncs before reaching them. CHECK FIRST: run the
45+ oracle trace on that exact stream and print the frame index of each b3 v3.
46+* 8-bit attempt 1 (cq 12, sp 3): 1 split group, luma **frame 5** mismatches.
47+ Frames 0..4 are exact, so the group is late in the sequence — bisect with
48+ `EC_TRACE_MODE` (`EC_MODE_VAL4` line added for the 4x4 sub-block) against the
49+ oracle's `EC_MODE`/`EC_MODE_VAL` at the same mi, comparing msac RANGE.
50+ Prime suspects, in order: (a) the sub-block `skip` context — I used the
51+ mi-granular `above_skip[cmi]`/`left_skip[rmi]` pair like `decode_inter_block8`,
52+ libaom uses `av1_get_skip_txfm_context`; (b) the chroma 2x2 piece offsets /
53+ which sub-block's filters each piece uses; (c) `record_mi_luma_rect` per 4x4 vs
54+ the group-level chroma neighbour tail; (d) `first_tx_type` when sub-block 0 is
55+ skip (libaom memsets tx_type_map to DCT_DCT for skip — we leave DctDct: OK).
56+
57+## 4. Still refused after this round
58+`an inter 8x8 HORZ/VERT partition (8x4/4x8 inter leaves...)` — needs (1) INTER
59+TxbSet twins for 4x8/8x4 (`LumaRect4x8Inter`/`Set1`: side 8 tables +
60+`inter_tx_type_4`, copy `LumaRect4x8` and swap the tx_type slice), (2) a
61+rectangular var-tx read: for BLOCK_8X4/4X8, TX_MODE_SELECT + !skip reads exactly
62+ONE `txfm_partition` symbol (max_txsize_rect_lookup = TX_8X4/TX_4X8; split →
63+TX_4X4), our `read_block_tx_size`/`read_var_tx_size` are square-only.
64+That is the bulk of the remaining work and is why r1 scoped to SPLIT.