[FFmpeg-devel] [PATCH] arm/aarch64: Use mach_absolute_time as timer on apple platforms

Martin Storsjö martin at martin.st
Fri Feb 12 12:32:56 EET 2021


This is much less precise than the cycle counter register, but
the cycle counter register is not available on apple platforms
(and on linux, it requires a kernel module for allowing user mode
access).
---
 libavutil/aarch64/timer.h | 8 +++++++-
 libavutil/arm/timer.h     | 8 +++++++-
 2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/libavutil/aarch64/timer.h b/libavutil/aarch64/timer.h
index b570039416..8b28fd354c 100644
--- a/libavutil/aarch64/timer.h
+++ b/libavutil/aarch64/timer.h
@@ -24,7 +24,13 @@
 #include <stdint.h>
 #include "config.h"
 
-#if HAVE_INLINE_ASM
+#if defined(__APPLE__)
+
+#include <mach/mach_time.h>
+
+#define AV_READ_TIME mach_absolute_time
+
+#elif HAVE_INLINE_ASM
 
 #define AV_READ_TIME read_time
 
diff --git a/libavutil/arm/timer.h b/libavutil/arm/timer.h
index 5e8bc8edd0..caf23e2a5a 100644
--- a/libavutil/arm/timer.h
+++ b/libavutil/arm/timer.h
@@ -24,7 +24,13 @@
 #include <stdint.h>
 #include "config.h"
 
-#if HAVE_INLINE_ASM && defined(__ARM_ARCH_7A__)
+#if defined(__APPLE__)
+
+#include <mach/mach_time.h>
+
+#define AV_READ_TIME mach_absolute_time
+
+#elif HAVE_INLINE_ASM && defined(__ARM_ARCH_7A__)
 
 #define AV_READ_TIME read_time
 
-- 
2.25.1



More information about the ffmpeg-devel mailing list