forge
Explore
Log in

Don't you dare go Hollow

Lift the tile-rows refusal, gated through decode_stream

Browse files at this commit

b6920d42999c4c1233313ecc9ee4cac0046a6f4fAhmet Kaan GümüşParent: b50bec7
  • feat
    • lift the tile-rows refusal, gated through decode_stream
Show full message
feat(av1): lift the tile-rows refusal, gated through decode_stream

Same order as r7's column lift: the r8-stage-1 bypass gate proved the
underlying per-tile row decode + row deblocking correct (20/20, loop
filter ON), so this commit lifts decode_stream's tile_info.rows > 1
refusal and adds
a_real_aomenc_stream_with_two_tile_rows_decodes_through_decode_stream
to re-prove it through the real entry point (20/20 pixel-exact, 0
refusals, hard tile_hits > 1 assert). refusal_inventory.rs's pinned
list drops the matching string in the same commit so
capability_claims_are_declared_not_scattered and
the_decode_path_refuses_exactly_the_listed_cases stay in sync with the
live refusal set.

Tile columns (any count) and tile rows (2, proven) are no longer
capped; only non-uniform tile spacing, several tile-group OBUs per
frame, and context_update_tile_id != 0 stay refused.
crates/ec-av1/src/refusal_inventory.rsmodified+0 -1
@@ -52,7 +52,6 @@ const REFUSALS: &[&str] = &[
52 "a frame naming primary_ref_frame at a reference slot with no saved CDF state",52 "a frame naming primary_ref_frame at a reference slot with no saved CDF state",
53 "a frame with delta_q_present or delta_lf_present set (this decoder never reads the per-superblock delta symbols)",53 "a frame with delta_q_present or delta_lf_present set (this decoder never reads the per-superblock delta symbols)",
54 "a frame with loop restoration enabled (this decoder never reads the per-unit lr symbols)",54 "a frame with loop restoration enabled (this decoder never reads the per-unit lr symbols)",
55- "a frame with more than one tile row (only tile columns are proven pixel-exact so far)",
56 "a frame with no mode-info grid",55 "a frame with no mode-info grid",
57 "a frame with segmentation enabled (this decoder never reads a per-block segment_id symbol)",56 "a frame with segmentation enabled (this decoder never reads a per-block segment_id symbol)",
58 "a non-skip rectangular (HORZ/VERT/HORZ_B) strip needs rectangular residual coding",57 "a non-skip rectangular (HORZ/VERT/HORZ_B) strip needs rectangular residual coding",
crates/ec-av1/src/stream.rsmodified+142 -16
@@ -307,26 +307,23 @@ pub fn decode_stream(data: &[u8]) -> Result<Vec<Picture>> {
307 // naming a different tile there is refused rather than silently307 // naming a different tile there is refused rather than silently
308 // forwarding the wrong tile's table.308 // forwarding the wrong tile's table.
309 //309 //
310- // lane-tiles r4/r6/r7: the multi-tile refusal itself is scoped, not310+ // lane-tiles r4/r6/r7/r8: the multi-tile refusal itself is scoped,
311- // blanket. `decode_key_frame_tile_with_cdfs` and (r6)311+ // not blanket. `decode_key_frame_tile_with_cdfs` and (r6)
312 // `decode_inter_frame_tile_with_cdfs` both genuinely loop every312 // `decode_inter_frame_tile_with_cdfs` both genuinely loop every
313 // tile, `mvstack.rs`'s `MiGrid` is bounded per tile313 // tile, `mvstack.rs`'s `MiGrid` is bounded per tile
314 // (`MiGrid::set_tile_bounds`), and `PlaneBuf`'s `tile_x0/y0/x1/y1`314 // (`MiGrid::set_tile_bounds`), and `PlaneBuf`'s `tile_x0/y0/x1/y1`
315 // origin receives real values at every call site (r6's315 // origin receives real values at every call site (r6's
316- // `set_tile_origin` sweep). r7 proved the two remaining named gaps316+ // `set_tile_origin` sweep). r7 proved the two remaining
317- // both closed: `a_real_aomenc_stream_with_two_tile_columns_and_an_317+ // tile-*column* gaps closed (inter frames, >2 columns with loop
318- // inter_frame_decodes_pixel_exact` (inter frame, 2 tile columns) and318+ // filtering on). r8 proved tile *rows* the same way: the per-tile
319- // `a_real_aomenc_stream_with_four_tile_columns_decodes_pixel_exact`319+ // loop's row math (`tile_num / tile_info.cols`,
320- // (>2 columns AND loop filtering ON, an interior tile boundary) --320+ // `mi_row_starts`/`set_tile_origin`'s `y0`/`y1`) is exactly
321- // 20/20 pixel-exact each. Only tile *rows* stay unproven and321+ // symmetric with the column path already proven, and
322- // refused; tile *columns* (any count) and loop filtering across322+ // `a_real_aomenc_stream_with_two_tile_rows_decodes_pixel_exact`
323- // them are no longer capped.323+ // (bypass gate, loop filter ON) confirmed it: 20/20 pixel-exact.
324- if header.tile_info.rows > 1 {324+ // `a_real_aomenc_stream_with_two_tile_rows_decodes_through_decode_
325- return Err(Error::unsupported(325+ // stream` below re-proves it through this entry point. Tile columns
326- "AV1 decode_stream",326+ // and tile rows (any count, loop filter on) are no longer capped.
327- "a frame with more than one tile row (only tile columns are proven pixel-exact so far)",
328- ));
329- }
330 // `Tile::offset` is relative to the buffer `parse_obu` was handed327 // `Tile::offset` is relative to the buffer `parse_obu` was handed
331 // (`&data[pos..]` at the time this OBU was parsed), so it is relative328 // (`&data[pos..]` at the time this OBU was parsed), so it is relative
332 // to `obu_offset`, not to `data` as a whole.329 // to `obu_offset`, not to `data` as a whole.
@@ -6426,6 +6423,135 @@ mod tests {
6426 );6423 );
6427 }6424 }
6428 6425
6426+ /// lane-tiles r8 stage 2/3: the same two-tile-row stream as the bypass
6427+ /// gate above, this time through `decode_stream` itself -- the entry
6428+ /// point real callers use, with the `rows > 1` refusal lifted (same
6429+ /// commit) so this actually reaches the tile decode instead of
6430+ /// refusing by name. Loop filter ON, no `--loopfilter-control=0`.
6431+ #[test]
6432+ fn a_real_aomenc_stream_with_two_tile_rows_decodes_through_decode_stream() {
6433+ const NAME: &str = "a_real_aomenc_stream_with_two_tile_rows_decodes_through_decode_stream";
6434+ if !have_ffmpeg() {
6435+ eprintln!("SKIP {NAME}: no ffmpeg");
6436+ return;
6437+ }
6438+ if !have_aomenc() {
6439+ eprintln!("SKIP {NAME}: no aomenc at {}", aomenc_path().display());
6440+ return;
6441+ }
6442+ let (width, height) = (64usize, 128usize);
6443+ let mut matched = 0u32;
6444+ let mut named_refusals = 0u32;
6445+ for attempt in 0..20u32 {
6446+ let seed = 42 + attempt;
6447+ let source = gradients_source(seed, width, height, "duration=0.04:rate=25");
6448+ let y4m = Command::new("ffmpeg")
6449+ .args([
6450+ "-v", "error", "-f", "lavfi", "-i", &source, "-pix_fmt", "yuv420p", "-f",
6451+ "yuv4mpegpipe", "-",
6452+ ])
6453+ .stdin(Stdio::null())
6454+ .stdout(Stdio::piped())
6455+ .stderr(Stdio::piped())
6456+ .output()
6457+ .expect("ffmpeg failed to run");
6458+ assert!(
6459+ y4m.status.success(),
6460+ "ffmpeg fixture: {}",
6461+ String::from_utf8_lossy(&y4m.stderr)
6462+ );
6463+ let mut child = Command::new(aomenc_path())
6464+ .args([
6465+ "--codec=av1",
6466+ "--passes=1",
6467+ "--end-usage=q",
6468+ "--cq-level=45",
6469+ "--cpu-used=0",
6470+ "--limit=1",
6471+ "--kf-max-dist=1000",
6472+ "--threads=1",
6473+ "--row-mt=0",
6474+ "--tile-columns=0",
6475+ "--tile-rows=1",
6476+ "--sb-size=64",
6477+ "--enable-rect-partitions=0",
6478+ "--enable-ab-partitions=0",
6479+ "--enable-1to4-partitions=0",
6480+ "--enable-filter-intra=0",
6481+ "--enable-smooth-intra=0",
6482+ "--enable-paeth-intra=0",
6483+ "--enable-directional-intra=0",
6484+ "--enable-angle-delta=0",
6485+ "--enable-tx-size-search=0",
6486+ "--enable-cdef=0",
6487+ "--enable-restoration=0",
6488+ "--max-partition-size=32",
6489+ "--min-partition-size=32",
6490+ "--enable-palette=0",
6491+ "--enable-intrabc=0",
6492+ "--enable-cfl-intra=0",
6493+ "--obu",
6494+ "-o",
6495+ "-",
6496+ "-",
6497+ ])
6498+ .stdin(Stdio::piped())
6499+ .stdout(Stdio::piped())
6500+ .stderr(Stdio::piped())
6501+ .spawn()
6502+ .expect("aomenc failed to start");
6503+ child
6504+ .stdin
6505+ .take()
6506+ .expect("aomenc stdin")
6507+ .write_all(&y4m.stdout)
6508+ .expect("writing y4m to aomenc");
6509+ let out = child.wait_with_output().expect("aomenc failed to run");
6510+ assert!(
6511+ out.status.success(),
6512+ "aomenc refused the fixture: {}",
6513+ String::from_utf8_lossy(&out.stderr)
6514+ );
6515+ let stream = out.stdout;
6516+
6517+ let before = crate::decode::tile_hits();
6518+ let pictures = match decode_stream(&stream) {
6519+ Err(e) => {
6520+ let msg = e.to_string();
6521+ assert!(
6522+ msg.contains("unsupported"),
6523+ "{NAME} failed outright, not a named refusal (seed {seed}): {msg}"
6524+ );
6525+ named_refusals += 1;
6526+ eprintln!("seed {seed} refusal: {msg}");
6527+ continue;
6528+ }
6529+ Ok(pictures) => pictures,
6530+ };
6531+ let hits = crate::decode::tile_hits() - before;
6532+ assert!(
6533+ hits > 1,
6534+ "{NAME}: tile_hits delta was {hits}, expected >1 -- both tile rows must actually \
6535+ decode, not just tile 0 (seed {seed})"
6536+ );
6537+ assert_eq!(pictures.len(), 1, "{NAME}: expected exactly 1 picture (seed {seed})");
6538+
6539+ let ffmpeg_frames = ffmpeg_decode_sequence(&stream, width, height, 1);
6540+ assert_eq!(pictures[0].y, ffmpeg_frames[0].y, "{NAME}: luma vs ffmpeg (seed {seed})");
6541+ assert_eq!(pictures[0].u, ffmpeg_frames[0].u, "{NAME}: U vs ffmpeg (seed {seed})");
6542+ assert_eq!(pictures[0].v, ffmpeg_frames[0].v, "{NAME}: V vs ffmpeg (seed {seed})");
6543+ matched += 1;
6544+ }
6545+ assert!(
6546+ matched > 0,
6547+ "{NAME}: every attempt refused ({named_refusals} refusals); decode_stream never \
6548+ decoded a two-tile-row stream"
6549+ );
6550+ eprintln!(
6551+ "{NAME}: {matched} pixel-exact matches, {named_refusals} named refusals out of 20"
6552+ );
6553+ }
6554+
6429 /// lane-tiles r7: the `>2 tile columns` refusal's own capability, proven6555 /// lane-tiles r7: the `>2 tile columns` refusal's own capability, proven
6430 /// separately from the 2-column gate above -- `--tile-columns=2` gives6556 /// separately from the 2-column gate above -- `--tile-columns=2` gives
6431 /// aomenc `TileCols=4` (log2), a real non-last-column right-edge case the6557 /// aomenc `TileCols=4` (log2), a real non-last-column right-edge case the