| 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 14 matching lines...) Expand all Loading... |
| 25 #include <windows.h> | 25 #include <windows.h> |
| 26 #else | 26 #else |
| 27 /* | 27 /* |
| 28 * POSIX specific includes | 28 * POSIX specific includes |
| 29 */ | 29 */ |
| 30 #include <sys/time.h> | 30 #include <sys/time.h> |
| 31 | 31 |
| 32 /* timersub is not provided by msys at this time. */ | 32 /* timersub is not provided by msys at this time. */ |
| 33 #ifndef timersub | 33 #ifndef timersub |
| 34 #define timersub(a, b, result) \ | 34 #define timersub(a, b, result) \ |
| 35 do { \ | 35 do { \ |
| 36 (result)->tv_sec = (a)->tv_sec - (b)->tv_sec; \ | 36 (result)->tv_sec = (a)->tv_sec - (b)->tv_sec; \ |
| 37 (result)->tv_usec = (a)->tv_usec - (b)->tv_usec; \ | 37 (result)->tv_usec = (a)->tv_usec - (b)->tv_usec; \ |
| 38 if ((result)->tv_usec < 0) { \ | 38 if ((result)->tv_usec < 0) { \ |
| 39 --(result)->tv_sec; \ | 39 --(result)->tv_sec; \ |
| 40 (result)->tv_usec += 1000000; \ | 40 (result)->tv_usec += 1000000; \ |
| 41 } \ | 41 } \ |
| 42 } while (0) | 42 } while (0) |
| 43 #endif | 43 #endif |
| 44 #endif | 44 #endif |
| 45 | 45 |
| 46 | 46 |
| 47 struct vpx_usec_timer | 47 struct vpx_usec_timer { |
| 48 { | |
| 49 #if defined(_WIN32) | 48 #if defined(_WIN32) |
| 50 LARGE_INTEGER begin, end; | 49 LARGE_INTEGER begin, end; |
| 51 #else | 50 #else |
| 52 struct timeval begin, end; | 51 struct timeval begin, end; |
| 53 #endif | 52 #endif |
| 54 }; | 53 }; |
| 55 | 54 |
| 56 | 55 |
| 57 static void | 56 static void |
| 58 vpx_usec_timer_start(struct vpx_usec_timer *t) | 57 vpx_usec_timer_start(struct vpx_usec_timer *t) { |
| 59 { | |
| 60 #if defined(_WIN32) | 58 #if defined(_WIN32) |
| 61 QueryPerformanceCounter(&t->begin); | 59 QueryPerformanceCounter(&t->begin); |
| 62 #else | 60 #else |
| 63 gettimeofday(&t->begin, NULL); | 61 gettimeofday(&t->begin, NULL); |
| 64 #endif | 62 #endif |
| 65 } | 63 } |
| 66 | 64 |
| 67 | 65 |
| 68 static void | 66 static void |
| 69 vpx_usec_timer_mark(struct vpx_usec_timer *t) | 67 vpx_usec_timer_mark(struct vpx_usec_timer *t) { |
| 70 { | |
| 71 #if defined(_WIN32) | 68 #if defined(_WIN32) |
| 72 QueryPerformanceCounter(&t->end); | 69 QueryPerformanceCounter(&t->end); |
| 73 #else | 70 #else |
| 74 gettimeofday(&t->end, NULL); | 71 gettimeofday(&t->end, NULL); |
| 75 #endif | 72 #endif |
| 76 } | 73 } |
| 77 | 74 |
| 78 | 75 |
| 79 static int64_t | 76 static int64_t |
| 80 vpx_usec_timer_elapsed(struct vpx_usec_timer *t) | 77 vpx_usec_timer_elapsed(struct vpx_usec_timer *t) { |
| 81 { | |
| 82 #if defined(_WIN32) | 78 #if defined(_WIN32) |
| 83 LARGE_INTEGER freq, diff; | 79 LARGE_INTEGER freq, diff; |
| 84 | 80 |
| 85 diff.QuadPart = t->end.QuadPart - t->begin.QuadPart; | 81 diff.QuadPart = t->end.QuadPart - t->begin.QuadPart; |
| 86 | 82 |
| 87 QueryPerformanceFrequency(&freq); | 83 QueryPerformanceFrequency(&freq); |
| 88 return diff.QuadPart * 1000000 / freq.QuadPart; | 84 return diff.QuadPart * 1000000 / freq.QuadPart; |
| 89 #else | 85 #else |
| 90 struct timeval diff; | 86 struct timeval diff; |
| 91 | 87 |
| 92 timersub(&t->end, &t->begin, &diff); | 88 timersub(&t->end, &t->begin, &diff); |
| 93 return diff.tv_sec * 1000000 + diff.tv_usec; | 89 return diff.tv_sec * 1000000 + diff.tv_usec; |
| 94 #endif | 90 #endif |
| 95 } | 91 } |
| 96 | 92 |
| 97 #else /* CONFIG_OS_SUPPORT = 0*/ | 93 #else /* CONFIG_OS_SUPPORT = 0*/ |
| 98 | 94 |
| 99 /* Empty timer functions if CONFIG_OS_SUPPORT = 0 */ | 95 /* Empty timer functions if CONFIG_OS_SUPPORT = 0 */ |
| 100 #ifndef timersub | 96 #ifndef timersub |
| 101 #define timersub(a, b, result) | 97 #define timersub(a, b, result) |
| 102 #endif | 98 #endif |
| 103 | 99 |
| 104 struct vpx_usec_timer | 100 struct vpx_usec_timer { |
| 105 { | 101 void *dummy; |
| 106 void *dummy; | |
| 107 }; | 102 }; |
| 108 | 103 |
| 109 static void | 104 static void |
| 110 vpx_usec_timer_start(struct vpx_usec_timer *t) { } | 105 vpx_usec_timer_start(struct vpx_usec_timer *t) { } |
| 111 | 106 |
| 112 static void | 107 static void |
| 113 vpx_usec_timer_mark(struct vpx_usec_timer *t) { } | 108 vpx_usec_timer_mark(struct vpx_usec_timer *t) { } |
| 114 | 109 |
| 115 static long | 110 static long |
| 116 vpx_usec_timer_elapsed(struct vpx_usec_timer *t) { return 0; } | 111 vpx_usec_timer_elapsed(struct vpx_usec_timer *t) { |
| 112 return 0; |
| 113 } |
| 117 | 114 |
| 118 #endif /* CONFIG_OS_SUPPORT */ | 115 #endif /* CONFIG_OS_SUPPORT */ |
| 119 | 116 |
| 120 #endif | 117 #endif |
| OLD | NEW |