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 #include <string.h>
21 #include "ixheaacd_type_def.h"
22 #include "ixheaacd_mps_struct_def.h"
23 #include "ixheaacd_mps_res_rom.h"
24 #include "ixheaacd_mps_aac_struct.h"
25 #include "ixheaacd_constants.h"
26 #include "ixheaacd_basic_ops32.h"
27 #include "ixheaacd_basic_ops40.h"
28 #include "ixheaacd_bitbuffer.h"
29 #include "ixheaacd_common_rom.h"
30 #include "ixheaacd_sbrdecsettings.h"
31 #include "ixheaacd_sbr_scale.h"
32 #include "ixheaacd_env_extr_part.h"
33 #include "ixheaacd_sbr_rom.h"
34 #include "ixheaacd_hybrid.h"
35 #include "ixheaacd_ps_dec.h"
36 #include "ixheaacd_error_standards.h"
37 #include "ixheaacd_mps_polyphase.h"
38 #include "ixheaacd_config.h"
39 #include "ixheaacd_qmf_dec.h"
40 #include "ixheaacd_mps_dec.h"
41 #include "ixheaacd_mps_macro_def.h"
42 #include "ixheaacd_mps_basic_op.h"
43 #include "ixheaacd_mps_calc_m1m2_common.h"
44
ixheaacd_calc_m1m2_7571(ia_heaac_mps_state_struct * pstr_mps_state)45 VOID ixheaacd_calc_m1m2_7571(ia_heaac_mps_state_struct *pstr_mps_state) {
46 ia_mps_dec_auxilary_struct *p_aux_struct = pstr_mps_state->aux_struct;
47 ia_mps_dec_m2_param_struct *m2_param = p_aux_struct->m2_param;
48 ia_mps_dec_m1_param_struct *m1_param = pstr_mps_state->array_struct->m1_param;
49 WORD32 ps, pb;
50
51 WORD32 *h11_l, *h11_r, *h12_l, *h12_r, *h21_l, *h21_r, *h22_l, *h22_r, *h12_res_l, *h12_res_r,
52 *h22_res_l, *h22_res_r;
53 WORD16 *c_f_l, *c_f_r, *dummy;
54
55 WORD32 idx;
56 WORD32 residual_coding = pstr_mps_state->residual_coding;
57 WORD32 num_parameter_sets = pstr_mps_state->num_parameter_sets;
58 WORD32 num_parameter_bands = pstr_mps_state->num_parameter_bands;
59
60 h11_l = pstr_mps_state->mps_scratch_mem_v;
61 h11_r = h11_l + MAX_PARAMETER_BANDS;
62 h12_l = h11_r + MAX_PARAMETER_BANDS;
63 h12_r = h12_l + MAX_PARAMETER_BANDS;
64 h21_l = h12_r + MAX_PARAMETER_BANDS;
65 h21_r = h21_l + MAX_PARAMETER_BANDS;
66 h22_l = h21_r + MAX_PARAMETER_BANDS;
67 h22_r = h22_l + MAX_PARAMETER_BANDS;
68 h12_res_l = h22_r + MAX_PARAMETER_BANDS;
69 h12_res_r = h12_res_l + MAX_PARAMETER_BANDS;
70 h22_res_l = h12_res_r + MAX_PARAMETER_BANDS;
71 h22_res_r = h22_res_l + MAX_PARAMETER_BANDS;
72
73 c_f_l = (WORD16 *)pstr_mps_state->mps_scratch_mem_v + PARAMETER_BANDSX24;
74 c_f_r = c_f_l + MAX_PARAMETER_BANDS;
75 dummy = c_f_r + MAX_PARAMETER_BANDS;
76
77 for (ps = 0; ps < num_parameter_sets; ps++) {
78 ixheaacd_param_2_umx_ps(pstr_mps_state, h11_l, h12_l, h21_l, h22_l, h12_res_l, h22_res_l,
79 c_f_l, dummy, 0, ps, pstr_mps_state->res_bands[0]);
80 ixheaacd_param_2_umx_ps(pstr_mps_state, h11_r, h12_r, h21_r, h22_r, h12_res_r, h22_res_r,
81 c_f_r, dummy, 1, ps, pstr_mps_state->res_bands[1]);
82
83 for (pb = 0; pb < num_parameter_bands; pb++) {
84 m1_param->m1_param_real[0][0][ps][pb] = ONE_IN_Q15;
85 m1_param->m1_param_real[1][1][ps][pb] = ONE_IN_Q15;
86 m1_param->m1_param_real[2][2][ps][pb] = ONE_IN_Q15;
87 m1_param->m1_param_real[3][3][ps][pb] = ONE_IN_Q15;
88 m1_param->m1_param_real[4][4][ps][pb] = ONE_IN_Q15;
89 m1_param->m1_param_real[5][5][ps][pb] = ONE_IN_Q15;
90 m1_param->m1_param_real[6][0][ps][pb] = ONE_IN_Q15;
91 m1_param->m1_param_real[7][1][ps][pb] = ONE_IN_Q15;
92 }
93
94 memcpy(m2_param->m2_decor_real[0][ps], h12_l, num_parameter_bands * sizeof(h12_l[0]));
95 memcpy(m2_param->m2_decor_real[1][ps], h22_l, num_parameter_bands * sizeof(h22_l[0]));
96 memcpy(m2_param->m2_decor_real[2][ps], h12_r, num_parameter_bands * sizeof(h12_r[0]));
97 memcpy(m2_param->m2_decor_real[3][ps], h22_r, num_parameter_bands * sizeof(h22_r[0]));
98
99 for (pb = 0; pb < num_parameter_bands; pb++) {
100 idx = 0;
101
102 m2_param->m2_resid_real[idx++][ps][pb] = h11_l[pb];
103
104 if (residual_coding) m2_param->m2_resid_real[idx++][ps][pb] = h12_res_l[pb];
105
106 m2_param->m2_resid_real[idx++][ps][pb] = h21_l[pb];
107
108 if (residual_coding) m2_param->m2_resid_real[idx++][ps][pb] = h22_res_l[pb];
109
110 m2_param->m2_resid_real[idx++][ps][pb] = ONE_IN_Q15;
111
112 m2_param->m2_resid_real[idx++][ps][pb] = h11_r[pb];
113
114 if (residual_coding) m2_param->m2_resid_real[idx++][ps][pb] = h12_res_r[pb];
115
116 m2_param->m2_resid_real[idx++][ps][pb] = h21_r[pb];
117
118 if (residual_coding) m2_param->m2_resid_real[idx++][ps][pb] = h22_res_r[pb];
119
120 m2_param->m2_resid_real[idx++][ps][pb] = ONE_IN_Q15;
121
122 m2_param->m2_resid_real[idx++][ps][pb] = ONE_IN_Q15;
123
124 m2_param->m2_resid_real[idx++][ps][pb] = ONE_IN_Q15;
125 }
126 }
127 return;
128 }
129
ixheaacd_calc_m1m2_7572(ia_heaac_mps_state_struct * pstr_mps_state)130 VOID ixheaacd_calc_m1m2_7572(ia_heaac_mps_state_struct *pstr_mps_state) {
131 ia_mps_dec_auxilary_struct *p_aux_struct = pstr_mps_state->aux_struct;
132 ia_mps_dec_m2_param_struct *m2_param = p_aux_struct->m2_param;
133 ia_mps_dec_m1_param_struct *m1_param = pstr_mps_state->array_struct->m1_param;
134 WORD32 ps, pb;
135 WORD32 *h11_l, *h11_r, *h12_l, *h12_r, *h21_l, *h21_r, *h22_l, *h22_r, *h12_res_l, *h12_res_r,
136 *h22_res_l, *h22_res_r;
137 WORD16 *c_f_l, *c_f_r, *dummy;
138
139 WORD32 idx;
140 WORD32 residual_coding = pstr_mps_state->residual_coding;
141 WORD32 num_parameter_sets = pstr_mps_state->num_parameter_sets;
142 WORD32 num_parameter_bands = pstr_mps_state->num_parameter_bands;
143
144 h11_l = pstr_mps_state->mps_scratch_mem_v;
145 h11_r = h11_l + MAX_PARAMETER_BANDS;
146 h12_l = h11_r + MAX_PARAMETER_BANDS;
147 h12_r = h12_l + MAX_PARAMETER_BANDS;
148 h21_l = h12_r + MAX_PARAMETER_BANDS;
149 h21_r = h21_l + MAX_PARAMETER_BANDS;
150 h22_l = h21_r + MAX_PARAMETER_BANDS;
151 h22_r = h22_l + MAX_PARAMETER_BANDS;
152 h12_res_l = h22_r + MAX_PARAMETER_BANDS;
153 h12_res_r = h12_res_l + MAX_PARAMETER_BANDS;
154 h22_res_l = h12_res_r + MAX_PARAMETER_BANDS;
155 h22_res_r = h22_res_l + MAX_PARAMETER_BANDS;
156
157 c_f_l = (WORD16 *)pstr_mps_state->mps_scratch_mem_v + PARAMETER_BANDSX24;
158 c_f_r = c_f_l + MAX_PARAMETER_BANDS;
159 dummy = c_f_r + MAX_PARAMETER_BANDS;
160
161 for (ps = 0; ps < num_parameter_sets; ps++) {
162 ixheaacd_param_2_umx_ps(pstr_mps_state, h11_l, h12_l, h21_l, h22_l, h12_res_l, h22_res_l,
163 c_f_l, dummy, 0, ps, pstr_mps_state->res_bands[0]);
164 ixheaacd_param_2_umx_ps(pstr_mps_state, h11_r, h12_r, h21_r, h22_r, h12_res_r, h22_res_r,
165 c_f_r, dummy, 1, ps, pstr_mps_state->res_bands[1]);
166
167 for (pb = 0; pb < num_parameter_bands; pb++) {
168 m1_param->m1_param_real[0][0][ps][pb] = ONE_IN_Q15;
169 m1_param->m1_param_real[1][1][ps][pb] = ONE_IN_Q15;
170 m1_param->m1_param_real[2][2][ps][pb] = ONE_IN_Q15;
171 m1_param->m1_param_real[3][3][ps][pb] = ONE_IN_Q15;
172 m1_param->m1_param_real[4][4][ps][pb] = ONE_IN_Q15;
173 m1_param->m1_param_real[5][5][ps][pb] = ONE_IN_Q15;
174 m1_param->m1_param_real[6][4][ps][pb] = ONE_IN_Q15;
175 m1_param->m1_param_real[7][5][ps][pb] = ONE_IN_Q15;
176 }
177
178 memcpy(m2_param->m2_decor_real[0][ps], h22_l, num_parameter_bands * sizeof(h22_l[0]));
179 memcpy(m2_param->m2_decor_real[1][ps], h12_l, num_parameter_bands * sizeof(h12_l[0]));
180 memcpy(m2_param->m2_decor_real[2][ps], h22_r, num_parameter_bands * sizeof(h22_r[0]));
181 memcpy(m2_param->m2_decor_real[3][ps], h12_r, num_parameter_bands * sizeof(h12_r[0]));
182
183 for (pb = 0; pb < num_parameter_bands; pb++) {
184 idx = 0;
185
186 m2_param->m2_resid_real[idx++][ps][pb] = ONE_IN_Q15;
187
188 m2_param->m2_resid_real[idx++][ps][pb] = h21_l[pb];
189
190 if (residual_coding) m2_param->m2_resid_real[idx++][ps][pb] = h22_res_l[pb];
191
192 m2_param->m2_resid_real[idx++][ps][pb] = h11_l[pb];
193
194 if (residual_coding) m2_param->m2_resid_real[idx++][ps][pb] = h12_res_l[pb];
195
196 m2_param->m2_resid_real[idx++][ps][pb] = ONE_IN_Q15;
197
198 m2_param->m2_resid_real[idx++][ps][pb] = h21_r[pb];
199
200 if (residual_coding) m2_param->m2_resid_real[idx++][ps][pb] = h22_res_r[pb];
201
202 m2_param->m2_resid_real[idx++][ps][pb] = h11_r[pb];
203
204 if (residual_coding) m2_param->m2_resid_real[idx++][ps][pb] = h12_res_r[pb];
205
206 m2_param->m2_resid_real[idx++][ps][pb] = ONE_IN_Q15;
207
208 m2_param->m2_resid_real[idx++][ps][pb] = ONE_IN_Q15;
209 }
210 }
211 return;
212 }
213