vpx_timer: increase resolution
authorJohn Koleszar <jkoleszar@google.com>
Thu, 1 Mar 2012 20:49:43 +0000 (12:49 -0800)
committerJohn Koleszar <jkoleszar@google.com>
Thu, 1 Mar 2012 21:57:17 +0000 (13:57 -0800)
There's no useful reason to limit this timer to 1 second.

Change-Id: Idd1960268624e8bdfe958d99833ae6482fdb423e

vpx_ports/vpx_timer.h

index c8335a0..d07e086 100644 (file)
@@ -11,6 +11,7 @@
 
 #ifndef VPX_TIMER_H
 #define VPX_TIMER_H
+#include "vpx/vpx_integer.h"
 
 #if CONFIG_OS_SUPPORT
 
@@ -75,7 +76,7 @@ vpx_usec_timer_mark(struct vpx_usec_timer *t)
 }
 
 
-static long
+static int64_t
 vpx_usec_timer_elapsed(struct vpx_usec_timer *t)
 {
 #if defined(_WIN32)
@@ -83,15 +84,13 @@ vpx_usec_timer_elapsed(struct vpx_usec_timer *t)
 
     diff.QuadPart = t->end.QuadPart - t->begin.QuadPart;
 
-    if (QueryPerformanceFrequency(&freq) && diff.QuadPart < freq.QuadPart)
-        return (long)(diff.QuadPart * 1000000 / freq.QuadPart);
-
-    return 1000000;
+    QueryPerformanceFrequency(&freq);
+    return diff.QuadPart * 1000000 / freq.QuadPart;
 #else
     struct timeval diff;
 
     timersub(&t->end, &t->begin, &diff);
-    return diff.tv_sec ? 1000000 : diff.tv_usec;
+    return diff.tv_sec * 1000000 + diff.tv_usec;
 #endif
 }