• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_type_def.h>
52 #include <ixheaacd_basic_ops32.h>
53 #include <ixheaacd_basic_ops40.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 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   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 VOID 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   pstr_td_frame_data->noise_factor[k] = ixheaacd_read_bits_buf(it_bit_buff, 3);
335 
336   pstr_td_frame_data->global_gain[k] = ixheaacd_read_bits_buf(it_bit_buff, 7);
337 
338   switch (pstr_td_frame_data->mod[k]) {
339     case 1:
340       pstr_td_frame_data->tcx_lg[k] = usac_data->len_subfrm;
341       break;
342     case 2:
343       pstr_td_frame_data->tcx_lg[k] = 2 * (usac_data->len_subfrm);
344       break;
345     case 3:
346       pstr_td_frame_data->tcx_lg[k] = 4 * (usac_data->len_subfrm);
347       break;
348   }
349 
350   if (first_tcx_flag) {
351     if (usac_data->usac_independency_flg) {
352       pstr_td_frame_data->arith_reset_flag = 1;
353     } else {
354       pstr_td_frame_data->arith_reset_flag =
355           ixheaacd_read_bits_buf(it_bit_buff, 1);
356     }
357   }
358 
359   ixheaacd_arith_data(pstr_td_frame_data, quant, usac_data, it_bit_buff,
360                       (first_tcx_flag), k);
361 }
362 
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)363 WORD32 ixheaacd_lpd_channel_stream(ia_usac_data_struct *usac_data,
364                                    ia_td_frame_data_struct *pstr_td_frame_data,
365                                    ia_bit_buf_struct *it_bit_buff,
366                                    FLOAT32 *synth
367 
368                                    )
369 
370 {
371   WORD32 lpd_mode, k, cnt, ii;
372   WORD32 first_tcx_flag;
373   WORD32 *quant;
374   WORD32 core_mode_last, fac_data_present;
375   WORD32 *fac_data;
376   WORD32 first_lpd_flag;
377   WORD32 short_fac_flag;
378   WORD32 bpf_control_info;
379   WORD32 chan = usac_data->present_chan;
380   WORD32 last_lpd_mode = usac_data->str_tddec[chan]->mode_prev;
381   WORD32 err = 0;
382   short_fac_flag = 0;
383 
384   pstr_td_frame_data->acelp_core_mode = ixheaacd_read_bits_buf(it_bit_buff, 3);
385 
386   lpd_mode = ixheaacd_read_bits_buf(it_bit_buff, 5);
387 
388   if (lpd_mode == 25) {
389     pstr_td_frame_data->mod[0] = pstr_td_frame_data->mod[1] =
390         pstr_td_frame_data->mod[2] = pstr_td_frame_data->mod[3] = 3;
391   } else if (lpd_mode == 24) {
392     pstr_td_frame_data->mod[0] = pstr_td_frame_data->mod[1] =
393         pstr_td_frame_data->mod[2] = pstr_td_frame_data->mod[3] = 2;
394   } else {
395     if (lpd_mode >= 20) {
396       pstr_td_frame_data->mod[0] = lpd_mode & 1;
397       pstr_td_frame_data->mod[1] = (lpd_mode >> 1) & 1;
398       pstr_td_frame_data->mod[2] = pstr_td_frame_data->mod[3] = 2;
399     } else if (lpd_mode >= 16) {
400       pstr_td_frame_data->mod[0] = pstr_td_frame_data->mod[1] = 2;
401       pstr_td_frame_data->mod[2] = lpd_mode & 1;
402       pstr_td_frame_data->mod[3] = (lpd_mode >> 1) & 1;
403     } else {
404       pstr_td_frame_data->mod[0] = lpd_mode & 1;
405       pstr_td_frame_data->mod[1] = (lpd_mode >> 1) & 1;
406       pstr_td_frame_data->mod[2] = (lpd_mode >> 2) & 1;
407       pstr_td_frame_data->mod[3] = (lpd_mode >> 3) & 1;
408     }
409   }
410 
411   bpf_control_info = ixheaacd_read_bits_buf(it_bit_buff, 1);
412 
413   core_mode_last = ixheaacd_read_bits_buf(it_bit_buff, 1);
414 
415   fac_data_present = ixheaacd_read_bits_buf(it_bit_buff, 1);
416 
417   first_lpd_flag = (core_mode_last == 0) ? 1 : 0;
418 
419   quant = pstr_td_frame_data->x_tcx_invquant;
420   first_tcx_flag = 1;
421   k = 0;
422   while (k < 4) {
423     if (k == 0) {
424       if ((core_mode_last == 1) && (fac_data_present == 1))
425         ixheaacd_fac_decoding((usac_data->len_subfrm) / 2, k,
426                               pstr_td_frame_data->fac, it_bit_buff);
427     } else {
428       if (((last_lpd_mode == 0) && (pstr_td_frame_data->mod[k] > 0)) ||
429           ((last_lpd_mode > 0) && (pstr_td_frame_data->mod[k] == 0)))
430         ixheaacd_fac_decoding((usac_data->len_subfrm) / 2, k,
431                               pstr_td_frame_data->fac, it_bit_buff);
432     }
433 
434     if (pstr_td_frame_data->mod[k] == 0) {
435       ixheaacd_acelp_decoding(k, usac_data, pstr_td_frame_data, it_bit_buff,
436                               chan);
437       last_lpd_mode = 0;
438       pstr_td_frame_data->tcx_lg[k] = 0;
439       k += 1;
440     } else {
441       ixheaacd_tcx_coding(usac_data, quant, k, first_tcx_flag,
442                           pstr_td_frame_data, it_bit_buff);
443       last_lpd_mode = pstr_td_frame_data->mod[k];
444       quant += pstr_td_frame_data->tcx_lg[k];
445 
446       cnt = 1 << (pstr_td_frame_data->mod[k] - 1);
447 
448       for (ii = 0; ii < cnt - 1; ii++)
449         pstr_td_frame_data->tcx_lg[k + 1 + ii] = 0;
450 
451       k += cnt;
452       first_tcx_flag = 0;
453     }
454   }
455 
456   ixheaacd_lpc_data(first_lpd_flag, pstr_td_frame_data->mod, pstr_td_frame_data,
457                     it_bit_buff);
458 
459   if ((core_mode_last == 0) && (fac_data_present == 1)) {
460     WORD32 fac_length;
461     short_fac_flag = ixheaacd_read_bits_buf(it_bit_buff, 1);
462 
463     fac_length =
464         (short_fac_flag) ? ((usac_data->ccfl) / 16) : ((usac_data->ccfl) / 8);
465 
466     fac_data = pstr_td_frame_data->fac_data;
467     fac_data[0] = ixheaacd_read_bits_buf(it_bit_buff, 7);
468     ixheaacd_fac_decoding(fac_length, 0, &fac_data[1], it_bit_buff);
469   }
470 
471   err = ixheaacd_lpd_dec(usac_data, usac_data->str_tddec[chan],
472                          pstr_td_frame_data, synth, first_lpd_flag,
473                          short_fac_flag, bpf_control_info);
474 
475   return (err);
476 }
477 
ixheaacd_tw_buff_update(ia_usac_data_struct * usac_data,WORD32 i,ia_usac_lpd_decoder_handle st)478 WORD32 ixheaacd_tw_buff_update(ia_usac_data_struct *usac_data, WORD32 i,
479                                ia_usac_lpd_decoder_handle st) {
480   WORD32 *p_ioverlap = usac_data->overlap_data_ptr[i];
481   WORD32 td_frame_prev = usac_data->td_frame_prev[i];
482   WORD32 window_sequence_last = usac_data->window_sequence_last[i];
483   WORD32 tw_mdct = usac_data->tw_mdct[0];
484 
485   if (!td_frame_prev) {
486     if (tw_mdct) {
487       return -1;
488     } else {
489       ixheaacd_reset_acelp_data_fix(
490           usac_data, st, p_ioverlap,
491           (window_sequence_last == EIGHT_SHORT_SEQUENCE), 0);
492     }
493   }
494   return 0;
495 }
496 
ixheaacd_td_frm_dec(ia_usac_data_struct * usac_data,WORD32 k,WORD32 mod0)497 VOID ixheaacd_td_frm_dec(ia_usac_data_struct *usac_data, WORD32 k,
498                          WORD32 mod0) {
499   WORD32 i;
500   WORD32 lfac = 0;
501 
502   WORD32 *p_out_idata = usac_data->output_data_ptr[k];
503   WORD32 *p_ioverlap = usac_data->overlap_data_ptr[k];
504   WORD32 nlong = usac_data->ccfl;
505   WORD32 window_sequence_last = usac_data->window_sequence_last[k];
506   WORD32 td_frame_prev = usac_data->td_frame_prev[k];
507   WORD32 tw_mdct = usac_data->tw_mdct[0];
508   WORD32 nshort = nlong / 8;
509   WORD32 *p_in_idata = p_out_idata;
510 
511   if (!td_frame_prev) {
512     if (window_sequence_last == EIGHT_SHORT_SEQUENCE) {
513       lfac = nshort / 2;
514     } else {
515       lfac = nshort;
516     }
517   }
518 
519   if (!td_frame_prev && (mod0 == 0)) {
520     for (i = 0; i < (nlong / 2) - lfac - (LEN_SUBFR); i++) {
521       p_in_idata[i] = 0;
522     }
523   } else if (!td_frame_prev && (mod0 > 0)) {
524     for (i = 0; i < (nlong / 2) - lfac; i++) {
525       p_in_idata[i] = 0;
526     }
527   }
528 
529   if (tw_mdct) {
530     if (!td_frame_prev && (mod0 == 0)) {
531       for (i = (nlong / 2) - lfac - (LEN_SUBFR); i < nlong / 2; i++) {
532         p_ioverlap[i + (nlong / 2)] = 0;
533       }
534     }
535     for (i = 0; i < nlong / 2; i++) {
536       p_out_idata[i] = p_ioverlap[i] << 1;
537       p_out_idata[i + nlong / 2] =
538           ixheaacd_add32_sat(p_ioverlap[i + nlong / 2] << 1, p_in_idata[i]);
539       p_ioverlap[i] = ixheaacd_add32_sat(p_in_idata[i + (nlong / 2)] >> 1,
540                                          p_ioverlap[i + nlong]);
541       p_ioverlap[i + (nlong / 2)] = 0;
542       p_ioverlap[i + nlong] = 0;
543       p_ioverlap[i + nlong + (nlong / 2)] = 0;
544     }
545   } else {
546     if (!td_frame_prev && (mod0 == 0)) {
547       for (i = (nlong / 2) - lfac - (LEN_SUBFR); i < nlong / 2; i++) {
548         p_ioverlap[i] = 0;
549       }
550     } else if (!td_frame_prev) {
551       for (i = (nlong / 2) - lfac; i < nlong; i++) {
552         p_ioverlap[i] = 0;
553       }
554     }
555     for (i = 0; i < nlong; i++) {
556       p_out_idata[i] = ixheaacd_add32_sat(p_ioverlap[i] << 1, p_in_idata[i]);
557       p_ioverlap[i] = 0;
558     }
559   }
560 }