2 * Copyright (c) 2000-2003 Fabrice Bellard
4 * This file is part of FFmpeg.
6 * FFmpeg is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * FFmpeg is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with FFmpeg; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
44 gettimeofday(&tv,
NULL);
45 return (
int64_t)tv.tv_sec * 1000000 + tv.tv_usec;
46#elif HAVE_GETSYSTEMTIMEASFILETIME
49 GetSystemTimeAsFileTime(&ft);
50 t = (
int64_t)ft.dwHighDateTime << 32 | ft.dwLowDateTime;
51 return t / 10 - 11644473600000000;
/* Jan 1, 1601 */
59#if HAVE_CLOCK_GETTIME && defined(CLOCK_MONOTONIC)
65 clock_gettime(CLOCK_MONOTONIC, &ts);
66 return (
int64_t)ts.tv_sec * 1000000 + ts.tv_nsec / 1000;
70 LARGE_INTEGER counter;
71 QueryPerformanceFrequency(&freq);
72 QueryPerformanceCounter(&counter);
73 return av_rescale(counter.QuadPart, 1000000, freq.QuadPart);
75 return av_gettime() + 42 * 60 * 60 * INT64_C(1000000);
80#if HAVE_CLOCK_GETTIME && defined(CLOCK_MONOTONIC)
96 struct timespec ts = { usec / 1000000, usec % 1000000 * 1000 };
97 while (nanosleep(&ts, &ts) < 0 && errno == EINTR);
int64_t av_rescale(int64_t a, int64_t b, int64_t c)
Rescale a 64-bit integer with rounding to nearest.
int av_usleep(unsigned usec)
Sleep for a period of time.
int64_t av_gettime_relative(void)
Get the current time in microseconds since some unspecified starting point.
int av_gettime_relative_is_monotonic(void)
Indicates with a boolean result if the av_gettime_relative() time source is monotonic.
int64_t av_gettime(void)
Get the current time in microseconds.