Fixes a win build issue related to denoising.
[profile/ivi/libvpx.git] / vpx_ports / vpx_timer.h
index f5e817f..d07e086 100644 (file)
@@ -1,5 +1,5 @@
 /*
- *  Copyright (c) 2010 The VP8 project authors. All Rights Reserved.
+ *  Copyright (c) 2010 The WebM project authors. All Rights Reserved.
  *
  *  Use of this source code is governed by a BSD-style license
  *  that can be found in the LICENSE file in the root of the source
 
 #ifndef VPX_TIMER_H
 #define VPX_TIMER_H
+#include "vpx/vpx_integer.h"
 
-#if defined(_MSC_VER)
+#if CONFIG_OS_SUPPORT
+
+#if defined(_WIN32)
 /*
  * Win32 specific includes
  */
@@ -43,7 +46,7 @@
 
 struct vpx_usec_timer
 {
-#if defined(_MSC_VER)
+#if defined(_WIN32)
     LARGE_INTEGER  begin, end;
 #else
     struct timeval begin, end;
@@ -54,7 +57,7 @@ struct vpx_usec_timer
 static void
 vpx_usec_timer_start(struct vpx_usec_timer *t)
 {
-#if defined(_MSC_VER)
+#if defined(_WIN32)
     QueryPerformanceCounter(&t->begin);
 #else
     gettimeofday(&t->begin, NULL);
@@ -65,7 +68,7 @@ vpx_usec_timer_start(struct vpx_usec_timer *t)
 static void
 vpx_usec_timer_mark(struct vpx_usec_timer *t)
 {
-#if defined(_MSC_VER)
+#if defined(_WIN32)
     QueryPerformanceCounter(&t->end);
 #else
     gettimeofday(&t->end, NULL);
@@ -73,25 +76,45 @@ 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(_MSC_VER)
+#if defined(_WIN32)
     LARGE_INTEGER freq, diff;
 
     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
 }
 
+#else /* CONFIG_OS_SUPPORT = 0*/
+
+/* Empty timer functions if CONFIG_OS_SUPPORT = 0 */
+#ifndef timersub
+#define timersub(a, b, result)
+#endif
+
+struct vpx_usec_timer
+{
+    void *dummy;
+};
+
+static void
+vpx_usec_timer_start(struct vpx_usec_timer *t) { }
+
+static void
+vpx_usec_timer_mark(struct vpx_usec_timer *t) { }
+
+static long
+vpx_usec_timer_elapsed(struct vpx_usec_timer *t) { return 0; }
+
+#endif /* CONFIG_OS_SUPPORT */
 
 #endif