Coverage Report

Created: 2025-08-28 07:12

/src/libvpx/vpx_ports/vpx_timer.h
Line
Count
Source
1
/*
2
 *  Copyright (c) 2010 The WebM project authors. All Rights Reserved.
3
 *
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
6
 *  tree. An additional intellectual property rights grant can be found
7
 *  in the file PATENTS.  All contributing project authors may
8
 *  be found in the AUTHORS file in the root of the source tree.
9
 */
10
11
#ifndef VPX_VPX_PORTS_VPX_TIMER_H_
12
#define VPX_VPX_PORTS_VPX_TIMER_H_
13
14
#include "./vpx_config.h"
15
16
#include "vpx/vpx_integer.h"
17
18
#if CONFIG_OS_SUPPORT
19
20
#if defined(_WIN32)
21
/*
22
 * Win32 specific includes
23
 */
24
#undef NOMINMAX
25
#define NOMINMAX
26
#ifndef WIN32_LEAN_AND_MEAN
27
#define WIN32_LEAN_AND_MEAN
28
#endif
29
#include <windows.h>
30
#else
31
/*
32
 * POSIX specific includes
33
 */
34
#include <time.h>
35
36
/* timersub is not provided by msys at this time. */
37
#ifndef timersub_ns
38
#define timersub_ns(a, b, result)                    \
39
43.7k
  do {                                               \
40
43.7k
    (result)->tv_sec = (a)->tv_sec - (b)->tv_sec;    \
41
43.7k
    (result)->tv_nsec = (a)->tv_nsec - (b)->tv_nsec; \
42
43.7k
    if ((result)->tv_nsec < 0) {                     \
43
23
      --(result)->tv_sec;                            \
44
23
      (result)->tv_nsec += 1000000000;               \
45
23
    }                                                \
46
43.7k
  } while (0)
