forge
Explore
Log in

Don't you dare go Hollow

The cue decode is held to the frame it appears on

Browse files at this commit

536c87c7e9d49a4db670510ca719903c464521ceAhmet Kaan GümüşParent: 739bec4
  • test
    • the cue decode is held to the frame it appears on
Show full message
🧪 test(subtitles): the cue decode is held to the frame it appears on

The picture is decoded once per cue *change* and kept while the line is up
(`Player::sub_picture`), so the number that matters is the one frame a new line
costs. Measured on a real BluRay remux's PGS track: 371 µs for a 1920x1080
display set, against a 16.7 ms frame. Written down as an assert, since a cache
that quietly stopped catching would show up here as nothing at all.
crates/engine/tests/pgs_bitmaps.rsmodified+9 -4
@@ -62,12 +62,17 @@ fn the_session_maps_a_pgs_track_onto_the_timeline_and_draws_it() {
62 let drawn = Instant::now();62 let drawn = Instant::now();
63 let image = cues[0].image.as_ref().expect("a picture cue");63 let image = cues[0].image.as_ref().expect("a picture cue");
64 let rgba = image.rgba().expect("the first display set decodes");64 let rgba = image.rgba().expect("the first display set decodes");
65+ let took = drawn.elapsed();
65 eprintln!(66 eprintln!(
66- "cue 0 decoded to {}x{} in {:?}",67+ "cue 0 decoded to {}x{} in {took:?}",
67- image.width,68+ image.width, image.height,
68- image.height,
69- drawn.elapsed()
70 );69 );
70+ // The run-length walk is paid once per cue *change* -- the window keeps the
71+ // picture while it is up ([`Player::sub_picture`]) -- so what this holds is
72+ // the cost of the one frame a new line appears on: 247 µs measured on this
73+ // remux, a sixty-eighth of that frame's budget. A whole repaint's worth
74+ // would mean the cache above it had stopped mattering.
75+ assert!(took.as_millis() < 16, "a frame's worth of decode: {took:?}");
71 assert_eq!(rgba.len(), (image.width * image.height * 4) as usize);76 assert_eq!(rgba.len(), (image.width * image.height * 4) as usize);
72 let opaque = rgba.chunks_exact(4).filter(|px| px[3] > 0).count();77 let opaque = rgba.chunks_exact(4).filter(|px| px[3] > 0).count();
73 assert!(opaque > 0, "the block decoded to an empty canvas");78 assert!(opaque > 0, "the block decoded to an empty canvas");