1 /*
2 * Copyright © 2018, VideoLAN and dav1d authors
3 * Copyright © 2018, 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 #include "config.h"
29
30 #include "src/mc.h"
31 #include "src/cpu.h"
32
33 #define decl_8tap_gen(decl_name, fn_name, opt) \
34 decl_##decl_name##_fn(BF(dav1d_##fn_name##_8tap_regular, opt)); \
35 decl_##decl_name##_fn(BF(dav1d_##fn_name##_8tap_regular_smooth, opt)); \
36 decl_##decl_name##_fn(BF(dav1d_##fn_name##_8tap_regular_sharp, opt)); \
37 decl_##decl_name##_fn(BF(dav1d_##fn_name##_8tap_smooth_regular, opt)); \
38 decl_##decl_name##_fn(BF(dav1d_##fn_name##_8tap_smooth, opt)); \
39 decl_##decl_name##_fn(BF(dav1d_##fn_name##_8tap_smooth_sharp, opt)); \
40 decl_##decl_name##_fn(BF(dav1d_##fn_name##_8tap_sharp_regular, opt)); \
41 decl_##decl_name##_fn(BF(dav1d_##fn_name##_8tap_sharp_smooth, opt)); \
42 decl_##decl_name##_fn(BF(dav1d_##fn_name##_8tap_sharp, opt))
43
44 #define decl_8tap_fns(opt) \
45 decl_8tap_gen(mc, put, opt); \
46 decl_8tap_gen(mct, prep, opt)
47
48 #define init_8tap_gen(name, opt) \
49 init_##name##_fn(FILTER_2D_8TAP_REGULAR, 8tap_regular, opt); \
50 init_##name##_fn(FILTER_2D_8TAP_REGULAR_SMOOTH, 8tap_regular_smooth, opt); \
51 init_##name##_fn(FILTER_2D_8TAP_REGULAR_SHARP, 8tap_regular_sharp, opt); \
52 init_##name##_fn(FILTER_2D_8TAP_SMOOTH_REGULAR, 8tap_smooth_regular, opt); \
53 init_##name##_fn(FILTER_2D_8TAP_SMOOTH, 8tap_smooth, opt); \
54 init_##name##_fn(FILTER_2D_8TAP_SMOOTH_SHARP, 8tap_smooth_sharp, opt); \
55 init_##name##_fn(FILTER_2D_8TAP_SHARP_REGULAR, 8tap_sharp_regular, opt); \
56 init_##name##_fn(FILTER_2D_8TAP_SHARP_SMOOTH, 8tap_sharp_smooth, opt); \
57 init_##name##_fn(FILTER_2D_8TAP_SHARP, 8tap_sharp, opt)
58
59 #define init_8tap_fns(opt) \
60 init_8tap_gen(mc, opt); \
61 init_8tap_gen(mct, opt)
62
63 decl_8tap_fns(neon);
64 decl_8tap_fns(neon_dotprod);
65 decl_8tap_fns(neon_i8mm);
66 decl_8tap_fns(sve2);
67
68 decl_mc_fn(BF(dav1d_put_bilin, neon));
69 decl_mct_fn(BF(dav1d_prep_bilin, neon));
70
71 decl_avg_fn(BF(dav1d_avg, neon));
72 decl_w_avg_fn(BF(dav1d_w_avg, neon));
73 decl_mask_fn(BF(dav1d_mask, neon));
74 decl_blend_fn(BF(dav1d_blend, neon));
75 decl_blend_dir_fn(BF(dav1d_blend_h, neon));
76 decl_blend_dir_fn(BF(dav1d_blend_v, neon));
77
78 decl_w_mask_fn(BF(dav1d_w_mask_444, neon));
79 decl_w_mask_fn(BF(dav1d_w_mask_422, neon));
80 decl_w_mask_fn(BF(dav1d_w_mask_420, neon));
81
82 decl_warp8x8_fn(BF(dav1d_warp_affine_8x8, neon));
83 decl_warp8x8t_fn(BF(dav1d_warp_affine_8x8t, neon));
84
85 decl_emu_edge_fn(BF(dav1d_emu_edge, neon));
86
mc_dsp_init_arm(Dav1dMCDSPContext * const c)87 static ALWAYS_INLINE void mc_dsp_init_arm(Dav1dMCDSPContext *const c) {
88 #define init_mc_fn(type, name, suffix) \
89 c->mc[type] = BF(dav1d_put_##name, suffix)
90 #define init_mct_fn(type, name, suffix) \
91 c->mct[type] = BF(dav1d_prep_##name, suffix)
92 const unsigned flags = dav1d_get_cpu_flags();
93
94 if (!(flags & DAV1D_ARM_CPU_FLAG_NEON)) return;
95
96 init_8tap_fns(neon);
97
98 init_mc_fn (FILTER_2D_BILINEAR, bilin, neon);
99 init_mct_fn(FILTER_2D_BILINEAR, bilin, neon);
100
101 c->avg = BF(dav1d_avg, neon);
102 c->w_avg = BF(dav1d_w_avg, neon);
103 c->mask = BF(dav1d_mask, neon);
104 c->blend = BF(dav1d_blend, neon);
105 c->blend_h = BF(dav1d_blend_h, neon);
106 c->blend_v = BF(dav1d_blend_v, neon);
107 c->w_mask[0] = BF(dav1d_w_mask_444, neon);
108 c->w_mask[1] = BF(dav1d_w_mask_422, neon);
109 c->w_mask[2] = BF(dav1d_w_mask_420, neon);
110 c->warp8x8 = BF(dav1d_warp_affine_8x8, neon);
111 c->warp8x8t = BF(dav1d_warp_affine_8x8t, neon);
112 c->emu_edge = BF(dav1d_emu_edge, neon);
113
114 #if ARCH_AARCH64
115 #if BITDEPTH == 8
116 #if HAVE_DOTPROD
117 if (flags & DAV1D_ARM_CPU_FLAG_DOTPROD) {
118 init_8tap_fns(neon_dotprod);
119 }
120 #endif // HAVE_DOTPROD
121
122 #if HAVE_I8MM
123 if (flags & DAV1D_ARM_CPU_FLAG_I8MM) {
124 init_8tap_fns(neon_i8mm);
125 }
126 #endif // HAVE_I8MM
127 #endif // BITDEPTH == 8
128
129 #if BITDEPTH == 16
130 #if HAVE_SVE2
131 if (flags & DAV1D_ARM_CPU_FLAG_SVE2) {
132 init_8tap_fns(sve2);
133 }
134 #endif // HAVE_SVE2
135 #endif // BITDEPTH == 16
136 #endif // ARCH_AARCH64
137 }
138