[FFmpeg-cvslog] timer: use mach_absolute_time as high resolution clock on darwin

Janne Grunau git at videolan.org
Sun Mar 9 15:23:31 CET 2014


ffmpeg | branch: master | Janne Grunau <j at jannau.net> | Fri Jan 24 01:15:31 2014 +0100| [c708b5403346255ea5adc776645616cc7c61f078] | committer: Janne Grunau

timer: use mach_absolute_time as high resolution clock on darwin

Not guaranteed to be in nanosecond resolution. On iOS 7 the duration
of one tick is 125/3 ns which is still more than an order of magnitude
better then microseconds.

Replace decicycles with the neutral UNITS. Decicycles is strange but
tenths of a nanosecond and unspecific "deci"-ticks for mach_absolute_time
is just silly.

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

 configure         |    4 ++++
 libavutil/timer.h |   14 +++++++++++---
 2 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/configure b/configure
index 0ac7328..766df99 100755
--- a/configure
+++ b/configure
@@ -1387,6 +1387,8 @@ HAVE_LIST="
     local_aligned_8
     localtime_r
     loongson
+    mach_absolute_time
+    mach_mach_time_h
     machine_ioctl_bt848_h
     machine_ioctl_meteor_h
     machine_rw_barrier
@@ -3853,6 +3855,7 @@ check_struct "sys/time.h sys/resource.h" "struct rusage" ru_maxrss
 check_func  gettimeofday
 check_func  isatty
 check_func  localtime_r
+check_func  mach_absolute_time
 check_func  ${malloc_prefix}memalign            && enable memalign
 check_func  mkstemp
 check_func  mmap
@@ -3887,6 +3890,7 @@ check_header dlfcn.h
 check_header dxva.h
 check_header dxva2api.h
 check_header io.h
+check_header mach/mach_time.h
 check_header malloc.h
 check_header poll.h
 check_header sys/mman.h
diff --git a/libavutil/timer.h b/libavutil/timer.h
index d2c5001..0d93d7c 100644
--- a/libavutil/timer.h
+++ b/libavutil/timer.h
@@ -32,6 +32,10 @@
 
 #include "config.h"
 
+#if HAVE_MACH_MACH_TIME_H
+#include <mach/mach_time.h>
+#endif
+
 #include "log.h"
 
 #if   ARCH_ARM
@@ -44,8 +48,12 @@
 #   include "x86/timer.h"
 #endif
 
-#if !defined(AV_READ_TIME) && HAVE_GETHRTIME
-#   define AV_READ_TIME gethrtime
+#if !defined(AV_READ_TIME)
+#   if HAVE_GETHRTIME
+#       define AV_READ_TIME gethrtime
+#   elif HAVE_MACH_ABSOLUTE_TIME
+#       define AV_READ_TIME mach_absolute_time
+#   endif
 #endif
 
 #ifdef AV_READ_TIME
@@ -68,7 +76,7 @@
             tskip_count++;                                                \
         if (((tcount + tskip_count) & (tcount + tskip_count - 1)) == 0) { \
             av_log(NULL, AV_LOG_ERROR,                                    \
-                   "%"PRIu64" decicycles in %s, %d runs, %d skips\n",     \
+                   "%"PRIu64" UNITS in %s, %d runs, %d skips\n",          \
                    tsum * 10 / tcount, id, tcount, tskip_count);          \
         }                                                                 \
     }



More information about the ffmpeg-cvslog mailing list