From 3bfef8bfe0d6f196c809d50140c31d4f10a6b533 Mon Sep 17 00:00:00 2001 From: Zaggy1024 Date: Mon, 6 Feb 2023 01:25:02 -0600 Subject: [PATCH] LibVideo: Pass the current sample to demuxers to lazily seek better In cases where the PlaybackManager's earliest buffered or displayed sample is closer to the seek target than the demuxer's chosen keyframe, we don't want to seek at all. To enable this, demuxers now receive an optional parameter with the earliest timestamp that the caller can still access. The demuxer in turn returns an optional to indicate when a seek was not needed, which allows PlaybackManager to avoid clearing its queue and re-decoding frames. --- .../Libraries/LibVideo/Containers/Demuxer.h | 4 +- .../Containers/Matroska/MatroskaDemuxer.cpp | 20 +++++++++- .../Containers/Matroska/MatroskaDemuxer.h | 2 +- .../LibVideo/Containers/Matroska/Reader.cpp | 37 ++++++------------- .../LibVideo/Containers/Matroska/Reader.h | 6 +-- .../Libraries/LibVideo/PlaybackManager.cpp | 32 ++++++++++++---- Userland/Libraries/LibVideo/PlaybackManager.h | 2 +- 7 files changed, 61 insertions(+), 42 deletions(-) diff --git a/Userland/Libraries/LibVideo/Containers/Demuxer.h b/Userland/Libraries/LibVideo/Containers/Demuxer.h index 1a2d2355d2..0915b8685e 100644 --- a/Userland/Libraries/LibVideo/Containers/Demuxer.h +++ b/Userland/Libraries/LibVideo/Containers/Demuxer.h @@ -29,7 +29,9 @@ public: } // Returns the timestamp of the keyframe that was seeked to. - virtual DecoderErrorOr