Coverage Report

Created: 2026-02-26 06:35

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libxaac/encoder/iusace_acelp_enc.c
Line
Count
Source
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
#include <math.h>
23
#include "ixheaac_type_def.h"
24
#include "iusace_bitbuffer.h"
25
26
/* DRC */
27
#include "impd_drc_common_enc.h"
28
#include "impd_drc_uni_drc.h"
29
#include "impd_drc_tables.h"
30
#include "impd_drc_api.h"
31
#include "impd_drc_uni_drc_eq.h"
32
#include "impd_drc_uni_drc_filter_bank.h"
33
#include "impd_drc_gain_enc.h"
34
#include "impd_drc_struct_def.h"
35
36
#include "iusace_cnst.h"
37
#include "iusace_tns_usac.h"
38
#include "iusace_psy_mod.h"
39
#include "ixheaace_adjust_threshold_data.h"
40
#include "iusace_fd_qc_util.h"
41
#include "iusace_config.h"
42
#include "iusace_arith_enc.h"
43
#include "iusace_block_switch_const.h"
44
#include "iusace_block_switch_struct_def.h"
45
#include "iusace_lpd_rom.h"
46
#include "iusace_lpd.h"
47
48
VOID iusace_acelp_encode(FLOAT32 *lp_filt_coeff, FLOAT32 *quant_lp_filt_coeff, FLOAT32 *speech_in,
49
                         FLOAT32 *wsig_in, FLOAT32 *synth_out, FLOAT32 *wsynth_out,
50
                         WORD16 acelp_core_mode, ia_usac_lpd_state_struct *lpd_state,
51
                         WORD32 len_subfrm, FLOAT32 norm_corr, FLOAT32 norm_corr2,
52
                         WORD32 ol_pitch_lag1, WORD32 ol_pitch_lag2, WORD32 pit_adj,
53
421k
                         WORD32 *acelp_params, iusace_scratch_mem *pstr_scratch) {
54
421k
  WORD32 i, i_subfr, num_bits, t;
55
421k
  WORD32 t0, t0_min, t0_max, index, subfrm_flag;
56
421k
  WORD32 t0_frac;
57
421k
  FLOAT32 temp, energy, max_ener, mean_ener_code;
58
421k
  FLOAT32 pitch_gain, code_gain, gain1, gain2;
59
421k
  FLOAT32 tgt_cb_corr[5], tgt_cb_corr2[2];
60
421k
  FLOAT32 *p_lp_filt_coeff, *p_quant_lp_filt_coeff, weighted_lpc[ORDER + 1];
61
421k
  FLOAT32 imp_res[LEN_SUBFR];
62
421k
  FLOAT32 code[LEN_SUBFR];
63
421k
  WORD16 cb_exc[LEN_SUBFR];
64
421k
  FLOAT32 error[ORDER + LEN_SUBFR + 8];
65
421k
  FLOAT32 cn[LEN_SUBFR];
66
421k
  FLOAT32 xn[LEN_SUBFR];
67
421k
  FLOAT32 xn2[LEN_SUBFR];
68
421k
  FLOAT32 dn[LEN_SUBFR];
69
421k
  FLOAT32 y0[LEN_SUBFR];
70
421k
  FLOAT32 y1[LEN_SUBFR];
71
421k
  FLOAT32 y2[LEN_SUBFR];
72
421k
  WORD32 min_pitch_lag_res1_4;
73
421k
  WORD32 min_pitch_lag_res1_2;
74
421k
  WORD32 min_pitch_lag_res1;
75
421k
  WORD32 max_pitch_lag;
76
421k
  FLOAT32 *exc_buf = pstr_scratch->p_acelp_exc_buf;
77
421k
  FLOAT32 *exc;
78
421k
  FLOAT32 mem_txn, mem_txnq;
79
421k
  WORD32 fac_length = len_subfrm / 2;
80
421k
  if (lpd_state->mode > 0) {
81
28.6M
    for (i = 0; i < fac_length; i++) {
82
28.3M
      acelp_params[i] = lpd_state->avq_params[i];
83
28.3M
    }
84
237k
    acelp_params += fac_length;
85
237k
  }
86
87
421k
  if (pit_adj == SR_MAX)
88
64.9k
    exc = exc_buf + (2 * len_subfrm) + 41;
89
356k
  else
90
356k
    exc = exc_buf + (2 * len_subfrm);
91
92
421k
  memset(exc_buf, 0, (2 * len_subfrm) * sizeof(exc_buf[0]));
93
421k
  memcpy(exc_buf, lpd_state->acelp_exc, 2 * len_subfrm * sizeof(FLOAT32));
94
421k
  memcpy(synth_out - 128, &(lpd_state->synth[ORDER]), 128 * sizeof(FLOAT32));
95
421k
  memcpy(wsynth_out - 128, &(lpd_state->wsynth[1]), 128 * sizeof(FLOAT32));
96
97
421k
  num_bits = ((iusace_acelp_core_numbits_1024[acelp_core_mode] - NBITS_MODE) / 4) - NBITS_LPC;
98
99
421k
  if (pit_adj == 0) {
100
0
    min_pitch_lag_res1_4 = TMIN;
101
0
    min_pitch_lag_res1_2 = TFR2;
102
0
    min_pitch_lag_res1 = TFR1;
103
0
    max_pitch_lag = TMAX;
104
421k
  } else {
105
421k
    i = (((pit_adj * TMIN) + (FSCALE_DENOM / 2)) / FSCALE_DENOM) - TMIN;
106
421k
    min_pitch_lag_res1_4 = TMIN + i;
107
421k
    min_pitch_lag_res1_2 = TFR2 - i;
108
421k
    min_pitch_lag_res1 = TFR1;
109
421k
    max_pitch_lag = TMAX + (6 * i);
110
421k
  }
111
112
421k
  ol_pitch_lag1 *= OPL_DECIM;
113
421k
  ol_pitch_lag2 *= OPL_DECIM;
114
115
421k
  t0_min = ol_pitch_lag1 - 8;
116
117
421k
  t = MIN(ol_pitch_lag1, ol_pitch_lag2) - 4;
118
421k
  if (t0_min < t) t0_min = t;
119
120
421k
  if (t0_min < min_pitch_lag_res1_4) {
121
115k
    t0_min = min_pitch_lag_res1_4;
122
115k
  }
123
421k
  t0_max = t0_min + 15;
124
421k
  t = MAX(ol_pitch_lag1, ol_pitch_lag2) + 4;
125
421k
  if (t0_max > t) t0_max = t;
126
127
421k
  if (t0_max > max_pitch_lag) {
128
18.0k
    t0_max = max_pitch_lag;
129
18.0k
    t0_min = t0_max - 15;
130
18.0k
  }
131
132
421k
  max_ener = 0.0;
133
421k
  mean_ener_code = 0.0;
134
421k
  p_quant_lp_filt_coeff = quant_lp_filt_coeff;
135
1.99M
  for (i_subfr = 0; i_subfr < len_subfrm; i_subfr += LEN_SUBFR) {
136
1.57M
    iusace_compute_lp_residual(p_quant_lp_filt_coeff, &speech_in[i_subfr], &exc[i_subfr],
137
1.57M
                               LEN_SUBFR);
138
1.57M
    energy = 0.01f;
139
102M
    for (i = 0; i < LEN_SUBFR; i++) {
140
100M
      energy += exc[i + i_subfr] * exc[i + i_subfr];
141
100M
    }
142
1.57M
    energy = 10.0f * (FLOAT32)log10(energy / ((FLOAT32)LEN_SUBFR));
143
1.57M
    if (energy < 0.0) {
144
872k
      energy = 0.0;
145
872k
    }
146
1.57M
    if (energy > max_ener) {
147
374k
      max_ener = energy;
148
374k
    }
149
1.57M
    mean_ener_code += 0.25f * energy;
150
1.57M
    p_quant_lp_filt_coeff += (ORDER + 1);
151
1.57M
  }
152
153
421k
  mean_ener_code -= 5.0f * norm_corr;
154
421k
  mean_ener_code -= 5.0f * norm_corr2;
155
156
421k
  temp = (mean_ener_code - 18.0f) / 12.0f;
157
421k
  index = (WORD32)floor(temp + 0.5);
158
421k
  if (index < 0) {
159
268k
    index = 0;
160
268k
  }
161
421k
  if (index > 3) {
162
11.7k
    index = 3;
163
11.7k
  }
164
421k
  mean_ener_code = (((FLOAT32)index) * 12.0f) + 18.0f;
165
166
458k
  while ((mean_ener_code < (max_ener - 27.0)) && (index < 3)) {
167
36.6k
    index++;
168
36.6k
    mean_ener_code += 12.0;
169
36.6k
  }
170
421k
  *acelp_params = index;
171
421k
  acelp_params++;
172
173
421k
  p_lp_filt_coeff = lp_filt_coeff;
174
421k
  p_quant_lp_filt_coeff = quant_lp_filt_coeff;
175
1.99M
  for (i_subfr = 0; i_subfr < len_subfrm; i_subfr += LEN_SUBFR) {
176
1.57M
    subfrm_flag = i_subfr;
177
1.57M
    if ((len_subfrm == 256) && (i_subfr == (2 * LEN_SUBFR))) {
178
307k
      subfrm_flag = 0;
179
180
307k
      t0_min = ol_pitch_lag2 - 8;
181
182
307k
      t = MIN(ol_pitch_lag1, ol_pitch_lag2) - 4;
183
307k
      if (t0_min < t) t0_min = t;
184
185
307k
      if (t0_min < min_pitch_lag_res1_4) {
186
68.9k
        t0_min = min_pitch_lag_res1_4;
187
68.9k
      }
188
307k
      t0_max = t0_min + 15;
189
190
307k
      t = MAX(ol_pitch_lag1, ol_pitch_lag2) + 4;
191
307k
      if (t0_max > t) t0_max = t;
192
193
307k
      if (t0_max > max_pitch_lag) {
194
6.25k
        t0_max = max_pitch_lag;
195
6.25k
        t0_min = t0_max - 15;
196
6.25k
      }
197
307k
    }
198
199
1.57M
    memcpy(xn, &wsig_in[i_subfr], LEN_SUBFR * sizeof(FLOAT32));
200
201
1.57M
    memcpy(error, &synth_out[i_subfr - ORDER], ORDER * sizeof(FLOAT32));
202
1.57M
    memset(error + ORDER, 0, LEN_SUBFR * sizeof(FLOAT32));
203
1.57M
    iusace_synthesis_tool_float(p_quant_lp_filt_coeff, error + ORDER, error + ORDER, LEN_SUBFR,
204
1.57M
                                error, pstr_scratch->p_buf_synthesis_tool);
205
1.57M
    iusace_get_weighted_lpc(p_lp_filt_coeff, weighted_lpc);
206
1.57M
    iusace_compute_lp_residual(weighted_lpc, error + ORDER, xn2, LEN_SUBFR);
207
208
1.57M
    temp = wsynth_out[i_subfr - 1];
209
1.57M
    iusace_apply_deemph(xn2, TILT_FAC, LEN_SUBFR, &temp);
210
1.57M
    memcpy(y0, xn2, LEN_SUBFR * sizeof(FLOAT32));
211
212
102M
    for (i = 0; i < LEN_SUBFR; i++) {
213
100M
      xn[i] -= xn2[i];
214
100M
    }
215
1.57M
    iusace_compute_lp_residual(p_quant_lp_filt_coeff, &speech_in[i_subfr], &exc[i_subfr],
216
1.57M
                               LEN_SUBFR);
217
218
1.57M
    memset(&code[0], 0, ORDER * sizeof(code[0]));
219
1.57M
    memcpy(code + ORDER, xn, (LEN_SUBFR / 2) * sizeof(FLOAT32));
220
1.57M
    temp = 0.0;
221
1.57M
    iusace_apply_preemph(code + ORDER, TILT_FAC, LEN_SUBFR / 2, &temp);
222
1.57M
    iusace_get_weighted_lpc(p_lp_filt_coeff, weighted_lpc);
223
1.57M
    iusace_synthesis_tool_float(weighted_lpc, code + ORDER, code + ORDER, LEN_SUBFR / 2, code,
224
1.57M
                                pstr_scratch->p_buf_synthesis_tool);
225
1.57M
    iusace_compute_lp_residual(p_quant_lp_filt_coeff, code + ORDER, cn, LEN_SUBFR / 2);
226
1.57M
    memcpy(cn + (LEN_SUBFR / 2), &exc[i_subfr + (LEN_SUBFR / 2)],
227
1.57M
           (LEN_SUBFR / 2) * sizeof(FLOAT32));
228
229
1.57M
    iusace_get_weighted_lpc(p_lp_filt_coeff, weighted_lpc);
230
1.57M
    memset(imp_res, 0, LEN_SUBFR * sizeof(FLOAT32));
231
1.57M
    memcpy(imp_res, weighted_lpc, (ORDER + 1) * sizeof(FLOAT32));
232
1.57M
    iusace_synthesis_tool_float(p_quant_lp_filt_coeff, imp_res, imp_res, LEN_SUBFR,
233
1.57M
                                &imp_res[ORDER + 1], pstr_scratch->p_buf_synthesis_tool);
234
1.57M
    temp = 0.0;
235
1.57M
    iusace_apply_deemph(imp_res, TILT_FAC, LEN_SUBFR, &temp);
236
237
1.57M
    iusace_closed_loop_search(&exc[i_subfr], xn, imp_res, t0_min, t0_max, &t0_frac, subfrm_flag,
238
1.57M
                              min_pitch_lag_res1_2, min_pitch_lag_res1, &t0);
239
240
1.57M
    if (subfrm_flag == 0) {
241
729k
      if (t0 < min_pitch_lag_res1_2) {
242
446k
        index = t0 * 4 + t0_frac - (min_pitch_lag_res1_4 * 4);
243
446k
      } else if (t0 < min_pitch_lag_res1) {
244
103k
        index = t0 * 2 + (t0_frac >> 1) - (min_pitch_lag_res1_2 * 2) +
245
103k
                ((min_pitch_lag_res1_2 - min_pitch_lag_res1_4) * 4);
246
180k
      } else {
247
180k
        index = t0 - min_pitch_lag_res1 + ((min_pitch_lag_res1_2 - min_pitch_lag_res1_4) * 4) +
248
180k
                ((min_pitch_lag_res1 - min_pitch_lag_res1_2) * 2);
249
180k
      }
250
251
729k
      t0_min = t0 - 8;
252
729k
      if (t0_min < min_pitch_lag_res1_4) {
253
270k
        t0_min = min_pitch_lag_res1_4;
254
270k
      }
255
729k
      t0_max = t0_min + 15;
256
729k
      if (t0_max > max_pitch_lag) {
257
12.9k
        t0_max = max_pitch_lag;
258
12.9k
        t0_min = t0_max - 15;
259
12.9k
      }
260
843k
    } else {
261
843k
      i = t0 - t0_min;
262
843k
      index = i * 4 + t0_frac;
263
843k
    }
264
1.57M
    *acelp_params = index;
265
1.57M
    acelp_params++;
266
267
1.57M
    iusace_acelp_ltpred_cb_exc(&exc[i_subfr], t0, t0_frac, LEN_SUBFR + 1);
268
1.57M
    iusace_convolve(&exc[i_subfr], imp_res, y1);
269
1.57M
    gain1 = iusace_acelp_tgt_cb_corr2(xn, y1, tgt_cb_corr);
270
1.57M
    iusace_acelp_cb_target_update(xn, xn2, y1, gain1);
271
1.57M
    energy = 0.0;
272
102M
    for (i = 0; i < LEN_SUBFR; i++) {
273
100M
      energy += xn2[i] * xn2[i];
274
100M
    }
275
276
102M
    for (i = 0; i < LEN_SUBFR; i++) {
277
100M
      code[i] = (FLOAT32)(0.18 * exc[i - 1 + i_subfr] + 0.64 * exc[i + i_subfr] +
278
100M
                          0.18 * exc[i + 1 + i_subfr]);
279
100M
    }
280
1.57M
    iusace_convolve(code, imp_res, y2);
281
1.57M
    gain2 = iusace_acelp_tgt_cb_corr2(xn, y2, tgt_cb_corr2);
282
283
1.57M
    iusace_acelp_cb_target_update(xn, xn2, y2, gain2);
284
1.57M
    temp = 0.0;
285
102M
    for (i = 0; i < LEN_SUBFR; i++) {
286
100M
      temp += xn2[i] * xn2[i];
287
100M
    }
288
289
1.57M
    if (temp < energy) {
290
640k
      *acelp_params = 0;
291
640k
      memcpy(&exc[i_subfr], code, LEN_SUBFR * sizeof(FLOAT32));
292
640k
      memcpy(y1, y2, LEN_SUBFR * sizeof(FLOAT32));
293
640k
      pitch_gain = gain2;
294
640k
      tgt_cb_corr[0] = tgt_cb_corr2[0];
295
640k
      tgt_cb_corr[1] = tgt_cb_corr2[1];
296
932k
    } else {
297
932k
      *acelp_params = 1;
298
932k
      pitch_gain = gain1;
299
932k
    }
300
1.57M
    acelp_params++;
301
302
1.57M
    iusace_acelp_cb_target_update(xn, xn2, y1, pitch_gain);
303
1.57M
    iusace_acelp_cb_target_update(cn, cn, &exc[i_subfr], pitch_gain);
304
305
1.57M
    temp = 0.0;
306
1.57M
    iusace_apply_preemph(imp_res, TILT_CODE, LEN_SUBFR, &temp);
307
1.57M
    if (t0_frac > 2) {
308
308k
      t0++;
309
308k
    }
310
311
15.3M
    for (i = t0; i < LEN_SUBFR; i++) {
312
13.7M
      imp_res[i] += imp_res[i - t0] * PIT_SHARP;
313
13.7M
    }
314
315
1.57M
    iusace_acelp_tgt_ir_corr(xn2, imp_res, dn);
316
317
1.57M
    if (acelp_core_mode == ACELP_CORE_MODE_9k6) {
318
0
      iusace_acelp_cb_exc(dn, cn, imp_res, cb_exc, y2, ACELP_NUM_BITS_20, acelp_params,
319
0
                          pstr_scratch->p_acelp_ir_buf);
320
0
      acelp_params += 4;
321
1.57M
    } else if (acelp_core_mode == ACELP_CORE_MODE_11k2) {
322
0
      iusace_acelp_cb_exc(dn, cn, imp_res, cb_exc, y2, ACELP_NUM_BITS_28, acelp_params,
323
0
                          pstr_scratch->p_acelp_ir_buf);
324
0
      acelp_params += 4;
325
1.57M
    } else if (acelp_core_mode == ACELP_CORE_MODE_12k8) {
326
169k
      iusace_acelp_cb_exc(dn, cn, imp_res, cb_exc, y2, ACELP_NUM_BITS_36, acelp_params,
327
169k
                          pstr_scratch->p_acelp_ir_buf);
328
169k
      acelp_params += 4;
329
1.40M
    } else if (acelp_core_mode == ACELP_CORE_MODE_14k4) {
330
0
      iusace_acelp_cb_exc(dn, cn, imp_res, cb_exc, y2, ACELP_NUM_BITS_44, acelp_params,
331
0
                          pstr_scratch->p_acelp_ir_buf);
332
0
      acelp_params += 4;
333
1.40M
    } else if (acelp_core_mode == ACELP_CORE_MODE_16k) {
334
9.97k
      iusace_acelp_cb_exc(dn, cn, imp_res, cb_exc, y2, ACELP_NUM_BITS_52, acelp_params,
335
9.97k
                          pstr_scratch->p_acelp_ir_buf);
336
9.97k
      acelp_params += 4;
337
1.39M
    } else if (acelp_core_mode == ACELP_CORE_MODE_18k4) {
338
1.39M
      iusace_acelp_cb_exc(dn, cn, imp_res, cb_exc, y2, ACELP_NUM_BITS_64, acelp_params,
339
1.39M
                          pstr_scratch->p_acelp_ir_buf);
340
1.39M
      acelp_params += 8;
341
1.39M
    } else {
342
0
      iusace_acelp_cb_exc(dn, cn, imp_res, cb_exc, y2, ACELP_NUM_BITS_64, acelp_params,
343
0
                          pstr_scratch->p_acelp_ir_buf);
344
0
      acelp_params += 8;
345
0
    }
346
347
102M
    for (i = 0; i < LEN_SUBFR; i++) {
348
100M
      code[i] = (FLOAT32)(cb_exc[i] / 512);
349
100M
    }
350
351
1.57M
    temp = 0.0;
352
1.57M
    iusace_apply_preemph(code, TILT_CODE, LEN_SUBFR, &temp);
353
15.3M
    for (i = t0; i < LEN_SUBFR; i++) {
354
13.7M
      code[i] += code[i - t0] * PIT_SHARP;
355
13.7M
    }
356
357
1.57M
    iusace_acelp_tgt_cb_corr1(xn, y1, y2, tgt_cb_corr);
358
1.57M
    iusace_acelp_quant_gain(code, &pitch_gain, &code_gain, tgt_cb_corr, mean_ener_code,
359
1.57M
                            acelp_params);
360
1.57M
    acelp_params++;
361
362
1.57M
    temp = 0.0;
363
102M
    for (i = 0; i < LEN_SUBFR; i++) {
364
100M
      temp += code[i] * code[i];
365
100M
    }
366
1.57M
    temp *= code_gain * code_gain;
367
368
102M
    for (i = 0; i < LEN_SUBFR; i++) {
369
100M
      wsynth_out[i + i_subfr] = y0[i] + (pitch_gain * y1[i]) + (code_gain * y2[i]);
370
100M
    }
371
372
102M
    for (i = 0; i < LEN_SUBFR; i++) {
373
100M
      exc[i + i_subfr] = pitch_gain * exc[i + i_subfr] + code_gain * code[i];
374
100M
    }
375
376
1.57M
    iusace_synthesis_tool_float(p_quant_lp_filt_coeff, &exc[i_subfr], &synth_out[i_subfr],
377
1.57M
                                LEN_SUBFR, &synth_out[i_subfr - ORDER],
378
1.57M
                                pstr_scratch->p_buf_synthesis_tool);
379
1.57M
    p_lp_filt_coeff += (ORDER + 1);
380
1.57M
    p_quant_lp_filt_coeff += (ORDER + 1);
381
1.57M
  }
382
383
421k
  memcpy(lpd_state->acelp_exc, exc - len_subfrm, 2 * len_subfrm * sizeof(FLOAT32));
384
421k
  memcpy(lpd_state->synth, synth_out + len_subfrm - (ORDER + 128),
385
421k
         (ORDER + 128) * sizeof(FLOAT32));
386
421k
  memcpy(lpd_state->wsynth, wsynth_out + len_subfrm - (1 + 128), (1 + 128) * sizeof(FLOAT32));
387
421k
  memcpy(lpd_state->lpc_coeffs_quant, p_quant_lp_filt_coeff - (2 * (ORDER + 1)),
388
421k
         (2 * (ORDER + 1)) * sizeof(FLOAT32));
389
421k
  memcpy(lpd_state->lpc_coeffs, p_lp_filt_coeff - (2 * (ORDER + 1)),
390
421k
         (2 * (ORDER + 1)) * sizeof(FLOAT32));
391
392
421k
  mem_txn = lpd_state->tcx_mem[128 - 1];
393
421k
  mem_txnq = lpd_state->tcx_fac;
394
395
421k
  p_quant_lp_filt_coeff = quant_lp_filt_coeff;
396
1.15M
  for (i_subfr = 0; i_subfr < (len_subfrm - 2 * LEN_SUBFR); i_subfr += LEN_SUBFR) {
397
729k
    iusace_get_weighted_lpc(p_quant_lp_filt_coeff, weighted_lpc);
398
399
729k
    memcpy(error, &speech_in[i_subfr], LEN_SUBFR * sizeof(FLOAT32));
400
729k
    iusace_apply_deemph(error, TILT_FAC, LEN_SUBFR, &mem_txn);
401
402
729k
    memcpy(error, &synth_out[i_subfr], LEN_SUBFR * sizeof(FLOAT32));
403
729k
    iusace_apply_deemph(error, TILT_FAC, LEN_SUBFR, &mem_txnq);
404
405
729k
    p_quant_lp_filt_coeff += (ORDER + 1);
406
729k
  }
407
408
421k
  lpd_state->tcx_quant[0] = mem_txnq;
409
1.26M
  for (i_subfr = 0; i_subfr < (2 * LEN_SUBFR); i_subfr += LEN_SUBFR) {
410
843k
    iusace_get_weighted_lpc(p_quant_lp_filt_coeff, weighted_lpc);
411
412
843k
    memcpy(&(lpd_state->tcx_mem[i_subfr]), &speech_in[i_subfr + (len_subfrm - 2 * LEN_SUBFR)],
413
843k
           LEN_SUBFR * sizeof(FLOAT32));
414
843k
    iusace_apply_deemph(&(lpd_state->tcx_mem[i_subfr]), TILT_FAC, LEN_SUBFR, &mem_txn);
415
416
843k
    memcpy(&(lpd_state->tcx_quant[1 + i_subfr]),
417
843k
           &synth_out[i_subfr + (len_subfrm - 2 * LEN_SUBFR)], LEN_SUBFR * sizeof(FLOAT32));
418
843k
    iusace_apply_deemph(&(lpd_state->tcx_quant[1 + i_subfr]), TILT_FAC, LEN_SUBFR, &mem_txnq);
419
843k
    p_quant_lp_filt_coeff += (ORDER + 1);
420
843k
  }
421
421k
  lpd_state->tcx_fac = mem_txnq;
422
423
421k
  iusace_get_weighted_lpc(p_quant_lp_filt_coeff, weighted_lpc);
424
425
421k
  memcpy(error, &synth_out[len_subfrm - ORDER], ORDER * sizeof(FLOAT32));
426
1.26M
  for (i_subfr = (2 * LEN_SUBFR); i_subfr < (4 * LEN_SUBFR); i_subfr += LEN_SUBFR) {
427
843k
    memset(error + ORDER, 0, LEN_SUBFR * sizeof(FLOAT32));
428
429
843k
    iusace_synthesis_tool_float(p_quant_lp_filt_coeff, error + ORDER, error + ORDER, LEN_SUBFR,
430
843k
                                error, pstr_scratch->p_buf_synthesis_tool);
431
843k
    memcpy(&(lpd_state->tcx_quant[1 + i_subfr]), error + ORDER, LEN_SUBFR * sizeof(FLOAT32));
432
843k
    iusace_apply_deemph(&(lpd_state->tcx_quant[1 + i_subfr]), TILT_FAC, LEN_SUBFR, &mem_txnq);
433
843k
    memcpy(error, error + LEN_SUBFR, ORDER * sizeof(FLOAT32));
434
843k
  }
435
436
421k
  lpd_state->mode = 0;
437
438
421k
  lpd_state->num_bits = num_bits;
439
421k
}