Witness gate for the small-side GLOBALMV and rect warp-reach paths, and 7 gate helpers that deadlocked ffmpeg
Browse files at this commit2696d8897537c65d7efaa738b2667d6c79a79905Parent: 00aa449- test
- witness gate for the small-side GLOBALMV and rect warp-reach paths, and 7 gate helpers that deadlocked ffmpeg
6 changed files +284 -43
- crates/ec-av1/fixtures/gm_small_side_witness.obu +0 -0
- crates/ec-av1/src/decode.rs +26 -12
- crates/ec-av1/src/encode.rs +26 -12
- crates/ec-av1/src/stream.rs +107 -13
- crates/ec-av1/src/tile.rs +13 -6
- lanes/t900-r10.report.md +112 -0
crates/ec-av1/fixtures/gm_small_side_witness.obuadded+0 -0
Binary file changed
crates/ec-av1/src/decode.rsmodified+26 -12
| @@ -30423,13 +30423,20 @@ mod tests { | |||
| 30423 | .stderr(Stdio::piped()) | 30423 | .stderr(Stdio::piped()) |
| 30424 | .spawn() | 30424 | .spawn() |
| 30425 | .expect("ffmpeg failed to start"); | 30425 | .expect("ffmpeg failed to start"); |
| 30426 | - child | 30426 | + // lane-t900 r10: the stream goes down stdin on ITS OWN THREAD. Writing |
| 30427 | - .stdin | 30427 | + // it inline deadlocks the moment ffmpeg's stdout pipe buffer (64 KiB) |
| 30428 | - .take() | 30428 | + // fills before the last input byte is written -- which is exactly what |
| 30429 | - .expect("ffmpeg stdin") | 30429 | + // a 1.1 MB fixture decoding to 150 MB of raw 10-bit frames does |
| 30430 | - .write_all(stream) | 30430 | + // (measured: 45 min, both processes at 0% CPU). A write error here is |
| 30431 | - .expect("writing the stream to ffmpeg"); | 30431 | + // swallowed on purpose: ffmpeg's own exit status and stderr, asserted |
| 30432 | + // below, are the real diagnosis. | ||
| 30433 | + let mut stdin = child.stdin.take().expect("ffmpeg stdin"); | ||
| 30434 | + let payload = stream.to_vec(); | ||
| 30435 | + let writer = std::thread::spawn(move || { | ||
| 30436 | + let _ = stdin.write_all(&payload); | ||
| 30437 | + }); | ||
| 30432 | let out = child.wait_with_output().expect("ffmpeg failed to run"); | 30438 | let out = child.wait_with_output().expect("ffmpeg failed to run"); |
| 30439 | + writer.join().expect("ffmpeg stdin writer thread"); | ||
| 30433 | assert!( | 30440 | assert!( |
| 30434 | out.status.success(), | 30441 | out.status.success(), |
| 30435 | "ffmpeg refused the stream: {}", | 30442 | "ffmpeg refused the stream: {}", |
| @@ -30466,13 +30473,20 @@ mod tests { | |||
| 30466 | .stderr(Stdio::piped()) | 30473 | .stderr(Stdio::piped()) |
| 30467 | .spawn() | 30474 | .spawn() |
| 30468 | .expect("ffmpeg failed to start"); | 30475 | .expect("ffmpeg failed to start"); |
| 30469 | - child | 30476 | + // lane-t900 r10: the stream goes down stdin on ITS OWN THREAD. Writing |
| 30470 | - .stdin | 30477 | + // it inline deadlocks the moment ffmpeg's stdout pipe buffer (64 KiB) |
| 30471 | - .take() | 30478 | + // fills before the last input byte is written -- which is exactly what |
| 30472 | - .expect("ffmpeg stdin") | 30479 | + // a 1.1 MB fixture decoding to 150 MB of raw 10-bit frames does |
| 30473 | - .write_all(stream) | 30480 | + // (measured: 45 min, both processes at 0% CPU). A write error here is |
| 30474 | - .expect("writing the stream to ffmpeg"); | 30481 | + // swallowed on purpose: ffmpeg's own exit status and stderr, asserted |
| 30482 | + // below, are the real diagnosis. | ||
| 30483 | + let mut stdin = child.stdin.take().expect("ffmpeg stdin"); | ||
| 30484 | + let payload = stream.to_vec(); | ||
| 30485 | + let writer = std::thread::spawn(move || { | ||
| 30486 | + let _ = stdin.write_all(&payload); | ||
| 30487 | + }); | ||
| 30475 | let out = child.wait_with_output().expect("ffmpeg failed to run"); | 30488 | let out = child.wait_with_output().expect("ffmpeg failed to run"); |
| 30489 | + writer.join().expect("ffmpeg stdin writer thread"); | ||
| 30476 | assert!( | 30490 | assert!( |
| 30477 | out.status.success(), | 30491 | out.status.success(), |
| 30478 | "ffmpeg refused the stream: {}", | 30492 | "ffmpeg refused the stream: {}", |
crates/ec-av1/src/encode.rsmodified+26 -12
| @@ -3566,13 +3566,20 @@ mod tests { | |||
| 3566 | .stderr(Stdio::piped()) | 3566 | .stderr(Stdio::piped()) |
| 3567 | .spawn() | 3567 | .spawn() |
| 3568 | .expect("ffmpeg failed to start"); | 3568 | .expect("ffmpeg failed to start"); |
| 3569 | - child | 3569 | + // lane-t900 r10: the stream goes down stdin on ITS OWN THREAD. Writing |
| 3570 | - .stdin | 3570 | + // it inline deadlocks the moment ffmpeg's stdout pipe buffer (64 KiB) |
| 3571 | - .take() | 3571 | + // fills before the last input byte is written -- which is exactly what |
| 3572 | - .expect("ffmpeg stdin") | 3572 | + // a 1.1 MB fixture decoding to 150 MB of raw 10-bit frames does |
| 3573 | - .write_all(stream) | 3573 | + // (measured: 45 min, both processes at 0% CPU). A write error here is |
| 3574 | - .expect("writing the stream to ffmpeg"); | 3574 | + // swallowed on purpose: ffmpeg's own exit status and stderr, asserted |
| 3575 | + // below, are the real diagnosis. | ||
| 3576 | + let mut stdin = child.stdin.take().expect("ffmpeg stdin"); | ||
| 3577 | + let payload = stream.to_vec(); | ||
| 3578 | + let writer = std::thread::spawn(move || { | ||
| 3579 | + let _ = stdin.write_all(&payload); | ||
| 3580 | + }); | ||
| 3575 | let out = child.wait_with_output().expect("ffmpeg failed to run"); | 3581 | let out = child.wait_with_output().expect("ffmpeg failed to run"); |
| 3582 | + writer.join().expect("ffmpeg stdin writer thread"); | ||
| 3576 | assert!( | 3583 | assert!( |
| 3577 | out.status.success(), | 3584 | out.status.success(), |
| 3578 | "ffmpeg refused the stream: {}", | 3585 | "ffmpeg refused the stream: {}", |
| @@ -5008,13 +5015,20 @@ mod tests { | |||
| 5008 | .stderr(Stdio::piped()) | 5015 | .stderr(Stdio::piped()) |
| 5009 | .spawn() | 5016 | .spawn() |
| 5010 | .expect("ffmpeg failed to start"); | 5017 | .expect("ffmpeg failed to start"); |
| 5011 | - child | 5018 | + // lane-t900 r10: the stream goes down stdin on ITS OWN THREAD. Writing |
| 5012 | - .stdin | 5019 | + // it inline deadlocks the moment ffmpeg's stdout pipe buffer (64 KiB) |
| 5013 | - .take() | 5020 | + // fills before the last input byte is written -- which is exactly what |
| 5014 | - .expect("ffmpeg stdin") | 5021 | + // a 1.1 MB fixture decoding to 150 MB of raw 10-bit frames does |
| 5015 | - .write_all(stream) | 5022 | + // (measured: 45 min, both processes at 0% CPU). A write error here is |
| 5016 | - .expect("writing the stream to ffmpeg"); | 5023 | + // swallowed on purpose: ffmpeg's own exit status and stderr, asserted |
| 5024 | + // below, are the real diagnosis. | ||
| 5025 | + let mut stdin = child.stdin.take().expect("ffmpeg stdin"); | ||
| 5026 | + let payload = stream.to_vec(); | ||
| 5027 | + let writer = std::thread::spawn(move || { | ||
| 5028 | + let _ = stdin.write_all(&payload); | ||
| 5029 | + }); | ||
| 5017 | let out = child.wait_with_output().expect("ffmpeg failed to run"); | 5030 | let out = child.wait_with_output().expect("ffmpeg failed to run"); |
| 5031 | + writer.join().expect("ffmpeg stdin writer thread"); | ||
| 5018 | assert!( | 5032 | assert!( |
| 5019 | out.status.success(), | 5033 | out.status.success(), |
| 5020 | "ffmpeg refused the stream: {}", | 5034 | "ffmpeg refused the stream: {}", |
crates/ec-av1/src/stream.rsmodified+107 -13
| @@ -1565,13 +1565,20 @@ mod tests { | |||
| 1565 | .stderr(Stdio::piped()) | 1565 | .stderr(Stdio::piped()) |
| 1566 | .spawn() | 1566 | .spawn() |
| 1567 | .expect("ffmpeg failed to start"); | 1567 | .expect("ffmpeg failed to start"); |
| 1568 | - child | 1568 | + // lane-t900 r10: the stream goes down stdin on ITS OWN THREAD. Writing |
| 1569 | - .stdin | 1569 | + // it inline deadlocks the moment ffmpeg's stdout pipe buffer (64 KiB) |
| 1570 | - .take() | 1570 | + // fills before the last input byte is written -- which is exactly what |
| 1571 | - .expect("ffmpeg stdin") | 1571 | + // a 1.1 MB fixture decoding to 150 MB of raw 10-bit frames does |
| 1572 | - .write_all(stream) | 1572 | + // (measured: 45 min, both processes at 0% CPU). A write error here is |
| 1573 | - .expect("writing the stream to ffmpeg"); | 1573 | + // swallowed on purpose: ffmpeg's own exit status and stderr, asserted |
| 1574 | + // below, are the real diagnosis. | ||
| 1575 | + let mut stdin = child.stdin.take().expect("ffmpeg stdin"); | ||
| 1576 | + let payload = stream.to_vec(); | ||
| 1577 | + let writer = std::thread::spawn(move || { | ||
| 1578 | + let _ = stdin.write_all(&payload); | ||
| 1579 | + }); | ||
| 1574 | let out = child.wait_with_output().expect("ffmpeg failed to run"); | 1580 | let out = child.wait_with_output().expect("ffmpeg failed to run"); |
| 1581 | + writer.join().expect("ffmpeg stdin writer thread"); | ||
| 1575 | assert!( | 1582 | assert!( |
| 1576 | out.status.success(), | 1583 | out.status.success(), |
| 1577 | "ffmpeg refused the stream: {}", | 1584 | "ffmpeg refused the stream: {}", |
| @@ -1620,13 +1627,20 @@ mod tests { | |||
| 1620 | .stderr(Stdio::piped()) | 1627 | .stderr(Stdio::piped()) |
| 1621 | .spawn() | 1628 | .spawn() |
| 1622 | .expect("ffmpeg failed to start"); | 1629 | .expect("ffmpeg failed to start"); |
| 1623 | - child | 1630 | + // lane-t900 r10: the stream goes down stdin on ITS OWN THREAD. Writing |
| 1624 | - .stdin | 1631 | + // it inline deadlocks the moment ffmpeg's stdout pipe buffer (64 KiB) |
| 1625 | - .take() | 1632 | + // fills before the last input byte is written -- which is exactly what |
| 1626 | - .expect("ffmpeg stdin") | 1633 | + // a 1.1 MB fixture decoding to 150 MB of raw 10-bit frames does |
| 1627 | - .write_all(stream) | 1634 | + // (measured: 45 min, both processes at 0% CPU). A write error here is |
| 1628 | - .expect("writing the stream to ffmpeg"); | 1635 | + // swallowed on purpose: ffmpeg's own exit status and stderr, asserted |
| 1636 | + // below, are the real diagnosis. | ||
| 1637 | + let mut stdin = child.stdin.take().expect("ffmpeg stdin"); | ||
| 1638 | + let payload = stream.to_vec(); | ||
| 1639 | + let writer = std::thread::spawn(move || { | ||
| 1640 | + let _ = stdin.write_all(&payload); | ||
| 1641 | + }); | ||
| 1629 | let out = child.wait_with_output().expect("ffmpeg failed to run"); | 1642 | let out = child.wait_with_output().expect("ffmpeg failed to run"); |
| 1643 | + writer.join().expect("ffmpeg stdin writer thread"); | ||
| 1630 | assert!( | 1644 | assert!( |
| 1631 | out.status.success(), | 1645 | out.status.success(), |
| 1632 | "ffmpeg refused the stream: {}", | 1646 | "ffmpeg refused the stream: {}", |
| @@ -30455,6 +30469,8 @@ mod tests { | |||
| 30455 | // lane-t900 r8: the intra edge-filter type an INTER neighbour keeps | 30469 | // lane-t900 r8: the intra edge-filter type an INTER neighbour keeps |
| 30456 | // non-smooth (the coarse SUB band still holds an older SMOOTH mode). | 30470 | // non-smooth (the coarse SUB band still holds an older SMOOTH mode). |
| 30457 | let notsmooth_before = crate::decode::inter_neighbour_not_smooth_hits(); | 30471 | let notsmooth_before = crate::decode::inter_neighbour_not_smooth_hits(); |
| 30472 | + // lane-t900 r10: the rect warp top-right reach (600 blocks here). | ||
| 30473 | + let tr_before = crate::decode::tr_reach_longer_side_hits(); | ||
| 30458 | let i16_before = crate::decode::intra16x4_in_inter_hits(); | 30474 | let i16_before = crate::decode::intra16x4_in_inter_hits(); |
| 30459 | let frames = match decode_stream(&stream) { | 30475 | let frames = match decode_stream(&stream) { |
| 30460 | Ok(frames) => frames, | 30476 | Ok(frames) => frames, |
| @@ -30471,6 +30487,7 @@ mod tests { | |||
| 30471 | ); | 30487 | ); |
| 30472 | let sub8tx = crate::decode::sub8_chroma_tx_from_ref_hits() - sub8tx_before; | 30488 | let sub8tx = crate::decode::sub8_chroma_tx_from_ref_hits() - sub8tx_before; |
| 30473 | let notsmooth = crate::decode::inter_neighbour_not_smooth_hits() - notsmooth_before; | 30489 | let notsmooth = crate::decode::inter_neighbour_not_smooth_hits() - notsmooth_before; |
| 30490 | + let tr = crate::decode::tr_reach_longer_side_hits() - tr_before; | ||
| 30474 | let i16_now = crate::decode::intra16x4_in_inter_hits(); | 30491 | let i16_now = crate::decode::intra16x4_in_inter_hits(); |
| 30475 | let i16 = ( | 30492 | let i16 = ( |
| 30476 | i16_now.0 - i16_before.0, | 30493 | i16_now.0 - i16_before.0, |
| @@ -30490,6 +30507,7 @@ mod tests { | |||
| 30490 | ("intra16x4_in_inter chroma_ref", i16.2), | 30507 | ("intra16x4_in_inter chroma_ref", i16.2), |
| 30491 | ("sub8_chroma_tx_from_ref", sub8tx), | 30508 | ("sub8_chroma_tx_from_ref", sub8tx), |
| 30492 | ("inter_neighbour_not_smooth", notsmooth), | 30509 | ("inter_neighbour_not_smooth", notsmooth), |
| 30510 | + ("tr_reach_longer_side", tr), | ||
| 30493 | ] { | 30511 | ] { |
| 30494 | assert!( | 30512 | assert!( |
| 30495 | n > 0, | 30513 | n > 0, |
| @@ -30515,11 +30533,87 @@ mod tests { | |||
| 30515 | "{NAME}: 15 shown frames pixel-exact on every plane; warp_plane_suppress={} \ | 30533 | "{NAME}: 15 shown frames pixel-exact on every plane; warp_plane_suppress={} \ |
| 30516 | cdef_idx={} inter_sb128_vert={} interintra_rect={} non_chroma_ref_ctx_skip={} \ | 30534 | cdef_idx={} inter_sb128_vert={} interintra_rect={} non_chroma_ref_ctx_skip={} \ |
| 30517 | intra_in_inter_txctx={} edge_filter_mi_fix={} intra16x4_in_inter={:?} \ | 30535 | intra_in_inter_txctx={} edge_filter_mi_fix={} intra16x4_in_inter={:?} \ |
| 30518 | - sub8_chroma_tx_from_ref={sub8tx} inter_neighbour_not_smooth={notsmooth}", | 30536 | + sub8_chroma_tx_from_ref={sub8tx} inter_neighbour_not_smooth={notsmooth} \ |
| 30537 | + tr_reach_longer_side={tr}", | ||
| 30519 | fired.0, fired.1, fired.2, fired.3, fired.4, fired.5, fired.6, i16 | 30538 | fired.0, fired.1, fired.2, fired.3, fired.4, fired.5, fired.6, i16 |
| 30520 | ); | 30539 | ); |
| 30521 | } | 30540 | } |
| 30522 | 30541 | ||
| 30542 | + /// lane-t900 r10: the small-side GLOBALMV / rect warp-reach witness. | ||
| 30543 | + /// `crates/ec-av1/fixtures/gm_small_side_witness.obu`, 1158066 bytes, | ||
| 30544 | + /// sha256 `f1cdbcbb8d6d469c7957d70252ab42b24ab75f48a717600ffa25991458775dca`: | ||
| 30545 | + /// the first 50 frame-carrying OBUs of a 2 s cut taken 5400 s into a 10-bit | ||
| 30546 | + /// 1920x792 AV1 stream with `use_128x128_superblock=1` -- 34 decode-order | ||
| 30547 | + /// frames, 33 shown, every ARF in it coded with `allow_warped_motion=1`. | ||
| 30548 | + /// Truncated twice independently from the same source, both cuts hash | ||
| 30549 | + /// identically. All 34 DECODE-order frames (the hidden ARF included) were | ||
| 30550 | + /// compared byte-exact against instrumented aomdec with `EC_AV1_FINAL_DUMP` | ||
| 30551 | + /// -- see the lane report's EVIDENCE line; the gate itself compares the 33 | ||
| 30552 | + /// shown frames on every plane, which is all ffmpeg hands back. | ||
| 30553 | + /// | ||
| 30554 | + /// It is the only stream in this repository that fires BOTH r9/r10 paths: | ||
| 30555 | + /// | ||
| 30556 | + /// * `gm_nontrans_small_side_hits` -- libaom `is_nontrans_global_motion` | ||
| 30557 | + /// returns 0 at `AOMMIN(mi_size_wide, mi_size_high) < 2` BEFORE it looks | ||
| 30558 | + /// at any warp model, so a GLOBALMV block with a 4-px side still reads | ||
| 30559 | + /// its interp filter. We suppressed that symbol before r9. | ||
| 30560 | + /// * `tr_reach_longer_side_hits` -- `av1_findSamples` probes the top-right | ||
| 30561 | + /// warp sample at `AOMMAX(xd->width, xd->height)` (mvref_common.c:1235) | ||
| 30562 | + /// with libaom's two rect shape refinements | ||
| 30563 | + /// (`is_last_vertical_rect` / `is_first_horizontal_rect`, | ||
| 30564 | + /// av1_common_int.h:1419-1428) applied; probing at the block's WIDTH | ||
| 30565 | + /// instead picks the 3-symbol `motion_mode` alphabet where libaom reads | ||
| 30566 | + /// the 2-symbol `obmc` one -- same value, different narrowing. | ||
| 30567 | + #[test] | ||
| 30568 | + fn a_10bit_film_frames_with_small_side_globalmv_and_rect_warp_reach_decode_pixel_exact() { | ||
| 30569 | + const NAME: &str = | ||
| 30570 | + "a_10bit_film_frames_with_small_side_globalmv_and_rect_warp_reach_decode_pixel_exact"; | ||
| 30571 | + if !have_ffmpeg() { | ||
| 30572 | + eprintln!("SKIP {NAME}: no ffmpeg"); | ||
| 30573 | + return; | ||
| 30574 | + } | ||
| 30575 | + let path = std::path::Path::new(env!("CARGO_MANIFEST_DIR")) | ||
| 30576 | + .join("fixtures/gm_small_side_witness.obu"); | ||
| 30577 | + let stream = std::fs::read(&path) | ||
| 30578 | + .unwrap_or_else(|e| panic!("{NAME}: reading {}: {e}", path.display())); | ||
| 30579 | + let (width, height) = (1920usize, 792usize); | ||
| 30580 | + let gm_before = crate::decode::gm_nontrans_small_side_hits(); | ||
| 30581 | + let tr_before = crate::decode::tr_reach_longer_side_hits(); | ||
| 30582 | + let frames = match decode_stream(&stream) { | ||
| 30583 | + Ok(frames) => frames, | ||
| 30584 | + Err(e) => panic!("{NAME}: decode_stream refused: {e}"), | ||
| 30585 | + }; | ||
| 30586 | + let gm = crate::decode::gm_nontrans_small_side_hits() - gm_before; | ||
| 30587 | + let tr = crate::decode::tr_reach_longer_side_hits() - tr_before; | ||
| 30588 | + assert!( | ||
| 30589 | + gm > 0, | ||
| 30590 | + "{NAME}: gm_nontrans_small_side never fired -- the gate would be vacuous for it" | ||
| 30591 | + ); | ||
| 30592 | + assert!( | ||
| 30593 | + tr > 0, | ||
| 30594 | + "{NAME}: tr_reach_longer_side never fired -- the gate would be vacuous for it" | ||
| 30595 | + ); | ||
| 30596 | + assert_eq!(frames.len(), 33, "{NAME}: 33 shown frames"); | ||
| 30597 | + assert_eq!((frames[0].width, frames[0].height), (width, height)); | ||
| 30598 | + let ffmpeg_frames = ffmpeg_decode_sequence_10bit(&stream, width, height, frames.len()); | ||
| 30599 | + assert_eq!( | ||
| 30600 | + ffmpeg_frames.len(), | ||
| 30601 | + frames.len(), | ||
| 30602 | + "{NAME}: ffmpeg returned {} frames, we decoded {}", | ||
| 30603 | + ffmpeg_frames.len(), | ||
| 30604 | + frames.len() | ||
| 30605 | + ); | ||
| 30606 | + for (i, (ours, theirs)) in frames.iter().zip(&ffmpeg_frames).enumerate() { | ||
| 30607 | + assert_eq!(ours.y, theirs.y, "{NAME}: frame {i} luma vs ffmpeg"); | ||
| 30608 | + assert_eq!(ours.u, theirs.u, "{NAME}: frame {i} U vs ffmpeg"); | ||
| 30609 | + assert_eq!(ours.v, theirs.v, "{NAME}: frame {i} V vs ffmpeg"); | ||
| 30610 | + } | ||
| 30611 | + eprintln!( | ||
| 30612 | + "{NAME}: 33 shown frames pixel-exact on every plane; \ | ||
| 30613 | + gm_nontrans_small_side={gm} tr_reach_longer_side={tr}" | ||
| 30614 | + ); | ||
| 30615 | + } | ||
| 30616 | + | ||
| 30523 | 30617 | ||
| 30524 | /// lane-sub8x4 r2, the gate that lifts BOTH sub-8x8 intra refusals ("an | 30618 | /// lane-sub8x4 r2, the gate that lifts BOTH sub-8x8 intra refusals ("an |
| 30525 | /// intra 4x4 block inside an inter frame's sub-8x8 split" and "an intra | 30619 | /// intra 4x4 block inside an inter frame's sub-8x8 split" and "an intra |
crates/ec-av1/src/tile.rsmodified+13 -6
| @@ -3017,13 +3017,20 @@ mod tests { | |||
| 3017 | .stderr(Stdio::piped()) | 3017 | .stderr(Stdio::piped()) |
| 3018 | .spawn() | 3018 | .spawn() |
| 3019 | .expect("ffmpeg failed to start"); | 3019 | .expect("ffmpeg failed to start"); |
| 3020 | - child | 3020 | + // lane-t900 r10: the stream goes down stdin on ITS OWN THREAD. Writing |
| 3021 | - .stdin | 3021 | + // it inline deadlocks the moment ffmpeg's stdout pipe buffer (64 KiB) |
| 3022 | - .take() | 3022 | + // fills before the last input byte is written -- which is exactly what |
| 3023 | - .expect("ffmpeg stdin") | 3023 | + // a 1.1 MB fixture decoding to 150 MB of raw 10-bit frames does |
| 3024 | - .write_all(stream) | 3024 | + // (measured: 45 min, both processes at 0% CPU). A write error here is |
| 3025 | - .expect("writing the stream to ffmpeg"); | 3025 | + // swallowed on purpose: ffmpeg's own exit status and stderr, asserted |
| 3026 | + // below, are the real diagnosis. | ||
| 3027 | + let mut stdin = child.stdin.take().expect("ffmpeg stdin"); | ||
| 3028 | + let payload = stream.to_vec(); | ||
| 3029 | + let writer = std::thread::spawn(move || { | ||
| 3030 | + let _ = stdin.write_all(&payload); | ||
| 3031 | + }); | ||
| 3026 | let out = child.wait_with_output().expect("ffmpeg failed to run"); | 3032 | let out = child.wait_with_output().expect("ffmpeg failed to run"); |
| 3033 | + writer.join().expect("ffmpeg stdin writer thread"); | ||
| 3027 | assert!( | 3034 | assert!( |
| 3028 | out.status.success(), | 3035 | out.status.success(), |
| 3029 | "ffmpeg refused the stream: {}", | 3036 | "ffmpeg refused the stream: {}", |
lanes/t900-r10.report.mdadded+112 -0
| @@ -0,0 +1,112 @@ | |||
| 1 | +# lane-t900 r10 -- the r9 top-right hunk was half a port; with libaom's rect shape refinements the 1080p cut's mode stream is exact for all 264 frames | ||
| 2 | + | ||
| 3 | +Tip on `lane-t900` (see git log). Suite: see below. | ||
| 4 | + | ||
| 5 | +## STEP 0 -- verdict on the unverified r9 hunk `5c8ab7f2`: KEPT, but only after completing it | ||
| 6 | + | ||
| 7 | +Named gates at `6d2ba001` (before any r10 edit), unit `t900-named-r10b`: | ||
| 8 | +`128sb_film interintra hidden_arf rect64_corner_tus sub8 obmc mv_stack | ||
| 9 | +refusal_inventory gate_coverage` -> **34 passed, 0 failed, 1 ignored** | ||
| 10 | +(98.6 s, `$HOME/.cache/t900-named-r10.log`). So the r9 hunk reddened nothing. | ||
| 11 | + | ||
| 12 | +libaom, cited: `av1_findSamples` probes the top-right warp sample with | ||
| 13 | +`has_top_right(cm, xd, mi_row, mi_col, AOMMAX(xd->width, xd->height))` | ||
| 14 | +(`mvref_common.c:1235`) -- r9's premise is correct, and it is the ONLY place | ||
| 15 | +that uses the longer side for that probe in a way our port reaches | ||
| 16 | +(`mvstack::has_top_right` has exactly one caller, `decode::find_samples`; the | ||
| 17 | +mv-stack scan's own `bs = AOMMAX(w,h)` at `mvref_common.c:496` is served by the | ||
| 18 | +separate `top_right_scan_allowed`). For a 64x128 block `bs = 32`, and | ||
| 19 | +`has_top_right` returns 0 at once (`if (bs > mi_size_wide[BLOCK_64X64]) return 0`, | ||
| 20 | +`mvref_common.c:270`) -- so YES, libaom uses max(w,h) there and a 128-tall block | ||
| 21 | +gets no top-right warp sample. r9's mi(64,144) analysis stands. | ||
| 22 | + | ||
| 23 | +**Why it moved the divergence earlier**: our `has_top_right` port never carried | ||
| 24 | +libaom's two rect shape refinements (`av1_common_int.h:1419-1428`) | ||
| 25 | + | ||
| 26 | + is_last_vertical_rect = !((mi_col + width) & (height - 1)) [w < h] | ||
| 27 | + is_first_horizontal_rect = !( mi_row & (width - 1)) [w > h] | ||
| 28 | + | ||
| 29 | +which are applied AFTER the mask loop and only bite when `bw4 != bh4` -- i.e. | ||
| 30 | +exactly the blocks whose probe size r9 changed. Probing at the longer side | ||
| 31 | +without them is half a port. Root cause fixed in `b5e1cbde` | ||
| 32 | +(`crates/ec-av1/src/mvstack.rs:705-733`, call site | ||
| 33 | +`crates/ec-av1/src/decode.rs:18995`), NOT reverted. | ||
| 34 | + | ||
| 35 | +## Result on the 10-bit 1920x792 264-frame cut (`~/.cache/t900-tmp/cut_900.obu`) | ||
| 36 | + | ||
| 37 | +| ladder | r9 tip `5c8ab7f2` | r10 tip | | ||
| 38 | +|---|---|---| | ||
| 39 | +| first EC_MODE divergence | frame 49, mi(24,376)->mi(24,380) | **none in 264 frames** | | ||
| 40 | +| mode-ladder opcodes vs aomdec | replace at frame 48 | 915 equal / 914 insert / **0 replace, 0 delete** | | ||
| 41 | +| frames differing vs aomdec | 218 of 267 (frame 49 alone 2.26 MB) | **36 of 267, 1-3 bytes each** | | ||
| 42 | +| first differing frame | 41 | 41 (the known r8 chroma-MC bottom-row clamp, 1 byte) | | ||
| 43 | + | ||
| 44 | +The 914 "insert" runs are lines only WE emit (per-sub-block EC_MODE prints where | ||
| 45 | +libaom prints once per block, and intra blocks in inter frames); every | ||
| 46 | +`(mi_row, mi_col, rng)` triple aomdec emits is matched in order. | ||
| 47 | + | ||
| 48 | +EVIDENCE: `~/.cache/t900-tmp/o900e.mode` + `a900.mode` | `python3 lad2.py a900.mode o900e_i.mode` (difflib over (frame,mi_row,mi_col,rng)) | Counter({'equal': 915, 'insert': 914}), first delete/replace: None | ||
| 49 | +EVIDENCE: `~/.cache/t900-tmp/d_r10_900/` | `bash cmp.sh r10_900 cut_900.obu` (aomdec EC_AV1_FINAL_DUMP vs ours, 267 decode-order frames) | 231/267 bit-exact, 36 differ by 1-3 bytes, worst frame 55 = 3 bytes | ||
| 50 | + | ||
| 51 | +## STEP 2 -- witness gates | ||
| 52 | + | ||
| 53 | +* `crates/ec-av1/fixtures/gm_small_side_witness.obu`, **1158066 bytes**, sha256 | ||
| 54 | + `f1cdbcbb8d6d469c7957d70252ab42b24ab75f48a717600ffa25991458775dca` (truncated | ||
| 55 | + twice independently, identical hashes): first 50 frame-carrying OBUs of a 2 s | ||
| 56 | + 10-bit 1920x792 cut, 34 decode-order frames, 33 shown. It is the SMALLEST such | ||
| 57 | + prefix that fires `gm_nontrans_small_side` (N=49 fires 0, N=50 fires 1) and it | ||
| 58 | + is decode-exact: all 34 decode-order frames byte-identical to aomdec. | ||
| 59 | + New gate `a_10bit_film_frames_with_small_side_globalmv_and_rect_warp_reach_decode_pixel_exact` | ||
| 60 | + (`crates/ec-av1/src/stream.rs`): 33 shown frames vs ffmpeg on every plane, | ||
| 61 | + hard asserts `gm_nontrans_small_side_hits > 0` (1) and | ||
| 62 | + `tr_reach_longer_side_hits > 0` (2295). | ||
| 63 | +* The existing 128-SB witness gate now also hard-asserts | ||
| 64 | + `tr_reach_longer_side` (fires 600 on `reelc_sb128_inter_witness.obu`); | ||
| 65 | + `gm_nontrans_small_side` fires 0 there and on every other fixture in the repo, | ||
| 66 | + which is why the new fixture was needed. | ||
| 67 | + | ||
| 68 | +EVIDENCE: `~/.cache/t900-tmp/d_r10_t54w/` | `bash cmp.sh r10_t54w t54w_a.obu` | 34/34 decode-order frames exact, first differing frame: None | ||
| 69 | +EVIDENCE: `$HOME/.cache/t900-gm-r10.log` | `cargo test -p ec-av1 --lib -- small_side_globalmv 128sb_film gate_coverage refusal_inventory` | 14 passed, 0 failed, 51.46 s; gate prints "33 shown frames pixel-exact on every plane; gm_nontrans_small_side=1 tr_reach_longer_side=2295" | ||
| 70 | + | ||
| 71 | +## Film / stream table at the r10 tip (`cmp.sh`, aomdec EC_AV1_FINAL_DUMP vs ours) | ||
| 72 | + | ||
| 73 | +| stream | decode | frames differing | first bad | worst | | ||
| 74 | +|---|---|---|---|---| | ||
| 75 | +| 10-bit 1080p cut @900s (267 f) | OK 264 shown | 36 | 41 | 3 bytes | | ||
| 76 | +| 10-bit 1080p head 0-10s (241 f) | OK 240 shown | 78 | 86 (2 bytes) | f130 1143 bytes | | ||
| 77 | +| 10-bit 1080p cut @5400s (275 f) | OK 273 shown | 134 | 61 (1 byte) | f113 1942 bytes | | ||
| 78 | +| 10-bit 1080p cut @6300s (125 f) | OK 122 shown | 86 | 11 (2 bytes) | ~6 bytes | | ||
| 79 | +| 10-bit 1080p cut @8100s (96 f) | OK 95 shown | 18 | 66 (2 bytes) | ~4 bytes | | ||
| 80 | +| 10-bit 2160p head 0-10s, 148-OBU prefix (100 f) | OK 97 shown | **1** | 88 (221 bytes) | 221 bytes | | ||
| 81 | + | ||
| 82 | +No stream refuses. Every remaining 1-6 byte residue sits on a block/frame BOTTOM | ||
| 83 | +edge (the r8 chroma-MC clamp class). | ||
| 84 | + | ||
| 85 | +## Open residue | ||
| 86 | + | ||
| 87 | +* fix-now(next round): 2160p decode frame 88 of the 0-10 s head -- 221 bytes, | ||
| 88 | + 218 luma + 3 chroma, ALL in picture rows 1593-1607 / chroma rows 799-801 (the | ||
| 89 | + last rows of 1608). It is the only frame in that 100-frame prefix that is not | ||
| 90 | + exact and the only one whose header carries `lr=[Sgrproj, Sgrproj, Sgrproj]` | ||
| 91 | + on the luma plane -- prime suspect is the self-guided restoration's last | ||
| 92 | + stripe at the frame bottom, NOT the chroma-MC clamp. Independent of the r9/r10 | ||
| 93 | + warp work (the N=147 prefix, which fires no gm hit, shows the same 221 bytes). | ||
| 94 | +* deferred(a round of its own): the 1000+ byte walls at 1080p head f130 and | ||
| 95 | + @5400 f113 -- unmeasured this round. | ||
| 96 | +* accepted: the 1-3 byte bottom-edge chroma-MC clamp residue (r8, class | ||
| 97 | + `reach-is-per-transform-unit` neighbours), unchanged this round. | ||
| 98 | +* corner-cut: libaom's third `has_top_right` refinement (the PARTITION_VERT_A | ||
| 99 | + bottom-left square) still not ported -- needs the parent partition type | ||
| 100 | + threaded into `mvstack::has_top_right`; ceiling + upgrade path in its doc | ||
| 101 | + comment. | ||
| 102 | + | ||
| 103 | +## Class fixed on the way: ffmpeg pipe deadlock in every gate helper | ||
| 104 | + | ||
| 105 | +`ffmpeg_decode_sequence_10bit` (and 6 sibling helpers, one shape, in | ||
| 106 | +`stream.rs` x2, `decode.rs` x2, `tile.rs` x1, `encode.rs` x2) wrote the whole | ||
| 107 | +stream to ffmpeg's stdin INLINE and only then read stdout. With a 1.1 MB | ||
| 108 | +fixture that decodes to ~150 MB the stdout pipe fills first and both processes | ||
| 109 | +park at 0% CPU -- the new gate sat there for 45 minutes before I killed it | ||
| 110 | +(`ps` showed `ffmpeg -f obu -i -` at 0.0% and the test binary at 2.5%). | ||
| 111 | +All 7 now write on their own thread. Same run afterwards: **51.5 s**. | ||
| 112 | +EVIDENCE: `$HOME/.cache/t900-gm-r10d.log` | same test command as the 45-min hang | `test result: ok. 14 passed; 0 failed` in 51.46 s | ||