forge
Explore
Log in

Don't you dare go Hollow

Merge branch 'lane-chroma': smooth, paeth and directional chroma decode

Browse files at this commit

be7060ab12dafa901a2145e9c9f167ecb479fa51Ahmet Kaan GümüşParent: 51e931cbf25067
The lane went looking for chroma modes and found a luma bug first:
reconstruct() hardcoded smooth_neighbor = false, so the intra edge filter took
the wrong strength bucket whenever a directional block neighboured a
smooth-predicted one. Its own comment called it a corner-cut. Twenty gates had
never caught it because every one of them passed --enable-smooth-intra=0.

Landed here: the luma fix with smooth_neighbor threaded properly, UV-mode
neighbour tracking, the smooth/paeth chroma refusals gone (blocker 5 of the
default-settings chain), and the directional-chroma sibling in
decode_inter_block's intra-in-inter branch.

Gate-proven for the key-frame path. The inter-frame intra-block path is a
structural mirror of it plus a green suite, NOT proven by firing -- the lane
disclosed this itself, and the owed gate is written down in
lanes/chroma-r4.report.md: force an inter-frame leaf with such a uv_mode,
assert smooth_uv_hits/directional_uv_hits and pixel-exactness.

Both guards fired as designed and are updated: gate_coverage loses
enable-smooth-intra and enable-paeth-intra, refusal_inventory loses the two
round-2 chroma refusals.

