mirror of
https://code.videolan.org/videolan/dav1d
synced 2026-06-11 04:03:05 +00:00
Use CLOCK_REALTIME for providing the initial seed value
CLOCK_MONOTONIC is specified as returning time "since an unspecified point in the past". On RISC OS with UnixLib this returns the time since the last hard reset, but with SharedCLibrary this returns the time since the program started - combined with the coarse resolution used internally, this almost always results in a seed of 0. CLOCK_REALTIME meanwhile is specified as returning time since the epoch, so it should behave consistently across all platforms.
This commit is contained in:
@@ -644,7 +644,7 @@ static unsigned get_seed(void) {
|
||||
return (unsigned) mach_absolute_time();
|
||||
#else
|
||||
struct timespec ts;
|
||||
clock_gettime(CLOCK_MONOTONIC, &ts);
|
||||
clock_gettime(CLOCK_REALTIME, &ts);
|
||||
return (unsigned) (1000000000ULL * ts.tv_sec + ts.tv_nsec);
|
||||
#endif
|
||||
}
|
||||
|
||||
+1
-1
@@ -62,7 +62,7 @@ static unsigned get_seed(void) {
|
||||
return (unsigned) mach_absolute_time();
|
||||
#elif HAVE_CLOCK_GETTIME
|
||||
struct timespec ts;
|
||||
clock_gettime(CLOCK_MONOTONIC, &ts);
|
||||
clock_gettime(CLOCK_REALTIME, &ts);
|
||||
return (unsigned) (1000000000ULL * ts.tv_sec + ts.tv_nsec);
|
||||
#endif
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user