mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 20:37:36 +00:00
LibVideo: Implement Matroska keyframe search for when there are no Cues
This just searches sequentially through each block in a SampleIterator until it finds a block after the specified seek timestamp. Once it finds one, it will try to set the input/output iterator to the most recent keyframe. If the iterator's original position is closer to the target, however, it leaves it at that original position, allowing callers to continue decoding from that position until they reach the target timestamp.
This commit is contained in:
parent
9040194d54
commit
eef8867d9e
3 changed files with 67 additions and 9 deletions
|
@ -53,13 +53,16 @@ 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)
|
||||
DecoderErrorOr<void> MatroskaDemuxer::seek_to_most_recent_keyframe(Track track, Time timestamp)
|
||||
{
|
||||
// Removing the track status will cause us to start from the beginning.
|
||||
// FIXME: We just go back to the beginning always, so that the PlaybackManager seeking
|
||||
// technology can be tested.
|
||||
m_track_statuses.remove(track);
|
||||
return {};
|
||||
if (timestamp.is_zero()) {
|
||||
m_track_statuses.remove(track);
|
||||
return {};
|
||||
}
|
||||
|
||||
auto& track_status = *TRY(get_track_status(track));
|
||||
return m_reader.seek_to_random_access_point(track_status.iterator, timestamp);
|
||||
}
|
||||
|
||||
DecoderErrorOr<NonnullOwnPtr<Sample>> MatroskaDemuxer::get_next_sample_for_track(Track track)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue