Inter chroma tx_type inherits colocated luma's coded type
Browse files at this commit752b1efcc8129303e06feb6a4eb087c43e2a4714Parent: 74c4dbd- fix
- inter chroma tx_type inherits colocated luma's coded type
1 changed file +36 -48
- crates/ec-av1/src/decode.rs +36 -48
crates/ec-av1/src/decode.rsmodified+36 -48
| @@ -2488,34 +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 | -/// bisect scratch (lane-chromau): dump this frame's Y/U/V pre-deblock, mirrors | ||
| 2497 | -/// the instrumented `aomdec` build's `EC_AV1_PREFILT_DUMP` (raw | ||
| 2498 | -/// `true_width`x`true_height` bytes per plane, decode order, one file per | ||
| 2499 | -/// frame index). Zero-cost/zero-behavior off. Called from both the key-frame | ||
| 2500 | -/// and inter-frame tile decoders so the frame index lines up with aomdec's. | ||
| 2501 | -fn scratch_dump_prefilt(y: &PlaneBuf, u: &PlaneBuf, v: &PlaneBuf) { | ||
| 2502 | - let Some(base) = std::env::var_os("EC_AV1_PREFILT_DUMP_OURS") else { | ||
| 2503 | - return; | ||
| 2504 | - }; | ||
| 2505 | - use std::sync::atomic::{AtomicUsize, Ordering}; | ||
| 2506 | - static IDX: AtomicUsize = AtomicUsize::new(0); | ||
| 2507 | - let idx = IDX.fetch_add(1, Ordering::SeqCst); | ||
| 2508 | - let path = format!("{}.f{}", base.to_string_lossy(), idx); | ||
| 2509 | - let mut out = Vec::new(); | ||
| 2510 | - for plane in [y, u, v] { | ||
| 2511 | - for row in 0..plane.true_height { | ||
| 2512 | - let start = row * plane.width; | ||
| 2513 | - out.extend_from_slice(&plane.data[start..start + plane.true_width]); | ||
| 2514 | - } | ||
| 2515 | - } | ||
| 2516 | - let _ = std::fs::write(path, out); | ||
| 2517 | -} | ||
| 2518 | - | ||
| 2519 | /// 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 |
| 2520 | /// tile reconstruction and before [`apply_cdef`]. Uniform-level path only -- | 2492 | /// tile reconstruction and before [`apply_cdef`]. Uniform-level path only -- |
| 2521 | /// `stream.rs` already refuses `delta_lf_present`/segmentation upstream, so | 2493 | /// `stream.rs` already refuses `delta_lf_present`/segmentation upstream, so |
| @@ -3619,7 +3591,6 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | |||
| 3619 | } | 3591 | } |
| 3620 | } | 3592 | } |
| 3621 | 3593 | ||
| 3622 | - scratch_dump_prefilt(&y, &u, &v); | ||
| 3623 | apply_deblock(&mut y, &mut u, &mut v, loop_filter, &neighbours); | 3594 | apply_deblock(&mut y, &mut u, &mut v, loop_filter, &neighbours); |
| 3624 | apply_cdef(&mut y, &mut u, &mut v, cdef, &neighbours); | 3595 | apply_cdef(&mut y, &mut u, &mut v, cdef, &neighbours); |
| 3625 | 3596 | ||
| @@ -3902,12 +3873,6 @@ fn read_inter_plane( | |||
| 3902 | default_tx_type, | 3873 | default_tx_type, |
| 3903 | )?; | 3874 | )?; |
| 3904 | 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); |
| 3905 | - if std::env::var_os("EC_AV1_CHROMA_TRACE").is_some() && x == 16 && y == 24 && plane_idx != 0 { | ||
| 3906 | - eprintln!( | ||
| 3907 | - "CHROMA_TRACE plane={plane_idx} x={x} y={y} side={side} tx_type={tx_type:?} \ | ||
| 3908 | - q_idx={base_q_idx} grid={grid:?} pred={prediction:?} residual={residual:?}" | ||
| 3909 | - ); | ||
| 3910 | - } | ||
| 3911 | plane.reconstruct_mc(x, y, side, prediction, &residual); | 3876 | plane.reconstruct_mc(x, y, side, prediction, &residual); |
| 3912 | Ok((grid, tx_type)) | 3877 | Ok((grid, tx_type)) |
| 3913 | } | 3878 | } |
| @@ -4874,7 +4839,8 @@ fn decode_inter_block( | |||
| 4874 | v_grid = vec![0i32; chroma_side * chroma_side]; | 4839 | v_grid = vec![0i32; chroma_side * chroma_side]; |
| 4875 | } else { | 4840 | } else { |
| 4876 | let around = neighbours.around(at, side); | 4841 | let around = neighbours.around(at, side); |
| 4877 | - luma_grid = read_inter_plane( | 4842 | + let luma_tx_type; |
| 4843 | + (luma_grid, luma_tx_type) = read_inter_plane( | ||
| 4878 | dec, | 4844 | dec, |
| 4879 | cdfs, | 4845 | cdfs, |
| 4880 | luma_set_inter, | 4846 | luma_set_inter, |
| @@ -4888,6 +4854,7 @@ fn decode_inter_block( | |||
| 4888 | side, | 4854 | side, |
| 4889 | base_q_idx, | 4855 | base_q_idx, |
| 4890 | &pred_y, | 4856 | &pred_y, |
| 4857 | + None, | ||
| 4891 | )?; | 4858 | )?; |
| 4892 | u_grid = read_inter_plane( | 4859 | u_grid = read_inter_plane( |
| 4893 | dec, | 4860 | dec, |
| @@ -4903,7 +4870,9 @@ fn decode_inter_block( | |||
| 4903 | chroma_side, | 4870 | chroma_side, |
| 4904 | base_q_idx, | 4871 | base_q_idx, |
| 4905 | &pred_u, | 4872 | &pred_u, |
| 4906 | - )?; | 4873 | + Some(luma_tx_type), |
| 4874 | + )? | ||
| 4875 | + .0; | ||
| 4907 | v_grid = read_inter_plane( | 4876 | v_grid = read_inter_plane( |
| 4908 | dec, | 4877 | dec, |
| 4909 | cdfs, | 4878 | cdfs, |
| @@ -4918,7 +4887,9 @@ fn decode_inter_block( | |||
| 4918 | chroma_side, | 4887 | chroma_side, |
| 4919 | base_q_idx, | 4888 | base_q_idx, |
| 4920 | &pred_v, | 4889 | &pred_v, |
| 4921 | - )?; | 4890 | + Some(luma_tx_type), |
| 4891 | + )? | ||
| 4892 | + .0; | ||
| 4922 | } | 4893 | } |
| 4923 | } else { | 4894 | } else { |
| 4924 | let ref_frame = | 4895 | let ref_frame = |
| @@ -5166,7 +5137,8 @@ fn decode_inter_block( | |||
| 5166 | v_grid = vec![0i32; chroma_side * chroma_side]; | 5137 | v_grid = vec![0i32; chroma_side * chroma_side]; |
| 5167 | } else { | 5138 | } else { |
| 5168 | let around = neighbours.around(at, side); | 5139 | let around = neighbours.around(at, side); |
| 5169 | - luma_grid = read_inter_plane( | 5140 | + let luma_tx_type; |
| 5141 | + (luma_grid, luma_tx_type) = read_inter_plane( | ||
| 5170 | dec, | 5142 | dec, |
| 5171 | cdfs, | 5143 | cdfs, |
| 5172 | luma_set_inter, | 5144 | luma_set_inter, |
| @@ -5180,6 +5152,7 @@ fn decode_inter_block( | |||
| 5180 | side, | 5152 | side, |
| 5181 | base_q_idx, | 5153 | base_q_idx, |
| 5182 | &pred_y, | 5154 | &pred_y, |
| 5155 | + None, | ||
| 5183 | )?; | 5156 | )?; |
| 5184 | u_grid = read_inter_plane( | 5157 | u_grid = read_inter_plane( |
| 5185 | dec, | 5158 | dec, |
| @@ -5195,7 +5168,9 @@ fn decode_inter_block( | |||
| 5195 | chroma_side, | 5168 | chroma_side, |
| 5196 | base_q_idx, | 5169 | base_q_idx, |
| 5197 | &pred_u, | 5170 | &pred_u, |
| 5198 | - )?; | 5171 | + Some(luma_tx_type), |
| 5172 | + )? | ||
| 5173 | + .0; | ||
| 5199 | v_grid = read_inter_plane( | 5174 | v_grid = read_inter_plane( |
| 5200 | dec, | 5175 | dec, |
| 5201 | cdfs, | 5176 | cdfs, |
| @@ -5210,7 +5185,9 @@ fn decode_inter_block( | |||
| 5210 | chroma_side, | 5185 | chroma_side, |
| 5211 | base_q_idx, | 5186 | base_q_idx, |
| 5212 | &pred_v, | 5187 | &pred_v, |
| 5213 | - )?; | 5188 | + Some(luma_tx_type), |
| 5189 | + )? | ||
| 5190 | + .0; | ||
| 5214 | } | 5191 | } |
| 5215 | } | 5192 | } |
| 5216 | } else { | 5193 | } else { |
| @@ -5764,7 +5741,8 @@ fn decode_inter_block8( | |||
| 5764 | v_grid = vec![0i32; CHROMA_SIDE * CHROMA_SIDE]; | 5741 | v_grid = vec![0i32; CHROMA_SIDE * CHROMA_SIDE]; |
| 5765 | } else { | 5742 | } else { |
| 5766 | let around = neighbours.around_mi(leaf_mi, 8); | 5743 | let around = neighbours.around_mi(leaf_mi, 8); |
| 5767 | - luma_grid = read_inter_plane( | 5744 | + let luma_tx_type; |
| 5745 | + (luma_grid, luma_tx_type) = read_inter_plane( | ||
| 5768 | dec, | 5746 | dec, |
| 5769 | cdfs, | 5747 | cdfs, |
| 5770 | if reduced_tx_set { | 5748 | if reduced_tx_set { |
| @@ -5782,6 +5760,7 @@ fn decode_inter_block8( | |||
| 5782 | SIDE, | 5760 | SIDE, |
| 5783 | base_q_idx, | 5761 | base_q_idx, |
| 5784 | &pred_y, | 5762 | &pred_y, |
| 5763 | + None, | ||
| 5785 | )?; | 5764 | )?; |
| 5786 | u_grid = read_inter_plane( | 5765 | u_grid = read_inter_plane( |
| 5787 | dec, | 5766 | dec, |
| @@ -5797,7 +5776,9 @@ fn decode_inter_block8( | |||
| 5797 | CHROMA_SIDE, | 5776 | CHROMA_SIDE, |
| 5798 | base_q_idx, | 5777 | base_q_idx, |
| 5799 | &pred_u, | 5778 | &pred_u, |
| 5800 | - )?; | 5779 | + Some(luma_tx_type), |
| 5780 | + )? | ||
| 5781 | + .0; | ||
| 5801 | v_grid = read_inter_plane( | 5782 | v_grid = read_inter_plane( |
| 5802 | dec, | 5783 | dec, |
| 5803 | cdfs, | 5784 | cdfs, |
| @@ -5812,7 +5793,9 @@ fn decode_inter_block8( | |||
| 5812 | CHROMA_SIDE, | 5793 | CHROMA_SIDE, |
| 5813 | base_q_idx, | 5794 | base_q_idx, |
| 5814 | &pred_v, | 5795 | &pred_v, |
| 5815 | - )?; | 5796 | + Some(luma_tx_type), |
| 5797 | + )? | ||
| 5798 | + .0; | ||
| 5816 | } | 5799 | } |
| 5817 | return Ok((skip, is_inter, skip_mode, compound_ctx8)); | 5800 | return Ok((skip, is_inter, skip_mode, compound_ctx8)); |
| 5818 | } | 5801 | } |
| @@ -5962,7 +5945,8 @@ fn decode_inter_block8( | |||
| 5962 | v_grid = vec![0i32; CHROMA_SIDE * CHROMA_SIDE]; | 5945 | v_grid = vec![0i32; CHROMA_SIDE * CHROMA_SIDE]; |
| 5963 | } else { | 5946 | } else { |
| 5964 | let around = neighbours.around_mi(leaf_mi, 8); | 5947 | let around = neighbours.around_mi(leaf_mi, 8); |
| 5965 | - luma_grid = read_inter_plane( | 5948 | + let luma_tx_type; |
| 5949 | + (luma_grid, luma_tx_type) = read_inter_plane( | ||
| 5966 | dec, | 5950 | dec, |
| 5967 | cdfs, | 5951 | cdfs, |
| 5968 | if reduced_tx_set { | 5952 | if reduced_tx_set { |
| @@ -5980,6 +5964,7 @@ fn decode_inter_block8( | |||
| 5980 | SIDE, | 5964 | SIDE, |
| 5981 | base_q_idx, | 5965 | base_q_idx, |
| 5982 | &pred_y, | 5966 | &pred_y, |
| 5967 | + None, | ||
| 5983 | )?; | 5968 | )?; |
| 5984 | u_grid = read_inter_plane( | 5969 | u_grid = read_inter_plane( |
| 5985 | dec, | 5970 | dec, |
| @@ -5995,7 +5980,9 @@ fn decode_inter_block8( | |||
| 5995 | CHROMA_SIDE, | 5980 | CHROMA_SIDE, |
| 5996 | base_q_idx, | 5981 | base_q_idx, |
| 5997 | &pred_u, | 5982 | &pred_u, |
| 5998 | - )?; | 5983 | + Some(luma_tx_type), |
| 5984 | + )? | ||
| 5985 | + .0; | ||
| 5999 | v_grid = read_inter_plane( | 5986 | v_grid = read_inter_plane( |
| 6000 | dec, | 5987 | dec, |
| 6001 | cdfs, | 5988 | cdfs, |
| @@ -6010,7 +5997,9 @@ fn decode_inter_block8( | |||
| 6010 | CHROMA_SIDE, | 5997 | CHROMA_SIDE, |
| 6011 | base_q_idx, | 5998 | base_q_idx, |
| 6012 | &pred_v, | 5999 | &pred_v, |
| 6013 | - )?; | 6000 | + Some(luma_tx_type), |
| 6001 | + )? | ||
| 6002 | + .0; | ||
| 6014 | } | 6003 | } |
| 6015 | } else { | 6004 | } else { |
| 6016 | let mode = dec.symbol(&mut cdfs.y_mode[SIZE_GROUP_8]); | 6005 | let mode = dec.symbol(&mut cdfs.y_mode[SIZE_GROUP_8]); |
| @@ -6657,7 +6646,6 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 6657 | } | 6646 | } |
| 6658 | } | 6647 | } |
| 6659 | 6648 | ||
| 6660 | - scratch_dump_prefilt(&y, &u, &v); | ||
| 6661 | apply_deblock(&mut y, &mut u, &mut v, loop_filter, &neighbours); | 6649 | apply_deblock(&mut y, &mut u, &mut v, loop_filter, &neighbours); |
| 6662 | apply_cdef(&mut y, &mut u, &mut v, cdef, &neighbours); | 6650 | apply_cdef(&mut y, &mut u, &mut v, cdef, &neighbours); |
| 6663 | 6651 | ||