mirror of
https://github.com/love2d/love.git
synced 2026-08-14 10:13:46 +02:00
Faster video seeking
By using our current position (if known), we shrink the search area. --HG-- branch : minor
This commit is contained in:
@@ -171,6 +171,16 @@ bool OggDemuxer::seek(ogg_packet &packet, double target, std::function<double(in
|
||||
double low = 0;
|
||||
double high = file->getSize();
|
||||
|
||||
// If we know our current position, we can drastically decrease the search area
|
||||
if (packet.granulepos != -1)
|
||||
{
|
||||
double currentTime = getTime(packet.granulepos);
|
||||
if (currentTime < target)
|
||||
low = file->tell();
|
||||
else if (currentTime > target)
|
||||
high = file->tell();
|
||||
}
|
||||
|
||||
while (high-low > rewindThreshold)
|
||||
{
|
||||
// Determine our next binary search position
|
||||
|
||||
Reference in New Issue
Block a user