forge
Explore
Log in

Don't you dare go Hollow

wip(av1): smooth-intra gate in progress, committed at the 75-turn cap

Browse files at this commit

7ba8085c8bc1bdeb90c14e11d613e0a2688cad4bAhmet Kaan GümüşParent: f3c639d
Committed verbatim by the orchestrator so the work survives the cap; the gate
compiles but has never been run.
crates/ec-av1/src/stream.rsmodified+140 -0
@@ -1706,6 +1706,146 @@ mod tests {
1706 );1706 );
1707 }1707 }
1708 1708
1709+ /// lane-chroma r2 stage 1: a real aomenc key frame with
1710+ /// `--enable-smooth-intra=1` (opposite of every sibling recipe's `=0`)
1711+ /// and `--enable-paeth-intra=0` -- paeth chroma stays off so the still-
1712+ /// refused smooth/paeth `uv_mode` (round-2, unrelated to this gate) never
1713+ /// fires; smooth *luma* neighbours are exactly what this gate wants to
1714+ /// exercise, proving [`decode::smooth_luma_hits`] actually landed a
1715+ /// directional block next to a smooth-predicted one and decoded
1716+ /// pixel-exact (the [`PlaneBuf::reconstruct`] `smooth_neighbor` fix).
1717+ #[test]
1718+ fn a_real_aomenc_stream_with_smooth_luma_neighbour_decodes_pixel_exact() {
1719+ if !have_ffmpeg() {
1720+ eprintln!(
1721+ "SKIP a_real_aomenc_stream_with_smooth_luma_neighbour_decodes_pixel_exact: no ffmpeg"
1722+ );
1723+ return;
1724+ }
1725+ if !have_aomenc() {
1726+ eprintln!(
1727+ "SKIP a_real_aomenc_stream_with_smooth_luma_neighbour_decodes_pixel_exact: no aomenc at {}",
1728+ aomenc_path().display()
1729+ );
1730+ return;
1731+ }
1732+ let (width, height) = (64usize, 64usize);
1733+ let mut refusals = Vec::new();
1734+ let mut fired_runs = 0u32;
1735+ for attempt in 0..40u32 {
1736+ let seed = 42 + attempt;
1737+ let source = format!(
1738+ "mandelbrot=size=64x64:start_scale={}:rate=25",
1739+ 5.0 - f64::from(attempt) * 0.06
1740+ );
1741+ let y4m = Command::new("ffmpeg")
1742+ .args([
1743+ "-v",
1744+ "error",
1745+ "-f",
1746+ "lavfi",
1747+ "-i",
1748+ &source,
1749+ "-pix_fmt",
1750+ "yuv420p",
1751+ "-t",
1752+ "0.04",
1753+ "-f",
1754+ "yuv4mpegpipe",
1755+ "-",
1756+ ])
1757+ .stdin(Stdio::null())
1758+ .stdout(Stdio::piped())
1759+ .stderr(Stdio::piped())
1760+ .output()
1761+ .expect("ffmpeg failed to run");
1762+ assert!(
1763+ y4m.status.success(),
1764+ "ffmpeg fixture: {}",
1765+ String::from_utf8_lossy(&y4m.stderr)
1766+ );
1767+ let mut child = Command::new(aomenc_path())
1768+ .args([
1769+ "--codec=av1",
1770+ "--passes=1",
1771+ "--end-usage=q",
1772+ "--cq-level=45",
1773+ "--cpu-used=0",
1774+ "--enable-rect-partitions=0",
1775+ "--enable-ab-partitions=0",
1776+ "--enable-1to4-partitions=0",
1777+ "--enable-filter-intra=0",
1778+ "--enable-smooth-intra=1",
1779+ // Smooth/paeth chroma is a still-refused, separate
1780+ // round-2 gap -- off so no attempt trips it while this
1781+ // gate is purely about luma's edge-filter fix.
1782+ "--enable-paeth-intra=0",
1783+ "--enable-tx-size-search=0",
1784+ "--enable-cdef=0",
1785+ "--enable-restoration=0",
1786+ "--enable-intra-edge-filter=1",
1787+ "--max-partition-size=32",
1788+ "--min-partition-size=16",
1789+ "--enable-palette=0",
1790+ "--enable-intrabc=0",
1791+ "--enable-cfl-intra=0",
1792+ "--enable-ref-frame-mvs=0",
1793+ "--obu",
1794+ "-o",
1795+ "-",
1796+ "-",
1797+ ])
1798+ .stdin(Stdio::piped())
1799+ .stdout(Stdio::piped())
1800+ .stderr(Stdio::piped())
1801+ .spawn()
1802+ .expect("aomenc failed to start");
1803+ child
1804+ .stdin
1805+ .take()
1806+ .expect("aomenc stdin")
1807+ .write_all(&y4m.stdout)
1808+ .expect("writing y4m to aomenc");
1809+ let out = child.wait_with_output().expect("aomenc failed to run");
1810+ assert!(
1811+ out.status.success(),
1812+ "aomenc refused the fixture: {}",
1813+ String::from_utf8_lossy(&out.stderr)
1814+ );
1815+ let stream = out.stdout;
1816+ let smooth_before = decode::smooth_luma_hits();
1817+ let frames = match decode_stream(&stream) {
1818+ Ok(frames) => frames,
1819+ Err(e) => {
1820+ refusals.push(format!("seed {seed}: {e}"));
1821+ continue;
1822+ }
1823+ };
1824+ if decode::smooth_luma_hits() == smooth_before {
1825+ refusals.push(format!(
1826+ "seed {seed}: decoded, but no smooth-luma-neighbour block fired"
1827+ ));
1828+ continue;
1829+ }
1830+ fired_runs += 1;
1831+ let ffmpeg_frames = ffmpeg_decode_sequence(&stream, width, height, 1);
1832+ assert_eq!(
1833+ frames[0].y, ffmpeg_frames[0].y,
1834+ "luma vs ffmpeg (seed {seed})"
1835+ );
1836+ assert_eq!(frames[0].u, ffmpeg_frames[0].u, "U vs ffmpeg (seed {seed})");
1837+ assert_eq!(frames[0].v, ffmpeg_frames[0].v, "V vs ffmpeg (seed {seed})");
1838+ if fired_runs >= 4 {
1839+ return;
1840+ }
1841+ }
1842+ assert!(
1843+ fired_runs > 0,
1844+ "every attempt hit a named refusal or never exercised a smooth luma neighbour:\n{}",
1845+ refusals.join("\n")
1846+ );
1847+ }
1848+
1709 /// The directional-chroma/angle-delta gate: a real aomenc key frame with1849 /// The directional-chroma/angle-delta gate: a real aomenc key frame with
1710 /// `--enable-directional-intra`/`--enable-angle-delta` left ON (the1850 /// `--enable-directional-intra`/`--enable-angle-delta` left ON (the
1711 /// opposite of every sibling recipe's `=0`, which existed specifically to1851 /// opposite of every sibling recipe's `=0`, which existed specifically to