From 20d28e80a5c861a9d5f449ea911ab75b4f37ad0d Mon Sep 17 00:00:00 2001 From: Jef Date: Tue, 24 Sep 2024 14:54:57 +0200 Subject: Initial community commit --- Src/h264dec/lcommon/src/win32.c | 67 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 Src/h264dec/lcommon/src/win32.c (limited to 'Src/h264dec/lcommon/src/win32.c') diff --git a/Src/h264dec/lcommon/src/win32.c b/Src/h264dec/lcommon/src/win32.c new file mode 100644 index 00000000..7d921e1e --- /dev/null +++ b/Src/h264dec/lcommon/src/win32.c @@ -0,0 +1,67 @@ + +/*! + ************************************************************************************* + * \file win32.c + * + * \brief + * Platform dependent code + * + * \author + * Main contributors (see contributors.h for copyright, address and affiliation details) + * - Karsten Suehring + ************************************************************************************* + */ + +#include "global.h" + + +#ifdef _WIN32 + +static LARGE_INTEGER freq; + +void gettime(TIME_T* time) +{ + QueryPerformanceCounter(time); +} + +int64 timediff(TIME_T* start, TIME_T* end) +{ + return (int64)((end->QuadPart - start->QuadPart)); +} + +int64 timenorm(int64 cur_time) +{ + static int first = 1; + + if(first) + { + QueryPerformanceFrequency(&freq); + first = 0; + } + + return (int64)(cur_time * 1000 /(freq.QuadPart)); +} + +#else + +static struct timezone tz; + +void gettime(TIME_T* time) +{ + gettimeofday(time, &tz); +} + +int64 timediff(TIME_T* start, TIME_T* end) +{ + int t1, t2; + + t1 = end->tv_sec - start->tv_sec; + t2 = end->tv_usec - start->tv_usec; + return (int64) t2 + (int64) t1 * (int64) 1000000; +} + +int64 timenorm(int64 cur_time) +{ + return (int64)(cur_time / (int64) 1000); +} +#endif -- cgit