[FFmpeg-cvslog] avutil/timer: Add clock_gettime as a fallback of AV_READ_TIME

Zhao Zhili git at videolan.org
Mon Jun 10 20:12:44 EEST 2024


ffmpeg | branch: master | Zhao Zhili <zhilizhao at tencent.com> | Fri Jun  7 21:44:50 2024 +0800| [33e4cc963d5e2a189e4e52eaa38e9a8e31dad35a] | committer: Zhao Zhili

avutil/timer: Add clock_gettime as a fallback of AV_READ_TIME

Reviewed-by: Rémi Denis-Courmont <remi at remlab.net>
Reviewed-by: Martin Storsjö <martin at martin.st>
Signed-off-by: Zhao Zhili <zhilizhao at tencent.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=33e4cc963d5e2a189e4e52eaa38e9a8e31dad35a
---

 libavutil/timer.h | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/libavutil/timer.h b/libavutil/timer.h
index 2cd299eca3..6bd6a0c645 100644
--- a/libavutil/timer.h
+++ b/libavutil/timer.h
@@ -46,6 +46,8 @@
 #include "macos_kperf.h"
 #elif HAVE_MACH_ABSOLUTE_TIME
 #include <mach/mach_time.h>
+#elif HAVE_CLOCK_GETTIME
+#include <time.h>
 #endif
 
 #include "common.h"
@@ -70,6 +72,14 @@
 #       define AV_READ_TIME gethrtime
 #   elif HAVE_MACH_ABSOLUTE_TIME
 #       define AV_READ_TIME mach_absolute_time
+#   elif HAVE_CLOCK_GETTIME && defined(CLOCK_MONOTONIC)
+        static inline int64_t ff_read_time(void)
+        {
+            struct timespec ts;
+            clock_gettime(CLOCK_MONOTONIC, &ts);
+            return ts.tv_sec * INT64_C(1000000000) + ts.tv_nsec;
+        }
+#       define AV_READ_TIME ff_read_time
 #   endif
 #endif
 



More information about the ffmpeg-cvslog mailing list