The reused decoder is held to the pixels a fresh one gives
Browse files at this commit86e94558ec24409c8edf12e29a2a468fc50ec75dParent: fffcda0- test
- the reused decoder is held to the pixels a fresh one gives
1 changed file +26 -0
crates/engine/tests/playback.rsmodified+26 -0
| @@ -1516,3 +1516,29 @@ fn a_watched_session_still_lands_on_the_frame_a_seek_asked_for() { | |||
| 1516 | (1.0 * fps) as u32 | 1516 | (1.0 * fps) as u32 |
| 1517 | ); | 1517 | ); |
| 1518 | } | 1518 | } |
| 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 | +} | ||