1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 09:37:34 +00:00

LibVideo: Add a fast seeking mode to seek only to keyframes

Now that we're able to find the nearest keyframe, we can have a fast
seeking mode that only seeks to keyframes, so that it doesn't have to
also decode inter frames until it reaches the timestamp.

The default is still accurate seeking, so that the entire seeking
implementation can be tested.
This commit is contained in:
Zaggy1024 2022-11-13 20:33:23 -06:00 committed by Andreas Kling
parent eef8867d9e
commit fd3ffd88ce
5 changed files with 22 additions and 6 deletions

View file

@ -53,16 +53,17 @@ DecoderErrorOr<MatroskaDemuxer::TrackStatus*> MatroskaDemuxer::get_track_status(
return &m_track_statuses.get(track).release_value();
}
DecoderErrorOr<void> MatroskaDemuxer::seek_to_most_recent_keyframe(Track track, Time timestamp)
DecoderErrorOr<Time> MatroskaDemuxer::seek_to_most_recent_keyframe(Track track, Time timestamp)
{
// Removing the track status will cause us to start from the beginning.
if (timestamp.is_zero()) {
m_track_statuses.remove(track);
return {};
return timestamp;
}
auto& track_status = *TRY(get_track_status(track));
return m_reader.seek_to_random_access_point(track_status.iterator, timestamp);
TRY(m_reader.seek_to_random_access_point(track_status.iterator, timestamp));
return track_status.iterator.last_timestamp();
}
DecoderErrorOr<NonnullOwnPtr<Sample>> MatroskaDemuxer::get_next_sample_for_track(Track track)