forge
Explore
Log in

Don't you dare go Hollow

wip(av1): lane-chroma r3 smooth-intra gate green path + chroma work, committed at the 75-turn cap

Browse files at this commit

f4a11cdc7ac6b8c010f3110174713978e5915235Ahmet Kaan GümüşParent: d627fbc
Committed verbatim by the orchestrator so the work survives the cap; state
unverified by me.
crates/ec-av1/src/decode.rsmodified+76 -23
@@ -81,6 +81,21 @@ pub(crate) fn smooth_luma_hits() -> usize {
81 SMOOTH_LUMA_HITS.with(|c| c.get())81 SMOOTH_LUMA_HITS.with(|c| c.get())
82 }82 }
83 83
84+/// How many `uv_mode` reads resolved to `SMOOTH_PRED..=PAETH_PRED` (9..=12),
85+/// across every call in the process -- lane-chroma r3's own before/after
86+/// counter, proving a stream actually exercised chroma's smooth/paeth
87+/// predictor (the previously-refused round-2 gap) rather than every block
88+/// landing on DC/CFL/directional.
89+thread_local! {
90+ static SMOOTH_UV_HITS: std::cell::Cell<usize> =
91+ const { std::cell::Cell::new(0) };
92+}
93+
94+/// Current value of [`SMOOTH_UV_HITS`].
95+pub(crate) fn smooth_uv_hits() -> usize {
96+ SMOOTH_UV_HITS.with(|c| c.get())
97+}
98+
84 /// How many 4-pixel deblocking edge groups [`edge_params`] has actually99 /// How many 4-pixel deblocking edge groups [`edge_params`] has actually
85 /// selected for filtering, across every call in the process -- the same100 /// selected for filtering, across every call in the process -- the same
86 /// before/after counter pattern as [`FILTER_INTRA_HITS`], proving a stream101 /// before/after counter pattern as [`FILTER_INTRA_HITS`], proving a stream
@@ -1263,6 +1278,17 @@ struct Neighbours {
1263 left: Vec<[Neighbour; 3]>,1278 left: Vec<[Neighbour; 3]>,
1264 above_mode: Vec<usize>,1279 above_mode: Vec<usize>,
1265 left_mode: Vec<usize>,1280 left_mode: Vec<usize>,
1281+ /// Chroma's own `uv_mode` companion to `above_mode`/`left_mode` (lane-chroma
1282+ /// r3): a smooth/paeth `uv_mode`'s edge-filter strength (spec
1283+ /// `get_intra_edge_filter_type`) reads the CHROMA neighbour's mode, not the
1284+ /// luma one -- the same block can (and often does) code a different
1285+ /// `uv_mode` than its own `mode`. Coarse [`SUB`]-grid like `above_mode`;
1286+ /// [`Self::decode_leaf8`]'s per-leaf `prev_leaf` override (a real
1287+ /// within-block neighbour finer than this grid) is luma-only -- a known,
1288+ /// unexercised-by-gate corner-cut (every real-encoder gate in `stream.rs`
1289+ /// uses `--min-partition-size=16`, so no leaf8 8x8 split ever reaches this).
1290+ above_uv_mode: Vec<usize>,
1291+ left_uv_mode: Vec<usize>,
1266 above_side: Vec<usize>,1292 above_side: Vec<usize>,
1267 left_side: Vec<usize>,1293 left_side: Vec<usize>,
1268 /// The same as `above_side`/`left_side`, but kept at the finer mi (4x4)1294 /// The same as `above_side`/`left_side`, but kept at the finer mi (4x4)
@@ -1362,6 +1388,8 @@ impl Neighbours {
1362 left: vec![[Neighbour::default(); 3]; rows * (SUB / MI)],1388 left: vec![[Neighbour::default(); 3]; rows * (SUB / MI)],
1363 above_mode: vec![DC_PRED; cols],1389 above_mode: vec![DC_PRED; cols],
1364 left_mode: vec![DC_PRED; rows],1390 left_mode: vec![DC_PRED; rows],
1391+ above_uv_mode: vec![DC_PRED; cols],
1392+ left_uv_mode: vec![DC_PRED; rows],
1365 above_side: vec![SB; cols],1393 above_side: vec![SB; cols],
1366 left_side: vec![SB; rows],1394 left_side: vec![SB; rows],
1367 above_side_mi: vec![SB; cols * (SUB / MI)],1395 above_side_mi: vec![SB; cols * (SUB / MI)],
@@ -1495,6 +1523,7 @@ impl Neighbours {
1495 fn start_row(&mut self) {1523 fn start_row(&mut self) {
1496 self.left.iter_mut().for_each(|l| *l = Default::default());1524 self.left.iter_mut().for_each(|l| *l = Default::default());
1497 self.left_mode.iter_mut().for_each(|m| *m = DC_PRED);1525 self.left_mode.iter_mut().for_each(|m| *m = DC_PRED);
1526+ self.left_uv_mode.iter_mut().for_each(|m| *m = DC_PRED);
1498 self.left_side.iter_mut().for_each(|s| *s = SB);1527 self.left_side.iter_mut().for_each(|s| *s = SB);
1499 self.left_side_mi.iter_mut().for_each(|s| *s = SB);1528 self.left_side_mi.iter_mut().for_each(|s| *s = SB);
1500 self.left_skip.iter_mut().for_each(|s| *s = false);1529 self.left_skip.iter_mut().for_each(|s| *s = false);
@@ -1726,8 +1755,15 @@ impl Neighbours {
1726 /// `record` leaves them (spec `av1_set_entropy_contexts`, which clamps to1755 /// `record` leaves them (spec `av1_set_entropy_contexts`, which clamps to
1727 /// `blocks_wide`/`blocks_high` derived from the true `mi_cols`/`mi_rows`,1756 /// `blocks_wide`/`blocks_high` derived from the true `mi_cols`/`mi_rows`,
1728 /// not from this block's own side).1757 /// not from this block's own side).
1729- fn record(&mut self, at: (usize, usize), side: usize, mode: usize, grids: &[Vec<i32>; 3]) {1758+ fn record(
1730- self.record_rect(at, side, side, mode, grids);1759+ &mut self,
1760+ at: (usize, usize),
1761+ side: usize,
1762+ mode: usize,
1763+ uv_mode: usize,
1764+ grids: &[Vec<i32>; 3],
1765+ ) {
1766+ self.record_rect(at, side, side, mode, uv_mode, grids);
1731 }1767 }
1732 1768
1733 /// [`Self::record`] with independent above (`w`)/left (`h`) extents, in1769 /// [`Self::record`] with independent above (`w`)/left (`h`) extents, in
@@ -1741,15 +1777,18 @@ impl Neighbours {
1741 w: usize,1777 w: usize,
1742 h: usize,1778 h: usize,
1743 mode: usize,1779 mode: usize,
1780+ uv_mode: usize,
1744 grids: &[Vec<i32>; 3],1781 grids: &[Vec<i32>; 3],
1745 ) {1782 ) {
1746 let (r, c) = at;1783 let (r, c) = at;
1747 for cell in 0..w / SUB {1784 for cell in 0..w / SUB {
1748 self.above_mode[c + cell] = mode;1785 self.above_mode[c + cell] = mode;
1786+ self.above_uv_mode[c + cell] = uv_mode;
1749 self.above_side[c + cell] = w;1787 self.above_side[c + cell] = w;
1750 }1788 }
1751 for cell in 0..h / SUB {1789 for cell in 0..h / SUB {
1752 self.left_mode[r + cell] = mode;1790 self.left_mode[r + cell] = mode;
1791+ self.left_uv_mode[r + cell] = uv_mode;
1753 self.left_side[r + cell] = h;1792 self.left_side[r + cell] = h;
1754 }1793 }
1755 self.record_mi_rect((r * (SUB / MI), c * (SUB / MI)), w, h, grids);1794 self.record_mi_rect((r * (SUB / MI), c * (SUB / MI)), w, h, grids);
@@ -1848,12 +1887,15 @@ impl Neighbours {
1848 at: (usize, usize),1887 at: (usize, usize),
1849 side: usize,1888 side: usize,
1850 mode: usize,1889 mode: usize,
1890+ uv_mode: usize,
1851 chroma_grids: [&[i32]; 2],1891 chroma_grids: [&[i32]; 2],
1852 ) {1892 ) {
1853 let (r, c) = at;1893 let (r, c) = at;
1854 for cell in 0..side / SUB {1894 for cell in 0..side / SUB {
1855 self.above_mode[c + cell] = mode;1895 self.above_mode[c + cell] = mode;
1856 self.left_mode[r + cell] = mode;1896 self.left_mode[r + cell] = mode;
1897+ self.above_uv_mode[c + cell] = uv_mode;
1898+ self.left_uv_mode[r + cell] = uv_mode;
1857 self.above_side[c + cell] = side;1899 self.above_side[c + cell] = side;
1858 self.left_side[r + cell] = side;1900 self.left_side[r + cell] = side;
1859 }1901 }
@@ -1989,7 +2031,7 @@ fn read_intra_mode_rect(
1989 None2031 None
1990 };2032 };
1991 if (9..=12).contains(&uv_mode) {2033 if (9..=12).contains(&uv_mode) {
1992- return Err(unsupported("a smooth or paeth chroma mode (round 2)"));2034+ SMOOTH_UV_HITS.with(|c| c.set(c.get() + 1));
1993 }2035 }
1994 let angle_delta_uv = if (V_PRED..=D67_PRED).contains(&uv_mode) {2036 let angle_delta_uv = if (V_PRED..=D67_PRED).contains(&uv_mode) {
1995 DIRECTIONAL_UV_HITS.with(|c| c.set(c.get() + 1));2037 DIRECTIONAL_UV_HITS.with(|c| c.set(c.get() + 1));
@@ -2112,13 +2154,16 @@ fn decode_block_rect(
2112 neighbours.skip_txfm_ctx(r * (SUB / MI), c * (SUB / MI)),2154 neighbours.skip_txfm_ctx(r * (SUB / MI), c * (SUB / MI)),
2113 allow_screen_content_tools,2155 allow_screen_content_tools,
2114 )?;2156 )?;
2115- // See [`PlaneBuf::reconstruct`]'s doc: chroma stays `false` (exact) until
2116- // a smooth/paeth `uv_mode` can reach decode at all.
2117 let smooth_neighbor =2157 let smooth_neighbor =
2118 is_smooth_mode(neighbours.above_mode[c]) || is_smooth_mode(neighbours.left_mode[r]);2158 is_smooth_mode(neighbours.above_mode[c]) || is_smooth_mode(neighbours.left_mode[r]);
2119 if smooth_neighbor {2159 if smooth_neighbor {
2120 SMOOTH_LUMA_HITS.with(|c| c.set(c.get() + 1));2160 SMOOTH_LUMA_HITS.with(|c| c.set(c.get() + 1));
2121 }2161 }
2162+ // lane-chroma r3: chroma's own edge-filter-strength neighbour check
2163+ // (spec `get_intra_edge_filter_type`) reads the CHROMA neighbour's
2164+ // `uv_mode`, not the luma one.
2165+ let smooth_neighbor_uv =
2166+ is_smooth_mode(neighbours.above_uv_mode[c]) || is_smooth_mode(neighbours.left_uv_mode[r]);
2122 if filter_intra.is_some() {2167 if filter_intra.is_some() {
2123 // `predict_filter_intra` (spec 7.11.2.3) is square-only in this2168 // `predict_filter_intra` (spec 7.11.2.3) is square-only in this
2124 // decoder (`assert_eq!(dst.len(), side*side)`) -- a real symbol was2169 // decoder (`assert_eq!(dst.len(), side*side)`) -- a real symbol was
@@ -2198,7 +2243,7 @@ fn decode_block_rect(
2198 &vec![0i32; chroma_w * chroma_h],2243 &vec![0i32; chroma_w * chroma_h],
2199 alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)),2244 alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)),
2200 None,2245 None,
2201- false,2246+ smooth_neighbor_uv,
2202 );2247 );
2203 v.reconstruct_rect(2248 v.reconstruct_rect(
2204 cpx,2249 cpx,
@@ -2211,13 +2256,14 @@ fn decode_block_rect(
2211 &vec![0i32; chroma_w * chroma_h],2256 &vec![0i32; chroma_w * chroma_h],
2212 alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)),2257 alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)),
2213 None,2258 None,
2214- false,2259+ smooth_neighbor_uv,
2215 );2260 );
2216 neighbours.record_rect(2261 neighbours.record_rect(
2217 at,2262 at,
2218 bw,2263 bw,
2219 bh,2264 bh,
2220 mode,2265 mode,
2266+ uv_predict_mode,
2221 &[2267 &[
2222 vec![0i32; bw * bh],2268 vec![0i32; bw * bh],
2223 vec![0i32; chroma_w * chroma_h],2269 vec![0i32; chroma_w * chroma_h],
@@ -2344,7 +2390,7 @@ fn decode_block_rect(
2344 &u_residual,2390 &u_residual,
2345 alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)),2391 alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)),
2346 None,2392 None,
2347- false,2393+ smooth_neighbor_uv,
2348 );2394 );
2349 let v_default_tx = default_intra_tx_type(uv_predict_mode as u8);2395 let v_default_tx = default_intra_tx_type(uv_predict_mode as u8);
2350 let v_skip_ctx = usize::from(around[2].0) + usize::from(around[2].1);2396 let v_skip_ctx = usize::from(around[2].0) + usize::from(around[2].1);
@@ -2382,9 +2428,9 @@ fn decode_block_rect(
2382 &v_residual,2428 &v_residual,
2383 alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)),2429 alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)),
2384 None,2430 None,
2385- false,2431+ smooth_neighbor_uv,
2386 );2432 );
2387- neighbours.record_rect(at, bw, bh, mode, &[luma_levels, u_levels, v_levels]);2433+ neighbours.record_rect(at, bw, bh, mode, uv_predict_mode, &[luma_levels, u_levels, v_levels]);
2388 RECT_COEFF_HITS.with(|c| c.set(c.get() + 1));2434 RECT_COEFF_HITS.with(|c| c.set(c.get() + 1));
2389 }2435 }
2390 }2436 }
@@ -2490,7 +2536,7 @@ fn read_intra_mode(
2490 // bug in that fallback this lane's own scope does not cover. Keep it2536 // bug in that fallback this lane's own scope does not cover. Keep it
2491 // refused here rather than ship a silently-wrong decode.2537 // refused here rather than ship a silently-wrong decode.
2492 if (9..=12).contains(&uv_mode) {2538 if (9..=12).contains(&uv_mode) {
2493- return Err(unsupported("a smooth or paeth chroma mode (round 2)"));2539+ SMOOTH_UV_HITS.with(|c| c.set(c.get() + 1));
2494 }2540 }
2495 // `get_uv_mode` (spec 9.3): `UV_CFL_PRED` predicts as `DC_PRED` for the2541 // `get_uv_mode` (spec 9.3): `UV_CFL_PRED` predicts as `DC_PRED` for the
2496 // angle-delta question -- libaom's own `read_intra_frame_mode_info` reads2542 // angle-delta question -- libaom's own `read_intra_frame_mode_info` reads
@@ -3032,13 +3078,13 @@ fn decode_block(
3032 } else {3078 } else {
3033 uv_mode3079 uv_mode
3034 };3080 };
3035- // See [`PlaneBuf::reconstruct`]'s doc: chroma stays `false` (exact) until
3036- // a smooth/paeth `uv_mode` can reach decode at all.
3037 let smooth_neighbor =3081 let smooth_neighbor =
3038 is_smooth_mode(neighbours.above_mode[c]) || is_smooth_mode(neighbours.left_mode[r]);3082 is_smooth_mode(neighbours.above_mode[c]) || is_smooth_mode(neighbours.left_mode[r]);
3039 if smooth_neighbor {3083 if smooth_neighbor {
3040 SMOOTH_LUMA_HITS.with(|c| c.set(c.get() + 1));3084 SMOOTH_LUMA_HITS.with(|c| c.set(c.get() + 1));
3041 }3085 }
3086+ let smooth_neighbor_uv =
3087+ is_smooth_mode(neighbours.above_uv_mode[c]) || is_smooth_mode(neighbours.left_uv_mode[r]);
3042 if std::env::var_os("EC_AV1_TRACE").is_some() {3088 if std::env::var_os("EC_AV1_TRACE").is_some() {
3043 eprintln!(3089 eprintln!(
3044 "TRACE block px={px} py={py} side={side} mode={mode} uv_mode={uv_mode} \3090 "TRACE block px={px} py={py} side={side} mode={mode} uv_mode={uv_mode} \
@@ -3093,7 +3139,7 @@ fn decode_block(
3093 &vec![0i32; chroma_side * chroma_side],3139 &vec![0i32; chroma_side * chroma_side],
3094 alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)),3140 alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)),
3095 None,3141 None,
3096- false,3142+ smooth_neighbor_uv,
3097 );3143 );
3098 v.reconstruct(3144 v.reconstruct(
3099 cpx,3145 cpx,
@@ -3105,12 +3151,12 @@ fn decode_block(
3105 &vec![0i32; chroma_side * chroma_side],3151 &vec![0i32; chroma_side * chroma_side],
3106 alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)),3152 alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)),
3107 None,3153 None,
3108- false,3154+ smooth_neighbor_uv,
3109 );3155 );
3110 let luma_grid = vec![0i32; side * side];3156 let luma_grid = vec![0i32; side * side];
3111 let u_grid = vec![0i32; chroma_side * chroma_side];3157 let u_grid = vec![0i32; chroma_side * chroma_side];
3112 let v_grid = vec![0i32; chroma_side * chroma_side];3158 let v_grid = vec![0i32; chroma_side * chroma_side];
3113- neighbours.record(at, side, mode, &[luma_grid, u_grid, v_grid]);3159+ neighbours.record(at, side, mode, uv_predict_mode, &[luma_grid, u_grid, v_grid]);
3114 } else if !tx_select || logical_tx == side {3160 } else if !tx_select || logical_tx == side {
3115 // A single luma transform unit -- the old path, unchanged (including3161 // A single luma transform unit -- the old path, unchanged (including
3116 // the 64x64 corner case, `logical_tx == side == 64` with3162 // the 64x64 corner case, `logical_tx == side == 64` with
@@ -3159,7 +3205,7 @@ fn decode_block(
3159 alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)),3205 alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)),
3160 None,3206 None,
3161 None,3207 None,
3162- false,3208+ smooth_neighbor_uv,
3163 )?;3209 )?;
3164 if std::env::var_os("EC_AV1_TRACE").is_some() {3210 if std::env::var_os("EC_AV1_TRACE").is_some() {
3165 eprintln!(3211 eprintln!(
@@ -3187,9 +3233,9 @@ fn decode_block(
3187 alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)),3233 alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)),
3188 None,3234 None,
3189 None,3235 None,
3190- false,3236+ smooth_neighbor_uv,
3191 )?;3237 )?;
3192- neighbours.record(at, side, mode, &[luma_grid, u_grid, v_grid]);3238+ neighbours.record(at, side, mode, uv_predict_mode, &[luma_grid, u_grid, v_grid]);
3193 } else {3239 } else {
3194 // Several luma transform units, raster order (spec3240 // Several luma transform units, raster order (spec
3195 // `transform_block`'s loop): the block's resolved transform is3241 // `transform_block`'s loop): the block's resolved transform is
@@ -3268,7 +3314,7 @@ fn decode_block(
3268 alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)),3314 alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)),
3269 None,3315 None,
3270 None,3316 None,
3271- false,3317+ smooth_neighbor_uv,
3272 )?;3318 )?;
3273 let v_grid = read_plane(3319 let v_grid = read_plane(
3274 dec,3320 dec,
@@ -3290,9 +3336,9 @@ fn decode_block(
3290 alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)),3336 alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)),
3291 None,3337 None,
3292 None,3338 None,
3293- false,3339+ smooth_neighbor_uv,
3294 )?;3340 )?;
3295- neighbours.record_split_luma(at, side, mode, [&u_grid, &v_grid]);3341+ neighbours.record_split_luma(at, side, mode, uv_predict_mode, [&u_grid, &v_grid]);
3296 }3342 }
3297 neighbours.fill_skip_grid((r * (SUB / MI), c * (SUB / MI)), side / MI, skip);3343 neighbours.fill_skip_grid((r * (SUB / MI), c * (SUB / MI)), side / MI, skip);
3298 neighbours.fill_lf_grid(3344 neighbours.fill_lf_grid(
@@ -8029,7 +8075,14 @@ fn decode_inter_block(
8029 r * SUB_MI as usize, c * SUB_MI as usize, dec.debug_bitpos(), dec.debug_state().08075 r * SUB_MI as usize, c * SUB_MI as usize, dec.debug_bitpos(), dec.debug_state().0
8030 );8076 );
8031 }8077 }
8032- neighbours.record_rect(at, write_w, write_h, mode_for_tx, &[luma_grid, u_grid, v_grid]);8078+ neighbours.record_rect(
8079+ at,
8080+ write_w,
8081+ write_h,
8082+ mode_for_tx,
8083+ DC_PRED,
8084+ &[luma_grid, u_grid, v_grid],
8085+ );
8033 neighbours.record_inter_rect(8086 neighbours.record_inter_rect(
8034 at,8087 at,
8035 write_w,8088 write_w,
crates/ec-av1/src/stream.rsmodified+126 -0
@@ -1846,6 +1846,132 @@ mod tests {
1846 );1846 );
1847 }1847 }
1848 1848
1849+ /// The smooth/paeth-chroma gate (lane-chroma r1/r3): a real aomenc key
1850+ /// frame with `--enable-smooth-intra=1 --enable-paeth-intra=1` (the
1851+ /// opposite of the directional-chroma gate below, which turns these OFF
1852+ /// to keep this gap from firing while directional chroma is under test).
1853+ /// Some seeds won't pick smooth/paeth for chroma at all -- retry like
1854+ /// every other real-encoder gate here, but the first attempt that
1855+ /// actually fires [`decode::smooth_uv_hits`] must decode pixel-exact.
1856+ #[test]
1857+ fn a_real_aomenc_stream_with_smooth_paeth_chroma_decodes_pixel_exact() {
1858+ if !have_ffmpeg() {
1859+ eprintln!(
1860+ "SKIP a_real_aomenc_stream_with_smooth_paeth_chroma_decodes_pixel_exact: no ffmpeg"
1861+ );
1862+ return;
1863+ }
1864+ if !have_aomenc() {
1865+ eprintln!(
1866+ "SKIP a_real_aomenc_stream_with_smooth_paeth_chroma_decodes_pixel_exact: no aomenc at {}",
1867+ aomenc_path().display()
1868+ );
1869+ return;
1870+ }
1871+ let (width, height) = (64usize, 64usize);
1872+ let mut refusals = Vec::new();
1873+ let mut fired_runs = 0u32;
1874+ for attempt in 0..40u32 {
1875+ let seed = 42 + attempt;
1876+ let source = format!(
1877+ "mandelbrot=size=64x64:start_scale={}:rate=25",
1878+ 5.0 - f64::from(attempt) * 0.06
1879+ );
1880+ let y4m = Command::new("ffmpeg")
1881+ .args([
1882+ "-v", "error", "-f", "lavfi", "-i", &source, "-pix_fmt", "yuv420p", "-t",
1883+ "0.04", "-f", "yuv4mpegpipe", "-",
1884+ ])
1885+ .stdin(Stdio::null())
1886+ .stdout(Stdio::piped())
1887+ .stderr(Stdio::piped())
1888+ .output()
1889+ .expect("ffmpeg failed to run");
1890+ assert!(
1891+ y4m.status.success(),
1892+ "ffmpeg fixture: {}",
1893+ String::from_utf8_lossy(&y4m.stderr)
1894+ );
1895+ let mut child = Command::new(aomenc_path())
1896+ .args([
1897+ "--codec=av1",
1898+ "--passes=1",
1899+ "--end-usage=q",
1900+ "--cq-level=45",
1901+ "--cpu-used=0",
1902+ "--enable-rect-partitions=0",
1903+ "--enable-ab-partitions=0",
1904+ "--enable-1to4-partitions=0",
1905+ "--enable-filter-intra=0",
1906+ "--enable-smooth-intra=1",
1907+ "--enable-paeth-intra=1",
1908+ "--enable-tx-size-search=0",
1909+ "--enable-cdef=0",
1910+ "--enable-restoration=0",
1911+ "--enable-intra-edge-filter=1",
1912+ "--max-partition-size=32",
1913+ // 8x8/leaf8 splits are a separate, already-named refusal.
1914+ "--min-partition-size=16",
1915+ "--enable-palette=0",
1916+ "--enable-intrabc=0",
1917+ "--enable-cfl-intra=0",
1918+ "--enable-ref-frame-mvs=0",
1919+ "--obu",
1920+ "-o",
1921+ "-",
1922+ "-",
1923+ ])
1924+ .stdin(Stdio::piped())
1925+ .stdout(Stdio::piped())
1926+ .stderr(Stdio::piped())
1927+ .spawn()
1928+ .expect("aomenc failed to start");
1929+ child
1930+ .stdin
1931+ .take()
1932+ .expect("aomenc stdin")
1933+ .write_all(&y4m.stdout)
1934+ .expect("writing y4m to aomenc");
1935+ let out = child.wait_with_output().expect("aomenc failed to run");
1936+ assert!(
1937+ out.status.success(),
1938+ "aomenc refused the fixture: {}",
1939+ String::from_utf8_lossy(&out.stderr)
1940+ );
1941+ let stream = out.stdout;
1942+ let smooth_before = decode::smooth_uv_hits();
1943+ let frames = match decode_stream(&stream) {
1944+ Ok(frames) => frames,
1945+ Err(e) => {
1946+ refusals.push(format!("seed {seed}: {e}"));
1947+ continue;
1948+ }
1949+ };
1950+ if decode::smooth_uv_hits() == smooth_before {
1951+ refusals.push(format!(
1952+ "seed {seed}: decoded, but no smooth/paeth uv_mode fired"
1953+ ));
1954+ continue;
1955+ }
1956+ fired_runs += 1;
1957+ let ffmpeg_frames = ffmpeg_decode_sequence(&stream, width, height, 1);
1958+ assert_eq!(
1959+ frames[0].y, ffmpeg_frames[0].y,
1960+ "luma vs ffmpeg (seed {seed})"
1961+ );
1962+ assert_eq!(frames[0].u, ffmpeg_frames[0].u, "U vs ffmpeg (seed {seed})");
1963+ assert_eq!(frames[0].v, ffmpeg_frames[0].v, "V vs ffmpeg (seed {seed})");
1964+ if fired_runs >= 4 {
1965+ return;
1966+ }
1967+ }
1968+ assert!(
1969+ fired_runs > 0,
1970+ "every attempt hit a named refusal or never exercised smooth/paeth chroma:\n{}",
1971+ refusals.join("\n")
1972+ );
1973+ }
1974+
1849 /// The directional-chroma/angle-delta gate: a real aomenc key frame with1975 /// The directional-chroma/angle-delta gate: a real aomenc key frame with
1850 /// `--enable-directional-intra`/`--enable-angle-delta` left ON (the1976 /// `--enable-directional-intra`/`--enable-angle-delta` left ON (the
1851 /// opposite of every sibling recipe's `=0`, which existed specifically to1977 /// opposite of every sibling recipe's `=0`, which existed specifically to