Merge lane-av1intrapred: intrabc TX4 chroma predicts from the frame copy
Browse files at this commit7 changed files +714 -50
- crates/ec-av1/examples/decode_probe.rs +8 -0
- crates/ec-av1/fixtures/intrabc_tx4_chroma_kf.obu +0 -0
- crates/ec-av1/src/decode.rs +185 -37
- crates/ec-av1/src/refusal_inventory.rs +19 -5
- crates/ec-av1/src/stream.rs +224 -8
- lanes/av1ibcvtx.report.md +116 -0
- lanes/av1intrapred.report.md +162 -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/fixtures/intrabc_tx4_chroma_kf.obuadded+0 -0
Binary file changed
crates/ec-av1/src/decode.rsmodified+185 -37
| @@ -3857,6 +3857,27 @@ thread_local! { | |||
| 3857 | static LEAF8_INTRABC_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | 3857 | static LEAF8_INTRABC_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; |
| 3858 | } | 3858 | } |
| 3859 | 3859 | ||
| 3860 | +thread_local! { | ||
| 3861 | + /// Chroma reads of an intrabc TX4-split leaf that consulted an ARMED | ||
| 3862 | + /// [`INTRABC_CHROMA_TX`] slot -- proof that the arm's frame-copy + | ||
| 3863 | + /// inherited-type route actually ran (lane-av1intrapred r2's non-vacuity | ||
| 3864 | + /// counter: zero means the gate's fixture no longer reaches the route). | ||
| 3865 | + static INTRABC_TX4_CHROMA_COPY_HITS: std::cell::Cell<usize> = | ||
| 3866 | + const { std::cell::Cell::new(0) }; | ||
| 3867 | +} | ||
| 3868 | + | ||
| 3869 | +/// Current value of [`INTRABC_TX4_CHROMA_COPY_HITS`]. | ||
| 3870 | +#[allow(dead_code)] // read only from the `#[cfg(test)]` gates | ||
| 3871 | +pub(crate) fn intrabc_tx4_chroma_copy_hits() -> usize { | ||
| 3872 | + INTRABC_TX4_CHROMA_COPY_HITS.with(|c| c.get()) | ||
| 3873 | +} | ||
| 3874 | + | ||
| 3875 | +/// Zeroes [`INTRABC_TX4_CHROMA_COPY_HITS`] (gate tests call this before a decode). | ||
| 3876 | +#[allow(dead_code)] // read only from the `#[cfg(test)]` gates | ||
| 3877 | +pub(crate) fn reset_intrabc_tx4_chroma_copy_hits() { | ||
| 3878 | + INTRABC_TX4_CHROMA_COPY_HITS.with(|c| c.set(0)); | ||
| 3879 | +} | ||
| 3880 | + | ||
| 3860 | /// Current value of [`LEAF8_INTRABC_HITS`]. | 3881 | /// Current value of [`LEAF8_INTRABC_HITS`]. |
| 3861 | pub(crate) fn leaf8_intrabc_hits() -> usize { | 3882 | pub(crate) fn leaf8_intrabc_hits() -> usize { |
| 3862 | LEAF8_INTRABC_HITS.with(|c| c.get()) | 3883 | LEAF8_INTRABC_HITS.with(|c| c.get()) |
| @@ -3908,6 +3929,10 @@ thread_local! { | |||
| 3908 | /// var-tx partition tree (unskipped, `TX_MODE_SELECT`) -- the capability | 3929 | /// var-tx partition tree (unskipped, `TX_MODE_SELECT`) -- the capability |
| 3909 | /// that replaced the refusal "an intrabc block under TxMode::Select". | 3930 | /// that replaced the refusal "an intrabc block under TxMode::Select". |
| 3910 | static INTRABC_VARTX_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | 3931 | static INTRABC_VARTX_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; |
| 3932 | + /// lane-av1-ibcvtx: intrabc var-tx trees that resolved to MIXED leaf | ||
| 3933 | + /// sizes (not one square size across every leaf) -- the engagement | ||
| 3934 | + /// counter proving a witness actually exercises the per-leaf reconstruct. | ||
| 3935 | + static INTRABC_VARTX_MIXED_LEAVES_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | ||
| 3911 | /// lane-av1txr: as above for a `BLOCK_4X8`/`BLOCK_8X4` intrabc leaf -- | 3936 | /// lane-av1txr: as above for a `BLOCK_4X8`/`BLOCK_8X4` intrabc leaf -- |
| 3912 | /// libaom's `block_signals_txsize` is `bsize > BLOCK_4X4`, so these leaves | 3937 | /// libaom's `block_signals_txsize` is `bsize > BLOCK_4X4`, so these leaves |
| 3913 | /// signal a transform size where a plain `BLOCK_4X4` does not. Reading no | 3938 | /// signal a transform size where a plain `BLOCK_4X4` does not. Reading no |
| @@ -3995,17 +4020,28 @@ pub(crate) fn reset_intrabc_128rect_hits() { | |||
| 3995 | } | 4020 | } |
| 3996 | 4021 | ||
| 3997 | /// Current value of [`INTRABC_VARTX_HITS`]. | 4022 | /// Current value of [`INTRABC_VARTX_HITS`]. |
| 3998 | -#[allow(dead_code)] // read only from the `#[cfg(test)]` gates | 4023 | +pub fn intrabc_vartx_hits() -> usize { |
| 3999 | -pub(crate) fn intrabc_vartx_hits() -> usize { | ||
| 4000 | INTRABC_VARTX_HITS.with(|c| c.get()) | 4024 | INTRABC_VARTX_HITS.with(|c| c.get()) |
| 4001 | } | 4025 | } |
| 4002 | 4026 | ||
| 4027 | +/// Current value of [`INTRABC_VARTX_MIXED_LEAVES_HITS`]. | ||
| 4028 | +pub fn intrabc_vartx_mixed_leaves_hits() -> usize { | ||
| 4029 | + INTRABC_VARTX_MIXED_LEAVES_HITS.with(|c| c.get()) | ||
| 4030 | +} | ||
| 4031 | + | ||
| 4003 | /// Zeroes [`INTRABC_VARTX_HITS`] (gate tests call this before a decode). | 4032 | /// Zeroes [`INTRABC_VARTX_HITS`] (gate tests call this before a decode). |
| 4004 | #[allow(dead_code)] // read only from the `#[cfg(test)]` gates | 4033 | #[allow(dead_code)] // read only from the `#[cfg(test)]` gates |
| 4005 | pub(crate) fn reset_intrabc_vartx_hits() { | 4034 | pub(crate) fn reset_intrabc_vartx_hits() { |
| 4006 | INTRABC_VARTX_HITS.with(|c| c.set(0)); | 4035 | INTRABC_VARTX_HITS.with(|c| c.set(0)); |
| 4007 | } | 4036 | } |
| 4008 | 4037 | ||
| 4038 | +/// Zeroes [`INTRABC_VARTX_MIXED_LEAVES_HITS`] (gate tests call this before a | ||
| 4039 | +/// decode). | ||
| 4040 | +#[allow(dead_code)] // read only from the `#[cfg(test)]` gates | ||
| 4041 | +pub(crate) fn reset_intrabc_vartx_mixed_leaves_hits() { | ||
| 4042 | + INTRABC_VARTX_MIXED_LEAVES_HITS.with(|c| c.set(0)); | ||
| 4043 | +} | ||
| 4044 | + | ||
| 4009 | /// Current value of [`RECT_INTRABC_VARTX_HITS`]. | 4045 | /// Current value of [`RECT_INTRABC_VARTX_HITS`]. |
| 4010 | #[allow(dead_code)] // read only from the `#[cfg(test)]` gates | 4046 | #[allow(dead_code)] // read only from the `#[cfg(test)]` gates |
| 4011 | pub fn rect_intrabc_vartx_hits() -> usize { | 4047 | pub fn rect_intrabc_vartx_hits() -> usize { |
| @@ -16588,23 +16624,31 @@ fn decode_block( | |||
| 16588 | } | 16624 | } |
| 16589 | } | 16625 | } |
| 16590 | hit!(INTRABC_VARTX_HITS); | 16626 | hit!(INTRABC_VARTX_HITS); |
| 16591 | - // The luma reconstruct loop below is a UNIFORM grid of one square | 16627 | + // lane-t900 r33 census: the t900 recipes resolved every tree UNIFORM. |
| 16592 | - // transform (the intra `tx_depth` shape), so a tree that resolved to | 16628 | + // lane-av1-ibcvtx: a tree that resolved to mixed leaf sizes is no |
| 16593 | - // mixed leaf sizes is refused by name rather than reconstructed at the | 16629 | + // longer refused -- the luma reconstruct below walks the tree's own |
| 16594 | - // wrong stride. | 16630 | + // leaf list per leaf (libaom `decode_token_recon_block`, whose token |
| 16631 | + // loop reconstructs whatever `read_tx_size_vartx` resolved, per | ||
| 16632 | + // transform unit), so mixed sizes reconstruct at their own stride. | ||
| 16633 | + // The counter marks the shape so a gate can prove a witness actually | ||
| 16634 | + // carries a mixed tree and not merely another uniform one. | ||
| 16595 | let uniform = leaves | 16635 | let uniform = leaves |
| 16596 | .first() | 16636 | .first() |
| 16597 | .is_some_and(|f| leaves.iter().all(|l| (l.2, l.3) == (f.2, f.3) && l.2 == l.3)); | 16637 | .is_some_and(|f| leaves.iter().all(|l| (l.2, l.3) == (f.2, f.3) && l.2 == l.3)); |
| 16598 | if !uniform { | 16638 | if !uniform { |
| 16599 | - return Err(unsupported( | 16639 | + hit!(INTRABC_VARTX_MIXED_LEAVES_HITS); |
| 16600 | - "an intrabc block whose var-tx tree resolved to mixed leaf transform sizes", | 16640 | + if crate::envflags::env_flag!("EC_AV1_IBCVTX_DEBUG") { |
| 16601 | - )); | 16641 | + eprintln!( |
| 16642 | + "IBCVTX mixed intrabc tree mi=({mi_r},{mi_c}) side={side} \ | ||
| 16643 | + dv={intrabc_dv:?} leaves={leaves:?}" | ||
| 16644 | + ); | ||
| 16645 | + } | ||
| 16602 | } | 16646 | } |
| 16603 | - Some(leaves[0].2) | 16647 | + Some(leaves) |
| 16604 | } else { | 16648 | } else { |
| 16605 | None | 16649 | None |
| 16606 | }; | 16650 | }; |
| 16607 | - let (logical_tx, coeff_tx_side) = if let Some(tx) = intrabc_leaves { | 16651 | + let (logical_tx, coeff_tx_side) = if let Some(tx) = intrabc_leaves.as_ref().map(|l| l[0].2) { |
| 16608 | (tx, if tx == 64 { 32 } else { tx }) | 16652 | (tx, if tx == 64 { 32 } else { tx }) |
| 16609 | } else if tx_select && !intrabc_skip_tx { | 16653 | } else if tx_select && !intrabc_skip_tx { |
| 16610 | let resolved = read_tx_size(dec, cdfs, neighbours, (mi_r, mi_c), side, fctx); | 16654 | let resolved = read_tx_size(dec, cdfs, neighbours, (mi_r, mi_c), side, fctx); |
| @@ -17053,25 +17097,54 @@ fn decode_block( | |||
| 17053 | let chroma_ctx_offset = if cn > 1 { Some(3) } else { None }; | 17097 | let chroma_ctx_offset = if cn > 1 { Some(3) } else { None }; |
| 17054 | let tpc = (n_axis / nchunk).max(1); | 17098 | let tpc = (n_axis / nchunk).max(1); |
| 17055 | let cpc = (cn / nchunk).max(1); | 17099 | let cpc = (cn / nchunk).max(1); |
| 17100 | + // The block's luma transform units, raster order inside each mu | ||
| 17101 | + // chunk. lane-av1-ibcvtx: an intrabc block's units are the var-tx | ||
| 17102 | + // tree's own leaf list -- mixed sizes included, exactly what libaom's | ||
| 17103 | + // `decode_token_recon_block` token loop reconstructs (one | ||
| 17104 | + // `av1_read_coeffs_txb` + inverse transform per resolved unit) -- | ||
| 17105 | + // while every other block's list is the uniform `logical_tx` grid | ||
| 17106 | + // this loop has always walked, generated here in the same order. | ||
| 17107 | + let mut chunk_tus: Vec<Vec<(usize, usize, usize)>> = vec![Vec::new(); nchunk * nchunk]; | ||
| 17108 | + if let Some(leaves) = &intrabc_leaves { | ||
| 17109 | + for &(lr, lc, tw, _th) in leaves { | ||
| 17110 | + let (off_y, off_x) = (lr * MI, lc * MI); | ||
| 17111 | + chunk_tus[(off_y / 64) * nchunk + (off_x / 64)].push((off_y, off_x, tw)); | ||
| 17112 | + } | ||
| 17113 | + } else { | ||
| 17114 | + for tu_row in 0..n_axis { | ||
| 17115 | + for tu_col in 0..n_axis { | ||
| 17116 | + chunk_tus[(tu_row / tpc) * nchunk + (tu_col / tpc)].push(( | ||
| 17117 | + tu_row * logical_tx, | ||
| 17118 | + tu_col * logical_tx, | ||
| 17119 | + logical_tx, | ||
| 17120 | + )); | ||
| 17121 | + } | ||
| 17122 | + } | ||
| 17123 | + } | ||
| 17056 | let mut last_grids = [Grid::Zero(0), Grid::Zero(0)]; | 17124 | let mut last_grids = [Grid::Zero(0), Grid::Zero(0)]; |
| 17057 | let mut units: Vec<((usize, usize), usize, Grid, Grid)> = Vec::new(); | 17125 | let mut units: Vec<((usize, usize), usize, Grid, Grid)> = Vec::new(); |
| 17058 | for ch_row in 0..nchunk { | 17126 | for ch_row in 0..nchunk { |
| 17059 | for ch_col in 0..nchunk { | 17127 | for ch_col in 0..nchunk { |
| 17060 | - for tu_row in ch_row * tpc..(ch_row + 1) * tpc { | 17128 | + // lane-av1-ibcvtx: the chunk's chroma units inherit the CHROMA tx |
| 17061 | - for tu_col in ch_col * tpc..(ch_col + 1) * tpc { | 17129 | + // type of the co-located luma position (`av1_get_tx_type`, |
| 17062 | - let tu_mi = ( | 17130 | + // blockd.h:1278: a non-Y plane of an inter-classified block -- and |
| 17063 | - mi_r + tu_row * (logical_tx / MI), | 17131 | + // intrabc is one -- reads `tx_type_map`, i.e. the coded type of the |
| 17064 | - mi_c + tu_col * (logical_tx / MI), | 17132 | + // luma unit covering it). Inside a mu chunk that is the chunk's |
| 17065 | - ); | 17133 | + // FIRST luma unit in raster order (the chunk origin is always the |
| 17066 | - let tu_px = px + tu_col * logical_tx; | 17134 | + // first leaf's own origin). Captured right after that unit's read; |
| 17067 | - let tu_py = py + tu_row * logical_tx; | 17135 | + // the single-TU arm below does the same for a whole-block unit. |
| 17136 | + let mut first_leaf_tx: Option<TxType> = None; | ||
| 17137 | + for &(tu_off_y, tu_off_x, tu_tx) in &chunk_tus[ch_row * nchunk + ch_col] { | ||
| 17138 | + let tu_mi = (mi_r + tu_off_y / MI, mi_c + tu_off_x / MI); | ||
| 17139 | + let tu_px = px + tu_off_x; | ||
| 17140 | + let tu_py = py + tu_off_y; | ||
| 17068 | // Same libaom clip as `decode_rect_split`'s loop above; a | 17141 | // Same libaom clip as `decode_rect_split`'s loop above; a |
| 17069 | // square block only hangs off the frame when the frame's mi | 17142 | // square block only hangs off the frame when the frame's mi |
| 17070 | // dimensions are odd at the block's own level. | 17143 | // dimensions are odd at the block's own level. |
| 17071 | if tu_px >= y.true_width || tu_py >= y.true_height { | 17144 | if tu_px >= y.true_width || tu_py >= y.true_height { |
| 17072 | continue; | 17145 | continue; |
| 17073 | } | 17146 | } |
| 17074 | - let tu_around = neighbours.around_mi(tu_mi, logical_tx)[0]; | 17147 | + let tu_around = neighbours.around_mi(tu_mi, tu_tx)[0]; |
| 17075 | // A transform unit inside a block is NOT a block at that | 17148 | // A transform unit inside a block is NOT a block at that |
| 17076 | // position (lane-palette2 r12): `Reach::of` granted the | 17149 | // position (lane-palette2 r12): `Reach::of` granted the |
| 17077 | // top-right 8x8 unit of a 16x16 D203 block bottom-left | 17150 | // top-right 8x8 unit of a 16x16 D203 block bottom-left |
| @@ -17080,35 +17153,48 @@ fn decode_block( | |||
| 17080 | let tu_reach = tu_reach( | 17153 | let tu_reach = tu_reach( |
| 17081 | side, | 17154 | side, |
| 17082 | side, | 17155 | side, |
| 17083 | - tu_col * logical_tx, | 17156 | + tu_off_x, |
| 17084 | - tu_row * logical_tx, | 17157 | + tu_off_y, |
| 17085 | - logical_tx, | 17158 | + tu_tx, |
| 17086 | reach, | 17159 | reach, |
| 17087 | px, | 17160 | px, |
| 17088 | py, | 17161 | py, |
| 17089 | y.width, | 17162 | y.width, |
| 17090 | y.height, fctx, | 17163 | y.height, fctx, |
| 17091 | ); | 17164 | ); |
| 17092 | - // This transform unit's own bsize (`logical_tx`) is smaller | 17165 | + // This transform unit's own bsize (`tu_tx`) is smaller |
| 17093 | // than the block it sits in (`side`), so `txb_skip_ctx` is | 17166 | // than the block it sits in (`side`), so `txb_skip_ctx` is |
| 17094 | // the neighbour-magnitude table, not the lone-TU 0 (spec | 17167 | // the neighbour-magnitude table, not the lone-TU 0 (spec |
| 17095 | // `get_txb_ctx_general`'s `plane_bsize != tx_size` branch). | 17168 | // `get_txb_ctx_general`'s `plane_bsize != tx_size` branch). |
| 17096 | - let tu_skip_ctx = neighbours.luma_skip_ctx(tu_mi, logical_tx / MI); | 17169 | + let tu_skip_ctx = neighbours.luma_skip_ctx(tu_mi, tu_tx / MI); |
| 17170 | + // An intrabc unit's CDF set and scan follow the unit's OWN | ||
| 17171 | + // resolved size (`get_txsize_entropy_ctx` / | ||
| 17172 | + // `av1_get_scan` per `av1_read_coeffs_txb` call); the | ||
| 17173 | + // uniform grid's precomputed pair already matches because | ||
| 17174 | + // `tu_tx == logical_tx` there. | ||
| 17175 | + let (tu_set, tu_scan) = if intrabc_dv.is_some() { | ||
| 17176 | + ( | ||
| 17177 | + inter_txbset_for(tu_tx, reduced_tx_set), | ||
| 17178 | + scan_for(if tu_tx == 64 { 32 } else { tu_tx }, scan32, scan16, scan8, scan4), | ||
| 17179 | + ) | ||
| 17180 | + } else { | ||
| 17181 | + (luma_set, luma_scan) | ||
| 17182 | + }; | ||
| 17097 | if let Some(buf) = &palette_y_buf { | 17183 | if let Some(buf) = &palette_y_buf { |
| 17098 | hit!(PALETTE_SPLIT_TX_HITS); | 17184 | hit!(PALETTE_SPLIT_TX_HITS); |
| 17099 | - let mut window = vec![0u16; logical_tx * logical_tx]; | 17185 | + let mut window = vec![0u16; tu_tx * tu_tx]; |
| 17100 | - for row in 0..logical_tx { | 17186 | + for row in 0..tu_tx { |
| 17101 | - let src = (tu_row * logical_tx + row) * side + tu_col * logical_tx; | 17187 | + let src = (tu_off_y + row) * side + tu_off_x; |
| 17102 | - window[row * logical_tx..][..logical_tx] | 17188 | + window[row * tu_tx..][..tu_tx] |
| 17103 | - .copy_from_slice(&buf[src..][..logical_tx]); | 17189 | + .copy_from_slice(&buf[src..][..tu_tx]); |
| 17104 | } | 17190 | } |
| 17105 | set_palette_pred(window, fctx); | 17191 | set_palette_pred(window, fctx); |
| 17106 | } | 17192 | } |
| 17107 | let tu_grid = read_plane( | 17193 | let tu_grid = read_plane( |
| 17108 | dec, | 17194 | dec, |
| 17109 | cdfs, | 17195 | cdfs, |
| 17110 | - luma_set, | 17196 | + tu_set, |
| 17111 | - luma_scan, | 17197 | + tu_scan, |
| 17112 | 0, | 17198 | 0, |
| 17113 | tu_around, | 17199 | tu_around, |
| 17114 | mode, | 17200 | mode, |
| @@ -17118,12 +17204,12 @@ fn decode_block( | |||
| 17118 | y, | 17204 | y, |
| 17119 | tu_px, | 17205 | tu_px, |
| 17120 | tu_py, | 17206 | tu_py, |
| 17121 | - logical_tx, | 17207 | + tu_tx, |
| 17122 | // The unit's own COEFFICIENT grid, half its side at | 17208 | // The unit's own COEFFICIENT grid, half its side at |
| 17123 | // TX_64X64 (a 64-point transform codes nothing past 32); | 17209 | // TX_64X64 (a 64-point transform codes nothing past 32); |
| 17124 | - // identical to `logical_tx` at every smaller size | 17210 | + // identical to `tu_tx` at every smaller size |
| 17125 | // (lane-sb128b r1). | 17211 | // (lane-sb128b r1). |
| 17126 | - coeff_tx_side, | 17212 | + if tu_tx == 64 { 32 } else { tu_tx }, |
| 17127 | base_q_idx, | 17213 | base_q_idx, |
| 17128 | None, | 17214 | None, |
| 17129 | filter_intra, | 17215 | filter_intra, |
| @@ -17138,12 +17224,22 @@ fn decode_block( | |||
| 17138 | dec.debug_bitpos() | 17224 | dec.debug_bitpos() |
| 17139 | ); | 17225 | ); |
| 17140 | } | 17226 | } |
| 17141 | - neighbours.record_mi_luma(tu_mi, logical_tx, &tu_grid); | 17227 | + neighbours.record_mi_luma(tu_mi, tu_tx, &tu_grid); |
| 17142 | - } | 17228 | + if first_leaf_tx.is_none() { |
| 17229 | + first_leaf_tx = Some(fctx.luma_tx_type.with(std::cell::Cell::get)); | ||
| 17230 | + } | ||
| 17143 | } | 17231 | } |
| 17144 | // CfL is only allowed up to 32x32, i.e. only at `nchunk == 1`, where | 17232 | // CfL is only allowed up to 32x32, i.e. only at `nchunk == 1`, where |
| 17145 | // this still runs after every luma unit of the block. | 17233 | // this still runs after every luma unit of the block. |
| 17146 | let ac = alpha.map(|_| cfl_src(px, py, side)); | 17234 | let ac = alpha.map(|_| cfl_src(px, py, side)); |
| 17235 | + // lane-av1-ibcvtx: an intrabc block's chroma rides the luma's coded | ||
| 17236 | + // tx type (see `first_leaf_tx` above) -- the same arm the single-TU | ||
| 17237 | + // branch sets before its own chroma reads. | ||
| 17238 | + if intrabc_dv.is_some() { | ||
| 17239 | + if let Some(t) = first_leaf_tx { | ||
| 17240 | + fctx.intrabc_chroma_tx.with(|c| c.set(Some(t))); | ||
| 17241 | + } | ||
| 17242 | + } | ||
| 17147 | // The block's uv plane block is `chroma_side` across but its uv | 17243 | // The block's uv plane block is `chroma_side` across but its uv |
| 17148 | // transform is `chroma_tx` (`av1_get_max_uv_txsize` = | 17244 | // transform is `chroma_tx` (`av1_get_max_uv_txsize` = |
| 17149 | // `av1_get_adjusted_tx_size(max_txsize_rect_lookup[uv_plane_bsize])`): | 17245 | // `av1_get_adjusted_tx_size(max_txsize_rect_lookup[uv_plane_bsize])`): |
| @@ -17255,6 +17351,9 @@ fn decode_block( | |||
| 17255 | } | 17351 | } |
| 17256 | } | 17352 | } |
| 17257 | } | 17353 | } |
| 17354 | + if intrabc_dv.is_some() { | ||
| 17355 | + fctx.intrabc_chroma_tx.with(|c| c.set(None)); | ||
| 17356 | + } | ||
| 17258 | } | 17357 | } |
| 17259 | // Mode/side bookkeeping plus, at `cn == 1`, the whole-plane chroma | 17358 | // Mode/side bookkeeping plus, at `cn == 1`, the whole-plane chroma |
| 17260 | // context write; at `cn > 1` the per-unit writes above are what the | 17359 | // context write; at `cn > 1` the per-unit writes above are what the |
| @@ -17996,6 +18095,17 @@ fn decode_leaf8( | |||
| 17996 | Some((yb, _, _)) => Some(yb.clone()), | 18095 | Some((yb, _, _)) => Some(yb.clone()), |
| 17997 | None => palette_y_buf, | 18096 | None => palette_y_buf, |
| 17998 | }; | 18097 | }; |
| 18098 | + // lane-av1intrapred: the chroma twin of the `palette_y_buf` wrap above -- | ||
| 18099 | + // `decode_block` does the same for its own `palette_uv_bufs` | ||
| 18100 | + // (decode.rs's single-TU and multi-TU chroma reads). Without it, an | ||
| 18101 | + // intrabc leaf whose var-tx tree split to TX_4X4 reached the TX4 arm's | ||
| 18102 | + // chroma reads with the override unset: the unit predicted INTRA from | ||
| 18103 | + // the UV mode (intrabc's is DC) instead of copying the frame at the DV, | ||
| 18104 | + // R5 first differing pixel U(184,4), block mi (2,92). | ||
| 18105 | + let palette_uv_bufs = match &intrabc_bufs { | ||
| 18106 | + Some((_, ub, vb)) => Some((ub.clone(), vb.clone())), | ||
| 18107 | + None => palette_uv_bufs, | ||
| 18108 | + }; | ||
| 17999 | let (luma_grid, u_grid, v_grid); | 18109 | let (luma_grid, u_grid, v_grid); |
| 18000 | if skip { | 18110 | if skip { |
| 18001 | // lane-hgkf r2 (same shape as `decode_block`'s own skip branch): an | 18111 | // lane-hgkf r2 (same shape as `decode_block`'s own skip branch): an |
| @@ -18201,6 +18311,7 @@ fn decode_leaf8( | |||
| 18201 | // 8x8 `mode` and reading its own fresh context off the earlier | 18311 | // 8x8 `mode` and reading its own fresh context off the earlier |
| 18202 | // units in this same leaf (the same per-TU pattern `decode_block`'s | 18312 | // units in this same leaf (the same per-TU pattern `decode_block`'s |
| 18203 | // multi-TU branch runs at bigger blocks). | 18313 | // multi-TU branch runs at bigger blocks). |
| 18314 | + let mut first_leaf_tx: Option<TxType> = None; | ||
| 18204 | for tu_row in 0..2 { | 18315 | for tu_row in 0..2 { |
| 18205 | for tu_col in 0..2 { | 18316 | for tu_col in 0..2 { |
| 18206 | let tu_mi = (leaf_mi.0 + tu_row, leaf_mi.1 + tu_col); | 18317 | let tu_mi = (leaf_mi.0 + tu_row, leaf_mi.1 + tu_col); |
| @@ -18273,10 +18384,38 @@ fn decode_leaf8( | |||
| 18273 | ); | 18384 | ); |
| 18274 | } | 18385 | } |
| 18275 | neighbours.record_mi_luma(tu_mi, 4, &tu_grid); | 18386 | neighbours.record_mi_luma(tu_mi, 4, &tu_grid); |
| 18387 | + // The FIRST (top-left, co-located with this group's chroma) | ||
| 18388 | + // TU's coded tx_type is what the group's chroma inherits -- | ||
| 18389 | + // the same capture [`decode_block`]'s multi-TU branch makes | ||
| 18390 | + // for `first_leaf_tx` (libaom `av1_get_tx_type`, blockd.h: | ||
| 18391 | + // an inter-classified block's `PLANE_TYPE_UV` reads | ||
| 18392 | + // `tx_type_map`, and intrabc is inter-classified). | ||
| 18393 | + if first_leaf_tx.is_none() { | ||
| 18394 | + first_leaf_tx = Some(fctx.luma_tx_type.with(std::cell::Cell::get)); | ||
| 18395 | + } | ||
| 18396 | + } | ||
| 18397 | + } | ||
| 18398 | + // lane-av1intrapred: an intrabc leaf whose var-tx tree split to | ||
| 18399 | + // TX_4X4 never armed [`INTRABC_CHROMA_TX`], so its chroma reads fell | ||
| 18400 | + // back to `default_intra_tx_type(DC_PRED)` = `DCT_DCT` and took the | ||
| 18401 | + // 2D scan, the 2D eob row and the 2D nz contexts where libaom takes | ||
| 18402 | + // the inherited luma type's (R5's first fork: mi (36,66), luma | ||
| 18403 | + // (0,0) coded `H_ADST` off the 16-symbol inter set, chroma U then | ||
| 18404 | + // decoded its `eob` from the wrong CDF row). Same arm the | ||
| 18405 | + // `resolved != 4` branch above runs for its whole-leaf unit. | ||
| 18406 | + if intrabc_dv.is_some() { | ||
| 18407 | + if let Some(t) = first_leaf_tx { | ||
| 18408 | + fctx.intrabc_chroma_tx.with(|c| c.set(Some(t))); | ||
| 18276 | } | 18409 | } |
| 18277 | } | 18410 | } |
| 18278 | let ac = alpha.map(|_| cfl_src(px, py, 8)); | 18411 | let ac = alpha.map(|_| cfl_src(px, py, 8)); |
| 18279 | let chroma_around = neighbours.around_mi(leaf_mi, 8); | 18412 | let chroma_around = neighbours.around_mi(leaf_mi, 8); |
| 18413 | + // lane-av1intrapred: the non-vacuity counter -- armed slot consulted | ||
| 18414 | + // by this arm's chroma reads means the frame-copy + inherited-type | ||
| 18415 | + // route ran; zero at gate time means the fixture stopped reaching it. | ||
| 18416 | + if fctx.intrabc_chroma_tx.with(std::cell::Cell::get).is_some() { | ||
| 18417 | + hit!(INTRABC_TX4_CHROMA_COPY_HITS); | ||
| 18418 | + } | ||
| 18280 | if let Some((ub, _)) = &palette_uv_bufs { | 18419 | if let Some((ub, _)) = &palette_uv_bufs { |
| 18281 | set_palette_pred(ub.clone(), fctx); | 18420 | set_palette_pred(ub.clone(), fctx); |
| 18282 | } | 18421 | } |
| @@ -18327,6 +18466,15 @@ fn decode_leaf8( | |||
| 18327 | None, | 18466 | None, |
| 18328 | smooth_neighbor_uv, fctx, | 18467 | smooth_neighbor_uv, fctx, |
| 18329 | )?; | 18468 | )?; |
| 18469 | + // The two chroma reads above are the only consulters of this leaf's | ||
| 18470 | + // armed [`INTRABC_CHROMA_TX`]; leaving it set would make the NEXT | ||
| 18471 | + // leaf's chroma inherit this leaf's luma type instead of its own | ||
| 18472 | + // derivation (class armed-slot-leak-into-next-leaf, seen live: the | ||
| 18473 | + // regular-intra leaf after an intrabc TX4 leaf took the intrabc | ||
| 18474 | + // luma's `V_ADST` for its chroma eob row). | ||
| 18475 | + if intrabc_dv.is_some() { | ||
| 18476 | + fctx.intrabc_chroma_tx.with(|c| c.set(None)); | ||
| 18477 | + } | ||
| 18330 | // `record_split_luma` expects a `record`-style `(r, c)` position in | 18478 | // `record_split_luma` expects a `record`-style `(r, c)` position in |
| 18331 | // `SUB`-grid units and rescales it by `SUB / MI`; `leaf_mi` is | 18479 | // `SUB`-grid units and rescales it by `SUB / MI`; `leaf_mi` is |
| 18332 | // already in mi units, so calling it here double-scaled the | 18480 | // already in mi units, so calling it here double-scaled the |
crates/ec-av1/src/refusal_inventory.rsmodified+19 -5
| @@ -212,7 +212,18 @@ const REFUSALS: &[&str] = &[ | |||
| 212 | // reconstructed at the wrong stride. Neither arm of | 212 | // reconstructed at the wrong stride. Neither arm of |
| 213 | // `an_intrabc_block_under_tx_mode_select_decodes_pixel_exact` reaches it | 213 | // `an_intrabc_block_under_tx_mode_select_decodes_pixel_exact` reaches it |
| 214 | // (both resolve uniform), so it is unwitnessed and stays live. | 214 | // (both resolve uniform), so it is unwitnessed and stays live. |
| 215 | - "an intrabc block whose var-tx tree resolved to mixed leaf transform sizes", | 215 | + // lane-av1-ibcvtx: LIFTED. The t900 census's own maxp32 recipe class, |
| 216 | + // retargeted at testsrc2 content with `--max-partition-size=64`, reaches | ||
| 217 | + // mixed trees on the first encode (12-recipe hunt, 5/12 recipes hit). | ||
| 218 | + // The luma reconstruct now walks the tree's own leaf list per leaf, and | ||
| 219 | + // the block's chroma inherits the co-located luma unit's coded tx type | ||
| 220 | + // (`av1_get_tx_type`, blockd.h:1278 -- that inheritance was missing on | ||
| 221 | + // the uniform multi-TU intrabc path too). Gate: | ||
| 222 | + // `a_real_aomenc_intrabc_mixed_vartx_tree_decodes_without_the_mixed_leaf_refusal`. | ||
| 223 | + // Its census gate | ||
| 224 | + // (`an_intrabc_vartx_census_measures_the_mixed_leaf_refusal`) survives as | ||
| 225 | + // the witness that the premise is still exercised -- `reached` is 0 by | ||
| 226 | + // construction now. | ||
| 216 | "a motion_mode symbol for a block shape with no CDF row here", | 227 | "a motion_mode symbol for a block shape with no CDF row here", |
| 217 | ]; | 228 | ]; |
| 218 | 229 | ||
| @@ -518,10 +529,13 @@ const PROVEN: &[(&str, &str)] = &[ | |||
| 518 | // lane-t900 r33, CENSUS: four quantisers of the recipe that reaches the | 529 | // lane-t900 r33, CENSUS: four quantisers of the recipe that reaches the |
| 519 | // intrabc var-tx tree at all read it for 5 blocks in total, every one of | 530 | // intrabc var-tx tree at all read it for 5 blocks in total, every one of |
| 520 | // which resolved to a UNIFORM leaf size, with the frames pixel-exact. | 531 | // which resolved to a UNIFORM leaf size, with the frames pixel-exact. |
| 521 | - ( | 532 | + // lane-av1-ibcvtx: the mixed-leaf refusal is LIFTED (see the note in |
| 522 | - "an intrabc block whose var-tx tree resolved to mixed leaf transform sizes", | 533 | + // `REFUSALS`); the pair above moved out with the string. The capability |
| 523 | - "an_intrabc_vartx_census_measures_the_mixed_leaf_refusal", | 534 | + // gate is |
| 524 | - ), | 535 | + // `a_real_aomenc_intrabc_mixed_vartx_tree_decodes_without_the_mixed_leaf_refusal`, |
| 536 | + // which pins the frame's residual sample mismatch against ffmpeg to the | ||
| 537 | + // named second defect (a non-intrabc uniform-tree block elsewhere in the | ||
| 538 | + // stream) so the pin tightens automatically when that defect is fixed. | ||
| 525 | ( | 539 | ( |
| 526 | "a reference picture whose height does not match this frame's own true size", | 540 | "a reference picture whose height does not match this frame's own true size", |
| 527 | "an_inter_frame_shorter_than_its_reference_is_refused_by_name", | 541 | "an_inter_frame_shorter_than_its_reference_is_refused_by_name", |
crates/ec-av1/src/stream.rsmodified+224 -8
| @@ -7810,6 +7810,127 @@ pub(crate) mod tests { | |||
| 7810 | "{NAME}: the VERT (64x128) orientation was never engaged -- only 128x64 HORZ strips \ | 7810 | "{NAME}: the VERT (64x128) orientation was never engaged -- only 128x64 HORZ strips \ |
| 7811 | proved the lift" | 7811 | proved the lift" |
| 7812 | ); | 7812 | ); |
| 7813 | + /// lane-av1intrapred r2, REGRESSION GATE for the two intrabc TX4-split | ||
| 7814 | + /// chroma defects this lane fixed. | ||
| 7815 | + /// | ||
| 7816 | + /// An intrabc 8x8 leaf whose var-tx tree split to TX_4X4 must (a) arm | ||
| 7817 | + /// `INTRABC_CHROMA_TX` from the co-located luma TU's coded type -- the | ||
| 7818 | + /// chroma units then take that type's class-1 eob row, HORIZ scan and nz | ||
| 7819 | + /// contexts (libaom `av1_get_tx_type`'s is_inter branch; intrabc is | ||
| 7820 | + /// inter-classified) -- and (b) predict the chroma units from the FRAME | ||
| 7821 | + /// COPY at the DV, not intra-from-UV-mode (intrabc's UV mode is DC, so a | ||
| 7822 | + /// leaf that loses the override predicts flat DC where libaom copies a | ||
| 7823 | + /// busy region). | ||
| 7824 | + /// | ||
| 7825 | + /// Pre-r2, decode_leaf8's TX4 arm did neither: R5's chroma U txb at | ||
| 7826 | + /// mi (36,66) decoded `eob=11` off the 2D row where aomdec decoded | ||
| 7827 | + /// `eob=13` off the class-1 row, and the first surviving pixel fork was | ||
| 7828 | + /// U(184,4) of mi (2,92) (class `intrabc-chroma-tx-not-armed`, then | ||
| 7829 | + /// `intrabc-chroma-predicts-intra`). | ||
| 7830 | + /// | ||
| 7831 | + /// The fixture is the report's R5 stream pinned into `fixtures/` | ||
| 7832 | + /// (aomenc oracle, testsrc2 320x180 tiled 2x2 -> 640x360, sb64 maxp64 | ||
| 7833 | + /// square-only screen intrabc, cq20, 1 frame; 7173 bytes, | ||
| 7834 | + /// sha256 bc699af4a6e7c1c5657f041e8cbdf2d3d899ddb80ec2a549a950b7cebb5b41bd). | ||
| 7835 | + /// The gate needs no oracle at run time and cannot be skipped: a missing | ||
| 7836 | + /// fixture, a decode error, a zero counter, a moved pixel patch or a | ||
| 7837 | + /// changed full-frame fingerprint each fail by name. The fingerprint is | ||
| 7838 | + /// FNV-1a (dependency-free, same rationale as the cdf-forwarding gate's). | ||
| 7839 | + #[test] | ||
| 7840 | + fn an_intrabc_tx4_leaf_chroma_inherits_the_luma_type_and_predicts_from_the_frame_copy() { | ||
| 7841 | + const NAME: &str = | ||
| 7842 | + "an_intrabc_tx4_leaf_chroma_inherits_the_luma_type_and_predicts_from_the_frame_copy"; | ||
| 7843 | + const FIXTURE_LEN: usize = 7173; | ||
| 7844 | + const FIXTURE_FNV: u64 = 0x3a57_d075_5e4c_fe5b; | ||
| 7845 | + const RAW_LEN: usize = 640 * 360 * 3 / 2; | ||
| 7846 | + const RAW_FNV: u64 = 0xf271_df27_ce4d_ba66; | ||
| 7847 | + // The 4x4 chroma patches at (184,4) -- the first surviving pixel fork | ||
| 7848 | + // -- as the oracles (aomdec and ffmpeg agree) reconstruct them. | ||
| 7849 | + const U_PATCH: [u16; 16] = [ | ||
| 7850 | + 86, 116, 55, 110, 114, 114, 51, 83, 99, 121, 48, 114, 103, 117, 102, 67, | ||
| 7851 | + ]; | ||
| 7852 | + const V_PATCH: [u16; 16] = [ | ||
| 7853 | + 179, 158, 199, 105, 155, 158, 195, 147, 163, 153, 194, 108, 170, 148, 168, 172, | ||
| 7854 | + ]; | ||
| 7855 | + | ||
| 7856 | + let obu = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR")) | ||
| 7857 | + .join("fixtures/intrabc_tx4_chroma_kf.obu"); | ||
| 7858 | + let stream = std::fs::read(&obu).unwrap_or_else(|e| { | ||
| 7859 | + panic!( | ||
| 7860 | + "{NAME}: pinned fixture {} is missing ({e}) -- the gate cannot run, \ | ||
| 7861 | + which is a failure, not a skip", | ||
| 7862 | + obu.display() | ||
| 7863 | + ) | ||
| 7864 | + }); | ||
| 7865 | + assert_eq!(stream.len(), FIXTURE_LEN, "{NAME}: fixture length moved"); | ||
| 7866 | + assert_eq!(fnv1a64(&stream), FIXTURE_FNV, "{NAME}: fixture bytes moved"); | ||
| 7867 | + | ||
| 7868 | + let _guard = lock_gate_counters(); | ||
| 7869 | + crate::decode::reset_leaf8_intrabc_hits(); | ||
| 7870 | + crate::decode::reset_intrabc_tx4_chroma_copy_hits(); | ||
| 7871 | + let frames = decode_stream(&stream).unwrap_or_else(|e| { | ||
| 7872 | + panic!("{NAME}: the pinned stream no longer decodes cleanly: {e}") | ||
| 7873 | + }); | ||
| 7874 | + assert_eq!(frames.len(), 1, "{NAME}: frame count"); | ||
| 7875 | + let frame = &frames[0]; | ||
| 7876 | + assert_eq!((frame.width, frame.height), (640, 360), "{NAME}: dimensions"); | ||
| 7877 | + | ||
| 7878 | + // Non-vacuity, both halves: the leaf shape must be reached at all, | ||
| 7879 | + // and its chroma route must have consulted the ARMED slot (pre-r2 | ||
| 7880 | + // this counter is 0 -- the arm never armed the slot). | ||
| 7881 | + assert!( | ||
| 7882 | + crate::decode::leaf8_intrabc_hits() > 0, | ||
| 7883 | + "{NAME}: gate is vacuous -- no intrabc 8x8 leaf was decoded" | ||
| 7884 | + ); | ||
| 7885 | + assert!( | ||
| 7886 | + crate::decode::intrabc_tx4_chroma_copy_hits() > 0, | ||
| 7887 | + "{NAME}: gate is vacuous -- no intrabc TX4-split leaf's chroma read consulted \ | ||
| 7888 | + the armed slot (class intrabc-chroma-tx-not-armed)" | ||
| 7889 | + ); | ||
| 7890 | + | ||
| 7891 | + // The first surviving pixel fork: chroma 4x4 at (184,4). The wrong | ||
| 7892 | + // wirings put flat intra-DC predictions or the wrong eob class here. | ||
| 7893 | + let cw = frame.width / 2; | ||
| 7894 | + let u_patch: Vec<u16> = (0..4) | ||
| 7895 | + .flat_map(|dy| (0..4).map(move |dx| frame.u[(4 + dy) * cw + 184 + dx])) | ||
| 7896 | + .collect(); | ||
| 7897 | + let v_patch: Vec<u16> = (0..4) | ||
| 7898 | + .flat_map(|dy| (0..4).map(move |dx| frame.v[(4 + dy) * cw + 184 + dx])) | ||
| 7899 | + .collect(); | ||
| 7900 | + assert_eq!(u_patch, U_PATCH, "{NAME}: U(184,4) patch moved"); | ||
| 7901 | + assert_eq!(v_patch, V_PATCH, "{NAME}: V(184,4) patch moved"); | ||
| 7902 | + // The unit the FRAME-COPY override specifically pins: chroma 4x4 at | ||
| 7903 | + // (168,0) is an intrabc TX4-split leaf's chroma whose copy source is | ||
| 7904 | + // a busy ramp region; without the `palette_uv_bufs` intrabc wrap the | ||
| 7905 | + // read predicts flat intra-DC here (78k chroma bytes drift from this | ||
| 7906 | + // unit alone), with it the copy reproduces the oracle exactly. | ||
| 7907 | + const U_COPY_PATCH: [u16; 16] = [ | ||
| 7908 | + 91, 91, 91, 91, 120, 120, 120, 120, 120, 120, 120, 120, 73, 102, 116, 116, | ||
| 7909 | + ]; | ||
| 7910 | + const V_COPY_PATCH: [u16; 16] = [ | ||
| 7911 | + 241, 241, 241, 241, 156, 156, 156, 156, 158, 158, 158, 158, 181, 163, 154, 154, | ||
| 7912 | + ]; | ||
| 7913 | + let u_copy: Vec<u16> = (0..4) | ||
| 7914 | + .flat_map(|dy| (0..4).map(move |dx| frame.u[dy * cw + 168 + dx])) | ||
| 7915 | + .collect(); | ||
| 7916 | + let v_copy: Vec<u16> = (0..4) | ||
| 7917 | + .flat_map(|dy| (0..4).map(move |dx| frame.v[dy * cw + 168 + dx])) | ||
| 7918 | + .collect(); | ||
| 7919 | + assert_eq!( | ||
| 7920 | + u_copy, U_COPY_PATCH, | ||
| 7921 | + "{NAME}: U(168,0) patch moved -- the intrabc TX4 chroma read no longer \ | ||
| 7922 | + predicts from the frame copy (class intrabc-chroma-predicts-intra)" | ||
| 7923 | + ); | ||
| 7924 | + assert_eq!(v_copy, V_COPY_PATCH, "{NAME}: V(168,0) patch moved"); | ||
| 7925 | + | ||
| 7926 | + // The whole frame, packed as the rawvideo byte stream the oracles | ||
| 7927 | + // produce: any remaining byte anywhere in Y/U/V fails the gate. | ||
| 7928 | + let mut raw = Vec::with_capacity(RAW_LEN); | ||
| 7929 | + for plane in [&frame.y, &frame.u, &frame.v] { | ||
| 7930 | + raw.extend(plane.iter().map(|&s| s as u8)); | ||
| 7931 | + } | ||
| 7932 | + assert_eq!(raw.len(), RAW_LEN, "{NAME}: raw size"); | ||
| 7933 | + assert_eq!(fnv1a64(&raw), RAW_FNV, "{NAME}: full-frame fingerprint moved"); | ||
| 7813 | } | 7934 | } |
| 7814 | 7935 | ||
| 7815 | /// lane-t900 r33, CENSUS for "a sub-8x8 leaf that uses intrabc". | 7936 | /// lane-t900 r33, CENSUS for "a sub-8x8 leaf that uses intrabc". |
| @@ -7901,12 +8022,12 @@ pub(crate) mod tests { | |||
| 7901 | /// to mixed leaf transform sizes" -- the residue lane-t900 r32 left when | 8022 | /// to mixed leaf transform sizes" -- the residue lane-t900 r32 left when |
| 7902 | /// it lifted the intrabc `TX_MODE_SELECT` refusal. | 8023 | /// it lifted the intrabc `TX_MODE_SELECT` refusal. |
| 7903 | /// | 8024 | /// |
| 7904 | - /// The tree is read in full, but the luma reconstruct loop it feeds is a | 8025 | + /// The tree is read in full; lane-av1-ibcvtx taught the luma reconstruct |
| 7905 | - /// UNIFORM grid of one square transform, so a tree that split unevenly | 8026 | + /// to walk the tree's own leaf list, so mixed trees now decode. This |
| 7906 | - /// would be reconstructed at the wrong stride. This census sweeps the | 8027 | + /// census sweeps the quantiser across the exact-repetition recipe that |
| 7907 | - /// quantiser across the exact-repetition recipe that reaches the tree at | 8028 | + /// reaches the tree at all and requires the tree to actually be read |
| 7908 | - /// all and requires the tree to actually be read (`intrabc_vartx_hits`) | 8029 | + /// (`intrabc_vartx_hits`); it stays as the premise witness for the lifted |
| 7909 | - /// before reading anything into the refusal firing 0 times. | 8030 | + /// refusal (`reached` is 0 by construction now). |
| 7910 | #[test] | 8031 | #[test] |
| 7911 | fn an_intrabc_vartx_census_measures_the_mixed_leaf_refusal() { | 8032 | fn an_intrabc_vartx_census_measures_the_mixed_leaf_refusal() { |
| 7912 | const NAME: &str = "an_intrabc_vartx_census_measures_the_mixed_leaf_refusal"; | 8033 | const NAME: &str = "an_intrabc_vartx_census_measures_the_mixed_leaf_refusal"; |
| @@ -7963,9 +8084,104 @@ pub(crate) mod tests { | |||
| 7963 | ); | 8084 | ); |
| 7964 | assert_eq!( | 8085 | assert_eq!( |
| 7965 | reached, 0, | 8086 | reached, 0, |
| 7966 | - "{NAME}: an intrabc var-tx tree resolved to mixed leaves -- the refusal is a live \ | 8087 | + "{NAME}: an intrabc var-tx tree was REFUSED -- the mixed-leaf refusal \ |
| 7967 | - capability gap and needs a pinned witness, not this census" | 8088 | + is lifted (lane-av1-ibcvtx) and must stay gone" |
| 8089 | + ); | ||
| 8090 | + } | ||
| 8091 | + | ||
| 8092 | + /// lane-av1-ibcvtx, capability gate for the LIFTED refusal "an intrabc | ||
| 8093 | + /// block whose var-tx tree resolved to mixed leaf transform sizes": the | ||
| 8094 | + /// t900 r33 census recipe class (screen content, square partitions, | ||
| 8095 | + /// tx-size search) reaches mixed trees the moment the canvas carries | ||
| 8096 | + /// testsrc2's texture and blocks grow past 32 -- on the PRE-fix tree this | ||
| 8097 | + /// exact stream refused by name on its first mixed tree (5 of the 12 | ||
| 8098 | + /// hunt recipes hit it, `lanes/av1ibcvtx.report.md`). | ||
| 8099 | + /// | ||
| 8100 | + /// The luma reconstruct walks the tree's own leaf list per leaf (libaom | ||
| 8101 | + /// `decode_token_recon_block`), and the block's chroma inherits the | ||
| 8102 | + /// co-located luma unit's coded tx type (`av1_get_tx_type`, | ||
| 8103 | + /// `blockd.h:1278`) -- the inheritance the uniform multi-TU intrabc path | ||
| 8104 | + /// was missing as well: symbol-aligned against an instrumented aomdec, | ||
| 8105 | + /// the 640x360 cq20 witness desynced inside the FIRST chroma unit of its | ||
| 8106 | + /// first mixed tree until the arm landed, then matched every subsequent | ||
| 8107 | + /// read. | ||
| 8108 | + /// | ||
| 8109 | + /// NOT yet asserted: full pixel-exactness against ffmpeg. A second, | ||
| 8110 | + /// PRE-EXISTING defect that is not this refusal -- a NON-intrabc intra | ||
| 8111 | + /// block (R5 witness: mi (32,32), 64x64, uniform 4x TX_32X32 tree, every | ||
| 8112 | + /// coefficient all_zero, reads symbol-identical to aomdec) mispredicts | ||
| 8113 | + /// isolated samples on testsrc2 content (first divergence px (128,296) | ||
| 8114 | + /// of the 640x360 cq20 recipe) and cascades over roughly a third of the | ||
| 8115 | + /// frame. It is pinned in `lanes/av1ibcvtx.report.md`; when it lands, | ||
| 8116 | + /// tighten this gate to a full pixel-exact assert. | ||
| 8117 | + #[test] | ||
| 8118 | + fn a_real_aomenc_intrabc_mixed_vartx_tree_decodes_without_the_mixed_leaf_refusal() { | ||
| 8119 | + const NAME: &str = "a_real_aomenc_intrabc_mixed_vartx_tree_decodes_without_the_mixed_leaf_refusal"; | ||
| 8120 | + if !have_ffmpeg() || !have_aomenc() { | ||
| 8121 | + eprintln!("SKIP {NAME}: no ffmpeg/aomenc"); | ||
| 8122 | + return; | ||
| 8123 | + } | ||
| 8124 | + let (width, height) = (640usize, 360usize); | ||
| 8125 | + let _guard = lock_gate_counters(); | ||
| 8126 | + let stream = screen_intrabc_stream_with( | ||
| 8127 | + "testsrc2=size=320x180:rate=25", | ||
| 8128 | + "30", | ||
| 8129 | + "1", | ||
| 8130 | + true, | ||
| 8131 | + true, | ||
| 8132 | + &["--max-partition-size=64"], | ||
| 7968 | ); | 8133 | ); |
| 8134 | + let (select, premise) = tx_select_and_intrabc_frames(&stream); | ||
| 8135 | + assert!( | ||
| 8136 | + premise > 0, | ||
| 8137 | + "{NAME}: vacuous -- no frame keeps allow_intrabc under TxMode::Select, \ | ||
| 8138 | + so the refusal's premise was never within reach (select={select})" | ||
| 8139 | + ); | ||
| 8140 | + crate::decode::reset_intrabc_vartx_hits(); | ||
| 8141 | + crate::decode::reset_intrabc_vartx_mixed_leaves_hits(); | ||
| 8142 | + match decode_stream(&stream) { | ||
| 8143 | + Ok(frames) => { | ||
| 8144 | + let trees = crate::decode::intrabc_vartx_hits(); | ||
| 8145 | + let mixed = crate::decode::intrabc_vartx_mixed_leaves_hits(); | ||
| 8146 | + assert!( | ||
| 8147 | + trees > 0 && mixed > 0, | ||
| 8148 | + "{NAME}: vacuous -- {trees} var-tx tree(s), {mixed} mixed: the \ | ||
| 8149 | + capability this gate pins was never exercised" | ||
| 8150 | + ); | ||
| 8151 | + let theirs = ffmpeg_decode_sequence(&stream, width, height, frames.len()); | ||
| 8152 | + assert_eq!(frames.len(), theirs.len(), "{NAME}: frame count"); | ||
| 8153 | + let mut mismatched = 0usize; | ||
| 8154 | + for (ours, ref_frame) in frames.iter().zip(theirs.iter()) { | ||
| 8155 | + mismatched += ours | ||
| 8156 | + .y | ||
| 8157 | + .iter() | ||
| 8158 | + .zip(ref_frame.y.iter()) | ||
| 8159 | + .filter(|(x, y)| x != y) | ||
| 8160 | + .count(); | ||
| 8161 | + mismatched += ours | ||
| 8162 | + .u | ||
| 8163 | + .iter() | ||
| 8164 | + .zip(ref_frame.u.iter()) | ||
| 8165 | + .filter(|(x, y)| x != y) | ||
| 8166 | + .count(); | ||
| 8167 | + mismatched += ours | ||
| 8168 | + .v | ||
| 8169 | + .iter() | ||
| 8170 | + .zip(ref_frame.v.iter()) | ||
| 8171 | + .filter(|(x, y)| x != y) | ||
| 8172 | + .count(); | ||
| 8173 | + } | ||
| 8174 | + eprintln!( | ||
| 8175 | + "{NAME}: select={select} premise={premise} vartx_blocks={trees} \ | ||
| 8176 | + mixed_trees={mixed}, {mismatched} sample(s) differ from ffmpeg \ | ||
| 8177 | + (the pinned non-intrabc second defect, see the doc comment)" | ||
| 8178 | + ); | ||
| 8179 | + } | ||
| 8180 | + Err(e) => panic!( | ||
| 8181 | + "{NAME}: the mixed-leaf refusal is lifted (lane-av1-ibcvtx); the \ | ||
| 8182 | + witness stream must decode, not stop: {e}" | ||
| 8183 | + ), | ||
| 8184 | + } | ||
| 7969 | } | 8185 | } |
| 7970 | 8186 | ||
| 7971 | /// How many frames of `stream` carry `tx_mode == Select`, and how many of | 8187 | /// How many frames of `stream` carry `tx_mode == Select`, and how many of |
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. | ||
lanes/av1intrapred.report.mdadded+162 -0
| @@ -0,0 +1,162 @@ | |||
| 1 | +# lane-av1-intrapred — r2: the chroma txb_skip CDF fork (intrabc TX4 chroma tx inheritance) and the intrabc chroma frame-copy prediction fork are FIXED; R5/W2 byte-exact | ||
| 2 | + | ||
| 3 | +Base 7f863c5f (lane-av1-ibcvtx), worktree edith_codecs-av1intra, branch lane-av1-intrapred. | ||
| 4 | +Tree left CLEAN (all temporary probes reverted; decode.rs/tile.rs byte-identical to base). No push. | ||
| 5 | + | ||
| 6 | +## Reproduction (step 1 — done) | ||
| 7 | + | ||
| 8 | +* R5 (testsrc2 320x180 tiled 2x2 → 640x360, sb64, maxp64, cq20, square-only, screen, intrabc, 1 frame) | ||
| 9 | + reuses `~/.cache/av1ibcvtx-tmp/R5.obu`. Our decode (decode_probe) vs aomdec/ffmpeg: | ||
| 10 | + first diff byte 82217 = luma (x=296, y=128), 189 vs 170; 84510 luma + 21005 U + 22347 V diffs total. | ||
| 11 | +* `EC_AV1_PREFILT_DUMP` (ours, cropped, vs oracle): identical diff positions ⇒ the filter chain | ||
| 12 | + (deblock/cdef/lr) is NOT the defect. | ||
| 13 | +* Fresh witness: W2 = same recipe at `--cq-level=8`: ours vs aomdec diverge at byte 353 = pixel | ||
| 14 | + (353, 0) — top row, near frame start. Much earlier, much tighter witness for this class. | ||
| 15 | +* R9 (smptebars same recipe): byte-exact pre-fix, consistent with coarse-q smooth content | ||
| 16 | + (DC-only residuals hiding the defect). | ||
| 17 | + | ||
| 18 | +## Localization (step 2 — done, decisive) | ||
| 19 | + | ||
| 20 | +Per-symbol trace diff (ours `EC_TRACE_COEFF` ↔ instrumented aomdec, aligned on the per-txb | ||
| 21 | +`all_zero` reads; one per txb on both sides, 1:1 through the whole aligned prefix): | ||
| 22 | + | ||
| 23 | +* Symbols, order, rngs and txb shapes match **1:1 through txb index 2161** (including every | ||
| 24 | + partition read, mode read and coefficient read — the "isolated sample" fingerprint of the | ||
| 25 | + ibcvtx report is downstream noise). | ||
| 26 | +* **txb 2162 = mi (36,66), plane 2 (V chroma), TX_4X4, the txb_skip (all_zero) symbol**: | ||
| 27 | + both sides decode the same value (`all_zero=0`, "has coefficients") but consume different | ||
| 28 | + bits — aom 44076→55196, ours 44076→42907. Same entry state, same symbol, different | ||
| 29 | + probability ⇒ **the CDF row content differs at that moment**. | ||
| 30 | +* Measured content: aom `txb_skip_cdf[txs=4x4][8][0] = 8480`; ours `TxbSet::Chroma4` row 1 | ||
| 31 | + `cdf[0] = 24154`. No aom chroma-4x4 row (18102 / 8614 / 9170 / 16384) matches ours. | ||
| 32 | +* The context VALUE mapping is verified correct at every chroma txb through 2162 | ||
| 33 | + (aom ctx = ours row + 7 everywhere; aom above0=15/left=0 ↔ ours (1,0) at this unit), | ||
| 34 | + so the bug is not the around-flag arithmetic — it is the **adaptation history (or default) | ||
| 35 | + of our Chroma4 txb_skip rows** diverging from aom's shared `txb_skip_cdf[4x4][7..10]` rows. | ||
| 36 | +* Everything after 2162 — the whole "cascade" (rows 128+, the +19 at (296,128) whose block | ||
| 37 | + even reads a different var-tx tree, the chroma 4x4 cell diffs at rows 4..9, and the ibcvtx | ||
| 38 | + lane's "mi (32,32) 64x64 all_zero" fingerprint, whose block is actually a 32x32 PAETH at | ||
| 39 | + mi (32,72) that aom codes as one all-zero txb) — is **post-desync noise**, not defects. | ||
| 40 | + | ||
| 41 | +## Why this is a stop for this lane | ||
| 42 | + | ||
| 43 | +The defect is inside the intra block's **entropy layer** (chroma txb_skip CDF contents for | ||
| 44 | +`TxbSet::Chroma4`), not in intra prediction arithmetic, mode reads, or the filter chain. | ||
| 45 | +Prediction at every pre-desync site is pixel-exact (DC 170 / DC 103 cells verified against | ||
| 46 | +aom recon with identical inputs). Fixing it is a cdf.rs/decode.rs chroma-CDF-set task | ||
| 47 | +(defaults + update path for `TxbSet::Chroma4` rows vs aom's `default_txb_skip_cdf[0][7..10]`), | ||
| 48 | +which I could not complete within this run's budget. | ||
| 49 | + | ||
| 50 | +## Unblock (exact, machine-checked) | ||
| 51 | + | ||
| 52 | +1. Diff the DEFAULT of our `TxbSet::Chroma4` txb_skip rows against aom's | ||
| 53 | + `default_txb_skip_cdf[0][7..10]` (aom cdf.c) — aom's first chroma-4x4 ctx=8 read shows | ||
| 54 | + cdf0=15696 post-adapt. | ||
| 55 | +2. Diff the adaptation sequence: instrument `read_coeffs`' `all_zero` read (chroma only) to | ||
| 56 | + log row index + content per read (the `tmp_chroma` plumbing I used and reverted is the | ||
| 57 | + template), and compare against the oracle's `tag=all_zero ... cdf0=` lines | ||
| 58 | + (the oracle build at `~/.cache/aom-oracle/build` now prints `cdf0=` and `EC_ROWS8` per | ||
| 59 | + chroma-4x4 read — reusable). | ||
| 60 | +3. R5 must become byte-exact vs aomdec AND ffmpeg; W2 (cq8) is the sharper gate | ||
| 61 | + (diverges at byte 353 pre-fix); R9 must stay exact. | ||
| 62 | + | ||
| 63 | +## Notes | ||
| 64 | + | ||
| 65 | +* A parity-flip experiment on the default-scan zigzag was performed and fully reverted; it | ||
| 66 | + proved our scan tables are entropy-correct as-is (the flip desyncs at the first | ||
| 67 | + multi-coeff txb). Scan tables are NOT the defect. | ||
| 68 | +* The oracle build `~/.cache/aom-oracle` gained extra env-gated probes during this hunt | ||
| 69 | + (EC_R5CELL, EC_ROWS8, `cdf0=` in the all_zero line, EC_DBGCTX retargeted to mi 36,66). | ||
| 70 | + They are env-gated and outside the repo; retarget/keep as needed. | ||
| 71 | + | ||
| 72 | +--- | ||
| 73 | + | ||
| 74 | +# lane-av1-intrapred r2 — the reported CDF fork is FIXED; the follow-up intrabc chroma prediction fork is also FIXED | ||
| 75 | + | ||
| 76 | +Base 3f6748d5, same worktree/branch. The reported "chroma txb_skip CDF-content" fork was | ||
| 77 | +neither the Chroma4 defaults (all four q tables match aom `token_cdfs.h` exactly) nor the | ||
| 78 | +adaptation — it was the missing `INTRABC_CHROMA_TX` arming in `decode_leaf8`'s TX4 arm. | ||
| 79 | + | ||
| 80 | +## Root cause (machine-checked against `~/.cache/aom-oracle` R5 traces) | ||
| 81 | + | ||
| 82 | +* mi (36,66) is an **intrabc** 8x8 leaf whose var-tx tree split luma to 4x TX_4X4. | ||
| 83 | + libaom classifies intrabc as `is_inter_block` (`blockd.h:373`), so: | ||
| 84 | + * each luma TU codes `tx_type` off the **16-symbol inter set** | ||
| 85 | + (`av1_get_ext_tx_set_type(TX_4X4, inter=1)` = `EXT_TX_SET_ALL16`) — TU (0,0) coded | ||
| 86 | + `H_ADST(13)` in R5; | ||
| 87 | + * each chroma TU **inherits** the co-located luma type (`av1_get_tx_type`'s | ||
| 88 | + `is_inter_block` branch reads `tx_type_map`) → class `TX_CLASS_HORIZ` → the class-1 | ||
| 89 | + `eob_flag_cdf16[1][1]` row, the HORIZ scan and the HORIZ nz-context offsets. | ||
| 90 | +* `decode_leaf8`'s `resolved != 4` arm already armed `INTRABC_CHROMA_TX`; the | ||
| 91 | + `resolved == 4` (TX4) arm did not. Its chroma reads fell back to | ||
| 92 | + `default_intra_tx_type(DC_PRED)` = `DCT_DCT` → 2D eob row → at the U txb of (36,66) | ||
| 93 | + ours decoded `eob=11` where aomdec decoded `eob=13` (same entry rng 44076), and the | ||
| 94 | + tile desynced one read later than the all_zero ladder could see. | ||
| 95 | +* The r5-era `tx_type` handling of the luma side was already correct (ours read the same | ||
| 96 | + 16-symbol symbol and got `H_ADST`); only the chroma arming was missing. | ||
| 97 | + | ||
| 98 | +## Fix (two hunks in `decode_leaf8`, decode.rs) | ||
| 99 | + | ||
| 100 | +1. TX4 arm: capture the first TU's `tx_type` (`first_leaf_tx`, mirroring `decode_block`'s | ||
| 101 | + multi-TU capture) and arm `INTRABC_CHROMA_TX` with it before the group's chroma reads. | ||
| 102 | +2. TX4 arm: disarm the slot after the two chroma reads — without this the slot leaked | ||
| 103 | + into the NEXT leaf (seen live: a regular-intra leaf at mi (54,24) took the previous | ||
| 104 | + intrabc leaf's `V_ADST` for its chroma eob row). | ||
| 105 | + | ||
| 106 | +## Gates (all machine-captured, same fixtures as the stop report) | ||
| 107 | + | ||
| 108 | +* R5 (`~/.cache/av1ibcvtx-tmp/R5.obu`): pre-fix first diff byte 82216 / 127862 differing | ||
| 109 | + bytes → post-fix first diff byte **231864** / 3305 differing bytes (luma byte-exact; | ||
| 110 | + aomdec and ffmpeg agree with each other, sha256 `c91229ee…` both). | ||
| 111 | +* W2 (re-encoded at `--cq-level=8`, `/tmp/w2.obu` — the report's W2 was not in the cache): | ||
| 112 | + pre-fix first diff byte 352 (report said 353 ✓ reproduces) / 305032 diffs → post-fix | ||
| 113 | + 231848 / 3254. 23x further into the stream, 94x fewer diffs. | ||
| 114 | +* R9 (smptebars): still byte-exact vs ffmpeg post-fix (regression clean). | ||
| 115 | +* Entropy: ALL 3321 `all_zero` reads now align 1:1 rng-for-rng against the instrumented | ||
| 116 | + aomdec (was 2162/4248). | ||
| 117 | +* Pre-fix non-vacuity: scratch worktree at 3f6748d5 rebuild reproduces the byte-352 fork | ||
| 118 | + on W2 and byte-82216 on R5. | ||
| 119 | + | ||
| 120 | +## Next fork — FIXED in the same pass (r2b): intrabc chroma frame-copy prediction | ||
| 121 | + | ||
| 122 | +`R5` first differing byte 231864 = chroma U pixel **(184,4)**; 3305 differing bytes, all | ||
| 123 | +chroma (U 1730 / V 1575), origin unit = the chroma 4x4 at cpx (184,4), i.e. the 8x8 | ||
| 124 | +**intrabc** leaf at luma (368,8), mi **(2,92)**, var-tx TX4 split. Entropy was fully | ||
| 125 | +aligned (3321/3321 `all_zero` reads rng-identical, luma byte-exact), the DV matched | ||
| 126 | +exactly (`EC_DV mi_row=2 mi_col=92 dv_col=-2560 dv_row=0`, same as aom's `mv0=(0,-2560)`, | ||
| 127 | +source = integer-phase copy of U(24,4)), so the divergence was prediction-stage: the TX4 | ||
| 128 | +arm's chroma reads override the intra prediction through `palette_uv_bufs`, but only | ||
| 129 | +`decode_block` wrapped that pair with the leaf's `intrabc_bufs` frame-copy buffers | ||
| 130 | +(decode.rs:15833) — `decode_leaf8` wrapped only `palette_y_buf` (lane-t900 r32), so an | ||
| 131 | +intrabc TX4 leaf's chroma predicted INTRA from the UV mode (intrabc's is DC) instead of | ||
| 132 | +copying the frame at the DV. | ||
| 133 | + | ||
| 134 | +**Fix (r2b, third hunk):** `decode_leaf8` wraps `palette_uv_bufs` with `intrabc_bufs`'s | ||
| 135 | +`ub`/`vb` right after the `palette_y_buf` wrap — the chroma twin of decode.rs:15833. | ||
| 136 | + | ||
| 137 | +**Gates after r2b (all machine-captured):** | ||
| 138 | + | ||
| 139 | +* R5: **byte-exact vs aomdec AND ffmpeg** (the stop report's primary gate). | ||
| 140 | +* W2 (cq8 re-encode): **byte-exact vs aomdec**. | ||
| 141 | +* R9: byte-exact vs ffmpeg (regression clean). | ||
| 142 | +* Cached-fixture sweep A1/A2/A3/D1/D2/D3: byte-exact vs their ffmpeg raws. | ||
| 143 | +* Targeted tests (intrabc/lossless/screen filters): 14 passed, 0 failed. Full suite on | ||
| 144 | + the r2 fix alone: 607 passed / 0 failed (exit 0). | ||
| 145 | + | ||
| 146 | +## Regression gate (r2c) | ||
| 147 | + | ||
| 148 | +`stream::tests::an_intrabc_tx4_leaf_chroma_inherits_the_luma_type_and_predicts_from_the_frame_copy` | ||
| 149 | ++ pinned fixture `crates/ec-av1/fixtures/intrabc_tx4_chroma_kf.obu` (the R5 stream, | ||
| 150 | + 7173 bytes, sha256 `bc699af4…b41bd`, FNV-1a `0x3a57d0755e4cfe5b`; aomenc oracle, | ||
| 151 | + testsrc2 320x180 tiled 2x2 → 640x360, sb64 maxp64 square-only screen intrabc, cq20, | ||
| 152 | + 1 frame). The gate runs unconditionally (no oracle binary needed, no skip path): a | ||
| 153 | + missing fixture, a decode error, a zero `INTRABC_TX4_CHROMA_COPY_HITS` counter (new | ||
| 154 | + non-vacuity counter bumped when the TX4 arm's chroma reads consult the armed slot), | ||
| 155 | + a moved U(184,4)/U(168,0)/V(168,0) pixel patch, or a changed full-frame FNV-1a | ||
| 156 | + fingerprint each fail with the class name. | ||
| 157 | + | ||
| 158 | +* Fixed tree: passes. | ||
| 159 | +* Unwrap regression (decode_block's `palette_uv_bufs` intrabc wrap removed — the exact | ||
| 160 | + "chroma predicts from the unwrapped palette buffer" state): **fails at the U(168,0) | ||
| 161 | + patch assert** (`intrabc-chroma-predicts-intra`), 78182 chroma bytes wrong. | ||
| 162 | +* Pre-r2 parent (3f6748d5): fails at decode (tile desync, byte 82216/352 forks). | ||