Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

Merge remote-tracking branch 'origin/main' into perf/windows-media-pipeline

Marcos Daniel Rivera Gonzalez9afd21438c06
diff --cc crates/rendering/src/decoder/media_foundation.rs
index 664fb43ad,9eed68256..85274d8d7
--- a/crates/rendering/src/decoder/media_foundation.rs
+++ b/crates/rendering/src/decoder/media_foundation.rs
@@@ -369,34 -367,6 +369,34 @@@ impl MFDecoder
break;
}
+ // Serve requests that arrive during readahead between samples and slide the
+ // window with them; otherwise a sequential reader waits out the whole batch
+ // and then finds the decoder idle while it consumes the cached frames.
+ if sender.is_none() && deferred_requests.is_empty() {
+ match rx.try_recv() {
+ Ok(VideoDecoderMessage::GetFrame(time, distance, reply)) => {
- let frame = (time * fps as f32).floor() as u32;
++ let frame = super::request_frame(time, fps);
+ if let Some(cached) =
+ cached_frame_for(&cache, last_decoded_frame, frame)
+ {
+ let _ =
+ reply.send(cached.to_decoded_frame().with_matrix(matrix));
+ readahead_target =
+ readahead_target.max(frame + readahead_frames);
+ cache_min = frame.saturating_sub(FRAME_CACHE_SIZE as u32 / 2);
+ cache_max = frame + FRAME_CACHE_SIZE as u32 / 2;
+ batch_start = Instant::now();
+ continue;
+ }
+ carried =
+ Some(VideoDecoderMessage::GetFrame(time, distance, reply));
+ break;
+ }
+ Err(mpsc::TryRecvError::Empty) => {}
+ Err(mpsc::TryRecvError::Disconnected) => break,
+ }
+ }
+
let decode_start = Instant::now();
match decoder.read_sample() {
Ok(Some(mf_frame)) => {