[vlc-commits] [Git][videolan/vlc][master] clock: do not convert offset to double

Romain Vimont (@rom1v) gitlab at videolan.org
Tue Jul 6 17:20:36 UTC 2021



Romain Vimont pushed to branch master at VideoLAN / VLC


Commits:
69b61afb by Romain Vimont at 2021-07-06T15:34:17+00:00
clock: do not convert offset to double

The clock offset is a 64-bit integer (vlc_tick_t), so a conversion to
double, which has only 53 bits precision, could produce incorrect
values.

- - - - -


1 changed file:

- src/clock/clock.c


Changes:

=====================================
src/clock/clock.c
=====================================
@@ -83,8 +83,8 @@ static vlc_tick_t main_stream_to_system(vlc_clock_main_t *main_clock,
 {
     if (main_clock->offset == VLC_TICK_INVALID)
         return VLC_TICK_INVALID;
-    return (vlc_tick_t)
-        (ts * main_clock->coeff / main_clock->rate + main_clock->offset);
+    return ((vlc_tick_t) (ts * main_clock->coeff / main_clock->rate))
+            + main_clock->offset;
 }
 
 static void vlc_clock_main_reset(vlc_clock_main_t *main_clock)
@@ -151,7 +151,8 @@ static vlc_tick_t vlc_clock_master_update(vlc_clock_t *clock,
                 clock_point_Create(VLC_TICK_INVALID, VLC_TICK_INVALID);
         }
 
-        main_clock->offset = system_now - ts * main_clock->coeff / rate;
+        main_clock->offset =
+            system_now - ((vlc_tick_t) (ts * main_clock->coeff / rate));
 
         main_clock->last = clock_point_Create(system_now, ts);
 



View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/69b61afbcd7c875bc4c62f7664779f08b08c3a5e

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/69b61afbcd7c875bc4c62f7664779f08b08c3a5e
You're receiving this email because of your account on code.videolan.org.




More information about the vlc-commits mailing list