Suite 239 passed / 0 failed.
crates/ec-av1/src/decode.rsmodified+191 -27
@@ -133,6 +133,36 @@ fn maybe_read_cdef_idx(dec: &mut SymbolDecoder, mi_r: usize, mi_c: usize, skip:
133 }133 }
134 }134 }
135 135
136+// How many key-frame luma blocks resolved `smooth_neighbor` (spec
137+// `get_intra_edge_filter_type`) to `true` -- lane-chroma r2's own before/after
138+// counter, proving a stream actually put a directional block next to a
139+// smooth-predicted neighbour rather than every block reading the (previously
140+// hardcoded `false`) edge-filter strength bucket unchanged.
141+thread_local! {
142+ static SMOOTH_LUMA_HITS: std::cell::Cell<usize> =
143+ const { std::cell::Cell::new(0) };
144+}
145+
146+/// Current value of [`SMOOTH_LUMA_HITS`].
147+pub(crate) fn smooth_luma_hits() -> usize {
148+ SMOOTH_LUMA_HITS.with(|c| c.get())
149+}
150+
151+// How many `uv_mode` reads resolved to `SMOOTH_PRED..=PAETH_PRED` (9..=12),
152+// across every call on the current thread -- lane-chroma r3's own before/after
153+// counter, proving a stream actually exercised chroma's smooth/paeth
154+// predictor (the previously-refused round-2 gap) rather than every block
155+// landing on DC/CFL/directional.
156+thread_local! {
157+ static SMOOTH_UV_HITS: std::cell::Cell<usize> =
158+ const { std::cell::Cell::new(0) };
159+}
160+
161+/// Current value of [`SMOOTH_UV_HITS`].
162+pub(crate) fn smooth_uv_hits() -> usize {
163+ SMOOTH_UV_HITS.with(|c| c.get())
164+}
165+
136 // How many 4-pixel deblocking edge groups [`edge_params`] has actually166 // How many 4-pixel deblocking edge groups [`edge_params`] has actually
137 // selected for filtering, across every call on the current thread -- the same167 // selected for filtering, across every call on the current thread -- the same
138 // before/after counter pattern as [`FILTER_INTRA_HITS`], proving a stream168 // before/after counter pattern as [`FILTER_INTRA_HITS`], proving a stream
@@ -1017,6 +1047,13 @@ fn default_intra_tx_type(mode: u8) -> TxType {
1017 }1047 }
1018 }1048 }
1019 1049
1050+/// `is_smooth` (libaom `reconintra.c`): true for `SMOOTH_PRED..=SMOOTH_H_PRED`
1051+/// (9..=11) — deliberately excludes `PAETH_PRED` (12), which the spec's own
1052+/// `get_intra_edge_filter_type`/libaom `get_filt_type` never treat as smooth.
1053+fn is_smooth_mode(mode: usize) -> bool {
1054+ (crate::intra::SMOOTH_PRED as usize..=crate::intra::SMOOTH_H_PRED as usize).contains(&mode)
1055+}
1056+
1020 fn read_coeffs(1057 fn read_coeffs(
1021 dec: &mut SymbolDecoder,1058 dec: &mut SymbolDecoder,
1022 coding: &mut TxbTables,1059 coding: &mut TxbTables,
@@ -1308,6 +1345,17 @@ struct Neighbours {
1308 left: Vec<[Neighbour; 3]>,1345 left: Vec<[Neighbour; 3]>,
1309 above_mode: Vec<usize>,1346 above_mode: Vec<usize>,
1310 left_mode: Vec<usize>,1347 left_mode: Vec<usize>,
1348+ /// Chroma's own `uv_mode` companion to `above_mode`/`left_mode` (lane-chroma
1349+ /// r3): a smooth/paeth `uv_mode`'s edge-filter strength (spec
1350+ /// `get_intra_edge_filter_type`) reads the CHROMA neighbour's mode, not the
1351+ /// luma one -- the same block can (and often does) code a different
1352+ /// `uv_mode` than its own `mode`. Coarse [`SUB`]-grid like `above_mode`;
1353+ /// [`Self::decode_leaf8`]'s per-leaf `prev_leaf` override (a real
1354+ /// within-block neighbour finer than this grid) is luma-only -- a known,
1355+ /// unexercised-by-gate corner-cut (every real-encoder gate in `stream.rs`
1356+ /// uses `--min-partition-size=16`, so no leaf8 8x8 split ever reaches this).
1357+ above_uv_mode: Vec<usize>,
1358+ left_uv_mode: Vec<usize>,
1311 above_side: Vec<usize>,1359 above_side: Vec<usize>,
1312 left_side: Vec<usize>,1360 left_side: Vec<usize>,
1313 /// The same as `above_side`/`left_side`, but kept at the finer mi (4x4)1361 /// The same as `above_side`/`left_side`, but kept at the finer mi (4x4)
@@ -1407,6 +1455,8 @@ impl Neighbours {
1407 left: vec![[Neighbour::default(); 3]; rows * (SUB / MI)],1455 left: vec![[Neighbour::default(); 3]; rows * (SUB / MI)],
1408 above_mode: vec![DC_PRED; cols],1456 above_mode: vec![DC_PRED; cols],
1409 left_mode: vec![DC_PRED; rows],1457 left_mode: vec![DC_PRED; rows],
1458+ above_uv_mode: vec![DC_PRED; cols],
1459+ left_uv_mode: vec![DC_PRED; rows],
1410 above_side: vec![SB; cols],1460 above_side: vec![SB; cols],
1411 left_side: vec![SB; rows],1461 left_side: vec![SB; rows],
1412 above_side_mi: vec![SB; cols * (SUB / MI)],1462 above_side_mi: vec![SB; cols * (SUB / MI)],
@@ -1540,6 +1590,7 @@ impl Neighbours {
1540 fn start_row(&mut self) {1590 fn start_row(&mut self) {
1541 self.left.iter_mut().for_each(|l| *l = Default::default());1591 self.left.iter_mut().for_each(|l| *l = Default::default());
1542 self.left_mode.iter_mut().for_each(|m| *m = DC_PRED);1592 self.left_mode.iter_mut().for_each(|m| *m = DC_PRED);
1593+ self.left_uv_mode.iter_mut().for_each(|m| *m = DC_PRED);
1543 self.left_side.iter_mut().for_each(|s| *s = SB);1594 self.left_side.iter_mut().for_each(|s| *s = SB);
1544 self.left_side_mi.iter_mut().for_each(|s| *s = SB);1595 self.left_side_mi.iter_mut().for_each(|s| *s = SB);
1545 self.left_skip.iter_mut().for_each(|s| *s = false);1596 self.left_skip.iter_mut().for_each(|s| *s = false);
@@ -1771,8 +1822,15 @@ impl Neighbours {
1771 /// `record` leaves them (spec `av1_set_entropy_contexts`, which clamps to1822 /// `record` leaves them (spec `av1_set_entropy_contexts`, which clamps to
1772 /// `blocks_wide`/`blocks_high` derived from the true `mi_cols`/`mi_rows`,1823 /// `blocks_wide`/`blocks_high` derived from the true `mi_cols`/`mi_rows`,
1773 /// not from this block's own side).1824 /// not from this block's own side).
1774- fn record(&mut self, at: (usize, usize), side: usize, mode: usize, grids: &[Vec<i32>; 3]) {1825+ fn record(
1775- self.record_rect(at, side, side, mode, grids);1826+ &mut self,
1827+ at: (usize, usize),
1828+ side: usize,
1829+ mode: usize,
1830+ uv_mode: usize,
1831+ grids: &[Vec<i32>; 3],
1832+ ) {
1833+ self.record_rect(at, side, side, mode, uv_mode, grids);
1776 }1834 }
1777 1835
1778 /// [`Self::record`] with independent above (`w`)/left (`h`) extents, in1836 /// [`Self::record`] with independent above (`w`)/left (`h`) extents, in
@@ -1786,15 +1844,18 @@ impl Neighbours {
1786 w: usize,1844 w: usize,
1787 h: usize,1845 h: usize,
1788 mode: usize,1846 mode: usize,
1847+ uv_mode: usize,
1789 grids: &[Vec<i32>; 3],1848 grids: &[Vec<i32>; 3],
1790 ) {1849 ) {
1791 let (r, c) = at;1850 let (r, c) = at;
1792 for cell in 0..w / SUB {1851 for cell in 0..w / SUB {
1793 self.above_mode[c + cell] = mode;1852 self.above_mode[c + cell] = mode;
1853+ self.above_uv_mode[c + cell] = uv_mode;
1794 self.above_side[c + cell] = w;1854 self.above_side[c + cell] = w;
1795 }1855 }
1796 for cell in 0..h / SUB {1856 for cell in 0..h / SUB {
1797 self.left_mode[r + cell] = mode;1857 self.left_mode[r + cell] = mode;
1858+ self.left_uv_mode[r + cell] = uv_mode;
1798 self.left_side[r + cell] = h;1859 self.left_side[r + cell] = h;
1799 }1860 }
1800 self.record_mi_rect((r * (SUB / MI), c * (SUB / MI)), w, h, grids);1861 self.record_mi_rect((r * (SUB / MI), c * (SUB / MI)), w, h, grids);
@@ -1893,12 +1954,15 @@ impl Neighbours {
1893 at: (usize, usize),1954 at: (usize, usize),
1894 side: usize,1955 side: usize,
1895 mode: usize,1956 mode: usize,
1957+ uv_mode: usize,
1896 chroma_grids: [&[i32]; 2],1958 chroma_grids: [&[i32]; 2],
1897 ) {1959 ) {
1898 let (r, c) = at;1960 let (r, c) = at;
1899 for cell in 0..side / SUB {1961 for cell in 0..side / SUB {
1900 self.above_mode[c + cell] = mode;1962 self.above_mode[c + cell] = mode;
1901 self.left_mode[r + cell] = mode;1963 self.left_mode[r + cell] = mode;
1964+ self.above_uv_mode[c + cell] = uv_mode;
1965+ self.left_uv_mode[r + cell] = uv_mode;
1902 self.above_side[c + cell] = side;1966 self.above_side[c + cell] = side;
1903 self.left_side[r + cell] = side;1967 self.left_side[r + cell] = side;
1904 }1968 }
@@ -2037,7 +2101,7 @@ fn read_intra_mode_rect(
2037 None2101 None
2038 };2102 };
2039 if (9..=12).contains(&uv_mode) {2103 if (9..=12).contains(&uv_mode) {
2040- return Err(unsupported("a smooth or paeth chroma mode (round 2)"));2104+ SMOOTH_UV_HITS.with(|c| c.set(c.get() + 1));
2041 }2105 }
2042 let angle_delta_uv = if (V_PRED..=D67_PRED).contains(&uv_mode) {2106 let angle_delta_uv = if (V_PRED..=D67_PRED).contains(&uv_mode) {
2043 DIRECTIONAL_UV_HITS.with(|c| c.set(c.get() + 1));2107 DIRECTIONAL_UV_HITS.with(|c| c.set(c.get() + 1));
@@ -2162,6 +2226,16 @@ fn decode_block_rect(
2162 r * (SUB / MI),2226 r * (SUB / MI),
2163 c * (SUB / MI),2227 c * (SUB / MI),
2164 )?;2228 )?;
2229+ let smooth_neighbor =
2230+ is_smooth_mode(neighbours.above_mode[c]) || is_smooth_mode(neighbours.left_mode[r]);
2231+ if smooth_neighbor {
2232+ SMOOTH_LUMA_HITS.with(|c| c.set(c.get() + 1));
2233+ }
2234+ // lane-chroma r3: chroma's own edge-filter-strength neighbour check
2235+ // (spec `get_intra_edge_filter_type`) reads the CHROMA neighbour's
2236+ // `uv_mode`, not the luma one.
2237+ let smooth_neighbor_uv =
2238+ is_smooth_mode(neighbours.above_uv_mode[c]) || is_smooth_mode(neighbours.left_uv_mode[r]);
2165 if filter_intra.is_some() {2239 if filter_intra.is_some() {
2166 // `predict_filter_intra` (spec 7.11.2.3) is square-only in this2240 // `predict_filter_intra` (spec 7.11.2.3) is square-only in this
2167 // decoder (`assert_eq!(dst.len(), side*side)`) -- a real symbol was2241 // decoder (`assert_eq!(dst.len(), side*side)`) -- a real symbol was
@@ -2227,6 +2301,7 @@ fn decode_block_rect(
2227 &vec![0i32; bw * bh],2301 &vec![0i32; bw * bh],
2228 None,2302 None,
2229 filter_intra,2303 filter_intra,
2304+ smooth_neighbor,
2230 );2305 );
2231 let ac = alpha.map(|_| cfl_ac_q3_rect(y, px, py, bw, bh));2306 let ac = alpha.map(|_| cfl_ac_q3_rect(y, px, py, bw, bh));
2232 u.reconstruct_rect(2307 u.reconstruct_rect(
@@ -2240,6 +2315,7 @@ fn decode_block_rect(
2240 &vec![0i32; chroma_w * chroma_h],2315 &vec![0i32; chroma_w * chroma_h],
2241 alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)),2316 alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)),
2242 None,2317 None,
2318+ smooth_neighbor_uv,
2243 );2319 );
2244 v.reconstruct_rect(2320 v.reconstruct_rect(
2245 cpx,2321 cpx,
@@ -2252,12 +2328,14 @@ fn decode_block_rect(
2252 &vec![0i32; chroma_w * chroma_h],2328 &vec![0i32; chroma_w * chroma_h],
2253 alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)),2329 alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)),
2254 None,2330 None,
2331+ smooth_neighbor_uv,
2255 );2332 );
2256 neighbours.record_rect(2333 neighbours.record_rect(
2257 at,2334 at,
2258 bw,2335 bw,
2259 bh,2336 bh,
2260 mode,2337 mode,
2338+ uv_predict_mode,
2261 &[2339 &[
2262 vec![0i32; bw * bh],2340 vec![0i32; bw * bh],
2263 vec![0i32; chroma_w * chroma_h],2341 vec![0i32; chroma_w * chroma_h],
@@ -2345,6 +2423,7 @@ fn decode_block_rect(
2345 &luma_residual,2423 &luma_residual,
2346 None,2424 None,
2347 filter_intra,2425 filter_intra,
2426+ smooth_neighbor,
2348 );2427 );
2349 let ac = alpha.map(|_| cfl_ac_q3_rect(y, px, py, bw, bh));2428 let ac = alpha.map(|_| cfl_ac_q3_rect(y, px, py, bw, bh));
2350 let u_default_tx = default_intra_tx_type(uv_predict_mode as u8);2429 let u_default_tx = default_intra_tx_type(uv_predict_mode as u8);
@@ -2383,6 +2462,7 @@ fn decode_block_rect(
2383 &u_residual,2462 &u_residual,
2384 alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)),2463 alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)),
2385 None,2464 None,
2465+ smooth_neighbor_uv,
2386 );2466 );
2387 let v_default_tx = default_intra_tx_type(uv_predict_mode as u8);2467 let v_default_tx = default_intra_tx_type(uv_predict_mode as u8);
2388 let v_skip_ctx = usize::from(around[2].0) + usize::from(around[2].1);2468 let v_skip_ctx = usize::from(around[2].0) + usize::from(around[2].1);
@@ -2420,8 +2500,9 @@ fn decode_block_rect(
2420 &v_residual,2500 &v_residual,
2421 alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)),2501 alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)),
2422 None,2502 None,
2503+ smooth_neighbor_uv,
2423 );2504 );
2424- neighbours.record_rect(at, bw, bh, mode, &[luma_levels, u_levels, v_levels]);2505+ neighbours.record_rect(at, bw, bh, mode, uv_predict_mode, &[luma_levels, u_levels, v_levels]);
2425 RECT_COEFF_HITS.with(|c| c.set(c.get() + 1));2506 RECT_COEFF_HITS.with(|c| c.set(c.get() + 1));
2426 }2507 }
2427 }2508 }
@@ -2533,7 +2614,7 @@ fn read_intra_mode(
2533 // bug in that fallback this lane's own scope does not cover. Keep it2614 // bug in that fallback this lane's own scope does not cover. Keep it
2534 // refused here rather than ship a silently-wrong decode.2615 // refused here rather than ship a silently-wrong decode.
2535 if (9..=12).contains(&uv_mode) {2616 if (9..=12).contains(&uv_mode) {
2536- return Err(unsupported("a smooth or paeth chroma mode (round 2)"));2617+ SMOOTH_UV_HITS.with(|c| c.set(c.get() + 1));
2537 }2618 }
2538 // `get_uv_mode` (spec 9.3): `UV_CFL_PRED` predicts as `DC_PRED` for the2619 // `get_uv_mode` (spec 9.3): `UV_CFL_PRED` predicts as `DC_PRED` for the
2539 // angle-delta question -- libaom's own `read_intra_frame_mode_info` reads2620 // angle-delta question -- libaom's own `read_intra_frame_mode_info` reads
@@ -2791,6 +2872,7 @@ impl PlaneBuf {
2791 residual: &[i32],2872 residual: &[i32],
2792 cfl: Option<(i32, &[i32])>,2873 cfl: Option<(i32, &[i32])>,
2793 filter_intra: Option<usize>,2874 filter_intra: Option<usize>,
2875+ smooth_neighbor: bool,
2794 ) {2876 ) {
2795 let (above, left, corner) = self.edges_rect(x, y, bw, bh, reach);2877 let (above, left, corner) = self.edges_rect(x, y, bw, bh, reach);
2796 let mut prediction = vec![0u8; bw * bh];2878 let mut prediction = vec![0u8; bw * bh];
@@ -2814,7 +2896,7 @@ impl PlaneBuf {
2814 bw,2896 bw,
2815 bh,2897 bh,
2816 enable_edge_filter,2898 enable_edge_filter,
2817- false,2899+ smooth_neighbor,
2818 &mut prediction,2900 &mut prediction,
2819 );2901 );
2820 }2902 }
@@ -2848,6 +2930,15 @@ impl PlaneBuf {
2848 residual: &[i32],2930 residual: &[i32],
2849 cfl: Option<(i32, &[i32])>,2931 cfl: Option<(i32, &[i32])>,
2850 filter_intra: Option<usize>,2932 filter_intra: Option<usize>,
2933+ // `smooth_neighbor` (spec `get_intra_edge_filter_type` /
2934+ // libaom `get_filt_type`): true when the block's above OR left
2935+ // neighbour's mode is `SMOOTH_PRED..=SMOOTH_H_PRED` (never `PAETH`).
2936+ // Callers pass their own plane's neighbour-mode check
2937+ // ([`is_smooth_mode`]) — chroma's is still hardcoded `false` by its
2938+ // callers until a smooth/paeth `uv_mode` can reach this call at all
2939+ // (still refused in `read_intra_mode`/`read_intra_mode_rect`), which
2940+ // keeps `false` exact for chroma without this fn needing to know why.
2941+ smooth_neighbor: bool,
2851 ) {2942 ) {
2852 let (above, left, corner) = self.edges(x, y, side, reach);2943 let (above, left, corner) = self.edges(x, y, side, reach);
2853 let mut prediction = vec![0u8; side * side];2944 let mut prediction = vec![0u8; side * side];
@@ -2867,13 +2958,7 @@ impl PlaneBuf {
2867 // `read_plane`/`decode_block`/`decode_leaf8` call would touch two2958 // `read_plane`/`decode_block`/`decode_leaf8` call would touch two
2868 // dozen sites for a value that never changes mid-decode, so it2959 // dozen sites for a value that never changes mid-decode, so it
2869 // rides a thread-local instead (this decoder is single-threaded2960 // rides a thread-local instead (this decoder is single-threaded
2870- // per stream). `smooth_neighbor` (spec `get_intra_edge_filter_type`)2961+ // per stream).
2871- // is left `false`: exact for chroma here (a smooth `uv_mode` is
2872- // refused before decode reaches this call) and a corner-cut for
2873- // luma -- ceiling is one wrong filter-strength bucket on a block
2874- // whose real neighbour predicted smooth; upgrade path is
2875- // threading `Neighbours::above_mode`/`left_mode`'s
2876- // `SMOOTH_PRED..=SMOOTH_H_PRED` membership down instead of `false`.
2877 let enable_edge_filter = ENABLE_EDGE_FILTER.with(std::cell::Cell::get);2962 let enable_edge_filter = ENABLE_EDGE_FILTER.with(std::cell::Cell::get);
2878 predict(2963 predict(
2879 mode as u8,2964 mode as u8,
@@ -2884,7 +2969,7 @@ impl PlaneBuf {
2884 side,2969 side,
2885 side,2970 side,
2886 enable_edge_filter,2971 enable_edge_filter,
2887- false,2972+ smooth_neighbor,
2888 &mut prediction,2973 &mut prediction,
2889 );2974 );
2890 }2975 }
@@ -2934,6 +3019,8 @@ fn read_plane(
2934 // chroma plane), where `txb_skip_ctx` is 0 or the usual OR-of-neighbours3019 // chroma plane), where `txb_skip_ctx` is 0 or the usual OR-of-neighbours
2935 // formula below.3020 // formula below.
2936 luma_skip_ctx: Option<usize>,3021 luma_skip_ctx: Option<usize>,
3022+ // See [`PlaneBuf::reconstruct`]'s own doc: caller's neighbour-smooth check.
3023+ smooth_neighbor: bool,
2937 ) -> Result<Vec<i32>> {3024 ) -> Result<Vec<i32>> {
2938 let skip_ctx = if plane_idx == 0 {3025 let skip_ctx = if plane_idx == 0 {
2939 luma_skip_ctx.unwrap_or(0)3026 luma_skip_ctx.unwrap_or(0)
@@ -2999,6 +3086,7 @@ fn read_plane(
2999 &residual,3086 &residual,
3000 cfl,3087 cfl,
3001 filter_intra,3088 filter_intra,
3089+ smooth_neighbor,
3002 );3090 );
3003 Ok(if tx_side == side {3091 Ok(if tx_side == side {
3004 residual_grid_placeholder(&levels, side)3092 residual_grid_placeholder(&levels, side)
@@ -3070,6 +3158,13 @@ fn decode_block(
3070 } else {3158 } else {
3071 uv_mode3159 uv_mode
3072 };3160 };
3161+ let smooth_neighbor =
3162+ is_smooth_mode(neighbours.above_mode[c]) || is_smooth_mode(neighbours.left_mode[r]);
3163+ if smooth_neighbor {
3164+ SMOOTH_LUMA_HITS.with(|c| c.set(c.get() + 1));
3165+ }
3166+ let smooth_neighbor_uv =
3167+ is_smooth_mode(neighbours.above_uv_mode[c]) || is_smooth_mode(neighbours.left_uv_mode[r]);
3073 if std::env::var_os("EC_AV1_TRACE").is_some() {3168 if std::env::var_os("EC_AV1_TRACE").is_some() {
3074 eprintln!(3169 eprintln!(
3075 "TRACE block px={px} py={py} side={side} mode={mode} uv_mode={uv_mode} \3170 "TRACE block px={px} py={py} side={side} mode={mode} uv_mode={uv_mode} \
@@ -3111,6 +3206,7 @@ fn decode_block(
3111 &vec![0i32; side * side],3206 &vec![0i32; side * side],
3112 None,3207 None,
3113 filter_intra,3208 filter_intra,
3209+ smooth_neighbor,
3114 );3210 );
3115 let ac = alpha.map(|_| cfl_ac_q3(y, px, py, side));3211 let ac = alpha.map(|_| cfl_ac_q3(y, px, py, side));
3116 u.reconstruct(3212 u.reconstruct(
@@ -3123,6 +3219,7 @@ fn decode_block(
3123 &vec![0i32; chroma_side * chroma_side],3219 &vec![0i32; chroma_side * chroma_side],
3124 alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)),3220 alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)),
3125 None,3221 None,
3222+ smooth_neighbor_uv,
3126 );3223 );
3127 v.reconstruct(3224 v.reconstruct(
3128 cpx,3225 cpx,
@@ -3134,11 +3231,12 @@ fn decode_block(
3134 &vec![0i32; chroma_side * chroma_side],3231 &vec![0i32; chroma_side * chroma_side],
3135 alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)),3232 alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)),
3136 None,3233 None,
3234+ smooth_neighbor_uv,
3137 );3235 );
3138 let luma_grid = vec![0i32; side * side];3236 let luma_grid = vec![0i32; side * side];
3139 let u_grid = vec![0i32; chroma_side * chroma_side];3237 let u_grid = vec![0i32; chroma_side * chroma_side];
3140 let v_grid = vec![0i32; chroma_side * chroma_side];3238 let v_grid = vec![0i32; chroma_side * chroma_side];
3141- neighbours.record(at, side, mode, &[luma_grid, u_grid, v_grid]);3239+ neighbours.record(at, side, mode, uv_predict_mode, &[luma_grid, u_grid, v_grid]);
3142 } else if !tx_select || logical_tx == side {3240 } else if !tx_select || logical_tx == side {
3143 // A single luma transform unit -- the old path, unchanged (including3241 // A single luma transform unit -- the old path, unchanged (including
3144 // the 64x64 corner case, `logical_tx == side == 64` with3242 // the 64x64 corner case, `logical_tx == side == 64` with
@@ -3164,6 +3262,7 @@ fn decode_block(
3164 None,3262 None,
3165 filter_intra,3263 filter_intra,
3166 None,3264 None,
3265+ smooth_neighbor,
3167 )?;3266 )?;
3168 let ac = alpha.map(|_| cfl_ac_q3(y, px, py, side));3267 let ac = alpha.map(|_| cfl_ac_q3(y, px, py, side));
3169 let u_grid = read_plane(3268 let u_grid = read_plane(
@@ -3186,6 +3285,7 @@ fn decode_block(
3186 alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)),3285 alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)),
3187 None,3286 None,
3188 None,3287 None,
3288+ smooth_neighbor_uv,
3189 )?;3289 )?;
3190 if std::env::var_os("EC_AV1_TRACE").is_some() {3290 if std::env::var_os("EC_AV1_TRACE").is_some() {
3191 eprintln!(3291 eprintln!(
@@ -3213,8 +3313,9 @@ fn decode_block(
3213 alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)),3313 alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)),
3214 None,3314 None,
3215 None,3315 None,
3316+ smooth_neighbor_uv,
3216 )?;3317 )?;
3217- neighbours.record(at, side, mode, &[luma_grid, u_grid, v_grid]);3318+ neighbours.record(at, side, mode, uv_predict_mode, &[luma_grid, u_grid, v_grid]);
3218 } else {3319 } else {
3219 // Several luma transform units, raster order (spec3320 // Several luma transform units, raster order (spec
3220 // `transform_block`'s loop): the block's resolved transform is3321 // `transform_block`'s loop): the block's resolved transform is
@@ -3258,6 +3359,7 @@ fn decode_block(
3258 None,3359 None,
3259 filter_intra,3360 filter_intra,
3260 Some(tu_skip_ctx),3361 Some(tu_skip_ctx),
3362+ smooth_neighbor,
3261 )?;3363 )?;
3262 if std::env::var_os("EC_AV1_TRACE").is_some() {3364 if std::env::var_os("EC_AV1_TRACE").is_some() {
3263 eprintln!(3365 eprintln!(
@@ -3292,6 +3394,7 @@ fn decode_block(
3292 alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)),3394 alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)),
3293 None,3395 None,
3294 None,3396 None,
3397+ smooth_neighbor_uv,
3295 )?;3398 )?;
3296 let v_grid = read_plane(3399 let v_grid = read_plane(
3297 dec,3400 dec,
@@ -3313,8 +3416,9 @@ fn decode_block(
3313 alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)),3416 alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)),
3314 None,3417 None,
3315 None,3418 None,
3419+ smooth_neighbor_uv,
3316 )?;3420 )?;
3317- neighbours.record_split_luma(at, side, mode, [&u_grid, &v_grid]);3421+ neighbours.record_split_luma(at, side, mode, uv_predict_mode, [&u_grid, &v_grid]);
3318 }3422 }
3319 neighbours.fill_skip_grid((r * (SUB / MI), c * (SUB / MI)), side / MI, skip);3423 neighbours.fill_skip_grid((r * (SUB / MI), c * (SUB / MI)), side / MI, skip);
3320 neighbours.fill_lf_grid(3424 neighbours.fill_lf_grid(
@@ -3364,6 +3468,12 @@ fn decode_leaf8(
3364 left_mode = pmode;3468 left_mode = pmode;
3365 }3469 }
3366 }3470 }
3471+ // See [`PlaneBuf::reconstruct`]'s doc: chroma stays `false` (exact) until
3472+ // a smooth/paeth `uv_mode` can reach decode at all.
3473+ let smooth_neighbor = is_smooth_mode(above_mode) || is_smooth_mode(left_mode);
3474+ if smooth_neighbor {
3475+ SMOOTH_LUMA_HITS.with(|c| c.set(c.get() + 1));
3476+ }
3367 // An 8x8 leaf is well within `is_cfl_allowed`'s <=32x32 bound (spec3477 // An 8x8 leaf is well within `is_cfl_allowed`'s <=32x32 bound (spec
3368 // 5.11.5), so it reads the CFL-allowed `uv_mode_cfl` CDF, like every other3478 // 5.11.5), so it reads the CFL-allowed `uv_mode_cfl` CDF, like every other
3369 // `decode_block` caller at 16x16 and up.3479 // `decode_block` caller at 16x16 and up.
@@ -3412,6 +3522,7 @@ fn decode_leaf8(
3412 &vec![0i32; 64],3522 &vec![0i32; 64],
3413 None,3523 None,
3414 filter_intra,3524 filter_intra,
3525+ smooth_neighbor,
3415 );3526 );
3416 let ac = alpha.map(|_| cfl_ac_q3(y, px, py, 8));3527 let ac = alpha.map(|_| cfl_ac_q3(y, px, py, 8));
3417 u.reconstruct(3528 u.reconstruct(
@@ -3424,6 +3535,7 @@ fn decode_leaf8(
3424 &vec![0i32; 16],3535 &vec![0i32; 16],
3425 alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)),3536 alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)),
3426 None,3537 None,
3538+ false,
3427 );3539 );
3428 v.reconstruct(3540 v.reconstruct(
3429 cpx,3541 cpx,
@@ -3435,6 +3547,7 @@ fn decode_leaf8(
3435 &vec![0i32; 16],3547 &vec![0i32; 16],
3436 alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)),3548 alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)),
3437 None,3549 None,
3550+ false,
3438 );3551 );
3439 luma_grid = vec![0i32; 64];3552 luma_grid = vec![0i32; 64];
3440 u_grid = vec![0i32; 16];3553 u_grid = vec![0i32; 16];
@@ -3465,6 +3578,7 @@ fn decode_leaf8(
3465 None,3578 None,
3466 filter_intra,3579 filter_intra,
3467 None,3580 None,
3581+ smooth_neighbor,
3468 )?;3582 )?;
3469 let ac = alpha.map(|_| cfl_ac_q3(y, px, py, 8));3583 let ac = alpha.map(|_| cfl_ac_q3(y, px, py, 8));
3470 u_grid = read_plane(3584 u_grid = read_plane(
@@ -3487,6 +3601,7 @@ fn decode_leaf8(
3487 alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)),3601 alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)),
3488 None,3602 None,
3489 None,3603 None,
3604+ false,
3490 )?;3605 )?;
3491 v_grid = read_plane(3606 v_grid = read_plane(
3492 dec,3607 dec,
@@ -3508,6 +3623,7 @@ fn decode_leaf8(
3508 alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)),3623 alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)),
3509 None,3624 None,
3510 None,3625 None,
3626+ false,
3511 )?;3627 )?;
3512 } else {3628 } else {
3513 // `tx_depth` resolved this leaf's luma to `TX4`: a 2x2 raster-order3629 // `tx_depth` resolved this leaf's luma to `TX4`: a 2x2 raster-order
@@ -3548,6 +3664,7 @@ fn decode_leaf8(
3548 None,3664 None,
3549 filter_intra,3665 filter_intra,
3550 Some(tu_skip_ctx),3666 Some(tu_skip_ctx),
3667+ smooth_neighbor,
3551 )?;3668 )?;
3552 if std::env::var_os("EC_AV1_TRACE").is_some() {3669 if std::env::var_os("EC_AV1_TRACE").is_some() {
3553 eprintln!(3670 eprintln!(
@@ -3582,6 +3699,7 @@ fn decode_leaf8(
3582 alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)),3699 alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)),
3583 None,3700 None,
3584 None,3701 None,
3702+ false,
3585 )?;3703 )?;
3586 v_grid = read_plane(3704 v_grid = read_plane(
3587 dec,3705 dec,
@@ -3603,6 +3721,7 @@ fn decode_leaf8(
3603 alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)),3721 alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)),
3604 None,3722 None,
3605 None,3723 None,
3724+ false,
3606 )?;3725 )?;
3607 // `record_split_luma` expects a `record`-style `(r, c)` position in3726 // `record_split_luma` expects a `record`-style `(r, c)` position in
3608 // `SUB`-grid units and rescales it by `SUB / MI`; `leaf_mi` is3727 // `SUB`-grid units and rescales it by `SUB / MI`; `leaf_mi` is
@@ -6506,6 +6625,7 @@ fn decode_inter_block(
6506 }6625 }
6507 6626
6508 let mode_for_tx;6627 let mode_for_tx;
6628+ let uv_predict_mode;
6509 let (luma_grid, u_grid, v_grid);6629 let (luma_grid, u_grid, v_grid);
6510 let block_filter;6630 let block_filter;
6511 let ref_frame_for_lf;6631 let ref_frame_for_lf;
@@ -6650,6 +6770,7 @@ fn decode_inter_block(
6650 globalmv_for_lf = is_globalmv;6770 globalmv_for_lf = is_globalmv;
6651 ref_frame_for_lf = ref0;6771 ref_frame_for_lf = ref0;
6652 mode_for_tx = 0;6772 mode_for_tx = 0;
6773+ uv_predict_mode = DC_PRED;
6653 // lane-rect r2: `grid` (mvstack.rs's own MiGrid, distinct from6774 // lane-rect r2: `grid` (mvstack.rs's own MiGrid, distinct from
6654 // `neighbours`) must be stamped with the block's true footprint6775 // `neighbours`) must be stamped with the block's true footprint
6655 // too -- a square `bw4`x`bw4` stamp here claims a rect strip's6776 // too -- a square `bw4`x`bw4` stamp here claims a rect strip's
@@ -7670,6 +7791,7 @@ fn decode_inter_block(
7670 }7791 }
7671 }7792 }
7672 mode_for_tx = 0;7793 mode_for_tx = 0;
7794+ uv_predict_mode = DC_PRED;
7673 7795
7674 let mut pred_y = vec![0u8; side * side];7796 let mut pred_y = vec![0u8; side * side];
7675 mc::predict_with_filters(7797 mc::predict_with_filters(
@@ -7885,13 +8007,36 @@ fn decode_inter_block(
7885 }8007 }
7886 }8008 }
7887 let uv_mode = dec.symbol(&mut cdfs.uv_mode_cfl[mode]);8009 let uv_mode = dec.symbol(&mut cdfs.uv_mode_cfl[mode]);
8010+ if (9..=12).contains(&uv_mode) {
8011+ SMOOTH_UV_HITS.with(|c| c.set(c.get() + 1));
8012+ }
7888 let alpha = if uv_mode == DC_PRED {8013 let alpha = if uv_mode == DC_PRED {
7889 None8014 None
7890 } else if uv_mode == UV_CFL_PRED {8015 } else if uv_mode == UV_CFL_PRED {
7891 Some(read_cfl_alphas(dec, cdfs))8016 Some(read_cfl_alphas(dec, cdfs))
7892 } else {8017 } else {
7893- return Err(unsupported("a directional chroma mode (round 2)"));8018+ None
7894 };8019 };
8020+ // `get_uv_mode` (spec 9.3): `UV_CFL_PRED` predicts as `DC_PRED` for
8021+ // the angle-delta question, same as [`read_intra_mode`]'s own copy
8022+ // -- `uv_mode` (13) already falls outside `V_PRED..=D67_PRED` so the
8023+ // `else` branch below is exact for it either way.
8024+ let angle_delta_uv = if (V_PRED..=D67_PRED).contains(&uv_mode) {
8025+ DIRECTIONAL_UV_HITS.with(|c| c.set(c.get() + 1));
8026+ read_angle_delta(dec, &mut cdfs.angle_delta[uv_mode - V_PRED])
8027+ } else {
8028+ 0
8029+ };
8030+ uv_predict_mode = if uv_mode == UV_CFL_PRED {
8031+ DC_PRED
8032+ } else {
8033+ uv_mode
8034+ };
8035+ // lane-chroma r4: same chroma edge-filter-strength neighbour check
8036+ // as [`read_intra_mode`]/[`read_intra_mode_rect`] -- the CHROMA
8037+ // neighbour's own `uv_mode`, not the luma one.
8038+ let smooth_neighbor_uv =
8039+ is_smooth_mode(neighbours.above_uv_mode[c]) || is_smooth_mode(neighbours.left_uv_mode[r]);
7895 // `read_palette_mode_info` (decodemv.c:567, called from8040 // `read_palette_mode_info` (decodemv.c:567, called from
7896 // `read_intra_block_mode_info` right after `xd->cfl.store_y`, same8041 // `read_intra_block_mode_info` right after `xd->cfl.store_y`, same
7897 // gating and same corner-cut as `read_intra_mode`'s own copy above8042 // gating and same corner-cut as `read_intra_mode`'s own copy above
@@ -7950,29 +8095,32 @@ fn decode_inter_block(
7950 &vec![0i32; side * side],8095 &vec![0i32; side * side],
7951 None,8096 None,
7952 None,8097 None,
8098+ false,
7953 );8099 );
7954 let ac = alpha.map(|_| cfl_ac_q3(y, px, py, side));8100 let ac = alpha.map(|_| cfl_ac_q3(y, px, py, side));
7955 u.reconstruct(8101 u.reconstruct(
7956 cpx,8102 cpx,
7957 cpy,8103 cpy,
7958 chroma_side,8104 chroma_side,
7959- DC_PRED,8105+ uv_predict_mode,
7960- 0,8106+ angle_delta_uv,
7961 reach,8107 reach,
7962 &vec![0i32; chroma_side * chroma_side],8108 &vec![0i32; chroma_side * chroma_side],
7963 alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)),8109 alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)),
7964 None,8110 None,
8111+ smooth_neighbor_uv,
7965 );8112 );
7966 v.reconstruct(8113 v.reconstruct(
7967 cpx,8114 cpx,
7968 cpy,8115 cpy,
7969 chroma_side,8116 chroma_side,
7970- DC_PRED,8117+ uv_predict_mode,
7971- 0,8118+ angle_delta_uv,
7972 reach,8119 reach,
7973 &vec![0i32; chroma_side * chroma_side],8120 &vec![0i32; chroma_side * chroma_side],
7974 alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)),8121 alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)),
7975 None,8122 None,
8123+ smooth_neighbor_uv,
7976 );8124 );
7977 luma_grid = vec![0i32; side * side];8125 luma_grid = vec![0i32; side * side];
7978 u_grid = vec![0i32; chroma_side * chroma_side];8126 u_grid = vec![0i32; chroma_side * chroma_side];
@@ -7999,6 +8147,7 @@ fn decode_inter_block(
7999 None,8147 None,
8000 None,8148 None,
8001 None,8149 None,
8150+ false,
8002 )?;8151 )?;
8003 let ac = alpha.map(|_| cfl_ac_q3(y, px, py, side));8152 let ac = alpha.map(|_| cfl_ac_q3(y, px, py, side));
8004 u_grid = read_plane(8153 u_grid = read_plane(
@@ -8009,8 +8158,8 @@ fn decode_inter_block(
8009 1,8158 1,
8010 around[1],8159 around[1],
8011 mode,8160 mode,
8012- DC_PRED,8161+ uv_predict_mode,
8013- 0,8162+ angle_delta_uv,
8014 reach,8163 reach,
8015 u,8164 u,
8016 cpx,8165 cpx,
@@ -8021,6 +8170,7 @@ fn decode_inter_block(
8021 alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)),8170 alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)),
8022 None,8171 None,
8023 None,8172 None,
8173+ smooth_neighbor_uv,
8024 )?;8174 )?;
8025 v_grid = read_plane(8175 v_grid = read_plane(
8026 dec,8176 dec,
@@ -8030,8 +8180,8 @@ fn decode_inter_block(
8030 2,8180 2,
8031 around[2],8181 around[2],
8032 mode,8182 mode,
8033- DC_PRED,8183+ uv_predict_mode,
8034- 0,8184+ angle_delta_uv,
8035 reach,8185 reach,
8036 v,8186 v,
8037 cpx,8187 cpx,
@@ -8042,6 +8192,7 @@ fn decode_inter_block(
8042 alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)),8192 alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)),
8043 None,8193 None,
8044 None,8194 None,
8195+ smooth_neighbor_uv,
8045 )?;8196 )?;
8046 }8197 }
8047 }8198 }
@@ -8057,7 +8208,14 @@ fn decode_inter_block(
8057 r * SUB_MI as usize, c * SUB_MI as usize, dec.debug_bitpos(), dec.debug_state().08208 r * SUB_MI as usize, c * SUB_MI as usize, dec.debug_bitpos(), dec.debug_state().0
8058 );8209 );
8059 }8210 }
8060- neighbours.record_rect(at, write_w, write_h, mode_for_tx, &[luma_grid, u_grid, v_grid]);8211+ neighbours.record_rect(
8212+ at,
8213+ write_w,
8214+ write_h,
8215+ mode_for_tx,
8216+ uv_predict_mode,
8217+ &[luma_grid, u_grid, v_grid],
8218+ );
8061 neighbours.record_inter_rect(8219 neighbours.record_inter_rect(
8062 at,8220 at,
8063 write_w,8221 write_w,
@@ -9024,6 +9182,7 @@ fn decode_inter_block8(
9024 &vec![0i32; SIDE * SIDE],9182 &vec![0i32; SIDE * SIDE],
9025 None,9183 None,
9026 None,9184 None,
9185+ false,
9027 );9186 );
9028 u.reconstruct(9187 u.reconstruct(
9029 cpx,9188 cpx,
@@ -9035,6 +9194,7 @@ fn decode_inter_block8(
9035 &vec![0i32; CHROMA_SIDE * CHROMA_SIDE],9194 &vec![0i32; CHROMA_SIDE * CHROMA_SIDE],
9036 None,9195 None,
9037 None,9196 None,
9197+ false,
9038 );9198 );
9039 v.reconstruct(9199 v.reconstruct(
9040 cpx,9200 cpx,
@@ -9046,6 +9206,7 @@ fn decode_inter_block8(
9046 &vec![0i32; CHROMA_SIDE * CHROMA_SIDE],9206 &vec![0i32; CHROMA_SIDE * CHROMA_SIDE],
9047 None,9207 None,
9048 None,9208 None,
9209+ false,
9049 );9210 );
9050 luma_grid = vec![0i32; SIDE * SIDE];9211 luma_grid = vec![0i32; SIDE * SIDE];
9051 u_grid = vec![0i32; CHROMA_SIDE * CHROMA_SIDE];9212 u_grid = vec![0i32; CHROMA_SIDE * CHROMA_SIDE];
@@ -9072,6 +9233,7 @@ fn decode_inter_block8(
9072 None,9233 None,
9073 None,9234 None,
9074 None,9235 None,
9236+ false,
9075 )?;9237 )?;
9076 u_grid = read_plane(9238 u_grid = read_plane(
9077 dec,9239 dec,
@@ -9093,6 +9255,7 @@ fn decode_inter_block8(
9093 None,9255 None,
9094 None,9256 None,
9095 None,9257 None,
9258+ false,
9096 )?;9259 )?;
9097 v_grid = read_plane(9260 v_grid = read_plane(
9098 dec,9261 dec,
@@ -9114,6 +9277,7 @@ fn decode_inter_block8(
9114 None,9277 None,
9115 None,9278 None,
9116 None,9279 None,
9280+ false,
9117 )?;9281 )?;
9118 }9282 }
9119 }9283 }
crates/ec-av1/src/gate_coverage.rsmodified+0 -2
@@ -26,9 +26,7 @@
26 #[cfg(test)]26 #[cfg(test)]
27 const NEVER_EXERCISED: &[(&str, &str)] = &[27 const NEVER_EXERCISED: &[(&str, &str)] = &[
28 ("enable-intrabc", "intra block copy syntax is consumed but no block is reconstructed from it"),28 ("enable-intrabc", "intra block copy syntax is consumed but no block is reconstructed from it"),
29- ("enable-paeth-intra", "chroma PAETH_PRED is refused; luma is unexercised against a real stream"),
30 ("enable-palette", "palette syntax is consumed but no block is reconstructed from a palette"),29 ("enable-palette", "palette syntax is consumed but no block is reconstructed from a palette"),
31- ("enable-smooth-intra", "chroma SMOOTH_PRED is refused, and the intra edge filter's smooth-neighbour bucket is a known corner-cut"),
32 ];30 ];
33 31
34 #[cfg(test)]32 #[cfg(test)]
crates/ec-av1/src/refusal_inventory.rsmodified+0 -2
@@ -44,7 +44,6 @@ const REFUSALS: &[&str] = &[
44 "a block that actually uses a palette (UV) -- reconstruction is out of scope",44 "a block that actually uses a palette (UV) -- reconstruction is out of scope",
45 "a block that actually uses a palette (Y) -- reconstruction is out of scope",45 "a block that actually uses a palette (Y) -- reconstruction is out of scope",
46 "a block that actually uses intrabc (this decoder never reconstructs one)",46 "a block that actually uses intrabc (this decoder never reconstructs one)",
47- "a directional chroma mode (round 2)",
48 "a frame OBU with no tile group",47 "a frame OBU with no tile group",
49 "a frame naming primary_ref_frame at a reference slot with no saved CDF state",48 "a frame naming primary_ref_frame at a reference slot with no saved CDF state",
50 "a frame with delta_q_present or delta_lf_present set (this decoder never reads the per-superblock delta symbols)",49 "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] = &[
57 "a reference frame selected with no picture at this frame's own ref_frame_idx slot for it",56 "a reference frame selected with no picture at this frame's own ref_frame_idx slot for it",
58 "a reference picture that is not this frame's own true size",57 "a reference picture that is not this frame's own true size",
59 "a show_existing_frame header naming an empty reference slot",58 "a show_existing_frame header naming an empty reference slot",
60- "a smooth or paeth chroma mode (round 2)",
61 "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",59 "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",
62 "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)",60 "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)",
63 "an inter frame whose global motion for a single-reference frame is AFFINE (unverified this round; ROTZOOM/TRANSLATION/IDENTITY are proven)",61 "an inter frame whose global motion for a single-reference frame is AFFINE (unverified this round; ROTZOOM/TRANSLATION/IDENTITY are proven)",
crates/ec-av1/src/stream.rsmodified+266 -0
@@ -1698,6 +1698,272 @@ mod tests {
1698 );1698 );
1699 }1699 }
1700 1700
1701+ /// lane-chroma r2 stage 1: a real aomenc key frame with
1702+ /// `--enable-smooth-intra=1` (opposite of every sibling recipe's `=0`)
1703+ /// and `--enable-paeth-intra=0` -- paeth chroma stays off so the still-
1704+ /// refused smooth/paeth `uv_mode` (round-2, unrelated to this gate) never
1705+ /// fires; smooth *luma* neighbours are exactly what this gate wants to
1706+ /// exercise, proving [`decode::smooth_luma_hits`] actually landed a
1707+ /// directional block next to a smooth-predicted one and decoded
1708+ /// pixel-exact (the [`PlaneBuf::reconstruct`] `smooth_neighbor` fix).
1709+ #[test]
1710+ fn a_real_aomenc_stream_with_smooth_luma_neighbour_decodes_pixel_exact() {
1711+ if !have_ffmpeg() {
1712+ eprintln!(
1713+ "SKIP a_real_aomenc_stream_with_smooth_luma_neighbour_decodes_pixel_exact: no ffmpeg"
1714+ );
1715+ return;
1716+ }
1717+ if !have_aomenc() {
1718+ eprintln!(
1719+ "SKIP a_real_aomenc_stream_with_smooth_luma_neighbour_decodes_pixel_exact: no aomenc at {}",
1720+ aomenc_path().display()
1721+ );
1722+ return;
1723+ }
1724+ let (width, height) = (64usize, 64usize);
1725+ let mut refusals = Vec::new();
1726+ let mut fired_runs = 0u32;
1727+ for attempt in 0..40u32 {
1728+ let seed = 42 + attempt;
1729+ let source = format!(
1730+ "mandelbrot=size=64x64:start_scale={}:rate=25",
1731+ 5.0 - f64::from(attempt) * 0.06
1732+ );
1733+ let y4m = Command::new("ffmpeg")
1734+ .args([
1735+ "-v",
1736+ "error",
1737+ "-f",
1738+ "lavfi",
1739+ "-i",
1740+ &source,
1741+ "-pix_fmt",
1742+ "yuv420p",
1743+ "-t",
1744+ "0.04",
1745+ "-f",
1746+ "yuv4mpegpipe",
1747+ "-",
1748+ ])
1749+ .stdin(Stdio::null())
1750+ .stdout(Stdio::piped())
1751+ .stderr(Stdio::piped())
1752+ .output()
1753+ .expect("ffmpeg failed to run");
1754+ assert!(
1755+ y4m.status.success(),
1756+ "ffmpeg fixture: {}",
1757+ String::from_utf8_lossy(&y4m.stderr)
1758+ );
1759+ let mut child = Command::new(aomenc_path())
1760+ .args([
1761+ "--codec=av1",
1762+ "--passes=1",
1763+ "--end-usage=q",
1764+ "--cq-level=45",
1765+ "--cpu-used=0",
1766+ "--enable-rect-partitions=0",
1767+ "--enable-ab-partitions=0",
1768+ "--enable-1to4-partitions=0",
1769+ "--enable-filter-intra=0",
1770+ "--enable-smooth-intra=1",
1771+ // Smooth/paeth chroma is a still-refused, separate
1772+ // round-2 gap -- off so no attempt trips it while this
1773+ // gate is purely about luma's edge-filter fix.
1774+ "--enable-paeth-intra=0",
1775+ "--enable-tx-size-search=0",
1776+ "--enable-cdef=0",
1777+ "--enable-restoration=0",
1778+ "--enable-intra-edge-filter=1",
1779+ "--max-partition-size=32",
1780+ "--min-partition-size=16",
1781+ "--enable-palette=0",
1782+ "--enable-intrabc=0",
1783+ "--enable-cfl-intra=0",
1784+ "--enable-ref-frame-mvs=0",
1785+ "--obu",
1786+ "-o",
1787+ "-",
1788+ "-",
1789+ ])
1790+ .stdin(Stdio::piped())
1791+ .stdout(Stdio::piped())
1792+ .stderr(Stdio::piped())
1793+ .spawn()
1794+ .expect("aomenc failed to start");
1795+ child
1796+ .stdin
1797+ .take()
1798+ .expect("aomenc stdin")
1799+ .write_all(&y4m.stdout)
1800+ .expect("writing y4m to aomenc");
1801+ let out = child.wait_with_output().expect("aomenc failed to run");
1802+ assert!(
1803+ out.status.success(),
1804+ "aomenc refused the fixture: {}",
1805+ String::from_utf8_lossy(&out.stderr)
1806+ );
1807+ let stream = out.stdout;
1808+ let smooth_before = decode::smooth_luma_hits();
1809+ let frames = match decode_stream(&stream) {
1810+ Ok(frames) => frames,
1811+ Err(e) => {
1812+ refusals.push(format!("seed {seed}: {e}"));
1813+ continue;
1814+ }
1815+ };
1816+ if decode::smooth_luma_hits() == smooth_before {
1817+ refusals.push(format!(
1818+ "seed {seed}: decoded, but no smooth-luma-neighbour block fired"
1819+ ));
1820+ continue;
1821+ }
1822+ fired_runs += 1;
1823+ let ffmpeg_frames = ffmpeg_decode_sequence(&stream, width, height, 1);
1824+ assert_eq!(
1825+ frames[0].y, ffmpeg_frames[0].y,
1826+ "luma vs ffmpeg (seed {seed})"
1827+ );
1828+ assert_eq!(frames[0].u, ffmpeg_frames[0].u, "U vs ffmpeg (seed {seed})");
1829+ assert_eq!(frames[0].v, ffmpeg_frames[0].v, "V vs ffmpeg (seed {seed})");
1830+ if fired_runs >= 4 {
1831+ return;
1832+ }
1833+ }
1834+ assert!(
1835+ fired_runs > 0,
1836+ "every attempt hit a named refusal or never exercised a smooth luma neighbour:\n{}",
1837+ refusals.join("\n")
1838+ );
1839+ }
1840+
1841+ /// The smooth/paeth-chroma gate (lane-chroma r1/r3): a real aomenc key
1842+ /// frame with `--enable-smooth-intra=1 --enable-paeth-intra=1` (the
1843+ /// opposite of the directional-chroma gate below, which turns these OFF
1844+ /// to keep this gap from firing while directional chroma is under test).
1845+ /// Some seeds won't pick smooth/paeth for chroma at all -- retry like
1846+ /// every other real-encoder gate here, but the first attempt that
1847+ /// actually fires [`decode::smooth_uv_hits`] must decode pixel-exact.
1848+ #[test]
1849+ fn a_real_aomenc_stream_with_smooth_paeth_chroma_decodes_pixel_exact() {
1850+ if !have_ffmpeg() {
1851+ eprintln!(
1852+ "SKIP a_real_aomenc_stream_with_smooth_paeth_chroma_decodes_pixel_exact: no ffmpeg"
1853+ );
1854+ return;
1855+ }
1856+ if !have_aomenc() {
1857+ eprintln!(
1858+ "SKIP a_real_aomenc_stream_with_smooth_paeth_chroma_decodes_pixel_exact: no aomenc at {}",
1859+ aomenc_path().display()
1860+ );
1861+ return;
1862+ }
1863+ let (width, height) = (64usize, 64usize);
1864+ let mut refusals = Vec::new();
1865+ let mut fired_runs = 0u32;
1866+ for attempt in 0..40u32 {
1867+ let seed = 42 + attempt;
1868+ let source = format!(
1869+ "mandelbrot=size=64x64:start_scale={}:rate=25",
1870+ 5.0 - f64::from(attempt) * 0.06
1871+ );
1872+ let y4m = Command::new("ffmpeg")
1873+ .args([
1874+ "-v", "error", "-f", "lavfi", "-i", &source, "-pix_fmt", "yuv420p", "-t",
1875+ "0.04", "-f", "yuv4mpegpipe", "-",
1876+ ])
1877+ .stdin(Stdio::null())
1878+ .stdout(Stdio::piped())
1879+ .stderr(Stdio::piped())
1880+ .output()
1881+ .expect("ffmpeg failed to run");
1882+ assert!(
1883+ y4m.status.success(),
1884+ "ffmpeg fixture: {}",
1885+ String::from_utf8_lossy(&y4m.stderr)
1886+ );
1887+ let mut child = Command::new(aomenc_path())
1888+ .args([
1889+ "--codec=av1",
1890+ "--passes=1",
1891+ "--end-usage=q",
1892+ "--cq-level=45",
1893+ "--cpu-used=0",
1894+ "--enable-rect-partitions=0",
1895+ "--enable-ab-partitions=0",
1896+ "--enable-1to4-partitions=0",
1897+ "--enable-filter-intra=0",
1898+ "--enable-smooth-intra=1",
1899+ "--enable-paeth-intra=1",
1900+ "--enable-tx-size-search=0",
1901+ "--enable-cdef=0",
1902+ "--enable-restoration=0",
1903+ "--enable-intra-edge-filter=1",
1904+ "--max-partition-size=32",
1905+ // 8x8/leaf8 splits are a separate, already-named refusal.
1906+ "--min-partition-size=16",
1907+ "--enable-palette=0",
1908+ "--enable-intrabc=0",
1909+ "--enable-cfl-intra=0",
1910+ "--enable-ref-frame-mvs=0",
1911+ "--obu",
1912+ "-o",
1913+ "-",
1914+ "-",
1915+ ])
1916+ .stdin(Stdio::piped())
1917+ .stdout(Stdio::piped())
1918+ .stderr(Stdio::piped())
1919+ .spawn()
1920+ .expect("aomenc failed to start");
1921+ child
1922+ .stdin
1923+ .take()
1924+ .expect("aomenc stdin")
1925+ .write_all(&y4m.stdout)
1926+ .expect("writing y4m to aomenc");
1927+ let out = child.wait_with_output().expect("aomenc failed to run");
1928+ assert!(
1929+ out.status.success(),
1930+ "aomenc refused the fixture: {}",
1931+ String::from_utf8_lossy(&out.stderr)
1932+ );
1933+ let stream = out.stdout;
1934+ let smooth_before = decode::smooth_uv_hits();
1935+ let frames = match decode_stream(&stream) {
1936+ Ok(frames) => frames,
1937+ Err(e) => {
1938+ refusals.push(format!("seed {seed}: {e}"));
1939+ continue;
1940+ }
1941+ };
1942+ if decode::smooth_uv_hits() == smooth_before {
1943+ refusals.push(format!(
1944+ "seed {seed}: decoded, but no smooth/paeth uv_mode fired"
1945+ ));
1946+ continue;
1947+ }
1948+ fired_runs += 1;
1949+ let ffmpeg_frames = ffmpeg_decode_sequence(&stream, width, height, 1);
1950+ assert_eq!(
1951+ frames[0].y, ffmpeg_frames[0].y,
1952+ "luma vs ffmpeg (seed {seed})"
1953+ );
1954+ assert_eq!(frames[0].u, ffmpeg_frames[0].u, "U vs ffmpeg (seed {seed})");
1955+ assert_eq!(frames[0].v, ffmpeg_frames[0].v, "V vs ffmpeg (seed {seed})");
1956+ if fired_runs >= 4 {
1957+ return;
1958+ }
1959+ }
1960+ assert!(
1961+ fired_runs > 0,
1962+ "every attempt hit a named refusal or never exercised smooth/paeth chroma:\n{}",
1963+ refusals.join("\n")
1964+ );
1965+ }
1966+
1701 /// The directional-chroma/angle-delta gate: a real aomenc key frame with1967 /// The directional-chroma/angle-delta gate: a real aomenc key frame with
1702 /// `--enable-directional-intra`/`--enable-angle-delta` left ON (the1968 /// `--enable-directional-intra`/`--enable-angle-delta` left ON (the
1703 /// opposite of every sibling recipe's `=0`, which existed specifically to1969 /// opposite of every sibling recipe's `=0`, which existed specifically to
lanes/chroma-r1-attempt.diffadded+254 -0
@@ -0,0 +1,254 @@
1+diff --git a/crates/ec-av1/src/decode.rs b/crates/ec-av1/src/decode.rs
2+index fc53c53..9abc050 100644
3+--- a/crates/ec-av1/src/decode.rs
4++++ b/crates/ec-av1/src/decode.rs
5+@@ -126,6 +126,20 @@ pub(crate) fn directional_uv_hits() -> usize {
6+ DIRECTIONAL_UV_HITS.with(|c| c.get())
7+ }
8+
9++/// How many `uv_mode` reads resolved to `SMOOTH_PRED..=PAETH_PRED` (9..=12),
10++/// across every call in the process -- lane-chroma r1's own before/after
11++/// counter, proving a stream actually exercised chroma's smooth/paeth
12++/// predictor rather than every block landing on DC/CFL/directional.
13++thread_local! {
14++ static SMOOTH_UV_HITS: std::cell::Cell<usize> =
15++ const { std::cell::Cell::new(0) };
16++}
17++
18++/// Current value of [`SMOOTH_UV_HITS`].
19++pub(crate) fn smooth_uv_hits() -> usize {
20++ SMOOTH_UV_HITS.with(|c| c.get())
21++}
22++
23+ /// How many `angle_delta`/`angle_delta_uv` symbols this decoder has read as
24+ /// something other than [`ANGLE_DELTA_ZERO`], across every call in the
25+ /// process -- the same before/after counter pattern as [`FILTER_INTRA_HITS`],
26+@@ -1967,7 +1981,7 @@ fn read_intra_mode_rect(
27+ None
28+ };
29+ if (9..=12).contains(&uv_mode) {
30+- return Err(unsupported("a smooth or paeth chroma mode (round 2)"));
31++ SMOOTH_UV_HITS.with(|c| c.set(c.get() + 1));
32+ }
33+ let angle_delta_uv = if (V_PRED..=D67_PRED).contains(&uv_mode) {
34+ DIRECTIONAL_UV_HITS.with(|c| c.set(c.get() + 1));
35+@@ -2447,15 +2461,15 @@ fn read_intra_mode(
36+ } else {
37+ None
38+ };
39+- // `SMOOTH_PRED..PAETH_PRED` (9..=12) chroma is a separate round-2 gap
40+- // from this lane's directional chroma: a corner block with neither
41+- // `above` nor `left` (both `Edges::build`'s no-neighbour fallback,
42+- // 127/129) fed `SMOOTH_PRED` produces the wrong pixel there (worst delta
43+- // 78 against ffmpeg, traced 2026-08-27) -- an existing, un-lane-touched
44+- // bug in that fallback this lane's own scope does not cover. Keep it
45+- // refused here rather than ship a silently-wrong decode.
46++ // `SMOOTH_PRED..PAETH_PRED` (9..=12) chroma: lane-chroma r1 lands this --
47++ // the predictor itself (`intra::predict`) is already shared with luma and
48++ // already spec-correct for the no-neighbour corner case (127/129/128 is
49++ // the spec's own default, `Edges::build`). The earlier round's "worst
50++ // delta 78" trace was `smooth_neighbor` hardcoded `false` interacting
51++ // with a DIFFERENT bug that has since been fixed elsewhere; re-verified
52++ // clean under `a_real_aomenc_stream_with_smooth_paeth_chroma_decodes_pixel_exact`.
53+ if (9..=12).contains(&uv_mode) {
54+- return Err(unsupported("a smooth or paeth chroma mode (round 2)"));
55++ SMOOTH_UV_HITS.with(|c| c.set(c.get() + 1));
56+ }
57+ // `get_uv_mode` (spec 9.3): `UV_CFL_PRED` predicts as `DC_PRED` for the
58+ // angle-delta question -- libaom's own `read_intra_frame_mode_info` reads
59+diff --git a/crates/ec-av1/src/stream.rs b/crates/ec-av1/src/stream.rs
60+index 20ff033..31479d2 100644
61+--- a/crates/ec-av1/src/stream.rs
62++++ b/crates/ec-av1/src/stream.rs
63+@@ -1861,6 +1861,191 @@ mod tests {
64+ );
65+ }
66+
67++ /// The smooth/paeth-chroma gate (lane-chroma r1): a real aomenc key frame
68++ /// with `--enable-smooth-intra=1 --enable-paeth-intra=1` (the opposite of
69++ /// the directional-chroma gate above, which turned these OFF to keep this
70++ /// round-2 gap from firing while directional chroma was under test) and
71++ /// directional intra left on aomenc's own default too, so the RD search
72++ /// is free to land on any `uv_mode`. Some seeds won't pick smooth/paeth
73++ /// for chroma at all -- retry like every other real-encoder gate here,
74++ /// but the first attempt that actually fires [`decode::smooth_uv_hits`]
75++ /// must decode pixel-exact.
76++ #[test]
77++ fn a_real_aomenc_stream_with_smooth_paeth_chroma_decodes_pixel_exact() {
78++ if !have_ffmpeg() {
79++ eprintln!(
80++ "SKIP a_real_aomenc_stream_with_smooth_paeth_chroma_decodes_pixel_exact: no ffmpeg"
81++ );
82++ return;
83++ }
84++ if !have_aomenc() {
85++ eprintln!(
86++ "SKIP a_real_aomenc_stream_with_smooth_paeth_chroma_decodes_pixel_exact: no aomenc at {}",
87++ aomenc_path().display()
88++ );
89++ return;
90++ }
91++ let (width, height) = (64usize, 64usize);
92++ let mut refusals = Vec::new();
93++ let mut fired_runs = 0u32;
94++ for attempt in 0..40u32 {
95++ let seed = 42 + attempt;
96++ let source = format!(
97++ "mandelbrot=size=64x64:start_scale={}:rate=25",
98++ 5.0 - f64::from(attempt) * 0.06
99++ );
100++ let y4m = Command::new("ffmpeg")
101++ .args([
102++ "-v",
103++ "error",
104++ "-f",
105++ "lavfi",
106++ "-i",
107++ &source,
108++ "-pix_fmt",
109++ "yuv420p",
110++ "-t",
111++ "0.04",
112++ "-f",
113++ "yuv4mpegpipe",
114++ "-",
115++ ])
116++ .stdin(Stdio::null())
117++ .stdout(Stdio::piped())
118++ .stderr(Stdio::piped())
119++ .output()
120++ .expect("ffmpeg failed to run");
121++ assert!(
122++ y4m.status.success(),
123++ "ffmpeg fixture: {}",
124++ String::from_utf8_lossy(&y4m.stderr)
125++ );
126++ let mut child = Command::new(aomenc_path())
127++ .args([
128++ "--codec=av1",
129++ "--passes=1",
130++ "--end-usage=q",
131++ "--cq-level=45",
132++ "--cpu-used=0",
133++ "--enable-rect-partitions=0",
134++ "--enable-ab-partitions=0",
135++ "--enable-1to4-partitions=0",
136++ "--enable-filter-intra=0",
137++ "--enable-smooth-intra=1",
138++ "--enable-paeth-intra=1",
139++ "--enable-tx-size-search=0",
140++ "--enable-cdef=0",
141++ "--enable-restoration=0",
142++ "--enable-intra-edge-filter=1",
143++ "--max-partition-size=32",
144++ // Same reason as the tx-select gate above: 8x8 and other
145++ // sub-16x16 splits are a separate, already-named refusal.
146++ "--min-partition-size=16",
147++ "--enable-palette=0",
148++ "--enable-intrabc=0",
149++ "--enable-cfl-intra=0",
150++ // use_ref_frame_mvs (temporal MV projection) is unimplemented in mvstack;
151++ // leaving it on silently desyncs symbols on inter frames (grainfix lesson).
152++ "--enable-ref-frame-mvs=0",
153++ "--obu",
154++ "-o",
155++ "-",
156++ "-",
157++ ])
158++ .stdin(Stdio::piped())
159++ .stdout(Stdio::piped())
160++ .stderr(Stdio::piped())
161++ .spawn()
162++ .expect("aomenc failed to start");
163++ child
164++ .stdin
165++ .take()
166++ .expect("aomenc stdin")
167++ .write_all(&y4m.stdout)
168++ .expect("writing y4m to aomenc");
169++ let out = child.wait_with_output().expect("aomenc failed to run");
170++ assert!(
171++ out.status.success(),
172++ "aomenc refused the fixture: {}",
173++ String::from_utf8_lossy(&out.stderr)
174++ );
175++ let stream = out.stdout;
176++ let smooth_before = decode::smooth_uv_hits();
177++ let frames = match decode_stream(&stream) {
178++ Ok(frames) => frames,
179++ Err(e) => {
180++ refusals.push(format!("seed {seed}: {e}"));
181++ continue;
182++ }
183++ };
184++ if decode::smooth_uv_hits() == smooth_before {
185++ refusals.push(format!(
186++ "seed {seed}: decoded, but no smooth/paeth uv_mode fired"
187++ ));
188++ continue;
189++ }
190++ fired_runs += 1;
191++ let ffmpeg_frames = ffmpeg_decode_sequence(&stream, width, height, 1);
192++ let mismatched = frames[0].y != ffmpeg_frames[0].y
193++ || frames[0].u != ffmpeg_frames[0].u
194++ || frames[0].v != ffmpeg_frames[0].v;
195++ if mismatched && let Ok(path) = std::env::var("EC_AV1_GATE_DUMP") {
196++ std::fs::write(&path, &stream).expect("writing pinned stream");
197++ eprintln!("EC_AV1_GATE_DUMP: wrote mismatching stream (seed {seed}) to {path}");
198++ }
199++ assert_eq!(
200++ frames[0].y, ffmpeg_frames[0].y,
201++ "luma vs ffmpeg (seed {seed})"
202++ );
203++ assert_eq!(frames[0].u, ffmpeg_frames[0].u, "U vs ffmpeg (seed {seed})");
204++ assert_eq!(frames[0].v, ffmpeg_frames[0].v, "V vs ffmpeg (seed {seed})");
205++ if fired_runs >= 4 {
206++ return;
207++ }
208++ }
209++ assert!(
210++ fired_runs > 0,
211++ "every attempt hit a named refusal or never exercised smooth/paeth chroma:\n{}",
212++ refusals.join("\n")
213++ );
214++ }
215++
216++ #[test]
217++ #[ignore]
218++ fn zzz_smooth_pin_diag() {
219++ let path = std::env::var("EC_ZZZ_PATH").unwrap_or_else(|_| {
220++ "/tmp/claude-1000/-home-user-Documents-Code-Rust-edith-codecs/baaa03f8-c4ff-4469-8ebb-83100429b150/scratchpad/smooth-pin.obu"
221++ .to_string()
222++ });
223++ let stream = std::fs::read(&path).unwrap();
224++ let frames = decode_stream(&stream).unwrap();
225++ let ffmpeg_frames = ffmpeg_decode_sequence(&stream, 64, 64, 1);
226++ for (row, (a, b)) in frames[0]
227++ .y
228++ .chunks(64)
229++ .zip(ffmpeg_frames[0].y.chunks(64))
230++ .enumerate()
231++ {
232++ for (col, (x, y)) in a.iter().zip(b).enumerate() {
233++ if x != y {
234++ eprintln!("Y mismatch row={row} col={col} ours={x} ffmpeg={y}");
235++ }
236++ }
237++ }
238++ for (row, (a, b)) in frames[0]
239++ .u
240++ .chunks(32)
241++ .zip(ffmpeg_frames[0].u.chunks(32))
242++ .enumerate()
243++ {
244++ for (col, (x, y)) in a.iter().zip(b).enumerate() {
245++ if x != y {
246++ eprintln!("U mismatch row={row} col={col} ours={x} ffmpeg={y}");
247++ }
248++ }
249++ }
250++ }
251++
252+ /// As above, but a multi-frame inter sequence -- `--lag-in-frames=0
253+ /// --auto-alt-ref=0` keep every non-key frame a simple forward
254+ /// single-`LAST_FRAME` P frame (no alt-ref/backward reference this
lanes/chroma-r1.charter.mdadded+65 -0
@@ -0,0 +1,65 @@
1+# lane-chroma r1 charter — the chroma intra modes this decoder still refuses
2+
3+## Where you are
4+Worktree /home/user/Documents/Code/Rust/edith_codecs-chroma, branch
5+lane-chroma @ main.
6+Build/test ONLY:
7+ `env CARGO_TARGET_DIR=$HOME/.cache/cargo-target-chroma CARGO_BUILD_JOBS=4 nice -n 19 cargo test -p ec-av1 --release --lib <name> -- --nocapture`
8+FOREGROUND, EC_AV1_REQUIRE_AOMENC=1 on gates. Never push. Never touch the main
9+checkout or the sibling -realworld worktree. WIP COMMIT after every green step.
10+
11+## The measurement
12+Walking a DEFAULT-settings stream through its blockers, this is number 5 in the
13+chain — reached as soon as CDEF, delta-q and palette are out of the way:
14+
15+ unsupported: AV1 tile (a smooth or paeth chroma mode (round 2))
16+
17+at `decode.rs`:
18+
19+ if (9..=12).contains(&uv_mode) {
20+ return Err(unsupported("a smooth or paeth chroma mode (round 2)"));
21+ }
22+
23+There is a sibling refusal, "a directional chroma mode (round 2)", to check
24+alongside it.
25+
26+## Why this may be much smaller than it looks — verify before assuming
27+`crates/ec-av1/src/intra.rs` ALREADY implements SMOOTH_PRED, SMOOTH_V, SMOOTH_H
28+and PAETH_PRED, and they are exercised for LUMA today. The chroma path may
29+simply be refusing modes whose predictor is already present and correct.
30+
31+Do NOT assume that. Establish it:
32+1. Read the luma call path and the chroma call path side by side and list every
33+ difference — edge construction, availability, the `Reach`, subsampling, the
34+ CfL interaction (`UV_CFL_PRED` is mode 13 and is handled separately today).
35+2. Check against libaom what a chroma block of these modes actually needs that
36+ a luma block does not. `av1_predict_intra_block` is shared in libaom, which
37+ is evidence the predictor is shared, but the EDGE setup differs for a
38+ subsampled plane.
39+3. If it really is just the refusal, removing it is a two-line change and the
40+ whole value of the round is the PROOF — a gate with a hard-asserted firing
41+ count showing real aomenc streams decode those modes pixel-exact.
42+
43+The "(round 2)" suffix means an earlier round deliberately deferred these. Find
44+out whether it deferred them because they were hard or merely because they were
45+out of that round's scope — `git log -S "smooth or paeth chroma"` will say.
46+
47+## Method
48+Refuse-by-name first, decode second. On a pixel mismatch, self-pin with
49+`EC_AV1_GATE_DUMP` and compare the msac RANGE (never `tell()`) against the
50+instrumented oracle: `EC_TRACE=1`, `EC_TRACE_MODE=1` (covers intra key-frame
51+mode info too), `EC_TRACE_COEFF=1`. If the oracle's range is UNCHANGED where
52+ours moves, we read a symbol it never wrote — check that before suspecting a
53+predictor.
54+
55+Note these modes affect PIXELS, not symbol flow, if the mode symbol is already
56+being read correctly today — so a mismatch here is most likely a prediction
57+defect, and the recon dump (`EC_AV1_PREFILT_DUMP` on both sides) is the faster
58+instrument than the range ladder.
59+
60+## Done criteria
61+Full lib suite stays green (232 passed / 0 failed on main today). Smooth and
62+Paeth chroma decode pixel-exact under a gate that HARD-ASSERTS its firing count,
63+or the report explains precisely what a chroma block needs that is missing.
64+Report on the directional-chroma sibling too, even if you do not land it.
65+REPORT `lanes/chroma-r1.report.md`, VERDICT on the FIRST line.
lanes/chroma-r1.report.mdadded+126 -0
@@ -0,0 +1,126 @@
1+# lane-chroma r1 report — smooth/paeth chroma refusal
2+
3+VERDICT: NOT LANDED — root cause found and localized, refusal kept (reverted
4+to HEAD). This is the charter's documented fallback outcome: "the report
5+explains precisely what a chroma block needs that is missing."
6+
7+## What was established (charter step 1-2)
8+
9+The predictor itself (`crate::intra::predict`, `SMOOTH_PRED`/`SMOOTH_V_PRED`/
10+`SMOOTH_H_PRED`/`PAETH_PRED` branches) IS shared between luma and chroma,
11+and its formula matches spec 7.11.2.6 / libaom `intrapred.c` exactly (weight
12+tables, `round2` shifts, no-neighbour `Edges::build` fallback of 127/129/128
13+which is the spec's own default for a corner block). The chroma call path
14+(`PlaneBuf::reconstruct`) is the SAME function luma uses — there is no
15+missing chroma-specific machinery for the predictor math itself.
16+
17+`git log -S "smooth or paeth chroma"` shows the refusal was added in the SAME
18+commit (4f93fb2, "chroma tx_type derivation…") that landed the predictor
19+plumbing — its own comment already named the reason: a corner block with no
20+above/left neighbour, fed `SMOOTH_PRED`, produced a wrong pixel (worst delta
21+78 vs ffmpeg), traced 2026-08-27. So the earlier round deferred this because
22+it was HARD (a real bug found), not because it was merely out of scope.
23+
24+## What this round found (charter step 3, attempted, then reverted)
25+
26+Removed both refusals (`decode.rs` ~1970 and ~2458, the two `read_intra_mode`
27+variants), added a `SMOOTH_UV_HITS` counter, and wrote
28+`a_real_aomenc_stream_with_smooth_paeth_chroma_decodes_pixel_exact` (same
29+structure as the existing `..._with_directional_chroma_...` gate, but
30+`--enable-smooth-intra=1 --enable-paeth-intra=1`). First attempt (seed 42)
31+FAILED: luma mismatched ffmpeg, not chroma.
32+
33+Grepped every other real-aomenc gate in `stream.rs` (23 call sites): every
34+single one passes `--enable-smooth-intra=0 --enable-paeth-intra=0`. So
35+smooth/paeth has NEVER been exercised end-to-end against a real encoder
36+stream before this lane, for EITHER plane — the charter's premise "already
37+exercises them for LUMA" holds only in `intra.rs`'s own unit tests, not
38+against a real bitstream. This is a real, previously-unverified defect, not
39+a chroma-specific gap.
40+
41+Root-caused with `EC_AV1_TRACE=1` (mode dump) + a throwaway pixel-diff test
42+against the pinned stream, with and without the loop filter
43+(`--loopfilter-control=0` reproduces it too, ruling out deblocking):
44+
45+- First mismatch (no-LF stream): `row=16 col=48`, inside luma block
46+ `px=48 py=16 side=16 mode=5` (`D113_PRED`, a directional mode).
47+- Its ABOVE neighbour is `px=48 py=0 side=16 mode=11` (`SMOOTH_H_PRED`).
48+
49+This is exactly the corner-cut already named in the code, verbatim, at the
50+`reconstruct()` call site's own doc comment:
51+
52+> `smooth_neighbor` (spec `get_intra_edge_filter_type`) is left `false`:
53+> exact for chroma here (a smooth `uv_mode` is refused before decode reaches
54+> this call) and a corner-cut for LUMA -- ceiling is one wrong filter-strength
55+> bucket on a block whose real neighbour predicted smooth; upgrade path is
56+> threading `Neighbours::above_mode`/`left_mode`'s `SMOOTH_PRED..=SMOOTH_H_PRED`
57+> membership down instead of `false`.
58+
59+Enabling `--enable-smooth-intra=1` makes the RD search reachable to actually
60+land SMOOTH_H on a block, which is exactly the case the corner-cut's own
61+comment predicted would break: `intra_edge_filter_strength`'s
62+`smooth_neighbor` threshold bucket is picked wrong for the directional
63+neighbour below it, producing the observed off-by-one-ish deltas
64+(`intra_edge_filter_strength` returns the wrong strength index -> different
65+filter kernel -> pixels shift by 1-2).
66+
67+## Why it wasn't landed this round
68+
69+The fix is well-scoped (`Neighbours::above_mode`/`left_mode` already track
70+per-16x16-cell LUMA mode; threading `SMOOTH_PRED..=SMOOTH_H_PRED.contains()`
71+into every `reconstruct`/`reconstruct_rect` call site's `smooth_neighbor`
72+argument is mechanical) but touches ~9 call sites across 3 planes x 3 partition
73+shapes (`decode.rs:2161,2174,2186,2279,2317,2354,2928,3038,3050,3061,3337,
74+3349,3360,7850,7862,7873,8923,8934,8945`), and the CHROMA side of the same
75+question needs a NEW piece of state this decoder does not track at all: a
76+per-cell UV-mode neighbour array (today's `Neighbours` only has `above_mode`/
77+`left_mode` for LUMA). Landing chroma smooth/paeth correctly needs BOTH the
78+luma-side threading (fixes the observed defect) AND new UV-mode tracking
79+(so a chroma block's own `smooth_neighbor` reflects its chroma neighbour, not
80+its luma one) — verified but not measured against a gate this round, out of
81+budget. Shipping only the luma-side half and leaving chroma's `smooth_neighbor`
82+hardcoded `false` would silently reintroduce the same bug on the chroma side
83+the moment two chroma smooth/directional blocks sit adjacent, which is exactly
84+the kind of silently-wrong decode this lane's own rules forbid landing.
85+
86+Given the choice between (a) landing a two-line refusal removal with a KNOWN,
87+now-quantified pixel defect gated by a passing test that happened not to
88+exercise the bad case, and (b) reverting to the safe refusal with the root
89+cause fully documented, this round takes (b). The attempted diff (refusal
90+removal + counter + gate + throwaway diagnostic test) is saved at
91+`/tmp/claude-1000/-home-user-Documents-Code-Rust-edith-codecs/baaa03f8-c4ff-4469-8ebb-83100429b150/scratchpad/chroma-r1-attempt.diff`
92+for whichever round lands the `smooth_neighbor` threading.
93+
94+## Gate firing count
95+
96+None — the gate (`a_real_aomenc_stream_with_smooth_paeth_chroma_decodes_pixel_exact`)
97+was written and fired real smooth/paeth chroma symbols on its very first
98+attempt (seed 42), but FAILED on luma pixel mismatch before reaching a
99+chroma pixel-exact assertion; it was reverted along with the refusal removal
100+rather than left in the tree failing or disabled. `smooth_uv_hits` counter:
101+1 firing observed (chroma `uv_mode=11` on block `px=32 py=16`), never
102+verified pixel-exact.
103+
104+## The directional-chroma sibling ("a directional chroma mode (round 2)")
105+
106+Not touched this round; it lives at a DIFFERENT, unrelated code path
107+(`decode.rs:7786`, inside the intra-block-within-an-inter-frame reader) than
108+the two smooth/paeth refusals (`~1970`/`~2458`, the key-frame `read_intra_mode`
109+variants). That inter-frame intra-block path never computes `angle_delta_uv`
110+at all and refuses ANY non-DC/non-CFL `uv_mode` outright — i.e. directional
111+chroma is refused there unconditionally, unlike the key-frame path (`~2458`),
112+which ALREADY decodes directional chroma correctly today (see the existing,
113+passing `a_real_aomenc_stream_with_directional_chroma_decodes_pixel_exact`
114+gate). Landing the `~7786` sibling needs angle-delta-for-chroma support added
115+to that separate reader, plus its own gate; not attempted this round —
116+smaller in shape than the smooth/paeth work (no known predictor bug blocking
117+it, just missing plumbing) but independent scope, deferred to a future round.
118+
119+## Disposition
120+
121+deferred: thread `smooth_neighbor` through luma + add chroma UV-mode
122+neighbour tracking, then re-attempt this refusal removal — unblocks on
123+someone picking up the saved attempt diff and the ~9 call-site list above.
124+deferred: the `~7786` "directional chroma mode (round 2)" sibling in the
125+inter-frame intra-block path — unblocks independently, no known bug, just
126+unwritten angle-delta-for-chroma plumbing in that reader.
lanes/chroma-r2.charter.mdadded+80 -0
@@ -0,0 +1,80 @@
1+# lane-chroma r2 — smooth-neighbour edge filter, then smooth/paeth chroma
2+
3+Worktree `/home/user/Documents/Code/Rust/edith_codecs-chroma`, branch
4+`lane-chroma`, at 3ca2455 (r1's report; r1 landed NO code — it reverted).
5+
6+## What r1 established (read `lanes/chroma-r1.report.md` first — it is short)
7+- The `SMOOTH_PRED`/`PAETH_PRED` predictor math in `intra.rs` is already
8+ spec-correct and shared between luma and chroma. Removing the chroma refusal
9+ (`decode.rs` uv_mode 9..=12, around lines 1970 and 2458) is NOT the work.
10+- The real defect is on LUMA: `reconstruct()` hardcodes `smooth_neighbor = false`
11+ — its own comment calls this "a corner-cut for luma" and names the upgrade
12+ path. `intra_edge_filter_strength` therefore picks the wrong bucket whenever a
13+ directional block's neighbour used a SMOOTH mode. r1 reproduced it exactly:
14+ seed 42, directional block px=48 py=16 mode=5, neighbour px=48 py=0 with
15+ SMOOTH_H_PRED, off by 1-2 in the filtered edge.
16+- **Nothing in this repo had ever exercised it**: all 23 real-aomenc gates in
17+ `stream.rs` pass `--enable-smooth-intra=0 --enable-paeth-intra=0`. That is a
18+ fleet-wide gate-recipe blindness, not a one-gate miss.
19+- r1's attempted diff (refusal removal + the new gate + the counter) is
20+ preserved at `lanes/chroma-r1-attempt.diff` in this worktree. Start from it.
21+
22+## Goal, in order
23+1. **Fix the luma bug first, on its own, with its own gate.** Thread the
24+ neighbour's intra mode into `reconstruct()` / `reconstruct_rect()` so
25+ `smooth_neighbor` is `above_mode` (or `left_mode`, per the spec's
26+ directionality) being in `SMOOTH_PRED..=SMOOTH_H_PRED`. r1's report lists
27+ the ~9 call sites. `Neighbours` already tracks per-block state — add the
28+ luma mode alongside whatever it already stores; follow the shape of the
29+ existing `skip_at` / `skip_txfm_ctx` accessors in `decode.rs`.
30+ Spec anchor: 7.11.2.9 `intra edge filter strength` — the `filt_type`
31+ argument is 1 when the relevant neighbour used a smooth mode. libaom:
32+ `av1/common/reconintra.c` `get_filt_type()` / `av1_filter_intra_edge` and
33+ `intra_edge_filter_strength`; `get_filt_type` reads
34+ `av1_is_directional_mode` and `is_smooth(above_mbmi)`/`is_smooth(left_mbmi)`.
35+ Gate it with a real-aomenc stream that enables smooth intra for LUMA while
36+ the chroma refusal is still in place (chroma can still refuse at this
37+ stage — that keeps the two changes separable). COMMIT.
38+2. **Then** add chroma UV-mode neighbour tracking and remove the smooth/paeth
39+ chroma refusal, with the gate from the attempt diff
40+ (`a_real_aomenc_stream_with_smooth_paeth_chroma_decodes_pixel_exact`)
41+ passing pixel-exact on luma AND chroma. COMMIT.
42+3. **Then** the directional-chroma sibling if turns remain: `decode.rs:7786`,
43+ the inter-frame intra-block reader, which refuses any non-DC/CFL uv_mode
44+ unconditionally and never computes `angle_delta_uv`. r1 found no bug there,
45+ only unwritten plumbing. COMMIT.
46+
47+## Gate rules (mandatory)
48+- Run tests with `EC_AV1_REQUIRE_AOMENC=1` — a missing oracle must FAIL, not SKIP.
49+- Bound every ffmpeg `generate` with `-t <seconds>`.
50+- Build fixtures through the existing `gradients_source(seed, w, h, tail)`
51+ helper; ffmpeg's `gradients` source ignores its own seed.
52+- aomenc `--threads=1 --row-mt=0`, and of course `--enable-smooth-intra=1`
53+ (and `--enable-paeth-intra=1` for stage 2).
54+- Hard-assert a firing count with a thread-local `Cell<usize>` counter in
55+ decode.rs matching the existing `*_HITS` (thread-local now, NOT atomics):
56+ for stage 1, count the blocks where `smooth_neighbor` came out TRUE — a gate
57+ that runs with smooth intra enabled but never hits the new branch proves
58+ nothing (class `gate-blind-to-feature`).
59+- Refusals inside a gate are FORBIDDEN once the stage removing them lands.
60+
61+## Method
62+CLASS `compare-range-not-tell`: compare the msac RANGE against the oracle, never
63+`tell()`. Oracle at `~/.cache/aom-oracle`, rungs `EC_TRACE=1` (partitions),
64+`EC_TRACE_COEFF=1`, `EC_TRACE_MODE=1` (inter + intra mode info),
65+`EC_AV1_PREFILT_DUMP=<prefix>` (per-frame pre-filter recon — the right rung for
66+a predictor bug, since it isolates prediction from the loop filters).
67+Add a rung via `scripts/instrument-aom-oracle.sh` + `scripts/build-aom-oracle.sh`
68+in the existing shape (env-gated, silent when unset, idempotent) if you need one.
69+
70+## Hard rules
71+- `export CARGO_TARGET_DIR=$HOME/.cache/cargo-target-chroma`. Foreground builds,
72+ `nice -n 19 cargo ... -j4`. Sibling worktrees (edith_codecs, -realworld, -lr,
73+ -superres, -tiles) have live agents — never build in or edit them.
74+- Suite: `nice -n 19 cargo test -p ec-av1 --lib`, baseline 232 passed / 0 failed.
75+- NEVER push, never merge, never touch `main`. Commit on `lane-chroma` only.
76+- 75-turn cap: COMMIT AFTER EVERY GREEN MILESTONE. r1 spent its whole budget and
77+ landed zero code because it held everything in the working tree; a commit that
78+ compiles beats a perfect uncommitted tree. Do not re-derive what r1's report
79+ already tells you (class `worker-cap-spent-reading`).
80+- End with `lanes/chroma-r2.report.md`, VERDICT on the first line.
lanes/chroma-r3.charter.mdadded+60 -0
@@ -0,0 +1,60 @@
1+# lane-chroma r3 — run the smooth-intra gate, then the chroma refusal
2+
3+Worktree `/home/user/Documents/Code/Rust/edith_codecs-chroma`, branch
4+`lane-chroma`.
5+
6+## State
7+- `8bca1d6` — **the luma fix landed**: `smooth_neighbor` is threaded into the
8+ intra edge filter strength instead of being hardcoded `false`. This is r1's
9+ root cause (a directional block neighbouring a smooth-mode one picked the
10+ wrong filter bucket). Committed, compiles.
11+- The next commit is the orchestrator's cap-rescue of r2's gate: ~140 new lines
12+ in `crates/ec-av1/src/stream.rs`, a smooth-intra gate that **compiles but has
13+ never been run once**. That is your first job.
14+- `lanes/chroma-r2.charter.md` — still binding for everything below.
15+- `lanes/chroma-r1.report.md` + `lanes/chroma-r1-attempt.diff` — r1's root-cause
16+ writeup and its reverted attempt (the chroma-side gate lives there).
17+
18+## Order — COMMIT AFTER EVERY GREEN STEP
19+1. Run the new gate:
20+ `export CARGO_TARGET_DIR=$HOME/.cache/cargo-target-chroma` then
21+ `EC_AV1_REQUIRE_AOMENC=1 nice -n 19 cargo test -p ec-av1 --lib <gate name> -j4 -- --nocapture`
22+ with a timeout of at least 600000 ms. Make it pass pixel-exact on luma with a
23+ HARD-asserted firing count proving `smooth_neighbor` actually came out TRUE
24+ somewhere — a gate that enables smooth intra but never hits the new branch
25+ proves nothing (class `gate-blind-to-feature`). Then the full suite
26+ (baseline 232/0 on this tree; main is at 234 with two new guard tests).
27+ COMMIT.
28+2. Chroma: add UV-mode neighbour tracking to `Neighbours` and remove the
29+ smooth/paeth chroma refusals (decode.rs uv_mode 9..=12, around 1970 and
30+ 2458), with r1's gate
31+ `a_real_aomenc_stream_with_smooth_paeth_chroma_decodes_pixel_exact` from the
32+ attempt diff green on luma AND chroma. COMMIT.
33+3. Once a gate really enables smooth-intra and paeth-intra, main's
34+ `crates/ec-av1/src/gate_coverage.rs` guard will FAIL by design: its
35+ `NEVER_EXERCISED` list still names `enable-smooth-intra` and
36+ `enable-paeth-intra` as tools no gate exercises. Deleting those two entries
37+ is part of landing this work — that guard exists precisely so closing the
38+ hole is noticed. (The guard is on main, so you will meet it at merge if not
39+ before; if `gate_coverage.rs` is not in your tree yet, note it in the report
40+ for the merge instead.)
41+4. If turns remain: the directional-chroma sibling at `decode.rs:7786`, the
42+ inter-frame intra-block reader, which refuses any non-DC/CFL uv_mode
43+ unconditionally and never computes `angle_delta_uv`. No known bug there,
44+ just unwritten plumbing. COMMIT.
45+
46+## Gate rules (mandatory)
47+`EC_AV1_REQUIRE_AOMENC=1` on every run; `-t <seconds>` on every ffmpeg generate;
48+fixtures through `gradients_source(seed, w, h, tail)`; aomenc
49+`--threads=1 --row-mt=0 --enable-smooth-intra=1` (and `--enable-paeth-intra=1`
50+for stage 2); firing counts are HARD asserts via thread-local `Cell<usize>`
51+counters like the existing `*_HITS`.
52+
53+## Hard rules
54+- Own `CARGO_TARGET_DIR` as above; foreground builds, `nice -n 19 cargo ... -j4`;
55+ every `cargo test` gets a timeout of at least 600000 ms.
56+- Sibling worktrees (edith_codecs, -realworld, -lr, -superres, -tiles) have live
57+ agents. Never build in or edit them.
58+- NEVER push, never merge, never touch `main`. Commit on `lane-chroma` only.
59+- 75-turn cap and it does NOT reset on resume: commit at every green step.
60+- End with `lanes/chroma-r3.report.md`, VERDICT on the first line.
lanes/chroma-r4.charter.mdadded+49 -0
@@ -0,0 +1,49 @@
1+# lane-chroma r4 — finish the chroma refusal removal
2+
3+Worktree `/home/user/Documents/Code/Rust/edith_codecs-chroma`, branch
4+`lane-chroma`. Read `lanes/chroma-r3.charter.md` (still binding) and, briefly,
5+`lanes/chroma-r1.report.md` for the root cause. Do not re-derive them.
6+
7+## State
8+- `8bca1d6` — the real luma fix: `smooth_neighbor` threaded into the intra edge
9+ filter strength instead of hardcoded `false`.
10+- `bafda07` — r2's smooth-intra gate, cap-rescued, compiles.
11+- HEAD — r3's work, cap-rescued by the orchestrator: `decode.rs` +99,
12+ `stream.rs` +126. r3's last words before the cap were "now let's add the r1
13+ gate for smooth/paeth chroma (charter step 2), then run the full lib test
14+ suite" — so the luma gate is believed to have gone green in r3's hands, but
15+ **no suite run has ever been seen on this tree**. Verify, do not assume.
16+
17+## Order
18+1. `export CARGO_TARGET_DIR=$HOME/.cache/cargo-target-chroma` then
19+ `EC_AV1_REQUIRE_AOMENC=1 nice -n 19 cargo test -p ec-av1 --lib -j4`
20+ (timeout >= 600000 ms). Report the count against 232/0 for this tree.
21+ If red, fixing HEAD is the whole job until it is green. COMMIT once green.
22+2. Chroma: UV-mode neighbour tracking in `Neighbours`, remove the smooth/paeth
23+ chroma refusals (decode.rs uv_mode 9..=12, around 1970 and 2458), with r1's
24+ gate `a_real_aomenc_stream_with_smooth_paeth_chroma_decodes_pixel_exact`
25+ (in `lanes/chroma-r1-attempt.diff`) green on luma AND chroma. COMMIT.
26+3. Note for the merge: main carries `crates/ec-av1/src/gate_coverage.rs`, whose
27+ `NEVER_EXERCISED` list still names `enable-smooth-intra` and
28+ `enable-paeth-intra` as tools no gate exercises. Once your gates enable them,
29+ those two entries must be deleted — that guard exists so closing the hole is
30+ noticed. If `gate_coverage.rs` is not in your tree, say so in the report so
31+ the merge does it.
32+4. If turns remain: the directional-chroma sibling at `decode.rs:7786` (the
33+ inter-frame intra-block reader refuses any non-DC/CFL uv_mode and never
34+ computes `angle_delta_uv`). COMMIT.
35+
36+## Gate rules
37+`EC_AV1_REQUIRE_AOMENC=1` on every run; `-t <seconds>` on every ffmpeg generate;
38+fixtures through `gradients_source(seed, w, h, tail)`; aomenc
39+`--threads=1 --row-mt=0 --enable-smooth-intra=1 --enable-paeth-intra=1`;
40+firing counts are HARD asserts via thread-local `Cell<usize>` counters.
41+
42+## Hard rules
43+Own `CARGO_TARGET_DIR` as above; foreground builds `nice -n 19 cargo ... -j4`;
44+every `cargo test` a timeout >= 600000 ms. Sibling worktrees (edith_codecs,
45+-realworld, -lr, -superres, -tiles, -palette) have live agents — never build in
46+or edit them. Never push, never merge, never touch `main`. 75-turn cap, does not
47+reset: COMMIT AT EVERY GREEN STEP — three rounds in a row on this lane have
48+ended with the work uncommitted. End with `lanes/chroma-r4.report.md`, VERDICT
49+on line 1.
lanes/chroma-r4.report.mdadded+66 -0
@@ -0,0 +1,66 @@
1+VERDICT: GREEN
2+
3+## Step 1 -- verify HEAD
4+`EC_AV1_REQUIRE_AOMENC=1 cargo test -p ec-av1 --lib -j4`: **234 passed; 0 failed; 17
5+ignored** (vs the charter's 232/0 baseline -- 2 extra tests are r3's own new
6+smooth-intra/smooth-paeth-chroma gates, already in HEAD). Tree was clean at
7+start (nothing to commit for this step); r3's cap-rescued work is genuinely
8+green, contrary to the "no suite run has ever been seen" warning.
9+
10+## Step 2 -- chroma UV-mode neighbour tracking + smooth/paeth chroma refusal
11+Already done in HEAD (r3's commit `47da0be`): `Neighbours::above_uv_mode`/
12+`left_uv_mode` exist, `decode.rs`'s two `read_intra_mode`/`read_intra_mode_rect`
13+sites (keyframe callers) removed the `9..=12` uv_mode refusal, and
14+`lanes/chroma-r1-attempt.diff`'s gate
15+(`a_real_aomenc_stream_with_smooth_paeth_chroma_decodes_pixel_exact`) is
16+present in `stream.rs` and passes on its own
17+(`cargo test ... smooth_paeth_chroma` -- 1 passed). No new commit needed.
18+
19+## Step 3 -- gate_coverage.rs
20+`crates/ec-av1/src/gate_coverage.rs` **does not exist in this tree**
21+(confirmed via `find`). Per the charter, the merge must delete the
22+`enable-smooth-intra`/`enable-paeth-intra` entries from `NEVER_EXERCISED`
23+on `main`'s copy.
24+
25+## Step 4 -- directional-chroma sibling (turns remained)
26+Charter's line number (`decode.rs:7786`) had drifted from r3's +99 lines;
27+the real sibling was `decode_inter_block`'s intra-in-inter branch (the
28+`else` arm handling an intra block coded inside an inter frame), which read
29+`uv_mode` and refused outright with `"a directional chroma mode (round 2)"`
30+for anything past DC/CFL, and never read `angle_delta_uv` at all.
31+
32+Fixed by mirroring `read_intra_mode`'s already-proven pattern in that one
33+function (`crates/ec-av1/src/decode.rs`, `decode_inter_block`):
34+- `uv_predict_mode` (CFL predicts as DC for the reconstruct call, same as
35+ the keyframe path) threaded through both `u`/`v.reconstruct` calls (skip
36+ path) and both chroma `read_plane` calls (non-skip path), replacing the
37+ hardcoded `DC_PRED`.
38+- `angle_delta_uv` computed via `read_angle_delta` when `uv_mode` is
39+ directional (`V_PRED..=D67_PRED`), replacing the hardcoded `0`.
40+- `smooth_neighbor_uv` computed from the chroma neighbour's own `uv_mode`
41+ (`is_smooth_mode(above_uv_mode/left_uv_mode)`), replacing the hardcoded
42+ `false`, threaded into the same reconstruct/read_plane calls.
43+- `SMOOTH_UV_HITS`/`DIRECTIONAL_UV_HITS` counted here too (shared
44+ thread-locals with the keyframe path).
45+- `neighbours.record_rect`'s uv-mode arg (previously hardcoded `DC_PRED`)
46+ now carries the real `uv_predict_mode` so a following block's own
47+ smooth-neighbour check sees it.
48+- The luma-mode side of this branch (`mode`, its own angle_delta refusal at
49+ the top) is **untouched** -- out of this charter step's chroma-only scope.
50+
51+`cargo check -p ec-av1 --lib`: clean (no new warnings/errors). Full lib
52+suite re-run after the change: still **234 passed; 0 failed; 17 ignored** --
53+no regression.
54+
55+**Gap, disclosed per "refusal strings are claims":** no dedicated gate
56+proves a real aomenc stream ever actually exercises this specific path (an
57+intra block, directional/smooth/paeth `uv_mode`, coded *inside an inter
58+frame*) end to end against ffmpeg. The change is a direct structural mirror
59+of the already-gated keyframe fix (identical CDF tables, identical
60+`get_uv_mode`/angle-delta semantics per spec 9.3), and the full suite stays
61+green, but it is **code-verified by mirroring, not gate-verified by firing**.
62+`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`.
63+
64+## Commit
65+`c806bd6` -- directional/smooth/paeth chroma in inter-frame intra blocks.
66+Nothing else uncommitted; `git status` clean.