avformat/hls: avoid floating point arithmetic
authorMichael Niedermayer <michaelni@gmx.at>
Mon, 22 Jul 2013 17:36:33 +0000 (19:36 +0200)
committerMichael Niedermayer <michaelni@gmx.at>
Mon, 22 Jul 2013 17:36:33 +0000 (19:36 +0200)
Should make things more reproducable across platforms

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
libavformat/hls.c

index 995dc9f..355f1a6 100644 (file)
@@ -524,10 +524,10 @@ static int hls_read_header(AVFormatContext *s)
     /* If this isn't a live stream, calculate the total duration of the
      * stream. */
     if (c->variants[0]->finished) {
-        double duration = 0.0;
+        int64_t duration = 0;
         for (i = 0; i < c->variants[0]->n_segments; i++)
-            duration += c->variants[0]->segments[i]->duration;
-        s->duration = duration * AV_TIME_BASE;
+            duration += round(c->variants[0]->segments[i]->duration * AV_TIME_BASE);
+        s->duration = duration;
     }
 
     /* Open the demuxer for each variant */