[vlc-devel] [PATCH 03/15] vlc_common: add helper functions to convert (milli)seconds to/from mtime_t
Steve Lhomme
robux4 at ycbcr.xyz
Fri Jun 15 17:09:14 CEST 2018
---
include/vlc_common.h | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/include/vlc_common.h b/include/vlc_common.h
index 3d17d8e6a63..d4186883df6 100644
--- a/include/vlc_common.h
+++ b/include/vlc_common.h
@@ -294,6 +294,27 @@ 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;
+}
+
+static inline mtime_t vtick_from_milli(int64_t ms)
+{
+ /* TODO refine if CLOCK_FREQ is not a multiple of 1000 */
+ return ms * (CLOCK_FREQ / 1000);
+}
+
+static inline int64_t milli_from_vtick(mtime_t mt)
+{
+ /* TODO refine if CLOCK_FREQ is not a multiple of 1000 */
+ return mt / (CLOCK_FREQ / 1000);
+}
/**
* The vlc_fourcc_t type.
--
2.17.0
More information about the vlc-devel
mailing list