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

Frédéric Yhuel fyhuel at viotech.net
Thu Mar 29 17:25:17 CEST 2012


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

diff --git a/modules/stream_filter/httplive.c b/modules/stream_filter/httplive.c
index 6a711be..3adb34a 100644
--- a/modules/stream_filter/httplive.c
+++ b/modules/stream_filter/httplive.c
@@ -1495,11 +1495,9 @@ static int hls_DownloadSegmentData(stream_t *s, hls_stream_t *hls, segment_t *se
                 segment->sequence, *cur_stream);
 
     /* check for division by zero */
-    double ms = (double)duration / 1000.0; /* ms */
-    if (ms <= 0.0)
-        return VLC_SUCCESS;
+    unsigned ms = __MAX( 1, duration / 1000 );
 
-    uint64_t bw = ((double)(segment->size * 8) / ms) * 1000; /* bits / s */
+    uint64_t bw = segment->size * 8 * 1000 / ms; /* bits / s */
     p_sys->bandwidth = bw;
     if (p_sys->b_meta && (hls->bandwidth != bw))
     {
-- 
1.7.5.4




More information about the vlc-devel mailing list