OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2010 The WebM project authors. All Rights Reserved. | 2 * Copyright (c) 2010 The WebM project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 | 46 |
47 struct vpx_usec_timer { | 47 struct vpx_usec_timer { |
48 #if defined(_WIN32) | 48 #if defined(_WIN32) |
49 LARGE_INTEGER begin, end; | 49 LARGE_INTEGER begin, end; |
50 #else | 50 #else |
51 struct timeval begin, end; | 51 struct timeval begin, end; |
52 #endif | 52 #endif |
53 }; | 53 }; |
54 | 54 |
55 | 55 |
56 static void | 56 static INLINE void |
57 vpx_usec_timer_start(struct vpx_usec_timer *t) { | 57 vpx_usec_timer_start(struct vpx_usec_timer *t) { |
58 #if defined(_WIN32) | 58 #if defined(_WIN32) |
59 QueryPerformanceCounter(&t->begin); | 59 QueryPerformanceCounter(&t->begin); |
60 #else | 60 #else |
61 gettimeofday(&t->begin, NULL); | 61 gettimeofday(&t->begin, NULL); |
62 #endif | 62 #endif |
63 } | 63 } |
64 | 64 |
65 | 65 |
66 static void | 66 static INLINE void |
67 vpx_usec_timer_mark(struct vpx_usec_timer *t) { | 67 vpx_usec_timer_mark(struct vpx_usec_timer *t) { |
68 #if defined(_WIN32) | 68 #if defined(_WIN32) |
69 QueryPerformanceCounter(&t->end); | 69 QueryPerformanceCounter(&t->end); |
70 #else | 70 #else |
71 gettimeofday(&t->end, NULL); | 71 gettimeofday(&t->end, NULL); |
72 #endif | 72 #endif |
73 } | 73 } |
74 | 74 |
75 | 75 |
76 static int64_t | 76 static INLINE int64_t |
77 vpx_usec_timer_elapsed(struct vpx_usec_timer *t) { | 77 vpx_usec_timer_elapsed(struct vpx_usec_timer *t) { |
78 #if defined(_WIN32) | 78 #if defined(_WIN32) |
79 LARGE_INTEGER freq, diff; | 79 LARGE_INTEGER freq, diff; |
80 | 80 |
81 diff.QuadPart = t->end.QuadPart - t->begin.QuadPart; | 81 diff.QuadPart = t->end.QuadPart - t->begin.QuadPart; |
82 | 82 |
83 QueryPerformanceFrequency(&freq); | 83 QueryPerformanceFrequency(&freq); |
84 return diff.QuadPart * 1000000 / freq.QuadPart; | 84 return diff.QuadPart * 1000000 / freq.QuadPart; |
85 #else | 85 #else |
86 struct timeval diff; | 86 struct timeval diff; |
87 | 87 |
88 timersub(&t->end, &t->begin, &diff); | 88 timersub(&t->end, &t->begin, &diff); |
89 return diff.tv_sec * 1000000 + diff.tv_usec; | 89 return diff.tv_sec * 1000000 + diff.tv_usec; |
90 #endif | 90 #endif |
91 } | 91 } |
92 | 92 |
93 #else /* CONFIG_OS_SUPPORT = 0*/ | 93 #else /* CONFIG_OS_SUPPORT = 0*/ |
94 | 94 |
95 /* Empty timer functions if CONFIG_OS_SUPPORT = 0 */ | 95 /* Empty timer functions if CONFIG_OS_SUPPORT = 0 */ |
96 #ifndef timersub | 96 #ifndef timersub |
97 #define timersub(a, b, result) | 97 #define timersub(a, b, result) |
98 #endif | 98 #endif |
99 | 99 |
100 struct vpx_usec_timer { | 100 struct vpx_usec_timer { |
101 void *dummy; | 101 void *dummy; |
102 }; | 102 }; |
103 | 103 |
104 static void | 104 static INLINE void |
105 vpx_usec_timer_start(struct vpx_usec_timer *t) { } | 105 vpx_usec_timer_start(struct vpx_usec_timer *t) { } |
106 | 106 |
107 static void | 107 static INLINE void |
108 vpx_usec_timer_mark(struct vpx_usec_timer *t) { } | 108 vpx_usec_timer_mark(struct vpx_usec_timer *t) { } |
109 | 109 |
110 static long | 110 static INLINE int |
111 vpx_usec_timer_elapsed(struct vpx_usec_timer *t) { | 111 vpx_usec_timer_elapsed(struct vpx_usec_timer *t) { |
112 return 0; | 112 return 0; |
113 } | 113 } |
114 | 114 |
115 #endif /* CONFIG_OS_SUPPORT */ | 115 #endif /* CONFIG_OS_SUPPORT */ |
116 | 116 |
117 #endif // VPX_PORTS_VPX_TIMER_H_ | 117 #endif // VPX_PORTS_VPX_TIMER_H_ |
OLD | NEW |