OLD | NEW |
1 /* Copyright (c) 2015 Xiph.Org Foundation | 1 /* Copyright (C) 2003 Jean-Marc Valin */ |
2 Written by Viswanath Puttagunta */ | |
3 /** | 2 /** |
4 @file fft_arm.h | 3 @file fixed_c5x.h |
5 @brief ARM Neon Intrinsic optimizations for fft using NE10 library | 4 @brief Fixed-point operations for the TI C5x DSP family |
6 */ | 5 */ |
7 | |
8 /* | 6 /* |
9 Redistribution and use in source and binary forms, with or without | 7 Redistribution and use in source and binary forms, with or without |
10 modification, are permitted provided that the following conditions | 8 modification, are permitted provided that the following conditions |
11 are met: | 9 are met: |
12 | 10 |
13 - Redistributions of source code must retain the above copyright | 11 - Redistributions of source code must retain the above copyright |
14 notice, this list of conditions and the following disclaimer. | 12 notice, this list of conditions and the following disclaimer. |
15 | 13 |
16 - Redistributions in binary form must reproduce the above copyright | 14 - Redistributions in binary form must reproduce the above copyright |
17 notice, this list of conditions and the following disclaimer in the | 15 notice, this list of conditions and the following disclaimer in the |
18 documentation and/or other materials provided with the distribution. | 16 documentation and/or other materials provided with the distribution. |
19 | 17 |
20 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | 18 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
21 ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | 19 ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
22 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | 20 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
23 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER | 21 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER |
24 OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | 22 OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
25 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | 23 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
26 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | 24 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
27 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | 25 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF |
28 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | 26 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
29 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 27 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
30 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
31 */ | 29 */ |
32 | 30 |
| 31 #ifndef FIXED_C5X_H |
| 32 #define FIXED_C5X_H |
33 | 33 |
34 #if !defined(FFT_ARM_H) | 34 #include "dsplib.h" |
35 #define FFT_ARM_H | |
36 | 35 |
37 #include "config.h" | 36 #undef IMUL32 |
38 #include "kiss_fft.h" | 37 static OPUS_INLINE long IMUL32(long i, long j) |
| 38 { |
| 39 long ac0, ac1; |
| 40 ac0 = _lmpy(i>>16,j); |
| 41 ac1 = ac0 + _lmpy(i,j>>16); |
| 42 return _lmpyu(i,j) + (ac1<<16); |
| 43 } |
39 | 44 |
40 #if defined(HAVE_ARM_NE10) | 45 #undef MAX16 |
| 46 #define MAX16(a,b) _max(a,b) |
41 | 47 |
42 int opus_fft_alloc_arm_neon(kiss_fft_state *st); | 48 #undef MIN16 |
43 void opus_fft_free_arm_neon(kiss_fft_state *st); | 49 #define MIN16(a,b) _min(a,b) |
44 | 50 |
45 void opus_fft_neon(const kiss_fft_state *st, | 51 #undef MAX32 |
46 const kiss_fft_cpx *fin, | 52 #define MAX32(a,b) _lmax(a,b) |
47 kiss_fft_cpx *fout); | |
48 | 53 |
49 void opus_ifft_neon(const kiss_fft_state *st, | 54 #undef MIN32 |
50 const kiss_fft_cpx *fin, | 55 #define MIN32(a,b) _lmin(a,b) |
51 kiss_fft_cpx *fout); | |
52 | 56 |
53 #if !defined(OPUS_HAVE_RTCD) | 57 #undef VSHR32 |
54 #define OVERRIDE_OPUS_FFT (1) | 58 #define VSHR32(a, shift) _lshl(a,-(shift)) |
55 | 59 |
56 #define opus_fft_alloc_arch(_st, arch) \ | 60 #undef MULT16_16_Q15 |
57 ((void)(arch), opus_fft_alloc_arm_neon(_st)) | 61 #define MULT16_16_Q15(a,b) (_smpy(a,b)) |
58 | 62 |
59 #define opus_fft_free_arch(_st, arch) \ | 63 #undef MULT16_16SU |
60 ((void)(arch), opus_fft_free_arm_neon(_st)) | 64 #define MULT16_16SU(a,b) _lmpysu(a,b) |
61 | 65 |
62 #define opus_fft(_st, _fin, _fout, arch) \ | 66 #undef MULT_16_16 |
63 ((void)(arch), opus_fft_neon(_st, _fin, _fout)) | 67 #define MULT_16_16(a,b) _lmpy(a,b) |
64 | 68 |
65 #define opus_ifft(_st, _fin, _fout, arch) \ | 69 /* FIXME: This is technically incorrect and is bound to cause problems. Is there
any cleaner solution? */ |
66 ((void)(arch), opus_ifft_neon(_st, _fin, _fout)) | 70 #undef MULT16_32_Q15 |
| 71 #define MULT16_32_Q15(a,b) ADD32(SHL(MULT16_16((a),SHR((b),16)),1), SHR(MULT16_1
6SU((a),(b)),15)) |
67 | 72 |
68 #endif /* OPUS_HAVE_RTCD */ | 73 #define celt_ilog2(x) (30 - _lnorm(x)) |
| 74 #define OVERRIDE_CELT_ILOG2 |
69 | 75 |
70 #endif /* HAVE_ARM_NE10 */ | 76 #define celt_maxabs16(x, len) MAX32(EXTEND32(maxval((DATA *)x, len)),-EXTEND32(m
inval((DATA *)x, len))) |
| 77 #define OVERRIDE_CELT_MAXABS16 |
71 | 78 |
72 #endif | 79 #endif /* FIXED_C5X_H */ |
OLD | NEW |