[vlc-commits] demux: hls: scale duration from tick

Francois Cartegnie git at videolan.org
Thu Jul 23 19:27:49 CEST 2020


vlc/vlc-3.0 | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Fri Jul 10 18:29:07 2020 +0200| [4c0cb56f29f63da4feee55c10299425dfedc398d] | committer: Francois Cartegnie

demux: hls: scale duration from tick

(cherry picked from commit 1e133cd6f79529f66ee94d453eb5234f3b3a059a)

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

 modules/demux/hls/playlist/Parser.cpp | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/modules/demux/hls/playlist/Parser.cpp b/modules/demux/hls/playlist/Parser.cpp
index 28b1b65d21..057e614aa5 100644
--- a/modules/demux/hls/playlist/Parser.cpp
+++ b/modules/demux/hls/playlist/Parser.cpp
@@ -258,16 +258,15 @@ void M3U8Parser::parseSegments(vlc_object_t *, Representation *rep, const std::l
                 segment->setSourceUrl(uritag->getValue().value);
 
                 /* Need to use EXTXTARGETDURATION as default as some can't properly set segment one */
-                double duration = rep->targetDuration;
+                mtime_t nzDuration = CLOCK_FREQ * rep->targetDuration;
                 if(ctx_extinf)
                 {
                     const Attribute *durAttribute = ctx_extinf->getAttributeByName("DURATION");
                     if(durAttribute)
-                        duration = durAttribute->floatingPoint();
+                        nzDuration = CLOCK_FREQ * durAttribute->floatingPoint();
                     ctx_extinf = NULL;
                 }
-                const mtime_t nzDuration = CLOCK_FREQ * duration;
-                segment->duration.Set(duration * (uint64_t) rep->getTimescale());
+                segment->duration.Set(rep->getTimescale().ToScaled(nzDuration));
                 segment->startTime.Set(rep->getTimescale().ToScaled(nzStartTime));
                 nzStartTime += nzDuration;
                 totalduration += nzDuration;



More information about the vlc-commits mailing list