[vlc-devel] [PATCH 04/15] vlc_common: add helper function for explicit nanosecond to/from mtime_t conversion

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


It will be handy if mtime_t has better precision than microseconds.
---
 include/vlc_common.h | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/include/vlc_common.h b/include/vlc_common.h
index d4186883df6..3191d3ce4c8 100644
--- a/include/vlc_common.h
+++ b/include/vlc_common.h
@@ -316,6 +316,15 @@ static inline int64_t milli_from_vtick(mtime_t mt)
     return mt / (CLOCK_FREQ / 1000);
 }
 
+static inline mtime_t vtick_from_nano(int64_t nano)
+{
+    return nano / (INT64_C(1000000000) / CLOCK_FREQ);
+}
+static inline int64_t nano_from_vtick(mtime_t tck)
+{
+    return tck * INT64_C(1000000000) / CLOCK_FREQ;
+}
+
 /**
  * The vlc_fourcc_t type.
  *
-- 
2.17.0



More information about the vlc-devel mailing list