[vlc-commits] demux: adaptive: fix timeline getMinAhead

Francois Cartegnie git at videolan.org
Mon Mar 30 16:16:47 CEST 2020


vlc/vlc-3.0 | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Wed Mar 18 18:04:02 2020 +0100| [750352d3fe110e22047c51076aa201ff698bdcd0] | committer: Francois Cartegnie

demux: adaptive: fix timeline getMinAhead

(cherry picked from commit beff032660d4b389a6d91467a3bc62570f9bf05a)

> http://git.videolan.org/gitweb.cgi/vlc/vlc-3.0.git/?a=commit;h=750352d3fe110e22047c51076aa201ff698bdcd0
---

 modules/demux/adaptive/playlist/SegmentTimeline.cpp | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/modules/demux/adaptive/playlist/SegmentTimeline.cpp b/modules/demux/adaptive/playlist/SegmentTimeline.cpp
index 855e066459..7daa517dde 100644
--- a/modules/demux/adaptive/playlist/SegmentTimeline.cpp
+++ b/modules/demux/adaptive/playlist/SegmentTimeline.cpp
@@ -69,21 +69,21 @@ mtime_t SegmentTimeline::getMinAheadScaledTime(uint64_t number) const
 {
     stime_t totalscaledtime = 0;
 
+    if(!elements.size() ||
+       minElementNumber() > number ||
+       maxElementNumber() < number)
+        return 0;
+
     std::list<Element *>::const_reverse_iterator it;
     for(it = elements.rbegin(); it != elements.rend(); ++it)
     {
         const Element *el = *it;
-
-        if(number < el->number)
-        {
-            totalscaledtime += (el->d * (el->r + 1));
+        if(number > el->number + el->r)
             break;
-        }
-        else if(number <= el->number + el->r)
-        {
+        else if(number < el->number + el->r)
+            totalscaledtime += (el->d * (el->r + 1));
+        else /* within repeat range */
             totalscaledtime += el->d * (el->number + el->r - number);
-        }
-        else break;
     }
 
     return totalscaledtime;



More information about the vlc-commits mailing list