47
#endif
48
#endif
49
50
struct vpx_usec_timer {
51
#if defined(_WIN32)
52
  LARGE_INTEGER begin, end;
53
#else
54
  struct timespec begin, end;
55
#endif
56
};
57
58
43.7k
static INLINE void vpx_usec_timer_start(struct vpx_usec_timer *t) {
59
#if defined(_WIN32)
60
  QueryPerformanceCounter(&t->begin);
61
#elif defined(CLOCK_MONOTONIC_RAW)
62
  clock_gettime(CLOCK_MONOTONIC_RAW, &t->begin);
63
#else
64
  clock_gettime(CLOCK_MONOTONIC, &t->begin);
65
#endif
66
43.7k
}
Unexecuted instantiation: onyxd_if.c:vpx_usec_timer_start
Unexecuted instantiation: threading.c:vpx_usec_timer_start
Unexecuted instantiation: vp9_decoder.c:vpx_usec_timer_start
Unexecuted instantiation: vp9_encoder.c:vpx_usec_timer_start
Unexecuted instantiation: vp9_temporal_filter.c:vpx_usec_timer_start
Unexecuted instantiation: vp9_encodeframe.c:vpx_usec_timer_start
onyx_if.c:vpx_usec_timer_start
Line
Count
Source
58
43.7k
static INLINE void vpx_usec_timer_start(struct vpx_usec_timer *t) {
59
#if defined(_WIN32)
60
  QueryPerformanceCounter(&t->begin);
61
#elif defined(CLOCK_MONOTONIC_RAW)
62
  clock_gettime(CLOCK_MONOTONIC_RAW, &t->begin);
63
#else
64
  clock_gettime(CLOCK_MONOTONIC, &t->begin);
65
#endif
66
43.7k
}
Unexecuted instantiation: temporal_filter.c:vpx_usec_timer_start
Unexecuted instantiation: encodeframe.c:vpx_usec_timer_start
67
68
43.7k
static INLINE void vpx_usec_timer_mark(struct vpx_usec_timer *t) {
69
#if defined(_WIN32)
70
  QueryPerformanceCounter(&t->end);
71
#elif defined(CLOCK_MONOTONIC_RAW)
72
  clock_gettime(CLOCK_MONOTONIC_RAW, &t->end);
73
#else
74
  clock_gettime(CLOCK_MONOTONIC, &t->end);
75
#endif
76
43.7k
}
Unexecuted instantiation: onyxd_if.c:vpx_usec_timer_mark
Unexecuted instantiation: threading.c:vpx_usec_timer_mark
Unexecuted instantiation: vp9_decoder.c:vpx_usec_timer_mark
Unexecuted instantiation: vp9_encoder.c:vpx_usec_timer_mark
Unexecuted instantiation: vp9_temporal_filter.c:vpx_usec_timer_mark
Unexecuted instantiation: vp9_encodeframe.c:vpx_usec_timer_mark
onyx_if.c:vpx_usec_timer_mark
Line
Count
Source
68
43.7k
static INLINE void vpx_usec_timer_mark(struct vpx_usec_timer *t) {
69
#if defined(_WIN32)
70
  QueryPerformanceCounter(&t->end);
71
#elif defined(CLOCK_MONOTONIC_RAW)
72
  clock_gettime(CLOCK_MONOTONIC_RAW, &t->end);
73
#else
74
  clock_gettime(CLOCK_MONOTONIC, &t->end);
75
#endif
76
43.7k
}
Unexecuted instantiation: temporal_filter.c:vpx_usec_timer_mark
Unexecuted instantiation: encodeframe.c:vpx_usec_timer_mark
77
78
43.7k
static INLINE int64_t vpx_usec_timer_elapsed(struct vpx_usec_timer *t) {
79
#if defined(_WIN32)
80
  LARGE_INTEGER freq, diff;
81
82
  diff.QuadPart = t->end.QuadPart - t->begin.QuadPart;
83
84
  QueryPerformanceFrequency(&freq);
85
  return diff.QuadPart * 1000000 / freq.QuadPart;
86
#else
87
43.7k
  struct timespec diff;
88
89
43.7k
  timersub_ns(&t->end, &t->begin, &diff);
90
43.7k
  return (int64_t)diff.tv_sec * 1000000 + diff.tv_nsec / 1000;
91
43.7k
#endif
92
43.7k
}
Unexecuted instantiation: onyxd_if.c:vpx_usec_timer_elapsed
Unexecuted instantiation: threading.c:vpx_usec_timer_elapsed
Unexecuted instantiation: vp9_decoder.c:vpx_usec_timer_elapsed
Unexecuted instantiation: vp9_encoder.c:vpx_usec_timer_elapsed
Unexecuted instantiation: vp9_temporal_filter.c:vpx_usec_timer_elapsed
Unexecuted instantiation: vp9_encodeframe.c:vpx_usec_timer_elapsed
onyx_if.c:vpx_usec_timer_elapsed
Line
Count
Source
78
43.7k
static INLINE int64_t vpx_usec_timer_elapsed(struct vpx_usec_timer *t) {
79
#if defined(_WIN32)
80
  LARGE_INTEGER freq, diff;
81
82
  diff.QuadPart = t->end.QuadPart - t->begin.QuadPart;
83
84
  QueryPerformanceFrequency(&freq);
85
  return diff.QuadPart * 1000000 / freq.QuadPart;
86
#else
87
43.7k
  struct timespec diff;
88
89
43.7k
  timersub_ns(&t->end, &t->begin, &diff);
90
43.7k
  return (int64_t)diff.tv_sec * 1000000 + diff.tv_nsec / 1000;
91
43.7k
#endif
92
43.7k
}
Unexecuted instantiation: temporal_filter.c:vpx_usec_timer_elapsed
Unexecuted instantiation: encodeframe.c:vpx_usec_timer_elapsed
93
94
#else /* CONFIG_OS_SUPPORT = 0*/
95
96
/* Empty timer functions if CONFIG_OS_SUPPORT = 0 */
97
#ifndef timersub_ns
98
#define timersub_ns(a, b, result)
99
#endif
100
101
struct vpx_usec_timer {
102
  void *dummy;
103
};
104
105
static INLINE void vpx_usec_timer_start(struct vpx_usec_timer *t) {}
106
107
static INLINE void vpx_usec_timer_mark(struct vpx_usec_timer *t) {}
108
109
static INLINE int vpx_usec_timer_elapsed(struct vpx_usec_timer *t) { return 0; }
110
111
#endif /* CONFIG_OS_SUPPORT */
112
113
#endif  // VPX_VPX_PORTS_VPX_TIMER_H_