Line data Source code
1 : /******************************************************************************
2 : * ETSI TS 103 634 V1.5.1 *
3 : * Low Complexity Communication Codec Plus (LC3plus) *
4 : * *
5 : * Copyright licence is solely granted through ETSI Intellectual Property *
6 : * Rights Policy, 3rd April 2019. No patent licence is granted by implication, *
7 : * estoppel or otherwise. *
8 : ******************************************************************************/
9 :
10 : #include "options.h"
11 : #include "wmc_auto.h"
12 : #include "defines.h"
13 : #include "functions.h"
14 :
15 0 : void plc_phEcu_hq_ecu(
16 : LC3_FLOAT *f0binPtr, LC3_FLOAT *f0ltpGainPtr, LC3_FLOAT *xfp,
17 : LC3_INT16 prev_bfi, LC3_INT32 *short_flag_prev, LC3_INT32 fs,
18 : LC3_INT32 *time_offs, Complex *X_sav_m, LC3_INT32 *n_plocs, LC3_INT32 *plocs, LC3_FLOAT *f0est,
19 : const LC3_FLOAT *mdctWin, LC3_FLOAT *env_stabPtr, LC3_INT32 delta_corr, LC3_FLOAT *pfind_sensPtr,
20 : LC3_INT32 PhECU_LA, LC3_INT32 t_adv, const LC3_FLOAT *winWhr,
21 : LC3_FLOAT *oold_grp_shape, LC3_FLOAT *oold_EwPtr, LC3_FLOAT *old_grp_shape, LC3_FLOAT *old_EwPtr,
22 : LC3_FLOAT *st_beta_mute, LC3_FLOAT *st_mag_chg_1st, LC3_FLOAT *st_Xavg, LC3_INT32 LA_ZEROS, LC3_FLOAT *x_tda,
23 : LC3_FLOAT *xsubst_dbg, Complex *X_out_m_dbg,
24 : LC3_INT32 *seed_dbg, LC3_FLOAT *mag_chg_dbg, LC3_INT32 *tr_dec_dbg, LC3_FLOAT *gpc_dbg, LC3_FLOAT *X_i_new_re_dbg, LC3_FLOAT *X_i_new_im_dbg,
25 : LC3_FLOAT *corr_phase_dbg,
26 : Fft *PhEcu_Fft, Fft *PhEcu_Ifft
27 : , LC3_UINT8 plc_fadeout_type, LC3_INT16 *nonpure_tone_flag_ptr /* nonpure tone flag */
28 :
29 : )
30 : {
31 : LC3_INT32 i;
32 : LC3_INT32 fs_idx, L, Lprot, n_grp, Lecu, LXsav, Lxfp_inuse;
33 : LC3_FLOAT alpha[8];
34 : LC3_FLOAT beta[8];
35 : LC3_FLOAT mag_chg[8];
36 : LC3_FLOAT xfp_local_rnd[2*MAX_LEN];
37 : Complex X_out_m[2*MAX_LEN];
38 : LC3_INT32 seed;
39 : LC3_INT32 burst_len;
40 :
41 :
42 0 : fs_idx = (LC3_INT32)floor(fs / 10000.0);
43 0 : L = (LC3_INT32)floor(0.01 * fs);
44 0 : Lprot = (LC3_INT32)(1.6 * L);
45 0 : n_grp = xavg_N_grp[fs_idx];
46 0 : Lecu = 2 * L;
47 0 : LXsav = Lprot / 2 + 1; /* 48 kHz may be optimized , to save only up to 20 kHz as in BASOP */
48 0 : Lxfp_inuse = Lprot ;
49 0 : if (prev_bfi == 1){
50 0 : Lxfp_inuse = (LC3_INT32)(L*(3.75/10.0));
51 : }
52 :
53 :
54 :
55 : UNUSED(env_stabPtr);
56 : UNUSED(xsubst_dbg);
57 : UNUSED(X_out_m_dbg);
58 : UNUSED(seed_dbg);
59 : UNUSED(mag_chg_dbg);
60 : UNUSED(tr_dec_dbg);
61 : UNUSED(gpc_dbg);
62 : UNUSED(X_i_new_re_dbg);
63 : UNUSED(X_i_new_im_dbg);
64 : UNUSED(corr_phase_dbg);
65 :
66 :
67 0 : if (prev_bfi != 1)
68 : {
69 0 : for (i = (Lprot-Lxfp_inuse); i < Lprot; i++) {
70 0 : xfp_local_rnd[i] = xfp[i];
71 : /* hysteresis of low level input aligns float fft analysis and peak picking to BASOP performance for low level noisy signals */
72 0 : if (xfp[i] >= -0.5 && xfp[i] <= 0.5) {
73 0 : xfp_local_rnd[i] = 0.0;
74 : }
75 : }
76 0 : *nonpure_tone_flag_ptr = -1; /* set nonpure tone flag for new analysis */
77 :
78 0 : *time_offs = 0;
79 0 : burst_len = (*time_offs / L + 1);
80 0 : plc_phEcu_trans_burst_ana_sub(fs_idx, burst_len, n_grp, oold_grp_shape, oold_EwPtr , old_grp_shape, old_EwPtr, st_beta_mute,
81 : st_mag_chg_1st, st_Xavg, alpha, beta, mag_chg, NULL, NULL
82 : , plc_fadeout_type
83 : );
84 :
85 0 : plc_phEcu_spec_ana(xfp_local_rnd, Lprot, winWhr, pfind_sensPtr, plocs, n_plocs, f0est, X_sav_m, &LXsav, f0binPtr, f0ltpGainPtr, fs_idx, PhEcu_Fft);
86 : }
87 : else
88 : {
89 0 : *time_offs = *time_offs + L;
90 0 : *time_offs = imin(32767 ,*time_offs); /* limit to Word16 range as in BASOP ~= 70 10ms frames@48kHz */
91 0 : burst_len = ((*time_offs / L) + 1);
92 :
93 0 : plc_phEcu_trans_burst_ana_sub(fs_idx, burst_len, n_grp, oold_grp_shape, oold_EwPtr, old_grp_shape, old_EwPtr, st_beta_mute,
94 : st_mag_chg_1st, st_Xavg, alpha, beta, mag_chg, NULL, NULL
95 : , plc_fadeout_type
96 : );
97 :
98 : }
99 :
100 0 : seed = *time_offs;
101 :
102 0 : if (*short_flag_prev != 0)
103 : {
104 0 : *n_plocs = 0;
105 : }
106 :
107 0 : move_cmplx( X_out_m, X_sav_m, LXsav);
108 :
109 : /* inplace X_out_m update */
110 0 : plc_phEcu_subst_spec(plocs, *n_plocs, f0est, *time_offs, X_out_m, LXsav, mag_chg, &seed, alpha, beta, st_Xavg, t_adv, Lprot, delta_corr,
111 : plc_fadeout_type,
112 : nonpure_tone_flag_ptr, /* nonpure_tone_flag , a state updated here */
113 :
114 :
115 : NULL, NULL, NULL);
116 :
117 :
118 :
119 :
120 0 : plc_phEcu_rec_frame(X_out_m, L, Lecu, winWhr, mdctWin, Lprot,
121 : xfp, /* last 3.75ms of non-rounded xfp used here */
122 : *time_offs,
123 : x_tda /* output */,
124 : NULL, NULL, NULL,
125 : LA_ZEROS, PhECU_LA, PhEcu_Ifft);
126 :
127 0 : }
128 :
|