forge
Explore
Log in

Don't you dare go Hollow

Interior tile-row boundary gate (four rows), mirroring r7's four-column gate

Browse files at this commit

2451a89d25485f0caee1229348cd68732234b0f0Ahmet Kaan GümüşParent: b6920d4
  • test
    • interior tile-row boundary gate (four rows), mirroring r7's four-column gate
Show full message
test(av1): interior tile-row boundary gate (four rows), mirroring r7's four-column gate

a_real_aomenc_stream_with_four_tile_rows_decodes_pixel_exact --
--tile-rows=2 (TileRows=4), 64x256, loop filter ON, through
decode_stream. Proves an interior row boundary (row 1/2, neither top
nor bottom frame edge) the two-tile-row gate's edge case (row 1 is
also the bottom edge) couldn't exercise, same reason r7 needed 4
columns rather than 2. 20/20 pixel-exact vs ffmpeg, 0 refusals, hard
tile_hits > 2 assert.
crates/ec-av1/src/stream.rsmodified+147 -0
@@ -6736,6 +6736,153 @@ mod tests {
67366736 );
67376737 }
67386738
6739+ /// lane-tiles r8: the tile-*row* analogue of the four-tile-column gate
6740+ /// above -- `--tile-rows=2` gives aomenc `TileRows=4` (log2; uniform
6741+ /// tile spacing is always a power of two, so this is the smallest count
6742+ /// that has an interior row neither the top nor bottom frame edge,
6743+ /// mirroring why the column gate needed 4 columns rather than 3). 64x256
6744+ /// is four 64x64 superblocks tall with `--sb-size=64`, one per tile row.
6745+ /// Loop filter ON, run through `decode_stream` itself since the
6746+ /// `rows > 1` refusal is already lifted by this commit.
6747+ #[test]
6748+ fn a_real_aomenc_stream_with_four_tile_rows_decodes_pixel_exact() {
6749+ const NAME: &str = "a_real_aomenc_stream_with_four_tile_rows_decodes_pixel_exact";
6750+ if !have_ffmpeg() {
6751+ eprintln!("SKIP {NAME}: no ffmpeg");
6752+ return;
6753+ }
6754+ if !have_aomenc() {
6755+ eprintln!("SKIP {NAME}: no aomenc at {}", aomenc_path().display());
6756+ return;
6757+ }
6758+ let (width, height) = (64usize, 256usize);
6759+ let mut matched = 0u32;
6760+ let mut named_refusals = 0u32;
6761+ for attempt in 0..20u32 {
6762+ let seed = 42 + attempt;
6763+ let source = gradients_source(seed, width, height, "duration=0.04:rate=25");
6764+ let y4m = Command::new("ffmpeg")
6765+ .args([
6766+ "-v", "error", "-f", "lavfi", "-i", &source, "-pix_fmt", "yuv420p", "-f",
6767+ "yuv4mpegpipe", "-",
6768+ ])
6769+ .stdin(Stdio::null())
6770+ .stdout(Stdio::piped())
6771+ .stderr(Stdio::piped())
6772+ .output()
6773+ .expect("ffmpeg failed to run");
6774+ assert!(
6775+ y4m.status.success(),
6776+ "ffmpeg fixture: {}",
6777+ String::from_utf8_lossy(&y4m.stderr)
6778+ );
6779+ let mut child = Command::new(aomenc_path())
6780+ .args([
6781+ "--codec=av1",
6782+ "--passes=1",
6783+ "--end-usage=q",
6784+ "--cq-level=45",
6785+ "--cpu-used=0",
6786+ "--limit=1",
6787+ "--kf-max-dist=1000",
6788+ "--threads=1",
6789+ "--row-mt=0",
6790+ "--tile-columns=0",
6791+ "--tile-rows=2",
6792+ "--sb-size=64",
6793+ "--enable-rect-partitions=0",
6794+ "--enable-ab-partitions=0",
6795+ "--enable-1to4-partitions=0",
6796+ "--enable-filter-intra=0",
6797+ "--enable-smooth-intra=0",
6798+ "--enable-paeth-intra=0",
6799+ "--enable-directional-intra=0",
6800+ "--enable-angle-delta=0",
6801+ "--enable-tx-size-search=0",
6802+ "--enable-cdef=0",
6803+ "--enable-restoration=0",
6804+ "--max-partition-size=32",
6805+ "--min-partition-size=32",
6806+ "--enable-palette=0",
6807+ "--enable-intrabc=0",
6808+ "--enable-cfl-intra=0",
6809+ "--obu",
6810+ "-o",
6811+ "-",
6812+ "-",
6813+ ])
6814+ .stdin(Stdio::piped())
6815+ .stdout(Stdio::piped())
6816+ .stderr(Stdio::piped())
6817+ .spawn()
6818+ .expect("aomenc failed to start");
6819+ child
6820+ .stdin
6821+ .take()
6822+ .expect("aomenc stdin")
6823+ .write_all(&y4m.stdout)
6824+ .expect("writing y4m to aomenc");
6825+ let out = child.wait_with_output().expect("aomenc failed to run");
6826+ assert!(
6827+ out.status.success(),
6828+ "aomenc refused the fixture: {}",
6829+ String::from_utf8_lossy(&out.stderr)
6830+ );
6831+ let stream = out.stdout;
6832+
6833+ let mut parser = Av1Parser::new();
6834+ let mut pos = 0usize;
6835+ let mut rows_seen = 0u32;
6836+ while pos < stream.len() {
6837+ let obu = parser.parse_obu(&stream[pos..]).unwrap();
6838+ pos += obu.total_size;
6839+ if let ObuKind::Frame(header, _) = &obu.kind {
6840+ rows_seen = header.tile_info.rows;
6841+ }
6842+ }
6843+ assert!(
6844+ rows_seen > 2,
6845+ "{NAME}: aomenc did not actually split into >2 tile rows (rows={rows_seen}, seed {seed})"
6846+ );
6847+
6848+ let before = crate::decode::tile_hits();
6849+ let pictures = match decode_stream(&stream) {
6850+ Err(e) => {
6851+ let msg = e.to_string();
6852+ assert!(
6853+ msg.contains("unsupported"),
6854+ "{NAME} failed outright, not a named refusal (seed {seed}): {msg}"
6855+ );
6856+ named_refusals += 1;
6857+ eprintln!("seed {seed} refusal: {msg}");
6858+ continue;
6859+ }
6860+ Ok(pictures) => pictures,
6861+ };
6862+ let hits = crate::decode::tile_hits() - before;
6863+ assert!(
6864+ hits > 2,
6865+ "{NAME}: tile_hits delta was {hits}, expected >2 -- all four tile rows must \
6866+ actually decode, not just a subset (seed {seed})"
6867+ );
6868+ assert_eq!(pictures.len(), 1, "{NAME}: expected exactly 1 picture (seed {seed})");
6869+
6870+ let ffmpeg_frames = ffmpeg_decode_sequence(&stream, width, height, 1);
6871+ assert_eq!(pictures[0].y, ffmpeg_frames[0].y, "{NAME}: luma vs ffmpeg (seed {seed})");
6872+ assert_eq!(pictures[0].u, ffmpeg_frames[0].u, "{NAME}: U vs ffmpeg (seed {seed})");
6873+ assert_eq!(pictures[0].v, ffmpeg_frames[0].v, "{NAME}: V vs ffmpeg (seed {seed})");
6874+ matched += 1;
6875+ }
6876+ assert!(
6877+ matched > 0,
6878+ "{NAME}: every attempt refused ({named_refusals} refusals); the gate never decoded \
6879+ a four-tile-row stream"
6880+ );
6881+ eprintln!(
6882+ "{NAME}: {matched} pixel-exact matches, {named_refusals} named refusals out of 20"
6883+ );
6884+ }
6885+
67396886 /// lane-tiles r4/r7: the same real two-tile-column stream as the
67406887 /// bypass gate above, this time run through `decode_stream` itself --
67416888 /// the entry point real callers use. Proves the `cols > 1` refusal is