1 /******************************************************************************
2 * *
3 * Copyright (C) 2018 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 <math.h>
21 #include <stdio.h>
22 #include <string.h>
23 #include "ixheaacd_type_def.h"
24
25 #include "ixheaacd_acelp_com.h"
26 #include "ixheaacd_windows.h"
27 #include "ixheaacd_vec_baisc_ops.h"
28 #include "ixheaacd_bitbuffer.h"
29
30 #include "ixheaacd_interface.h"
31
32 #include "ixheaacd_tns_usac.h"
33 #include "ixheaacd_cnst.h"
34
35 #include "ixheaacd_acelp_info.h"
36
37 #include "ixheaacd_sbrdecsettings.h"
38 #include "ixheaacd_info.h"
39 #include "ixheaacd_sbr_common.h"
40 #include "ixheaacd_drc_data_struct.h"
41 #include "ixheaacd_drc_dec.h"
42 #include "ixheaacd_sbrdecoder.h"
43 #include "ixheaacd_mps_polyphase.h"
44 #include "ixheaacd_sbr_const.h"
45 #include "ixheaacd_main.h"
46 #include "ixheaacd_arith_dec.h"
47 #include "ixheaacd_bit_extract.h"
48 #include "ixheaacd_main.h"
49 #include "ixheaacd_func_def.h"
50 #include "ixheaacd_constants.h"
51 #include "ixheaacd_basic_ops32.h"
52 #include "ixheaacd_basic_ops40.h"
53 #include "ixheaacd_error_standards.h"
54
ixheaacd_get_mode_lpc(WORD32 lpc_set,ia_bit_buf_struct * it_bit_buff,WORD32 * nk_mode)55 WORD32 ixheaacd_get_mode_lpc(WORD32 lpc_set, ia_bit_buf_struct *it_bit_buff,
56 WORD32 *nk_mode) {
57 WORD32 mode_lpc = 0;
58 switch (lpc_set) {
59 case 4:
60 mode_lpc = 0;
61 break;
62 case 0:
63 case 2:
64 mode_lpc = ixheaacd_read_bits_buf(it_bit_buff, 1);
65 if (mode_lpc == 1) *nk_mode = 3;
66 break;
67 case 1:
68 if (ixheaacd_read_bits_buf(it_bit_buff, 1) == 0)
69 mode_lpc = *nk_mode = 2;
70 else {
71 if (ixheaacd_read_bits_buf(it_bit_buff, 1) == 0)
72 mode_lpc = *nk_mode = 0;
73 else
74 mode_lpc = *nk_mode = 1;
75 }
76 break;
77 case 3:
78 if (ixheaacd_read_bits_buf(it_bit_buff, 1) == 0)
79 mode_lpc = *nk_mode = 1;
80 else {
81 if (ixheaacd_read_bits_buf(it_bit_buff, 1) == 0)
82 mode_lpc = *nk_mode = 0;
83 else {
84 if (ixheaacd_read_bits_buf(it_bit_buff, 1) == 0)
85 mode_lpc = 2;
86 else
87 mode_lpc = 3;
88 *nk_mode = 2;
89 }
90 }
91 break;
92 }
93 return mode_lpc;
94 }
95
ixheaacd_qn_data(WORD32 nk_mode,WORD32 * qn,ia_bit_buf_struct * it_bit_buff)96 VOID ixheaacd_qn_data(WORD32 nk_mode, WORD32 *qn,
97 ia_bit_buf_struct *it_bit_buff) {
98 WORD32 k;
99 switch (nk_mode) {
100 case 1:
101 for (k = 0; k < 2; k++) {
102 while (ixheaacd_read_bits_buf(it_bit_buff, 1) == 1) {
103 qn[k] += 1;
104 }
105 if (qn[k] > 0) qn[k] += 1;
106 }
107 break;
108 case 0:
109 case 2:
110 case 3:
111 for (k = 0; k < 2; k++)
112 qn[k] = 2 + ixheaacd_read_bits_buf(it_bit_buff, 2);
113
114 if (nk_mode == 2) {
115 for (k = 0; k < 2; k++) {
116 if (qn[k] > 4) {
117 qn[k] = 0;
118
119 while (ixheaacd_read_bits_buf(it_bit_buff, 1) == 1) qn[k] += 1;
120
121 if (qn[k] > 0) qn[k] += 4;
122 }
123 }
124 } else {
125 for (k = 0; k < 2; k++) {
126 if (qn[k] > 4) {
127 WORD32 qn_ext = 0;
128 while (ixheaacd_read_bits_buf(it_bit_buff, 1) == 1) qn_ext += 1;
129
130 switch (qn_ext) {
131 case 0:
132 qn[k] = 5;
133 break;
134 case 1:
135 qn[k] = 6;
136 break;
137 case 2:
138 qn[k] = 0;
139 break;
140 default:
141 qn[k] = qn_ext + 4;
142 break;
143 }
144 }
145 }
146 }
147 break;
148 }
149 return;
150 }
151
ixheaacd_code_book_indices(ia_td_frame_data_struct * pstr_td_frame_data,WORD32 nk_mode,WORD32 * pos,ia_bit_buf_struct * it_bit_buff)152 VOID ixheaacd_code_book_indices(ia_td_frame_data_struct *pstr_td_frame_data,
153 WORD32 nk_mode, WORD32 *pos,
154 ia_bit_buf_struct *it_bit_buff) {
155 WORD32 k, qn[2] = {0, 0}, nk, n, i;
156
157 ixheaacd_qn_data(nk_mode, &qn[0], it_bit_buff);
158
159 pstr_td_frame_data->lpc_first_approx_idx[(*pos)++] = qn[0];
160 pstr_td_frame_data->lpc_first_approx_idx[(*pos)++] = qn[1];
161
162 for (k = 0; k < 2; k++) {
163 if (qn[k] > 0) {
164 if (qn[k] > 4) {
165 nk = (qn[k] - 3) / 2;
166 n = qn[k] - nk * 2;
167 } else {
168 nk = 0;
169 n = qn[k];
170 }
171 pstr_td_frame_data->lpc_first_approx_idx[(*pos)++] =
172 ixheaacd_read_bits_buf(it_bit_buff, 4 * n);
173
174 for (i = 0; i < 8; i++)
175 pstr_td_frame_data->lpc_first_approx_idx[(*pos)++] =
176 ixheaacd_read_bits_buf(it_bit_buff, nk);
177 }
178 }
179 return;
180 }
181
ixheaacd_lpc_data(WORD32 first_lpd_flag,WORD32 mod[],ia_td_frame_data_struct * pstr_td_frame_data,ia_bit_buf_struct * it_bit_buff)182 VOID ixheaacd_lpc_data(WORD32 first_lpd_flag, WORD32 mod[],
183 ia_td_frame_data_struct *pstr_td_frame_data,
184 ia_bit_buf_struct *it_bit_buff) {
185 WORD32 mode_lpc, nk_mode = 0, j = 0;
186
187 mode_lpc = ixheaacd_get_mode_lpc(4, it_bit_buff, &nk_mode);
188
189 pstr_td_frame_data->lpc_first_approx_idx[j++] =
190 ixheaacd_read_bits_buf(it_bit_buff, 8);
191
192 ixheaacd_code_book_indices(pstr_td_frame_data, nk_mode, &j, it_bit_buff);
193 if (first_lpd_flag) {
194 mode_lpc = ixheaacd_get_mode_lpc(0, it_bit_buff, &nk_mode);
195 pstr_td_frame_data->lpc_first_approx_idx[j++] = mode_lpc;
196
197 if (mode_lpc == 0)
198 pstr_td_frame_data->lpc_first_approx_idx[j++] =
199 ixheaacd_read_bits_buf(it_bit_buff, 8);
200
201 ixheaacd_code_book_indices(pstr_td_frame_data, nk_mode, &j, it_bit_buff);
202 }
203 if (mod[0] < 3) {
204 mode_lpc = ixheaacd_get_mode_lpc(2, it_bit_buff, &nk_mode);
205 pstr_td_frame_data->lpc_first_approx_idx[j++] = mode_lpc;
206
207 if (mode_lpc == 0)
208 pstr_td_frame_data->lpc_first_approx_idx[j++] =
209 ixheaacd_read_bits_buf(it_bit_buff, 8);
210
211 ixheaacd_code_book_indices(pstr_td_frame_data, nk_mode, &j, it_bit_buff);
212 }
213 if (mod[0] < 2) {
214 mode_lpc = ixheaacd_get_mode_lpc(1, it_bit_buff, &nk_mode);
215 pstr_td_frame_data->lpc_first_approx_idx[j++] = mode_lpc;
216
217 if (mode_lpc == 0)
218 pstr_td_frame_data->lpc_first_approx_idx[j++] =
219 ixheaacd_read_bits_buf(it_bit_buff, 8);
220
221 if (mode_lpc != 1)
222 ixheaacd_code_book_indices(pstr_td_frame_data, nk_mode, &j, it_bit_buff);
223 }
224 if (mod[2] < 2) {
225 mode_lpc = ixheaacd_get_mode_lpc(3, it_bit_buff, &nk_mode);
226 pstr_td_frame_data->lpc_first_approx_idx[j++] = mode_lpc;
227
228 if (mode_lpc == 0)
229 pstr_td_frame_data->lpc_first_approx_idx[j++] =
230 ixheaacd_read_bits_buf(it_bit_buff, 8);
231
232 ixheaacd_code_book_indices(pstr_td_frame_data, nk_mode, &j, it_bit_buff);
233 }
234 return;
235 }
236
ixheaacd_fac_decoding(WORD32 fac_length,WORD32 k,WORD32 * fac_prm,ia_bit_buf_struct * it_bit_buff)237 VOID ixheaacd_fac_decoding(WORD32 fac_length, WORD32 k, WORD32 *fac_prm,
238 ia_bit_buf_struct *it_bit_buff) {
239 WORD32 i, j, n, qn, nk, kv[8];
240 long code_book_index;
241
242 for (i = 0; i < fac_length; i += 8) {
243 qn = 0;
244 while (ixheaacd_read_bits_buf(it_bit_buff, 1) == 1) {
245 qn += 1;
246 }
247 if (qn != 0) qn += 1;
248
249 nk = 0;
250 n = qn;
251 if (qn > 4) {
252 nk = (qn - 3) >> 1;
253 n = qn - nk * 2;
254 }
255
256 code_book_index = ixheaacd_read_bits_buf(it_bit_buff, 4 * n);
257
258 for (j = 0; j < 8; j++) {
259 kv[j] = ixheaacd_read_bits_buf(it_bit_buff, nk);
260 }
261
262 ixheaacd_rotated_gosset_mtx_dec(qn, code_book_index, kv,
263 &fac_prm[k * FAC_LENGTH + i]);
264 }
265 }
266
267 const UWORD8 ixheaacd_num_bites_celp_coding[8][4] = {
268 {5, 5, 5, 5}, {9, 9, 5, 5}, {9, 9, 9, 9}, {13, 13, 9, 9},
269 {13, 13, 13, 13}, {16, 16, 16, 16}, {1, 5, 1, 5}, {1, 5, 5, 5}};
270
ixheaacd_acelp_decoding(WORD32 k,ia_usac_data_struct * usac_data,ia_td_frame_data_struct * pstr_td_frame_data,ia_bit_buf_struct * it_bit_buff,WORD32 chan)271 VOID ixheaacd_acelp_decoding(WORD32 k, ia_usac_data_struct *usac_data,
272 ia_td_frame_data_struct *pstr_td_frame_data,
273 ia_bit_buf_struct *it_bit_buff, WORD32 chan) {
274 WORD32 sfr, kk;
275 WORD32 nb_subfr = usac_data->num_subfrm;
276 const UWORD8 *ptr_num_bits =
277 &ixheaacd_num_bites_celp_coding[pstr_td_frame_data->acelp_core_mode][0];
278
279 chan = 0;
280 pstr_td_frame_data->mean_energy[k] = ixheaacd_read_bits_buf(it_bit_buff, 2);
281
282 for (sfr = 0; sfr < nb_subfr; sfr++) {
283 kk = k * 4 + sfr;
284
285 if ((sfr == 0) || ((nb_subfr == 4) && (sfr == 2)))
286 pstr_td_frame_data->acb_index[kk] =
287 ixheaacd_read_bits_buf(it_bit_buff, 9);
288
289 else
290 pstr_td_frame_data->acb_index[kk] =
291 ixheaacd_read_bits_buf(it_bit_buff, 6);
292
293 pstr_td_frame_data->ltp_filtering_flag[kk] =
294 ixheaacd_read_bits_buf(it_bit_buff, 1);
295
296 if (pstr_td_frame_data->acelp_core_mode == 5) {
297 pstr_td_frame_data->icb_index[kk][0] =
298 ixheaacd_read_bits_buf(it_bit_buff, 2);
299 pstr_td_frame_data->icb_index[kk][1] =
300 ixheaacd_read_bits_buf(it_bit_buff, 2);
301 pstr_td_frame_data->icb_index[kk][2] =
302 ixheaacd_read_bits_buf(it_bit_buff, 2);
303 pstr_td_frame_data->icb_index[kk][3] =
304 ixheaacd_read_bits_buf(it_bit_buff, 2);
305 pstr_td_frame_data->icb_index[kk][4] =
306 ixheaacd_read_bits_buf(it_bit_buff, 14);
307 pstr_td_frame_data->icb_index[kk][5] =
308 ixheaacd_read_bits_buf(it_bit_buff, 14);
309 pstr_td_frame_data->icb_index[kk][6] =
310 ixheaacd_read_bits_buf(it_bit_buff, 14);
311 pstr_td_frame_data->icb_index[kk][7] =
312 ixheaacd_read_bits_buf(it_bit_buff, 14);
313 } else {
314 pstr_td_frame_data->icb_index[kk][0] =
315 ixheaacd_read_bits_buf(it_bit_buff, ptr_num_bits[0]);
316 pstr_td_frame_data->icb_index[kk][1] =
317 ixheaacd_read_bits_buf(it_bit_buff, ptr_num_bits[1]);
318 pstr_td_frame_data->icb_index[kk][2] =
319 ixheaacd_read_bits_buf(it_bit_buff, ptr_num_bits[2]);
320 pstr_td_frame_data->icb_index[kk][3] =
321 ixheaacd_read_bits_buf(it_bit_buff, ptr_num_bits[3]);
322 }
323
324 pstr_td_frame_data->gains[kk] = ixheaacd_read_bits_buf(it_bit_buff, 7);
325 }
326 }
327
ixheaacd_tcx_coding(ia_usac_data_struct * usac_data,pWORD32 quant,WORD32 k,WORD32 first_tcx_flag,ia_td_frame_data_struct * pstr_td_frame_data,ia_bit_buf_struct * it_bit_buff)328 IA_ERRORCODE ixheaacd_tcx_coding(ia_usac_data_struct *usac_data, pWORD32 quant,
329 WORD32 k, WORD32 first_tcx_flag,
330 ia_td_frame_data_struct *pstr_td_frame_data,
331 ia_bit_buf_struct *it_bit_buff
332
333 ) {
334 IA_ERRORCODE err = IA_NO_ERROR;
335
336 pstr_td_frame_data->noise_factor[k] = ixheaacd_read_bits_buf(it_bit_buff, 3);
337
338 pstr_td_frame_data->global_gain[k] = ixheaacd_read_bits_buf(it_bit_buff, 7);
339
340 switch (pstr_td_frame_data->mod[k]) {
341 case 1:
342 pstr_td_frame_data->tcx_lg[k] = usac_data->len_subfrm;
343 break;
344 case 2:
345 pstr_td_frame_data->tcx_lg[k] = 2 * (usac_data->len_subfrm);
346 break;
347 case 3:
348 pstr_td_frame_data->tcx_lg[k] = 4 * (usac_data->len_subfrm);
349 break;
350 }
351
352 if (first_tcx_flag) {
353 if (usac_data->usac_independency_flg) {
354 pstr_td_frame_data->arith_reset_flag = 1;
355 } else {
356 pstr_td_frame_data->arith_reset_flag =
357 ixheaacd_read_bits_buf(it_bit_buff, 1);
358 }
359 }
360
361 err = ixheaacd_arith_data(pstr_td_frame_data, quant, usac_data, it_bit_buff,
362 (first_tcx_flag), k);
363 if (err) return err;
364
365 return IA_NO_ERROR;
366 }
367
ixheaacd_lpd_channel_stream(ia_usac_data_struct * usac_data,ia_td_frame_data_struct * pstr_td_frame_data,ia_bit_buf_struct * it_bit_buff,FLOAT32 * synth)368 WORD32 ixheaacd_lpd_channel_stream(ia_usac_data_struct *usac_data,
369 ia_td_frame_data_struct *pstr_td_frame_data,
370 ia_bit_buf_struct *it_bit_buff,
371 FLOAT32 *synth
372
373 )
374
375 {
376 WORD32 lpd_mode, k, cnt, ii;
377 WORD32 first_tcx_flag;
378 WORD32 *quant;
379 WORD32 core_mode_last, fac_data_present;
380 WORD32 *fac_data;
381 WORD32 first_lpd_flag;
382 WORD32 short_fac_flag;
383 WORD32 bpf_control_info;
384 WORD32 chan = usac_data->present_chan;
385 WORD32 last_lpd_mode = usac_data->str_tddec[chan]->mode_prev;
386 WORD32 err = 0;
387 short_fac_flag = 0;
388
389 pstr_td_frame_data->acelp_core_mode = ixheaacd_read_bits_buf(it_bit_buff, 3);
390
391 lpd_mode = ixheaacd_read_bits_buf(it_bit_buff, 5);
392
393 if (lpd_mode == 25) {
394 pstr_td_frame_data->mod[0] = pstr_td_frame_data->mod[1] =
395 pstr_td_frame_data->mod[2] = pstr_td_frame_data->mod[3] = 3;
396 } else if (lpd_mode == 24) {
397 pstr_td_frame_data->mod[0] = pstr_td_frame_data->mod[1] =
398 pstr_td_frame_data->mod[2] = pstr_td_frame_data->mod[3] = 2;
399 } else {
400 if (lpd_mode >= 20) {
401 pstr_td_frame_data->mod[0] = lpd_mode & 1;
402 pstr_td_frame_data->mod[1] = (lpd_mode >> 1) & 1;
403 pstr_td_frame_data->mod[2] = pstr_td_frame_data->mod[3] = 2;
404 } else if (lpd_mode >= 16) {
405 pstr_td_frame_data->mod[0] = pstr_td_frame_data->mod[1] = 2;
406 pstr_td_frame_data->mod[2] = lpd_mode & 1;
407 pstr_td_frame_data->mod[3] = (lpd_mode >> 1) & 1;
408 } else {
409 pstr_td_frame_data->mod[0] = lpd_mode & 1;
410 pstr_td_frame_data->mod[1] = (lpd_mode >> 1) & 1;
411 pstr_td_frame_data->mod[2] = (lpd_mode >> 2) & 1;
412 pstr_td_frame_data->mod[3] = (lpd_mode >> 3) & 1;
413 }
414 }
415
416 bpf_control_info = ixheaacd_read_bits_buf(it_bit_buff, 1);
417
418 core_mode_last = ixheaacd_read_bits_buf(it_bit_buff, 1);
419
420 fac_data_present = ixheaacd_read_bits_buf(it_bit_buff, 1);
421
422 first_lpd_flag = (core_mode_last == 0) ? 1 : 0;
423
424 quant = pstr_td_frame_data->x_tcx_invquant;
425 first_tcx_flag = 1;
426 k = 0;
427 while (k < 4) {
428 if (k == 0) {
429 if ((core_mode_last == 1) && (fac_data_present == 1))
430 ixheaacd_fac_decoding((usac_data->len_subfrm) / 2, k,
431 pstr_td_frame_data->fac, it_bit_buff);
432 } else {
433 if (((last_lpd_mode == 0) && (pstr_td_frame_data->mod[k] > 0)) ||
434 ((last_lpd_mode > 0) && (pstr_td_frame_data->mod[k] == 0)))
435 ixheaacd_fac_decoding((usac_data->len_subfrm) / 2, k,
436 pstr_td_frame_data->fac, it_bit_buff);
437 }
438
439 if (pstr_td_frame_data->mod[k] == 0) {
440 ixheaacd_acelp_decoding(k, usac_data, pstr_td_frame_data, it_bit_buff,
441 chan);
442 last_lpd_mode = 0;
443 pstr_td_frame_data->tcx_lg[k] = 0;
444 k += 1;
445 } else {
446 err = ixheaacd_tcx_coding(usac_data, quant, k, first_tcx_flag,
447 pstr_td_frame_data, it_bit_buff);
448 if (err) return err;
449 last_lpd_mode = pstr_td_frame_data->mod[k];
450 quant += pstr_td_frame_data->tcx_lg[k];
451
452 cnt = 1 << (pstr_td_frame_data->mod[k] - 1);
453
454 for (ii = 0; ii < cnt - 1; ii++)
455 pstr_td_frame_data->tcx_lg[k + 1 + ii] = 0;
456
457 k += cnt;
458 first_tcx_flag = 0;
459 }
460 }
461
462 ixheaacd_lpc_data(first_lpd_flag, pstr_td_frame_data->mod, pstr_td_frame_data,
463 it_bit_buff);
464
465 if ((core_mode_last == 0) && (fac_data_present == 1)) {
466 WORD32 fac_length;
467 short_fac_flag = ixheaacd_read_bits_buf(it_bit_buff, 1);
468
469 fac_length =
470 (short_fac_flag) ? ((usac_data->ccfl) / 16) : ((usac_data->ccfl) / 8);
471
472 fac_data = pstr_td_frame_data->fac_data;
473 fac_data[0] = ixheaacd_read_bits_buf(it_bit_buff, 7);
474 ixheaacd_fac_decoding(fac_length, 0, &fac_data[1], it_bit_buff);
475 }
476
477 err = ixheaacd_lpd_dec(usac_data, usac_data->str_tddec[chan],
478 pstr_td_frame_data, synth, first_lpd_flag,
479 short_fac_flag, bpf_control_info);
480
481 return (err);
482 }
483
ixheaacd_tw_buff_update(ia_usac_data_struct * usac_data,WORD32 i,ia_usac_lpd_decoder_handle st)484 WORD32 ixheaacd_tw_buff_update(ia_usac_data_struct *usac_data, WORD32 i,
485 ia_usac_lpd_decoder_handle st) {
486 WORD32 *p_ioverlap = usac_data->overlap_data_ptr[i];
487 WORD32 td_frame_prev = usac_data->td_frame_prev[i];
488 WORD32 window_sequence_last = usac_data->window_sequence_last[i];
489 WORD32 tw_mdct = usac_data->tw_mdct[0];
490
491 if (!td_frame_prev) {
492 if (tw_mdct) {
493 return -1;
494 } else {
495 ixheaacd_reset_acelp_data_fix(
496 usac_data, st, p_ioverlap,
497 (window_sequence_last == EIGHT_SHORT_SEQUENCE), 0);
498 }
499 }
500 return 0;
501 }
502
ixheaacd_td_frm_dec(ia_usac_data_struct * usac_data,WORD32 k,WORD32 mod0)503 VOID ixheaacd_td_frm_dec(ia_usac_data_struct *usac_data, WORD32 k,
504 WORD32 mod0) {
505 WORD32 i;
506 WORD32 lfac = 0;
507
508 WORD32 *p_out_idata = usac_data->output_data_ptr[k];
509 WORD32 *p_ioverlap = usac_data->overlap_data_ptr[k];
510 WORD32 nlong = usac_data->ccfl;
511 WORD32 window_sequence_last = usac_data->window_sequence_last[k];
512 WORD32 td_frame_prev = usac_data->td_frame_prev[k];
513 WORD32 tw_mdct = usac_data->tw_mdct[0];
514 WORD32 nshort = nlong / 8;
515 WORD32 *p_in_idata = p_out_idata;
516
517 if (!td_frame_prev) {
518 if (window_sequence_last == EIGHT_SHORT_SEQUENCE) {
519 lfac = nshort / 2;
520 } else {
521 lfac = nshort;
522 }
523 }
524
525 if (!td_frame_prev && (mod0 == 0)) {
526 for (i = 0; i < (nlong / 2) - lfac - (LEN_SUBFR); i++) {
527 p_in_idata[i] = 0;
528 }
529 } else if (!td_frame_prev && (mod0 > 0)) {
530 for (i = 0; i < (nlong / 2) - lfac; i++) {
531 p_in_idata[i] = 0;
532 }
533 }
534
535 if (tw_mdct) {
536 if (!td_frame_prev && (mod0 == 0)) {
537 for (i = (nlong / 2) - lfac - (LEN_SUBFR); i < nlong / 2; i++) {
538 p_ioverlap[i + (nlong / 2)] = 0;
539 }
540 }
541 for (i = 0; i < nlong / 2; i++) {
542 p_out_idata[i] = p_ioverlap[i] << 1;
543 p_out_idata[i + nlong / 2] =
544 ixheaacd_add32_sat(p_ioverlap[i + nlong / 2] << 1, p_in_idata[i]);
545 p_ioverlap[i] = ixheaacd_add32_sat(p_in_idata[i + (nlong / 2)] >> 1,
546 p_ioverlap[i + nlong]);
547 p_ioverlap[i + (nlong / 2)] = 0;
548 p_ioverlap[i + nlong] = 0;
549 p_ioverlap[i + nlong + (nlong / 2)] = 0;
550 }
551 } else {
552 if (!td_frame_prev && (mod0 == 0)) {
553 for (i = (nlong / 2) - lfac - (LEN_SUBFR); i < nlong / 2; i++) {
554 p_ioverlap[i] = 0;
555 }
556 } else if (!td_frame_prev) {
557 for (i = (nlong / 2) - lfac; i < nlong; i++) {
558 p_ioverlap[i] = 0;
559 }
560 }
561 for (i = 0; i < nlong; i++) {
562 p_out_idata[i] = ixheaacd_add32_sat(p_ioverlap[i] << 1, p_in_idata[i]);
563 p_ioverlap[i] = 0;
564 }
565 }
566 }
567