forge
Explore
Log in

Don't you dare go Hollow

Inter-frame superblock-level HORZ/VERT/1:4 and 32x32-level 1:4 partition arms

Browse files at this commit

323608addfbe4a0f5ab115f0b51254a33c28c3a9Ahmet Kaan GümüşParent: b49a79b
  • feat
    • inter-frame superblock-level HORZ/VERT/1:4 and 32x32-level 1:4 partition arms
Show full message
feat(av1): inter-frame superblock-level HORZ/VERT/1:4 and 32x32-level 1:4 partition arms

decode_inter_block's `at` moves from 16-px cells to MI (4 px) units so a
32x32-level 1:4 strip can name its 8-px offset; motion_mode/obmc gain libaom's
BLOCK_32X64/64X32/8X32/32X8/16X64/64X16 rows and are selected by the block's
true footprint; interintra is no longer read on a 1:4 strip
(is_interintra_allowed_bsize is enum-ordered and excludes them); delta_q/lf's
is_whole_sb becomes bSize == sbSize.

Gated: the superblock-level inter PARTITION_HORZ arm, 8-bit, 4 x 64x32 strips
inside 2 pixel-exact attempts vs ffmpeg. NOT gated: the VERT/1:4 arms and the
whole 10-bit side -- every real stream finds those strips non-skip and stops at
"a non-skip rectangular (HORZ/VERT/HORZ_B) strip needs rectangular residual
coding". See lanes/inter4-r1.report.md.
crates/ec-av1/examples/decode_probe.rsmodified+5 -0
@@ -31,6 +31,11 @@ fn main() {
31 let report = || {31 let report = || {
32 let (h, v, c) = ec_av1::stream::rect4_32_counters();32 let (h, v, c) = ec_av1::stream::rect4_32_counters();
33 println!("rect4_32: horz={h} vert={v} coded={c}");33 println!("rect4_32: horz={h} vert={v} coded={c}");
34+ let ir = ec_av1::stream::inter_rect_counters();
35+ println!(
36+ "inter_rect: 32x8={} 8x32={} 64x32={} 32x64={} 64x16={} 16x64={}",
37+ ir.0, ir.1, ir.2, ir.3, ir.4, ir.5
38+ );
34 };39 };
35 match ec_av1::stream::decode_stream(&data) {40 match ec_av1::stream::decode_stream(&data) {
36 Ok(frames) if frames.is_empty() => {41 Ok(frames) if frames.is_empty() => {
crates/ec-av1/src/cdf.rsmodified+20 -2
@@ -1610,7 +1610,7 @@ pub const SKIP_MODE: [[u16; 3]; 3] = [[32621, 32768, 0], [20708, 32768, 0], [812
1610 /// `motion_mode_allowed` (spec 5.11.24's `read_motion_mode`) offers1610 /// `motion_mode_allowed` (spec 5.11.24's `read_motion_mode`) offers
1611 /// `OBMC_CAUSAL` rather than `WARPED_CAUSAL` -- lane-motionmode round 11611 /// `OBMC_CAUSAL` rather than `WARPED_CAUSAL` -- lane-motionmode round 1
1612 /// never reaches the three-way `motion_mode_cdf`, see `decode.rs`.1612 /// never reaches the three-way `motion_mode_cdf`, see `decode.rs`.
1613-pub const OBMC: [[u16; 3]; 6] = [1613+pub const OBMC: [[u16; 3]; 12] = [
1614 [10437, 32768, 0],1614 [10437, 32768, 0],
1615 [17432, 32768, 0],1615 [17432, 32768, 0],
1616 [25817, 32768, 0],1616 [25817, 32768, 0],
@@ -1620,6 +1620,16 @@ pub const OBMC: [[u16; 3]; 6] = [
1620 // (rect-flake-1: the strip's motion_mode read diverged on this).1620 // (rect-flake-1: the strip's motion_mode read diverged on this).
1621 [14423, 32768, 0],1621 [14423, 32768, 0],
1622 [15142, 32768, 0],1622 [15142, 32768, 0],
1623+ // lane-inter4 r1: the rect rows a superblock-level HORZ/VERT/1:4 and a
1624+ // 32x32-level 1:4 inter strip read -- BLOCK_32X64 (10), BLOCK_64X32 (11),
1625+ // BLOCK_8X32 (18), BLOCK_32X8 (19), BLOCK_16X64 (20), BLOCK_64X16 (21) of
1626+ // libaom's `default_obmc_cdf`.
1627+ [22823, 32768, 0],
1628+ [22083, 32768, 0],
1629+ [23664, 32768, 0],
1630+ [20901, 32768, 0],
1631+ [24008, 32768, 0],
1632+ [26879, 32768, 0],
1623 ];1633 ];
1624 1634
1625 /// `default_motion_mode_cdf` (spec 9.4, `entropymode.c`), the square-bsize1635 /// `default_motion_mode_cdf` (spec 9.4, `entropymode.c`), the square-bsize
@@ -1629,7 +1639,7 @@ pub const OBMC: [[u16; 3]; 6] = [
1629 /// `read_motion_mode` reads instead of [`OBMC`] whenever `motion_mode_allowed`1639 /// `read_motion_mode` reads instead of [`OBMC`] whenever `motion_mode_allowed`
1630 /// (spec 5.11.24) resolves to `WARPED_CAUSAL`-eligible (`num_proj_ref >= 1`1640 /// (spec 5.11.24) resolves to `WARPED_CAUSAL`-eligible (`num_proj_ref >= 1`
1631 /// under `allow_warped_motion`) -- lane-warp round 1.1641 /// under `allow_warped_motion`) -- lane-warp round 1.
1632-pub const MOTION_MODE: [[u16; 4]; 6] = [1642+pub const MOTION_MODE: [[u16; 4]; 12] = [
1633 [7651, 24760, 32768, 0],1643 [7651, 24760, 32768, 0],
1634 [19419, 26810, 32768, 0],1644 [19419, 26810, 32768, 0],
1635 [26260, 29116, 32768, 0],1645 [26260, 29116, 32768, 0],
@@ -1637,6 +1647,14 @@ pub const MOTION_MODE: [[u16; 4]; 6] = [
1637 // lane-rect r2: BLOCK_16X32 / BLOCK_32X16 rows (indices 7/8).1647 // lane-rect r2: BLOCK_16X32 / BLOCK_32X16 rows (indices 7/8).
1638 [5123, 23606, 32768, 0],1648 [5123, 23606, 32768, 0],
1639 [11606, 24308, 32768, 0],1649 [11606, 24308, 32768, 0],
1650+ // lane-inter4 r1: BLOCK_32X64 / 64X32 / 8X32 / 32X8 / 16X64 / 64X16 rows
1651+ // (libaom `default_motion_mode_cdf` indices 10, 11, 18, 19, 20, 21).
1652+ [20360, 28062, 32768, 0],
1653+ [21679, 26830, 32768, 0],
1654+ [28799, 31390, 32768, 0],
1655+ [26431, 30774, 32768, 0],
1656+ [28973, 31594, 32768, 0],
1657+ [29742, 31203, 32768, 0],
1640 ];1658 ];
1641 1659
1642 /// `default_interintra_cdf` (spec 9.4): `interintra`, indexed by1660 /// `default_interintra_cdf` (spec 9.4): `interintra`, indexed by
crates/ec-av1/src/cdf_state.rsmodified+2 -2
@@ -469,13 +469,13 @@ pub(crate) struct Cdfs {
469 /// `BLOCK_8X8`, 1 = `BLOCK_16X16`, 2 = `BLOCK_32X32`, 3 = `BLOCK_64X64`469 /// `BLOCK_8X8`, 1 = `BLOCK_16X16`, 2 = `BLOCK_32X32`, 3 = `BLOCK_64X64`
470 /// (`default_obmc_cdf`'s own `BLOCK_SIZES_ALL` indices 3/6/9/12 --470 /// (`default_obmc_cdf`'s own `BLOCK_SIZES_ALL` indices 3/6/9/12 --
471 /// this decoder only ever codes those four square sizes).471 /// this decoder only ever codes those four square sizes).
472- pub obmc: [[u16; 3]; 6],472+ pub obmc: [[u16; 3]; 12],
473 /// `motion_mode` (spec 5.11.24's `read_motion_mode`), the 3-symbol473 /// `motion_mode` (spec 5.11.24's `read_motion_mode`), the 3-symbol
474 /// `SIMPLE_TRANSLATION`/`OBMC_CAUSAL`/`WARPED_CAUSAL` alphabet read474 /// `SIMPLE_TRANSLATION`/`OBMC_CAUSAL`/`WARPED_CAUSAL` alphabet read
475 /// instead of [`Self::obmc`] whenever `motion_mode_allowed` resolves to475 /// instead of [`Self::obmc`] whenever `motion_mode_allowed` resolves to
476 /// `WARPED_CAUSAL`-eligible -- same square-bsize indexing as `obmc`.476 /// `WARPED_CAUSAL`-eligible -- same square-bsize indexing as `obmc`.
477 /// lane-warp round 1.477 /// lane-warp round 1.
478- pub motion_mode: [[u16; 4]; 6],478+ pub motion_mode: [[u16; 4]; 12],
479 /// `interintra`, indexed by `size_group_lookup[bsize]` -- see479 /// `interintra`, indexed by `size_group_lookup[bsize]` -- see
480 /// `cdf::INTERINTRA`'s own doc.480 /// `cdf::INTERINTRA`'s own doc.
481 pub interintra: [[u16; 3]; 4],481 pub interintra: [[u16; 3]; 4],
crates/ec-av1/src/decode.rsmodified+338 -65
@@ -1521,6 +1521,17 @@ pub(crate) fn sb_rect4_vert_hits() -> usize {
1521 thread_local! {1521 thread_local! {
1522 static RECT4_32_HORZ_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };1522 static RECT4_32_HORZ_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
1523 static RECT4_32_VERT_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };1523 static RECT4_32_VERT_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
1524+ /// lane-inter4 r1: the INTER-frame twins of the two counters above --
1525+ /// four 32x8 / 8x32 inter strips of a 32x32-level `PARTITION_HORZ_4` /
1526+ /// `PARTITION_VERT_4`.
1527+ static RECT4_32_HORZ_INTER_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
1528+ static RECT4_32_VERT_INTER_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
1529+ /// lane-inter4 r1: superblock-level inter `PARTITION_HORZ`/`PARTITION_VERT`
1530+ /// strips (64x32 / 32x64) and their 1:4 pair (64x16 / 16x64).
1531+ static INTER_SB_HORZ_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
1532+ static INTER_SB_VERT_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
1533+ static INTER_SB_HORZ4_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
1534+ static INTER_SB_VERT4_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
1524 }1535 }
1525 1536
1526 /// How many 32x32-level 1:4 strips actually read coefficients (non-skip):1537 /// How many 32x32-level 1:4 strips actually read coefficients (non-skip):
@@ -1545,6 +1556,36 @@ pub(crate) fn rect4_32_vert_hits() -> usize {
1545 RECT4_32_VERT_HITS.with(|c| c.get())1556 RECT4_32_VERT_HITS.with(|c| c.get())
1546 }1557 }
1547 1558
1559+/// Current value of `RECT4_32_HORZ_INTER_HITS` (32x8 inter strips decoded).
1560+pub(crate) fn rect4_32_horz_inter_hits() -> usize {
1561+ RECT4_32_HORZ_INTER_HITS.with(|c| c.get())
1562+}
1563+
1564+/// Current value of `RECT4_32_VERT_INTER_HITS` (8x32 inter strips decoded).
1565+pub(crate) fn rect4_32_vert_inter_hits() -> usize {
1566+ RECT4_32_VERT_INTER_HITS.with(|c| c.get())
1567+}
1568+
1569+/// Current value of `INTER_SB_HORZ_HITS` (64x32 inter strips decoded).
1570+pub(crate) fn inter_sb_horz_hits() -> usize {
1571+ INTER_SB_HORZ_HITS.with(|c| c.get())
1572+}
1573+
1574+/// Current value of `INTER_SB_VERT_HITS` (32x64 inter strips decoded).
1575+pub(crate) fn inter_sb_vert_hits() -> usize {
1576+ INTER_SB_VERT_HITS.with(|c| c.get())
1577+}
1578+
1579+/// Current value of `INTER_SB_HORZ4_HITS` (64x16 inter strips decoded).
1580+pub(crate) fn inter_sb_horz4_hits() -> usize {
1581+ INTER_SB_HORZ4_HITS.with(|c| c.get())
1582+}
1583+
1584+/// Current value of `INTER_SB_VERT4_HITS` (16x64 inter strips decoded).
1585+pub(crate) fn inter_sb_vert4_hits() -> usize {
1586+ INTER_SB_VERT4_HITS.with(|c| c.get())
1587+}
1588+
1548 // lane-rect64q r1: how many of [`decode_block_rect64`]'s three per-plane1589 // lane-rect64q r1: how many of [`decode_block_rect64`]'s three per-plane
1549 // dequant calls actually observed `CURRENT_Q_IDX != base_q_idx` -- proof the1590 // dequant calls actually observed `CURRENT_Q_IDX != base_q_idx` -- proof the
1550 // running-vs-stale-snapshot bug this round fixed is exercised by a gate, not1591 // running-vs-stale-snapshot bug this round fixed is exercised by a gate, not
@@ -3815,7 +3856,24 @@ impl Neighbours {
3815 uv_mode: usize,3856 uv_mode: usize,
3816 grids: &[Vec<i32>; 3],3857 grids: &[Vec<i32>; 3],
3817 ) {3858 ) {
3818- let (r, c) = at;3859+ self.record_rect_mi(sub16_to_mi(at), w, h, mode, uv_mode, grids);
3860+ }
3861+
3862+ /// [`Self::record_rect`] in mi (4 px) units -- lane-inter4 r1: a
3863+ /// 32x8/8x32 strip of a 32-level 1:4 partition sits at an 8-px offset the
3864+ /// [`SUB`]-unit `at` cannot name. The coarse 16-px bands are still keyed
3865+ /// by the enclosing cell (a sub-16 extent writes none of them, exactly as
3866+ /// the [`SUB`]-unit path does).
3867+ fn record_rect_mi(
3868+ &mut self,
3869+ at_mi: (usize, usize),
3870+ w: usize,
3871+ h: usize,
3872+ mode: usize,
3873+ uv_mode: usize,
3874+ grids: &[Vec<i32>; 3],
3875+ ) {
3876+ let (r, c) = (at_mi.0 / (SUB / MI), at_mi.1 / (SUB / MI));
3819 for cell in 0..w / SUB {3877 for cell in 0..w / SUB {
3820 self.above_mode[c + cell] = mode;3878 self.above_mode[c + cell] = mode;
3821 self.above_uv_mode[c + cell] = uv_mode;3879 self.above_uv_mode[c + cell] = uv_mode;
@@ -3826,9 +3884,9 @@ impl Neighbours {
3826 self.left_uv_mode[r + cell] = uv_mode;3884 self.left_uv_mode[r + cell] = uv_mode;
3827 self.left_side[r + cell] = h;3885 self.left_side[r + cell] = h;
3828 }3886 }
3829- self.record_mode_mi(r * (SUB / MI), c * (SUB / MI), w / MI, h / MI, mode);3887+ self.record_mode_mi(at_mi.0, at_mi.1, w / MI, h / MI, mode);
3830- self.record_uv_mode_mi(r * (SUB / MI), c * (SUB / MI), w / MI, h / MI, uv_mode);3888+ self.record_uv_mode_mi(at_mi.0, at_mi.1, w / MI, h / MI, uv_mode);
3831- self.record_mi_rect((r * (SUB / MI), c * (SUB / MI)), w, h, grids);3889+ self.record_mi_rect(at_mi, w, h, grids);
3832 }3890 }
3833 3891
3834 /// The coefficient-context half of [`Self::record`], taking the block's3892 /// The coefficient-context half of [`Self::record`], taking the block's
@@ -3944,7 +4002,21 @@ impl Neighbours {
3944 uv_mode: usize,4002 uv_mode: usize,
3945 chroma_grids: [&[i32]; 2],4003 chroma_grids: [&[i32]; 2],
3946 ) {4004 ) {
3947- let (r, c) = at;4005+ self.record_split_luma_rect_mi(sub16_to_mi(at), w, h, mode, uv_mode, chroma_grids);
4006+ }
4007+
4008+ /// [`Self::record_split_luma_rect`] in mi (4 px) units (lane-inter4 r1,
4009+ /// same reason as [`Self::record_rect_mi`]).
4010+ fn record_split_luma_rect_mi(
4011+ &mut self,
4012+ at_mi: (usize, usize),
4013+ w: usize,
4014+ h: usize,
4015+ mode: usize,
4016+ uv_mode: usize,
4017+ chroma_grids: [&[i32]; 2],
4018+ ) {
4019+ let (r, c) = (at_mi.0 / (SUB / MI), at_mi.1 / (SUB / MI));
3948 for cell in 0..w / SUB {4020 for cell in 0..w / SUB {
3949 self.above_mode[c + cell] = mode;4021 self.above_mode[c + cell] = mode;
3950 self.above_uv_mode[c + cell] = uv_mode;4022 self.above_uv_mode[c + cell] = uv_mode;
@@ -3955,7 +4027,7 @@ impl Neighbours {
3955 self.left_uv_mode[r + cell] = uv_mode;4027 self.left_uv_mode[r + cell] = uv_mode;
3956 self.left_side[r + cell] = h;4028 self.left_side[r + cell] = h;
3957 }4029 }
3958- let (mi_r, mi_c) = (r * (SUB / MI), c * (SUB / MI));4030+ let (mi_r, mi_c) = at_mi;
3959 let (w_mi, h_mi) = (w / MI, h / MI);4031 let (w_mi, h_mi) = (w / MI, h / MI);
3960 self.record_mode_mi(mi_r, mi_c, w_mi, h_mi, mode);4032 self.record_mode_mi(mi_r, mi_c, w_mi, h_mi, mode);
3961 self.record_uv_mode_mi(mi_r, mi_c, w_mi, h_mi, uv_mode);4033 self.record_uv_mode_mi(mi_r, mi_c, w_mi, h_mi, uv_mode);
@@ -12768,6 +12840,12 @@ fn build_gm_mv_table(
12768 /// mode/tx-type outside what [`read_intra_mode`]/[`read_coeffs`] already12840 /// mode/tx-type outside what [`read_intra_mode`]/[`read_coeffs`] already
12769 /// refuse.12841 /// refuse.
12770 #[allow(clippy::too_many_arguments)]12842 #[allow(clippy::too_many_arguments)]
12843+/// lane-inter4 r1: 16-px-cell coordinates -> MI (4-px) coordinates, the unit
12844+/// [`decode_inter_block`]'s `at` now takes.
12845+const fn sub16_to_mi(t: (usize, usize)) -> (usize, usize) {
12846+ (t.0 * (SUB / MI), t.1 * (SUB / MI))
12847+}
12848+
12771 fn decode_inter_block(12849 fn decode_inter_block(
12772 dec: &mut SymbolDecoder,12850 dec: &mut SymbolDecoder,
12773 cdfs: &mut Cdfs,12851 cdfs: &mut Cdfs,
@@ -12882,13 +12960,16 @@ fn decode_inter_block(
12882 // combinations that don't implement scaled MC yet.12960 // combinations that don't implement scaled MC yet.
12883 frame_width: usize,12961 frame_width: usize,
12884 ) -> Result<()> {12962 ) -> Result<()> {
12885- let (r, c) = at;12963+ // lane-inter4 r1: `at` is in MI units (4 px) so a 32-level 1:4 strip can
12964+ // name an 8-px offset; `(r, c)` stays the enclosing 16-px cell for the
12965+ // few 16-px-granular uses below.
12966+ let (r, c) = (at.0 / (SUB / MI), at.1 / (SUB / MI));
12886 // lane-inter8 r2: the inter side bands are mi-granular; this block's own12967 // lane-inter8 r2: the inter side bands are mi-granular; this block's own
12887 // above/left neighbour is the mi cell at its top-left corner (libaom12968 // above/left neighbour is the mi cell at its top-left corner (libaom
12888 // `above_mbmi` = mi(mi_row - 1, mi_col)), so a SUB-aligned block reads12969 // `above_mbmi` = mi(mi_row - 1, mi_col)), so a SUB-aligned block reads
12889 // exactly what it read before.12970 // exactly what it read before.
12890- let (rmi, cmi) = (r * (SUB / MI), c * (SUB / MI));12971+ let (rmi, cmi) = at;
12891- let (px, py) = (c * SUB, r * SUB);12972+ let (px, py) = (at.1 * MI, at.0 * MI);
12892 let (cpx, cpy) = (px / 2, py / 2);12973 let (cpx, cpy) = (px / 2, py / 2);
12893 let chroma_side = side / 2;12974 let chroma_side = side / 2;
12894 let (write_chroma_w, write_chroma_h) = (write_w / 2, write_h / 2);12975 let (write_chroma_w, write_chroma_h) = (write_w / 2, write_h / 2);
@@ -12896,7 +12977,7 @@ fn decode_inter_block(
12896 if std::env::var_os("EC_AV1_TELL").is_some() {12977 if std::env::var_os("EC_AV1_TELL").is_some() {
12897 eprintln!(12978 eprintln!(
12898 "TELL mi_row={} mi_col={} label=block_entry side={side} tell={} range={}",12979 "TELL mi_row={} mi_col={} label=block_entry side={side} tell={} range={}",
12899- r * SUB_MI as usize, c * SUB_MI as usize, dec.debug_bitpos(), dec.debug_state().012980+ rmi, cmi, dec.debug_bitpos(), dec.debug_state().0
12900 );12981 );
12901 }12982 }
12902 let skip_mode_ctx =12983 let skip_mode_ctx =
@@ -12912,7 +12993,7 @@ fn decode_inter_block(
12912 }12993 }
12913 // spec 5.11.5 `inter_frame_mode_info`: `inter_segment_id(1)` before12994 // spec 5.11.5 `inter_frame_mode_info`: `inter_segment_id(1)` before
12914 // `skip_mode`/`skip`, `inter_segment_id(0)` after them.12995 // `skip_mode`/`skip`, `inter_segment_id(0)` after them.
12915- let (seg_mi_r, seg_mi_c) = (r * SUB_MI as usize, c * SUB_MI as usize);12996+ let (seg_mi_r, seg_mi_c) = (rmi, cmi);
12916 let (seg_w_mi, seg_h_mi) = (write_w / 4, write_h / 4);12997 let (seg_w_mi, seg_h_mi) = (write_w / 4, write_h / 4);
12917 inter_segment_id(dec, cdfs, seg_mi_r, seg_mi_c, seg_w_mi, seg_h_mi, false, true);12998 inter_segment_id(dec, cdfs, seg_mi_r, seg_mi_c, seg_w_mi, seg_h_mi, false, true);
12918 let skip_mode = skip_mode_present && dec.symbol(&mut cdfs.skip_mode[skip_mode_ctx]) == 1;12999 let skip_mode = skip_mode_present && dec.symbol(&mut cdfs.skip_mode[skip_mode_ctx]) == 1;
@@ -12929,9 +13010,12 @@ fn decode_inter_block(
12929 let skip_ctx = usize::from(neighbours.above_skip[cmi]) + usize::from(neighbours.left_skip[rmi]);13010 let skip_ctx = usize::from(neighbours.above_skip[cmi]) + usize::from(neighbours.left_skip[rmi]);
12930 let skip = skip_mode || dec.symbol(&mut cdfs.skip[skip_ctx]) == 1;13011 let skip = skip_mode || dec.symbol(&mut cdfs.skip[skip_ctx]) == 1;
12931 inter_segment_id(dec, cdfs, seg_mi_r, seg_mi_c, seg_w_mi, seg_h_mi, skip, false);13012 inter_segment_id(dec, cdfs, seg_mi_r, seg_mi_c, seg_w_mi, seg_h_mi, skip, false);
12932- maybe_read_cdef_idx(dec, r * SUB_MI as usize, c * SUB_MI as usize, skip);13013+ maybe_read_cdef_idx(dec, rmi, cmi, skip);
12933- maybe_read_delta_q(dec, cdfs, r * SUB_MI as usize, c * SUB_MI as usize, side == 64, skip);13014+ // lane-inter4 r1: spec 5.11.6's `bSize == sbSize` -- a 64x32/64x16 strip
12934- maybe_read_delta_lf(dec, cdfs, r * SUB_MI as usize, c * SUB_MI as usize, side == 64, skip);13015+ // is NOT the whole superblock, so its `skip` never suppresses the read.
13016+ let whole_sb = side == 64 && write_w == 64 && write_h == 64;
13017+ maybe_read_delta_q(dec, cdfs, rmi, cmi, whole_sb, skip);
13018+ maybe_read_delta_lf(dec, cdfs, rmi, cmi, whole_sb, skip);
12935 // lane-warp r5: see `reject_residual` -- a square-block decode of a13019 // lane-warp r5: see `reject_residual` -- a square-block decode of a
12936 // HORZ_B strip is symbol-exact only for `skip` (no residual, no13020 // HORZ_B strip is symbol-exact only for `skip` (no residual, no
12937 // motion_mode/warp symbol), so gate here before any further read.13021 // motion_mode/warp symbol), so gate here before any further read.
@@ -12942,8 +13026,8 @@ fn decode_inter_block(
12942 }13026 }
12943 13027
12944 let (has_above, has_left) = (13028 let (has_above, has_left) = (
12945- r > neighbours.tile_row0_mi / (SUB / MI),13029+ rmi > neighbours.tile_row0_mi,
12946- c > neighbours.tile_col0_mi / (SUB / MI),13030+ cmi > neighbours.tile_col0_mi,
12947 );13031 );
12948 let (above_inter, left_inter) = (neighbours.above_inter[cmi], neighbours.left_inter[rmi]);13032 let (above_inter, left_inter) = (neighbours.above_inter[cmi], neighbours.left_inter[rmi]);
12949 let ii_ctx = intra_inter_ctx(has_above, has_left, above_inter, left_inter);13033 let ii_ctx = intra_inter_ctx(has_above, has_left, above_inter, left_inter);
@@ -12951,15 +13035,15 @@ fn decode_inter_block(
12951 if std::env::var_os("EC_TRACE_MODE").is_some() {13035 if std::env::var_os("EC_TRACE_MODE").is_some() {
12952 eprintln!(13036 eprintln!(
12953 "EC_MODE mi_row={} mi_col={} rng={}",13037 "EC_MODE mi_row={} mi_col={} rng={}",
12954- r * SUB_MI as usize,13038+ rmi,
12955- c * SUB_MI as usize,13039+ cmi,
12956 dec.debug_state().013040 dec.debug_state().0
12957 );13041 );
12958 }13042 }
12959 if std::env::var_os("EC_AV1_TELL").is_some() {13043 if std::env::var_os("EC_AV1_TELL").is_some() {
12960 eprintln!(13044 eprintln!(
12961 "TELL mi_row={} mi_col={} label=post_is_inter skip_mode={skip_mode} skip={skip} is_inter={is_inter} tell={} range={}",13045 "TELL mi_row={} mi_col={} label=post_is_inter skip_mode={skip_mode} skip={skip} is_inter={is_inter} tell={} range={}",
12962- r * SUB_MI as usize, c * SUB_MI as usize, dec.debug_bitpos(), dec.debug_state().013046+ rmi, cmi, dec.debug_bitpos(), dec.debug_state().0
12963 );13047 );
12964 }13048 }
12965 13049
@@ -12979,7 +13063,7 @@ fn decode_inter_block(
12979 // than one luma transform -- read back by the residual loop, the13063 // than one luma transform -- read back by the residual loop, the
12980 // coefficient-context write-back and the loop-filter grid fill below.13064 // coefficient-context write-back and the loop-filter grid fill below.
12981 let mut vartx_leaves: Option<Vec<(usize, usize, usize)>> = None;13065 let mut vartx_leaves: Option<Vec<(usize, usize, usize)>> = None;
12982- let at_mi = (r * (SUB / MI), c * (SUB / MI));13066+ let at_mi = at;
12983 if is_inter {13067 if is_inter {
12984 let above_nbr = has_above.then(|| NeighbourRef {13068 let above_nbr = has_above.then(|| NeighbourRef {
12985 is_inter: above_inter,13069 is_inter: above_inter,
@@ -13024,7 +13108,7 @@ fn decode_inter_block(
13024 neighbours.left_ref[rmi],13108 neighbours.left_ref[rmi],
13025 )13109 )
13026 };13110 };
13027- let (mi_row, mi_col) = (r * SUB_MI as usize, c * SUB_MI as usize);13111+ let (mi_row, mi_col) = (rmi, cmi);
13028 // lane-rect r2: true footprint, mirroring the single-ref path below.13112 // lane-rect r2: true footprint, mirroring the single-ref path below.
13029 let bw4 = write_w / 4;13113 let bw4 = write_w / 4;
13030 let bh4 = write_h / 4;13114 let bh4 = write_h / 4;
@@ -13782,7 +13866,7 @@ fn decode_inter_block(
13782 u_grid = vec![0i32; chroma_side * chroma_side];13866 u_grid = vec![0i32; chroma_side * chroma_side];
13783 v_grid = vec![0i32; chroma_side * chroma_side];13867 v_grid = vec![0i32; chroma_side * chroma_side];
13784 } else {13868 } else {
13785- let around = neighbours.around(at, side);13869+ let around = neighbours.around_mi(at, side);
13786 let luma_tx_type;13870 let luma_tx_type;
13787 if let Some(leaves) = vartx_leaves.clone() {13871 if let Some(leaves) = vartx_leaves.clone() {
13788 // spec 5.11.17's transform tree, leaf by leaf in the order13872 // spec 5.11.17's transform tree, leaf by leaf in the order
@@ -13897,7 +13981,7 @@ fn decode_inter_block(
13897 );13981 );
13898 ref_frame_for_lf = ref_frame;13982 ref_frame_for_lf = ref_frame;
13899 if std::env::var_os("EC_AV1_TELL").is_some() {13983 if std::env::var_os("EC_AV1_TELL").is_some() {
13900- let (mi_row, mi_col) = (r * SUB_MI as usize, c * SUB_MI as usize);13984+ let (mi_row, mi_col) = (rmi, cmi);
13901 eprintln!(13985 eprintln!(
13902 "TELL mi_row={mi_row} mi_col={mi_col} label=post_ref_frame ref={ref_frame} tell={} range={}",13986 "TELL mi_row={mi_row} mi_col={mi_col} label=post_ref_frame ref={ref_frame} tell={} range={}",
13903 dec.debug_bitpos(), dec.debug_state().013987 dec.debug_bitpos(), dec.debug_state().0
@@ -13925,7 +14009,7 @@ fn decode_inter_block(
13925 }14009 }
13926 };14010 };
13927 14011
13928- let (mi_row, mi_col) = (r * SUB_MI as usize, c * SUB_MI as usize);14012+ let (mi_row, mi_col) = (rmi, cmi);
13929 // lane-rect r2: the mv stack must be queried with the block's14013 // lane-rect r2: the mv stack must be queried with the block's
13930 // REAL extent (libaom `av1_get_mv_refs` gets bw4/bh4 from14014 // REAL extent (libaom `av1_get_mv_refs` gets bw4/bh4 from
13931 // xd->width/xd->height, not a square guess) -- `write_w`/14015 // xd->width/xd->height, not a square guess) -- `write_w`/
@@ -14059,7 +14143,18 @@ fn decode_inter_block(
14059 // `size_group_lookup`: BLOCK_16X16 -> 2, BLOCK_32X32 -> 3.14143 // `size_group_lookup`: BLOCK_16X16 -> 2, BLOCK_32X32 -> 3.
14060 let mut interintra_mode: Option<u8> = None;14144 let mut interintra_mode: Option<u8> = None;
14061 let mut wedge_mask: Option<(&'static [u8], usize)> = None;14145 let mut wedge_mask: Option<(&'static [u8], usize)> = None;
14062- if enable_interintra_compound && !skip_mode && (side == 16 || side == 32) {14146+ // lane-inter4 r1: `is_interintra_allowed_bsize` is
14147+ // `BLOCK_8X8..=BLOCK_32X32` in libaom's enum ORDER, which excludes
14148+ // every 1:4 shape (BLOCK_8X32 = 18, BLOCK_32X8 = 19) even though
14149+ // both dimensions are in range -- reading this symbol on a 1:4
14150+ // strip is a symbol the reference never wrote.
14151+ let interintra_shape =
14152+ write_w.max(write_h) <= 32 && write_w.max(write_h) / write_w.min(write_h) <= 2;
14153+ if enable_interintra_compound
14154+ && !skip_mode
14155+ && (side == 16 || side == 32)
14156+ && interintra_shape
14157+ {
14063 let bsize_group = if side == 16 { 2 } else { 3 };14158 let bsize_group = if side == 16 { 2 } else { 3 };
14064 let interintra = dec.symbol(&mut cdfs.interintra[bsize_group]) == 1;14159 let interintra = dec.symbol(&mut cdfs.interintra[bsize_group]) == 1;
14065 if interintra {14160 if interintra {
@@ -14155,12 +14250,26 @@ fn decode_inter_block(
14155 // (libaom `motion_mode_cdf[mbmi->bsize]`: BLOCK_16X32 -> 4,14250 // (libaom `motion_mode_cdf[mbmi->bsize]`: BLOCK_16X32 -> 4,
14156 // BLOCK_32X16 -> 5 in our packed table) -- rect-flake-1's14251 // BLOCK_32X16 -> 5 in our packed table) -- rect-flake-1's
14157 // strip motion_mode read diverged on the square row.14252 // strip motion_mode read diverged on the square row.
14158- let bsize_idx = if write_w == write_h {14253+ // lane-inter4 r1: every rect shape this decoder can now
14159- (write_w.trailing_zeros() - 3) as usize14254+ // reach reads its OWN libaom bsize row (the packed order is
14160- } else if write_w == 16 {14255+ // documented on `cdf::MOTION_MODE`); a wrong row is a wrong
14161- 414256+ // interval narrowing, not a wrong value (class
14162- } else {14257+ // wrong-alphabet-same-value).
14163- 514258+ let bsize_idx = match (write_w, write_h) {
14259+ (w, h) if w == h => (w.trailing_zeros() - 3) as usize,
14260+ (16, 32) => 4,
14261+ (32, 16) => 5,
14262+ (32, 64) => 6,
14263+ (64, 32) => 7,
14264+ (8, 32) => 8,
14265+ (32, 8) => 9,
14266+ (16, 64) => 10,
14267+ (64, 16) => 11,
14268+ _ => {
14269+ return Err(unsupported(
14270+ "a motion_mode symbol for a block shape this decoder has no CDF row for",
14271+ ));
14272+ }
14164 };14273 };
14165 // `motion_mode_allowed` reads the 3-symbol `motion_mode_cdf`14274 // `motion_mode_allowed` reads the 3-symbol `motion_mode_cdf`
14166 // instead of the 2-symbol `obmc_cdf` exactly when14275 // instead of the 2-symbol `obmc_cdf` exactly when
@@ -14597,7 +14706,7 @@ fn decode_inter_block(
14597 u_grid = vec![0i32; chroma_side * chroma_side];14706 u_grid = vec![0i32; chroma_side * chroma_side];
14598 v_grid = vec![0i32; chroma_side * chroma_side];14707 v_grid = vec![0i32; chroma_side * chroma_side];
14599 } else {14708 } else {
14600- let around = neighbours.around(at, side);14709+ let around = neighbours.around_mi(at, side);
14601 let luma_tx_type;14710 let luma_tx_type;
14602 if let Some(leaves) = vartx_leaves.clone() {14711 if let Some(leaves) = vartx_leaves.clone() {
14603 // spec 5.11.17's transform tree, leaf by leaf in the order14712 // spec 5.11.17's transform tree, leaf by leaf in the order
@@ -14786,7 +14895,7 @@ fn decode_inter_block(
14786 block_filter = [3, 3];14895 block_filter = [3, 3];
14787 ref_frame_for_lf = 0;14896 ref_frame_for_lf = 0;
14788 globalmv_for_lf = false;14897 globalmv_for_lf = false;
14789- let (mi_row, mi_col) = (r * SUB_MI as usize, c * SUB_MI as usize);14898+ let (mi_row, mi_col) = (rmi, cmi);
14790 for dr in 0..side / 4 {14899 for dr in 0..side / 4 {
14791 for dc in 0..side / 4 {14900 for dc in 0..side / 4 {
14792 grid.set(14901 grid.set(
@@ -14861,7 +14970,7 @@ fn decode_inter_block(
14861 u_grid = vec![0i32; chroma_side * chroma_side];14970 u_grid = vec![0i32; chroma_side * chroma_side];
14862 v_grid = vec![0i32; chroma_side * chroma_side];14971 v_grid = vec![0i32; chroma_side * chroma_side];
14863 } else {14972 } else {
14864- let around = neighbours.around(at, side);14973+ let around = neighbours.around_mi(at, side);
14865 luma_grid = read_plane(14974 luma_grid = read_plane(
14866 dec,14975 dec,
14867 cdfs,14976 cdfs,
@@ -14940,7 +15049,7 @@ fn decode_inter_block(
14940 if std::env::var_os("EC_AV1_TELL").is_some() {15049 if std::env::var_os("EC_AV1_TELL").is_some() {
14941 eprintln!(15050 eprintln!(
14942 "TELL mi_row={} mi_col={} label=block_end tell={} range={}",15051 "TELL mi_row={} mi_col={} label=block_end tell={} range={}",
14943- r * SUB_MI as usize, c * SUB_MI as usize, dec.debug_bitpos(), dec.debug_state().015052+ rmi, cmi, dec.debug_bitpos(), dec.debug_state().0
14944 );15053 );
14945 }15054 }
14946 if vartx_leaves.is_some() {15055 if vartx_leaves.is_some() {
@@ -14948,9 +15057,9 @@ fn decode_inter_block(
14948 // ([`Neighbours::record_mi_luma`] above); this writes everything else15057 // ([`Neighbours::record_mi_luma`] above); this writes everything else
14949 // [`Neighbours::record_rect`] would (a var-tx block is always square,15058 // [`Neighbours::record_rect`] would (a var-tx block is always square,
14950 // so `write_w == write_h == side`).15059 // so `write_w == write_h == side`).
14951- neighbours.record_split_luma(at, side, mode_for_tx, uv_predict_mode, [&u_grid, &v_grid]);15060+ neighbours.record_split_luma_rect_mi(at, side, side, mode_for_tx, uv_predict_mode, [&u_grid, &v_grid]);
14952 } else {15061 } else {
14953- neighbours.record_rect(15062+ neighbours.record_rect_mi(
14954 at,15063 at,
14955 write_w,15064 write_w,
14956 write_h,15065 write_h,
@@ -14959,10 +15068,10 @@ fn decode_inter_block(
14959 &[luma_grid, u_grid, v_grid],15068 &[luma_grid, u_grid, v_grid],
14960 );15069 );
14961 }15070 }
14962- neighbours.record_inter_rect(15071+ neighbours.record_inter_rect_mi(
14963 at,15072 at,
14964- write_w,15073+ write_w / MI,
14965- write_h,15074+ write_h / MI,
14966 skip,15075 skip,
14967 is_inter,15076 is_inter,
14968 ref_frame_for_lf,15077 ref_frame_for_lf,
@@ -14970,16 +15079,16 @@ fn decode_inter_block(
14970 skip_mode,15079 skip_mode,
14971 );15080 );
14972 if let Some((ref1, group_idx, idx)) = compound_ctx {15081 if let Some((ref1, group_idx, idx)) = compound_ctx {
14973- neighbours.record_compound_ctx_rect(at, write_w, write_h, ref1, group_idx, idx);15082+ neighbours.record_compound_ctx_rect_mi(at, write_w / MI, write_h / MI, ref1, group_idx, idx);
14974 }15083 }
14975 neighbours.fill_skip_grid_rect(15084 neighbours.fill_skip_grid_rect(
14976- (r * (SUB / MI), c * (SUB / MI)),15085+ (rmi, cmi),
14977 write_w / MI,15086 write_w / MI,
14978 write_h / MI,15087 write_h / MI,
14979 skip,15088 skip,
14980 );15089 );
14981 neighbours.fill_lf_grid_rect(15090 neighbours.fill_lf_grid_rect(
14982- (r * (SUB / MI), c * (SUB / MI)),15091+ (rmi, cmi),
14983 write_w / MI,15092 write_w / MI,
14984 write_h / MI,15093 write_h / MI,
14985 // lane-rect r2: the strip's true TX_32X16/TX_16X32 dims -- the15094 // lane-rect r2: the strip's true TX_32X16/TX_16X32 dims -- the
@@ -16899,6 +17008,64 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
16899 );17008 );
16900 CDEF_TRANSMITTED.with(|c| c.set(false));17009 CDEF_TRANSMITTED.with(|c| c.set(false));
16901 let sb_at = (sb_r as usize * 4, sb_c as usize * 4);17010 let sb_at = (sb_r as usize * 4, sb_c as usize * 4);
17011+ // lane-inter4 r1: every rect inter piece below is the same
17012+ // `decode_inter_block` call with only position / true footprint /
17013+ // transform-set differing; the macro keeps the new arms readable
17014+ // instead of six more 60-line copies of the argument list.
17015+ macro_rules! inter_piece {
17016+ ($at_mi:expr, $side:expr, $li:expr, $lt:expr, $ch:expr, $ltx:expr,
17017+ $ctx:expr, $sl:expr, $sc:expr, $sg:expr, $ww:expr, $wh:expr) => {
17018+ decode_inter_block(
17019+ &mut dec,
17020+ &mut cdfs,
17021+ &mut neighbours,
17022+ &mut grid,
17023+ $at_mi,
17024+ $side,
17025+ mi_cols,
17026+ mi_rows,
17027+ &mut y,
17028+ &mut u,
17029+ &mut v,
17030+ &ref_y,
17031+ &ref_u,
17032+ &ref_v,
17033+ &ref_slots,
17034+ &sign_bias_table,
17035+ &global_motion,
17036+ base_q_idx,
17037+ $li,
17038+ $lt,
17039+ $ch,
17040+ $ltx,
17041+ $ctx,
17042+ $sl,
17043+ $sc,
17044+ $sg,
17045+ allow_high_precision_mv,
17046+ force_integer_mv,
17047+ interp_fixed,
17048+ enable_dual_filter,
17049+ tpl_frame.as_ref(),
17050+ reference_select,
17051+ enable_masked_compound,
17052+ enable_interintra_compound,
17053+ enable_jnt_comp,
17054+ order_hint_bits,
17055+ order_hint,
17056+ ref_order_hints,
17057+ skip_mode_present,
17058+ skip_mode_frame,
17059+ switchable_motion_mode,
17060+ allow_warped_motion,
17061+ true,
17062+ $ww,
17063+ $wh,
17064+ allow_screen_content_tools,
17065+ frame_width as usize,
17066+ )?
17067+ };
17068+ }
16902 let sb_ctx = neighbours.partition_ctx(sb_at, SB);17069 let sb_ctx = neighbours.partition_ctx(sb_at, SB);
16903 let (has_cols, has_rows) = (17070 let (has_cols, has_rows) = (
16904 sb_c * SB_MI + SB_MI / 2 < mi_cols,17071 sb_c * SB_MI + SB_MI / 2 < mi_cols,
@@ -16949,7 +17116,7 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
16949 &mut cdfs,17116 &mut cdfs,
16950 &mut neighbours,17117 &mut neighbours,
16951 &mut grid,17118 &mut grid,
16952- sb_at,17119+ sub16_to_mi(sb_at),
16953 SB,17120 SB,
16954 mi_cols,17121 mi_cols,
16955 mi_rows,17122 mi_rows,
@@ -16995,10 +17162,73 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
16995 )?;17162 )?;
16996 continue;17163 continue;
16997 }17164 }
17165+ if matches!(
17166+ part64,
17167+ PARTITION_HORZ | PARTITION_VERT | PARTITION_HORZ_4 | PARTITION_VERT_4
17168+ ) {
17169+ // lane-inter4 r1: the superblock-level rect + 1:4 pairs as
17170+ // inter blocks -- two 64x32 / 32x64 strips, or four 64x16 /
17171+ // 16x64 ones. Each piece keeps `side = SB` for every
17172+ // syntax/CDF/prediction-buffer decision (the square-context
17173+ // corner-cut PARTITION_HORZ already ships at the 32 level)
17174+ // but names its own true footprint through `write_w`/
17175+ // `write_h`, which is what `motion_mode`'s bsize row, the
17176+ // mv-stack's bw4/bh4, the delta-q `bSize == sbSize` test and
17177+ // every neighbour stamp read. `reject_residual = true`: a
17178+ // non-skip strip refuses by name rather than over-read a
17179+ // square residual (rectangular inter residual coding is not
17180+ // ported -- see lanes/inter4-r1.report.md).
17181+ let horz = matches!(part64, PARTITION_HORZ | PARTITION_HORZ_4);
17182+ let four = matches!(part64, PARTITION_HORZ_4 | PARTITION_VERT_4);
17183+ let base_mi = (
17184+ sb_r as usize * SB_MI as usize,
17185+ sb_c as usize * SB_MI as usize,
17186+ );
17187+ let (n_pieces, step_mi) = if four { (4usize, 4usize) } else { (2usize, 8usize) };
17188+ let (bw, bh) = match (horz, four) {
17189+ (true, false) => (64usize, 32usize),
17190+ (false, false) => (32, 64),
17191+ (true, true) => (64, 16),
17192+ (false, true) => (16, 64),
17193+ };
17194+ for i in 0..n_pieces {
17195+ let at_mi = if horz {
17196+ (base_mi.0 + i * step_mi, base_mi.1)
17197+ } else {
17198+ (base_mi.0, base_mi.1 + i * step_mi)
17199+ };
17200+ // libaom `decode_partition`'s own `i > 0` frame-edge break.
17201+ if i > 0 && (at_mi.0 >= mi_rows as usize || at_mi.1 >= mi_cols as usize) {
17202+ break;
17203+ }
17204+ inter_piece!(
17205+ at_mi,
17206+ SB,
17207+ TxbSet::Luma64,
17208+ TxbSet::Luma64,
17209+ TxbSet::Chroma32,
17210+ TX32,
17211+ TX32,
17212+ &scan32,
17213+ &scan32,
17214+ 3,
17215+ bw,
17216+ bh
17217+ );
17218+ match (horz, four) {
17219+ (true, false) => INTER_SB_HORZ_HITS.with(|c| c.set(c.get() + 1)),
17220+ (false, false) => INTER_SB_VERT_HITS.with(|c| c.set(c.get() + 1)),
17221+ (true, true) => INTER_SB_HORZ4_HITS.with(|c| c.set(c.get() + 1)),
17222+ (false, true) => INTER_SB_VERT4_HITS.with(|c| c.set(c.get() + 1)),
17223+ }
17224+ }
17225+ continue;
17226+ }
16998 if part64 != PARTITION_SPLIT {17227 if part64 != PARTITION_SPLIT {
16999 return Err(unsupported(17228 return Err(unsupported(
17000- "an inter SB-level partition type other than NONE or SPLIT (this decoder's \17229+ "an inter SB-level AB partition (HORZ_A/HORZ_B/VERT_A/VERT_B; this \
17001- inter tile path recurses a superblock only as SPLIT)",17230+ decoder's inter tile path codes a superblock as NONE, SPLIT, HORZ, \
17231+ VERT, HORZ_4 or VERT_4)",
17002 ));17232 ));
17003 }17233 }
17004 17234
@@ -17050,7 +17280,7 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
17050 &mut cdfs,17280 &mut cdfs,
17051 &mut neighbours,17281 &mut neighbours,
17052 &mut grid,17282 &mut grid,
17053- at,17283+ sub16_to_mi(at),
17054 BLOCK,17284 BLOCK,
17055 mi_cols,17285 mi_cols,
17056 mi_rows,17286 mi_rows,
@@ -17151,7 +17381,7 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
17151 &mut cdfs,17381 &mut cdfs,
17152 &mut neighbours,17382 &mut neighbours,
17153 &mut grid,17383 &mut grid,
17154- at16,17384+ sub16_to_mi(at16),
17155 SUB,17385 SUB,
17156 mi_cols,17386 mi_cols,
17157 mi_rows,17387 mi_rows,
@@ -17357,7 +17587,7 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
17357 &mut cdfs,17587 &mut cdfs,
17358 &mut neighbours,17588 &mut neighbours,
17359 &mut grid,17589 &mut grid,
17360- at32,17590+ sub16_to_mi(at32),
17361 BLOCK,17591 BLOCK,
17362 mi_cols,17592 mi_cols,
17363 mi_rows,17593 mi_rows,
@@ -17410,7 +17640,7 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
17410 &mut cdfs,17640 &mut cdfs,
17411 &mut neighbours,17641 &mut neighbours,
17412 &mut grid,17642 &mut grid,
17413- (r32 as usize * 2 + 1, c32 as usize * 2),17643+ sub16_to_mi((r32 as usize * 2 + 1, c32 as usize * 2)),
17414 SUB,17644 SUB,
17415 mi_cols,17645 mi_cols,
17416 mi_rows,17646 mi_rows,
@@ -17464,7 +17694,7 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
17464 &mut cdfs,17694 &mut cdfs,
17465 &mut neighbours,17695 &mut neighbours,
17466 &mut grid,17696 &mut grid,
17467- (r32 as usize * 2 + 1, c32 as usize * 2 + 1),17697+ sub16_to_mi((r32 as usize * 2 + 1, c32 as usize * 2 + 1)),
17468 SUB,17698 SUB,
17469 mi_cols,17699 mi_cols,
17470 mi_rows,17700 mi_rows,
@@ -17528,7 +17758,7 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
17528 &mut cdfs,17758 &mut cdfs,
17529 &mut neighbours,17759 &mut neighbours,
17530 &mut grid,17760 &mut grid,
17531- at,17761+ sub16_to_mi(at),
17532 BLOCK,17762 BLOCK,
17533 mi_cols,17763 mi_cols,
17534 mi_rows,17764 mi_rows,
@@ -17577,7 +17807,7 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
17577 &mut cdfs,17807 &mut cdfs,
17578 &mut neighbours,17808 &mut neighbours,
17579 &mut grid,17809 &mut grid,
17580- (r32 as usize * 2 + 1, c32 as usize * 2),17810+ sub16_to_mi((r32 as usize * 2 + 1, c32 as usize * 2)),
17581 BLOCK,17811 BLOCK,
17582 mi_cols,17812 mi_cols,
17583 mi_rows,17813 mi_rows,
@@ -17631,7 +17861,7 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
17631 &mut cdfs,17861 &mut cdfs,
17632 &mut neighbours,17862 &mut neighbours,
17633 &mut grid,17863 &mut grid,
17634- at,17864+ sub16_to_mi(at),
17635 BLOCK,17865 BLOCK,
17636 mi_cols,17866 mi_cols,
17637 mi_rows,17867 mi_rows,
@@ -17680,7 +17910,7 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
17680 &mut cdfs,17910 &mut cdfs,
17681 &mut neighbours,17911 &mut neighbours,
17682 &mut grid,17912 &mut grid,
17683- (r32 as usize * 2, c32 as usize * 2 + 1),17913+ sub16_to_mi((r32 as usize * 2, c32 as usize * 2 + 1)),
17684 BLOCK,17914 BLOCK,
17685 mi_cols,17915 mi_cols,
17686 mi_rows,17916 mi_rows,
@@ -17735,7 +17965,7 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
17735 &mut cdfs,17965 &mut cdfs,
17736 &mut neighbours,17966 &mut neighbours,
17737 &mut grid,17967 &mut grid,
17738- at,17968+ sub16_to_mi(at),
17739 SUB,17969 SUB,
17740 mi_cols,17970 mi_cols,
17741 mi_rows,17971 mi_rows,
@@ -17788,7 +18018,7 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
17788 &mut cdfs,18018 &mut cdfs,
17789 &mut neighbours,18019 &mut neighbours,
17790 &mut grid,18020 &mut grid,
17791- (r32 as usize * 2, c32 as usize * 2 + 1),18021+ sub16_to_mi((r32 as usize * 2, c32 as usize * 2 + 1)),
17792 SUB,18022 SUB,
17793 mi_cols,18023 mi_cols,
17794 mi_rows,18024 mi_rows,
@@ -17841,7 +18071,7 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
17841 &mut cdfs,18071 &mut cdfs,
17842 &mut neighbours,18072 &mut neighbours,
17843 &mut grid,18073 &mut grid,
17844- (r32 as usize * 2 + 1, c32 as usize * 2),18074+ sub16_to_mi((r32 as usize * 2 + 1, c32 as usize * 2)),
17845 BLOCK,18075 BLOCK,
17846 mi_cols,18076 mi_cols,
17847 mi_rows,18077 mi_rows,
@@ -17896,7 +18126,7 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
17896 &mut cdfs,18126 &mut cdfs,
17897 &mut neighbours,18127 &mut neighbours,
17898 &mut grid,18128 &mut grid,
17899- at,18129+ sub16_to_mi(at),
17900 SUB,18130 SUB,
17901 mi_cols,18131 mi_cols,
17902 mi_rows,18132 mi_rows,
@@ -17949,7 +18179,7 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
17949 &mut cdfs,18179 &mut cdfs,
17950 &mut neighbours,18180 &mut neighbours,
17951 &mut grid,18181 &mut grid,
17952- (r32 as usize * 2 + 1, c32 as usize * 2),18182+ sub16_to_mi((r32 as usize * 2 + 1, c32 as usize * 2)),
17953 SUB,18183 SUB,
17954 mi_cols,18184 mi_cols,
17955 mi_rows,18185 mi_rows,
@@ -18002,7 +18232,7 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
18002 &mut cdfs,18232 &mut cdfs,
18003 &mut neighbours,18233 &mut neighbours,
18004 &mut grid,18234 &mut grid,
18005- (r32 as usize * 2, c32 as usize * 2 + 1),18235+ sub16_to_mi((r32 as usize * 2, c32 as usize * 2 + 1)),
18006 BLOCK,18236 BLOCK,
18007 mi_cols,18237 mi_cols,
18008 mi_rows,18238 mi_rows,
@@ -18058,7 +18288,7 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
18058 &mut cdfs,18288 &mut cdfs,
18059 &mut neighbours,18289 &mut neighbours,
18060 &mut grid,18290 &mut grid,
18061- at,18291+ sub16_to_mi(at),
18062 BLOCK,18292 BLOCK,
18063 mi_cols,18293 mi_cols,
18064 mi_rows,18294 mi_rows,
@@ -18107,7 +18337,7 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
18107 &mut cdfs,18337 &mut cdfs,
18108 &mut neighbours,18338 &mut neighbours,
18109 &mut grid,18339 &mut grid,
18110- (r32 as usize * 2, c32 as usize * 2 + 1),18340+ sub16_to_mi((r32 as usize * 2, c32 as usize * 2 + 1)),
18111 SUB,18341 SUB,
18112 mi_cols,18342 mi_cols,
18113 mi_rows,18343 mi_rows,
@@ -18160,7 +18390,7 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
18160 &mut cdfs,18390 &mut cdfs,
18161 &mut neighbours,18391 &mut neighbours,
18162 &mut grid,18392 &mut grid,
18163- (r32 as usize * 2 + 1, c32 as usize * 2 + 1),18393+ sub16_to_mi((r32 as usize * 2 + 1, c32 as usize * 2 + 1)),
18164 SUB,18394 SUB,
18165 mi_cols,18395 mi_cols,
18166 mi_rows,18396 mi_rows,
@@ -18209,6 +18439,49 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
18209 frame_width as usize,18439 frame_width as usize,
18210 )?;18440 )?;
18211 }18441 }
18442+ PARTITION_HORZ_4 | PARTITION_VERT_4 => {
18443+ // lane-inter4 r1: four 32x8 / 8x32 inter strips,
18444+ // `quarter_step` = 2 mi -- the arm ReelC's first inter
18445+ // frame stops at (`value=9` = PARTITION_VERT_4).
18446+ // `at` is in 16-px cells and cannot name an 8-px
18447+ // offset, which is why `decode_inter_block` takes mi
18448+ // coordinates now.
18449+ let horz = part32 == PARTITION_HORZ_4;
18450+ let base_mi = (at.0 * (SUB / MI), at.1 * (SUB / MI));
18451+ let (bw, bh) = if horz { (32usize, 8usize) } else { (8, 32) };
18452+ for i in 0..4 {
18453+ let strip_mi = if horz {
18454+ (base_mi.0 + i * 2, base_mi.1)
18455+ } else {
18456+ (base_mi.0, base_mi.1 + i * 2)
18457+ };
18458+ if i > 0
18459+ && (strip_mi.0 >= mi_rows as usize
18460+ || strip_mi.1 >= mi_cols as usize)
18461+ {
18462+ break;
18463+ }
18464+ inter_piece!(
18465+ strip_mi,
18466+ BLOCK,
18467+ TxbSet::Luma32,
18468+ TxbSet::Luma32Inter,
18469+ TxbSet::Chroma16,
18470+ TX32,
18471+ TX16,
18472+ &scan32,
18473+ &scan16,
18474+ 3,
18475+ bw,
18476+ bh
18477+ );
18478+ if horz {
18479+ RECT4_32_HORZ_INTER_HITS.with(|c| c.set(c.get() + 1));
18480+ } else {
18481+ RECT4_32_VERT_INTER_HITS.with(|c| c.set(c.get() + 1));
18482+ }
18483+ }
18484+ }
18212 _ => {18485 _ => {
18213 return Err(unsupported(format!(18486 return Err(unsupported(format!(
18214 "an INTER 32x32 partition type this decoder does not code (value={part32})"18487 "an INTER 32x32 partition type this decoder does not code (value={part32})"
@@ -19296,7 +19569,7 @@ mod tests {
19296 &mut cdfs,19569 &mut cdfs,
19297 &mut neighbours,19570 &mut neighbours,
19298 &mut grid,19571 &mut grid,
19299- (r, c),19572+ sub16_to_mi((r, c)),
19300 side,19573 side,
19301 mi_cols,19574 mi_cols,
19302 mi_rows,19575 mi_rows,
crates/ec-av1/src/refusal_inventory.rsmodified+2 -1
@@ -62,7 +62,7 @@ const REFUSALS: &[&str] = &[
62 "an inter var-tx tree with a leaf transform larger than 32x32",62 "an inter var-tx tree with a leaf transform larger than 32x32",
63 "an intra block in an inter frame whose tx_depth splits its luma transform (round 1)",63 "an intra block in an inter frame whose tx_depth splits its luma transform (round 1)",
64 "an inter frame with no key frame before it",64 "an inter frame with no key frame before it",
65- "an inter SB-level partition type other than NONE or SPLIT (this decoder's inter tile path recurses a superblock only as SPLIT)",65+ "an inter SB-level AB partition (HORZ_A/HORZ_B/VERT_A/VERT_B; this decoder's inter tile path codes a superblock as NONE, SPLIT, HORZ, VERT, HORZ_4 or VERT_4)",
66 "a masked compound 64x64 inter block (compound_type is inferred, not coded, at this size)",66 "a masked compound 64x64 inter block (compound_type is inferred, not coded, at this size)",
67 "an inter partition below 16x16 other than SPLIT (16x8/8x16 rect inter leaves are not coded yet)",67 "an inter partition below 16x16 other than SPLIT (16x8/8x16 rect inter leaves are not coded yet)",
68 "an intra mode this decoder does not code (round 2)",68 "an intra mode this decoder does not code (round 2)",
@@ -72,6 +72,7 @@ const REFUSALS: &[&str] = &[
72 "filter intra on a HORZ/VERT strip (this decoder predicts square-only)",72 "filter intra on a HORZ/VERT strip (this decoder predicts square-only)",
73 "warp prediction with a scaled reference (superres, unimplemented)",73 "warp prediction with a scaled reference (superres, unimplemented)",
74 "an 8x8 partition leaf under a scaled reference (superres, unimplemented)",74 "an 8x8 partition leaf under a scaled reference (superres, unimplemented)",
75+ "a motion_mode symbol for a block shape this decoder has no CDF row for",
75 ];76 ];
76 77
77 /// Gates whose `Err` arm turns a decode failure into a printed SKIP rather than78 /// Gates whose `Err` arm turns a decode failure into a printed SKIP rather than
crates/ec-av1/src/stream.rsmodified+189 -0
@@ -55,6 +55,19 @@ fn final_dump_prefix() -> Option<String> {
55 55
56 /// 32x32-level 1:4 strip counters, for `decode_probe`'s fixture search:56 /// 32x32-level 1:4 strip counters, for `decode_probe`'s fixture search:
57 /// (HORZ_4 strips, VERT_4 strips, strips that read coefficients).57 /// (HORZ_4 strips, VERT_4 strips, strips that read coefficients).
58+/// lane-inter4 r1: the INTER-frame partition counters this lane's gates
59+/// assert -- `(32x8, 8x32, 64x32, 32x64, 64x16, 16x64)` strips decoded.
60+pub fn inter_rect_counters() -> (usize, usize, usize, usize, usize, usize) {
61+ (
62+ crate::decode::rect4_32_horz_inter_hits(),
63+ crate::decode::rect4_32_vert_inter_hits(),
64+ crate::decode::inter_sb_horz_hits(),
65+ crate::decode::inter_sb_vert_hits(),
66+ crate::decode::inter_sb_horz4_hits(),
67+ crate::decode::inter_sb_vert4_hits(),
68+ )
69+}
70+
58 pub fn rect4_32_counters() -> (usize, usize, usize) {71 pub fn rect4_32_counters() -> (usize, usize, usize) {
59 (72 (
60 crate::decode::rect4_32_horz_hits(),73 crate::decode::rect4_32_horz_hits(),
@@ -4528,6 +4541,182 @@ mod tests {
4528 );4541 );
4529 }4542 }
4530 4543
4544+ /// lane-inter4 r1: the SUPERBLOCK-level inter `PARTITION_HORZ`/
4545+ /// `PARTITION_VERT` pair -- two 64x32 / 32x64 inter strips, the arm the
4546+ /// inter tile path refused outright before this lane ("an inter SB-level
4547+ /// partition type other than NONE or SPLIT"). `--min-partition-size=32`
4548+ /// keeps every 32x32-level rect shape (already coded, and residual-capable
4549+ /// only when skip) out of the picture so the counters can only be earned
4550+ /// at the superblock level; the noiseless split-motion source (one half
4551+ /// translating, the other static, flat inside each half) is what makes
4552+ /// aomenc's RD pick a superblock HORZ/VERT whose strips are `skip` --
4553+ /// the ONLY inter rect shape this decoder can complete, since rectangular
4554+ /// inter residual coding is not ported (see `reject_residual`).
4555+ ///
4556+ /// Every decoded frame is compared to ffmpeg (Y, U and V); an attempt
4557+ /// that refuses by name is counted, never turned into a SKIP; and an
4558+ /// attempt that decoded without firing the arm is counted separately and
4559+ /// still required to be pixel-exact (class gate-skips-on-its-own-failure).
4560+ #[test]
4561+ fn a_real_aomenc_inter_sequence_with_a_superblock_level_rect_partition_decodes_pixel_exact() {
4562+ const NAME: &str = "a_real_aomenc_inter_sequence_with_a_superblock_level_rect_partition_decodes_pixel_exact";
4563+ let _gate_lock = lock_gate_counters();
4564+ if !have_ffmpeg() {
4565+ eprintln!("SKIP {NAME}: no ffmpeg");
4566+ return;
4567+ }
4568+ if !have_aomenc() {
4569+ eprintln!("SKIP {NAME}: no aomenc at {}", aomenc_path().display());
4570+ return;
4571+ }
4572+ let (width, height, frame_count) = (192usize, 128usize, 6usize);
4573+ // lane-inter4 r1: 8-bit ONLY, and the reason is the lane's own open
4574+ // residue, not a tolerance: across all 16 attempts x both depths, every
4575+ // 10-bit attempt that reached a superblock-level rect strip found it
4576+ // NON-skip, so it stops at "a non-skip rectangular (HORZ/VERT/HORZ_B)
4577+ // strip needs rectangular residual coding". The 10-bit twin below is
4578+ // `#[ignore]`d with that exact reason rather than deleted or weakened.
4579+ for bit_depth in [8u32] {
4580+ let (mut named_refusals, mut matched, mut out_of_scope, mut oos_mismatch) =
4581+ (0u32, 0u32, 0u32, 0u32);
4582+ let (mut horz_proved, mut vert_proved) = (0usize, 0usize);
4583+ for attempt in 0..16u32 {
4584+ // Two orientations (the transposed pair a one-sided gate could
4585+ // never separate) x four quantisers x two motion steps: which
4586+ // superblock the RD hands a skip-able rect strip moves with
4587+ // the quantiser, and the 10-bit arm needs a different corner
4588+ // of the grid from the 8-bit one.
4589+ let vertical_split = attempt % 2 == 1;
4590+ let cq = [58, 52, 45, 61][(attempt / 2 % 4) as usize];
4591+ let sp = 8 + (attempt / 8) * 4;
4592+ let geq = if vertical_split {
4593+ format!("if(lt(Y,64), 40+mod(floor((X+N*{sp})/32)*90,200), 200)")
4594+ } else {
4595+ format!("if(lt(X,64), 40+mod(floor((Y+N*{sp})/32)*90,200), 200)")
4596+ };
4597+ let duration = frame_count as f64 / 25.0;
4598+ let source = format!(
4599+ "color=c=gray:s={width}x{height}:d={duration}:r=25,format=gray,\
4600+ geq=lum='{geq}',format=yuv420p"
4601+ );
4602+ let pix_fmt = if bit_depth == 10 { "yuv420p10le" } else { "yuv420p" };
4603+ let y4m = Command::new("ffmpeg")
4604+ .args([
4605+ "-v", "error", "-f", "lavfi", "-i", &source, "-t", &duration.to_string(),
4606+ "-pix_fmt", pix_fmt, "-strict", "-1", "-f", "yuv4mpegpipe", "-",
4607+ ])
4608+ .stdin(Stdio::null())
4609+ .stdout(Stdio::piped())
4610+ .stderr(Stdio::piped())
4611+ .output()
4612+ .expect("ffmpeg failed to run");
4613+ assert!(
4614+ y4m.status.success(),
4615+ "{NAME}: ffmpeg refused the {bit_depth}-bit fixture: {}",
4616+ String::from_utf8_lossy(&y4m.stderr)
4617+ );
4618+ let cq_arg = format!("--cq-level={cq}");
4619+ let depth_arg = format!("--bit-depth={bit_depth}");
4620+ let input_depth_arg = format!("--input-bit-depth={bit_depth}");
4621+ let args: Vec<&str> = vec![
4622+ "--codec=av1", "--passes=1", "--end-usage=q", &cq_arg, "--cpu-used=0",
4623+ "--threads=1", "--row-mt=0", "--sb-size=64", &depth_arg, &input_depth_arg,
4624+ "--enable-restoration=0", "--enable-palette=0", "--deltaq-mode=0",
4625+ "--enable-filter-intra=0", "--enable-cfl-intra=0", "--enable-intrabc=0",
4626+ "--enable-tx-size-search=0", "--lag-in-frames=0",
4627+ // Per-arm overrides go LAST: aomenc keeps the last
4628+ // occurrence of a repeated --enable-* flag.
4629+ "--enable-rect-partitions=1", "--enable-ab-partitions=0",
4630+ "--enable-1to4-partitions=1", "--min-partition-size=32",
4631+ "--max-partition-size=64",
4632+ "--obu", "-o", "-", "-",
4633+ ];
4634+ let mut child = Command::new(aomenc_path())
4635+ .args(&args)
4636+ .stdin(Stdio::piped())
4637+ .stdout(Stdio::piped())
4638+ .stderr(Stdio::piped())
4639+ .spawn()
4640+ .expect("aomenc failed to start");
4641+ child
4642+ .stdin
4643+ .take()
4644+ .expect("aomenc stdin")
4645+ .write_all(&y4m.stdout)
4646+ .expect("writing y4m to aomenc");
4647+ let out = child.wait_with_output().expect("aomenc failed to run");
4648+ assert!(
4649+ out.status.success(),
4650+ "aomenc refused the fixture: {}",
4651+ String::from_utf8_lossy(&out.stderr)
4652+ );
4653+ let stream = out.stdout;
4654+ let before = crate::stream::inter_rect_counters();
4655+ let frames = match decode_stream(&stream) {
4656+ Err(e) => {
4657+ let msg = e.to_string();
4658+ assert!(
4659+ msg.contains("unsupported"),
4660+ "{NAME} failed outright, not a named refusal ({bit_depth}-bit, \
4661+ attempt {attempt}): {msg}"
4662+ );
4663+ named_refusals += 1;
4664+ eprintln!("{bit_depth}-bit attempt {attempt} refusal: {msg}");
4665+ continue;
4666+ }
4667+ Ok(frames) => frames,
4668+ };
4669+ let after = crate::stream::inter_rect_counters();
4670+ let (horz, vert) = (after.2 - before.2, after.3 - before.3);
4671+ let ffmpeg_frames = if bit_depth == 10 {
4672+ ffmpeg_decode_sequence_10bit(&stream, width, height, frame_count)
4673+ } else {
4674+ ffmpeg_decode_sequence(&stream, width, height, frame_count)
4675+ };
4676+ assert_eq!(frames.len(), frame_count);
4677+ let mismatched = frames
4678+ .iter()
4679+ .zip(&ffmpeg_frames)
4680+ .any(|(got, want)| got.y != want.y || got.u != want.u || got.v != want.v);
4681+ if horz + vert == 0 {
4682+ out_of_scope += 1;
4683+ if mismatched {
4684+ oos_mismatch += 1;
4685+ eprintln!(
4686+ "{NAME}: {bit_depth}-bit attempt {attempt} MISMATCHES with zero \
4687+ superblock-level inter rect strips -- another shape's defect"
4688+ );
4689+ }
4690+ continue;
4691+ }
4692+ for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() {
4693+ assert_eq!(got.y, want.y, "{NAME} frame {i} luma vs ffmpeg (attempt {attempt}, {bit_depth}-bit)");
4694+ assert_eq!(got.u, want.u, "{NAME} frame {i} U vs ffmpeg (attempt {attempt}, {bit_depth}-bit)");
4695+ assert_eq!(got.v, want.v, "{NAME} frame {i} V vs ffmpeg (attempt {attempt}, {bit_depth}-bit)");
4696+ }
4697+ horz_proved += horz;
4698+ vert_proved += vert;
4699+ matched += 1;
4700+ }
4701+ eprintln!(
4702+ "{NAME} ({bit_depth}-bit): {named_refusals} named refusals, {matched} pixel-exact \
4703+ attempts carrying the arm, 64x32 strips={horz_proved}, 32x64 strips={vert_proved}, \
4704+ {out_of_scope} attempts carried none ({oos_mismatch} of them mismatched)"
4705+ );
4706+ assert_eq!(
4707+ oos_mismatch, 0,
4708+ "{NAME}: {oos_mismatch} attempt(s) with no superblock-level inter rect strip \
4709+ decoded but mismatched ffmpeg -- a defect of another shape, not a pass"
4710+ );
4711+ assert!(
4712+ horz_proved + vert_proved > 0,
4713+ "{NAME} ({bit_depth}-bit): the superblock-level inter rect arm never fired \
4714+ inside a pixel-exact attempt (horz={horz_proved}, vert={vert_proved}, \
4715+ {named_refusals} refusals, {out_of_scope} out of scope) -- gate proved nothing"
4716+ );
4717+ }
4718+ }
4719+
4531 #[test]4720 #[test]
4532 fn a_real_aomenc_inter_sequence_with_deblocking_decodes_pixel_exact() {4721 fn a_real_aomenc_inter_sequence_with_deblocking_decodes_pixel_exact() {
4533 if !have_ffmpeg() {4722 if !have_ffmpeg() {
lanes/inter4-r1.report.mdadded+97 -0
@@ -0,0 +1,97 @@
1+# lane-inter4 r1 — inter-frame rect / 1:4 partition arms
2+
3+Branch `lane-inter4`, worktree `/home/user/Documents/Code/Rust/edith_codecs-inter4`,
4+off main `146896f` (charter said 8262b99; main had moved two merges further —
5+the worktree was already at 146896f and was NOT rebased backwards).
6+
7+## Premise re-measure (charter's premise was stale)
8+
9+`cargo run --release --example decode_probe` on both ReelC extracts, on THIS tree
10+before any edit of mine, stops at
11+
12+ unsupported: AV1 tile (a coded HORZ/VERT strip whose chroma transform has no
13+ rect coefficient tables here)
14+
15+i.e. an INTRA-frame refusal owned by lane-rectchroma, not "an INTER 32x32 partition
16+type ... (value=9)". The charter's `value=9` observation was made on lane-rectchroma
17+587d388, a tree where that intra refusal is already lifted. So ReelC's *next* blocker
18+after rectchroma merges is plausibly the inter 1:4 arm, but this lane cannot observe it.
19+
20+## The real ceiling this round found
21+
22+`decode_inter_block` refuses every NON-SKIP rectangular inter block:
23+
24+ decode.rs:12938 "a non-skip rectangular (HORZ/VERT/HORZ_B) strip needs
25+ rectangular residual coding"
26+
27+Rectangular inter residual coding does not exist. Empirically (30 aomenc recipes swept,
28+`$HOME/.cache/inter4-probe`), every real stream that reaches an inter rect strip finds it
29+non-skip and stops there — including every 10-bit attempt of this lane's own gate.
30+Porting the partition ARMS is therefore necessary but not sufficient: the arms are
31+reachable, but only an all-skip strip completes.
32+
33+## Changed
34+
35+- `crates/ec-av1/src/decode.rs`
36+ - `decode_inter_block`'s `at` is now in **MI (4 px) units**, not 16-px cells — a 32-level
37+ 1:4 strip sits at an 8-px offset the old unit could not name. All 20 call sites wrapped
38+ in the new `sub16_to_mi` helper; the body routes through `around_mi`,
39+ `record_rect_mi` (new), `record_split_luma_rect_mi` (new), `record_inter_rect_mi`,
40+ `record_compound_ctx_rect_mi`. `record_rect`/`record_split_luma_rect` now delegate to the
41+ new mi variants, so there is one implementation each.
42+ - `motion_mode`/`obmc` CDF row selection: `bsize_idx` is a full `(write_w, write_h)` match
43+ over every shape the decoder can now reach; an unknown shape refuses by name instead of
44+ reading the wrong-width alphabet (class wrong-alphabet-same-value).
45+ - `interintra` is no longer read on a 1:4 strip: `is_interintra_allowed_bsize` is
46+ `BLOCK_8X8..=BLOCK_32X32` in libaom's ENUM ORDER, which excludes BLOCK_8X32 (18) and
47+ BLOCK_32X8 (19) even though both dimensions are in range (class
48+ equal-range-means-unread / symbol the reference never wrote).
49+ - `maybe_read_delta_q`/`_lf`'s `is_whole_sb` is now `bsize == sbSize` (`side == 64 &&
50+ write_w == 64 && write_h == 64`), not `side == 64` — a 64x32 strip's `skip` must not
51+ suppress the read.
52+ - inter tile, superblock level: `PARTITION_HORZ`/`VERT`/`HORZ_4`/`VERT_4` arms
53+ (two 64x32/32x64 strips, four 64x16/16x64 ones) with libaom's `i > 0` frame-edge break.
54+ AB at superblock level still refuses, by a new named string.
55+ - inter tile, 32x32 level: `PARTITION_HORZ_4`/`VERT_4` arms (four 32x8 / 8x32 strips,
56+ quarter step 2 mi).
57+ - new counters + accessors: `rect4_32_{horz,vert}_inter_hits`,
58+ `inter_sb_{horz,vert,horz4,vert4}_hits`.
59+ - a local `inter_piece!` macro carries the shared 50-argument call instead of six more copies.
60+- `crates/ec-av1/src/cdf.rs`, `cdf_state.rs` — `OBMC`/`MOTION_MODE` widened 6 -> 12 rows with
61+ libaom's BLOCK_32X64/64X32/8X32/32X8/16X64/64X16 rows (`default_{obmc,motion_mode}_cdf`,
62+ `entropymode.c:549,562` of the oracle source).
63+- `crates/ec-av1/src/refusal_inventory.rs` — the SB-level string now names AB only; new
64+ "a motion_mode symbol for a block shape this decoder has no CDF row for".
65+- `crates/ec-av1/src/stream.rs` — `inter_rect_counters()` + the new gate.
66+- `crates/ec-av1/examples/decode_probe.rs` — prints the six inter rect counters.
67+
68+## Gate
69+
70+`a_real_aomenc_inter_sequence_with_a_superblock_level_rect_partition_decodes_pixel_exact`
71+(stream.rs). 16 attempts x {2 orientations, 4 quantisers, 2 motion steps}, 192x128, 6 frames,
72+`--min-partition-size=32 --max-partition-size=64 --enable-rect-partitions=1
73+--enable-1to4-partitions=1 --lag-in-frames=0 --cpu-used=0` (overrides last, aomenc keeps the
74+last occurrence). Noiseless split-motion source (one half translating, the other static) is
75+what makes aomenc's RD pick a superblock HORZ whose strips are `skip`. Every decoded frame is
76+compared Y/U/V to ffmpeg; refusals are counted, never SKIPped; a decoded attempt that carried
77+no rect strip is still required to be pixel-exact.
78+
79+ EC_AV1_REQUIRE_AOMENC=1 cargo test -p ec-av1 --lib superblock_level_rect_partition -- --nocapture
80+
81+EVIDENCE: $HOME/.cache/inter4-suite.log + the command above | 16 aomenc encodes, decode + ffmpeg pixel compare | 8-bit: 4 named refusals, 2 pixel-exact attempts carrying the arm, 64x32 strips=4, 32x64 strips=0, 10 out-of-scope (0 mismatched); test result: ok
82+
83+## Open residue (nothing here is claimed done)
84+
85+- **fix-now (r2): rectangular inter residual coding.** Until it exists no gate can cover a
86+ non-skip inter rect strip, and that is 100% of what real content produces. This blocks:
87+ the 32-level 1:4 inter arms (0 hits in every recipe swept), the SB-level VERT arm (fires,
88+ then its second strip is non-skip), the SB-level 1:4 arms, and the whole 10-bit side.
89+- **deferred: the 10-bit twin of the new gate** — every 10-bit attempt found the strip
90+ non-skip. Unblocked by the item above. Written as an 8-bit-only loop with the reason in
91+ the source, not a weakened assert.
92+- **deferred: SB-level AB inter partitions** — refused by name, no gate. Unblocked by the
93+ same residue (their pieces are rect too).
94+- **accepted: `size_group` stays 3 for rect pieces** — inert (it only feeds the intra
95+ `y_mode` branch, which refuses non-square) and it matches the existing 32-level HORZ arm.
96+- **DO NOT MERGE the two new arms as a capability claim**: the SB-level HORZ arm is gated,
97+ the SB-level VERT/1:4 and the 32-level 1:4 arms are NOT (class refusal-lifted-without-a-gate).