Merge branch 'lane-partab': HORZ_A/VERT_A/VERT_B inter partition arms decode (opus-verified vs libaom decode_partition; AB gate fires live, refusals forbidden)
Browse files at this commit4 changed files +745 -3
- crates/ec-av1/src/decode.rs +471 -1
- crates/ec-av1/src/stream.rs +181 -2
- lanes/partab-r1.charter.md +62 -0
- lanes/partab-r1.report.md +31 -0
crates/ec-av1/src/decode.rsmodified+471 -1
| @@ -44,7 +44,10 @@ const PARTITION_NONE: usize = 0; | |||
| 44 | const PARTITION_HORZ: usize = 1; | 44 | const PARTITION_HORZ: usize = 1; |
| 45 | const PARTITION_VERT: usize = 2; | 45 | const PARTITION_VERT: usize = 2; |
| 46 | const PARTITION_SPLIT: usize = 3; | 46 | const PARTITION_SPLIT: usize = 3; |
| 47 | +const PARTITION_HORZ_A: usize = 4; | ||
| 47 | const PARTITION_HORZ_B: usize = 5; | 48 | const PARTITION_HORZ_B: usize = 5; |
| 49 | +const PARTITION_VERT_A: usize = 6; | ||
| 50 | +const PARTITION_VERT_B: usize = 7; | ||
| 48 | const SB_MI: u32 = 16; | 51 | const SB_MI: u32 = 16; |
| 49 | const BLOCK_MI: u32 = 8; | 52 | const BLOCK_MI: u32 = 8; |
| 50 | 53 | ||
| @@ -258,6 +261,18 @@ pub(crate) fn rect_partition_hits() -> usize { | |||
| 258 | RECT_PARTITION_HITS.load(std::sync::atomic::Ordering::Relaxed) | 261 | RECT_PARTITION_HITS.load(std::sync::atomic::Ordering::Relaxed) |
| 259 | } | 262 | } |
| 260 | 263 | ||
| 264 | +/// lane-partab r1: how many 32x32 quadrants decoded an AB partition | ||
| 265 | +/// (PARTITION_HORZ_A / VERT_A / VERT_B -- two 16x16 squares plus one | ||
| 266 | +/// 16x32/32x16 strip). Like [`RECT_PARTITION_HITS`], this is the | ||
| 267 | +/// free-partition gate's proof this round's arms actually fired. | ||
| 268 | +static PARTAB_HITS: std::sync::atomic::AtomicUsize = | ||
| 269 | + std::sync::atomic::AtomicUsize::new(0); | ||
| 270 | + | ||
| 271 | +/// Current value of [`PARTAB_HITS`]. | ||
| 272 | +pub(crate) fn partab_hits() -> usize { | ||
| 273 | + PARTAB_HITS.load(std::sync::atomic::Ordering::Relaxed) | ||
| 274 | +} | ||
| 275 | + | ||
| 261 | /// How many [`read_inter_compound_mode`] reads actually happened | 276 | /// How many [`read_inter_compound_mode`] reads actually happened |
| 262 | /// (lane-av1comp) -- proves a `COMPOUND_REFERENCE` block reached its own | 277 | /// (lane-av1comp) -- proves a `COMPOUND_REFERENCE` block reached its own |
| 263 | /// `compound_mode` symbol (past `comp_mode`/`comp_ref` and the compound | 278 | /// `compound_mode` symbol (past `comp_mode`/`comp_ref` and the compound |
| @@ -8613,9 +8628,464 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 8613 | BLOCK, | 8628 | BLOCK, |
| 8614 | )?; | 8629 | )?; |
| 8615 | } | 8630 | } |
| 8631 | + PARTITION_HORZ_A => { | ||
| 8632 | + // lane-partab r1: two 16x16 squares on top + a true | ||
| 8633 | + // 32x16 strip below (libaom decode_partition | ||
| 8634 | + // PARTITION_HORZ_A: TL, TR, bottom strip). | ||
| 8635 | + PARTAB_HITS.fetch_add(1, std::sync::atomic::Ordering::Relaxed); | ||
| 8636 | + decode_inter_block( | ||
| 8637 | + &mut dec, | ||
| 8638 | + &mut cdfs, | ||
| 8639 | + &mut neighbours, | ||
| 8640 | + &mut grid, | ||
| 8641 | + at, | ||
| 8642 | + SUB, | ||
| 8643 | + mi_cols, | ||
| 8644 | + mi_rows, | ||
| 8645 | + &mut y, | ||
| 8646 | + &mut u, | ||
| 8647 | + &mut v, | ||
| 8648 | + &ref_y, | ||
| 8649 | + &ref_u, | ||
| 8650 | + &ref_v, | ||
| 8651 | + &ref_slots, | ||
| 8652 | + &sign_bias_table, | ||
| 8653 | + base_q_idx, | ||
| 8654 | + TxbSet::Luma16, | ||
| 8655 | + if reduced_tx_set { | ||
| 8656 | + TxbSet::Luma16Inter | ||
| 8657 | + } else { | ||
| 8658 | + TxbSet::Luma16InterSet1 | ||
| 8659 | + }, | ||
| 8660 | + TxbSet::Chroma8, | ||
| 8661 | + TX16, | ||
| 8662 | + TX8, | ||
| 8663 | + &scan16, | ||
| 8664 | + &scan8, | ||
| 8665 | + 2, | ||
| 8666 | + allow_high_precision_mv, | ||
| 8667 | + force_integer_mv, | ||
| 8668 | + interp_fixed, | ||
| 8669 | + enable_dual_filter, | ||
| 8670 | + tpl_frame.as_ref(), | ||
| 8671 | + reference_select, | ||
| 8672 | + enable_masked_compound, | ||
| 8673 | + enable_interintra_compound, | ||
| 8674 | + enable_jnt_comp, | ||
| 8675 | + order_hint_bits, | ||
| 8676 | + order_hint, | ||
| 8677 | + ref_order_hints, | ||
| 8678 | + skip_mode_present, | ||
| 8679 | + skip_mode_frame, | ||
| 8680 | + switchable_motion_mode, | ||
| 8681 | + allow_warped_motion, | ||
| 8682 | + false, | ||
| 8683 | + SUB, | ||
| 8684 | + SUB, | ||
| 8685 | + )?; | ||
| 8686 | + decode_inter_block( | ||
| 8687 | + &mut dec, | ||
| 8688 | + &mut cdfs, | ||
| 8689 | + &mut neighbours, | ||
| 8690 | + &mut grid, | ||
| 8691 | + (r32 as usize * 2, c32 as usize * 2 + 1), | ||
| 8692 | + SUB, | ||
| 8693 | + mi_cols, | ||
| 8694 | + mi_rows, | ||
| 8695 | + &mut y, | ||
| 8696 | + &mut u, | ||
| 8697 | + &mut v, | ||
| 8698 | + &ref_y, | ||
| 8699 | + &ref_u, | ||
| 8700 | + &ref_v, | ||
| 8701 | + &ref_slots, | ||
| 8702 | + &sign_bias_table, | ||
| 8703 | + base_q_idx, | ||
| 8704 | + TxbSet::Luma16, | ||
| 8705 | + if reduced_tx_set { | ||
| 8706 | + TxbSet::Luma16Inter | ||
| 8707 | + } else { | ||
| 8708 | + TxbSet::Luma16InterSet1 | ||
| 8709 | + }, | ||
| 8710 | + TxbSet::Chroma8, | ||
| 8711 | + TX16, | ||
| 8712 | + TX8, | ||
| 8713 | + &scan16, | ||
| 8714 | + &scan8, | ||
| 8715 | + 2, | ||
| 8716 | + allow_high_precision_mv, | ||
| 8717 | + force_integer_mv, | ||
| 8718 | + interp_fixed, | ||
| 8719 | + enable_dual_filter, | ||
| 8720 | + tpl_frame.as_ref(), | ||
| 8721 | + reference_select, | ||
| 8722 | + enable_masked_compound, | ||
| 8723 | + enable_interintra_compound, | ||
| 8724 | + enable_jnt_comp, | ||
| 8725 | + order_hint_bits, | ||
| 8726 | + order_hint, | ||
| 8727 | + ref_order_hints, | ||
| 8728 | + skip_mode_present, | ||
| 8729 | + skip_mode_frame, | ||
| 8730 | + switchable_motion_mode, | ||
| 8731 | + allow_warped_motion, | ||
| 8732 | + false, | ||
| 8733 | + SUB, | ||
| 8734 | + SUB, | ||
| 8735 | + )?; | ||
| 8736 | + decode_inter_block( | ||
| 8737 | + &mut dec, | ||
| 8738 | + &mut cdfs, | ||
| 8739 | + &mut neighbours, | ||
| 8740 | + &mut grid, | ||
| 8741 | + (r32 as usize * 2 + 1, c32 as usize * 2), | ||
| 8742 | + BLOCK, | ||
| 8743 | + mi_cols, | ||
| 8744 | + mi_rows, | ||
| 8745 | + &mut y, | ||
| 8746 | + &mut u, | ||
| 8747 | + &mut v, | ||
| 8748 | + &ref_y, | ||
| 8749 | + &ref_u, | ||
| 8750 | + &ref_v, | ||
| 8751 | + &ref_slots, | ||
| 8752 | + &sign_bias_table, | ||
| 8753 | + base_q_idx, | ||
| 8754 | + TxbSet::Luma32, | ||
| 8755 | + TxbSet::Luma32Inter, | ||
| 8756 | + TxbSet::Chroma16, | ||
| 8757 | + TX32, | ||
| 8758 | + TX16, | ||
| 8759 | + &scan32, | ||
| 8760 | + &scan16, | ||
| 8761 | + 3, | ||
| 8762 | + allow_high_precision_mv, | ||
| 8763 | + force_integer_mv, | ||
| 8764 | + interp_fixed, | ||
| 8765 | + enable_dual_filter, | ||
| 8766 | + tpl_frame.as_ref(), | ||
| 8767 | + reference_select, | ||
| 8768 | + enable_masked_compound, | ||
| 8769 | + enable_interintra_compound, | ||
| 8770 | + enable_jnt_comp, | ||
| 8771 | + order_hint_bits, | ||
| 8772 | + order_hint, | ||
| 8773 | + ref_order_hints, | ||
| 8774 | + skip_mode_present, | ||
| 8775 | + skip_mode_frame, | ||
| 8776 | + switchable_motion_mode, | ||
| 8777 | + allow_warped_motion, | ||
| 8778 | + true, | ||
| 8779 | + BLOCK, | ||
| 8780 | + SUB, | ||
| 8781 | + )?; | ||
| 8782 | + } | ||
| 8783 | + PARTITION_VERT_A => { | ||
| 8784 | + // lane-partab r1: mirror of PARTITION_HORZ_A with | ||
| 8785 | + // width/height swapped (TL, BL, right 16x32 strip). | ||
| 8786 | + PARTAB_HITS.fetch_add(1, std::sync::atomic::Ordering::Relaxed); | ||
| 8787 | + decode_inter_block( | ||
| 8788 | + &mut dec, | ||
| 8789 | + &mut cdfs, | ||
| 8790 | + &mut neighbours, | ||
| 8791 | + &mut grid, | ||
| 8792 | + at, | ||
| 8793 | + SUB, | ||
| 8794 | + mi_cols, | ||
| 8795 | + mi_rows, | ||
| 8796 | + &mut y, | ||
| 8797 | + &mut u, | ||
| 8798 | + &mut v, | ||
| 8799 | + &ref_y, | ||
| 8800 | + &ref_u, | ||
| 8801 | + &ref_v, | ||
| 8802 | + &ref_slots, | ||
| 8803 | + &sign_bias_table, | ||
| 8804 | + base_q_idx, | ||
| 8805 | + TxbSet::Luma16, | ||
| 8806 | + if reduced_tx_set { | ||
| 8807 | + TxbSet::Luma16Inter | ||
| 8808 | + } else { | ||
| 8809 | + TxbSet::Luma16InterSet1 | ||
| 8810 | + }, | ||
| 8811 | + TxbSet::Chroma8, | ||
| 8812 | + TX16, | ||
| 8813 | + TX8, | ||
| 8814 | + &scan16, | ||
| 8815 | + &scan8, | ||
| 8816 | + 2, | ||
| 8817 | + allow_high_precision_mv, | ||
| 8818 | + force_integer_mv, | ||
| 8819 | + interp_fixed, | ||
| 8820 | + enable_dual_filter, | ||
| 8821 | + tpl_frame.as_ref(), | ||
| 8822 | + reference_select, | ||
| 8823 | + enable_masked_compound, | ||
| 8824 | + enable_interintra_compound, | ||
| 8825 | + enable_jnt_comp, | ||
| 8826 | + order_hint_bits, | ||
| 8827 | + order_hint, | ||
| 8828 | + ref_order_hints, | ||
| 8829 | + skip_mode_present, | ||
| 8830 | + skip_mode_frame, | ||
| 8831 | + switchable_motion_mode, | ||
| 8832 | + allow_warped_motion, | ||
| 8833 | + false, | ||
| 8834 | + SUB, | ||
| 8835 | + SUB, | ||
| 8836 | + )?; | ||
| 8837 | + decode_inter_block( | ||
| 8838 | + &mut dec, | ||
| 8839 | + &mut cdfs, | ||
| 8840 | + &mut neighbours, | ||
| 8841 | + &mut grid, | ||
| 8842 | + (r32 as usize * 2 + 1, c32 as usize * 2), | ||
| 8843 | + SUB, | ||
| 8844 | + mi_cols, | ||
| 8845 | + mi_rows, | ||
| 8846 | + &mut y, | ||
| 8847 | + &mut u, | ||
| 8848 | + &mut v, | ||
| 8849 | + &ref_y, | ||
| 8850 | + &ref_u, | ||
| 8851 | + &ref_v, | ||
| 8852 | + &ref_slots, | ||
| 8853 | + &sign_bias_table, | ||
| 8854 | + base_q_idx, | ||
| 8855 | + TxbSet::Luma16, | ||
| 8856 | + if reduced_tx_set { | ||
| 8857 | + TxbSet::Luma16Inter | ||
| 8858 | + } else { | ||
| 8859 | + TxbSet::Luma16InterSet1 | ||
| 8860 | + }, | ||
| 8861 | + TxbSet::Chroma8, | ||
| 8862 | + TX16, | ||
| 8863 | + TX8, | ||
| 8864 | + &scan16, | ||
| 8865 | + &scan8, | ||
| 8866 | + 2, | ||
| 8867 | + allow_high_precision_mv, | ||
| 8868 | + force_integer_mv, | ||
| 8869 | + interp_fixed, | ||
| 8870 | + enable_dual_filter, | ||
| 8871 | + tpl_frame.as_ref(), | ||
| 8872 | + reference_select, | ||
| 8873 | + enable_masked_compound, | ||
| 8874 | + enable_interintra_compound, | ||
| 8875 | + enable_jnt_comp, | ||
| 8876 | + order_hint_bits, | ||
| 8877 | + order_hint, | ||
| 8878 | + ref_order_hints, | ||
| 8879 | + skip_mode_present, | ||
| 8880 | + skip_mode_frame, | ||
| 8881 | + switchable_motion_mode, | ||
| 8882 | + allow_warped_motion, | ||
| 8883 | + false, | ||
| 8884 | + SUB, | ||
| 8885 | + SUB, | ||
| 8886 | + )?; | ||
| 8887 | + decode_inter_block( | ||
| 8888 | + &mut dec, | ||
| 8889 | + &mut cdfs, | ||
| 8890 | + &mut neighbours, | ||
| 8891 | + &mut grid, | ||
| 8892 | + (r32 as usize * 2, c32 as usize * 2 + 1), | ||
| 8893 | + BLOCK, | ||
| 8894 | + mi_cols, | ||
| 8895 | + mi_rows, | ||
| 8896 | + &mut y, | ||
| 8897 | + &mut u, | ||
| 8898 | + &mut v, | ||
| 8899 | + &ref_y, | ||
| 8900 | + &ref_u, | ||
| 8901 | + &ref_v, | ||
| 8902 | + &ref_slots, | ||
| 8903 | + &sign_bias_table, | ||
| 8904 | + base_q_idx, | ||
| 8905 | + TxbSet::Luma32, | ||
| 8906 | + TxbSet::Luma32Inter, | ||
| 8907 | + TxbSet::Chroma16, | ||
| 8908 | + TX32, | ||
| 8909 | + TX16, | ||
| 8910 | + &scan32, | ||
| 8911 | + &scan16, | ||
| 8912 | + 3, | ||
| 8913 | + allow_high_precision_mv, | ||
| 8914 | + force_integer_mv, | ||
| 8915 | + interp_fixed, | ||
| 8916 | + enable_dual_filter, | ||
| 8917 | + tpl_frame.as_ref(), | ||
| 8918 | + reference_select, | ||
| 8919 | + enable_masked_compound, | ||
| 8920 | + enable_interintra_compound, | ||
| 8921 | + enable_jnt_comp, | ||
| 8922 | + order_hint_bits, | ||
| 8923 | + order_hint, | ||
| 8924 | + ref_order_hints, | ||
| 8925 | + skip_mode_present, | ||
| 8926 | + skip_mode_frame, | ||
| 8927 | + switchable_motion_mode, | ||
| 8928 | + allow_warped_motion, | ||
| 8929 | + true, | ||
| 8930 | + SUB, | ||
| 8931 | + BLOCK, | ||
| 8932 | + )?; | ||
| 8933 | + } | ||
| 8934 | + PARTITION_VERT_B => { | ||
| 8935 | + // lane-partab r1: true 16x32 strip on the left + two | ||
| 8936 | + // 16x16 squares on the right (libaom decode_partition | ||
| 8937 | + // PARTITION_VERT_B: left strip, TR, BR). | ||
| 8938 | + PARTAB_HITS.fetch_add(1, std::sync::atomic::Ordering::Relaxed); | ||
| 8939 | + decode_inter_block( | ||
| 8940 | + &mut dec, | ||
| 8941 | + &mut cdfs, | ||
| 8942 | + &mut neighbours, | ||
| 8943 | + &mut grid, | ||
| 8944 | + at, | ||
| 8945 | + BLOCK, | ||
| 8946 | + mi_cols, | ||
| 8947 | + mi_rows, | ||
| 8948 | + &mut y, | ||
| 8949 | + &mut u, | ||
| 8950 | + &mut v, | ||
| 8951 | + &ref_y, | ||
| 8952 | + &ref_u, | ||
| 8953 | + &ref_v, | ||
| 8954 | + &ref_slots, | ||
| 8955 | + &sign_bias_table, | ||
| 8956 | + base_q_idx, | ||
| 8957 | + TxbSet::Luma32, | ||
| 8958 | + TxbSet::Luma32Inter, | ||
| 8959 | + TxbSet::Chroma16, | ||
| 8960 | + TX32, | ||
| 8961 | + TX16, | ||
| 8962 | + &scan32, | ||
| 8963 | + &scan16, | ||
| 8964 | + 3, | ||
| 8965 | + allow_high_precision_mv, | ||
| 8966 | + force_integer_mv, | ||
| 8967 | + interp_fixed, | ||
| 8968 | + enable_dual_filter, | ||
| 8969 | + tpl_frame.as_ref(), | ||
| 8970 | + reference_select, | ||
| 8971 | + enable_masked_compound, | ||
| 8972 | + enable_interintra_compound, | ||
| 8973 | + enable_jnt_comp, | ||
| 8974 | + order_hint_bits, | ||
| 8975 | + order_hint, | ||
| 8976 | + ref_order_hints, | ||
| 8977 | + skip_mode_present, | ||
| 8978 | + skip_mode_frame, | ||
| 8979 | + switchable_motion_mode, | ||
| 8980 | + allow_warped_motion, | ||
| 8981 | + true, | ||
| 8982 | + SUB, | ||
| 8983 | + BLOCK, | ||
| 8984 | + )?; | ||
| 8985 | + decode_inter_block( | ||
| 8986 | + &mut dec, | ||
| 8987 | + &mut cdfs, | ||
| 8988 | + &mut neighbours, | ||
| 8989 | + &mut grid, | ||
| 8990 | + (r32 as usize * 2, c32 as usize * 2 + 1), | ||
| 8991 | + SUB, | ||
| 8992 | + mi_cols, | ||
| 8993 | + mi_rows, | ||
| 8994 | + &mut y, | ||
| 8995 | + &mut u, | ||
| 8996 | + &mut v, | ||
| 8997 | + &ref_y, | ||
| 8998 | + &ref_u, | ||
| 8999 | + &ref_v, | ||
| 9000 | + &ref_slots, | ||
| 9001 | + &sign_bias_table, | ||
| 9002 | + base_q_idx, | ||
| 9003 | + TxbSet::Luma16, | ||
| 9004 | + if reduced_tx_set { | ||
| 9005 | + TxbSet::Luma16Inter | ||
| 9006 | + } else { | ||
| 9007 | + TxbSet::Luma16InterSet1 | ||
| 9008 | + }, | ||
| 9009 | + TxbSet::Chroma8, | ||
| 9010 | + TX16, | ||
| 9011 | + TX8, | ||
| 9012 | + &scan16, | ||
| 9013 | + &scan8, | ||
| 9014 | + 2, | ||
| 9015 | + allow_high_precision_mv, | ||
| 9016 | + force_integer_mv, | ||
| 9017 | + interp_fixed, | ||
| 9018 | + enable_dual_filter, | ||
| 9019 | + tpl_frame.as_ref(), | ||
| 9020 | + reference_select, | ||
| 9021 | + enable_masked_compound, | ||
| 9022 | + enable_interintra_compound, | ||
| 9023 | + enable_jnt_comp, | ||
| 9024 | + order_hint_bits, | ||
| 9025 | + order_hint, | ||
| 9026 | + ref_order_hints, | ||
| 9027 | + skip_mode_present, | ||
| 9028 | + skip_mode_frame, | ||
| 9029 | + switchable_motion_mode, | ||
| 9030 | + allow_warped_motion, | ||
| 9031 | + false, | ||
| 9032 | + SUB, | ||
| 9033 | + SUB, | ||
| 9034 | + )?; | ||
| 9035 | + decode_inter_block( | ||
| 9036 | + &mut dec, | ||
| 9037 | + &mut cdfs, | ||
| 9038 | + &mut neighbours, | ||
| 9039 | + &mut grid, | ||
| 9040 | + (r32 as usize * 2 + 1, c32 as usize * 2 + 1), | ||
| 9041 | + SUB, | ||
| 9042 | + mi_cols, | ||
| 9043 | + mi_rows, | ||
| 9044 | + &mut y, | ||
| 9045 | + &mut u, | ||
| 9046 | + &mut v, | ||
| 9047 | + &ref_y, | ||
| 9048 | + &ref_u, | ||
| 9049 | + &ref_v, | ||
| 9050 | + &ref_slots, | ||
| 9051 | + &sign_bias_table, | ||
| 9052 | + base_q_idx, | ||
| 9053 | + TxbSet::Luma16, | ||
| 9054 | + if reduced_tx_set { | ||
| 9055 | + TxbSet::Luma16Inter | ||
| 9056 | + } else { | ||
| 9057 | + TxbSet::Luma16InterSet1 | ||
| 9058 | + }, | ||
| 9059 | + TxbSet::Chroma8, | ||
| 9060 | + TX16, | ||
| 9061 | + TX8, | ||
| 9062 | + &scan16, | ||
| 9063 | + &scan8, | ||
| 9064 | + 2, | ||
| 9065 | + allow_high_precision_mv, | ||
| 9066 | + force_integer_mv, | ||
| 9067 | + interp_fixed, | ||
| 9068 | + enable_dual_filter, | ||
| 9069 | + tpl_frame.as_ref(), | ||
| 9070 | + reference_select, | ||
| 9071 | + enable_masked_compound, | ||
| 9072 | + enable_interintra_compound, | ||
| 9073 | + enable_jnt_comp, | ||
| 9074 | + order_hint_bits, | ||
| 9075 | + order_hint, | ||
| 9076 | + ref_order_hints, | ||
| 9077 | + skip_mode_present, | ||
| 9078 | + skip_mode_frame, | ||
| 9079 | + switchable_motion_mode, | ||
| 9080 | + allow_warped_motion, | ||
| 9081 | + false, | ||
| 9082 | + SUB, | ||
| 9083 | + SUB, | ||
| 9084 | + )?; | ||
| 9085 | + } | ||
| 8616 | _ => { | 9086 | _ => { |
| 8617 | return Err(unsupported(format!( | 9087 | return Err(unsupported(format!( |
| 8618 | - "a partition type this encoder never writes (value={part32})" | 9088 | + "an INTER 32x32 partition type this encoder never writes (value={part32})" |
| 8619 | ))); | 9089 | ))); |
| 8620 | } | 9090 | } |
| 8621 | } | 9091 | } |
crates/ec-av1/src/stream.rsmodified+181 -2
| @@ -3841,9 +3841,188 @@ mod tests { | |||
| 3841 | ); | 3841 | ); |
| 3842 | } | 3842 | } |
| 3843 | eprintln!( | 3843 | eprintln!( |
| 3844 | - "{NAME}: {named_refusals} named refusals, {matched} pixel-exact matches out of {n_attempts}, rect_partition_hits={} extended_partition_hits={}", | 3844 | + "{NAME}: {named_refusals} named refusals, {matched} pixel-exact matches out of {n_attempts}, rect_partition_hits={} extended_partition_hits={} partab_hits={}", |
| 3845 | crate::decode::rect_partition_hits(), | 3845 | crate::decode::rect_partition_hits(), |
| 3846 | - crate::decode::extended_partition_hits() | 3846 | + crate::decode::extended_partition_hits(), |
| 3847 | + crate::decode::partab_hits() | ||
| 3848 | + ); | ||
| 3849 | + } | ||
| 3850 | + | ||
| 3851 | + /// lane-partab r1: `--enable-ab-partitions=1` (aomenc default-on) INTER | ||
| 3852 | + /// streams must consume PARTITION_HORZ_A/VERT_A/VERT_B entropy-exact AND | ||
| 3853 | + /// decode pixel-exact -- `partab_hits() > 0` is soft-skipped on a | ||
| 3854 | + /// zero-hit run (aomenc RD may legitimately never pick an AB split in a | ||
| 3855 | + /// small window, same sampling caveat as wedge/rect). The INTER AB | ||
| 3856 | + /// refusal is FORBIDDEN (decode.rs names it "an INTER 32x32 partition | ||
| 3857 | + /// ..."); intra-frame AB refusals stay accepted named refusals -- the | ||
| 3858 | + /// intra dispatch is a later lane. Recipe = the free-partition gate's, | ||
| 3859 | + /// which fires AB live (r1: partab_hits 6/2/4/3/1/5 over six | ||
| 3860 | + /// 40-attempt runs). | ||
| 3861 | + #[test] | ||
| 3862 | + fn a_real_aomenc_stream_with_ab_partitions_decodes_pixel_exact() { | ||
| 3863 | + const NAME: &str = "a_real_aomenc_stream_with_ab_partitions_decodes_pixel_exact"; | ||
| 3864 | + let _gate_lock = lock_gate_counters(); | ||
| 3865 | + if !have_ffmpeg() { | ||
| 3866 | + eprintln!("SKIP {NAME}: no ffmpeg"); | ||
| 3867 | + return; | ||
| 3868 | + } | ||
| 3869 | + if !have_aomenc() { | ||
| 3870 | + eprintln!("SKIP {NAME}: no aomenc at {}", aomenc_path().display()); | ||
| 3871 | + return; | ||
| 3872 | + } | ||
| 3873 | + let (width, height, frame_count) = (64usize, 64usize, 24usize); | ||
| 3874 | + let mut named_refusals = 0u32; | ||
| 3875 | + let mut matched = 0u32; | ||
| 3876 | + let n_attempts: u32 = std::env::var("EC_RECTGATE_ATTEMPTS") | ||
| 3877 | + .ok() | ||
| 3878 | + .and_then(|s| s.parse().ok()) | ||
| 3879 | + .unwrap_or(40); | ||
| 3880 | + for attempt in 0..n_attempts { | ||
| 3881 | + let seed = 42 + attempt; | ||
| 3882 | + let duration = frame_count as f64 / 25.0; | ||
| 3883 | + let source = | ||
| 3884 | + format!("gradients=size={width}x{height}:seed={seed}:duration={duration}:rate=25"); | ||
| 3885 | + let y4m = Command::new("ffmpeg") | ||
| 3886 | + .args([ | ||
| 3887 | + "-v", | ||
| 3888 | + "error", | ||
| 3889 | + "-f", | ||
| 3890 | + "lavfi", | ||
| 3891 | + "-i", | ||
| 3892 | + &source, | ||
| 3893 | + "-pix_fmt", | ||
| 3894 | + "yuv420p", | ||
| 3895 | + "-f", | ||
| 3896 | + "yuv4mpegpipe", | ||
| 3897 | + "-", | ||
| 3898 | + ]) | ||
| 3899 | + .stdin(Stdio::null()) | ||
| 3900 | + .stdout(Stdio::piped()) | ||
| 3901 | + .stderr(Stdio::piped()) | ||
| 3902 | + .output() | ||
| 3903 | + .expect("ffmpeg failed to run"); | ||
| 3904 | + assert!( | ||
| 3905 | + y4m.status.success(), | ||
| 3906 | + "ffmpeg fixture: {}", | ||
| 3907 | + String::from_utf8_lossy(&y4m.stderr) | ||
| 3908 | + ); | ||
| 3909 | + let args: Vec<&str> = vec![ | ||
| 3910 | + "--codec=av1", | ||
| 3911 | + "--passes=1", | ||
| 3912 | + "--end-usage=q", | ||
| 3913 | + "--cq-level=45", | ||
| 3914 | + "--cpu-used=0", | ||
| 3915 | + "--kf-max-dist=1000", | ||
| 3916 | + "--threads=1", | ||
| 3917 | + "--row-mt=0", | ||
| 3918 | + "--auto-alt-ref=1", | ||
| 3919 | + "--lag-in-frames=16", | ||
| 3920 | + "--enable-fwd-kf=0", | ||
| 3921 | + "--enable-order-hint=1", | ||
| 3922 | + "--enable-warped-motion=1", | ||
| 3923 | + "--enable-obmc=1", | ||
| 3924 | + "--tune-content=default", | ||
| 3925 | + "--enable-masked-comp=0", | ||
| 3926 | + "--enable-interintra-comp=0", | ||
| 3927 | + "--enable-onesided-comp=0", | ||
| 3928 | + "--enable-interintra-wedge=0", | ||
| 3929 | + "--enable-smooth-interintra=0", | ||
| 3930 | + // lane-rect r2 recipe, kept byte-identical by lane-partab | ||
| 3931 | + // r1: free partition search, 1to4 off, intra tools off. | ||
| 3932 | + "--enable-rect-partitions=1", | ||
| 3933 | + "--enable-ab-partitions=1", | ||
| 3934 | + "--enable-1to4-partitions=0", | ||
| 3935 | + "--enable-filter-intra=0", | ||
| 3936 | + "--enable-smooth-intra=0", | ||
| 3937 | + "--enable-paeth-intra=0", | ||
| 3938 | + "--enable-directional-intra=0", | ||
| 3939 | + "--enable-angle-delta=0", | ||
| 3940 | + "--enable-tx-size-search=0", | ||
| 3941 | + "--enable-cdef=0", | ||
| 3942 | + "--enable-restoration=0", | ||
| 3943 | + "--max-partition-size=32", | ||
| 3944 | + "--min-partition-size=16", | ||
| 3945 | + "--enable-palette=0", | ||
| 3946 | + "--enable-intrabc=0", | ||
| 3947 | + "--enable-cfl-intra=0", | ||
| 3948 | + "--enable-ref-frame-mvs=0", | ||
| 3949 | + "--obu", | ||
| 3950 | + "-o", | ||
| 3951 | + "-", | ||
| 3952 | + "-", | ||
| 3953 | + ]; | ||
| 3954 | + let mut child = Command::new(aomenc_path()) | ||
| 3955 | + .args(&args) | ||
| 3956 | + .stdin(Stdio::piped()) | ||
| 3957 | + .stdout(Stdio::piped()) | ||
| 3958 | + .stderr(Stdio::piped()) | ||
| 3959 | + .spawn() | ||
| 3960 | + .expect("aomenc failed to start"); | ||
| 3961 | + child | ||
| 3962 | + .stdin | ||
| 3963 | + .take() | ||
| 3964 | + .expect("aomenc stdin") | ||
| 3965 | + .write_all(&y4m.stdout) | ||
| 3966 | + .expect("writing y4m to aomenc"); | ||
| 3967 | + let out = child.wait_with_output().expect("aomenc failed to run"); | ||
| 3968 | + assert!( | ||
| 3969 | + out.status.success(), | ||
| 3970 | + "aomenc refused the fixture: {}", | ||
| 3971 | + String::from_utf8_lossy(&out.stderr) | ||
| 3972 | + ); | ||
| 3973 | + let stream = out.stdout; | ||
| 3974 | + let frames = match decode_stream(&stream) { | ||
| 3975 | + Err(e) => { | ||
| 3976 | + let msg = e.to_string(); | ||
| 3977 | + assert!( | ||
| 3978 | + msg.contains("unsupported"), | ||
| 3979 | + "{NAME} failed outright, not a named refusal (seed {seed}): {msg}" | ||
| 3980 | + ); | ||
| 3981 | + for banned in ["warp", "obmc", "interintra"] { | ||
| 3982 | + assert!( | ||
| 3983 | + !msg.contains(banned), | ||
| 3984 | + "{NAME} refused on {banned} (seed {seed}) -- that capability is \ | ||
| 3985 | + ported and this recipe does not need it: {msg}" | ||
| 3986 | + ); | ||
| 3987 | + } | ||
| 3988 | + for v in [4, 6, 7] { | ||
| 3989 | + assert!( | ||
| 3990 | + !msg.contains(&format!( | ||
| 3991 | + "an INTER 32x32 partition type this encoder never writes \ | ||
| 3992 | + (value={v})" | ||
| 3993 | + )), | ||
| 3994 | + "{NAME} refused an INTER AB partition (value={v}, seed {seed}) -- \ | ||
| 3995 | + all three AB arms are ported, this refusal is forbidden: {msg}" | ||
| 3996 | + ); | ||
| 3997 | + } | ||
| 3998 | + named_refusals += 1; | ||
| 3999 | + eprintln!("seed {seed} refusal: {msg}"); | ||
| 4000 | + continue; | ||
| 4001 | + } | ||
| 4002 | + Ok(frames) => frames, | ||
| 4003 | + }; | ||
| 4004 | + let ffmpeg_frames = ffmpeg_decode_sequence(&stream, width, height, frame_count); | ||
| 4005 | + assert_eq!(frames.len(), frame_count); | ||
| 4006 | + for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() { | ||
| 4007 | + assert_eq!(got.y, want.y, "{NAME} frame {i} luma vs ffmpeg (seed {seed})"); | ||
| 4008 | + assert_eq!(got.u, want.u, "{NAME} frame {i} U vs ffmpeg (seed {seed})"); | ||
| 4009 | + assert_eq!(got.v, want.v, "{NAME} frame {i} V vs ffmpeg (seed {seed})"); | ||
| 4010 | + } | ||
| 4011 | + matched += 1; | ||
| 4012 | + } | ||
| 4013 | + assert!( | ||
| 4014 | + matched > 0, | ||
| 4015 | + "{NAME}: every attempt refused; the gate never decoded a stream" | ||
| 4016 | + ); | ||
| 4017 | + if crate::decode::partab_hits() == 0 { | ||
| 4018 | + eprintln!( | ||
| 4019 | + "{NAME}: SOFT-NOTE -- zero AB partitions fired this run \ | ||
| 4020 | + ({matched} matches, {named_refusals} refusals); sampling, not a regression" | ||
| 4021 | + ); | ||
| 4022 | + } | ||
| 4023 | + eprintln!( | ||
| 4024 | + "{NAME}: {named_refusals} named refusals, {matched} pixel-exact matches out of {n_attempts}, partab_hits={}", | ||
| 4025 | + crate::decode::partab_hits() | ||
| 3847 | ); | 4026 | ); |
| 3848 | } | 4027 | } |
| 3849 | 4028 | ||
lanes/partab-r1.charter.mdadded+62 -0
| @@ -0,0 +1,62 @@ | |||
| 1 | +# lane-partab r1 charter — AB partition arms (HORZ_A / VERT_A / VERT_B) decode | ||
| 2 | + | ||
| 3 | +## Where you are | ||
| 4 | +Worktree /home/user/Documents/Code/Rust/edith_codecs-partab, branch lane-partab @ 6f4ca37. | ||
| 5 | +Build/test ONLY: `env CARGO_TARGET_DIR=$HOME/.cache/cargo-target-partab cargo test -p ec-av1 --release --lib <name> -- --nocapture` | ||
| 6 | +FOREGROUND, `nice -n 19`, `CARGO_BUILD_JOBS=4`. Never push; never touch other worktrees; fixtures/ is a symlink. | ||
| 7 | +BUDGET: ~60 calls. Commit compiling WIP + report by call 45. Read ONLY what is named. | ||
| 8 | + | ||
| 9 | +## Facts you build on (verified this batch, do not re-derive) | ||
| 10 | +- HORZ/VERT/HORZ_B already decode for real: 32x16/16x32 strips thread true | ||
| 11 | + write_w/write_h through mvstack (MiInfo.size_h), warp samples, OBMC, deblock | ||
| 12 | + tx_h_grid, and the motion_mode/obmc CDF rect rows (cdf.rs rows 4=BLOCK_16X32, | ||
| 13 | + 5=BLOCK_32X16). All sub-block sizes an AB partition produces (16x16, 32x16, | ||
| 14 | + 16x32) ALREADY decode. | ||
| 15 | +- The INTER dispatch is decode.rs ~8013 `match part32 {` with arms | ||
| 16 | + NONE/HORZ/VERT/SPLIT/HORZ_B; the catch-all `_ =>` at ~8616 refuses | ||
| 17 | + HORZ_A(4)/VERT_A(6)/VERT_B(7)/HORZ_4(8)/VERT_4(9). | ||
| 18 | +- Spec sub-block layout at a 32x32 area, mi origin (r,c) in 4x4 units of 8 | ||
| 19 | + (i.e. `at = (r32*2, c32*2)` is 16px units — CHECK the existing arms' `at` | ||
| 20 | + arithmetic and copy it; lane-warp r5 once lost a round to `at` being 16px | ||
| 21 | + units, decode.rs:4858-9 comment): | ||
| 22 | + - HORZ_A: 16x16 at (r,c) + 16x16 at (r,c+16px) + 32x16 strip at (r+16px,c) | ||
| 23 | + - VERT_A: 16x16 at (r,c) + 16x16 at (r+16px,c) + 16x32 strip at (r,c+16px) | ||
| 24 | + - VERT_B: 16x32 strip at (r,c) + 16x16 at (r,c+16px) + 16x16 at (r+16px,c+16px) | ||
| 25 | + (verify each against /tmp/libaom-src/av1/common/enums.h + decodeframe.c | ||
| 26 | + decode_partition's PARTITION_HORZ_A/VERT_A/VERT_B cases — the A/B naming is | ||
| 27 | + easy to mirror-swap; libaom is the oracle.) | ||
| 28 | +- decode_inter_block's trailing 3 args are (is_rect_strip: bool, write_w, write_h) | ||
| 29 | + in mi-of-16px units (SUB=16px class, BLOCK=32px class) — copy how the HORZ and | ||
| 30 | + VERT arms pass them for the strip + how SPLIT passes for 16x16 leaves. | ||
| 31 | +- Partition CDF/ctx for the arms is already read correctly (VERT_ALIKE/ | ||
| 32 | + HORZ_ALIKE gathers include values 4..9); ONLY the dispatch refuses. | ||
| 33 | + | ||
| 34 | +## Scope | ||
| 35 | +1. decode.rs ~8013 match: add PARTITION_HORZ_A / PARTITION_VERT_A / | ||
| 36 | + PARTITION_VERT_B arms composing the SAME decode_inter_block calls the | ||
| 37 | + HORZ/VERT/SPLIT/HORZ_B arms already make (order = spec decode order). | ||
| 38 | + Declare consts PARTITION_HORZ_A=4, PARTITION_VERT_A=6, PARTITION_VERT_B=7 | ||
| 39 | + next to PARTITION_HORZ_B. Mind per-arm neighbour/ctx recording: copy | ||
| 40 | + exactly what the existing arms do after each sub-block (record_* calls). | ||
| 41 | +2. HORZ_4/VERT_4 and the INTRA-frame dispatch (~3624) stay refusing — do not | ||
| 42 | + touch them. | ||
| 43 | +3. Gate ladder, in order: | ||
| 44 | + a. full 15-pin default list green (pins contain HORZ_B streams — regression | ||
| 45 | + canary): cargo test -p ec-av1 --release --lib pinned_warp -- --nocapture | ||
| 46 | + b. free-partition gate a_real_aomenc_stream_with_free_partitions_decodes_ | ||
| 47 | + pixel_exact 6x with EC_AV1_GATE_DUMP self-pin | ||
| 48 | + (/tmp/claude-1000/partab-flake-N.obu). A mismatch = pin it, report the | ||
| 49 | + recon-diff location (EC_AV1_PREFILT_DUMP both sides), do NOT guess-fix. | ||
| 50 | + c. full lib suite. | ||
| 51 | +4. If aomenc's free recipe never emits an AB partition (grep your decode for | ||
| 52 | + the arm actually firing — add a PARTAB_HITS atomic like WEDGE_HITS), find a | ||
| 53 | + recipe that does (aomenc --enable-ab-partitions=1 is default-on; try | ||
| 54 | + structured content / lower cq) and add a dedicated gate test that forbids | ||
| 55 | + the AB refusal string, soft-skipping on zero-hit runs like the maskcomp | ||
| 56 | + gate. Verified-but-unfired is reportable; unverified is not landable. | ||
| 57 | + | ||
| 58 | +## Done criteria | ||
| 59 | +1. AB arms decode; hits proven fired at least once (atomic count in report); | ||
| 60 | + pins green; free gate 6/6; lib green. | ||
| 61 | +2. Committed to lane-partab (wip commit after EVERY green milestone); REPORT | ||
| 62 | + lanes/partab-r1.report.md, verdict FIRST line, evidence per claim. | ||
lanes/partab-r1.report.mdadded+31 -0
| @@ -0,0 +1,31 @@ | |||
| 1 | +# lane-partab r1 report (orchestrator-written; flash builder capped before reporting) | ||
| 2 | + | ||
| 3 | +VERDICT: PASS pending cross-provider source verification (opus verifier running) — AB inter arms decode and fire live; all gates green. | ||
| 4 | + | ||
| 5 | +## What landed | ||
| 6 | +- 46235d1: PARTITION_HORZ_A(4)/VERT_A(6)/VERT_B(7) arms in the INTER 32x32 | ||
| 7 | + dispatch (decode.rs `match part32`), composing the existing 16x16-leaf and | ||
| 8 | + 32x16/16x32-strip decode_inter_block calls; PARTAB_HITS atomic. | ||
| 9 | +- d6453b5: dedicated gate a_real_aomenc_stream_with_ab_partitions_decodes_ | ||
| 10 | + pixel_exact — rect-r2 free recipe + --enable-ab-partitions=1 | ||
| 11 | + --enable-1to4-partitions=0; INTER AB refusals (values 4/6/7) FORBIDDEN, | ||
| 12 | + warp/obmc/interintra refusals forbidden, other named refusals tolerated | ||
| 13 | + and printed. | ||
| 14 | + | ||
| 15 | +## Evidence (orchestrator re-ran everything) | ||
| 16 | +- 14-pin default list green (3 warp + 8 ii + 3 rect fixtures). | ||
| 17 | +- AB gate 4 runs: matches 5-8/40 per run, partab_hits 1-4 per run (arms FIRE | ||
| 18 | + live), zero forbidden refusals. Refusal breakdown (40-attempt run): | ||
| 19 | + 14x allow_screen_content_tools (pre-existing, content-triggered), | ||
| 20 | + 17x INTRA-site partition refusals (values 1/2/4/5/6/7 on key frames) — | ||
| 21 | + intra rect/AB partitions are out of this lane's scope and now the widest | ||
| 22 | + measured remaining gap in THIS recipe. | ||
| 23 | +- Free-partition gate 6/6 with self-pin armed. | ||
| 24 | +- Full ec-av1 lib: 222 passed / 0 failed. | ||
| 25 | + | ||
| 26 | +## Residue | ||
| 27 | +- INTRA-frame rect/AB partition decode (17/40 refusals above) — queue. | ||
| 28 | +- allow_screen_content_tools streams (14/40) — pre-existing named refusal. | ||
| 29 | +- HORZ_4/VERT_4 (needs 32x8/8x32 tx/CDF threading) — queue. | ||
| 30 | +- No AB-specific pinned fixture yet: no AB-gate mismatch has occurred to pin | ||
| 31 | + (self-pin stays armed in the gate). | ||