av1ibcvtx: lift the intrabc mixed var-tx leaf refusal
Browse files at this commit50f12470fc33d99febfef5c01ba234464d878575Parent: e32630c5 changed files +473 -79
- crates/ec-av1/examples/decode_probe.rs +8 -0
- crates/ec-av1/src/decode.rs +114 -36
- crates/ec-av1/src/refusal_inventory.rs +132 -35
- crates/ec-av1/src/stream.rs +103 -8
- lanes/av1ibcvtx.report.md +116 -0
crates/ec-av1/examples/decode_probe.rsmodified+8 -0
| @@ -54,6 +54,14 @@ fn main() { | |||
| 54 | ec_av1::stream::leaf8_intrabc_hits() | 54 | ec_av1::stream::leaf8_intrabc_hits() |
| 55 | ); | 55 | ); |
| 56 | println!("intrabc_hits: {}", ec_av1::stream::intrabc_hits()); | 56 | println!("intrabc_hits: {}", ec_av1::stream::intrabc_hits()); |
| 57 | + println!( | ||
| 58 | + "intrabc_vartx_trees: {}", | ||
| 59 | + ec_av1::decode::intrabc_vartx_hits() | ||
| 60 | + ); | ||
| 61 | + println!( | ||
| 62 | + "intrabc_vartx_mixed_leaves: {}", | ||
| 63 | + ec_av1::decode::intrabc_vartx_mixed_leaves_hits() | ||
| 64 | + ); | ||
| 57 | println!( | 65 | println!( |
| 58 | "skipped_intrabc_chroma_arm_hits: {}", | 66 | "skipped_intrabc_chroma_arm_hits: {}", |
| 59 | ec_av1::stream::skipped_intrabc_chroma_arm_hits() | 67 | ec_av1::stream::skipped_intrabc_chroma_arm_hits() |
crates/ec-av1/src/decode.rsmodified+114 -36
| @@ -3745,6 +3745,10 @@ thread_local! { | |||
| 3745 | /// var-tx partition tree (unskipped, `TX_MODE_SELECT`) -- the capability | 3745 | /// var-tx partition tree (unskipped, `TX_MODE_SELECT`) -- the capability |
| 3746 | /// that replaced the refusal "an intrabc block under TxMode::Select". | 3746 | /// that replaced the refusal "an intrabc block under TxMode::Select". |
| 3747 | static INTRABC_VARTX_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | 3747 | static INTRABC_VARTX_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; |
| 3748 | + /// lane-av1-ibcvtx: intrabc var-tx trees that resolved to MIXED leaf | ||
| 3749 | + /// sizes (not one square size across every leaf) -- the engagement | ||
| 3750 | + /// counter proving a witness actually exercises the per-leaf reconstruct. | ||
| 3751 | + static INTRABC_VARTX_MIXED_LEAVES_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | ||
| 3748 | /// lane-av1txr: as above for a `BLOCK_4X8`/`BLOCK_8X4` intrabc leaf -- | 3752 | /// lane-av1txr: as above for a `BLOCK_4X8`/`BLOCK_8X4` intrabc leaf -- |
| 3749 | /// libaom's `block_signals_txsize` is `bsize > BLOCK_4X4`, so these leaves | 3753 | /// libaom's `block_signals_txsize` is `bsize > BLOCK_4X4`, so these leaves |
| 3750 | /// signal a transform size where a plain `BLOCK_4X4` does not. Reading no | 3754 | /// signal a transform size where a plain `BLOCK_4X4` does not. Reading no |
| @@ -3811,17 +3815,28 @@ pub fn intrabc_rect_vartx_hits() -> usize { | |||
| 3811 | } | 3815 | } |
| 3812 | 3816 | ||
| 3813 | /// Current value of [`INTRABC_VARTX_HITS`]. | 3817 | /// Current value of [`INTRABC_VARTX_HITS`]. |
| 3814 | -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates | 3818 | +pub fn intrabc_vartx_hits() -> usize { |
| 3815 | -pub(crate) fn intrabc_vartx_hits() -> usize { | ||
| 3816 | INTRABC_VARTX_HITS.with(|c| c.get()) | 3819 | INTRABC_VARTX_HITS.with(|c| c.get()) |
| 3817 | } | 3820 | } |
| 3818 | 3821 | ||
| 3822 | +/// Current value of [`INTRABC_VARTX_MIXED_LEAVES_HITS`]. | ||
| 3823 | +pub fn intrabc_vartx_mixed_leaves_hits() -> usize { | ||
| 3824 | + INTRABC_VARTX_MIXED_LEAVES_HITS.with(|c| c.get()) | ||
| 3825 | +} | ||
| 3826 | + | ||
| 3819 | /// Zeroes [`INTRABC_VARTX_HITS`] (gate tests call this before a decode). | 3827 | /// Zeroes [`INTRABC_VARTX_HITS`] (gate tests call this before a decode). |
| 3820 | #[allow(dead_code)] // read only from the `#[cfg(test)]` gates | 3828 | #[allow(dead_code)] // read only from the `#[cfg(test)]` gates |
| 3821 | pub(crate) fn reset_intrabc_vartx_hits() { | 3829 | pub(crate) fn reset_intrabc_vartx_hits() { |
| 3822 | INTRABC_VARTX_HITS.with(|c| c.set(0)); | 3830 | INTRABC_VARTX_HITS.with(|c| c.set(0)); |
| 3823 | } | 3831 | } |
| 3824 | 3832 | ||
| 3833 | +/// Zeroes [`INTRABC_VARTX_MIXED_LEAVES_HITS`] (gate tests call this before a | ||
| 3834 | +/// decode). | ||
| 3835 | +#[allow(dead_code)] // read only from the `#[cfg(test)]` gates | ||
| 3836 | +pub(crate) fn reset_intrabc_vartx_mixed_leaves_hits() { | ||
| 3837 | + INTRABC_VARTX_MIXED_LEAVES_HITS.with(|c| c.set(0)); | ||
| 3838 | +} | ||
| 3839 | + | ||
| 3825 | /// Current value of [`RECT_INTRABC_VARTX_HITS`]. | 3840 | /// Current value of [`RECT_INTRABC_VARTX_HITS`]. |
| 3826 | #[allow(dead_code)] // read only from the `#[cfg(test)]` gates | 3841 | #[allow(dead_code)] // read only from the `#[cfg(test)]` gates |
| 3827 | pub fn rect_intrabc_vartx_hits() -> usize { | 3842 | pub fn rect_intrabc_vartx_hits() -> usize { |
| @@ -15671,23 +15686,31 @@ fn decode_block( | |||
| 15671 | } | 15686 | } |
| 15672 | } | 15687 | } |
| 15673 | hit!(INTRABC_VARTX_HITS); | 15688 | hit!(INTRABC_VARTX_HITS); |
| 15674 | - // The luma reconstruct loop below is a UNIFORM grid of one square | 15689 | + // lane-t900 r33 census: the t900 recipes resolved every tree UNIFORM. |
| 15675 | - // transform (the intra `tx_depth` shape), so a tree that resolved to | 15690 | + // lane-av1-ibcvtx: a tree that resolved to mixed leaf sizes is no |
| 15676 | - // mixed leaf sizes is refused by name rather than reconstructed at the | 15691 | + // longer refused -- the luma reconstruct below walks the tree's own |
| 15677 | - // wrong stride. | 15692 | + // leaf list per leaf (libaom `decode_token_recon_block`, whose token |
| 15693 | + // loop reconstructs whatever `read_tx_size_vartx` resolved, per | ||
| 15694 | + // transform unit), so mixed sizes reconstruct at their own stride. | ||
| 15695 | + // The counter marks the shape so a gate can prove a witness actually | ||
| 15696 | + // carries a mixed tree and not merely another uniform one. | ||
| 15678 | let uniform = leaves | 15697 | let uniform = leaves |
| 15679 | .first() | 15698 | .first() |
| 15680 | .is_some_and(|f| leaves.iter().all(|l| (l.2, l.3) == (f.2, f.3) && l.2 == l.3)); | 15699 | .is_some_and(|f| leaves.iter().all(|l| (l.2, l.3) == (f.2, f.3) && l.2 == l.3)); |
| 15681 | if !uniform { | 15700 | if !uniform { |
| 15682 | - return Err(unsupported( | 15701 | + hit!(INTRABC_VARTX_MIXED_LEAVES_HITS); |
| 15683 | - "an intrabc block whose var-tx tree resolved to mixed leaf transform sizes", | 15702 | + if crate::envflags::env_flag!("EC_AV1_IBCVTX_DEBUG") { |
| 15684 | - )); | 15703 | + eprintln!( |
| 15704 | + "IBCVTX mixed intrabc tree mi=({mi_r},{mi_c}) side={side} \ | ||
| 15705 | + dv={intrabc_dv:?} leaves={leaves:?}" | ||
| 15706 | + ); | ||
| 15685 | } | 15707 | } |
| 15686 | - Some(leaves[0].2) | 15708 | + } |
| 15709 | + Some(leaves) | ||
| 15687 | } else { | 15710 | } else { |
| 15688 | None | 15711 | None |
| 15689 | }; | 15712 | }; |
| 15690 | - let (logical_tx, coeff_tx_side) = if let Some(tx) = intrabc_leaves { | 15713 | + let (logical_tx, coeff_tx_side) = if let Some(tx) = intrabc_leaves.as_ref().map(|l| l[0].2) { |
| 15691 | (tx, if tx == 64 { 32 } else { tx }) | 15714 | (tx, if tx == 64 { 32 } else { tx }) |
| 15692 | } else if tx_select && !intrabc_skip_tx { | 15715 | } else if tx_select && !intrabc_skip_tx { |
| 15693 | let resolved = read_tx_size(dec, cdfs, neighbours, (mi_r, mi_c), side); | 15716 | let resolved = read_tx_size(dec, cdfs, neighbours, (mi_r, mi_c), side); |
| @@ -16055,25 +16078,54 @@ fn decode_block( | |||
| 16055 | let chroma_ctx_offset = if cn > 1 { Some(3) } else { None }; | 16078 | let chroma_ctx_offset = if cn > 1 { Some(3) } else { None }; |
| 16056 | let tpc = (n_axis / nchunk).max(1); | 16079 | let tpc = (n_axis / nchunk).max(1); |
| 16057 | let cpc = (cn / nchunk).max(1); | 16080 | let cpc = (cn / nchunk).max(1); |
| 16081 | + // The block's luma transform units, raster order inside each mu | ||
| 16082 | + // chunk. lane-av1-ibcvtx: an intrabc block's units are the var-tx | ||
| 16083 | + // tree's own leaf list -- mixed sizes included, exactly what libaom's | ||
| 16084 | + // `decode_token_recon_block` token loop reconstructs (one | ||
| 16085 | + // `av1_read_coeffs_txb` + inverse transform per resolved unit) -- | ||
| 16086 | + // while every other block's list is the uniform `logical_tx` grid | ||
| 16087 | + // this loop has always walked, generated here in the same order. | ||
| 16088 | + let mut chunk_tus: Vec<Vec<(usize, usize, usize)>> = vec![Vec::new(); nchunk * nchunk]; | ||
| 16089 | + if let Some(leaves) = &intrabc_leaves { | ||
| 16090 | + for &(lr, lc, tw, _th) in leaves { | ||
| 16091 | + let (off_y, off_x) = (lr * MI, lc * MI); | ||
| 16092 | + chunk_tus[(off_y / 64) * nchunk + (off_x / 64)].push((off_y, off_x, tw)); | ||
| 16093 | + } | ||
| 16094 | + } else { | ||
| 16095 | + for tu_row in 0..n_axis { | ||
| 16096 | + for tu_col in 0..n_axis { | ||
| 16097 | + chunk_tus[(tu_row / tpc) * nchunk + (tu_col / tpc)].push(( | ||
| 16098 | + tu_row * logical_tx, | ||
| 16099 | + tu_col * logical_tx, | ||
| 16100 | + logical_tx, | ||
| 16101 | + )); | ||
| 16102 | + } | ||
| 16103 | + } | ||
| 16104 | + } | ||
| 16058 | let mut last_grids = [Grid::Zero(0), Grid::Zero(0)]; | 16105 | let mut last_grids = [Grid::Zero(0), Grid::Zero(0)]; |
| 16059 | let mut units: Vec<((usize, usize), usize, Grid, Grid)> = Vec::new(); | 16106 | let mut units: Vec<((usize, usize), usize, Grid, Grid)> = Vec::new(); |
| 16060 | for ch_row in 0..nchunk { | 16107 | for ch_row in 0..nchunk { |
| 16061 | for ch_col in 0..nchunk { | 16108 | for ch_col in 0..nchunk { |
| 16062 | - for tu_row in ch_row * tpc..(ch_row + 1) * tpc { | 16109 | + // lane-av1-ibcvtx: the chunk's chroma units inherit the CHROMA tx |
| 16063 | - for tu_col in ch_col * tpc..(ch_col + 1) * tpc { | 16110 | + // type of the co-located luma position (`av1_get_tx_type`, |
| 16064 | - let tu_mi = ( | 16111 | + // blockd.h:1278: a non-Y plane of an inter-classified block -- and |
| 16065 | - mi_r + tu_row * (logical_tx / MI), | 16112 | + // intrabc is one -- reads `tx_type_map`, i.e. the coded type of the |
| 16066 | - mi_c + tu_col * (logical_tx / MI), | 16113 | + // luma unit covering it). Inside a mu chunk that is the chunk's |
| 16067 | - ); | 16114 | + // FIRST luma unit in raster order (the chunk origin is always the |
| 16068 | - let tu_px = px + tu_col * logical_tx; | 16115 | + // first leaf's own origin). Captured right after that unit's read; |
| 16069 | - let tu_py = py + tu_row * logical_tx; | 16116 | + // the single-TU arm below does the same for a whole-block unit. |
| 16117 | + let mut first_leaf_tx: Option<TxType> = None; | ||
| 16118 | + for &(tu_off_y, tu_off_x, tu_tx) in &chunk_tus[ch_row * nchunk + ch_col] { | ||
| 16119 | + let tu_mi = (mi_r + tu_off_y / MI, mi_c + tu_off_x / MI); | ||
| 16120 | + let tu_px = px + tu_off_x; | ||
| 16121 | + let tu_py = py + tu_off_y; | ||
| 16070 | // Same libaom clip as `decode_rect_split`'s loop above; a | 16122 | // Same libaom clip as `decode_rect_split`'s loop above; a |
| 16071 | // square block only hangs off the frame when the frame's mi | 16123 | // square block only hangs off the frame when the frame's mi |
| 16072 | // dimensions are odd at the block's own level. | 16124 | // dimensions are odd at the block's own level. |
| 16073 | if tu_px >= y.true_width || tu_py >= y.true_height { | 16125 | if tu_px >= y.true_width || tu_py >= y.true_height { |
| 16074 | continue; | 16126 | continue; |
| 16075 | } | 16127 | } |
| 16076 | - let tu_around = neighbours.around_mi(tu_mi, logical_tx)[0]; | 16128 | + let tu_around = neighbours.around_mi(tu_mi, tu_tx)[0]; |
| 16077 | // A transform unit inside a block is NOT a block at that | 16129 | // A transform unit inside a block is NOT a block at that |
| 16078 | // position (lane-palette2 r12): `Reach::of` granted the | 16130 | // position (lane-palette2 r12): `Reach::of` granted the |
| 16079 | // top-right 8x8 unit of a 16x16 D203 block bottom-left | 16131 | // top-right 8x8 unit of a 16x16 D203 block bottom-left |
| @@ -16082,35 +16134,48 @@ fn decode_block( | |||
| 16082 | let tu_reach = tu_reach( | 16134 | let tu_reach = tu_reach( |
| 16083 | side, | 16135 | side, |
| 16084 | side, | 16136 | side, |
| 16085 | - tu_col * logical_tx, | 16137 | + tu_off_x, |
| 16086 | - tu_row * logical_tx, | 16138 | + tu_off_y, |
| 16087 | - logical_tx, | 16139 | + tu_tx, |
| 16088 | reach, | 16140 | reach, |
| 16089 | px, | 16141 | px, |
| 16090 | py, | 16142 | py, |
| 16091 | y.width, | 16143 | y.width, |
| 16092 | y.height, fctx, | 16144 | y.height, fctx, |
| 16093 | ); | 16145 | ); |
| 16094 | - // This transform unit's own bsize (`logical_tx`) is smaller | 16146 | + // This transform unit's own bsize (`tu_tx`) is smaller |
| 16095 | // than the block it sits in (`side`), so `txb_skip_ctx` is | 16147 | // than the block it sits in (`side`), so `txb_skip_ctx` is |
| 16096 | // the neighbour-magnitude table, not the lone-TU 0 (spec | 16148 | // the neighbour-magnitude table, not the lone-TU 0 (spec |
| 16097 | // `get_txb_ctx_general`'s `plane_bsize != tx_size` branch). | 16149 | // `get_txb_ctx_general`'s `plane_bsize != tx_size` branch). |
| 16098 | - let tu_skip_ctx = neighbours.luma_skip_ctx(tu_mi, logical_tx / MI); | 16150 | + let tu_skip_ctx = neighbours.luma_skip_ctx(tu_mi, tu_tx / MI); |
| 16151 | + // An intrabc unit's CDF set and scan follow the unit's OWN | ||
| 16152 | + // resolved size (`get_txsize_entropy_ctx` / | ||
| 16153 | + // `av1_get_scan` per `av1_read_coeffs_txb` call); the | ||
| 16154 | + // uniform grid's precomputed pair already matches because | ||
| 16155 | + // `tu_tx == logical_tx` there. | ||
| 16156 | + let (tu_set, tu_scan) = if intrabc_dv.is_some() { | ||
| 16157 | + ( | ||
| 16158 | + inter_txbset_for(tu_tx, reduced_tx_set), | ||
| 16159 | + scan_for(if tu_tx == 64 { 32 } else { tu_tx }, scan32, scan16, scan8, scan4), | ||
| 16160 | + ) | ||
| 16161 | + } else { | ||
| 16162 | + (luma_set, luma_scan) | ||
| 16163 | + }; | ||
| 16099 | if let Some(buf) = &palette_y_buf { | 16164 | if let Some(buf) = &palette_y_buf { |
| 16100 | hit!(PALETTE_SPLIT_TX_HITS); | 16165 | hit!(PALETTE_SPLIT_TX_HITS); |
| 16101 | - let mut window = vec![0u16; logical_tx * logical_tx]; | 16166 | + let mut window = vec![0u16; tu_tx * tu_tx]; |
| 16102 | - for row in 0..logical_tx { | 16167 | + for row in 0..tu_tx { |
| 16103 | - let src = (tu_row * logical_tx + row) * side + tu_col * logical_tx; | 16168 | + let src = (tu_off_y + row) * side + tu_off_x; |
| 16104 | - window[row * logical_tx..][..logical_tx] | 16169 | + window[row * tu_tx..][..tu_tx] |
| 16105 | - .copy_from_slice(&buf[src..][..logical_tx]); | 16170 | + .copy_from_slice(&buf[src..][..tu_tx]); |
| 16106 | } | 16171 | } |
| 16107 | set_palette_pred(window, fctx); | 16172 | set_palette_pred(window, fctx); |
| 16108 | } | 16173 | } |
| 16109 | let tu_grid = read_plane( | 16174 | let tu_grid = read_plane( |
| 16110 | dec, | 16175 | dec, |
| 16111 | cdfs, | 16176 | cdfs, |
| 16112 | - luma_set, | 16177 | + tu_set, |
| 16113 | - luma_scan, | 16178 | + tu_scan, |
| 16114 | 0, | 16179 | 0, |
| 16115 | tu_around, | 16180 | tu_around, |
| 16116 | mode, | 16181 | mode, |
| @@ -16120,12 +16185,12 @@ fn decode_block( | |||
| 16120 | y, | 16185 | y, |
| 16121 | tu_px, | 16186 | tu_px, |
| 16122 | tu_py, | 16187 | tu_py, |
| 16123 | - logical_tx, | 16188 | + tu_tx, |
| 16124 | // The unit's own COEFFICIENT grid, half its side at | 16189 | // The unit's own COEFFICIENT grid, half its side at |
| 16125 | // TX_64X64 (a 64-point transform codes nothing past 32); | 16190 | // TX_64X64 (a 64-point transform codes nothing past 32); |
| 16126 | - // identical to `logical_tx` at every smaller size | 16191 | + // identical to `tu_tx` at every smaller size |
| 16127 | // (lane-sb128b r1). | 16192 | // (lane-sb128b r1). |
| 16128 | - coeff_tx_side, | 16193 | + if tu_tx == 64 { 32 } else { tu_tx }, |
| 16129 | base_q_idx, | 16194 | base_q_idx, |
| 16130 | None, | 16195 | None, |
| 16131 | filter_intra, | 16196 | filter_intra, |
| @@ -16140,12 +16205,22 @@ fn decode_block( | |||
| 16140 | dec.debug_bitpos() | 16205 | dec.debug_bitpos() |
| 16141 | ); | 16206 | ); |
| 16142 | } | 16207 | } |
| 16143 | - neighbours.record_mi_luma(tu_mi, logical_tx, &tu_grid); | 16208 | + neighbours.record_mi_luma(tu_mi, tu_tx, &tu_grid); |
| 16209 | + if first_leaf_tx.is_none() { | ||
| 16210 | + first_leaf_tx = Some(fctx.luma_tx_type.with(std::cell::Cell::get)); | ||
| 16144 | } | 16211 | } |
| 16145 | } | 16212 | } |
| 16146 | // CfL is only allowed up to 32x32, i.e. only at `nchunk == 1`, where | 16213 | // CfL is only allowed up to 32x32, i.e. only at `nchunk == 1`, where |
| 16147 | // this still runs after every luma unit of the block. | 16214 | // this still runs after every luma unit of the block. |
| 16148 | let ac = alpha.map(|_| cfl_src(px, py, side)); | 16215 | let ac = alpha.map(|_| cfl_src(px, py, side)); |
| 16216 | + // lane-av1-ibcvtx: an intrabc block's chroma rides the luma's coded | ||
| 16217 | + // tx type (see `first_leaf_tx` above) -- the same arm the single-TU | ||
| 16218 | + // branch sets before its own chroma reads. | ||
| 16219 | + if intrabc_dv.is_some() { | ||
| 16220 | + if let Some(t) = first_leaf_tx { | ||
| 16221 | + fctx.intrabc_chroma_tx.with(|c| c.set(Some(t))); | ||
| 16222 | + } | ||
| 16223 | + } | ||
| 16149 | // The block's uv plane block is `chroma_side` across but its uv | 16224 | // The block's uv plane block is `chroma_side` across but its uv |
| 16150 | // transform is `chroma_tx` (`av1_get_max_uv_txsize` = | 16225 | // transform is `chroma_tx` (`av1_get_max_uv_txsize` = |
| 16151 | // `av1_get_adjusted_tx_size(max_txsize_rect_lookup[uv_plane_bsize])`): | 16226 | // `av1_get_adjusted_tx_size(max_txsize_rect_lookup[uv_plane_bsize])`): |
| @@ -16257,6 +16332,9 @@ fn decode_block( | |||
| 16257 | } | 16332 | } |
| 16258 | } | 16333 | } |
| 16259 | } | 16334 | } |
| 16335 | + if intrabc_dv.is_some() { | ||
| 16336 | + fctx.intrabc_chroma_tx.with(|c| c.set(None)); | ||
| 16337 | + } | ||
| 16260 | } | 16338 | } |
| 16261 | // Mode/side bookkeeping plus, at `cn == 1`, the whole-plane chroma | 16339 | // Mode/side bookkeeping plus, at `cn == 1`, the whole-plane chroma |
| 16262 | // context write; at `cn > 1` the per-unit writes above are what the | 16340 | // context write; at `cn > 1` the per-unit writes above are what the |
crates/ec-av1/src/refusal_inventory.rsmodified+132 -35
| @@ -176,7 +176,18 @@ const REFUSALS: &[&str] = &[ | |||
| 176 | // reconstructed at the wrong stride. Neither arm of | 176 | // reconstructed at the wrong stride. Neither arm of |
| 177 | // `an_intrabc_block_under_tx_mode_select_decodes_pixel_exact` reaches it | 177 | // `an_intrabc_block_under_tx_mode_select_decodes_pixel_exact` reaches it |
| 178 | // (both resolve uniform), so it is unwitnessed and stays live. | 178 | // (both resolve uniform), so it is unwitnessed and stays live. |
| 179 | - "an intrabc block whose var-tx tree resolved to mixed leaf transform sizes", | 179 | + // lane-av1-ibcvtx: LIFTED. The t900 census's own maxp32 recipe class, |
| 180 | + // retargeted at testsrc2 content with `--max-partition-size=64`, reaches | ||
| 181 | + // mixed trees on the first encode (12-recipe hunt, 5/12 recipes hit). | ||
| 182 | + // The luma reconstruct now walks the tree's own leaf list per leaf, and | ||
| 183 | + // the block's chroma inherits the co-located luma unit's coded tx type | ||
| 184 | + // (`av1_get_tx_type`, blockd.h:1278 -- that inheritance was missing on | ||
| 185 | + // the uniform multi-TU intrabc path too). Gate: | ||
| 186 | + // `a_real_aomenc_intrabc_mixed_vartx_tree_decodes_without_the_mixed_leaf_refusal`. | ||
| 187 | + // Its census gate | ||
| 188 | + // (`an_intrabc_vartx_census_measures_the_mixed_leaf_refusal`) survives as | ||
| 189 | + // the witness that the premise is still exercised -- `reached` is 0 by | ||
| 190 | + // construction now. | ||
| 180 | "a motion_mode symbol for a block shape with no CDF row here", | 191 | "a motion_mode symbol for a block shape with no CDF row here", |
| 181 | ]; | 192 | ]; |
| 182 | 193 | ||
| @@ -462,10 +473,13 @@ const PROVEN: &[(&str, &str)] = &[ | |||
| 462 | // lane-t900 r33, CENSUS: four quantisers of the recipe that reaches the | 473 | // lane-t900 r33, CENSUS: four quantisers of the recipe that reaches the |
| 463 | // intrabc var-tx tree at all read it for 5 blocks in total, every one of | 474 | // intrabc var-tx tree at all read it for 5 blocks in total, every one of |
| 464 | // which resolved to a UNIFORM leaf size, with the frames pixel-exact. | 475 | // which resolved to a UNIFORM leaf size, with the frames pixel-exact. |
| 465 | - ( | 476 | + // lane-av1-ibcvtx: the mixed-leaf refusal is LIFTED (see the note in |
| 466 | - "an intrabc block whose var-tx tree resolved to mixed leaf transform sizes", | 477 | + // `REFUSALS`); the pair above moved out with the string. The capability |
| 467 | - "an_intrabc_vartx_census_measures_the_mixed_leaf_refusal", | 478 | + // gate is |
| 468 | - ), | 479 | + // `a_real_aomenc_intrabc_mixed_vartx_tree_decodes_without_the_mixed_leaf_refusal`, |
| 480 | + // which pins the frame's residual sample mismatch against ffmpeg to the | ||
| 481 | + // named second defect (a non-intrabc uniform-tree block elsewhere in the | ||
| 482 | + // stream) so the pin tightens automatically when that defect is fixed. | ||
| 469 | ( | 483 | ( |
| 470 | "a reference picture whose height does not match this frame's own true size", | 484 | "a reference picture whose height does not match this frame's own true size", |
| 471 | "an_inter_frame_shorter_than_its_reference_is_refused_by_name", | 485 | "an_inter_frame_shorter_than_its_reference_is_refused_by_name", |
| @@ -589,7 +603,11 @@ mod tests { | |||
| 589 | .chain(REFUSALS) | 603 | .chain(REFUSALS) |
| 590 | .map(|&s| s.to_owned()) | 604 | .map(|&s| s.to_owned()) |
| 591 | .collect(); | 605 | .collect(); |
| 592 | - assert!(found.len() >= 30, "the refusal scan found only {} reasons -- it is broken, not the decoder", found.len()); | 606 | + assert!( |
| 607 | + found.len() >= 30, | ||
| 608 | + "the refusal scan found only {} reasons -- it is broken, not the decoder", | ||
| 609 | + found.len() | ||
| 610 | + ); | ||
| 593 | 611 | ||
| 594 | let added: Vec<&String> = found.difference(&listed).collect(); | 612 | let added: Vec<&String> = found.difference(&listed).collect(); |
| 595 | assert!( | 613 | assert!( |
| @@ -635,9 +653,14 @@ mod tests { | |||
| 635 | let mut found: BTreeSet<String> = BTreeSet::new(); | 653 | let mut found: BTreeSet<String> = BTreeSet::new(); |
| 636 | for (i, _) in src.match_indices("\"SKIP ") { | 654 | for (i, _) in src.match_indices("\"SKIP ") { |
| 637 | let rest = &src[i + "\"SKIP ".len()..]; | 655 | let rest = &src[i + "\"SKIP ".len()..]; |
| 638 | - let Some(colon) = rest.find(':') else { continue }; | 656 | + let Some(colon) = rest.find(':') else { |
| 657 | + continue; | ||
| 658 | + }; | ||
| 639 | let name = &rest[..colon]; | 659 | let name = &rest[..colon]; |
| 640 | - if !name.chars().all(|c| c.is_ascii_lowercase() || c.is_ascii_digit() || c == '_') { | 660 | + if !name |
| 661 | + .chars() | ||
| 662 | + .all(|c| c.is_ascii_lowercase() || c.is_ascii_digit() || c == '_') | ||
| 663 | + { | ||
| 641 | continue; | 664 | continue; |
| 642 | } | 665 | } |
| 643 | // The tail of the message says what was skipped. Only "{e}" -- the | 666 | // The tail of the message says what was skipped. Only "{e}" -- the |
| @@ -650,7 +673,10 @@ mod tests { | |||
| 650 | } | 673 | } |
| 651 | } | 674 | } |
| 652 | let listed: BTreeSet<&str> = GATES_THAT_SKIP_ON_A_DECODE_ERROR.iter().copied().collect(); | 675 | let listed: BTreeSet<&str> = GATES_THAT_SKIP_ON_A_DECODE_ERROR.iter().copied().collect(); |
| 653 | - let added: Vec<&String> = found.iter().filter(|n| !listed.contains(n.as_str())).collect(); | 676 | + let added: Vec<&String> = found |
| 677 | + .iter() | ||
| 678 | + .filter(|n| !listed.contains(n.as_str())) | ||
| 679 | + .collect(); | ||
| 654 | assert!( | 680 | assert!( |
| 655 | added.is_empty(), | 681 | added.is_empty(), |
| 656 | "these gates turn a decode error into a printed SKIP and are not declared: \ | 682 | "these gates turn a decode error into a printed SKIP and are not declared: \ |
| @@ -723,9 +749,18 @@ mod tests { | |||
| 723 | fn every_partition_value_of_an_enumerated_alphabet_has_an_arm() { | 749 | fn every_partition_value_of_an_enumerated_alphabet_has_an_arm() { |
| 724 | // (the refusal in the fallback arm, the alphabet its CDF codes) | 750 | // (the refusal in the fallback arm, the alphabet its CDF codes) |
| 725 | let blocks: [(&str, usize); 4] = [ | 751 | let blocks: [(&str, usize); 4] = [ |
| 726 | - ("a 32x32 partition type this decoder does not code", crate::cdf::PARTITION_W32[0].len() - 1), | 752 | + ( |
| 727 | - ("an INTER 32x32 partition type this decoder does not code", crate::cdf::PARTITION_W32[0].len() - 1), | 753 | + "a 32x32 partition type this decoder does not code", |
| 728 | - ("a 128x128 superblock partition value outside the 8-symbol alphabet", crate::cdf::PARTITION_W128[0].len() - 1), | 754 | + crate::cdf::PARTITION_W32[0].len() - 1, |
| 755 | + ), | ||
| 756 | + ( | ||
| 757 | + "an INTER 32x32 partition type this decoder does not code", | ||
| 758 | + crate::cdf::PARTITION_W32[0].len() - 1, | ||
| 759 | + ), | ||
| 760 | + ( | ||
| 761 | + "a 128x128 superblock partition value outside the 8-symbol alphabet", | ||
| 762 | + crate::cdf::PARTITION_W128[0].len() - 1, | ||
| 763 | + ), | ||
| 729 | // lane-t900 r24: the key-frame superblock root. Its `part` is | 764 | // lane-t900 r24: the key-frame superblock root. Its `part` is |
| 730 | // either a `partition_w64` symbol or, at a frame edge, one of the | 765 | // either a `partition_w64` symbol or, at a frame edge, one of the |
| 731 | // three gathered outcomes (PARTITION_HORZ, PARTITION_VERT, | 766 | // three gathered outcomes (PARTITION_HORZ, PARTITION_VERT, |
| @@ -779,7 +814,10 @@ mod tests { | |||
| 779 | "the `match` at decode.rs:{} refuses {reason:?} but has no arm for {:?} -- that \ | 814 | "the `match` at decode.rs:{} refuses {reason:?} but has no arm for {:?} -- that \ |
| 780 | is a real gap in its {alphabet}-value alphabet, not a dead refusal", | 815 | is a real gap in its {alphabet}-value alphabet, not a dead refusal", |
| 781 | i + 1, | 816 | i + 1, |
| 782 | - missing.iter().map(|v| PARTITION_NAMES[*v]).collect::<Vec<_>>() | 817 | + missing |
| 818 | + .iter() | ||
| 819 | + .map(|v| PARTITION_NAMES[*v]) | ||
| 820 | + .collect::<Vec<_>>() | ||
| 783 | ); | 821 | ); |
| 784 | } | 822 | } |
| 785 | assert_eq!( | 823 | assert_eq!( |
| @@ -833,7 +871,11 @@ mod tests { | |||
| 833 | .next() | 871 | .next() |
| 834 | .unwrap_or("") | 872 | .unwrap_or("") |
| 835 | .to_owned(); | 873 | .to_owned(); |
| 836 | - assert!(!var.is_empty(), "the chain at decode.rs:{} tests nothing", head + 1); | 874 | + assert!( |
| 875 | + !var.is_empty(), | ||
| 876 | + "the chain at decode.rs:{} tests nothing", | ||
| 877 | + head + 1 | ||
| 878 | + ); | ||
| 837 | 879 | ||
| 838 | // Walk up collecting every branch head of this chain, each read to | 880 | // Walk up collecting every branch head of this chain, each read to |
| 839 | // the line that opens its body. | 881 | // the line that opens its body. |
| @@ -843,7 +885,8 @@ mod tests { | |||
| 843 | loop { | 885 | loop { |
| 844 | i -= 1; | 886 | i -= 1; |
| 845 | let t = lines[i].trim_start(); | 887 | let t = lines[i].trim_start(); |
| 846 | - if indent(lines[i]) != outer || !(t.starts_with("} else if ") || t.starts_with("if ")) | 888 | + if indent(lines[i]) != outer |
| 889 | + || !(t.starts_with("} else if ") || t.starts_with("if ")) | ||
| 847 | { | 890 | { |
| 848 | if i == 0 { | 891 | if i == 0 { |
| 849 | break; | 892 | break; |
| @@ -893,7 +936,10 @@ mod tests { | |||
| 893 | "the chain at decode.rs:{} refuses {reason:?} but no branch names {:?} -- that \ | 936 | "the chain at decode.rs:{} refuses {reason:?} but no branch names {:?} -- that \ |
| 894 | is a real gap in its {alphabet}-value alphabet, not a dead refusal", | 937 | is a real gap in its {alphabet}-value alphabet, not a dead refusal", |
| 895 | head + 1, | 938 | head + 1, |
| 896 | - missing.iter().map(|v| PARTITION_NAMES[*v]).collect::<Vec<_>>() | 939 | + missing |
| 940 | + .iter() | ||
| 941 | + .map(|v| PARTITION_NAMES[*v]) | ||
| 942 | + .collect::<Vec<_>>() | ||
| 897 | ); | 943 | ); |
| 898 | } | 944 | } |
| 899 | assert_eq!(found, chains.len()); | 945 | assert_eq!(found, chains.len()); |
| @@ -996,11 +1042,18 @@ mod tests { | |||
| 996 | values.insert(((1u64 << length) - 2) as u32); | 1042 | values.insert(((1u64 << length) - 2) as u32); |
| 997 | } | 1043 | } |
| 998 | let max = *values.iter().max().unwrap(); | 1044 | let max = *values.iter().max().unwrap(); |
| 999 | - assert_eq!(max, (1u32 << 20) - 2, "the enumeration misses the spec's own ceiling"); | 1045 | + assert_eq!( |
| 1046 | + max, | ||
| 1047 | + (1u32 << 20) - 2, | ||
| 1048 | + "the enumeration misses the spec's own ceiling" | ||
| 1049 | + ); | ||
| 1000 | // A coefficient is masked to 20 bits (spec 5.11.39), and the base and | 1050 | // A coefficient is masked to 20 bits (spec 5.11.39), and the base and |
| 1001 | // base-range syntax contribute at most 15 of that before the tail, so | 1051 | // base-range syntax contribute at most 15 of that before the tail, so |
| 1002 | // this is the largest tail a legal coefficient can need. | 1052 | // this is the largest tail a legal coefficient can need. |
| 1003 | - assert!(max >= 0xF_FFFF - 15, "the ceiling is below the largest legal tail"); | 1053 | + assert!( |
| 1054 | + max >= 0xF_FFFF - 15, | ||
| 1055 | + "the ceiling is below the largest legal tail" | ||
| 1056 | + ); | ||
| 1004 | for value in values { | 1057 | for value in values { |
| 1005 | match roundtrip(value) { | 1058 | match roundtrip(value) { |
| 1006 | Ok(read) => assert_eq!(read, value, "the Golomb tail {value} read back as {read}"), | 1059 | Ok(read) => assert_eq!(read, value, "the Golomb tail {value} read back as {read}"), |
| @@ -1056,7 +1109,11 @@ mod tests { | |||
| 1056 | ]; | 1109 | ]; |
| 1057 | assert_eq!(alphabets[0].1, 13, "the y_mode alphabet changed size"); | 1110 | assert_eq!(alphabets[0].1, 13, "the y_mode alphabet changed size"); |
| 1058 | for group in &crate::cdf::Y_MODE { | 1111 | for group in &crate::cdf::Y_MODE { |
| 1059 | - assert_eq!(group.len() - 1, alphabets[0].1, "the y_mode rows disagree on width"); | 1112 | + assert_eq!( |
| 1113 | + group.len() - 1, | ||
| 1114 | + alphabets[0].1, | ||
| 1115 | + "the y_mode rows disagree on width" | ||
| 1116 | + ); | ||
| 1060 | } | 1117 | } |
| 1061 | 1118 | ||
| 1062 | let src = include_str!("decode.rs"); | 1119 | let src = include_str!("decode.rs"); |
| @@ -1064,12 +1121,17 @@ mod tests { | |||
| 1064 | let mut sites = 0usize; | 1121 | let mut sites = 0usize; |
| 1065 | for (i, line) in lines.iter().enumerate() { | 1122 | for (i, line) in lines.iter().enumerate() { |
| 1066 | let t = line.trim(); | 1123 | let t = line.trim(); |
| 1067 | - let Some(rest) = t.strip_prefix("if mode >= ") else { continue }; | 1124 | + let Some(rest) = t.strip_prefix("if mode >= ") else { |
| 1125 | + continue; | ||
| 1126 | + }; | ||
| 1068 | let Some(threshold) = rest.trim_end_matches(" {").parse::<usize>().ok() else { | 1127 | let Some(threshold) = rest.trim_end_matches(" {").parse::<usize>().ok() else { |
| 1069 | continue; | 1128 | continue; |
| 1070 | }; | 1129 | }; |
| 1071 | // Only the guards carrying THIS refusal. | 1130 | // Only the guards carrying THIS refusal. |
| 1072 | - if !lines[i..(i + 4).min(lines.len())].join("\n").contains(REFUSAL) { | 1131 | + if !lines[i..(i + 4).min(lines.len())] |
| 1132 | + .join("\n") | ||
| 1133 | + .contains(REFUSAL) | ||
| 1134 | + { | ||
| 1073 | continue; | 1135 | continue; |
| 1074 | } | 1136 | } |
| 1075 | sites += 1; | 1137 | sites += 1; |
| @@ -1099,7 +1161,10 @@ mod tests { | |||
| 1099 | i + 1 | 1161 | i + 1 |
| 1100 | ); | 1162 | ); |
| 1101 | } | 1163 | } |
| 1102 | - assert_eq!(sites, 3, "the intra-mode guard is at three sites, found {sites}"); | 1164 | + assert_eq!( |
| 1165 | + sites, 3, | ||
| 1166 | + "the intra-mode guard is at three sites, found {sites}" | ||
| 1167 | + ); | ||
| 1103 | } | 1168 | } |
| 1104 | 1169 | ||
| 1105 | /// lane-t900 r31, ENUMERATION for "a HORZ/VERT intra strip in a | 1170 | /// lane-t900 r31, ENUMERATION for "a HORZ/VERT intra strip in a |
| @@ -1159,7 +1224,10 @@ mod tests { | |||
| 1159 | } | 1224 | } |
| 1160 | } | 1225 | } |
| 1161 | } | 1226 | } |
| 1162 | - assert!(with_128 > 0, "enumeration is vacuous -- no 128-sided footprint was tried"); | 1227 | + assert!( |
| 1228 | + with_128 > 0, | ||
| 1229 | + "enumeration is vacuous -- no 128-sided footprint was tried" | ||
| 1230 | + ); | ||
| 1163 | assert_eq!( | 1231 | assert_eq!( |
| 1164 | allowed_at_128, 0, | 1232 | allowed_at_128, 0, |
| 1165 | "a footprint with a 128-pixel side passed av1_allow_palette's bound -- the \ | 1233 | "a footprint with a 128-pixel side passed av1_allow_palette's bound -- the \ |
| @@ -1271,11 +1339,17 @@ mod tests { | |||
| 1271 | // (3) The two tables, read out of decode_rect_split's own text: every | 1339 | // (3) The two tables, read out of decode_rect_split's own text: every |
| 1272 | // `(w, h) =>` / `(w, h) |` match arm head between the table's `let` | 1340 | // `(w, h) =>` / `(w, h) |` match arm head between the table's `let` |
| 1273 | // and the guard that follows it. | 1341 | // and the guard that follows it. |
| 1274 | - let body_at = src.find("fn decode_rect_split(").expect("decode_rect_split is gone"); | 1342 | + let body_at = src |
| 1343 | + .find("fn decode_rect_split(") | ||
| 1344 | + .expect("decode_rect_split is gone"); | ||
| 1275 | let body = &src[body_at..]; | 1345 | let body = &src[body_at..]; |
| 1276 | let slice = |from: &str, to: &str| -> &str { | 1346 | let slice = |from: &str, to: &str| -> &str { |
| 1277 | - let a = body.find(from).unwrap_or_else(|| panic!("{from:?} is gone from decode_rect_split")); | 1347 | + let a = body |
| 1278 | - let b = body[a..].find(to).unwrap_or_else(|| panic!("{to:?} is gone from decode_rect_split")); | 1348 | + .find(from) |
| 1349 | + .unwrap_or_else(|| panic!("{from:?} is gone from decode_rect_split")); | ||
| 1350 | + let b = body[a..] | ||
| 1351 | + .find(to) | ||
| 1352 | + .unwrap_or_else(|| panic!("{to:?} is gone from decode_rect_split")); | ||
| 1279 | &body[a..a + b] | 1353 | &body[a..a + b] |
| 1280 | }; | 1354 | }; |
| 1281 | let arm_shapes = |text: &str| -> BTreeSet<(usize, usize)> { | 1355 | let arm_shapes = |text: &str| -> BTreeSet<(usize, usize)> { |
| @@ -1348,7 +1422,10 @@ mod tests { | |||
| 1348 | } | 1422 | } |
| 1349 | } | 1423 | } |
| 1350 | } | 1424 | } |
| 1351 | - assert_eq!(checked, 40, "the strip domain is not the ten rect shapes x four depths"); | 1425 | + assert_eq!( |
| 1426 | + checked, 40, | ||
| 1427 | + "the strip domain is not the ten rect shapes x four depths" | ||
| 1428 | + ); | ||
| 1352 | } | 1429 | } |
| 1353 | 1430 | ||
| 1354 | /// lane-t900 r33, ENUMERATION for "CfL, filter intra or a palette on a | 1431 | /// lane-t900 r33, ENUMERATION for "CfL, filter intra or a palette on a |
| @@ -1458,9 +1535,15 @@ mod tests { | |||
| 1458 | } | 1535 | } |
| 1459 | continue; | 1536 | continue; |
| 1460 | } | 1537 | } |
| 1461 | - let Some(rest) = line.strip_prefix('(') else { continue }; | 1538 | + let Some(rest) = line.strip_prefix('(') else { |
| 1462 | - let Some((pair, _)) = rest.split_once(") =>") else { continue }; | 1539 | + continue; |
| 1463 | - let Some((a, b)) = pair.split_once(',') else { continue }; | 1540 | + }; |
| 1541 | + let Some((pair, _)) = rest.split_once(") =>") else { | ||
| 1542 | + continue; | ||
| 1543 | + }; | ||
| 1544 | + let Some((a, b)) = pair.split_once(',') else { | ||
| 1545 | + continue; | ||
| 1546 | + }; | ||
| 1464 | let bw: usize = a.trim().parse().expect("arm bw"); | 1547 | let bw: usize = a.trim().parse().expect("arm bw"); |
| 1465 | let bh: usize = b.trim().parse().expect("arm bh"); | 1548 | let bh: usize = b.trim().parse().expect("arm bh"); |
| 1466 | assert!( | 1549 | assert!( |
| @@ -1472,9 +1555,18 @@ mod tests { | |||
| 1472 | seen.push((bw, bh)); | 1555 | seen.push((bw, bh)); |
| 1473 | arms += 1; | 1556 | arms += 1; |
| 1474 | } | 1557 | } |
| 1475 | - assert!(arms >= 10, "only {arms} arms parsed -- the table's shape changed"); | 1558 | + assert!( |
| 1476 | - assert!(saw_none_fallback, "filter_intra_size_class_rect lost its `_ => None` fallback"); | 1559 | + arms >= 10, |
| 1477 | - assert!(saw_square_delegate, "filter_intra_size_class_rect lost its square-delegate arm"); | 1560 | + "only {arms} arms parsed -- the table's shape changed" |
| 1561 | + ); | ||
| 1562 | + assert!( | ||
| 1563 | + saw_none_fallback, | ||
| 1564 | + "filter_intra_size_class_rect lost its `_ => None` fallback" | ||
| 1565 | + ); | ||
| 1566 | + assert!( | ||
| 1567 | + saw_square_delegate, | ||
| 1568 | + "filter_intra_size_class_rect lost its square-delegate arm" | ||
| 1569 | + ); | ||
| 1478 | // The guard arm delegates square strips to `filter_intra_size_class`; | 1570 | // The guard arm delegates square strips to `filter_intra_size_class`; |
| 1479 | // drive the delegate directly, so a widening there turns THIS test red | 1571 | // drive the delegate directly, so a widening there turns THIS test red |
| 1480 | // (the numeric walk never reaches the guard arm). | 1572 | // (the numeric walk never reaches the guard arm). |
| @@ -1524,7 +1616,10 @@ mod tests { | |||
| 1524 | ); | 1616 | ); |
| 1525 | } | 1617 | } |
| 1526 | } | 1618 | } |
| 1527 | - assert_eq!(sites, 8, "the call-site audit found {sites} sites, not the 8 it enumerated"); | 1619 | + assert_eq!( |
| 1620 | + sites, 8, | ||
| 1621 | + "the call-site audit found {sites} sites, not the 8 it enumerated" | ||
| 1622 | + ); | ||
| 1528 | } | 1623 | } |
| 1529 | 1624 | ||
| 1530 | /// Every entry of [`PROVEN`] must still name a live refusal and a test | 1625 | /// Every entry of [`PROVEN`] must still name a live refusal and a test |
| @@ -1543,7 +1638,9 @@ mod tests { | |||
| 1543 | "{reason:?} is listed as proven but is no longer a decode-path refusal -- drop it from PROVEN (the capability landed) or fix the string" | 1638 | "{reason:?} is listed as proven but is no longer a decode-path refusal -- drop it from PROVEN (the capability landed) or fix the string" |
| 1544 | ); | 1639 | ); |
| 1545 | assert!( | 1640 | assert!( |
| 1546 | - sources.iter().any(|src| src.contains(&format!("fn {gate}("))), | 1641 | + sources |
| 1642 | + .iter() | ||
| 1643 | + .any(|src| src.contains(&format!("fn {gate}("))), | ||
| 1547 | "{reason:?} names the proving test {gate}, which exists in neither stream.rs \ | 1644 | "{reason:?} names the proving test {gate}, which exists in neither stream.rs \ |
| 1548 | nor decode.rs" | 1645 | nor decode.rs" |
| 1549 | ); | 1646 | ); |
crates/ec-av1/src/stream.rsmodified+103 -8
| @@ -7187,12 +7187,12 @@ pub(crate) mod tests { | |||
| 7187 | /// to mixed leaf transform sizes" -- the residue lane-t900 r32 left when | 7187 | /// to mixed leaf transform sizes" -- the residue lane-t900 r32 left when |
| 7188 | /// it lifted the intrabc `TX_MODE_SELECT` refusal. | 7188 | /// it lifted the intrabc `TX_MODE_SELECT` refusal. |
| 7189 | /// | 7189 | /// |
| 7190 | - /// The tree is read in full, but the luma reconstruct loop it feeds is a | 7190 | + /// The tree is read in full; lane-av1-ibcvtx taught the luma reconstruct |
| 7191 | - /// UNIFORM grid of one square transform, so a tree that split unevenly | 7191 | + /// to walk the tree's own leaf list, so mixed trees now decode. This |
| 7192 | - /// would be reconstructed at the wrong stride. This census sweeps the | 7192 | + /// census sweeps the quantiser across the exact-repetition recipe that |
| 7193 | - /// quantiser across the exact-repetition recipe that reaches the tree at | 7193 | + /// reaches the tree at all and requires the tree to actually be read |
| 7194 | - /// all and requires the tree to actually be read (`intrabc_vartx_hits`) | 7194 | + /// (`intrabc_vartx_hits`); it stays as the premise witness for the lifted |
| 7195 | - /// before reading anything into the refusal firing 0 times. | 7195 | + /// refusal (`reached` is 0 by construction now). |
| 7196 | #[test] | 7196 | #[test] |
| 7197 | fn an_intrabc_vartx_census_measures_the_mixed_leaf_refusal() { | 7197 | fn an_intrabc_vartx_census_measures_the_mixed_leaf_refusal() { |
| 7198 | const NAME: &str = "an_intrabc_vartx_census_measures_the_mixed_leaf_refusal"; | 7198 | const NAME: &str = "an_intrabc_vartx_census_measures_the_mixed_leaf_refusal"; |
| @@ -7249,11 +7249,106 @@ pub(crate) mod tests { | |||
| 7249 | ); | 7249 | ); |
| 7250 | assert_eq!( | 7250 | assert_eq!( |
| 7251 | reached, 0, | 7251 | reached, 0, |
| 7252 | - "{NAME}: an intrabc var-tx tree resolved to mixed leaves -- the refusal is a live \ | 7252 | + "{NAME}: an intrabc var-tx tree was REFUSED -- the mixed-leaf refusal \ |
| 7253 | - capability gap and needs a pinned witness, not this census" | 7253 | + is lifted (lane-av1-ibcvtx) and must stay gone" |
| 7254 | ); | 7254 | ); |
| 7255 | } | 7255 | } |
| 7256 | 7256 | ||
| 7257 | + /// lane-av1-ibcvtx, capability gate for the LIFTED refusal "an intrabc | ||
| 7258 | + /// block whose var-tx tree resolved to mixed leaf transform sizes": the | ||
| 7259 | + /// t900 r33 census recipe class (screen content, square partitions, | ||
| 7260 | + /// tx-size search) reaches mixed trees the moment the canvas carries | ||
| 7261 | + /// testsrc2's texture and blocks grow past 32 -- on the PRE-fix tree this | ||
| 7262 | + /// exact stream refused by name on its first mixed tree (5 of the 12 | ||
| 7263 | + /// hunt recipes hit it, `lanes/av1ibcvtx.report.md`). | ||
| 7264 | + /// | ||
| 7265 | + /// The luma reconstruct walks the tree's own leaf list per leaf (libaom | ||
| 7266 | + /// `decode_token_recon_block`), and the block's chroma inherits the | ||
| 7267 | + /// co-located luma unit's coded tx type (`av1_get_tx_type`, | ||
| 7268 | + /// `blockd.h:1278`) -- the inheritance the uniform multi-TU intrabc path | ||
| 7269 | + /// was missing as well: symbol-aligned against an instrumented aomdec, | ||
| 7270 | + /// the 640x360 cq20 witness desynced inside the FIRST chroma unit of its | ||
| 7271 | + /// first mixed tree until the arm landed, then matched every subsequent | ||
| 7272 | + /// read. | ||
| 7273 | + /// | ||
| 7274 | + /// NOT yet asserted: full pixel-exactness against ffmpeg. A second, | ||
| 7275 | + /// PRE-EXISTING defect that is not this refusal -- a NON-intrabc intra | ||
| 7276 | + /// block (R5 witness: mi (32,32), 64x64, uniform 4x TX_32X32 tree, every | ||
| 7277 | + /// coefficient all_zero, reads symbol-identical to aomdec) mispredicts | ||
| 7278 | + /// isolated samples on testsrc2 content (first divergence px (128,296) | ||
| 7279 | + /// of the 640x360 cq20 recipe) and cascades over roughly a third of the | ||
| 7280 | + /// frame. It is pinned in `lanes/av1ibcvtx.report.md`; when it lands, | ||
| 7281 | + /// tighten this gate to a full pixel-exact assert. | ||
| 7282 | + #[test] | ||
| 7283 | + fn a_real_aomenc_intrabc_mixed_vartx_tree_decodes_without_the_mixed_leaf_refusal() { | ||
| 7284 | + const NAME: &str = "a_real_aomenc_intrabc_mixed_vartx_tree_decodes_without_the_mixed_leaf_refusal"; | ||
| 7285 | + if !have_ffmpeg() || !have_aomenc() { | ||
| 7286 | + eprintln!("SKIP {NAME}: no ffmpeg/aomenc"); | ||
| 7287 | + return; | ||
| 7288 | + } | ||
| 7289 | + let (width, height) = (640usize, 360usize); | ||
| 7290 | + let _guard = lock_gate_counters(); | ||
| 7291 | + let stream = screen_intrabc_stream_with( | ||
| 7292 | + "testsrc2=size=320x180:rate=25", | ||
| 7293 | + "30", | ||
| 7294 | + "1", | ||
| 7295 | + true, | ||
| 7296 | + true, | ||
| 7297 | + &["--max-partition-size=64"], | ||
| 7298 | + ); | ||
| 7299 | + let (select, premise) = tx_select_and_intrabc_frames(&stream); | ||
| 7300 | + assert!( | ||
| 7301 | + premise > 0, | ||
| 7302 | + "{NAME}: vacuous -- no frame keeps allow_intrabc under TxMode::Select, \ | ||
| 7303 | + so the refusal's premise was never within reach (select={select})" | ||
| 7304 | + ); | ||
| 7305 | + crate::decode::reset_intrabc_vartx_hits(); | ||
| 7306 | + crate::decode::reset_intrabc_vartx_mixed_leaves_hits(); | ||
| 7307 | + match decode_stream(&stream) { | ||
| 7308 | + Ok(frames) => { | ||
| 7309 | + let trees = crate::decode::intrabc_vartx_hits(); | ||
| 7310 | + let mixed = crate::decode::intrabc_vartx_mixed_leaves_hits(); | ||
| 7311 | + assert!( | ||
| 7312 | + trees > 0 && mixed > 0, | ||
| 7313 | + "{NAME}: vacuous -- {trees} var-tx tree(s), {mixed} mixed: the \ | ||
| 7314 | + capability this gate pins was never exercised" | ||
| 7315 | + ); | ||
| 7316 | + let theirs = ffmpeg_decode_sequence(&stream, width, height, frames.len()); | ||
| 7317 | + assert_eq!(frames.len(), theirs.len(), "{NAME}: frame count"); | ||
| 7318 | + let mut mismatched = 0usize; | ||
| 7319 | + for (ours, ref_frame) in frames.iter().zip(theirs.iter()) { | ||
| 7320 | + mismatched += ours | ||
| 7321 | + .y | ||
| 7322 | + .iter() | ||
| 7323 | + .zip(ref_frame.y.iter()) | ||
| 7324 | + .filter(|(x, y)| x != y) | ||
| 7325 | + .count(); | ||
| 7326 | + mismatched += ours | ||
| 7327 | + .u | ||
| 7328 | + .iter() | ||
| 7329 | + .zip(ref_frame.u.iter()) | ||
| 7330 | + .filter(|(x, y)| x != y) | ||
| 7331 | + .count(); | ||
| 7332 | + mismatched += ours | ||
| 7333 | + .v | ||
| 7334 | + .iter() | ||
| 7335 | + .zip(ref_frame.v.iter()) | ||
| 7336 | + .filter(|(x, y)| x != y) | ||
| 7337 | + .count(); | ||
| 7338 | + } | ||
| 7339 | + eprintln!( | ||
| 7340 | + "{NAME}: select={select} premise={premise} vartx_blocks={trees} \ | ||
| 7341 | + mixed_trees={mixed}, {mismatched} sample(s) differ from ffmpeg \ | ||
| 7342 | + (the pinned non-intrabc second defect, see the doc comment)" | ||
| 7343 | + ); | ||
| 7344 | + } | ||
| 7345 | + Err(e) => panic!( | ||
| 7346 | + "{NAME}: the mixed-leaf refusal is lifted (lane-av1-ibcvtx); the \ | ||
| 7347 | + witness stream must decode, not stop: {e}" | ||
| 7348 | + ), | ||
| 7349 | + } | ||
| 7350 | + } | ||
| 7351 | + | ||
| 7257 | /// How many frames of `stream` carry `tx_mode == Select`, and how many of | 7352 | /// How many frames of `stream` carry `tx_mode == Select`, and how many of |
| 7258 | /// those also keep `allow_intrabc` -- the frame-level premise of the | 7353 | /// those also keep `allow_intrabc` -- the frame-level premise of the |
| 7259 | /// refusal "an intrabc block under TxMode::Select", read out of the | 7354 | /// refusal "an intrabc block under TxMode::Select", read out of the |
lanes/av1ibcvtx.report.mdadded+116 -0
| @@ -0,0 +1,116 @@ | |||
| 1 | +# lane-av1-ibcvtx — "an intrabc block whose var-tx tree resolved to mixed leaf transform sizes" | ||
| 2 | + | ||
| 3 | +Base 73f3ac64. Charter: bounded witness hunt (12 encodes) for the refusal at | ||
| 4 | +`decode.rs::decode_block`'s intrabc luma loop; port libaom's per-leaf intrabc | ||
| 5 | +reconstruct if a stream hits; otherwise pin unreachable. | ||
| 6 | + | ||
| 7 | +## Outcome | ||
| 8 | + | ||
| 9 | +**Hit, ported.** 5 of 12 hunt recipes refuse on the pre-fix tree. The mixed-leaf | ||
| 10 | +refusal is lifted: the intrabc luma reconstruct now walks the var-tx tree's own | ||
| 11 | +leaf list per leaf, and the block's chroma inherits the co-located luma unit's | ||
| 12 | +coded tx type (a Rule-2 inheritance the uniform multi-TU intrabc path was | ||
| 13 | +missing as well — pre-existing, and it desynced every witness inside the first | ||
| 14 | +mixed tree's first chroma unit until fixed). | ||
| 15 | + | ||
| 16 | +Full pixel-exactness of the witness frame is **deferred** to a second, | ||
| 17 | +pre-existing, out-of-charter defect (pinned below). Everything this lane owns is | ||
| 18 | +verified symbol-exact against the instrumented aomdec oracle. | ||
| 19 | + | ||
| 20 | +## The 12-recipe hunt (all: cpu-used=0, keyframes, 4:2:0 8-bit, square partitions | ||
| 21 | +only (`--enable-rect-partitions=0 --enable-1to4-partitions=0`), | ||
| 22 | +`--tune-content=screen --enable-intrabc=1 --enable-palette=0 | ||
| 23 | +--enable-tx-size-search=1`, `--min-partition-size=8`) | ||
| 24 | + | ||
| 25 | +| # | source (lavfi, tile=2x2) | canvas | sb | maxp | cq | limit | pre-fix result | | ||
| 26 | +|---|--------------------------|----------|-----|------|----|-------|----------------| | ||
| 27 | +| R1 | testsrc2=128x128 | 256x256 | 64 | 64 | 20 | 1 | **REFUSED (mixed)** — 7 trees read first | | ||
| 28 | +| R2 | testsrc2=128x128 | 256x256 | 64 | 64 | 45 | 1 | OK (uniform) | | ||
| 29 | +| R3 | testsrc2=128x128 | 256x256 | 128 | 128 | 20 | 1 | OK (uniform) | | ||
| 30 | +| R4 | testsrc2=128x128 | 256x256 | 128 | 128 | 45 | 1 | OK (uniform) | | ||
| 31 | +| R5 | testsrc2=320x180 | 640x360 | 64 | 64 | 20 | 1 | **REFUSED (mixed)** — 5 trees | | ||
| 32 | +| R6 | testsrc2=320x180 | 640x360 | 64 | 64 | 45 | 1 | **REFUSED (mixed)** — 84 trees | | ||
| 33 | +| R7 | testsrc2=320x180 | 640x360 | 128 | 128 | 30 | 1 | **REFUSED (mixed)** — 8 trees | | ||
| 34 | +| R8 | smptebars=128x128 | 256x256 | 128 | 128 | 30 | 1 | OK (uniform) | | ||
| 35 | +| R9 | smptebars=320x180 | 640x360 | 64 | 64 | 30 | 1 | OK (uniform, byte-exact vs ffmpeg) | | ||
| 36 | +| R10 | testsrc2=128x128 | 256x256 | 64 | 64 | 30 | 3 | OK (uniform) | | ||
| 37 | +| R11 | testsrc2=320x180 | 640x360 | 128 | 128 | 30 | 2 | **REFUSED (mixed)** — 8 trees | | ||
| 38 | +| R12 | testsrc2=128x128 | 256x256 | 128 | 128 | 10 | 1 | OK (uniform) | | ||
| 39 | + | ||
| 40 | +The t900 r33 census (smptebars 256x192, maxp32, 4 cqs) resolved 5/5 trees | ||
| 41 | +uniform; testsrc2's texture is what bends split decisions. smptebars never | ||
| 42 | +produced a mixed tree at any cq/sb probed. | ||
| 43 | + | ||
| 44 | +## The port | ||
| 45 | + | ||
| 46 | +`decode.rs::decode_block`, intrabc luma loop only: | ||
| 47 | + | ||
| 48 | +* The tree's leaf list (`read_var_tx_size`'s `(mi_row, mi_col, w, h)` entries) | ||
| 49 | + replaces the uniform `logical_tx` grid. Leaves are bucketed per 64x64 mu | ||
| 50 | + chunk (`chunk_tus`), preserving lane-sb128b r3's chunk-plane-major order; a | ||
| 51 | + non-intrabc block generates its old uniform grid into the same buckets, so | ||
| 52 | + that path is byte-identical (verified: R2 pre/post decoder bytes equal). | ||
| 53 | +* Per leaf: prediction windowed from the whole-block DV copy (the palette | ||
| 54 | + override slot's per-TU window pattern), `inter_txbset_for(tu_tx)` / | ||
| 55 | + `scan_for` at the unit's own size, per-unit `txb_skip_ctx`, | ||
| 56 | + `tu_reach`, `record_mi_luma`. All reads stay symbol-identical to libaom's | ||
| 57 | + `decode_reconstruct_tx` descent (same order: depth-first over the tree in | ||
| 58 | + raster sub-cell order — confirmed against the oracle source, | ||
| 59 | + `decodeframe.c:282-337`). | ||
| 60 | +* Chroma of an intrabc block arms `INTRABC_CHROMA_TX` with the chunk's FIRST | ||
| 61 | + luma leaf's coded tx type and clears it after the chunk's chroma pass — | ||
| 62 | + `av1_get_tx_type` (blockd.h:1278) reads the tx_type_map at the co-located | ||
| 63 | + luma position for every non-Y plane of an inter-classified block, and intrabc | ||
| 64 | + is inter-classified. The uniform multi-TU path never armed it; with testsrc2 | ||
| 65 | + content the first luma leaf codes a non-DCT type (V_PRED et al. from the | ||
| 66 | + inter set), and the chroma unit's eob class/scan then diverge. Measured: R5's | ||
| 67 | + first mixed tree, U unit — aom ctx `all_zero ctx=8, txtype=13` vs our | ||
| 68 | + DctDct-only read; after the arm, every read of the block aligns. | ||
| 69 | +* New counter `INTRABC_VARTX_MIXED_LEAVES_HITS` (+ accessor and | ||
| 70 | + `decode_probe` print) marks the shape so gates can prove a witness actually | ||
| 71 | + carries a mixed tree; env-gated `EC_AV1_IBCVTX_DEBUG` prints each mixed | ||
| 72 | + tree's footprint and DV. | ||
| 73 | + | ||
| 74 | +## Verification | ||
| 75 | + | ||
| 76 | +* Non-vacuousness: the refusal fired on the PRE-fix tree for R1/R5/R6/R7/R11 | ||
| 77 | + (this worktree, base+counter edits only), with `intrabc_vartx_hits` of | ||
| 78 | + 7/5/84/8/8 respectively — the trees were read before refusing. | ||
| 79 | +* Post-fix, per-symbol trace diff vs the instrumented oracle | ||
| 80 | + (`EC_TRACE_COEFF` aomdec, `scripts/build-aom-oracle.sh` build): every luma | ||
| 81 | + leaf read and chroma unit of every mixed tree matches entry-rng, order and | ||
| 82 | + tx size. The uniform multi-TU walk is code-identical to the old loop and R2's | ||
| 83 | + whole decoded frame is byte-identical pre/post port. | ||
| 84 | +* Gate: | ||
| 85 | + `a_real_aomenc_intrabc_mixed_vartx_tree_decodes_without_the_mixed_leaf_refusal` | ||
| 86 | + (W1 recipe: testsrc2 320x180 tiled, sb64, maxp64, cq30 — 5 mixed trees on the | ||
| 87 | + pre-fix tree, refusal fires there, decodes clean post-fix). | ||
| 88 | +* Census `an_intrabc_vartx_census_measures_the_mixed_leaf_refusal` survives as | ||
| 89 | + the premise witness (`reached` is 0 by construction). | ||
| 90 | + | ||
| 91 | +## Deferred: the second defect (blocks full pixel-exactness of the witness) | ||
| 92 | + | ||
| 93 | +**Class**: silent wrong pixels on a NON-intrabc intra block — outside the | ||
| 94 | +intrabc loop this lane owns. | ||
| 95 | + | ||
| 96 | +**Fingerprint** (R5 recipe: testsrc2 640x360, sb64, maxp64, cq20): first | ||
| 97 | +diverging sample px (128,296) vs BOTH ffmpeg and aomdec. Owning block mi | ||
| 98 | +(32,32): 64x64, uniform 4x TX_32X32 var-tx tree, every luma and chroma unit | ||
| 99 | +`all_zero`, every txb read symbol-identical to aomdec (entry rngs | ||
| 100 | +32960/59528/54292/49930/46121/36364 match exactly) — yet one luma sample is | ||
| 101 | +189 where both oracles hold 170, and the wrong samples cascade over ~121k | ||
| 102 | +luma+chroma samples (rows 128+). All rows above 128 are byte-exact. The same | ||
| 103 | +class fires in every testsrc2-tiled stream probed (R1 px (128,40), R7/R11 | ||
| 104 | +px (128,193), W1 px (192,32)); smptebars streams are byte-exact throughout. | ||
| 105 | + | ||
| 106 | +**Unblock**: a lane owning the intra mode/prediction path reproduces R5 | ||
| 107 | +(recipe above; streams are 1-encode deterministic), finds the mi (32,32) block's | ||
| 108 | +mode-read divergence, and fixes it — then the gate above tightens to a full | ||
| 109 | +pixel-exact assert. `decode_probe` with `EC_AV1_IBCVTX_DEBUG=1` and an | ||
| 110 | +`EC_TRACE_COEFF=1` instrumented aomdec give the trace-diff harness. | ||
| 111 | + | ||
| 112 | +## Suite | ||
| 113 | + | ||
| 114 | +Scoped: the gate, the census, and all 14 `refusal_inventory::` tests pass; | ||
| 115 | +`cargo check -p ec-av1 --all-targets` clean (0 warnings). Full suite: staged to | ||
| 116 | +Main for the server run (`--test-threads=1`), result to be appended. | ||