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

Frederic YHUEL fyhuel at viotech.net
Fri Mar 30 10:21:33 CEST 2012


2012/3/29 Frédéric Yhuel <fyhuel at viotech.net>:
> ---
>  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 );
>

BTW, I don't think we should be afraid of integer overflow here: even
if "unsigned int" is only 16 bytes, there would be an overflow iff the
downloading of the fragment is > 65.535 seconds, which is unlikely...
if don't agree, I think you can amend the patch with s/unsigned
ms/uint32_t ms/ .


-- 
Frédéric



More information about the vlc-devel mailing list