vlc | branch: master | Steve Lhomme <[email protected]> | 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 ***************************************************************************** _______________________________________________ vlc-commits mailing list [email protected] https://mailman.videolan.org/listinfo/vlc-commits
