wip(av1): lane-chroma r3 smooth-intra gate green path + chroma work, committed at the 75-turn cap
Browse files at this commitf4a11cdc7ac6b8c010f3110174713978e5915235Parent: d627fbc2 changed files +202 -23
- crates/ec-av1/src/decode.rs +76 -23
- crates/ec-av1/src/stream.rs +126 -0
crates/ec-av1/src/decode.rsmodified+76 -23
| @@ -81,6 +81,21 @@ pub(crate) fn smooth_luma_hits() -> usize { | ||
| 81 | 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 | 99 | /// How many 4-pixel deblocking edge groups [`edge_params`] has actually |
| 85 | 100 | /// selected for filtering, across every call in the process -- the same |
| 86 | 101 | /// before/after counter pattern as [`FILTER_INTRA_HITS`], proving a stream |
| @@ -1263,6 +1278,17 @@ struct Neighbours { | ||
| 1263 | 1278 | left: Vec<[Neighbour; 3]>, |
| 1264 | 1279 | above_mode: Vec<usize>, |
| 1265 | 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 | 1292 | above_side: Vec<usize>, |
| 1267 | 1293 | left_side: Vec<usize>, |
| 1268 | 1294 | /// The same as `above_side`/`left_side`, but kept at the finer mi (4x4) |
| @@ -1362,6 +1388,8 @@ impl Neighbours { | ||
| 1362 | 1388 | left: vec![[Neighbour::default(); 3]; rows * (SUB / MI)], |
| 1363 | 1389 | above_mode: vec![DC_PRED; cols], |
| 1364 | 1390 | left_mode: vec![DC_PRED; rows], |
| 1391 | + above_uv_mode: vec![DC_PRED; cols], | |
| 1392 | + left_uv_mode: vec![DC_PRED; rows], | |
| 1365 | 1393 | above_side: vec![SB; cols], |
| 1366 | 1394 | left_side: vec![SB; rows], |
| 1367 | 1395 | above_side_mi: vec![SB; cols * (SUB / MI)], |
| @@ -1495,6 +1523,7 @@ impl Neighbours { | ||
| 1495 | 1523 | fn start_row(&mut self) { |
| 1496 | 1524 | self.left.iter_mut().for_each(|l| *l = Default::default()); |
| 1497 | 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 | 1527 | self.left_side.iter_mut().for_each(|s| *s = SB); |
| 1499 | 1528 | self.left_side_mi.iter_mut().for_each(|s| *s = SB); |
| 1500 | 1529 | self.left_skip.iter_mut().for_each(|s| *s = false); |
| @@ -1726,8 +1755,15 @@ impl Neighbours { | ||
| 1726 | 1755 | /// `record` leaves them (spec `av1_set_entropy_contexts`, which clamps to |
| 1727 | 1756 | /// `blocks_wide`/`blocks_high` derived from the true `mi_cols`/`mi_rows`, |
| 1728 | 1757 | /// not from this block's own side). |
| 1729 | - fn record(&mut self, at: (usize, usize), side: usize, mode: usize, grids: &[Vec<i32>; 3]) { | |
| 1730 | - self.record_rect(at, side, side, mode, grids); | |
| 1758 | + fn record( | |
| 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 | 1769 | /// [`Self::record`] with independent above (`w`)/left (`h`) extents, in |
| @@ -1741,15 +1777,18 @@ impl Neighbours { | ||
| 1741 | 1777 | w: usize, |
| 1742 | 1778 | h: usize, |
| 1743 | 1779 | mode: usize, |
| 1780 | + uv_mode: usize, | |
| 1744 | 1781 | grids: &[Vec<i32>; 3], |
| 1745 | 1782 | ) { |
| 1746 | 1783 | let (r, c) = at; |
| 1747 | 1784 | for cell in 0..w / SUB { |
| 1748 | 1785 | self.above_mode[c + cell] = mode; |
| 1786 | + self.above_uv_mode[c + cell] = uv_mode; | |
| 1749 | 1787 | self.above_side[c + cell] = w; |
| 1750 | 1788 | } |
| 1751 | 1789 | for cell in 0..h / SUB { |
| 1752 | 1790 | self.left_mode[r + cell] = mode; |
| 1791 | + self.left_uv_mode[r + cell] = uv_mode; | |
| 1753 | 1792 | self.left_side[r + cell] = h; |
| 1754 | 1793 | } |
| 1755 | 1794 | self.record_mi_rect((r * (SUB / MI), c * (SUB / MI)), w, h, grids); |
| @@ -1848,12 +1887,15 @@ impl Neighbours { | ||
| 1848 | 1887 | at: (usize, usize), |
| 1849 | 1888 | side: usize, |
| 1850 | 1889 | mode: usize, |
| 1890 | + uv_mode: usize, | |
| 1851 | 1891 | chroma_grids: [&[i32]; 2], |
| 1852 | 1892 | ) { |
| 1853 | 1893 | let (r, c) = at; |
| 1854 | 1894 | for cell in 0..side / SUB { |
| 1855 | 1895 | self.above_mode[c + cell] = mode; |
| 1856 | 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 | 1899 | self.above_side[c + cell] = side; |
| 1858 | 1900 | self.left_side[r + cell] = side; |
| 1859 | 1901 | } |
| @@ -1989,7 +2031,7 @@ fn read_intra_mode_rect( | ||
| 1989 | 2031 | None |
| 1990 | 2032 | }; |
| 1991 | 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 | 2036 | let angle_delta_uv = if (V_PRED..=D67_PRED).contains(&uv_mode) { |
| 1995 | 2037 | DIRECTIONAL_UV_HITS.with(|c| c.set(c.get() + 1)); |
| @@ -2112,13 +2154,16 @@ fn decode_block_rect( | ||
| 2112 | 2154 | neighbours.skip_txfm_ctx(r * (SUB / MI), c * (SUB / MI)), |
| 2113 | 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 | 2157 | let smooth_neighbor = |
| 2118 | 2158 | is_smooth_mode(neighbours.above_mode[c]) || is_smooth_mode(neighbours.left_mode[r]); |
| 2119 | 2159 | if smooth_neighbor { |
| 2120 | 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 | 2167 | if filter_intra.is_some() { |
| 2123 | 2168 | // `predict_filter_intra` (spec 7.11.2.3) is square-only in this |
| 2124 | 2169 | // decoder (`assert_eq!(dst.len(), side*side)`) -- a real symbol was |
| @@ -2198,7 +2243,7 @@ fn decode_block_rect( | ||
| 2198 | 2243 | &vec![0i32; chroma_w * chroma_h], |
| 2199 | 2244 | alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)), |
| 2200 | 2245 | None, |
| 2201 | - false, | |
| 2246 | + smooth_neighbor_uv, | |
| 2202 | 2247 | ); |
| 2203 | 2248 | v.reconstruct_rect( |
| 2204 | 2249 | cpx, |
| @@ -2211,13 +2256,14 @@ fn decode_block_rect( | ||
| 2211 | 2256 | &vec![0i32; chroma_w * chroma_h], |
| 2212 | 2257 | alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)), |
| 2213 | 2258 | None, |
| 2214 | - false, | |
| 2259 | + smooth_neighbor_uv, | |
| 2215 | 2260 | ); |
| 2216 | 2261 | neighbours.record_rect( |
| 2217 | 2262 | at, |
| 2218 | 2263 | bw, |
| 2219 | 2264 | bh, |
| 2220 | 2265 | mode, |
| 2266 | + uv_predict_mode, | |
| 2221 | 2267 | &[ |
| 2222 | 2268 | vec![0i32; bw * bh], |
| 2223 | 2269 | vec![0i32; chroma_w * chroma_h], |
| @@ -2344,7 +2390,7 @@ fn decode_block_rect( | ||
| 2344 | 2390 | &u_residual, |
| 2345 | 2391 | alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)), |
| 2346 | 2392 | None, |
| 2347 | - false, | |
| 2393 | + smooth_neighbor_uv, | |
| 2348 | 2394 | ); |
| 2349 | 2395 | let v_default_tx = default_intra_tx_type(uv_predict_mode as u8); |
| 2350 | 2396 | let v_skip_ctx = usize::from(around[2].0) + usize::from(around[2].1); |
| @@ -2382,9 +2428,9 @@ fn decode_block_rect( | ||
| 2382 | 2428 | &v_residual, |
| 2383 | 2429 | alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)), |
| 2384 | 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 | 2434 | RECT_COEFF_HITS.with(|c| c.set(c.get() + 1)); |
| 2389 | 2435 | } |
| 2390 | 2436 | } |
| @@ -2490,7 +2536,7 @@ fn read_intra_mode( | ||
| 2490 | 2536 | // bug in that fallback this lane's own scope does not cover. Keep it |
| 2491 | 2537 | // refused here rather than ship a silently-wrong decode. |
| 2492 | 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 | 2541 | // `get_uv_mode` (spec 9.3): `UV_CFL_PRED` predicts as `DC_PRED` for the |
| 2496 | 2542 | // angle-delta question -- libaom's own `read_intra_frame_mode_info` reads |
| @@ -3032,13 +3078,13 @@ fn decode_block( | ||
| 3032 | 3078 | } else { |
| 3033 | 3079 | 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 | 3081 | let smooth_neighbor = |
| 3038 | 3082 | is_smooth_mode(neighbours.above_mode[c]) || is_smooth_mode(neighbours.left_mode[r]); |
| 3039 | 3083 | if smooth_neighbor { |
| 3040 | 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 | 3088 | if std::env::var_os("EC_AV1_TRACE").is_some() { |
| 3043 | 3089 | eprintln!( |
| 3044 | 3090 | "TRACE block px={px} py={py} side={side} mode={mode} uv_mode={uv_mode} \ |
| @@ -3093,7 +3139,7 @@ fn decode_block( | ||
| 3093 | 3139 | &vec![0i32; chroma_side * chroma_side], |
| 3094 | 3140 | alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)), |
| 3095 | 3141 | None, |
| 3096 | - false, | |
| 3142 | + smooth_neighbor_uv, | |
| 3097 | 3143 | ); |
| 3098 | 3144 | v.reconstruct( |
| 3099 | 3145 | cpx, |
| @@ -3105,12 +3151,12 @@ fn decode_block( | ||
| 3105 | 3151 | &vec![0i32; chroma_side * chroma_side], |
| 3106 | 3152 | alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)), |
| 3107 | 3153 | None, |
| 3108 | - false, | |
| 3154 | + smooth_neighbor_uv, | |
| 3109 | 3155 | ); |
| 3110 | 3156 | let luma_grid = vec![0i32; side * side]; |
| 3111 | 3157 | let u_grid = vec![0i32; chroma_side * chroma_side]; |
| 3112 | 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 | 3160 | } else if !tx_select || logical_tx == side { |
| 3115 | 3161 | // A single luma transform unit -- the old path, unchanged (including |
| 3116 | 3162 | // the 64x64 corner case, `logical_tx == side == 64` with |
| @@ -3159,7 +3205,7 @@ fn decode_block( | ||
| 3159 | 3205 | alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)), |
| 3160 | 3206 | None, |
| 3161 | 3207 | None, |
| 3162 | - false, | |
| 3208 | + smooth_neighbor_uv, | |
| 3163 | 3209 | )?; |
| 3164 | 3210 | if std::env::var_os("EC_AV1_TRACE").is_some() { |
| 3165 | 3211 | eprintln!( |
| @@ -3187,9 +3233,9 @@ fn decode_block( | ||
| 3187 | 3233 | alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)), |
| 3188 | 3234 | None, |
| 3189 | 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 | 3239 | } else { |
| 3194 | 3240 | // Several luma transform units, raster order (spec |
| 3195 | 3241 | // `transform_block`'s loop): the block's resolved transform is |
| @@ -3268,7 +3314,7 @@ fn decode_block( | ||
| 3268 | 3314 | alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)), |
| 3269 | 3315 | None, |
| 3270 | 3316 | None, |
| 3271 | - false, | |
| 3317 | + smooth_neighbor_uv, | |
| 3272 | 3318 | )?; |
| 3273 | 3319 | let v_grid = read_plane( |
| 3274 | 3320 | dec, |
| @@ -3290,9 +3336,9 @@ fn decode_block( | ||
| 3290 | 3336 | alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)), |
| 3291 | 3337 | None, |
| 3292 | 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 | 3343 | neighbours.fill_skip_grid((r * (SUB / MI), c * (SUB / MI)), side / MI, skip); |
| 3298 | 3344 | neighbours.fill_lf_grid( |
| @@ -8029,7 +8075,14 @@ fn decode_inter_block( | ||
| 8029 | 8075 | 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 | 8086 | neighbours.record_inter_rect( |
| 8034 | 8087 | at, |
| 8035 | 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 | 1975 | /// The directional-chroma/angle-delta gate: a real aomenc key frame with |
| 1850 | 1976 | /// `--enable-directional-intra`/`--enable-angle-delta` left ON (the |
| 1851 | 1977 | /// opposite of every sibling recipe's `=0`, which existed specifically to |