[vlc-commits] vlc_tick: add msftime_t to express 100ns time

Steve Lhomme git at videolan.org
Fri Jun 29 17:36:10 CEST 2018


vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Fri Jun 22 18:07:38 2018 +0200| [36cba01030cb3c96d37865db4b450a0d4a3b04a4] | committer: Steve Lhomme

vlc_tick: add msftime_t to express 100ns time

Such values currently have a better resolution than vlc_tick_t
Also provide conversion macros/functions to/from vlc_tick_t

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=36cba01030cb3c96d37865db4b450a0d4a3b04a4
---

 include/vlc_tick.h | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/include/vlc_tick.h b/include/vlc_tick.h
index c168113e3e..4e2ca3d4eb 100644
--- a/include/vlc_tick.h
+++ b/include/vlc_tick.h
@@ -143,6 +143,25 @@ static inline double secf_from_vlc_tick(vlc_tick_t vtk)
 #endif /* CLOCK_FREQ / 1000000000 */
 
 
+/*
+ * msftime_t is a time with 100ns resolutions, typically used by Microsoft
+ */
+typedef int64_t msftime_t;
+
+#define MSFTIME_FROM_SEC(sec)       (INT64_C(10000000) * (sec))  /* seconds in msftime_t */
+
+#if (CLOCK_FREQ % 10000000) == 0
+#define VLC_TICK_FROM_MSFTIME(msft) ((msft) * (CLOCK_FREQ / INT64_C(10000000))
+#define MSFTIME_FROM_VLC_TICK(vtk)  ((vtk)  / (CLOCK_FREQ / INT64_C(10000000))
+#elif (10000000 % CLOCK_FREQ) == 0
+#define VLC_TICK_FROM_MSFTIME(msft) ((msft) / (INT64_C(10000000) / CLOCK_FREQ))
+#define MSFTIME_FROM_VLC_TICK(vtk)  ((vtk)  * (INT64_C(10000000) / CLOCK_FREQ))
+#else /* rounded overflowing conversion */
+#define VLC_TICK_FROM_MSFTIME(msft) (CLOCK_FREQ * (msft) / INT64_C(10000000))
+#define MSFTIME_FROM_VLC_TICK(vtk)  ((vtk)  * INT64_C(10000000) / CLOCK_FREQ)
+#endif /* CLOCK_FREQ / 10000000 */
+
+
 /*****************************************************************************
  * MSTRTIME_MAX_SIZE: maximum possible size of mstrtime
  *****************************************************************************



More information about the vlc-commits mailing list