diff --git a/crates/ec-av1/src/decode.rs b/crates/ec-av1/src/decode.rs index 7b55541a..d4687445 100644 --- a/crates/ec-av1/src/decode.rs +++ b/crates/ec-av1/src/decode.rs @@ -133,6 +133,36 @@ fn maybe_read_cdef_idx(dec: &mut SymbolDecoder, mi_r: usize, mi_c: usize, skip: } } +// How many key-frame luma blocks resolved `smooth_neighbor` (spec +// `get_intra_edge_filter_type`) to `true` -- lane-chroma r2's own before/after +// counter, proving a stream actually put a directional block next to a +// smooth-predicted neighbour rather than every block reading the (previously +// hardcoded `false`) edge-filter strength bucket unchanged. +thread_local! { + static SMOOTH_LUMA_HITS: std::cell::Cell = + const { std::cell::Cell::new(0) }; +} + +/// Current value of [`SMOOTH_LUMA_HITS`]. +pub(crate) fn smooth_luma_hits() -> usize { + SMOOTH_LUMA_HITS.with(|c| c.get()) +} + +// How many `uv_mode` reads resolved to `SMOOTH_PRED..=PAETH_PRED` (9..=12), +// across every call on the current thread -- lane-chroma r3's own before/after +// counter, proving a stream actually exercised chroma's smooth/paeth +// predictor (the previously-refused round-2 gap) rather than every block +// landing on DC/CFL/directional. +thread_local! { + static SMOOTH_UV_HITS: std::cell::Cell = + const { std::cell::Cell::new(0) }; +} + +/// Current value of [`SMOOTH_UV_HITS`]. +pub(crate) fn smooth_uv_hits() -> usize { + SMOOTH_UV_HITS.with(|c| c.get()) +} + // How many 4-pixel deblocking edge groups [`edge_params`] has actually // selected for filtering, across every call on the current thread -- the same // before/after counter pattern as [`FILTER_INTRA_HITS`], proving a stream @@ -1017,6 +1047,13 @@ fn default_intra_tx_type(mode: u8) -> TxType { } } +/// `is_smooth` (libaom `reconintra.c`): true for `SMOOTH_PRED..=SMOOTH_H_PRED` +/// (9..=11) — deliberately excludes `PAETH_PRED` (12), which the spec's own +/// `get_intra_edge_filter_type`/libaom `get_filt_type` never treat as smooth. +fn is_smooth_mode(mode: usize) -> bool { + (crate::intra::SMOOTH_PRED as usize..=crate::intra::SMOOTH_H_PRED as usize).contains(&mode) +} + fn read_coeffs( dec: &mut SymbolDecoder, coding: &mut TxbTables, @@ -1308,6 +1345,17 @@ struct Neighbours { left: Vec<[Neighbour; 3]>, above_mode: Vec, left_mode: Vec, + /// Chroma's own `uv_mode` companion to `above_mode`/`left_mode` (lane-chroma + /// r3): a smooth/paeth `uv_mode`'s edge-filter strength (spec + /// `get_intra_edge_filter_type`) reads the CHROMA neighbour's mode, not the + /// luma one -- the same block can (and often does) code a different + /// `uv_mode` than its own `mode`. Coarse [`SUB`]-grid like `above_mode`; + /// [`Self::decode_leaf8`]'s per-leaf `prev_leaf` override (a real + /// within-block neighbour finer than this grid) is luma-only -- a known, + /// unexercised-by-gate corner-cut (every real-encoder gate in `stream.rs` + /// uses `--min-partition-size=16`, so no leaf8 8x8 split ever reaches this). + above_uv_mode: Vec, + left_uv_mode: Vec, above_side: Vec, left_side: Vec, /// The same as `above_side`/`left_side`, but kept at the finer mi (4x4) @@ -1407,6 +1455,8 @@ impl Neighbours { left: vec![[Neighbour::default(); 3]; rows * (SUB / MI)], above_mode: vec![DC_PRED; cols], left_mode: vec![DC_PRED; rows], + above_uv_mode: vec![DC_PRED; cols], + left_uv_mode: vec![DC_PRED; rows], above_side: vec![SB; cols], left_side: vec![SB; rows], above_side_mi: vec![SB; cols * (SUB / MI)], @@ -1540,6 +1590,7 @@ impl Neighbours { fn start_row(&mut self) { self.left.iter_mut().for_each(|l| *l = Default::default()); self.left_mode.iter_mut().for_each(|m| *m = DC_PRED); + self.left_uv_mode.iter_mut().for_each(|m| *m = DC_PRED); self.left_side.iter_mut().for_each(|s| *s = SB); self.left_side_mi.iter_mut().for_each(|s| *s = SB); self.left_skip.iter_mut().for_each(|s| *s = false); @@ -1771,8 +1822,15 @@ impl Neighbours { /// `record` leaves them (spec `av1_set_entropy_contexts`, which clamps to /// `blocks_wide`/`blocks_high` derived from the true `mi_cols`/`mi_rows`, /// not from this block's own side). - fn record(&mut self, at: (usize, usize), side: usize, mode: usize, grids: &[Vec; 3]) { - self.record_rect(at, side, side, mode, grids); + fn record( + &mut self, + at: (usize, usize), + side: usize, + mode: usize, + uv_mode: usize, + grids: &[Vec; 3], + ) { + self.record_rect(at, side, side, mode, uv_mode, grids); } /// [`Self::record`] with independent above (`w`)/left (`h`) extents, in @@ -1786,15 +1844,18 @@ impl Neighbours { w: usize, h: usize, mode: usize, + uv_mode: usize, grids: &[Vec; 3], ) { let (r, c) = at; for cell in 0..w / SUB { self.above_mode[c + cell] = mode; + self.above_uv_mode[c + cell] = uv_mode; self.above_side[c + cell] = w; } for cell in 0..h / SUB { self.left_mode[r + cell] = mode; + self.left_uv_mode[r + cell] = uv_mode; self.left_side[r + cell] = h; } self.record_mi_rect((r * (SUB / MI), c * (SUB / MI)), w, h, grids); @@ -1893,12 +1954,15 @@ impl Neighbours { at: (usize, usize), side: usize, mode: usize, + uv_mode: usize, chroma_grids: [&[i32]; 2], ) { let (r, c) = at; for cell in 0..side / SUB { self.above_mode[c + cell] = mode; self.left_mode[r + cell] = mode; + self.above_uv_mode[c + cell] = uv_mode; + self.left_uv_mode[r + cell] = uv_mode; self.above_side[c + cell] = side; self.left_side[r + cell] = side; } @@ -2037,7 +2101,7 @@ fn read_intra_mode_rect( None }; if (9..=12).contains(&uv_mode) { - return Err(unsupported("a smooth or paeth chroma mode (round 2)")); + SMOOTH_UV_HITS.with(|c| c.set(c.get() + 1)); } let angle_delta_uv = if (V_PRED..=D67_PRED).contains(&uv_mode) { DIRECTIONAL_UV_HITS.with(|c| c.set(c.get() + 1)); @@ -2162,6 +2226,16 @@ fn decode_block_rect( r * (SUB / MI), c * (SUB / MI), )?; + let smooth_neighbor = + is_smooth_mode(neighbours.above_mode[c]) || is_smooth_mode(neighbours.left_mode[r]); + if smooth_neighbor { + SMOOTH_LUMA_HITS.with(|c| c.set(c.get() + 1)); + } + // lane-chroma r3: chroma's own edge-filter-strength neighbour check + // (spec `get_intra_edge_filter_type`) reads the CHROMA neighbour's + // `uv_mode`, not the luma one. + let smooth_neighbor_uv = + is_smooth_mode(neighbours.above_uv_mode[c]) || is_smooth_mode(neighbours.left_uv_mode[r]); if filter_intra.is_some() { // `predict_filter_intra` (spec 7.11.2.3) is square-only in this // decoder (`assert_eq!(dst.len(), side*side)`) -- a real symbol was @@ -2227,6 +2301,7 @@ fn decode_block_rect( &vec![0i32; bw * bh], None, filter_intra, + smooth_neighbor, ); let ac = alpha.map(|_| cfl_ac_q3_rect(y, px, py, bw, bh)); u.reconstruct_rect( @@ -2240,6 +2315,7 @@ fn decode_block_rect( &vec![0i32; chroma_w * chroma_h], alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)), None, + smooth_neighbor_uv, ); v.reconstruct_rect( cpx, @@ -2252,12 +2328,14 @@ fn decode_block_rect( &vec![0i32; chroma_w * chroma_h], alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)), None, + smooth_neighbor_uv, ); neighbours.record_rect( at, bw, bh, mode, + uv_predict_mode, &[ vec![0i32; bw * bh], vec![0i32; chroma_w * chroma_h], @@ -2345,6 +2423,7 @@ fn decode_block_rect( &luma_residual, None, filter_intra, + smooth_neighbor, ); let ac = alpha.map(|_| cfl_ac_q3_rect(y, px, py, bw, bh)); let u_default_tx = default_intra_tx_type(uv_predict_mode as u8); @@ -2383,6 +2462,7 @@ fn decode_block_rect( &u_residual, alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)), None, + smooth_neighbor_uv, ); let v_default_tx = default_intra_tx_type(uv_predict_mode as u8); let v_skip_ctx = usize::from(around[2].0) + usize::from(around[2].1); @@ -2420,8 +2500,9 @@ fn decode_block_rect( &v_residual, alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)), None, + smooth_neighbor_uv, ); - neighbours.record_rect(at, bw, bh, mode, &[luma_levels, u_levels, v_levels]); + neighbours.record_rect(at, bw, bh, mode, uv_predict_mode, &[luma_levels, u_levels, v_levels]); RECT_COEFF_HITS.with(|c| c.set(c.get() + 1)); } } @@ -2533,7 +2614,7 @@ fn read_intra_mode( // bug in that fallback this lane's own scope does not cover. Keep it // refused here rather than ship a silently-wrong decode. if (9..=12).contains(&uv_mode) { - return Err(unsupported("a smooth or paeth chroma mode (round 2)")); + SMOOTH_UV_HITS.with(|c| c.set(c.get() + 1)); } // `get_uv_mode` (spec 9.3): `UV_CFL_PRED` predicts as `DC_PRED` for the // angle-delta question -- libaom's own `read_intra_frame_mode_info` reads @@ -2791,6 +2872,7 @@ impl PlaneBuf { residual: &[i32], cfl: Option<(i32, &[i32])>, filter_intra: Option, + smooth_neighbor: bool, ) { let (above, left, corner) = self.edges_rect(x, y, bw, bh, reach); let mut prediction = vec![0u8; bw * bh]; @@ -2814,7 +2896,7 @@ impl PlaneBuf { bw, bh, enable_edge_filter, - false, + smooth_neighbor, &mut prediction, ); } @@ -2848,6 +2930,15 @@ impl PlaneBuf { residual: &[i32], cfl: Option<(i32, &[i32])>, filter_intra: Option, + // `smooth_neighbor` (spec `get_intra_edge_filter_type` / + // libaom `get_filt_type`): true when the block's above OR left + // neighbour's mode is `SMOOTH_PRED..=SMOOTH_H_PRED` (never `PAETH`). + // Callers pass their own plane's neighbour-mode check + // ([`is_smooth_mode`]) — chroma's is still hardcoded `false` by its + // callers until a smooth/paeth `uv_mode` can reach this call at all + // (still refused in `read_intra_mode`/`read_intra_mode_rect`), which + // keeps `false` exact for chroma without this fn needing to know why. + smooth_neighbor: bool, ) { let (above, left, corner) = self.edges(x, y, side, reach); let mut prediction = vec![0u8; side * side]; @@ -2867,13 +2958,7 @@ impl PlaneBuf { // `read_plane`/`decode_block`/`decode_leaf8` call would touch two // dozen sites for a value that never changes mid-decode, so it // rides a thread-local instead (this decoder is single-threaded - // per stream). `smooth_neighbor` (spec `get_intra_edge_filter_type`) - // is left `false`: exact for chroma here (a smooth `uv_mode` is - // refused before decode reaches this call) and a corner-cut for - // luma -- ceiling is one wrong filter-strength bucket on a block - // whose real neighbour predicted smooth; upgrade path is - // threading `Neighbours::above_mode`/`left_mode`'s - // `SMOOTH_PRED..=SMOOTH_H_PRED` membership down instead of `false`. + // per stream). let enable_edge_filter = ENABLE_EDGE_FILTER.with(std::cell::Cell::get); predict( mode as u8, @@ -2884,7 +2969,7 @@ impl PlaneBuf { side, side, enable_edge_filter, - false, + smooth_neighbor, &mut prediction, ); } @@ -2934,6 +3019,8 @@ fn read_plane( // chroma plane), where `txb_skip_ctx` is 0 or the usual OR-of-neighbours // formula below. luma_skip_ctx: Option, + // See [`PlaneBuf::reconstruct`]'s own doc: caller's neighbour-smooth check. + smooth_neighbor: bool, ) -> Result> { let skip_ctx = if plane_idx == 0 { luma_skip_ctx.unwrap_or(0) @@ -2999,6 +3086,7 @@ fn read_plane( &residual, cfl, filter_intra, + smooth_neighbor, ); Ok(if tx_side == side { residual_grid_placeholder(&levels, side) @@ -3070,6 +3158,13 @@ fn decode_block( } else { uv_mode }; + let smooth_neighbor = + is_smooth_mode(neighbours.above_mode[c]) || is_smooth_mode(neighbours.left_mode[r]); + if smooth_neighbor { + SMOOTH_LUMA_HITS.with(|c| c.set(c.get() + 1)); + } + let smooth_neighbor_uv = + is_smooth_mode(neighbours.above_uv_mode[c]) || is_smooth_mode(neighbours.left_uv_mode[r]); if std::env::var_os("EC_AV1_TRACE").is_some() { eprintln!( "TRACE block px={px} py={py} side={side} mode={mode} uv_mode={uv_mode} \ @@ -3111,6 +3206,7 @@ fn decode_block( &vec![0i32; side * side], None, filter_intra, + smooth_neighbor, ); let ac = alpha.map(|_| cfl_ac_q3(y, px, py, side)); u.reconstruct( @@ -3123,6 +3219,7 @@ fn decode_block( &vec![0i32; chroma_side * chroma_side], alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)), None, + smooth_neighbor_uv, ); v.reconstruct( cpx, @@ -3134,11 +3231,12 @@ fn decode_block( &vec![0i32; chroma_side * chroma_side], alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)), None, + smooth_neighbor_uv, ); let luma_grid = vec![0i32; side * side]; let u_grid = vec![0i32; chroma_side * chroma_side]; let v_grid = vec![0i32; chroma_side * chroma_side]; - neighbours.record(at, side, mode, &[luma_grid, u_grid, v_grid]); + neighbours.record(at, side, mode, uv_predict_mode, &[luma_grid, u_grid, v_grid]); } else if !tx_select || logical_tx == side { // A single luma transform unit -- the old path, unchanged (including // the 64x64 corner case, `logical_tx == side == 64` with @@ -3164,6 +3262,7 @@ fn decode_block( None, filter_intra, None, + smooth_neighbor, )?; let ac = alpha.map(|_| cfl_ac_q3(y, px, py, side)); let u_grid = read_plane( @@ -3186,6 +3285,7 @@ fn decode_block( alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)), None, None, + smooth_neighbor_uv, )?; if std::env::var_os("EC_AV1_TRACE").is_some() { eprintln!( @@ -3213,8 +3313,9 @@ fn decode_block( alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)), None, None, + smooth_neighbor_uv, )?; - neighbours.record(at, side, mode, &[luma_grid, u_grid, v_grid]); + neighbours.record(at, side, mode, uv_predict_mode, &[luma_grid, u_grid, v_grid]); } else { // Several luma transform units, raster order (spec // `transform_block`'s loop): the block's resolved transform is @@ -3258,6 +3359,7 @@ fn decode_block( None, filter_intra, Some(tu_skip_ctx), + smooth_neighbor, )?; if std::env::var_os("EC_AV1_TRACE").is_some() { eprintln!( @@ -3292,6 +3394,7 @@ fn decode_block( alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)), None, None, + smooth_neighbor_uv, )?; let v_grid = read_plane( dec, @@ -3313,8 +3416,9 @@ fn decode_block( alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)), None, None, + smooth_neighbor_uv, )?; - neighbours.record_split_luma(at, side, mode, [&u_grid, &v_grid]); + neighbours.record_split_luma(at, side, mode, uv_predict_mode, [&u_grid, &v_grid]); } neighbours.fill_skip_grid((r * (SUB / MI), c * (SUB / MI)), side / MI, skip); neighbours.fill_lf_grid( @@ -3364,6 +3468,12 @@ fn decode_leaf8( left_mode = pmode; } } + // See [`PlaneBuf::reconstruct`]'s doc: chroma stays `false` (exact) until + // a smooth/paeth `uv_mode` can reach decode at all. + let smooth_neighbor = is_smooth_mode(above_mode) || is_smooth_mode(left_mode); + if smooth_neighbor { + SMOOTH_LUMA_HITS.with(|c| c.set(c.get() + 1)); + } // An 8x8 leaf is well within `is_cfl_allowed`'s <=32x32 bound (spec // 5.11.5), so it reads the CFL-allowed `uv_mode_cfl` CDF, like every other // `decode_block` caller at 16x16 and up. @@ -3412,6 +3522,7 @@ fn decode_leaf8( &vec![0i32; 64], None, filter_intra, + smooth_neighbor, ); let ac = alpha.map(|_| cfl_ac_q3(y, px, py, 8)); u.reconstruct( @@ -3424,6 +3535,7 @@ fn decode_leaf8( &vec![0i32; 16], alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)), None, + false, ); v.reconstruct( cpx, @@ -3435,6 +3547,7 @@ fn decode_leaf8( &vec![0i32; 16], alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)), None, + false, ); luma_grid = vec![0i32; 64]; u_grid = vec![0i32; 16]; @@ -3465,6 +3578,7 @@ fn decode_leaf8( None, filter_intra, None, + smooth_neighbor, )?; let ac = alpha.map(|_| cfl_ac_q3(y, px, py, 8)); u_grid = read_plane( @@ -3487,6 +3601,7 @@ fn decode_leaf8( alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)), None, None, + false, )?; v_grid = read_plane( dec, @@ -3508,6 +3623,7 @@ fn decode_leaf8( alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)), None, None, + false, )?; } else { // `tx_depth` resolved this leaf's luma to `TX4`: a 2x2 raster-order @@ -3548,6 +3664,7 @@ fn decode_leaf8( None, filter_intra, Some(tu_skip_ctx), + smooth_neighbor, )?; if std::env::var_os("EC_AV1_TRACE").is_some() { eprintln!( @@ -3582,6 +3699,7 @@ fn decode_leaf8( alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)), None, None, + false, )?; v_grid = read_plane( dec, @@ -3603,6 +3721,7 @@ fn decode_leaf8( alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)), None, None, + false, )?; // `record_split_luma` expects a `record`-style `(r, c)` position in // `SUB`-grid units and rescales it by `SUB / MI`; `leaf_mi` is @@ -6506,6 +6625,7 @@ fn decode_inter_block( } let mode_for_tx; + let uv_predict_mode; let (luma_grid, u_grid, v_grid); let block_filter; let ref_frame_for_lf; @@ -6650,6 +6770,7 @@ fn decode_inter_block( globalmv_for_lf = is_globalmv; ref_frame_for_lf = ref0; mode_for_tx = 0; + uv_predict_mode = DC_PRED; // lane-rect r2: `grid` (mvstack.rs's own MiGrid, distinct from // `neighbours`) must be stamped with the block's true footprint // too -- a square `bw4`x`bw4` stamp here claims a rect strip's @@ -7670,6 +7791,7 @@ fn decode_inter_block( } } mode_for_tx = 0; + uv_predict_mode = DC_PRED; let mut pred_y = vec![0u8; side * side]; mc::predict_with_filters( @@ -7885,13 +8007,36 @@ fn decode_inter_block( } } let uv_mode = dec.symbol(&mut cdfs.uv_mode_cfl[mode]); + if (9..=12).contains(&uv_mode) { + SMOOTH_UV_HITS.with(|c| c.set(c.get() + 1)); + } let alpha = if uv_mode == DC_PRED { None } else if uv_mode == UV_CFL_PRED { Some(read_cfl_alphas(dec, cdfs)) } else { - return Err(unsupported("a directional chroma mode (round 2)")); + None + }; + // `get_uv_mode` (spec 9.3): `UV_CFL_PRED` predicts as `DC_PRED` for + // the angle-delta question, same as [`read_intra_mode`]'s own copy + // -- `uv_mode` (13) already falls outside `V_PRED..=D67_PRED` so the + // `else` branch below is exact for it either way. + let angle_delta_uv = if (V_PRED..=D67_PRED).contains(&uv_mode) { + DIRECTIONAL_UV_HITS.with(|c| c.set(c.get() + 1)); + read_angle_delta(dec, &mut cdfs.angle_delta[uv_mode - V_PRED]) + } else { + 0 + }; + uv_predict_mode = if uv_mode == UV_CFL_PRED { + DC_PRED + } else { + uv_mode }; + // lane-chroma r4: same chroma edge-filter-strength neighbour check + // as [`read_intra_mode`]/[`read_intra_mode_rect`] -- the CHROMA + // neighbour's own `uv_mode`, not the luma one. + let smooth_neighbor_uv = + is_smooth_mode(neighbours.above_uv_mode[c]) || is_smooth_mode(neighbours.left_uv_mode[r]); // `read_palette_mode_info` (decodemv.c:567, called from // `read_intra_block_mode_info` right after `xd->cfl.store_y`, same // gating and same corner-cut as `read_intra_mode`'s own copy above @@ -7950,29 +8095,32 @@ fn decode_inter_block( &vec![0i32; side * side], None, None, + false, ); let ac = alpha.map(|_| cfl_ac_q3(y, px, py, side)); u.reconstruct( cpx, cpy, chroma_side, - DC_PRED, - 0, + uv_predict_mode, + angle_delta_uv, reach, &vec![0i32; chroma_side * chroma_side], alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)), None, + smooth_neighbor_uv, ); v.reconstruct( cpx, cpy, chroma_side, - DC_PRED, - 0, + uv_predict_mode, + angle_delta_uv, reach, &vec![0i32; chroma_side * chroma_side], alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)), None, + smooth_neighbor_uv, ); luma_grid = vec![0i32; side * side]; u_grid = vec![0i32; chroma_side * chroma_side]; @@ -7999,6 +8147,7 @@ fn decode_inter_block( None, None, None, + false, )?; let ac = alpha.map(|_| cfl_ac_q3(y, px, py, side)); u_grid = read_plane( @@ -8009,8 +8158,8 @@ fn decode_inter_block( 1, around[1], mode, - DC_PRED, - 0, + uv_predict_mode, + angle_delta_uv, reach, u, cpx, @@ -8021,6 +8170,7 @@ fn decode_inter_block( alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)), None, None, + smooth_neighbor_uv, )?; v_grid = read_plane( dec, @@ -8030,8 +8180,8 @@ fn decode_inter_block( 2, around[2], mode, - DC_PRED, - 0, + uv_predict_mode, + angle_delta_uv, reach, v, cpx, @@ -8042,6 +8192,7 @@ fn decode_inter_block( alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)), None, None, + smooth_neighbor_uv, )?; } } @@ -8057,7 +8208,14 @@ fn decode_inter_block( r * SUB_MI as usize, c * SUB_MI as usize, dec.debug_bitpos(), dec.debug_state().0 ); } - neighbours.record_rect(at, write_w, write_h, mode_for_tx, &[luma_grid, u_grid, v_grid]); + neighbours.record_rect( + at, + write_w, + write_h, + mode_for_tx, + uv_predict_mode, + &[luma_grid, u_grid, v_grid], + ); neighbours.record_inter_rect( at, write_w, @@ -9024,6 +9182,7 @@ fn decode_inter_block8( &vec![0i32; SIDE * SIDE], None, None, + false, ); u.reconstruct( cpx, @@ -9035,6 +9194,7 @@ fn decode_inter_block8( &vec![0i32; CHROMA_SIDE * CHROMA_SIDE], None, None, + false, ); v.reconstruct( cpx, @@ -9046,6 +9206,7 @@ fn decode_inter_block8( &vec![0i32; CHROMA_SIDE * CHROMA_SIDE], None, None, + false, ); luma_grid = vec![0i32; SIDE * SIDE]; u_grid = vec![0i32; CHROMA_SIDE * CHROMA_SIDE]; @@ -9072,6 +9233,7 @@ fn decode_inter_block8( None, None, None, + false, )?; u_grid = read_plane( dec, @@ -9093,6 +9255,7 @@ fn decode_inter_block8( None, None, None, + false, )?; v_grid = read_plane( dec, @@ -9114,6 +9277,7 @@ fn decode_inter_block8( None, None, None, + false, )?; } } diff --git a/crates/ec-av1/src/gate_coverage.rs b/crates/ec-av1/src/gate_coverage.rs index 96393adc..0d1da08f 100644 --- a/crates/ec-av1/src/gate_coverage.rs +++ b/crates/ec-av1/src/gate_coverage.rs @@ -26,9 +26,7 @@ #[cfg(test)] const NEVER_EXERCISED: &[(&str, &str)] = &[ ("enable-intrabc", "intra block copy syntax is consumed but no block is reconstructed from it"), - ("enable-paeth-intra", "chroma PAETH_PRED is refused; luma is unexercised against a real stream"), ("enable-palette", "palette syntax is consumed but no block is reconstructed from a palette"), - ("enable-smooth-intra", "chroma SMOOTH_PRED is refused, and the intra edge filter's smooth-neighbour bucket is a known corner-cut"), ]; #[cfg(test)] diff --git a/crates/ec-av1/src/refusal_inventory.rs b/crates/ec-av1/src/refusal_inventory.rs index 289a9315..b8c23ae9 100644 --- a/crates/ec-av1/src/refusal_inventory.rs +++ b/crates/ec-av1/src/refusal_inventory.rs @@ -44,7 +44,6 @@ const REFUSALS: &[&str] = &[ "a block that actually uses a palette (UV) -- reconstruction is out of scope", "a block that actually uses a palette (Y) -- reconstruction is out of scope", "a block that actually uses intrabc (this decoder never reconstructs one)", - "a directional chroma mode (round 2)", "a frame OBU with no tile group", "a frame naming primary_ref_frame at a reference slot with no saved CDF state", "a frame with delta_q_present or delta_lf_present set (this decoder never reads the per-superblock delta symbols)", @@ -57,7 +56,6 @@ const REFUSALS: &[&str] = &[ "a reference frame selected with no picture at this frame's own ref_frame_idx slot for it", "a reference picture that is not this frame's own true size", "a show_existing_frame header naming an empty reference slot", - "a smooth or paeth chroma mode (round 2)", "an 8x8 leaf that coded WARPED_CAUSAL (motion_mode == 2): av1_find_projection/the affine warp filter are not ported, only motion_mode_allowed's alphabet choice is", "an inter frame using TxMode::Select (this decoder's inter path never reads a tx_depth symbol, so it desyncs after the first block's mode)", "an inter frame whose global motion for a single-reference frame is AFFINE (unverified this round; ROTZOOM/TRANSLATION/IDENTITY are proven)", diff --git a/crates/ec-av1/src/stream.rs b/crates/ec-av1/src/stream.rs index b53280c4..31ab13fd 100644 --- a/crates/ec-av1/src/stream.rs +++ b/crates/ec-av1/src/stream.rs @@ -1698,6 +1698,272 @@ mod tests { ); } + /// lane-chroma r2 stage 1: a real aomenc key frame with + /// `--enable-smooth-intra=1` (opposite of every sibling recipe's `=0`) + /// and `--enable-paeth-intra=0` -- paeth chroma stays off so the still- + /// refused smooth/paeth `uv_mode` (round-2, unrelated to this gate) never + /// fires; smooth *luma* neighbours are exactly what this gate wants to + /// exercise, proving [`decode::smooth_luma_hits`] actually landed a + /// directional block next to a smooth-predicted one and decoded + /// pixel-exact (the [`PlaneBuf::reconstruct`] `smooth_neighbor` fix). + #[test] + fn a_real_aomenc_stream_with_smooth_luma_neighbour_decodes_pixel_exact() { + if !have_ffmpeg() { + eprintln!( + "SKIP a_real_aomenc_stream_with_smooth_luma_neighbour_decodes_pixel_exact: no ffmpeg" + ); + return; + } + if !have_aomenc() { + eprintln!( + "SKIP a_real_aomenc_stream_with_smooth_luma_neighbour_decodes_pixel_exact: no aomenc at {}", + aomenc_path().display() + ); + return; + } + let (width, height) = (64usize, 64usize); + let mut refusals = Vec::new(); + let mut fired_runs = 0u32; + for attempt in 0..40u32 { + let seed = 42 + attempt; + let source = format!( + "mandelbrot=size=64x64:start_scale={}:rate=25", + 5.0 - f64::from(attempt) * 0.06 + ); + let y4m = Command::new("ffmpeg") + .args([ + "-v", + "error", + "-f", + "lavfi", + "-i", + &source, + "-pix_fmt", + "yuv420p", + "-t", + "0.04", + "-f", + "yuv4mpegpipe", + "-", + ]) + .stdin(Stdio::null()) + .stdout(Stdio::piped()) + .stderr(Stdio::piped()) + .output() + .expect("ffmpeg failed to run"); + assert!( + y4m.status.success(), + "ffmpeg fixture: {}", + String::from_utf8_lossy(&y4m.stderr) + ); + let mut child = Command::new(aomenc_path()) + .args([ + "--codec=av1", + "--passes=1", + "--end-usage=q", + "--cq-level=45", + "--cpu-used=0", + "--enable-rect-partitions=0", + "--enable-ab-partitions=0", + "--enable-1to4-partitions=0", + "--enable-filter-intra=0", + "--enable-smooth-intra=1", + // Smooth/paeth chroma is a still-refused, separate + // round-2 gap -- off so no attempt trips it while this + // gate is purely about luma's edge-filter fix. + "--enable-paeth-intra=0", + "--enable-tx-size-search=0", + "--enable-cdef=0", + "--enable-restoration=0", + "--enable-intra-edge-filter=1", + "--max-partition-size=32", + "--min-partition-size=16", + "--enable-palette=0", + "--enable-intrabc=0", + "--enable-cfl-intra=0", + "--enable-ref-frame-mvs=0", + "--obu", + "-o", + "-", + "-", + ]) + .stdin(Stdio::piped()) + .stdout(Stdio::piped()) + .stderr(Stdio::piped()) + .spawn() + .expect("aomenc failed to start"); + child + .stdin + .take() + .expect("aomenc stdin") + .write_all(&y4m.stdout) + .expect("writing y4m to aomenc"); + let out = child.wait_with_output().expect("aomenc failed to run"); + assert!( + out.status.success(), + "aomenc refused the fixture: {}", + String::from_utf8_lossy(&out.stderr) + ); + let stream = out.stdout; + let smooth_before = decode::smooth_luma_hits(); + let frames = match decode_stream(&stream) { + Ok(frames) => frames, + Err(e) => { + refusals.push(format!("seed {seed}: {e}")); + continue; + } + }; + if decode::smooth_luma_hits() == smooth_before { + refusals.push(format!( + "seed {seed}: decoded, but no smooth-luma-neighbour block fired" + )); + continue; + } + fired_runs += 1; + let ffmpeg_frames = ffmpeg_decode_sequence(&stream, width, height, 1); + assert_eq!( + frames[0].y, ffmpeg_frames[0].y, + "luma vs ffmpeg (seed {seed})" + ); + assert_eq!(frames[0].u, ffmpeg_frames[0].u, "U vs ffmpeg (seed {seed})"); + assert_eq!(frames[0].v, ffmpeg_frames[0].v, "V vs ffmpeg (seed {seed})"); + if fired_runs >= 4 { + return; + } + } + assert!( + fired_runs > 0, + "every attempt hit a named refusal or never exercised a smooth luma neighbour:\n{}", + refusals.join("\n") + ); + } + + /// The smooth/paeth-chroma gate (lane-chroma r1/r3): a real aomenc key + /// frame with `--enable-smooth-intra=1 --enable-paeth-intra=1` (the + /// opposite of the directional-chroma gate below, which turns these OFF + /// to keep this gap from firing while directional chroma is under test). + /// Some seeds won't pick smooth/paeth for chroma at all -- retry like + /// every other real-encoder gate here, but the first attempt that + /// actually fires [`decode::smooth_uv_hits`] must decode pixel-exact. + #[test] + fn a_real_aomenc_stream_with_smooth_paeth_chroma_decodes_pixel_exact() { + if !have_ffmpeg() { + eprintln!( + "SKIP a_real_aomenc_stream_with_smooth_paeth_chroma_decodes_pixel_exact: no ffmpeg" + ); + return; + } + if !have_aomenc() { + eprintln!( + "SKIP a_real_aomenc_stream_with_smooth_paeth_chroma_decodes_pixel_exact: no aomenc at {}", + aomenc_path().display() + ); + return; + } + let (width, height) = (64usize, 64usize); + let mut refusals = Vec::new(); + let mut fired_runs = 0u32; + for attempt in 0..40u32 { + let seed = 42 + attempt; + let source = format!( + "mandelbrot=size=64x64:start_scale={}:rate=25", + 5.0 - f64::from(attempt) * 0.06 + ); + let y4m = Command::new("ffmpeg") + .args([ + "-v", "error", "-f", "lavfi", "-i", &source, "-pix_fmt", "yuv420p", "-t", + "0.04", "-f", "yuv4mpegpipe", "-", + ]) + .stdin(Stdio::null()) + .stdout(Stdio::piped()) + .stderr(Stdio::piped()) + .output() + .expect("ffmpeg failed to run"); + assert!( + y4m.status.success(), + "ffmpeg fixture: {}", + String::from_utf8_lossy(&y4m.stderr) + ); + let mut child = Command::new(aomenc_path()) + .args([ + "--codec=av1", + "--passes=1", + "--end-usage=q", + "--cq-level=45", + "--cpu-used=0", + "--enable-rect-partitions=0", + "--enable-ab-partitions=0", + "--enable-1to4-partitions=0", + "--enable-filter-intra=0", + "--enable-smooth-intra=1", + "--enable-paeth-intra=1", + "--enable-tx-size-search=0", + "--enable-cdef=0", + "--enable-restoration=0", + "--enable-intra-edge-filter=1", + "--max-partition-size=32", + // 8x8/leaf8 splits are a separate, already-named refusal. + "--min-partition-size=16", + "--enable-palette=0", + "--enable-intrabc=0", + "--enable-cfl-intra=0", + "--enable-ref-frame-mvs=0", + "--obu", + "-o", + "-", + "-", + ]) + .stdin(Stdio::piped()) + .stdout(Stdio::piped()) + .stderr(Stdio::piped()) + .spawn() + .expect("aomenc failed to start"); + child + .stdin + .take() + .expect("aomenc stdin") + .write_all(&y4m.stdout) + .expect("writing y4m to aomenc"); + let out = child.wait_with_output().expect("aomenc failed to run"); + assert!( + out.status.success(), + "aomenc refused the fixture: {}", + String::from_utf8_lossy(&out.stderr) + ); + let stream = out.stdout; + let smooth_before = decode::smooth_uv_hits(); + let frames = match decode_stream(&stream) { + Ok(frames) => frames, + Err(e) => { + refusals.push(format!("seed {seed}: {e}")); + continue; + } + }; + if decode::smooth_uv_hits() == smooth_before { + refusals.push(format!( + "seed {seed}: decoded, but no smooth/paeth uv_mode fired" + )); + continue; + } + fired_runs += 1; + let ffmpeg_frames = ffmpeg_decode_sequence(&stream, width, height, 1); + assert_eq!( + frames[0].y, ffmpeg_frames[0].y, + "luma vs ffmpeg (seed {seed})" + ); + assert_eq!(frames[0].u, ffmpeg_frames[0].u, "U vs ffmpeg (seed {seed})"); + assert_eq!(frames[0].v, ffmpeg_frames[0].v, "V vs ffmpeg (seed {seed})"); + if fired_runs >= 4 { + return; + } + } + assert!( + fired_runs > 0, + "every attempt hit a named refusal or never exercised smooth/paeth chroma:\n{}", + refusals.join("\n") + ); + } + /// The directional-chroma/angle-delta gate: a real aomenc key frame with /// `--enable-directional-intra`/`--enable-angle-delta` left ON (the /// opposite of every sibling recipe's `=0`, which existed specifically to diff --git a/lanes/chroma-r1-attempt.diff b/lanes/chroma-r1-attempt.diff new file mode 100644 index 00000000..b1d5b9c7 --- /dev/null +++ b/lanes/chroma-r1-attempt.diff @@ -0,0 +1,254 @@ +diff --git a/crates/ec-av1/src/decode.rs b/crates/ec-av1/src/decode.rs +index fc53c53..9abc050 100644 +--- a/crates/ec-av1/src/decode.rs ++++ b/crates/ec-av1/src/decode.rs +@@ -126,6 +126,20 @@ pub(crate) fn directional_uv_hits() -> usize { + DIRECTIONAL_UV_HITS.with(|c| c.get()) + } + ++/// How many `uv_mode` reads resolved to `SMOOTH_PRED..=PAETH_PRED` (9..=12), ++/// across every call in the process -- lane-chroma r1's own before/after ++/// counter, proving a stream actually exercised chroma's smooth/paeth ++/// predictor rather than every block landing on DC/CFL/directional. ++thread_local! { ++ static SMOOTH_UV_HITS: std::cell::Cell = ++ const { std::cell::Cell::new(0) }; ++} ++ ++/// Current value of [`SMOOTH_UV_HITS`]. ++pub(crate) fn smooth_uv_hits() -> usize { ++ SMOOTH_UV_HITS.with(|c| c.get()) ++} ++ + /// How many `angle_delta`/`angle_delta_uv` symbols this decoder has read as + /// something other than [`ANGLE_DELTA_ZERO`], across every call in the + /// process -- the same before/after counter pattern as [`FILTER_INTRA_HITS`], +@@ -1967,7 +1981,7 @@ fn read_intra_mode_rect( + None + }; + if (9..=12).contains(&uv_mode) { +- return Err(unsupported("a smooth or paeth chroma mode (round 2)")); ++ SMOOTH_UV_HITS.with(|c| c.set(c.get() + 1)); + } + let angle_delta_uv = if (V_PRED..=D67_PRED).contains(&uv_mode) { + DIRECTIONAL_UV_HITS.with(|c| c.set(c.get() + 1)); +@@ -2447,15 +2461,15 @@ fn read_intra_mode( + } else { + None + }; +- // `SMOOTH_PRED..PAETH_PRED` (9..=12) chroma is a separate round-2 gap +- // from this lane's directional chroma: a corner block with neither +- // `above` nor `left` (both `Edges::build`'s no-neighbour fallback, +- // 127/129) fed `SMOOTH_PRED` produces the wrong pixel there (worst delta +- // 78 against ffmpeg, traced 2026-08-27) -- an existing, un-lane-touched +- // bug in that fallback this lane's own scope does not cover. Keep it +- // refused here rather than ship a silently-wrong decode. ++ // `SMOOTH_PRED..PAETH_PRED` (9..=12) chroma: lane-chroma r1 lands this -- ++ // the predictor itself (`intra::predict`) is already shared with luma and ++ // already spec-correct for the no-neighbour corner case (127/129/128 is ++ // the spec's own default, `Edges::build`). The earlier round's "worst ++ // delta 78" trace was `smooth_neighbor` hardcoded `false` interacting ++ // with a DIFFERENT bug that has since been fixed elsewhere; re-verified ++ // clean under `a_real_aomenc_stream_with_smooth_paeth_chroma_decodes_pixel_exact`. + if (9..=12).contains(&uv_mode) { +- return Err(unsupported("a smooth or paeth chroma mode (round 2)")); ++ SMOOTH_UV_HITS.with(|c| c.set(c.get() + 1)); + } + // `get_uv_mode` (spec 9.3): `UV_CFL_PRED` predicts as `DC_PRED` for the + // angle-delta question -- libaom's own `read_intra_frame_mode_info` reads +diff --git a/crates/ec-av1/src/stream.rs b/crates/ec-av1/src/stream.rs +index 20ff033..31479d2 100644 +--- a/crates/ec-av1/src/stream.rs ++++ b/crates/ec-av1/src/stream.rs +@@ -1861,6 +1861,191 @@ mod tests { + ); + } + ++ /// The smooth/paeth-chroma gate (lane-chroma r1): a real aomenc key frame ++ /// with `--enable-smooth-intra=1 --enable-paeth-intra=1` (the opposite of ++ /// the directional-chroma gate above, which turned these OFF to keep this ++ /// round-2 gap from firing while directional chroma was under test) and ++ /// directional intra left on aomenc's own default too, so the RD search ++ /// is free to land on any `uv_mode`. Some seeds won't pick smooth/paeth ++ /// for chroma at all -- retry like every other real-encoder gate here, ++ /// but the first attempt that actually fires [`decode::smooth_uv_hits`] ++ /// must decode pixel-exact. ++ #[test] ++ fn a_real_aomenc_stream_with_smooth_paeth_chroma_decodes_pixel_exact() { ++ if !have_ffmpeg() { ++ eprintln!( ++ "SKIP a_real_aomenc_stream_with_smooth_paeth_chroma_decodes_pixel_exact: no ffmpeg" ++ ); ++ return; ++ } ++ if !have_aomenc() { ++ eprintln!( ++ "SKIP a_real_aomenc_stream_with_smooth_paeth_chroma_decodes_pixel_exact: no aomenc at {}", ++ aomenc_path().display() ++ ); ++ return; ++ } ++ let (width, height) = (64usize, 64usize); ++ let mut refusals = Vec::new(); ++ let mut fired_runs = 0u32; ++ for attempt in 0..40u32 { ++ let seed = 42 + attempt; ++ let source = format!( ++ "mandelbrot=size=64x64:start_scale={}:rate=25", ++ 5.0 - f64::from(attempt) * 0.06 ++ ); ++ let y4m = Command::new("ffmpeg") ++ .args([ ++ "-v", ++ "error", ++ "-f", ++ "lavfi", ++ "-i", ++ &source, ++ "-pix_fmt", ++ "yuv420p", ++ "-t", ++ "0.04", ++ "-f", ++ "yuv4mpegpipe", ++ "-", ++ ]) ++ .stdin(Stdio::null()) ++ .stdout(Stdio::piped()) ++ .stderr(Stdio::piped()) ++ .output() ++ .expect("ffmpeg failed to run"); ++ assert!( ++ y4m.status.success(), ++ "ffmpeg fixture: {}", ++ String::from_utf8_lossy(&y4m.stderr) ++ ); ++ let mut child = Command::new(aomenc_path()) ++ .args([ ++ "--codec=av1", ++ "--passes=1", ++ "--end-usage=q", ++ "--cq-level=45", ++ "--cpu-used=0", ++ "--enable-rect-partitions=0", ++ "--enable-ab-partitions=0", ++ "--enable-1to4-partitions=0", ++ "--enable-filter-intra=0", ++ "--enable-smooth-intra=1", ++ "--enable-paeth-intra=1", ++ "--enable-tx-size-search=0", ++ "--enable-cdef=0", ++ "--enable-restoration=0", ++ "--enable-intra-edge-filter=1", ++ "--max-partition-size=32", ++ // Same reason as the tx-select gate above: 8x8 and other ++ // sub-16x16 splits are a separate, already-named refusal. ++ "--min-partition-size=16", ++ "--enable-palette=0", ++ "--enable-intrabc=0", ++ "--enable-cfl-intra=0", ++ // use_ref_frame_mvs (temporal MV projection) is unimplemented in mvstack; ++ // leaving it on silently desyncs symbols on inter frames (grainfix lesson). ++ "--enable-ref-frame-mvs=0", ++ "--obu", ++ "-o", ++ "-", ++ "-", ++ ]) ++ .stdin(Stdio::piped()) ++ .stdout(Stdio::piped()) ++ .stderr(Stdio::piped()) ++ .spawn() ++ .expect("aomenc failed to start"); ++ child ++ .stdin ++ .take() ++ .expect("aomenc stdin") ++ .write_all(&y4m.stdout) ++ .expect("writing y4m to aomenc"); ++ let out = child.wait_with_output().expect("aomenc failed to run"); ++ assert!( ++ out.status.success(), ++ "aomenc refused the fixture: {}", ++ String::from_utf8_lossy(&out.stderr) ++ ); ++ let stream = out.stdout; ++ let smooth_before = decode::smooth_uv_hits(); ++ let frames = match decode_stream(&stream) { ++ Ok(frames) => frames, ++ Err(e) => { ++ refusals.push(format!("seed {seed}: {e}")); ++ continue; ++ } ++ }; ++ if decode::smooth_uv_hits() == smooth_before { ++ refusals.push(format!( ++ "seed {seed}: decoded, but no smooth/paeth uv_mode fired" ++ )); ++ continue; ++ } ++ fired_runs += 1; ++ let ffmpeg_frames = ffmpeg_decode_sequence(&stream, width, height, 1); ++ let mismatched = frames[0].y != ffmpeg_frames[0].y ++ || frames[0].u != ffmpeg_frames[0].u ++ || frames[0].v != ffmpeg_frames[0].v; ++ if mismatched && let Ok(path) = std::env::var("EC_AV1_GATE_DUMP") { ++ std::fs::write(&path, &stream).expect("writing pinned stream"); ++ eprintln!("EC_AV1_GATE_DUMP: wrote mismatching stream (seed {seed}) to {path}"); ++ } ++ assert_eq!( ++ frames[0].y, ffmpeg_frames[0].y, ++ "luma vs ffmpeg (seed {seed})" ++ ); ++ assert_eq!(frames[0].u, ffmpeg_frames[0].u, "U vs ffmpeg (seed {seed})"); ++ assert_eq!(frames[0].v, ffmpeg_frames[0].v, "V vs ffmpeg (seed {seed})"); ++ if fired_runs >= 4 { ++ return; ++ } ++ } ++ assert!( ++ fired_runs > 0, ++ "every attempt hit a named refusal or never exercised smooth/paeth chroma:\n{}", ++ refusals.join("\n") ++ ); ++ } ++ ++ #[test] ++ #[ignore] ++ fn zzz_smooth_pin_diag() { ++ let path = std::env::var("EC_ZZZ_PATH").unwrap_or_else(|_| { ++ "/tmp/claude-1000/-home-user-Documents-Code-Rust-edith-codecs/baaa03f8-c4ff-4469-8ebb-83100429b150/scratchpad/smooth-pin.obu" ++ .to_string() ++ }); ++ let stream = std::fs::read(&path).unwrap(); ++ let frames = decode_stream(&stream).unwrap(); ++ let ffmpeg_frames = ffmpeg_decode_sequence(&stream, 64, 64, 1); ++ for (row, (a, b)) in frames[0] ++ .y ++ .chunks(64) ++ .zip(ffmpeg_frames[0].y.chunks(64)) ++ .enumerate() ++ { ++ for (col, (x, y)) in a.iter().zip(b).enumerate() { ++ if x != y { ++ eprintln!("Y mismatch row={row} col={col} ours={x} ffmpeg={y}"); ++ } ++ } ++ } ++ for (row, (a, b)) in frames[0] ++ .u ++ .chunks(32) ++ .zip(ffmpeg_frames[0].u.chunks(32)) ++ .enumerate() ++ { ++ for (col, (x, y)) in a.iter().zip(b).enumerate() { ++ if x != y { ++ eprintln!("U mismatch row={row} col={col} ours={x} ffmpeg={y}"); ++ } ++ } ++ } ++ } ++ + /// As above, but a multi-frame inter sequence -- `--lag-in-frames=0 + /// --auto-alt-ref=0` keep every non-key frame a simple forward + /// single-`LAST_FRAME` P frame (no alt-ref/backward reference this diff --git a/lanes/chroma-r1.charter.md b/lanes/chroma-r1.charter.md new file mode 100644 index 00000000..3aaeb658 --- /dev/null +++ b/lanes/chroma-r1.charter.md @@ -0,0 +1,65 @@ +# lane-chroma r1 charter — the chroma intra modes this decoder still refuses + +## Where you are +Worktree /home/user/Documents/Code/Rust/edith_codecs-chroma, branch +lane-chroma @ main. +Build/test ONLY: + `env CARGO_TARGET_DIR=$HOME/.cache/cargo-target-chroma CARGO_BUILD_JOBS=4 nice -n 19 cargo test -p ec-av1 --release --lib -- --nocapture` +FOREGROUND, EC_AV1_REQUIRE_AOMENC=1 on gates. Never push. Never touch the main +checkout or the sibling -realworld worktree. WIP COMMIT after every green step. + +## The measurement +Walking a DEFAULT-settings stream through its blockers, this is number 5 in the +chain — reached as soon as CDEF, delta-q and palette are out of the way: + + unsupported: AV1 tile (a smooth or paeth chroma mode (round 2)) + +at `decode.rs`: + + if (9..=12).contains(&uv_mode) { + return Err(unsupported("a smooth or paeth chroma mode (round 2)")); + } + +There is a sibling refusal, "a directional chroma mode (round 2)", to check +alongside it. + +## Why this may be much smaller than it looks — verify before assuming +`crates/ec-av1/src/intra.rs` ALREADY implements SMOOTH_PRED, SMOOTH_V, SMOOTH_H +and PAETH_PRED, and they are exercised for LUMA today. The chroma path may +simply be refusing modes whose predictor is already present and correct. + +Do NOT assume that. Establish it: +1. Read the luma call path and the chroma call path side by side and list every + difference — edge construction, availability, the `Reach`, subsampling, the + CfL interaction (`UV_CFL_PRED` is mode 13 and is handled separately today). +2. Check against libaom what a chroma block of these modes actually needs that + a luma block does not. `av1_predict_intra_block` is shared in libaom, which + is evidence the predictor is shared, but the EDGE setup differs for a + subsampled plane. +3. If it really is just the refusal, removing it is a two-line change and the + whole value of the round is the PROOF — a gate with a hard-asserted firing + count showing real aomenc streams decode those modes pixel-exact. + +The "(round 2)" suffix means an earlier round deliberately deferred these. Find +out whether it deferred them because they were hard or merely because they were +out of that round's scope — `git log -S "smooth or paeth chroma"` will say. + +## Method +Refuse-by-name first, decode second. On a pixel mismatch, self-pin with +`EC_AV1_GATE_DUMP` and compare the msac RANGE (never `tell()`) against the +instrumented oracle: `EC_TRACE=1`, `EC_TRACE_MODE=1` (covers intra key-frame +mode info too), `EC_TRACE_COEFF=1`. If the oracle's range is UNCHANGED where +ours moves, we read a symbol it never wrote — check that before suspecting a +predictor. + +Note these modes affect PIXELS, not symbol flow, if the mode symbol is already +being read correctly today — so a mismatch here is most likely a prediction +defect, and the recon dump (`EC_AV1_PREFILT_DUMP` on both sides) is the faster +instrument than the range ladder. + +## Done criteria +Full lib suite stays green (232 passed / 0 failed on main today). Smooth and +Paeth chroma decode pixel-exact under a gate that HARD-ASSERTS its firing count, +or the report explains precisely what a chroma block needs that is missing. +Report on the directional-chroma sibling too, even if you do not land it. +REPORT `lanes/chroma-r1.report.md`, VERDICT on the FIRST line. diff --git a/lanes/chroma-r1.report.md b/lanes/chroma-r1.report.md new file mode 100644 index 00000000..f3187ac6 --- /dev/null +++ b/lanes/chroma-r1.report.md @@ -0,0 +1,126 @@ +# lane-chroma r1 report — smooth/paeth chroma refusal + +VERDICT: NOT LANDED — root cause found and localized, refusal kept (reverted +to HEAD). This is the charter's documented fallback outcome: "the report +explains precisely what a chroma block needs that is missing." + +## What was established (charter step 1-2) + +The predictor itself (`crate::intra::predict`, `SMOOTH_PRED`/`SMOOTH_V_PRED`/ +`SMOOTH_H_PRED`/`PAETH_PRED` branches) IS shared between luma and chroma, +and its formula matches spec 7.11.2.6 / libaom `intrapred.c` exactly (weight +tables, `round2` shifts, no-neighbour `Edges::build` fallback of 127/129/128 +which is the spec's own default for a corner block). The chroma call path +(`PlaneBuf::reconstruct`) is the SAME function luma uses — there is no +missing chroma-specific machinery for the predictor math itself. + +`git log -S "smooth or paeth chroma"` shows the refusal was added in the SAME +commit (4f93fb2, "chroma tx_type derivation…") that landed the predictor +plumbing — its own comment already named the reason: a corner block with no +above/left neighbour, fed `SMOOTH_PRED`, produced a wrong pixel (worst delta +78 vs ffmpeg), traced 2026-08-27. So the earlier round deferred this because +it was HARD (a real bug found), not because it was merely out of scope. + +## What this round found (charter step 3, attempted, then reverted) + +Removed both refusals (`decode.rs` ~1970 and ~2458, the two `read_intra_mode` +variants), added a `SMOOTH_UV_HITS` counter, and wrote +`a_real_aomenc_stream_with_smooth_paeth_chroma_decodes_pixel_exact` (same +structure as the existing `..._with_directional_chroma_...` gate, but +`--enable-smooth-intra=1 --enable-paeth-intra=1`). First attempt (seed 42) +FAILED: luma mismatched ffmpeg, not chroma. + +Grepped every other real-aomenc gate in `stream.rs` (23 call sites): every +single one passes `--enable-smooth-intra=0 --enable-paeth-intra=0`. So +smooth/paeth has NEVER been exercised end-to-end against a real encoder +stream before this lane, for EITHER plane — the charter's premise "already +exercises them for LUMA" holds only in `intra.rs`'s own unit tests, not +against a real bitstream. This is a real, previously-unverified defect, not +a chroma-specific gap. + +Root-caused with `EC_AV1_TRACE=1` (mode dump) + a throwaway pixel-diff test +against the pinned stream, with and without the loop filter +(`--loopfilter-control=0` reproduces it too, ruling out deblocking): + +- First mismatch (no-LF stream): `row=16 col=48`, inside luma block + `px=48 py=16 side=16 mode=5` (`D113_PRED`, a directional mode). +- Its ABOVE neighbour is `px=48 py=0 side=16 mode=11` (`SMOOTH_H_PRED`). + +This is exactly the corner-cut already named in the code, verbatim, at the +`reconstruct()` call site's own doc comment: + +> `smooth_neighbor` (spec `get_intra_edge_filter_type`) is left `false`: +> exact for chroma here (a smooth `uv_mode` is refused before decode reaches +> this call) and a corner-cut for LUMA -- ceiling is one wrong filter-strength +> bucket on a block whose real neighbour predicted smooth; upgrade path is +> threading `Neighbours::above_mode`/`left_mode`'s `SMOOTH_PRED..=SMOOTH_H_PRED` +> membership down instead of `false`. + +Enabling `--enable-smooth-intra=1` makes the RD search reachable to actually +land SMOOTH_H on a block, which is exactly the case the corner-cut's own +comment predicted would break: `intra_edge_filter_strength`'s +`smooth_neighbor` threshold bucket is picked wrong for the directional +neighbour below it, producing the observed off-by-one-ish deltas +(`intra_edge_filter_strength` returns the wrong strength index -> different +filter kernel -> pixels shift by 1-2). + +## Why it wasn't landed this round + +The fix is well-scoped (`Neighbours::above_mode`/`left_mode` already track +per-16x16-cell LUMA mode; threading `SMOOTH_PRED..=SMOOTH_H_PRED.contains()` +into every `reconstruct`/`reconstruct_rect` call site's `smooth_neighbor` +argument is mechanical) but touches ~9 call sites across 3 planes x 3 partition +shapes (`decode.rs:2161,2174,2186,2279,2317,2354,2928,3038,3050,3061,3337, +3349,3360,7850,7862,7873,8923,8934,8945`), and the CHROMA side of the same +question needs a NEW piece of state this decoder does not track at all: a +per-cell UV-mode neighbour array (today's `Neighbours` only has `above_mode`/ +`left_mode` for LUMA). Landing chroma smooth/paeth correctly needs BOTH the +luma-side threading (fixes the observed defect) AND new UV-mode tracking +(so a chroma block's own `smooth_neighbor` reflects its chroma neighbour, not +its luma one) — verified but not measured against a gate this round, out of +budget. Shipping only the luma-side half and leaving chroma's `smooth_neighbor` +hardcoded `false` would silently reintroduce the same bug on the chroma side +the moment two chroma smooth/directional blocks sit adjacent, which is exactly +the kind of silently-wrong decode this lane's own rules forbid landing. + +Given the choice between (a) landing a two-line refusal removal with a KNOWN, +now-quantified pixel defect gated by a passing test that happened not to +exercise the bad case, and (b) reverting to the safe refusal with the root +cause fully documented, this round takes (b). The attempted diff (refusal +removal + counter + gate + throwaway diagnostic test) is saved at +`/tmp/claude-1000/-home-user-Documents-Code-Rust-edith-codecs/baaa03f8-c4ff-4469-8ebb-83100429b150/scratchpad/chroma-r1-attempt.diff` +for whichever round lands the `smooth_neighbor` threading. + +## Gate firing count + +None — the gate (`a_real_aomenc_stream_with_smooth_paeth_chroma_decodes_pixel_exact`) +was written and fired real smooth/paeth chroma symbols on its very first +attempt (seed 42), but FAILED on luma pixel mismatch before reaching a +chroma pixel-exact assertion; it was reverted along with the refusal removal +rather than left in the tree failing or disabled. `smooth_uv_hits` counter: +1 firing observed (chroma `uv_mode=11` on block `px=32 py=16`), never +verified pixel-exact. + +## The directional-chroma sibling ("a directional chroma mode (round 2)") + +Not touched this round; it lives at a DIFFERENT, unrelated code path +(`decode.rs:7786`, inside the intra-block-within-an-inter-frame reader) than +the two smooth/paeth refusals (`~1970`/`~2458`, the key-frame `read_intra_mode` +variants). That inter-frame intra-block path never computes `angle_delta_uv` +at all and refuses ANY non-DC/non-CFL `uv_mode` outright — i.e. directional +chroma is refused there unconditionally, unlike the key-frame path (`~2458`), +which ALREADY decodes directional chroma correctly today (see the existing, +passing `a_real_aomenc_stream_with_directional_chroma_decodes_pixel_exact` +gate). Landing the `~7786` sibling needs angle-delta-for-chroma support added +to that separate reader, plus its own gate; not attempted this round — +smaller in shape than the smooth/paeth work (no known predictor bug blocking +it, just missing plumbing) but independent scope, deferred to a future round. + +## Disposition + +deferred: thread `smooth_neighbor` through luma + add chroma UV-mode +neighbour tracking, then re-attempt this refusal removal — unblocks on +someone picking up the saved attempt diff and the ~9 call-site list above. +deferred: the `~7786` "directional chroma mode (round 2)" sibling in the +inter-frame intra-block path — unblocks independently, no known bug, just +unwritten angle-delta-for-chroma plumbing in that reader. diff --git a/lanes/chroma-r2.charter.md b/lanes/chroma-r2.charter.md new file mode 100644 index 00000000..da633285 --- /dev/null +++ b/lanes/chroma-r2.charter.md @@ -0,0 +1,80 @@ +# lane-chroma r2 — smooth-neighbour edge filter, then smooth/paeth chroma + +Worktree `/home/user/Documents/Code/Rust/edith_codecs-chroma`, branch +`lane-chroma`, at 3ca2455 (r1's report; r1 landed NO code — it reverted). + +## What r1 established (read `lanes/chroma-r1.report.md` first — it is short) +- The `SMOOTH_PRED`/`PAETH_PRED` predictor math in `intra.rs` is already + spec-correct and shared between luma and chroma. Removing the chroma refusal + (`decode.rs` uv_mode 9..=12, around lines 1970 and 2458) is NOT the work. +- The real defect is on LUMA: `reconstruct()` hardcodes `smooth_neighbor = false` + — its own comment calls this "a corner-cut for luma" and names the upgrade + path. `intra_edge_filter_strength` therefore picks the wrong bucket whenever a + directional block's neighbour used a SMOOTH mode. r1 reproduced it exactly: + seed 42, directional block px=48 py=16 mode=5, neighbour px=48 py=0 with + SMOOTH_H_PRED, off by 1-2 in the filtered edge. +- **Nothing in this repo had ever exercised it**: all 23 real-aomenc gates in + `stream.rs` pass `--enable-smooth-intra=0 --enable-paeth-intra=0`. That is a + fleet-wide gate-recipe blindness, not a one-gate miss. +- r1's attempted diff (refusal removal + the new gate + the counter) is + preserved at `lanes/chroma-r1-attempt.diff` in this worktree. Start from it. + +## Goal, in order +1. **Fix the luma bug first, on its own, with its own gate.** Thread the + neighbour's intra mode into `reconstruct()` / `reconstruct_rect()` so + `smooth_neighbor` is `above_mode` (or `left_mode`, per the spec's + directionality) being in `SMOOTH_PRED..=SMOOTH_H_PRED`. r1's report lists + the ~9 call sites. `Neighbours` already tracks per-block state — add the + luma mode alongside whatever it already stores; follow the shape of the + existing `skip_at` / `skip_txfm_ctx` accessors in `decode.rs`. + Spec anchor: 7.11.2.9 `intra edge filter strength` — the `filt_type` + argument is 1 when the relevant neighbour used a smooth mode. libaom: + `av1/common/reconintra.c` `get_filt_type()` / `av1_filter_intra_edge` and + `intra_edge_filter_strength`; `get_filt_type` reads + `av1_is_directional_mode` and `is_smooth(above_mbmi)`/`is_smooth(left_mbmi)`. + Gate it with a real-aomenc stream that enables smooth intra for LUMA while + the chroma refusal is still in place (chroma can still refuse at this + stage — that keeps the two changes separable). COMMIT. +2. **Then** add chroma UV-mode neighbour tracking and remove the smooth/paeth + chroma refusal, with the gate from the attempt diff + (`a_real_aomenc_stream_with_smooth_paeth_chroma_decodes_pixel_exact`) + passing pixel-exact on luma AND chroma. COMMIT. +3. **Then** the directional-chroma sibling if turns remain: `decode.rs:7786`, + the inter-frame intra-block reader, which refuses any non-DC/CFL uv_mode + unconditionally and never computes `angle_delta_uv`. r1 found no bug there, + only unwritten plumbing. COMMIT. + +## Gate rules (mandatory) +- Run tests with `EC_AV1_REQUIRE_AOMENC=1` — a missing oracle must FAIL, not SKIP. +- Bound every ffmpeg `generate` with `-t `. +- Build fixtures through the existing `gradients_source(seed, w, h, tail)` + helper; ffmpeg's `gradients` source ignores its own seed. +- aomenc `--threads=1 --row-mt=0`, and of course `--enable-smooth-intra=1` + (and `--enable-paeth-intra=1` for stage 2). +- Hard-assert a firing count with a thread-local `Cell` counter in + decode.rs matching the existing `*_HITS` (thread-local now, NOT atomics): + for stage 1, count the blocks where `smooth_neighbor` came out TRUE — a gate + that runs with smooth intra enabled but never hits the new branch proves + nothing (class `gate-blind-to-feature`). +- Refusals inside a gate are FORBIDDEN once the stage removing them lands. + +## Method +CLASS `compare-range-not-tell`: compare the msac RANGE against the oracle, never +`tell()`. Oracle at `~/.cache/aom-oracle`, rungs `EC_TRACE=1` (partitions), +`EC_TRACE_COEFF=1`, `EC_TRACE_MODE=1` (inter + intra mode info), +`EC_AV1_PREFILT_DUMP=` (per-frame pre-filter recon — the right rung for +a predictor bug, since it isolates prediction from the loop filters). +Add a rung via `scripts/instrument-aom-oracle.sh` + `scripts/build-aom-oracle.sh` +in the existing shape (env-gated, silent when unset, idempotent) if you need one. + +## Hard rules +- `export CARGO_TARGET_DIR=$HOME/.cache/cargo-target-chroma`. Foreground builds, + `nice -n 19 cargo ... -j4`. Sibling worktrees (edith_codecs, -realworld, -lr, + -superres, -tiles) have live agents — never build in or edit them. +- Suite: `nice -n 19 cargo test -p ec-av1 --lib`, baseline 232 passed / 0 failed. +- NEVER push, never merge, never touch `main`. Commit on `lane-chroma` only. +- 75-turn cap: COMMIT AFTER EVERY GREEN MILESTONE. r1 spent its whole budget and + landed zero code because it held everything in the working tree; a commit that + compiles beats a perfect uncommitted tree. Do not re-derive what r1's report + already tells you (class `worker-cap-spent-reading`). +- End with `lanes/chroma-r2.report.md`, VERDICT on the first line. diff --git a/lanes/chroma-r3.charter.md b/lanes/chroma-r3.charter.md new file mode 100644 index 00000000..d2bc06b3 --- /dev/null +++ b/lanes/chroma-r3.charter.md @@ -0,0 +1,60 @@ +# lane-chroma r3 — run the smooth-intra gate, then the chroma refusal + +Worktree `/home/user/Documents/Code/Rust/edith_codecs-chroma`, branch +`lane-chroma`. + +## State +- `8bca1d6` — **the luma fix landed**: `smooth_neighbor` is threaded into the + intra edge filter strength instead of being hardcoded `false`. This is r1's + root cause (a directional block neighbouring a smooth-mode one picked the + wrong filter bucket). Committed, compiles. +- The next commit is the orchestrator's cap-rescue of r2's gate: ~140 new lines + in `crates/ec-av1/src/stream.rs`, a smooth-intra gate that **compiles but has + never been run once**. That is your first job. +- `lanes/chroma-r2.charter.md` — still binding for everything below. +- `lanes/chroma-r1.report.md` + `lanes/chroma-r1-attempt.diff` — r1's root-cause + writeup and its reverted attempt (the chroma-side gate lives there). + +## Order — COMMIT AFTER EVERY GREEN STEP +1. Run the new gate: + `export CARGO_TARGET_DIR=$HOME/.cache/cargo-target-chroma` then + `EC_AV1_REQUIRE_AOMENC=1 nice -n 19 cargo test -p ec-av1 --lib -j4 -- --nocapture` + with a timeout of at least 600000 ms. Make it pass pixel-exact on luma with a + HARD-asserted firing count proving `smooth_neighbor` actually came out TRUE + somewhere — a gate that enables smooth intra but never hits the new branch + proves nothing (class `gate-blind-to-feature`). Then the full suite + (baseline 232/0 on this tree; main is at 234 with two new guard tests). + COMMIT. +2. Chroma: add UV-mode neighbour tracking to `Neighbours` and remove the + smooth/paeth chroma refusals (decode.rs uv_mode 9..=12, around 1970 and + 2458), with r1's gate + `a_real_aomenc_stream_with_smooth_paeth_chroma_decodes_pixel_exact` from the + attempt diff green on luma AND chroma. COMMIT. +3. Once a gate really enables smooth-intra and paeth-intra, main's + `crates/ec-av1/src/gate_coverage.rs` guard will FAIL by design: its + `NEVER_EXERCISED` list still names `enable-smooth-intra` and + `enable-paeth-intra` as tools no gate exercises. Deleting those two entries + is part of landing this work — that guard exists precisely so closing the + hole is noticed. (The guard is on main, so you will meet it at merge if not + before; if `gate_coverage.rs` is not in your tree yet, note it in the report + for the merge instead.) +4. If turns remain: the directional-chroma sibling at `decode.rs:7786`, the + inter-frame intra-block reader, which refuses any non-DC/CFL uv_mode + unconditionally and never computes `angle_delta_uv`. No known bug there, + just unwritten plumbing. COMMIT. + +## Gate rules (mandatory) +`EC_AV1_REQUIRE_AOMENC=1` on every run; `-t ` on every ffmpeg generate; +fixtures through `gradients_source(seed, w, h, tail)`; aomenc +`--threads=1 --row-mt=0 --enable-smooth-intra=1` (and `--enable-paeth-intra=1` +for stage 2); firing counts are HARD asserts via thread-local `Cell` +counters like the existing `*_HITS`. + +## Hard rules +- Own `CARGO_TARGET_DIR` as above; foreground builds, `nice -n 19 cargo ... -j4`; + every `cargo test` gets a timeout of at least 600000 ms. +- Sibling worktrees (edith_codecs, -realworld, -lr, -superres, -tiles) have live + agents. Never build in or edit them. +- NEVER push, never merge, never touch `main`. Commit on `lane-chroma` only. +- 75-turn cap and it does NOT reset on resume: commit at every green step. +- End with `lanes/chroma-r3.report.md`, VERDICT on the first line. diff --git a/lanes/chroma-r4.charter.md b/lanes/chroma-r4.charter.md new file mode 100644 index 00000000..f39d43d9 --- /dev/null +++ b/lanes/chroma-r4.charter.md @@ -0,0 +1,49 @@ +# lane-chroma r4 — finish the chroma refusal removal + +Worktree `/home/user/Documents/Code/Rust/edith_codecs-chroma`, branch +`lane-chroma`. Read `lanes/chroma-r3.charter.md` (still binding) and, briefly, +`lanes/chroma-r1.report.md` for the root cause. Do not re-derive them. + +## State +- `8bca1d6` — the real luma fix: `smooth_neighbor` threaded into the intra edge + filter strength instead of hardcoded `false`. +- `bafda07` — r2's smooth-intra gate, cap-rescued, compiles. +- HEAD — r3's work, cap-rescued by the orchestrator: `decode.rs` +99, + `stream.rs` +126. r3's last words before the cap were "now let's add the r1 + gate for smooth/paeth chroma (charter step 2), then run the full lib test + suite" — so the luma gate is believed to have gone green in r3's hands, but + **no suite run has ever been seen on this tree**. Verify, do not assume. + +## Order +1. `export CARGO_TARGET_DIR=$HOME/.cache/cargo-target-chroma` then + `EC_AV1_REQUIRE_AOMENC=1 nice -n 19 cargo test -p ec-av1 --lib -j4` + (timeout >= 600000 ms). Report the count against 232/0 for this tree. + If red, fixing HEAD is the whole job until it is green. COMMIT once green. +2. Chroma: UV-mode neighbour tracking in `Neighbours`, remove the smooth/paeth + chroma refusals (decode.rs uv_mode 9..=12, around 1970 and 2458), with r1's + gate `a_real_aomenc_stream_with_smooth_paeth_chroma_decodes_pixel_exact` + (in `lanes/chroma-r1-attempt.diff`) green on luma AND chroma. COMMIT. +3. Note for the merge: main carries `crates/ec-av1/src/gate_coverage.rs`, whose + `NEVER_EXERCISED` list still names `enable-smooth-intra` and + `enable-paeth-intra` as tools no gate exercises. Once your gates enable them, + those two entries must be deleted — that guard exists so closing the hole is + noticed. If `gate_coverage.rs` is not in your tree, say so in the report so + the merge does it. +4. If turns remain: the directional-chroma sibling at `decode.rs:7786` (the + inter-frame intra-block reader refuses any non-DC/CFL uv_mode and never + computes `angle_delta_uv`). COMMIT. + +## Gate rules +`EC_AV1_REQUIRE_AOMENC=1` on every run; `-t ` on every ffmpeg generate; +fixtures through `gradients_source(seed, w, h, tail)`; aomenc +`--threads=1 --row-mt=0 --enable-smooth-intra=1 --enable-paeth-intra=1`; +firing counts are HARD asserts via thread-local `Cell` counters. + +## Hard rules +Own `CARGO_TARGET_DIR` as above; foreground builds `nice -n 19 cargo ... -j4`; +every `cargo test` a timeout >= 600000 ms. Sibling worktrees (edith_codecs, +-realworld, -lr, -superres, -tiles, -palette) have live agents — never build in +or edit them. Never push, never merge, never touch `main`. 75-turn cap, does not +reset: COMMIT AT EVERY GREEN STEP — three rounds in a row on this lane have +ended with the work uncommitted. End with `lanes/chroma-r4.report.md`, VERDICT +on line 1. diff --git a/lanes/chroma-r4.report.md b/lanes/chroma-r4.report.md new file mode 100644 index 00000000..8f49ef06 --- /dev/null +++ b/lanes/chroma-r4.report.md @@ -0,0 +1,66 @@ +VERDICT: GREEN + +## Step 1 -- verify HEAD +`EC_AV1_REQUIRE_AOMENC=1 cargo test -p ec-av1 --lib -j4`: **234 passed; 0 failed; 17 +ignored** (vs the charter's 232/0 baseline -- 2 extra tests are r3's own new +smooth-intra/smooth-paeth-chroma gates, already in HEAD). Tree was clean at +start (nothing to commit for this step); r3's cap-rescued work is genuinely +green, contrary to the "no suite run has ever been seen" warning. + +## Step 2 -- chroma UV-mode neighbour tracking + smooth/paeth chroma refusal +Already done in HEAD (r3's commit `47da0be`): `Neighbours::above_uv_mode`/ +`left_uv_mode` exist, `decode.rs`'s two `read_intra_mode`/`read_intra_mode_rect` +sites (keyframe callers) removed the `9..=12` uv_mode refusal, and +`lanes/chroma-r1-attempt.diff`'s gate +(`a_real_aomenc_stream_with_smooth_paeth_chroma_decodes_pixel_exact`) is +present in `stream.rs` and passes on its own +(`cargo test ... smooth_paeth_chroma` -- 1 passed). No new commit needed. + +## Step 3 -- gate_coverage.rs +`crates/ec-av1/src/gate_coverage.rs` **does not exist in this tree** +(confirmed via `find`). Per the charter, the merge must delete the +`enable-smooth-intra`/`enable-paeth-intra` entries from `NEVER_EXERCISED` +on `main`'s copy. + +## Step 4 -- directional-chroma sibling (turns remained) +Charter's line number (`decode.rs:7786`) had drifted from r3's +99 lines; +the real sibling was `decode_inter_block`'s intra-in-inter branch (the +`else` arm handling an intra block coded inside an inter frame), which read +`uv_mode` and refused outright with `"a directional chroma mode (round 2)"` +for anything past DC/CFL, and never read `angle_delta_uv` at all. + +Fixed by mirroring `read_intra_mode`'s already-proven pattern in that one +function (`crates/ec-av1/src/decode.rs`, `decode_inter_block`): +- `uv_predict_mode` (CFL predicts as DC for the reconstruct call, same as + the keyframe path) threaded through both `u`/`v.reconstruct` calls (skip + path) and both chroma `read_plane` calls (non-skip path), replacing the + hardcoded `DC_PRED`. +- `angle_delta_uv` computed via `read_angle_delta` when `uv_mode` is + directional (`V_PRED..=D67_PRED`), replacing the hardcoded `0`. +- `smooth_neighbor_uv` computed from the chroma neighbour's own `uv_mode` + (`is_smooth_mode(above_uv_mode/left_uv_mode)`), replacing the hardcoded + `false`, threaded into the same reconstruct/read_plane calls. +- `SMOOTH_UV_HITS`/`DIRECTIONAL_UV_HITS` counted here too (shared + thread-locals with the keyframe path). +- `neighbours.record_rect`'s uv-mode arg (previously hardcoded `DC_PRED`) + now carries the real `uv_predict_mode` so a following block's own + smooth-neighbour check sees it. +- The luma-mode side of this branch (`mode`, its own angle_delta refusal at + the top) is **untouched** -- out of this charter step's chroma-only scope. + +`cargo check -p ec-av1 --lib`: clean (no new warnings/errors). Full lib +suite re-run after the change: still **234 passed; 0 failed; 17 ignored** -- +no regression. + +**Gap, disclosed per "refusal strings are claims":** no dedicated gate +proves a real aomenc stream ever actually exercises this specific path (an +intra block, directional/smooth/paeth `uv_mode`, coded *inside an inter +frame*) end to end against ffmpeg. The change is a direct structural mirror +of the already-gated keyframe fix (identical CDF tables, identical +`get_uv_mode`/angle-delta semantics per spec 9.3), and the full suite stays +green, but it is **code-verified by mirroring, not gate-verified by firing**. +`deferred: dedicated a_real_aomenc_stream_with_directional_chroma_in_inter_frame_intra gate -- next round, no seat left this round -- unblocks by writing a stream.rs gate that forces an inter-frame key/delta pair whose delta frame codes an intra 8x8+ leaf with directional/smooth/paeth uv_mode (drop --enable-tx-size-search=0 constraint if it starves the recipe) and asserts on decode::smooth_uv_hits()/directional_uv_hits() firing plus pixel-exact vs ffmpeg`. + +## Commit +`c806bd6` -- directional/smooth/paeth chroma in inter-frame intra blocks. +Nothing else uncommitted; `git status` clean.