Merge branch 'lane-inter4': inter superblock/32-level rect and 1:4 partition arms, 16x8/8x16 inter leaves with rectangular residual coding, motion field walks both reference slots (temporal MV candidates were wrong)
Browse files at this commit12 changed files +2642 -121
- crates/ec-av1/examples/decode_probe.rs +7 -0
- crates/ec-av1/src/cdf.rs +28 -2
- crates/ec-av1/src/cdf_state.rs +66 -2
- crates/ec-av1/src/decode.rs +1098 -114
- crates/ec-av1/src/motion_field.rs +11 -1
- crates/ec-av1/src/refusal_inventory.rs +3 -2
- crates/ec-av1/src/stream.rs +808 -0
- lanes/inter4-r1.report.md +97 -0
- lanes/inter4-r2.report.md +128 -0
- lanes/inter4-r3.report.md +125 -0
- lanes/inter4-r4.report.md +142 -0
- lanes/interbis-r1.report.md +129 -0
crates/ec-av1/examples/decode_probe.rsmodified+7 -0
| @@ -31,6 +31,13 @@ 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 (rtu, rsplit, robmc) = ec_av1::stream::rect_inter_tu_counters(); | ||
| 35 | + println!("rect_inter: tu={rtu} txsplit={rsplit} obmc_leaf={robmc}"); | ||
| 36 | + let ir = ec_av1::stream::inter_rect_counters(); | ||
| 37 | + println!( | ||
| 38 | + "inter_rect: 32x8={} 8x32={} 64x32={} 32x64={} 64x16={} 16x64={}", | ||
| 39 | + ir.0, ir.1, ir.2, ir.3, ir.4, ir.5 | ||
| 40 | + ); | ||
| 34 | }; | 41 | }; |
| 35 | // lane-tiles: the tiling a real stream actually uses is a decision input | 42 | // lane-tiles: the tiling a real stream actually uses is a decision input |
| 36 | // (every gate in `stream.rs` picks its own `--tile-columns`), so report it | 43 | // (every gate in `stream.rs` picks its own `--tile-columns`), so report it |
crates/ec-av1/src/cdf.rsmodified+28 -2
| @@ -1628,7 +1628,7 @@ pub const SKIP_MODE: [[u16; 3]; 3] = [[32621, 32768, 0], [20708, 32768, 0], [812 | |||
| 1628 | /// `motion_mode_allowed` (spec 5.11.24's `read_motion_mode`) offers | 1628 | /// `motion_mode_allowed` (spec 5.11.24's `read_motion_mode`) offers |
| 1629 | /// `OBMC_CAUSAL` rather than `WARPED_CAUSAL` -- lane-motionmode round 1 | 1629 | /// `OBMC_CAUSAL` rather than `WARPED_CAUSAL` -- lane-motionmode round 1 |
| 1630 | /// never reaches the three-way `motion_mode_cdf`, see `decode.rs`. | 1630 | /// never reaches the three-way `motion_mode_cdf`, see `decode.rs`. |
| 1631 | -pub const OBMC: [[u16; 3]; 6] = [ | 1631 | +pub const OBMC: [[u16; 3]; 14] = [ |
| 1632 | [10437, 32768, 0], | 1632 | [10437, 32768, 0], |
| 1633 | [17432, 32768, 0], | 1633 | [17432, 32768, 0], |
| 1634 | [25817, 32768, 0], | 1634 | [25817, 32768, 0], |
| @@ -1638,6 +1638,20 @@ pub const OBMC: [[u16; 3]; 6] = [ | |||
| 1638 | // (rect-flake-1: the strip's motion_mode read diverged on this). | 1638 | // (rect-flake-1: the strip's motion_mode read diverged on this). |
| 1639 | [14423, 32768, 0], | 1639 | [14423, 32768, 0], |
| 1640 | [15142, 32768, 0], | 1640 | [15142, 32768, 0], |
| 1641 | + // lane-inter4 r1: the rect rows a superblock-level HORZ/VERT/1:4 and a | ||
| 1642 | + // 32x32-level 1:4 inter strip read -- BLOCK_32X64 (10), BLOCK_64X32 (11), | ||
| 1643 | + // BLOCK_8X32 (18), BLOCK_32X8 (19), BLOCK_16X64 (20), BLOCK_64X16 (21) of | ||
| 1644 | + // libaom's `default_obmc_cdf`. | ||
| 1645 | + [22823, 32768, 0], | ||
| 1646 | + [22083, 32768, 0], | ||
| 1647 | + [23664, 32768, 0], | ||
| 1648 | + [20901, 32768, 0], | ||
| 1649 | + [24008, 32768, 0], | ||
| 1650 | + [26879, 32768, 0], | ||
| 1651 | + // lane-inter4 r3: the 16x16-level rect inter leaves' own rows -- | ||
| 1652 | + // BLOCK_8X16 (4) and BLOCK_16X8 (5) of libaom's `default_obmc_cdf`. | ||
| 1653 | + [9371, 32768, 0], | ||
| 1654 | + [9301, 32768, 0], | ||
| 1641 | ]; | 1655 | ]; |
| 1642 | 1656 | ||
| 1643 | /// `default_motion_mode_cdf` (spec 9.4, `entropymode.c`), the square-bsize | 1657 | /// `default_motion_mode_cdf` (spec 9.4, `entropymode.c`), the square-bsize |
| @@ -1647,7 +1661,7 @@ pub const OBMC: [[u16; 3]; 6] = [ | |||
| 1647 | /// `read_motion_mode` reads instead of [`OBMC`] whenever `motion_mode_allowed` | 1661 | /// `read_motion_mode` reads instead of [`OBMC`] whenever `motion_mode_allowed` |
| 1648 | /// (spec 5.11.24) resolves to `WARPED_CAUSAL`-eligible (`num_proj_ref >= 1` | 1662 | /// (spec 5.11.24) resolves to `WARPED_CAUSAL`-eligible (`num_proj_ref >= 1` |
| 1649 | /// under `allow_warped_motion`) -- lane-warp round 1. | 1663 | /// under `allow_warped_motion`) -- lane-warp round 1. |
| 1650 | -pub const MOTION_MODE: [[u16; 4]; 6] = [ | 1664 | +pub const MOTION_MODE: [[u16; 4]; 14] = [ |
| 1651 | [7651, 24760, 32768, 0], | 1665 | [7651, 24760, 32768, 0], |
| 1652 | [19419, 26810, 32768, 0], | 1666 | [19419, 26810, 32768, 0], |
| 1653 | [26260, 29116, 32768, 0], | 1667 | [26260, 29116, 32768, 0], |
| @@ -1655,6 +1669,18 @@ pub const MOTION_MODE: [[u16; 4]; 6] = [ | |||
| 1655 | // lane-rect r2: BLOCK_16X32 / BLOCK_32X16 rows (indices 7/8). | 1669 | // lane-rect r2: BLOCK_16X32 / BLOCK_32X16 rows (indices 7/8). |
| 1656 | [5123, 23606, 32768, 0], | 1670 | [5123, 23606, 32768, 0], |
| 1657 | [11606, 24308, 32768, 0], | 1671 | [11606, 24308, 32768, 0], |
| 1672 | + // lane-inter4 r1: BLOCK_32X64 / 64X32 / 8X32 / 32X8 / 16X64 / 64X16 rows | ||
| 1673 | + // (libaom `default_motion_mode_cdf` indices 10, 11, 18, 19, 20, 21). | ||
| 1674 | + [20360, 28062, 32768, 0], | ||
| 1675 | + [21679, 26830, 32768, 0], | ||
| 1676 | + [28799, 31390, 32768, 0], | ||
| 1677 | + [26431, 30774, 32768, 0], | ||
| 1678 | + [28973, 31594, 32768, 0], | ||
| 1679 | + [29742, 31203, 32768, 0], | ||
| 1680 | + // lane-inter4 r3: BLOCK_8X16 / BLOCK_16X8 rows (libaom | ||
| 1681 | + // `default_motion_mode_cdf` indices 4 and 5). | ||
| 1682 | + [4738, 24765, 32768, 0], | ||
| 1683 | + [5391, 25528, 32768, 0], | ||
| 1658 | ]; | 1684 | ]; |
| 1659 | 1685 | ||
| 1660 | /// `default_interintra_cdf` (spec 9.4): `interintra`, indexed by | 1686 | /// `default_interintra_cdf` (spec 9.4): `interintra`, indexed by |
crates/ec-av1/src/cdf_state.rsmodified+66 -2
| @@ -119,6 +119,16 @@ pub(crate) enum TxbSet { | |||
| 119 | /// [`LumaRect32x16`](TxbSet::LumaRect32x16) has none). | 119 | /// [`LumaRect32x16`](TxbSet::LumaRect32x16) has none). |
| 120 | LumaRect32x8, | 120 | LumaRect32x8, |
| 121 | LumaRect32x16, | 121 | LumaRect32x16, |
| 122 | + /// lane-inter4 r2: [`LumaRect32x16`](TxbSet::LumaRect32x16)'s INTER twin -- | ||
| 123 | + /// same coefficient tables (`get_txsize_entropy_ctx` reduces TX_32X16 and | ||
| 124 | + /// TX_16X32 alike to the 32x32 set, 512-coefficient `eob_pt`), but an | ||
| 125 | + /// inter block DOES code a `tx_type` symbol here: `av1_get_ext_tx_set_type` | ||
| 126 | + /// with `tx_size_sqr_up == TX_32X32` and `is_inter` returns | ||
| 127 | + /// `EXT_TX_SET_DCT_IDTX` (2 symbols), whose CDF is | ||
| 128 | + /// `default_inter_ext_tx_cdf[3][txsize_sqr_map[TX_32X16] == TX_16X16]`, | ||
| 129 | + /// i.e. exactly [`INTER_TX_TYPE_SET3_16`](crate::cdf::INTER_TX_TYPE_SET3_16) | ||
| 130 | + /// -- the same table the square `Luma16Inter` set reads. | ||
| 131 | + LumaRect32x16Inter, | ||
| 122 | /// The chroma 16x8/8x16 transform under the same strip (lane-rectwire): | 132 | /// The chroma 16x8/8x16 transform under the same strip (lane-rectwire): |
| 123 | /// [`Chroma16`](TxbSet::Chroma16)'s tables except `eob_pt`, which reads | 133 | /// [`Chroma16`](TxbSet::Chroma16)'s tables except `eob_pt`, which reads |
| 124 | /// the true 128-position [`crate::cdf::EOB_PT_128_CHROMA`] instead of | 134 | /// the true 128-position [`crate::cdf::EOB_PT_128_CHROMA`] instead of |
| @@ -165,6 +175,24 @@ pub(crate) enum TxbSet { | |||
| 165 | /// 16x16 row's five-symbol reduced CDF here and desynced on the very | 175 | /// 16x16 row's five-symbol reduced CDF here and desynced on the very |
| 166 | /// first coded rect leaf. | 176 | /// first coded rect leaf. |
| 167 | LumaRect16x8Set1, | 177 | LumaRect16x8Set1, |
| 178 | + /// lane-inter4 r3: [`LumaRect16x8`](TxbSet::LumaRect16x8)'s INTER twin -- | ||
| 179 | + /// the same coefficient tables (`get_txsize_entropy_ctx` reduces TX_16X8 | ||
| 180 | + /// and TX_8X16 alike to the 16x16 set, 128-position `eob_pt`), with the | ||
| 181 | + /// inter `tx_type` alphabet in place of the intra one. Under | ||
| 182 | + /// `reduced_tx_set` `av1_get_ext_tx_set_type` (`tx_size_sqr_up == | ||
| 183 | + /// TX_16X16`, `is_inter`) returns `EXT_TX_SET_DCT_IDTX` (2 symbols), | ||
| 184 | + /// whose CDF row is `default_inter_ext_tx_cdf[1][txsize_sqr_map[TX_16X8] | ||
| 185 | + /// == TX_8X8]`, i.e. [`INTER_TX_TYPE_SET3_8`](crate::cdf::INTER_TX_TYPE_SET3_8) | ||
| 186 | + /// -- the same table the square `Luma8Inter` set reads. | ||
| 187 | + LumaRect16x8Inter, | ||
| 188 | + /// [`LumaRect16x8Inter`](TxbSet::LumaRect16x8Inter)'s `reduced_tx_set: | ||
| 189 | + /// false` counterpart: `tx_size_sqr` is `TX_8X8` here (NOT the | ||
| 190 | + /// `txsize_sqr_up_map` `TX_16X16` the coefficient tables use), so | ||
| 191 | + /// `av1_ext_tx_set_lookup[is_inter=1][tx_size_sqr == TX_16X16 -> 0]` is | ||
| 192 | + /// `EXT_TX_SET_ALL16` -- sixteen symbols, `default_inter_ext_tx_cdf[1] | ||
| 193 | + /// [TX_8X8]`, i.e. [`INTER_TX_TYPE_SET1_8`](crate::cdf::INTER_TX_TYPE_SET1_8), | ||
| 194 | + /// the table [`Luma8InterSet1`](TxbSet::Luma8InterSet1) also reads. | ||
| 195 | + LumaRect16x8InterSet1, | ||
| 168 | /// The chroma 8x4/4x8 transform under the same leaf (lane-rectx): | 196 | /// The chroma 8x4/4x8 transform under the same leaf (lane-rectx): |
| 169 | /// [`Chroma8`](TxbSet::Chroma8)'s tables except `eob_pt`, which reads the | 197 | /// [`Chroma8`](TxbSet::Chroma8)'s tables except `eob_pt`, which reads the |
| 170 | /// true 32-position [`crate::cdf::EOB_PT_32_CHROMA`] instead of | 198 | /// true 32-position [`crate::cdf::EOB_PT_32_CHROMA`] instead of |
| @@ -473,13 +501,13 @@ pub(crate) struct Cdfs { | |||
| 473 | /// `BLOCK_8X8`, 1 = `BLOCK_16X16`, 2 = `BLOCK_32X32`, 3 = `BLOCK_64X64` | 501 | /// `BLOCK_8X8`, 1 = `BLOCK_16X16`, 2 = `BLOCK_32X32`, 3 = `BLOCK_64X64` |
| 474 | /// (`default_obmc_cdf`'s own `BLOCK_SIZES_ALL` indices 3/6/9/12 -- | 502 | /// (`default_obmc_cdf`'s own `BLOCK_SIZES_ALL` indices 3/6/9/12 -- |
| 475 | /// this decoder only ever codes those four square sizes). | 503 | /// this decoder only ever codes those four square sizes). |
| 476 | - pub obmc: [[u16; 3]; 6], | 504 | + pub obmc: [[u16; 3]; 14], |
| 477 | /// `motion_mode` (spec 5.11.24's `read_motion_mode`), the 3-symbol | 505 | /// `motion_mode` (spec 5.11.24's `read_motion_mode`), the 3-symbol |
| 478 | /// `SIMPLE_TRANSLATION`/`OBMC_CAUSAL`/`WARPED_CAUSAL` alphabet read | 506 | /// `SIMPLE_TRANSLATION`/`OBMC_CAUSAL`/`WARPED_CAUSAL` alphabet read |
| 479 | /// instead of [`Self::obmc`] whenever `motion_mode_allowed` resolves to | 507 | /// instead of [`Self::obmc`] whenever `motion_mode_allowed` resolves to |
| 480 | /// `WARPED_CAUSAL`-eligible -- same square-bsize indexing as `obmc`. | 508 | /// `WARPED_CAUSAL`-eligible -- same square-bsize indexing as `obmc`. |
| 481 | /// lane-warp round 1. | 509 | /// lane-warp round 1. |
| 482 | - pub motion_mode: [[u16; 4]; 6], | 510 | + pub motion_mode: [[u16; 4]; 14], |
| 483 | /// `interintra`, indexed by `size_group_lookup[bsize]` -- see | 511 | /// `interintra`, indexed by `size_group_lookup[bsize]` -- see |
| 484 | /// `cdf::INTERINTRA`'s own doc. | 512 | /// `cdf::INTERINTRA`'s own doc. |
| 485 | pub interintra: [[u16; 3]; 4], | 513 | pub interintra: [[u16; 3]; 4], |
| @@ -1683,6 +1711,18 @@ impl Cdfs { | |||
| 1683 | tx_type: None, | 1711 | tx_type: None, |
| 1684 | eob_pt_class1: Some(&mut self.eob_pt_256_luma_class1), | 1712 | eob_pt_class1: Some(&mut self.eob_pt_256_luma_class1), |
| 1685 | }, | 1713 | }, |
| 1714 | + TxbSet::LumaRect32x16Inter => TxbTables { | ||
| 1715 | + side: 32, | ||
| 1716 | + txb_skip: &mut self.txb_skip_luma_32, | ||
| 1717 | + eob_pt: &mut self.eob_pt_512_luma, | ||
| 1718 | + eob_extra: &mut self.eob_extra_luma_32, | ||
| 1719 | + base: &mut self.base_luma_32, | ||
| 1720 | + base_eob: &mut self.base_eob_luma_32, | ||
| 1721 | + br: &mut self.br_luma_32, | ||
| 1722 | + dc_sign: &mut self.dc_sign_luma, | ||
| 1723 | + tx_type: Some(self.inter_tx_type_16.as_mut_slice()), | ||
| 1724 | + eob_pt_class1: Some(&mut self.eob_pt_512_luma_class1), | ||
| 1725 | + }, | ||
| 1686 | TxbSet::LumaRect32x16 => TxbTables { | 1726 | TxbSet::LumaRect32x16 => TxbTables { |
| 1687 | side: 32, | 1727 | side: 32, |
| 1688 | txb_skip: &mut self.txb_skip_luma_32, | 1728 | txb_skip: &mut self.txb_skip_luma_32, |
| @@ -1767,6 +1807,30 @@ impl Cdfs { | |||
| 1767 | tx_type: Some(self.intra_tx_type_8_set1[mode].as_mut_slice()), | 1807 | tx_type: Some(self.intra_tx_type_8_set1[mode].as_mut_slice()), |
| 1768 | eob_pt_class1: Some(&mut self.eob_pt_128_luma_class1), | 1808 | eob_pt_class1: Some(&mut self.eob_pt_128_luma_class1), |
| 1769 | }, | 1809 | }, |
| 1810 | + TxbSet::LumaRect16x8Inter => TxbTables { | ||
| 1811 | + side: 16, | ||
| 1812 | + txb_skip: &mut self.txb_skip_luma_16, | ||
| 1813 | + eob_pt: &mut self.eob_pt_128_luma, | ||
| 1814 | + eob_extra: &mut self.eob_extra_luma_16, | ||
| 1815 | + base: &mut self.base_luma_16, | ||
| 1816 | + base_eob: &mut self.base_eob_luma_16, | ||
| 1817 | + br: &mut self.br_luma_16, | ||
| 1818 | + dc_sign: &mut self.dc_sign_luma, | ||
| 1819 | + tx_type: Some(self.inter_tx_type_8.as_mut_slice()), | ||
| 1820 | + eob_pt_class1: Some(&mut self.eob_pt_128_luma_class1), | ||
| 1821 | + }, | ||
| 1822 | + TxbSet::LumaRect16x8InterSet1 => TxbTables { | ||
| 1823 | + side: 16, | ||
| 1824 | + txb_skip: &mut self.txb_skip_luma_16, | ||
| 1825 | + eob_pt: &mut self.eob_pt_128_luma, | ||
| 1826 | + eob_extra: &mut self.eob_extra_luma_16, | ||
| 1827 | + base: &mut self.base_luma_16, | ||
| 1828 | + base_eob: &mut self.base_eob_luma_16, | ||
| 1829 | + br: &mut self.br_luma_16, | ||
| 1830 | + dc_sign: &mut self.dc_sign_luma, | ||
| 1831 | + tx_type: Some(self.inter_tx_type_8_set1.as_mut_slice()), | ||
| 1832 | + eob_pt_class1: Some(&mut self.eob_pt_128_luma_class1), | ||
| 1833 | + }, | ||
| 1770 | TxbSet::ChromaRect8x4 => TxbTables { | 1834 | TxbSet::ChromaRect8x4 => TxbTables { |
| 1771 | side: 8, | 1835 | side: 8, |
| 1772 | txb_skip: &mut self.txb_skip_chroma_8, | 1836 | txb_skip: &mut self.txb_skip_chroma_8, |
crates/ec-av1/src/decode.rsmodified+1098 -114
| @@ -911,6 +911,15 @@ pub(crate) fn tx_depth_hits() -> usize { | |||
| 911 | thread_local! { | 911 | thread_local! { |
| 912 | static TXFM_SPLIT_READS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | 912 | static TXFM_SPLIT_READS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; |
| 913 | static TXFM_SPLIT_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | 913 | static TXFM_SPLIT_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; |
| 914 | + // lane-inter4 r2: rectangular INTER residual coding -- how many rect | ||
| 915 | + // strips coded one whole-block rect transform unit, and how many split | ||
| 916 | + // their rect max transform into square sub-transforms. | ||
| 917 | + static RECT_INTER_TU_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | ||
| 918 | + static RECT_INTER_TXSPLIT_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | ||
| 919 | + // lane-inter4 r3: 16x16-level PARTITION_HORZ / PARTITION_VERT on an inter | ||
| 920 | + // frame -- 16x8 and 8x16 inter leaves. | ||
| 921 | + static INTER_LEAF16_HORZ_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | ||
| 922 | + static INTER_LEAF16_VERT_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | ||
| 914 | // This frame's own `tx_mode == TxMode::Select` and `reduced_tx_set` bits, | 923 | // This frame's own `tx_mode == TxMode::Select` and `reduced_tx_set` bits, |
| 915 | // set once per inter tile by [`decode_inter_frame_tile_with_cdfs`] -- | 924 | // set once per inter tile by [`decode_inter_frame_tile_with_cdfs`] -- |
| 916 | // `decode_inter_block` already carries forty parameters and both are | 925 | // `decode_inter_block` already carries forty parameters and both are |
| @@ -934,6 +943,26 @@ pub(crate) fn txfm_split_hits() -> usize { | |||
| 934 | TXFM_SPLIT_HITS.with(|c| c.get()) | 943 | TXFM_SPLIT_HITS.with(|c| c.get()) |
| 935 | } | 944 | } |
| 936 | 945 | ||
| 946 | +/// Current value of [`INTER_LEAF16_HORZ_HITS`] (lane-inter4 r3). | ||
| 947 | +pub(crate) fn inter_leaf16_horz_hits() -> usize { | ||
| 948 | + INTER_LEAF16_HORZ_HITS.with(|c| c.get()) | ||
| 949 | +} | ||
| 950 | + | ||
| 951 | +/// Current value of [`INTER_LEAF16_VERT_HITS`] (lane-inter4 r3). | ||
| 952 | +pub(crate) fn inter_leaf16_vert_hits() -> usize { | ||
| 953 | + INTER_LEAF16_VERT_HITS.with(|c| c.get()) | ||
| 954 | +} | ||
| 955 | + | ||
| 956 | +/// Current value of [`RECT_INTER_TU_HITS`] (lane-inter4 r2). | ||
| 957 | +pub(crate) fn rect_inter_tu_hits() -> usize { | ||
| 958 | + RECT_INTER_TU_HITS.with(|c| c.get()) | ||
| 959 | +} | ||
| 960 | + | ||
| 961 | +/// Current value of [`RECT_INTER_TXSPLIT_HITS`] (lane-inter4 r2). | ||
| 962 | +pub(crate) fn rect_inter_txsplit_hits() -> usize { | ||
| 963 | + RECT_INTER_TXSPLIT_HITS.with(|c| c.get()) | ||
| 964 | +} | ||
| 965 | + | ||
| 937 | /// Sets the current thread's [`TX_SELECT_INTER`]/[`REDUCED_TX_SET_INTER`]/ | 966 | /// Sets the current thread's [`TX_SELECT_INTER`]/[`REDUCED_TX_SET_INTER`]/ |
| 938 | /// [`ENABLE_FILTER_INTRA_INTER`]. | 967 | /// [`ENABLE_FILTER_INTRA_INTER`]. |
| 939 | pub(crate) fn set_inter_tx_mode( | 968 | pub(crate) fn set_inter_tx_mode( |
| @@ -1701,6 +1730,19 @@ pub(crate) fn wii_hits() -> usize { | |||
| 1701 | WII_HITS.with(|c| c.get()) | 1730 | WII_HITS.with(|c| c.get()) |
| 1702 | } | 1731 | } |
| 1703 | 1732 | ||
| 1733 | +// lane-inter4 r4: how many 16x8/8x16 INTER LEAVES actually ran the OBMC | ||
| 1734 | +// blend -- the gate's proof that `--enable-obmc=1` reached this shape (the | ||
| 1735 | +// r3 refusal's replacement: prefilt frames are bit-exact vs an instrumented | ||
| 1736 | +// aomdec, neighbour list included). | ||
| 1737 | +thread_local! { | ||
| 1738 | + static OBMC_RECT_LEAF_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | ||
| 1739 | +} | ||
| 1740 | + | ||
| 1741 | +/// Current value of [`OBMC_RECT_LEAF_HITS`]. | ||
| 1742 | +pub(crate) fn obmc_rect_leaf_hits() -> usize { | ||
| 1743 | + OBMC_RECT_LEAF_HITS.with(|c| c.get()) | ||
| 1744 | +} | ||
| 1745 | + | ||
| 1704 | /// Current value of [`OBMC_HITS_8`]. | 1746 | /// Current value of [`OBMC_HITS_8`]. |
| 1705 | pub(crate) fn obmc_hits_8() -> usize { | 1747 | pub(crate) fn obmc_hits_8() -> usize { |
| 1706 | OBMC_HITS_8.with(|c| c.get()) | 1748 | OBMC_HITS_8.with(|c| c.get()) |
| @@ -1935,6 +1977,17 @@ pub(crate) fn sb_rect4_vert_hits() -> usize { | |||
| 1935 | thread_local! { | 1977 | thread_local! { |
| 1936 | static RECT4_32_HORZ_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | 1978 | static RECT4_32_HORZ_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; |
| 1937 | static RECT4_32_VERT_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | 1979 | static RECT4_32_VERT_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; |
| 1980 | + /// lane-inter4 r1: the INTER-frame twins of the two counters above -- | ||
| 1981 | + /// four 32x8 / 8x32 inter strips of a 32x32-level `PARTITION_HORZ_4` / | ||
| 1982 | + /// `PARTITION_VERT_4`. | ||
| 1983 | + static RECT4_32_HORZ_INTER_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | ||
| 1984 | + static RECT4_32_VERT_INTER_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | ||
| 1985 | + /// lane-inter4 r1: superblock-level inter `PARTITION_HORZ`/`PARTITION_VERT` | ||
| 1986 | + /// strips (64x32 / 32x64) and their 1:4 pair (64x16 / 16x64). | ||
| 1987 | + static INTER_SB_HORZ_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | ||
| 1988 | + static INTER_SB_VERT_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | ||
| 1989 | + static INTER_SB_HORZ4_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | ||
| 1990 | + static INTER_SB_VERT4_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | ||
| 1938 | } | 1991 | } |
| 1939 | 1992 | ||
| 1940 | /// How many 32x32-level 1:4 strips actually read coefficients (non-skip): | 1993 | /// How many 32x32-level 1:4 strips actually read coefficients (non-skip): |
| @@ -1983,6 +2036,36 @@ pub(crate) fn rect4_32_vert_hits() -> usize { | |||
| 1983 | RECT4_32_VERT_HITS.with(|c| c.get()) | 2036 | RECT4_32_VERT_HITS.with(|c| c.get()) |
| 1984 | } | 2037 | } |
| 1985 | 2038 | ||
| 2039 | +/// Current value of `RECT4_32_HORZ_INTER_HITS` (32x8 inter strips decoded). | ||
| 2040 | +pub(crate) fn rect4_32_horz_inter_hits() -> usize { | ||
| 2041 | + RECT4_32_HORZ_INTER_HITS.with(|c| c.get()) | ||
| 2042 | +} | ||
| 2043 | + | ||
| 2044 | +/// Current value of `RECT4_32_VERT_INTER_HITS` (8x32 inter strips decoded). | ||
| 2045 | +pub(crate) fn rect4_32_vert_inter_hits() -> usize { | ||
| 2046 | + RECT4_32_VERT_INTER_HITS.with(|c| c.get()) | ||
| 2047 | +} | ||
| 2048 | + | ||
| 2049 | +/// Current value of `INTER_SB_HORZ_HITS` (64x32 inter strips decoded). | ||
| 2050 | +pub(crate) fn inter_sb_horz_hits() -> usize { | ||
| 2051 | + INTER_SB_HORZ_HITS.with(|c| c.get()) | ||
| 2052 | +} | ||
| 2053 | + | ||
| 2054 | +/// Current value of `INTER_SB_VERT_HITS` (32x64 inter strips decoded). | ||
| 2055 | +pub(crate) fn inter_sb_vert_hits() -> usize { | ||
| 2056 | + INTER_SB_VERT_HITS.with(|c| c.get()) | ||
| 2057 | +} | ||
| 2058 | + | ||
| 2059 | +/// Current value of `INTER_SB_HORZ4_HITS` (64x16 inter strips decoded). | ||
| 2060 | +pub(crate) fn inter_sb_horz4_hits() -> usize { | ||
| 2061 | + INTER_SB_HORZ4_HITS.with(|c| c.get()) | ||
| 2062 | +} | ||
| 2063 | + | ||
| 2064 | +/// Current value of `INTER_SB_VERT4_HITS` (16x64 inter strips decoded). | ||
| 2065 | +pub(crate) fn inter_sb_vert4_hits() -> usize { | ||
| 2066 | + INTER_SB_VERT4_HITS.with(|c| c.get()) | ||
| 2067 | +} | ||
| 2068 | + | ||
| 1986 | // lane-rect64q r1: how many of [`decode_block_rect64`]'s three per-plane | 2069 | // lane-rect64q r1: how many of [`decode_block_rect64`]'s three per-plane |
| 1987 | // dequant calls actually observed `CURRENT_Q_IDX != base_q_idx` -- proof the | 2070 | // dequant calls actually observed `CURRENT_Q_IDX != base_q_idx` -- proof the |
| 1988 | // running-vs-stale-snapshot bug this round fixed is exercised by a gate, not | 2071 | // running-vs-stale-snapshot bug this round fixed is exercised by a gate, not |
| @@ -2112,24 +2195,61 @@ pub(crate) fn build_motion_field( | |||
| 2112 | mi_cols: usize, | 2195 | mi_cols: usize, |
| 2113 | mi_rows: usize, | 2196 | mi_rows: usize, |
| 2114 | order_hint: u32, | 2197 | order_hint: u32, |
| 2198 | + order_hint_bits: u32, | ||
| 2115 | ref_order_hints: [u32; 7], | 2199 | ref_order_hints: [u32; 7], |
| 2116 | ) -> crate::motion_field::MotionField { | 2200 | ) -> crate::motion_field::MotionField { |
| 2117 | let mut field = | 2201 | let mut field = |
| 2118 | crate::motion_field::MotionField::new(mi_cols, mi_rows, order_hint, ref_order_hints); | 2202 | crate::motion_field::MotionField::new(mi_cols, mi_rows, order_hint, ref_order_hints); |
| 2203 | + // lane-interbis r1: libaom `av1_calculate_ref_frame_side` -- a reference | ||
| 2204 | + // whose OrderHint is AHEAD of (or equal to) this frame's is "on the other | ||
| 2205 | + // side", and `av1_copy_frame_mvs` skips it entirely, so a compound block | ||
| 2206 | + // referencing one stores only its OTHER side's mv. With | ||
| 2207 | + // `enable_order_hint` off (`order_hint_bits == 0`) every side is 0 and | ||
| 2208 | + // nothing is skipped. | ||
| 2209 | + let other_side = |rf: i8| -> bool { | ||
| 2210 | + if order_hint_bits == 0 { | ||
| 2211 | + return false; | ||
| 2212 | + } | ||
| 2213 | + let oh = ref_order_hints[(rf - LAST_FRAME) as usize]; | ||
| 2214 | + crate::motion_field::get_relative_dist(order_hint_bits, oh, order_hint) > 0 | ||
| 2215 | + || oh == order_hint | ||
| 2216 | + }; | ||
| 2217 | + // libaom `REFMVS_LIMIT` (`mvref_common.h`): a stored motion field mv is | ||
| 2218 | + // capped at 12 bits per component; a longer one is not stored at all. | ||
| 2219 | + const REFMVS_LIMIT: i32 = (1 << 12) - 1; | ||
| 2119 | for row in 0..mi_rows { | 2220 | for row in 0..mi_rows { |
| 2120 | for col in 0..mi_cols { | 2221 | for col in 0..mi_cols { |
| 2121 | - if let Some(info) = grid.get(row, col) | 2222 | + let Some(info) = grid.get(row, col) else { |
| 2122 | - && info.is_inter | 2223 | + continue; |
| 2123 | - && info.ref_frame > 0 | 2224 | + }; |
| 2124 | - { | 2225 | + if !info.is_inter { |
| 2125 | - field.set( | 2226 | + continue; |
| 2126 | - row, | 2227 | + } |
| 2127 | - col, | 2228 | + // `av1_copy_frame_mvs` walks BOTH reference slots and the LAST |
| 2128 | - crate::motion_field::SavedMv { | 2229 | + // qualifying one wins -- a compound block stores its second |
| 2129 | - mv: info.mv, | 2230 | + // reference's mv, never its first (unless the second is on the |
| 2130 | - ref_frame: info.ref_frame, | 2231 | + // other side or over the limit). Storing slot 0 unconditionally |
| 2131 | - }, | 2232 | + // put the wrong (mv, ref_frame_offset) pair in every compound |
| 2132 | - ); | 2233 | + // block's cell, which a later frame's temporal candidate then |
| 2234 | + // projected with the wrong reference distance. | ||
| 2235 | + let mut saved: Option<crate::motion_field::SavedMv> = None; | ||
| 2236 | + for (rf, mv) in [ | ||
| 2237 | + (info.ref_frame, Some(info.mv)), | ||
| 2238 | + (info.ref_frame1.unwrap_or(0), info.mv1), | ||
| 2239 | + ] { | ||
| 2240 | + let (Some(mv), true) = (mv, rf > 0) else { | ||
| 2241 | + continue; | ||
| 2242 | + }; | ||
| 2243 | + if other_side(rf) { | ||
| 2244 | + continue; | ||
| 2245 | + } | ||
| 2246 | + if mv.0.abs() > REFMVS_LIMIT || mv.1.abs() > REFMVS_LIMIT { | ||
| 2247 | + continue; | ||
| 2248 | + } | ||
| 2249 | + saved = Some(crate::motion_field::SavedMv { mv, ref_frame: rf }); | ||
| 2250 | + } | ||
| 2251 | + if let Some(saved) = saved { | ||
| 2252 | + field.set(row, col, saved); | ||
| 2133 | } | 2253 | } |
| 2134 | } | 2254 | } |
| 2135 | } | 2255 | } |
| @@ -4420,20 +4540,46 @@ impl Neighbours { | |||
| 4420 | uv_mode: usize, | 4540 | uv_mode: usize, |
| 4421 | grids: &[Vec<i32>; 3], | 4541 | grids: &[Vec<i32>; 3], |
| 4422 | ) { | 4542 | ) { |
| 4423 | - let (r, c) = at; | 4543 | + self.record_rect_mi(sub16_to_mi(at), w, h, mode, uv_mode, grids); |
| 4544 | + } | ||
| 4545 | + | ||
| 4546 | + /// [`Self::record_rect`] in mi (4 px) units -- lane-inter4 r1: a | ||
| 4547 | + /// 32x8/8x32 strip of a 32-level 1:4 partition sits at an 8-px offset the | ||
| 4548 | + /// [`SUB`]-unit `at` cannot name. The coarse 16-px bands are still keyed | ||
| 4549 | + /// by the enclosing cell (a sub-16 extent writes none of them, exactly as | ||
| 4550 | + /// the [`SUB`]-unit path does). | ||
| 4551 | + fn record_rect_mi( | ||
| 4552 | + &mut self, | ||
| 4553 | + at_mi: (usize, usize), | ||
| 4554 | + w: usize, | ||
| 4555 | + h: usize, | ||
| 4556 | + mode: usize, | ||
| 4557 | + uv_mode: usize, | ||
| 4558 | + grids: &[Vec<i32>; 3], | ||
| 4559 | + ) { | ||
| 4560 | + let (r, c) = (at_mi.0 / (SUB / MI), at_mi.1 / (SUB / MI)); | ||
| 4561 | + // lane-inter4 r2: a strip whose own footprint runs past the frame's | ||
| 4562 | + // last 16-px column/row stamps only the cells that exist (libaom's | ||
| 4563 | + // arrays are padded past the frame and those cells are never read). | ||
| 4424 | for cell in 0..w / SUB { | 4564 | for cell in 0..w / SUB { |
| 4565 | + if c + cell >= self.above_mode.len() { | ||
| 4566 | + break; | ||
| 4567 | + } | ||
| 4425 | self.above_mode[c + cell] = mode; | 4568 | self.above_mode[c + cell] = mode; |
| 4426 | self.above_uv_mode[c + cell] = uv_mode; | 4569 | self.above_uv_mode[c + cell] = uv_mode; |
| 4427 | self.above_side[c + cell] = w; | 4570 | self.above_side[c + cell] = w; |
| 4428 | } | 4571 | } |
| 4429 | for cell in 0..h / SUB { | 4572 | for cell in 0..h / SUB { |
| 4573 | + if r + cell >= self.left_mode.len() { | ||
| 4574 | + break; | ||
| 4575 | + } | ||
| 4430 | self.left_mode[r + cell] = mode; | 4576 | self.left_mode[r + cell] = mode; |
| 4431 | self.left_uv_mode[r + cell] = uv_mode; | 4577 | self.left_uv_mode[r + cell] = uv_mode; |
| 4432 | self.left_side[r + cell] = h; | 4578 | self.left_side[r + cell] = h; |
| 4433 | } | 4579 | } |
| 4434 | - self.record_mode_mi(r * (SUB / MI), c * (SUB / MI), w / MI, h / MI, mode); | 4580 | + self.record_mode_mi(at_mi.0, at_mi.1, w / MI, h / MI, mode); |
| 4435 | - self.record_uv_mode_mi(r * (SUB / MI), c * (SUB / MI), w / MI, h / MI, uv_mode); | 4581 | + self.record_uv_mode_mi(at_mi.0, at_mi.1, w / MI, h / MI, uv_mode); |
| 4436 | - self.record_mi_rect((r * (SUB / MI), c * (SUB / MI)), w, h, grids); | 4582 | + self.record_mi_rect(at_mi, w, h, grids); |
| 4437 | } | 4583 | } |
| 4438 | 4584 | ||
| 4439 | /// The coefficient-context half of [`Self::record`], taking the block's | 4585 | /// The coefficient-context half of [`Self::record`], taking the block's |
| @@ -4457,10 +4603,14 @@ impl Neighbours { | |||
| 4457 | let states: [Neighbour; 3] = std::array::from_fn(|plane| neighbour_state(&grids[plane])); | 4603 | let states: [Neighbour; 3] = std::array::from_fn(|plane| neighbour_state(&grids[plane])); |
| 4458 | let (w_mi, h_mi) = (w / MI, h / MI); | 4604 | let (w_mi, h_mi) = (w / MI, h / MI); |
| 4459 | for cell in 0..h_mi { | 4605 | for cell in 0..h_mi { |
| 4460 | - self.left_side_mi[mi_r + cell] = h; | 4606 | + if let Some(slot) = self.left_side_mi.get_mut(mi_r + cell) { |
| 4607 | + *slot = h; | ||
| 4608 | + } | ||
| 4461 | } | 4609 | } |
| 4462 | for cell in 0..w_mi { | 4610 | for cell in 0..w_mi { |
| 4463 | - self.above_side_mi[mi_c + cell] = w; | 4611 | + if let Some(slot) = self.above_side_mi.get_mut(mi_c + cell) { |
| 4612 | + *slot = w; | ||
| 4613 | + } | ||
| 4464 | } | 4614 | } |
| 4465 | // A chroma 4x4 unit straddling the true luma edge is still whole in | 4615 | // A chroma 4x4 unit straddling the true luma edge is still whole in |
| 4466 | // chroma's own halved grid, so libaom rounds the luma bound up to the | 4616 | // chroma's own halved grid, so libaom rounds the luma bound up to the |
| @@ -4591,23 +4741,34 @@ impl Neighbours { | |||
| 4591 | let (mi_r, mi_c) = at_mi; | 4741 | let (mi_r, mi_c) = at_mi; |
| 4592 | let (r, c) = (mi_r / (SUB / MI), mi_c / (SUB / MI)); | 4742 | let (r, c) = (mi_r / (SUB / MI), mi_c / (SUB / MI)); |
| 4593 | for cell in 0..w.div_ceil(SUB) { | 4743 | for cell in 0..w.div_ceil(SUB) { |
| 4744 | + if c + cell >= self.above_mode.len() { | ||
| 4745 | + break; | ||
| 4746 | + } | ||
| 4594 | self.above_mode[c + cell] = mode; | 4747 | self.above_mode[c + cell] = mode; |
| 4595 | self.above_uv_mode[c + cell] = uv_mode; | 4748 | self.above_uv_mode[c + cell] = uv_mode; |
| 4596 | self.above_side[c + cell] = w; | 4749 | self.above_side[c + cell] = w; |
| 4597 | } | 4750 | } |
| 4598 | for cell in 0..h.div_ceil(SUB) { | 4751 | for cell in 0..h.div_ceil(SUB) { |
| 4752 | + if r + cell >= self.left_mode.len() { | ||
| 4753 | + break; | ||
| 4754 | + } | ||
| 4599 | self.left_mode[r + cell] = mode; | 4755 | self.left_mode[r + cell] = mode; |
| 4600 | self.left_uv_mode[r + cell] = uv_mode; | 4756 | self.left_uv_mode[r + cell] = uv_mode; |
| 4601 | self.left_side[r + cell] = h; | 4757 | self.left_side[r + cell] = h; |
| 4602 | } | 4758 | } |
| 4759 | + | ||
| 4603 | let (w_mi, h_mi) = (w / MI, h / MI); | 4760 | let (w_mi, h_mi) = (w / MI, h / MI); |
| 4604 | self.record_mode_mi(mi_r, mi_c, w_mi, h_mi, mode); | 4761 | self.record_mode_mi(mi_r, mi_c, w_mi, h_mi, mode); |
| 4605 | self.record_uv_mode_mi(mi_r, mi_c, w_mi, h_mi, uv_mode); | 4762 | self.record_uv_mode_mi(mi_r, mi_c, w_mi, h_mi, uv_mode); |
| 4606 | for cell in 0..h_mi { | 4763 | for cell in 0..h_mi { |
| 4607 | - self.left_side_mi[mi_r + cell] = h; | 4764 | + if let Some(slot) = self.left_side_mi.get_mut(mi_r + cell) { |
| 4765 | + *slot = h; | ||
| 4766 | + } | ||
| 4608 | } | 4767 | } |
| 4609 | for cell in 0..w_mi { | 4768 | for cell in 0..w_mi { |
| 4610 | - self.above_side_mi[mi_c + cell] = w; | 4769 | + if let Some(slot) = self.above_side_mi.get_mut(mi_c + cell) { |
| 4770 | + *slot = w; | ||
| 4771 | + } | ||
| 4611 | } | 4772 | } |
| 4612 | let round_up_even = |n: usize| n.div_ceil(2) * 2; | 4773 | let round_up_even = |n: usize| n.div_ceil(2) * 2; |
| 4613 | let (bound_h, bound_w) = (round_up_even(self.mi_rows), round_up_even(self.mi_cols)); | 4774 | let (bound_h, bound_w) = (round_up_even(self.mi_rows), round_up_even(self.mi_cols)); |
| @@ -9957,8 +10118,25 @@ fn read_tx_size( | |||
| 9957 | /// the two neighbour terms (whether the transform last written above/left of | 10118 | /// the two neighbour terms (whether the transform last written above/left of |
| 9958 | /// this unit is narrower/shorter than the unit itself). | 10119 | /// this unit is narrower/shorter than the unit itself). |
| 9959 | fn txfm_partition_ctx(above_px: u8, left_px: u8, blk_max_px: usize, tx_px: usize) -> usize { | 10120 | fn txfm_partition_ctx(above_px: u8, left_px: u8, blk_max_px: usize, tx_px: usize) -> usize { |
| 9960 | - let above = usize::from(usize::from(above_px) < tx_px); | 10121 | + txfm_partition_ctx_rect(above_px, left_px, blk_max_px, tx_px, tx_px) |
| 9961 | - let left = usize::from(usize::from(left_px) < tx_px); | 10122 | +} |
| 10123 | + | ||
| 10124 | +/// [`txfm_partition_ctx`] for a *rectangular* transform (lane-inter4 r2): | ||
| 10125 | +/// libaom's `txfm_partition_context` compares the above context against | ||
| 10126 | +/// `tx_size_wide` and the left one against `tx_size_high`, and takes its | ||
| 10127 | +/// category from `txsize_sqr_up_map[tx_size]` -- all three collapse to one | ||
| 10128 | +/// side for a square transform, which is why the square form above is a | ||
| 10129 | +/// special case of this one. | ||
| 10130 | +fn txfm_partition_ctx_rect( | ||
| 10131 | + above_px: u8, | ||
| 10132 | + left_px: u8, | ||
| 10133 | + blk_max_px: usize, | ||
| 10134 | + tx_w: usize, | ||
| 10135 | + tx_h: usize, | ||
| 10136 | +) -> usize { | ||
| 10137 | + let above = usize::from(usize::from(above_px) < tx_w); | ||
| 10138 | + let left = usize::from(usize::from(left_px) < tx_h); | ||
| 10139 | + let tx_px = tx_w.max(tx_h); | ||
| 9962 | // `get_sqr_tx_size(max(block_size_wide, block_size_high))`, capped at the | 10140 | // `get_sqr_tx_size(max(block_size_wide, block_size_high))`, capped at the |
| 9963 | // largest transform (`TX_64X64`); `TX_4X4`..`TX_64X64` index as | 10141 | // largest transform (`TX_64X64`); `TX_4X4`..`TX_64X64` index as |
| 9964 | // `log2(px) - 2`. | 10142 | // `log2(px) - 2`. |
| @@ -9973,16 +10151,30 @@ fn txfm_partition_ctx(above_px: u8, left_px: u8, blk_max_px: usize, tx_px: usize | |||
| 9973 | /// resolved transform's own size. | 10151 | /// resolved transform's own size. |
| 9974 | fn txfm_partition_update( | 10152 | fn txfm_partition_update( |
| 9975 | n: &mut Neighbours, | 10153 | n: &mut Neighbours, |
| 9976 | - (mi_r, mi_c): (usize, usize), | 10154 | + at_mi: (usize, usize), |
| 9977 | tx_px: usize, | 10155 | tx_px: usize, |
| 9978 | txb_px: usize, | 10156 | txb_px: usize, |
| 9979 | ) { | 10157 | ) { |
| 9980 | - for i in 0..txb_px / MI { | 10158 | + txfm_partition_update_rect(n, at_mi, (tx_px, tx_px), (txb_px, txb_px)); |
| 10159 | +} | ||
| 10160 | + | ||
| 10161 | +/// [`txfm_partition_update`] for a rectangular transform (lane-inter4 r2): | ||
| 10162 | +/// the left column records `tx_size_high` over the parent's own height and | ||
| 10163 | +/// the above row records `tx_size_wide` over its width. | ||
| 10164 | +fn txfm_partition_update_rect( | ||
| 10165 | + n: &mut Neighbours, | ||
| 10166 | + (mi_r, mi_c): (usize, usize), | ||
| 10167 | + (tx_w, tx_h): (usize, usize), | ||
| 10168 | + (txb_w, txb_h): (usize, usize), | ||
| 10169 | +) { | ||
| 10170 | + for i in 0..txb_h / MI { | ||
| 9981 | if let Some(cell) = n.left_txfm.get_mut(mi_r + i) { | 10171 | if let Some(cell) = n.left_txfm.get_mut(mi_r + i) { |
| 9982 | - *cell = tx_px as u8; | 10172 | + *cell = tx_h as u8; |
| 9983 | } | 10173 | } |
| 10174 | + } | ||
| 10175 | + for i in 0..txb_w / MI { | ||
| 9984 | if let Some(cell) = n.above_txfm.get_mut(mi_c + i) { | 10176 | if let Some(cell) = n.above_txfm.get_mut(mi_c + i) { |
| 9985 | - *cell = tx_px as u8; | 10177 | + *cell = tx_w as u8; |
| 9986 | } | 10178 | } |
| 9987 | } | 10179 | } |
| 9988 | } | 10180 | } |
| @@ -10204,6 +10396,264 @@ fn read_block_tx_size( | |||
| 10204 | Ok((tx, None)) | 10396 | Ok((tx, None)) |
| 10205 | } | 10397 | } |
| 10206 | 10398 | ||
| 10399 | +/// lane-inter4 r2: the shapes whose *rectangular inter* residual this | ||
| 10400 | +/// decoder codes -- a 2:1 strip whose own max rect transform | ||
| 10401 | +/// (`max_txsize_rect_lookup[BLOCK_32X16] == TX_32X16`) has both a | ||
| 10402 | +/// coefficient table set ([`TxbSet::LumaRect32x16Inter`], 512-coefficient | ||
| 10403 | +/// `eob_pt`) and a `tx_type` alphabet here. 64x32/64x16 strips would need a | ||
| 10404 | +/// 64-point rect transform, and 16x8/8x16 needs | ||
| 10405 | +/// `default_inter_ext_tx_cdf[2][TX_8X8]` (the 12-symbol | ||
| 10406 | +/// `DTT9_IDTX_1DDCT` row at `tx_size_sqr == TX_8X8`, only reachable through a | ||
| 10407 | +/// rect transform), neither of which exists yet -- both stay refused by name. | ||
| 10408 | +fn rect_inter_residual_supported(w: usize, h: usize) -> bool { | ||
| 10409 | + matches!((w, h), (32, 16) | (16, 32) | (16, 8) | (8, 16)) | ||
| 10410 | +} | ||
| 10411 | + | ||
| 10412 | +/// The luma coefficient/`tx_type` table set of a whole-block rectangular | ||
| 10413 | +/// INTER transform unit (lane-inter4 r3). `av1_get_ext_tx_set_type` splits | ||
| 10414 | +/// the two shapes: a 32x16/16x32 unit has `tx_size_sqr_up == TX_32X32`, so | ||
| 10415 | +/// it reads the 2-symbol `EXT_TX_SET_DCT_IDTX` set regardless of | ||
| 10416 | +/// `reduced_tx_set`; a 16x8/8x16 unit has `tx_size_sqr_up == TX_16X16` and | ||
| 10417 | +/// `tx_size_sqr == TX_8X8`, so it reads `EXT_TX_SET_DCT_IDTX` when reduced | ||
| 10418 | +/// and the 16-symbol `EXT_TX_SET_ALL16` otherwise -- both at the *8x8* CDF | ||
| 10419 | +/// row (`txsize_sqr_map`), never the 16x16 one. | ||
| 10420 | +fn rect_inter_luma_set(w: usize, h: usize) -> TxbSet { | ||
| 10421 | + match (w, h) { | ||
| 10422 | + (32, 16) | (16, 32) => TxbSet::LumaRect32x16Inter, | ||
| 10423 | + (16, 8) | (8, 16) => { | ||
| 10424 | + if REDUCED_TX_SET_INTER.with(std::cell::Cell::get) { | ||
| 10425 | + TxbSet::LumaRect16x8Inter | ||
| 10426 | + } else { | ||
| 10427 | + TxbSet::LumaRect16x8InterSet1 | ||
| 10428 | + } | ||
| 10429 | + } | ||
| 10430 | + _ => unreachable!("rect_inter_residual_supported gates every shape that reaches here"), | ||
| 10431 | + } | ||
| 10432 | +} | ||
| 10433 | + | ||
| 10434 | +/// The chroma table set of the same block's single rectangular chroma unit | ||
| 10435 | +/// (`av1_get_max_uv_txsize`): 16x8/8x16 under a 32x16/16x32 strip, 8x4/4x8 | ||
| 10436 | +/// under a 16x8/8x16 one. Neither codes a `tx_type` symbol -- both inherit | ||
| 10437 | +/// the luma unit's. | ||
| 10438 | +fn rect_inter_chroma_set(w: usize, h: usize) -> TxbSet { | ||
| 10439 | + match (w, h) { | ||
| 10440 | + (16, 8) | (8, 16) => TxbSet::ChromaRect16x8, | ||
| 10441 | + (8, 4) | (4, 8) => TxbSet::ChromaRect8x4, | ||
| 10442 | + _ => unreachable!("rect_inter_residual_supported gates every shape that reaches here"), | ||
| 10443 | + } | ||
| 10444 | +} | ||
| 10445 | + | ||
| 10446 | +/// libaom `size_group_lookup[bsize]` for the block shapes this decoder's | ||
| 10447 | +/// inter path reaches, from the block's TRUE footprint rather than the | ||
| 10448 | +/// square `side` corner-cut: 8x8/8x16/16x8 -> 1, 16x16/16x32/32x16 -> 2, | ||
| 10449 | +/// everything 32 and above -> 3. | ||
| 10450 | +fn size_group_wh(w: usize, h: usize) -> usize { | ||
| 10451 | + // lane-inter4 r4: `size_group_lookup[BLOCK_SIZES_ALL]` (libaom | ||
| 10452 | + // `common_data.h:60`) is 0 for every block with a 4-px side | ||
| 10453 | + // (4x4/4x8/8x4/4x16/16x4), 1 for min side 8, 2 for 16, 3 above -- the old | ||
| 10454 | + // `0..=8 => 1` row gave a sub-8 leaf group 1 where libaom says 0. | ||
| 10455 | + match w.min(h) { | ||
| 10456 | + 0..=4 => 0, | ||
| 10457 | + 8 => 1, | ||
| 10458 | + 16 => 2, | ||
| 10459 | + _ => 3, | ||
| 10460 | + } | ||
| 10461 | +} | ||
| 10462 | + | ||
| 10463 | +#[test] | ||
| 10464 | +fn size_group_wh_matches_libaom_size_group_lookup() { | ||
| 10465 | + // `BLOCK_SIZES_ALL` in libaom's own order, with `size_group_lookup`'s | ||
| 10466 | + // transcribed values (common_data.h:60-62). | ||
| 10467 | + const TABLE: [((usize, usize), usize); 22] = [ | ||
| 10468 | + ((4, 4), 0), ((4, 8), 0), ((8, 4), 0), ((8, 8), 1), ((8, 16), 1), ((16, 8), 1), | ||
| 10469 | + ((16, 16), 2), ((16, 32), 2), ((32, 16), 2), ((32, 32), 3), ((32, 64), 3), | ||
| 10470 | + ((64, 32), 3), ((64, 64), 3), ((64, 128), 3), ((128, 64), 3), ((128, 128), 3), | ||
| 10471 | + ((4, 16), 0), ((16, 4), 0), ((8, 32), 1), ((32, 8), 1), ((16, 64), 2), ((64, 16), 2), | ||
| 10472 | + ]; | ||
| 10473 | + for ((w, h), want) in TABLE { | ||
| 10474 | + assert_eq!(size_group_wh(w, h), want, "size_group_wh({w}, {h})"); | ||
| 10475 | + } | ||
| 10476 | +} | ||
| 10477 | + | ||
| 10478 | +/// The default (2D) coefficient scan of a rectangular transform. | ||
| 10479 | +fn rect_scan(w: usize, h: usize) -> &'static [u16] { | ||
| 10480 | + match (w, h) { | ||
| 10481 | + (32, 16) => &SCAN_32X16, | ||
| 10482 | + (16, 32) => &SCAN_16X32, | ||
| 10483 | + (16, 8) => &SCAN_16X8, | ||
| 10484 | + (8, 16) => &SCAN_8X16, | ||
| 10485 | + (8, 4) => &SCAN_8X4, | ||
| 10486 | + (4, 8) => &SCAN_4X8, | ||
| 10487 | + _ => unreachable!("rect_inter_residual_supported gates every shape that reaches here"), | ||
| 10488 | + } | ||
| 10489 | +} | ||
| 10490 | + | ||
| 10491 | +/// [`read_block_tx_size`] for a rectangular inter block (lane-inter4 r2): | ||
| 10492 | +/// spec 5.11.17 / libaom `read_tx_size_vartx` starting from the block's own | ||
| 10493 | +/// `max_txsize_rect_lookup` entry, which for a 2:1 strip IS rectangular. The | ||
| 10494 | +/// depth-0 `txfm_partition` symbol reads its context off the rect transform's | ||
| 10495 | +/// own width/height; a `0` leaves one whole-block rect transform unit | ||
| 10496 | +/// (`None`), and a `1` splits it into `sub_tx_size_map`'s two SQUARE | ||
| 10497 | +/// sub-transforms (`sub_tx_size_map[TX_32X16] == TX_16X16`), from which the | ||
| 10498 | +/// ordinary square [`read_var_tx_size`] recursion continues at depth 1 -- so | ||
| 10499 | +/// every leaf of a split rect block is square and the existing square leaf | ||
| 10500 | +/// loop reconstructs it unchanged. | ||
| 10501 | +#[allow(clippy::too_many_arguments)] | ||
| 10502 | +fn read_block_tx_size_rect( | ||
| 10503 | + dec: &mut SymbolDecoder, | ||
| 10504 | + cdfs: &mut Cdfs, | ||
| 10505 | + n: &mut Neighbours, | ||
| 10506 | + at_mi: (usize, usize), | ||
| 10507 | + (bw, bh): (usize, usize), | ||
| 10508 | + (mi_cols, mi_rows): (usize, usize), | ||
| 10509 | + skip: bool, | ||
| 10510 | +) -> Result<Option<Vec<(usize, usize, usize)>>> { | ||
| 10511 | + if skip { | ||
| 10512 | + // `set_txfm_ctxs(.., skip && is_inter)`: a skipped inter block records | ||
| 10513 | + // its own BLOCK size -- width above, height left -- not a transform. | ||
| 10514 | + txfm_partition_update_rect(n, at_mi, (bw, bh), (bw, bh)); | ||
| 10515 | + return Ok(None); | ||
| 10516 | + } | ||
| 10517 | + // `max_txsize_rect_lookup` is the block's own size, capped at 64 -- and | ||
| 10518 | + // `rect_inter_residual_supported` has already excluded everything above 32. | ||
| 10519 | + let (tx_w, tx_h) = (bw, bh); | ||
| 10520 | + if !TX_SELECT_INTER.with(std::cell::Cell::get) { | ||
| 10521 | + // `TX_MODE_LARGEST`: no symbol at all, the whole block is one | ||
| 10522 | + // transform, and `set_txfm_ctxs` records exactly what | ||
| 10523 | + // `txfm_partition_update` would for that same unit. | ||
| 10524 | + txfm_partition_update_rect(n, at_mi, (tx_w, tx_h), (bw, bh)); | ||
| 10525 | + RECT_INTER_TU_HITS.with(|c| c.set(c.get() + 1)); | ||
| 10526 | + return Ok(None); | ||
| 10527 | + } | ||
| 10528 | + let ctx = txfm_partition_ctx_rect( | ||
| 10529 | + n.above_txfm[at_mi.1], | ||
| 10530 | + n.left_txfm[at_mi.0], | ||
| 10531 | + bw.max(bh), | ||
| 10532 | + tx_w, | ||
| 10533 | + tx_h, | ||
| 10534 | + ); | ||
| 10535 | + let split = dec.symbol(&mut cdfs.txfm_partition[ctx]) == 1; | ||
| 10536 | + TXFM_SPLIT_READS.with(|c| c.set(c.get() + 1)); | ||
| 10537 | + if std::env::var_os("EC_TRACE_MODE_STEP").is_some() { | ||
| 10538 | + let (rng, _) = dec.debug_state(); | ||
| 10539 | + eprintln!( | ||
| 10540 | + "EC_ISTEP mi_row={} mi_col={} name=txfm_split_rect val={} ctx={ctx} rng={rng}", | ||
| 10541 | + at_mi.0, | ||
| 10542 | + at_mi.1, | ||
| 10543 | + u8::from(split) | ||
| 10544 | + ); | ||
| 10545 | + } | ||
| 10546 | + if !split { | ||
| 10547 | + txfm_partition_update_rect(n, at_mi, (tx_w, tx_h), (bw, bh)); | ||
| 10548 | + RECT_INTER_TU_HITS.with(|c| c.set(c.get() + 1)); | ||
| 10549 | + return Ok(None); | ||
| 10550 | + } | ||
| 10551 | + TXFM_SPLIT_HITS.with(|c| c.set(c.get() + 1)); | ||
| 10552 | + RECT_INTER_TXSPLIT_HITS.with(|c| c.set(c.get() + 1)); | ||
| 10553 | + let sub = tx_w.min(tx_h); | ||
| 10554 | + let max_w_mi = (bw / MI).min(mi_cols.saturating_sub(at_mi.1)); | ||
| 10555 | + let max_h_mi = (bh / MI).min(mi_rows.saturating_sub(at_mi.0)); | ||
| 10556 | + let mut leaves = Vec::new(); | ||
| 10557 | + for row in (0..bh / MI).step_by(sub / MI) { | ||
| 10558 | + for col in (0..bw / MI).step_by(sub / MI) { | ||
| 10559 | + read_var_tx_size( | ||
| 10560 | + dec, | ||
| 10561 | + cdfs, | ||
| 10562 | + n, | ||
| 10563 | + at_mi, | ||
| 10564 | + bw.max(bh), | ||
| 10565 | + (max_w_mi, max_h_mi), | ||
| 10566 | + sub, | ||
| 10567 | + 1, | ||
| 10568 | + row, | ||
| 10569 | + col, | ||
| 10570 | + &mut leaves, | ||
| 10571 | + ); | ||
| 10572 | + } | ||
| 10573 | + } | ||
| 10574 | + Ok(Some(leaves)) | ||
| 10575 | +} | ||
| 10576 | + | ||
| 10577 | +/// [`read_inter_plane`] for a rectangular transform unit (lane-inter4 r2): | ||
| 10578 | +/// the coefficients are read with the rect coefficient machinery | ||
| 10579 | +/// ([`read_coeffs_rect`], whose `TxClass` handling covers the 1D `V_*`/`H_*` | ||
| 10580 | +/// types), inverted with the rect inverse transform | ||
| 10581 | +/// ([`dequant_and_inverse_typed_wh`], which carries the 2:1 `sqrt2` scale), | ||
| 10582 | +/// and added onto the top-left `w x h` of the block's own square-strided | ||
| 10583 | +/// motion-compensated prediction buffer. Returns the *rect* coefficient grid | ||
| 10584 | +/// and the coded `tx_type`. | ||
| 10585 | +/// | ||
| 10586 | +/// `txb_skip_ctx` is 0 for luma: this unit covers the whole block, i.e. | ||
| 10587 | +/// `get_txb_ctx`'s `plane_bsize == txsize_to_bsize[tx_size]` branch. | ||
| 10588 | +#[allow(clippy::too_many_arguments)] | ||
| 10589 | +fn read_inter_plane_rect( | ||
| 10590 | + dec: &mut SymbolDecoder, | ||
| 10591 | + cdfs: &mut Cdfs, | ||
| 10592 | + set: TxbSet, | ||
| 10593 | + (w, h): (usize, usize), | ||
| 10594 | + stride: usize, | ||
| 10595 | + plane_idx: usize, | ||
| 10596 | + around: (bool, bool, i32), | ||
| 10597 | + tx_mode: usize, | ||
| 10598 | + plane: &mut PlaneBuf, | ||
| 10599 | + x: usize, | ||
| 10600 | + y: usize, | ||
| 10601 | + prediction: &[u16], | ||
| 10602 | + inherited_luma_tx_type: Option<TxType>, | ||
| 10603 | +) -> Result<(Vec<i32>, TxType)> { | ||
| 10604 | + let skip_ctx = if plane_idx == 0 { | ||
| 10605 | + 0 | ||
| 10606 | + } else { | ||
| 10607 | + usize::from(around.0) + usize::from(around.1) | ||
| 10608 | + }; | ||
| 10609 | + let mut coding = cdfs.txb(set, tx_mode); | ||
| 10610 | + // `av1_get_ext_tx_set_type`'s DCT-only clamp is on `tx_size_sqr_up`, i.e. | ||
| 10611 | + // the *longer* side of this rect transform. | ||
| 10612 | + let default_tx_type = match inherited_luma_tx_type { | ||
| 10613 | + Some(t) if w.max(h) < 32 => t, | ||
| 10614 | + _ => TxType::DctDct, | ||
| 10615 | + }; | ||
| 10616 | + let (grid, tx_type) = read_coeffs_rect( | ||
| 10617 | + dec, | ||
| 10618 | + &mut coding, | ||
| 10619 | + rect_scan(w, h), | ||
| 10620 | + w, | ||
| 10621 | + h, | ||
| 10622 | + skip_ctx, | ||
| 10623 | + dc_sign_ctx(around.2), | ||
| 10624 | + default_tx_type, | ||
| 10625 | + )?; | ||
| 10626 | + let (dc_delta, ac_delta) = plane_q_delta(plane_idx); | ||
| 10627 | + let residual = dequant_and_inverse_typed_wh( | ||
| 10628 | + &grid, | ||
| 10629 | + w, | ||
| 10630 | + h, | ||
| 10631 | + bit_depth(), | ||
| 10632 | + block_q_idx(), | ||
| 10633 | + dc_delta, | ||
| 10634 | + ac_delta, | ||
| 10635 | + tx_type, | ||
| 10636 | + ); | ||
| 10637 | + // `reconstruct_mc_rect` reads both buffers at the square prediction | ||
| 10638 | + // stride, so the dense `w x h` residual is re-laid at that stride first. | ||
| 10639 | + let mut strided = vec![0i32; stride * stride]; | ||
| 10640 | + for row in 0..h { | ||
| 10641 | + strided[row * stride..][..w].copy_from_slice(&residual[row * w..][..w]); | ||
| 10642 | + } | ||
| 10643 | + plane.reconstruct_mc_rect(x, y, stride, w, h, prediction, &strided); | ||
| 10644 | + Ok((grid, tx_type)) | ||
| 10645 | +} | ||
| 10646 | + | ||
| 10647 | +/// A rect coefficient grid re-laid into the square `stride x stride` grid the | ||
| 10648 | +/// neighbour/deblock stamps downstream of the residual expect. | ||
| 10649 | +fn embed_rect_grid(grid: &[i32], w: usize, h: usize, stride: usize) -> Vec<i32> { | ||
| 10650 | + let mut full = vec![0i32; stride * stride]; | ||
| 10651 | + for row in 0..h { | ||
| 10652 | + full[row * stride..][..w].copy_from_slice(&grid[row * w..][..w]); | ||
| 10653 | + } | ||
| 10654 | + full | ||
| 10655 | +} | ||
| 10656 | + | ||
| 10207 | /// One 8x8 inter leaf's luma residual (lane-txselect): either the whole-8x8 | 10657 | /// One 8x8 inter leaf's luma residual (lane-txselect): either the whole-8x8 |
| 10208 | /// transform, or -- when [`read_block_tx_size`]'s var-tx tree took the single | 10658 | /// transform, or -- when [`read_block_tx_size`]'s var-tx tree took the single |
| 10209 | /// split a `BLOCK_8X8` can take (`split`) -- the four 4x4 transform units in | 10659 | /// split a `BLOCK_8X8` can take (`split`) -- the four 4x4 transform units in |
| @@ -13741,11 +14191,33 @@ fn obmc_blend( | |||
| 13741 | // its OWN neighbour cap (width-log2 for above, height-log2 for left) and | 14191 | // its OWN neighbour cap (width-log2 for above, height-log2 for left) and |
| 13742 | // overlap (bh/2 rows above, bw/2 cols left) -- one square `side` was | 14192 | // overlap (bh/2 rows above, bw/2 cols left) -- one square `side` was |
| 13743 | // right only for square blocks. | 14193 | // right only for square blocks. |
| 14194 | + // libaom `max_neighbor_obmc[6] = { 0, 1, 2, 3, 4, 4 }` indexed by | ||
| 14195 | + // `mi_size_wide_log2[bsize]` (above pass) / `mi_size_high_log2` (left): | ||
| 14196 | + // 1 mi -> 0, 2 -> 1, 4 -> 2, 8 -> 3, 16+ -> 4. lane-inter4 r3: the old | ||
| 14197 | + // `1..=4 => 2` row was right only for blocks at least 16 px on that axis | ||
| 14198 | + // -- a 16x8 leaf's LEFT pass (bh4 = 2) walked up to two neighbours where | ||
| 14199 | + // libaom walks one, blending an extra 8-px-tall neighbour into every | ||
| 14200 | + // rect leaf with two of them on its left edge (class table-narrowed-to- | ||
| 14201 | + // the-reachable-sizes; the square gates could never expose it). | ||
| 13744 | let max_nb = |n4: usize| match n4 { | 14202 | let max_nb = |n4: usize| match n4 { |
| 13745 | - 1..=4 => 2, | 14203 | + 0..=1 => 0, |
| 14204 | + 2 => 1, | ||
| 14205 | + 3..=4 => 2, | ||
| 13746 | 5..=8 => 3, | 14206 | 5..=8 => 3, |
| 13747 | _ => 4, | 14207 | _ => 4, |
| 13748 | }; | 14208 | }; |
| 14209 | + // lane-inter4 r4: r3 refused OBMC on a 16x8/8x16 leaf (5302 luma pixels | ||
| 14210 | + // of one frame wrong). Re-measured on this tree with an `EC_OBMC` rung in | ||
| 14211 | + // both decoders on that exact stream: the neighbour lists agree entry for | ||
| 14212 | + // entry (position, span, mv, ref, size, filter) and all six pre-filter | ||
| 14213 | + // frames are byte-identical to the instrumented aomdec's. The refusal is | ||
| 14214 | + // gone; the counter below is what the gate's `--enable-obmc=1` arm reads. | ||
| 14215 | + // The only decode-path change between r3's measurement and this one is the | ||
| 14216 | + // lane-interbis merge (`build_motion_field`'s compound slot walk), which | ||
| 14217 | + // moves temporal MV candidates -- not bisected further. | ||
| 14218 | + if matches!((write_w, write_h), (16, 8) | (8, 16)) { | ||
| 14219 | + OBMC_RECT_LEAF_HITS.with(|c| c.set(c.get() + 1)); | ||
| 14220 | + } | ||
| 13749 | let overlap_above = write_h / 2; | 14221 | let overlap_above = write_h / 2; |
| 13750 | let overlap_left = write_w / 2; | 14222 | let overlap_left = write_w / 2; |
| 13751 | // lane-inter8 r1 / lane-scaledref r1: `av1_skip_u4x4_pred_in_obmc` | 14223 | // lane-inter8 r1 / lane-scaledref r1: `av1_skip_u4x4_pred_in_obmc` |
| @@ -14128,6 +14600,12 @@ fn build_gm_mv_table( | |||
| 14128 | /// mode/tx-type outside what [`read_intra_mode`]/[`read_coeffs`] already | 14600 | /// mode/tx-type outside what [`read_intra_mode`]/[`read_coeffs`] already |
| 14129 | /// refuse. | 14601 | /// refuse. |
| 14130 | #[allow(clippy::too_many_arguments)] | 14602 | #[allow(clippy::too_many_arguments)] |
| 14603 | +/// lane-inter4 r1: 16-px-cell coordinates -> MI (4-px) coordinates, the unit | ||
| 14604 | +/// [`decode_inter_block`]'s `at` now takes. | ||
| 14605 | +const fn sub16_to_mi(t: (usize, usize)) -> (usize, usize) { | ||
| 14606 | + (t.0 * (SUB / MI), t.1 * (SUB / MI)) | ||
| 14607 | +} | ||
| 14608 | + | ||
| 14131 | fn decode_inter_block( | 14609 | fn decode_inter_block( |
| 14132 | dec: &mut SymbolDecoder, | 14610 | dec: &mut SymbolDecoder, |
| 14133 | cdfs: &mut Cdfs, | 14611 | cdfs: &mut Cdfs, |
| @@ -14164,7 +14642,11 @@ fn decode_inter_block( | |||
| 14164 | chroma_tx: usize, | 14642 | chroma_tx: usize, |
| 14165 | scan_luma: &[u16], | 14643 | scan_luma: &[u16], |
| 14166 | scan_chroma: &[u16], | 14644 | scan_chroma: &[u16], |
| 14167 | - size_group: usize, | 14645 | + // lane-inter4 r3: superseded by `size_group_wh(write_w, write_h)` at the |
| 14646 | + // one site that read it (`y_mode`) -- a rect strip's group comes from its | ||
| 14647 | + // true footprint, not the caller's square `side`. Kept in the signature | ||
| 14648 | + // rather than editing twenty call sites. | ||
| 14649 | + _size_group: usize, | ||
| 14168 | allow_high_precision_mv: bool, | 14650 | allow_high_precision_mv: bool, |
| 14169 | force_integer_mv: bool, | 14651 | force_integer_mv: bool, |
| 14170 | interp_fixed: Option<mc::InterpFilterKind>, | 14652 | interp_fixed: Option<mc::InterpFilterKind>, |
| @@ -14242,13 +14724,16 @@ fn decode_inter_block( | |||
| 14242 | // combinations that don't implement scaled MC yet. | 14724 | // combinations that don't implement scaled MC yet. |
| 14243 | frame_width: usize, | 14725 | frame_width: usize, |
| 14244 | ) -> Result<()> { | 14726 | ) -> Result<()> { |
| 14245 | - let (r, c) = at; | 14727 | + // lane-inter4 r1: `at` is in MI units (4 px) so a 32-level 1:4 strip can |
| 14728 | + // name an 8-px offset; `(r, c)` stays the enclosing 16-px cell for the | ||
| 14729 | + // few 16-px-granular uses below. | ||
| 14730 | + let (r, c) = (at.0 / (SUB / MI), at.1 / (SUB / MI)); | ||
| 14246 | // lane-inter8 r2: the inter side bands are mi-granular; this block's own | 14731 | // lane-inter8 r2: the inter side bands are mi-granular; this block's own |
| 14247 | // above/left neighbour is the mi cell at its top-left corner (libaom | 14732 | // above/left neighbour is the mi cell at its top-left corner (libaom |
| 14248 | // `above_mbmi` = mi(mi_row - 1, mi_col)), so a SUB-aligned block reads | 14733 | // `above_mbmi` = mi(mi_row - 1, mi_col)), so a SUB-aligned block reads |
| 14249 | // exactly what it read before. | 14734 | // exactly what it read before. |
| 14250 | - let (rmi, cmi) = (r * (SUB / MI), c * (SUB / MI)); | 14735 | + let (rmi, cmi) = at; |
| 14251 | - let (px, py) = (c * SUB, r * SUB); | 14736 | + let (px, py) = (at.1 * MI, at.0 * MI); |
| 14252 | let (cpx, cpy) = (px / 2, py / 2); | 14737 | let (cpx, cpy) = (px / 2, py / 2); |
| 14253 | let chroma_side = side / 2; | 14738 | let chroma_side = side / 2; |
| 14254 | let (write_chroma_w, write_chroma_h) = (write_w / 2, write_h / 2); | 14739 | let (write_chroma_w, write_chroma_h) = (write_w / 2, write_h / 2); |
| @@ -14256,7 +14741,7 @@ fn decode_inter_block( | |||
| 14256 | if std::env::var_os("EC_AV1_TELL").is_some() { | 14741 | if std::env::var_os("EC_AV1_TELL").is_some() { |
| 14257 | eprintln!( | 14742 | eprintln!( |
| 14258 | "TELL mi_row={} mi_col={} label=block_entry side={side} tell={} range={}", | 14743 | "TELL mi_row={} mi_col={} label=block_entry side={side} tell={} range={}", |
| 14259 | - r * SUB_MI as usize, c * SUB_MI as usize, dec.debug_bitpos(), dec.debug_state().0 | 14744 | + rmi, cmi, dec.debug_bitpos(), dec.debug_state().0 |
| 14260 | ); | 14745 | ); |
| 14261 | } | 14746 | } |
| 14262 | let skip_mode_ctx = | 14747 | let skip_mode_ctx = |
| @@ -14272,7 +14757,7 @@ fn decode_inter_block( | |||
| 14272 | } | 14757 | } |
| 14273 | // spec 5.11.5 `inter_frame_mode_info`: `inter_segment_id(1)` before | 14758 | // spec 5.11.5 `inter_frame_mode_info`: `inter_segment_id(1)` before |
| 14274 | // `skip_mode`/`skip`, `inter_segment_id(0)` after them. | 14759 | // `skip_mode`/`skip`, `inter_segment_id(0)` after them. |
| 14275 | - let (seg_mi_r, seg_mi_c) = (r * SUB_MI as usize, c * SUB_MI as usize); | 14760 | + let (seg_mi_r, seg_mi_c) = (rmi, cmi); |
| 14276 | let (seg_w_mi, seg_h_mi) = (write_w / 4, write_h / 4); | 14761 | let (seg_w_mi, seg_h_mi) = (write_w / 4, write_h / 4); |
| 14277 | inter_segment_id(dec, cdfs, seg_mi_r, seg_mi_c, seg_w_mi, seg_h_mi, false, true); | 14762 | inter_segment_id(dec, cdfs, seg_mi_r, seg_mi_c, seg_w_mi, seg_h_mi, false, true); |
| 14278 | let skip_mode = skip_mode_present && dec.symbol(&mut cdfs.skip_mode[skip_mode_ctx]) == 1; | 14763 | let skip_mode = skip_mode_present && dec.symbol(&mut cdfs.skip_mode[skip_mode_ctx]) == 1; |
| @@ -14289,21 +14774,27 @@ fn decode_inter_block( | |||
| 14289 | let skip_ctx = usize::from(neighbours.above_skip[cmi]) + usize::from(neighbours.left_skip[rmi]); | 14774 | let skip_ctx = usize::from(neighbours.above_skip[cmi]) + usize::from(neighbours.left_skip[rmi]); |
| 14290 | let skip = skip_mode || dec.symbol(&mut cdfs.skip[skip_ctx]) == 1; | 14775 | let skip = skip_mode || dec.symbol(&mut cdfs.skip[skip_ctx]) == 1; |
| 14291 | inter_segment_id(dec, cdfs, seg_mi_r, seg_mi_c, seg_w_mi, seg_h_mi, skip, false); | 14776 | inter_segment_id(dec, cdfs, seg_mi_r, seg_mi_c, seg_w_mi, seg_h_mi, skip, false); |
| 14292 | - maybe_read_cdef_idx(dec, r * SUB_MI as usize, c * SUB_MI as usize, skip); | 14777 | + maybe_read_cdef_idx(dec, rmi, cmi, skip); |
| 14293 | - maybe_read_delta_q(dec, cdfs, r * SUB_MI as usize, c * SUB_MI as usize, side == 64, skip); | 14778 | + // lane-inter4 r1: spec 5.11.6's `bSize == sbSize` -- a 64x32/64x16 strip |
| 14294 | - maybe_read_delta_lf(dec, cdfs, r * SUB_MI as usize, c * SUB_MI as usize, side == 64, skip); | 14779 | + // is NOT the whole superblock, so its `skip` never suppresses the read. |
| 14780 | + let whole_sb = side == 64 && write_w == 64 && write_h == 64; | ||
| 14781 | + maybe_read_delta_q(dec, cdfs, rmi, cmi, whole_sb, skip); | ||
| 14782 | + maybe_read_delta_lf(dec, cdfs, rmi, cmi, whole_sb, skip); | ||
| 14295 | // lane-warp r5: see `reject_residual` -- a square-block decode of a | 14783 | // lane-warp r5: see `reject_residual` -- a square-block decode of a |
| 14296 | // HORZ_B strip is symbol-exact only for `skip` (no residual, no | 14784 | // HORZ_B strip is symbol-exact only for `skip` (no residual, no |
| 14297 | // motion_mode/warp symbol), so gate here before any further read. | 14785 | // motion_mode/warp symbol), so gate here before any further read. |
| 14298 | - if reject_residual && !skip { | 14786 | + if reject_residual && !skip && !rect_inter_residual_supported(write_w, write_h) { |
| 14787 | + if std::env::var_os("EC_AV1_RECT_DUMP").is_some() { | ||
| 14788 | + eprintln!("EC_RECT_REFUSE mi_row={rmi} mi_col={cmi} w={write_w} h={write_h} side={side}"); | ||
| 14789 | + } | ||
| 14299 | return Err(unsupported( | 14790 | return Err(unsupported( |
| 14300 | "a non-skip rectangular (HORZ/VERT/HORZ_B) strip needs rectangular residual coding", | 14791 | "a non-skip rectangular (HORZ/VERT/HORZ_B) strip needs rectangular residual coding", |
| 14301 | )); | 14792 | )); |
| 14302 | } | 14793 | } |
| 14303 | 14794 | ||
| 14304 | let (has_above, has_left) = ( | 14795 | let (has_above, has_left) = ( |
| 14305 | - r > neighbours.tile_row0_mi / (SUB / MI), | 14796 | + rmi > neighbours.tile_row0_mi, |
| 14306 | - c > neighbours.tile_col0_mi / (SUB / MI), | 14797 | + cmi > neighbours.tile_col0_mi, |
| 14307 | ); | 14798 | ); |
| 14308 | let (above_inter, left_inter) = (neighbours.above_inter[cmi], neighbours.left_inter[rmi]); | 14799 | let (above_inter, left_inter) = (neighbours.above_inter[cmi], neighbours.left_inter[rmi]); |
| 14309 | let ii_ctx = intra_inter_ctx(has_above, has_left, above_inter, left_inter); | 14800 | let ii_ctx = intra_inter_ctx(has_above, has_left, above_inter, left_inter); |
| @@ -14311,15 +14802,15 @@ fn decode_inter_block( | |||
| 14311 | if std::env::var_os("EC_TRACE_MODE").is_some() { | 14802 | if std::env::var_os("EC_TRACE_MODE").is_some() { |
| 14312 | eprintln!( | 14803 | eprintln!( |
| 14313 | "EC_MODE mi_row={} mi_col={} rng={}", | 14804 | "EC_MODE mi_row={} mi_col={} rng={}", |
| 14314 | - r * SUB_MI as usize, | 14805 | + rmi, |
| 14315 | - c * SUB_MI as usize, | 14806 | + cmi, |
| 14316 | dec.debug_state().0 | 14807 | dec.debug_state().0 |
| 14317 | ); | 14808 | ); |
| 14318 | } | 14809 | } |
| 14319 | if std::env::var_os("EC_AV1_TELL").is_some() { | 14810 | if std::env::var_os("EC_AV1_TELL").is_some() { |
| 14320 | eprintln!( | 14811 | eprintln!( |
| 14321 | "TELL mi_row={} mi_col={} label=post_is_inter skip_mode={skip_mode} skip={skip} is_inter={is_inter} tell={} range={}", | 14812 | "TELL mi_row={} mi_col={} label=post_is_inter skip_mode={skip_mode} skip={skip} is_inter={is_inter} tell={} range={}", |
| 14322 | - r * SUB_MI as usize, c * SUB_MI as usize, dec.debug_bitpos(), dec.debug_state().0 | 14813 | + rmi, cmi, dec.debug_bitpos(), dec.debug_state().0 |
| 14323 | ); | 14814 | ); |
| 14324 | } | 14815 | } |
| 14325 | 14816 | ||
| @@ -14339,7 +14830,7 @@ fn decode_inter_block( | |||
| 14339 | // than one luma transform -- read back by the residual loop, the | 14830 | // than one luma transform -- read back by the residual loop, the |
| 14340 | // coefficient-context write-back and the loop-filter grid fill below. | 14831 | // coefficient-context write-back and the loop-filter grid fill below. |
| 14341 | let mut vartx_leaves: Option<Vec<(usize, usize, usize)>> = None; | 14832 | let mut vartx_leaves: Option<Vec<(usize, usize, usize)>> = None; |
| 14342 | - let at_mi = (r * (SUB / MI), c * (SUB / MI)); | 14833 | + let at_mi = at; |
| 14343 | if is_inter { | 14834 | if is_inter { |
| 14344 | let above_nbr = has_above.then(|| NeighbourRef { | 14835 | let above_nbr = has_above.then(|| NeighbourRef { |
| 14345 | is_inter: above_inter, | 14836 | is_inter: above_inter, |
| @@ -14384,7 +14875,7 @@ fn decode_inter_block( | |||
| 14384 | neighbours.left_ref[rmi], | 14875 | neighbours.left_ref[rmi], |
| 14385 | ) | 14876 | ) |
| 14386 | }; | 14877 | }; |
| 14387 | - let (mi_row, mi_col) = (r * SUB_MI as usize, c * SUB_MI as usize); | 14878 | + let (mi_row, mi_col) = (rmi, cmi); |
| 14388 | // lane-rect r2: true footprint, mirroring the single-ref path below. | 14879 | // lane-rect r2: true footprint, mirroring the single-ref path below. |
| 14389 | let bw4 = write_w / 4; | 14880 | let bw4 = write_w / 4; |
| 14390 | let bh4 = write_h / 4; | 14881 | let bh4 = write_h / 4; |
| @@ -15102,17 +15593,32 @@ fn decode_inter_block( | |||
| 15102 | mc::combine_compound(&inter0_v, &inter1_v, fwd_offset, bck_offset, &mut pred_v); | 15593 | mc::combine_compound(&inter0_v, &inter1_v, fwd_offset, bck_offset, &mut pred_v); |
| 15103 | } | 15594 | } |
| 15104 | 15595 | ||
| 15105 | - vartx_leaves = read_block_tx_size( | 15596 | + // lane-inter4 r2: a rectangular strip's transform tree starts from |
| 15106 | - dec, | 15597 | + // its own rect `max_txsize_rect_lookup` entry, not a square one. |
| 15107 | - cdfs, | 15598 | + let rect_tu = (write_w, write_h) != (side, side); |
| 15108 | - neighbours, | 15599 | + vartx_leaves = if rect_tu { |
| 15109 | - at_mi, | 15600 | + read_block_tx_size_rect( |
| 15110 | - side, | 15601 | + dec, |
| 15111 | - (mi_cols as usize, mi_rows as usize), | 15602 | + cdfs, |
| 15112 | - true, | 15603 | + neighbours, |
| 15113 | - skip, | 15604 | + at_mi, |
| 15114 | - )? | 15605 | + (write_w, write_h), |
| 15115 | - .1; | 15606 | + (mi_cols as usize, mi_rows as usize), |
| 15607 | + skip, | ||
| 15608 | + )? | ||
| 15609 | + } else { | ||
| 15610 | + read_block_tx_size( | ||
| 15611 | + dec, | ||
| 15612 | + cdfs, | ||
| 15613 | + neighbours, | ||
| 15614 | + at_mi, | ||
| 15615 | + side, | ||
| 15616 | + (mi_cols as usize, mi_rows as usize), | ||
| 15617 | + true, | ||
| 15618 | + skip, | ||
| 15619 | + )? | ||
| 15620 | + .1 | ||
| 15621 | + }; | ||
| 15116 | if skip { | 15622 | if skip { |
| 15117 | y.reconstruct_mc_rect( | 15623 | y.reconstruct_mc_rect( |
| 15118 | px, | 15624 | px, |
| @@ -15145,7 +15651,14 @@ fn decode_inter_block( | |||
| 15145 | u_grid = vec![0i32; chroma_side * chroma_side]; | 15651 | u_grid = vec![0i32; chroma_side * chroma_side]; |
| 15146 | v_grid = vec![0i32; chroma_side * chroma_side]; | 15652 | v_grid = vec![0i32; chroma_side * chroma_side]; |
| 15147 | } else { | 15653 | } else { |
| 15148 | - let around = neighbours.around(at, side); | 15654 | + // lane-inter4 r2: a rect strip's coefficient context spans its |
| 15655 | + // OWN width above and height left -- reading `side` cells both | ||
| 15656 | + // ways indexes past the tile's last mi row for a bottom strip. | ||
| 15657 | + let around = if rect_tu { | ||
| 15658 | + neighbours.around_mi_rect(at_mi, write_w, write_h) | ||
| 15659 | + } else { | ||
| 15660 | + neighbours.around_mi(at, side) | ||
| 15661 | + }; | ||
| 15149 | let luma_tx_type; | 15662 | let luma_tx_type; |
| 15150 | if let Some(leaves) = vartx_leaves.clone() { | 15663 | if let Some(leaves) = vartx_leaves.clone() { |
| 15151 | // spec 5.11.17's transform tree, leaf by leaf in the order | 15664 | // spec 5.11.17's transform tree, leaf by leaf in the order |
| @@ -15192,6 +15705,26 @@ fn decode_inter_block( | |||
| 15192 | // inherits the *first* (top-left) luma unit's coded type. | 15705 | // inherits the *first* (top-left) luma unit's coded type. |
| 15193 | luma_tx_type = first_tx_type; | 15706 | luma_tx_type = first_tx_type; |
| 15194 | luma_grid = vec![0i32; side * side]; | 15707 | luma_grid = vec![0i32; side * side]; |
| 15708 | + } else if rect_tu { | ||
| 15709 | + // The whole-block rectangular transform unit | ||
| 15710 | + // (`txfm_partition` said 0 at depth 0). | ||
| 15711 | + let (grid, tx_type) = read_inter_plane_rect( | ||
| 15712 | + dec, | ||
| 15713 | + cdfs, | ||
| 15714 | + rect_inter_luma_set(write_w, write_h), | ||
| 15715 | + (write_w, write_h), | ||
| 15716 | + side, | ||
| 15717 | + 0, | ||
| 15718 | + around[0], | ||
| 15719 | + mode_for_tx, | ||
| 15720 | + y, | ||
| 15721 | + px, | ||
| 15722 | + py, | ||
| 15723 | + &pred_y, | ||
| 15724 | + None, | ||
| 15725 | + )?; | ||
| 15726 | + luma_tx_type = tx_type; | ||
| 15727 | + luma_grid = embed_rect_grid(&grid, write_w, write_h, side); | ||
| 15195 | } else { | 15728 | } else { |
| 15196 | (luma_grid, luma_tx_type) = read_inter_plane( | 15729 | (luma_grid, luma_tx_type) = read_inter_plane( |
| 15197 | dec, | 15730 | dec, |
| @@ -15211,6 +15744,55 @@ fn decode_inter_block( | |||
| 15211 | None, | 15744 | None, |
| 15212 | )?; | 15745 | )?; |
| 15213 | } | 15746 | } |
| 15747 | + if rect_tu { | ||
| 15748 | + // `av1_get_max_uv_txsize(bsize)`: the chroma transform of a | ||
| 15749 | + // 2:1 strip is the strip's own rect chroma size (16x8 / | ||
| 15750 | + // 8x16), one unit for the whole block, and it codes no | ||
| 15751 | + // `tx_type` symbol -- it inherits the luma unit's. | ||
| 15752 | + let (uw, uh) = (write_chroma_w, write_chroma_h); | ||
| 15753 | + u_grid = embed_rect_grid( | ||
| 15754 | + &read_inter_plane_rect( | ||
| 15755 | + dec, | ||
| 15756 | + cdfs, | ||
| 15757 | + rect_inter_chroma_set(write_chroma_w, write_chroma_h), | ||
| 15758 | + (uw, uh), | ||
| 15759 | + chroma_side, | ||
| 15760 | + 1, | ||
| 15761 | + around[1], | ||
| 15762 | + mode_for_tx, | ||
| 15763 | + u, | ||
| 15764 | + cpx, | ||
| 15765 | + cpy, | ||
| 15766 | + &pred_u, | ||
| 15767 | + Some(luma_tx_type), | ||
| 15768 | + )? | ||
| 15769 | + .0, | ||
| 15770 | + uw, | ||
| 15771 | + uh, | ||
| 15772 | + chroma_side, | ||
| 15773 | + ); | ||
| 15774 | + v_grid = embed_rect_grid( | ||
| 15775 | + &read_inter_plane_rect( | ||
| 15776 | + dec, | ||
| 15777 | + cdfs, | ||
| 15778 | + rect_inter_chroma_set(write_chroma_w, write_chroma_h), | ||
| 15779 | + (uw, uh), | ||
| 15780 | + chroma_side, | ||
| 15781 | + 2, | ||
| 15782 | + around[2], | ||
| 15783 | + mode_for_tx, | ||
| 15784 | + v, | ||
| 15785 | + cpx, | ||
| 15786 | + cpy, | ||
| 15787 | + &pred_v, | ||
| 15788 | + Some(luma_tx_type), | ||
| 15789 | + )? | ||
| 15790 | + .0, | ||
| 15791 | + uw, | ||
| 15792 | + uh, | ||
| 15793 | + chroma_side, | ||
| 15794 | + ); | ||
| 15795 | + } else { | ||
| 15214 | u_grid = read_inter_plane( | 15796 | u_grid = read_inter_plane( |
| 15215 | dec, | 15797 | dec, |
| 15216 | cdfs, | 15798 | cdfs, |
| @@ -15247,6 +15829,7 @@ fn decode_inter_block( | |||
| 15247 | None, | 15829 | None, |
| 15248 | )? | 15830 | )? |
| 15249 | .0; | 15831 | .0; |
| 15832 | + } | ||
| 15250 | } | 15833 | } |
| 15251 | } else { | 15834 | } else { |
| 15252 | let ref_frame = | 15835 | let ref_frame = |
| @@ -15260,7 +15843,7 @@ fn decode_inter_block( | |||
| 15260 | ); | 15843 | ); |
| 15261 | ref_frame_for_lf = ref_frame; | 15844 | ref_frame_for_lf = ref_frame; |
| 15262 | if std::env::var_os("EC_AV1_TELL").is_some() { | 15845 | if std::env::var_os("EC_AV1_TELL").is_some() { |
| 15263 | - let (mi_row, mi_col) = (r * SUB_MI as usize, c * SUB_MI as usize); | 15846 | + let (mi_row, mi_col) = (rmi, cmi); |
| 15264 | eprintln!( | 15847 | eprintln!( |
| 15265 | "TELL mi_row={mi_row} mi_col={mi_col} label=post_ref_frame ref={ref_frame} tell={} range={}", | 15848 | "TELL mi_row={mi_row} mi_col={mi_col} label=post_ref_frame ref={ref_frame} tell={} range={}", |
| 15266 | dec.debug_bitpos(), dec.debug_state().0 | 15849 | dec.debug_bitpos(), dec.debug_state().0 |
| @@ -15288,7 +15871,7 @@ fn decode_inter_block( | |||
| 15288 | } | 15871 | } |
| 15289 | }; | 15872 | }; |
| 15290 | 15873 | ||
| 15291 | - let (mi_row, mi_col) = (r * SUB_MI as usize, c * SUB_MI as usize); | 15874 | + let (mi_row, mi_col) = (rmi, cmi); |
| 15292 | // lane-rect r2: the mv stack must be queried with the block's | 15875 | // lane-rect r2: the mv stack must be queried with the block's |
| 15293 | // REAL extent (libaom `av1_get_mv_refs` gets bw4/bh4 from | 15876 | // REAL extent (libaom `av1_get_mv_refs` gets bw4/bh4 from |
| 15294 | // xd->width/xd->height, not a square guess) -- `write_w`/ | 15877 | // xd->width/xd->height, not a square guess) -- `write_w`/ |
| @@ -15335,6 +15918,10 @@ fn decode_inter_block( | |||
| 15335 | ); | 15918 | ); |
| 15336 | let not_new = dec.symbol(&mut cdfs.new_mv[stack.new_mv_ctx]) == 1; | 15919 | let not_new = dec.symbol(&mut cdfs.new_mv[stack.new_mv_ctx]) == 1; |
| 15337 | let mut is_globalmv = false; | 15920 | let mut is_globalmv = false; |
| 15921 | + // lane-interbis r1: which single-ref mode this block resolved to, | ||
| 15922 | + // in the oracle's own numbering (NEARESTMV=13 .. NEWMV=16), for | ||
| 15923 | + // the `EC_MODE_VAL` value ladder below. | ||
| 15924 | + let mut dbg_mode = 16u32; | ||
| 15338 | let (mv, is_new_mv) = if !not_new { | 15925 | let (mv, is_new_mv) = if !not_new { |
| 15339 | // NEWMV (spec 5.11.24's `read_drl_idx`, `RefMvIdx` starting at 0): | 15926 | // NEWMV (spec 5.11.24's `read_drl_idx`, `RefMvIdx` starting at 0): |
| 15340 | // read at most two `drl_mode` bits, one per stack entry past the | 15927 | // read at most two `drl_mode` bits, one per stack entry past the |
| @@ -15367,9 +15954,11 @@ fn decode_inter_block( | |||
| 15367 | let mv = if !not_zero { | 15954 | let mv = if !not_zero { |
| 15368 | // GLOBALMV: `gm_get_motion_vector` (spec 7.10.2.1), already | 15955 | // GLOBALMV: `gm_get_motion_vector` (spec 7.10.2.1), already |
| 15369 | // computed at this block's own position in `gm_table`. | 15956 | // computed at this block's own position in `gm_table`. |
| 15957 | + dbg_mode = 15; | ||
| 15370 | gm_table[(ref_frame - LAST_FRAME) as usize] | 15958 | gm_table[(ref_frame - LAST_FRAME) as usize] |
| 15371 | } else { | 15959 | } else { |
| 15372 | let nearest = dec.symbol(&mut cdfs.ref_mv[stack.ref_mv_ctx]) == 0; | 15960 | let nearest = dec.symbol(&mut cdfs.ref_mv[stack.ref_mv_ctx]) == 0; |
| 15961 | + dbg_mode = if nearest { 13 } else { 14 }; | ||
| 15373 | if nearest { | 15962 | if nearest { |
| 15374 | stack.nearest_mv | 15963 | stack.nearest_mv |
| 15375 | } else { | 15964 | } else { |
| @@ -15391,6 +15980,21 @@ fn decode_inter_block( | |||
| 15391 | }; | 15980 | }; |
| 15392 | (mv, false) | 15981 | (mv, false) |
| 15393 | }; | 15982 | }; |
| 15983 | + if std::env::var_os("EC_TRACE_MODE").is_some() { | ||
| 15984 | + for (i, e) in stack.entries.iter().enumerate() { | ||
| 15985 | + eprintln!( | ||
| 15986 | + "EC_STACK mi_row={mi_row} mi_col={mi_col} ref={ref_frame} i={i} this=({},{}) comp=(0,0) w={}", | ||
| 15987 | + e.mv.0, e.mv.1, e.weight | ||
| 15988 | + ); | ||
| 15989 | + } | ||
| 15990 | + eprintln!( | ||
| 15991 | + "EC_MODE_VAL mi_row={mi_row} mi_col={mi_col} mode={dbg_mode} ref0={ref_frame} ref1=-1 mv0=({},{}) stack={} rng={}", | ||
| 15992 | + mv.0, | ||
| 15993 | + mv.1, | ||
| 15994 | + stack.entries.len(), | ||
| 15995 | + dec.debug_state().0 | ||
| 15996 | + ); | ||
| 15997 | + } | ||
| 15394 | // lane-gm r2: the two libaom predicates single-ref GLOBALMV | 15998 | // lane-gm r2: the two libaom predicates single-ref GLOBALMV |
| 15395 | // blocks need -- `is_global_mv_block` (blockd.h:421-429, mode | 15999 | // blocks need -- `is_global_mv_block` (blockd.h:421-429, mode |
| 15396 | // GLOBAL* AND model > TRANSLATION AND min(bw,bh) >= 8px, gating | 16000 | // GLOBAL* AND model > TRANSLATION AND min(bw,bh) >= 8px, gating |
| @@ -15422,8 +16026,22 @@ fn decode_inter_block( | |||
| 15422 | // `size_group_lookup`: BLOCK_16X16 -> 2, BLOCK_32X32 -> 3. | 16026 | // `size_group_lookup`: BLOCK_16X16 -> 2, BLOCK_32X32 -> 3. |
| 15423 | let mut interintra_mode: Option<u8> = None; | 16027 | let mut interintra_mode: Option<u8> = None; |
| 15424 | let mut wedge_mask: Option<(&'static [u8], usize)> = None; | 16028 | let mut wedge_mask: Option<(&'static [u8], usize)> = None; |
| 15425 | - if enable_interintra_compound && !skip_mode && (side == 16 || side == 32) { | 16029 | + // lane-inter4 r1: `is_interintra_allowed_bsize` is |
| 15426 | - let bsize_group = if side == 16 { 2 } else { 3 }; | 16030 | + // `BLOCK_8X8..=BLOCK_32X32` in libaom's enum ORDER, which excludes |
| 16031 | + // every 1:4 shape (BLOCK_8X32 = 18, BLOCK_32X8 = 19) even though | ||
| 16032 | + // both dimensions are in range -- reading this symbol on a 1:4 | ||
| 16033 | + // strip is a symbol the reference never wrote. | ||
| 16034 | + let interintra_shape = | ||
| 16035 | + write_w.max(write_h) <= 32 && write_w.max(write_h) / write_w.min(write_h) <= 2; | ||
| 16036 | + if enable_interintra_compound | ||
| 16037 | + && !skip_mode | ||
| 16038 | + && (side == 16 || side == 32) | ||
| 16039 | + && interintra_shape | ||
| 16040 | + { | ||
| 16041 | + // lane-inter4 r3: `size_group_lookup` reads the block's | ||
| 16042 | + // TRUE footprint -- a 16x8 strip is group 1, a 32x16 strip | ||
| 16043 | + // group 2, not their square `side`'s 2/3. | ||
| 16044 | + let bsize_group = size_group_wh(write_w, write_h); | ||
| 15427 | let interintra = dec.symbol(&mut cdfs.interintra[bsize_group]) == 1; | 16045 | let interintra = dec.symbol(&mut cdfs.interintra[bsize_group]) == 1; |
| 15428 | if interintra { | 16046 | if interintra { |
| 15429 | // lane-interintra r1 (decodemv.c 1540-1555): interintra_mode, | 16047 | // lane-interintra r1 (decodemv.c 1540-1555): interintra_mode, |
| @@ -15518,12 +16136,29 @@ fn decode_inter_block( | |||
| 15518 | // (libaom `motion_mode_cdf[mbmi->bsize]`: BLOCK_16X32 -> 4, | 16136 | // (libaom `motion_mode_cdf[mbmi->bsize]`: BLOCK_16X32 -> 4, |
| 15519 | // BLOCK_32X16 -> 5 in our packed table) -- rect-flake-1's | 16137 | // BLOCK_32X16 -> 5 in our packed table) -- rect-flake-1's |
| 15520 | // strip motion_mode read diverged on the square row. | 16138 | // strip motion_mode read diverged on the square row. |
| 15521 | - let bsize_idx = if write_w == write_h { | 16139 | + // lane-inter4 r1: every rect shape this decoder can now |
| 15522 | - (write_w.trailing_zeros() - 3) as usize | 16140 | + // reach reads its OWN libaom bsize row (the packed order is |
| 15523 | - } else if write_w == 16 { | 16141 | + // documented on `cdf::MOTION_MODE`); a wrong row is a wrong |
| 15524 | - 4 | 16142 | + // interval narrowing, not a wrong value (class |
| 15525 | - } else { | 16143 | + // wrong-alphabet-same-value). |
| 15526 | - 5 | 16144 | + let bsize_idx = match (write_w, write_h) { |
| 16145 | + (w, h) if w == h => (w.trailing_zeros() - 3) as usize, | ||
| 16146 | + (16, 32) => 4, | ||
| 16147 | + (32, 16) => 5, | ||
| 16148 | + (32, 64) => 6, | ||
| 16149 | + (64, 32) => 7, | ||
| 16150 | + (8, 32) => 8, | ||
| 16151 | + (32, 8) => 9, | ||
| 16152 | + (16, 64) => 10, | ||
| 16153 | + (64, 16) => 11, | ||
| 16154 | + // lane-inter4 r3: the 16x16-level rect inter leaves. | ||
| 16155 | + (8, 16) => 12, | ||
| 16156 | + (16, 8) => 13, | ||
| 16157 | + _ => { | ||
| 16158 | + return Err(unsupported( | ||
| 16159 | + "a motion_mode symbol for a block shape with no CDF row here", | ||
| 16160 | + )); | ||
| 16161 | + } | ||
| 15527 | }; | 16162 | }; |
| 15528 | // `motion_mode_allowed` reads the 3-symbol `motion_mode_cdf` | 16163 | // `motion_mode_allowed` reads the 3-symbol `motion_mode_cdf` |
| 15529 | // instead of the 2-symbol `obmc_cdf` exactly when | 16164 | // instead of the 2-symbol `obmc_cdf` exactly when |
| @@ -15936,17 +16571,32 @@ fn decode_inter_block( | |||
| 15936 | interintra_blend(v, cpx, cpy, chroma_side, ii, wedge_mask, &mut pred_v); | 16571 | interintra_blend(v, cpx, cpy, chroma_side, ii, wedge_mask, &mut pred_v); |
| 15937 | } | 16572 | } |
| 15938 | 16573 | ||
| 15939 | - vartx_leaves = read_block_tx_size( | 16574 | + // lane-inter4 r2: a rectangular strip's transform tree starts from |
| 15940 | - dec, | 16575 | + // its own rect `max_txsize_rect_lookup` entry, not a square one. |
| 15941 | - cdfs, | 16576 | + let rect_tu = (write_w, write_h) != (side, side); |
| 15942 | - neighbours, | 16577 | + vartx_leaves = if rect_tu { |
| 15943 | - at_mi, | 16578 | + read_block_tx_size_rect( |
| 15944 | - side, | 16579 | + dec, |
| 15945 | - (mi_cols as usize, mi_rows as usize), | 16580 | + cdfs, |
| 15946 | - true, | 16581 | + neighbours, |
| 15947 | - skip, | 16582 | + at_mi, |
| 15948 | - )? | 16583 | + (write_w, write_h), |
| 15949 | - .1; | 16584 | + (mi_cols as usize, mi_rows as usize), |
| 16585 | + skip, | ||
| 16586 | + )? | ||
| 16587 | + } else { | ||
| 16588 | + read_block_tx_size( | ||
| 16589 | + dec, | ||
| 16590 | + cdfs, | ||
| 16591 | + neighbours, | ||
| 16592 | + at_mi, | ||
| 16593 | + side, | ||
| 16594 | + (mi_cols as usize, mi_rows as usize), | ||
| 16595 | + true, | ||
| 16596 | + skip, | ||
| 16597 | + )? | ||
| 16598 | + .1 | ||
| 16599 | + }; | ||
| 15950 | if skip { | 16600 | if skip { |
| 15951 | y.reconstruct_mc_rect( | 16601 | y.reconstruct_mc_rect( |
| 15952 | px, | 16602 | px, |
| @@ -15979,7 +16629,14 @@ fn decode_inter_block( | |||
| 15979 | u_grid = vec![0i32; chroma_side * chroma_side]; | 16629 | u_grid = vec![0i32; chroma_side * chroma_side]; |
| 15980 | v_grid = vec![0i32; chroma_side * chroma_side]; | 16630 | v_grid = vec![0i32; chroma_side * chroma_side]; |
| 15981 | } else { | 16631 | } else { |
| 15982 | - let around = neighbours.around(at, side); | 16632 | + // lane-inter4 r2: a rect strip's coefficient context spans its |
| 16633 | + // OWN width above and height left -- reading `side` cells both | ||
| 16634 | + // ways indexes past the tile's last mi row for a bottom strip. | ||
| 16635 | + let around = if rect_tu { | ||
| 16636 | + neighbours.around_mi_rect(at_mi, write_w, write_h) | ||
| 16637 | + } else { | ||
| 16638 | + neighbours.around_mi(at, side) | ||
| 16639 | + }; | ||
| 15983 | let luma_tx_type; | 16640 | let luma_tx_type; |
| 15984 | if let Some(leaves) = vartx_leaves.clone() { | 16641 | if let Some(leaves) = vartx_leaves.clone() { |
| 15985 | // spec 5.11.17's transform tree, leaf by leaf in the order | 16642 | // spec 5.11.17's transform tree, leaf by leaf in the order |
| @@ -16026,6 +16683,26 @@ fn decode_inter_block( | |||
| 16026 | // inherits the *first* (top-left) luma unit's coded type. | 16683 | // inherits the *first* (top-left) luma unit's coded type. |
| 16027 | luma_tx_type = first_tx_type; | 16684 | luma_tx_type = first_tx_type; |
| 16028 | luma_grid = vec![0i32; side * side]; | 16685 | luma_grid = vec![0i32; side * side]; |
| 16686 | + } else if rect_tu { | ||
| 16687 | + // The whole-block rectangular transform unit | ||
| 16688 | + // (`txfm_partition` said 0 at depth 0). | ||
| 16689 | + let (grid, tx_type) = read_inter_plane_rect( | ||
| 16690 | + dec, | ||
| 16691 | + cdfs, | ||
| 16692 | + rect_inter_luma_set(write_w, write_h), | ||
| 16693 | + (write_w, write_h), | ||
| 16694 | + side, | ||
| 16695 | + 0, | ||
| 16696 | + around[0], | ||
| 16697 | + mode_for_tx, | ||
| 16698 | + y, | ||
| 16699 | + px, | ||
| 16700 | + py, | ||
| 16701 | + &pred_y, | ||
| 16702 | + None, | ||
| 16703 | + )?; | ||
| 16704 | + luma_tx_type = tx_type; | ||
| 16705 | + luma_grid = embed_rect_grid(&grid, write_w, write_h, side); | ||
| 16029 | } else { | 16706 | } else { |
| 16030 | (luma_grid, luma_tx_type) = read_inter_plane( | 16707 | (luma_grid, luma_tx_type) = read_inter_plane( |
| 16031 | dec, | 16708 | dec, |
| @@ -16045,6 +16722,55 @@ fn decode_inter_block( | |||
| 16045 | None, | 16722 | None, |
| 16046 | )?; | 16723 | )?; |
| 16047 | } | 16724 | } |
| 16725 | + if rect_tu { | ||
| 16726 | + // `av1_get_max_uv_txsize(bsize)`: the chroma transform of a | ||
| 16727 | + // 2:1 strip is the strip's own rect chroma size (16x8 / | ||
| 16728 | + // 8x16), one unit for the whole block, and it codes no | ||
| 16729 | + // `tx_type` symbol -- it inherits the luma unit's. | ||
| 16730 | + let (uw, uh) = (write_chroma_w, write_chroma_h); | ||
| 16731 | + u_grid = embed_rect_grid( | ||
| 16732 | + &read_inter_plane_rect( | ||
| 16733 | + dec, | ||
| 16734 | + cdfs, | ||
| 16735 | + rect_inter_chroma_set(write_chroma_w, write_chroma_h), | ||
| 16736 | + (uw, uh), | ||
| 16737 | + chroma_side, | ||
| 16738 | + 1, | ||
| 16739 | + around[1], | ||
| 16740 | + mode_for_tx, | ||
| 16741 | + u, | ||
| 16742 | + cpx, | ||
| 16743 | + cpy, | ||
| 16744 | + &pred_u, | ||
| 16745 | + Some(luma_tx_type), | ||
| 16746 | + )? | ||
| 16747 | + .0, | ||
| 16748 | + uw, | ||
| 16749 | + uh, | ||
| 16750 | + chroma_side, | ||
| 16751 | + ); | ||
| 16752 | + v_grid = embed_rect_grid( | ||
| 16753 | + &read_inter_plane_rect( | ||
| 16754 | + dec, | ||
| 16755 | + cdfs, | ||
| 16756 | + rect_inter_chroma_set(write_chroma_w, write_chroma_h), | ||
| 16757 | + (uw, uh), | ||
| 16758 | + chroma_side, | ||
| 16759 | + 2, | ||
| 16760 | + around[2], | ||
| 16761 | + mode_for_tx, | ||
| 16762 | + v, | ||
| 16763 | + cpx, | ||
| 16764 | + cpy, | ||
| 16765 | + &pred_v, | ||
| 16766 | + Some(luma_tx_type), | ||
| 16767 | + )? | ||
| 16768 | + .0, | ||
| 16769 | + uw, | ||
| 16770 | + uh, | ||
| 16771 | + chroma_side, | ||
| 16772 | + ); | ||
| 16773 | + } else { | ||
| 16048 | u_grid = read_inter_plane( | 16774 | u_grid = read_inter_plane( |
| 16049 | dec, | 16775 | dec, |
| 16050 | cdfs, | 16776 | cdfs, |
| @@ -16081,6 +16807,7 @@ fn decode_inter_block( | |||
| 16081 | None, | 16807 | None, |
| 16082 | )? | 16808 | )? |
| 16083 | .0; | 16809 | .0; |
| 16810 | + } | ||
| 16084 | } | 16811 | } |
| 16085 | } | 16812 | } |
| 16086 | } else { | 16813 | } else { |
| @@ -16096,7 +16823,7 @@ fn decode_inter_block( | |||
| 16096 | this decoder does not code yet", | 16823 | this decoder does not code yet", |
| 16097 | )); | 16824 | )); |
| 16098 | } | 16825 | } |
| 16099 | - let mode = dec.symbol(&mut cdfs.y_mode[size_group]); | 16826 | + let mode = dec.symbol(&mut cdfs.y_mode[size_group_wh(write_w, write_h)]); |
| 16100 | if mode >= 13 { | 16827 | if mode >= 13 { |
| 16101 | return Err(unsupported( | 16828 | return Err(unsupported( |
| 16102 | "an intra mode this decoder does not code (round 2)", | 16829 | "an intra mode this decoder does not code (round 2)", |
| @@ -16202,7 +16929,7 @@ fn decode_inter_block( | |||
| 16202 | block_filter = [3, 3]; | 16929 | block_filter = [3, 3]; |
| 16203 | ref_frame_for_lf = 0; | 16930 | ref_frame_for_lf = 0; |
| 16204 | globalmv_for_lf = false; | 16931 | globalmv_for_lf = false; |
| 16205 | - let (mi_row, mi_col) = (r * SUB_MI as usize, c * SUB_MI as usize); | 16932 | + let (mi_row, mi_col) = (rmi, cmi); |
| 16206 | for dr in 0..side / 4 { | 16933 | for dr in 0..side / 4 { |
| 16207 | for dc in 0..side / 4 { | 16934 | for dc in 0..side / 4 { |
| 16208 | grid.set( | 16935 | grid.set( |
| @@ -16343,7 +17070,7 @@ fn decode_inter_block( | |||
| 16343 | u_grid = vec![0i32; chroma_side * chroma_side]; | 17070 | u_grid = vec![0i32; chroma_side * chroma_side]; |
| 16344 | v_grid = vec![0i32; chroma_side * chroma_side]; | 17071 | v_grid = vec![0i32; chroma_side * chroma_side]; |
| 16345 | } else { | 17072 | } else { |
| 16346 | - let around = neighbours.around(at, side); | 17073 | + let around = neighbours.around_mi(at, side); |
| 16347 | luma_grid = if split_luma { | 17074 | luma_grid = if split_luma { |
| 16348 | // Already coded and reconstructed unit by unit above; the | 17075 | // Already coded and reconstructed unit by unit above; the |
| 16349 | // block-level grid is only the neighbour write-back's input, | 17076 | // block-level grid is only the neighbour write-back's input, |
| @@ -16429,7 +17156,7 @@ fn decode_inter_block( | |||
| 16429 | if std::env::var_os("EC_AV1_TELL").is_some() { | 17156 | if std::env::var_os("EC_AV1_TELL").is_some() { |
| 16430 | eprintln!( | 17157 | eprintln!( |
| 16431 | "TELL mi_row={} mi_col={} label=block_end tell={} range={}", | 17158 | "TELL mi_row={} mi_col={} label=block_end tell={} range={}", |
| 16432 | - r * SUB_MI as usize, c * SUB_MI as usize, dec.debug_bitpos(), dec.debug_state().0 | 17159 | + rmi, cmi, dec.debug_bitpos(), dec.debug_state().0 |
| 16433 | ); | 17160 | ); |
| 16434 | } | 17161 | } |
| 16435 | if vartx_leaves.is_some() { | 17162 | if vartx_leaves.is_some() { |
| @@ -16437,9 +17164,9 @@ fn decode_inter_block( | |||
| 16437 | // ([`Neighbours::record_mi_luma`] above); this writes everything else | 17164 | // ([`Neighbours::record_mi_luma`] above); this writes everything else |
| 16438 | // [`Neighbours::record_rect`] would (a var-tx block is always square, | 17165 | // [`Neighbours::record_rect`] would (a var-tx block is always square, |
| 16439 | // so `write_w == write_h == side`). | 17166 | // so `write_w == write_h == side`). |
| 16440 | - neighbours.record_split_luma(at, side, mode_for_tx, uv_predict_mode, [&u_grid, &v_grid]); | 17167 | + neighbours.record_split_luma_rect_mi(at, side, side, mode_for_tx, uv_predict_mode, [&u_grid, &v_grid]); |
| 16441 | } else { | 17168 | } else { |
| 16442 | - neighbours.record_rect( | 17169 | + neighbours.record_rect_mi( |
| 16443 | at, | 17170 | at, |
| 16444 | write_w, | 17171 | write_w, |
| 16445 | write_h, | 17172 | write_h, |
| @@ -16448,10 +17175,10 @@ fn decode_inter_block( | |||
| 16448 | &[luma_grid, u_grid, v_grid], | 17175 | &[luma_grid, u_grid, v_grid], |
| 16449 | ); | 17176 | ); |
| 16450 | } | 17177 | } |
| 16451 | - neighbours.record_inter_rect( | 17178 | + neighbours.record_inter_rect_mi( |
| 16452 | at, | 17179 | at, |
| 16453 | - write_w, | 17180 | + write_w / MI, |
| 16454 | - write_h, | 17181 | + write_h / MI, |
| 16455 | skip, | 17182 | skip, |
| 16456 | is_inter, | 17183 | is_inter, |
| 16457 | ref_frame_for_lf, | 17184 | ref_frame_for_lf, |
| @@ -16459,16 +17186,16 @@ fn decode_inter_block( | |||
| 16459 | skip_mode, | 17186 | skip_mode, |
| 16460 | ); | 17187 | ); |
| 16461 | if let Some((ref1, group_idx, idx)) = compound_ctx { | 17188 | if let Some((ref1, group_idx, idx)) = compound_ctx { |
| 16462 | - neighbours.record_compound_ctx_rect(at, write_w, write_h, ref1, group_idx, idx); | 17189 | + neighbours.record_compound_ctx_rect_mi(at, write_w / MI, write_h / MI, ref1, group_idx, idx); |
| 16463 | } | 17190 | } |
| 16464 | neighbours.fill_skip_grid_rect( | 17191 | neighbours.fill_skip_grid_rect( |
| 16465 | - (r * (SUB / MI), c * (SUB / MI)), | 17192 | + (rmi, cmi), |
| 16466 | write_w / MI, | 17193 | write_w / MI, |
| 16467 | write_h / MI, | 17194 | write_h / MI, |
| 16468 | skip, | 17195 | skip, |
| 16469 | ); | 17196 | ); |
| 16470 | neighbours.fill_lf_grid_rect( | 17197 | neighbours.fill_lf_grid_rect( |
| 16471 | - (r * (SUB / MI), c * (SUB / MI)), | 17198 | + (rmi, cmi), |
| 16472 | write_w / MI, | 17199 | write_w / MI, |
| 16473 | write_h / MI, | 17200 | write_h / MI, |
| 16474 | // lane-rect r2: the strip's true TX_32X16/TX_16X32 dims -- the | 17201 | // lane-rect r2: the strip's true TX_32X16/TX_16X32 dims -- the |
| @@ -18456,6 +19183,64 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 18456 | ); | 19183 | ); |
| 18457 | CDEF_TRANSMITTED.with(|c| c.set(false)); | 19184 | CDEF_TRANSMITTED.with(|c| c.set(false)); |
| 18458 | let sb_at = (sb_r as usize * 4, sb_c as usize * 4); | 19185 | let sb_at = (sb_r as usize * 4, sb_c as usize * 4); |
| 19186 | + // lane-inter4 r1: every rect inter piece below is the same | ||
| 19187 | + // `decode_inter_block` call with only position / true footprint / | ||
| 19188 | + // transform-set differing; the macro keeps the new arms readable | ||
| 19189 | + // instead of six more 60-line copies of the argument list. | ||
| 19190 | + macro_rules! inter_piece { | ||
| 19191 | + ($at_mi:expr, $side:expr, $li:expr, $lt:expr, $ch:expr, $ltx:expr, | ||
| 19192 | + $ctx:expr, $sl:expr, $sc:expr, $sg:expr, $ww:expr, $wh:expr) => { | ||
| 19193 | + decode_inter_block( | ||
| 19194 | + &mut dec, | ||
| 19195 | + &mut cdfs, | ||
| 19196 | + &mut neighbours, | ||
| 19197 | + &mut grid, | ||
| 19198 | + $at_mi, | ||
| 19199 | + $side, | ||
| 19200 | + mi_cols, | ||
| 19201 | + mi_rows, | ||
| 19202 | + &mut y, | ||
| 19203 | + &mut u, | ||
| 19204 | + &mut v, | ||
| 19205 | + &ref_y, | ||
| 19206 | + &ref_u, | ||
| 19207 | + &ref_v, | ||
| 19208 | + &ref_slots, | ||
| 19209 | + &sign_bias_table, | ||
| 19210 | + &global_motion, | ||
| 19211 | + base_q_idx, | ||
| 19212 | + $li, | ||
| 19213 | + $lt, | ||
| 19214 | + $ch, | ||
| 19215 | + $ltx, | ||
| 19216 | + $ctx, | ||
| 19217 | + $sl, | ||
| 19218 | + $sc, | ||
| 19219 | + $sg, | ||
| 19220 | + allow_high_precision_mv, | ||
| 19221 | + force_integer_mv, | ||
| 19222 | + interp_fixed, | ||
| 19223 | + enable_dual_filter, | ||
| 19224 | + tpl_frame.as_ref(), | ||
| 19225 | + reference_select, | ||
| 19226 | + enable_masked_compound, | ||
| 19227 | + enable_interintra_compound, | ||
| 19228 | + enable_jnt_comp, | ||
| 19229 | + order_hint_bits, | ||
| 19230 | + order_hint, | ||
| 19231 | + ref_order_hints, | ||
| 19232 | + skip_mode_present, | ||
| 19233 | + skip_mode_frame, | ||
| 19234 | + switchable_motion_mode, | ||
| 19235 | + allow_warped_motion, | ||
| 19236 | + true, | ||
| 19237 | + $ww, | ||
| 19238 | + $wh, | ||
| 19239 | + allow_screen_content_tools, | ||
| 19240 | + frame_width as usize, | ||
| 19241 | + )? | ||
| 19242 | + }; | ||
| 19243 | + } | ||
| 18459 | let sb_ctx = neighbours.partition_ctx(sb_at, SB); | 19244 | let sb_ctx = neighbours.partition_ctx(sb_at, SB); |
| 18460 | let (has_cols, has_rows) = ( | 19245 | let (has_cols, has_rows) = ( |
| 18461 | sb_c * SB_MI + SB_MI / 2 < mi_cols, | 19246 | sb_c * SB_MI + SB_MI / 2 < mi_cols, |
| @@ -18506,7 +19291,7 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 18506 | &mut cdfs, | 19291 | &mut cdfs, |
| 18507 | &mut neighbours, | 19292 | &mut neighbours, |
| 18508 | &mut grid, | 19293 | &mut grid, |
| 18509 | - sb_at, | 19294 | + sub16_to_mi(sb_at), |
| 18510 | SB, | 19295 | SB, |
| 18511 | mi_cols, | 19296 | mi_cols, |
| 18512 | mi_rows, | 19297 | mi_rows, |
| @@ -18552,10 +19337,73 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 18552 | )?; | 19337 | )?; |
| 18553 | continue; | 19338 | continue; |
| 18554 | } | 19339 | } |
| 19340 | + if matches!( | ||
| 19341 | + part64, | ||
| 19342 | + PARTITION_HORZ | PARTITION_VERT | PARTITION_HORZ_4 | PARTITION_VERT_4 | ||
| 19343 | + ) { | ||
| 19344 | + // lane-inter4 r1: the superblock-level rect + 1:4 pairs as | ||
| 19345 | + // inter blocks -- two 64x32 / 32x64 strips, or four 64x16 / | ||
| 19346 | + // 16x64 ones. Each piece keeps `side = SB` for every | ||
| 19347 | + // syntax/CDF/prediction-buffer decision (the square-context | ||
| 19348 | + // corner-cut PARTITION_HORZ already ships at the 32 level) | ||
| 19349 | + // but names its own true footprint through `write_w`/ | ||
| 19350 | + // `write_h`, which is what `motion_mode`'s bsize row, the | ||
| 19351 | + // mv-stack's bw4/bh4, the delta-q `bSize == sbSize` test and | ||
| 19352 | + // every neighbour stamp read. `reject_residual = true`: a | ||
| 19353 | + // non-skip strip refuses by name rather than over-read a | ||
| 19354 | + // square residual (rectangular inter residual coding is not | ||
| 19355 | + // ported -- see lanes/inter4-r1.report.md). | ||
| 19356 | + let horz = matches!(part64, PARTITION_HORZ | PARTITION_HORZ_4); | ||
| 19357 | + let four = matches!(part64, PARTITION_HORZ_4 | PARTITION_VERT_4); | ||
| 19358 | + let base_mi = ( | ||
| 19359 | + sb_r as usize * SB_MI as usize, | ||
| 19360 | + sb_c as usize * SB_MI as usize, | ||
| 19361 | + ); | ||
| 19362 | + let (n_pieces, step_mi) = if four { (4usize, 4usize) } else { (2usize, 8usize) }; | ||
| 19363 | + let (bw, bh) = match (horz, four) { | ||
| 19364 | + (true, false) => (64usize, 32usize), | ||
| 19365 | + (false, false) => (32, 64), | ||
| 19366 | + (true, true) => (64, 16), | ||
| 19367 | + (false, true) => (16, 64), | ||
| 19368 | + }; | ||
| 19369 | + for i in 0..n_pieces { | ||
| 19370 | + let at_mi = if horz { | ||
| 19371 | + (base_mi.0 + i * step_mi, base_mi.1) | ||
| 19372 | + } else { | ||
| 19373 | + (base_mi.0, base_mi.1 + i * step_mi) | ||
| 19374 | + }; | ||
| 19375 | + // libaom `decode_partition`'s own `i > 0` frame-edge break. | ||
| 19376 | + if i > 0 && (at_mi.0 >= mi_rows as usize || at_mi.1 >= mi_cols as usize) { | ||
| 19377 | + break; | ||
| 19378 | + } | ||
| 19379 | + inter_piece!( | ||
| 19380 | + at_mi, | ||
| 19381 | + SB, | ||
| 19382 | + TxbSet::Luma64, | ||
| 19383 | + TxbSet::Luma64, | ||
| 19384 | + TxbSet::Chroma32, | ||
| 19385 | + TX32, | ||
| 19386 | + TX32, | ||
| 19387 | + &scan32, | ||
| 19388 | + &scan32, | ||
| 19389 | + 3, | ||
| 19390 | + bw, | ||
| 19391 | + bh | ||
| 19392 | + ); | ||
| 19393 | + match (horz, four) { | ||
| 19394 | + (true, false) => INTER_SB_HORZ_HITS.with(|c| c.set(c.get() + 1)), | ||
| 19395 | + (false, false) => INTER_SB_VERT_HITS.with(|c| c.set(c.get() + 1)), | ||
| 19396 | + (true, true) => INTER_SB_HORZ4_HITS.with(|c| c.set(c.get() + 1)), | ||
| 19397 | + (false, true) => INTER_SB_VERT4_HITS.with(|c| c.set(c.get() + 1)), | ||
| 19398 | + } | ||
| 19399 | + } | ||
| 19400 | + continue; | ||
| 19401 | + } | ||
| 18555 | if part64 != PARTITION_SPLIT { | 19402 | if part64 != PARTITION_SPLIT { |
| 18556 | return Err(unsupported( | 19403 | return Err(unsupported( |
| 18557 | - "an inter SB-level partition type other than NONE or SPLIT (this decoder's \ | 19404 | + "an inter SB-level AB partition (HORZ_A/HORZ_B/VERT_A/VERT_B; this \ |
| 18558 | - inter tile path recurses a superblock only as SPLIT)", | 19405 | + decoder's inter tile path codes a superblock as NONE, SPLIT, HORZ, \ |
| 19406 | + VERT, HORZ_4 or VERT_4)", | ||
| 18559 | )); | 19407 | )); |
| 18560 | } | 19408 | } |
| 18561 | 19409 | ||
| @@ -18607,7 +19455,7 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 18607 | &mut cdfs, | 19455 | &mut cdfs, |
| 18608 | &mut neighbours, | 19456 | &mut neighbours, |
| 18609 | &mut grid, | 19457 | &mut grid, |
| 18610 | - at, | 19458 | + sub16_to_mi(at), |
| 18611 | BLOCK, | 19459 | BLOCK, |
| 18612 | mi_cols, | 19460 | mi_cols, |
| 18613 | mi_rows, | 19461 | mi_rows, |
| @@ -18708,7 +19556,7 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 18708 | &mut cdfs, | 19556 | &mut cdfs, |
| 18709 | &mut neighbours, | 19557 | &mut neighbours, |
| 18710 | &mut grid, | 19558 | &mut grid, |
| 18711 | - at16, | 19559 | + sub16_to_mi(at16), |
| 18712 | SUB, | 19560 | SUB, |
| 18713 | mi_cols, | 19561 | mi_cols, |
| 18714 | mi_rows, | 19562 | mi_rows, |
| @@ -18756,9 +19604,96 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 18756 | allow_screen_content_tools, | 19604 | allow_screen_content_tools, |
| 18757 | frame_width as usize, | 19605 | frame_width as usize, |
| 18758 | )?; | 19606 | )?; |
| 19607 | + } else if part16 == PARTITION_HORZ || part16 == PARTITION_VERT { | ||
| 19608 | + // lane-inter4 r3: the 16x16-level rect inter | ||
| 19609 | + // leaves -- two true 16x8 (HORZ) or 8x16 | ||
| 19610 | + // (VERT) inter blocks. Same shape as the | ||
| 19611 | + // 32-level HORZ/VERT arm above: `side = SUB` | ||
| 19612 | + // keeps every CDF/prediction-buffer decision | ||
| 19613 | + // square, `write_w`/`write_h` carry the true | ||
| 19614 | + // footprint into the mv stack, the motion-mode | ||
| 19615 | + // row, the neighbour stamps and the rectangular | ||
| 19616 | + // residual path (`rect_inter_residual_supported` | ||
| 19617 | + // covers 16x8/8x16 since this round). | ||
| 19618 | + let horz = part16 == PARTITION_HORZ; | ||
| 19619 | + if horz { | ||
| 19620 | + INTER_LEAF16_HORZ_HITS.with(|c| c.set(c.get() + 1)); | ||
| 19621 | + } else { | ||
| 19622 | + INTER_LEAF16_VERT_HITS.with(|c| c.set(c.get() + 1)); | ||
| 19623 | + } | ||
| 19624 | + let base_mi = sub16_to_mi(at16); | ||
| 19625 | + let (ww, wh) = if horz { (16, 8) } else { (8, 16) }; | ||
| 19626 | + for piece in 0..2 { | ||
| 19627 | + let piece_mi = if horz { | ||
| 19628 | + (base_mi.0 + piece * 2, base_mi.1) | ||
| 19629 | + } else { | ||
| 19630 | + (base_mi.0, base_mi.1 + piece * 2) | ||
| 19631 | + }; | ||
| 19632 | + // libaom `decode_partition`'s own second- | ||
| 19633 | + // half frame-edge break. | ||
| 19634 | + if piece > 0 | ||
| 19635 | + && (piece_mi.0 >= mi_rows as usize | ||
| 19636 | + || piece_mi.1 >= mi_cols as usize) | ||
| 19637 | + { | ||
| 19638 | + break; | ||
| 19639 | + } | ||
| 19640 | + decode_inter_block( | ||
| 19641 | + &mut dec, | ||
| 19642 | + &mut cdfs, | ||
| 19643 | + &mut neighbours, | ||
| 19644 | + &mut grid, | ||
| 19645 | + piece_mi, | ||
| 19646 | + SUB, | ||
| 19647 | + mi_cols, | ||
| 19648 | + mi_rows, | ||
| 19649 | + &mut y, | ||
| 19650 | + &mut u, | ||
| 19651 | + &mut v, | ||
| 19652 | + &ref_y, | ||
| 19653 | + &ref_u, | ||
| 19654 | + &ref_v, | ||
| 19655 | + &ref_slots, | ||
| 19656 | + &sign_bias_table, | ||
| 19657 | + &global_motion, | ||
| 19658 | + base_q_idx, | ||
| 19659 | + TxbSet::Luma16, | ||
| 19660 | + if reduced_tx_set { | ||
| 19661 | + TxbSet::Luma16Inter | ||
| 19662 | + } else { | ||
| 19663 | + TxbSet::Luma16InterSet1 | ||
| 19664 | + }, | ||
| 19665 | + TxbSet::Chroma8, | ||
| 19666 | + TX16, | ||
| 19667 | + TX8, | ||
| 19668 | + &scan16, | ||
| 19669 | + &scan8, | ||
| 19670 | + 1, | ||
| 19671 | + allow_high_precision_mv, | ||
| 19672 | + force_integer_mv, | ||
| 19673 | + interp_fixed, | ||
| 19674 | + enable_dual_filter, | ||
| 19675 | + tpl_frame.as_ref(), | ||
| 19676 | + reference_select, | ||
| 19677 | + enable_masked_compound, | ||
| 19678 | + enable_interintra_compound, | ||
| 19679 | + enable_jnt_comp, | ||
| 19680 | + order_hint_bits, | ||
| 19681 | + order_hint, | ||
| 19682 | + ref_order_hints, | ||
| 19683 | + skip_mode_present, | ||
| 19684 | + skip_mode_frame, | ||
| 19685 | + switchable_motion_mode, | ||
| 19686 | + allow_warped_motion, | ||
| 19687 | + true, | ||
| 19688 | + ww, | ||
| 19689 | + wh, | ||
| 19690 | + allow_screen_content_tools, | ||
| 19691 | + frame_width as usize, | ||
| 19692 | + )?; | ||
| 19693 | + } | ||
| 18759 | } else if part16 != PARTITION_SPLIT { | 19694 | } else if part16 != PARTITION_SPLIT { |
| 18760 | return Err(unsupported( | 19695 | return Err(unsupported( |
| 18761 | - "an inter partition below 16x16 other than SPLIT (16x8/8x16 rect inter leaves are not coded yet)", | 19696 | + "an inter 16x16-level AB or 1:4 partition (HORZ_A/HORZ_B/VERT_A/VERT_B/HORZ_4/VERT_4; this decoder's inter path codes a 16x16 as NONE, HORZ, VERT or SPLIT)", |
| 18762 | )); | 19697 | )); |
| 18763 | } else { | 19698 | } else { |
| 18764 | if has_cols16 && has_rows16 { | 19699 | if has_cols16 && has_rows16 { |
| @@ -18914,7 +19849,7 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 18914 | &mut cdfs, | 19849 | &mut cdfs, |
| 18915 | &mut neighbours, | 19850 | &mut neighbours, |
| 18916 | &mut grid, | 19851 | &mut grid, |
| 18917 | - at32, | 19852 | + sub16_to_mi(at32), |
| 18918 | BLOCK, | 19853 | BLOCK, |
| 18919 | mi_cols, | 19854 | mi_cols, |
| 18920 | mi_rows, | 19855 | mi_rows, |
| @@ -18967,7 +19902,7 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 18967 | &mut cdfs, | 19902 | &mut cdfs, |
| 18968 | &mut neighbours, | 19903 | &mut neighbours, |
| 18969 | &mut grid, | 19904 | &mut grid, |
| 18970 | - (r32 as usize * 2 + 1, c32 as usize * 2), | 19905 | + sub16_to_mi((r32 as usize * 2 + 1, c32 as usize * 2)), |
| 18971 | SUB, | 19906 | SUB, |
| 18972 | mi_cols, | 19907 | mi_cols, |
| 18973 | mi_rows, | 19908 | mi_rows, |
| @@ -19021,7 +19956,7 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 19021 | &mut cdfs, | 19956 | &mut cdfs, |
| 19022 | &mut neighbours, | 19957 | &mut neighbours, |
| 19023 | &mut grid, | 19958 | &mut grid, |
| 19024 | - (r32 as usize * 2 + 1, c32 as usize * 2 + 1), | 19959 | + sub16_to_mi((r32 as usize * 2 + 1, c32 as usize * 2 + 1)), |
| 19025 | SUB, | 19960 | SUB, |
| 19026 | mi_cols, | 19961 | mi_cols, |
| 19027 | mi_rows, | 19962 | mi_rows, |
| @@ -19085,7 +20020,7 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 19085 | &mut cdfs, | 20020 | &mut cdfs, |
| 19086 | &mut neighbours, | 20021 | &mut neighbours, |
| 19087 | &mut grid, | 20022 | &mut grid, |
| 19088 | - at, | 20023 | + sub16_to_mi(at), |
| 19089 | BLOCK, | 20024 | BLOCK, |
| 19090 | mi_cols, | 20025 | mi_cols, |
| 19091 | mi_rows, | 20026 | mi_rows, |
| @@ -19134,7 +20069,7 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 19134 | &mut cdfs, | 20069 | &mut cdfs, |
| 19135 | &mut neighbours, | 20070 | &mut neighbours, |
| 19136 | &mut grid, | 20071 | &mut grid, |
| 19137 | - (r32 as usize * 2 + 1, c32 as usize * 2), | 20072 | + sub16_to_mi((r32 as usize * 2 + 1, c32 as usize * 2)), |
| 19138 | BLOCK, | 20073 | BLOCK, |
| 19139 | mi_cols, | 20074 | mi_cols, |
| 19140 | mi_rows, | 20075 | mi_rows, |
| @@ -19188,7 +20123,7 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 19188 | &mut cdfs, | 20123 | &mut cdfs, |
| 19189 | &mut neighbours, | 20124 | &mut neighbours, |
| 19190 | &mut grid, | 20125 | &mut grid, |
| 19191 | - at, | 20126 | + sub16_to_mi(at), |
| 19192 | BLOCK, | 20127 | BLOCK, |
| 19193 | mi_cols, | 20128 | mi_cols, |
| 19194 | mi_rows, | 20129 | mi_rows, |
| @@ -19237,7 +20172,7 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 19237 | &mut cdfs, | 20172 | &mut cdfs, |
| 19238 | &mut neighbours, | 20173 | &mut neighbours, |
| 19239 | &mut grid, | 20174 | &mut grid, |
| 19240 | - (r32 as usize * 2, c32 as usize * 2 + 1), | 20175 | + sub16_to_mi((r32 as usize * 2, c32 as usize * 2 + 1)), |
| 19241 | BLOCK, | 20176 | BLOCK, |
| 19242 | mi_cols, | 20177 | mi_cols, |
| 19243 | mi_rows, | 20178 | mi_rows, |
| @@ -19292,7 +20227,7 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 19292 | &mut cdfs, | 20227 | &mut cdfs, |
| 19293 | &mut neighbours, | 20228 | &mut neighbours, |
| 19294 | &mut grid, | 20229 | &mut grid, |
| 19295 | - at, | 20230 | + sub16_to_mi(at), |
| 19296 | SUB, | 20231 | SUB, |
| 19297 | mi_cols, | 20232 | mi_cols, |
| 19298 | mi_rows, | 20233 | mi_rows, |
| @@ -19345,7 +20280,7 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 19345 | &mut cdfs, | 20280 | &mut cdfs, |
| 19346 | &mut neighbours, | 20281 | &mut neighbours, |
| 19347 | &mut grid, | 20282 | &mut grid, |
| 19348 | - (r32 as usize * 2, c32 as usize * 2 + 1), | 20283 | + sub16_to_mi((r32 as usize * 2, c32 as usize * 2 + 1)), |
| 19349 | SUB, | 20284 | SUB, |
| 19350 | mi_cols, | 20285 | mi_cols, |
| 19351 | mi_rows, | 20286 | mi_rows, |
| @@ -19398,7 +20333,7 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 19398 | &mut cdfs, | 20333 | &mut cdfs, |
| 19399 | &mut neighbours, | 20334 | &mut neighbours, |
| 19400 | &mut grid, | 20335 | &mut grid, |
| 19401 | - (r32 as usize * 2 + 1, c32 as usize * 2), | 20336 | + sub16_to_mi((r32 as usize * 2 + 1, c32 as usize * 2)), |
| 19402 | BLOCK, | 20337 | BLOCK, |
| 19403 | mi_cols, | 20338 | mi_cols, |
| 19404 | mi_rows, | 20339 | mi_rows, |
| @@ -19453,7 +20388,7 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 19453 | &mut cdfs, | 20388 | &mut cdfs, |
| 19454 | &mut neighbours, | 20389 | &mut neighbours, |
| 19455 | &mut grid, | 20390 | &mut grid, |
| 19456 | - at, | 20391 | + sub16_to_mi(at), |
| 19457 | SUB, | 20392 | SUB, |
| 19458 | mi_cols, | 20393 | mi_cols, |
| 19459 | mi_rows, | 20394 | mi_rows, |
| @@ -19506,7 +20441,7 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 19506 | &mut cdfs, | 20441 | &mut cdfs, |
| 19507 | &mut neighbours, | 20442 | &mut neighbours, |
| 19508 | &mut grid, | 20443 | &mut grid, |
| 19509 | - (r32 as usize * 2 + 1, c32 as usize * 2), | 20444 | + sub16_to_mi((r32 as usize * 2 + 1, c32 as usize * 2)), |
| 19510 | SUB, | 20445 | SUB, |
| 19511 | mi_cols, | 20446 | mi_cols, |
| 19512 | mi_rows, | 20447 | mi_rows, |
| @@ -19559,7 +20494,7 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 19559 | &mut cdfs, | 20494 | &mut cdfs, |
| 19560 | &mut neighbours, | 20495 | &mut neighbours, |
| 19561 | &mut grid, | 20496 | &mut grid, |
| 19562 | - (r32 as usize * 2, c32 as usize * 2 + 1), | 20497 | + sub16_to_mi((r32 as usize * 2, c32 as usize * 2 + 1)), |
| 19563 | BLOCK, | 20498 | BLOCK, |
| 19564 | mi_cols, | 20499 | mi_cols, |
| 19565 | mi_rows, | 20500 | mi_rows, |
| @@ -19615,7 +20550,7 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 19615 | &mut cdfs, | 20550 | &mut cdfs, |
| 19616 | &mut neighbours, | 20551 | &mut neighbours, |
| 19617 | &mut grid, | 20552 | &mut grid, |
| 19618 | - at, | 20553 | + sub16_to_mi(at), |
| 19619 | BLOCK, | 20554 | BLOCK, |
| 19620 | mi_cols, | 20555 | mi_cols, |
| 19621 | mi_rows, | 20556 | mi_rows, |
| @@ -19664,7 +20599,7 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 19664 | &mut cdfs, | 20599 | &mut cdfs, |
| 19665 | &mut neighbours, | 20600 | &mut neighbours, |
| 19666 | &mut grid, | 20601 | &mut grid, |
| 19667 | - (r32 as usize * 2, c32 as usize * 2 + 1), | 20602 | + sub16_to_mi((r32 as usize * 2, c32 as usize * 2 + 1)), |
| 19668 | SUB, | 20603 | SUB, |
| 19669 | mi_cols, | 20604 | mi_cols, |
| 19670 | mi_rows, | 20605 | mi_rows, |
| @@ -19717,7 +20652,7 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 19717 | &mut cdfs, | 20652 | &mut cdfs, |
| 19718 | &mut neighbours, | 20653 | &mut neighbours, |
| 19719 | &mut grid, | 20654 | &mut grid, |
| 19720 | - (r32 as usize * 2 + 1, c32 as usize * 2 + 1), | 20655 | + sub16_to_mi((r32 as usize * 2 + 1, c32 as usize * 2 + 1)), |
| 19721 | SUB, | 20656 | SUB, |
| 19722 | mi_cols, | 20657 | mi_cols, |
| 19723 | mi_rows, | 20658 | mi_rows, |
| @@ -19766,6 +20701,49 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 19766 | frame_width as usize, | 20701 | frame_width as usize, |
| 19767 | )?; | 20702 | )?; |
| 19768 | } | 20703 | } |
| 20704 | + PARTITION_HORZ_4 | PARTITION_VERT_4 => { | ||
| 20705 | + // lane-inter4 r1: four 32x8 / 8x32 inter strips, | ||
| 20706 | + // `quarter_step` = 2 mi -- the arm ReelC's first inter | ||
| 20707 | + // frame stops at (`value=9` = PARTITION_VERT_4). | ||
| 20708 | + // `at` is in 16-px cells and cannot name an 8-px | ||
| 20709 | + // offset, which is why `decode_inter_block` takes mi | ||
| 20710 | + // coordinates now. | ||
| 20711 | + let horz = part32 == PARTITION_HORZ_4; | ||
| 20712 | + let base_mi = (at.0 * (SUB / MI), at.1 * (SUB / MI)); | ||
| 20713 | + let (bw, bh) = if horz { (32usize, 8usize) } else { (8, 32) }; | ||
| 20714 | + for i in 0..4 { | ||
| 20715 | + let strip_mi = if horz { | ||
| 20716 | + (base_mi.0 + i * 2, base_mi.1) | ||
| 20717 | + } else { | ||
| 20718 | + (base_mi.0, base_mi.1 + i * 2) | ||
| 20719 | + }; | ||
| 20720 | + if i > 0 | ||
| 20721 | + && (strip_mi.0 >= mi_rows as usize | ||
| 20722 | + || strip_mi.1 >= mi_cols as usize) | ||
| 20723 | + { | ||
| 20724 | + break; | ||
| 20725 | + } | ||
| 20726 | + inter_piece!( | ||
| 20727 | + strip_mi, | ||
| 20728 | + BLOCK, | ||
| 20729 | + TxbSet::Luma32, | ||
| 20730 | + TxbSet::Luma32Inter, | ||
| 20731 | + TxbSet::Chroma16, | ||
| 20732 | + TX32, | ||
| 20733 | + TX16, | ||
| 20734 | + &scan32, | ||
| 20735 | + &scan16, | ||
| 20736 | + 3, | ||
| 20737 | + bw, | ||
| 20738 | + bh | ||
| 20739 | + ); | ||
| 20740 | + if horz { | ||
| 20741 | + RECT4_32_HORZ_INTER_HITS.with(|c| c.set(c.get() + 1)); | ||
| 20742 | + } else { | ||
| 20743 | + RECT4_32_VERT_INTER_HITS.with(|c| c.set(c.get() + 1)); | ||
| 20744 | + } | ||
| 20745 | + } | ||
| 20746 | + } | ||
| 19769 | _ => { | 20747 | _ => { |
| 19770 | return Err(unsupported(format!( | 20748 | return Err(unsupported(format!( |
| 19771 | "an INTER 32x32 partition type this decoder does not code (value={part32})" | 20749 | "an INTER 32x32 partition type this decoder does not code (value={part32})" |
| @@ -19821,6 +20799,7 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 19821 | mi_cols as usize, | 20799 | mi_cols as usize, |
| 19822 | mi_rows as usize, | 20800 | mi_rows as usize, |
| 19823 | order_hint, | 20801 | order_hint, |
| 20802 | + order_hint_bits, | ||
| 19824 | ref_order_hints, | 20803 | ref_order_hints, |
| 19825 | ); | 20804 | ); |
| 19826 | 20805 | ||
| @@ -20396,8 +21375,13 @@ mod tests { | |||
| 20396 | ) | 21375 | ) |
| 20397 | .unwrap_err(); | 21376 | .unwrap_err(); |
| 20398 | let msg = err.to_string(); | 21377 | let msg = err.to_string(); |
| 21378 | + // lane-inter4 r1: this fixture's SB value is PARTITION_HORZ, now | ||
| 21379 | + // DECODED rather than refused outright; its first 64x32 strip is | ||
| 21380 | + // non-skip, so the named refusal is the rectangular-inter-residual | ||
| 21381 | + // one. Either string proves what the pin was written for: a non-SPLIT | ||
| 21382 | + // superblock never silently decodes as SPLIT. | ||
| 20399 | assert!( | 21383 | assert!( |
| 20400 | - msg.contains("SPLIT"), | 21384 | + msg.contains("SPLIT") || msg.contains("rectangular residual coding"), |
| 20401 | "expected the named inter-SB-partition refusal, got: {msg}" | 21385 | "expected the named inter-SB-partition refusal, got: {msg}" |
| 20402 | ); | 21386 | ); |
| 20403 | } | 21387 | } |
| @@ -20880,7 +21864,7 @@ mod tests { | |||
| 20880 | &mut cdfs, | 21864 | &mut cdfs, |
| 20881 | &mut neighbours, | 21865 | &mut neighbours, |
| 20882 | &mut grid, | 21866 | &mut grid, |
| 20883 | - (r, c), | 21867 | + sub16_to_mi((r, c)), |
| 20884 | side, | 21868 | side, |
| 20885 | mi_cols, | 21869 | mi_cols, |
| 20886 | mi_rows, | 21870 | mi_rows, |
crates/ec-av1/src/motion_field.rsmodified+11 -1
| @@ -420,7 +420,17 @@ pub fn add_tpl_ref_mv( | |||
| 420 | if row8 < 0 || col8 < 0 { | 420 | if row8 < 0 || col8 < 0 { |
| 421 | return None; | 421 | return None; |
| 422 | } | 422 | } |
| 423 | - let (fwd_mv, ref_frame_offset) = tpl.get(row8 as usize / 2, col8 as usize / 2)?; | 423 | + let probe = tpl.get(row8 as usize / 2, col8 as usize / 2); |
| 424 | + if std::env::var_os("EC_TRACE_TPL").is_some() { | ||
| 425 | + match probe { | ||
| 426 | + None => eprintln!("EC_TPL mi_row={mi_row} mi_col={mi_col} blk=({blk_row},{blk_col}) INVALID"), | ||
| 427 | + Some((m, rfo)) => eprintln!( | ||
| 428 | + "EC_TPL mi_row={mi_row} mi_col={mi_col} blk=({blk_row},{blk_col}) mfmv0=({},{}) rfo={rfo}", | ||
| 429 | + m.0, m.1 | ||
| 430 | + ), | ||
| 431 | + } | ||
| 432 | + } | ||
| 433 | + let (fwd_mv, ref_frame_offset) = probe?; | ||
| 424 | let projected = get_mv_projection(fwd_mv, cur_offset_0, ref_frame_offset); | 434 | let projected = get_mv_projection(fwd_mv, cur_offset_0, ref_frame_offset); |
| 425 | let mv = lower_mv_precision(projected, allow_high_precision_mv); | 435 | let mv = lower_mv_precision(projected, allow_high_precision_mv); |
| 426 | Some(TplCandidate { mv }) | 436 | Some(TplCandidate { mv }) |
crates/ec-av1/src/refusal_inventory.rsmodified+3 -2
| @@ -65,12 +65,13 @@ const REFUSALS: &[&str] = &[ | |||
| 65 | // the 8x8 leaf's TX_4X4 2x2 grid is still refused here. | 65 | // the 8x8 leaf's TX_4X4 2x2 grid is still refused here. |
| 66 | "an 8x8 intra leaf in an inter frame whose tx_depth splits it into 4x4 transform units", | 66 | "an 8x8 intra leaf in an inter frame whose tx_depth splits it into 4x4 transform units", |
| 67 | "an inter frame with no key frame before it", | 67 | "an inter frame with no key frame before it", |
| 68 | - "an inter SB-level partition type other than NONE or SPLIT (this decoder's inter tile path recurses a superblock only as SPLIT)", | 68 | + "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)", |
| 69 | - "an inter partition below 16x16 other than SPLIT (16x8/8x16 rect inter leaves are not coded yet)", | 69 | + "an inter 16x16-level AB or 1:4 partition (HORZ_A/HORZ_B/VERT_A/VERT_B/HORZ_4/VERT_4; this decoder's inter path codes a 16x16 as NONE, HORZ, VERT or SPLIT)", |
| 70 | "an intra mode this decoder does not code (round 2)", | 70 | "an intra mode this decoder does not code (round 2)", |
| 71 | "an intra-coded HORZ/VERT strip needs rectangular intra prediction this decoder does not code yet", | 71 | "an intra-coded HORZ/VERT strip needs rectangular intra prediction this decoder does not code yet", |
| 72 | "warp prediction with a scaled reference (superres, unimplemented)", | 72 | "warp prediction with a scaled reference (superres, unimplemented)", |
| 73 | "an 8x8 partition leaf under a scaled reference (superres, unimplemented)", | 73 | "an 8x8 partition leaf under a scaled reference (superres, unimplemented)", |
| 74 | + "a motion_mode symbol for a block shape with no CDF row here", | ||
| 74 | ]; | 75 | ]; |
| 75 | 76 | ||
| 76 | /// Gates whose `Err` arm turns a decode failure into a printed SKIP rather than | 77 | /// Gates whose `Err` arm turns a decode failure into a printed SKIP rather than |
crates/ec-av1/src/stream.rsmodified+808 -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(), |
| @@ -63,6 +76,17 @@ pub fn rect4_32_counters() -> (usize, usize, usize) { | |||
| 63 | ) | 76 | ) |
| 64 | } | 77 | } |
| 65 | 78 | ||
| 79 | +/// lane-inter4 r4: rectangular inter transform units coded whole, rect | ||
| 80 | +/// var-tx trees that split, and OBMC blends run on a 16x8/8x16 leaf -- the | ||
| 81 | +/// three counters a recipe sweep needs to see from outside the crate. | ||
| 82 | +pub fn rect_inter_tu_counters() -> (usize, usize, usize) { | ||
| 83 | + ( | ||
| 84 | + crate::decode::rect_inter_tu_hits(), | ||
| 85 | + crate::decode::rect_inter_txsplit_hits(), | ||
| 86 | + crate::decode::obmc_rect_leaf_hits(), | ||
| 87 | + ) | ||
| 88 | +} | ||
| 89 | + | ||
| 66 | /// Decode every frame in a raw AV1 OBU stream, in coding order. | 90 | /// Decode every frame in a raw AV1 OBU stream, in coding order. |
| 67 | /// | 91 | /// |
| 68 | /// A key frame becomes the reference for the inter frames that follow it, | 92 | /// A key frame becomes the reference for the inter frames that follow it, |
| @@ -1953,6 +1977,10 @@ mod tests { | |||
| 1953 | // masked compound, palette, ...) are other lanes' work; | 1977 | // masked compound, palette, ...) are other lanes' work; |
| 1954 | // this gate is about hidden frames, not about them. | 1978 | // this gate is about hidden frames, not about them. |
| 1955 | "--enable-warped-motion=0", | 1979 | "--enable-warped-motion=0", |
| 1980 | + // OBMC stays off HERE (this gate is about hidden frames); | ||
| 1981 | + // the tool's own coverage is the `obmc*` gates and, on a | ||
| 1982 | + // 16x8/8x16 leaf, the `--enable-obmc=1` arm of | ||
| 1983 | + // `..._with_a_16_level_rect_leaf_...` (lane-inter4 r4). | ||
| 1956 | "--enable-obmc=0", | 1984 | "--enable-obmc=0", |
| 1957 | "--enable-masked-comp=0", | 1985 | "--enable-masked-comp=0", |
| 1958 | "--enable-interintra-comp=0", | 1986 | "--enable-interintra-comp=0", |
| @@ -5898,6 +5926,786 @@ mod tests { | |||
| 5898 | ); | 5926 | ); |
| 5899 | } | 5927 | } |
| 5900 | 5928 | ||
| 5929 | + /// lane-inter4 r1: the SUPERBLOCK-level inter `PARTITION_HORZ`/ | ||
| 5930 | + /// `PARTITION_VERT` pair -- two 64x32 / 32x64 inter strips, the arm the | ||
| 5931 | + /// inter tile path refused outright before this lane ("an inter SB-level | ||
| 5932 | + /// partition type other than NONE or SPLIT"). `--min-partition-size=32` | ||
| 5933 | + /// keeps every 32x32-level rect shape (already coded, and residual-capable | ||
| 5934 | + /// only when skip) out of the picture so the counters can only be earned | ||
| 5935 | + /// at the superblock level; the noiseless split-motion source (one half | ||
| 5936 | + /// translating, the other static, flat inside each half) is what makes | ||
| 5937 | + /// aomenc's RD pick a superblock HORZ/VERT whose strips are `skip` -- | ||
| 5938 | + /// the ONLY inter rect shape this decoder can complete, since rectangular | ||
| 5939 | + /// inter residual coding is not ported (see `reject_residual`). | ||
| 5940 | + /// | ||
| 5941 | + /// Every decoded frame is compared to ffmpeg (Y, U and V); an attempt | ||
| 5942 | + /// that refuses by name is counted, never turned into a SKIP; and an | ||
| 5943 | + /// attempt that decoded without firing the arm is counted separately and | ||
| 5944 | + /// still required to be pixel-exact (class gate-skips-on-its-own-failure). | ||
| 5945 | + #[test] | ||
| 5946 | + fn a_real_aomenc_inter_sequence_with_a_superblock_level_rect_partition_decodes_pixel_exact() { | ||
| 5947 | + const NAME: &str = "a_real_aomenc_inter_sequence_with_a_superblock_level_rect_partition_decodes_pixel_exact"; | ||
| 5948 | + let _gate_lock = lock_gate_counters(); | ||
| 5949 | + if !have_ffmpeg() { | ||
| 5950 | + eprintln!("SKIP {NAME}: no ffmpeg"); | ||
| 5951 | + return; | ||
| 5952 | + } | ||
| 5953 | + if !have_aomenc() { | ||
| 5954 | + eprintln!("SKIP {NAME}: no aomenc at {}", aomenc_path().display()); | ||
| 5955 | + return; | ||
| 5956 | + } | ||
| 5957 | + let (width, height, frame_count) = (192usize, 128usize, 6usize); | ||
| 5958 | + // lane-inter4 r1: 8-bit ONLY, and the reason is the lane's own open | ||
| 5959 | + // residue, not a tolerance: across all 16 attempts x both depths, every | ||
| 5960 | + // 10-bit attempt that reached a superblock-level rect strip found it | ||
| 5961 | + // NON-skip, so it stops at "a non-skip rectangular (HORZ/VERT/HORZ_B) | ||
| 5962 | + // strip needs rectangular residual coding". The 10-bit twin below is | ||
| 5963 | + // `#[ignore]`d with that exact reason rather than deleted or weakened. | ||
| 5964 | + for bit_depth in [8u32] { | ||
| 5965 | + let (mut named_refusals, mut matched, mut out_of_scope, mut oos_mismatch) = | ||
| 5966 | + (0u32, 0u32, 0u32, 0u32); | ||
| 5967 | + let (mut horz_proved, mut vert_proved) = (0usize, 0usize); | ||
| 5968 | + for attempt in 0..16u32 { | ||
| 5969 | + // Two orientations (the transposed pair a one-sided gate could | ||
| 5970 | + // never separate) x four quantisers x two motion steps: which | ||
| 5971 | + // superblock the RD hands a skip-able rect strip moves with | ||
| 5972 | + // the quantiser, and the 10-bit arm needs a different corner | ||
| 5973 | + // of the grid from the 8-bit one. | ||
| 5974 | + let vertical_split = attempt % 2 == 1; | ||
| 5975 | + let cq = [58, 52, 45, 61][(attempt / 2 % 4) as usize]; | ||
| 5976 | + let sp = 8 + (attempt / 8) * 4; | ||
| 5977 | + let geq = if vertical_split { | ||
| 5978 | + format!("if(lt(Y,64), 40+mod(floor((X+N*{sp})/32)*90,200), 200)") | ||
| 5979 | + } else { | ||
| 5980 | + format!("if(lt(X,64), 40+mod(floor((Y+N*{sp})/32)*90,200), 200)") | ||
| 5981 | + }; | ||
| 5982 | + let duration = frame_count as f64 / 25.0; | ||
| 5983 | + let source = format!( | ||
| 5984 | + "color=c=gray:s={width}x{height}:d={duration}:r=25,format=gray,\ | ||
| 5985 | + geq=lum='{geq}',format=yuv420p" | ||
| 5986 | + ); | ||
| 5987 | + let pix_fmt = if bit_depth == 10 { "yuv420p10le" } else { "yuv420p" }; | ||
| 5988 | + let y4m = Command::new("ffmpeg") | ||
| 5989 | + .args([ | ||
| 5990 | + "-v", "error", "-f", "lavfi", "-i", &source, "-t", &duration.to_string(), | ||
| 5991 | + "-pix_fmt", pix_fmt, "-strict", "-1", "-f", "yuv4mpegpipe", "-", | ||
| 5992 | + ]) | ||
| 5993 | + .stdin(Stdio::null()) | ||
| 5994 | + .stdout(Stdio::piped()) | ||
| 5995 | + .stderr(Stdio::piped()) | ||
| 5996 | + .output() | ||
| 5997 | + .expect("ffmpeg failed to run"); | ||
| 5998 | + assert!( | ||
| 5999 | + y4m.status.success(), | ||
| 6000 | + "{NAME}: ffmpeg refused the {bit_depth}-bit fixture: {}", | ||
| 6001 | + String::from_utf8_lossy(&y4m.stderr) | ||
| 6002 | + ); | ||
| 6003 | + let cq_arg = format!("--cq-level={cq}"); | ||
| 6004 | + let depth_arg = format!("--bit-depth={bit_depth}"); | ||
| 6005 | + let input_depth_arg = format!("--input-bit-depth={bit_depth}"); | ||
| 6006 | + let args: Vec<&str> = vec![ | ||
| 6007 | + "--codec=av1", "--passes=1", "--end-usage=q", &cq_arg, "--cpu-used=0", | ||
| 6008 | + "--threads=1", "--row-mt=0", "--sb-size=64", &depth_arg, &input_depth_arg, | ||
| 6009 | + "--enable-restoration=0", "--enable-palette=0", "--deltaq-mode=0", | ||
| 6010 | + "--enable-filter-intra=0", "--enable-cfl-intra=0", "--enable-intrabc=0", | ||
| 6011 | + "--enable-tx-size-search=0", "--lag-in-frames=0", | ||
| 6012 | + // Per-arm overrides go LAST: aomenc keeps the last | ||
| 6013 | + // occurrence of a repeated --enable-* flag. | ||
| 6014 | + "--enable-rect-partitions=1", "--enable-ab-partitions=0", | ||
| 6015 | + "--enable-1to4-partitions=1", "--min-partition-size=32", | ||
| 6016 | + "--max-partition-size=64", | ||
| 6017 | + "--obu", "-o", "-", "-", | ||
| 6018 | + ]; | ||
| 6019 | + let mut child = Command::new(aomenc_path()) | ||
| 6020 | + .args(&args) | ||
| 6021 | + .stdin(Stdio::piped()) | ||
| 6022 | + .stdout(Stdio::piped()) | ||
| 6023 | + .stderr(Stdio::piped()) | ||
| 6024 | + .spawn() | ||
| 6025 | + .expect("aomenc failed to start"); | ||
| 6026 | + child | ||
| 6027 | + .stdin | ||
| 6028 | + .take() | ||
| 6029 | + .expect("aomenc stdin") | ||
| 6030 | + .write_all(&y4m.stdout) | ||
| 6031 | + .expect("writing y4m to aomenc"); | ||
| 6032 | + let out = child.wait_with_output().expect("aomenc failed to run"); | ||
| 6033 | + assert!( | ||
| 6034 | + out.status.success(), | ||
| 6035 | + "aomenc refused the fixture: {}", | ||
| 6036 | + String::from_utf8_lossy(&out.stderr) | ||
| 6037 | + ); | ||
| 6038 | + let stream = out.stdout; | ||
| 6039 | + let before = crate::stream::inter_rect_counters(); | ||
| 6040 | + let frames = match decode_stream(&stream) { | ||
| 6041 | + Err(e) => { | ||
| 6042 | + let msg = e.to_string(); | ||
| 6043 | + assert!( | ||
| 6044 | + msg.contains("unsupported"), | ||
| 6045 | + "{NAME} failed outright, not a named refusal ({bit_depth}-bit, \ | ||
| 6046 | + attempt {attempt}): {msg}" | ||
| 6047 | + ); | ||
| 6048 | + named_refusals += 1; | ||
| 6049 | + eprintln!("{bit_depth}-bit attempt {attempt} refusal: {msg}"); | ||
| 6050 | + continue; | ||
| 6051 | + } | ||
| 6052 | + Ok(frames) => frames, | ||
| 6053 | + }; | ||
| 6054 | + let after = crate::stream::inter_rect_counters(); | ||
| 6055 | + let (horz, vert) = (after.2 - before.2, after.3 - before.3); | ||
| 6056 | + let ffmpeg_frames = if bit_depth == 10 { | ||
| 6057 | + ffmpeg_decode_sequence_10bit(&stream, width, height, frame_count) | ||
| 6058 | + } else { | ||
| 6059 | + ffmpeg_decode_sequence(&stream, width, height, frame_count) | ||
| 6060 | + }; | ||
| 6061 | + assert_eq!(frames.len(), frame_count); | ||
| 6062 | + let mismatched = frames | ||
| 6063 | + .iter() | ||
| 6064 | + .zip(&ffmpeg_frames) | ||
| 6065 | + .any(|(got, want)| got.y != want.y || got.u != want.u || got.v != want.v); | ||
| 6066 | + if horz + vert == 0 { | ||
| 6067 | + out_of_scope += 1; | ||
| 6068 | + if mismatched { | ||
| 6069 | + oos_mismatch += 1; | ||
| 6070 | + eprintln!( | ||
| 6071 | + "{NAME}: {bit_depth}-bit attempt {attempt} MISMATCHES with zero \ | ||
| 6072 | + superblock-level inter rect strips -- another shape's defect" | ||
| 6073 | + ); | ||
| 6074 | + } | ||
| 6075 | + continue; | ||
| 6076 | + } | ||
| 6077 | + for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() { | ||
| 6078 | + assert_eq!(got.y, want.y, "{NAME} frame {i} luma vs ffmpeg (attempt {attempt}, {bit_depth}-bit)"); | ||
| 6079 | + assert_eq!(got.u, want.u, "{NAME} frame {i} U vs ffmpeg (attempt {attempt}, {bit_depth}-bit)"); | ||
| 6080 | + assert_eq!(got.v, want.v, "{NAME} frame {i} V vs ffmpeg (attempt {attempt}, {bit_depth}-bit)"); | ||
| 6081 | + } | ||
| 6082 | + horz_proved += horz; | ||
| 6083 | + vert_proved += vert; | ||
| 6084 | + matched += 1; | ||
| 6085 | + } | ||
| 6086 | + eprintln!( | ||
| 6087 | + "{NAME} ({bit_depth}-bit): {named_refusals} named refusals, {matched} pixel-exact \ | ||
| 6088 | + attempts carrying the arm, 64x32 strips={horz_proved}, 32x64 strips={vert_proved}, \ | ||
| 6089 | + {out_of_scope} attempts carried none ({oos_mismatch} of them mismatched)" | ||
| 6090 | + ); | ||
| 6091 | + assert_eq!( | ||
| 6092 | + oos_mismatch, 0, | ||
| 6093 | + "{NAME}: {oos_mismatch} attempt(s) with no superblock-level inter rect strip \ | ||
| 6094 | + decoded but mismatched ffmpeg -- a defect of another shape, not a pass" | ||
| 6095 | + ); | ||
| 6096 | + assert!( | ||
| 6097 | + horz_proved + vert_proved > 0, | ||
| 6098 | + "{NAME} ({bit_depth}-bit): the superblock-level inter rect arm never fired \ | ||
| 6099 | + inside a pixel-exact attempt (horz={horz_proved}, vert={vert_proved}, \ | ||
| 6100 | + {named_refusals} refusals, {out_of_scope} out of scope) -- gate proved nothing" | ||
| 6101 | + ); | ||
| 6102 | + } | ||
| 6103 | + } | ||
| 6104 | + | ||
| 6105 | + /// lane-inter4 r2: the 32x32-level inter `PARTITION_HORZ`/`PARTITION_VERT` | ||
| 6106 | + /// strips (32x16 / 16x32) carrying a REAL residual -- the capability r1 | ||
| 6107 | + /// found missing ("a non-skip rectangular (HORZ/VERT/HORZ_B) strip needs | ||
| 6108 | + /// rectangular residual coding"). The strip's own rectangular max | ||
| 6109 | + /// transform (`TX_32X16`/`TX_16X32`) is read through the rect var-tx tree, | ||
| 6110 | + /// its coefficients through [`TxbSet::LumaRect32x16Inter`] / | ||
| 6111 | + /// `ChromaRect16x8`, and inverted with the rect (sqrt2-scaled) inverse | ||
| 6112 | + /// transform. | ||
| 6113 | + /// | ||
| 6114 | + /// `--min-partition-size=16 --max-partition-size=32` keeps the superblock | ||
| 6115 | + /// level (64x32, still refused -- no 64-point rect transform) out, so | ||
| 6116 | + /// every counted hit is a 32-level strip. The source is textured and | ||
| 6117 | + /// translating precisely so the strips are NOT skip: a flat source (r1's) | ||
| 6118 | + /// makes aomenc code them skip and proves nothing about the residual. | ||
| 6119 | + /// Both `--enable-tx-size-search` arms run: `=0` exercises the | ||
| 6120 | + /// whole-block rect transform with no `txfm_partition` symbol at all, | ||
| 6121 | + /// `=1` the rect var-tx tree (no-split rect unit, or the split into square | ||
| 6122 | + /// sub-transforms). | ||
| 6123 | + /// | ||
| 6124 | + /// 8-bit AND 10-bit. Every decoded frame is compared to ffmpeg on Y, U and | ||
| 6125 | + /// V; a refusal is counted, never SKIPped; an attempt that carried no rect | ||
| 6126 | + /// inter residual is counted separately and still required pixel-exact. | ||
| 6127 | + /// Temporal (MFMV) motion-vector candidates, on a real aomenc stream | ||
| 6128 | + /// whose compound blocks feed the next frame's motion field | ||
| 6129 | + /// (`av1_copy_frame_mvs` -> `av1_setup_motion_field` -> `add_tpl_ref_mv`). | ||
| 6130 | + /// | ||
| 6131 | + /// lane-interbis r1 pinned this recipe because it is the one the rect | ||
| 6132 | + /// gate's attempt 1 decoded FULLY and still mismatched ffmpeg (a | ||
| 6133 | + /// 32x32 NEARESTMV block at mi (24, 40) of decode-order frame 5 took its | ||
| 6134 | + /// nearest candidate from a temporal cell holding the wrong reference: | ||
| 6135 | + /// `build_motion_field` stored a compound block's FIRST reference where | ||
| 6136 | + /// libaom stores its second). Every fully decoded attempt is compared | ||
| 6137 | + /// plane by plane; a refusal is counted, never SKIPped; the temporal | ||
| 6138 | + /// candidate counter must fire on a compared attempt, or the gate proves | ||
| 6139 | + /// nothing. | ||
| 6140 | + #[test] | ||
| 6141 | + fn a_real_aomenc_inter_sequence_with_temporal_mv_candidates_decodes_pixel_exact() { | ||
| 6142 | + const NAME: &str = | ||
| 6143 | + "a_real_aomenc_inter_sequence_with_temporal_mv_candidates_decodes_pixel_exact"; | ||
| 6144 | + let _gate_lock = lock_gate_counters(); | ||
| 6145 | + if !have_ffmpeg() { | ||
| 6146 | + eprintln!("SKIP {NAME}: no ffmpeg"); | ||
| 6147 | + return; | ||
| 6148 | + } | ||
| 6149 | + if !have_aomenc() { | ||
| 6150 | + eprintln!("SKIP {NAME}: no aomenc at {}", aomenc_path().display()); | ||
| 6151 | + return; | ||
| 6152 | + } | ||
| 6153 | + let (width, height, frame_count) = (192usize, 128usize, 6usize); | ||
| 6154 | + for bit_depth in [8u32, 10u32] { | ||
| 6155 | + let (mut named_refusals, mut compared, mut tmv_proved) = (0u32, 0u32, 0usize); | ||
| 6156 | + for attempt in 0..2u32 { | ||
| 6157 | + let tx_search = if attempt == 0 { "0" } else { "1" }; | ||
| 6158 | + let duration = frame_count as f64 / 25.0; | ||
| 6159 | + // The pinned source: horizontal structure translating along X | ||
| 6160 | + // at 3 px/frame, which makes aomenc code compound LAST+GOLDEN | ||
| 6161 | + // blocks whose stored motion field the last frame reads back. | ||
| 6162 | + let source = format!( | ||
| 6163 | + "color=c=gray:s={width}x{height}:d={duration}:r=25,format=gray,\ | ||
| 6164 | + geq=lum='128+58*sin((X+N*3)/6)+18*sin(Y/23)',format=yuv420p" | ||
| 6165 | + ); | ||
| 6166 | + let pix_fmt = if bit_depth == 10 { "yuv420p10le" } else { "yuv420p" }; | ||
| 6167 | + let y4m = Command::new("ffmpeg") | ||
| 6168 | + .args([ | ||
| 6169 | + "-v", "error", "-f", "lavfi", "-i", &source, "-t", &duration.to_string(), | ||
| 6170 | + "-pix_fmt", pix_fmt, "-strict", "-1", "-f", "yuv4mpegpipe", "-", | ||
| 6171 | + ]) | ||
| 6172 | + .stdin(Stdio::null()) | ||
| 6173 | + .stdout(Stdio::piped()) | ||
| 6174 | + .stderr(Stdio::piped()) | ||
| 6175 | + .output() | ||
| 6176 | + .expect("ffmpeg failed to run"); | ||
| 6177 | + assert!( | ||
| 6178 | + y4m.status.success(), | ||
| 6179 | + "{NAME}: ffmpeg refused the {bit_depth}-bit fixture: {}", | ||
| 6180 | + String::from_utf8_lossy(&y4m.stderr) | ||
| 6181 | + ); | ||
| 6182 | + let depth_arg = format!("--bit-depth={bit_depth}"); | ||
| 6183 | + let input_depth_arg = format!("--input-bit-depth={bit_depth}"); | ||
| 6184 | + let tx_arg = format!("--enable-tx-size-search={tx_search}"); | ||
| 6185 | + let args: Vec<&str> = vec![ | ||
| 6186 | + "--codec=av1", "--passes=1", "--end-usage=q", "--cq-level=34", "--cpu-used=0", | ||
| 6187 | + "--threads=1", "--row-mt=0", "--sb-size=64", &depth_arg, &input_depth_arg, | ||
| 6188 | + "--enable-restoration=0", "--enable-palette=0", "--deltaq-mode=0", | ||
| 6189 | + "--enable-filter-intra=0", "--enable-cfl-intra=0", "--enable-intrabc=0", | ||
| 6190 | + "--lag-in-frames=0", | ||
| 6191 | + // Per-arm overrides go LAST (aomenc keeps the last | ||
| 6192 | + // occurrence of a repeated --enable-* flag). | ||
| 6193 | + &tx_arg, | ||
| 6194 | + "--enable-rect-partitions=1", "--enable-ab-partitions=0", | ||
| 6195 | + "--enable-1to4-partitions=0", "--min-partition-size=16", | ||
| 6196 | + "--max-partition-size=32", | ||
| 6197 | + "--obu", "-o", "-", "-", | ||
| 6198 | + ]; | ||
| 6199 | + let mut child = Command::new(aomenc_path()) | ||
| 6200 | + .args(&args) | ||
| 6201 | + .stdin(Stdio::piped()) | ||
| 6202 | + .stdout(Stdio::piped()) | ||
| 6203 | + .stderr(Stdio::piped()) | ||
| 6204 | + .spawn() | ||
| 6205 | + .expect("aomenc failed to start"); | ||
| 6206 | + child | ||
| 6207 | + .stdin | ||
| 6208 | + .take() | ||
| 6209 | + .expect("aomenc stdin") | ||
| 6210 | + .write_all(&y4m.stdout) | ||
| 6211 | + .expect("writing y4m to aomenc"); | ||
| 6212 | + let out = child.wait_with_output().expect("aomenc failed to run"); | ||
| 6213 | + assert!( | ||
| 6214 | + out.status.success(), | ||
| 6215 | + "aomenc refused the fixture: {}", | ||
| 6216 | + String::from_utf8_lossy(&out.stderr) | ||
| 6217 | + ); | ||
| 6218 | + let stream = out.stdout; | ||
| 6219 | + let before = decode::tmv_hits(); | ||
| 6220 | + let frames = match decode_stream(&stream) { | ||
| 6221 | + Err(e) => { | ||
| 6222 | + let msg = e.to_string(); | ||
| 6223 | + assert!( | ||
| 6224 | + msg.contains("unsupported"), | ||
| 6225 | + "{NAME} failed outright, not a named refusal ({bit_depth}-bit, \ | ||
| 6226 | + attempt {attempt}): {msg}" | ||
| 6227 | + ); | ||
| 6228 | + named_refusals += 1; | ||
| 6229 | + eprintln!("{bit_depth}-bit attempt {attempt} refusal: {msg}"); | ||
| 6230 | + continue; | ||
| 6231 | + } | ||
| 6232 | + Ok(frames) => frames, | ||
| 6233 | + }; | ||
| 6234 | + let tmv = decode::tmv_hits() - before; | ||
| 6235 | + let ffmpeg_frames = if bit_depth == 10 { | ||
| 6236 | + ffmpeg_decode_sequence_10bit(&stream, width, height, frame_count) | ||
| 6237 | + } else { | ||
| 6238 | + ffmpeg_decode_sequence(&stream, width, height, frame_count) | ||
| 6239 | + }; | ||
| 6240 | + assert_eq!(frames.len(), frame_count); | ||
| 6241 | + for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() { | ||
| 6242 | + assert_eq!(got.y, want.y, "{NAME} frame {i} luma vs ffmpeg (attempt {attempt}, {bit_depth}-bit)"); | ||
| 6243 | + assert_eq!(got.u, want.u, "{NAME} frame {i} U vs ffmpeg (attempt {attempt}, {bit_depth}-bit)"); | ||
| 6244 | + assert_eq!(got.v, want.v, "{NAME} frame {i} V vs ffmpeg (attempt {attempt}, {bit_depth}-bit)"); | ||
| 6245 | + } | ||
| 6246 | + compared += 1; | ||
| 6247 | + tmv_proved += tmv; | ||
| 6248 | + } | ||
| 6249 | + eprintln!( | ||
| 6250 | + "{NAME} ({bit_depth}-bit): {named_refusals} named refusals, {compared} \ | ||
| 6251 | + pixel-exact attempts, blocks with a temporal MV candidate={tmv_proved}" | ||
| 6252 | + ); | ||
| 6253 | + assert!( | ||
| 6254 | + compared > 0, | ||
| 6255 | + "{NAME} ({bit_depth}-bit): every attempt refused -- gate proved nothing" | ||
| 6256 | + ); | ||
| 6257 | + assert!( | ||
| 6258 | + tmv_proved > 0, | ||
| 6259 | + "{NAME} ({bit_depth}-bit): no compared attempt ever folded a temporal MV \ | ||
| 6260 | + candidate into a block's stack -- gate proved nothing" | ||
| 6261 | + ); | ||
| 6262 | + } | ||
| 6263 | + } | ||
| 6264 | + | ||
| 6265 | + #[test] | ||
| 6266 | + // lane-inter4 r2: RED, kept (not weakened, not deleted) -- the rect inter | ||
| 6267 | + // residual path IS implemented and reached, but no aomenc recipe swept | ||
| 6268 | + // this round produced a stream whose FIRST rect inter block is a 32x16 / | ||
| 6269 | + // 16x32 one: real motion content always codes a 16x8/8x16 inter leaf (or | ||
| 6270 | + // an intra rect strip) earlier in the tile, and both of those still refuse | ||
| 6271 | + // by name, so the decode stops before any 32-level 2:1 strip. The 16x8 | ||
| 6272 | + // shape additionally needs `default_inter_ext_tx_cdf[2][TX_8X8]` (the | ||
| 6273 | + // 12-symbol DTT9_IDTX_1DDCT row, only reachable through a rect | ||
| 6274 | + // transform), which this round did not add. See lanes/inter4-r2.report.md. | ||
| 6275 | + // lane-inter4 r4 re-measured after the 16-level rect inter leaf shipped | ||
| 6276 | + // (r3): STILL RED, and the blocker moved -- 12 named refusals over 16 | ||
| 6277 | + // 8-bit attempts, 10 of them "an intra-coded HORZ/VERT strip needs | ||
| 6278 | + // rectangular intra prediction this decoder does not code yet" and 2 the | ||
| 6279 | + // 16-level AB/1:4 inter refusal; 4 attempts decoded with no rect inter | ||
| 6280 | + // residual at all and none of them mismatched (tu=0, split=0). Neither | ||
| 6281 | + // remaining blocker is this lane's: the gate un-ignores when the intra | ||
| 6282 | + // rect strip lands. | ||
| 6283 | + #[ignore = "lane-inter4 r4 (re-measured): 12/16 8-bit attempts stop at the intra-rect-strip (10) or 16-level inter AB/1:4 (2) refusal, the other 4 code no rect inter residual -- tu=0, split=0; blocked on rectangular INTRA prediction, not on this lane"] | ||
| 6284 | + fn a_real_aomenc_inter_sequence_with_a_coded_rectangular_residual_decodes_pixel_exact() { | ||
| 6285 | + const NAME: &str = | ||
| 6286 | + "a_real_aomenc_inter_sequence_with_a_coded_rectangular_residual_decodes_pixel_exact"; | ||
| 6287 | + let _gate_lock = lock_gate_counters(); | ||
| 6288 | + if !have_ffmpeg() { | ||
| 6289 | + eprintln!("SKIP {NAME}: no ffmpeg"); | ||
| 6290 | + return; | ||
| 6291 | + } | ||
| 6292 | + if !have_aomenc() { | ||
| 6293 | + eprintln!("SKIP {NAME}: no aomenc at {}", aomenc_path().display()); | ||
| 6294 | + return; | ||
| 6295 | + } | ||
| 6296 | + let (width, height, frame_count) = (192usize, 128usize, 6usize); | ||
| 6297 | + for bit_depth in [8u32, 10u32] { | ||
| 6298 | + let (mut named_refusals, mut matched, mut out_of_scope, mut oos_mismatch) = | ||
| 6299 | + (0u32, 0u32, 0u32, 0u32); | ||
| 6300 | + let (mut tu_proved, mut split_proved) = (0usize, 0usize); | ||
| 6301 | + for attempt in 0..16u32 { | ||
| 6302 | + // Two sources (a translating textured ramp, and testsrc2's | ||
| 6303 | + // natural motion) x two quantisers x two tx-size-search arms x | ||
| 6304 | + // two motion steps. | ||
| 6305 | + let tx_search = if attempt % 2 == 0 { "0" } else { "1" }; | ||
| 6306 | + let cq = [34, 22][(attempt / 2 % 2) as usize]; | ||
| 6307 | + let natural = attempt / 4 % 2 == 1; | ||
| 6308 | + let sp = 3 + (attempt / 8) * 5; | ||
| 6309 | + let duration = frame_count as f64 / 25.0; | ||
| 6310 | + // Continuous-tone, mid-frequency, translating: a flat or | ||
| 6311 | + // banded source makes aomenc code the strips `skip` (r1's | ||
| 6312 | + // gate) and its screen-content detector fires on the | ||
| 6313 | + // synthetic ramps, stopping the decode at an unrelated intra | ||
| 6314 | + // refusal long before any inter strip. | ||
| 6315 | + // Structure ALONG one axis is what makes aomenc's RD pick a | ||
| 6316 | + // 2:1 rect partition on that axis: horizontal bands drifting | ||
| 6317 | + // vertically favour PARTITION_HORZ (32x16 strips), the | ||
| 6318 | + // transposed source PARTITION_VERT (16x32). | ||
| 6319 | + let lum = if natural { | ||
| 6320 | + format!("128+58*sin((Y+N*{sp})/6)+18*sin(X/23)") | ||
| 6321 | + } else { | ||
| 6322 | + format!("128+58*sin((X+N*{sp})/6)+18*sin(Y/23)") | ||
| 6323 | + }; | ||
| 6324 | + let source = format!( | ||
| 6325 | + "color=c=gray:s={width}x{height}:d={duration}:r=25,format=gray,\ | ||
| 6326 | + geq=lum='{lum}',format=yuv420p" | ||
| 6327 | + ); | ||
| 6328 | + let pix_fmt = if bit_depth == 10 { "yuv420p10le" } else { "yuv420p" }; | ||
| 6329 | + let y4m = Command::new("ffmpeg") | ||
| 6330 | + .args([ | ||
| 6331 | + "-v", "error", "-f", "lavfi", "-i", &source, "-t", &duration.to_string(), | ||
| 6332 | + "-pix_fmt", pix_fmt, "-strict", "-1", "-f", "yuv4mpegpipe", "-", | ||
| 6333 | + ]) | ||
| 6334 | + .stdin(Stdio::null()) | ||
| 6335 | + .stdout(Stdio::piped()) | ||
| 6336 | + .stderr(Stdio::piped()) | ||
| 6337 | + .output() | ||
| 6338 | + .expect("ffmpeg failed to run"); | ||
| 6339 | + assert!( | ||
| 6340 | + y4m.status.success(), | ||
| 6341 | + "{NAME}: ffmpeg refused the {bit_depth}-bit fixture: {}", | ||
| 6342 | + String::from_utf8_lossy(&y4m.stderr) | ||
| 6343 | + ); | ||
| 6344 | + let cq_arg = format!("--cq-level={cq}"); | ||
| 6345 | + let depth_arg = format!("--bit-depth={bit_depth}"); | ||
| 6346 | + let input_depth_arg = format!("--input-bit-depth={bit_depth}"); | ||
| 6347 | + let tx_arg = format!("--enable-tx-size-search={tx_search}"); | ||
| 6348 | + let args: Vec<&str> = vec![ | ||
| 6349 | + "--codec=av1", "--passes=1", "--end-usage=q", &cq_arg, "--cpu-used=0", | ||
| 6350 | + "--threads=1", "--row-mt=0", "--sb-size=64", &depth_arg, &input_depth_arg, | ||
| 6351 | + "--enable-restoration=0", "--enable-palette=0", "--deltaq-mode=0", | ||
| 6352 | + "--enable-filter-intra=0", "--enable-cfl-intra=0", "--enable-intrabc=0", | ||
| 6353 | + "--lag-in-frames=0", | ||
| 6354 | + // Per-arm overrides go LAST: aomenc keeps the last | ||
| 6355 | + // occurrence of a repeated --enable-* flag. | ||
| 6356 | + &tx_arg, | ||
| 6357 | + "--enable-rect-partitions=1", "--enable-ab-partitions=0", | ||
| 6358 | + "--enable-1to4-partitions=0", "--min-partition-size=16", | ||
| 6359 | + "--max-partition-size=32", | ||
| 6360 | + "--obu", "-o", "-", "-", | ||
| 6361 | + ]; | ||
| 6362 | + let mut child = Command::new(aomenc_path()) | ||
| 6363 | + .args(&args) | ||
| 6364 | + .stdin(Stdio::piped()) | ||
| 6365 | + .stdout(Stdio::piped()) | ||
| 6366 | + .stderr(Stdio::piped()) | ||
| 6367 | + .spawn() | ||
| 6368 | + .expect("aomenc failed to start"); | ||
| 6369 | + child | ||
| 6370 | + .stdin | ||
| 6371 | + .take() | ||
| 6372 | + .expect("aomenc stdin") | ||
| 6373 | + .write_all(&y4m.stdout) | ||
| 6374 | + .expect("writing y4m to aomenc"); | ||
| 6375 | + let out = child.wait_with_output().expect("aomenc failed to run"); | ||
| 6376 | + assert!( | ||
| 6377 | + out.status.success(), | ||
| 6378 | + "aomenc refused the fixture: {}", | ||
| 6379 | + String::from_utf8_lossy(&out.stderr) | ||
| 6380 | + ); | ||
| 6381 | + let stream = out.stdout; | ||
| 6382 | + let before = (decode::rect_inter_tu_hits(), decode::rect_inter_txsplit_hits()); | ||
| 6383 | + let frames = match decode_stream(&stream) { | ||
| 6384 | + Err(e) => { | ||
| 6385 | + let msg = e.to_string(); | ||
| 6386 | + assert!( | ||
| 6387 | + msg.contains("unsupported"), | ||
| 6388 | + "{NAME} failed outright, not a named refusal ({bit_depth}-bit, \ | ||
| 6389 | + attempt {attempt}): {msg}" | ||
| 6390 | + ); | ||
| 6391 | + named_refusals += 1; | ||
| 6392 | + eprintln!("{bit_depth}-bit attempt {attempt} refusal: {msg}"); | ||
| 6393 | + continue; | ||
| 6394 | + } | ||
| 6395 | + Ok(frames) => frames, | ||
| 6396 | + }; | ||
| 6397 | + let after = (decode::rect_inter_tu_hits(), decode::rect_inter_txsplit_hits()); | ||
| 6398 | + let (tu, split) = (after.0 - before.0, after.1 - before.1); | ||
| 6399 | + let ffmpeg_frames = if bit_depth == 10 { | ||
| 6400 | + ffmpeg_decode_sequence_10bit(&stream, width, height, frame_count) | ||
| 6401 | + } else { | ||
| 6402 | + ffmpeg_decode_sequence(&stream, width, height, frame_count) | ||
| 6403 | + }; | ||
| 6404 | + assert_eq!(frames.len(), frame_count); | ||
| 6405 | + let mismatched = frames | ||
| 6406 | + .iter() | ||
| 6407 | + .zip(&ffmpeg_frames) | ||
| 6408 | + .any(|(got, want)| got.y != want.y || got.u != want.u || got.v != want.v); | ||
| 6409 | + if tu + split == 0 { | ||
| 6410 | + out_of_scope += 1; | ||
| 6411 | + if mismatched { | ||
| 6412 | + oos_mismatch += 1; | ||
| 6413 | + eprintln!( | ||
| 6414 | + "{NAME}: {bit_depth}-bit attempt {attempt} MISMATCHES with zero \ | ||
| 6415 | + coded rect inter transform units -- another shape's defect" | ||
| 6416 | + ); | ||
| 6417 | + } | ||
| 6418 | + continue; | ||
| 6419 | + } | ||
| 6420 | + for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() { | ||
| 6421 | + assert_eq!(got.y, want.y, "{NAME} frame {i} luma vs ffmpeg (attempt {attempt}, {bit_depth}-bit, tx_search={tx_search})"); | ||
| 6422 | + assert_eq!(got.u, want.u, "{NAME} frame {i} U vs ffmpeg (attempt {attempt}, {bit_depth}-bit, tx_search={tx_search})"); | ||
| 6423 | + assert_eq!(got.v, want.v, "{NAME} frame {i} V vs ffmpeg (attempt {attempt}, {bit_depth}-bit, tx_search={tx_search})"); | ||
| 6424 | + } | ||
| 6425 | + tu_proved += tu; | ||
| 6426 | + split_proved += split; | ||
| 6427 | + matched += 1; | ||
| 6428 | + } | ||
| 6429 | + eprintln!( | ||
| 6430 | + "{NAME} ({bit_depth}-bit): {named_refusals} named refusals, {matched} pixel-exact \ | ||
| 6431 | + attempts carrying a coded rect inter residual, whole-block rect TUs={tu_proved}, \ | ||
| 6432 | + rect trees that split={split_proved}, {out_of_scope} attempts carried none \ | ||
| 6433 | + ({oos_mismatch} of them mismatched)" | ||
| 6434 | + ); | ||
| 6435 | + assert_eq!( | ||
| 6436 | + oos_mismatch, 0, | ||
| 6437 | + "{NAME}: {oos_mismatch} attempt(s) with no coded rect inter residual decoded but \ | ||
| 6438 | + mismatched ffmpeg -- a defect of another shape, not a pass" | ||
| 6439 | + ); | ||
| 6440 | + assert!( | ||
| 6441 | + tu_proved > 0, | ||
| 6442 | + "{NAME} ({bit_depth}-bit): no pixel-exact attempt ever coded a rectangular inter \ | ||
| 6443 | + residual (tu={tu_proved}, split={split_proved}, {named_refusals} refusals, \ | ||
| 6444 | + {out_of_scope} out of scope) -- gate proved nothing" | ||
| 6445 | + ); | ||
| 6446 | + } | ||
| 6447 | + } | ||
| 6448 | + | ||
| 6449 | + #[test] | ||
| 6450 | + // lane-inter4 r3: the 16x16-level rect INTER leaf -- PARTITION_HORZ / | ||
| 6451 | + // PARTITION_VERT at 16x16 on an inter frame, i.e. two 16x8 / 8x16 inter | ||
| 6452 | + // blocks, mode info + rectangular residual + prediction. Every decoded | ||
| 6453 | + // frame is compared Y/U/V against ffmpeg, refusals are counted and never | ||
| 6454 | + // SKIPped, and the gate asserts a pixel-exact attempt for BOTH axes that | ||
| 6455 | + // also coded a rectangular inter transform unit (i.e. was not `skip`). | ||
| 6456 | + fn a_real_aomenc_inter_sequence_with_a_16_level_rect_leaf_decodes_pixel_exact() { | ||
| 6457 | + const NAME: &str = | ||
| 6458 | + "a_real_aomenc_inter_sequence_with_a_16_level_rect_leaf_decodes_pixel_exact"; | ||
| 6459 | + let _gate_lock = lock_gate_counters(); | ||
| 6460 | + if !have_ffmpeg() { | ||
| 6461 | + eprintln!("SKIP {NAME}: no ffmpeg"); | ||
| 6462 | + return; | ||
| 6463 | + } | ||
| 6464 | + if !have_aomenc() { | ||
| 6465 | + eprintln!("SKIP {NAME}: no aomenc at {}", aomenc_path().display()); | ||
| 6466 | + return; | ||
| 6467 | + } | ||
| 6468 | + let (width, height, frame_count) = (192usize, 128usize, 6usize); | ||
| 6469 | + // Coded (non-skip) rect inter transform units, summed over both bit | ||
| 6470 | + // depths: at 10 bits this recipe's rect leaves all come out `skip` | ||
| 6471 | + // (measured at cq 34/22, 30/26 and 24/12 -- the lower pairs stop | ||
| 6472 | + // reaching a rect leaf at all), so the RESIDUAL half of the claim is | ||
| 6473 | + // proven by the 8-bit arm while the 10-bit arm proves the mode-info, | ||
| 6474 | + // prediction and neighbour halves on both axes. | ||
| 6475 | + let mut tu_total = 0usize; | ||
| 6476 | + for bit_depth in [8u32, 10u32] { | ||
| 6477 | + let (mut named_refusals, mut matched, mut out_of_scope, mut oos_mismatch) = | ||
| 6478 | + (0u32, 0u32, 0u32, 0u32); | ||
| 6479 | + let (mut tu_proved, mut split_proved) = (0usize, 0usize); | ||
| 6480 | + let (mut horz_proved, mut vert_proved, mut sub16_split) = (0u32, 0u32, 0usize); | ||
| 6481 | + // lane-inter4 r4, measured residue of this recipe family (sweep | ||
| 6482 | + // over cq {8,12,16,22} x {both axes} x both depths, tx-size-search | ||
| 6483 | + // on, via `decode_probe`'s `rect_inter:` counters): the rect | ||
| 6484 | + // var-tx SPLIT arm never fires (txsplit=0 everywhere) and a 10-bit | ||
| 6485 | + // rect leaf is always `skip` (tu=0 at every cq that decodes) -- | ||
| 6486 | + // below cq 22 every attempt stops at another lane's intra refusal | ||
| 6487 | + // ("a HORZ/VERT intra strip below 16x16 with a split transform"). | ||
| 6488 | + // Both are asserted here only where they DO fire (8-bit tu>0); | ||
| 6489 | + // shipped-but-unexercised, see lanes/inter4-r4.report.md. | ||
| 6490 | + // lane-inter4 r4: attempts 16..32 repeat the same sweep with | ||
| 6491 | + // `--enable-obmc=1`. r3 refused OBMC on this shape; r4's | ||
| 6492 | + // instrumented-aomdec comparison showed the neighbour list AND | ||
| 6493 | + // every pre-filter frame bit-exact, so the arm is a gate now. | ||
| 6494 | + let mut obmc_leaf_proved = 0usize; | ||
| 6495 | + for attempt in 0..32u32 { | ||
| 6496 | + let obmc_arg = if attempt >= 16 { "--enable-obmc=1" } else { "--enable-obmc=0" }; | ||
| 6497 | + let attempt = attempt % 16; | ||
| 6498 | + // Two sources (a translating textured ramp, and testsrc2's | ||
| 6499 | + // natural motion) x two quantisers x two tx-size-search arms x | ||
| 6500 | + // two motion steps. | ||
| 6501 | + let tx_search = if attempt % 2 == 0 { "0" } else { "1" }; | ||
| 6502 | + // A 10-bit encode of the same source spends fewer bits on | ||
| 6503 | + // residual at a given cq, so it needs the lower pair to make | ||
| 6504 | + // a rect leaf non-skip at all (measured: cq 34/22 gives zero | ||
| 6505 | + // coded rect inter TUs in 16 10-bit attempts). | ||
| 6506 | + let cq = [34, 22][(attempt / 2 % 2) as usize]; | ||
| 6507 | + let natural = attempt / 4 % 2 == 1; | ||
| 6508 | + let sp = 3 + (attempt / 8) * 5; | ||
| 6509 | + let duration = frame_count as f64 / 25.0; | ||
| 6510 | + // Continuous-tone, mid-frequency, translating: a flat or | ||
| 6511 | + // banded source makes aomenc code the strips `skip` (r1's | ||
| 6512 | + // gate) and its screen-content detector fires on the | ||
| 6513 | + // synthetic ramps, stopping the decode at an unrelated intra | ||
| 6514 | + // refusal long before any inter strip. | ||
| 6515 | + // Structure ALONG one axis is what makes aomenc's RD pick a | ||
| 6516 | + // 2:1 rect partition on that axis: horizontal bands drifting | ||
| 6517 | + // vertically favour PARTITION_HORZ (32x16 strips), the | ||
| 6518 | + // transposed source PARTITION_VERT (16x32). | ||
| 6519 | + let lum = if natural { | ||
| 6520 | + format!("128+58*sin((Y+N*{sp})/6)+18*sin(X/23)") | ||
| 6521 | + } else { | ||
| 6522 | + format!("128+58*sin((X+N*{sp})/6)+18*sin(Y/23)") | ||
| 6523 | + }; | ||
| 6524 | + let source = format!( | ||
| 6525 | + "color=c=gray:s={width}x{height}:d={duration}:r=25,format=gray,\ | ||
| 6526 | + geq=lum='{lum}',format=yuv420p" | ||
| 6527 | + ); | ||
| 6528 | + let pix_fmt = if bit_depth == 10 { "yuv420p10le" } else { "yuv420p" }; | ||
| 6529 | + let y4m = Command::new("ffmpeg") | ||
| 6530 | + .args([ | ||
| 6531 | + "-v", "error", "-f", "lavfi", "-i", &source, "-t", &duration.to_string(), | ||
| 6532 | + "-pix_fmt", pix_fmt, "-strict", "-1", "-f", "yuv4mpegpipe", "-", | ||
| 6533 | + ]) | ||
| 6534 | + .stdin(Stdio::null()) | ||
| 6535 | + .stdout(Stdio::piped()) | ||
| 6536 | + .stderr(Stdio::piped()) | ||
| 6537 | + .output() | ||
| 6538 | + .expect("ffmpeg failed to run"); | ||
| 6539 | + assert!( | ||
| 6540 | + y4m.status.success(), | ||
| 6541 | + "{NAME}: ffmpeg refused the {bit_depth}-bit fixture: {}", | ||
| 6542 | + String::from_utf8_lossy(&y4m.stderr) | ||
| 6543 | + ); | ||
| 6544 | + let cq_arg = format!("--cq-level={cq}"); | ||
| 6545 | + let depth_arg = format!("--bit-depth={bit_depth}"); | ||
| 6546 | + let input_depth_arg = format!("--input-bit-depth={bit_depth}"); | ||
| 6547 | + let tx_arg = format!("--enable-tx-size-search={tx_search}"); | ||
| 6548 | + let args: Vec<&str> = vec![ | ||
| 6549 | + "--codec=av1", "--passes=1", "--end-usage=q", &cq_arg, "--cpu-used=0", | ||
| 6550 | + "--threads=1", "--row-mt=0", "--sb-size=64", &depth_arg, &input_depth_arg, | ||
| 6551 | + "--enable-restoration=0", "--enable-palette=0", "--deltaq-mode=0", | ||
| 6552 | + "--enable-filter-intra=0", "--enable-cfl-intra=0", "--enable-intrabc=0", | ||
| 6553 | + "--lag-in-frames=0", | ||
| 6554 | + // Per-arm overrides go LAST: aomenc keeps the last | ||
| 6555 | + // occurrence of a repeated --enable-* flag. | ||
| 6556 | + &tx_arg, | ||
| 6557 | + "--enable-rect-partitions=1", "--enable-ab-partitions=0", | ||
| 6558 | + "--enable-1to4-partitions=0", "--min-partition-size=8", | ||
| 6559 | + "--max-partition-size=16", | ||
| 6560 | + obmc_arg, | ||
| 6561 | + "--obu", "-o", "-", "-", | ||
| 6562 | + ]; | ||
| 6563 | + let mut child = Command::new(aomenc_path()) | ||
| 6564 | + .args(&args) | ||
| 6565 | + .stdin(Stdio::piped()) | ||
| 6566 | + .stdout(Stdio::piped()) | ||
| 6567 | + .stderr(Stdio::piped()) | ||
| 6568 | + .spawn() | ||
| 6569 | + .expect("aomenc failed to start"); | ||
| 6570 | + child | ||
| 6571 | + .stdin | ||
| 6572 | + .take() | ||
| 6573 | + .expect("aomenc stdin") | ||
| 6574 | + .write_all(&y4m.stdout) | ||
| 6575 | + .expect("writing y4m to aomenc"); | ||
| 6576 | + let out = child.wait_with_output().expect("aomenc failed to run"); | ||
| 6577 | + assert!( | ||
| 6578 | + out.status.success(), | ||
| 6579 | + "aomenc refused the fixture: {}", | ||
| 6580 | + String::from_utf8_lossy(&out.stderr) | ||
| 6581 | + ); | ||
| 6582 | + let stream = out.stdout; | ||
| 6583 | + let before = (decode::rect_inter_tu_hits(), decode::rect_inter_txsplit_hits()); | ||
| 6584 | + let before_obmc_leaf = decode::obmc_rect_leaf_hits(); | ||
| 6585 | + let before_leaf = ( | ||
| 6586 | + decode::inter_leaf16_horz_hits(), | ||
| 6587 | + decode::inter_leaf16_vert_hits(), | ||
| 6588 | + decode::inter_sub16_split_hits(), | ||
| 6589 | + ); | ||
| 6590 | + let frames = match decode_stream(&stream) { | ||
| 6591 | + Err(e) => { | ||
| 6592 | + let msg = e.to_string(); | ||
| 6593 | + assert!( | ||
| 6594 | + msg.contains("unsupported"), | ||
| 6595 | + "{NAME} failed outright, not a named refusal ({bit_depth}-bit, \ | ||
| 6596 | + attempt {attempt}): {msg}" | ||
| 6597 | + ); | ||
| 6598 | + named_refusals += 1; | ||
| 6599 | + eprintln!("{bit_depth}-bit attempt {attempt} refusal: {msg}"); | ||
| 6600 | + continue; | ||
| 6601 | + } | ||
| 6602 | + Ok(frames) => frames, | ||
| 6603 | + }; | ||
| 6604 | + let after = (decode::rect_inter_tu_hits(), decode::rect_inter_txsplit_hits()); | ||
| 6605 | + let (tu, split) = (after.0 - before.0, after.1 - before.1); | ||
| 6606 | + let obmc_leaf = decode::obmc_rect_leaf_hits() - before_obmc_leaf; | ||
| 6607 | + let (horz, vert, splits16) = ( | ||
| 6608 | + decode::inter_leaf16_horz_hits() - before_leaf.0, | ||
| 6609 | + decode::inter_leaf16_vert_hits() - before_leaf.1, | ||
| 6610 | + decode::inter_sub16_split_hits() - before_leaf.2, | ||
| 6611 | + ); | ||
| 6612 | + let ffmpeg_frames = if bit_depth == 10 { | ||
| 6613 | + ffmpeg_decode_sequence_10bit(&stream, width, height, frame_count) | ||
| 6614 | + } else { | ||
| 6615 | + ffmpeg_decode_sequence(&stream, width, height, frame_count) | ||
| 6616 | + }; | ||
| 6617 | + assert_eq!(frames.len(), frame_count); | ||
| 6618 | + let mismatched = frames | ||
| 6619 | + .iter() | ||
| 6620 | + .zip(&ffmpeg_frames) | ||
| 6621 | + .any(|(got, want)| got.y != want.y || got.u != want.u || got.v != want.v); | ||
| 6622 | + if horz + vert == 0 { | ||
| 6623 | + out_of_scope += 1; | ||
| 6624 | + if mismatched { | ||
| 6625 | + oos_mismatch += 1; | ||
| 6626 | + eprintln!( | ||
| 6627 | + "{NAME}: {bit_depth}-bit attempt {attempt} MISMATCHES with zero \ | ||
| 6628 | + 16-level rect inter leaf -- another shape's defect" | ||
| 6629 | + ); | ||
| 6630 | + } | ||
| 6631 | + continue; | ||
| 6632 | + } | ||
| 6633 | + if mismatched { | ||
| 6634 | + // lane-inter4 r3: where, not just that -- a handful of | ||
| 6635 | + // 4x4-aligned pixels is a prediction/reconstruction | ||
| 6636 | + // defect, a whole band from the first row down is a | ||
| 6637 | + // desync. | ||
| 6638 | + for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() { | ||
| 6639 | + let bad: Vec<usize> = (0..got.y.len()) | ||
| 6640 | + .filter(|&k| got.y[k] != want.y[k]) | ||
| 6641 | + .collect(); | ||
| 6642 | + if !bad.is_empty() { | ||
| 6643 | + eprintln!( | ||
| 6644 | + "{NAME}: attempt {attempt} {bit_depth}-bit frame {i}: {} luma \ | ||
| 6645 | + pixels differ, first at ({}, {}), max |delta| {}", | ||
| 6646 | + bad.len(), | ||
| 6647 | + bad[0] % width, | ||
| 6648 | + bad[0] / width, | ||
| 6649 | + bad.iter() | ||
| 6650 | + .map(|&k| (got.y[k] as i32 - want.y[k] as i32).abs()) | ||
| 6651 | + .max() | ||
| 6652 | + .unwrap_or(0) | ||
| 6653 | + ); | ||
| 6654 | + } | ||
| 6655 | + } | ||
| 6656 | + } | ||
| 6657 | + for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() { | ||
| 6658 | + assert_eq!(got.y, want.y, "{NAME} frame {i} luma vs ffmpeg (attempt {attempt}, {bit_depth}-bit, tx_search={tx_search})"); | ||
| 6659 | + assert_eq!(got.u, want.u, "{NAME} frame {i} U vs ffmpeg (attempt {attempt}, {bit_depth}-bit, tx_search={tx_search})"); | ||
| 6660 | + assert_eq!(got.v, want.v, "{NAME} frame {i} V vs ffmpeg (attempt {attempt}, {bit_depth}-bit, tx_search={tx_search})"); | ||
| 6661 | + } | ||
| 6662 | + tu_proved += tu; | ||
| 6663 | + obmc_leaf_proved += obmc_leaf; | ||
| 6664 | + split_proved += split; | ||
| 6665 | + sub16_split += splits16; | ||
| 6666 | + if horz > 0 { | ||
| 6667 | + horz_proved += 1; | ||
| 6668 | + } | ||
| 6669 | + if vert > 0 { | ||
| 6670 | + vert_proved += 1; | ||
| 6671 | + } | ||
| 6672 | + matched += 1; | ||
| 6673 | + } | ||
| 6674 | + eprintln!( | ||
| 6675 | + "{NAME} ({bit_depth}-bit): {named_refusals} named refusals, {matched} pixel-exact \ | ||
| 6676 | + attempts carrying a 16-level rect inter leaf, 16x8-carrying={horz_proved}, \ | ||
| 6677 | + 8x16-carrying={vert_proved}, whole-block rect TUs={tu_proved}, rect trees that \ | ||
| 6678 | + split={split_proved}, 16x16 SPLITs={sub16_split}, OBMC blends on a rect \ | ||
| 6679 | + leaf={obmc_leaf_proved}, {out_of_scope} attempts \ | ||
| 6680 | + carried none ({oos_mismatch} of them mismatched)" | ||
| 6681 | + ); | ||
| 6682 | + assert_eq!( | ||
| 6683 | + oos_mismatch, 0, | ||
| 6684 | + "{NAME}: {oos_mismatch} attempt(s) with no coded rect inter residual decoded but \ | ||
| 6685 | + mismatched ffmpeg -- a defect of another shape, not a pass" | ||
| 6686 | + ); | ||
| 6687 | + assert!( | ||
| 6688 | + horz_proved > 0 && vert_proved > 0, | ||
| 6689 | + "{NAME} ({bit_depth}-bit): the 16-level rect inter leaf is not proven on both \ | ||
| 6690 | + axes (16x8={horz_proved}, 8x16={vert_proved}, tu={tu_proved}, 16x16 \ | ||
| 6691 | + SPLITs={sub16_split}, {named_refusals} refusals, {out_of_scope} out of \ | ||
| 6692 | + scope) -- gate proved nothing" | ||
| 6693 | + ); | ||
| 6694 | + assert!( | ||
| 6695 | + obmc_leaf_proved > 0, | ||
| 6696 | + "{NAME} ({bit_depth}-bit): no pixel-exact attempt ever ran the OBMC blend on a \ | ||
| 6697 | + 16x8/8x16 inter leaf -- the `--enable-obmc=1` arm proved nothing" | ||
| 6698 | + ); | ||
| 6699 | + tu_total += tu_proved; | ||
| 6700 | + } | ||
| 6701 | + assert!( | ||
| 6702 | + tu_total > 0, | ||
| 6703 | + "{NAME}: no pixel-exact attempt at either bit depth coded a rectangular inter \ | ||
| 6704 | + residual on a 16-level leaf -- the residual half of the claim is unproven" | ||
| 6705 | + ); | ||
| 6706 | + } | ||
| 6707 | + | ||
| 6708 | + | ||
| 5901 | #[test] | 6709 | #[test] |
| 5902 | fn a_real_aomenc_inter_sequence_with_deblocking_decodes_pixel_exact() { | 6710 | fn a_real_aomenc_inter_sequence_with_deblocking_decodes_pixel_exact() { |
| 5903 | if !have_ffmpeg() { | 6711 | 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 + `cargo test -p ec-av1 --lib superblock_level_rect_partition` | 16 aomenc encodes, decode + ffmpeg Y/U/V pixel compare over 6 frames each | 8-bit: 4 named refusals, 2 pixel-exact attempts carrying the arm, 64x32 strips=4, 32x64 strips=0, 10 out-of-scope (0 mismatched); gate ok. Full suite at commit 754a7dd: 321 passed / 2 failed / 30 ignored; both failures were stale pins of MINE (the SB refusal string and a line-continuation in a new refusal literal) and are fixed in the follow-up commit -- the suite has NOT been re-run end to end since. | ||
| 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). | ||
lanes/inter4-r2.report.mdadded+128 -0
| @@ -0,0 +1,128 @@ | |||
| 1 | +# lane-inter4 r2 — rectangular INTER residual coding | ||
| 2 | + | ||
| 3 | +Branch `lane-inter4`, worktree `/home/user/Documents/Code/Rust/edith_codecs-inter4`, | ||
| 4 | +off r1's `59ccb01` (main `146896f`). No rebase this round (main unchanged since). | ||
| 5 | + | ||
| 6 | +## Owed from r1: the full suite at 59ccb01 | ||
| 7 | + | ||
| 8 | + $HOME/.cache/inter4-suite-r2a.log | ||
| 9 | + test result: ok. 323 passed; 0 failed; 30 ignored; finished in 458.10s | ||
| 10 | + | ||
| 11 | +r1's two self-failures were indeed fixed by `59ccb01`. | ||
| 12 | + | ||
| 13 | +EVIDENCE: $HOME/.cache/inter4-suite-r2a.log | ec-av1 --lib under systemd-run at 59ccb01 | 323 passed / 0 failed / 30 ignored | ||
| 14 | + | ||
| 15 | +## What this round built (capability present, NOT claimed proven) | ||
| 16 | + | ||
| 17 | +Rectangular inter residual coding for the 2:1 shapes whose tables exist — | ||
| 18 | +32x16 / 16x32 (`crates/ec-av1/src/decode.rs`): | ||
| 19 | + | ||
| 20 | +- `rect_inter_residual_supported` (decode.rs) — the shape gate. The r1 refusal | ||
| 21 | + string ("a non-skip rectangular (HORZ/VERT/HORZ_B) strip needs rectangular | ||
| 22 | + residual coding") is now conditional on it, so `refusal_inventory` is | ||
| 23 | + unchanged and 64x32/64x16/32x8/8x32/16x8 keep refusing by name. | ||
| 24 | +- `read_block_tx_size_rect` — spec 5.11.17 from the block's own *rect* | ||
| 25 | + `max_txsize_rect_lookup` entry. `TX_MODE_LARGEST`: no symbol, one rect TU. | ||
| 26 | + `TX_MODE_SELECT`: one depth-0 `txfm_partition` symbol whose context comes | ||
| 27 | + from the new `txfm_partition_ctx_rect` (above compares `tx_size_wide`, left | ||
| 28 | + `tx_size_high`, category from `txsize_sqr_up_map`); `0` leaves one rect TU, | ||
| 29 | + `1` splits into `sub_tx_size_map`'s two SQUARE sub-transforms from which the | ||
| 30 | + existing square `read_var_tx_size` continues at depth 1 — so every leaf of a | ||
| 31 | + split rect block is square and the existing square leaf loop reconstructs it. | ||
| 32 | +- `txfm_partition_update_rect` / the skipped-inter case — a skipped rect inter | ||
| 33 | + block records its own BLOCK width above and height left (libaom | ||
| 34 | + `set_txfm_ctxs(.., skip && is_inter)`), where r1 recorded a square `side` | ||
| 35 | + both ways. | ||
| 36 | +- `read_inter_plane_rect` + `embed_rect_grid` — rect coefficients via | ||
| 37 | + `read_coeffs_rect` (TxClass-aware scans/contexts), rect inverse via | ||
| 38 | + `dequant_and_inverse_typed_wh`, added onto the top-left `w x h` of the | ||
| 39 | + square-strided MC predictor. `txb_skip_ctx` 0 for luma (this unit IS the | ||
| 40 | + block: `get_txb_ctx`'s `plane_bsize == txsize_to_bsize[tx_size]` branch); | ||
| 41 | + chroma at `av1_get_max_uv_txsize` (16x8 / 8x16, `TxbSet::ChromaRect16x8`), | ||
| 42 | + inheriting the luma unit's `tx_type`. | ||
| 43 | +- `cdf_state.rs`: new `TxbSet::LumaRect32x16Inter` — `LumaRect32x16`'s | ||
| 44 | + coefficient tables (512-coefficient `eob_pt`) plus the inter `tx_type` | ||
| 45 | + alphabet `default_inter_ext_tx_cdf[3][TX_16X16]` (`EXT_TX_SET_DCT_IDTX`, | ||
| 46 | + which is what `av1_get_ext_tx_set_type` returns for an inter TU with | ||
| 47 | + `tx_size_sqr_up == TX_32X32`) — i.e. the existing `INTER_TX_TYPE_SET3_16`. | ||
| 48 | +- Two out-of-bounds fixes found by the new content (both in r1 code, both hit | ||
| 49 | + before any of this round's residual code runs): `around_mi(at, side)` read | ||
| 50 | + `side` cells left for a rect strip and indexed past the tile's last mi row | ||
| 51 | + (now `around_mi_rect(at_mi, write_w, write_h)` for a rect strip); and | ||
| 52 | + `record_rect_mi`/`record_split_luma_rect_mi` stamped past the frame's last | ||
| 53 | + 16-px column for an edge strip (now bounds-checked). | ||
| 54 | +- `EC_AV1_RECT_DUMP=1` prints the shape of every refused rect strip. | ||
| 55 | +- New counters `rect_inter_tu_hits` / `rect_inter_txsplit_hits` + accessors. | ||
| 56 | + | ||
| 57 | +## Gate — RED, kept and `#[ignore]`d with its exact reason | ||
| 58 | + | ||
| 59 | +`a_real_aomenc_inter_sequence_with_a_coded_rectangular_residual_decodes_pixel_exact` | ||
| 60 | +(stream.rs): 16 attempts x {2 axis-structured sources, 2 quantisers, 2 | ||
| 61 | +`--enable-tx-size-search` arms, 2 motion steps} x {8-bit, 10-bit}, 192x128, | ||
| 62 | +6 frames, `--enable-rect-partitions=1 --enable-ab-partitions=0 | ||
| 63 | +--enable-1to4-partitions=0 --min-partition-size=16 --max-partition-size=32`, | ||
| 64 | +overrides last; every decoded frame compared Y/U/V to ffmpeg, refusals counted | ||
| 65 | +never SKIPped, out-of-scope attempts still required pixel-exact. | ||
| 66 | + | ||
| 67 | +It never fires, and the reason is NOT the residual code: on real motion content | ||
| 68 | +the decode stops earlier, every attempt, at one of | ||
| 69 | + | ||
| 70 | + an inter partition below 16x16 other than SPLIT (16x8/8x16 rect inter leaves are not coded yet) | ||
| 71 | + an intra-coded HORZ/VERT strip needs rectangular intra prediction this decoder does not code yet | ||
| 72 | + an inter partition below 8x8 ... | ||
| 73 | + | ||
| 74 | +so no stream ever reached a 32x16/16x32 inter strip. Content sweep this round | ||
| 75 | +(4 source families x cq 22..61): flat/banded sources make the strips `skip` | ||
| 76 | +(r1's case) or trip aomenc's screen-content detector into an intra-strip | ||
| 77 | +refusal; textured/natural ones reach 16-level rect leaves first. `EC_AV1_RECT_DUMP` | ||
| 78 | +on the earlier recipe showed the only rect shapes actually refused were 32x8 / | ||
| 79 | +8x32 (the 32-level 1:4 arms), never 32x16. | ||
| 80 | + | ||
| 81 | +EVIDENCE: `cargo test -p ec-av1 --lib coded_rectangular_residual -- --nocapture` | 16 aomenc encodes x 8-bit, decode + ffmpeg Y/U/V compare | 15 named refusals, 0 attempts carrying a rect inter residual, whole-block rect TUs=0 -- gate proved nothing, so it is `#[ignore]`d with that sentence, not weakened | ||
| 82 | + | ||
| 83 | +EVIDENCE: `cargo test -p ec-av1 --lib superblock_level_rect_partition -- --nocapture` | r1's skip-strip gate re-run on this round's tree | 4 named refusals, 2 pixel-exact attempts carrying the arm, 64x32 strips=4, 0 mismatches -- the rect skip-context change did not regress it | ||
| 84 | + | ||
| 85 | +## Suite | ||
| 86 | + | ||
| 87 | + $HOME/.cache/inter4-suite-r2.log (systemd-run, unit inter4-suite-r2) | ||
| 88 | + test result: ok. 323 passed; 0 failed; 31 ignored; finished in 410.27s | ||
| 89 | + | ||
| 90 | +Same 323 passing as the 59ccb01 baseline; the one extra ignored test is this | ||
| 91 | +round's red gate. | ||
| 92 | + | ||
| 93 | +EVIDENCE: $HOME/.cache/inter4-suite-r2.log | ec-av1 --lib under systemd-run at b9dec1f | 323 passed / 0 failed / 31 ignored | ||
| 94 | + | ||
| 95 | +Sibling gates inside that run: inter_sequence*, 8x8_leaf_split, tx_select, | ||
| 96 | +superblock_level_*, obmc, warp, globalmv, force_integer_mv, refusal_inventory, | ||
| 97 | +gate_coverage -- all green. | ||
| 98 | + | ||
| 99 | +## Residue | ||
| 100 | + | ||
| 101 | +- **fix-now (r3): 16x8/8x16 inter rect leaves.** They are the real reach | ||
| 102 | + blocker: real content codes one before any 32-level 2:1 strip. Needs (a) the | ||
| 103 | + 16-level rect inter partition arm, (b) `default_inter_ext_tx_cdf[2][TX_8X8]` | ||
| 104 | + (12-symbol `DTT9_IDTX_1DDCT` at `tx_size_sqr == TX_8X8`, reachable only | ||
| 105 | + through a rect transform) as a new CDF + adaptation field, (c) a | ||
| 106 | + `TxbSet::LumaRect16x8Inter`. The residual machinery this round added then | ||
| 107 | + covers them unchanged. | ||
| 108 | +- **deferred: the 32x16/16x32 gate** — unblocked by the item above (or by a | ||
| 109 | + recipe that reaches a 32-level strip first; four source families did not). | ||
| 110 | +- **deferred: 64x32/32x64/64x16/16x64 and 32x8/8x32 rect residual** — 64-point | ||
| 111 | + and 1:4 rect transforms have no coefficient tables here; still refused by name. | ||
| 112 | +- **deferred: film probe** — not re-run: r1 measured both ReelC extracts stopping | ||
| 113 | + at lane-rectchroma's INTRA refusal ("a coded HORZ/VERT strip whose chroma | ||
| 114 | + transform has no rect coefficient tables here"), which nothing in this diff | ||
| 115 | + touches. | ||
| 116 | +- **accepted: a rect block's luma/chroma coefficient grid is embedded in the | ||
| 117 | + square grid** the downstream neighbour/deblock stamps expect (top-left | ||
| 118 | + placement). The split-leaf path already hands those stamps an all-zero square | ||
| 119 | + grid, so this is strictly more information than the shipping behaviour. | ||
| 120 | +- **open (not this lane's shape): 1-2 attempts per recipe decode fully with | ||
| 121 | + ZERO rect inter transform units and still MISMATCH ffmpeg** on 192x128 | ||
| 122 | + rect-partition inter content. Proven pre-existing for the banded recipe: with | ||
| 123 | + r1's square skip-context recording restored the same three attempts mismatch | ||
| 124 | + identically, so it is not this round's change. Not bisected (budget). | ||
| 125 | +- **DO NOT MERGE as a capability claim**: rectangular inter residual coding is | ||
| 126 | + implemented and compiles, and is exercised by no green gate (class | ||
| 127 | + refusal-lifted-without-a-gate). The refusal itself is still in place for every | ||
| 128 | + shape but 32x16/16x32. | ||
lanes/inter4-r3.report.mdadded+125 -0
| @@ -0,0 +1,125 @@ | |||
| 1 | +# lane-inter4 r3 — the 16x16-level rectangular INTER leaf | ||
| 2 | + | ||
| 3 | +Branch `lane-inter4`, worktree `/home/user/Documents/Code/Rust/edith_codecs-inter4`, | ||
| 4 | +off r2's `d2d7327` (main `11633d7`). No rebase needed (main unchanged since r2). | ||
| 5 | + | ||
| 6 | +## What shipped (commit `d913935`) | ||
| 7 | + | ||
| 8 | +The refusal r2 named as the reach blocker is gone: `PARTITION_HORZ`/`PARTITION_VERT` | ||
| 9 | +at 16x16 on an inter frame now decodes two 16x8 / 8x16 inter blocks. | ||
| 10 | + | ||
| 11 | +- `crates/ec-av1/src/decode.rs` (16-level partition site, ~17930): the HORZ/VERT | ||
| 12 | + arms. `side = SUB` keeps every CDF / prediction-buffer decision square (the | ||
| 13 | + corner-cut the 32-level rect arm already ships), `write_w`/`write_h` carry the | ||
| 14 | + true 16x8 / 8x16 footprint into the mv stack, the motion-mode row, the neighbour | ||
| 15 | + stamps and the rect residual path. AB / 1:4 at 16 refuse by name. | ||
| 16 | +- `rect_inter_residual_supported` + `rect_inter_luma_set` / `rect_inter_chroma_set` | ||
| 17 | + (decode.rs ~9020): 16x8/8x16 joins 32x16/16x32; the residual call sites pick the | ||
| 18 | + TxbSet from the block's TRUE shape instead of the hard-coded 32x16 pair. | ||
| 19 | +- `TxbSet::LumaRect16x8Inter` / `LumaRect16x8InterSet1` (cdf_state.rs): | ||
| 20 | + `LumaRect16x8`'s coefficient tables with the INTER `tx_type` alphabet. | ||
| 21 | + `av1_get_ext_tx_set_type(TX_16X8, is_inter=1, reduced)` = `EXT_TX_SET_DCT_IDTX` | ||
| 22 | + reduced, `EXT_TX_SET_ALL16` otherwise (`tx_size_sqr == TX_8X8`, not TX_16X16), | ||
| 23 | + both at the **TX_8X8** CDF row -- i.e. the existing `inter_tx_type_8` / | ||
| 24 | + `inter_tx_type_8_set1` tables, no new CDF and no new counter-reset entry. | ||
| 25 | + **r2's report was wrong here** (it predicted the 12-symbol | ||
| 26 | + `default_inter_ext_tx_cdf[2][TX_8X8]`); checked against | ||
| 27 | + `blockd.h:1092-1122` + `av1_num_ext_tx_set = {1,2,5,7,12,16}` in the oracle tree. | ||
| 28 | +- **Defect found in shipped code (class: table narrowed to the reachable sizes):** | ||
| 29 | + `eob_pt_128_luma_class1` and `eob_pt_32_chroma_class1` did not exist, so | ||
| 30 | + `LumaRect16x8`/`LumaRect16x8Set1` (the INTRA rect leaf, already shipping) and | ||
| 31 | + `ChromaRect8x4` fell back to the 2D `eob_pt` alphabet for `V_DCT`/`H_DCT` | ||
| 32 | + units. Added from `token_cdfs.h:792-848` (plane 0 / plane 1, class index 1), | ||
| 33 | + wired into all four `LumaRect16x8*` sets, `ChromaRect8x4`, and the per-frame | ||
| 34 | + `reset1` list. | ||
| 35 | +- **Second defect in shipped code:** `obmc_blend`'s `max_nb` closure was | ||
| 36 | + `1..=4 => 2`, while libaom's `max_neighbor_obmc[] = {0,1,2,3,4,4}` indexed by | ||
| 37 | + `mi_size_{wide,high}_log2` gives 0 for 1 mi and 1 for 2 mi. Only a block under | ||
| 38 | + 16 px on that axis can expose it -- i.e. exactly this round's leaves. | ||
| 39 | +- `size_group_wh` (decode.rs): `y_mode` (intra block in an inter frame) and the | ||
| 40 | + `interintra` / `interintra_mode` rows now come from `size_group_lookup[bsize]` | ||
| 41 | + of the block's TRUE footprint. The 32-level rect strips were reading the square | ||
| 42 | + row (3 where libaom says 2); a 16x8 leaf would have read 2 where libaom says 1. | ||
| 43 | + Deviation from charter: not requested, but it is the same defect shape and one | ||
| 44 | + helper covers every caller. | ||
| 45 | +- `MOTION_MODE` / `OBMC` CDFs extended from 12 to 14 packed rows with libaom's | ||
| 46 | + `BLOCK_8X16` (index 4) and `BLOCK_16X8` (index 5) entries. | ||
| 47 | + | ||
| 48 | +## Gate — GREEN | ||
| 49 | + | ||
| 50 | +`a_real_aomenc_inter_sequence_with_a_16_level_rect_leaf_decodes_pixel_exact` | ||
| 51 | +(stream.rs): 16 attempts x {2 axis-structured sources, 2 quantisers, 2 | ||
| 52 | +`--enable-tx-size-search` arms, 2 motion steps} x {8-bit, 10-bit}, 192x128, 6 | ||
| 53 | +frames, `--enable-rect-partitions=1 --enable-ab-partitions=0 | ||
| 54 | +--enable-1to4-partitions=0 --min-partition-size=8 --max-partition-size=16 | ||
| 55 | +--enable-obmc=0`, per-arm overrides LAST. Every decoded frame compared Y/U/V vs | ||
| 56 | +ffmpeg; a refusal is counted, never SKIPped; an attempt carrying no 16-level rect | ||
| 57 | +leaf is still required pixel-exact (`oos_mismatch == 0`). Hard asserts: a | ||
| 58 | +pixel-exact attempt carrying a 16x8 leaf AND one carrying an 8x16 leaf, per bit | ||
| 59 | +depth, plus at least one coded (non-skip) rectangular inter transform unit across | ||
| 60 | +the two depths. | ||
| 61 | + | ||
| 62 | + cargo test -p ec-av1 --lib 16_level_rect_leaf -- --nocapture | ||
| 63 | + | ||
| 64 | +EVIDENCE: $HOME/.cache/inter4-suite-r3.log (gate line) | 32 aomenc encodes, decode + ffmpeg Y/U/V compare of every frame | 8-bit: 6 refusals, 5 pixel-exact leaf-carrying attempts, 16x8=3, 8x16=2, coded rect TUs=2, 0 mismatches; 10-bit: 2 refusals, 4 leaf-carrying attempts, 16x8=2, 8x16=3, 0 mismatches | ||
| 65 | + | ||
| 66 | +## Refusals | ||
| 67 | + | ||
| 68 | +Lifted: `"an inter partition below 16x16 other than SPLIT (16x8/8x16 rect inter | ||
| 69 | +leaves are not coded yet)"`. | ||
| 70 | + | ||
| 71 | +Added (both in `refusal_inventory.rs`, both named, both narrow): | ||
| 72 | + | ||
| 73 | +- `"an inter 16x16-level AB or 1:4 partition (HORZ_A/HORZ_B/VERT_A/VERT_B/HORZ_4/VERT_4; ...)"` | ||
| 74 | +- `"OBMC on a 16x8/8x16 inter leaf (blend mismatches the reference on this shape)"` | ||
| 75 | + | ||
| 76 | +## The OBMC residue (open, instrumented) | ||
| 77 | + | ||
| 78 | +With `--enable-obmc=1` and everything else identical, attempt 10 (8-bit, cq 22, | ||
| 79 | +tx-size-search off) decodes all 6 frames but frame 5 has **5302 luma pixels | ||
| 80 | +wrong, max |delta| 84, first at (176,0)**; frames 0-4 are exact. The same recipe | ||
| 81 | +with `--enable-obmc=0` decodes 5 leaf-carrying attempts pixel-exact, and a run | ||
| 82 | +with obmc/warp/interintra/masked-compound ALL off is also exact -- re-enabling | ||
| 83 | +obmc alone reproduces it, so warp, interintra and masked compound are exonerated | ||
| 84 | +for this shape. The blend geometry in `obmc_blend` was checked element by element | ||
| 85 | +against libaom `build_obmc_inter_pred_above`/`_left` and | ||
| 86 | +`av1_skip_u4x4_pred_in_obmc` and matches for these shapes; `max_neighbor_obmc` | ||
| 87 | +was wrong and is fixed, but the fix left the mismatch byte-identical, so the | ||
| 88 | +cause is upstream of the blend (the neighbour walk's `size`/`size_h` stamps for a | ||
| 89 | +rect leaf, or `has_top_right`, whose doc still says "no rectangular partition | ||
| 90 | +ever produces an inter leaf here"). Refused by name rather than shipped. | ||
| 91 | + | ||
| 92 | +EVIDENCE: gate run with `--enable-obmc=1` | same 16 attempts, decode + ffmpeg compare | attempt 10 frame 5: 5302 luma pixels differ, max |delta| 84; with `--enable-obmc=0`: 0 mismatches over 5 leaf-carrying attempts | ||
| 93 | + | ||
| 94 | +## Suite | ||
| 95 | + | ||
| 96 | + $HOME/.cache/inter4-suite-r3.log (systemd user unit inter4-suite-1788315557) | ||
| 97 | + test result: ok. 324 passed; 0 failed; 31 ignored; finished in 412.37s | ||
| 98 | + | ||
| 99 | +Same 323 as r2's baseline plus this round's new gate; the one ignored addition | ||
| 100 | +is still r2's own 32x16/16x32 gate. Sibling gates inside that run: every | ||
| 101 | +`inter_sequence*`, `8x8_leaf_split`, `tx_select`, `superblock_level_rect_partition`, | ||
| 102 | +`obmc`, `warp`, `globalmv`, `force_integer_mv`, `refusal_inventory`, | ||
| 103 | +`gate_coverage` -- all green, including the ones that read the tables this round | ||
| 104 | +touched (`MOTION_MODE`/`OBMC` rows, `LumaRect16x8*`, `ChromaRect8x4`). | ||
| 105 | + | ||
| 106 | +EVIDENCE: $HOME/.cache/inter4-suite-r3.log | ec-av1 --lib under a systemd user unit at d913935 | 324 passed / 0 failed / 31 ignored | ||
| 107 | + | ||
| 108 | +## Residue | ||
| 109 | + | ||
| 110 | +- **fix-now (r4): OBMC on a 16x8/8x16 leaf** -- named refusal today. Next step is | ||
| 111 | + `has_top_right` for rect inter blocks (libaom's `xd->width < xd->height` / | ||
| 112 | + `> ` / `PARTITION_VERT_A` branches are dropped in our copy) and the | ||
| 113 | + `overlappable_above/left` step caps (`AOMMIN(xd->width, mi_size_wide[nb])`). | ||
| 114 | +- **deferred: r2's 32x16/16x32 gate** (`..._with_a_coded_rectangular_residual_...`) | ||
| 115 | + -- still `#[ignore]`d; not re-measured this round (budget). With the 16-level | ||
| 116 | + leaves reachable it may now get past its first rect strip; unblocked by simply | ||
| 117 | + re-running it, which r4 should do before anything else. | ||
| 118 | +- **deferred: 16x16 SPLIT under this recipe** -- the gate counts `16x16 SPLITs=0` | ||
| 119 | + on every attempt (aomenc picks NONE/HORZ/VERT at 16 here); the 8x8-leaf path is | ||
| 120 | + gated by its own sibling test, so the count is printed, not asserted. | ||
| 121 | +- **accepted: the 10-bit arm proves no residual** -- every 10-bit rect leaf in | ||
| 122 | + this recipe is `skip` at cq 34/22, and cq 30/26 or 24/12 stops reaching a rect | ||
| 123 | + leaf at all (measured). The residual half is asserted across both depths. | ||
| 124 | +- **accepted: `_size_group` is now a dead parameter** of `decode_inter_block` | ||
| 125 | + (superseded by `size_group_wh`), kept rather than editing twenty call sites. | ||
lanes/inter4-r4.report.mdadded+142 -0
| @@ -0,0 +1,142 @@ | |||
| 1 | +# lane-inter4 r4 — OBMC on a 16x8/8x16 inter leaf (refusal lifted, gated) | ||
| 2 | + | ||
| 3 | +Branch `lane-inter4`, worktree `/home/user/Documents/Code/Rust/edith_codecs-inter4`, | ||
| 4 | +off r3's `96847a3`, with `lane-interbis` (`8a6bede`, `build_motion_field`'s compound | ||
| 5 | +slot walk) merged FIRST as chartered. | ||
| 6 | + | ||
| 7 | +## TASK 1 — r2's ignored 32x16/16x32 gate: re-measured, STILL RED, blocker moved | ||
| 8 | + | ||
| 9 | + cargo test -p ec-av1 --lib coded_rectangular_residual -- --ignored --nocapture | ||
| 10 | + | ||
| 11 | +`a_real_aomenc_inter_sequence_with_a_coded_rectangular_residual_decodes_pixel_exact` | ||
| 12 | +still cannot prove itself: over its 16 8-bit attempts, **12 named refusals** — 10 of | ||
| 13 | +them `"an intra-coded HORZ/VERT strip needs rectangular intra prediction this decoder | ||
| 14 | +does not code yet"` and 2 `"an inter 16x16-level AB or 1:4 partition ..."` — and the | ||
| 15 | +other 4 attempts decode with **zero** rect inter residual (`tu=0`, `split=0`, 0 | ||
| 16 | +mismatches). So the 16-level leaf landing in r3 did NOT unblock it: what stops these | ||
| 17 | +streams now is rectangular *intra* prediction, another lane's refusal. Kept `#[ignore]`, | ||
| 18 | +with the reason string replaced by that measurement (stream.rs:4902). | ||
| 19 | + | ||
| 20 | +EVIDENCE: $HOME/.cache/inter4-t1.log | 16 aomenc encodes, decode + counter read | 12 named refusals (10 intra-rect-strip, 2 inter AB/1:4), 4 attempts with tu=0/split=0, 0 mismatches | ||
| 21 | + | ||
| 22 | +## TASK 2 — the OBMC residue: no defect left; refusal lifted | ||
| 23 | + | ||
| 24 | +r3 refused `"OBMC on a 16x8/8x16 inter leaf (blend mismatches the reference on this | ||
| 25 | +shape)"` off a measured 5302-luma-pixel mismatch (attempt 10, 8-bit, cq 22, frame 5). | ||
| 26 | +Re-measured on THIS tree before touching any code: | ||
| 27 | + | ||
| 28 | +- Rebuilt that exact stream from the gate's attempt-10 recipe with `--enable-obmc=1` | ||
| 29 | + (`scratchpad/o10.obu`, md5 `b643a93a8db45e2a1b89b2d777147ee3`, 828 B). | ||
| 30 | +- Added an `EC_OBMC` rung to the oracle `aomdec` | ||
| 31 | + (`dec_build_prediction_by_above_pred` / `_left_pred`, printing the block, the | ||
| 32 | + neighbour's rel position, `op_mi_size`, mv, ref, bsize, filter) and the matching | ||
| 33 | + rung to our `obmc_blend`, then compared. | ||
| 34 | + | ||
| 35 | +Both decoders emit **exactly 9 OBMC neighbour invocations**, in the same order, with | ||
| 36 | +identical block shape, `off4`/`rel`, `span4`/`op_mi_size`, neighbour mv, ref frame and | ||
| 37 | +filter — including the three on `wh=(8x16)` leaves. And every one of the six | ||
| 38 | +`EC_AV1_PREFILT_DUMP` frames is **byte-identical** between our decoder and aomdec | ||
| 39 | +(luma diff 0 on f0..f5). There is nothing left to fix on this shape: the mismatch r3 | ||
| 40 | +saw is gone. The only decode-path change between r3's measurement and this one is the | ||
| 41 | +lane-interbis merge (temporal MV candidates); not bisected further. | ||
| 42 | + | ||
| 43 | +EVIDENCE: scratchpad/{ours.obmc,ref.obmc,ours.yuv.f0-5,ref.yuv.f0-5} | EC_OBMC + EC_AV1_PREFILT_DUMP on o10.obu, ours (release decode_probe) vs instrumented aomdec | 9 vs 9 identical neighbour lines; per-frame luma diff 0/0/0/0/0/0 | ||
| 44 | + | ||
| 45 | +### What shipped | ||
| 46 | + | ||
| 47 | +- `crates/ec-av1/src/decode.rs` (`obmc_blend`, ~12843): the `(16,8)|(8,16)` refusal | ||
| 48 | + deleted; in its place the new `OBMC_RECT_LEAF_HITS` counter (+ `obmc_rect_leaf_hits()` | ||
| 49 | + at ~1355) that the gate reads. | ||
| 50 | +- `crates/ec-av1/src/refusal_inventory.rs`: the OBMC-rect-leaf string removed. | ||
| 51 | +- `crates/ec-av1/src/stream.rs` (`..._with_a_16_level_rect_leaf_...`, ~5090): the sweep | ||
| 52 | + runs **32 attempts** now — the same 16 (2 sources x 2 quantisers x 2 tx-size-search | ||
| 53 | + arms x 2 motion steps) with `--enable-obmc=0`, then repeated with `--enable-obmc=1` | ||
| 54 | + as the LAST flag. New hard assert per bit depth: `obmc_leaf_proved > 0`. | ||
| 55 | +- `crates/ec-av1/src/stream.rs` ~1948: the hidden-frames gate's `--enable-obmc=0` | ||
| 56 | + comment no longer cites a refusal that does not exist. | ||
| 57 | + | ||
| 58 | +### Gate — GREEN | ||
| 59 | + | ||
| 60 | + cargo test -p ec-av1 --lib 16_level_rect_leaf -- --nocapture | ||
| 61 | + | ||
| 62 | +- 8-bit: 15 named refusals, 9 pixel-exact leaf-carrying attempts (16x8=5, 8x16=4), | ||
| 63 | + whole-block rect TUs=4, **OBMC blends on a rect leaf=10**, 8 attempts carried none | ||
| 64 | + (0 mismatched). | ||
| 65 | +- 10-bit: 4 named refusals, 8 pixel-exact leaf-carrying attempts (16x8=4, 8x16=6), | ||
| 66 | + **OBMC blends on a rect leaf=4**, 20 carried none (0 mismatched). | ||
| 67 | + | ||
| 68 | +EVIDENCE: $HOME/.cache/inter4-g4.log | 64 aomenc encodes (32 attempts x 2 depths), every decoded frame Y/U/V vs ffmpeg | test result: ok. 1 passed; 0 failed; OBMC-on-rect-leaf blends 10 (8-bit) / 4 (10-bit), 0 mismatches | ||
| 69 | + | ||
| 70 | +## Verifier findings folded in (r4, after the OBMC commit) | ||
| 71 | + | ||
| 72 | +1. **`size_group_wh` was wrong for a 4-px side** (decode.rs ~9126): libaom | ||
| 73 | + `size_group_lookup[BLOCK_SIZES_ALL]` (`common_data.h:60`) is **0** for | ||
| 74 | + BLOCK_4X4/4X8/8X4/4X16/16X4, and our `0..=8 => 1` row gave those group 1 -- | ||
| 75 | + the `y_mode` / `interintra` / `interintra_mode` CDF row of every sub-8 leaf. | ||
| 76 | + Fixed, and pinned by a new unit test `size_group_wh_matches_libaom_size_group_lookup` | ||
| 77 | + that enumerates all 22 `BLOCK_SIZES_ALL` entries against the transcribed table | ||
| 78 | + (class enumerate-the-table-domain). | ||
| 79 | + | ||
| 80 | + cargo test -p ec-av1 --lib size_group_wh_matches -- --nocapture | ||
| 81 | + | ||
| 82 | +2. **rect var-tx SPLIT and the 10-bit coded rect TU are shipped unexercised.** | ||
| 83 | + Swept cq {8,12,16,22} x both source axes x both depths with tx-size-search on, | ||
| 84 | + reading `decode_probe`'s new `rect_inter: tu=.. txsplit=.. obmc_leaf=..` line: | ||
| 85 | + `txsplit=0` in every single decoding attempt, and every 10-bit rect leaf is | ||
| 86 | + `skip` (`tu=0`) at every cq that decodes at all. Below cq 22 the attempts stop | ||
| 87 | + at another lane's refusal -- mostly `"a HORZ/VERT intra strip below 16x16 with | ||
| 88 | + a split transform (per-unit rect prediction is not ported)"`, plus the sub-16 | ||
| 89 | + `HORZ_A/HORZ_B/VERT_A` and 32-level 1:4 ones. Deviation from the verifier's | ||
| 90 | + ask, stated: I did NOT add an `#[ignore]`d pin -- an ignored test that runs | ||
| 91 | + nothing carries the same information as the measurement now written into the | ||
| 92 | + gate's own comment (stream.rs ~5097) and into the residue below, at less code. | ||
| 93 | + The asserts stay where the feature does fire (8-bit `tu_total > 0`). | ||
| 94 | + | ||
| 95 | +3. `stream.rs` "aomenc keeps the last occurrence of a repeated `--enable-*` flag" | ||
| 96 | + is CORRECT (class aomenc-first-flag-wins is about `--enable-*` repeats resolving | ||
| 97 | + to the last one, and it is what the r4 obmc arm relies on) -- left unchanged. | ||
| 98 | + | ||
| 99 | +4. `cdf.rs` doc slip fixed: `EOB_PT_128_CHROMA_CLASS1_Q0` had lost its doc comment | ||
| 100 | + to the `EOB_PT_128_LUMA_CLASS1_Q0` block added in r3; moved back. | ||
| 101 | + | ||
| 102 | +EVIDENCE: sweep output in this round's transcript | 16 aomenc encodes (cq 8/12/16/22 x 2 axes x 8/10-bit) decoded through release decode_probe | txsplit=0 in all 7 decoding attempts, 10-bit tu=0 in all 4, 8-bit cq22 tu=1 txsplit=0 obmc_leaf=1 | ||
| 103 | + | ||
| 104 | +## Refusals | ||
| 105 | + | ||
| 106 | +Lifted: `"OBMC on a 16x8/8x16 inter leaf (blend mismatches the reference on this shape)"`. | ||
| 107 | +None added. | ||
| 108 | + | ||
| 109 | +## Suite | ||
| 110 | + | ||
| 111 | + $HOME/.cache/inter4-suite-r4.log | ||
| 112 | + | ||
| 113 | + test result: ok. 326 passed; 0 failed; 31 ignored; finished in 776.14s | ||
| 114 | + | ||
| 115 | +r3's 324 + the lane-interbis gate + this round's `size_group_wh` unit test; the 31 | ||
| 116 | +ignored are unchanged (still including r2's 32x16/16x32 gate). Every sibling ran in | ||
| 117 | +it: `obmc*`, `16_level_rect_leaf`, `superblock_level_rect_partition`, | ||
| 118 | +`inter_sequence*`, `temporal_mv_candidates`, `refusal_inventory`, `gate_coverage`. | ||
| 119 | + | ||
| 120 | +EVIDENCE: $HOME/.cache/inter4-suite-r4.log | ec-av1 --lib under a systemd user unit at b0588e4 + this report | 326 passed / 0 failed / 31 ignored | ||
| 121 | + | ||
| 122 | +## Film | ||
| 123 | + | ||
| 124 | +`scratchpad/hg-head.obu` through the release `decode_probe` on this lane still stops at | ||
| 125 | +`unsupported: AV1 tile (filter intra on a HORZ/VERT strip (this decoder predicts | ||
| 126 | +square-only))` — an intra refusal owned by another lane, unchanged by this round. | ||
| 127 | + | ||
| 128 | +EVIDENCE: scratchpad/hg-head.obu | release decode_probe under a 6G scope | REFUSED: filter intra on a HORZ/VERT strip | ||
| 129 | + | ||
| 130 | +## Residue | ||
| 131 | + | ||
| 132 | +- deferred: r2's 32x16/16x32 rect-residual gate — still `#[ignore]`d — unblocked by | ||
| 133 | + rectangular INTRA prediction (`an intra-coded HORZ/VERT strip ...`) landing, not by | ||
| 134 | + anything in this lane. | ||
| 135 | +- accepted: which change fixed r3's OBMC mismatch is not bisected (interbis merge is the | ||
| 136 | + only candidate); the shape is now proven exact against an instrumented aomdec, so the | ||
| 137 | + question is archaeology, not a defect. | ||
| 138 | +- deferred: the rect var-tx SPLIT path and a coded 10-bit rect TU are unexercised -- | ||
| 139 | + unblocked by the sub-16 intra-rect-strip refusal landing (every lower-cq attempt | ||
| 140 | + stops there before a rect inter leaf can carry a split tree). | ||
| 141 | +- accepted: `16x16 SPLITs=0` under this recipe (aomenc picks NONE/HORZ/VERT at 16); | ||
| 142 | + covered by the 8x8-leaf sibling gate. | ||
lanes/interbis-r1.report.mdadded+129 -0
| @@ -0,0 +1,129 @@ | |||
| 1 | +# lane-interbis r1 — the "decodes fully, still mismatches" inter defect | ||
| 2 | + | ||
| 3 | +Branch `lane-interbis`, worktree `edith_codecs-interbis`, off lane-inter4 `d2d7327`. | ||
| 4 | +No rebase (main unchanged since that base). | ||
| 5 | + | ||
| 6 | +## STEP 1 — reproduced and pinned | ||
| 7 | + | ||
| 8 | +The rect gate's 8-bit **attempt 1** is the one that decodes fully and mismatches: | ||
| 9 | +192x128, 6 frames @25, `geq=lum='128+58*sin((X+N*3)/6)+18*sin(Y/23)'`, cq 34, | ||
| 10 | +`--enable-tx-size-search=1`, `--min/max-partition-size=16/32`, cpu-used=0, lag 0. | ||
| 11 | +Regenerated twice, byte-identical: | ||
| 12 | +`fa70b7f68d311e577e3d14a86574909e6e58cac817b5a7fae04341c41ff50260` | ||
| 13 | +(script `$HOME/.cache/interbis/gen.sh`; 10-bit twin | ||
| 14 | +`67cad9bd5341db897de8a5308faecaedb1b0df761e4f315f1817156d124caef7`). | ||
| 15 | + | ||
| 16 | +Decode order == display order (no hidden frames; `--lag-in-frames=0`). | ||
| 17 | +Frames 0..4 exact; **frame 5** luma only, 646 px, bbox x160-191 y93-127, max delta 39. | ||
| 18 | +`EC_AV1_PREFILT_DUMP` (ours) vs the same rung from the instrumented aomdec: | ||
| 19 | +frames 0-4 byte-identical, frame 5 differs in 640 luma px at x160-191 y96-127 — | ||
| 20 | +i.e. **reconstruction**, not deblock/CDEF/LR, and exactly one 32x32 block: | ||
| 21 | +mi (row 24, col 40), the frame's last block. | ||
| 22 | + | ||
| 23 | +EVIDENCE: $HOME/.cache/interbis/{o_pre.f5,a_pre.f5} | EC_AV1_PREFILT_DUMP ours vs aomdec, per-frame byte diff | frames 0-4 identical, frame 5 640 luma px wrong in the single 32x32 block at mi(24,40) | ||
| 24 | + | ||
| 25 | +## STEP 2 — first divergent element | ||
| 26 | + | ||
| 27 | +Entropy is **exact**: the msac range ladder agrees at that block's entry | ||
| 28 | +(`EC_MODE ... rng=37852` both) and at the end of its mode read | ||
| 29 | +(`rng=59818` both). Both decoders read mode 13 (NEARESTMV), ref0=2 (LAST2), | ||
| 30 | +stack size 3. The **VALUE** differs: | ||
| 31 | + | ||
| 32 | + ours EC_MODE_VAL mi_row=24 mi_col=40 mode=13 ref0=2 mv0=(0,72) | ||
| 33 | + aomdec EC_MODE_VAL mi_row=24 mi_col=40 mode=13 ref0=2 mv0=(0,-230) | ||
| 34 | + | ||
| 35 | +New `EC_STACK` rung (added to both decoders) shows entries 1 and 2 identical | ||
| 36 | +(`(0,24) w=2`, `(0,-785) w=2`, the extra-search neighbours) and entry 0 — | ||
| 37 | +the temporal (MFMV) candidate — wrong: ours `(0,72) w=32`, aomdec `(0,-230) w=16`. | ||
| 38 | + | ||
| 39 | +New `EC_TPL` rung (per `add_tpl_ref_mv` probe, both decoders) isolates it to the | ||
| 40 | +projected motion field itself: over the 16 probes of that block, aomdec reads | ||
| 41 | +`INVALID` at blk_col 0/2 and `mfmv0=(0,-230) rfo=3` at blk_col 4/6; ours reads | ||
| 42 | +`mfmv0=(0,24) rfo=1` at all 16. `(0,24)*3/1 = (0,72)` — our wrong stored pair | ||
| 43 | +projected exactly to the wrong candidate. | ||
| 44 | + | ||
| 45 | +EVIDENCE: $HOME/.cache/interbis/{o_tpl.txt,a_tpl.txt} | EC_TRACE_MODE + EC_TRACE_TPL on both decoders, block mi(24,40) of frame 5 | ours mfmv0=(0,24) rfo=1 x16 vs aomdec INVALID x8 + (0,-230) rfo=3 x8; stack entry 0 (0,72) vs (0,-230) | ||
| 46 | + | ||
| 47 | +## Root cause (decode.rs `build_motion_field`, spec 7.19 / libaom `av1_copy_frame_mvs`) | ||
| 48 | + | ||
| 49 | +Our per-frame saved motion field stored **`ref_frame[0]`/`mv[0]` of every inter | ||
| 50 | +block**. libaom walks **both** reference slots and the **last qualifying one | ||
| 51 | +wins**, skipping a slot when | ||
| 52 | + | ||
| 53 | +* `cm->ref_frame_side[ref]` is non-zero — the reference's OrderHint is ahead of | ||
| 54 | + (or equal to) this frame's (`av1_calculate_ref_frame_side`), or | ||
| 55 | +* `|mv| > REFMVS_LIMIT` (`(1<<12)-1`). | ||
| 56 | + | ||
| 57 | +Every compound block in this stream is `LAST + GOLDEN` (both past), so libaom | ||
| 58 | +stores GOLDEN's mv with `ref_frame_offset = 3` where we stored LAST's with | ||
| 59 | +offset 1 — a wrong (mv, distance) pair in every compound block's 8x8 cell, which | ||
| 60 | +the next frame's temporal candidate then projects with the wrong reference | ||
| 61 | +distance. Class name: **saved-field-keeps-slot-0** — a per-frame/DPB *summary* | ||
| 62 | +of a multi-slot field must replay the reference's own slot walk (order + skips), | ||
| 63 | +not keep slot 0. (Sibling of `neighbour-votes-all-its-fields`: there the | ||
| 64 | +consumer voted only one slot, here the producer stores only one.) | ||
| 65 | + | ||
| 66 | +Fix: `crates/ec-av1/src/decode.rs:1728-1800` (`build_motion_field` now takes | ||
| 67 | +`order_hint_bits`, walks both slots last-wins, applies the side and | ||
| 68 | +`REFMVS_LIMIT` skips); call site `decode.rs:19040`. | ||
| 69 | + | ||
| 70 | +## Sweep | ||
| 71 | + | ||
| 72 | +`build_motion_field` is the only writer of `MotionField`/`SavedMv` | ||
| 73 | +(`grep -rn "SavedMv\|MotionField" crates/ec-av1/src`); the mv-stack neighbour | ||
| 74 | +maps already carry both slots (`MiInfo::ref_frame1`/`mv1`), and | ||
| 75 | +`motion_field_projection`/`setup_motion_field` were re-read line-for-line | ||
| 76 | +against `mvref_common.c` this round and match (one known, unreached gap noted | ||
| 77 | +below). | ||
| 78 | + | ||
| 79 | +## Gate — GREEN, and it binds | ||
| 80 | + | ||
| 81 | +`a_real_aomenc_inter_sequence_with_temporal_mv_candidates_decodes_pixel_exact` | ||
| 82 | +(`crates/ec-av1/src/stream.rs`, next to the rect gate): the pinned recipe above, | ||
| 83 | +2 tx-size-search arms x {8-bit, 10-bit}, every fully decoded attempt compared | ||
| 84 | +Y/U/V against ffmpeg, refusals counted (never SKIPped), and `decode::tmv_hits()` | ||
| 85 | +asserted > 0 per depth. | ||
| 86 | + | ||
| 87 | + cargo test -p ec-av1 --lib temporal_mv_candidates -- --nocapture | ||
| 88 | + 8-bit: 1 named refusal, 1 pixel-exact attempt, temporal-MV blocks = 66 | ||
| 89 | + 10-bit: 1 named refusal, 1 pixel-exact attempt, temporal-MV blocks = 67 | ||
| 90 | + test result: ok. 1 passed; 0 failed | ||
| 91 | + | ||
| 92 | +EVIDENCE: $HOME/.cache/interbis-tmvgate.log | cargo test -p ec-av1 --lib temporal_mv_candidates | 8-bit + 10-bit pixel-exact, tmv counter 66/67 | ||
| 93 | + | ||
| 94 | +Negative control (gate binds): with the store put back to first-slot-wins the | ||
| 95 | +same gate fails at `frame 5 luma vs ffmpeg (attempt 1, 8-bit)`. | ||
| 96 | + | ||
| 97 | +EVIDENCE: $HOME/.cache/interbis-tmvgate-neg.log | one-line revert to `if saved.is_none()` then re-run the gate | FAILED, frame 5 luma, restored immediately after | ||
| 98 | + | ||
| 99 | +## Instruments added (env-gated, both decoders) | ||
| 100 | + | ||
| 101 | +- ours: `EC_MODE_VAL` + `EC_STACK` on the single-ref path of `decode_inter_block` | ||
| 102 | + (byte-format-identical to the oracle's rung), `EC_TPL` per `add_tpl_ref_mv` probe. | ||
| 103 | +- oracle (`~/.cache/aom-oracle/src`): `EC_STACK` (stack dump at `EC_MODE_VAL`) and | ||
| 104 | + `EC_TPL` (per probe, incl. the `INVALID_MV` arm); `ninja aomdec` rebuilt. | ||
| 105 | + | ||
| 106 | +## Residue | ||
| 107 | + | ||
| 108 | +- **accepted: `motion_field_projection` does not check the source frame's | ||
| 109 | + frame_type.** libaom returns 0 for a KEY/INTRA_ONLY source; here an intra | ||
| 110 | + frame's saved field has no cells set, so the projection is inert — but its | ||
| 111 | + *return value* (which feeds `ref_stamp`) can differ. Unreached on every stream | ||
| 112 | + swept; fix-now if a future stream shows a `ref_stamp` divergence. | ||
| 113 | +- **deferred: the rect inter residual gate** stays `#[ignore]`d (lane-inter4's | ||
| 114 | + own residue, unblocked by 16x8/8x16 rect inter leaves); its | ||
| 115 | + `out_of_scope_mismatch` assert is what surfaced this defect and is now | ||
| 116 | + satisfiable on the 8-bit arm. | ||
| 117 | +- **deferred: film probe** — this diff lifts no refusal; both films still stop at | ||
| 118 | + lane-rectchroma's intra-rect-strip refusal. | ||
| 119 | + | ||
| 120 | +## Suite | ||
| 121 | + | ||
| 122 | + $HOME/.cache/interbis-suite.log (systemd-run unit, MemoryMax=10G) | ||
| 123 | + test result: ok. 324 passed; 0 failed; 31 ignored; finished in 443.08s | ||
| 124 | + | ||
| 125 | +323 (lane-inter4 r2 baseline) + this round's new gate. Siblings inside that run: | ||
| 126 | +inter_sequence*, obmc, warp, globalmv, compound_*, altref/hidden-frame, | ||
| 127 | +tx_select, refusal_inventory, gate_coverage — all green. | ||
| 128 | + | ||
| 129 | +EVIDENCE: $HOME/.cache/interbis-suite.log | ec-av1 --lib at 0527911 | 324 passed / 0 failed / 31 ignored | ||