xref: /aosp_15_r20/external/libxaac/encoder/ixheaace_fft.h (revision 15dc779a375ca8b5125643b829a8aa4b70d7f451)
1 /******************************************************************************
2  *                                                                            *
3  * Copyright (C) 2023 The Android Open Source Project
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  * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore
19  */
20 
21 #pragma once
22 #ifndef PI
23 #define PI (3.141592653589795)
24 #endif
25 
26 #define LS_TRANS_128 448  //((long_frame_len - FRAME_LEN_SHORT_128) / 2)
27 #define LS_TRANS_120 420
28 
29 #define DIG_REV(i, m, j)                                      \
30   do {                                                        \
31     unsigned _ = (i);                                         \
32     _ = ((_ & 0x33333333) << 2) | ((_ & ~0x33333333) >> 2);   \
33     _ = ((_ & 0x0F0F0F0F) << 4) | ((_ & ~0x0F0F0F0F) >> 4);   \
34     _ = ((_ & 0x00FF00FF) << 8) | ((_ & ~0x00FF00FF) >> 8);   \
35     _ = ((_ & 0x0000FFFF) << 16) | ((_ & ~0x0000FFFF) >> 16); \
36     (j) = _ >> (m);                                           \
37   } while (0)
38 
39 #define DIG_REV_NEW(i, m, j)                                \
40   do {                                                      \
41     unsigned _ = (i);                                       \
42     _ = ((_ & 0x33333333) << 2) | ((_ & ~0x33333333) >> 2); \
43     _ = ((_ & 0x0F0F0F0F) << 4) | ((_ & ~0x0F0F0F0F) >> 4); \
44     _ = ((_ & 0x00FF00FF) << 8) | ((_ & ~0x00FF00FF) >> 8); \
45     (j) = _ >> (m);                                         \
46   } while (0)
47 
48 typedef struct {
49   FLOAT32 p_fft_p2_y[2048];
50   FLOAT32 p_fft_p3_data_3[800];
51   FLOAT32 p_fft_p3_y[2048];
52 } ixheaace_scratch_mem;
53 
54 VOID ia_enhaacplus_enc_complex_fft(FLOAT32 *ptr_data, WORD32 len,
55                                    ixheaace_scratch_mem *pstr_scratch);
56 
57 VOID ia_eaacp_enc_pre_twiddle_aac(FLOAT32 *ptr_x, FLOAT32 *ptr_data, WORD32 n,
58                                   const FLOAT32 *ptr_cos_array);
59 
60 VOID ia_enhaacplus_enc_post_twiddle(FLOAT32 *ptr_out, FLOAT32 *ptr_x,
61                                     const FLOAT32 *ptr_cos_sin_tbl, WORD m);
62 
63 VOID ia_aac_ld_enc_mdct_480(FLOAT32 *ptr_inp, FLOAT32 *ptr_scratch, WORD32 mdct_flag,
64                             ixheaace_mdct_tables *pstr_mdct_tables);
65 
66 VOID ia_enhaacplus_enc_complex_fft_p2(FLOAT32 *ptr_x, WORD32 nlength,
67                                       FLOAT32 *ptr_scratch_fft_p2_y);
68 
69 VOID ixheaace_transform_real_lc_ld(FLOAT32 *ptr_mdct_delay_buffer, const FLOAT32 *ptr_time_signal,
70                                    WORD32 ch_increment, FLOAT32 *ptr_real_out, WORD32 block_type,
71                                    WORD32 frame_len, WORD8 *ptr_scratch);
72 
73 VOID ia_enhaacplus_enc_transform_real_eld(FLOAT32 *ptr_mdct_delay_buffer,
74                                           const FLOAT32 *ptr_time_signal, WORD32 ch_increment,
75                                           FLOAT32 *ptr_real_out, WORD8 *ptr_shared_buffer5,
76                                           WORD32 frame_len);
77 
78 VOID ia_enhaacplus_enc_transform_real(FLOAT32 *ptr_mdct_delay_buffer,
79                                       const FLOAT32 *ptr_time_signal, WORD32 ch_increment,
80                                       FLOAT32 *ptr_real_out, ixheaace_mdct_tables *pstr_mdct_tab,
81                                       FLOAT32 *ptr_shared_buffer1, WORD8 *ptr_shared_buffer5,
82                                       WORD32 long_frame_len);