Merge branch 'lane-chromau': inter chroma inherits the colocated luma's coded tx_type
Browse files at this commit1 changed file +53 -26
- crates/ec-av1/src/decode.rs +53 -26
crates/ec-av1/src/decode.rsmodified+53 -26
| @@ -2488,11 +2488,6 @@ fn cdef_filter_block( | |||
| 2488 | } | 2488 | } |
| 2489 | } | 2489 | } |
| 2490 | 2490 | ||
| 2491 | -/// Applies CDEF (spec 7.15) to the whole reconstructed frame, over its true | ||
| 2492 | -/// (unpadded) `mi_cols`/`mi_rows` extent, before it is cropped to its display | ||
| 2493 | -/// size. `cdef_bits == 0` is this crate's only supported case so far (see the | ||
| 2494 | -/// refusal in `stream.rs`), so every 64x64 filter block always uses index 0's | ||
| 2495 | -/// strengths -- no per-block `cdef_idx` selection is implemented yet. | ||
| 2496 | /// Spec 7.14: the in-loop deblocking filter, applied once per frame after | 2491 | /// Spec 7.14: the in-loop deblocking filter, applied once per frame after |
| 2497 | /// tile reconstruction and before [`apply_cdef`]. Uniform-level path only -- | 2492 | /// tile reconstruction and before [`apply_cdef`]. Uniform-level path only -- |
| 2498 | /// `stream.rs` already refuses `delta_lf_present`/segmentation upstream, so | 2493 | /// `stream.rs` already refuses `delta_lf_present`/segmentation upstream, so |
| @@ -3847,20 +3842,28 @@ fn read_inter_plane( | |||
| 3847 | side: usize, | 3842 | side: usize, |
| 3848 | base_q_idx: u8, | 3843 | base_q_idx: u8, |
| 3849 | prediction: &[u8], | 3844 | prediction: &[u8], |
| 3850 | -) -> Result<Vec<i32>> { | 3845 | + // lane-chromau: this block's own luma transform's *actual coded* |
| 3846 | + // `tx_type` -- `av1_get_tx_type` (libaom `blockd.h`): an inter block's | ||
| 3847 | + // chroma plane never codes its own `tx_type` symbol, but (unlike an | ||
| 3848 | + // intra block, which falls back to `Intra_Mode_To_Tx_Type`) it inherits | ||
| 3849 | + // the colocated luma transform's coded type verbatim, clamped back to | ||
| 3850 | + // `DCT_DCT` at the chroma tx sizes the spec forces DCT-only | ||
| 3851 | + // (`av1_get_ext_tx_set_type`: `tx_size_sqr_up >= TX_32X32`, i.e. this | ||
| 3852 | + // function's own `side >= 32`). `None` for the luma call itself | ||
| 3853 | + // (`plane_idx == 0`), where the `TxbSet`'s own symbol (or the true | ||
| 3854 | + // `DCT_DCT` default at 32-point+) already resolves it without help. | ||
| 3855 | + inherited_luma_tx_type: Option<TxType>, | ||
| 3856 | +) -> Result<(Vec<i32>, TxType)> { | ||
| 3851 | let skip_ctx = if plane_idx == 0 { | 3857 | let skip_ctx = if plane_idx == 0 { |
| 3852 | 0 | 3858 | 0 |
| 3853 | } else { | 3859 | } else { |
| 3854 | usize::from(around.0) + usize::from(around.1) | 3860 | usize::from(around.0) + usize::from(around.1) |
| 3855 | }; | 3861 | }; |
| 3856 | let mut coding = cdfs.txb(set, tx_mode); | 3862 | let mut coding = cdfs.txb(set, tx_mode); |
| 3857 | - // `av1_get_tx_type` (libaom `blockd.h`): `Intra_Mode_To_Tx_Type` only | 3863 | + let default_tx_type = match inherited_luma_tx_type { |
| 3858 | - // ever applies to an intra block's chroma plane -- an `is_inter` block | 3864 | + Some(t) if side < 32 => t, |
| 3859 | - // (this function, [`read_inter_plane`], reads only those) has no | 3865 | + _ => TxType::DctDct, |
| 3860 | - // predicted intra mode to index it with, and its `tx_type` (luma or | 3866 | + }; |
| 3861 | - // chroma alike) is `DCT_DCT` whenever the `TxbSet` itself codes no | ||
| 3862 | - // symbol for it. | ||
| 3863 | - let default_tx_type = TxType::DctDct; | ||
| 3864 | let (grid, tx_type) = read_coeffs( | 3867 | let (grid, tx_type) = read_coeffs( |
| 3865 | dec, | 3868 | dec, |
| 3866 | &mut coding, | 3869 | &mut coding, |
| @@ -3871,7 +3874,7 @@ fn read_inter_plane( | |||
| 3871 | )?; | 3874 | )?; |
| 3872 | let residual = dequant_and_inverse_typed(&grid, side, 8, i32::from(base_q_idx), tx_type); | 3875 | let residual = dequant_and_inverse_typed(&grid, side, 8, i32::from(base_q_idx), tx_type); |
| 3873 | plane.reconstruct_mc(x, y, side, prediction, &residual); | 3876 | plane.reconstruct_mc(x, y, side, prediction, &residual); |
| 3874 | - Ok(grid) | 3877 | + Ok((grid, tx_type)) |
| 3875 | } | 3878 | } |
| 3876 | 3879 | ||
| 3877 | /// Spec 5.11.25's `single_ref_p1`..`p6` tree (reachable only once `comp_mode` | 3880 | /// Spec 5.11.25's `single_ref_p1`..`p6` tree (reachable only once `comp_mode` |
| @@ -4836,7 +4839,8 @@ fn decode_inter_block( | |||
| 4836 | v_grid = vec![0i32; chroma_side * chroma_side]; | 4839 | v_grid = vec![0i32; chroma_side * chroma_side]; |
| 4837 | } else { | 4840 | } else { |
| 4838 | let around = neighbours.around(at, side); | 4841 | let around = neighbours.around(at, side); |
| 4839 | - luma_grid = read_inter_plane( | 4842 | + let luma_tx_type; |
| 4843 | + (luma_grid, luma_tx_type) = read_inter_plane( | ||
| 4840 | dec, | 4844 | dec, |
| 4841 | cdfs, | 4845 | cdfs, |
| 4842 | luma_set_inter, | 4846 | luma_set_inter, |
| @@ -4850,6 +4854,7 @@ fn decode_inter_block( | |||
| 4850 | side, | 4854 | side, |
| 4851 | base_q_idx, | 4855 | base_q_idx, |
| 4852 | &pred_y, | 4856 | &pred_y, |
| 4857 | + None, | ||
| 4853 | )?; | 4858 | )?; |
| 4854 | u_grid = read_inter_plane( | 4859 | u_grid = read_inter_plane( |
| 4855 | dec, | 4860 | dec, |
| @@ -4865,7 +4870,9 @@ fn decode_inter_block( | |||
| 4865 | chroma_side, | 4870 | chroma_side, |
| 4866 | base_q_idx, | 4871 | base_q_idx, |
| 4867 | &pred_u, | 4872 | &pred_u, |
| 4868 | - )?; | 4873 | + Some(luma_tx_type), |
| 4874 | + )? | ||
| 4875 | + .0; | ||
| 4869 | v_grid = read_inter_plane( | 4876 | v_grid = read_inter_plane( |
| 4870 | dec, | 4877 | dec, |
| 4871 | cdfs, | 4878 | cdfs, |
| @@ -4880,7 +4887,9 @@ fn decode_inter_block( | |||
| 4880 | chroma_side, | 4887 | chroma_side, |
| 4881 | base_q_idx, | 4888 | base_q_idx, |
| 4882 | &pred_v, | 4889 | &pred_v, |
| 4883 | - )?; | 4890 | + Some(luma_tx_type), |
| 4891 | + )? | ||
| 4892 | + .0; | ||
| 4884 | } | 4893 | } |
| 4885 | } else { | 4894 | } else { |
| 4886 | let ref_frame = | 4895 | let ref_frame = |
| @@ -5128,7 +5137,8 @@ fn decode_inter_block( | |||
| 5128 | v_grid = vec![0i32; chroma_side * chroma_side]; | 5137 | v_grid = vec![0i32; chroma_side * chroma_side]; |
| 5129 | } else { | 5138 | } else { |
| 5130 | let around = neighbours.around(at, side); | 5139 | let around = neighbours.around(at, side); |
| 5131 | - luma_grid = read_inter_plane( | 5140 | + let luma_tx_type; |
| 5141 | + (luma_grid, luma_tx_type) = read_inter_plane( | ||
| 5132 | dec, | 5142 | dec, |
| 5133 | cdfs, | 5143 | cdfs, |
| 5134 | luma_set_inter, | 5144 | luma_set_inter, |
| @@ -5142,6 +5152,7 @@ fn decode_inter_block( | |||
| 5142 | side, | 5152 | side, |
| 5143 | base_q_idx, | 5153 | base_q_idx, |
| 5144 | &pred_y, | 5154 | &pred_y, |
| 5155 | + None, | ||
| 5145 | )?; | 5156 | )?; |
| 5146 | u_grid = read_inter_plane( | 5157 | u_grid = read_inter_plane( |
| 5147 | dec, | 5158 | dec, |
| @@ -5157,7 +5168,9 @@ fn decode_inter_block( | |||
| 5157 | chroma_side, | 5168 | chroma_side, |
| 5158 | base_q_idx, | 5169 | base_q_idx, |
| 5159 | &pred_u, | 5170 | &pred_u, |
| 5160 | - )?; | 5171 | + Some(luma_tx_type), |
| 5172 | + )? | ||
| 5173 | + .0; | ||
| 5161 | v_grid = read_inter_plane( | 5174 | v_grid = read_inter_plane( |
| 5162 | dec, | 5175 | dec, |
| 5163 | cdfs, | 5176 | cdfs, |
| @@ -5172,7 +5185,9 @@ fn decode_inter_block( | |||
| 5172 | chroma_side, | 5185 | chroma_side, |
| 5173 | base_q_idx, | 5186 | base_q_idx, |
| 5174 | &pred_v, | 5187 | &pred_v, |
| 5175 | - )?; | 5188 | + Some(luma_tx_type), |
| 5189 | + )? | ||
| 5190 | + .0; | ||
| 5176 | } | 5191 | } |
| 5177 | } | 5192 | } |
| 5178 | } else { | 5193 | } else { |
| @@ -5726,7 +5741,8 @@ fn decode_inter_block8( | |||
| 5726 | v_grid = vec![0i32; CHROMA_SIDE * CHROMA_SIDE]; | 5741 | v_grid = vec![0i32; CHROMA_SIDE * CHROMA_SIDE]; |
| 5727 | } else { | 5742 | } else { |
| 5728 | let around = neighbours.around_mi(leaf_mi, 8); | 5743 | let around = neighbours.around_mi(leaf_mi, 8); |
| 5729 | - luma_grid = read_inter_plane( | 5744 | + let luma_tx_type; |
| 5745 | + (luma_grid, luma_tx_type) = read_inter_plane( | ||
| 5730 | dec, | 5746 | dec, |
| 5731 | cdfs, | 5747 | cdfs, |
| 5732 | if reduced_tx_set { | 5748 | if reduced_tx_set { |
| @@ -5744,6 +5760,7 @@ fn decode_inter_block8( | |||
| 5744 | SIDE, | 5760 | SIDE, |
| 5745 | base_q_idx, | 5761 | base_q_idx, |
| 5746 | &pred_y, | 5762 | &pred_y, |
| 5763 | + None, | ||
| 5747 | )?; | 5764 | )?; |
| 5748 | u_grid = read_inter_plane( | 5765 | u_grid = read_inter_plane( |
| 5749 | dec, | 5766 | dec, |
| @@ -5759,7 +5776,9 @@ fn decode_inter_block8( | |||
| 5759 | CHROMA_SIDE, | 5776 | CHROMA_SIDE, |
| 5760 | base_q_idx, | 5777 | base_q_idx, |
| 5761 | &pred_u, | 5778 | &pred_u, |
| 5762 | - )?; | 5779 | + Some(luma_tx_type), |
| 5780 | + )? | ||
| 5781 | + .0; | ||
| 5763 | v_grid = read_inter_plane( | 5782 | v_grid = read_inter_plane( |
| 5764 | dec, | 5783 | dec, |
| 5765 | cdfs, | 5784 | cdfs, |
| @@ -5774,7 +5793,9 @@ fn decode_inter_block8( | |||
| 5774 | CHROMA_SIDE, | 5793 | CHROMA_SIDE, |
| 5775 | base_q_idx, | 5794 | base_q_idx, |
| 5776 | &pred_v, | 5795 | &pred_v, |
| 5777 | - )?; | 5796 | + Some(luma_tx_type), |
| 5797 | + )? | ||
| 5798 | + .0; | ||
| 5778 | } | 5799 | } |
| 5779 | return Ok((skip, is_inter, skip_mode, compound_ctx8)); | 5800 | return Ok((skip, is_inter, skip_mode, compound_ctx8)); |
| 5780 | } | 5801 | } |
| @@ -5924,7 +5945,8 @@ fn decode_inter_block8( | |||
| 5924 | v_grid = vec![0i32; CHROMA_SIDE * CHROMA_SIDE]; | 5945 | v_grid = vec![0i32; CHROMA_SIDE * CHROMA_SIDE]; |
| 5925 | } else { | 5946 | } else { |
| 5926 | let around = neighbours.around_mi(leaf_mi, 8); | 5947 | let around = neighbours.around_mi(leaf_mi, 8); |
| 5927 | - luma_grid = read_inter_plane( | 5948 | + let luma_tx_type; |
| 5949 | + (luma_grid, luma_tx_type) = read_inter_plane( | ||
| 5928 | dec, | 5950 | dec, |
| 5929 | cdfs, | 5951 | cdfs, |
| 5930 | if reduced_tx_set { | 5952 | if reduced_tx_set { |
| @@ -5942,6 +5964,7 @@ fn decode_inter_block8( | |||
| 5942 | SIDE, | 5964 | SIDE, |
| 5943 | base_q_idx, | 5965 | base_q_idx, |
| 5944 | &pred_y, | 5966 | &pred_y, |
| 5967 | + None, | ||
| 5945 | )?; | 5968 | )?; |
| 5946 | u_grid = read_inter_plane( | 5969 | u_grid = read_inter_plane( |
| 5947 | dec, | 5970 | dec, |
| @@ -5957,7 +5980,9 @@ fn decode_inter_block8( | |||
| 5957 | CHROMA_SIDE, | 5980 | CHROMA_SIDE, |
| 5958 | base_q_idx, | 5981 | base_q_idx, |
| 5959 | &pred_u, | 5982 | &pred_u, |
| 5960 | - )?; | 5983 | + Some(luma_tx_type), |
| 5984 | + )? | ||
| 5985 | + .0; | ||
| 5961 | v_grid = read_inter_plane( | 5986 | v_grid = read_inter_plane( |
| 5962 | dec, | 5987 | dec, |
| 5963 | cdfs, | 5988 | cdfs, |
| @@ -5972,7 +5997,9 @@ fn decode_inter_block8( | |||
| 5972 | CHROMA_SIDE, | 5997 | CHROMA_SIDE, |
| 5973 | base_q_idx, | 5998 | base_q_idx, |
| 5974 | &pred_v, | 5999 | &pred_v, |
| 5975 | - )?; | 6000 | + Some(luma_tx_type), |
| 6001 | + )? | ||
| 6002 | + .0; | ||
| 5976 | } | 6003 | } |
| 5977 | } else { | 6004 | } else { |
| 5978 | let mode = dec.symbol(&mut cdfs.y_mode[SIZE_GROUP_8]); | 6005 | let mode = dec.symbol(&mut cdfs.y_mode[SIZE_GROUP_8]); |