1 /******************************************************************************
2 *
3 * Copyright 2022 Google LLC
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at:
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 ******************************************************************************/
18
19 #include "neon.h"
20
21 #include <stdio.h>
22 #include <stdint.h>
23 #include <stdlib.h>
24
25 /* -------------------------------------------------------------------------- */
26
27 #define TEST_NEON
28 #include <mdct.c>
29
30 /* -------------------------------------------------------------------------- */
31
check_fft(void)32 static int check_fft(void)
33 {
34 struct lc3_complex x[240];
35 struct lc3_complex y[240], y_neon[240];
36
37 for (int i = 0; i < 240; i++) {
38 x[i].re = (double)rand() / RAND_MAX;
39 x[i].im = (double)rand() / RAND_MAX;
40 }
41
42 fft_5(x, y, 240/5);
43 neon_fft_5(x, y_neon, 240/5);
44 for (int i = 0; i < 240; i++)
45 if (fabsf(y[i].re - y_neon[i].re) > 1e-6f ||
46 fabsf(y[i].im - y_neon[i].im) > 1e-6f )
47 return -1;
48
49 fft_bf3(lc3_fft_twiddles_bf3[0], x, y, 240/15);
50 neon_fft_bf3(lc3_fft_twiddles_bf3[0], x, y_neon, 240/15);
51 for (int i = 0; i < 240; i++)
52 if (fabsf(y[i].re - y_neon[i].re) > 1e-6f ||
53 fabsf(y[i].im - y_neon[i].im) > 1e-6f )
54 return -1;
55
56 fft_bf2(lc3_fft_twiddles_bf2[0][1], x, y, 240/30);
57 neon_fft_bf2(lc3_fft_twiddles_bf2[0][1], x, y_neon, 240/30);
58 for (int i = 0; i < 240; i++)
59 if (fabsf(y[i].re - y_neon[i].re) > 1e-6f ||
60 fabsf(y[i].im - y_neon[i].im) > 1e-6f )
61 return -1;
62
63 return 0;
64 }
65
check_mdct(void)66 int check_mdct(void)
67 {
68 int ret;
69
70 if ((ret = check_fft()) < 0)
71 return ret;
72
73 return 0;
74 }
75