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 #include <string.h>
22
23 #include "ixheaac_type_def.h"
24 #include "ixheaac_constants.h"
25 #include "ixheaace_sbr_def.h"
26 #include "ixheaace_resampler.h"
27 #include "ixheaace_sbr_rom.h"
28 #include "ixheaace_common_rom.h"
29 #include "ixheaace_sbr_hbe.h"
30 #include "ixheaace_sbr_qmf_enc.h"
31
32 #include "ixheaace_sbr_hybrid.h"
33 #include "ixheaace_aac_constants.h"
34 #include "ixheaac_basic_ops32.h"
35 #include "ixheaac_basic_ops16.h"
36 #include "ixheaac_basic_ops40.h"
37 #include "ixheaac_basic_ops.h"
38 #include "ixheaac_error_standards.h"
39
ixheaace_create_synthesis_qmf_bank(ixheaace_pstr_sbr_qmf_filter_bank pstr_sbr_qmf_filter_bank,WORD32 * ptr_common_buffer,ixheaace_str_sbr_tabs * pstr_sbr_tab)40 VOID ixheaace_create_synthesis_qmf_bank(
41 ixheaace_pstr_sbr_qmf_filter_bank pstr_sbr_qmf_filter_bank, WORD32 *ptr_common_buffer,
42 ixheaace_str_sbr_tabs *pstr_sbr_tab) {
43 WORD32 *ptr_temp;
44 ptr_temp =
45 &ptr_common_buffer[5 * NO_OF_ESTIMATES * MAXIMUM_FREQ_COEFFS + IXHEAACE_PS_BUF4_SIZE];
46 memset(pstr_sbr_qmf_filter_bank, 0, sizeof(ixheaace_str_sbr_qmf_filter_bank));
47
48 pstr_sbr_qmf_filter_bank->ptr_flt_filter = pstr_sbr_tab->ptr_qmf_tab->sbr_p_64_640_qmf;
49 pstr_sbr_qmf_filter_bank->ptr_flt_alt_sin_twiddle =
50 pstr_sbr_tab->ptr_qmf_tab->sbr_alt_sin_twiddle;
51 pstr_sbr_qmf_filter_bank->ptr_flt_cos_twiddle = pstr_sbr_tab->ptr_qmf_tab->sbr_cos_sin_twiddle;
52
53 pstr_sbr_qmf_filter_bank->ptr_flt_work_buf = (FLOAT32 *)ptr_temp;
54 ptr_temp += 64;
55 pstr_sbr_qmf_filter_bank->ptr_flt_time_buf = (FLOAT32 *)ptr_temp;
56 }
57
ixheaace_create_qmf_bank(ixheaace_pstr_sbr_qmf_filter_bank pstr_sbr_qmf_filter_bank,ixheaace_str_sbr_tabs * pstr_sbr_tab,WORD32 is_ld_sbr)58 VOID ixheaace_create_qmf_bank(ixheaace_pstr_sbr_qmf_filter_bank pstr_sbr_qmf_filter_bank,
59 ixheaace_str_sbr_tabs *pstr_sbr_tab, WORD32 is_ld_sbr) {
60 pstr_sbr_qmf_filter_bank->offset = 0;
61 pstr_sbr_qmf_filter_bank->flag = 0;
62
63 pstr_sbr_qmf_filter_bank->ptr_filter =
64 (is_ld_sbr) ? &cld_fb_64_640[0] : pstr_sbr_tab->ptr_qmf_tab->sbr_qmf_64_640;
65
66 pstr_sbr_qmf_filter_bank->ptr_qmf_states_buf =
67 (FLOAT32 *)pstr_sbr_qmf_filter_bank->ptr_sbr_qmf_states_ana;
68
69 if (is_ld_sbr) {
70 pstr_sbr_qmf_filter_bank->ptr_qmf_states_curr_pos =
71 (FLOAT32 *)pstr_sbr_qmf_filter_bank->ptr_qmf_states_buf;
72 pstr_sbr_qmf_filter_bank->ptr_fp1 = pstr_sbr_qmf_filter_bank->ptr_qmf_states_buf;
73 pstr_sbr_qmf_filter_bank->ptr_fp2 = pstr_sbr_qmf_filter_bank->ptr_qmf_states_buf + 64;
74
75 pstr_sbr_qmf_filter_bank->start_coeff_cnt = 0;
76 }
77
78 pstr_sbr_qmf_filter_bank->ptr_ref_coeff_l = pstr_sbr_tab->ptr_qmf_tab->sbr_qmf_64_640 + 10;
79 pstr_sbr_qmf_filter_bank->ptr_ref_coeff_r = pstr_sbr_tab->ptr_qmf_tab->sbr_qmf_64_640 + 640;
80 pstr_sbr_qmf_filter_bank->ptr_cld_filt = pstr_sbr_tab->ptr_qmf_tab->sbr_cld_fb;
81
82 pstr_sbr_qmf_filter_bank->offset_l = 5;
83 pstr_sbr_qmf_filter_bank->offset_r = 5;
84
85 memset(pstr_sbr_qmf_filter_bank->ptr_qmf_states_buf, 0,
86 QMF_FILTER_LENGTH * sizeof(pstr_sbr_qmf_filter_bank->ptr_qmf_states_buf[0]));
87 }
88