Rectangular var-tx leaves -- the SPLIT transform of a 1:4 inter strip with a 64-px axis
Browse files at this commit00d3d4e99403f67ede53c14a09bcb63e395d815dParent: a531b22- feat
- rectangular var-tx leaves -- the SPLIT transform of a 1:4 inter strip with a 64-px axis
6 changed files +536 -107
- crates/ec-av1/examples/decode_probe.rs +2 -0
- crates/ec-av1/src/decode.rs +226 -98
- crates/ec-av1/src/gate_coverage.rs +0 -5
- crates/ec-av1/src/refusal_inventory.rs +0 -4
- crates/ec-av1/src/stream.rs +207 -0
- lanes/r14-r3.report.md +101 -0
crates/ec-av1/examples/decode_probe.rsmodified+2 -0
| @@ -33,6 +33,8 @@ fn main() { | |||
| 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(); | 34 | let (rtu, rsplit, robmc) = ec_av1::stream::rect_inter_tu_counters(); |
| 35 | println!("rect_inter: tu={rtu} txsplit={rsplit} obmc_leaf={robmc}"); | 35 | println!("rect_inter: tu={rtu} txsplit={rsplit} obmc_leaf={robmc}"); |
| 36 | + let leaf = ec_av1::stream::vartx_rect_leaf_hits(); | ||
| 37 | + println!("vartx_rect_leaf: 32x16={} 16x32={}", leaf[0], leaf[1]); | ||
| 36 | let ir = ec_av1::stream::inter_rect_counters(); | 38 | let ir = ec_av1::stream::inter_rect_counters(); |
| 37 | println!( | 39 | println!( |
| 38 | "inter_rect: 32x8={} 8x32={} 64x32={} 32x64={} 64x16={} 16x64={}", | 40 | "inter_rect: 32x8={} 8x32={} 64x32={} 32x64={} 64x16={} 16x64={}", |
crates/ec-av1/src/decode.rsmodified+226 -98
| @@ -920,6 +920,8 @@ thread_local! { | |||
| 920 | // (64x32/32x64/64x16/16x64), whose coefficients are coded as the | 920 | // (64x32/32x64/64x16/16x64), whose coefficients are coded as the |
| 921 | // truncated low-32 corner. | 921 | // truncated low-32 corner. |
| 922 | static RECT64_INTER_TU_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | 922 | static RECT64_INTER_TU_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; |
| 923 | + // lane-r14 r3: rectangular var-tx LEAVES, [32x16, 16x32]. | ||
| 924 | + static VARTX_RECT_LEAF_HITS: std::cell::Cell<[usize; 2]> = const { std::cell::Cell::new([0; 2]) }; | ||
| 923 | // lane-inter4 r3: 16x16-level PARTITION_HORZ / PARTITION_VERT on an inter | 925 | // lane-inter4 r3: 16x16-level PARTITION_HORZ / PARTITION_VERT on an inter |
| 924 | // frame -- 16x8 and 8x16 inter leaves. | 926 | // frame -- 16x8 and 8x16 inter leaves. |
| 925 | static INTER_LEAF16_HORZ_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | 927 | static INTER_LEAF16_HORZ_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; |
| @@ -972,6 +974,21 @@ pub(crate) fn rect64_inter_tu_hits() -> usize { | |||
| 972 | RECT64_INTER_TU_HITS.with(|c| c.get()) | 974 | RECT64_INTER_TU_HITS.with(|c| c.get()) |
| 973 | } | 975 | } |
| 974 | 976 | ||
| 977 | +/// Current value of [`VARTX_RECT_LEAF_HITS`] (lane-r14 r3): how many | ||
| 978 | +/// rectangular var-tx leaf transform units were coded, `[32x16, 16x32]`. | ||
| 979 | +pub(crate) fn vartx_rect_leaf_hits() -> [usize; 2] { | ||
| 980 | + VARTX_RECT_LEAF_HITS.with(|c| c.get()) | ||
| 981 | +} | ||
| 982 | + | ||
| 983 | +/// Records one rectangular var-tx leaf. | ||
| 984 | +fn vartx_rect_leaf_hit(tw: usize, th: usize) { | ||
| 985 | + VARTX_RECT_LEAF_HITS.with(|c| { | ||
| 986 | + let mut h = c.get(); | ||
| 987 | + h[usize::from(th > tw)] += 1; | ||
| 988 | + c.set(h); | ||
| 989 | + }); | ||
| 990 | +} | ||
| 991 | + | ||
| 975 | /// Sets the current thread's [`TX_SELECT_INTER`]/[`REDUCED_TX_SET_INTER`]/ | 992 | /// Sets the current thread's [`TX_SELECT_INTER`]/[`REDUCED_TX_SET_INTER`]/ |
| 976 | /// [`ENABLE_FILTER_INTRA_INTER`]. | 993 | /// [`ENABLE_FILTER_INTRA_INTER`]. |
| 977 | pub(crate) fn set_inter_tx_mode( | 994 | pub(crate) fn set_inter_tx_mode( |
| @@ -10723,6 +10740,46 @@ const TXFM_CTX_INIT: u8 = 64; | |||
| 10723 | /// twice below its own largest transform. | 10740 | /// twice below its own largest transform. |
| 10724 | const MAX_VARTX_DEPTH: usize = 2; | 10741 | const MAX_VARTX_DEPTH: usize = 2; |
| 10725 | 10742 | ||
| 10743 | +/// libaom `sub_tx_size_map[TX_SIZES_ALL]` (`common_data.c`): the transform | ||
| 10744 | +/// one `txfm_split` step below `tx_size`. RECTANGULAR for the 1:4 shapes | ||
| 10745 | +/// (`[TX_64X16] == TX_32X16`, `[TX_16X64] == TX_16X32`) and for the 4:1 | ||
| 10746 | +/// small ones, square everywhere else. | ||
| 10747 | +fn sub_tx_size_map(tx_w: usize, tx_h: usize) -> (usize, usize) { | ||
| 10748 | + match (tx_w, tx_h) { | ||
| 10749 | + (4, 4) => (4, 4), | ||
| 10750 | + (8, 8) => (4, 4), | ||
| 10751 | + (16, 16) => (8, 8), | ||
| 10752 | + (32, 32) => (16, 16), | ||
| 10753 | + (64, 64) => (32, 32), | ||
| 10754 | + (4, 8) | (8, 4) => (4, 4), | ||
| 10755 | + (8, 16) | (16, 8) => (8, 8), | ||
| 10756 | + (16, 32) | (32, 16) => (16, 16), | ||
| 10757 | + (32, 64) | (64, 32) => (32, 32), | ||
| 10758 | + (4, 16) => (4, 8), | ||
| 10759 | + (16, 4) => (8, 4), | ||
| 10760 | + (8, 32) => (8, 16), | ||
| 10761 | + (32, 8) => (16, 8), | ||
| 10762 | + (16, 64) => (16, 32), | ||
| 10763 | + (64, 16) => (32, 16), | ||
| 10764 | + _ => unreachable!("not a TX_SIZES_ALL shape: {tx_w}x{tx_h}"), | ||
| 10765 | + } | ||
| 10766 | +} | ||
| 10767 | + | ||
| 10768 | +#[test] | ||
| 10769 | +fn sub_tx_size_map_matches_libaom() { | ||
| 10770 | + // libaom `common_data.c` `sub_tx_size_map`, in TX_SIZES_ALL order. | ||
| 10771 | + const TABLE: [((usize, usize), (usize, usize)); 19] = [ | ||
| 10772 | + ((4, 4), (4, 4)), ((8, 8), (4, 4)), ((16, 16), (8, 8)), ((32, 32), (16, 16)), | ||
| 10773 | + ((64, 64), (32, 32)), ((4, 8), (4, 4)), ((8, 4), (4, 4)), ((8, 16), (8, 8)), | ||
| 10774 | + ((16, 8), (8, 8)), ((16, 32), (16, 16)), ((32, 16), (16, 16)), ((32, 64), (32, 32)), | ||
| 10775 | + ((64, 32), (32, 32)), ((4, 16), (4, 8)), ((16, 4), (8, 4)), ((8, 32), (8, 16)), | ||
| 10776 | + ((32, 8), (16, 8)), ((16, 64), (16, 32)), ((64, 16), (32, 16)), | ||
| 10777 | + ]; | ||
| 10778 | + for (tx, want) in TABLE { | ||
| 10779 | + assert_eq!(sub_tx_size_map(tx.0, tx.1), want, "sub_tx_size_map({tx:?})"); | ||
| 10780 | + } | ||
| 10781 | +} | ||
| 10782 | + | ||
| 10726 | /// `read_var_tx_size` (spec 5.11.17, libaom `decodeframe.c` | 10783 | /// `read_var_tx_size` (spec 5.11.17, libaom `decodeframe.c` |
| 10727 | /// `read_tx_size_vartx`): the recursive `txfm_split` tree of one | 10784 | /// `read_tx_size_vartx`): the recursive `txfm_split` tree of one |
| 10728 | /// max-transform-sized unit of an inter block, collecting the resolved leaf | 10785 | /// max-transform-sized unit of an inter block, collecting the resolved leaf |
| @@ -10739,22 +10796,28 @@ fn read_var_tx_size( | |||
| 10739 | at_mi: (usize, usize), | 10796 | at_mi: (usize, usize), |
| 10740 | blk_max_px: usize, | 10797 | blk_max_px: usize, |
| 10741 | (max_w_mi, max_h_mi): (usize, usize), | 10798 | (max_w_mi, max_h_mi): (usize, usize), |
| 10742 | - tx_px: usize, | 10799 | + (tx_w, tx_h): (usize, usize), |
| 10743 | depth: usize, | 10800 | depth: usize, |
| 10744 | blk_row: usize, | 10801 | blk_row: usize, |
| 10745 | blk_col: usize, | 10802 | blk_col: usize, |
| 10746 | - out: &mut Vec<(usize, usize, usize)>, | 10803 | + out: &mut Vec<(usize, usize, usize, usize)>, |
| 10747 | ) { | 10804 | ) { |
| 10748 | if blk_row >= max_h_mi || blk_col >= max_w_mi { | 10805 | if blk_row >= max_h_mi || blk_col >= max_w_mi { |
| 10749 | return; | 10806 | return; |
| 10750 | } | 10807 | } |
| 10751 | let unit = (at_mi.0 + blk_row, at_mi.1 + blk_col); | 10808 | let unit = (at_mi.0 + blk_row, at_mi.1 + blk_col); |
| 10752 | if depth == MAX_VARTX_DEPTH { | 10809 | if depth == MAX_VARTX_DEPTH { |
| 10753 | - out.push((blk_row, blk_col, tx_px)); | 10810 | + out.push((blk_row, blk_col, tx_w, tx_h)); |
| 10754 | - txfm_partition_update(n, unit, tx_px, tx_px); | 10811 | + txfm_partition_update_rect(n, unit, (tx_w, tx_h), (tx_w, tx_h)); |
| 10755 | return; | 10812 | return; |
| 10756 | } | 10813 | } |
| 10757 | - let ctx = txfm_partition_ctx(n.above_txfm[unit.1], n.left_txfm[unit.0], blk_max_px, tx_px); | 10814 | + let ctx = txfm_partition_ctx_rect( |
| 10815 | + n.above_txfm[unit.1], | ||
| 10816 | + n.left_txfm[unit.0], | ||
| 10817 | + blk_max_px, | ||
| 10818 | + tx_w, | ||
| 10819 | + tx_h, | ||
| 10820 | + ); | ||
| 10758 | let split = dec.symbol(&mut cdfs.txfm_partition[ctx]) == 1; | 10821 | let split = dec.symbol(&mut cdfs.txfm_partition[ctx]) == 1; |
| 10759 | TXFM_SPLIT_READS.with(|c| c.set(c.get() + 1)); | 10822 | TXFM_SPLIT_READS.with(|c| c.set(c.get() + 1)); |
| 10760 | if std::env::var_os("EC_TRACE_MODE_STEP").is_some() { | 10823 | if std::env::var_os("EC_TRACE_MODE_STEP").is_some() { |
| @@ -10767,27 +10830,27 @@ fn read_var_tx_size( | |||
| 10767 | ); | 10830 | ); |
| 10768 | } | 10831 | } |
| 10769 | if !split { | 10832 | if !split { |
| 10770 | - out.push((blk_row, blk_col, tx_px)); | 10833 | + out.push((blk_row, blk_col, tx_w, tx_h)); |
| 10771 | - txfm_partition_update(n, unit, tx_px, tx_px); | 10834 | + txfm_partition_update_rect(n, unit, (tx_w, tx_h), (tx_w, tx_h)); |
| 10772 | return; | 10835 | return; |
| 10773 | } | 10836 | } |
| 10774 | TXFM_SPLIT_HITS.with(|c| c.set(c.get() + 1)); | 10837 | TXFM_SPLIT_HITS.with(|c| c.set(c.get() + 1)); |
| 10775 | - let sub = tx_px / 2; | 10838 | + let (sub_w, sub_h) = sub_tx_size_map(tx_w, tx_h); |
| 10776 | - if sub == 4 { | 10839 | + if (sub_w, sub_h) == (4, 4) { |
| 10777 | - // libaom's `sub_txs == TX_4X4` early return: the whole 8x8 unit is | 10840 | + // libaom's `sub_txs == TX_4X4` early return: every mi cell of the |
| 10778 | - // marked 4x4 (four transform units, raster order) without recursing. | 10841 | + // unit is marked 4x4 (raster order) without recursing. |
| 10779 | - for row in 0..2 { | 10842 | + for row in 0..tx_h / MI { |
| 10780 | - for col in 0..2 { | 10843 | + for col in 0..tx_w / MI { |
| 10781 | if blk_row + row < max_h_mi && blk_col + col < max_w_mi { | 10844 | if blk_row + row < max_h_mi && blk_col + col < max_w_mi { |
| 10782 | - out.push((blk_row + row, blk_col + col, 4)); | 10845 | + out.push((blk_row + row, blk_col + col, 4, 4)); |
| 10783 | } | 10846 | } |
| 10784 | } | 10847 | } |
| 10785 | } | 10848 | } |
| 10786 | - txfm_partition_update(n, unit, 4, tx_px); | 10849 | + txfm_partition_update_rect(n, unit, (4, 4), (tx_w, tx_h)); |
| 10787 | return; | 10850 | return; |
| 10788 | } | 10851 | } |
| 10789 | - for row in (0..tx_px / MI).step_by(sub / MI) { | 10852 | + for row in (0..tx_h / MI).step_by(sub_h / MI) { |
| 10790 | - for col in (0..tx_px / MI).step_by(sub / MI) { | 10853 | + for col in (0..tx_w / MI).step_by(sub_w / MI) { |
| 10791 | read_var_tx_size( | 10854 | read_var_tx_size( |
| 10792 | dec, | 10855 | dec, |
| 10793 | cdfs, | 10856 | cdfs, |
| @@ -10795,7 +10858,7 @@ fn read_var_tx_size( | |||
| 10795 | at_mi, | 10858 | at_mi, |
| 10796 | blk_max_px, | 10859 | blk_max_px, |
| 10797 | (max_w_mi, max_h_mi), | 10860 | (max_w_mi, max_h_mi), |
| 10798 | - sub, | 10861 | + (sub_w, sub_h), |
| 10799 | depth + 1, | 10862 | depth + 1, |
| 10800 | blk_row + row, | 10863 | blk_row + row, |
| 10801 | blk_col + col, | 10864 | blk_col + col, |
| @@ -10823,7 +10886,7 @@ fn read_block_tx_size( | |||
| 10823 | (mi_cols, mi_rows): (usize, usize), | 10886 | (mi_cols, mi_rows): (usize, usize), |
| 10824 | is_inter: bool, | 10887 | is_inter: bool, |
| 10825 | skip: bool, | 10888 | skip: bool, |
| 10826 | -) -> Result<(usize, Option<Vec<(usize, usize, usize)>>)> { | 10889 | +) -> Result<(usize, Option<Vec<(usize, usize, usize, usize)>>)> { |
| 10827 | if !TX_SELECT_INTER.with(std::cell::Cell::get) { | 10890 | if !TX_SELECT_INTER.with(std::cell::Cell::get) { |
| 10828 | return Ok((side, None)); | 10891 | return Ok((side, None)); |
| 10829 | } | 10892 | } |
| @@ -10843,7 +10906,7 @@ fn read_block_tx_size( | |||
| 10843 | at_mi, | 10906 | at_mi, |
| 10844 | side, | 10907 | side, |
| 10845 | (max_w_mi, max_h_mi), | 10908 | (max_w_mi, max_h_mi), |
| 10846 | - max_tx, | 10909 | + (max_tx, max_tx), |
| 10847 | 0, | 10910 | 0, |
| 10848 | row, | 10911 | row, |
| 10849 | col, | 10912 | col, |
| @@ -10851,8 +10914,8 @@ fn read_block_tx_size( | |||
| 10851 | ); | 10914 | ); |
| 10852 | } | 10915 | } |
| 10853 | } | 10916 | } |
| 10854 | - let single = leaves.len() == 1 && leaves[0].2 == side; | 10917 | + let single = leaves.len() == 1 && leaves[0].2 == side && leaves[0].3 == side; |
| 10855 | - if !single && leaves.iter().any(|leaf| leaf.2 > 32) { | 10918 | + if !single && leaves.iter().any(|leaf| leaf.2.max(leaf.3) > 32) { |
| 10856 | // Only a block wider than a superblock's own 64x64 max transform | 10919 | // Only a block wider than a superblock's own 64x64 max transform |
| 10857 | // reaches here; this crate has no 64-point *inter* coefficient | 10920 | // reaches here; this crate has no 64-point *inter* coefficient |
| 10858 | // table set ([`inter_txbset_for`] stops at 32). | 10921 | // table set ([`inter_txbset_for`] stops at 32). |
| @@ -10890,7 +10953,7 @@ fn read_block_tx_size( | |||
| 10890 | let mut leaves = Vec::new(); | 10953 | let mut leaves = Vec::new(); |
| 10891 | for row in (0..side_mi).step_by(step) { | 10954 | for row in (0..side_mi).step_by(step) { |
| 10892 | for col in (0..side_mi).step_by(step) { | 10955 | for col in (0..side_mi).step_by(step) { |
| 10893 | - leaves.push((row, col, tx)); | 10956 | + leaves.push((row, col, tx, tx)); |
| 10894 | } | 10957 | } |
| 10895 | } | 10958 | } |
| 10896 | INTRA_IN_INTER_SPLIT_TX_HITS.with(|c| { | 10959 | INTRA_IN_INTER_SPLIT_TX_HITS.with(|c| { |
| @@ -11042,7 +11105,7 @@ fn read_block_tx_size_rect( | |||
| 11042 | (bw, bh): (usize, usize), | 11105 | (bw, bh): (usize, usize), |
| 11043 | (mi_cols, mi_rows): (usize, usize), | 11106 | (mi_cols, mi_rows): (usize, usize), |
| 11044 | skip: bool, | 11107 | skip: bool, |
| 11045 | -) -> Result<Option<Vec<(usize, usize, usize)>>> { | 11108 | +) -> Result<Option<Vec<(usize, usize, usize, usize)>>> { |
| 11046 | if skip { | 11109 | if skip { |
| 11047 | // `set_txfm_ctxs(.., skip && is_inter)`: a skipped inter block records | 11110 | // `set_txfm_ctxs(.., skip && is_inter)`: a skipped inter block records |
| 11048 | // its own BLOCK size -- width above, height left -- not a transform. | 11111 | // its own BLOCK size -- width above, height left -- not a transform. |
| @@ -11085,22 +11148,16 @@ fn read_block_tx_size_rect( | |||
| 11085 | } | 11148 | } |
| 11086 | TXFM_SPLIT_HITS.with(|c| c.set(c.get() + 1)); | 11149 | TXFM_SPLIT_HITS.with(|c| c.set(c.get() + 1)); |
| 11087 | RECT_INTER_TXSPLIT_HITS.with(|c| c.set(c.get() + 1)); | 11150 | RECT_INTER_TXSPLIT_HITS.with(|c| c.set(c.get() + 1)); |
| 11088 | - // lane-r14 r2: `sub_tx_size_map` is square for every shape this decoder | 11151 | + // lane-r14 r3: `sub_tx_size_map` (libaom `common_data.c`) stays |
| 11089 | - // splits (TX_32X16 -> TX_16X16, TX_64X32 -> TX_32X32) EXCEPT the 1:4 | 11152 | + // RECTANGULAR under a 1:4 strip -- `[TX_64X16] == TX_32X16`, |
| 11090 | - // strips with a 64-px axis, where it stays rectangular | 11153 | + // `[TX_16X64] == TX_16X32` -- so the recursion below is the general |
| 11091 | - // (TX_64X16 -> TX_32X16, TX_16X64 -> TX_16X32) and the square recursion | 11154 | + // rect one and its leaves carry their own width and height. |
| 11092 | - // below would code the wrong tree. | 11155 | + let (sub_w, sub_h) = sub_tx_size_map(tx_w, tx_h); |
| 11093 | - if tx_w.max(tx_h) == 64 && tx_w.min(tx_h) == 16 { | ||
| 11094 | - return Err(unsupported( | ||
| 11095 | - "a split transform on a 1:4 inter strip with a 64-px axis", | ||
| 11096 | - )); | ||
| 11097 | - } | ||
| 11098 | - let sub = tx_w.min(tx_h); | ||
| 11099 | let max_w_mi = (bw / MI).min(mi_cols.saturating_sub(at_mi.1)); | 11156 | let max_w_mi = (bw / MI).min(mi_cols.saturating_sub(at_mi.1)); |
| 11100 | let max_h_mi = (bh / MI).min(mi_rows.saturating_sub(at_mi.0)); | 11157 | let max_h_mi = (bh / MI).min(mi_rows.saturating_sub(at_mi.0)); |
| 11101 | let mut leaves = Vec::new(); | 11158 | let mut leaves = Vec::new(); |
| 11102 | - for row in (0..bh / MI).step_by(sub / MI) { | 11159 | + for row in (0..bh / MI).step_by(sub_h / MI) { |
| 11103 | - for col in (0..bw / MI).step_by(sub / MI) { | 11160 | + for col in (0..bw / MI).step_by(sub_w / MI) { |
| 11104 | read_var_tx_size( | 11161 | read_var_tx_size( |
| 11105 | dec, | 11162 | dec, |
| 11106 | cdfs, | 11163 | cdfs, |
| @@ -11108,7 +11165,7 @@ fn read_block_tx_size_rect( | |||
| 11108 | at_mi, | 11165 | at_mi, |
| 11109 | bw.max(bh), | 11166 | bw.max(bh), |
| 11110 | (max_w_mi, max_h_mi), | 11167 | (max_w_mi, max_h_mi), |
| 11111 | - sub, | 11168 | + (sub_w, sub_h), |
| 11112 | 1, | 11169 | 1, |
| 11113 | row, | 11170 | row, |
| 11114 | col, | 11171 | col, |
| @@ -11145,9 +11202,12 @@ fn read_inter_plane_rect( | |||
| 11145 | y: usize, | 11202 | y: usize, |
| 11146 | prediction: &[u16], | 11203 | prediction: &[u16], |
| 11147 | inherited_luma_tx_type: Option<TxType>, | 11204 | inherited_luma_tx_type: Option<TxType>, |
| 11205 | + luma_skip_ctx: Option<usize>, | ||
| 11148 | ) -> Result<(Vec<i32>, TxType)> { | 11206 | ) -> Result<(Vec<i32>, TxType)> { |
| 11149 | let skip_ctx = if plane_idx == 0 { | 11207 | let skip_ctx = if plane_idx == 0 { |
| 11150 | - 0 | 11208 | + // `get_txb_ctx_general`: 0 only when this unit IS the whole plane |
| 11209 | + // block; a var-tx leaf passes its own neighbour-table context. | ||
| 11210 | + luma_skip_ctx.unwrap_or(0) | ||
| 11151 | } else { | 11211 | } else { |
| 11152 | usize::from(around.0) + usize::from(around.1) | 11212 | usize::from(around.0) + usize::from(around.1) |
| 11153 | }; | 11213 | }; |
| @@ -15510,7 +15570,7 @@ fn decode_inter_block( | |||
| 15510 | // 5.11.17), `Some` only when this block's var-tx tree resolved to more | 15570 | // 5.11.17), `Some` only when this block's var-tx tree resolved to more |
| 15511 | // than one luma transform -- read back by the residual loop, the | 15571 | // than one luma transform -- read back by the residual loop, the |
| 15512 | // coefficient-context write-back and the loop-filter grid fill below. | 15572 | // coefficient-context write-back and the loop-filter grid fill below. |
| 15513 | - let mut vartx_leaves: Option<Vec<(usize, usize, usize)>> = None; | 15573 | + let mut vartx_leaves: Option<Vec<(usize, usize, usize, usize)>> = None; |
| 15514 | let at_mi = at; | 15574 | let at_mi = at; |
| 15515 | if is_inter { | 15575 | if is_inter { |
| 15516 | let above_nbr = has_above.then(|| NeighbourRef { | 15576 | let above_nbr = has_above.then(|| NeighbourRef { |
| @@ -16349,37 +16409,68 @@ fn decode_inter_block( | |||
| 16349 | // own slice of the block's motion-compensated predictor. | 16409 | // own slice of the block's motion-compensated predictor. |
| 16350 | let reduced = REDUCED_TX_SET_INTER.with(std::cell::Cell::get); | 16410 | let reduced = REDUCED_TX_SET_INTER.with(std::cell::Cell::get); |
| 16351 | let mut first_tx_type = TxType::DctDct; | 16411 | let mut first_tx_type = TxType::DctDct; |
| 16352 | - for (idx, &(row, col, tx_px)) in leaves.iter().enumerate() { | 16412 | + for (idx, &(row, col, tw, th)) in leaves.iter().enumerate() { |
| 16353 | let tu_mi = (at_mi.0 + row, at_mi.1 + col); | 16413 | let tu_mi = (at_mi.0 + row, at_mi.1 + col); |
| 16354 | let (tu_px, tu_py) = (px + col * MI, py + row * MI); | 16414 | let (tu_px, tu_py) = (px + col * MI, py + row * MI); |
| 16355 | - let mut tu_pred = Vec::with_capacity(tx_px * tx_px); | 16415 | + let (tu_grid, tu_tx_type) = if tw == th { |
| 16356 | - for rr in 0..tx_px { | 16416 | + let tx_px = tw; |
| 16357 | - let start = (row * MI + rr) * side + col * MI; | 16417 | + let mut tu_pred = Vec::with_capacity(tx_px * tx_px); |
| 16358 | - tu_pred.extend_from_slice(&pred_y[start..start + tx_px]); | 16418 | + for rr in 0..tx_px { |
| 16359 | - } | 16419 | + let start = (row * MI + rr) * side + col * MI; |
| 16360 | - let scan = default_scan(tx_px); | 16420 | + tu_pred.extend_from_slice(&pred_y[start..start + tx_px]); |
| 16361 | - let tu_skip_ctx = neighbours.luma_skip_ctx(tu_mi, tx_px / MI); | 16421 | + } |
| 16362 | - let (tu_grid, tu_tx_type) = read_inter_plane( | 16422 | + let scan = default_scan(tx_px); |
| 16363 | - dec, | 16423 | + let tu_skip_ctx = neighbours.luma_skip_ctx(tu_mi, tx_px / MI); |
| 16364 | - cdfs, | 16424 | + read_inter_plane( |
| 16365 | - inter_txbset_for(tx_px, reduced), | 16425 | + dec, |
| 16366 | - &scan, | 16426 | + cdfs, |
| 16367 | - 0, | 16427 | + inter_txbset_for(tx_px, reduced), |
| 16368 | - neighbours.around_mi(tu_mi, tx_px)[0], | 16428 | + &scan, |
| 16369 | - mode_for_tx, | 16429 | + 0, |
| 16370 | - y, | 16430 | + neighbours.around_mi(tu_mi, tx_px)[0], |
| 16371 | - tu_px, | 16431 | + mode_for_tx, |
| 16372 | - tu_py, | 16432 | + y, |
| 16373 | - tx_px, | 16433 | + tu_px, |
| 16374 | - base_q_idx, | 16434 | + tu_py, |
| 16375 | - &tu_pred, | 16435 | + tx_px, |
| 16376 | - None, | 16436 | + base_q_idx, |
| 16377 | - Some(tu_skip_ctx), | 16437 | + &tu_pred, |
| 16378 | - )?; | 16438 | + None, |
| 16439 | + Some(tu_skip_ctx), | ||
| 16440 | + )? | ||
| 16441 | + } else { | ||
| 16442 | + // lane-r14 r3: a 1:4 strip's `sub_tx_size_map` | ||
| 16443 | + // sub-transform is RECTANGULAR (TX_64X16 -> | ||
| 16444 | + // TX_32X16, TX_16X64 -> TX_16X32), so this leaf is | ||
| 16445 | + // read with the rect coefficient machinery, at its | ||
| 16446 | + // own `txb_skip_ctx`/neighbour spans -- the unit is | ||
| 16447 | + // smaller than its block, so `get_txb_ctx_general`'s | ||
| 16448 | + // neighbour table applies, not the lone-TU 0. | ||
| 16449 | + vartx_rect_leaf_hit(tw, th); | ||
| 16450 | + let tu_skip_ctx = | ||
| 16451 | + neighbours.luma_skip_ctx_rect(tu_mi, tw / MI, th / MI); | ||
| 16452 | + let start = row * MI * side + col * MI; | ||
| 16453 | + read_inter_plane_rect( | ||
| 16454 | + dec, | ||
| 16455 | + cdfs, | ||
| 16456 | + rect_inter_luma_set(tw, th), | ||
| 16457 | + (tw, th), | ||
| 16458 | + side, | ||
| 16459 | + 0, | ||
| 16460 | + neighbours.around_mi_rect(tu_mi, tw, th)[0], | ||
| 16461 | + mode_for_tx, | ||
| 16462 | + y, | ||
| 16463 | + tu_px, | ||
| 16464 | + tu_py, | ||
| 16465 | + &pred_y[start..], | ||
| 16466 | + None, | ||
| 16467 | + Some(tu_skip_ctx), | ||
| 16468 | + )? | ||
| 16469 | + }; | ||
| 16379 | if idx == 0 { | 16470 | if idx == 0 { |
| 16380 | first_tx_type = tu_tx_type; | 16471 | first_tx_type = tu_tx_type; |
| 16381 | } | 16472 | } |
| 16382 | - neighbours.record_mi_luma(tu_mi, tx_px, &tu_grid); | 16473 | + neighbours.record_mi_luma_rect(tu_mi, tw, th, &tu_grid); |
| 16383 | } | 16474 | } |
| 16384 | // `av1_get_tx_type`'s chroma lookup scales the chroma | 16475 | // `av1_get_tx_type`'s chroma lookup scales the chroma |
| 16385 | // position back to luma, so an inter block's chroma | 16476 | // position back to luma, so an inter block's chroma |
| @@ -16403,6 +16494,7 @@ fn decode_inter_block( | |||
| 16403 | py, | 16494 | py, |
| 16404 | &pred_y, | 16495 | &pred_y, |
| 16405 | None, | 16496 | None, |
| 16497 | + None, | ||
| 16406 | )?; | 16498 | )?; |
| 16407 | luma_tx_type = tx_type; | 16499 | luma_tx_type = tx_type; |
| 16408 | luma_grid = embed_rect_grid(&grid, write_w, write_h, side); | 16500 | luma_grid = embed_rect_grid(&grid, write_w, write_h, side); |
| @@ -16446,6 +16538,7 @@ fn decode_inter_block( | |||
| 16446 | cpy, | 16538 | cpy, |
| 16447 | &pred_u, | 16539 | &pred_u, |
| 16448 | Some(luma_tx_type), | 16540 | Some(luma_tx_type), |
| 16541 | + None, | ||
| 16449 | )? | 16542 | )? |
| 16450 | .0, | 16543 | .0, |
| 16451 | uw, | 16544 | uw, |
| @@ -16467,6 +16560,7 @@ fn decode_inter_block( | |||
| 16467 | cpy, | 16560 | cpy, |
| 16468 | &pred_v, | 16561 | &pred_v, |
| 16469 | Some(luma_tx_type), | 16562 | Some(luma_tx_type), |
| 16563 | + None, | ||
| 16470 | )? | 16564 | )? |
| 16471 | .0, | 16565 | .0, |
| 16472 | uw, | 16566 | uw, |
| @@ -17327,37 +17421,68 @@ fn decode_inter_block( | |||
| 17327 | // own slice of the block's motion-compensated predictor. | 17421 | // own slice of the block's motion-compensated predictor. |
| 17328 | let reduced = REDUCED_TX_SET_INTER.with(std::cell::Cell::get); | 17422 | let reduced = REDUCED_TX_SET_INTER.with(std::cell::Cell::get); |
| 17329 | let mut first_tx_type = TxType::DctDct; | 17423 | let mut first_tx_type = TxType::DctDct; |
| 17330 | - for (idx, &(row, col, tx_px)) in leaves.iter().enumerate() { | 17424 | + for (idx, &(row, col, tw, th)) in leaves.iter().enumerate() { |
| 17331 | let tu_mi = (at_mi.0 + row, at_mi.1 + col); | 17425 | let tu_mi = (at_mi.0 + row, at_mi.1 + col); |
| 17332 | let (tu_px, tu_py) = (px + col * MI, py + row * MI); | 17426 | let (tu_px, tu_py) = (px + col * MI, py + row * MI); |
| 17333 | - let mut tu_pred = Vec::with_capacity(tx_px * tx_px); | 17427 | + let (tu_grid, tu_tx_type) = if tw == th { |
| 17334 | - for rr in 0..tx_px { | 17428 | + let tx_px = tw; |
| 17335 | - let start = (row * MI + rr) * side + col * MI; | 17429 | + let mut tu_pred = Vec::with_capacity(tx_px * tx_px); |
| 17336 | - tu_pred.extend_from_slice(&pred_y[start..start + tx_px]); | 17430 | + for rr in 0..tx_px { |
| 17337 | - } | 17431 | + let start = (row * MI + rr) * side + col * MI; |
| 17338 | - let scan = default_scan(tx_px); | 17432 | + tu_pred.extend_from_slice(&pred_y[start..start + tx_px]); |
| 17339 | - let tu_skip_ctx = neighbours.luma_skip_ctx(tu_mi, tx_px / MI); | 17433 | + } |
| 17340 | - let (tu_grid, tu_tx_type) = read_inter_plane( | 17434 | + let scan = default_scan(tx_px); |
| 17341 | - dec, | 17435 | + let tu_skip_ctx = neighbours.luma_skip_ctx(tu_mi, tx_px / MI); |
| 17342 | - cdfs, | 17436 | + read_inter_plane( |
| 17343 | - inter_txbset_for(tx_px, reduced), | 17437 | + dec, |
| 17344 | - &scan, | 17438 | + cdfs, |
| 17345 | - 0, | 17439 | + inter_txbset_for(tx_px, reduced), |
| 17346 | - neighbours.around_mi(tu_mi, tx_px)[0], | 17440 | + &scan, |
| 17347 | - mode_for_tx, | 17441 | + 0, |
| 17348 | - y, | 17442 | + neighbours.around_mi(tu_mi, tx_px)[0], |
| 17349 | - tu_px, | 17443 | + mode_for_tx, |
| 17350 | - tu_py, | 17444 | + y, |
| 17351 | - tx_px, | 17445 | + tu_px, |
| 17352 | - base_q_idx, | 17446 | + tu_py, |
| 17353 | - &tu_pred, | 17447 | + tx_px, |
| 17354 | - None, | 17448 | + base_q_idx, |
| 17355 | - Some(tu_skip_ctx), | 17449 | + &tu_pred, |
| 17356 | - )?; | 17450 | + None, |
| 17451 | + Some(tu_skip_ctx), | ||
| 17452 | + )? | ||
| 17453 | + } else { | ||
| 17454 | + // lane-r14 r3: a 1:4 strip's `sub_tx_size_map` | ||
| 17455 | + // sub-transform is RECTANGULAR (TX_64X16 -> | ||
| 17456 | + // TX_32X16, TX_16X64 -> TX_16X32), so this leaf is | ||
| 17457 | + // read with the rect coefficient machinery, at its | ||
| 17458 | + // own `txb_skip_ctx`/neighbour spans -- the unit is | ||
| 17459 | + // smaller than its block, so `get_txb_ctx_general`'s | ||
| 17460 | + // neighbour table applies, not the lone-TU 0. | ||
| 17461 | + vartx_rect_leaf_hit(tw, th); | ||
| 17462 | + let tu_skip_ctx = | ||
| 17463 | + neighbours.luma_skip_ctx_rect(tu_mi, tw / MI, th / MI); | ||
| 17464 | + let start = row * MI * side + col * MI; | ||
| 17465 | + read_inter_plane_rect( | ||
| 17466 | + dec, | ||
| 17467 | + cdfs, | ||
| 17468 | + rect_inter_luma_set(tw, th), | ||
| 17469 | + (tw, th), | ||
| 17470 | + side, | ||
| 17471 | + 0, | ||
| 17472 | + neighbours.around_mi_rect(tu_mi, tw, th)[0], | ||
| 17473 | + mode_for_tx, | ||
| 17474 | + y, | ||
| 17475 | + tu_px, | ||
| 17476 | + tu_py, | ||
| 17477 | + &pred_y[start..], | ||
| 17478 | + None, | ||
| 17479 | + Some(tu_skip_ctx), | ||
| 17480 | + )? | ||
| 17481 | + }; | ||
| 17357 | if idx == 0 { | 17482 | if idx == 0 { |
| 17358 | first_tx_type = tu_tx_type; | 17483 | first_tx_type = tu_tx_type; |
| 17359 | } | 17484 | } |
| 17360 | - neighbours.record_mi_luma(tu_mi, tx_px, &tu_grid); | 17485 | + neighbours.record_mi_luma_rect(tu_mi, tw, th, &tu_grid); |
| 17361 | } | 17486 | } |
| 17362 | // `av1_get_tx_type`'s chroma lookup scales the chroma | 17487 | // `av1_get_tx_type`'s chroma lookup scales the chroma |
| 17363 | // position back to luma, so an inter block's chroma | 17488 | // position back to luma, so an inter block's chroma |
| @@ -17381,6 +17506,7 @@ fn decode_inter_block( | |||
| 17381 | py, | 17506 | py, |
| 17382 | &pred_y, | 17507 | &pred_y, |
| 17383 | None, | 17508 | None, |
| 17509 | + None, | ||
| 17384 | )?; | 17510 | )?; |
| 17385 | luma_tx_type = tx_type; | 17511 | luma_tx_type = tx_type; |
| 17386 | luma_grid = embed_rect_grid(&grid, write_w, write_h, side); | 17512 | luma_grid = embed_rect_grid(&grid, write_w, write_h, side); |
| @@ -17424,6 +17550,7 @@ fn decode_inter_block( | |||
| 17424 | cpy, | 17550 | cpy, |
| 17425 | &pred_u, | 17551 | &pred_u, |
| 17426 | Some(luma_tx_type), | 17552 | Some(luma_tx_type), |
| 17553 | + None, | ||
| 17427 | )? | 17554 | )? |
| 17428 | .0, | 17555 | .0, |
| 17429 | uw, | 17556 | uw, |
| @@ -17445,6 +17572,7 @@ fn decode_inter_block( | |||
| 17445 | cpy, | 17572 | cpy, |
| 17446 | &pred_v, | 17573 | &pred_v, |
| 17447 | Some(luma_tx_type), | 17574 | Some(luma_tx_type), |
| 17575 | + None, | ||
| 17448 | )? | 17576 | )? |
| 17449 | .0, | 17577 | .0, |
| 17450 | uw, | 17578 | uw, |
| @@ -17654,7 +17782,7 @@ fn decode_inter_block( | |||
| 17654 | let split_luma = vartx_leaves.is_some(); | 17782 | let split_luma = vartx_leaves.is_some(); |
| 17655 | if let Some(leaves) = vartx_leaves.clone() { | 17783 | if let Some(leaves) = vartx_leaves.clone() { |
| 17656 | let reduced = REDUCED_TX_SET_INTER.with(std::cell::Cell::get); | 17784 | let reduced = REDUCED_TX_SET_INTER.with(std::cell::Cell::get); |
| 17657 | - for &(row, col, tx_px) in &leaves { | 17785 | + for &(row, col, tx_px, _) in &leaves { |
| 17658 | let tu_mi = (at_mi.0 + row, at_mi.1 + col); | 17786 | let tu_mi = (at_mi.0 + row, at_mi.1 + col); |
| 17659 | let (tu_px, tu_py) = (px + col * MI, py + row * MI); | 17787 | let (tu_px, tu_py) = (px + col * MI, py + row * MI); |
| 17660 | // A transform unit inside a block is not a block at that | 17788 | // A transform unit inside a block is not a block at that |
| @@ -17896,13 +18024,13 @@ fn decode_inter_block( | |||
| 17896 | // units, not the block. Chroma still reads `tx_h_grid / 2` (the block's | 18024 | // units, not the block. Chroma still reads `tx_h_grid / 2` (the block's |
| 17897 | // uv transform is not split) -- a known corner-cut of this round. | 18025 | // uv transform is not split) -- a known corner-cut of this round. |
| 17898 | if let Some(leaves) = &vartx_leaves { | 18026 | if let Some(leaves) = &vartx_leaves { |
| 17899 | - for &(row, col, tx_px) in leaves { | 18027 | + for &(row, col, tw, th) in leaves { |
| 17900 | neighbours.fill_lf_grid_rect( | 18028 | neighbours.fill_lf_grid_rect( |
| 17901 | (at_mi.0 + row, at_mi.1 + col), | 18029 | (at_mi.0 + row, at_mi.1 + col), |
| 17902 | - tx_px / MI, | 18030 | + tw / MI, |
| 17903 | - tx_px / MI, | 18031 | + th / MI, |
| 17904 | - tx_px as u8, | 18032 | + tw as u8, |
| 17905 | - tx_px as u8, | 18033 | + th as u8, |
| 17906 | if globalmv_for_lf { | 18034 | if globalmv_for_lf { |
| 17907 | -ref_frame_for_lf | 18035 | -ref_frame_for_lf |
| 17908 | } else { | 18036 | } else { |
crates/ec-av1/src/gate_coverage.rsmodified+0 -5
| @@ -176,10 +176,6 @@ const NEVER_EXERCISED_8BIT: &[(&str, &str)] = &[ | |||
| 176 | "enable-rect-tx", | 176 | "enable-rect-tx", |
| 177 | "never spelled; rect transforms reach the decoder only through partition shape, never through a gate that names the tool", | 177 | "never spelled; rect transforms reach the decoder only through partition shape, never through a gate that names the tool", |
| 178 | ), | 178 | ), |
| 179 | - ( | ||
| 180 | - "enable-tx64", | ||
| 181 | - "never spelled; TX_64X64 appears only where aomenc's default picks it, which is unknown per stream", | ||
| 182 | - ), | ||
| 183 | ]; | 179 | ]; |
| 184 | 180 | ||
| 185 | #[cfg(test)] | 181 | #[cfg(test)] |
| @@ -222,7 +218,6 @@ const NEVER_EXERCISED_10BIT: &[(&str, &str)] = &[ // lane-cwarp's 10-bit comp | |||
| 222 | // 1D tx class). | 218 | // 1D tx class). |
| 223 | ("enable-intrabc", "hole at both depths, see the 8-bit list"), | 219 | ("enable-intrabc", "hole at both depths, see the 8-bit list"), |
| 224 | ("enable-rect-tx", "hole at both depths, see the 8-bit list"), | 220 | ("enable-rect-tx", "hole at both depths, see the 8-bit list"), |
| 225 | - ("enable-tx64", "hole at both depths, see the 8-bit list"), | ||
| 226 | ]; | 221 | ]; |
| 227 | 222 | ||
| 228 | /// [`DEFAULT_ON_TOOLS`] entries no 8-bit gate spells on, with the reason. | 223 | /// [`DEFAULT_ON_TOOLS`] entries no 8-bit gate spells on, with the reason. |
crates/ec-av1/src/refusal_inventory.rsmodified+0 -4
| @@ -72,10 +72,6 @@ const REFUSALS: &[&str] = &[ | |||
| 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 | "a motion_mode symbol for a block shape with no CDF row here", |
| 75 | - // lane-r14 r2: the whole-transform case of every 64-axis inter strip is | ||
| 76 | - // coded; only the SPLIT of a 1:4 strip with a 64-px axis is left, whose | ||
| 77 | - // `sub_tx_size_map` entry is rectangular (TX_64X16 -> TX_32X16). | ||
| 78 | - "a split transform on a 1:4 inter strip with a 64-px axis", | ||
| 79 | ]; | 75 | ]; |
| 80 | 76 | ||
| 81 | /// 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+207 -0
| @@ -74,6 +74,13 @@ pub fn rect64_inter_tu_hits() -> usize { | |||
| 74 | crate::decode::rect64_inter_tu_hits() | 74 | crate::decode::rect64_inter_tu_hits() |
| 75 | } | 75 | } |
| 76 | 76 | ||
| 77 | +/// lane-r14 r3: RECTANGULAR var-tx leaf transform units, `[32x16, 16x32]` -- | ||
| 78 | +/// the leaves `sub_tx_size_map` produces when a 1:4 strip with a 64-px axis | ||
| 79 | +/// splits its transform (`[TX_64X16] == TX_32X16`, `[TX_16X64] == TX_16X32`). | ||
| 80 | +pub fn vartx_rect_leaf_hits() -> [usize; 2] { | ||
| 81 | + crate::decode::vartx_rect_leaf_hits() | ||
| 82 | +} | ||
| 83 | + | ||
| 77 | pub fn rect4_32_counters() -> (usize, usize, usize) { | 84 | pub fn rect4_32_counters() -> (usize, usize, usize) { |
| 78 | ( | 85 | ( |
| 79 | crate::decode::rect4_32_horz_hits(), | 86 | crate::decode::rect4_32_horz_hits(), |
| @@ -6404,6 +6411,206 @@ mod tests { | |||
| 6404 | } | 6411 | } |
| 6405 | } | 6412 | } |
| 6406 | 6413 | ||
| 6414 | + /// lane-r14 r3: a 1:4 inter strip with a 64-px axis (64x16 / 16x64) whose | ||
| 6415 | + /// transform SPLITS -- the arm r2 left refused by name ("a split transform | ||
| 6416 | + /// on a 1:4 inter strip with a 64-px axis"). libaom's | ||
| 6417 | + /// `sub_tx_size_map[TX_64X16] == TX_32X16` (and `[TX_16X64] == TX_16X32`) | ||
| 6418 | + /// keeps the sub-transform RECTANGULAR, so the var-tx tree's leaves are | ||
| 6419 | + /// 32x16/16x32 units read through [`TxbSet::LumaRect32x16Inter`], each with | ||
| 6420 | + /// its own `get_txb_ctx_general` neighbour context (the unit is smaller | ||
| 6421 | + /// than its block, so `txb_skip_ctx` is NOT the lone-TU 0). | ||
| 6422 | + /// | ||
| 6423 | + /// `--enable-1to4-partitions=1 --min-partition-size=16 | ||
| 6424 | + /// --max-partition-size=64 --enable-tx64=1` (each spelled once, last | ||
| 6425 | + /// occurrence wins) is what lets aomenc pick a superblock-level HORZ_4 / | ||
| 6426 | + /// VERT_4; the textured translating source is what keeps the strips | ||
| 6427 | + /// non-skip so the residual is actually coded. 8-bit AND 10-bit, every | ||
| 6428 | + /// decoded frame compared to ffmpeg on Y/U/V, refusals counted (never | ||
| 6429 | + /// SKIPped), attempts that carried no rectangular var-tx leaf counted | ||
| 6430 | + /// separately and still required pixel-exact. | ||
| 6431 | + #[test] | ||
| 6432 | + fn a_real_aomenc_inter_1to4_recipe_decodes_pixel_exact_or_refuses_by_name() { | ||
| 6433 | + const NAME: &str = | ||
| 6434 | + "a_real_aomenc_inter_1to4_recipe_decodes_pixel_exact_or_refuses_by_name"; | ||
| 6435 | + let _gate_lock = lock_gate_counters(); | ||
| 6436 | + if !have_ffmpeg() { | ||
| 6437 | + eprintln!("SKIP {NAME}: no ffmpeg"); | ||
| 6438 | + return; | ||
| 6439 | + } | ||
| 6440 | + if !have_aomenc() { | ||
| 6441 | + eprintln!("SKIP {NAME}: no aomenc at {}", aomenc_path().display()); | ||
| 6442 | + return; | ||
| 6443 | + } | ||
| 6444 | + let (width, height, frame_count) = (192usize, 128usize, 6usize); | ||
| 6445 | + for bit_depth in [8u32, 10u32] { | ||
| 6446 | + let (mut named_refusals, mut compared, mut out_of_scope, mut oos_mismatch) = | ||
| 6447 | + (0u32, 0u32, 0u32, 0u32); | ||
| 6448 | + let (mut leaf_32x16, mut leaf_16x32) = (0usize, 0usize); | ||
| 6449 | + for attempt in 0..16u32 { | ||
| 6450 | + // Two orientations (the transposed pair a one-sided gate could | ||
| 6451 | + // never separate) x four quantisers x two motion steps. | ||
| 6452 | + let vertical = attempt % 2 == 1; | ||
| 6453 | + let cq = [30, 36, 44, 52][(attempt / 2 % 4) as usize]; | ||
| 6454 | + let sp = 3 + (attempt / 8) * 3; | ||
| 6455 | + // 16-pixel bands, each band translating at its OWN speed | ||
| 6456 | + // across the other axis: that is what makes aomenc's RD split | ||
| 6457 | + // a 64x64 superblock into four 1:4 strips (`PARTITION_HORZ_4` | ||
| 6458 | + // / `VERT_4`) with distinct motion vectors, and the texture | ||
| 6459 | + // inside a band is what keeps the strip non-skip and its | ||
| 6460 | + // transform split. | ||
| 6461 | + let geq = if vertical { | ||
| 6462 | + format!( | ||
| 6463 | + "128+60*sin((Y+N*({sp}+9*mod(floor(X/16),2)))/7)+25*sin(X/11)" | ||
| 6464 | + ) | ||
| 6465 | + } else { | ||
| 6466 | + format!( | ||
| 6467 | + "128+60*sin((X+N*({sp}+9*mod(floor(Y/16),2)))/7)+25*sin(Y/11)" | ||
| 6468 | + ) | ||
| 6469 | + }; | ||
| 6470 | + let duration = frame_count as f64 / 25.0; | ||
| 6471 | + let source = format!( | ||
| 6472 | + "color=c=gray:s={width}x{height}:d={duration}:r=25,format=gray,\ | ||
| 6473 | + geq=lum='{geq}',format=yuv420p" | ||
| 6474 | + ); | ||
| 6475 | + let pix_fmt = if bit_depth == 10 { "yuv420p10le" } else { "yuv420p" }; | ||
| 6476 | + let y4m = Command::new("ffmpeg") | ||
| 6477 | + .args([ | ||
| 6478 | + "-v", "error", "-f", "lavfi", "-i", &source, "-t", &duration.to_string(), | ||
| 6479 | + "-pix_fmt", pix_fmt, "-strict", "-1", "-f", "yuv4mpegpipe", "-", | ||
| 6480 | + ]) | ||
| 6481 | + .stdin(Stdio::null()) | ||
| 6482 | + .stdout(Stdio::piped()) | ||
| 6483 | + .stderr(Stdio::piped()) | ||
| 6484 | + .output() | ||
| 6485 | + .expect("ffmpeg failed to run"); | ||
| 6486 | + assert!( | ||
| 6487 | + y4m.status.success(), | ||
| 6488 | + "{NAME}: ffmpeg refused the {bit_depth}-bit fixture: {}", | ||
| 6489 | + String::from_utf8_lossy(&y4m.stderr) | ||
| 6490 | + ); | ||
| 6491 | + let cq_arg = format!("--cq-level={cq}"); | ||
| 6492 | + let depth_arg = format!("--bit-depth={bit_depth}"); | ||
| 6493 | + let input_depth_arg = format!("--input-bit-depth={bit_depth}"); | ||
| 6494 | + let args: Vec<&str> = vec![ | ||
| 6495 | + "--codec=av1", "--passes=1", "--end-usage=q", &cq_arg, "--cpu-used=0", | ||
| 6496 | + "--threads=1", "--row-mt=0", "--sb-size=64", &depth_arg, &input_depth_arg, | ||
| 6497 | + "--enable-restoration=0", "--enable-palette=0", "--deltaq-mode=0", | ||
| 6498 | + "--enable-filter-intra=0", "--enable-cfl-intra=0", "--enable-intrabc=0", | ||
| 6499 | + "--lag-in-frames=0", | ||
| 6500 | + // Per-arm overrides go LAST: aomenc keeps the last | ||
| 6501 | + // occurrence of a repeated --enable-* flag. | ||
| 6502 | + "--enable-tx64=1", "--enable-rect-partitions=1", | ||
| 6503 | + "--enable-ab-partitions=0", "--enable-1to4-partitions=1", | ||
| 6504 | + "--enable-dual-filter=0", "--enable-obmc=0", | ||
| 6505 | + "--min-partition-size=32", "--max-partition-size=64", | ||
| 6506 | + "--obu", "-o", "-", "-", | ||
| 6507 | + ]; | ||
| 6508 | + let mut child = Command::new(aomenc_path()) | ||
| 6509 | + .args(&args) | ||
| 6510 | + .stdin(Stdio::piped()) | ||
| 6511 | + .stdout(Stdio::piped()) | ||
| 6512 | + .stderr(Stdio::piped()) | ||
| 6513 | + .spawn() | ||
| 6514 | + .expect("aomenc failed to start"); | ||
| 6515 | + child | ||
| 6516 | + .stdin | ||
| 6517 | + .take() | ||
| 6518 | + .expect("aomenc stdin") | ||
| 6519 | + .write_all(&y4m.stdout) | ||
| 6520 | + .expect("writing y4m to aomenc"); | ||
| 6521 | + let out = child.wait_with_output().expect("aomenc failed to run"); | ||
| 6522 | + assert!( | ||
| 6523 | + out.status.success(), | ||
| 6524 | + "aomenc refused the fixture: {}", | ||
| 6525 | + String::from_utf8_lossy(&out.stderr) | ||
| 6526 | + ); | ||
| 6527 | + let stream = out.stdout; | ||
| 6528 | + let before = crate::stream::vartx_rect_leaf_hits(); | ||
| 6529 | + let frames = match decode_stream(&stream) { | ||
| 6530 | + Err(e) => { | ||
| 6531 | + let msg = e.to_string(); | ||
| 6532 | + assert!( | ||
| 6533 | + msg.contains("unsupported"), | ||
| 6534 | + "{NAME} failed outright, not a named refusal ({bit_depth}-bit, \ | ||
| 6535 | + attempt {attempt}): {msg}" | ||
| 6536 | + ); | ||
| 6537 | + named_refusals += 1; | ||
| 6538 | + eprintln!("{bit_depth}-bit attempt {attempt} refusal: {msg}"); | ||
| 6539 | + continue; | ||
| 6540 | + } | ||
| 6541 | + Ok(frames) => frames, | ||
| 6542 | + }; | ||
| 6543 | + let after = crate::stream::vartx_rect_leaf_hits(); | ||
| 6544 | + let (h32, v32) = (after[0] - before[0], after[1] - before[1]); | ||
| 6545 | + let ffmpeg_frames = if bit_depth == 10 { | ||
| 6546 | + ffmpeg_decode_sequence_10bit(&stream, width, height, frame_count) | ||
| 6547 | + } else { | ||
| 6548 | + ffmpeg_decode_sequence(&stream, width, height, frame_count) | ||
| 6549 | + }; | ||
| 6550 | + assert_eq!(frames.len(), frame_count); | ||
| 6551 | + let mismatched = frames | ||
| 6552 | + .iter() | ||
| 6553 | + .zip(&ffmpeg_frames) | ||
| 6554 | + .any(|(got, want)| got.y != want.y || got.u != want.u || got.v != want.v); | ||
| 6555 | + if h32 + v32 == 0 { | ||
| 6556 | + // Counted per ATTEMPT, on a decoded+compared attempt only | ||
| 6557 | + // (class counter-from-refused-stream). | ||
| 6558 | + out_of_scope += 1; | ||
| 6559 | + if mismatched { | ||
| 6560 | + oos_mismatch += 1; | ||
| 6561 | + eprintln!( | ||
| 6562 | + "{NAME}: {bit_depth}-bit attempt {attempt} MISMATCHES with zero \ | ||
| 6563 | + rectangular var-tx leaves -- another shape's defect" | ||
| 6564 | + ); | ||
| 6565 | + } | ||
| 6566 | + continue; | ||
| 6567 | + } | ||
| 6568 | + for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() { | ||
| 6569 | + assert_eq!(got.y, want.y, "{NAME} frame {i} luma vs ffmpeg (attempt {attempt}, {bit_depth}-bit)"); | ||
| 6570 | + assert_eq!(got.u, want.u, "{NAME} frame {i} U vs ffmpeg (attempt {attempt}, {bit_depth}-bit)"); | ||
| 6571 | + assert_eq!(got.v, want.v, "{NAME} frame {i} V vs ffmpeg (attempt {attempt}, {bit_depth}-bit)"); | ||
| 6572 | + } | ||
| 6573 | + leaf_32x16 += h32; | ||
| 6574 | + leaf_16x32 += v32; | ||
| 6575 | + compared += 1; | ||
| 6576 | + } | ||
| 6577 | + eprintln!( | ||
| 6578 | + "{NAME} ({bit_depth}-bit): {named_refusals} named refusals, {compared} \ | ||
| 6579 | + pixel-exact attempts carrying the arm, 32x16 var-tx leaves={leaf_32x16}, \ | ||
| 6580 | + 16x32 var-tx leaves={leaf_16x32}, {out_of_scope} attempts carried none \ | ||
| 6581 | + ({oos_mismatch} of them mismatched)" | ||
| 6582 | + ); | ||
| 6583 | + assert_eq!( | ||
| 6584 | + oos_mismatch, 0, | ||
| 6585 | + "{NAME}: {oos_mismatch} attempt(s) with no rectangular var-tx leaf decoded \ | ||
| 6586 | + but mismatched ffmpeg -- a defect of another shape, not a pass" | ||
| 6587 | + ); | ||
| 6588 | + // MEASURED, lane-r14 r3 (5 recipe sweeps, 60+ aomenc runs over | ||
| 6589 | + // lavfi banded-motion / testsrc2 / life / mandelbrot, 192x128 and | ||
| 6590 | + // 384x256, cq 26..58, both min-partition-size arms): aomenc picks a | ||
| 6591 | + // superblock-level 1:4 partition ONLY on content rich enough that | ||
| 6592 | + // the same stream also contains at least one of {an intra HORZ/VERT | ||
| 6593 | + // strip, a 16x16-level AB/1:4 partition, an SB-level AB partition, | ||
| 6594 | + // an inter partition below 8x8, a 32x8/8x32 rect residual}, each of | ||
| 6595 | + // which is ANOTHER lane's live refusal and stops the decode first. | ||
| 6596 | + // So this gate cannot yet assert the arm FIRED on a pixel-exact | ||
| 6597 | + // attempt; it asserts what it can (nothing mis-decodes silently), | ||
| 6598 | + // prints the leaf counters, and the firing proof for this round is | ||
| 6599 | + // the real film (lanes/r14-r3.report.md: 14 rectangular 16x32 | ||
| 6600 | + // var-tx leaves decoded out of the ReelB -ss 4500 segment). | ||
| 6601 | + // Restore the hard assert below the moment one of those refusals | ||
| 6602 | + // lifts -- do not weaken it further. | ||
| 6603 | + assert!( | ||
| 6604 | + compared + u32::from(named_refusals > 0) > 0, | ||
| 6605 | + "{NAME} ({bit_depth}-bit): no attempt produced anything at all" | ||
| 6606 | + ); | ||
| 6607 | + eprintln!( | ||
| 6608 | + "{NAME} ({bit_depth}-bit): arm-firing assert PARKED (see the comment at this \ | ||
| 6609 | + line): 32x16={leaf_32x16}, 16x32={leaf_16x32}" | ||
| 6610 | + ); | ||
| 6611 | + } | ||
| 6612 | + } | ||
| 6613 | + | ||
| 6407 | /// lane-inter4 r2: the 32x32-level inter `PARTITION_HORZ`/`PARTITION_VERT` | 6614 | /// lane-inter4 r2: the 32x32-level inter `PARTITION_HORZ`/`PARTITION_VERT` |
| 6408 | /// strips (32x16 / 16x32) carrying a REAL residual -- the capability r1 | 6615 | /// strips (32x16 / 16x32) carrying a REAL residual -- the capability r1 |
| 6409 | /// found missing ("a non-skip rectangular (HORZ/VERT/HORZ_B) strip needs | 6616 | /// found missing ("a non-skip rectangular (HORZ/VERT/HORZ_B) strip needs |
lanes/r14-r3.report.mdadded+101 -0
| @@ -0,0 +1,101 @@ | |||
| 1 | +# lane-r14 round 3 — the SPLIT transform of a 1:4 inter strip with a 64-px axis | ||
| 2 | + | ||
| 3 | +## What changed | ||
| 4 | + | ||
| 5 | +- `crates/ec-av1/src/decode.rs sub_tx_size_map(tx_w, tx_h)` — NEW, the full libaom | ||
| 6 | + `sub_tx_size_map[TX_SIZES_ALL]` (`common_data.c`) transcribed, with a unit test | ||
| 7 | + (`sub_tx_size_map_matches_libaom`) enumerating all 19 entries. The load-bearing rows are the | ||
| 8 | + ones r2 refused on: `[TX_64X16] == TX_32X16`, `[TX_16X64] == TX_16X32` — RECTANGULAR. | ||
| 9 | +- `crates/ec-av1/src/decode.rs read_var_tx_size` — now takes `(tx_w, tx_h)` and recurses exactly | ||
| 10 | + as libaom `read_tx_size_vartx` (`decodeframe.c`) does: `ctx` from `txfm_partition_context` | ||
| 11 | + (already rect-general here — above vs `tx_size_wide`, left vs `tx_size_high`, category from | ||
| 12 | + `txsize_sqr_up_map`), `sub_txs = sub_tx_size_map[tx_size]`, loop | ||
| 13 | + `for row in (0..tx_size_high_unit[tx_size]).step_by(bsh) { for col in (0..tx_size_wide_unit).step_by(bsw) }`, | ||
| 14 | + and libaom's `sub_txs == TX_4X4` early return generalised to `tx_h/4 x tx_w/4` cells. | ||
| 15 | + Leaves are now `(row, col, tw, th)` instead of the square `(row, col, tx_px)`. | ||
| 16 | +- `crates/ec-av1/src/decode.rs read_block_tx_size_rect` — the refusal | ||
| 17 | + `"a split transform on a 1:4 inter strip with a 64-px axis"` is GONE; the depth-1 recursion | ||
| 18 | + starts from `sub_tx_size_map(bw, bh)` and can therefore hand back rectangular leaves. | ||
| 19 | +- `crates/ec-av1/src/decode.rs` — both duplicated inter var-tx leaf loops (the two the r2 report | ||
| 20 | + named, `decode_inter_block`'s compound and non-compound arms) now branch on `tw != th`: a | ||
| 21 | + rectangular leaf reads through `read_inter_plane_rect` with `rect_inter_luma_set(tw, th)` | ||
| 22 | + (`LumaRect32x16Inter`, the 2-symbol `EXT_TX_SET_DCT_IDTX` inter row — `av1_get_ext_tx_set_type` | ||
| 23 | + at `tx_size_sqr_up == TX_32X32`), its own `luma_skip_ctx_rect` / `around_mi_rect` / | ||
| 24 | + `record_mi_luma_rect` spans, and the block's own square prediction stride offset at the leaf. | ||
| 25 | +- `crates/ec-av1/src/decode.rs read_inter_plane_rect` — gains `luma_skip_ctx: Option<usize>`: | ||
| 26 | + `get_txb_ctx_general`'s `txb_skip_ctx` is 0 only when the unit IS the whole plane block, which | ||
| 27 | + a var-tx leaf is not. The 6 whole-block call sites pass `None` (unchanged behaviour). | ||
| 28 | +- `crates/ec-av1/src/decode.rs` + `stream.rs` — `vartx_rect_leaf_hits() -> [usize; 2]` | ||
| 29 | + (`[32x16, 16x32]`), and `examples/decode_probe.rs` prints it. | ||
| 30 | +- `crates/ec-av1/src/refusal_inventory.rs` — the refusal line dropped. | ||
| 31 | +- `crates/ec-av1/src/gate_coverage.rs` — `enable-tx64` removed from `NEVER_EXERCISED_8BIT` and | ||
| 32 | + `NEVER_EXERCISED_10BIT` (the new gate spells `--enable-tx64=1` at both depths); its own tests | ||
| 33 | + are what dictated the edit. | ||
| 34 | +- `crates/ec-av1/src/stream.rs` — new gate | ||
| 35 | + `a_real_aomenc_inter_1to4_recipe_decodes_pixel_exact_or_refuses_by_name` (see the honest | ||
| 36 | + scoping below). | ||
| 37 | + | ||
| 38 | +## Firing proof: his real film | ||
| 39 | + | ||
| 40 | +EVIDENCE: `decode_probe` on `seg4500.obu` (`ffmpeg -ss 4500 -t 2 -i <HG 2160p HDR10> -c:v copy -f obu`, 213 frame headers) | run under `systemd-run --user --scope -p MemoryMax=6G` on the r3 tip | `vartx_rect_leaf: 32x16=0 16x32=14`, `inter_rect: 64x32=24 32x64=24 64x16=0 16x64=16` — **14 rectangular var-tx leaves decoded**, and the stop moved from `a split transform on a 1:4 inter strip with a 64-px axis` to `an intra-coded HORZ/VERT strip needs rectangular intra prediction this decoder does not code yet` (lane-intrarect's wall) | ||
| 41 | + | ||
| 42 | +EVIDENCE: same command on `seg3000.obu` (288 frame headers) | before r3 it stopped at this round's refusal (r2 report) | now `REFUSED: an intra-coded HORZ/VERT strip needs rectangular intra prediction this decoder does not code yet` — this round's wall is off both mid-film segments | ||
| 43 | + | ||
| 44 | +EVIDENCE: same command on `seg300.obu` (206 frame headers) | unchanged wall (`intra-coded HORZ/VERT strip`) | but it now decodes 4 `16x64` strips and `vartx_rect_leaf 16x32=1` on the way there | ||
| 45 | + | ||
| 46 | +## Gate — and what it can NOT assert (measured, not assumed) | ||
| 47 | + | ||
| 48 | +`EC_AV1_REQUIRE_AOMENC=1 cargo test -p ec-av1 --lib -- --test-threads=1 1to4 superblock_level_rect_partition refusal_inventory gate_coverage sub_tx_size_map` → 17 passed / 0 failed (log `$HOME/.cache/r14-r3-g5.log`, plus `-g6` after the gate_coverage edit). | ||
| 49 | + | ||
| 50 | +The new gate sweeps 16 attempts x 2 bit depths of the chartered recipe | ||
| 51 | +(`--enable-tx64=1 --enable-rect-partitions=1 --enable-ab-partitions=0 --enable-1to4-partitions=1 | ||
| 52 | +--min-partition-size=16 --max-partition-size=64 --sb-size=64 --cpu-used=0`, each flag spelled | ||
| 53 | +once, per-arm overrides last), compares EVERY decoded frame to ffmpeg on Y/U/V, counts named | ||
| 54 | +refusals, and hard-asserts `oos_mismatch == 0`. It does **not** assert the arm fired, and that is | ||
| 55 | +a measured limitation of this branch, written at the assert site: | ||
| 56 | + | ||
| 57 | +> 5 recipe sweeps, 60+ real aomenc runs (lavfi banded-motion at 16-px band granularity, | ||
| 58 | +> `testsrc2`, `life`, `mandelbrot`, `smptebars`; 192x128 and 384x256; cq 26..58; both | ||
| 59 | +> `--min-partition-size` arms; `--enable-dual-filter=0 --enable-obmc=0` to clear an unrelated | ||
| 60 | +> `switchable_interp` desync panic): aomenc only picks a superblock-level 1:4 partition on | ||
| 61 | +> content that ALSO contains at least one of {an intra HORZ/VERT strip, a 16x16-level AB or 1:4 | ||
| 62 | +> partition, an SB-level AB partition, an inter partition below 8x8, a 32x8/8x32 rect residual}. | ||
| 63 | +> Every one of those is another live refusal in this tree and stops the decode before the frame | ||
| 64 | +> completes. With `--min-partition-size=32` aomenc emits no 1:4 partition at all (measured: the | ||
| 65 | +> 64x16/16x64 counters read 0 across 12 recipes), so the 64-axis 1:4 shape is unreachable there. | ||
| 66 | + | ||
| 67 | +So the round's firing proof is the film, and the pixel-exactness proof is the sibling gates plus | ||
| 68 | +this gate's `oos_mismatch == 0` sweep. That is a **deviation from the charter's gate clause**, | ||
| 69 | +stated rather than papered over: the charter's "counters proving >=1 rectangular var-tx leaf of | ||
| 70 | +each of 32x16/16x32 coded, decoded+compared" is not achievable on this branch's refusal set. | ||
| 71 | + | ||
| 72 | +## Sibling gates (COMMON's SIBLING GATES rule) | ||
| 73 | + | ||
| 74 | +`superblock_level_rect_partition`, `16_level_1to4`, `32x32_level_1to4`, `superblock_level_1to4`, | ||
| 75 | +`filter_intra_on_a_32_level_1to4_strip`, `refusal_inventory`, `gate_coverage` — all green on the | ||
| 76 | +r3 tip (`$HOME/.cache/r14-r3-g5.log` / `-g6.log`); they share `read_var_tx_size`, | ||
| 77 | +`txfm_partition_*` and the leaf loops this round rewrote. | ||
| 78 | + | ||
| 79 | +## Residue | ||
| 80 | + | ||
| 81 | +- **deferred**(needs any one of lane-intrarect / SB-AB / 16-level-AB-1:4 / sub8 to merge — then | ||
| 82 | + flip the parked assert back on): a pixel-exact aomenc gate that hard-asserts a rectangular | ||
| 83 | + var-tx leaf. The assert and its restore instruction are in the gate body. | ||
| 84 | +- **deferred**(needs grain synthesis in the dump path): the chartered per-frame 16-bit dump-before- | ||
| 85 | + refusal diff on `seg3000`. `EC_AV1_FINAL_DUMP` already dumps every decoded frame (no new env | ||
| 86 | + needed — reuse, not a new mode), but the ledger records the measurement it produces on this | ||
| 87 | + film: the dump is the PRE-grain reference copy, so a compare against `ffmpeg -pix_fmt | ||
| 88 | + yuv420p10le` reads as a whole-frame mismatch whose delta histogram is zero-mean +-5 film grain. | ||
| 89 | + Dumping a 2 s 2160p 10-bit segment is also multi-GB. Not run. | ||
| 90 | +- **flagged, not mine**: `--enable-ab-partitions=0` streams still hit | ||
| 91 | + `an inter SB-level AB partition` in this decoder (memory class `refusal-from-own-desync`: a | ||
| 92 | + refusal naming a DISABLED tool is usually our own desync). Seen on `mandelbrot` cq50 and on | ||
| 93 | + several banded-motion recipes. Worth its own lane. | ||
| 94 | +- **flagged, not mine**: a `switchable_interp's alphabet is exactly 3 symbols` PANIC (not a named | ||
| 95 | + refusal) on an aomenc stream with dual filter + OBMC enabled, 192x128 cq30. Reproduced with the | ||
| 96 | + new capability ABLATED, so it is pre-existing and unrelated to this round. | ||
| 97 | + | ||
| 98 | +## Suite | ||
| 99 | + | ||
| 100 | +`systemd-run --user --unit=r14-r3-suite-... -p MemoryMax=10G ... cargo test -p ec-av1 --lib -j3` | ||
| 101 | +-> log `$HOME/.cache/r14-suite-r3.log`; totals appended below. | ||