Coverage Report

Created: 2026-05-31 06:16

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/dav1d/src/cpu.h
Line
Count
Source
1
/*
2
 * Copyright © 2018-2022, VideoLAN and dav1d authors
3
 * Copyright © 2018-2022, Two Orioles, LLC
4
 * All rights reserved.
5
 *
6
 * Redistribution and use in source and binary forms, with or without
7
 * modification, are permitted provided that the following conditions are met:
8
 *
9
 * 1. Redistributions of source code must retain the above copyright notice, this
10
 *    list of conditions and the following disclaimer.
11
 *
12
 * 2. Redistributions in binary form must reproduce the above copyright notice,
13
 *    this list of conditions and the following disclaimer in the documentation
14
 *    and/or other materials provided with the distribution.
15
 *
16
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19
 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
20
 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26
 */
27
28
#ifndef DAV1D_SRC_CPU_H
29
#define DAV1D_SRC_CPU_H
30
31
#include "config.h"
32
33
#include "common/attributes.h"
34
35
#include "dav1d/common.h"
36
#include "dav1d/dav1d.h"
37
38
#if ARCH_AARCH64 || ARCH_ARM
39
#include "src/arm/cpu.h"
40
#elif ARCH_LOONGARCH
41
#include "src/loongarch/cpu.h"
42
#elif ARCH_PPC64LE
43
#include "src/ppc/cpu.h"
44
#elif ARCH_RISCV
45
#include "src/riscv/cpu.h"
46
#elif ARCH_X86
47
#include "src/x86/cpu.h"
48
#endif
49
50
EXTERN unsigned dav1d_cpu_flags;
51
EXTERN unsigned dav1d_cpu_flags_mask;
52
53
void dav1d_init_cpu(void);
54
DAV1D_API void dav1d_set_cpu_flags_mask(unsigned mask);
55
int dav1d_num_logical_processors(Dav1dContext *c);
56
unsigned long dav1d_getauxval(unsigned long);
57
58
2
static ALWAYS_INLINE unsigned dav1d_get_default_cpu_flags(void) {
59
2
    unsigned flags = 0;
60
61
#if ARCH_AARCH64 || ARCH_ARM
62
#if defined(__ARM_NEON) || defined(__APPLE__) || defined(_WIN32) || ARCH_AARCH64
63
    flags |= DAV1D_ARM_CPU_FLAG_NEON;
64
#endif
65
#ifdef __ARM_FEATURE_DOTPROD
66
    flags |= DAV1D_ARM_CPU_FLAG_DOTPROD;
67
#endif
68
#ifdef __ARM_FEATURE_MATMUL_INT8
69
    flags |= DAV1D_ARM_CPU_FLAG_I8MM;
70
#endif
71
#if ARCH_AARCH64
72
#ifdef __ARM_FEATURE_SVE
73
    flags |= DAV1D_ARM_CPU_FLAG_SVE;
74
#endif
75
#ifdef __ARM_FEATURE_SVE2
76
    flags |= DAV1D_ARM_CPU_FLAG_SVE2;
77
#endif
78
#endif /* ARCH_AARCH64 */
79
#elif ARCH_PPC64LE
80
#if defined(__VSX__)
81
    flags |= DAV1D_PPC_CPU_FLAG_VSX;
82
#endif
83
#if defined(__POWER9_VECTOR__)
84
    flags |= DAV1D_PPC_CPU_FLAG_PWR9;
85
#endif
86
#elif ARCH_RISCV
87
#if defined(__riscv_v)
88
    flags |= DAV1D_RISCV_CPU_FLAG_V;
89
#endif
90
#elif ARCH_X86
91
#if defined(__AVX512F__) && defined(__AVX512CD__) && \
92
    defined(__AVX512BW__) && defined(__AVX512DQ__) && \
93
    defined(__AVX512VL__) && defined(__AVX512VNNI__) && \
94
    defined(__AVX512IFMA__) && defined(__AVX512VBMI__) && \
95
    defined(__AVX512VBMI2__) && defined(__AVX512VPOPCNTDQ__) && \
96
    defined(__AVX512BITALG__) && defined(__GFNI__) && \
97
    defined(__VAES__) && defined(__VPCLMULQDQ__)
98
    flags |= DAV1D_X86_CPU_FLAG_AVX512ICL |
99
             DAV1D_X86_CPU_FLAG_AVX2 |
100
             DAV1D_X86_CPU_FLAG_SSE41 |
101
             DAV1D_X86_CPU_FLAG_SSSE3 |
102
             DAV1D_X86_CPU_FLAG_SSE2;
103
#elif defined(__AVX2__)
104
    flags |= DAV1D_X86_CPU_FLAG_AVX2 |
105
             DAV1D_X86_CPU_FLAG_SSE41 |
106
             DAV1D_X86_CPU_FLAG_SSSE3 |
107
             DAV1D_X86_CPU_FLAG_SSE2;
108
#elif defined(__SSE4_1__) || defined(__AVX__)
109
    flags |= DAV1D_X86_CPU_FLAG_SSE41 |
110
             DAV1D_X86_CPU_FLAG_SSSE3 |
111
             DAV1D_X86_CPU_FLAG_SSE2;
112
#elif defined(__SSSE3__)
113
    flags |= DAV1D_X86_CPU_FLAG_SSSE3 |
114
             DAV1D_X86_CPU_FLAG_SSE2;
115
#elif ARCH_X86_64 || defined(__SSE2__) || \
116
      (defined(_M_IX86_FP) && _M_IX86_FP >= 2)
117
    flags |= DAV1D_X86_CPU_FLAG_SSE2;
118
2
#endif
119
2
#endif
120
121
2
    return flags;
122
2
}
Unexecuted instantiation: dav1d_fuzzer.c:dav1d_get_default_cpu_flags
cpu.c:dav1d_get_default_cpu_flags
Line
Count
Source
58
2
static ALWAYS_INLINE unsigned dav1d_get_default_cpu_flags(void) {
59
2
    unsigned flags = 0;
60
61
#if ARCH_AARCH64 || ARCH_ARM
62
#if defined(__ARM_NEON) || defined(__APPLE__) || defined(_WIN32) || ARCH_AARCH64
63
    flags |= DAV1D_ARM_CPU_FLAG_NEON;
64
#endif
65
#ifdef __ARM_FEATURE_DOTPROD
66
    flags |= DAV1D_ARM_CPU_FLAG_DOTPROD;
67
#endif
68
#ifdef __ARM_FEATURE_MATMUL_INT8
69
    flags |= DAV1D_ARM_CPU_FLAG_I8MM;
70
#endif
71
#if ARCH_AARCH64
72
#ifdef __ARM_FEATURE_SVE
73
    flags |= DAV1D_ARM_CPU_FLAG_SVE;
74
#endif
75
#ifdef __ARM_FEATURE_SVE2
76
    flags |= DAV1D_ARM_CPU_FLAG_SVE2;
77
#endif
78
#endif /* ARCH_AARCH64 */
79
#elif ARCH_PPC64LE
80
#if defined(__VSX__)
81
    flags |= DAV1D_PPC_CPU_FLAG_VSX;
82
#endif
83
#if defined(__POWER9_VECTOR__)
84
    flags |= DAV1D_PPC_CPU_FLAG_PWR9;
85
#endif
86
#elif ARCH_RISCV
87
#if defined(__riscv_v)
88
    flags |= DAV1D_RISCV_CPU_FLAG_V;
89
#endif
90
#elif ARCH_X86
91
#if defined(__AVX512F__) && defined(__AVX512CD__) && \
92
    defined(__AVX512BW__) && defined(__AVX512DQ__) && \
93
    defined(__AVX512VL__) && defined(__AVX512VNNI__) && \
94
    defined(__AVX512IFMA__) && defined(__AVX512VBMI__) && \
95
    defined(__AVX512VBMI2__) && defined(__AVX512VPOPCNTDQ__) && \
96
    defined(__AVX512BITALG__) && defined(__GFNI__) && \
97
    defined(__VAES__) && defined(__VPCLMULQDQ__)
98
    flags |= DAV1D_X86_CPU_FLAG_AVX512ICL |
99
             DAV1D_X86_CPU_FLAG_AVX2 |
100
             DAV1D_X86_CPU_FLAG_SSE41 |
101
             DAV1D_X86_CPU_FLAG_SSSE3 |
102
             DAV1D_X86_CPU_FLAG_SSE2;
103
#elif defined(__AVX2__)
104
    flags |= DAV1D_X86_CPU_FLAG_AVX2 |
105
             DAV1D_X86_CPU_FLAG_SSE41 |
106
             DAV1D_X86_CPU_FLAG_SSSE3 |
107
             DAV1D_X86_CPU_FLAG_SSE2;
108
#elif defined(__SSE4_1__) || defined(__AVX__)
109
    flags |= DAV1D_X86_CPU_FLAG_SSE41 |
110
             DAV1D_X86_CPU_FLAG_SSSE3 |
111
             DAV1D_X86_CPU_FLAG_SSE2;
112
#elif defined(__SSSE3__)
113
    flags |= DAV1D_X86_CPU_FLAG_SSSE3 |
114
             DAV1D_X86_CPU_FLAG_SSE2;
115
#elif ARCH_X86_64 || defined(__SSE2__) || \
116
      (defined(_M_IX86_FP) && _M_IX86_FP >= 2)
117
    flags |= DAV1D_X86_CPU_FLAG_SSE2;
118
2
#endif
119
2
#endif
120
121
2
    return flags;
122
2
}
Unexecuted instantiation: lib.c:dav1d_get_default_cpu_flags
Unexecuted instantiation: mem.c:dav1d_get_default_cpu_flags
Unexecuted instantiation: obu.c:dav1d_get_default_cpu_flags
Unexecuted instantiation: pal.c:dav1d_get_default_cpu_flags
Unexecuted instantiation: picture.c:dav1d_get_default_cpu_flags
Unexecuted instantiation: refmvs.c:dav1d_get_default_cpu_flags
Unexecuted instantiation: thread_task.c:dav1d_get_default_cpu_flags
Unexecuted instantiation: cdf.c:dav1d_get_default_cpu_flags
Unexecuted instantiation: decode.c:dav1d_get_default_cpu_flags
Unexecuted instantiation: msac.c:dav1d_get_default_cpu_flags
Unexecuted instantiation: cdef_tmpl.c:dav1d_get_default_cpu_flags
Unexecuted instantiation: filmgrain_tmpl.c:dav1d_get_default_cpu_flags
Unexecuted instantiation: ipred_tmpl.c:dav1d_get_default_cpu_flags
Unexecuted instantiation: itx_tmpl.c:dav1d_get_default_cpu_flags
Unexecuted instantiation: loopfilter_tmpl.c:dav1d_get_default_cpu_flags
Unexecuted instantiation: looprestoration_tmpl.c:dav1d_get_default_cpu_flags
Unexecuted instantiation: mc_tmpl.c:dav1d_get_default_cpu_flags
Unexecuted instantiation: recon_tmpl.c:dav1d_get_default_cpu_flags
Unexecuted instantiation: cdef_apply_tmpl.c:dav1d_get_default_cpu_flags
Unexecuted instantiation: lf_apply_tmpl.c:dav1d_get_default_cpu_flags
Unexecuted instantiation: lr_apply_tmpl.c:dav1d_get_default_cpu_flags
123
124
452k
static ALWAYS_INLINE unsigned dav1d_get_cpu_flags(void) {
125
452k
    unsigned flags = dav1d_cpu_flags & dav1d_cpu_flags_mask;
126
127
#if TRIM_DSP_FUNCTIONS
128
/* Since this function is inlined, unconditionally setting a flag here will
129
 * enable dead code elimination in the calling function. */
130
    flags |= dav1d_get_default_cpu_flags();
131
#endif
132
133
452k
    return flags;
134
452k
}
Unexecuted instantiation: dav1d_fuzzer.c:dav1d_get_cpu_flags
Unexecuted instantiation: cpu.c:dav1d_get_cpu_flags
Unexecuted instantiation: lib.c:dav1d_get_cpu_flags
Unexecuted instantiation: mem.c:dav1d_get_cpu_flags
Unexecuted instantiation: obu.c:dav1d_get_cpu_flags
pal.c:dav1d_get_cpu_flags
Line
Count
Source
124
19.9k
static ALWAYS_INLINE unsigned dav1d_get_cpu_flags(void) {
125
19.9k
    unsigned flags = dav1d_cpu_flags & dav1d_cpu_flags_mask;
126
127
#if TRIM_DSP_FUNCTIONS
128
/* Since this function is inlined, unconditionally setting a flag here will
129
 * enable dead code elimination in the calling function. */
130
    flags |= dav1d_get_default_cpu_flags();
131
#endif
132
133
19.9k
    return flags;
134
19.9k
}
Unexecuted instantiation: picture.c:dav1d_get_cpu_flags
refmvs.c:dav1d_get_cpu_flags
Line
Count
Source
124
19.9k
static ALWAYS_INLINE unsigned dav1d_get_cpu_flags(void) {
125
19.9k
    unsigned flags = dav1d_cpu_flags & dav1d_cpu_flags_mask;
126
127
#if TRIM_DSP_FUNCTIONS
128
/* Since this function is inlined, unconditionally setting a flag here will
129
 * enable dead code elimination in the calling function. */
130
    flags |= dav1d_get_default_cpu_flags();
131
#endif
132
133
19.9k
    return flags;
134
19.9k
}
Unexecuted instantiation: thread_task.c:dav1d_get_cpu_flags
Unexecuted instantiation: cdf.c:dav1d_get_cpu_flags
Unexecuted instantiation: decode.c:dav1d_get_cpu_flags
msac.c:dav1d_get_cpu_flags
Line
Count
Source
124
291k
static ALWAYS_INLINE unsigned dav1d_get_cpu_flags(void) {
125
291k
    unsigned flags = dav1d_cpu_flags & dav1d_cpu_flags_mask;
126
127
#if TRIM_DSP_FUNCTIONS
128
/* Since this function is inlined, unconditionally setting a flag here will
129
 * enable dead code elimination in the calling function. */
130
    flags |= dav1d_get_default_cpu_flags();
131
#endif
132
133
291k
    return flags;
134
291k
}
cdef_tmpl.c:dav1d_get_cpu_flags
Line
Count
Source
124
17.3k
static ALWAYS_INLINE unsigned dav1d_get_cpu_flags(void) {
125
17.3k
    unsigned flags = dav1d_cpu_flags & dav1d_cpu_flags_mask;
126
127
#if TRIM_DSP_FUNCTIONS
128
/* Since this function is inlined, unconditionally setting a flag here will
129
 * enable dead code elimination in the calling function. */
130
    flags |= dav1d_get_default_cpu_flags();
131
#endif
132
133
17.3k
    return flags;
134
17.3k
}
filmgrain_tmpl.c:dav1d_get_cpu_flags
Line
Count
Source
124
17.3k
static ALWAYS_INLINE unsigned dav1d_get_cpu_flags(void) {
125
17.3k
    unsigned flags = dav1d_cpu_flags & dav1d_cpu_flags_mask;
126
127
#if TRIM_DSP_FUNCTIONS
128
/* Since this function is inlined, unconditionally setting a flag here will
129
 * enable dead code elimination in the calling function. */
130
    flags |= dav1d_get_default_cpu_flags();
131
#endif
132
133
17.3k
    return flags;
134
17.3k
}
ipred_tmpl.c:dav1d_get_cpu_flags
Line
Count
Source
124
17.3k
static ALWAYS_INLINE unsigned dav1d_get_cpu_flags(void) {
125
17.3k
    unsigned flags = dav1d_cpu_flags & dav1d_cpu_flags_mask;
126
127
#if TRIM_DSP_FUNCTIONS
128
/* Since this function is inlined, unconditionally setting a flag here will
129
 * enable dead code elimination in the calling function. */
130
    flags |= dav1d_get_default_cpu_flags();
131
#endif
132
133
17.3k
    return flags;
134
17.3k
}
itx_tmpl.c:dav1d_get_cpu_flags
Line
Count
Source
124
17.3k
static ALWAYS_INLINE unsigned dav1d_get_cpu_flags(void) {
125
17.3k
    unsigned flags = dav1d_cpu_flags & dav1d_cpu_flags_mask;
126
127
#if TRIM_DSP_FUNCTIONS
128
/* Since this function is inlined, unconditionally setting a flag here will
129
 * enable dead code elimination in the calling function. */
130
    flags |= dav1d_get_default_cpu_flags();
131
#endif
132
133
17.3k
    return flags;
134
17.3k
}
loopfilter_tmpl.c:dav1d_get_cpu_flags
Line
Count
Source
124
17.3k
static ALWAYS_INLINE unsigned dav1d_get_cpu_flags(void) {
125
17.3k
    unsigned flags = dav1d_cpu_flags & dav1d_cpu_flags_mask;
126
127
#if TRIM_DSP_FUNCTIONS
128
/* Since this function is inlined, unconditionally setting a flag here will
129
 * enable dead code elimination in the calling function. */
130
    flags |= dav1d_get_default_cpu_flags();
131
#endif
132
133
17.3k
    return flags;
134
17.3k
}
looprestoration_tmpl.c:dav1d_get_cpu_flags
Line
Count
Source
124
17.3k
static ALWAYS_INLINE unsigned dav1d_get_cpu_flags(void) {
125
17.3k
    unsigned flags = dav1d_cpu_flags & dav1d_cpu_flags_mask;
126
127
#if TRIM_DSP_FUNCTIONS
128
/* Since this function is inlined, unconditionally setting a flag here will
129
 * enable dead code elimination in the calling function. */
130
    flags |= dav1d_get_default_cpu_flags();
131
#endif
132
133
17.3k
    return flags;
134
17.3k
}
mc_tmpl.c:dav1d_get_cpu_flags
Line
Count
Source
124
17.3k
static ALWAYS_INLINE unsigned dav1d_get_cpu_flags(void) {
125
17.3k
    unsigned flags = dav1d_cpu_flags & dav1d_cpu_flags_mask;
126
127
#if TRIM_DSP_FUNCTIONS
128
/* Since this function is inlined, unconditionally setting a flag here will
129
 * enable dead code elimination in the calling function. */
130
    flags |= dav1d_get_default_cpu_flags();
131
#endif
132
133
17.3k
    return flags;
134
17.3k
}
Unexecuted instantiation: recon_tmpl.c:dav1d_get_cpu_flags
Unexecuted instantiation: cdef_apply_tmpl.c:dav1d_get_cpu_flags
Unexecuted instantiation: lf_apply_tmpl.c:dav1d_get_cpu_flags
Unexecuted instantiation: lr_apply_tmpl.c:dav1d_get_cpu_flags
135
136
#endif /* DAV1D_SRC_CPU_H */