[vlc-commits] demux: adaptive: fix timeline timescale regression

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


vlc/vlc-3.0 | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Fri May 17 15:32:38 2019 +0200| [bf293f8c43f1fd82875039342c64c844b33ae612] | committer: Francois Cartegnie

demux: adaptive: fix timeline timescale regression

(cherry picked from commit 1245b3ae7642435632cdb8eff1a35f012900ea5d)

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

 modules/demux/adaptive/playlist/SegmentInformation.cpp | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/modules/demux/adaptive/playlist/SegmentInformation.cpp b/modules/demux/adaptive/playlist/SegmentInformation.cpp
index e60b6317d9..5a7b945292 100644
--- a/modules/demux/adaptive/playlist/SegmentInformation.cpp
+++ b/modules/demux/adaptive/playlist/SegmentInformation.cpp
@@ -347,13 +347,14 @@ bool SegmentInformation::getSegmentNumberByTime(mtime_t time, uint64_t *ret) con
 {
     if( mediaSegmentTemplate )
     {
-        const Timescale timescale = mediaSegmentTemplate->inheritTimescale();
-
         const SegmentTimeline *timeline = mediaSegmentTemplate->inheritSegmentTimeline();
         if(timeline)
         {
-            time = timescale.ToScaled(time);
-            *ret = timeline->getElementNumberByScaledPlaybackTime(time);
+            const Timescale timescale = timeline->getTimescale().isValid()
+                                      ? timeline->getTimescale()
+                                      : mediaSegmentTemplate->inheritTimescale();
+            stime_t st = timescale.ToScaled(time);
+            *ret = timeline->getElementNumberByScaledPlaybackTime(st);
             return true;
         }
 
@@ -366,6 +367,7 @@ bool SegmentInformation::getSegmentNumberByTime(mtime_t time, uint64_t *ret) con
             }
             else
             {
+                const Timescale timescale = mediaSegmentTemplate->inheritTimescale();
                 *ret = mediaSegmentTemplate->inheritStartNumber();
                 *ret += timescale.ToScaled(time) / duration;
             }



More information about the vlc-commits mailing list