xref: /aosp_15_r20/external/libopus/celt/arm/arm_celt_map.c (revision a58d3d2adb790c104798cd88c8a3aff4fa8b82cc)
1 /* Copyright (c) 2010 Xiph.Org Foundation
2  * Copyright (c) 2013 Parrot */
3 /*
4    Redistribution and use in source and binary forms, with or without
5    modification, are permitted provided that the following conditions
6    are met:
7 
8    - Redistributions of source code must retain the above copyright
9    notice, this list of conditions and the following disclaimer.
10 
11    - Redistributions in binary form must reproduce the above copyright
12    notice, this list of conditions and the following disclaimer in the
13    documentation and/or other materials provided with the distribution.
14 
15    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16    ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17    LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
18    A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
19    OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
20    EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21    PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
22    PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
23    LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
24    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 #ifdef HAVE_CONFIG_H
29 #include "config.h"
30 #endif
31 
32 #include "pitch.h"
33 #include "kiss_fft.h"
34 #include "mdct.h"
35 
36 #if defined(OPUS_HAVE_RTCD)
37 
38 # if defined(OPUS_ARM_MAY_HAVE_NEON_INTR) && !defined(OPUS_ARM_PRESUME_NEON_INTR)
39 opus_val32 (*const CELT_INNER_PROD_IMPL[OPUS_ARCHMASK+1])(const opus_val16 *x, const opus_val16 *y, int N) = {
40   celt_inner_prod_c,   /* ARMv4 */
41   celt_inner_prod_c,   /* EDSP */
42   celt_inner_prod_c,   /* Media */
43   celt_inner_prod_neon,/* NEON */
44   celt_inner_prod_neon /* DOTPROD */
45 };
46 
47 void (*const DUAL_INNER_PROD_IMPL[OPUS_ARCHMASK+1])(const opus_val16 *x, const opus_val16 *y01, const opus_val16 *y02,
48       int N, opus_val32 *xy1, opus_val32 *xy2) = {
49   dual_inner_prod_c,   /* ARMv4 */
50   dual_inner_prod_c,   /* EDSP */
51   dual_inner_prod_c,   /* Media */
52   dual_inner_prod_neon,/* NEON */
53   dual_inner_prod_neon /* DOTPROD */
54 };
55 # endif
56 
57 # if defined(FIXED_POINT)
58 #  if ((defined(OPUS_ARM_MAY_HAVE_NEON) && !defined(OPUS_ARM_PRESUME_NEON)) || \
59     (defined(OPUS_ARM_MAY_HAVE_MEDIA) && !defined(OPUS_ARM_PRESUME_MEDIA)) || \
60     (defined(OPUS_ARM_MAY_HAVE_EDSP) && !defined(OPUS_ARM_PRESUME_EDSP)))
61 opus_val32 (*const CELT_PITCH_XCORR_IMPL[OPUS_ARCHMASK+1])(const opus_val16 *,
62     const opus_val16 *, opus_val32 *, int, int, int) = {
63   celt_pitch_xcorr_c,               /* ARMv4 */
64   MAY_HAVE_EDSP(celt_pitch_xcorr),  /* EDSP */
65   MAY_HAVE_MEDIA(celt_pitch_xcorr), /* Media */
66   MAY_HAVE_NEON(celt_pitch_xcorr),  /* NEON */
67   MAY_HAVE_NEON(celt_pitch_xcorr)   /* DOTPROD */
68 };
69 
70 #  endif
71 # else /* !FIXED_POINT */
72 #  if defined(OPUS_ARM_MAY_HAVE_NEON_INTR) && !defined(OPUS_ARM_PRESUME_NEON_INTR)
73 void (*const CELT_PITCH_XCORR_IMPL[OPUS_ARCHMASK+1])(const opus_val16 *,
74     const opus_val16 *, opus_val32 *, int, int, int) = {
75   celt_pitch_xcorr_c,              /* ARMv4 */
76   celt_pitch_xcorr_c,              /* EDSP */
77   celt_pitch_xcorr_c,              /* Media */
78   celt_pitch_xcorr_float_neon,     /* Neon */
79   celt_pitch_xcorr_float_neon      /* DOTPROD */
80 };
81 #  endif
82 # endif /* FIXED_POINT */
83 
84 #if defined(FIXED_POINT) && defined(OPUS_HAVE_RTCD) && \
85  defined(OPUS_ARM_MAY_HAVE_NEON_INTR) && !defined(OPUS_ARM_PRESUME_NEON_INTR)
86 
87 void (*const XCORR_KERNEL_IMPL[OPUS_ARCHMASK + 1])(
88          const opus_val16 *x,
89          const opus_val16 *y,
90          opus_val32       sum[4],
91          int              len
92 ) = {
93   xcorr_kernel_c,                /* ARMv4 */
94   xcorr_kernel_c,                /* EDSP */
95   xcorr_kernel_c,                /* Media */
96   xcorr_kernel_neon_fixed,       /* Neon */
97   xcorr_kernel_neon_fixed        /* DOTPROD */
98 };
99 
100 #endif
101 
102 # if defined(OPUS_ARM_MAY_HAVE_NEON_INTR)
103 #  if defined(HAVE_ARM_NE10)
104 #   if defined(CUSTOM_MODES)
105 int (*const OPUS_FFT_ALLOC_ARCH_IMPL[OPUS_ARCHMASK+1])(kiss_fft_state *st) = {
106    opus_fft_alloc_arch_c,        /* ARMv4 */
107    opus_fft_alloc_arch_c,        /* EDSP */
108    opus_fft_alloc_arch_c,        /* Media */
109    opus_fft_alloc_arm_neon,      /* Neon with NE10 library support */
110    opus_fft_alloc_arm_neon       /* DOTPROD with NE10 library support */
111 };
112 
113 void (*const OPUS_FFT_FREE_ARCH_IMPL[OPUS_ARCHMASK+1])(kiss_fft_state *st) = {
114    opus_fft_free_arch_c,         /* ARMv4 */
115    opus_fft_free_arch_c,         /* EDSP */
116    opus_fft_free_arch_c,         /* Media */
117    opus_fft_free_arm_neon,       /* Neon with NE10 */
118    opus_fft_free_arm_neon        /* DOTPROD with NE10 */
119 };
120 #   endif /* CUSTOM_MODES */
121 
122 void (*const OPUS_FFT[OPUS_ARCHMASK+1])(const kiss_fft_state *cfg,
123                                         const kiss_fft_cpx *fin,
124                                         kiss_fft_cpx *fout) = {
125    opus_fft_c,                   /* ARMv4 */
126    opus_fft_c,                   /* EDSP */
127    opus_fft_c,                   /* Media */
128    opus_fft_neon,                /* Neon with NE10 */
129    opus_fft_neon                 /* DOTPROD with NE10 */
130 };
131 
132 void (*const OPUS_IFFT[OPUS_ARCHMASK+1])(const kiss_fft_state *cfg,
133                                          const kiss_fft_cpx *fin,
134                                          kiss_fft_cpx *fout) = {
135    opus_ifft_c,                   /* ARMv4 */
136    opus_ifft_c,                   /* EDSP */
137    opus_ifft_c,                   /* Media */
138    opus_ifft_neon,                /* Neon with NE10 */
139    opus_ifft_neon                 /* DOTPROD with NE10 */
140 };
141 
142 void (*const CLT_MDCT_FORWARD_IMPL[OPUS_ARCHMASK+1])(const mdct_lookup *l,
143                                                      kiss_fft_scalar *in,
144                                                      kiss_fft_scalar * OPUS_RESTRICT out,
145                                                      const opus_val16 *window,
146                                                      int overlap, int shift,
147                                                      int stride, int arch) = {
148    clt_mdct_forward_c,           /* ARMv4 */
149    clt_mdct_forward_c,           /* EDSP */
150    clt_mdct_forward_c,           /* Media */
151    clt_mdct_forward_neon,        /* Neon with NE10 */
152    clt_mdct_forward_neon         /* DOTPROD with NE10 */
153 };
154 
155 void (*const CLT_MDCT_BACKWARD_IMPL[OPUS_ARCHMASK+1])(const mdct_lookup *l,
156                                                       kiss_fft_scalar *in,
157                                                       kiss_fft_scalar * OPUS_RESTRICT out,
158                                                       const opus_val16 *window,
159                                                       int overlap, int shift,
160                                                       int stride, int arch) = {
161    clt_mdct_backward_c,           /* ARMv4 */
162    clt_mdct_backward_c,           /* EDSP */
163    clt_mdct_backward_c,           /* Media */
164    clt_mdct_backward_neon,        /* Neon with NE10 */
165    clt_mdct_backward_neon         /* DOTPROD with NE10 */
166 };
167 
168 #  endif /* HAVE_ARM_NE10 */
169 # endif /* OPUS_ARM_MAY_HAVE_NEON_INTR */
170 
171 #endif /* OPUS_HAVE_RTCD */
172