forge
Explore
Log in

Don't you dare go Hollow

Inter chroma tx_type inherits colocated luma's coded type

Browse files at this commit

752b1efcc8129303e06feb6a4eb087c43e2a4714Ahmet Kaan GümüşParent: 74c4dbd
  • fix
    • inter chroma tx_type inherits colocated luma's coded type
Show full message
fix(av1): inter chroma tx_type inherits colocated luma's coded type

read_inter_plane now takes inherited_luma_tx_type: Option<TxType> and
threads the luma call's coded tx_type through to both chroma calls at
all 4 inter block-decode call sites (leaf16 compound/single, leaf8
compound/single), matching libaom av1_get_tx_type: an inter block's
chroma plane never codes its own tx_type symbol but inherits the
colocated luma transform's type verbatim (DCT_DCT-clamped at side>=32).
Fixes the delta-1 U-only pin mismatch on cdfflake-stream-seed45.bin,
now 4/4 frames all-plane byte-exact x3.

Also removes the scratch_dump_prefilt/EC_AV1_PREFILT_DUMP_OURS bisect
helper and EC_AV1_CHROMA_TRACE eprintln used to isolate this, keeping
the standing scratch_isolate_pinned_mismatch pin tool.
crates/ec-av1/src/decode.rsmodified+36 -48
@@ -2488,34 +2488,6 @@ fn cdef_filter_block(
24882488 }
24892489 }
24902490
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-
25192491 /// Spec 7.14: the in-loop deblocking filter, applied once per frame after
25202492 /// tile reconstruction and before [`apply_cdef`]. Uniform-level path only --
25212493 /// `stream.rs` already refuses `delta_lf_present`/segmentation upstream, so
@@ -3619,7 +3591,6 @@ pub(crate) fn decode_key_frame_tile_with_cdfs(
36193591 }
36203592 }
36213593
3622- scratch_dump_prefilt(&y, &u, &v);
36233594 apply_deblock(&mut y, &mut u, &mut v, loop_filter, &neighbours);
36243595 apply_cdef(&mut y, &mut u, &mut v, cdef, &neighbours);
36253596
@@ -3902,12 +3873,6 @@ fn read_inter_plane(
39023873 default_tx_type,
39033874 )?;
39043875 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- }
39113876 plane.reconstruct_mc(x, y, side, prediction, &residual);
39123877 Ok((grid, tx_type))
39133878 }
@@ -4874,7 +4839,8 @@ fn decode_inter_block(
48744839 v_grid = vec![0i32; chroma_side * chroma_side];
48754840 } else {
48764841 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(
48784844 dec,
48794845 cdfs,
48804846 luma_set_inter,
@@ -4888,6 +4854,7 @@ fn decode_inter_block(
48884854 side,
48894855 base_q_idx,
48904856 &pred_y,
4857+ None,
48914858 )?;
48924859 u_grid = read_inter_plane(
48934860 dec,
@@ -4903,7 +4870,9 @@ fn decode_inter_block(
49034870 chroma_side,
49044871 base_q_idx,
49054872 &pred_u,
4906- )?;
4873+ Some(luma_tx_type),
4874+ )?
4875+ .0;
49074876 v_grid = read_inter_plane(
49084877 dec,
49094878 cdfs,
@@ -4918,7 +4887,9 @@ fn decode_inter_block(
49184887 chroma_side,
49194888 base_q_idx,
49204889 &pred_v,
4921- )?;
4890+ Some(luma_tx_type),
4891+ )?
4892+ .0;
49224893 }
49234894 } else {
49244895 let ref_frame =
@@ -5166,7 +5137,8 @@ fn decode_inter_block(
51665137 v_grid = vec![0i32; chroma_side * chroma_side];
51675138 } else {
51685139 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(
51705142 dec,
51715143 cdfs,
51725144 luma_set_inter,
@@ -5180,6 +5152,7 @@ fn decode_inter_block(
51805152 side,
51815153 base_q_idx,
51825154 &pred_y,
5155+ None,
51835156 )?;
51845157 u_grid = read_inter_plane(
51855158 dec,
@@ -5195,7 +5168,9 @@ fn decode_inter_block(
51955168 chroma_side,
51965169 base_q_idx,
51975170 &pred_u,
5198- )?;
5171+ Some(luma_tx_type),
5172+ )?
5173+ .0;
51995174 v_grid = read_inter_plane(
52005175 dec,
52015176 cdfs,
@@ -5210,7 +5185,9 @@ fn decode_inter_block(
52105185 chroma_side,
52115186 base_q_idx,
52125187 &pred_v,
5213- )?;
5188+ Some(luma_tx_type),
5189+ )?
5190+ .0;
52145191 }
52155192 }
52165193 } else {
@@ -5764,7 +5741,8 @@ fn decode_inter_block8(
57645741 v_grid = vec![0i32; CHROMA_SIDE * CHROMA_SIDE];
57655742 } else {
57665743 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(
57685746 dec,
57695747 cdfs,
57705748 if reduced_tx_set {
@@ -5782,6 +5760,7 @@ fn decode_inter_block8(
57825760 SIDE,
57835761 base_q_idx,
57845762 &pred_y,
5763+ None,
57855764 )?;
57865765 u_grid = read_inter_plane(
57875766 dec,
@@ -5797,7 +5776,9 @@ fn decode_inter_block8(
57975776 CHROMA_SIDE,
57985777 base_q_idx,
57995778 &pred_u,
5800- )?;
5779+ Some(luma_tx_type),
5780+ )?
5781+ .0;
58015782 v_grid = read_inter_plane(
58025783 dec,
58035784 cdfs,
@@ -5812,7 +5793,9 @@ fn decode_inter_block8(
58125793 CHROMA_SIDE,
58135794 base_q_idx,
58145795 &pred_v,
5815- )?;
5796+ Some(luma_tx_type),
5797+ )?
5798+ .0;
58165799 }
58175800 return Ok((skip, is_inter, skip_mode, compound_ctx8));
58185801 }
@@ -5962,7 +5945,8 @@ fn decode_inter_block8(
59625945 v_grid = vec![0i32; CHROMA_SIDE * CHROMA_SIDE];
59635946 } else {
59645947 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(
59665950 dec,
59675951 cdfs,
59685952 if reduced_tx_set {
@@ -5980,6 +5964,7 @@ fn decode_inter_block8(
59805964 SIDE,
59815965 base_q_idx,
59825966 &pred_y,
5967+ None,
59835968 )?;
59845969 u_grid = read_inter_plane(
59855970 dec,
@@ -5995,7 +5980,9 @@ fn decode_inter_block8(
59955980 CHROMA_SIDE,
59965981 base_q_idx,
59975982 &pred_u,
5998- )?;
5983+ Some(luma_tx_type),
5984+ )?
5985+ .0;
59995986 v_grid = read_inter_plane(
60005987 dec,
60015988 cdfs,
@@ -6010,7 +5997,9 @@ fn decode_inter_block8(
60105997 CHROMA_SIDE,
60115998 base_q_idx,
60125999 &pred_v,
6013- )?;
6000+ Some(luma_tx_type),
6001+ )?
6002+ .0;
60146003 }
60156004 } else {
60166005 let mode = dec.symbol(&mut cdfs.y_mode[SIZE_GROUP_8]);
@@ -6657,7 +6646,6 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
66576646 }
66586647 }
66596648
6660- scratch_dump_prefilt(&y, &u, &v);
66616649 apply_deblock(&mut y, &mut u, &mut v, loop_filter, &neighbours);
66626650 apply_cdef(&mut y, &mut u, &mut v, cdef, &neighbours);
66636651