[vlc-devel] [PATCH] HLS: don't use floats when not necessary

Frédéric Yhuel fyhuel at viotech.net
Mon Apr 2 21:11:37 CEST 2012


---
 modules/stream_filter/httplive.c |    7 +------
 1 files changed, 1 insertions(+), 6 deletions(-)

diff --git a/modules/stream_filter/httplive.c b/modules/stream_filter/httplive.c
index 26f6d74..433dca0 100644
--- a/modules/stream_filter/httplive.c
+++ b/modules/stream_filter/httplive.c
@@ -1494,12 +1494,7 @@ static int hls_DownloadSegmentData(stream_t *s, hls_stream_t *hls, segment_t *se
     msg_Info(s, "downloaded segment %d from stream %d",
                 segment->sequence, *cur_stream);
 
-    /* check for division by zero */
-    double ms = (double)duration / 1000.0; /* ms */
-    if (ms <= 0.0)
-        return VLC_SUCCESS;
-
-    uint64_t bw = ((double)(segment->size * 8) / ms) * 1000; /* bits / s */
+    uint64_t bw = segment->size * 8 * 1000000 / __MAX(1, duration); /* bits / s */
     p_sys->bandwidth = bw;
     if (p_sys->b_meta && (hls->bandwidth != bw))
     {
-- 
1.7.9.1




More information about the vlc-devel mailing list