[vlc-devel] [PATCH 07/15] vlc_common: add msftime_t to express 100ns time

Steve Lhomme robux4 at ycbcr.xyz
Fri Jun 15 17:09:18 CEST 2018


Such values currently have a better resolution than mtime_t
Also provide conversion macros to/from mtime_t
---
 include/vlc_common.h | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/include/vlc_common.h b/include/vlc_common.h
index fe1b125625f..779ce49d9ed 100644
--- a/include/vlc_common.h
+++ b/include/vlc_common.h
@@ -294,11 +294,6 @@ typedef int64_t mtime_t;
 #define SEC_FROM_VTICK(mt)  ((mt) / CLOCK_FREQ)      /* mtime_t in seconds */
 #define VTICK_FROM_SEC(sec) ((mtime_t)((sec) * CLOCK_FREQ)) /* seconds in mtime_t */
 
-static inline mtime_t vtick_from_sec(int64_t sec)
-{
-    return sec * CLOCK_FREQ;
-}
-
 static inline int64_t sec_from_vtick(mtime_t mt)
 {
     return mt / CLOCK_FREQ;
@@ -342,6 +337,14 @@ static inline mtime_t vtick_from_secf(double secf)
     return secf * CLOCK_FREQ; /* TODO use llround */
 }
 
+/**
+ * Typically Microsoft time with 100ns resolutions
+  */
+typedef int64_t msftime_t;
+#define MSFTIME_FROM_VTICK(mt)    ((msftime_t)((mt) * (INT64_C(10000000) / CLOCK_FREQ)))
+#define VTICK_FROM_MSFTIME(msft)  ((mtime_t)((msft) / (INT64_C(10000000) / CLOCK_FREQ)))
+#define SEC_TO_MSFTIME(sec)     ((msftime_t)((sec) * INT64_C(10000000)))  /* seconds in msftime_t */
+
 
 /**
  * The vlc_fourcc_t type.
-- 
2.17.0



More information about the vlc-devel mailing list