Coverage Report

Created: 2022-08-24 06:15

/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
#include "aom/aom_integer.h"
18
19
#if CONFIG_OS_SUPPORT
20
21
#if defined(_WIN32)
22
/*
23
 * Win32 specific includes
24
 */
25
#ifndef WIN32_LEAN_AND_MEAN
26
#define WIN32_LEAN_AND_MEAN
27
#endif
28
#include <windows.h>
29
#else
30
/*
31
 * POSIX specific includes
32
 */
33
#include <sys/time.h>
34
35
/* timersub is not provided by msys at this time. */
36
#ifndef timersub
37
#define timersub(a, b, result)                       \
38
  do {                                               \
39
    (result)->tv_sec = (a)->tv_sec - (b)->tv_sec;    \
40
    (result)->tv_usec = (a)->tv_usec - (b)->tv_usec; \
41
    if ((result)->tv_usec < 0) {                     \
42
      --(result)->tv_sec;                            \
43
      (result)->tv_usec += 1000000;                  \
44
    }                                                \
45
  } while (0)
46
#endif
47
#endif
48
49
struct aom_usec_timer {
50
#if defined(_WIN32)
51
  LARGE_INTEGER begin, end;
52
#else
53
  struct timeval begin, end;
54
#endif
55
};
56
57
0
static INLINE void aom_usec_timer_start(struct aom_usec_timer *t) {
58
0
#if defined(_WIN32)
59
0
  QueryPerformanceCounter(&t->begin);
60
0
#else
61
0
  gettimeofday(&t->begin, NULL);
62
0
#endif
63
0
}
Unexecuted instantiation: decodeframe.c:aom_usec_timer_start
Unexecuted instantiation: decoder.c:aom_usec_timer_start
Unexecuted instantiation: encoder.c:aom_usec_timer_start
Unexecuted instantiation: ethread.c:aom_usec_timer_start
Unexecuted instantiation: rdopt.c:aom_usec_timer_start
Unexecuted instantiation: temporal_filter.c:aom_usec_timer_start
Unexecuted instantiation: tpl_model.c:aom_usec_timer_start
Unexecuted instantiation: var_based_part.c:aom_usec_timer_start
Unexecuted instantiation: encodeframe.c:aom_usec_timer_start
Unexecuted instantiation: encodeframe_utils.c:aom_usec_timer_start
Unexecuted instantiation: motion_search_facade.c:aom_usec_timer_start
Unexecuted instantiation: partition_search.c:aom_usec_timer_start
Unexecuted instantiation: partition_strategy.c:aom_usec_timer_start
Unexecuted instantiation: nonrd_pickmode.c:aom_usec_timer_start
64
65
0
static INLINE void aom_usec_timer_mark(struct aom_usec_timer *t) {
66
0
#if defined(_WIN32)
67
0
  QueryPerformanceCounter(&t->end);
68
0
#else
69
0
  gettimeofday(&t->end, NULL);
70
0
#endif
71
0
}
Unexecuted instantiation: decodeframe.c:aom_usec_timer_mark
Unexecuted instantiation: decoder.c:aom_usec_timer_mark
Unexecuted instantiation: encoder.c:aom_usec_timer_mark
Unexecuted instantiation: ethread.c:aom_usec_timer_mark
Unexecuted instantiation: rdopt.c:aom_usec_timer_mark
Unexecuted instantiation: temporal_filter.c:aom_usec_timer_mark
Unexecuted instantiation: tpl_model.c:aom_usec_timer_mark
Unexecuted instantiation: var_based_part.c:aom_usec_timer_mark
Unexecuted instantiation: encodeframe.c:aom_usec_timer_mark
Unexecuted instantiation: encodeframe_utils.c:aom_usec_timer_mark
Unexecuted instantiation: motion_search_facade.c:aom_usec_timer_mark
Unexecuted instantiation: partition_search.c:aom_usec_timer_mark
Unexecuted instantiation: partition_strategy.c:aom_usec_timer_mark
Unexecuted instantiation: nonrd_pickmode.c:aom_usec_timer_mark
72
73
0
static INLINE int64_t aom_usec_timer_elapsed(struct aom_usec_timer *t) {
74
0
#if defined(_WIN32)
75
0
  LARGE_INTEGER freq, diff;
76
0
77
0
  diff.QuadPart = t->end.QuadPart - t->begin.QuadPart;
78
0
79
0
  QueryPerformanceFrequency(&freq);
80
0
  return diff.QuadPart * 1000000 / freq.QuadPart;
81
0
#else
82
0
  struct timeval diff;
83
0
84
0
  timersub(&t->end, &t->begin, &diff);
85
0
  return ((int64_t)diff.tv_sec) * 1000000 + diff.tv_usec;
86
0
#endif
87
0
}
Unexecuted instantiation: decodeframe.c:aom_usec_timer_elapsed
Unexecuted instantiation: decoder.c:aom_usec_timer_elapsed
Unexecuted instantiation: encoder.c:aom_usec_timer_elapsed
Unexecuted instantiation: ethread.c:aom_usec_timer_elapsed
Unexecuted instantiation: rdopt.c:aom_usec_timer_elapsed
Unexecuted instantiation: temporal_filter.c:aom_usec_timer_elapsed
Unexecuted instantiation: tpl_model.c:aom_usec_timer_elapsed
Unexecuted instantiation: var_based_part.c:aom_usec_timer_elapsed
Unexecuted instantiation: encodeframe.c:aom_usec_timer_elapsed
Unexecuted instantiation: encodeframe_utils.c:aom_usec_timer_elapsed
Unexecuted instantiation: motion_search_facade.c:aom_usec_timer_elapsed
Unexecuted instantiation: partition_search.c:aom_usec_timer_elapsed
Unexecuted instantiation: partition_strategy.c:aom_usec_timer_elapsed
Unexecuted instantiation: nonrd_pickmode.c:aom_usec_timer_elapsed
88
89
#else /* CONFIG_OS_SUPPORT = 0*/
90
91
/* Empty timer functions if CONFIG_OS_SUPPORT = 0 */
92
#ifndef timersub
93
#define timersub(a, b, result)
94
#endif
95
96
struct aom_usec_timer {
97
  void *dummy;
98
};
99
100
static INLINE void aom_usec_timer_start(struct aom_usec_timer *t) { (void)t; }
101
102
static INLINE void aom_usec_timer_mark(struct aom_usec_timer *t) { (void)t; }
103
104
static INLINE int aom_usec_timer_elapsed(struct aom_usec_timer *t) {
105
  (void)t;
106
  return 0;
107
}
108
109
#endif /* CONFIG_OS_SUPPORT */
110
111
#endif  // AOM_AOM_PORTS_AOM_TIMER_H_