forge
Explore
Log in

Don't you dare go Hollow

The reused decoder is held to the pixels a fresh one gives

Browse files at this commit

86e94558ec24409c8edf12e29a2a468fc50ec75dAhmet Kaan GümüşParent: fffcda0
  • test
    • the reused decoder is held to the pixels a fresh one gives
Show full message
✅ test(playback): the reused decoder is held to the pixels a fresh one gives

The one thing a kept decoder can get wrong is the picture: a session
repositioned rather than reopened could carry one span's references into
the next and hand back a smear that still arrives at the right index and
the right time. One session takes three seeks -- forwards, backwards,
forwards -- and every landing is compared byte for byte against the
file-level API, which opens a decoder of its own for each of them.

Targets are small on purpose: the fixture's only sync sample is frame 0,
so each of these decodes from the start of the file under the debug-build
software decoder the suite runs on.
crates/engine/tests/playback.rsmodified+26 -0
@@ -1516,3 +1516,29 @@ fn a_watched_session_still_lands_on_the_frame_a_seek_asked_for() {
15161516 (1.0 * fps) as u32
15171517 );
15181518 }
1519+
1520+/// The pixels a *reused* decoder hands back are the pixels a fresh one does.
1521+/// One session takes three seeks -- forwards, backwards, forwards again -- and
1522+/// the worker survives all of them (`Worker::reseek`: the file stays open, the
1523+/// hardware session is repositioned rather than reopened), so a decoder left
1524+/// holding one span references while another span is asked for would show here
1525+/// as a smear and nowhere else. The reference is the file-level API, which
1526+/// opens a decoder of its own per frame.
1527+#[test]
1528+fn a_reseek_decodes_the_same_picture_a_fresh_decoder_does() {
1529+ let path = asset("test_baseline.mp4");
1530+ let mut session = open(&path);
1531+ let fps = session.meta().frame_rate;
1532+ // Small targets on purpose: the fixture's only sync sample is frame 0, so
1533+ // every one of these decodes from the start of the file and a debug-build
1534+ // software decoder is what runs the suite.
1535+ for target in [20u32, 5, 35] {
1536+ session.seek(f64::from(target) / fps);
1537+ let frame = next_frame(&mut session, "a seek onto a worker already open");
1538+ assert_eq!(frame.index, target, "the seek landed elsewhere");
1539+ assert!(
1540+ frame.bgra == source_frame(&path, target),
1541+ "frame {target} off the reused decoder is not the picture a fresh one decodes"
1542+ );
1543+ }
1544+}