forge
Explore
Log in

Don't you dare go Hollow

Merge main 727f29a into lane-sb128c: general (row,col,tw,th) var-tx leaves with the 128-root mu-chunk chroma interleave and the skip-inter lf suppression kept

Browse files at this commit

5810c7738b6e13cd94cce659958409e41d372c15Ahmet Kaan GümüşParent: b6c54c5fcf808d

11 changed files +1151 -126

crates/ec-av1/examples/decode_probe.rsmodified+2 -0
@@ -35,6 +35,8 @@ fn main() {
35 println!("rect4_32: horz={h} vert={v} coded={c}");35 println!("rect4_32: horz={h} vert={v} coded={c}");
36 let (rtu, rsplit, robmc) = ec_av1::stream::rect_inter_tu_counters();36 let (rtu, rsplit, robmc) = ec_av1::stream::rect_inter_tu_counters();
37 println!("rect_inter: tu={rtu} txsplit={rsplit} obmc_leaf={robmc}");37 println!("rect_inter: tu={rtu} txsplit={rsplit} obmc_leaf={robmc}");
38+ let leaf = ec_av1::stream::vartx_rect_leaf_hits();
39+ println!("vartx_rect_leaf: 32x16={} 16x32={}", leaf[0], leaf[1]);
38 let ir = ec_av1::stream::inter_rect_counters();40 let ir = ec_av1::stream::inter_rect_counters();
39 println!(41 println!(
40 "inter_rect: 32x8={} 8x32={} 64x32={} 32x64={} 64x16={} 16x64={}",42 "inter_rect: 32x8={} 8x32={} 64x32={} 32x64={} 64x16={} 16x64={}",
crates/ec-av1/fixtures/reelb_ss300_key_frame.obuadded+0 -0

Binary file changed

crates/ec-av1/src/decode.rsmodified+280 -110
@@ -997,6 +997,8 @@ thread_local! {
997 // (64x32/32x64/64x16/16x64), whose coefficients are coded as the997 // (64x32/32x64/64x16/16x64), whose coefficients are coded as the
998 // truncated low-32 corner.998 // truncated low-32 corner.
999 static RECT64_INTER_TU_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };999 static RECT64_INTER_TU_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
1000+ // lane-r14 r3: rectangular var-tx LEAVES, [32x16, 16x32].
1001+ static VARTX_RECT_LEAF_HITS: std::cell::Cell<[usize; 2]> = const { std::cell::Cell::new([0; 2]) };
1000 // lane-inter4 r3: 16x16-level PARTITION_HORZ / PARTITION_VERT on an inter1002 // lane-inter4 r3: 16x16-level PARTITION_HORZ / PARTITION_VERT on an inter
1001 // frame -- 16x8 and 8x16 inter leaves.1003 // frame -- 16x8 and 8x16 inter leaves.
1002 static INTER_LEAF16_HORZ_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };1004 static INTER_LEAF16_HORZ_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
@@ -1049,6 +1051,21 @@ pub(crate) fn rect64_inter_tu_hits() -> usize {
1049 RECT64_INTER_TU_HITS.with(|c| c.get())1051 RECT64_INTER_TU_HITS.with(|c| c.get())
1050 }1052 }
1051 1053
1054+/// Current value of [`VARTX_RECT_LEAF_HITS`] (lane-r14 r3): how many
1055+/// rectangular var-tx leaf transform units were coded, `[32x16, 16x32]`.
1056+pub(crate) fn vartx_rect_leaf_hits() -> [usize; 2] {
1057+ VARTX_RECT_LEAF_HITS.with(|c| c.get())
1058+}
1059+
1060+/// Records one rectangular var-tx leaf.
1061+fn vartx_rect_leaf_hit(tw: usize, th: usize) {
1062+ VARTX_RECT_LEAF_HITS.with(|c| {
1063+ let mut h = c.get();
1064+ h[usize::from(th > tw)] += 1;
1065+ c.set(h);
1066+ });
1067+}
1068+
1052 /// Sets the current thread's [`TX_SELECT_INTER`]/[`REDUCED_TX_SET_INTER`]/1069 /// Sets the current thread's [`TX_SELECT_INTER`]/[`REDUCED_TX_SET_INTER`]/
1053 /// [`ENABLE_FILTER_INTRA_INTER`].1070 /// [`ENABLE_FILTER_INTRA_INTER`].
1054 pub(crate) fn set_inter_tx_mode(1071 pub(crate) fn set_inter_tx_mode(
@@ -2220,6 +2237,26 @@ thread_local! {
2220 static RECT4_16_CHROMA_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };2237 static RECT4_16_CHROMA_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
2221 static RECT4_16_COEFF_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };2238 static RECT4_16_COEFF_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
2222 static RECT4_16_SPLIT_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };2239 static RECT4_16_SPLIT_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
2240+ /// lane-kf1200: pairs whose chroma edge-filter type read from the PAIR's
2241+ /// base mi differs from what the strip's own (odd) mi would have said --
2242+ /// the shape that made 4 chroma samples of the ReelB `-ss 1200`
2243+ /// key frame miss by 1. Zero here means a gate never exercised the fix.
2244+ static RECT4_16_UV_PAIR_FILT_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
2245+ /// lane-kf1200 r2: sub-8x8 chroma blocks that are `skip_txfm` AND
2246+ /// `UV_CFL_PRED` -- the arm that used to drop the CfL alpha entirely.
2247+ static SKIP_CFL_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
2248+}
2249+
2250+/// How many skipped sub-8x8 chroma blocks carried a CfL alpha (the shape
2251+/// that reconstructed as flat DC before lane-kf1200 r2).
2252+pub fn skip_cfl_hits() -> usize {
2253+ SKIP_CFL_HITS.with(|c| c.get())
2254+}
2255+
2256+/// How many 16x4/4x16 chroma pairs took a different `intra_edge_filter_type`
2257+/// from the pair's base mi than the strip's own mi would have given.
2258+pub fn rect4_16_uv_pair_filt_hits() -> usize {
2259+ RECT4_16_UV_PAIR_FILT_HITS.with(|c| c.get())
2223 }2260 }
2224 2261
2225 // lane-reelckf r1: the two chroma defects ReelC's key frames exposed --2262 // lane-reelckf r1: the two chroma defects ReelC's key frames exposed --
@@ -7787,14 +7824,22 @@ fn decode_rect4_16(
7787 RECT4_16_CHROMA_DIR_HITS.with(|h| h.set(h.get() + 1));7824 RECT4_16_CHROMA_DIR_HITS.with(|h| h.set(h.get() + 1));
7788 }7825 }
7789 let pair_reach = Reach::of_rect(pw, ph, ppx, ppy, y.width, y.height);7826 let pair_reach = Reach::of_rect(pw, ph, ppx, ppy, y.width, y.height);
7790- // libaom `get_intra_edge_filter_type` reads `chroma_above_mbmi` /7827+ // lane-kf1200 r1: the chroma edge-filter type reads the neighbours
7791- // `chroma_left_mbmi` -- the neighbours of the CHROMA REFERENCE7828+ // of the CHROMA block, which for a 16x4/4x16 pair is `pair_mi`'s
7792- // position, not of the closing strip. At `lmi` the above cell is7829+ // 16x8/8x16 region -- libaom builds `chroma_above_mbmi`/
7793- // the pair's own first strip, so the mi-exact map missed and the7830+ // `chroma_left_mbmi` from `mi[-((mi_row & ss_y) * stride + (mi_col
7794- // coarse fallback answered; the filter type then flipped the7831+ // & ss_x))]` (`set_mi_offsets`, av1/common/blockd.h ~1050), i.e.
7795- // `use_intra_edge_upsample` decision (blk_wh 12 <= 16 for type 0,7832+ // the pair's top-left luma mi, never this leaf's odd row/column.
7796- // no upsample for type 1) on directional chroma.7833+ // Reading `lmi` here named the leaf directly above (a non-chroma
7797- let smooth_neighbor_uv = neighbours.smooth_uv_neighbour(pair_mi.0, pair_mi.1, r, c);7834+ // -reference 4-row block, `uv_mode == UV_DC_PRED`) and so lost a
7835+ // SMOOTH neighbour: filt_type 0 instead of 1 turned
7836+ // `av1_use_intra_edge_upsample` on (blk_wh 12 <= 16) for a
7837+ // directional chroma strip, moving 4 samples by 1.
7838+ let smooth_neighbor_uv =
7839+ neighbours.smooth_uv_neighbour(pair_mi.0, pair_mi.1, r, c);
7840+ if smooth_neighbor_uv != neighbours.smooth_uv_neighbour(lmi.0, lmi.1, r, c) {
7841+ RECT4_16_UV_PAIR_FILT_HITS.with(|h| h.set(h.get() + 1));
7842+ }
7798 let (u_levels, v_levels) = if skip {7843 let (u_levels, v_levels) = if skip {
7799 let zeros = vec![0i32; cw * ch];7844 let zeros = vec![0i32; cw * ch];
7800 // libaom `predict_and_reconstruct_intra_block` (decodeframe.c7845 // libaom `predict_and_reconstruct_intra_block` (decodeframe.c
@@ -10616,11 +10661,18 @@ fn decode_leaf_split4(
10616 neighbours.left_uv_mode[r] = uv_predict_mode;10661 neighbours.left_uv_mode[r] = uv_predict_mode;
10617 neighbours.record_uv_mode_mi(leaf_mi.0, leaf_mi.1, 2, 2, uv_predict_mode);10662 neighbours.record_uv_mode_mi(leaf_mi.0, leaf_mi.1, 2, 2, uv_predict_mode);
10618 let (u_grid, v_grid): (Vec<i32>, Vec<i32>) = if leaf_skips[3] {10663 let (u_grid, v_grid): (Vec<i32>, Vec<i32>) = if leaf_skips[3] {
10619- // As the rect4 pair above: a skipped block still predicts, and CfL is10664+ // A skipped chroma block still gets its CfL contribution: libaom's
10620- // prediction (libaom `predict_and_reconstruct_intra_block`).10665+ // `predict_and_reconstruct_intra_block` calls `cfl_predict_block`
10666+ // from `av1_predict_intra_block_facade` (av1/common/reconintra.c:1719)
10667+ // whenever `mbmi->uv_mode == UV_CFL_PRED`, before any residual is
10668+ // added -- `skip_txfm` only drops the residual, never the alpha.
10669+ // lane-reelckf and lane-kf1200 fixed THIS SAME arm independently; the
10670+ // merge keeps one fix and feeds both lanes' counters so neither of
10671+ // their gates goes vacuous.
10621 let ac = alpha.map(|_| cfl_ac_q3(y, gpx, gpy, 8));10672 let ac = alpha.map(|_| cfl_ac_q3(y, gpx, gpy, 8));
10622 if alpha.is_some() {10673 if alpha.is_some() {
10623 CHROMA_SKIP_CFL_HITS.with(|h| h.set(h.get() + 1));10674 CHROMA_SKIP_CFL_HITS.with(|h| h.set(h.get() + 1));
10675+ SKIP_CFL_HITS.with(|c| c.set(c.get() + 1));
10624 }10676 }
10625 u.reconstruct(cpx, cpy, 4, uv_predict_mode, angle_delta_uv, group_reach, &vec![0i32; 16], alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)), None, smooth_neighbor_uv);10677 u.reconstruct(cpx, cpy, 4, uv_predict_mode, angle_delta_uv, group_reach, &vec![0i32; 16], alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)), None, smooth_neighbor_uv);
10626 v.reconstruct(cpx, cpy, 4, uv_predict_mode, angle_delta_uv, group_reach, &vec![0i32; 16], alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)), None, smooth_neighbor_uv);10678 v.reconstruct(cpx, cpy, 4, uv_predict_mode, angle_delta_uv, group_reach, &vec![0i32; 16], alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)), None, smooth_neighbor_uv);
@@ -10975,11 +11027,18 @@ fn decode_leaf_rect8(
10975 neighbours.left_uv_mode[r] = uv_predict_mode;11027 neighbours.left_uv_mode[r] = uv_predict_mode;
10976 neighbours.record_uv_mode_mi(leaf_mi.0, leaf_mi.1, 2, 2, uv_predict_mode);11028 neighbours.record_uv_mode_mi(leaf_mi.0, leaf_mi.1, 2, 2, uv_predict_mode);
10977 let (u_grid, v_grid): (Vec<i32>, Vec<i32>) = if leaf_skips[1] {11029 let (u_grid, v_grid): (Vec<i32>, Vec<i32>) = if leaf_skips[1] {
10978- // As the rect4 pair above: a skipped block still predicts, and CfL is11030+ // A skipped chroma block still gets its CfL contribution: libaom's
10979- // prediction (libaom `predict_and_reconstruct_intra_block`).11031+ // `predict_and_reconstruct_intra_block` calls `cfl_predict_block`
11032+ // from `av1_predict_intra_block_facade` (av1/common/reconintra.c:1719)
11033+ // whenever `mbmi->uv_mode == UV_CFL_PRED`, before any residual is
11034+ // added -- `skip_txfm` only drops the residual, never the alpha.
11035+ // lane-reelckf and lane-kf1200 fixed THIS SAME arm independently; the
11036+ // merge keeps one fix and feeds both lanes' counters so neither of
11037+ // their gates goes vacuous.
10980 let ac = alpha.map(|_| cfl_ac_q3(y, gpx, gpy, 8));11038 let ac = alpha.map(|_| cfl_ac_q3(y, gpx, gpy, 8));
10981 if alpha.is_some() {11039 if alpha.is_some() {
10982 CHROMA_SKIP_CFL_HITS.with(|h| h.set(h.get() + 1));11040 CHROMA_SKIP_CFL_HITS.with(|h| h.set(h.get() + 1));
11041+ SKIP_CFL_HITS.with(|c| c.set(c.get() + 1));
10983 }11042 }
10984 u.reconstruct(cpx, cpy, 4, uv_predict_mode, angle_delta_uv, group_reach, &vec![0i32; 16], alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)), None, smooth_neighbor_uv);11043 u.reconstruct(cpx, cpy, 4, uv_predict_mode, angle_delta_uv, group_reach, &vec![0i32; 16], alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)), None, smooth_neighbor_uv);
10985 v.reconstruct(cpx, cpy, 4, uv_predict_mode, angle_delta_uv, group_reach, &vec![0i32; 16], alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)), None, smooth_neighbor_uv);11044 v.reconstruct(cpx, cpy, 4, uv_predict_mode, angle_delta_uv, group_reach, &vec![0i32; 16], alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)), None, smooth_neighbor_uv);
@@ -11474,6 +11533,46 @@ const TXFM_CTX_INIT: u8 = 64;
11474 /// twice below its own largest transform.11533 /// twice below its own largest transform.
11475 const MAX_VARTX_DEPTH: usize = 2;11534 const MAX_VARTX_DEPTH: usize = 2;
11476 11535
11536+/// libaom `sub_tx_size_map[TX_SIZES_ALL]` (`common_data.c`): the transform
11537+/// one `txfm_split` step below `tx_size`. RECTANGULAR for the 1:4 shapes
11538+/// (`[TX_64X16] == TX_32X16`, `[TX_16X64] == TX_16X32`) and for the 4:1
11539+/// small ones, square everywhere else.
11540+fn sub_tx_size_map(tx_w: usize, tx_h: usize) -> (usize, usize) {
11541+ match (tx_w, tx_h) {
11542+ (4, 4) => (4, 4),
11543+ (8, 8) => (4, 4),
11544+ (16, 16) => (8, 8),
11545+ (32, 32) => (16, 16),
11546+ (64, 64) => (32, 32),
11547+ (4, 8) | (8, 4) => (4, 4),
11548+ (8, 16) | (16, 8) => (8, 8),
11549+ (16, 32) | (32, 16) => (16, 16),
11550+ (32, 64) | (64, 32) => (32, 32),
11551+ (4, 16) => (4, 8),
11552+ (16, 4) => (8, 4),
11553+ (8, 32) => (8, 16),
11554+ (32, 8) => (16, 8),
11555+ (16, 64) => (16, 32),
11556+ (64, 16) => (32, 16),
11557+ _ => unreachable!("not a TX_SIZES_ALL shape: {tx_w}x{tx_h}"),
11558+ }
11559+}
11560+
11561+#[test]
11562+fn sub_tx_size_map_matches_libaom() {
11563+ // libaom `common_data.c` `sub_tx_size_map`, in TX_SIZES_ALL order.
11564+ const TABLE: [((usize, usize), (usize, usize)); 19] = [
11565+ ((4, 4), (4, 4)), ((8, 8), (4, 4)), ((16, 16), (8, 8)), ((32, 32), (16, 16)),
11566+ ((64, 64), (32, 32)), ((4, 8), (4, 4)), ((8, 4), (4, 4)), ((8, 16), (8, 8)),
11567+ ((16, 8), (8, 8)), ((16, 32), (16, 16)), ((32, 16), (16, 16)), ((32, 64), (32, 32)),
11568+ ((64, 32), (32, 32)), ((4, 16), (4, 8)), ((16, 4), (8, 4)), ((8, 32), (8, 16)),
11569+ ((32, 8), (16, 8)), ((16, 64), (16, 32)), ((64, 16), (32, 16)),
11570+ ];
11571+ for (tx, want) in TABLE {
11572+ assert_eq!(sub_tx_size_map(tx.0, tx.1), want, "sub_tx_size_map({tx:?})");
11573+ }
11574+}
11575+
11477 /// `read_var_tx_size` (spec 5.11.17, libaom `decodeframe.c`11576 /// `read_var_tx_size` (spec 5.11.17, libaom `decodeframe.c`
11478 /// `read_tx_size_vartx`): the recursive `txfm_split` tree of one11577 /// `read_tx_size_vartx`): the recursive `txfm_split` tree of one
11479 /// max-transform-sized unit of an inter block, collecting the resolved leaf11578 /// max-transform-sized unit of an inter block, collecting the resolved leaf
@@ -11490,22 +11589,28 @@ fn read_var_tx_size(
11490 at_mi: (usize, usize),11589 at_mi: (usize, usize),
11491 blk_max_px: usize,11590 blk_max_px: usize,
11492 (max_w_mi, max_h_mi): (usize, usize),11591 (max_w_mi, max_h_mi): (usize, usize),
11493- tx_px: usize,11592+ (tx_w, tx_h): (usize, usize),
11494 depth: usize,11593 depth: usize,
11495 blk_row: usize,11594 blk_row: usize,
11496 blk_col: usize,11595 blk_col: usize,
11497- out: &mut Vec<(usize, usize, usize)>,11596+ out: &mut Vec<(usize, usize, usize, usize)>,
11498 ) {11597 ) {
11499 if blk_row >= max_h_mi || blk_col >= max_w_mi {11598 if blk_row >= max_h_mi || blk_col >= max_w_mi {
11500 return;11599 return;
11501 }11600 }
11502 let unit = (at_mi.0 + blk_row, at_mi.1 + blk_col);11601 let unit = (at_mi.0 + blk_row, at_mi.1 + blk_col);
11503 if depth == MAX_VARTX_DEPTH {11602 if depth == MAX_VARTX_DEPTH {
11504- out.push((blk_row, blk_col, tx_px));11603+ out.push((blk_row, blk_col, tx_w, tx_h));
11505- txfm_partition_update(n, unit, tx_px, tx_px);11604+ txfm_partition_update_rect(n, unit, (tx_w, tx_h), (tx_w, tx_h));
11506 return;11605 return;
11507 }11606 }
11508- let ctx = txfm_partition_ctx(n.above_txfm[unit.1], n.left_txfm[unit.0], blk_max_px, tx_px);11607+ let ctx = txfm_partition_ctx_rect(
11608+ n.above_txfm[unit.1],
11609+ n.left_txfm[unit.0],
11610+ blk_max_px,
11611+ tx_w,
11612+ tx_h,
11613+ );
11509 let split = dec.symbol(&mut cdfs.txfm_partition[ctx]) == 1;11614 let split = dec.symbol(&mut cdfs.txfm_partition[ctx]) == 1;
11510 TXFM_SPLIT_READS.with(|c| c.set(c.get() + 1));11615 TXFM_SPLIT_READS.with(|c| c.set(c.get() + 1));
11511 if std::env::var_os("EC_TRACE_MODE_STEP").is_some() {11616 if std::env::var_os("EC_TRACE_MODE_STEP").is_some() {
@@ -11518,27 +11623,27 @@ fn read_var_tx_size(
11518 );11623 );
11519 }11624 }
11520 if !split {11625 if !split {
11521- out.push((blk_row, blk_col, tx_px));11626+ out.push((blk_row, blk_col, tx_w, tx_h));
11522- txfm_partition_update(n, unit, tx_px, tx_px);11627+ txfm_partition_update_rect(n, unit, (tx_w, tx_h), (tx_w, tx_h));
11523 return;11628 return;
11524 }11629 }
11525 TXFM_SPLIT_HITS.with(|c| c.set(c.get() + 1));11630 TXFM_SPLIT_HITS.with(|c| c.set(c.get() + 1));
11526- let sub = tx_px / 2;11631+ let (sub_w, sub_h) = sub_tx_size_map(tx_w, tx_h);
11527- if sub == 4 {11632+ if (sub_w, sub_h) == (4, 4) {
11528- // libaom's `sub_txs == TX_4X4` early return: the whole 8x8 unit is11633+ // libaom's `sub_txs == TX_4X4` early return: every mi cell of the
11529- // marked 4x4 (four transform units, raster order) without recursing.11634+ // unit is marked 4x4 (raster order) without recursing.
11530- for row in 0..2 {11635+ for row in 0..tx_h / MI {
11531- for col in 0..2 {11636+ for col in 0..tx_w / MI {
11532 if blk_row + row < max_h_mi && blk_col + col < max_w_mi {11637 if blk_row + row < max_h_mi && blk_col + col < max_w_mi {
11533- out.push((blk_row + row, blk_col + col, 4));11638+ out.push((blk_row + row, blk_col + col, 4, 4));
11534 }11639 }
11535 }11640 }
11536 }11641 }
11537- txfm_partition_update(n, unit, 4, tx_px);11642+ txfm_partition_update_rect(n, unit, (4, 4), (tx_w, tx_h));
11538 return;11643 return;
11539 }11644 }
11540- for row in (0..tx_px / MI).step_by(sub / MI) {11645+ for row in (0..tx_h / MI).step_by(sub_h / MI) {
11541- for col in (0..tx_px / MI).step_by(sub / MI) {11646+ for col in (0..tx_w / MI).step_by(sub_w / MI) {
11542 read_var_tx_size(11647 read_var_tx_size(
11543 dec,11648 dec,
11544 cdfs,11649 cdfs,
@@ -11546,7 +11651,7 @@ fn read_var_tx_size(
11546 at_mi,11651 at_mi,
11547 blk_max_px,11652 blk_max_px,
11548 (max_w_mi, max_h_mi),11653 (max_w_mi, max_h_mi),
11549- sub,11654+ (sub_w, sub_h),
11550 depth + 1,11655 depth + 1,
11551 blk_row + row,11656 blk_row + row,
11552 blk_col + col,11657 blk_col + col,
@@ -11574,7 +11679,7 @@ fn read_block_tx_size(
11574 (mi_cols, mi_rows): (usize, usize),11679 (mi_cols, mi_rows): (usize, usize),
11575 is_inter: bool,11680 is_inter: bool,
11576 skip: bool,11681 skip: bool,
11577-) -> Result<(usize, Option<Vec<(usize, usize, usize)>>)> {11682+) -> Result<(usize, Option<Vec<(usize, usize, usize, usize)>>)> {
11578 if !TX_SELECT_INTER.with(std::cell::Cell::get) {11683 if !TX_SELECT_INTER.with(std::cell::Cell::get) {
11579 // lane-sb128c r1: `max_txsize_rect_lookup[BLOCK_128X128]` is TX_64X64,11684 // lane-sb128c r1: `max_txsize_rect_lookup[BLOCK_128X128]` is TX_64X64,
11580 // so a 128x128 inter block is FOUR luma units even with `tx_mode ==11685 // so a 128x128 inter block is FOUR luma units even with `tx_mode ==
@@ -11609,7 +11714,7 @@ fn read_block_tx_size(
11609 at_mi,11714 at_mi,
11610 side,11715 side,
11611 (max_w_mi, max_h_mi),11716 (max_w_mi, max_h_mi),
11612- max_tx,11717+ (max_tx, max_tx),
11613 0,11718 0,
11614 row,11719 row,
11615 col,11720 col,
@@ -11617,8 +11722,8 @@ fn read_block_tx_size(
11617 );11722 );
11618 }11723 }
11619 }11724 }
11620- let single = leaves.len() == 1 && leaves[0].2 == side;11725+ let single = leaves.len() == 1 && leaves[0].2 == side && leaves[0].3 == side;
11621- if !single && leaves.iter().any(|leaf| leaf.2 > 64) {11726+ if !single && leaves.iter().any(|leaf| leaf.2.max(leaf.3) > 64) {
11622 // Only a block wider than a superblock's own 64x64 max transform11727 // Only a block wider than a superblock's own 64x64 max transform
11623 // reaches here; this crate has no 64-point *inter* coefficient11728 // reaches here; this crate has no 64-point *inter* coefficient
11624 // table set ([`inter_txbset_for`] stops at 32).11729 // table set ([`inter_txbset_for`] stops at 32).
@@ -11659,7 +11764,7 @@ fn read_block_tx_size(
11659 let mut leaves = Vec::new();11764 let mut leaves = Vec::new();
11660 for row in (0..side_mi).step_by(step) {11765 for row in (0..side_mi).step_by(step) {
11661 for col in (0..side_mi).step_by(step) {11766 for col in (0..side_mi).step_by(step) {
11662- leaves.push((row, col, tx));11767+ leaves.push((row, col, tx, tx));
11663 }11768 }
11664 }11769 }
11665 INTRA_IN_INTER_SPLIT_TX_HITS.with(|c| {11770 INTRA_IN_INTER_SPLIT_TX_HITS.with(|c| {
@@ -11811,7 +11916,7 @@ fn read_block_tx_size_rect(
11811 (bw, bh): (usize, usize),11916 (bw, bh): (usize, usize),
11812 (mi_cols, mi_rows): (usize, usize),11917 (mi_cols, mi_rows): (usize, usize),
11813 skip: bool,11918 skip: bool,
11814-) -> Result<Option<Vec<(usize, usize, usize)>>> {11919+) -> Result<Option<Vec<(usize, usize, usize, usize)>>> {
11815 if skip {11920 if skip {
11816 // `set_txfm_ctxs(.., skip && is_inter)`: a skipped inter block records11921 // `set_txfm_ctxs(.., skip && is_inter)`: a skipped inter block records
11817 // its own BLOCK size -- width above, height left -- not a transform.11922 // its own BLOCK size -- width above, height left -- not a transform.
@@ -11854,22 +11959,16 @@ fn read_block_tx_size_rect(
11854 }11959 }
11855 TXFM_SPLIT_HITS.with(|c| c.set(c.get() + 1));11960 TXFM_SPLIT_HITS.with(|c| c.set(c.get() + 1));
11856 RECT_INTER_TXSPLIT_HITS.with(|c| c.set(c.get() + 1));11961 RECT_INTER_TXSPLIT_HITS.with(|c| c.set(c.get() + 1));
11857- // lane-r14 r2: `sub_tx_size_map` is square for every shape this decoder11962+ // lane-r14 r3: `sub_tx_size_map` (libaom `common_data.c`) stays
11858- // splits (TX_32X16 -> TX_16X16, TX_64X32 -> TX_32X32) EXCEPT the 1:411963+ // RECTANGULAR under a 1:4 strip -- `[TX_64X16] == TX_32X16`,
11859- // strips with a 64-px axis, where it stays rectangular11964+ // `[TX_16X64] == TX_16X32` -- so the recursion below is the general
11860- // (TX_64X16 -> TX_32X16, TX_16X64 -> TX_16X32) and the square recursion11965+ // rect one and its leaves carry their own width and height.
11861- // below would code the wrong tree.11966+ let (sub_w, sub_h) = sub_tx_size_map(tx_w, tx_h);
11862- if tx_w.max(tx_h) == 64 && tx_w.min(tx_h) == 16 {
11863- return Err(unsupported(
11864- "a split transform on a 1:4 inter strip with a 64-px axis",
11865- ));
11866- }
11867- let sub = tx_w.min(tx_h);
11868 let max_w_mi = (bw / MI).min(mi_cols.saturating_sub(at_mi.1));11967 let max_w_mi = (bw / MI).min(mi_cols.saturating_sub(at_mi.1));
11869 let max_h_mi = (bh / MI).min(mi_rows.saturating_sub(at_mi.0));11968 let max_h_mi = (bh / MI).min(mi_rows.saturating_sub(at_mi.0));
11870 let mut leaves = Vec::new();11969 let mut leaves = Vec::new();
11871- for row in (0..bh / MI).step_by(sub / MI) {11970+ for row in (0..bh / MI).step_by(sub_h / MI) {
11872- for col in (0..bw / MI).step_by(sub / MI) {11971+ for col in (0..bw / MI).step_by(sub_w / MI) {
11873 read_var_tx_size(11972 read_var_tx_size(
11874 dec,11973 dec,
11875 cdfs,11974 cdfs,
@@ -11877,7 +11976,7 @@ fn read_block_tx_size_rect(
11877 at_mi,11976 at_mi,
11878 bw.max(bh),11977 bw.max(bh),
11879 (max_w_mi, max_h_mi),11978 (max_w_mi, max_h_mi),
11880- sub,11979+ (sub_w, sub_h),
11881 1,11980 1,
11882 row,11981 row,
11883 col,11982 col,
@@ -11914,9 +12013,12 @@ fn read_inter_plane_rect(
11914 y: usize,12013 y: usize,
11915 prediction: &[u16],12014 prediction: &[u16],
11916 inherited_luma_tx_type: Option<TxType>,12015 inherited_luma_tx_type: Option<TxType>,
12016+ luma_skip_ctx: Option<usize>,
11917 ) -> Result<(Vec<i32>, TxType)> {12017 ) -> Result<(Vec<i32>, TxType)> {
11918 let skip_ctx = if plane_idx == 0 {12018 let skip_ctx = if plane_idx == 0 {
11919- 012019+ // `get_txb_ctx_general`: 0 only when this unit IS the whole plane
12020+ // block; a var-tx leaf passes its own neighbour-table context.
12021+ luma_skip_ctx.unwrap_or(0)
11920 } else {12022 } else {
11921 usize::from(around.0) + usize::from(around.1)12023 usize::from(around.0) + usize::from(around.1)
11922 };12024 };
@@ -16557,7 +16659,7 @@ fn decode_inter_block(
16557 // 5.11.17), `Some` only when this block's var-tx tree resolved to more16659 // 5.11.17), `Some` only when this block's var-tx tree resolved to more
16558 // than one luma transform -- read back by the residual loop, the16660 // than one luma transform -- read back by the residual loop, the
16559 // coefficient-context write-back and the loop-filter grid fill below.16661 // coefficient-context write-back and the loop-filter grid fill below.
16560- let mut vartx_leaves: Option<Vec<(usize, usize, usize)>> = None;16662+ let mut vartx_leaves: Option<Vec<(usize, usize, usize, usize)>> = None;
16561 let at_mi = at;16663 let at_mi = at;
16562 if is_inter {16664 if is_inter {
16563 let above_nbr = has_above.then(|| NeighbourRef {16665 let above_nbr = has_above.then(|| NeighbourRef {
@@ -17417,37 +17519,68 @@ fn decode_inter_block(
17417 // own slice of the block's motion-compensated predictor.17519 // own slice of the block's motion-compensated predictor.
17418 let reduced = REDUCED_TX_SET_INTER.with(std::cell::Cell::get);17520 let reduced = REDUCED_TX_SET_INTER.with(std::cell::Cell::get);
17419 let mut first_tx_type = TxType::DctDct;17521 let mut first_tx_type = TxType::DctDct;
17420- for (idx, &(row, col, tx_px)) in leaves.iter().enumerate() {17522+ for (idx, &(row, col, tw, th)) in leaves.iter().enumerate() {
17421 let tu_mi = (at_mi.0 + row, at_mi.1 + col);17523 let tu_mi = (at_mi.0 + row, at_mi.1 + col);
17422 let (tu_px, tu_py) = (px + col * MI, py + row * MI);17524 let (tu_px, tu_py) = (px + col * MI, py + row * MI);
17423- let mut tu_pred = Vec::with_capacity(tx_px * tx_px);17525+ let (tu_grid, tu_tx_type) = if tw == th {
17424- for rr in 0..tx_px {17526+ let tx_px = tw;
17425- let start = (row * MI + rr) * side + col * MI;17527+ let mut tu_pred = Vec::with_capacity(tx_px * tx_px);
17426- tu_pred.extend_from_slice(&pred_y[start..start + tx_px]);17528+ for rr in 0..tx_px {
17427- }17529+ let start = (row * MI + rr) * side + col * MI;
17428- let scan = default_scan(tx_px.min(32));17530+ tu_pred.extend_from_slice(&pred_y[start..start + tx_px]);
17429- let tu_skip_ctx = neighbours.luma_skip_ctx(tu_mi, tx_px / MI);17531+ }
17430- let (tu_grid, tu_tx_type) = read_inter_plane(17532+ let scan = default_scan(tx_px.min(32));
17431- dec,17533+ let tu_skip_ctx = neighbours.luma_skip_ctx(tu_mi, tx_px / MI);
17432- cdfs,17534+ read_inter_plane(
17433- inter_txbset_for(tx_px, reduced),17535+ dec,
17434- &scan,17536+ cdfs,
17435- 0,17537+ inter_txbset_for(tx_px, reduced),
17436- neighbours.around_mi(tu_mi, tx_px)[0],17538+ &scan,
17437- mode_for_tx,17539+ 0,
17438- y,17540+ neighbours.around_mi(tu_mi, tx_px)[0],
17439- tu_px,17541+ mode_for_tx,
17440- tu_py,17542+ y,
17441- tx_px,17543+ tu_px,
17442- base_q_idx,17544+ tu_py,
17443- &tu_pred,17545+ tx_px,
17444- None,17546+ base_q_idx,
17445- Some(tu_skip_ctx),17547+ &tu_pred,
17446- )?;17548+ None,
17549+ Some(tu_skip_ctx),
17550+ )?
17551+ } else {
17552+ // lane-r14 r3: a 1:4 strip's `sub_tx_size_map`
17553+ // sub-transform is RECTANGULAR (TX_64X16 ->
17554+ // TX_32X16, TX_16X64 -> TX_16X32), so this leaf is
17555+ // read with the rect coefficient machinery, at its
17556+ // own `txb_skip_ctx`/neighbour spans -- the unit is
17557+ // smaller than its block, so `get_txb_ctx_general`'s
17558+ // neighbour table applies, not the lone-TU 0.
17559+ vartx_rect_leaf_hit(tw, th);
17560+ let tu_skip_ctx =
17561+ neighbours.luma_skip_ctx_rect(tu_mi, tw / MI, th / MI);
17562+ let start = row * MI * side + col * MI;
17563+ read_inter_plane_rect(
17564+ dec,
17565+ cdfs,
17566+ rect_inter_luma_set(tw, th),
17567+ (tw, th),
17568+ side,
17569+ 0,
17570+ neighbours.around_mi_rect(tu_mi, tw, th)[0],
17571+ mode_for_tx,
17572+ y,
17573+ tu_px,
17574+ tu_py,
17575+ &pred_y[start..],
17576+ None,
17577+ Some(tu_skip_ctx),
17578+ )?
17579+ };
17447 if idx == 0 {17580 if idx == 0 {
17448 first_tx_type = tu_tx_type;17581 first_tx_type = tu_tx_type;
17449 }17582 }
17450- neighbours.record_mi_luma(tu_mi, tx_px, &tu_grid);17583+ neighbours.record_mi_luma_rect(tu_mi, tw, th, &tu_grid);
17451 // lane-sb128c r1: libaom's `decode_token_recon_block`17584 // lane-sb128c r1: libaom's `decode_token_recon_block`
17452 // walks 64x64 "mu" chunks (`mu_blocks_wide/high =17585 // walks 64x64 "mu" chunks (`mu_blocks_wide/high =
17453 // mi_size_wide[BLOCK_64X64]`) and codes EVERY PLANE of17586 // mi_size_wide[BLOCK_64X64]`) and codes EVERY PLANE of
@@ -17544,6 +17677,7 @@ fn decode_inter_block(
17544 py,17677 py,
17545 &pred_y,17678 &pred_y,
17546 None,17679 None,
17680+ None,
17547 )?;17681 )?;
17548 luma_tx_type = tx_type;17682 luma_tx_type = tx_type;
17549 luma_grid = embed_rect_grid(&grid, write_w, write_h, side);17683 luma_grid = embed_rect_grid(&grid, write_w, write_h, side);
@@ -17587,6 +17721,7 @@ fn decode_inter_block(
17587 cpy,17721 cpy,
17588 &pred_u,17722 &pred_u,
17589 Some(luma_tx_type),17723 Some(luma_tx_type),
17724+ None,
17590 )?17725 )?
17591 .0,17726 .0,
17592 uw,17727 uw,
@@ -17608,6 +17743,7 @@ fn decode_inter_block(
17608 cpy,17743 cpy,
17609 &pred_v,17744 &pred_v,
17610 Some(luma_tx_type),17745 Some(luma_tx_type),
17746+ None,
17611 )?17747 )?
17612 .0,17748 .0,
17613 uw,17749 uw,
@@ -18482,37 +18618,68 @@ fn decode_inter_block(
18482 // own slice of the block's motion-compensated predictor.18618 // own slice of the block's motion-compensated predictor.
18483 let reduced = REDUCED_TX_SET_INTER.with(std::cell::Cell::get);18619 let reduced = REDUCED_TX_SET_INTER.with(std::cell::Cell::get);
18484 let mut first_tx_type = TxType::DctDct;18620 let mut first_tx_type = TxType::DctDct;
18485- for (idx, &(row, col, tx_px)) in leaves.iter().enumerate() {18621+ for (idx, &(row, col, tw, th)) in leaves.iter().enumerate() {
18486 let tu_mi = (at_mi.0 + row, at_mi.1 + col);18622 let tu_mi = (at_mi.0 + row, at_mi.1 + col);
18487 let (tu_px, tu_py) = (px + col * MI, py + row * MI);18623 let (tu_px, tu_py) = (px + col * MI, py + row * MI);
18488- let mut tu_pred = Vec::with_capacity(tx_px * tx_px);18624+ let (tu_grid, tu_tx_type) = if tw == th {
18489- for rr in 0..tx_px {18625+ let tx_px = tw;
18490- let start = (row * MI + rr) * side + col * MI;18626+ let mut tu_pred = Vec::with_capacity(tx_px * tx_px);
18491- tu_pred.extend_from_slice(&pred_y[start..start + tx_px]);18627+ for rr in 0..tx_px {
18492- }18628+ let start = (row * MI + rr) * side + col * MI;
18493- let scan = default_scan(tx_px.min(32));18629+ tu_pred.extend_from_slice(&pred_y[start..start + tx_px]);
18494- let tu_skip_ctx = neighbours.luma_skip_ctx(tu_mi, tx_px / MI);18630+ }
18495- let (tu_grid, tu_tx_type) = read_inter_plane(18631+ let scan = default_scan(tx_px.min(32));
18496- dec,18632+ let tu_skip_ctx = neighbours.luma_skip_ctx(tu_mi, tx_px / MI);
18497- cdfs,18633+ read_inter_plane(
18498- inter_txbset_for(tx_px, reduced),18634+ dec,
18499- &scan,18635+ cdfs,
18500- 0,18636+ inter_txbset_for(tx_px, reduced),
18501- neighbours.around_mi(tu_mi, tx_px)[0],18637+ &scan,
18502- mode_for_tx,18638+ 0,
18503- y,18639+ neighbours.around_mi(tu_mi, tx_px)[0],
18504- tu_px,18640+ mode_for_tx,
18505- tu_py,18641+ y,
18506- tx_px,18642+ tu_px,
18507- base_q_idx,18643+ tu_py,
18508- &tu_pred,18644+ tx_px,
18509- None,18645+ base_q_idx,
18510- Some(tu_skip_ctx),18646+ &tu_pred,
18511- )?;18647+ None,
18648+ Some(tu_skip_ctx),
18649+ )?
18650+ } else {
18651+ // lane-r14 r3: a 1:4 strip's `sub_tx_size_map`
18652+ // sub-transform is RECTANGULAR (TX_64X16 ->
18653+ // TX_32X16, TX_16X64 -> TX_16X32), so this leaf is
18654+ // read with the rect coefficient machinery, at its
18655+ // own `txb_skip_ctx`/neighbour spans -- the unit is
18656+ // smaller than its block, so `get_txb_ctx_general`'s
18657+ // neighbour table applies, not the lone-TU 0.
18658+ vartx_rect_leaf_hit(tw, th);
18659+ let tu_skip_ctx =
18660+ neighbours.luma_skip_ctx_rect(tu_mi, tw / MI, th / MI);
18661+ let start = row * MI * side + col * MI;
18662+ read_inter_plane_rect(
18663+ dec,
18664+ cdfs,
18665+ rect_inter_luma_set(tw, th),
18666+ (tw, th),
18667+ side,
18668+ 0,
18669+ neighbours.around_mi_rect(tu_mi, tw, th)[0],
18670+ mode_for_tx,
18671+ y,
18672+ tu_px,
18673+ tu_py,
18674+ &pred_y[start..],
18675+ None,
18676+ Some(tu_skip_ctx),
18677+ )?
18678+ };
18512 if idx == 0 {18679 if idx == 0 {
18513 first_tx_type = tu_tx_type;18680 first_tx_type = tu_tx_type;
18514 }18681 }
18515- neighbours.record_mi_luma(tu_mi, tx_px, &tu_grid);18682+ neighbours.record_mi_luma_rect(tu_mi, tw, th, &tu_grid);
18516 // lane-sb128c r1: libaom's `decode_token_recon_block`18683 // lane-sb128c r1: libaom's `decode_token_recon_block`
18517 // walks 64x64 "mu" chunks (`mu_blocks_wide/high =18684 // walks 64x64 "mu" chunks (`mu_blocks_wide/high =
18518 // mi_size_wide[BLOCK_64X64]`) and codes EVERY PLANE of18685 // mi_size_wide[BLOCK_64X64]`) and codes EVERY PLANE of
@@ -18609,6 +18776,7 @@ fn decode_inter_block(
18609 py,18776 py,
18610 &pred_y,18777 &pred_y,
18611 None,18778 None,
18779+ None,
18612 )?;18780 )?;
18613 luma_tx_type = tx_type;18781 luma_tx_type = tx_type;
18614 luma_grid = embed_rect_grid(&grid, write_w, write_h, side);18782 luma_grid = embed_rect_grid(&grid, write_w, write_h, side);
@@ -18652,6 +18820,7 @@ fn decode_inter_block(
18652 cpy,18820 cpy,
18653 &pred_u,18821 &pred_u,
18654 Some(luma_tx_type),18822 Some(luma_tx_type),
18823+ None,
18655 )?18824 )?
18656 .0,18825 .0,
18657 uw,18826 uw,
@@ -18673,6 +18842,7 @@ fn decode_inter_block(
18673 cpy,18842 cpy,
18674 &pred_v,18843 &pred_v,
18675 Some(luma_tx_type),18844 Some(luma_tx_type),
18845+ None,
18676 )?18846 )?
18677 .0,18847 .0,
18678 uw,18848 uw,
@@ -18959,7 +19129,7 @@ fn decode_inter_block(
18959 let mut v_units = vec![0i32; chroma_side * chroma_side];19129 let mut v_units = vec![0i32; chroma_side * chroma_side];
18960 if let Some(leaves) = vartx_leaves.clone() {19130 if let Some(leaves) = vartx_leaves.clone() {
18961 let reduced = REDUCED_TX_SET_INTER.with(std::cell::Cell::get);19131 let reduced = REDUCED_TX_SET_INTER.with(std::cell::Cell::get);
18962- for (idx, &(row, col, tx_px)) in leaves.iter().enumerate() {19132+ for (idx, &(row, col, tx_px, _)) in leaves.iter().enumerate() {
18963 let tu_mi = (at_mi.0 + row, at_mi.1 + col);19133 let tu_mi = (at_mi.0 + row, at_mi.1 + col);
18964 let (tu_px, tu_py) = (px + col * MI, py + row * MI);19134 let (tu_px, tu_py) = (px + col * MI, py + row * MI);
18965 // A transform unit inside a block is not a block at that19135 // A transform unit inside a block is not a block at that
@@ -19302,13 +19472,13 @@ fn decode_inter_block(
19302 neighbours.suppress_internal_lf_edges((rmi, cmi), write_w / MI, write_h / MI);19472 neighbours.suppress_internal_lf_edges((rmi, cmi), write_w / MI, write_h / MI);
19303 }19473 }
19304 if let Some(leaves) = (!(skip && is_inter)).then_some(()).and(vartx_leaves.as_ref()) {19474 if let Some(leaves) = (!(skip && is_inter)).then_some(()).and(vartx_leaves.as_ref()) {
19305- for &(row, col, tx_px) in leaves {19475+ for &(row, col, tw, th) in leaves {
19306 neighbours.fill_lf_grid_rect(19476 neighbours.fill_lf_grid_rect(
19307 (at_mi.0 + row, at_mi.1 + col),19477 (at_mi.0 + row, at_mi.1 + col),
19308- tx_px / MI,19478+ tw / MI,
19309- tx_px / MI,19479+ th / MI,
19310- tx_px as u8,19480+ tw as u8,
19311- tx_px as u8,19481+ th as u8,
19312 if globalmv_for_lf {19482 if globalmv_for_lf {
19313 -ref_frame_for_lf19483 -ref_frame_for_lf
19314 } else {19484 } else {
crates/ec-av1/src/gate_coverage.rsmodified+0 -5
@@ -175,10 +175,6 @@ const NEVER_EXERCISED_8BIT: &[(&str, &str)] = &[
175 "enable-rect-tx",175 "enable-rect-tx",
176 "never spelled; rect transforms reach the decoder only through partition shape, never through a gate that names the tool",176 "never spelled; rect transforms reach the decoder only through partition shape, never through a gate that names the tool",
177 ),177 ),
178- (
179- "enable-tx64",
180- "never spelled; TX_64X64 appears only where aomenc's default picks it, which is unknown per stream",
181- ),
182 ];178 ];
183 179
184 #[cfg(test)]180 #[cfg(test)]
@@ -217,7 +213,6 @@ const NEVER_EXERCISED_10BIT: &[(&str, &str)] = &[ // lane-cwarp's 10-bit comp
217 // 1D tx class).213 // 1D tx class).
218 ("enable-intrabc", "hole at both depths, see the 8-bit list"),214 ("enable-intrabc", "hole at both depths, see the 8-bit list"),
219 ("enable-rect-tx", "hole at both depths, see the 8-bit list"),215 ("enable-rect-tx", "hole at both depths, see the 8-bit list"),
220- ("enable-tx64", "hole at both depths, see the 8-bit list"),
221 ];216 ];
222 217
223 /// [`DEFAULT_ON_TOOLS`] entries no 8-bit gate spells on, with the reason.218 /// [`DEFAULT_ON_TOOLS`] entries no 8-bit gate spells on, with the reason.
crates/ec-av1/src/refusal_inventory.rsmodified+0 -4
@@ -81,10 +81,6 @@ const REFUSALS: &[&str] = &[
81 "warp prediction with a scaled reference (superres, unimplemented)",81 "warp prediction with a scaled reference (superres, unimplemented)",
82 "an 8x8 partition leaf under a scaled reference (superres, unimplemented)",82 "an 8x8 partition leaf under a scaled reference (superres, unimplemented)",
83 "a motion_mode symbol for a block shape with no CDF row here",83 "a motion_mode symbol for a block shape with no CDF row here",
84- // lane-r14 r2: the whole-transform case of every 64-axis inter strip is
85- // coded; only the SPLIT of a 1:4 strip with a 64-px axis is left, whose
86- // `sub_tx_size_map` entry is rectangular (TX_64X16 -> TX_32X16).
87- "a split transform on a 1:4 inter strip with a 64-px axis",
88 ];84 ];
89 85
90 /// Gates whose `Err` arm turns a decode failure into a printed SKIP rather than86 /// Gates whose `Err` arm turns a decode failure into a printed SKIP rather than
crates/ec-av1/src/stream.rsmodified+317 -7
@@ -74,6 +74,13 @@ pub fn rect64_inter_tu_hits() -> usize {
74 crate::decode::rect64_inter_tu_hits()74 crate::decode::rect64_inter_tu_hits()
75 }75 }
76 76
77+/// lane-r14 r3: RECTANGULAR var-tx leaf transform units, `[32x16, 16x32]` --
78+/// the leaves `sub_tx_size_map` produces when a 1:4 strip with a 64-px axis
79+/// splits its transform (`[TX_64X16] == TX_32X16`, `[TX_16X64] == TX_16X32`).
80+pub fn vartx_rect_leaf_hits() -> [usize; 2] {
81+ crate::decode::vartx_rect_leaf_hits()
82+}
83+
77 pub fn rect4_32_counters() -> (usize, usize, usize) {84 pub fn rect4_32_counters() -> (usize, usize, usize) {
78 (85 (
79 crate::decode::rect4_32_horz_hits(),86 crate::decode::rect4_32_horz_hits(),
@@ -3031,6 +3038,47 @@ mod tests {
3031 eprintln!("{NAME}: pixel-exact, skipped_cfl={skip_cfl}");3038 eprintln!("{NAME}: pixel-exact, skipped_cfl={skip_cfl}");
3032 }3039 }
3033 3040
3041+ /// lane-kf1200 r2: the same film's `-ss 300` key frame, pinned because no
3042+ /// aomenc recipe reaches its shape -- a SKIPPED sub-8x8 chroma block whose
3043+ /// `uv_mode` is `UV_CFL_PRED`. (lane-reelckf r1 burned 20 recipes across cq
3044+ /// 40..63 and nine lavfi sources hunting exactly this block and never got
3045+ /// one; ledger dead-end "never produced a SKIPPED 1:4 or sub-8x8 CfL
3046+ /// block".) Before the fix the two sub-8x8 skip arms passed `None` for the
3047+ /// CfL argument, so the block reconstructed as flat DC and 463 bytes of
3048+ /// this frame's chroma were wrong. HARD-asserts `skip_cfl_hits` moved, so
3049+ /// the fixture cannot silently stop exercising the arm.
3050+ #[test]
3051+ fn the_reelb_ss300_key_frame_skipped_cfl_decodes_pixel_exact() {
3052+ const NAME: &str = "the_reelb_ss300_key_frame_skipped_cfl_decodes_pixel_exact";
3053+ if !have_ffmpeg() {
3054+ eprintln!("SKIP {NAME}: no ffmpeg");
3055+ return;
3056+ }
3057+ let path = std::path::Path::new(env!("CARGO_MANIFEST_DIR"))
3058+ .join("fixtures/reelb_ss300_key_frame.obu");
3059+ let stream = std::fs::read(&path)
3060+ .unwrap_or_else(|e| panic!("{NAME}: reading {}: {e}", path.display()));
3061+ let (width, height) = (3840usize, 1608usize);
3062+ let before = crate::decode::skip_cfl_hits();
3063+ let frames = match decode_stream(&stream) {
3064+ Ok(frames) => frames,
3065+ Err(e) => panic!("{NAME}: decode_stream refused: {e}"),
3066+ };
3067+ let skipped_cfl = crate::decode::skip_cfl_hits() - before;
3068+ assert!(
3069+ skipped_cfl > 0,
3070+ "{NAME}: zero skipped sub-8x8 CfL blocks -- the fixture no longer \
3071+ exercises the arm this test exists for"
3072+ );
3073+ assert_eq!(frames.len(), 1, "{NAME}: one key frame");
3074+ assert_eq!((frames[0].width, frames[0].height), (width, height));
3075+ let ffmpeg_frames = ffmpeg_decode_sequence_10bit(&stream, width, height, 1);
3076+ assert_eq!(frames[0].y, ffmpeg_frames[0].y, "{NAME}: luma vs ffmpeg");
3077+ assert_eq!(frames[0].u, ffmpeg_frames[0].u, "{NAME}: U vs ffmpeg");
3078+ assert_eq!(frames[0].v, ffmpeg_frames[0].v, "{NAME}: V vs ffmpeg");
3079+ eprintln!("{NAME}: {skipped_cfl} skipped sub-8x8 CfL chroma blocks, frame pixel-exact");
3080+ }
3081+
3034 /// lane-hbd10 r1: a real `aomenc --bit-depth=10 --superres-mode=13082 /// lane-hbd10 r1: a real `aomenc --bit-depth=10 --superres-mode=1
3035 /// --superres-denominator=12` key frame, decoded pixel-exact against3083 /// --superres-denominator=12` key frame, decoded pixel-exact against
3036 /// ffmpeg's own 10-bit decode. Proves `superres::upscale_row`'s3084 /// ffmpeg's own 10-bit decode. Proves `superres::upscale_row`'s
@@ -6782,6 +6830,240 @@ mod tests {
6782 }6830 }
6783 }6831 }
6784 6832
6833+ /// lane-r14 r3: a 1:4 inter strip with a 64-px axis (64x16 / 16x64) whose
6834+ /// transform SPLITS -- the arm r2 left refused by name ("a split transform
6835+ /// on a 1:4 inter strip with a 64-px axis"). libaom's
6836+ /// `sub_tx_size_map[TX_64X16] == TX_32X16` (and `[TX_16X64] == TX_16X32`)
6837+ /// keeps the sub-transform RECTANGULAR, so the var-tx tree's leaves are
6838+ /// 32x16/16x32 units read through [`TxbSet::LumaRect32x16Inter`], each with
6839+ /// its own `get_txb_ctx_general` neighbour context (the unit is smaller
6840+ /// than its block, so `txb_skip_ctx` is NOT the lone-TU 0).
6841+ ///
6842+ /// `--enable-1to4-partitions=1 --min-partition-size=16
6843+ /// --max-partition-size=64 --enable-tx64=1` (each spelled once, last
6844+ /// occurrence wins) is what lets aomenc pick a superblock-level HORZ_4 /
6845+ /// VERT_4; the textured translating source is what keeps the strips
6846+ /// non-skip so the residual is actually coded. 8-bit AND 10-bit, every
6847+ /// decoded frame compared to ffmpeg on Y/U/V, refusals counted (never
6848+ /// SKIPped), attempts that carried no rectangular var-tx leaf counted
6849+ /// separately and still required pixel-exact.
6850+ #[test]
6851+ fn real_aomenc_1to4_streams_decode_pixel_exact_and_rect_vartx_leaves_fire_before_a_named_refusal() {
6852+ const NAME: &str =
6853+ "real_aomenc_1to4_streams_decode_pixel_exact_and_rect_vartx_leaves_fire_before_a_named_refusal";
6854+ let _gate_lock = lock_gate_counters();
6855+ if !have_ffmpeg() {
6856+ eprintln!("SKIP {NAME}: no ffmpeg");
6857+ return;
6858+ }
6859+ if !have_aomenc() {
6860+ eprintln!("SKIP {NAME}: no aomenc at {}", aomenc_path().display());
6861+ return;
6862+ }
6863+ let frame_count = 6usize;
6864+ for bit_depth in [8u32, 10u32] {
6865+ let (mut named_refusals, mut compared, mut out_of_scope, mut oos_mismatch) =
6866+ (0u32, 0u32, 0u32, 0u32);
6867+ let (mut leaf_32x16, mut leaf_16x32) = (0usize, 0usize);
6868+ // Leaves decoded on ANY attempt, including one whose stream hits a
6869+ // later named refusal: the firing half of this gate, kept apart
6870+ // from `leaf_32x16`/`leaf_16x32` (pixel-compared attempts only) so
6871+ // a refused stream is never counted as a pixel proof
6872+ // (class counter-from-refused-stream).
6873+ let (mut fired_32x16, mut fired_16x32) = (0usize, 0usize);
6874+ for attempt in 0..18u32 {
6875+ // Two orientations (the transposed pair a one-sided gate could
6876+ // never separate) x four quantisers x two motion steps.
6877+ // lane-r14 r4 recipe hunt (~70 aomenc runs on the merged
6878+ // tree: testsrc2 / life / mandelbrot / banded motion, 64x64 up
6879+ // to 384x256, cq 20..58): attempts 16-17 carry the only recipe
6880+ // found that makes aomenc code a 64-axis 1:4 strip whose
6881+ // transform SPLITS -- 384x256, per-16-column band motion,
6882+ // cq 32 (16x32 leaves) and cq 38 (32x16 leaves).
6883+ let firing = attempt >= 16;
6884+ let (width, height) =
6885+ if firing { (384usize, 256usize) } else { (192usize, 128usize) };
6886+ let vertical = attempt % 2 == 1;
6887+ let cq = if firing {
6888+ [32, 38][(attempt - 16) as usize]
6889+ } else {
6890+ [30, 36, 44, 52][(attempt / 2 % 4) as usize]
6891+ };
6892+ let sp = 3 + (attempt / 8) * 3;
6893+ // 16-pixel bands, each band translating at its OWN speed
6894+ // across the other axis: that is what makes aomenc's RD split
6895+ // a 64x64 superblock into four 1:4 strips (`PARTITION_HORZ_4`
6896+ // / `VERT_4`) with distinct motion vectors, and the texture
6897+ // inside a band is what keeps the strip non-skip and its
6898+ // transform split.
6899+ let geq = if firing {
6900+ "128+60*sin((Y-N*(1+0.37*mod(floor(X/16),4)))/3)+45*sin(Y/17+X/23)"
6901+ .to_string()
6902+ } else if vertical {
6903+ format!(
6904+ "128+60*sin((Y+N*({sp}+9*mod(floor(X/16),2)))/7)+25*sin(X/11)"
6905+ )
6906+ } else {
6907+ format!(
6908+ "128+60*sin((X+N*({sp}+9*mod(floor(Y/16),2)))/7)+25*sin(Y/11)"
6909+ )
6910+ };
6911+ let duration = frame_count as f64 / 25.0;
6912+ let source = format!(
6913+ "color=c=gray:s={width}x{height}:d={duration}:r=25,format=gray,\
6914+ geq=lum='{geq}',format=yuv420p"
6915+ );
6916+ let pix_fmt = if bit_depth == 10 { "yuv420p10le" } else { "yuv420p" };
6917+ let y4m = Command::new("ffmpeg")
6918+ .args([
6919+ "-v", "error", "-f", "lavfi", "-i", &source, "-t", &duration.to_string(),
6920+ "-pix_fmt", pix_fmt, "-strict", "-1", "-f", "yuv4mpegpipe", "-",
6921+ ])
6922+ .stdin(Stdio::null())
6923+ .stdout(Stdio::piped())
6924+ .stderr(Stdio::piped())
6925+ .output()
6926+ .expect("ffmpeg failed to run");
6927+ assert!(
6928+ y4m.status.success(),
6929+ "{NAME}: ffmpeg refused the {bit_depth}-bit fixture: {}",
6930+ String::from_utf8_lossy(&y4m.stderr)
6931+ );
6932+ let cq_arg = format!("--cq-level={cq}");
6933+ let depth_arg = format!("--bit-depth={bit_depth}");
6934+ let input_depth_arg = format!("--input-bit-depth={bit_depth}");
6935+ let args: Vec<&str> = vec![
6936+ "--codec=av1", "--passes=1", "--end-usage=q", &cq_arg, "--cpu-used=0",
6937+ "--threads=1", "--row-mt=0", "--sb-size=64", &depth_arg, &input_depth_arg,
6938+ "--enable-restoration=0", "--enable-palette=0", "--deltaq-mode=0",
6939+ "--enable-filter-intra=0", "--enable-cfl-intra=0", "--enable-intrabc=0",
6940+ "--lag-in-frames=0",
6941+ // Per-arm overrides go LAST: aomenc keeps the last
6942+ // occurrence of a repeated --enable-* flag.
6943+ "--enable-tx64=1", "--enable-rect-partitions=1",
6944+ "--enable-ab-partitions=0", "--enable-1to4-partitions=1",
6945+ "--enable-dual-filter=0", "--enable-obmc=0",
6946+ "--min-partition-size=16", "--max-partition-size=64",
6947+ "--obu", "-o", "-", "-",
6948+ ];
6949+ let mut child = Command::new(aomenc_path())
6950+ .args(&args)
6951+ .stdin(Stdio::piped())
6952+ .stdout(Stdio::piped())
6953+ .stderr(Stdio::piped())
6954+ .spawn()
6955+ .expect("aomenc failed to start");
6956+ child
6957+ .stdin
6958+ .take()
6959+ .expect("aomenc stdin")
6960+ .write_all(&y4m.stdout)
6961+ .expect("writing y4m to aomenc");
6962+ let out = child.wait_with_output().expect("aomenc failed to run");
6963+ assert!(
6964+ out.status.success(),
6965+ "aomenc refused the fixture: {}",
6966+ String::from_utf8_lossy(&out.stderr)
6967+ );
6968+ let stream = out.stdout;
6969+ let before = crate::stream::vartx_rect_leaf_hits();
6970+ let frames = match decode_stream(&stream) {
6971+ Err(e) => {
6972+ let msg = e.to_string();
6973+ assert!(
6974+ msg.contains("unsupported"),
6975+ "{NAME} failed outright, not a named refusal ({bit_depth}-bit, \
6976+ attempt {attempt}): {msg}"
6977+ );
6978+ let after = crate::stream::vartx_rect_leaf_hits();
6979+ fired_32x16 += after[0] - before[0];
6980+ fired_16x32 += after[1] - before[1];
6981+ named_refusals += 1;
6982+ eprintln!(
6983+ "{bit_depth}-bit attempt {attempt} refusal (rect var-tx leaves \
6984+ decoded before it: 32x16={}, 16x32={}): {msg}",
6985+ after[0] - before[0],
6986+ after[1] - before[1]
6987+ );
6988+ continue;
6989+ }
6990+ Ok(frames) => frames,
6991+ };
6992+ let after = crate::stream::vartx_rect_leaf_hits();
6993+ let (h32, v32) = (after[0] - before[0], after[1] - before[1]);
6994+ fired_32x16 += h32;
6995+ fired_16x32 += v32;
6996+ let ffmpeg_frames = if bit_depth == 10 {
6997+ ffmpeg_decode_sequence_10bit(&stream, width, height, frame_count)
6998+ } else {
6999+ ffmpeg_decode_sequence(&stream, width, height, frame_count)
7000+ };
7001+ assert_eq!(frames.len(), frame_count);
7002+ let mismatched = frames
7003+ .iter()
7004+ .zip(&ffmpeg_frames)
7005+ .any(|(got, want)| got.y != want.y || got.u != want.u || got.v != want.v);
7006+ if h32 + v32 == 0 {
7007+ // Counted per ATTEMPT, on a decoded+compared attempt only
7008+ // (class counter-from-refused-stream).
7009+ out_of_scope += 1;
7010+ if mismatched {
7011+ oos_mismatch += 1;
7012+ eprintln!(
7013+ "{NAME}: {bit_depth}-bit attempt {attempt} MISMATCHES with zero \
7014+ rectangular var-tx leaves -- another shape's defect"
7015+ );
7016+ }
7017+ continue;
7018+ }
7019+ for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() {
7020+ assert_eq!(got.y, want.y, "{NAME} frame {i} luma vs ffmpeg (attempt {attempt}, {bit_depth}-bit)");
7021+ assert_eq!(got.u, want.u, "{NAME} frame {i} U vs ffmpeg (attempt {attempt}, {bit_depth}-bit)");
7022+ assert_eq!(got.v, want.v, "{NAME} frame {i} V vs ffmpeg (attempt {attempt}, {bit_depth}-bit)");
7023+ }
7024+ leaf_32x16 += h32;
7025+ leaf_16x32 += v32;
7026+ compared += 1;
7027+ }
7028+ eprintln!(
7029+ "{NAME} ({bit_depth}-bit): {named_refusals} named refusals, {compared} \
7030+ pixel-exact attempts carrying the arm, pixel-compared rect var-tx leaves \
7031+ 32x16={leaf_32x16} 16x32={leaf_16x32}, leaves decoded anywhere in the sweep \
7032+ 32x16={fired_32x16} 16x32={fired_16x32}, {out_of_scope} attempts carried none \
7033+ ({oos_mismatch} of them mismatched)"
7034+ );
7035+ assert_eq!(
7036+ oos_mismatch, 0,
7037+ "{NAME}: {oos_mismatch} attempt(s) with no rectangular var-tx leaf decoded \
7038+ but mismatched ffmpeg -- a defect of another shape, not a pass"
7039+ );
7040+ assert!(
7041+ compared + out_of_scope > 0,
7042+ "{NAME} ({bit_depth}-bit): every attempt refused -- the gate compared no pixels"
7043+ );
7044+ // The firing half. MEASURED on the merged tree (lane-r14 r4, ~70
7045+ // aomenc runs): the 8-bit 384x256 banded recipe codes BOTH
7046+ // orientations of the split -- cq 38 gives four 32x16 leaves (out
7047+ // of four 64x16 strips), cq 32 one 16x32 leaf (out of four 16x64
7048+ // strips). Those two streams stop LATER on another lane's live
7049+ // refusal ("an inter 16x16-level AB or 1:4 partition", "a non-skip
7050+ // rectangular (HORZ/VERT/HORZ_B) strip needs rectangular residual
7051+ // coding"), so the leaves are proved DECODED, not proved
7052+ // pixel-exact; every attempt that ran to the end is compared
7053+ // frame by frame above. At 10 bits the same sweep fires nothing
7054+ // (aomenc picks other shapes), so the firing assert is 8-bit only
7055+ // -- and it is a hard assert, never a print.
7056+ if bit_depth == 8 {
7057+ assert!(
7058+ fired_32x16 > 0 && fired_16x32 > 0,
7059+ "{NAME}: the rectangular var-tx leaf arm never fired (32x16={fired_32x16}, \
7060+ 16x32={fired_16x32}, {named_refusals} refusals, {compared} compared) -- \
7061+ `sub_tx_size_map[TX_64X16] == TX_32X16` is unproved by this gate"
7062+ );
7063+ }
7064+ }
7065+ }
7066+
6785 /// lane-inter4 r2: the 32x32-level inter `PARTITION_HORZ`/`PARTITION_VERT`7067 /// lane-inter4 r2: the 32x32-level inter `PARTITION_HORZ`/`PARTITION_VERT`
6786 /// strips (32x16 / 16x32) carrying a REAL residual -- the capability r17068 /// strips (32x16 / 16x32) carrying a REAL residual -- the capability r1
6787 /// found missing ("a non-skip rectangular (HORZ/VERT/HORZ_B) strip needs7069 /// found missing ("a non-skip rectangular (HORZ/VERT/HORZ_B) strip needs
@@ -21344,6 +21626,11 @@ mod tests {
21344 let (mut horz_proved, mut vert_proved) = (0usize, 0usize);21626 let (mut horz_proved, mut vert_proved) = (0usize, 0usize);
21345 let (mut chroma_proved, mut coeff_proved) = (0usize, 0usize);21627 let (mut chroma_proved, mut coeff_proved) = (0usize, 0usize);
21346 let mut split_proved = 0usize;21628 let mut split_proved = 0usize;
21629+ // lane-kf1200: chroma pairs whose intra-edge filter type comes out
21630+ // different when read from the PAIR's base mi (libaom's
21631+ // `chroma_above_mbmi`) rather than the odd strip mi -- the shape
21632+ // that was silently wrong by 1 on the ReelB key frames.
21633+ let mut pair_filt_proved = 0usize;
21347 let (mut out_of_scope, mut out_of_scope_mismatch) = (0u32, 0u32);21634 let (mut out_of_scope, mut out_of_scope_mismatch) = (0u32, 0u32);
21348 // The second half of the window turns `--enable-tx-size-search` on:21635 // The second half of the window turns `--enable-tx-size-search` on:
21349 // that is what makes a 16x4 strip SPLIT its transform (depth 1 =21636 // that is what makes a 16x4 strip SPLIT its transform (depth 1 =
@@ -21356,11 +21643,26 @@ mod tests {
21356 let axis = if attempt % 2 == 0 { "Y" } else { "X" };21643 let axis = if attempt % 2 == 0 { "Y" } else { "X" };
21357 let step = 67 + (attempt / 2) * 12;21644 let step = 67 + (attempt / 2) * 12;
21358 let noise = 6 + (attempt % 4) * 3;21645 let noise = 6 + (attempt % 4) * 3;
21359- let source = format!(21646+ // lane-kf1200: the odd attempts carry CHROMA content. The
21360- "color=c=gray:s={width}x{height}:d={duration}:r=25,format=gray,\21647+ // original gray source leaves both chroma planes constant, so
21361- geq=lum='mod(floor({axis}/4)*{step},256)',\21648+ // every `uv_mode` is DC and a pair's edge-filter type can never
21362- noise=alls={noise}:all_seed={seed},format=yuv420p"21649+ // differ from its strip's -- the shape that shipped wrong for
21363- );21650+ // months. A smooth chroma gradient makes aomenc pick SMOOTH /
21651+ // directional `uv_mode`s next to each other.
21652+ let source = if attempt % 2 == 0 {
21653+ format!(
21654+ "color=c=gray:s={width}x{height}:d={duration}:r=25,format=gray,\
21655+ geq=lum='mod(floor({axis}/4)*{step},256)',\
21656+ noise=alls={noise}:all_seed={seed},format=yuv420p"
21657+ )
21658+ } else {
21659+ format!(
21660+ "color=c=black:s={width}x{height}:d={duration}:r=25,format=yuv420p,\
21661+ geq=lum='mod(floor({axis}/4)*{step},256)'\
21662+ :cb='128+100*sin((X+Y)/23)':cr='128+100*cos(X/19)',\
21663+ noise=alls={noise}:all_seed={seed}"
21664+ )
21665+ };
21364 let cq_level = format!("--cq-level={}", 24 + (attempt % 4) * 8);21666 let cq_level = format!("--cq-level={}", 24 + (attempt % 4) * 8);
21365 let pix_fmt = if bit_depth == 10 { "yuv420p10le" } else { "yuv420p" };21667 let pix_fmt = if bit_depth == 10 { "yuv420p10le" } else { "yuv420p" };
21366 let y4m = Command::new("ffmpeg")21668 let y4m = Command::new("ffmpeg")
@@ -21439,6 +21741,7 @@ mod tests {
21439 );21741 );
21440 let stream = out.stdout;21742 let stream = out.stdout;
21441 let before = crate::decode::rect4_16_counters();21743 let before = crate::decode::rect4_16_counters();
21744+ let pair_filt_before = crate::decode::rect4_16_uv_pair_filt_hits();
21442 let frames = match decode_stream(&stream) {21745 let frames = match decode_stream(&stream) {
21443 Err(e) => {21746 Err(e) => {
21444 let msg = e.to_string();21747 let msg = e.to_string();
@@ -21507,6 +21810,7 @@ mod tests {
21507 vert_proved += vert;21810 vert_proved += vert;
21508 chroma_proved += chroma;21811 chroma_proved += chroma;
21509 coeff_proved += coeff;21812 coeff_proved += coeff;
21813+ pair_filt_proved += crate::decode::rect4_16_uv_pair_filt_hits() - pair_filt_before;
21510 split_proved += split;21814 split_proved += split;
21511 matched += 1;21815 matched += 1;
21512 }21816 }
@@ -21539,11 +21843,17 @@ mod tests {
21539 "{NAME}: {bit_depth}-bit compared attempts never split a strip's transform -- \21843 "{NAME}: {bit_depth}-bit compared attempts never split a strip's transform -- \
21540 the `--enable-tx-size-search=1` half of the window proved nothing"21844 the `--enable-tx-size-search=1` half of the window proved nothing"
21541 );21845 );
21846+ assert!(
21847+ pair_filt_proved > 0,
21848+ "{NAME}: {bit_depth}-bit compared attempts never decoded a chroma pair whose \
21849+ edge-filter type differs between the pair's base mi and the strip's own mi -- \
21850+ the lane-kf1200 fix is unexercised, so this gate would pass with it reverted"
21851+ );
21542 eprintln!(21852 eprintln!(
21543 "{NAME}: {bit_depth}-bit {matched} compared attempts, {horz_proved} 16x4 / \21853 "{NAME}: {bit_depth}-bit {matched} compared attempts, {horz_proved} 16x4 / \
21544 {vert_proved} 4x16 strips, {chroma_proved} chroma pairs, {coeff_proved} coded \21854 {vert_proved} 4x16 strips, {chroma_proved} chroma pairs, {coeff_proved} coded \
21545- units, {split_proved} split-transform strips, {named_refusals} refusals, \21855+ units, {split_proved} split-transform strips, {pair_filt_proved} pair-base \
21546- {out_of_scope} out of scope"21856+ filt-type flips, {named_refusals} refusals, {out_of_scope} out of scope"
21547 );21857 );
21548 }21858 }
21549 }21859 }
lanes/kf1200-r1.report.mdadded+106 -0
@@ -0,0 +1,106 @@
1+# lane-kf1200 r1 — the 16x4/4x16 chroma pair read its edge-filter type from the wrong mi
2+
3+## Defect (census4 premise, re-measured on this branch)
4+
5+ReelB `-ss 1200` key frame (1 frame, `3840x1608 yuv420p10le`), our
6+`EC_PROBE_OUT16` vs `ffmpeg -pix_fmt yuv420p10le`: **12 U samples at ±1, Y and V exact**.
7+Stage bisect (`EC_AV1_PREFILT_DUMP16` ours vs aomdec's): **13 U samples already wrong
8+before the loop filter** — a reconstruction defect, not deblock/CDEF/LR/film grain, and
9+not an entropy desync (lane-kf900's shape).
10+
11+## Root cause
12+
13+Block: chroma `(x=352, y=356)`, `8x4`, `uv_mode = H_PRED`, `angle_delta_uv = -2`
14+(`p_angle = 174`), the chroma half of a `16x8` **`PARTITION_HORZ_4` pair** at
15+luma mi `(178,176)`, strip mi `(179,176)`.
16+Its prediction differed from aomdec's by 4 samples of the last row
17+(`OUR_PRED sum=16208` vs `EC_PREDOUT sum=16212`); row 0 and column 0 identical.
18+
19+`decode.rs:7683` asked for the chroma edge-filter type at the **strip's own mi**
20+(`lmi = (179,176)`). libaom builds `chroma_above_mbmi`/`chroma_left_mbmi` from
21+`mi[-((mi_row & ss_y) * mi_stride + (mi_col & ss_x))]` (`set_mi_offsets`,
22+`av1/common/blockd.h`), i.e. from the **pair's base mi** `(178,176)`, and
23+`get_intra_edge_filter_type` (`av1/common/reconintra.c:974`) reads that block's
24+`uv_mode`. The mi directly above the strip, `(178,176)`, is a non-chroma-reference
25+4-row block whose `uv_mode` is `UV_DC_PRED`; the mi above the PAIR, `(177,176)`,
26+coded `uv_mode = SMOOTH` (aomdec `EC_IMODE_VAL mi_row=177 mi_col=176 uv_mode=9`).
27+
28+So we computed `filt_type = 0` where libaom has `1` (aomdec `EC_PRED ... ft=1`).
29+With `filt_type = 0`, `av1_use_intra_edge_upsample(4, 8, -6, 0)` is TRUE
30+(`blk_wh = 12 <= 16`) instead of false — the left edge was upsampled before the
31+z2 walk, moving 4 samples by 1. The strength/upsample/z2 code itself is correct:
32+recomputing z2 by hand from the (identical) neighbour pixels reproduces aomdec's
33+row exactly (`scratchpad/kf1200`, brute force over dy/offsets).
34+
35+## Change
36+
37+- `crates/ec-av1/src/decode.rs:7683` — `smooth_uv_neighbour(pair_mi.0, pair_mi.1, ...)`
38+ instead of `(lmi.0, lmi.1, ...)`, with the libaom citation.
39+- `crates/ec-av1/src/decode.rs:2196` — new `RECT4_16_UV_PAIR_FILT_HITS` counter +
40+ `rect4_16_uv_pair_filt_hits()`: pairs where the pair-base answer DIFFERS from the
41+ strip-mi answer, i.e. the blocks the fix changes.
42+- `crates/ec-av1/src/stream.rs` gate
43+ `a_real_aomenc_stream_with_a_16_level_1to4_partition_decodes_pixel_exact` — the odd
44+ attempts now use a **chroma-carrying** source (smooth `cb`/`cr` gradients); the gray
45+ source left both chroma planes constant, so every `uv_mode` was DC and the shape was
46+ unreachable. New hard assert: `pair_filt_proved > 0` per bit-depth arm.
47+
48+No refusal lifted, so `refusal_inventory.rs`/`gate_coverage.rs` are unchanged.
49+
50+## EVIDENCE
51+
52+EVIDENCE: /tmp/.../scratchpad/kf1200/{ours16,ref.yuv} | ffmpeg -ss 1200 -t 0.4 -c:v copy -f obu, trunc.py to 1 frame (sha256 b4b92873d0329964 twice), decode_probe EC_PROBE_OUT16 vs ffmpeg yuv420p10le | U samples differing 12 -> 0, Y/V 0 (Y 0, U 0, V 0 after fix)
53+EVIDENCE: /tmp/.../scratchpad/kf1200/{pre.f0,apre.f0} | EC_AV1_PREFILT_DUMP16 ours vs aomdec on the same 1-frame stream | 13 U samples differ pre-loop-filter => reconstruction, not filters/grain
54+EVIDENCE: /tmp/.../scratchpad/kf1200/{opred.txt,apred.txt} | EC_PRED=1 on both decoders | block (352,356) 8x4 mode=2 ad=-2: ours sum=16208 vs EC_PREDOUT sum=16212, oracle EC_PRED ft=1
55+EVIDENCE: gate run `cargo test -p ec-av1 --lib a_real_aomenc_stream_with_a_16_level_1to4_partition_decodes_pixel_exact -- --nocapture` | real aomenc, 8-bit and 10-bit arms | 8-bit: 16 compared attempts, 232 16x4 / 244 4x16, 238 chroma pairs, 13 pair-base filt-type flips, PASS; 10-bit: 15 attempts, 198 pairs, 8 flips, PASS
56+EVIDENCE: same gate with the fix reverted (pair_mi -> lmi) | one-line revert, rebuild, rerun | FAILED "frame 0 U vs ffmpeg (8-bit, seed 43)" -- the gate is decisive, not vacuous
57+EVIDENCE: $HOME/.cache/kf1200-census.log | 24 HG key frames, 1-frame truncation, EC_PROBE_OUT16 vs ffmpeg, each stream sha256'd twice (identical) | see table
58+
59+## 24 key-frame census (bytes differing, 1 frame each)
60+
61+| -ss | before (census4) | after |
62+|----:|-----------------:|------:|
63+| 0 | 0 | 0 |
64+| 300 | 463 | 463 |
65+| 600 | 48771 | 48771 |
66+| 900 | 14057195 | 14057191 |
67+| **1200** | **14** | **0** |
68+| 1500 | 16649701 | 16649650 |
69+| **1800** | **248** | **0** |
70+| 2100 | 15147518 | 15147782 |
71+| 2400 | 42343 | 42343 |
72+| 2700 | 7726287 | 7726287 |
73+| 3000 | 0 | 0 |
74+| 3300 | 44500 | **39971** |
75+| **3600** | **1** | **0** |
76+| 3900 | 7554020 | 7554023 |
77+| 4200 | 0 | 0 |
78+| 4500 | 0 | 0 |
79+| 4800 | 2348 | 2348 |
80+| 5100 | 0 | 0 |
81+| 5400 | 0 | 0 |
82+| 5700 | 16375 | 16375 |
83+| 6000 | 15450360 | 15449720 |
84+| 6300 | 15410936 | 15410864 |
85+| 6600 | 15181681 | 15181688 |
86+| 6900 | 0 | 0 |
87+
88+(The census4 numbers were taken with the same recipe; note census4 measured frame 0 of a
89+segment that then refused later frames, and this run truncates to 1 frame identically.
90+The multi-million counts are lane-kf900's entropy-desync territory, unchanged here.)
91+
92+## Residue
93+
94+- deferred: `-ss 300` (463 bytes) — a DIFFERENT shape, also chroma-only and also
95+ pre-loop-filter, but block-constant offsets of +1/+2 over a ~16x16 chroma region at
96+ chroma (412,384) (`EC_AV1_PREFILT_DUMP16` diff, this branch) — reads like CfL alpha or
97+ a chroma DC/dequant defect, not an edge-filter type. Unblocked by: localising that
98+ block's `uv_mode`/CfL alpha the same way (EC_IMODE_VAL + EC_PRED at mi (206,192)).
99+- deferred: `-ss 600 / 2400 / 4800 / 5700 / 3300` (48771 / 42343 / 2348 / 16375 / 39971) —
100+ larger residuals, not triaged in this round.
101+- accepted: the multi-million-byte segments are entropy desyncs owned by lane-kf900.
102+
103+## Suite
104+
105+`cargo test -p ec-av1 --lib` (systemd unit, `EC_AV1_REQUIRE_AOMENC=1`, log `$HOME/.cache/kf1200-suite-r1.log`):
106+**370 passed / 0 failed / 32 ignored**, 1546 s.
lanes/kf1200-r2.handoff.mdadded+72 -0
@@ -0,0 +1,72 @@
1+# lane-kf1200 r2 HANDOFF
2+
3+## Merge state
4+Branch `lane-kf1200`, tip `385b745`. `git merge main` (85887c7 = lane-mvtwin +
5+lane-sb128b) landed clean at `d85d7d2`; cdf.rs byte-identical to main's; r1's
6+pair-mi chroma edge-filter fix survives at decode.rs:7747. main contains
7+NEITHER lane-reelckf NOR lane-kf900 (`git log --oneline main | grep` empty for
8+both), so no duplicate-implementation resolution was needed and the
9+multi-million-byte census rows are still kf900's.
10+Do NOT commit `lanes/COMMON-20260901.md` — another agent edits it in this
11+worktree; it is intentionally left unstaged. (It is currently modified.)
12+
13+## Per-segment findings (ReelB, 1-frame truncation, EC_PROBE_OUT16 vs ffmpeg 10-bit)
14+- **-ss 300 — FIXED (463 -> 0 bytes).** Plane: U+V only, Y exact. First bad
15+ sample chroma (412,384). Stage: PRE-loop-filter (EC_AV1_PREFILT_DUMP16),
16+ 16x16 chroma region at (384,412). Block: the 4x4 chroma block of the
17+ BLOCK_4X4 2x2 group at luma mi (206,192); chroma-ref mi (207,193),
18+ `uv_mode=13` (UV_CFL_PRED), `skip=1`. Root cause: both sub-8x8 leaf decoders
19+ passed literal `None` for the CfL argument in their `skip_txfm` arm
20+ (decode.rs:10554/10555 4-leaf, :10916/10917 2-leaf), so the block
21+ reconstructed as flat DC. libaom `av1_predict_intra_block_facade`
22+ (av1/common/reconintra.c:1719) calls `cfl_predict_block` whenever
23+ `mbmi->uv_mode == UV_CFL_PRED`; `skip_txfm` drops only the residual.
24+ Fix: compute `cfl_ac_q3(y, gpx, gpy, 8)` and pass `alpha.zip(ac)` in both
25+ arms + `SKIP_CFL_HITS` counter (decode.rs:2207, `skip_cfl_hits()`).
26+ Effect: -ss 300 pixel-exact; -ss 4800 2348 -> 34 bytes as a side effect.
27+- **-ss 600 / 2400 / 3300 / 5700 — ONE class, open.** 48771 / 42343 / 39971 /
28+ 16375 bytes. All planes. Final-picture damage rows Y 1595..1607, chroma
29+ 796..803. Stage: PRE-loop-filter damage is EXACTLY luma rows 1600..1607,
30+ cols 192..3839 (rows 1595..1599 are deblock spill across the y=1600 edge).
31+ Frame is 1608 rows = 25 full 64-px SB rows + an 8-row remainder, so this is
32+ the bottom PARTIAL superblock row; its first three superblocks (cols 0..191)
33+ are pixel-exact. Block: our prediction trace matches aomdec block-for-block
34+ through mi (400,47) (mi 44 four TX_4X4 in an 8x8, mi 46 an 8x8). First
35+ divergence is the FIRST block of superblock #3:
36+ aomdec `EC_PRED mi_row=400 mi_col=48 txw=16 txh=8 mode=2 p_angle=180 bsize=5 part=1 ft=1`
37+ ours `OUR_PRED x=192 y=1600 bw=32 bh=16 mode=0 ad=0` (decode.rs:6511)
38+ i.e. a PARTITION-SYMBOL divergence at the root of a partial-height
39+ superblock (`has_rows == false`, 2 of 16 mi rows present). Not prediction,
40+ not caused by the preceding block. Root cause NOT yet identified.
41+- **-ss 4800 — open, small.** 34 bytes (was 2348). Chroma only, luma exact,
42+ PRE-loop-filter: U 25 + V 3 samples in an 8x4 chroma patch rows 540..543
43+ cols 1200..1207, |d| <= 6. Luma mi ~ (270,600). Same geometry as r1's
44+ 16x8 PARTITION_HORZ_4 pair defect -> likely a sibling of the pair-mi bug.
45+- Accepted (kf900's): 900, 1500, 2100, 2700, 3900, 6000, 6300, 6600.
46+
47+## Gate state
48+- New: `the_reelb_ss300_key_frame_skipped_cfl_decodes_pixel_exact`
49+ (crates/ec-av1/src/stream.rs), pins
50+ `crates/ec-av1/fixtures/reelb_ss300_key_frame.obu` (139201 B, sha256
51+ 7e3ddf0d602f9496b2f7eb11f051fd4a045020e094d5bc02f83825e2c494ef12, one
52+ 3840x1608 yuv420p10le key frame, `git add -f`, confirmed in `git ls-files`).
53+ HARD-asserts `skip_cfl_hits > 0` (it fires exactly ONCE in the whole frame)
54+ then Y/U/V vs ffmpeg. Fixture used because lane-reelckf r1's ledger dead-end
55+ records 20 aomenc recipes that never produced a skipped sub-8x8 CfL block.
56+- r1's `a_real_aomenc_stream_with_a_16_level_1to4_partition_decodes_pixel_exact`
57+ (chroma-carrying source + `pair_filt_proved > 0`) unchanged and green.
58+- No refusal lifted; refusal_inventory.rs / gate_coverage.rs untouched.
59+- Suite: 378 passed / 0 failed / 33 ignored (794.95 s),
60+ `$HOME/.cache/kf1200-suite-r2.log`.
61+
62+## Exact next step
63+Range-ladder the partition symbols of superblock (mi_row=400, mi_col=48) on
64+`scratchpad/kf1200/s600_f1.obu` (1 frame, sha256 36de46676ed7de70… stable
65+twice): both decoders are still in sync at mi (400,47), so start the ladder
66+there and compare aomdec's `r->ec.rng` at each `EC_IMODE`/partition read
67+against ours element by element (compare RANGE, never tell()). The suspect is
68+the `has_rows == false` forced-partition path at a 64x64 root with only 2 mi
69+rows left — we take a 32x16 where libaom takes 16x8. Artifacts already on disk
70+in scratchpad/kf1200: s600_f1.obu, a600p.trace (aomdec EC_PRED), o600.trace
71+(our OUR_PRED), pre600.f0 / apre600.f0 (prefilter dumps), d1.py (plane differ),
72+census.sh (24-frame census, debug probe path).
lanes/kf1200-r2.report.mdadded+183 -0
@@ -0,0 +1,183 @@
1+# lane-kf1200 r2 — a skipped sub-8x8 chroma block dropped its CfL alpha
2+
3+## 1. Merge
4+
5+`git merge --no-commit main` (main `85887c7`, lane-mvtwin + lane-sb128b) — clean
6+auto-merge, no conflicts. `crates/ec-av1/src/cdf.rs` byte-identical to main's
7+(`cmp <(git show main:.../cdf.rs) .../cdf.rs` → identical). r1's pair-mi chroma
8+edge-filter fix and its counter survive at `decode.rs:7747`. Commit `d85d7d2`.
9+main contains neither lane-reelckf nor lane-kf900 (`git log --oneline main | grep`
10+→ empty for both), so no duplicate-implementation resolution was needed and the
11+multi-million-byte census rows are still lane-kf900's territory.
12+
13+## 2. Defect found and fixed: `-ss 300`, 463 bytes → 0
14+
15+Re-measured premise on this branch (1-frame truncation, hash stable twice):
16+U 219 / V 220 samples wrong, Y exact. `EC_AV1_PREFILT_DUMP16` ours vs aomdec's:
17+227 U + 227 V wrong **before the loop filter**, in a 16x16 chroma region at
18+chroma `(384,412)` — reconstruction, not filters.
19+
20+First bad sample chroma `(412,384)` = the 4x4 chroma block of the `BLOCK_4X4`
21+2x2 group at luma mi `(206,192)`. aomdec `EC_TRACE_MODE`:
22+`EC_IMODE_VAL mi_row=207 mi_col=193 mode=4 uv_mode=13 skip=1` — `uv_mode = 13`
23+is `UV_CFL_PRED`, `skip_txfm = 1`. Our `OUR_PRED x=384 y=412 side=4 mode=0
24+sum=8240 row0=[515,515,515,515]` is flat: DC with **no CfL term at all**
25+(aomdec's own prediction sums to 8241 with a bottom-left ramp).
26+
27+Root cause: both sub-8x8 leaf decoders passed a literal `None` for the CfL
28+argument in their `skip_txfm` arm —
29+
30+- `crates/ec-av1/src/decode.rs:10554/10555` (the 4-leaf `BLOCK_4X4` group)
31+- `crates/ec-av1/src/decode.rs:10916/10917` (the 2-leaf group)
32+
33+libaom's `av1_predict_intra_block_facade` (`av1/common/reconintra.c:1719`) calls
34+`cfl_predict_block` whenever `mbmi->uv_mode == UV_CFL_PRED`; `skip_txfm` only
35+suppresses the residual, never the alpha. Both arms now compute
36+`cfl_ac_q3(y, gpx, gpy, 8)` and pass `alpha.zip(ac)`, exactly like the
37+non-skip arm two lines below and like the rect skip arms already did.
38+
39+### Class sweep
40+
41+Every chroma `reconstruct` / `reconstruct_rect` call site in `decode.rs` was
42+parsed and its cfl argument printed (script in the r2 scratchpad). The rect
43+skip arms (`6015`, `6519`, `8078`) already pass `alpha.zip(ac)`; the only other
44+literal `None` is `20284/20296`, which sits directly behind the refusal
45+"a non-DC chroma mode on an 8x8 inter-frame leaf" (`decode.rs:20212`), so
46+`uv_mode == DC_PRED` is guaranteed there. No other instance of the class.
47+
48+### Counter + gate
49+
50+- `decode.rs:2207` `SKIP_CFL_HITS` / `pub fn skip_cfl_hits()` — skipped sub-8x8
51+ chroma blocks that carried a CfL alpha.
52+- `crates/ec-av1/src/stream.rs`
53+ `the_reelb_ss300_key_frame_skipped_cfl_decodes_pixel_exact` — pins
54+ `crates/ec-av1/fixtures/reelb_ss300_key_frame.obu` (139 201 B, sha256
55+ `7e3ddf0d602f9496b2f7eb11f051fd4a045020e094d5bc02f83825e2c494ef12`, one
56+ 3840x1608 yuv420p10le key frame), decodes it, HARD-asserts
57+ `skip_cfl_hits > 0`, then compares Y/U/V against ffmpeg's own 10-bit decode.
58+ `git add -f` was used (bare `fixtures` in .gitignore); `git ls-files` confirms
59+ it is tracked.
60+
61+Why a fixture and not an aomenc recipe: lane-reelckf r1's ledger dead-end —
62+20 recipes (cq 40..63 × nine lavfi sources, min/max-partition sweeps, sb-size
63+64 and 128) never produced a **skipped** sub-8x8 CfL block (`skip_cfl` counter
64+0 in all). The shape fires exactly **once** in a whole 4K key frame, which is
65+why no synthetic source reaches it.
66+
67+No refusal lifted → `refusal_inventory.rs` / `gate_coverage.rs` unchanged.
68+
69+## 3. Remaining residuals — triaged, one class
70+
71+`-ss 600 / 2400 / 3300 / 5700` (48771 / 42343 / 39971 / 16375 bytes) are ONE
72+defect class, not four: in every one of them the damage is confined to the
73+**last 8 luma rows** of the frame.
74+
75+| -ss | Y rows wrong | U/V rows | first bad Y sample |
76+|----:|---|---|---|
77+| 600 | 1595..1607 | 796..803 | (1595, 2916) |
78+| 2400 | 1595..1607 | 796..803 | (1595, 2445) |
79+| 3300 | 1595..1607 | 796..803 | (1595, 1235) |
80+| 5700 | 1596..1607 | 796..803 | (1596, 3039) |
81+
82+`EC_AV1_PREFILT_DUMP16` on `-ss 600` narrows it further: pre-loop-filter the
83+damage is exactly rows **1600..1607**, columns **192..3839** (rows 1595..1599
84+in the final picture are deblock spill across the y=1600 edge). The frame is
85+1608 rows = 25 full 64-px superblock rows + one 8-row remainder, so this is the
86+bottom **partial** superblock row, and the first three superblocks of it
87+(columns 0..191) are pixel-exact.
88+
89+Divergence localised to a single block. Through luma mi `(400,47)` our
90+prediction trace matches aomdec's block for block (mi 44: four TX_4X4 in an
91+8x8; mi 46: 8x8 — `EC_PRED mi_row=400 mi_col=46 txw=8 txh=8`). At the very
92+first block of superblock #3:
93+
94+- aomdec: `EC_PRED mi_row=400 mi_col=48 txw=16 txh=8 mode=2 p_angle=180 bsize=5 part=1 ft=1`
95+- ours: `OUR_PRED x=192 y=1600 bw=32 bh=16 mode=0 ad=0` (decode.rs:6511)
96+
97+i.e. we read a 32x16 `PARTITION_HORZ` where libaom reads a 16x8, and the mode
98+differs too — a **partition-symbol divergence at the root of a partial-height
99+superblock** (`has_rows == false`, only 2 of 16 mi rows present), not a
100+prediction bug and not caused by the preceding block. Everything after it in
101+that row is garbage because the row never re-syncs (it is the last row, so
102+nothing propagates downward).
103+
104+`-ss 4800` (2348 bytes in r1, **34 bytes** after this round's CfL fix) is a
105+different, much smaller shape: chroma only,
106+U 29 + V 5 samples in the final picture. `EC_AV1_PREFILT_DUMP16` puts it
107+**pre-loop-filter** too — U 25 + V 3 samples in an **8x4 chroma patch** at
108+rows 540..543, cols 1200..1207 (`|d| <= 6`), luma exact. That is the same
109+geometry as r1's defect (an 8x4 chroma block = the chroma half of a 16x8
110+`PARTITION_HORZ_4` pair) at luma mi ~`(270,600)`, so it is a strong candidate
111+for a sibling of the pair-mi bug rather than a new class.
112+
113+## 4. Disposition
114+
115+- fix-now (done): `-ss 300` skipped-CfL, fixed + gated + swept.
116+- deferred: the bottom partial-superblock partition divergence (`-ss 600`,
117+ 2400, 3300, 5700). Unblocked by: a range ladder over the partition symbols
118+ of superblock `(mi_row=400, mi_col=48)` in `s600_f1.obu` comparing aomdec's
119+ `r->ec.rng` at `EC_IMODE` against ours — the first three superblocks of the
120+ same row are exact, so the ladder starts already in sync at mi 400/47.
121+- deferred: `-ss 4800` (34 B, down from 2348) — stage-attributed (pre-loop-filter, chroma-only,
122+ 8x4 patch at chroma (540,1200), luma mi ~(270,600)); the per-block
123+ `EC_IMODE_VAL`/`EC_PRED` comparison at that mi is the next step.
124+- accepted: `-ss 900 / 1500 / 2100 / 2700 / 3900 / 6000 / 6300 / 6600`
125+ (multi-million bytes) are lane-kf900's entropy desyncs, not merged into main.
126+
127+## 5. 24 key-frame census (bytes differing vs ffmpeg, 1 truncated frame each)
128+
129+Recipe: `$HOME/.cache/kf1200-census-r2.log` (script `census.sh` in the r2
130+scratchpad) — `ffmpeg -ss S -t 0.4 -c:v copy -f obu`, `trunc.py … 1`, each
131+stream sha256'd twice (identical in all 24 rows), `EC_PROBE_OUT16` vs
132+`ffmpeg -pix_fmt yuv420p10le`.
133+
134+| -ss | r1 (after pair-mi fix) | r2 (after skipped-CfL fix) |
135+|----:|-----------------------:|---------------------------:|
136+| 0 | 0 | 0 |
137+| **300** | **463** | **0** |
138+| 600 | 48771 | 48771 |
139+| 900 | 14057191 | 14057191 |
140+| 1200 | 0 | 0 |
141+| 1500 | 16649650 | 16649650 |
142+| 1800 | 0 | 0 |
143+| 2100 | 15147782 | 15148697 |
144+| 2400 | 42343 | 42343 |
145+| 2700 | 7726287 | 7726168 |
146+| 3000 | 0 | 0 |
147+| 3300 | 39971 | 39971 |
148+| 3600 | 0 | 0 |
149+| 3900 | 7554023 | 7554023 |
150+| 4200 | 0 | 0 |
151+| 4500 | 0 | 0 |
152+| **4800** | **2348** | **34** |
153+| 5100 | 0 | 0 |
154+| 5400 | 0 | 0 |
155+| 5700 | 16375 | 16375 |
156+| 6000 | 15449720 | 15449720 |
157+| 6300 | 15410864 | 15410664 |
158+| 6600 | 15181688 | 15180826 |
159+| 6900 | 0 | 0 |
160+
161+**11 of 24 key frames now decode pixel-exact** (was 10). `-ss 300` is exact;
162+`-ss 4800` fell 2348 → 34 bytes (its remaining 8x4 chroma patch is the residue
163+described in §3). Rows differing by a few hundred bytes inside the
164+multi-million-byte segments are the usual desync churn of lane-kf900's
165+territory, not a regression: none of them changed sign or magnitude class.
166+
167+## 6. Suite
168+
169+`cargo test -p ec-av1 --lib` under `systemd-run --user --unit=kf1200-suite-r2b
170+-p MemoryMax=10G`, `EC_AV1_REQUIRE_AOMENC=1 EC_NOMEMGUARD=1 -j3`, log
171+`$HOME/.cache/kf1200-suite-r2.log`:
172+**378 passed / 0 failed / 33 ignored**, 794.95 s.
173+
174+## EVIDENCE
175+
176+EVIDENCE: $HOME/.cache/kf1200-suite-r2.log | systemd unit kf1200-suite-r2b, EC_AV1_REQUIRE_AOMENC=1, cargo test -p ec-av1 --lib -j3 | test result: ok. 378 passed; 0 failed; 33 ignored; 794.95s
177+EVIDENCE: scratchpad/kf1200/{o300,r300} | 1-frame -ss 300 truncation (sha256 7e3ddf0d602f9496 twice), EC_PROBE_OUT16 vs ffmpeg -pix_fmt yuv420p10le | before fix Y 0 / U 219 / V 220 samples differ; after fix Y 0 / U 0 / V 0
178+EVIDENCE: scratchpad/kf1200/{pre300.f0,apre300.f0} | EC_AV1_PREFILT_DUMP16 ours vs aomdec, same stream | 227 U + 227 V wrong PRE-loop-filter in a 16x16 chroma region at (384,412) => reconstruction
179+EVIDENCE: scratchpad/kf1200/{o300.trace,a300.trace} | EC_PRED=1 ours, EC_TRACE_MODE=1 EC_PRED=1 aomdec | aomdec EC_IMODE_VAL mi_row=207 mi_col=193 uv_mode=13 (UV_CFL_PRED) skip=1; ours OUR_PRED x=384 y=412 side=4 mode=0 sum=8240 flat (no CfL term)
180+EVIDENCE: gate run `cargo test -p ec-av1 --lib the_reelb_ss300 -- --nocapture` | pinned 1-frame fixture + ffmpeg 10-bit reference | "1 skipped sub-8x8 CfL chroma blocks, frame pixel-exact", 1 passed / 0 failed
181+EVIDENCE: scratchpad/kf1200/{pre600.f0,apre600.f0} | EC_AV1_PREFILT_DUMP16 ours vs aomdec on the -ss 600 1-frame stream | damage exactly luma rows 1600..1607, cols 192..3839 = the bottom partial (8-row) superblock row from superblock #3 on
182+EVIDENCE: scratchpad/kf1200/{o600.trace,a600p.trace} | EC_PRED both decoders | mi (400,44) and (400,46) match block for block; at mi (400,48) aomdec txw=16 txh=8 mode=2 bsize=5 vs ours bw=32 bh=16 mode=0 => partition divergence at the partial-SB root
183+EVIDENCE: $HOME/.cache/kf1200-census-r2.log | census.sh, 24 key frames, each stream hashed twice | 11/24 pixel-exact (was 10); -ss 300 463->0, -ss 4800 2348->34
lanes/r14-r3.report.mdadded+104 -0
@@ -0,0 +1,104 @@
1+# lane-r14 round 3 — the SPLIT transform of a 1:4 inter strip with a 64-px axis
2+
3+## What changed
4+
5+- `crates/ec-av1/src/decode.rs sub_tx_size_map(tx_w, tx_h)` — NEW, the full libaom
6+ `sub_tx_size_map[TX_SIZES_ALL]` (`common_data.c`) transcribed, with a unit test
7+ (`sub_tx_size_map_matches_libaom`) enumerating all 19 entries. The load-bearing rows are the
8+ ones r2 refused on: `[TX_64X16] == TX_32X16`, `[TX_16X64] == TX_16X32` — RECTANGULAR.
9+- `crates/ec-av1/src/decode.rs read_var_tx_size` — now takes `(tx_w, tx_h)` and recurses exactly
10+ as libaom `read_tx_size_vartx` (`decodeframe.c`) does: `ctx` from `txfm_partition_context`
11+ (already rect-general here — above vs `tx_size_wide`, left vs `tx_size_high`, category from
12+ `txsize_sqr_up_map`), `sub_txs = sub_tx_size_map[tx_size]`, loop
13+ `for row in (0..tx_size_high_unit[tx_size]).step_by(bsh) { for col in (0..tx_size_wide_unit).step_by(bsw) }`,
14+ and libaom's `sub_txs == TX_4X4` early return generalised to `tx_h/4 x tx_w/4` cells.
15+ Leaves are now `(row, col, tw, th)` instead of the square `(row, col, tx_px)`.
16+- `crates/ec-av1/src/decode.rs read_block_tx_size_rect` — the refusal
17+ `"a split transform on a 1:4 inter strip with a 64-px axis"` is GONE; the depth-1 recursion
18+ starts from `sub_tx_size_map(bw, bh)` and can therefore hand back rectangular leaves.
19+- `crates/ec-av1/src/decode.rs` — both duplicated inter var-tx leaf loops (the two the r2 report
20+ named, `decode_inter_block`'s compound and non-compound arms) now branch on `tw != th`: a
21+ rectangular leaf reads through `read_inter_plane_rect` with `rect_inter_luma_set(tw, th)`
22+ (`LumaRect32x16Inter`, the 2-symbol `EXT_TX_SET_DCT_IDTX` inter row — `av1_get_ext_tx_set_type`
23+ at `tx_size_sqr_up == TX_32X32`), its own `luma_skip_ctx_rect` / `around_mi_rect` /
24+ `record_mi_luma_rect` spans, and the block's own square prediction stride offset at the leaf.
25+- `crates/ec-av1/src/decode.rs read_inter_plane_rect` — gains `luma_skip_ctx: Option<usize>`:
26+ `get_txb_ctx_general`'s `txb_skip_ctx` is 0 only when the unit IS the whole plane block, which
27+ a var-tx leaf is not. The 6 whole-block call sites pass `None` (unchanged behaviour).
28+- `crates/ec-av1/src/decode.rs` + `stream.rs` — `vartx_rect_leaf_hits() -> [usize; 2]`
29+ (`[32x16, 16x32]`), and `examples/decode_probe.rs` prints it.
30+- `crates/ec-av1/src/refusal_inventory.rs` — the refusal line dropped.
31+- `crates/ec-av1/src/gate_coverage.rs` — `enable-tx64` removed from `NEVER_EXERCISED_8BIT` and
32+ `NEVER_EXERCISED_10BIT` (the new gate spells `--enable-tx64=1` at both depths); its own tests
33+ are what dictated the edit.
34+- `crates/ec-av1/src/stream.rs` — new gate
35+ `a_real_aomenc_inter_1to4_recipe_decodes_pixel_exact_or_refuses_by_name` (see the honest
36+ scoping below).
37+
38+## Firing proof: his real film
39+
40+EVIDENCE: `decode_probe` on `seg4500.obu` (`ffmpeg -ss 4500 -t 2 -i <HG 2160p HDR10> -c:v copy -f obu`, 213 frame headers) | run under `systemd-run --user --scope -p MemoryMax=6G` on the r3 tip | `vartx_rect_leaf: 32x16=0 16x32=14`, `inter_rect: 64x32=24 32x64=24 64x16=0 16x64=16` — **14 rectangular var-tx leaves decoded**, and the stop moved from `a split transform on a 1:4 inter strip with a 64-px axis` to `an intra-coded HORZ/VERT strip needs rectangular intra prediction this decoder does not code yet` (lane-intrarect's wall)
41+
42+EVIDENCE: same command on `seg3000.obu` (288 frame headers) | before r3 it stopped at this round's refusal (r2 report) | now `REFUSED: an intra-coded HORZ/VERT strip needs rectangular intra prediction this decoder does not code yet` — this round's wall is off both mid-film segments
43+
44+EVIDENCE: same command on `seg300.obu` (206 frame headers) | unchanged wall (`intra-coded HORZ/VERT strip`) | but it now decodes 4 `16x64` strips and `vartx_rect_leaf 16x32=1` on the way there
45+
46+## Gate — and what it can NOT assert (measured, not assumed)
47+
48+`EC_AV1_REQUIRE_AOMENC=1 cargo test -p ec-av1 --lib -- --test-threads=1 1to4 superblock_level_rect_partition refusal_inventory gate_coverage sub_tx_size_map` → 17 passed / 0 failed (log `$HOME/.cache/r14-r3-g5.log`, plus `-g6` after the gate_coverage edit).
49+
50+The new gate sweeps 16 attempts x 2 bit depths of the chartered recipe
51+(`--enable-tx64=1 --enable-rect-partitions=1 --enable-ab-partitions=0 --enable-1to4-partitions=1
52+--min-partition-size=16 --max-partition-size=64 --sb-size=64 --cpu-used=0`, each flag spelled
53+once, per-arm overrides last), compares EVERY decoded frame to ffmpeg on Y/U/V, counts named
54+refusals, and hard-asserts `oos_mismatch == 0`. It does **not** assert the arm fired, and that is
55+a measured limitation of this branch, written at the assert site:
56+
57+> 5 recipe sweeps, 60+ real aomenc runs (lavfi banded-motion at 16-px band granularity,
58+> `testsrc2`, `life`, `mandelbrot`, `smptebars`; 192x128 and 384x256; cq 26..58; both
59+> `--min-partition-size` arms; `--enable-dual-filter=0 --enable-obmc=0` to clear an unrelated
60+> `switchable_interp` desync panic): aomenc only picks a superblock-level 1:4 partition on
61+> content that ALSO contains at least one of {an intra HORZ/VERT strip, a 16x16-level AB or 1:4
62+> partition, an SB-level AB partition, an inter partition below 8x8, a 32x8/8x32 rect residual}.
63+> Every one of those is another live refusal in this tree and stops the decode before the frame
64+> completes. With `--min-partition-size=32` aomenc emits no 1:4 partition at all (measured: the
65+> 64x16/16x64 counters read 0 across 12 recipes), so the 64-axis 1:4 shape is unreachable there.
66+
67+So the round's firing proof is the film, and the pixel-exactness proof is the sibling gates plus
68+this gate's `oos_mismatch == 0` sweep. That is a **deviation from the charter's gate clause**,
69+stated rather than papered over: the charter's "counters proving >=1 rectangular var-tx leaf of
70+each of 32x16/16x32 coded, decoded+compared" is not achievable on this branch's refusal set.
71+
72+## Sibling gates (COMMON's SIBLING GATES rule)
73+
74+`superblock_level_rect_partition`, `16_level_1to4`, `32x32_level_1to4`, `superblock_level_1to4`,
75+`filter_intra_on_a_32_level_1to4_strip`, `refusal_inventory`, `gate_coverage` — all green on the
76+r3 tip (`$HOME/.cache/r14-r3-g5.log` / `-g6.log`); they share `read_var_tx_size`,
77+`txfm_partition_*` and the leaf loops this round rewrote.
78+
79+## Residue
80+
81+- **deferred**(needs any one of lane-intrarect / SB-AB / 16-level-AB-1:4 / sub8 to merge — then
82+ flip the parked assert back on): a pixel-exact aomenc gate that hard-asserts a rectangular
83+ var-tx leaf. The assert and its restore instruction are in the gate body.
84+- **deferred**(needs grain synthesis in the dump path): the chartered per-frame 16-bit dump-before-
85+ refusal diff on `seg3000`. `EC_AV1_FINAL_DUMP` already dumps every decoded frame (no new env
86+ needed — reuse, not a new mode), but the ledger records the measurement it produces on this
87+ film: the dump is the PRE-grain reference copy, so a compare against `ffmpeg -pix_fmt
88+ yuv420p10le` reads as a whole-frame mismatch whose delta histogram is zero-mean +-5 film grain.
89+ Dumping a 2 s 2160p 10-bit segment is also multi-GB. Not run.
90+- **flagged, not mine**: `--enable-ab-partitions=0` streams still hit
91+ `an inter SB-level AB partition` in this decoder (memory class `refusal-from-own-desync`: a
92+ refusal naming a DISABLED tool is usually our own desync). Seen on `mandelbrot` cq50 and on
93+ several banded-motion recipes. Worth its own lane.
94+- **flagged, not mine**: a `switchable_interp's alphabet is exactly 3 symbols` PANIC (not a named
95+ refusal) on an aomenc stream with dual filter + OBMC enabled, 192x128 cq30. Reproduced with the
96+ new capability ABLATED, so it is pre-existing and unrelated to this round.
97+
98+## Suite
99+
100+`systemd-run --user --unit=r14-r3-suite-... -p MemoryMax=10G ... cargo test -p ec-av1 --lib -j3`
101+-> log `$HOME/.cache/r14-suite-r3.log`; totals appended below.
102+
103+**Suite result (r3 tip `81b6f9e`): 367 passed; 0 failed; 31 ignored, 622.33s** — up from r2's
104+365/0/31 by the two tests this round adds (`sub_tx_size_map_matches_libaom` and the new gate).
lanes/r14-r4.report.mdadded+87 -0
@@ -0,0 +1,87 @@
1+# lane-r14 round 4 — merge main, and the parked firing assert turned back on
2+
3+## 1. Merge `main` (18bf7dc) — commit `523c17d`
4+
5+`git merge --no-commit main` auto-merged with NO conflicts (diffstat: decode.rs +1117,
6+stream.rs +1100, mvstack.rs +114, encode.rs +47, refusal_inventory.rs, cdf.rs, cdf_state.rs,
7+decode_probe.rs, 9 lane reports). Checks run before committing:
8+
9+- `git diff main -- crates/ec-av1/src/cdf.rs` → **0 lines**: cdf.rs (NZ_MAP / FILTER_INTRA rows
10+ included) is byte-identical to main on the merged tree, so no table was rebound by the merge.
11+- `git diff main -- crates/ec-av1/src/refusal_inventory.rs` shows only THIS lane's deletion
12+ ("a split transform on a 1:4 inter strip with a 64-px axis"); every refusal main deleted
13+ (lane-oddh's 128x128 line, lane-intrarect's) stays deleted.
14+- `grep -rn '<<<<<<<|>>>>>>>' crates/` → nothing. No hand-resolved function, so no rebound-name
15+ re-read was needed (class merge-resolution-shadows-a-name did not apply this round).
16+
17+## 2. The firing assert is back on — and it is a hard assert
18+
19+Gate renamed
20+`a_real_aomenc_inter_1to4_recipe_decodes_pixel_exact_or_refuses_by_name` →
21+**`real_aomenc_1to4_streams_decode_pixel_exact_and_rect_vartx_leaves_fire_before_a_named_refusal`**
22+(`crates/ec-av1/src/stream.rs:6752`), which is what it now asserts.
23+
24+r4 recipe hunt on the merged tree, ~70 real aomenc runs (`testsrc2`, `life`, `mandelbrot`,
25+banded-motion lavfi with per-band and per-column speeds, 64x64 / 128x64 / 64x128 / 256x64 /
26+384x64 / 64x384 / 192x128 / 384x256, cq 20..58, `--min-partition-size` 16 and 32, 8- and
27+10-bit) found the recipe r3 could not: **384x256, per-16-column band motion**, at
28+`cq=38` and `cq=32`.
29+
30+EVIDENCE: `$HOME/.cache/r14-r4-gate.log` (gate run, quoted below) | `cargo test -p ec-av1 --lib -- --test-threads=1 --nocapture real_aomenc_1to4_streams` on `0b49322` | 8-bit: `attempt 17 refusal (rect var-tx leaves decoded before it: 32x16=4, 16x32=0)`, `attempt 16 ... (32x16=0, 16x32=1)`, summary `2 named refusals, leaves decoded anywhere in the sweep 32x16=4 16x32=1, 16 attempts carried none (0 of them mismatched)` — **test result: ok, 1 passed**
31+
32+What the gate asserts now:
33+- `oos_mismatch == 0` — every attempt that decodes to the end is compared to ffmpeg on Y/U/V,
34+ 8- AND 10-bit, and a mismatch is a failure, never a SKIP (16/16 banded attempts per depth
35+ decode fully and match; the recipe's `--min-partition-size` moved 32 → 16, so those 16
36+ attempts now also exercise the 16-level path).
37+- `compared + out_of_scope > 0` — the gate is not vacuous.
38+- **8-bit: `fired_32x16 > 0 && fired_16x32 > 0`** — both orientations of
39+ `sub_tx_size_map[TX_64X16] == TX_32X16` / `[TX_16X64] == TX_16X32` decoded out of a real
40+ aomenc stream. These two streams stop LATER on another lane's refusal
41+ (`a non-skip rectangular (HORZ/VERT/HORZ_B) strip needs rectangular residual coding` at cq 32,
42+ `an inter 16x16-level AB or 1:4 partition` at cq 38 — decode.rs:21305, genuinely unimplemented
43+ on the inter path), so the leaves are proved **decoded**, not proved pixel-exact. The counters
44+ are per-attempt deltas kept in a separate pair of variables from the pixel-compared ones
45+ (class counter-from-refused-stream), and the distinction is printed and commented.
46+- 10-bit: the same sweep fires ZERO leaves (measured: cq 32/35/38 pick other shapes), so the
47+ firing assert is 8-bit-only, with the measurement written at the assert.
48+
49+## 3. Suite
50+
51+`systemd-run --user --unit=r14-suite-r4-1788325638 -p MemoryMax=10G ... cargo test -p ec-av1 --lib -j3`
52+→ `$HOME/.cache/r14-suite-r4.log`. **Suite result (r4 tip `0b49322`): 372 passed; 0 failed; 32 ignored, 1487.04s** — GREEN.
53+(r3 tip was 367/0/31; +5 passed and +1 ignored come from main's three merged lanes.)
54+
55+## 4. Film probes on the merged tree — and a regression that is main's, not this lane's
56+
57+EVIDENCE: `/tmp/.../scratchpad/r14/seg{300,3000,4500}.obu` (2 s HG 2160p10 extracts, reused from r3) | `decode_probe` under `systemd-run --user --scope -p MemoryMax=6G`, `EC_AV1_FINAL_DUMP` file count = frames completed | merged tree `0b49322`:
58+
59+| segment | stop string | frames completed |
60+|---|---|---|
61+| `-ss 300` | `a split intra strip whose transform unit is 32x64 (no luma coefficient tables for that shape here)` | 1 |
62+| `-ss 3000` | same | 1 |
63+| `-ss 4500` | `an intra-coded 1:4 (or other non-2:1) rect strip on the inter block path` | 1 |
64+
65+That is **shallower than the r3 tip**, where `seg4500` decoded 14 rectangular var-tx leaves and
66+16 `16x64` strips before stopping. Attribution measured, not guessed:
67+
68+EVIDENCE: same three segments | `decode_probe` built from a detached worktree at **main 18bf7dc** (`CARGO_TARGET_DIR=$HOME/.cache/cargo-target-r14-main`, worktree + target dir removed after) | main alone gives the IDENTICAL stop strings and `frames=1` on all three
69+
70+So the films now stop in decode-order frame 2 on lane-intrarect's two NARROWER successor
71+refusals; the merge with lane-r14 changes nothing about it. **flagged, not mine**: main
72+18bf7dc is a film-depth regression against this lane's r3 tip — a broad refusal was replaced
73+by narrower ones that fire EARLIER in the stream (or our decode desyncs into them; class
74+refusal-from-own-desync is untested here). Owner: lane-intrarect / a fresh lane.
75+
76+## Residue
77+
78+- deferred(needs the 16x16-level inter 1:4 lane, or the non-skip HORZ_B rect residual lane) —
79+ a PIXEL-EXACT aomenc stream carrying a rectangular var-tx leaf. Both firing streams are one
80+ refusal short of running to the end; the assert to strengthen is the `if bit_depth == 8` block.
81+- deferred(needs an aomenc recipe that fires the arm at 10 bits) — the 10-bit firing assert.
82+ Measured absent over the 18-attempt sweep at cq 32/35/38.
83+- flagged, not mine — the film-depth regression above.
84+- accepted — `--enable-ab-partitions=0` streams still reach `an inter SB-level AB partition`
85+ and `--min-partition-size=16` streams reach `an inter partition below 8x8` (both re-observed
86+ this round, r3 flagged them first): a refusal naming a disabled tool is usually our own
87+ desync, and deserves its own lane.