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 | 2491 | /// Spec 7.14: the in-loop deblocking filter, applied once per frame after |
| 2497 | 2492 | /// tile reconstruction and before [`apply_cdef`]. Uniform-level path only -- |
| 2498 | 2493 | /// `stream.rs` already refuses `delta_lf_present`/segmentation upstream, so |
| @@ -3847,20 +3842,28 @@ fn read_inter_plane( | ||
| 3847 | 3842 | side: usize, |
| 3848 | 3843 | base_q_idx: u8, |
| 3849 | 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 | 3857 | let skip_ctx = if plane_idx == 0 { |
| 3852 | 3858 | 0 |
| 3853 | 3859 | } else { |
| 3854 | 3860 | usize::from(around.0) + usize::from(around.1) |
| 3855 | 3861 | }; |
| 3856 | 3862 | let mut coding = cdfs.txb(set, tx_mode); |
| 3857 | - // `av1_get_tx_type` (libaom `blockd.h`): `Intra_Mode_To_Tx_Type` only | |
| 3858 | - // ever applies to an intra block's chroma plane -- an `is_inter` block | |
| 3859 | - // (this function, [`read_inter_plane`], reads only those) has no | |
| 3860 | - // predicted intra mode to index it with, and its `tx_type` (luma or | |
| 3861 | - // chroma alike) is `DCT_DCT` whenever the `TxbSet` itself codes no | |
| 3862 | - // symbol for it. | |
| 3863 | - let default_tx_type = TxType::DctDct; | |
| 3863 | + let default_tx_type = match inherited_luma_tx_type { | |
| 3864 | + Some(t) if side < 32 => t, | |
| 3865 | + _ => TxType::DctDct, | |
| 3866 | + }; | |
| 3864 | 3867 | let (grid, tx_type) = read_coeffs( |
| 3865 | 3868 | dec, |
| 3866 | 3869 | &mut coding, |
| @@ -3871,7 +3874,7 @@ fn read_inter_plane( | ||
| 3871 | 3874 | )?; |
| 3872 | 3875 | let residual = dequant_and_inverse_typed(&grid, side, 8, i32::from(base_q_idx), tx_type); |
| 3873 | 3876 | plane.reconstruct_mc(x, y, side, prediction, &residual); |
| 3874 | - Ok(grid) | |
| 3877 | + Ok((grid, tx_type)) | |
| 3875 | 3878 | } |
| 3876 | 3879 | |
| 3877 | 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 | 4839 | v_grid = vec![0i32; chroma_side * chroma_side]; |
| 4837 | 4840 | } else { |
| 4838 | 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 | 4844 | dec, |
| 4841 | 4845 | cdfs, |
| 4842 | 4846 | luma_set_inter, |
| @@ -4850,6 +4854,7 @@ fn decode_inter_block( | ||
| 4850 | 4854 | side, |
| 4851 | 4855 | base_q_idx, |
| 4852 | 4856 | &pred_y, |
| 4857 | + None, | |
| 4853 | 4858 | )?; |
| 4854 | 4859 | u_grid = read_inter_plane( |
| 4855 | 4860 | dec, |
| @@ -4865,7 +4870,9 @@ fn decode_inter_block( | ||
| 4865 | 4870 | chroma_side, |
| 4866 | 4871 | base_q_idx, |
| 4867 | 4872 | &pred_u, |
| 4868 | - )?; | |
| 4873 | + Some(luma_tx_type), | |
| 4874 | + )? | |
| 4875 | + .0; | |
| 4869 | 4876 | v_grid = read_inter_plane( |
| 4870 | 4877 | dec, |
| 4871 | 4878 | cdfs, |
| @@ -4880,7 +4887,9 @@ fn decode_inter_block( | ||
| 4880 | 4887 | chroma_side, |
| 4881 | 4888 | base_q_idx, |
| 4882 | 4889 | &pred_v, |
| 4883 | - )?; | |
| 4890 | + Some(luma_tx_type), | |
| 4891 | + )? | |
| 4892 | + .0; | |
| 4884 | 4893 | } |
| 4885 | 4894 | } else { |
| 4886 | 4895 | let ref_frame = |
| @@ -5128,7 +5137,8 @@ fn decode_inter_block( | ||
| 5128 | 5137 | v_grid = vec![0i32; chroma_side * chroma_side]; |
| 5129 | 5138 | } else { |
| 5130 | 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 | 5142 | dec, |
| 5133 | 5143 | cdfs, |
| 5134 | 5144 | luma_set_inter, |
| @@ -5142,6 +5152,7 @@ fn decode_inter_block( | ||
| 5142 | 5152 | side, |
| 5143 | 5153 | base_q_idx, |
| 5144 | 5154 | &pred_y, |
| 5155 | + None, | |
| 5145 | 5156 | )?; |
| 5146 | 5157 | u_grid = read_inter_plane( |
| 5147 | 5158 | dec, |
| @@ -5157,7 +5168,9 @@ fn decode_inter_block( | ||
| 5157 | 5168 | chroma_side, |
| 5158 | 5169 | base_q_idx, |
| 5159 | 5170 | &pred_u, |
| 5160 | - )?; | |
| 5171 | + Some(luma_tx_type), | |
| 5172 | + )? | |
| 5173 | + .0; | |
| 5161 | 5174 | v_grid = read_inter_plane( |
| 5162 | 5175 | dec, |
| 5163 | 5176 | cdfs, |
| @@ -5172,7 +5185,9 @@ fn decode_inter_block( | ||
| 5172 | 5185 | chroma_side, |
| 5173 | 5186 | base_q_idx, |
| 5174 | 5187 | &pred_v, |
| 5175 | - )?; | |
| 5188 | + Some(luma_tx_type), | |
| 5189 | + )? | |
| 5190 | + .0; | |
| 5176 | 5191 | } |
| 5177 | 5192 | } |
| 5178 | 5193 | } else { |
| @@ -5726,7 +5741,8 @@ fn decode_inter_block8( | ||
| 5726 | 5741 | v_grid = vec![0i32; CHROMA_SIDE * CHROMA_SIDE]; |
| 5727 | 5742 | } else { |
| 5728 | 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 | 5746 | dec, |
| 5731 | 5747 | cdfs, |
| 5732 | 5748 | if reduced_tx_set { |
| @@ -5744,6 +5760,7 @@ fn decode_inter_block8( | ||
| 5744 | 5760 | SIDE, |
| 5745 | 5761 | base_q_idx, |
| 5746 | 5762 | &pred_y, |
| 5763 | + None, | |
| 5747 | 5764 | )?; |
| 5748 | 5765 | u_grid = read_inter_plane( |
| 5749 | 5766 | dec, |
| @@ -5759,7 +5776,9 @@ fn decode_inter_block8( | ||
| 5759 | 5776 | CHROMA_SIDE, |
| 5760 | 5777 | base_q_idx, |
| 5761 | 5778 | &pred_u, |
| 5762 | - )?; | |
| 5779 | + Some(luma_tx_type), | |
| 5780 | + )? | |
| 5781 | + .0; | |
| 5763 | 5782 | v_grid = read_inter_plane( |
| 5764 | 5783 | dec, |
| 5765 | 5784 | cdfs, |
| @@ -5774,7 +5793,9 @@ fn decode_inter_block8( | ||
| 5774 | 5793 | CHROMA_SIDE, |
| 5775 | 5794 | base_q_idx, |
| 5776 | 5795 | &pred_v, |
| 5777 | - )?; | |
| 5796 | + Some(luma_tx_type), | |
| 5797 | + )? | |
| 5798 | + .0; | |
| 5778 | 5799 | } |
| 5779 | 5800 | return Ok((skip, is_inter, skip_mode, compound_ctx8)); |
| 5780 | 5801 | } |
| @@ -5924,7 +5945,8 @@ fn decode_inter_block8( | ||
| 5924 | 5945 | v_grid = vec![0i32; CHROMA_SIDE * CHROMA_SIDE]; |
| 5925 | 5946 | } else { |
| 5926 | 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 | 5950 | dec, |
| 5929 | 5951 | cdfs, |
| 5930 | 5952 | if reduced_tx_set { |
| @@ -5942,6 +5964,7 @@ fn decode_inter_block8( | ||
| 5942 | 5964 | SIDE, |
| 5943 | 5965 | base_q_idx, |
| 5944 | 5966 | &pred_y, |
| 5967 | + None, | |
| 5945 | 5968 | )?; |
| 5946 | 5969 | u_grid = read_inter_plane( |
| 5947 | 5970 | dec, |
| @@ -5957,7 +5980,9 @@ fn decode_inter_block8( | ||
| 5957 | 5980 | CHROMA_SIDE, |
| 5958 | 5981 | base_q_idx, |
| 5959 | 5982 | &pred_u, |
| 5960 | - )?; | |
| 5983 | + Some(luma_tx_type), | |
| 5984 | + )? | |
| 5985 | + .0; | |
| 5961 | 5986 | v_grid = read_inter_plane( |
| 5962 | 5987 | dec, |
| 5963 | 5988 | cdfs, |
| @@ -5972,7 +5997,9 @@ fn decode_inter_block8( | ||
| 5972 | 5997 | CHROMA_SIDE, |
| 5973 | 5998 | base_q_idx, |
| 5974 | 5999 | &pred_v, |
| 5975 | - )?; | |
| 6000 | + Some(luma_tx_type), | |
| 6001 | + )? | |
| 6002 | + .0; | |
| 5976 | 6003 | } |
| 5977 | 6004 | } else { |
| 5978 | 6005 | let mode = dec.symbol(&mut cdfs.y_mode[SIZE_GROUP_8]); |