Faster video seeking

By using our current position (if known), we shrink the search area.

--HG--
branch : minor
This commit is contained in:
Bart van Strien
2017-10-12 15:24:07 +02:00
parent de945a528b
commit 75e0caa0ff
+10
View File
@@ -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