forge
Explore
Log in

Don't you dare go Hollow

Merge main 85887c7 (lane-mvtwin, lane-sb128b) into lane-kf1200

Browse files at this commit

28188f3dbaae5c630b3be36bd6a26ef161c1f18eAhmet Kaan GümüşParent: 503f24a9ae16b3
Clean auto-merge; cdf.rs byte-identical to main's. The r1 pair-mi
chroma edge-filter fix at decode.rs:7736 and its counter survive.

10 changed files +1372 -100

crates/ec-av1/src/cdf.rsmodified+10 -0
@@ -3167,6 +3167,16 @@ pub const TXB_SKIP_CHROMA_16_Q3: [[u16; 3]; 3] =
3167 /// TXB_SKIP_CHROMA_32, q-context 3: the same table as [`TXB_SKIP_CHROMA_32`], for `base_q_idx` 121..=255.3167 /// TXB_SKIP_CHROMA_32, q-context 3: the same table as [`TXB_SKIP_CHROMA_32`], for `base_q_idx` 121..=255.
3168 pub const TXB_SKIP_CHROMA_32_Q3: [[u16; 3]; 3] =3168 pub const TXB_SKIP_CHROMA_32_Q3: [[u16; 3]; 3] =
3169 [[4656, 32768, 0], [16074, 32768, 0], [24704, 32768, 0]];3169 [[4656, 32768, 0], [16074, 32768, 0], [24704, 32768, 0]];
3170+
3171+/// `av1_default_txb_skip_cdfs[q][TX_32X32][10..13]` (token_cdfs.h): libaom's
3172+/// chroma `txb_skip_ctx` offset is 10 instead of 7 when the plane block is
3173+/// LARGER than the transform (`get_txb_ctx`), which in AV1 happens only for a
3174+/// 128x128 block's four TX_32X32 chroma units -- the offset-7 rows above are
3175+/// every other case (lane-sb128b r3).
3176+pub const TXB_SKIP_CHROMA_32_BIG_Q0: [[u16; 3]; 3] = [[146, 32768, 0], [5132, 32768, 0], [31657, 32768, 0]];
3177+pub const TXB_SKIP_CHROMA_32_BIG_Q1: [[u16; 3]; 3] = [[641, 32768, 0], [22265, 32768, 0], [31452, 32768, 0]];
3178+pub const TXB_SKIP_CHROMA_32_BIG: [[u16; 3]; 3] = [[3082, 32768, 0], [20982, 32768, 0], [29443, 32768, 0]];
3179+pub const TXB_SKIP_CHROMA_32_BIG_Q3: [[u16; 3]; 3] = [[1806, 32768, 0], [14645, 32768, 0], [25336, 32768, 0]];
3170 /// EOB_EXTRA_LUMA_16, q-context 3: the same table as [`EOB_EXTRA_LUMA_16`], for `base_q_idx` 121..=255.3180 /// EOB_EXTRA_LUMA_16, q-context 3: the same table as [`EOB_EXTRA_LUMA_16`], for `base_q_idx` 121..=255.
3171 pub const EOB_EXTRA_LUMA_16_Q3: [[u16; 3]; 9] = [3181 pub const EOB_EXTRA_LUMA_16_Q3: [[u16; 3]; 9] = [
3172 [19941, 32768, 0],3182 [19941, 32768, 0],
crates/ec-av1/src/cdf_state.rsmodified+16 -3
@@ -399,7 +399,10 @@ pub(crate) struct Cdfs {
399 /// The all-zero flag of a 16x16 chroma transform.399 /// The all-zero flag of a 16x16 chroma transform.
400 pub txb_skip_chroma_16: [[u16; 3]; 3],400 pub txb_skip_chroma_16: [[u16; 3]; 3],
401 /// The all-zero flag of a 32x32 chroma transform.401 /// The all-zero flag of a 32x32 chroma transform.
402- pub txb_skip_chroma_32: [[u16; 3]; 3],402+ /// SIX contexts, not three: rows 0..3 are libaom's `txb_skip_ctx` 7..9
403+ /// (chroma transform == its plane block) and rows 3..6 its 10..12 (plane
404+ /// block larger, i.e. a 128x128 block's four TX_32X32 chroma units).
405+ pub txb_skip_chroma_32: [[u16; 3]; 6],
403 /// The end-of-block group of a luma transform of 1024 positions.406 /// The end-of-block group of a luma transform of 1024 positions.
404 pub eob_pt_1024_luma: [u16; 12],407 pub eob_pt_1024_luma: [u16; 12],
405 /// The same, for chroma.408 /// The same, for chroma.
@@ -1253,13 +1256,23 @@ impl Cdfs {
1253 cdf::TXB_SKIP_CHROMA_16,1256 cdf::TXB_SKIP_CHROMA_16,
1254 cdf::TXB_SKIP_CHROMA_16_Q3,1257 cdf::TXB_SKIP_CHROMA_16_Q3,
1255 ),1258 ),
1256- txb_skip_chroma_32: pick(1259+ txb_skip_chroma_32: {
1260+ let small = pick(
1257 q_ctx,1261 q_ctx,
1258 cdf::TXB_SKIP_CHROMA_32_Q0,1262 cdf::TXB_SKIP_CHROMA_32_Q0,
1259 cdf::TXB_SKIP_CHROMA_32_Q1,1263 cdf::TXB_SKIP_CHROMA_32_Q1,
1260 cdf::TXB_SKIP_CHROMA_32,1264 cdf::TXB_SKIP_CHROMA_32,
1261 cdf::TXB_SKIP_CHROMA_32_Q3,1265 cdf::TXB_SKIP_CHROMA_32_Q3,
1262- ),1266+ );
1267+ let big = pick(
1268+ q_ctx,
1269+ cdf::TXB_SKIP_CHROMA_32_BIG_Q0,
1270+ cdf::TXB_SKIP_CHROMA_32_BIG_Q1,
1271+ cdf::TXB_SKIP_CHROMA_32_BIG,
1272+ cdf::TXB_SKIP_CHROMA_32_BIG_Q3,
1273+ );
1274+ [small[0], small[1], small[2], big[0], big[1], big[2]]
1275+ },
1263 eob_pt_1024_luma: pick(1276 eob_pt_1024_luma: pick(
1264 q_ctx,1277 q_ctx,
1265 cdf::EOB_PT_1024_LUMA_Q0,1278 cdf::EOB_PT_1024_LUMA_Q0,
crates/ec-av1/src/decode.rsmodified+304 -78
@@ -310,10 +310,12 @@ fn maybe_read_delta_q(dec: &mut SymbolDecoder, cdfs: &mut Cdfs, mi_r: usize, mi_
310 if mi_r % sb_mi != 0 || mi_c % sb_mi != 0 {310 if mi_r % sb_mi != 0 || mi_c % sb_mi != 0 {
311 return;311 return;
312 }312 }
313- // `is_whole_sb` is the caller's "this leaf IS the superblock" flag, which313+ // `is_whole_sb` is the caller's "this leaf IS the superblock" flag,
314- // it computes against the 64x64 root; under a 128 superblock no leaf this314+ // computed against the sequence's own superblock size (lane-sb128b r1:
315- // decoder codes can be the whole superblock (the root is always SPLIT).315+ // it used to be hardcoded against 64 and disabled under `sb128`, which a
316- if is_whole_sb && !sb128() && skip {316+ // `PARTITION_NONE` 128x128 root -- itself the whole superblock -- makes
317+ // wrong).
318+ if is_whole_sb && skip {
317 return;319 return;
318 }320 }
319 let mut abs = dec.symbol(&mut cdfs.delta_q) as i32;321 let mut abs = dec.symbol(&mut cdfs.delta_q) as i32;
@@ -369,10 +371,12 @@ fn maybe_read_delta_lf(dec: &mut SymbolDecoder, cdfs: &mut Cdfs, mi_r: usize, mi
369 if mi_r % sb_mi != 0 || mi_c % sb_mi != 0 {371 if mi_r % sb_mi != 0 || mi_c % sb_mi != 0 {
370 return;372 return;
371 }373 }
372- // `is_whole_sb` is the caller's "this leaf IS the superblock" flag, which374+ // `is_whole_sb` is the caller's "this leaf IS the superblock" flag,
373- // it computes against the 64x64 root; under a 128 superblock no leaf this375+ // computed against the sequence's own superblock size (lane-sb128b r1:
374- // decoder codes can be the whole superblock (the root is always SPLIT).376+ // it used to be hardcoded against 64 and disabled under `sb128`, which a
375- if is_whole_sb && !sb128() && skip {377+ // `PARTITION_NONE` 128x128 root -- itself the whole superblock -- makes
378+ // wrong).
379+ if is_whole_sb && skip {
376 return;380 return;
377 }381 }
378 let multi = DELTA_LF_MULTI.with(|c| c.get());382 let multi = DELTA_LF_MULTI.with(|c| c.get());
@@ -4870,6 +4874,32 @@ impl Neighbours {
4870 self.record_mi_luma_rect(at_mi, tx_px, tx_px, grid);4874 self.record_mi_luma_rect(at_mi, tx_px, tx_px, grid);
4871 }4875 }
4872 4876
4877+ /// [`Self::record_mi_luma`] for ONE CHROMA transform unit of a block whose
4878+ /// uv plane block is several units (lane-sb128b r2: a 128x128 block's
4879+ /// 64x64 uv plane block is four TX_32X32 units, `av1_get_max_uv_txsize`).
4880+ /// `w_px`/`h_px` are the unit's extent in LUMA pixels -- the chroma
4881+ /// coefficient-context arrays are indexed by luma mi, the convention
4882+ /// [`Self::record_split_luma_rect_mi`] already writes them in, frame-edge
4883+ /// clamp included.
4884+ fn record_mi_chroma(
4885+ &mut self,
4886+ (mi_r, mi_c): (usize, usize),
4887+ w_px: usize,
4888+ h_px: usize,
4889+ plane: usize,
4890+ grid: &[i32],
4891+ ) {
4892+ let round_up_even = |n: usize| n.div_ceil(2) * 2;
4893+ let (bound_h, bound_w) = (round_up_even(self.mi_rows), round_up_even(self.mi_cols));
4894+ let state = neighbour_state(grid);
4895+ for cell in 0..(h_px / MI).min(bound_h.saturating_sub(mi_r)) {
4896+ self.left[mi_r + cell][plane] = state;
4897+ }
4898+ for cell in 0..(w_px / MI).min(bound_w.saturating_sub(mi_c)) {
4899+ self.above[mi_c + cell][plane] = state;
4900+ }
4901+ }
4902+
4873 /// [`Self::record_mi_luma`] for a RECTANGULAR transform unit (lane-rectsplitx4903 /// [`Self::record_mi_luma`] for a RECTANGULAR transform unit (lane-rectsplitx
4874 /// r1): the above context spans the unit's width, the left context its4904 /// r1): the above context spans the unit's width, the left context its
4875 /// height, which for a square unit is the same loop it always was.4905 /// height, which for a square unit is the same loop it always was.
@@ -8425,8 +8455,12 @@ fn read_intra_mode(
8425 // `segment_id`, `cdef`, `delta_q` -- `cdef` lands right here.8455 // `segment_id`, `cdef`, `delta_q` -- `cdef` lands right here.
8426 maybe_read_cdef_idx(dec, mi_r, mi_c, skip);8456 maybe_read_cdef_idx(dec, mi_r, mi_c, skip);
8427 istep!("cdef", 0);8457 istep!("cdef", 0);
8428- maybe_read_delta_q(dec, cdfs, mi_r, mi_c, side == 64, skip);8458+ // lane-sb128b r1: "this leaf IS the superblock" is `side == sb_size`, not
8429- maybe_read_delta_lf(dec, cdfs, mi_r, mi_c, side == 64, skip);8459+ // a hardcoded 64 -- a `PARTITION_NONE` 128x128 root is the whole
8460+ // superblock and skips `delta_q` exactly like a 64 one under a 64 root.
8461+ let whole_sb = side == sb_mi_cur() as usize * 4;
8462+ maybe_read_delta_q(dec, cdfs, mi_r, mi_c, whole_sb, skip);
8463+ maybe_read_delta_lf(dec, cdfs, mi_r, mi_c, whole_sb, skip);
8430 istep!("dq", 0);8464 istep!("dq", 0);
8431 // `read_intrabc_info` (spec 5.11.13, libaom decodemv.c:693, called at8465 // `read_intrabc_info` (spec 5.11.13, libaom decodemv.c:693, called at
8432 // :811 right after `skip_txfm`/`segment_id`/`cdef`/`delta_q` and before8466 // :811 right after `skip_txfm`/`segment_id`/`cdef`/`delta_q` and before
@@ -9120,7 +9154,12 @@ fn read_plane(
9120 let skip_ctx = if plane_idx == 0 {9154 let skip_ctx = if plane_idx == 0 {
9121 luma_skip_ctx.unwrap_or(0)9155 luma_skip_ctx.unwrap_or(0)
9122 } else {9156 } else {
9123- usize::from(around.0) + usize::from(around.1)9157+ // libaom `get_txb_ctx`: a chroma unit's context is
9158+ // `combine_entropy_contexts(above, left)` plus 7, or plus 10 when the
9159+ // plane block is bigger than the transform. Our chroma tables hold the
9160+ // offset-7 rows first, so the caller adds 3 for the bigger-block case
9161+ // (only a 128x128 block's TX_32X32 chroma units, lane-sb128b r3).
9162+ usize::from(around.0) + usize::from(around.1) + luma_skip_ctx.unwrap_or(0)
9124 };9163 };
9125 // spec 5.11.47/libaom `av1_read_tx_type`: a filter-intra luma block's9164 // spec 5.11.47/libaom `av1_read_tx_type`: a filter-intra luma block's
9126 // `intra_ext_tx_cdf` row is indexed by `fimode_to_intradir[filter_intra_mode]`,9165 // `intra_ext_tx_cdf` row is indexed by `fimode_to_intradir[filter_intra_mode]`,
@@ -9305,7 +9344,11 @@ fn decode_block(
9305 let resolved = read_tx_size(dec, cdfs, neighbours, (mi_r, mi_c), side, None);9344 let resolved = read_tx_size(dec, cdfs, neighbours, (mi_r, mi_c), side, None);
9306 (resolved, if resolved == 64 { 32 } else { resolved })9345 (resolved, if resolved == 64 { 32 } else { resolved })
9307 } else {9346 } else {
9308- (side, luma_tx)9347+ // lane-sb128b r1: `max_txsize_rect_lookup[BLOCK_128X128]` is
9348+ // TX_64X64, so a 128x128 block is always FOUR luma transform units
9349+ // even with `tx_select` off -- the TU loop below, never the
9350+ // single-unit path.
9351+ (side.min(64), luma_tx)
9309 };9352 };
9310 if tx_select && logical_tx < side && uv_mode != DC_PRED {9353 if tx_select && logical_tx < side && uv_mode != DC_PRED {
9311 SQ_CHROMA_TX_HITS.with(|c| c.set(c.get() + 1));9354 SQ_CHROMA_TX_HITS.with(|c| c.set(c.get() + 1));
@@ -9410,10 +9453,17 @@ fn decode_block(
9410 // The palette/intrabc override path keeps the single-call shape (its9453 // The palette/intrabc override path keeps the single-call shape (its
9411 // per-TU windowing is the non-skip loop's own `palette_y_buf` slice,9454 // per-TU windowing is the non-skip loop's own `palette_y_buf` slice,
9412 // untested for skip and unreachable in these streams).9455 // untested for skip and unreachable in these streams).
9456+ // lane-sb128b r2: a 128x128 block's transform is TX_64X64 even with
9457+ // `tx_select` off (`max_txsize_rect_lookup[BLOCK_128X128]`), so the
9458+ // per-unit prediction is keyed on the transform being smaller than
9459+ // the block, not on the tx-depth syntax. The counter keeps lane-hgkf's
9460+ // narrower meaning (a READ split tx depth).
9413 let split_tx_skip =9461 let split_tx_skip =
9414- tx_select && logical_tx < side && palette_y_buf.is_none() && intrabc_bufs.is_none();9462+ logical_tx < side && palette_y_buf.is_none() && intrabc_bufs.is_none();
9415 if split_tx_skip {9463 if split_tx_skip {
9464+ if tx_select {
9416 SKIP_SPLIT_TX_HITS.with(|c| c.set(c.get() + 1));9465 SKIP_SPLIT_TX_HITS.with(|c| c.set(c.get() + 1));
9466+ }
9417 let n_axis = side / logical_tx;9467 let n_axis = side / logical_tx;
9418 for tu_row in 0..n_axis {9468 for tu_row in 0..n_axis {
9419 for tu_col in 0..n_axis {9469 for tu_col in 0..n_axis {
@@ -9463,17 +9513,31 @@ fn decode_block(
9463 );9513 );
9464 }9514 }
9465 let ac = alpha.map(|_| cfl_ac_q3(y, px, py, side));9515 let ac = alpha.map(|_| cfl_ac_q3(y, px, py, side));
9516+ let cn = (chroma_side / chroma_tx).max(1);
9517+ for cu_row in 0..cn {
9518+ for cu_col in 0..cn {
9519+ let luma_span = chroma_tx * 2;
9520+ let cu_r = if cn == 1 {
9521+ reach
9522+ } else {
9523+ tu_reach(
9524+ side, side,
9525+ cu_col * luma_span, cu_row * luma_span, luma_span,
9526+ reach, px, py, y.width, y.height,
9527+ )
9528+ };
9529+ let (cu_x, cu_y) = (cpx + cu_col * chroma_tx, cpy + cu_row * chroma_tx);
9466 if let Some((ub, _)) = &palette_uv_bufs {9530 if let Some((ub, _)) = &palette_uv_bufs {
9467 set_palette_pred(ub.clone());9531 set_palette_pred(ub.clone());
9468 }9532 }
9469 u.reconstruct(9533 u.reconstruct(
9470- cpx,9534+ cu_x,
9471- cpy,9535+ cu_y,
9472- chroma_side,9536+ chroma_tx,
9473 uv_predict_mode,9537 uv_predict_mode,
9474 angle_delta_uv,9538 angle_delta_uv,
9475- reach,9539+ cu_r,
9476- &vec![0i32; chroma_side * chroma_side],9540+ &vec![0i32; chroma_tx * chroma_tx],
9477 alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)),9541 alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)),
9478 None,9542 None,
9479 smooth_neighbor_uv,9543 smooth_neighbor_uv,
@@ -9482,22 +9546,29 @@ fn decode_block(
9482 set_palette_pred(vb.clone());9546 set_palette_pred(vb.clone());
9483 }9547 }
9484 v.reconstruct(9548 v.reconstruct(
9485- cpx,9549+ cu_x,
9486- cpy,9550+ cu_y,
9487- chroma_side,9551+ chroma_tx,
9488 uv_predict_mode,9552 uv_predict_mode,
9489 angle_delta_uv,9553 angle_delta_uv,
9490- reach,9554+ cu_r,
9491- &vec![0i32; chroma_side * chroma_side],9555+ &vec![0i32; chroma_tx * chroma_tx],
9492 alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)),9556 alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)),
9493 None,9557 None,
9494 smooth_neighbor_uv,9558 smooth_neighbor_uv,
9495 );9559 );
9560+ }
9561+ }
9496 let luma_grid = vec![0i32; side * side];9562 let luma_grid = vec![0i32; side * side];
9497 let u_grid = vec![0i32; chroma_side * chroma_side];9563 let u_grid = vec![0i32; chroma_side * chroma_side];
9498 let v_grid = vec![0i32; chroma_side * chroma_side];9564 let v_grid = vec![0i32; chroma_side * chroma_side];
9499 neighbours.record(at, side, mode, uv_predict_mode, &[luma_grid, u_grid, v_grid]);9565 neighbours.record(at, side, mode, uv_predict_mode, &[luma_grid, u_grid, v_grid]);
9500- } else if !tx_select || logical_tx == side {9566+ } else if logical_tx == side {
9567+ // lane-sb128b r1: the test used to be `!tx_select || logical_tx == side`.
9568+ // Without `tx_select` `logical_tx` IS `side` at every size <= 64, so
9569+ // that arm was redundant -- and wrong at 128, where
9570+ // `max_txsize_rect_lookup` caps the block's transform at 64 and the
9571+ // block is four units whether or not `tx_select` is on.
9501 // A single luma transform unit -- the old path, unchanged (including9572 // A single luma transform unit -- the old path, unchanged (including
9502 // the 64x64 corner case, `logical_tx == side == 64` with9573 // the 64x64 corner case, `logical_tx == side == 64` with
9503 // `coeff_tx_side == 32`).9574 // `coeff_tx_side == 32`).
@@ -9590,8 +9661,27 @@ fn decode_block(
9590 // the earlier tiles in this same block already wrote -- the same9661 // the earlier tiles in this same block already wrote -- the same
9591 // per-TU pattern [`decode_leaf8`] already runs for an 8x8 leaf.9662 // per-TU pattern [`decode_leaf8`] already runs for an 8x8 leaf.
9592 let n_axis = side / logical_tx;9663 let n_axis = side / logical_tx;
9593- for tu_row in 0..n_axis {9664+ let cn = (chroma_side / chroma_tx).max(1);
9594- for tu_col in 0..n_axis {9665+ // libaom's transform-block loop is over 64x64 luma "mu" chunks
9666+ // (`decode_token_recon_block`: `mu_blocks_wide/high` =
9667+ // `mi_size_wide[BLOCK_64X64]`), and it codes EVERY PLANE of a chunk
9668+ // before moving to the next one. Below 128 a block is a single chunk,
9669+ // so this is byte-for-byte the all-luma-then-all-chroma order that has
9670+ // always run; at 128 the four quadrants interleave Y,U,V per quadrant
9671+ // and reading all four luma units first desyncs the tile at the second
9672+ // one (lane-sb128b r3, measured against aomdec's `EC_TRACE_COEFF`).
9673+ let nchunk = (side / 64).max(1);
9674+ // `cn > 1` means the uv plane block is larger than the uv transform,
9675+ // which moves libaom's chroma `txb_skip_ctx` offset from 7 to 10.
9676+ let chroma_ctx_offset = if cn > 1 { Some(3) } else { None };
9677+ let tpc = (n_axis / nchunk).max(1);
9678+ let cpc = (cn / nchunk).max(1);
9679+ let mut last_grids = [Vec::new(), Vec::new()];
9680+ let mut units: Vec<((usize, usize), usize, Vec<i32>, Vec<i32>)> = Vec::new();
9681+ for ch_row in 0..nchunk {
9682+ for ch_col in 0..nchunk {
9683+ for tu_row in ch_row * tpc..(ch_row + 1) * tpc {
9684+ for tu_col in ch_col * tpc..(ch_col + 1) * tpc {
9595 let tu_mi = (9685 let tu_mi = (
9596 mi_r + tu_row * (logical_tx / MI),9686 mi_r + tu_row * (logical_tx / MI),
9597 mi_c + tu_col * (logical_tx / MI),9687 mi_c + tu_col * (logical_tx / MI),
@@ -9652,7 +9742,11 @@ fn decode_block(
9652 tu_px,9742 tu_px,
9653 tu_py,9743 tu_py,
9654 logical_tx,9744 logical_tx,
9655- logical_tx,9745+ // The unit's own COEFFICIENT grid, half its side at
9746+ // TX_64X64 (a 64-point transform codes nothing past 32);
9747+ // identical to `logical_tx` at every smaller size
9748+ // (lane-sb128b r1).
9749+ coeff_tx_side,
9656 base_q_idx,9750 base_q_idx,
9657 None,9751 None,
9658 filter_intra,9752 filter_intra,
@@ -9670,59 +9764,81 @@ fn decode_block(
9670 neighbours.record_mi_luma(tu_mi, logical_tx, &tu_grid);9764 neighbours.record_mi_luma(tu_mi, logical_tx, &tu_grid);
9671 }9765 }
9672 }9766 }
9767+ // CfL is only allowed up to 32x32, i.e. only at `nchunk == 1`, where
9768+ // this still runs after every luma unit of the block.
9673 let ac = alpha.map(|_| cfl_ac_q3(y, px, py, side));9769 let ac = alpha.map(|_| cfl_ac_q3(y, px, py, side));
9674- let chroma_around = neighbours.around(at, side);9770+ // The block's uv plane block is `chroma_side` across but its uv
9771+ // transform is `chroma_tx` (`av1_get_max_uv_txsize` =
9772+ // `av1_get_adjusted_tx_size(max_txsize_rect_lookup[uv_plane_bsize])`):
9773+ // identical at every size up to 64x64, but a 128x128 block's 64x64 uv
9774+ // plane block adjusts TX_64X64 down to TX_32X32, so each plane is
9775+ // FOUR units (lane-sb128b r2) -- one per mu chunk.
9776+ for cu_row in ch_row * cpc..(ch_row + 1) * cpc {
9777+ for cu_col in ch_col * cpc..(ch_col + 1) * cpc {
9778+ // The chroma context arrays are indexed in LUMA mi, so this
9779+ // unit's anchor is its own luma quadrant: `chroma_tx` chroma
9780+ // pixels span `2 * chroma_tx` luma ones.
9781+ let luma_span = chroma_tx * 2;
9782+ let cu_mi = (
9783+ mi_r + cu_row * (luma_span / MI),
9784+ mi_c + cu_col * (luma_span / MI),
9785+ );
9786+ let cu_around = neighbours.around_mi(cu_mi, luma_span);
9787+ let cu_reach = if cn == 1 {
9788+ reach
9789+ } else {
9790+ tu_reach(
9791+ side, side,
9792+ cu_col * luma_span, cu_row * luma_span, luma_span,
9793+ reach, px, py, y.width, y.height,
9794+ )
9795+ };
9796+ let (cu_x, cu_y) = (cpx + cu_col * chroma_tx, cpy + cu_row * chroma_tx);
9675 if let Some((ub, _)) = &palette_uv_bufs {9797 if let Some((ub, _)) = &palette_uv_bufs {
9676 set_palette_pred(ub.clone());9798 set_palette_pred(ub.clone());
9677 }9799 }
9678 let u_grid = read_plane(9800 let u_grid = read_plane(
9679- dec,9801+ dec, cdfs, chroma_set, scans.1, 1, cu_around[1], mode,
9680- cdfs,9802+ uv_predict_mode, angle_delta_uv, cu_reach, u, cu_x, cu_y,
9681- chroma_set,9803+ chroma_tx, chroma_tx, base_q_idx,
9682- scans.1,
9683- 1,
9684- chroma_around[1],
9685- mode,
9686- uv_predict_mode,
9687- angle_delta_uv,
9688- reach,
9689- u,
9690- cpx,
9691- cpy,
9692- chroma_side,
9693- chroma_tx,
9694- base_q_idx,
9695 alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)),9804 alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)),
9696- None,9805+ None, chroma_ctx_offset, smooth_neighbor_uv,
9697- None,
9698- smooth_neighbor_uv,
9699 )?;9806 )?;
9700 if let Some((_, vb)) = &palette_uv_bufs {9807 if let Some((_, vb)) = &palette_uv_bufs {
9701 set_palette_pred(vb.clone());9808 set_palette_pred(vb.clone());
9702 }9809 }
9703 let v_grid = read_plane(9810 let v_grid = read_plane(
9704- dec,9811+ dec, cdfs, chroma_set, scans.1, 2, cu_around[2], mode,
9705- cdfs,9812+ uv_predict_mode, angle_delta_uv, cu_reach, v, cu_x, cu_y,
9706- chroma_set,9813+ chroma_tx, chroma_tx, base_q_idx,
9707- scans.1,
9708- 2,
9709- chroma_around[2],
9710- mode,
9711- uv_predict_mode,
9712- angle_delta_uv,
9713- reach,
9714- v,
9715- cpx,
9716- cpy,
9717- chroma_side,
9718- chroma_tx,
9719- base_q_idx,
9720 alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)),9814 alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)),
9721- None,9815+ None, chroma_ctx_offset, smooth_neighbor_uv,
9722- None,
9723- smooth_neighbor_uv,
9724 )?;9816 )?;
9725- neighbours.record_split_luma(at, side, mode, uv_predict_mode, [&u_grid, &v_grid]);9817+ if cn > 1 {
9818+ CHROMA_SPLIT_TX_HITS.with(|c| c.set(c.get() + 1));
9819+ // Immediately, so the NEXT unit of this same block reads
9820+ // this one's coefficient context (libaom's chroma
9821+ // `txb_skip_ctx` for the second quadrant is 11, i.e. base
9822+ // 1 from this left neighbour -- measured against aomdec).
9823+ // The same writes are replayed after `record_split_luma`
9824+ // below, which would otherwise clobber them whole-block.
9825+ neighbours.record_mi_chroma(cu_mi, luma_span, luma_span, 1, &u_grid);
9826+ neighbours.record_mi_chroma(cu_mi, luma_span, luma_span, 2, &v_grid);
9827+ units.push((cu_mi, luma_span, u_grid.clone(), v_grid.clone()));
9828+ }
9829+ last_grids = [u_grid, v_grid];
9830+ }
9831+ }
9832+ }
9833+ }
9834+ // Mode/side bookkeeping plus, at `cn == 1`, the whole-plane chroma
9835+ // context write; at `cn > 1` the per-unit writes above are what the
9836+ // next block reads, so they run after this (last writer wins).
9837+ neighbours.record_split_luma(at, side, mode, uv_predict_mode, [&last_grids[0], &last_grids[1]]);
9838+ for (cu_mi, luma_span, u_grid, v_grid) in &units {
9839+ neighbours.record_mi_chroma(*cu_mi, *luma_span, *luma_span, 1, u_grid);
9840+ neighbours.record_mi_chroma(*cu_mi, *luma_span, *luma_span, 2, v_grid);
9841+ }
9726 }9842 }
9727 // Unconditional, `size == 0` for a non-palette block: clears any stale9843 // Unconditional, `size == 0` for a non-palette block: clears any stale
9728 // neighbour palette state the same way [`Neighbours::record`] always9844 // neighbour palette state the same way [`Neighbours::record`] always
@@ -11129,8 +11245,14 @@ fn read_tx_size(
11129 // key-frame path's own deblock-grid approximation.11245 // key-frame path's own deblock-grid approximation.
11130 ctx_override: Option<usize>,11246 ctx_override: Option<usize>,
11131 ) -> usize {11247 ) -> usize {
11132- let ctx = ctx_override.unwrap_or_else(|| tx_size_context(n, at_mi, side));11248+ // `max_txsize_rect_lookup[bsize]` (libaom `read_selected_tx_size` /
11133- let depth = match side {11249+ // `get_tx_size_context`): a block wider than 64 still tops out at
11250+ // TX_64X64, so BLOCK_128X128 reads BLOCK_64X64's own category (its depth
11251+ // chain 64->32->16->8->4 is the same four steps) and resolves against 64,
11252+ // never against its own 128 side (lane-sb128b r1).
11253+ let max_tx = side.min(64);
11254+ let ctx = ctx_override.unwrap_or_else(|| tx_size_context(n, at_mi, max_tx));
11255+ let depth = match max_tx {
11134 8 => {11256 8 => {
11135 dec.symbol(&mut cdfs.tx_size_cat0[ctx])11257 dec.symbol(&mut cdfs.tx_size_cat0[ctx])
11136 }11258 }
@@ -11143,7 +11265,7 @@ fn read_tx_size(
11143 64 => {11265 64 => {
11144 dec.symbol(&mut cdfs.tx_size_cat3[ctx])11266 dec.symbol(&mut cdfs.tx_size_cat3[ctx])
11145 }11267 }
11146- _ => unreachable!("decode_block/decode_leaf8 only call this at 8/16/32/64"),11268+ _ => unreachable!("decode_block/decode_leaf8 only call this at 8/16/32/64/128"),
11147 };11269 };
11148 if std::env::var_os("EC_TRACE_MODE_STEP").is_some() {11270 if std::env::var_os("EC_TRACE_MODE_STEP").is_some() {
11149 let (rng, _) = dec.debug_state();11271 let (rng, _) = dec.debug_state();
@@ -11155,7 +11277,7 @@ fn read_tx_size(
11155 if depth != 0 {11277 if depth != 0 {
11156 TX_DEPTH_HITS.with(|c| c.set(c.get() + 1));11278 TX_DEPTH_HITS.with(|c| c.set(c.get() + 1));
11157 }11279 }
11158- side >> depth11280+ max_tx >> depth
11159 }11281 }
11160 11282
11161 /// `txfm_partition_context` (libaom `av1_common_int.h`): an inter block's11283 /// `txfm_partition_context` (libaom `av1_common_int.h`): an inter block's
@@ -12762,6 +12884,29 @@ fn sb_visit_order(r0: u32, r1: u32, c0: u32, c1: u32, sb128: bool) -> Vec<(u32,
12762 /// decides the root -- only SPLIT recurses into the four 64x64 quadrants this12884 /// decides the root -- only SPLIT recurses into the four 64x64 quadrants this
12763 /// decoder codes, the other seven arms refuse by name.12885 /// decoder codes, the other seven arms refuse by name.
12764 #[allow(clippy::too_many_arguments)]12886 #[allow(clippy::too_many_arguments)]
12887+thread_local! {
12888+ /// How many 128x128 superblock roots resolved to `PARTITION_NONE` -- one
12889+ /// whole 128x128 block (lane-sb128b r1's gate counter).
12890+ pub(crate) static PART128_NONE_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
12891+}
12892+
12893+/// [`PART128_NONE_HITS`], for a gate's own before/after delta.
12894+pub(crate) fn part128_none_hits() -> usize {
12895+ PART128_NONE_HITS.with(std::cell::Cell::get)
12896+}
12897+
12898+thread_local! {
12899+ /// How many CHROMA transform units were coded inside a block whose uv
12900+ /// plane block is more than one unit (lane-sb128b r2 -- only a 128x128
12901+ /// block, four per plane).
12902+ pub(crate) static CHROMA_SPLIT_TX_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
12903+}
12904+
12905+/// [`CHROMA_SPLIT_TX_HITS`], for a gate's own before/after delta.
12906+pub(crate) fn chroma_split_tx_hits() -> usize {
12907+ CHROMA_SPLIT_TX_HITS.with(std::cell::Cell::get)
12908+}
12909+
12765 fn read_sb128_root(12910 fn read_sb128_root(
12766 dec: &mut SymbolDecoder,12911 dec: &mut SymbolDecoder,
12767 cdfs: &mut Cdfs,12912 cdfs: &mut Cdfs,
@@ -12776,7 +12921,7 @@ fn read_sb128_root(
12776 sb_c: u32,12921 sb_c: u32,
12777 mi_cols: u32,12922 mi_cols: u32,
12778 mi_rows: u32,12923 mi_rows: u32,
12779-) -> Result<()> {12924+) -> Result<usize> {
12780 let (mi_r128, mi_c128) = ((sb_r & !1) * SB_MI, (sb_c & !1) * SB_MI);12925 let (mi_r128, mi_c128) = ((sb_r & !1) * SB_MI, (sb_c & !1) * SB_MI);
12781 crate::restoration::read_lr(12926 crate::restoration::read_lr(
12782 dec,12927 dec,
@@ -12827,13 +12972,20 @@ fn read_sb128_root(
12827 }12972 }
12828 }12973 }
12829 };12974 };
12830- if part128 != PARTITION_SPLIT {12975+ // lane-sb128b r1: `PARTITION_NONE` -- one 128x128 block -- is decoded by
12976+ // the key-frame caller below. The six remaining arms (HORZ/VERT and the
12977+ // four AB shapes) still need the rect/AB machinery at this size.
12978+ if part128 != PARTITION_SPLIT && part128 != PARTITION_NONE {
12831 return Err(unsupported(12979 return Err(unsupported(
12832- "a 128x128 superblock partition other than SPLIT (NONE/HORZ/VERT and the four AB arms at the 128 root are not decoded)",12980+ "a 128x128 superblock HORZ/VERT or AB partition (only SPLIT and NONE are decoded at the 128 root)",
12833 ));12981 ));
12834 }12982 }
12983+ if part128 == PARTITION_SPLIT {
12835 PART128_SPLIT_HITS.with(|c| c.set(c.get() + 1));12984 PART128_SPLIT_HITS.with(|c| c.set(c.get() + 1));
12836- Ok(())12985+ } else {
12986+ PART128_NONE_HITS.with(|c| c.set(c.get() + 1));
12987+ }
12988+ Ok(part128)
12837 }12989 }
12838 12990
12839 pub(crate) fn decode_key_frame_tile_with_cdfs(12991 pub(crate) fn decode_key_frame_tile_with_cdfs(
@@ -13011,10 +13163,20 @@ pub(crate) fn decode_key_frame_tile_with_cdfs(
13011 );13163 );
13012 TILE_HITS.with(|c| c.set(c.get() + 1));13164 TILE_HITS.with(|c| c.set(c.get() + 1));
13013 13165
13166+ // lane-sb128b r1: set when the 128 root resolved to `PARTITION_NONE` --
13167+ // its one block covers all four 64x64 quadrants, so the remaining three
13168+ // visits of this superblock code nothing at all.
13169+ let mut sb128_none = false;
13014 for (sb_r, sb_c, row_start, sb_start) in sb_visit_order(sb_r0, sb_r1, sb_c0, sb_c1, sb128) {13170 for (sb_r, sb_c, row_start, sb_start) in sb_visit_order(sb_r0, sb_r1, sb_c0, sb_c1, sb128) {
13015 if row_start {13171 if row_start {
13016 neighbours.start_row();13172 neighbours.start_row();
13017 }13173 }
13174+ if sb_start {
13175+ sb128_none = false;
13176+ }
13177+ if sb128_none {
13178+ continue;
13179+ }
13018 {13180 {
13019 // lane-sb128 r1: the 128 root. Its loop-restoration units are read13181 // lane-sb128 r1: the 128 root. Its loop-restoration units are read
13020 // once for the whole 128x128 (spec 5.11.57 is called with the13182 // once for the whole 128x128 (spec 5.11.57 is called with the
@@ -13022,7 +13184,7 @@ pub(crate) fn decode_key_frame_tile_with_cdfs(
13022 // `BLOCK_128X128` CDF (8 symbols) decides the root -- only SPLIT13184 // `BLOCK_128X128` CDF (8 symbols) decides the root -- only SPLIT
13023 // recurses into the four 64x64 quadrants this decoder codes.13185 // recurses into the four 64x64 quadrants this decoder codes.
13024 if sb128 && sb_start {13186 if sb128 && sb_start {
13025- read_sb128_root(13187+ let part128 = read_sb128_root(
13026 &mut dec,13188 &mut dec,
13027 &mut cdfs,13189 &mut cdfs,
13028 &neighbours,13190 &neighbours,
@@ -13034,6 +13196,62 @@ pub(crate) fn decode_key_frame_tile_with_cdfs(
13034 mi_cols,13196 mi_cols,
13035 mi_rows,13197 mi_rows,
13036 )?;13198 )?;
13199+ if part128 == PARTITION_NONE {
13200+ // One 128x128 intra block: four TX_64X64 luma units and a
13201+ // single 64x64 chroma unit per plane (`av1_get_max_uv_txsize`
13202+ // of a 128x128 block is TX_64X64 over its 64x64 uv plane
13203+ // block). No CfL, no filter intra, no palette at this size --
13204+ // [`read_intra_mode`]'s own size gates already say so.
13205+ sb128_none = true;
13206+ CDEF_TRANSMITTED.with(|c| c.set(false));
13207+ let at128 = ((sb_r & !1) as usize * 4, (sb_c & !1) as usize * 4);
13208+ decode_block(
13209+ &mut dec,
13210+ &mut cdfs,
13211+ &mut neighbours,
13212+ at128,
13213+ SB * 2,
13214+ TxbSet::Luma64,
13215+ TxbSet::Chroma32,
13216+ TX32,
13217+ TX32,
13218+ (&scan32, &scan32),
13219+ false,
13220+ &mut y,
13221+ &mut u,
13222+ &mut v,
13223+ base_q_idx,
13224+ enable_filter_intra,
13225+ allow_screen_content_tools,
13226+ allow_intrabc,
13227+ &scan32,
13228+ &scan16,
13229+ &scan8,
13230+ &scan4,
13231+ tx_select,
13232+ reduced_tx_set,
13233+ )?;
13234+ // libaom writes one `cdef_strength` into the block's own
13235+ // `MB_MODE_INFO`, which every mi cell of the block --
13236+ // hence all four 64x64 CDEF units -- points at; our grid
13237+ // is per-unit, so the read (which only ever lands in the
13238+ // top-left unit, `read_cdef`'s index 0) is copied across.
13239+ let (q_r, q_c) = ((sb_r & !1) as usize, (sb_c & !1) as usize);
13240+ CDEF_IDX_GRID.with(|g| {
13241+ let mut g = g.borrow_mut();
13242+ let cols = CDEF_SB_COLS.with(|c| c.get());
13243+ if cols > 0 && q_r * cols + q_c < g.len() {
13244+ let idx = g[q_r * cols + q_c];
13245+ for (dr, dc) in [(0, 1), (1, 0), (1, 1)] {
13246+ let i = (q_r + dr) * cols + q_c + dc;
13247+ if q_c + dc < cols && i < g.len() {
13248+ g[i] = idx;
13249+ }
13250+ }
13251+ }
13252+ });
13253+ continue;
13254+ }
13037 }13255 }
13038 if !sb128 {13256 if !sb128 {
13039 crate::restoration::read_lr(13257 crate::restoration::read_lr(
@@ -20630,7 +20848,7 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
20630 }20848 }
20631 {20849 {
20632 if sb128 && sb_start {20850 if sb128 && sb_start {
20633- read_sb128_root(20851+ if read_sb128_root(
20634 &mut dec,20852 &mut dec,
20635 &mut cdfs,20853 &mut cdfs,
20636 &neighbours,20854 &neighbours,
@@ -20641,7 +20859,15 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
20641 sb_c,20859 sb_c,
20642 mi_cols,20860 mi_cols,
20643 mi_rows,20861 mi_rows,
20644- )?;20862+ )? != PARTITION_SPLIT
20863+ {
20864+ // lane-sb128b r1 decodes a `PARTITION_NONE` 128 root on
20865+ // KEY frames only; an inter 128x128 leaf needs whole-block
20866+ // MC, OBMC and compound at a size this path has never run.
20867+ return Err(unsupported(
20868+ "a 128x128 superblock PARTITION_NONE root on an inter frame (only the key-frame path codes a whole 128x128 block)",
20869+ ));
20870+ }
20645 }20871 }
20646 if !sb128 {20872 if !sb128 {
20647 crate::restoration::read_lr(20873 crate::restoration::read_lr(
crates/ec-av1/src/mvstack.rsmodified+199 -18
@@ -92,6 +92,36 @@ pub(crate) fn tmv_hits() -> usize {
92 TMV_HITS.load(std::sync::atomic::Ordering::Relaxed)92 TMV_HITS.load(std::sync::atomic::Ordering::Relaxed)
93 }93 }
94 94
95+/// lane-mvtwin r1 firing counters, one per divergence this round closed.
96+/// `COMP_GM_FILL_HITS`: compound extension candidates whose `comp_list` slot
97+/// came from `gm_mv_candidates[side]` rather than a scanned neighbour, and
98+/// where that global mv was NOT `(0, 0)` (the only case the old zero fill
99+/// could not fake). `STACK_FULL_DROPS`: distinct candidates libaom drops at
100+/// `MAX_REF_MV_STACK_SIZE` on insertion. `TILE_REACH_CLIPS`: row/col reaches
101+/// shortened by a tile origin past mi 0, which the old frame-edge clamp
102+/// missed entirely.
103+static COMP_GM_FILL_HITS: std::sync::atomic::AtomicUsize =
104+ std::sync::atomic::AtomicUsize::new(0);
105+static STACK_FULL_DROPS: std::sync::atomic::AtomicUsize =
106+ std::sync::atomic::AtomicUsize::new(0);
107+static TILE_REACH_CLIPS: std::sync::atomic::AtomicUsize =
108+ std::sync::atomic::AtomicUsize::new(0);
109+
110+/// [`COMP_GM_FILL_HITS`].
111+pub(crate) fn comp_gm_fill_hits() -> usize {
112+ COMP_GM_FILL_HITS.load(std::sync::atomic::Ordering::Relaxed)
113+}
114+
115+/// [`STACK_FULL_DROPS`].
116+pub(crate) fn stack_full_drops() -> usize {
117+ STACK_FULL_DROPS.load(std::sync::atomic::Ordering::Relaxed)
118+}
119+
120+/// [`TILE_REACH_CLIPS`].
121+pub(crate) fn tile_reach_clips() -> usize {
122+ TILE_REACH_CLIPS.load(std::sync::atomic::Ordering::Relaxed)
123+}
124+
95 /// Everything [`find_mv_stack_with_sign_bias`] needs to fold temporal MV125 /// Everything [`find_mv_stack_with_sign_bias`] needs to fold temporal MV
96 /// candidates into a block's stack (spec 7.10.2.8, only reached when the126 /// candidates into a block's stack (spec 7.10.2.8, only reached when the
97 /// frame header's own `use_ref_frame_mvs` is set): the current frame's own127 /// frame header's own `use_ref_frame_mvs` is set): the current frame's own
@@ -213,6 +243,14 @@ impl MiGrid {
213 self.tile_col1 = col1;243 self.tile_col1 = col1;
214 }244 }
215 245
246+ /// The current tile's top-left mi-unit origin ([`Self::set_tile_bounds`]).
247+ /// libaom's `tile->mi_row_start`/`mi_col_start`, which every availability
248+ /// and reach clamp in `setup_ref_mv_list` is written against
249+ /// (`xd->up_available`, `find_valid_row_offset`, mvref_common.c:512-528).
250+ pub fn tile_origin(&self) -> (usize, usize) {
251+ (self.tile_row0, self.tile_col0)
252+ }
253+
216 /// Records the unit at `(row, col)`. Out-of-range coordinates are a254 /// Records the unit at `(row, col)`. Out-of-range coordinates are a
217 /// no-op — the caller only ever addresses units inside the grid it built.255 /// no-op — the caller only ever addresses units inside the grid it built.
218 pub fn set(&mut self, row: usize, col: usize, info: MiInfo) {256 pub fn set(&mut self, row: usize, col: usize, info: MiInfo) {
@@ -313,7 +351,15 @@ const MVREF_ROW_COLS: usize = 3;
313 fn add_candidate(candidates: &mut Vec<StackEntry>, mv: (i32, i32), weight: u32) {351 fn add_candidate(candidates: &mut Vec<StackEntry>, mv: (i32, i32), weight: u32) {
314 if let Some(entry) = candidates.iter_mut().find(|e| e.mv == mv) {352 if let Some(entry) = candidates.iter_mut().find(|e| e.mv == mv) {
315 entry.weight += weight;353 entry.weight += weight;
354+ } else if candidates.len() >= MAX_STACK_SIZE {
355+ STACK_FULL_DROPS.fetch_add(1, std::sync::atomic::Ordering::Relaxed);
316 } else {356 } else {
357+ // libaom `add_ref_mv_candidate` (mvref_common.c:100) and
358+ // `add_tpl_ref_mv` (:388) only push when
359+ // `*refmv_count < MAX_REF_MV_STACK_SIZE` -- the 9th distinct MV is
360+ // DROPPED AT INSERTION, never "kept if it outweighs an earlier one".
361+ // Sorting first and truncating afterwards (what this did) keeps a
362+ // different set whenever more than 8 distinct candidates are seen.
317 candidates.push(StackEntry { mv, weight });363 candidates.push(StackEntry { mv, weight });
318 }364 }
319 }365 }
@@ -773,22 +819,35 @@ pub fn find_mv_stack_with_sign_bias(
773 // nothing here relies on that.819 // nothing here relies on that.
774 let row_adj = bh4 < 2 && mi_row % 2 == 1;820 let row_adj = bh4 < 2 && mi_row % 2 == 1;
775 let col_adj = bw4 < 2 && mi_col % 2 == 1;821 let col_adj = bw4 < 2 && mi_col % 2 == 1;
776- let max_row_offset: isize = if mi_row > 0 {822+ // r1 (lane-mvtwin): availability and reach are TILE-relative, never
823+ // frame-relative -- libaom's `xd->up_available`/`left_available` are
824+ // `mi_row > tile->mi_row_start` / `mi_col > tile->mi_col_start`, and
825+ // `find_valid_row_offset`/`find_valid_col_offset` (mvref_common.c:512-528)
826+ // clamp the reach to `tile->mi_row_start - mi_row`. Clamping to the FRAME
827+ // edge left `max_row_offset`/`max_col_offset` too long inside every tile
828+ // that does not start at 0, which changes the row/col scan's `inc` weight
829+ // (and so the stack ORDER) even though `MiGrid::get` already returns
830+ // `None` for the cells outside the tile.
831+ let (tile_row0, tile_col0) = grid.tile_origin();
832+ if tile_row0 > 0 || tile_col0 > 0 {
833+ TILE_REACH_CLIPS.fetch_add(1, std::sync::atomic::Ordering::Relaxed);
834+ }
835+ let max_row_offset: isize = if mi_row > tile_row0 {
777 let reach = if bh4 < 2 { -4 } else { -6 } + isize::from(row_adj);836 let reach = if bh4 < 2 { -4 } else { -6 } + isize::from(row_adj);
778- reach.max(-(mi_row as isize))837+ reach.max(tile_row0 as isize - mi_row as isize)
779 } else {838 } else {
780 0839 0
781 };840 };
782- let max_col_offset: isize = if mi_col > 0 {841+ let max_col_offset: isize = if mi_col > tile_col0 {
783 let reach = if bw4 < 2 { -4 } else { -6 } + isize::from(col_adj);842 let reach = if bw4 < 2 { -4 } else { -6 } + isize::from(col_adj);
784- reach.max(-(mi_col as isize))843+ reach.max(tile_col0 as isize - mi_col as isize)
785 } else {844 } else {
786 0845 0
787 };846 };
788 847
789 let mut processed_rows = 0usize;848 let mut processed_rows = 0usize;
790 let mut processed_cols = 0usize;849 let mut processed_cols = 0usize;
791- let found_above = mi_row > 0850+ let found_above = max_row_offset.unsigned_abs() >= 1
792 && scan_row(851 && scan_row(
793 grid,852 grid,
794 mi_row,853 mi_row,
@@ -802,7 +861,7 @@ pub fn find_mv_stack_with_sign_bias(
802 &mut newmv_count,861 &mut newmv_count,
803 &mut processed_rows,862 &mut processed_rows,
804 );863 );
805- let found_left = mi_col > 0864+ let found_left = max_col_offset.unsigned_abs() >= 1
806 && scan_col(865 && scan_col(
807 grid,866 grid,
808 mi_row,867 mi_row,
@@ -1227,7 +1286,12 @@ fn add_compound_candidate(
1227 ) {1286 ) {
1228 if let Some(entry) = candidates.iter_mut().find(|e| e.mv0 == mv0 && e.mv1 == mv1) {1287 if let Some(entry) = candidates.iter_mut().find(|e| e.mv0 == mv0 && e.mv1 == mv1) {
1229 entry.weight += weight;1288 entry.weight += weight;
1289+ } else if candidates.len() >= MAX_STACK_SIZE {
1290+ STACK_FULL_DROPS.fetch_add(1, std::sync::atomic::Ordering::Relaxed);
1230 } else {1291 } else {
1292+ // Same insertion cap as [`add_candidate`]: libaom's compound branch
1293+ // of `add_ref_mv_candidate` (mvref_common.c:128) and `add_tpl_ref_mv`
1294+ // (:425) both gate the push on `*refmv_count < MAX_REF_MV_STACK_SIZE`.
1231 candidates.push(CompoundStackEntry { mv0, mv1, weight });1295 candidates.push(CompoundStackEntry { mv0, mv1, weight });
1232 }1296 }
1233 }1297 }
@@ -1477,9 +1541,18 @@ fn process_compound_ref_mv_candidate(
1477 /// libaom's combine step (`setup_ref_mv_list`, `mvref_common.c` ~696-720):1541 /// libaom's combine step (`setup_ref_mv_list`, `mvref_common.c` ~696-720):
1478 /// zips each side's `ref_id` (exact matches) then `ref_diff` (borrowed,1542 /// zips each side's `ref_id` (exact matches) then `ref_diff` (borrowed,
1479 /// sign-flipped) entries, position-wise and independently per side, into up1543 /// sign-flipped) entries, position-wise and independently per side, into up
1480-/// to two full `(mv0, mv1)` pair candidates — missing slots default to1544+/// to two full `(mv0, mv1)` pair candidates. r1 (lane-mvtwin): slots past
1481-/// `(0, 0)`, matching libaom's zero-initialized `combined_mvs`.1545+/// both lists are filled with THAT SIDE's own global motion vector
1482-fn combine_compound_candidates(lists: &CompoundRefLists) -> [((i32, i32), (i32, i32)); 2] {1546+/// (`gm_mv_candidates[idx]`, mvref_common.c:718-719), never `(0, 0)` — the
1547+/// exact gap the single-reference twin closed in r6 for its own
1548+/// `mv_ref_list` tail, still open on this side. Invisible while every live
1549+/// reference's global motion is IDENTITY (an unclamped gm mv of exactly
1550+/// `(0,0)`), wrong the moment a compound pair names a ROTZOOM/AFFINE
1551+/// reference and the scans leave the stack short.
1552+fn combine_compound_candidates(
1553+ lists: &CompoundRefLists,
1554+ gm_mv_candidates: [(i32, i32); 2],
1555+) -> [((i32, i32), (i32, i32)); 2] {
1483 let side_slots = |side: usize| -> [(i32, i32); 2] {1556 let side_slots = |side: usize| -> [(i32, i32); 2] {
1484 let merged: Vec<(i32, i32)> = lists.ref_id[side]1557 let merged: Vec<(i32, i32)> = lists.ref_id[side]
1485 .iter()1558 .iter()
@@ -1487,7 +1560,14 @@ fn combine_compound_candidates(lists: &CompoundRefLists) -> [((i32, i32), (i32,
1487 .take(2)1560 .take(2)
1488 .copied()1561 .copied()
1489 .collect();1562 .collect();
1490- std::array::from_fn(|i| merged.get(i).copied().unwrap_or((0, 0)))1563+ std::array::from_fn(|i| {
1564+ merged.get(i).copied().unwrap_or_else(|| {
1565+ if gm_mv_candidates[side] != (0, 0) {
1566+ COMP_GM_FILL_HITS.fetch_add(1, std::sync::atomic::Ordering::Relaxed);
1567+ }
1568+ gm_mv_candidates[side]
1569+ })
1570+ })
1491 };1571 };
1492 let side0 = side_slots(0);1572 let side0 = side_slots(0);
1493 let side1 = side_slots(1);1573 let side1 = side_slots(1);
@@ -1532,22 +1612,35 @@ pub fn find_mv_stack_compound(
1532 1612
1533 let row_adj = bh4 < 2 && mi_row % 2 == 1;1613 let row_adj = bh4 < 2 && mi_row % 2 == 1;
1534 let col_adj = bw4 < 2 && mi_col % 2 == 1;1614 let col_adj = bw4 < 2 && mi_col % 2 == 1;
1535- let max_row_offset: isize = if mi_row > 0 {1615+ // r1 (lane-mvtwin): availability and reach are TILE-relative, never
1616+ // frame-relative -- libaom's `xd->up_available`/`left_available` are
1617+ // `mi_row > tile->mi_row_start` / `mi_col > tile->mi_col_start`, and
1618+ // `find_valid_row_offset`/`find_valid_col_offset` (mvref_common.c:512-528)
1619+ // clamp the reach to `tile->mi_row_start - mi_row`. Clamping to the FRAME
1620+ // edge left `max_row_offset`/`max_col_offset` too long inside every tile
1621+ // that does not start at 0, which changes the row/col scan's `inc` weight
1622+ // (and so the stack ORDER) even though `MiGrid::get` already returns
1623+ // `None` for the cells outside the tile.
1624+ let (tile_row0, tile_col0) = grid.tile_origin();
1625+ if tile_row0 > 0 || tile_col0 > 0 {
1626+ TILE_REACH_CLIPS.fetch_add(1, std::sync::atomic::Ordering::Relaxed);
1627+ }
1628+ let max_row_offset: isize = if mi_row > tile_row0 {
1536 let reach = if bh4 < 2 { -4 } else { -6 } + isize::from(row_adj);1629 let reach = if bh4 < 2 { -4 } else { -6 } + isize::from(row_adj);
1537- reach.max(-(mi_row as isize))1630+ reach.max(tile_row0 as isize - mi_row as isize)
1538 } else {1631 } else {
1539 01632 0
1540 };1633 };
1541- let max_col_offset: isize = if mi_col > 0 {1634+ let max_col_offset: isize = if mi_col > tile_col0 {
1542 let reach = if bw4 < 2 { -4 } else { -6 } + isize::from(col_adj);1635 let reach = if bw4 < 2 { -4 } else { -6 } + isize::from(col_adj);
1543- reach.max(-(mi_col as isize))1636+ reach.max(tile_col0 as isize - mi_col as isize)
1544 } else {1637 } else {
1545 01638 0
1546 };1639 };
1547 1640
1548 let mut processed_rows = 0usize;1641 let mut processed_rows = 0usize;
1549 let mut processed_cols = 0usize;1642 let mut processed_cols = 0usize;
1550- let found_above = mi_row > 01643+ let found_above = max_row_offset.unsigned_abs() >= 1
1551 && scan_row_compound(1644 && scan_row_compound(
1552 grid,1645 grid,
1553 mi_row,1646 mi_row,
@@ -1561,7 +1654,7 @@ pub fn find_mv_stack_compound(
1561 &mut newmv_count,1654 &mut newmv_count,
1562 &mut processed_rows,1655 &mut processed_rows,
1563 );1656 );
1564- let found_left = mi_col > 01657+ let found_left = max_col_offset.unsigned_abs() >= 1
1565 && scan_col_compound(1658 && scan_col_compound(
1566 grid,1659 grid,
1567 mi_row,1660 mi_row,
@@ -1802,7 +1895,8 @@ pub fn find_mv_stack_compound(
1802 // bump) — otherwise append `comp_list[0]` as a brand-new entry. When1895 // bump) — otherwise append `comp_list[0]` as a brand-new entry. When
1803 // the stack is empty, both `comp_list[0]` and `comp_list[1]` are1896 // the stack is empty, both `comp_list[0]` and `comp_list[1]` are
1804 // appended unconditionally, with no dedup check at all.1897 // appended unconditionally, with no dedup check at all.
1805- let comp_list = combine_compound_candidates(&lists);1898+ let comp_list =
1899+ combine_compound_candidates(&lists, [gm_mv(gm, ref_frame.0), gm_mv(gm, ref_frame.1)]);
1806 if candidates.len() == 1 {1900 if candidates.len() == 1 {
1807 let (mv0, mv1) = if comp_list[0] == (candidates[0].mv0, candidates[0].mv1) {1901 let (mv0, mv1) = if comp_list[0] == (candidates[0].mv0, candidates[0].mv1) {
1808 comp_list[1]1902 comp_list[1]
@@ -2824,7 +2918,7 @@ mod tests {
2824 // side 1 has only one entry -> comp_idx 1 falls back to ref_diff.2918 // side 1 has only one entry -> comp_idx 1 falls back to ref_diff.
2825 lists.ref_diff[1].push((4, 4));2919 lists.ref_diff[1].push((4, 4));
2826 2920
2827- let combined = combine_compound_candidates(&lists);2921+ let combined = combine_compound_candidates(&lists, [(0, 0), (0, 0)]);
2828 assert_eq!(combined[0], ((1, 1), (3, 3)));2922 assert_eq!(combined[0], ((1, 1), (3, 3)));
2829 assert_eq!(combined[1], ((2, 2), (4, 4)));2923 assert_eq!(combined[1], ((2, 2), (4, 4)));
2830 }2924 }
@@ -2911,4 +3005,91 @@ mod tests {
2911 assert_eq!(stack.entries[1].mv0, (-3, -3));3005 assert_eq!(stack.entries[1].mv0, (-3, -3));
2912 assert_eq!(stack.entries[1].mv1, (7, 7));3006 assert_eq!(stack.entries[1].mv1, (7, 7));
2913 }3007 }
3008+
3009+ /// lane-mvtwin r1, defect 1 (twin drift, compound only): libaom fills a
3010+ /// `comp_list` slot past both `ref_id`/`ref_diff` lists with THAT SIDE's
3011+ /// own `gm_mv_candidates[idx]` (mvref_common.c:718-719). This module
3012+ /// filled it with `(0, 0)`, which is only accidentally right while every
3013+ /// live reference's global motion is IDENTITY -- the single-ref twin had
3014+ /// already closed the same gap on its own `mv_ref_list` tail in r6.
3015+ #[test]
3016+ fn a_missing_compound_combine_slot_takes_that_sides_global_mv_not_zero() {
3017+ let lists = CompoundRefLists::default();
3018+ let combined = combine_compound_candidates(&lists, [(9, -5), (-11, 3)]);
3019+ assert_eq!(combined[0], ((9, -5), (-11, 3)));
3020+ assert_eq!(combined[1], ((9, -5), (-11, 3)));
3021+ // One side supplied, the other short: only the short side falls back.
3022+ let mut half = CompoundRefLists::default();
3023+ half.ref_id[0].push((1, 2));
3024+ let combined = combine_compound_candidates(&half, [(9, -5), (-11, 3)]);
3025+ assert_eq!(combined[0], ((1, 2), (-11, 3)));
3026+ assert_eq!(combined[1], ((9, -5), (-11, 3)));
3027+ }
3028+
3029+ /// lane-mvtwin r1, defect 2 (both twins): libaom drops the 9th distinct
3030+ /// candidate AT INSERTION (`*refmv_count < MAX_REF_MV_STACK_SIZE`,
3031+ /// mvref_common.c:100/128/388/425). Pushing everything and truncating
3032+ /// after the weight sort keeps a different set: here the heavy 9th
3033+ /// candidate would survive and evict a scanned one.
3034+ #[test]
3035+ fn the_ninth_distinct_candidate_is_dropped_at_insertion_not_after_sorting() {
3036+ let mut candidates = Vec::new();
3037+ for i in 0..MAX_STACK_SIZE as i32 {
3038+ add_candidate(&mut candidates, (i, i), 2);
3039+ }
3040+ let before = stack_full_drops();
3041+ add_candidate(&mut candidates, (99, 99), 10_000);
3042+ assert_eq!(candidates.len(), MAX_STACK_SIZE);
3043+ assert!(!candidates.iter().any(|e| e.mv == (99, 99)));
3044+ assert_eq!(stack_full_drops(), before + 1);
3045+ // A full stack still takes the dedup weight bump libaom applies
3046+ // before the cap check.
3047+ add_candidate(&mut candidates, (0, 0), 6);
3048+ assert_eq!(candidates[0].weight, 8);
3049+
3050+ let mut comp = Vec::new();
3051+ for i in 0..MAX_STACK_SIZE as i32 {
3052+ add_compound_candidate(&mut comp, (i, i), (i, -i), 2);
3053+ }
3054+ add_compound_candidate(&mut comp, (99, 99), (99, 99), 10_000);
3055+ assert_eq!(comp.len(), MAX_STACK_SIZE);
3056+ }
3057+
3058+ /// lane-mvtwin r1, defect 3 (both twins): the row/col reach is clamped to
3059+ /// the TILE origin (`find_valid_row_offset`, mvref_common.c:512-528), not
3060+ /// the frame edge. `MiGrid::get` already hides the out-of-tile cells, so
3061+ /// the only visible symptom is the scan WEIGHT (`inc`) -- and through it
3062+ /// the stack order. Query at mi_row 9 with the tile starting at row 8:
3063+ /// the real reach is -1, so `inc = 1` and the weight stays at the floor
3064+ /// 2; the frame-edge clamp gave -6, `inc = min(6, size_h) = 4`, doubling
3065+ /// the vote.
3066+ #[test]
3067+ fn the_row_reach_is_clamped_to_the_tile_origin_not_the_frame_edge() {
3068+ let weight_with_tile_origin = |row0: usize| {
3069+ // A neighbour at least as wide as the query block (`bw4 <= n4`)
3070+ // is what makes libaom compute `inc` at all.
3071+ let wide = MiInfo {
3072+ size: 4,
3073+ size_h: 4,
3074+ ..inter((5, 5))
3075+ };
3076+ let mut grid = MiGrid::new(16, 16);
3077+ grid.set(8, 4, wide);
3078+ grid.set(8, 6, wide);
3079+ grid.set_tile_bounds(row0, 0, 16, 16);
3080+ let stack = find_mv_stack(&grid, 9, 4, 2, 2, LAST_FRAME, 16, 16);
3081+ assert_eq!(stack.entries.len(), 1);
3082+ stack.entries[0].weight
3083+ };
3084+ let tiled = weight_with_tile_origin(8);
3085+ let whole_frame = weight_with_tile_origin(0);
3086+ // One scanned row cell (`end_mi == bw4 == 2`, `len == 2`) plus the
3087+ // top-right probe's own flat `CORNER_WEIGHT`, which the reach never
3088+ // touches -- so the whole delta below is the row scan's `inc`.
3089+ // reach -1 -> inc 1 -> weight stays at the floor 2.
3090+ assert_eq!(tiled, REF_CAT_LEVEL + 2 * 2 + CORNER_WEIGHT);
3091+ // frame-edge clamp: reach -6 -> inc min(6, size_h) = 4.
3092+ assert_eq!(whole_frame, REF_CAT_LEVEL + 2 * 4 + CORNER_WEIGHT);
3093+ assert_ne!(tiled, whole_frame);
3094+ }
2914 }3095 }
crates/ec-av1/src/refusal_inventory.rsmodified+2 -1
@@ -42,7 +42,8 @@ const REFUSALS: &[&str] = &[
42 "a tx_type symbol outside its CDF's own set: {t}",42 "a tx_type symbol outside its CDF's own set: {t}",
43 "an INTER 32x32 partition type this decoder does not code (value={part32})",43 "an INTER 32x32 partition type this decoder does not code (value={part32})",
44 "a superblock-level partition value outside PARTITION_NONE..PARTITION_VERT_4",44 "a superblock-level partition value outside PARTITION_NONE..PARTITION_VERT_4",
45- "a 128x128 superblock partition other than SPLIT (NONE/HORZ/VERT and the four AB arms at the 128 root are not decoded)",45+ "a 128x128 superblock HORZ/VERT or AB partition (only SPLIT and NONE are decoded at the 128 root)",
46+ "a 128x128 superblock PARTITION_NONE root on an inter frame (only the key-frame path codes a whole 128x128 block)",
46 "intrabc under a 128x128 superblock (libaom's av1_is_dv_valid derives the block-vector delay from sb_size, which this decoder hardcodes to 64)",47 "intrabc under a 128x128 superblock (libaom's av1_is_dv_valid derives the block-vector delay from sb_size, which this decoder hardcodes to 64)",
47 "a palette block on a HORZ/VERT intra strip below 16x16 (reconstruction not ported)",48 "a palette block on a HORZ/VERT intra strip below 16x16 (reconstruction not ported)",
48 "a palette block with a real transform on a superblock-level HORZ/VERT strip (corner-cropped luma coefficients not ported for palette)",49 "a palette block with a real transform on a superblock-level HORZ/VERT strip (corner-cropped luma coefficients not ported for palette)",
crates/ec-av1/src/stream.rsmodified+449 -0
@@ -14395,6 +14395,299 @@ mod tests {
14395 a_real_aomenc_temporal_mv_gate(42, 40);14395 a_real_aomenc_temporal_mv_gate(42, 40);
14396 }14396 }
14397 14397
14398+ /// lane-mvtwin r1: the COMPOUND MV-stack gate. Every other compound gate
14399+ /// here pins `--enable-ref-frame-mvs=0`, so `find_mv_stack_compound`'s
14400+ /// temporal half (the three `tpl_sample_pos` extension samples lane-sb128
14401+ /// r3 found missing) and its extension pass have never been exercised by
14402+ /// a real encoder. This arm turns ref-frame-mvs ON, gives the encoder a
14403+ /// 25-frame lookahead plus alt-refs so `reference_select` really drives
14404+ /// blocks to COMPOUND_REFERENCE, and sweeps global motion off/on so the
14405+ /// combine step's `gm_mv_candidates` fill (r1 defect 1) is reachable.
14406+ ///
14407+ /// Firing proof, hard-asserted: `decode::comp_mode_hits` (a real
14408+ /// compound block) AND `mvstack::tmv_hits` (a temporal candidate landed
14409+ /// in some stack) must BOTH have advanced on an attempt that also
14410+ /// decoded pixel-exact -- class [[gate-skips-on-its-own-failure]]: a
14411+ /// decode that succeeds is ALWAYS compared, on every decode-order frame,
14412+ /// and only the counters decide whether the attempt counts.
14413+ fn a_real_aomenc_compound_mv_stack_gate(
14414+ gate_name: &str,
14415+ seed_base: u32,
14416+ attempts: u32,
14417+ bit_depth: u32,
14418+ sb_size: u32,
14419+ global_motion: u32,
14420+ width: usize,
14421+ tile_columns: u32,
14422+ ) {
14423+ let _gate_lock = lock_gate_counters();
14424+ if !have_ffmpeg() {
14425+ eprintln!("SKIP {gate_name}: no ffmpeg");
14426+ return;
14427+ }
14428+ if !have_aomenc() {
14429+ eprintln!("SKIP {gate_name}: no aomenc at {}", aomenc_path().display());
14430+ return;
14431+ }
14432+ let (height, frame_count) = (64usize, 16usize);
14433+ let mut never_fired = 0u32;
14434+ let mut refusals = Vec::new();
14435+ for attempt in 0..attempts {
14436+ let seed = seed_base + attempt;
14437+ let duration = frame_count as f64 / 25.0;
14438+ let source =
14439+ gradients_source(seed, width, height, &format!("duration={duration}:rate=25"));
14440+ let y4m = Command::new("ffmpeg")
14441+ .args([
14442+ "-v",
14443+ "error",
14444+ "-f",
14445+ "lavfi",
14446+ "-i",
14447+ &source,
14448+ "-pix_fmt",
14449+ if bit_depth == 10 { "yuv420p10le" } else { "yuv420p" },
14450+ "-strict",
14451+ "-1",
14452+ "-t",
14453+ "0.64",
14454+ "-f",
14455+ "yuv4mpegpipe",
14456+ "-strict",
14457+ "-1",
14458+ "-",
14459+ ])
14460+ .stdin(Stdio::null())
14461+ .stdout(Stdio::piped())
14462+ .stderr(Stdio::piped())
14463+ .output()
14464+ .expect("ffmpeg failed to run");
14465+ assert!(
14466+ y4m.status.success(),
14467+ "ffmpeg fixture: {}",
14468+ String::from_utf8_lossy(&y4m.stderr)
14469+ );
14470+ let depth_args: &[&str] = if bit_depth == 10 {
14471+ &["-b", "10", "--input-bit-depth=10"]
14472+ } else {
14473+ &[]
14474+ };
14475+ // The cq sweep: how finely RD partitions decides how often a
14476+ // block's stack comes up short enough to reach the extension
14477+ // pass at all.
14478+ let cq = format!("--cq-level={}", [45u32, 55, 35][(attempt % 3) as usize]);
14479+ let sb = format!("--sb-size={sb_size}");
14480+ let gm = format!("--enable-global-motion={global_motion}");
14481+ // `--tile-columns` is log2: 1 means two tile columns, which is
14482+ // what makes every block in the right-hand tile carry a nonzero
14483+ // `tile_col0` and so exercise r1 defect 3's reach clamp.
14484+ let tiles = format!("--tile-columns={tile_columns}");
14485+ // class [[aomenc-last-flag-wins]]: every flag appears exactly
14486+ // once below, so there is no override to order.
14487+ let out = {
14488+ let mut child = Command::new(aomenc_path())
14489+ .args(depth_args)
14490+ .arg(&cq)
14491+ .arg(&sb)
14492+ .arg(&gm)
14493+ .arg(&tiles)
14494+ .args([
14495+ "--codec=av1",
14496+ "--passes=1",
14497+ "--end-usage=q",
14498+ "--cpu-used=0",
14499+ "--kf-max-dist=1000",
14500+ "--threads=1",
14501+ "--row-mt=0",
14502+ // What this gate is about: real compound references
14503+ // with a real temporal MV field behind them.
14504+ "--enable-ref-frame-mvs=1",
14505+ "--enable-order-hint=1",
14506+ "--auto-alt-ref=1",
14507+ "--lag-in-frames=25",
14508+ "--enable-fwd-kf=0",
14509+ "--enable-warped-motion=0",
14510+ "--enable-obmc=0",
14511+ "--enable-masked-comp=0",
14512+ "--enable-interintra-comp=0",
14513+ "--enable-dist-wtd-comp=0",
14514+ "--enable-diff-wtd-comp=0",
14515+ "--enable-onesided-comp=0",
14516+ "--enable-interintra-wedge=0",
14517+ "--enable-smooth-interintra=0",
14518+ "--enable-rect-partitions=0",
14519+ "--enable-ab-partitions=0",
14520+ "--enable-1to4-partitions=0",
14521+ "--enable-filter-intra=0",
14522+ "--enable-smooth-intra=0",
14523+ "--enable-paeth-intra=0",
14524+ "--enable-directional-intra=0",
14525+ "--enable-angle-delta=0",
14526+ "--enable-tx-size-search=0",
14527+ "--enable-cdef=0",
14528+ "--enable-restoration=0",
14529+ "--max-partition-size=32",
14530+ "--min-partition-size=32",
14531+ "--enable-palette=0",
14532+ "--enable-intrabc=0",
14533+ "--enable-cfl-intra=0",
14534+ "--obu",
14535+ "-o",
14536+ "-",
14537+ "-",
14538+ ])
14539+ .stdin(Stdio::piped())
14540+ .stdout(Stdio::piped())
14541+ .stderr(Stdio::piped())
14542+ .spawn()
14543+ .expect("aomenc failed to start");
14544+ child
14545+ .stdin
14546+ .take()
14547+ .expect("aomenc stdin")
14548+ .write_all(&y4m.stdout)
14549+ .expect("writing y4m to aomenc");
14550+ child.wait_with_output().expect("aomenc failed to run")
14551+ };
14552+ assert!(
14553+ out.status.success(),
14554+ "aomenc refused the fixture: {}",
14555+ String::from_utf8_lossy(&out.stderr)
14556+ );
14557+ let stream = out.stdout;
14558+ let (before_comp, before_tmv) = (decode::comp_mode_hits(), decode::tmv_hits());
14559+ let frames = match decode_stream(&stream) {
14560+ Err(e) => {
14561+ let msg = e.to_string();
14562+ assert!(
14563+ msg.contains("unsupported"),
14564+ "{gate_name} failed outright (seed {seed}): {msg}"
14565+ );
14566+ refusals.push(format!("seed {seed}: {msg}"));
14567+ continue;
14568+ }
14569+ Ok(frames) => frames,
14570+ };
14571+ let counted =
14572+ decode::comp_mode_hits() != before_comp && decode::tmv_hits() != before_tmv;
14573+ if !counted {
14574+ never_fired += 1;
14575+ }
14576+ let ffmpeg_frames = if bit_depth == 10 {
14577+ ffmpeg_decode_sequence_10bit(&stream, width, height, frame_count)
14578+ } else {
14579+ ffmpeg_decode_sequence(&stream, width, height, frame_count)
14580+ };
14581+ assert_eq!(frames.len(), frame_count);
14582+ // EVERY decode-order frame compared, never just the shown ones
14583+ // (class [[gate-blind-to-hidden-frames]]).
14584+ for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() {
14585+ assert_eq!(
14586+ got.y, want.y,
14587+ "{gate_name} frame {i} luma vs ffmpeg (seed {seed})"
14588+ );
14589+ assert_eq!(
14590+ got.u, want.u,
14591+ "{gate_name} frame {i} U vs ffmpeg (seed {seed})"
14592+ );
14593+ assert_eq!(
14594+ got.v, want.v,
14595+ "{gate_name} frame {i} V vs ffmpeg (seed {seed})"
14596+ );
14597+ }
14598+ if counted {
14599+ eprintln!(
14600+ "{gate_name} FIRING seed {seed}: comp_mode_hits +{}, tmv_hits +{}, \
14601+ comp_gm_fill_hits={}, stack_full_drops={}, tile_reach_clips={}",
14602+ decode::comp_mode_hits() - before_comp,
14603+ decode::tmv_hits() - before_tmv,
14604+ crate::mvstack::comp_gm_fill_hits(),
14605+ crate::mvstack::stack_full_drops(),
14606+ crate::mvstack::tile_reach_clips(),
14607+ );
14608+ gate_buckets(gate_name, 1, never_fired, refusals.len());
14609+ return;
14610+ }
14611+ }
14612+ gate_buckets(gate_name, 0, never_fired, refusals.len());
14613+ eprintln!(
14614+ "SKIP {gate_name}: {never_fired} attempts decoded but never drove a compound block \
14615+ with a temporal MV candidate, and every other attempt hit a named refusal:\n{}",
14616+ refusals.join("\n")
14617+ );
14618+ }
14619+
14620+ #[test]
14621+ fn a_real_aomenc_compound_mv_stack_with_temporal_mvs_decodes_pixel_exact() {
14622+ a_real_aomenc_compound_mv_stack_gate(
14623+ "a_real_aomenc_compound_mv_stack_with_temporal_mvs_decodes_pixel_exact",
14624+ 42,
14625+ 30,
14626+ 8,
14627+ 64,
14628+ 0,
14629+ 64,
14630+ 0,
14631+ );
14632+ }
14633+
14634+ #[test]
14635+ fn a_real_aomenc_compound_mv_stack_with_global_motion_decodes_pixel_exact() {
14636+ a_real_aomenc_compound_mv_stack_gate(
14637+ "a_real_aomenc_compound_mv_stack_with_global_motion_decodes_pixel_exact",
14638+ 80,
14639+ 30,
14640+ 8,
14641+ 64,
14642+ 1,
14643+ 64,
14644+ 0,
14645+ );
14646+ }
14647+
14648+ #[test]
14649+ fn a_real_aomenc_10bit_compound_mv_stack_at_128_superblocks_decodes_pixel_exact() {
14650+ a_real_aomenc_compound_mv_stack_gate(
14651+ "a_real_aomenc_10bit_compound_mv_stack_at_128_superblocks_decodes_pixel_exact",
14652+ 120,
14653+ 30,
14654+ 10,
14655+ 128,
14656+ 1,
14657+ 64,
14658+ 0,
14659+ );
14660+ }
14661+
14662+ /// KNOWN OPEN DEFECT, found by lane-mvtwin r1 and NOT caused by it: a
14663+ /// real aomenc stream 128 px wide with `--tile-columns=1` (two 64-px tile
14664+ /// columns) mis-decodes frame 1's luma against ffmpeg, at seed 200 with
14665+ /// this exact recipe. ABLATION-PROVEN pre-existing: the same arm fails
14666+ /// identically with r1's tile-origin reach clamp
14667+ /// (`MiGrid::tile_origin`) forced back to `(0, 0)`, so the cause is
14668+ /// somewhere else in the multi-tile path, not in `mvstack`. Kept as the
14669+ /// exact reproducer for the lane that owns tiles -- it is `#[ignore]`d
14670+ /// rather than deleted so the repro command survives:
14671+ /// `cargo test -p ec-av1 --lib across_two_tile_columns -- --ignored --nocapture`.
14672+ ///
14673+ /// It is also the ONLY arm that reaches r1 defect 3 (the col reach is
14674+ /// clamped to `tile_col0`, not the frame edge): the counter
14675+ /// `mvstack::tile_reach_clips` advanced to 60 on this stream. Defect 3
14676+ /// itself is proven deterministically by
14677+ /// `mvstack::tests::the_row_reach_is_clamped_to_the_tile_origin_not_the_frame_edge`.
14678+ #[test]
14679+ #[ignore = "known pre-existing multi-tile-column decode defect, see doc comment"]
14680+ fn a_real_aomenc_compound_mv_stack_across_two_tile_columns_decodes_pixel_exact() {
14681+ let name = "a_real_aomenc_compound_mv_stack_across_two_tile_columns_decodes_pixel_exact";
14682+ let before = crate::mvstack::tile_reach_clips();
14683+ a_real_aomenc_compound_mv_stack_gate(name, 200, 30, 8, 64, 0, 128, 1);
14684+ assert!(
14685+ crate::mvstack::tile_reach_clips() > before,
14686+ "{name}: no block was ever built inside a tile past mi 0 -- \
14687+ --tile-columns=1 did not produce a second tile column"
14688+ );
14689+ }
14690+
14398 /// bisect scratch: decode a pinned stream exactly once -- generic14691 /// bisect scratch: decode a pinned stream exactly once -- generic
14399 /// pin-repro tool, kept for manual use.14692 /// pin-repro tool, kept for manual use.
14400 #[test]14693 #[test]
@@ -18001,6 +18294,162 @@ mod tests {
18001 );18294 );
18002 }18295 }
18003 18296
18297+ /// lane-sb128b r1 gate: a real `aomenc --sb-size=128` KEY frame whose 128
18298+ /// roots resolve to `PARTITION_NONE` -- one whole 128x128 intra block,
18299+ /// four TX_64X64 luma transform units and FOUR TX_32X32 chroma units per
18300+ /// plane (`av1_get_max_uv_txsize(BLOCK_128X128)` is
18301+ /// `av1_get_adjusted_tx_size` of its 64x64 uv plane block's TX_64X64, so
18302+ /// TX_32X32) -- lane-sb128b r2's `chroma_split_tx_hits` asserts them. The r1 gate above pins `--max-partition-size=64`, which
18303+ /// makes every 128 root a forced SPLIT and leaves this arm unexercised.
18304+ /// Smooth gradients at a high `--cq-level` are what make the RD search
18305+ /// keep a whole 128x128 block; `part128_none_hits` HARD-asserts it did.
18306+ #[test]
18307+ fn a_real_aomenc_key_frame_with_a_128x128_none_partition_decodes_pixel_exact() {
18308+ const NAME: &str =
18309+ "a_real_aomenc_key_frame_with_a_128x128_none_partition_decodes_pixel_exact";
18310+ let _gate_lock = lock_gate_counters();
18311+ if !have_ffmpeg() {
18312+ eprintln!("SKIP {NAME}: no ffmpeg");
18313+ return;
18314+ }
18315+ if !have_aomenc() {
18316+ eprintln!("SKIP {NAME}: no aomenc at {}", aomenc_path().display());
18317+ return;
18318+ }
18319+ let render = |seed: u32, width: usize, height: usize, ten_bit: bool| -> Vec<u8> {
18320+ let pix = if ten_bit { "yuv420p10le" } else { "yuv420p" };
18321+ let out = Command::new("ffmpeg")
18322+ .args([
18323+ "-v", "error", "-f", "lavfi", "-i",
18324+ &gradients_source(seed, width, height, "duration=0.04:rate=25"),
18325+ "-pix_fmt", pix, "-strict", "-1", "-t", "0.04",
18326+ "-f", "yuv4mpegpipe", "-",
18327+ ])
18328+ .stdin(Stdio::null())
18329+ .stdout(Stdio::piped())
18330+ .stderr(Stdio::piped())
18331+ .output()
18332+ .expect("ffmpeg failed to run");
18333+ assert!(
18334+ out.status.success(),
18335+ "ffmpeg fixture: {}",
18336+ String::from_utf8_lossy(&out.stderr)
18337+ );
18338+ out.stdout
18339+ };
18340+ let mut matched = 0u32;
18341+ let mut named_refusals = 0u32;
18342+ let mut none_arms = 0u32;
18343+ // (seed, cq, width, height, 10-bit). 384x384 is a 3x3 grid of whole
18344+ // 128 superblocks; 256x256 a 2x2.
18345+ let arms: Vec<(u32, &str, usize, usize, bool)> = vec![
18346+ (42, "--cq-level=63", 384, 384, false),
18347+ (43, "--cq-level=55", 384, 384, false),
18348+ (44, "--cq-level=63", 256, 256, false),
18349+ (45, "--cq-level=63", 384, 384, true),
18350+ ];
18351+ for (seed, cq, width, height, ten_bit) in arms {
18352+ let y4m = render(seed, width, height, ten_bit);
18353+ let mut args: Vec<&str> = vec![
18354+ "--codec=av1", "--passes=1", "--end-usage=q", cq,
18355+ "--cpu-used=0", "--threads=1", "--row-mt=0",
18356+ "--sb-size=128",
18357+ "--enable-rect-partitions=0",
18358+ "--enable-ab-partitions=0",
18359+ "--enable-1to4-partitions=0",
18360+ "--min-partition-size=16",
18361+ "--enable-restoration=1",
18362+ "--enable-palette=0",
18363+ "--deltaq-mode=0",
18364+ "--enable-intrabc=0",
18365+ "--enable-tx-size-search=0",
18366+ "--limit=1",
18367+ ];
18368+ if ten_bit {
18369+ args.extend_from_slice(&["--input-bit-depth=10", "--bit-depth=10"]);
18370+ }
18371+ args.extend_from_slice(&["--obu", "-o", "-", "-"]);
18372+ let mut child = Command::new(aomenc_path())
18373+ .args(&args)
18374+ .stdin(Stdio::piped())
18375+ .stdout(Stdio::piped())
18376+ .stderr(Stdio::piped())
18377+ .spawn()
18378+ .expect("aomenc failed to start");
18379+ child
18380+ .stdin
18381+ .take()
18382+ .expect("aomenc stdin")
18383+ .write_all(&y4m)
18384+ .expect("writing y4m to aomenc");
18385+ let out = child.wait_with_output().expect("aomenc failed to run");
18386+ assert!(
18387+ out.status.success(),
18388+ "aomenc refused the fixture: {}",
18389+ String::from_utf8_lossy(&out.stderr)
18390+ );
18391+ let stream = out.stdout;
18392+ let before = crate::decode::part128_none_hits();
18393+ let frames = match decode_stream(&stream) {
18394+ Err(e) => {
18395+ let msg = e.to_string();
18396+ assert!(
18397+ msg.contains("unsupported"),
18398+ "{NAME} failed outright, not a named refusal (seed {seed}): {msg}"
18399+ );
18400+ named_refusals += 1;
18401+ eprintln!("seed {seed} refusal: {msg}");
18402+ continue;
18403+ }
18404+ Ok(frames) => frames,
18405+ };
18406+ let want = if ten_bit {
18407+ ffmpeg_decode_sequence_10bit(&stream, width, height, 1)
18408+ } else {
18409+ ffmpeg_decode_sequence(&stream, width, height, 1)
18410+ };
18411+ assert_eq!(frames.len(), 1);
18412+ for (i, (got, want)) in frames.iter().zip(&want).enumerate() {
18413+ for (name, a, b, w) in [
18414+ ("Y", &got.y, &want.y, width),
18415+ ("U", &got.u, &want.u, width / 2),
18416+ ("V", &got.v, &want.v, width / 2),
18417+ ] {
18418+ let n = a.iter().zip(b.iter()).filter(|(x, y)| x != y).count();
18419+ let first = a.iter().zip(b.iter()).position(|(x, y)| x != y);
18420+ assert_eq!(
18421+ n, 0,
18422+ "{NAME} frame {i} {name} vs ffmpeg (seed {seed}): {n} differ, first row {} col {} ours {:?} ffmpeg {:?}",
18423+ first.unwrap_or(0) / w,
18424+ first.unwrap_or(0) % w,
18425+ first.map(|k| a[k]),
18426+ first.map(|k| b[k]),
18427+ );
18428+ }
18429+ }
18430+ let hits = crate::decode::part128_none_hits() - before;
18431+ eprintln!("seed {seed} cq {cq} {width}x{height}: part128_none_hits +{hits}");
18432+ if hits > 0 {
18433+ none_arms += 1;
18434+ }
18435+ matched += 1;
18436+ }
18437+ assert!(
18438+ matched > 0,
18439+ "{NAME}: every attempt refused; the gate never decoded a stream"
18440+ );
18441+ assert!(
18442+ none_arms > 0,
18443+ "{NAME}: {matched} stream(s) decoded pixel-exact but NOT ONE 128 root was \
18444+ PARTITION_NONE -- the arm this gate exists for never fired"
18445+ );
18446+ eprintln!(
18447+ "{NAME}: {matched} pixel-exact ({none_arms} with a 128 NONE root), \
18448+ {named_refusals} named refusals, part128_none_hits={}",
18449+ crate::decode::part128_none_hits()
18450+ );
18451+ }
18452+
18004 #[test]18453 #[test]
18005 #[ignore = "lane-sb128 r2 diagnostic: is the frame-6 mismatch sb128-specific?"]18454 #[ignore = "lane-sb128 r2 diagnostic: is the frame-6 mismatch sb128-specific?"]
18006 fn sb128_r2_control_sb64() {18455 fn sb128_r2_control_sb64() {
lanes/mvtwin-r1.report.mdadded+91 -0
@@ -0,0 +1,91 @@
1+# lane-mvtwin r1 — phase-by-phase diff of the two MV-stack twins vs libaom
2+
3+Base: lane-sb128 5ea5ec8, merged main 7a47fc1 (clean; the 128x128-superblock
4+refusal main re-added at b51719f stayed deleted — grep confirms).
5+Oracle: `~/.cache/aom-oracle/src/av1/common/mvref_common.c` (`setup_ref_mv_list`,
6+`av1_find_mv_refs`). Ours: `crates/ec-av1/src/mvstack.rs`
7+(`find_mv_stack_with_sign_bias` = single-ref twin, `find_mv_stack_compound` = compound twin).
8+
9+## The table (libaom line = mvref_common.c)
10+
11+| # | phase (libaom) | single-ref ours | compound ours | defect? |
12+|---|---|---|---|---|
13+| 1 | `row_adj`/`col_adj`, `find_valid_row/col_offset` reach (:502-533) | mvstack.rs:809 | mvstack.rs:1610 | **DEFECT 3** — both clamped the reach to the FRAME edge, libaom clamps to `tile->mi_row_start`/`mi_col_start` |
14+| 2 | `scan_row_mbmi` immediate, `len`/`weight`/`inc`/`processed_rows` (:141-190, :534-538) | `scan_row` :471 | `scan_row_compound` :1290 | exact (availability gate was `mi_row > 0`, folded into defect 3) |
15+| 3 | `scan_col_mbmi` (:192-236, :540-543) | `scan_col` :553 | `scan_col_compound` :1347 | exact |
16+| 4 | `has_top_right` + top-right `scan_blk_mbmi` (:264-312, :496, :544-548) | `scan_top_right` :645 | `scan_top_right_compound` :1403 | no change — see "has_tr" below |
17+| 5 | `nearest_match`, `REF_CAT_LEVEL` boost over `nearest_refmv_count` (:550-555) | :836 | :1600 | exact |
18+| 6 | `add_tpl_ref_mv` main loop, `step_h`/`step_w`/`blk_*_end` (:557-589) | :868 | :1625 | exact (compound reads the field once per side; `motion_field.rs:500` makes the lookup offset-independent, so both sides are Some/None together — libaom's single lookup) |
19+| 7 | `tpl_sample_pos` 3 extension samples + `check_sb_border` (:591-600, :316) | :898 | :1670 (added lane-sb128 r3) | exact — the twin drift r3 found, now symmetric |
20+| 8 | `GLOBALMV_OFFSET` / `zero_mv_ctx` far-or-missing test (:375-380, :406-412, :592) | :955 | :1750 | exact |
21+| 9 | corner `scan_blk_mbmi(-1,-1)` with `dummy_newmv_count`, weight `2*len`=4 (:604-607) | :967 | :1758 | exact |
22+| 10 | extended row/col scan `idx = 2..=MVREF_ROW_COLS` (:609-622) | :990 | :1770 | exact |
23+| 11 | `ref_match_count` + `mode_context` switch / `REFMV_OFFSET` (:624-651) | :1140 | :1858 | exact |
24+| 12 | the TWO bubble passes (nearest region, then the rest) (:653-682) | single stable `sort_by_key` :1050 | same :1802 | not a defect — every nearest entry carries `+REF_CAT_LEVEL` (640) and no post-boost entry can reach it (max post-boost weight seen is `len*weight` <= 80), so the two-phase ranking and one stable global sort agree |
25+| 13 | insertion cap `*refmv_count < MAX_REF_MV_STACK_SIZE` (:100, :128, :388, :425) | `add_candidate` :341 | `add_compound_candidate` :1268 | **DEFECT 2** — both pushed unbounded then sorted+truncated, keeping a different set than libaom's drop-at-insertion |
26+| 14 | `mi_size` = min(64x64 span, block span, frame edge) (:684-689) | :1060 | :1815 | exact |
27+| 15 | `process_compound_ref_mv_candidate`, sign-bias inversion, `can_rf > INTRA_FRAME` (:434-470, :693-706) | n/a | :1478 | exact |
28+| 16 | `comp_list` combine, slots past both lists = `gm_mv_candidates[idx]` (:708-720) | n/a | `combine_compound_candidates` :1520 | **DEFECT 1 (twin drift)** — filled `(0, 0)`; the single-ref twin closed the same gm-fallback gap in r6 |
29+| 17 | compound stack merge, `refmv_count==1` dedupe vs empty (:722-742) | n/a | :1845 | exact |
30+| 18 | `clamp_mv_ref` + `MV_BORDER`, every entry (:745-751, :768-772) | :1105 | :1878 | exact |
31+| 19 | single-ref extension gated per step on `MAX_MV_REF_CANDIDATES` (:754-766) | :1065 | n/a | exact |
32+| 20 | `mv_ref_list` tail filled with `gm_mv_candidates[0]`, unclamped (:775-782) | :1128 | n/a (libaom has no compound `mv_ref_list`) | exact |
33+
34+### has_tr (phase 4), why no change
35+Ours probes "is the grid cell at `(mi_row-1, mi_col+bw4)` populated", which for a
36+decoder is exactly "was it decoded". Walking libaom's mask logic: for SQUARE blocks
37+the mask result and "already decoded" coincide at both sb64 and sb128; for the
38+rect case that differs (`bs > 16` at a 64x128 block) libaom's own
39+`is_last_vertical_rect` refinement forces `has_tr = 1` again, agreeing with our
40+probe. Porting the mask WITHOUT the three shape refinements (which need the
41+partition type, not passed to this module) would REGRESS the VERT-rect case.
42+Recorded as the same corner-cut already documented at `mvstack.rs:588`;
43+upgrade path = thread the partition type in with the rect inter leaf.
44+
45+## Fixes (all in crates/ec-av1/src/mvstack.rs)
46+- D1 `combine_compound_candidates` (:1520 + call site :1859): unfilled slots take
47+ `gm_mv(gm, ref_frame.side)`, not `(0, 0)` (mvref_common.c:718-719).
48+- D2 `add_candidate` (:341) / `add_compound_candidate` (:1268): drop the 9th
49+ distinct candidate AT INSERTION (mvref_common.c:100/128/388/425); the dedup
50+ weight bump still applies on a full stack.
51+- D3 both twins (:809, :1610) + new `MiGrid::tile_origin` (:216): reach and
52+ availability are tile-relative (mvref_common.c:512-533).
53+
54+## Checks
55+`cargo test -p ec-av1 --lib mvstack::` -> 32 passed, 0 failed. Three new
56+deterministic tests, one per defect:
57+- `a_missing_compound_combine_slot_takes_that_sides_global_mv_not_zero`
58+- `the_ninth_distinct_candidate_is_dropped_at_insertion_not_after_sorting`
59+- `the_row_reach_is_clamped_to_the_tile_origin_not_the_frame_edge` (644 -> 648 vs 652)
60+
61+New real-aomenc gate `a_real_aomenc_compound_mv_stack_gate` (stream.rs), the first
62+compound gate here that does NOT pin `--enable-ref-frame-mvs=0`:
63+`--enable-ref-frame-mvs=1 --enable-order-hint=1 --auto-alt-ref=1 --lag-in-frames=25`,
64+cq sweep 45/55/35, 30 seeds/arm, hard-asserting BOTH `comp_mode_hits` and
65+`tmv_hits` advanced, every decode-order frame compared (Y/U/V) against ffmpeg,
66+decode errors only tolerated when the message contains "unsupported".
67+Arms: 8-bit sb64 gm=0 · 8-bit sb64 gm=1 · 10-bit sb128 gm=1.
68+
69+EVIDENCE: $HOME/.cache/mvtwin-suite-r1.log | cargo test -p ec-av1 --lib compound_mv_stack -- --test-threads=1 --nocapture | 3 arms FIRING pixel-exact: seed 44 comp_mode_hits +7 tmv_hits +56; seed 80 comp_mode_hits +1 tmv_hits +56; seed 122 (10-bit, sb128) comp_mode_hits +8 tmv_hits +55
70+EVIDENCE: crates/ec-av1/src/mvstack.rs tests | cargo test -p ec-av1 --lib mvstack:: | 32 passed 0 failed, each of the 3 defects asserted on its own values
71+
72+Full suite (systemd unit, MemoryMax=10G): `cargo test -p ec-av1 --lib -j3` ->
73+**375 passed, 0 failed, 33 ignored**, 692 s. Log `$HOME/.cache/mvtwin-suite-r1.log`.
74+
75+EVIDENCE: $HOME/.cache/mvtwin-suite-r1.log | systemd-run --user --unit=mvtwin-suite-... cargo test -p ec-av1 --lib -j3 | test result: ok. 375 passed; 0 failed; 33 ignored
76+
77+## Open residue
78+- fix-now-elsewhere (NOT this lane's surface): a real aomenc stream 128 px wide
79+ with `--tile-columns=1` MIS-DECODES frame 1 luma vs ffmpeg (seed 200, recipe in
80+ `a_real_aomenc_compound_mv_stack_across_two_tile_columns_decodes_pixel_exact`,
81+ `#[ignore]`d with the repro command in its doc). ABLATION-PROVEN pre-existing:
82+ identical failure with r1's tile-origin clamp forced back to `(0, 0)`. That arm
83+ is also the only one that reaches defect 3 on a real stream —
84+ `mvstack::tile_reach_clips` advanced to 60 there.
85+- deferred(a stream whose compound pair names a non-IDENTITY ROTZOOM/AFFINE
86+ reference) — `comp_gm_fill_hits` reads 0 on all three green arms, so D1 is
87+ proven by its unit test, not yet by a real stream. aomenc at gradients content
88+ keeps global motion IDENTITY even with `--enable-global-motion=1`.
89+- deferred(same) — `stack_full_drops` reads 0 on all three arms: no real block
90+ here produced 9 distinct candidates. D2 is unit-test-proven only.
91+- accepted — `has_tr` corner-cut (phase 4 above), ceiling and upgrade path named.
lanes/sb128b-r1.report.mdadded+103 -0
@@ -0,0 +1,103 @@
1+# lane-sb128b r1 — the 128 root's `PARTITION_NONE` arm (key frames)
2+
3+Branch `lane-sb128b` off `lane-sb128` 807c110, worktree `edith_codecs-sb128b`, commit `ceec9fa`.
4+
5+## ReelC first — the charter's premise is FALSE on ReelC's key frame
6+
7+EVIDENCE: `$HOME/.cache/sb128b-work/reelc2s.obu` (fresh cut, `ffmpeg -t 2 -c:v copy -f obu`
8+off the real film, 1428 bytes) | release `decode_probe` under a 6G scope with `EC_AV1_TRACE=1`
9+| **90 `partition_w128` symbols, value=3 (`PARTITION_SPLIT`) on every one** (ctx 3 x70, ctx 2
10+x14, ctx 1 x5, ctx 0 x1); the run then stops at `an inter frame under a 128x128 superblock`.
11+Same numbers on the pre-existing `reelc-head.obu`.
12+
13+So ReelC's KEY frame is 100% SPLIT at the 128 root — the key-frame 128 arms are **not** its
14+blocker, and TASK 4's "the inter arms" is where ReelC's non-SPLIT roots live (r2 saw them only
15+with the inter refusal locally lifted). Charter premise "ReelC's key frame is the first thing to
16+decode / stops at a TASK-B arm" corrected here, measured, not argued.
17+
18+## What landed (all against libaom, each cited)
19+
20+`crates/ec-av1/src/decode.rs`
21+- `read_sb128_root` (11286) returns the root partition; the key-frame loop (11536) decodes
22+ `PARTITION_NONE` as one 128x128 block and skips the superblock's other three visits
23+ (`sb128_none`). The inter loop refuses any non-SPLIT root by name.
24+- `read_tx_size` (10003): `max_txsize_rect_lookup[BLOCK_128X128]` is TX_64X64 → a 128 block
25+ reads BLOCK_64X64's own `tx_size_cat3` and resolves `max_tx >> depth`, and
26+ `get_tx_size_context` is asked about 64, not 128.
27+- `decode_block`: the single-TU arm was `!tx_select || logical_tx == side`. Without `tx_select`
28+ `logical_tx` IS `side` at every size <= 64, so the first half was redundant — and wrong at
29+ 128. Now `logical_tx == side`, and the non-select resolve is `(side.min(64), luma_tx)`, so a
30+ 128 block is always four TX_64X64 units. The TU loop passes the unit's **coefficient** side
31+ (32 at TX_64X64), not its transform side.
32+- `delta_q`/`delta_lf` "this leaf IS the superblock" is now `side == sb_size` (was a hardcoded
33+ 64 plus a `!sb128()` disable) — a NONE 128 root is the whole superblock.
34+- the 128 block's one `cdef_idx` read is copied to all four 64x64 CDEF units (libaom's four
35+ units share one `MB_MODE_INFO`).
36+
37+`crates/ec-av1/src/stream.rs`: new gate (below). `refusal_inventory.rs`: the single
38+"partition other than SPLIT" string splits into three named arms.
39+
40+## Gate
41+
42+`a_real_aomenc_key_frame_with_a_128x128_none_partition_decodes_pixel_exact` — real aomenc
43+`--sb-size=128` with **no** `--max-partition-size` (the r1 gate's flag is exactly what made
44+every 128 root a forced SPLIT), smooth gradients at `--cq-level=63/55`, 384x384 + 256x256,
45+8- and 10-bit, `--enable-tx-size-search=0`. `#[ignore]`d: it is a reproducer, not a pass.
46+
47+EVIDENCE: `cargo test -p ec-av1 --lib -- --nocapture a_real_aomenc_key_frame_with_a_128x128_none`
48+| aomenc 384x384 cq63 seed 42, decoded then compared to ffmpeg | the NONE arm **fires** and the
49+tile decodes end to end (no desync panic, no refusal), but frame 0 luma differs from ffmpeg at
50+138523 of 147456 samples, first at row 0 col 60, magnitudes 1..3 (ours 114/113 where ffmpeg has
51+115) — a reconstruction difference, not an entropy blow-up.
52+
53+Two earlier failures on the way, both fixed and both real defects of the generalisation:
54+`transform.rs:843 index out of bounds (len 64, index 64)` = the redundant `!tx_select` arm
55+above sending a 128-wide inverse transform; then the pixel deltas.
56+
57+## Root cause of the residual (found, not guessed)
58+
59+`av1_get_max_uv_txsize` = `av1_get_adjusted_tx_size(max_txsize_rect_lookup[uv_plane_bsize])`.
60+The uv plane block of a 128x128 is 64x64 → TX_64X64 → **adjusted to TX_32X32**. A 128 block's
61+chroma is therefore FOUR TX_32X32 units per plane, and `decode_block` codes exactly one
62+whole-plane chroma unit. That is the desync, and it also means the charter's
63+"one chroma TU of 64x64 per plane / new chroma TX_64X64 path" is wrong: **no `TxbSet::Chroma64`
64+is needed at all.** I had transcribed the 16 libaom `[TX_64X64][PLANE_TYPE_UV]` CDF tables and
65+wired the variant before finding this; that work is reverted (`cdf.rs`/`cdf_state.rs` are
66+untouched in this commit) rather than shipped as dead code.
67+
68+## Refusals
69+
70+- `a 128x128 superblock HORZ/VERT or AB partition (only SPLIT and NONE are decoded at the 128
71+ root)` — NOT lifted, TASKs 2/3, not started.
72+- `a 128x128 superblock PARTITION_NONE root on an inter frame (...)` — NOT lifted, TASK 4.
73+- `a 128x128 PARTITION_NONE block's chroma (its 64x64 uv plane block is four TX_32X32 units,
74+ and this decoder codes one whole-plane chroma unit per block)` — NEW, guards the arm this
75+ round built. fix-now(r2): give `decode_block` a chroma TU loop (2x2 TX_32X32, `TxbSet::Chroma32`,
76+ per-unit `chroma_skip_ctx`, grids assembled for `record_split_luma`) — unblocked by that loop;
77+ the gate above is the reproducer and flips green the moment it is right.
78+- `intrabc under a 128x128 superblock` — accepted, unchanged.
79+
80+## Suite
81+
82+`cargo test -p ec-av1 --lib` under user unit `sb128b-suite-1788322151.service`,
83+log `$HOME/.cache/sb128b-suite.log` — result appended below by the handoff line in the report
84+message. The 7 rect/AB reds inherited from 807c110 (r2's `deferred: attribute the 7`) are the
85+sibling lane's; this round touched no rect/AB path.
86+
87+## Deferred
88+
89+- deferred: TASK 2/3 (HORZ/VERT + AB at 128) — not started — unblocked by the chroma TU loop
90+ plus rect handling at 128.
91+- deferred: TASK 4 (inter 128 NONE) — refused by name — unblocked by the same loop and the
92+ sibling lane's inter residue.
93+- deferred: `tx_select` at 128 (`read_tx_size` now handles it, cat3 against 64) is UNTESTED —
94+ every gate arm here runs `--enable-tx-size-search=0` — unblocked by an r2 arm with it on.
95+
96+## Suite state at hand-off (honest, incomplete)
97+
98+`sb128b-suite-1788322151.service` was STILL RUNNING when this round hit its tool-call ceiling.
99+At that point the log showed **2 failures, both inherited from 807c110's rect/AB cluster**:
100+`a_real_aomenc_10bit_rect_and_ab_partitions_decode_pixel_exact`,
101+`a_real_aomenc_10bit_stream_with_a_32_level_ab_partition_decodes_pixel_exact`.
102+No total ("test result:" line) yet — read `$HOME/.cache/sb128b-suite.log` for the final count
103+before merging. NOT a clean-suite claim.
lanes/sb128b-r2.report.mdadded+97 -0
@@ -0,0 +1,97 @@
1+# lane-sb128b r2 — ReelC's key frame is BIT-EXACT; the 128 chroma TU loop; the 128 root's residual
2+
3+Branch `lane-sb128b`, worktree `edith_codecs-sb128b`, commits `4e13f60`, `1524838`, `c415a31`
4+(off r1's `d3bc8da` + `git merge main` b51719f, clean).
5+
6+## FIRST: the ReelC KEY-frame pixel check (the charter's first task — first ReelC pixel measurement ever)
7+
8+EVIDENCE: `$HOME/.cache/sb128b-work/{reelckf0.obu,ours.f0.yuv,ref.yuv}` |
9+`ffmpeg -ss 0 -t 2 -c:v copy -frames:v 1 -f obu` off the real film (74 B, 1920x792 yuv420p10le)
10+→ `dump_yuv` (release, 6G scope) vs `ffmpeg -pix_fmt yuv420p10le -f rawvideo` |
11+**`cmp` says BYTES EQUAL — ReelC's key frame decodes BIT-EXACT (4 561 920 bytes, 0 differing samples).**
12+
13+It was NOT exact before the merge. Pre-merge measurement (same artifacts, r1's tree):
14+Y 36448 samples off (max |d| 2), U/V 9483 each (max |d| 4), all inside the bottom partial
15+superblock row — luma rows 765..791 (768 = 6*128, frame is 792 tall) plus 3 deblock rows above,
16+`+1` per 16-row band, ref uniformly flat (this key frame is black). `git merge main` (lane-oddh's
17+odd-frame-size work) removes it entirely. Class: [[stale-premise lanes]] — the lane's base
18+predates the fix.
19+
20+ReelC now stops at `an inter frame under a 128x128 superblock` (probe on the 2 s cut, 72 frame
21+headers parsed) — the sibling lane-sb128 r3's residue, exactly as r1 predicted.
22+
23+## Merge seam (had to be fixed before anything could run)
24+
25+main b51719f re-introduced lane-oddh's blanket refusal `a sequence using 128x128 superblocks on a
26+frame larger than 64x64` (stream.rs) — textually a clean merge, semantically a lane-killer (the
27+ledger's recorded `merge seam` constraint). Deleted, with its inventory line, and its gate
28+`a_real_aomenc_128x128_superblock_stream_is_refused_by_name` turned into
29+`..._decodes_pixel_exact`.
30+
31+EVIDENCE: `cargo test -p ec-av1 --lib -- a_real_aomenc_128x128_superblock_stream gate_coverage` |
32+real aomenc 64x72 mandelbrot `--cpu-used=0 --sb-size=128` (`use_128x128_superblock` asserted in
33+the stream), decoded vs ffmpeg | **ok — 10 passed, 0 failed**; the frame's Y/U/V match ffmpeg
34+sample for sample. One recipe change was needed and is unrelated to the 128 root: at 64x72
35+aomenc also picks `PARTITION_HORZ_4` below 16x16, so the gate now passes
36+`--enable-1to4-partitions=0 --min-partition-size=16` (gate_coverage green with it).
37+
38+## TASK A — the chroma half of a 128x128 `PARTITION_NONE` block (landed, not yet exact)
39+
40+`crates/ec-av1/src/decode.rs`
41+- `decode_block`'s multi-TU arm now codes `cn = chroma_side / chroma_tx` **squared** chroma units
42+ per plane instead of one whole-plane unit. `av1_get_max_uv_txsize(BLOCK_128X128)` =
43+ `av1_get_adjusted_tx_size(max_txsize_rect_lookup[BLOCK_64X64])` = TX_32X32, so a 128 block is
44+ 2x2 TX_32X32 per plane; `cn == 1` (every block at 64 and below) is byte-for-byte the read this
45+ always did. Per unit: `around_mi` gathered over the unit's own 64-luma-pixel span (which is
46+ also its `txb_skip_ctx`, `read_plane`'s chroma branch), `tu_reach` on the matching luma
47+ quadrant, own `set_palette_pred`.
48+- `Neighbours::record_mi_chroma` (new, next to `record_mi_luma`): per-unit chroma coefficient
49+ context, luma-mi indexed with `record_split_luma_rect_mi`'s own frame-edge clamp. Applied
50+ AFTER `record_split_luma` so the per-unit state is what the next block reads.
51+- The `skip` arm predicts per transform unit now (libaom predicts inside the transform-block
52+ loop); `n_axis == 1` / `cn == 1` is the unchanged whole-block call.
53+- counter `chroma_split_tx_hits()`.
54+
55+**Result: not pixel-exact, so the refusal is BACK, reworded to what was measured.**
56+EVIDENCE: `$HOME/.cache/sb128b-work/g42.obu` (the gate's own arm reproduced by hand: gradients
57+seed 42, 384x384, cq63, `--sb-size=128 --cpu-used=0 --enable-tx-size-search=0`) | `dump_yuv` vs
58+`ffmpeg -pix_fmt yuv420p` | 139162/147456 luma samples differ, first at row 0 col 60 (ours 114,
59+ffmpeg 115). **ffmpeg's row 0 is a CONSTANT 115 across the whole first unit where ours ramps
60+115 → 112**, and the stream is 76 bytes: the mode and the DC agree, our first TX_64X64 luma unit
61+reads AC coefficients libaom never wrote. So the divergence is inside that unit's coefficient
62+read, not in chroma and not in prediction.
63+
64+Refusal now reads: `a 128x128 PARTITION_NONE block (four TX_64X64 luma and four TX_32X32 chroma
65+units all decode, but the first unit's coefficients already carry AC where libaom has DC only --
66+lane-sb128b r2's open entropy residual)`. Gate
67+`a_real_aomenc_key_frame_with_a_128x128_none_partition_decodes_pixel_exact` stays `#[ignore]`d as
68+the reproducer, with its plane asserts rewritten to LOCATE the divergence (count + first
69+row/col/values) instead of printing 147 456 samples.
70+
71+Also corrected in that gate's doc: r1 wrote "ONE TX_64X64 chroma unit per plane / `TxbSet::Chroma64`";
72+the truth is four TX_32X32 and no `Chroma64` set exists or is needed.
73+
74+## Not done
75+
76+- deferred: TASK A's `tx_select` at 128 arm (`--enable-tx-size-search=1`) — not added — unblocked
77+ by the NONE arm being exact at all (an inexact arm cannot gate a tx-depth counter).
78+- deferred: TASK B (HORZ/VERT + AB at 128) — not started, refused by name
79+ (`a 128x128 superblock HORZ/VERT or AB partition`) — unblocked by the same residual.
80+- deferred: TASK C (inter 128) — not started, refused by name on both this tree and the sibling's
81+ (`an inter frame under a 128x128 superblock`) — unblocked by lane-sb128 r3 lifting its inter
82+ root refusal; nothing of TASK C was written, so nothing is "ready behind" it.
83+- `git merge lane-sb128` NOT done: the sibling's tip is `dbf15a4` (gate-recipe fix only, no
84+ inter-128 lift yet), so there was nothing to take.
85+
86+## Suite
87+
88+r2's first run (`$HOME/.cache/sb128b-suite-r2.log`, unit `sb128b-suite-r2-1788322817.service`) was
89+armed at the intermediate commit `1524838` and is superseded. Its FAILED list: the 2 rect/AB reds
90+inherited from 807c110 (`a_real_aomenc_10bit_rect_and_ab_partitions_decode_pixel_exact`,
91+`a_real_aomenc_10bit_stream_with_a_32_level_ab_partition_decodes_pixel_exact`) — **still red after
92+`git merge main` b51719f, so main did NOT fix them** — plus the two 128 gates that this round's
93+final commit resolves (`..._128x128_superblock_stream...` now green,
94+`..._128x128_none_partition...` now `#[ignore]`d).
95+The authoritative run for `c415a31` is unit `sb128b-suite-r2b-1788323051.service` →
96+`$HOME/.cache/sb128b-suite-r2b.log`; it was still running at this round's tool-call ceiling.
97+NOT a clean-suite claim: read that log for the totals before merging.
lanes/sb128b-r3.report.mdadded+101 -0
@@ -0,0 +1,101 @@
1+# lane-sb128b r3 — the 128x128 PARTITION_NONE block decodes PIXEL-EXACT (3 root causes), the 10-bit reds were a recipe defect
2+
3+Branch `lane-sb128b`, worktree `edith_codecs-sb128b`, commits `dd6f934` (merge main 7a47fc1 + TASK B),
4+`f2b6f1c` (TASK A), `7ceb309` (merge main 18bf7dc / lane-sb128 5ea5ec8).
5+
6+## TASK A — the 128 NONE residual: THREE root causes, none of them where r2 pointed
7+
8+r2 read "our first TX_64X64 luma unit reads AC coefficients libaom never wrote". Measured with a
9+range ladder (instrumented `aomdec` `EC_TRACE_COEFF` vs our `EC_TRACE_COEFF`) that premise is
10+WRONG: the first luma unit is identical symbol for symbol and range for range
11+(`all_zero ctx=1 rng=59208 / eob=3 rng=41268 / base_eob level=5 rng=44688 / ... / rng=36616`).
12+The divergence is at the SECOND element of the block, and it is three separate defects:
13+
14+1. **Plane order.** libaom's `decode_token_recon_block` loops 64x64 luma "mu" chunks
15+ (`mu_blocks_wide/high = mi_size_wide[BLOCK_64X64]`) and codes EVERY PLANE of a chunk before the
16+ next chunk. The oracle ladder is Y(0,0) U(0,0) V(0,0) Y(0,16) U(0,8) V(0,8) ... — Y,U,V per
17+ quadrant. We read all four luma units and then all chroma units. Below 128 a block is one chunk,
18+ so the fix (`nchunk = side/64`, luma TUs then chroma units per chunk) is byte-for-byte the old
19+ order at every size the decoder already handled.
20+2. **The chroma `txb_skip_ctx` offset.** `get_txb_ctx`: chroma ctx is
21+ `combine_entropy_contexts(above,left)` **+7** normally, **+10** when the plane block is LARGER
22+ than the transform. A 128 block's 64x64 uv plane block with TX_32X32 units is AV1's only such
23+ case, and our chroma table only ever carried the offset-7 rows (`txb_skip_chroma_*: [[u16;3];3]`).
24+ Oracle read ctx=10, we read ctx=0. Added `TXB_SKIP_CHROMA_32_BIG{,_Q0,_Q1,_Q3}` from
25+ `av1_default_txb_skip_cdfs[q][TX_32X32][10..13]` (token_cdfs.h, all four q contexts, verified by
26+ re-deriving the existing offset-7 rows from the same array), `txb_skip_chroma_32` is six rows,
27+ caller adds 3 when `cn > 1`.
28+3. **Deferred chroma context writes.** r2 recorded each chroma unit's coefficient context only
29+ after the whole block, so the second quadrant read ctx 10 where the oracle reads 11 (base 1 from
30+ its left neighbour inside the same block). Now recorded per unit inside the loop; the
31+ post-`record_split_luma` replay stays, because that call would otherwise clobber them whole-block.
32+
33+Files: `crates/ec-av1/src/decode.rs` (mu-chunk loop + `chroma_ctx_offset` + per-unit record +
34+`read_plane`'s chroma `skip_ctx`), `crates/ec-av1/src/cdf.rs` (4 tables),
35+`crates/ec-av1/src/cdf_state.rs` (`txb_skip_chroma_32` 3 -> 6 rows).
36+
37+EVIDENCE: `$HOME/.cache/sb128b-work/{s44.obu,ref44.yuv,ours44.yuv.f0.yuv,ref.ladder}` |
38+aomenc gate-arm-3 recipe (seed 44 gradients 256x256 cq63 `--sb-size=128 --cpu-used=0
39+--enable-tx-size-search=0 ...`), `EC_TRACE_COEFF` ladders of aomdec and `dump_yuv`, then
40+`dump_yuv` vs `ffmpeg -pix_fmt yuv420p` | **48 `txb_skip` symbols, ranges identical one for one;
41+0 of 98304 samples differ (pixel-exact)**. Before the fix: 60857 luma samples differed.
42+
43+REFUSAL LIFTED (with its gate): `a 128x128 PARTITION_NONE block (...)` deleted from `decode.rs` and
44+`refusal_inventory.rs`; `a_real_aomenc_key_frame_with_a_128x128_none_partition_decodes_pixel_exact`
45+un-`#[ignore]`d.
46+EVIDENCE: `cargo test -p ec-av1 --lib -- a_real_aomenc_key_frame_with_a_128x128_none_partition_decodes_pixel_exact --nocapture` |
47+4 real-aomenc arms (384x384 seed 42 cq63, 384x384 seed 43 cq55, 256x256 seed 44 cq63, 384x384 seed 45
48+10-bit) decoded vs ffmpeg | **ok — 4/4 pixel-exact, 0 named refusals, `part128_none_hits=31`**
49+(9+9+4+9 128-NONE roots). Sibling gates `a_real_aomenc_128x128_superblock_stream_decodes_pixel_exact`,
50+`refusal_inventory`, `gate_coverage` re-run green in the same invocation (14 passed / 0 failed).
51+
52+## TASK B — the 2 inherited 10-bit reds were an ENCODER RECIPE defect
53+
54+`git show main:crates/ec-av1/src/stream.rs` vs the lane's: r2 rewrote `--min-partition-size=16` to
55+`32` at **13** call sites that main has at 16, including both failing gates. 32 removes the 16-level
56+the rect/AB gates assert. Reverted all 13 (the lane's own two 128 gates keep their deliberate 32).
57+EVIDENCE: `cargo test -p ec-av1 --lib -- a_real_aomenc_10bit_rect_and_ab_partitions_decode_pixel_exact a_real_aomenc_10bit_stream_with_a_32_level_ab_partition_decodes_pixel_exact refusal_inventory gate_coverage` |
58+recipe reverted, rebuilt, re-run | **ok — 14 passed, 0 failed**. Class:
59+[[gate-recipe-confound]] / the ledger's "a gate that decodes pixel-exact with counter 0 is an
60+encoder-recipe defect". Swept: those 13 are every 16->32 rewrite in the lane.
61+
62+## TASK C — merges
63+
64+`git merge main` twice: 7a47fc1 (one conflict, `decode.rs`'s skipped-block arm: took main's
65+lane-hgkf per-TU prediction + `true_width` guard + `SKIP_SPLIT_TX_HITS`, broadened its condition
66+from `tx_select && logical_tx < side` to `logical_tx < side` because a 128 block's transform is
67+TX_64X64 with no tx-depth syntax; the counter keeps its narrow `tx_select` meaning), then 18bf7dc
68+(= lane-sb128 5ea5ec8; three conflicts in `stream.rs`, ALL resolved to main's side per the batch
69+coordinator, so main's single seam gate `a_real_aomenc_128x128_superblock_stream_decodes_pixel_exact`
70+survives and lane-oddh's seam refusal stays deleted). `cdf.rs` merged clean; its NZ_MAP and
71+FILTER_INTRA regions are byte-identical to main's (`git diff main -- crates/ec-av1/src/cdf.rs` shows
72+only the four new `TXB_SKIP_CHROMA_32_BIG*` tables).
73+
74+## Suite
75+
76+EVIDENCE: `$HOME/.cache/sb128b-suite-r3.log` (unit `sb128b-suite-r3-1788323779.service`, tip
77+`7ceb309`) | `EC_NOMEMGUARD=1 EC_AV1_REQUIRE_AOMENC=1 cargo test -p ec-av1 --lib -j3` |
78+**test result: ok. 371 passed; 0 failed; 32 ignored; 473.61s** — GREEN.
79+
80+## ReelC key frame
81+
82+EVIDENCE: `$HOME/.cache/sb128b-work/{reelckf0.obu,reelcours.yuv.f0.yuv,ref.yuv}` | r2's recipe
83+(`ffmpeg -t 2 -c:v copy -f obu` off the film, 1920x792 yuv420p10le), `dump_yuv` under a 6G scope vs
84+ffmpeg's rawvideo | **`cmp` says BYTES EQUAL — 4 561 920 bytes, 0 differing samples.**
85+
86+Film probe on the 2 s cut (`decode_probe reelc2s.obu`) still stops at
87+`an inter frame under a 128x128 superblock (this decoder's inter tile path recurses a 64x64
88+superblock root only)` — main 18bf7dc (lane-sb128 5ea5ec8) did NOT lift this one on this tree.
89+
90+## Open residue
91+
92+- deferred: `a 128x128 superblock HORZ/VERT or AB partition` — not started; every 128 root in the
93+ four gate arms resolves NONE or SPLIT, so nothing here is measured. Unblocked by an aomenc recipe
94+ that actually emits a 128-level HORZ/VERT (r2's seed-42 "HORZ/VERT at 128" sighting was our own
95+ desync talking — class [[refusal-from-own-desync]]: with the entropy fixed, that same stream
96+ reads nine NONE roots).
97+- deferred: `a 128x128 superblock PARTITION_NONE root on an inter frame` and
98+ `an inter frame under a 128x128 superblock` (the ReelC blocker) — inter path untouched this round;
99+ unblocked by the inter tile path recursing a 128 root.
100+- deferred: the `--enable-tx-size-search=1` arm at 128 (a read tx_depth under a 128 NONE root) —
101+ the four arms all pin `=0`; unblocked now that the NONE arm is exact, so it is a one-arm follow-up.