[x264-devel] [patch] Prefer clock_gettime(CLOCK_MONOTONIC) on Linux.

Brad Smith brad at comstyle.com
Sun Jun 24 19:28:23 CEST 2018


This should be using a test in the configure script for clock_gettime()
and not limited to Linux.


On 6/16/2018 2:01 AM, Petter Reinholdtsen wrote:
> This avoid discontinuous jumps in the system time that affect
> gettimeofday() on Linux.
>
> Based on patch from Kieran Kunhya found in x264-obe.
>
> diff --git a/common/osdep.c b/common/osdep.c
> index 3f43d483..d1eeb6e8 100644
> --- a/common/osdep.c
> +++ b/common/osdep.c
> @@ -51,6 +51,10 @@ int64_t x264_mdate( void )
>       struct timeb tb;
>       ftime( &tb );
>       return ((int64_t)tb.time * 1000 + (int64_t)tb.millitm) * 1000;
> +#elif SYS_LINUX
> +    struct timespec ts_current;
> +    clock_gettime( CLOCK_MONOTONIC, &ts_current );
> +    return (int64_t)ts_current.tv_sec * 1000000 + (int64_t)ts_current.tv_nsec / 1000;
>   #else
>       struct timeval tv_date;
>       gettimeofday( &tv_date, NULL );
>



More information about the x264-devel mailing list