1 #include <stdlib.h>
2 #include <stdio.h>
3 
4 #include <ixheaacd_type_def.h>
5 #include "ixheaacd_interface.h"
6 #include "ixheaacd_constants.h"
7 #include <ixheaacd_basic_ops32.h>
8 #include "ixheaacd_function_selector.h"
9 
10 extern const WORD32 ixheaacd_twiddle_table_fft_32x32[514];
11 extern const WORD8 ixheaacd_mps_dig_rev[16];
12 
ixheaacd_complex_fft_p2_armv7(WORD32 * xr,WORD32 * xi,WORD32 nlength,WORD32 fft_mode,WORD32 * preshift)13 VOID ixheaacd_complex_fft_p2_armv7(WORD32 *xr, WORD32 *xi, WORD32 nlength,
14                                    WORD32 fft_mode, WORD32 *preshift) {
15   WORD32 i, n_stages;
16   WORD32 not_power_4;
17   WORD32 npts, shift;
18   WORD32 dig_rev_shift;
19   WORD32 ptr_x[1024];
20   WORD32 y[1024];
21   WORD32 npoints = nlength;
22   WORD32 n = 0;
23   WORD32 *ptr_y = y;
24   dig_rev_shift = ixheaacd_norm32(npoints) + 1 - 16;
25   n_stages = 30 - ixheaacd_norm32(npoints);  // log2(npoints), if npoints=2^m
26   not_power_4 = n_stages & 1;
27 
28   n_stages = n_stages >> 1;
29 
30   npts = npoints;  // CALCULATION OF GUARD BITS
31   while (npts >> 1) {
32     n++;
33     npts = npts >> 1;
34   }
35 
36   if (n % 2 == 0)
37     shift = ((n + 4)) / 2;
38   else
39     shift = ((n + 3) / 2);
40 
41   for (i = 0; i < nlength; i++) {
42     ptr_x[2 * i] = (xr[i] / (1 << (shift)));
43     ptr_x[2 * i + 1] = (xi[i] / (1 << (shift)));
44   }
45 
46   if (fft_mode == -1) {
47     ixheaacd_complex_fft_p2_asm(ixheaacd_twiddle_table_fft_32x32, nlength,
48                                 ptr_x, ptr_y);
49     if (not_power_4) shift += 1;
50   }
51 
52   else {
53     ixheaacd_complex_ifft_p2_asm(ixheaacd_twiddle_table_fft_32x32, nlength,
54                                  ptr_x, ptr_y);
55     if (not_power_4) shift += 1;
56   }
57 
58   for (i = 0; i < nlength; i++) {
59     xr[i] = y[2 * i];
60     xi[i] = y[2 * i + 1];
61   }
62 
63   *preshift = shift - *preshift;
64   return;
65 }
66 
ixheaacd_mps_complex_fft_64_armv7(WORD32 * ptr_x,WORD32 * fin_re,WORD32 * fin_im,WORD32 nlength)67 VOID ixheaacd_mps_complex_fft_64_armv7(WORD32 *ptr_x, WORD32 *fin_re,
68                                        WORD32 *fin_im, WORD32 nlength) {
69   WORD32 i, n_stages;
70   WORD32 y[128];
71   WORD32 npoints = nlength;
72   WORD32 *ptr_y = y;
73   const WORD32 *ptr_w;
74   n_stages = 30 - ixheaacd_norm32(npoints);  // log2(npoints), if npoints=2^m
75 
76   n_stages = n_stages >> 1;
77 
78   ptr_w = ixheaacd_twiddle_table_fft_32x32;  // 32 BIT TWIDDLE TABLE
79 
80   ixheaacd_mps_complex_fft_64_asm(ptr_w, nlength, ptr_x, ptr_y,
81                                   ixheaacd_mps_dig_rev);
82 
83   for (i = 0; i < 2 * nlength; i += 2) {
84     fin_re[i] = y[i];
85     fin_im[i] = y[i + 1];
86   }
87 
88   return;
89 }
90