[vlc-devel] [PATCH 09/10] vlc_tick: add msftime_t to express 100ns time
Steve Lhomme
robux4 at ycbcr.xyz
Fri Jun 22 14:53:26 CEST 2018
Such values currently have a better resolution than vlc_tick_t
Also provide conversion macros/functions to/from vlc_tick_t
---
include/vlc_tick.h | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/include/vlc_tick.h b/include/vlc_tick.h
index 9e7f909e149..6953ba346d4 100644
--- a/include/vlc_tick.h
+++ b/include/vlc_tick.h
@@ -138,6 +138,24 @@ static inline int64_t ns_from_vlc_tick(vlc_tick_t vtk)
return vtk * INT64_C(1000000000) / CLOCK_FREQ;
}
+/**
+ * Typically Microsoft time with 100ns resolutions
+ */
+typedef int64_t msftime_t;
+#define MSFTIME_FROM_VLC_TICK(vtk) ((msftime_t)((vtk) * (INT64_C(10000000) / CLOCK_FREQ)))
+#define VLC_TICK_FROM_MSFTIME(msft) ((vlc_tick_t)((msft) / (INT64_C(10000000) / CLOCK_FREQ)))
+#define MSFTIME_FROM_SEC(sec) ((msftime_t)((sec) * INT64_C(10000000))) /* seconds in msftime_t */
+
+static inline vlc_tick_t vlc_tick_from_msftime(msftime_t t)
+{
+ return t * CLOCK_FREQ / INT64_C(10000000);
+}
+
+static inline msftime_t msftime_from_vlc_tick(vlc_tick_t vtk)
+{
+ return vtk * INT64_C(10000000) / CLOCK_FREQ;
+}
+
/*****************************************************************************
* MSTRTIME_MAX_SIZE: maximum possible size of mstrtime
*****************************************************************************
--
2.17.0
More information about the vlc-devel
mailing list