Coverage Report

Created: 2025-06-13 07:07

/src/aom/aom_ports/aom_timer.h
Line
Count
Source (jump to first uncovered line)
1
/*
2
 * Copyright (c) 2016, Alliance for Open Media. All rights reserved.
3
 *
4
 * This source code is subject to the terms of the BSD 2 Clause License and
5
 * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
6
 * was not distributed with this source code in the LICENSE file, you can
7
 * obtain it at www.aomedia.org/license/software. If the Alliance for Open
8
 * Media Patent License 1.0 was not distributed with this source code in the
9
 * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
10
 */
11
12
#ifndef AOM_AOM_PORTS_AOM_TIMER_H_
13
#define AOM_AOM_PORTS_AOM_TIMER_H_
14
15
#include "config/aom_config.h"
16
17
#if CONFIG_OS_SUPPORT
18
19
#include <stddef.h>
20
#include <stdint.h>
21
22
#if defined(_WIN32)
23
/*
24
 * Win32 specific includes
25
 */
26
#undef NOMINMAX
27
#define NOMINMAX
28
#undef WIN32_LEAN_AND_MEAN
29
#define WIN32_LEAN_AND_MEAN
30
#include <windows.h>
31
#else
32
/*
33
 * POSIX specific includes
34
 */
35
#include <sys/time.h>
36
37
/* timersub is not provided by msys at this time. */
38
#ifndef timersub
39
#define timersub(a, b, result)                       \
40
  do {                                               \
41
    (result)->tv_sec = (a)->tv_sec - (b)->tv_sec;    \
42
    (result)->tv_usec = (a)->tv_usec - (b)->tv_usec; \
43
    if ((result)->tv_usec < 0) {                     \
44
      --(result)->tv_sec;                            \
45
      (result)->tv_usec += 1000000;                  \
46
    }                                                \
47
  } while (0)
48
#endif
49
#endif
50
51
struct aom_usec_timer {
52
#if defined(_WIN32)
53
  LARGE_INTEGER begin, end;
54
#else
55
  struct timeval begin, end;
56
#endif
57
};
58
59
0
static inline void aom_usec_timer_start(struct aom_usec_timer *t) {
60
0
#if defined(_WIN32)
61
0
  QueryPerformanceCounter(&t->begin);
62
0
#else
63
0
  gettimeofday(&t->begin, NULL);
64
0
#endif
65
0
}
Unexecuted instantiation: decodeframe.c:aom_usec_timer_start
Unexecuted instantiation: decoder.c:aom_usec_timer_start
66
67
0
static inline void aom_usec_timer_mark(struct aom_usec_timer *t) {
68
0
#if defined(_WIN32)
69
0
  QueryPerformanceCounter(&t->end);
70
0
#else
71
0
  gettimeofday(&t->end, NULL);
72
0
#endif
73
0
}
Unexecuted instantiation: decodeframe.c:aom_usec_timer_mark
Unexecuted instantiation: decoder.c:aom_usec_timer_mark
74
75
0
static inline int64_t aom_usec_timer_elapsed(struct aom_usec_timer *t) {
76
0
#if defined(_WIN32)
77
0
  LARGE_INTEGER freq, diff;
78
0
79
0
  diff.QuadPart = t->end.QuadPart - t->begin.QuadPart;
80
0
81
0
  QueryPerformanceFrequency(&freq);
82
0
  return diff.QuadPart * 1000000 / freq.QuadPart;
83
0
#else
84
0
  struct timeval diff;
85
0
86
0
  timersub(&t->end, &t->begin, &diff);
87
0
  return ((int64_t)diff.tv_sec) * 1000000 + diff.tv_usec;
88
0
#endif
89
0
}
Unexecuted instantiation: decodeframe.c:aom_usec_timer_elapsed
Unexecuted instantiation: decoder.c:aom_usec_timer_elapsed
90
91
#else /* CONFIG_OS_SUPPORT = 0*/
92
93
/* Empty timer functions if CONFIG_OS_SUPPORT = 0 */
94
#ifndef timersub
95
#define timersub(a, b, result)
96
#endif
97
98
struct aom_usec_timer {
99
  void *dummy;
100
};
101
102
static inline void aom_usec_timer_start(struct aom_usec_timer *t) { (void)t; }
103
104
static inline void aom_usec_timer_mark(struct aom_usec_timer *t) { (void)t; }
105
106
static inline int aom_usec_timer_elapsed(struct aom_usec_timer *t) {
107
  (void)t;
108
  return 0;
109
}
110
111
#endif /* CONFIG_OS_SUPPORT */
112
113
#endif  // AOM_AOM_PORTS_AOM_TIMER_H_