• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
67 decl_mc_fn(BF(dav1d_put_bilin, neon));
68 decl_mct_fn(BF(dav1d_prep_bilin, neon));
69 
70 decl_avg_fn(BF(dav1d_avg, neon));
71 decl_w_avg_fn(BF(dav1d_w_avg, neon));
72 decl_mask_fn(BF(dav1d_mask, neon));
73 decl_blend_fn(BF(dav1d_blend, neon));
74 decl_blend_dir_fn(BF(dav1d_blend_h, neon));
75 decl_blend_dir_fn(BF(dav1d_blend_v, neon));
76 
77 decl_w_mask_fn(BF(dav1d_w_mask_444, neon));
78 decl_w_mask_fn(BF(dav1d_w_mask_422, neon));
79 decl_w_mask_fn(BF(dav1d_w_mask_420, neon));
80 
81 decl_warp8x8_fn(BF(dav1d_warp_affine_8x8, neon));
82 decl_warp8x8t_fn(BF(dav1d_warp_affine_8x8t, neon));
83 
84 decl_emu_edge_fn(BF(dav1d_emu_edge, neon));
85 
mc_dsp_init_arm(Dav1dMCDSPContext * const c)86 static ALWAYS_INLINE void mc_dsp_init_arm(Dav1dMCDSPContext *const c) {
87 #define init_mc_fn(type, name, suffix) \
88     c->mc[type] = BF(dav1d_put_##name, suffix)
89 #define init_mct_fn(type, name, suffix) \
90     c->mct[type] = BF(dav1d_prep_##name, suffix)
91     const unsigned flags = dav1d_get_cpu_flags();
92 
93     if (!(flags & DAV1D_ARM_CPU_FLAG_NEON)) return;
94 
95     init_8tap_fns(neon);
96 
97     init_mc_fn (FILTER_2D_BILINEAR, bilin, neon);
98     init_mct_fn(FILTER_2D_BILINEAR, bilin, neon);
99 
100     c->avg = BF(dav1d_avg, neon);
101     c->w_avg = BF(dav1d_w_avg, neon);
102     c->mask = BF(dav1d_mask, neon);
103     c->blend = BF(dav1d_blend, neon);
104     c->blend_h = BF(dav1d_blend_h, neon);
105     c->blend_v = BF(dav1d_blend_v, neon);
106     c->w_mask[0] = BF(dav1d_w_mask_444, neon);
107     c->w_mask[1] = BF(dav1d_w_mask_422, neon);
108     c->w_mask[2] = BF(dav1d_w_mask_420, neon);
109     c->warp8x8 = BF(dav1d_warp_affine_8x8, neon);
110     c->warp8x8t = BF(dav1d_warp_affine_8x8t, neon);
111     c->emu_edge = BF(dav1d_emu_edge, neon);
112 
113 #if ARCH_AARCH64 && BITDEPTH == 8
114 #if HAVE_DOTPROD
115     if (!(flags & DAV1D_ARM_CPU_FLAG_DOTPROD)) return;
116 
117     init_8tap_fns(neon_dotprod);
118 #endif  // HAVE_DOTPROD
119 
120 #if HAVE_I8MM
121     if (!(flags & DAV1D_ARM_CPU_FLAG_I8MM)) return;
122 
123     init_8tap_fns(neon_i8mm);
124 #endif  // HAVE_I8MM
125 #endif  // ARCH_AARCH64 && BITDEPTH == 8
126 }
127