forge
Explore
Log in

Don't you dare go Hollow

Merge branch 'lane-r14' (b86eb38): general sub_tx_size_map and (row,col,tw,th) var-tx leaves, plus rectangular inter leaf coding

Browse files at this commit

fcf808ddab478a8156aaf5bd2daf36ebc47f1b72Ahmet Kaan GümüşParent: a8d25d45677085
Var-tx split now recurses with a general sub_tx_size_map and codes leaves by
(row, col, tx_w, tx_h) instead of a square-only shape, so a split transform on
a 1:4 inter strip with a 64-px axis decodes instead of refusing. Refusal
dropped from refusal_inventory.rs; gate_coverage drops enable-tx64 from the
never-exercised set.

Gate: real_aomenc_1to4_streams_decode_pixel_exact_and_rect_vartx_leaves_fire_before_a_named_refusal
Suite: 382 passed / 0 failed / 33 ignored.
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/src/decode.rsmodified+182 -54
@@ -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(
@@ -11451,6 +11468,46 @@ const TXFM_CTX_INIT: u8 = 64;
11451 /// twice below its own largest transform.11468 /// twice below its own largest transform.
11452 const MAX_VARTX_DEPTH: usize = 2;11469 const MAX_VARTX_DEPTH: usize = 2;
11453 11470
11471+/// libaom `sub_tx_size_map[TX_SIZES_ALL]` (`common_data.c`): the transform
11472+/// one `txfm_split` step below `tx_size`. RECTANGULAR for the 1:4 shapes
11473+/// (`[TX_64X16] == TX_32X16`, `[TX_16X64] == TX_16X32`) and for the 4:1
11474+/// small ones, square everywhere else.
11475+fn sub_tx_size_map(tx_w: usize, tx_h: usize) -> (usize, usize) {
11476+ match (tx_w, tx_h) {
11477+ (4, 4) => (4, 4),
11478+ (8, 8) => (4, 4),
11479+ (16, 16) => (8, 8),
11480+ (32, 32) => (16, 16),
11481+ (64, 64) => (32, 32),
11482+ (4, 8) | (8, 4) => (4, 4),
11483+ (8, 16) | (16, 8) => (8, 8),
11484+ (16, 32) | (32, 16) => (16, 16),
11485+ (32, 64) | (64, 32) => (32, 32),
11486+ (4, 16) => (4, 8),
11487+ (16, 4) => (8, 4),
11488+ (8, 32) => (8, 16),
11489+ (32, 8) => (16, 8),
11490+ (16, 64) => (16, 32),
11491+ (64, 16) => (32, 16),
11492+ _ => unreachable!("not a TX_SIZES_ALL shape: {tx_w}x{tx_h}"),
11493+ }
11494+}
11495+
11496+#[test]
11497+fn sub_tx_size_map_matches_libaom() {
11498+ // libaom `common_data.c` `sub_tx_size_map`, in TX_SIZES_ALL order.
11499+ const TABLE: [((usize, usize), (usize, usize)); 19] = [
11500+ ((4, 4), (4, 4)), ((8, 8), (4, 4)), ((16, 16), (8, 8)), ((32, 32), (16, 16)),
11501+ ((64, 64), (32, 32)), ((4, 8), (4, 4)), ((8, 4), (4, 4)), ((8, 16), (8, 8)),
11502+ ((16, 8), (8, 8)), ((16, 32), (16, 16)), ((32, 16), (16, 16)), ((32, 64), (32, 32)),
11503+ ((64, 32), (32, 32)), ((4, 16), (4, 8)), ((16, 4), (8, 4)), ((8, 32), (8, 16)),
11504+ ((32, 8), (16, 8)), ((16, 64), (16, 32)), ((64, 16), (32, 16)),
11505+ ];
11506+ for (tx, want) in TABLE {
11507+ assert_eq!(sub_tx_size_map(tx.0, tx.1), want, "sub_tx_size_map({tx:?})");
11508+ }
11509+}
11510+
11454 /// `read_var_tx_size` (spec 5.11.17, libaom `decodeframe.c`11511 /// `read_var_tx_size` (spec 5.11.17, libaom `decodeframe.c`
11455 /// `read_tx_size_vartx`): the recursive `txfm_split` tree of one11512 /// `read_tx_size_vartx`): the recursive `txfm_split` tree of one
11456 /// max-transform-sized unit of an inter block, collecting the resolved leaf11513 /// max-transform-sized unit of an inter block, collecting the resolved leaf
@@ -11467,22 +11524,28 @@ fn read_var_tx_size(
11467 at_mi: (usize, usize),11524 at_mi: (usize, usize),
11468 blk_max_px: usize,11525 blk_max_px: usize,
11469 (max_w_mi, max_h_mi): (usize, usize),11526 (max_w_mi, max_h_mi): (usize, usize),
11470- tx_px: usize,11527+ (tx_w, tx_h): (usize, usize),
11471 depth: usize,11528 depth: usize,
11472 blk_row: usize,11529 blk_row: usize,
11473 blk_col: usize,11530 blk_col: usize,
11474- out: &mut Vec<(usize, usize, usize)>,11531+ out: &mut Vec<(usize, usize, usize, usize)>,
11475 ) {11532 ) {
11476 if blk_row >= max_h_mi || blk_col >= max_w_mi {11533 if blk_row >= max_h_mi || blk_col >= max_w_mi {
11477 return;11534 return;
11478 }11535 }
11479 let unit = (at_mi.0 + blk_row, at_mi.1 + blk_col);11536 let unit = (at_mi.0 + blk_row, at_mi.1 + blk_col);
11480 if depth == MAX_VARTX_DEPTH {11537 if depth == MAX_VARTX_DEPTH {
11481- out.push((blk_row, blk_col, tx_px));11538+ out.push((blk_row, blk_col, tx_w, tx_h));
11482- txfm_partition_update(n, unit, tx_px, tx_px);11539+ txfm_partition_update_rect(n, unit, (tx_w, tx_h), (tx_w, tx_h));
11483 return;11540 return;
11484 }11541 }
11485- let ctx = txfm_partition_ctx(n.above_txfm[unit.1], n.left_txfm[unit.0], blk_max_px, tx_px);11542+ let ctx = txfm_partition_ctx_rect(
11543+ n.above_txfm[unit.1],
11544+ n.left_txfm[unit.0],
11545+ blk_max_px,
11546+ tx_w,
11547+ tx_h,
11548+ );
11486 let split = dec.symbol(&mut cdfs.txfm_partition[ctx]) == 1;11549 let split = dec.symbol(&mut cdfs.txfm_partition[ctx]) == 1;
11487 TXFM_SPLIT_READS.with(|c| c.set(c.get() + 1));11550 TXFM_SPLIT_READS.with(|c| c.set(c.get() + 1));
11488 if std::env::var_os("EC_TRACE_MODE_STEP").is_some() {11551 if std::env::var_os("EC_TRACE_MODE_STEP").is_some() {
@@ -11495,27 +11558,27 @@ fn read_var_tx_size(
11495 );11558 );
11496 }11559 }
11497 if !split {11560 if !split {
11498- out.push((blk_row, blk_col, tx_px));11561+ out.push((blk_row, blk_col, tx_w, tx_h));
11499- txfm_partition_update(n, unit, tx_px, tx_px);11562+ txfm_partition_update_rect(n, unit, (tx_w, tx_h), (tx_w, tx_h));
11500 return;11563 return;
11501 }11564 }
11502 TXFM_SPLIT_HITS.with(|c| c.set(c.get() + 1));11565 TXFM_SPLIT_HITS.with(|c| c.set(c.get() + 1));
11503- let sub = tx_px / 2;11566+ let (sub_w, sub_h) = sub_tx_size_map(tx_w, tx_h);
11504- if sub == 4 {11567+ if (sub_w, sub_h) == (4, 4) {
11505- // libaom's `sub_txs == TX_4X4` early return: the whole 8x8 unit is11568+ // libaom's `sub_txs == TX_4X4` early return: every mi cell of the
11506- // marked 4x4 (four transform units, raster order) without recursing.11569+ // unit is marked 4x4 (raster order) without recursing.
11507- for row in 0..2 {11570+ for row in 0..tx_h / MI {
11508- for col in 0..2 {11571+ for col in 0..tx_w / MI {
11509 if blk_row + row < max_h_mi && blk_col + col < max_w_mi {11572 if blk_row + row < max_h_mi && blk_col + col < max_w_mi {
11510- out.push((blk_row + row, blk_col + col, 4));11573+ out.push((blk_row + row, blk_col + col, 4, 4));
11511 }11574 }
11512 }11575 }
11513 }11576 }
11514- txfm_partition_update(n, unit, 4, tx_px);11577+ txfm_partition_update_rect(n, unit, (4, 4), (tx_w, tx_h));
11515 return;11578 return;
11516 }11579 }
11517- for row in (0..tx_px / MI).step_by(sub / MI) {11580+ for row in (0..tx_h / MI).step_by(sub_h / MI) {
11518- for col in (0..tx_px / MI).step_by(sub / MI) {11581+ for col in (0..tx_w / MI).step_by(sub_w / MI) {
11519 read_var_tx_size(11582 read_var_tx_size(
11520 dec,11583 dec,
11521 cdfs,11584 cdfs,
@@ -11523,7 +11586,7 @@ fn read_var_tx_size(
11523 at_mi,11586 at_mi,
11524 blk_max_px,11587 blk_max_px,
11525 (max_w_mi, max_h_mi),11588 (max_w_mi, max_h_mi),
11526- sub,11589+ (sub_w, sub_h),
11527 depth + 1,11590 depth + 1,
11528 blk_row + row,11591 blk_row + row,
11529 blk_col + col,11592 blk_col + col,
@@ -11551,7 +11614,7 @@ fn read_block_tx_size(
11551 (mi_cols, mi_rows): (usize, usize),11614 (mi_cols, mi_rows): (usize, usize),
11552 is_inter: bool,11615 is_inter: bool,
11553 skip: bool,11616 skip: bool,
11554-) -> Result<(usize, Option<Vec<(usize, usize, usize)>>)> {11617+) -> Result<(usize, Option<Vec<(usize, usize, usize, usize)>>)> {
11555 if !TX_SELECT_INTER.with(std::cell::Cell::get) {11618 if !TX_SELECT_INTER.with(std::cell::Cell::get) {
11556 return Ok((side, None));11619 return Ok((side, None));
11557 }11620 }
@@ -11571,7 +11634,7 @@ fn read_block_tx_size(
11571 at_mi,11634 at_mi,
11572 side,11635 side,
11573 (max_w_mi, max_h_mi),11636 (max_w_mi, max_h_mi),
11574- max_tx,11637+ (max_tx, max_tx),
11575 0,11638 0,
11576 row,11639 row,
11577 col,11640 col,
@@ -11579,8 +11642,8 @@ fn read_block_tx_size(
11579 );11642 );
11580 }11643 }
11581 }11644 }
11582- let single = leaves.len() == 1 && leaves[0].2 == side;11645+ let single = leaves.len() == 1 && leaves[0].2 == side && leaves[0].3 == side;
11583- if !single && leaves.iter().any(|leaf| leaf.2 > 32) {11646+ if !single && leaves.iter().any(|leaf| leaf.2.max(leaf.3) > 32) {
11584 // Only a block wider than a superblock's own 64x64 max transform11647 // Only a block wider than a superblock's own 64x64 max transform
11585 // reaches here; this crate has no 64-point *inter* coefficient11648 // reaches here; this crate has no 64-point *inter* coefficient
11586 // table set ([`inter_txbset_for`] stops at 32).11649 // table set ([`inter_txbset_for`] stops at 32).
@@ -11618,7 +11681,7 @@ fn read_block_tx_size(
11618 let mut leaves = Vec::new();11681 let mut leaves = Vec::new();
11619 for row in (0..side_mi).step_by(step) {11682 for row in (0..side_mi).step_by(step) {
11620 for col in (0..side_mi).step_by(step) {11683 for col in (0..side_mi).step_by(step) {
11621- leaves.push((row, col, tx));11684+ leaves.push((row, col, tx, tx));
11622 }11685 }
11623 }11686 }
11624 INTRA_IN_INTER_SPLIT_TX_HITS.with(|c| {11687 INTRA_IN_INTER_SPLIT_TX_HITS.with(|c| {
@@ -11770,7 +11833,7 @@ fn read_block_tx_size_rect(
11770 (bw, bh): (usize, usize),11833 (bw, bh): (usize, usize),
11771 (mi_cols, mi_rows): (usize, usize),11834 (mi_cols, mi_rows): (usize, usize),
11772 skip: bool,11835 skip: bool,
11773-) -> Result<Option<Vec<(usize, usize, usize)>>> {11836+) -> Result<Option<Vec<(usize, usize, usize, usize)>>> {
11774 if skip {11837 if skip {
11775 // `set_txfm_ctxs(.., skip && is_inter)`: a skipped inter block records11838 // `set_txfm_ctxs(.., skip && is_inter)`: a skipped inter block records
11776 // its own BLOCK size -- width above, height left -- not a transform.11839 // its own BLOCK size -- width above, height left -- not a transform.
@@ -11813,22 +11876,16 @@ fn read_block_tx_size_rect(
11813 }11876 }
11814 TXFM_SPLIT_HITS.with(|c| c.set(c.get() + 1));11877 TXFM_SPLIT_HITS.with(|c| c.set(c.get() + 1));
11815 RECT_INTER_TXSPLIT_HITS.with(|c| c.set(c.get() + 1));11878 RECT_INTER_TXSPLIT_HITS.with(|c| c.set(c.get() + 1));
11816- // lane-r14 r2: `sub_tx_size_map` is square for every shape this decoder11879+ // lane-r14 r3: `sub_tx_size_map` (libaom `common_data.c`) stays
11817- // splits (TX_32X16 -> TX_16X16, TX_64X32 -> TX_32X32) EXCEPT the 1:411880+ // RECTANGULAR under a 1:4 strip -- `[TX_64X16] == TX_32X16`,
11818- // strips with a 64-px axis, where it stays rectangular11881+ // `[TX_16X64] == TX_16X32` -- so the recursion below is the general
11819- // (TX_64X16 -> TX_32X16, TX_16X64 -> TX_16X32) and the square recursion11882+ // rect one and its leaves carry their own width and height.
11820- // below would code the wrong tree.11883+ let (sub_w, sub_h) = sub_tx_size_map(tx_w, tx_h);
11821- if tx_w.max(tx_h) == 64 && tx_w.min(tx_h) == 16 {
11822- return Err(unsupported(
11823- "a split transform on a 1:4 inter strip with a 64-px axis",
11824- ));
11825- }
11826- let sub = tx_w.min(tx_h);
11827 let max_w_mi = (bw / MI).min(mi_cols.saturating_sub(at_mi.1));11884 let max_w_mi = (bw / MI).min(mi_cols.saturating_sub(at_mi.1));
11828 let max_h_mi = (bh / MI).min(mi_rows.saturating_sub(at_mi.0));11885 let max_h_mi = (bh / MI).min(mi_rows.saturating_sub(at_mi.0));
11829 let mut leaves = Vec::new();11886 let mut leaves = Vec::new();
11830- for row in (0..bh / MI).step_by(sub / MI) {11887+ for row in (0..bh / MI).step_by(sub_h / MI) {
11831- for col in (0..bw / MI).step_by(sub / MI) {11888+ for col in (0..bw / MI).step_by(sub_w / MI) {
11832 read_var_tx_size(11889 read_var_tx_size(
11833 dec,11890 dec,
11834 cdfs,11891 cdfs,
@@ -11836,7 +11893,7 @@ fn read_block_tx_size_rect(
11836 at_mi,11893 at_mi,
11837 bw.max(bh),11894 bw.max(bh),
11838 (max_w_mi, max_h_mi),11895 (max_w_mi, max_h_mi),
11839- sub,11896+ (sub_w, sub_h),
11840 1,11897 1,
11841 row,11898 row,
11842 col,11899 col,
@@ -11873,9 +11930,12 @@ fn read_inter_plane_rect(
11873 y: usize,11930 y: usize,
11874 prediction: &[u16],11931 prediction: &[u16],
11875 inherited_luma_tx_type: Option<TxType>,11932 inherited_luma_tx_type: Option<TxType>,
11933+ luma_skip_ctx: Option<usize>,
11876 ) -> Result<(Vec<i32>, TxType)> {11934 ) -> Result<(Vec<i32>, TxType)> {
11877 let skip_ctx = if plane_idx == 0 {11935 let skip_ctx = if plane_idx == 0 {
11878- 011936+ // `get_txb_ctx_general`: 0 only when this unit IS the whole plane
11937+ // block; a var-tx leaf passes its own neighbour-table context.
11938+ luma_skip_ctx.unwrap_or(0)
11879 } else {11939 } else {
11880 usize::from(around.0) + usize::from(around.1)11940 usize::from(around.0) + usize::from(around.1)
11881 };11941 };
@@ -16492,7 +16552,7 @@ fn decode_inter_block(
16492 // 5.11.17), `Some` only when this block's var-tx tree resolved to more16552 // 5.11.17), `Some` only when this block's var-tx tree resolved to more
16493 // than one luma transform -- read back by the residual loop, the16553 // than one luma transform -- read back by the residual loop, the
16494 // coefficient-context write-back and the loop-filter grid fill below.16554 // coefficient-context write-back and the loop-filter grid fill below.
16495- let mut vartx_leaves: Option<Vec<(usize, usize, usize)>> = None;16555+ let mut vartx_leaves: Option<Vec<(usize, usize, usize, usize)>> = None;
16496 let at_mi = at;16556 let at_mi = at;
16497 if is_inter {16557 if is_inter {
16498 let above_nbr = has_above.then(|| NeighbourRef {16558 let above_nbr = has_above.then(|| NeighbourRef {
@@ -17347,9 +17407,11 @@ fn decode_inter_block(
17347 // own slice of the block's motion-compensated predictor.17407 // own slice of the block's motion-compensated predictor.
17348 let reduced = REDUCED_TX_SET_INTER.with(std::cell::Cell::get);17408 let reduced = REDUCED_TX_SET_INTER.with(std::cell::Cell::get);
17349 let mut first_tx_type = TxType::DctDct;17409 let mut first_tx_type = TxType::DctDct;
17350- for (idx, &(row, col, tx_px)) in leaves.iter().enumerate() {17410+ for (idx, &(row, col, tw, th)) in leaves.iter().enumerate() {
17351 let tu_mi = (at_mi.0 + row, at_mi.1 + col);17411 let tu_mi = (at_mi.0 + row, at_mi.1 + col);
17352 let (tu_px, tu_py) = (px + col * MI, py + row * MI);17412 let (tu_px, tu_py) = (px + col * MI, py + row * MI);
17413+ let (tu_grid, tu_tx_type) = if tw == th {
17414+ let tx_px = tw;
17353 let mut tu_pred = Vec::with_capacity(tx_px * tx_px);17415 let mut tu_pred = Vec::with_capacity(tx_px * tx_px);
17354 for rr in 0..tx_px {17416 for rr in 0..tx_px {
17355 let start = (row * MI + rr) * side + col * MI;17417 let start = (row * MI + rr) * side + col * MI;
@@ -17357,7 +17419,7 @@ fn decode_inter_block(
17357 }17419 }
17358 let scan = default_scan(tx_px);17420 let scan = default_scan(tx_px);
17359 let tu_skip_ctx = neighbours.luma_skip_ctx(tu_mi, tx_px / MI);17421 let tu_skip_ctx = neighbours.luma_skip_ctx(tu_mi, tx_px / MI);
17360- let (tu_grid, tu_tx_type) = read_inter_plane(17422+ read_inter_plane(
17361 dec,17423 dec,
17362 cdfs,17424 cdfs,
17363 inter_txbset_for(tx_px, reduced),17425 inter_txbset_for(tx_px, reduced),
@@ -17373,11 +17435,40 @@ fn decode_inter_block(
17373 &tu_pred,17435 &tu_pred,
17374 None,17436 None,
17375 Some(tu_skip_ctx),17437 Some(tu_skip_ctx),
17376- )?;17438+ )?
17439+ } else {
17440+ // lane-r14 r3: a 1:4 strip's `sub_tx_size_map`
17441+ // sub-transform is RECTANGULAR (TX_64X16 ->
17442+ // TX_32X16, TX_16X64 -> TX_16X32), so this leaf is
17443+ // read with the rect coefficient machinery, at its
17444+ // own `txb_skip_ctx`/neighbour spans -- the unit is
17445+ // smaller than its block, so `get_txb_ctx_general`'s
17446+ // neighbour table applies, not the lone-TU 0.
17447+ vartx_rect_leaf_hit(tw, th);
17448+ let tu_skip_ctx =
17449+ neighbours.luma_skip_ctx_rect(tu_mi, tw / MI, th / MI);
17450+ let start = row * MI * side + col * MI;
17451+ read_inter_plane_rect(
17452+ dec,
17453+ cdfs,
17454+ rect_inter_luma_set(tw, th),
17455+ (tw, th),
17456+ side,
17457+ 0,
17458+ neighbours.around_mi_rect(tu_mi, tw, th)[0],
17459+ mode_for_tx,
17460+ y,
17461+ tu_px,
17462+ tu_py,
17463+ &pred_y[start..],
17464+ None,
17465+ Some(tu_skip_ctx),
17466+ )?
17467+ };
17377 if idx == 0 {17468 if idx == 0 {
17378 first_tx_type = tu_tx_type;17469 first_tx_type = tu_tx_type;
17379 }17470 }
17380- neighbours.record_mi_luma(tu_mi, tx_px, &tu_grid);17471+ neighbours.record_mi_luma_rect(tu_mi, tw, th, &tu_grid);
17381 }17472 }
17382 // `av1_get_tx_type`'s chroma lookup scales the chroma17473 // `av1_get_tx_type`'s chroma lookup scales the chroma
17383 // position back to luma, so an inter block's chroma17474 // position back to luma, so an inter block's chroma
@@ -17401,6 +17492,7 @@ fn decode_inter_block(
17401 py,17492 py,
17402 &pred_y,17493 &pred_y,
17403 None,17494 None,
17495+ None,
17404 )?;17496 )?;
17405 luma_tx_type = tx_type;17497 luma_tx_type = tx_type;
17406 luma_grid = embed_rect_grid(&grid, write_w, write_h, side);17498 luma_grid = embed_rect_grid(&grid, write_w, write_h, side);
@@ -17444,6 +17536,7 @@ fn decode_inter_block(
17444 cpy,17536 cpy,
17445 &pred_u,17537 &pred_u,
17446 Some(luma_tx_type),17538 Some(luma_tx_type),
17539+ None,
17447 )?17540 )?
17448 .0,17541 .0,
17449 uw,17542 uw,
@@ -17465,6 +17558,7 @@ fn decode_inter_block(
17465 cpy,17558 cpy,
17466 &pred_v,17559 &pred_v,
17467 Some(luma_tx_type),17560 Some(luma_tx_type),
17561+ None,
17468 )?17562 )?
17469 .0,17563 .0,
17470 uw,17564 uw,
@@ -18325,9 +18419,11 @@ fn decode_inter_block(
18325 // own slice of the block's motion-compensated predictor.18419 // own slice of the block's motion-compensated predictor.
18326 let reduced = REDUCED_TX_SET_INTER.with(std::cell::Cell::get);18420 let reduced = REDUCED_TX_SET_INTER.with(std::cell::Cell::get);
18327 let mut first_tx_type = TxType::DctDct;18421 let mut first_tx_type = TxType::DctDct;
18328- for (idx, &(row, col, tx_px)) in leaves.iter().enumerate() {18422+ for (idx, &(row, col, tw, th)) in leaves.iter().enumerate() {
18329 let tu_mi = (at_mi.0 + row, at_mi.1 + col);18423 let tu_mi = (at_mi.0 + row, at_mi.1 + col);
18330 let (tu_px, tu_py) = (px + col * MI, py + row * MI);18424 let (tu_px, tu_py) = (px + col * MI, py + row * MI);
18425+ let (tu_grid, tu_tx_type) = if tw == th {
18426+ let tx_px = tw;
18331 let mut tu_pred = Vec::with_capacity(tx_px * tx_px);18427 let mut tu_pred = Vec::with_capacity(tx_px * tx_px);
18332 for rr in 0..tx_px {18428 for rr in 0..tx_px {
18333 let start = (row * MI + rr) * side + col * MI;18429 let start = (row * MI + rr) * side + col * MI;
@@ -18335,7 +18431,7 @@ fn decode_inter_block(
18335 }18431 }
18336 let scan = default_scan(tx_px);18432 let scan = default_scan(tx_px);
18337 let tu_skip_ctx = neighbours.luma_skip_ctx(tu_mi, tx_px / MI);18433 let tu_skip_ctx = neighbours.luma_skip_ctx(tu_mi, tx_px / MI);
18338- let (tu_grid, tu_tx_type) = read_inter_plane(18434+ read_inter_plane(
18339 dec,18435 dec,
18340 cdfs,18436 cdfs,
18341 inter_txbset_for(tx_px, reduced),18437 inter_txbset_for(tx_px, reduced),
@@ -18351,11 +18447,40 @@ fn decode_inter_block(
18351 &tu_pred,18447 &tu_pred,
18352 None,18448 None,
18353 Some(tu_skip_ctx),18449 Some(tu_skip_ctx),
18354- )?;18450+ )?
18451+ } else {
18452+ // lane-r14 r3: a 1:4 strip's `sub_tx_size_map`
18453+ // sub-transform is RECTANGULAR (TX_64X16 ->
18454+ // TX_32X16, TX_16X64 -> TX_16X32), so this leaf is
18455+ // read with the rect coefficient machinery, at its
18456+ // own `txb_skip_ctx`/neighbour spans -- the unit is
18457+ // smaller than its block, so `get_txb_ctx_general`'s
18458+ // neighbour table applies, not the lone-TU 0.
18459+ vartx_rect_leaf_hit(tw, th);
18460+ let tu_skip_ctx =
18461+ neighbours.luma_skip_ctx_rect(tu_mi, tw / MI, th / MI);
18462+ let start = row * MI * side + col * MI;
18463+ read_inter_plane_rect(
18464+ dec,
18465+ cdfs,
18466+ rect_inter_luma_set(tw, th),
18467+ (tw, th),
18468+ side,
18469+ 0,
18470+ neighbours.around_mi_rect(tu_mi, tw, th)[0],
18471+ mode_for_tx,
18472+ y,
18473+ tu_px,
18474+ tu_py,
18475+ &pred_y[start..],
18476+ None,
18477+ Some(tu_skip_ctx),
18478+ )?
18479+ };
18355 if idx == 0 {18480 if idx == 0 {
18356 first_tx_type = tu_tx_type;18481 first_tx_type = tu_tx_type;
18357 }18482 }
18358- neighbours.record_mi_luma(tu_mi, tx_px, &tu_grid);18483+ neighbours.record_mi_luma_rect(tu_mi, tw, th, &tu_grid);
18359 }18484 }
18360 // `av1_get_tx_type`'s chroma lookup scales the chroma18485 // `av1_get_tx_type`'s chroma lookup scales the chroma
18361 // position back to luma, so an inter block's chroma18486 // position back to luma, so an inter block's chroma
@@ -18379,6 +18504,7 @@ fn decode_inter_block(
18379 py,18504 py,
18380 &pred_y,18505 &pred_y,
18381 None,18506 None,
18507+ None,
18382 )?;18508 )?;
18383 luma_tx_type = tx_type;18509 luma_tx_type = tx_type;
18384 luma_grid = embed_rect_grid(&grid, write_w, write_h, side);18510 luma_grid = embed_rect_grid(&grid, write_w, write_h, side);
@@ -18422,6 +18548,7 @@ fn decode_inter_block(
18422 cpy,18548 cpy,
18423 &pred_u,18549 &pred_u,
18424 Some(luma_tx_type),18550 Some(luma_tx_type),
18551+ None,
18425 )?18552 )?
18426 .0,18553 .0,
18427 uw,18554 uw,
@@ -18443,6 +18570,7 @@ fn decode_inter_block(
18443 cpy,18570 cpy,
18444 &pred_v,18571 &pred_v,
18445 Some(luma_tx_type),18572 Some(luma_tx_type),
18573+ None,
18446 )?18574 )?
18447 .0,18575 .0,
18448 uw,18576 uw,
@@ -18706,7 +18834,7 @@ fn decode_inter_block(
18706 let split_luma = vartx_leaves.is_some();18834 let split_luma = vartx_leaves.is_some();
18707 if let Some(leaves) = vartx_leaves.clone() {18835 if let Some(leaves) = vartx_leaves.clone() {
18708 let reduced = REDUCED_TX_SET_INTER.with(std::cell::Cell::get);18836 let reduced = REDUCED_TX_SET_INTER.with(std::cell::Cell::get);
18709- for &(row, col, tx_px) in &leaves {18837+ for &(row, col, tx_px, _) in &leaves {
18710 let tu_mi = (at_mi.0 + row, at_mi.1 + col);18838 let tu_mi = (at_mi.0 + row, at_mi.1 + col);
18711 let (tu_px, tu_py) = (px + col * MI, py + row * MI);18839 let (tu_px, tu_py) = (px + col * MI, py + row * MI);
18712 // A transform unit inside a block is not a block at that18840 // A transform unit inside a block is not a block at that
@@ -18948,13 +19076,13 @@ fn decode_inter_block(
18948 // units, not the block. Chroma still reads `tx_h_grid / 2` (the block's19076 // units, not the block. Chroma still reads `tx_h_grid / 2` (the block's
18949 // uv transform is not split) -- a known corner-cut of this round.19077 // uv transform is not split) -- a known corner-cut of this round.
18950 if let Some(leaves) = &vartx_leaves {19078 if let Some(leaves) = &vartx_leaves {
18951- for &(row, col, tx_px) in leaves {19079+ for &(row, col, tw, th) in leaves {
18952 neighbours.fill_lf_grid_rect(19080 neighbours.fill_lf_grid_rect(
18953 (at_mi.0 + row, at_mi.1 + col),19081 (at_mi.0 + row, at_mi.1 + col),
18954- tx_px / MI,19082+ tw / MI,
18955- tx_px / MI,19083+ th / MI,
18956- tx_px as u8,19084+ tw as u8,
18957- tx_px as u8,19085+ th as u8,
18958 if globalmv_for_lf {19086 if globalmv_for_lf {
18959 -ref_frame_for_lf19087 -ref_frame_for_lf
18960 } else {19088 } 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
@@ -82,10 +82,6 @@ const REFUSALS: &[&str] = &[
82 "warp prediction with a scaled reference (superres, unimplemented)",82 "warp prediction with a scaled reference (superres, unimplemented)",
83 "an 8x8 partition leaf under a scaled reference (superres, unimplemented)",83 "an 8x8 partition leaf under a scaled reference (superres, unimplemented)",
84 "a motion_mode symbol for a block shape with no CDF row here",84 "a motion_mode symbol for a block shape with no CDF row here",
85- // lane-r14 r2: the whole-transform case of every 64-axis inter strip is
86- // coded; only the SPLIT of a 1:4 strip with a 64-px axis is left, whose
87- // `sub_tx_size_map` entry is rectangular (TX_64X16 -> TX_32X16).
88- "a split transform on a 1:4 inter strip with a 64-px axis",
89 ];85 ];
90 86
91 /// Gates whose `Err` arm turns a decode failure into a printed SKIP rather than87 /// Gates whose `Err` arm turns a decode failure into a printed SKIP rather than
crates/ec-av1/src/stream.rsmodified+241 -0
@@ -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(),
@@ -6823,6 +6830,240 @@ mod tests {
6823 }6830 }
6824 }6831 }
6825 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+
6826 /// lane-inter4 r2: the 32x32-level inter `PARTITION_HORZ`/`PARTITION_VERT`7067 /// lane-inter4 r2: the 32x32-level inter `PARTITION_HORZ`/`PARTITION_VERT`
6827 /// strips (32x16 / 16x32) carrying a REAL residual -- the capability r17068 /// strips (32x16 / 16x32) carrying a REAL residual -- the capability r1
6828 /// found missing ("a non-skip rectangular (HORZ/VERT/HORZ_B) strip needs7069 /// found missing ("a non-skip rectangular (HORZ/VERT/HORZ_B) strip needs
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.