Skip to content
/******************************************************************************
* ETSI TS 103 634 V1.4.3 *
* ETSI TS 103 634 V1.5.1 *
* Low Complexity Communication Codec Plus (LC3plus) *
* *
* Copyright licence is solely granted through ETSI Intellectual Property *
......@@ -7,7 +7,6 @@
* estoppel or otherwise. *
******************************************************************************/
#include "options.h"
#include "wmc_auto.h"
#include "functions.h"
......@@ -26,15 +25,11 @@ void processPlcMain_fl(LC3_FLOAT *q_d_fl_c, LC3_FLOAT *syntM_fl_c, LC3PLUS_Dec*
LC3_FLOAT phEcu_env_stab_local[1];
LC3_FLOAT phEcu_pfind_sens[1];
#ifdef CR8_A_PLC_FADEOUT_TUNING
LC3_INT16 consecutiveLostThreshold = 0;
#endif
#ifdef CR9_L_RETRAIN_FADEOUT_TYPE_CLASSIFIER
LC3_INT16 thresh_tdc_cnt;
LC3_INT16 thresh_ns_cnt;
LC3_INT16 thresh_tdc_ns_cnt;
#endif
prev_bfi_plc2 = 1;
if (PlcSetup->nbLostCmpt == 0)
......@@ -50,12 +45,6 @@ void processPlcMain_fl(LC3_FLOAT *q_d_fl_c, LC3_FLOAT *syntM_fl_c, LC3PLUS_Dec*
}
pitch_classifier = ltpf_pitch_int;
#ifdef NONBE_PLC_CLASSIFER_LAG_FIX
if (ltpf_pitch_fr > 2)
{
pitch_classifier++;
}
#endif
processPlcClassify_fl(plcMeth, &h_DecSetup->concealMethod, &PlcSetup->nbLostCmpt, bfi, &xcorr,
decoder->frame_length, decoder->frame_dms, pitch_classifier, decoder->fs,
......@@ -64,44 +53,34 @@ void processPlcMain_fl(LC3_FLOAT *q_d_fl_c, LC3_FLOAT *syntM_fl_c, LC3PLUS_Dec*
if (bfi == 1)
{
#ifdef CR8_A_PLC_FADEOUT_TUNING
switch(decoder->frame_dms)
{
case 25:
consecutiveLostThreshold = 16;
#ifdef CR9_L_RETRAIN_FADEOUT_TYPE_CLASSIFIER
thresh_tdc_cnt = THRESH_025_DMS_TDC_CNT;
thresh_ns_cnt = THRESH_025_DMS_NS_CNT;
thresh_tdc_ns_cnt = THRESH_025_DMS_TDC_NS_CNT;
#endif
break;
case 50: consecutiveLostThreshold = 8;
#ifdef CR9_L_RETRAIN_FADEOUT_TYPE_CLASSIFIER
thresh_tdc_cnt = THRESH_050_DMS_TDC_CNT;
thresh_ns_cnt = THRESH_050_DMS_NS_CNT;
thresh_tdc_ns_cnt = THRESH_050_DMS_TDC_NS_CNT;
#endif
break;
case 75: consecutiveLostThreshold = 6;
#ifdef CR9_L_RETRAIN_FADEOUT_TYPE_CLASSIFIER
thresh_tdc_cnt = THRESH_075_DMS_TDC_CNT;
thresh_ns_cnt = THRESH_075_DMS_NS_CNT;
thresh_tdc_ns_cnt = THRESH_075_DMS_TDC_NS_CNT;
#endif
break;
case 100: consecutiveLostThreshold = 4;
#ifdef CR9_L_RETRAIN_FADEOUT_TYPE_CLASSIFIER
thresh_tdc_cnt = THRESH_100_DMS_TDC_CNT;
thresh_ns_cnt = THRESH_100_DMS_NS_CNT;
thresh_tdc_ns_cnt = THRESH_100_DMS_TDC_NS_CNT;
#endif
break;
default: assert(0);
}
if (decoder->fs_idx == 2 || decoder->fs_idx >= 4)
{
#ifdef CR9_L_RETRAIN_FADEOUT_TYPE_CLASSIFIER
if (PlcAdvSetup->longterm_counter_plcTdc < thresh_tdc_cnt){
PlcAdvSetup->plc_fadeout_type = 1;
}
......@@ -114,41 +93,14 @@ void processPlcMain_fl(LC3_FLOAT *q_d_fl_c, LC3_FLOAT *syntM_fl_c, LC3PLUS_Dec*
else {
PlcAdvSetup->plc_fadeout_type = 0;
}
#else
if (((PlcAdvSetup->longterm_counter_plcPhaseEcu < PlcAdvSetup->longterm_counter_plcTdc*FAC1_FADEOUT) ||
(PlcAdvSetup->longterm_counter_plcPhaseEcu < PlcAdvSetup->longterm_counter_plcNsAdv*FAC1_FADEOUT)) &&
(PlcAdvSetup->longterm_counter_plcTdc / (PlcAdvSetup->longterm_counter_plcNsAdv + LC3_EPS) < FAC2_FADEOUT))
{
PlcAdvSetup->plc_fadeout_type = 0;
} else {
if ((PlcAdvSetup->longterm_counter_plcPhaseEcu > FAC3_FADEOUT * PlcAdvSetup->longterm_counter_plcTdc) ||
(PlcAdvSetup->longterm_counter_plcPhaseEcu > FAC3_FADEOUT * PlcAdvSetup->longterm_counter_plcNsAdv))
{
PlcAdvSetup->plc_fadeout_type = 1;
} else {
PlcAdvSetup->plc_fadeout_type = 0;
}
}
#endif
if ((PlcAdvSetup->overall_counter - (int)(PLC_LONGTERM_ANALYSIS_STARTUP_FILL * PlcAdvSetup->longterm_analysis_counter_max)) < 0)
{
PlcAdvSetup->plc_fadeout_type = 0;
}
#ifndef CR9_H_REMOVE_SWITCH_TO_PLC_NS
if (PlcSetup->nbLostCmpt >= consecutiveLostThreshold && PlcAdvSetup->plc_fadeout_type == 1)
{
if ( h_DecSetup->concealMethod == 3 )
{
h_DecSetup->concealMethod = 4;
}
}
#endif
#ifdef CR9_N_SHORT_FADE_FOR_UNSTABLE_PITCH
if (h_DecSetup->rel_pitch_change > REL_PITCH_THRESH && hrmode == 1 && (decoder->frame_dms == 50 || decoder->frame_dms == 25) ){
PlcAdvSetup->plc_fadeout_type = 2;
} else
#endif
if ( h_DecSetup->concealMethod != 2 ) {
/* not PhECU */
if (PlcSetup->nbLostCmpt < consecutiveLostThreshold )
......@@ -159,11 +111,7 @@ void processPlcMain_fl(LC3_FLOAT *q_d_fl_c, LC3_FLOAT *syntM_fl_c, LC3PLUS_Dec*
} else {
PlcAdvSetup->plc_fadeout_type = 0;
}
#endif
#ifdef PLC_CR8_A_PRINTF
printf("plc_fadeout_type = %d\n", PlcAdvSetup->plc_fadeout_type);
#endif
switch (h_DecSetup->concealMethod)
{
case 2:
......@@ -176,7 +124,7 @@ void processPlcMain_fl(LC3_FLOAT *q_d_fl_c, LC3_FLOAT *syntM_fl_c, LC3PLUS_Dec*
if (decoder->frame_dms != 100)
{
// muting, if frame size changed during phaseECU concealment
/* muting, if frame size changed during phaseECU concealment */
memset(q_d_fl_c, 0, sizeof(LC3_FLOAT) * decoder->frame_length);
h_DecSetup->alpha = 0;
break;
......@@ -266,10 +214,8 @@ void processPlcMain_fl(LC3_FLOAT *q_d_fl_c, LC3_FLOAT *syntM_fl_c, LC3PLUS_Dec*
,
&(PlcAdvSetup->PlcPhEcuSetup.PhEcu_Fft),
&(PlcAdvSetup->PlcPhEcuSetup.PhEcu_Ifft)
#ifdef CR8_A_PLC_FADEOUT_TUNING
,PlcAdvSetup->plc_fadeout_type,
&(PlcAdvSetup->PlcPhEcuSetup.PhECU_nonpure_tone_flag) /* nonpure tone flag */
#endif
);
......@@ -295,9 +241,8 @@ void processPlcMain_fl(LC3_FLOAT *q_d_fl_c, LC3_FLOAT *syntM_fl_c, LC3PLUS_Dec*
decoder->frame_dms, decoder->fs, PlcSetup->nbLostCmpt, decoder->frame_length - decoder->la_zeroes, &PlcAdvSetup->stabFac, PlcAdvSetup->PlcTdcSetup.harmonicBuf,
PlcAdvSetup->PlcTdcSetup.synthHist, &PlcAdvSetup->PlcTdcSetup.fract, &PlcAdvSetup->PlcTdcSetup.seed, &PlcAdvSetup->PlcTdcSetup.gain_c,
&h_DecSetup->alpha, synth
#ifdef CR9_I_INC_TDC_FADEOUT_LEN
, PlcAdvSetup->plc_fadeout_type
#endif
, decoder->alpha_type_2_table
);
processTdcTdac_fl(synth, decoder->imdct_win, decoder->frame_length, decoder->la_zeroes, h_DecSetup->imdct_mem);
......
/******************************************************************************
* ETSI TS 103 634 V1.4.3 *
* ETSI TS 103 634 V1.5.1 *
* Low Complexity Communication Codec Plus (LC3plus) *
* *
* Copyright licence is solely granted through ETSI Intellectual Property *
......@@ -7,12 +7,10 @@
* estoppel or otherwise. *
******************************************************************************/
#include "options.h"
#include "wmc_auto.h"
#include "functions.h"
void processNoiseSubstitution_fl(LC3_FLOAT* spec, LC3_FLOAT* spec_prev, LC3_INT32 yLen)
{
memmove(spec, spec_prev, sizeof(LC3_FLOAT) * yLen);
......
/******************************************************************************
* ETSI TS 103 634 V1.4.3 *
* ETSI TS 103 634 V1.5.1 *
* Low Complexity Communication Codec Plus (LC3plus) *
* *
* Copyright licence is solely granted through ETSI Intellectual Property *
......@@ -7,13 +7,11 @@
* estoppel or otherwise. *
******************************************************************************/
#include "options.h"
#include "wmc_auto.h"
#include "defines.h"
#include "functions.h"
void plc_phEcu_F0_refine_first( LC3_INT32 *plocs, /* i/o 0 ... Lprot/2 +1*/
LC3_INT32 n_plocs,
LC3_FLOAT *f0est, /* i/o f0est */
......
/******************************************************************************
* ETSI TS 103 634 V1.4.3 *
* ETSI TS 103 634 V1.5.1 *
* Low Complexity Communication Codec Plus (LC3plus) *
* *
* Copyright licence is solely granted through ETSI Intellectual Property *
......@@ -7,13 +7,11 @@
* estoppel or otherwise. *
******************************************************************************/
#include "options.h"
#include "wmc_auto.h"
#include "defines.h"
#include "functions.h"
LC3_FLOAT plc_phEcu_imax2_jacobsen_mag(const Complex *y, LC3_FLOAT *c_jacobPtr) {
LC3_FLOAT posi;
......
/******************************************************************************
* ETSI TS 103 634 V1.4.3 *
* ETSI TS 103 634 V1.5.1 *
* Low Complexity Communication Codec Plus (LC3plus) *
* *
* Copyright licence is solely granted through ETSI Intellectual Property *
......@@ -7,14 +7,11 @@
* estoppel or otherwise. *
******************************************************************************/
#include "options.h"
#include "wmc_auto.h"
#include "defines.h"
#include "functions.h"
void plc_phEcu_hq_ecu(
LC3_FLOAT *f0binPtr, LC3_FLOAT *f0ltpGainPtr, LC3_FLOAT *xfp,
LC3_INT16 prev_bfi, LC3_INT32 *short_flag_prev, LC3_INT32 fs,
......@@ -27,9 +24,7 @@ void plc_phEcu_hq_ecu(
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,
LC3_FLOAT *corr_phase_dbg,
Fft *PhEcu_Fft, Fft *PhEcu_Ifft
#ifdef CR8_A_PLC_FADEOUT_TUNING
, LC3_UINT8 plc_fadeout_type, LC3_INT16 *nonpure_tone_flag_ptr /* nonpure tone flag */
#endif
)
{
......@@ -78,19 +73,13 @@ void plc_phEcu_hq_ecu(
xfp_local_rnd[i] = 0.0;
}
}
#ifdef CR8_A_PLC_FADEOUT_TUNING
*nonpure_tone_flag_ptr = -1; /* set nonpure tone flag for new analysis */
#endif
*time_offs = 0;
burst_len = (*time_offs / L + 1);
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,
st_mag_chg_1st, st_Xavg, alpha, beta, mag_chg, NULL, NULL
#ifdef CR8_A_PLC_FADEOUT_TUNING
, plc_fadeout_type
#endif
);
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);
......@@ -103,9 +92,7 @@ void plc_phEcu_hq_ecu(
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,
st_mag_chg_1st, st_Xavg, alpha, beta, mag_chg, NULL, NULL
#ifdef CR8_A_PLC_FADEOUT_TUNING
, plc_fadeout_type
#endif
);
}
......@@ -121,10 +108,8 @@ void plc_phEcu_hq_ecu(
/* inplace X_out_m update */
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,
#ifdef CR8_A_PLC_FADEOUT_TUNING
plc_fadeout_type,
nonpure_tone_flag_ptr, /* nonpure_tone_flag , a state updated here */
#endif
NULL, NULL, NULL);
......
/******************************************************************************
* ETSI TS 103 634 V1.4.3 *
* ETSI TS 103 634 V1.5.1 *
* Low Complexity Communication Codec Plus (LC3plus) *
* *
* Copyright licence is solely granted through ETSI Intellectual Property *
......@@ -7,13 +7,11 @@
* estoppel or otherwise. *
******************************************************************************/
#include "options.h"
#include "wmc_auto.h"
#include "defines.h"
#include "functions.h"
void plc_phEcu_LF_peak_analysis(LC3_INT32 *plocs, /* i/o 0 ... Lprot/2 +1*/
LC3_INT32 *n_plocs, /* i/o 0.. MAX_PLOCS */
LC3_FLOAT *f0est, /* i/o Q16*/
......
/******************************************************************************
* ETSI TS 103 634 V1.4.3 *
* ETSI TS 103 634 V1.5.1 *
* Low Complexity Communication Codec Plus (LC3plus) *
* *
* Copyright licence is solely granted through ETSI Intellectual Property *
......@@ -7,13 +7,11 @@
* estoppel or otherwise. *
******************************************************************************/
#include "options.h"
#include "wmc_auto.h"
#include "defines.h"
#include "functions.h"
void plc_phEcu_rec_frame(Complex *X_in,
LC3_INT32 L,
LC3_INT32 Lecu,
......@@ -53,11 +51,7 @@ void plc_phEcu_rec_frame(Complex *X_in,
UNUSED(xsubst_dbg);
UNUSED(xsubst_LL);
#ifdef CR8_A_PLC_FADEOUT_TUNING
fs_idx = FRAME2FS_IDX_10MS(L);
#else
fs_idx = FRAME2FS_IDX(L);
#endif
hannOla = hannOla_wins[fs_idx];
X_in[0].i = X_in[Lprot / 2].r; /* move fs/2 real to imag part of X_in[0]*/
......
/******************************************************************************
* ETSI TS 103 634 V1.4.3 *
* ETSI TS 103 634 V1.5.1 *
* Low Complexity Communication Codec Plus (LC3plus) *
* *
* Copyright licence is solely granted through ETSI Intellectual Property *
......@@ -7,13 +7,11 @@
* estoppel or otherwise. *
******************************************************************************/
#include "options.h"
#include "wmc_auto.h"
#include "defines.h"
#include "functions.h"
LC3_FLOAT plc_phEcuSetF0Hz(LC3_INT32 fs, LC3_FLOAT * old_pitchPtr)
{
LC3_FLOAT result;
......
/******************************************************************************
* ETSI TS 103 634 V1.4.3 *
* ETSI TS 103 634 V1.5.1 *
* Low Complexity Communication Codec Plus (LC3plus) *
* *
* Copyright licence is solely granted through ETSI Intellectual Property *
......@@ -7,16 +7,13 @@
* estoppel or otherwise. *
******************************************************************************/
#include "options.h"
#include "wmc_auto.h"
#include "defines.h"
#include "functions.h"
#define PEAK_LOCATOR_RES_FX 1 /* fixed point resolution minimum value */
static LC3_INT16 plc_phEcu_find_ind_fx( /* o : output maximum indx 0.. len-1 */
const LC3_INT16 *inp, /* i : vector */
const LC3_INT16 len, /* i : length */
......
/******************************************************************************
* ETSI TS 103 634 V1.4.3 *
* ETSI TS 103 634 V1.5.1 *
* Low Complexity Communication Codec Plus (LC3plus) *
* *
* Copyright licence is solely granted through ETSI Intellectual Property *
......@@ -7,7 +7,6 @@
* estoppel or otherwise. *
******************************************************************************/
#include "options.h"
#include "wmc_auto.h"
#include "defines.h"
......@@ -18,20 +17,15 @@ static LC3_INT32 own_rand(LC3_INT32 seed);
static Complex valley_magnitude_adj(Complex X_i_in, LC3_INT32 uni_seed, LC3_FLOAT cos_F);
static LC3_INT32 rand_phase(LC3_INT32 seed_in, LC3_FLOAT* cos_F);
#ifdef CR8_A_PLC_FADEOUT_TUNING
#define ONE_SIDED_SINE_WIDTH (4) /* expected pure sine main lobe maximum width (4+1+4) bins *62.5 hz/bin => approx 560 Hz total width */
static LC3_INT16 plc_phEcu_nonpure_tone_ana(const LC3_INT32* plocs, const LC3_INT32 n_plocs, const Complex* X, const LC3_FLOAT* Xavg, const LC3_INT32 Lprot);
#endif
void plc_phEcu_subst_spec(LC3_INT32* plocs, LC3_INT32 n_plocs, LC3_FLOAT* f0est, LC3_INT32 time_offs, Complex* X, LC3_INT32 X_len,
LC3_FLOAT* mag_chg_gr, LC3_INT32 *seed, LC3_FLOAT* alpha, LC3_FLOAT* beta, LC3_FLOAT* Xavg,
LC3_INT32 t_adv_in, LC3_INT32 Lprot, LC3_INT32 delta_corr,
#ifdef CR8_A_PLC_FADEOUT_TUNING
LC3_INT16 fadeout, /* need for DC muting */
LC3_INT16* nonpure_tone_flag_ptr,
#endif
LC3_FLOAT *corr_phase_dbg,
LC3_FLOAT *X_i_new_re_dbg, LC3_FLOAT *X_i_new_im_dbg) {
......@@ -44,9 +38,7 @@ void plc_phEcu_subst_spec(LC3_INT32* plocs, LC3_INT32 n_plocs, LC3_FLOAT* f0est,
LC3_FLOAT Xph;
LC3_FLOAT seed_local;
LC3_INT32 binCounter = 1, subInd = 0;
#ifdef CR8_A_PLC_FADEOUT_TUNING
LC3_INT16 fs_idx;
#endif
UNUSED(corr_phase_dbg);
UNUSED(X_i_new_re_dbg);
......@@ -59,13 +51,12 @@ void plc_phEcu_subst_spec(LC3_INT32* plocs, LC3_INT32 n_plocs, LC3_FLOAT* f0est,
t_adv = t_adv_in + time_offs;
for (i = 0; i < n_plocs; i++) {
corr_phase[i] = (LC3_FLOAT)2.0 * (LC3_FLOAT)M_PI * (f0est[i]/Lprot)*(LC3_FLOAT)t_adv;
corr_phase[i] = (LC3_FLOAT)2.0 * (LC3_FLOAT)M_PI_LC3PLUS * (f0est[i]/Lprot)*(LC3_FLOAT)t_adv;
}
// EVOLVE PHASE -----------------
one_peak_flag_mask = -1;
#ifdef CR8_A_PLC_FADEOUT_TUNING
fs_idx = (LC3_INT16)LC3_FLOOR((LC3_FLOAT)Lprot / 160.0); /* aquire, fs_idx for 10 ms frame sizes */
if (n_plocs < 3 && n_plocs > 0)
{
......@@ -84,11 +75,6 @@ void plc_phEcu_subst_spec(LC3_INT32* plocs, LC3_INT32 n_plocs, LC3_FLOAT* f0est,
}
}
#else
if (n_plocs < 3 && n_plocs > 0) {
one_peak_flag_mask = 0;
}
#endif
noise_mag_scale = 0;
if (n_plocs == 0 || time_offs != 0) {
......@@ -100,7 +86,6 @@ void plc_phEcu_subst_spec(LC3_INT32* plocs, LC3_INT32 n_plocs, LC3_FLOAT* f0est,
X[X_len-1] = realtoc(0);
}
#ifdef CR8_A_PLC_FADEOUT_TUNING
/* binary selection of fadeout scheme */
assert(PLC2_FADEOUT_LONG_IN_MS >= PLC2_FADEOUT_IN_MS_MIN && PLC2_FADEOUT_IN_MS >= PLC2_FADEOUT_IN_MS_MIN);
assert(PLC2_FADEOUT_LONG_IN_MS <= PLC2_FADEOUT_IN_MS_MAX && PLC2_FADEOUT_IN_MS <= PLC2_FADEOUT_IN_MS_MAX);
......@@ -122,7 +107,6 @@ void plc_phEcu_subst_spec(LC3_INT32* plocs, LC3_INT32 n_plocs, LC3_FLOAT* f0est,
/* start fs/by2 attenuation */
X[X_len - 1].r = alpha[(xavg_N_grp[fs_idx] - 1)] * X[X_len - 1].r;
}
#endif
if (n_plocs != 0) {
for (i = 0; i < n_plocs; i++) {
......@@ -143,7 +127,7 @@ void plc_phEcu_subst_spec(LC3_INT32* plocs, LC3_INT32 n_plocs, LC3_FLOAT* f0est,
seed_local = (LC3_FLOAT)rand_phase((LC3_INT32)seed_local, &cos_F);
X_i = X[binCounter];
X_i_new = cmul(X_i, cexpi((LC3_FLOAT)M_PI*seed_local / (LC3_FLOAT)32768.0));
X_i_new = cmul(X_i, cexpi((LC3_FLOAT)M_PI_LC3PLUS*seed_local / (LC3_FLOAT)32768.0));
seed_local = (LC3_FLOAT)own_rand((LC3_INT32)seed_local);
......@@ -162,7 +146,7 @@ void plc_phEcu_subst_spec(LC3_INT32* plocs, LC3_INT32 n_plocs, LC3_FLOAT* f0est,
tmp = 0;
X_i_new = realtoc(0);
}
X[binCounter] = cadd(cmul(realtoc(alpha_local), X_i_new), cmul(realtoc(tmp), cexpi((LC3_FLOAT)M_PI*seed_local / (LC3_FLOAT)32768.0)));
X[binCounter] = cadd(cmul(realtoc(alpha_local), X_i_new), cmul(realtoc(tmp), cexpi((LC3_FLOAT)M_PI_LC3PLUS*seed_local / (LC3_FLOAT)32768.0)));
}
else {
if (one_peak_flag_mask == 0) {
......@@ -194,9 +178,9 @@ void plc_phEcu_subst_spec(LC3_INT32* plocs, LC3_INT32 n_plocs, LC3_FLOAT* f0est,
X_i = X[binCounter];
{
LC3_INT32 nrep =(LC3_INT32) LC3_FLOOR(Xph / (2.0f*(LC3_FLOAT)M_PI));
LC3_INT32 nrep =(LC3_INT32) LC3_FLOOR(Xph / (2.0f*(LC3_FLOAT)M_PI_LC3PLUS));
X_i_new = cmul(X_i, cexpi(Xph - (2.0f*(LC3_FLOAT)M_PI*(LC3_FLOAT)nrep)));
X_i_new = cmul(X_i, cexpi(Xph - (2.0f*(LC3_FLOAT)M_PI_LC3PLUS*(LC3_FLOAT)nrep)));
}
......@@ -210,7 +194,7 @@ void plc_phEcu_subst_spec(LC3_INT32* plocs, LC3_INT32 n_plocs, LC3_FLOAT* f0est,
assert(alpha_local == mag_chg_local);
tmp = beta_local * Xavg[subInd];
X[binCounter] = cadd(cmul(realtoc(alpha_local), X_i_new), cmul(realtoc(tmp), cexpi((LC3_FLOAT)M_PI*seed_local / (LC3_FLOAT)32768.0)));
X[binCounter] = cadd(cmul(realtoc(alpha_local), X_i_new), cmul(realtoc(tmp), cexpi((LC3_FLOAT)M_PI_LC3PLUS*seed_local / (LC3_FLOAT)32768.0)));
}
else
{
......@@ -232,7 +216,7 @@ void plc_phEcu_subst_spec(LC3_INT32* plocs, LC3_INT32 n_plocs, LC3_FLOAT* f0est,
seed_local = (LC3_FLOAT)rand_phase((LC3_INT32)seed_local, &cos_F);
X_i = X[binCounter];
X_i_new = cmul(X_i, cexpi((LC3_FLOAT)M_PI*seed_local/(LC3_FLOAT)32768.0));
X_i_new = cmul(X_i, cexpi((LC3_FLOAT)M_PI_LC3PLUS*seed_local/(LC3_FLOAT)32768.0));
seed_local = (LC3_FLOAT)own_rand((LC3_INT32)seed_local);
......@@ -256,7 +240,7 @@ void plc_phEcu_subst_spec(LC3_INT32* plocs, LC3_INT32 n_plocs, LC3_FLOAT* f0est,
tmp = 0;
}
X[binCounter] = cadd(cmul(realtoc(alpha_local), X_i_new), cmul(realtoc(tmp), cexpi((LC3_FLOAT)M_PI*seed_local/(LC3_FLOAT)32768.0)));
X[binCounter] = cadd(cmul(realtoc(alpha_local), X_i_new), cmul(realtoc(tmp), cexpi((LC3_FLOAT)M_PI_LC3PLUS*seed_local/(LC3_FLOAT)32768.0)));
}
else
{
......@@ -295,13 +279,10 @@ static Complex valley_magnitude_adj(Complex X_i_in, LC3_INT32 uni_seed, LC3_FLOA
static LC3_INT32 rand_phase(LC3_INT32 seed_in, LC3_FLOAT* cos_F) {
LC3_FLOAT seed = (LC3_FLOAT)own_rand(seed_in);
*cos_F = LC3_COS((LC3_FLOAT)M_PI*seed/(LC3_FLOAT)32768.0);
*cos_F = LC3_COS((LC3_FLOAT)M_PI_LC3PLUS*seed/(LC3_FLOAT)32768.0);
return (LC3_INT32) seed;
}
#ifdef CR8_A_PLC_FADEOUT_TUNING
static LC3_INT16 plc_phEcu_nonpure_tone_ana(const LC3_INT32* plocs, const LC3_INT32 n_plocs, const Complex* X, const LC3_FLOAT* Xavg, const LC3_INT32 Lprot)
{
......@@ -452,5 +433,3 @@ static LC3_INT16 plc_phEcu_nonpure_tone_ana(const LC3_INT32* plocs, const LC3_I
return nonpure_tone_detect;
}
#endif /* CR8_A_PLC_FADEOUT_TUNING */
/******************************************************************************
* ETSI TS 103 634 V1.4.3 *
* ETSI TS 103 634 V1.5.1 *
* Low Complexity Communication Codec Plus (LC3plus) *
* *
* Copyright licence is solely granted through ETSI Intellectual Property *
......@@ -7,13 +7,11 @@
* estoppel or otherwise. *
******************************************************************************/
#include "options.h"
#include "wmc_auto.h"
#include "defines.h"
#include "functions.h"
void plc_phEcu_tba_per_band_gain(LC3_INT32 n_grp, LC3_FLOAT *gr_pow_left, LC3_FLOAT *gr_pow_right, LC3_FLOAT *trans, LC3_FLOAT *grp_pow_change)
{
LC3_INT32 i;
......
/******************************************************************************
* ETSI TS 103 634 V1.4.3 *
* ETSI TS 103 634 V1.5.1 *
* Low Complexity Communication Codec Plus (LC3plus) *
* *
* Copyright licence is solely granted through ETSI Intellectual Property *
......@@ -7,13 +7,11 @@
* estoppel or otherwise. *
******************************************************************************/
#include "options.h"
#include "wmc_auto.h"
#include "defines.h"
#include "functions.h"
void plc_phEcu_tba_spect_Xavg(LC3_INT32 fs_idx, LC3_INT32 n_grp, LC3_FLOAT *oold_spec_shape,
LC3_FLOAT *oold_EwPtr, LC3_FLOAT *old_spec_shape,
LC3_FLOAT *old_EwPtr, LC3_FLOAT *gr_pow_left, LC3_FLOAT *gr_pow_right, LC3_FLOAT *Xavg)
......
/******************************************************************************
* ETSI TS 103 634 V1.4.3 *
* ETSI TS 103 634 V1.5.1 *
* Low Complexity Communication Codec Plus (LC3plus) *
* *
* Copyright licence is solely granted through ETSI Intellectual Property *
......@@ -7,25 +7,17 @@
* estoppel or otherwise. *
******************************************************************************/
#include "options.h"
#include "wmc_auto.h"
#include "defines.h"
#include "functions.h"
#define BETA_MUTE_FAC 0.5 /* % attenuation factor per additional bad frame, FX uses 0.5 (shift right with 1 bit) */
#define BETA_MUTE_FAC_INI 0.5
#define OFF_FRAMES_LIMIT 30 /* 300 ms for LC3 10 ms */
#define LGW32k 7
#define LGW16k 5
/* Tables for attentuation of mag_chg, copied from FX */
/* Tables are in Q15 */
/* 0.3 dB attenuation per frame for 16 frames, then 6 dB attenuation per frame */
......@@ -41,15 +33,8 @@ const LC3_INT32 POW_ATT_TABLE0[OFF_FRAMES_LIMIT + 1] = { 32767, 31293, 29885, 28
#ifdef PLC2_FADEOUT_IN_MS
#if PLC2_FADEOUT_IN_MS == 0
#ifndef CR8_A_PLC_FADEOUT_TUNING
/* default setting only requires two tables */
const Word16* const POW_ATT_TABLES[1 + 2] =
{ NULL, POW_ATT_TABLE1/*1 0.3dB steps */ , POW_ATT_TABLE0/*2 0.4 dB steps*/,
};
#endif
#else
#ifdef CR8_A_PLC_FADEOUT_TUNING
const LC3_INT32 POW_ATT_TABLE_p3x9_14_7[OFF_FRAMES_LIMIT + 1] = {
32767,
31656, 30581, 29543, 28540, 27571, 26635, 25731, 24857, 24013, /* 9 times .3dB steps , 14 6 dB steps, 7 muted steps */
......@@ -61,8 +46,6 @@ const LC3_INT32 POW_ATT_TABLE_p4x9_14_7[OFF_FRAMES_LIMIT + 1] =
31293, 29885, 28540, 27255, 26029, 24857, 23738, 22670, 21650, /* 9 times .4dB steps , 14 6 dB steps, 7 muted steps */
10825, 5413, 2706, 1353, 677, 338, 169, 85, 42, 21, 11, 5, 3, 1,
0, 0,0,0,0,0,0 };
#endif
const LC3_INT32 POW_ATT_TABLE_p3x8_6[] = {
32767, 31656, 30581, 29543, 28540, 27571, 26635, 25731, 12865, 6433,
......@@ -100,7 +83,6 @@ const LC3_INT32 POW_ATT_TABLE_p4x1_6[OFF_FRAMES_LIMIT + 1] = {
32, 16, 8, 4, 2, 1, 1, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
#ifdef CR8_A_PLC_FADEOUT_TUNING
const LC3_INT32 *const POW_ATT_TABLES[1 + 12] =
{ NULL,
/*0.3dB col , 0.4dB col */
......@@ -112,17 +94,6 @@ const LC3_INT32 *const POW_ATT_TABLES[1 + 12] =
/*11*/POW_ATT_TABLE1, POW_ATT_TABLE0, /* 15 0.3dB, 14 6dB , 1 mute */ /* 0.4dB version */ /* original curves */
};
#else
const LC3_INT32* const POW_ATT_TABLES[1 + 10] =
{ NULL,
POW_ATT_TABLE1 , POW_ATT_TABLE0, /* .3dB x16,16 6dB steps */ /* .4dB x16, 16 6dB steps */ /*original/default */
POW_ATT_TABLE_p3x8_6, POW_ATT_TABLE_p4x8_6, /* .3dB x8, 24 6dB steps */ /* .4dB x8, 24 6dB steps */
POW_ATT_TABLE_p3x4_6, POW_ATT_TABLE_p4x4_6, /* .3dB x4, 28 6dB steps */ /* .4dB x4, 28 6dB steps */
POW_ATT_TABLE_p3x2_6, POW_ATT_TABLE_p4x2_6, /* .3dB x2, 30 6dB steps */ /* .4dB x2, 30 6dB steps */
POW_ATT_TABLE_p3x1_6, POW_ATT_TABLE_p4x1_6 /* .3dB x1, 30 6dB steps */ /* .4dB x1, 30 6dB steps */
};
#endif
#endif
#endif
......@@ -130,9 +101,7 @@ void plc_phEcu_tba_trans_dect_gains(LC3_INT32 burst_len, LC3_INT32 n_grp, LC3_FL
LC3_FLOAT *stPhECU_beta_mute, LC3_FLOAT *stPhECU_mag_chg_1st,
LC3_FLOAT *alpha, LC3_FLOAT *beta, LC3_FLOAT *mag_chg, LC3_FLOAT *ph_dith, LC3_INT32 *tr_dec,
LC3_FLOAT *att_val, LC3_INT32 *attDegreeFrames_dbg, LC3_FLOAT *thresh_dbg
#ifdef CR8_A_PLC_FADEOUT_TUNING
, LC3_UINT8 plc_fadeout_type
#endif
)
{
......@@ -145,19 +114,8 @@ void plc_phEcu_tba_trans_dect_gains(LC3_INT32 burst_len, LC3_INT32 n_grp, LC3_FL
LC3_INT32 burst_att_thresh;
LC3_INT32 att_per_frame_idx;
LC3_INT32 att_always, attDegreeFrames;
#ifndef CR8_A_PLC_FADEOUT_TUNING
LC3_INT32 FADEOUT_IN_MS, PLC_P800_SPEECH_FADEOUT_IN_FRAMES,
PLC2_FADEOUT_IN_FRAMES, BURST_ATT_THRESH_PRE;
#endif
const LC3_INT32 *TABLEQ15;
#ifdef CR8_A_PLC_FADEOUT_TUNING
LC3_INT32 beta_mute_thr; /* time threshold in 10 ms frames to start beta - noise attenuation */
#endif
#ifndef CR8_A_PLC_FADEOUT_TUNING
LC3_INT32 BURST_ATT_THRESH; /* start attenuate with <burst_att_thresh> losses in a row, also starts FADE2AVG actions */
LC3_INT32 ATT_PER_FRAME; /* initial msuic attenuation table ptr, actually implemented in table lookup! */
LC3_INT32 BETA_MUTE_THR; /* time threshold in 10 ms frames to start beta - noise attenuation */
#endif
UNUSED(attDegreeFrames_dbg);
/* constants setup */
......@@ -165,47 +123,12 @@ void plc_phEcu_tba_trans_dect_gains(LC3_INT32 burst_len, LC3_INT32 n_grp, LC3_FL
XavgFadeinFactor = -1.0;
#ifndef CR8_A_PLC_FADEOUT_TUNING
if (PLC2_FADEOUT_IN_MS < 0)
{
FADEOUT_IN_MS = PLC_FADEOUT_IN_MS; /* % use TDC - SETTING as basic input */
}
else
{
FADEOUT_IN_MS = PLC2_FADEOUT_IN_MS; /* % use a PLC2 individual settings */
}
#endif
#ifndef CR8_A_PLC_FADEOUT_TUNING
PLC_P800_SPEECH_FADEOUT_IN_FRAMES = (LC3_INT32)LC3_FLOOR((LC3_FLOAT)FADEOUT_IN_MS / (LC3_FLOAT)10.0); /* % nominal value for speech */
PLC2_FADEOUT_IN_FRAMES = MIN(OFF_FRAMES_LIMIT, MAX(6, 3 * PLC_P800_SPEECH_FADEOUT_IN_FRAMES)); /* for PLC2 we typically maintain energy 3x longer */
BURST_ATT_THRESH_PRE = MIN(5, MAX(1, (1 * PLC2_FADEOUT_IN_FRAMES) / 6)); /* nominal 20-40 ms to start actual muting, will be thresh +1 */
ATT_PER_FRAME = MIN(10, MAX(2, 2 * (6 - BURST_ATT_THRESH_PRE))); /* % we let the BURST_ATT_thresh control the initial table selection */
BURST_ATT_THRESH = MIN(BURST_ATT_THRESH_PRE, 4);
BETA_MUTE_THR = MIN(4 + (OFF_FRAMES_LIMIT / 2) + 1, MAX(4, BURST_ATT_THRESH + 1 + (LC3_INT32)LC3_POW((LC3_FLOAT)2.0, BURST_ATT_THRESH_PRE - (LC3_FLOAT)1))); /* nominal time to start mandatory decrease of Xavg */
/* Initialize in the same way as done in trans_burst_ana_fx(), even though this is not really needed */
burst_att_thresh = BURST_ATT_THRESH;
att_per_frame_idx = ATT_PER_FRAME;
#endif
/* 10ms constants */
thresh_tr_dB = 10.0; /* dB threshold kept same as for 20ms, even though transient analysis frame size was shortened */
max_increase_grp_pow = 0; /* maximum amplification(dB) in case of onset transients, offset always deacy */
max_increase_grp_pow_lin = (LC3_FLOAT)1.0*LC3_POW((LC3_FLOAT)10.0, max_increase_grp_pow / (LC3_FLOAT)10.0)*(LC3_FLOAT)(32767.0 / 32768.0);
#ifndef CR8_A_PLC_FADEOUT_TUNING
/* envelope setting */
burst_att_thresh = BURST_ATT_THRESH + 1;
att_per_frame_idx = ATT_PER_FRAME - 1;
#endif
#ifdef CR8_A_PLC_FADEOUT_TUNING
if (plc_fadeout_type != 0)
{
i = (PLC2_FADEOUT_LONG_IN_MS - PLC2_FADEOUT_IN_MS_MIN) / PLC2_FADEOUT_RES; /*a long fading table entry in fade_scheme_tab */
......@@ -218,7 +141,6 @@ void plc_phEcu_tba_trans_dect_gains(LC3_INT32 burst_len, LC3_INT32 n_grp, LC3_FL
burst_att_thresh = fade_scheme_tab[i][1]; /* number of 1.0 frames before muting/mixing phase */
/* band gain muting may can take place earlier due to a band transient */
beta_mute_thr = fade_scheme_tab[i][2]; /* muting of Xavg contribution start when slow fadeout is over */
#endif
attDegreeFrames = 0;
if (burst_len > burst_att_thresh)
......@@ -289,33 +211,12 @@ void plc_phEcu_tba_trans_dect_gains(LC3_INT32 burst_len, LC3_INT32 n_grp, LC3_FL
assert(burst_len >= 2); /* states used here */
tr_dec[i] = 0;
#ifndef CR8_A_PLC_FADEOUT_TUNING
if (PLC_FADEOUT_IN_MS > 0)
#endif
{
#ifdef CR8_A_PLC_FADEOUT_TUNING
assert(att_per_frame_idx >= 1 && att_per_frame_idx <= (10+2));
#else
assert(att_per_frame_idx >= 1 && att_per_frame_idx <= 10);
#endif
TABLEQ15 = POW_ATT_TABLES[att_per_frame_idx];
att_val[i] = (LC3_FLOAT)1.0 * ( (LC3_FLOAT) TABLEQ15[MIN(OFF_FRAMES_LIMIT, attDegreeFrames )] / (LC3_FLOAT)32768.0); /* Table idx 0...N-1 therefore no + 1 */
att_val[i] = att_val[i];
}
#ifndef CR8_A_PLC_FADEOUT_TUNING
else
{
if (att_per_frame_idx == ATT_PER_FRAME)
{
att_val[i] = (LC3_FLOAT)1.0 * ( (LC3_FLOAT)POW_ATT_TABLE0[MIN(OFF_FRAMES_LIMIT, attDegreeFrames)] / (LC3_FLOAT)32768.0);
}
else
{
att_val[i] = (LC3_FLOAT)1.0 * ( (LC3_FLOAT)POW_ATT_TABLE1[MIN(OFF_FRAMES_LIMIT, attDegreeFrames)] / (LC3_FLOAT)32768.0);
}
}
#endif
if ( (att_val[i] != 0) && (att_val[i] * (LC3_FLOAT)32768.0 < (LC3_FLOAT)0.5) )
{
......@@ -332,13 +233,8 @@ void plc_phEcu_tba_trans_dect_gains(LC3_INT32 burst_len, LC3_INT32 n_grp, LC3_FL
mag_chg[i] = 0; /* for SNR measurments match in float lowest possible level to BASOP representation */
}
#ifdef CR8_A_PLC_FADEOUT_TUNING
/* note beta_mute decreased once per frame, not once per band */
if (i == 0 && burst_len > beta_mute_thr)
#else
if(burst_len > BETA_MUTE_THR)
#endif
{
*stPhECU_beta_mute = *stPhECU_beta_mute * (LC3_FLOAT)BETA_MUTE_FAC;
}
......
/******************************************************************************
* ETSI TS 103 634 V1.4.3 *
* ETSI TS 103 634 V1.5.1 *
* Low Complexity Communication Codec Plus (LC3plus) *
* *
* Copyright licence is solely granted through ETSI Intellectual Property *
......@@ -7,22 +7,16 @@
* estoppel or otherwise. *
******************************************************************************/
#include "options.h"
#include "wmc_auto.h"
#include "defines.h"
#include "functions.h"
void plc_phEcu_trans_burst_ana_sub(LC3_INT32 fs_idx, LC3_INT32 burst_len, LC3_INT32 n_grp, LC3_FLOAT *oold_spect_shape,
LC3_FLOAT *oold_EwPtr, LC3_FLOAT *old_spect_shape,
LC3_FLOAT *old_EwPtr, LC3_FLOAT *stPhECU_beta_mute,
LC3_FLOAT *stPhECU_mag_chg_1st, LC3_FLOAT *stPhECU_Xavg, LC3_FLOAT *alpha, LC3_FLOAT *beta, LC3_FLOAT *mag_chg, LC3_INT32 *tr_dec_dbg, LC3_FLOAT *gpc_dbg
#ifdef CR8_A_PLC_FADEOUT_TUNING
, LC3_UINT8 plc_fadeout_type
#endif
)
{
LC3_FLOAT gr_pow_left[MAX_LGW];
......@@ -48,9 +42,7 @@ void plc_phEcu_trans_burst_ana_sub(LC3_INT32 fs_idx, LC3_INT32 burst_len, LC3_IN
}
plc_phEcu_tba_trans_dect_gains(burst_len, n_grp, grp_pow_change, stPhECU_beta_mute, stPhECU_mag_chg_1st, alpha, beta, mag_chg, ph_dith, tr_dec, att_val, &attDegreeFrames, &thresh_dbg
#ifdef CR8_A_PLC_FADEOUT_TUNING
, plc_fadeout_type
#endif
);
......
/******************************************************************************
* ETSI TS 103 634 V1.4.3 *
* ETSI TS 103 634 V1.5.1 *
* Low Complexity Communication Codec Plus (LC3plus) *
* *
* Copyright licence is solely granted through ETSI Intellectual Property *
......@@ -7,7 +7,6 @@
* estoppel or otherwise. *
******************************************************************************/
/***************************************************************************\
* contents/description: Main function for Time domain concealment
\***************************************************************************/
......@@ -16,7 +15,7 @@
#include "wmc_auto.h"
#include <string.h>
#include "functions.h"
#include "constants.h"
static LC3_INT16 TDC_random_short(LC3_INT16 *seed);
static LC3_FLOAT TDC_get_gainp(const LC3_FLOAT x[], const LC3_FLOAT y[], LC3_INT32 n);
......@@ -33,7 +32,7 @@ const LC3_FLOAT TDC_high_32_harm[TDC_L_FIR_HP] = {-0.0053f, -0.0037f, -0.0140f,
static void TDC_levinson(LC3_FLOAT *acf, LC3_INT32 len, LC3_FLOAT *out);
static void TDC_copyFLOAT(const LC3_FLOAT * X, LC3_FLOAT * Z, LC3_INT32 n);
static LC3_FLOAT TDC_dotFLOAT(const LC3_FLOAT * X, const LC3_FLOAT * Y, LC3_INT32 n);
static LC3_FLOAT type_2_alpha_long(LC3_INT32 nbLostFramesInRow, LC3_INT32 frame_dms);
const LC3_INT32 beforeNextIncArray[4][4] = {{0,0,0,1},
{0,1,0,1},
{0,1,1,1},
......@@ -62,9 +61,8 @@ void processTdcApply_fl(const LC3_INT32 pitch_int,
LC3_FLOAT* gain_c,
LC3_FLOAT* alpha,
LC3_FLOAT* synth
#ifdef CR9_I_INC_TDC_FADEOUT_LEN
, LC3_UINT8 plc_fadeout_type
#endif
, LC3_FLOAT* alpha_type_2_table
)
{
LC3_FLOAT step, step_n;
......@@ -81,9 +79,7 @@ void processTdcApply_fl(const LC3_INT32 pitch_int,
LC3_FLOAT alphaPrev;
LC3_FLOAT throttle;
LC3_INT32 frame_dms_idx, nbLostFramesInRow_mod;
#ifdef CR9_I_INC_TDC_FADEOUT_LEN
LC3_INT32 plc_fadeout_len = 0;
#endif
memset(synth_mem, 0, M * sizeof(LC3_FLOAT));
memset(scratchSpace, 0, (MAX_LEN_PCM_PLC + MDCT_MEM_LEN_MAX + MAX_LEN_PCM_PLC + 1 + M) * sizeof(LC3_FLOAT));
......@@ -98,20 +94,14 @@ void processTdcApply_fl(const LC3_INT32 pitch_int,
beforeNextInc = beforeNextIncArray[frame_dms_idx][nbLostFramesInRow_mod];
nextInc = nextIncArray [frame_dms_idx][nbLostFramesInRow_mod];
#ifdef CR9_I_INC_TDC_FADEOUT_LEN
if (plc_fadeout_type == 1){
if (plc_fadeout_type >= 1){
plc_fadeout_len = PLC_FADEOUT_TYPE_1_IN_MS;
}
else{
plc_fadeout_len = PLC_FADEOUT_IN_MS;
}
#endif
#ifdef CR9_I_INC_TDC_FADEOUT_LEN
if (nbLostCmpt_loc > plc_fadeout_len/10)
#else
if (nbLostCmpt_loc > PLC_FADEOUT_IN_MS/10)
#endif
{
gain_p = 0;
*gain_c = 0;
......@@ -219,12 +209,10 @@ void processTdcApply_fl(const LC3_INT32 pitch_int,
alphaPrev = *alpha;
}
#ifdef CR9_N_SHORT_FADE_FOR_UNSTABLE_PITCH
if (plc_fadeout_type == 2){
*alpha = LC3_POW(0.5,(nbLostFramesInRow + LC3_ROUND(100.0/frame_dms) - 1) * frame_dms/100.0);
*alpha = alpha_type_2_table[nbLostFramesInRow];
}
else{
#endif
if (nextInc != 0)
{
......@@ -258,14 +246,8 @@ void processTdcApply_fl(const LC3_INT32 pitch_int,
switch (frame_dms)
{
case 25: *alpha *= PLC34_ATTEN_FAC_025; break;
#ifdef CR9_J_SLOW_TDC_FADEOUT
case 50: *alpha *= PLC34_ATTEN_FAC_025; break;
#else
case 50: *alpha *= PLC34_ATTEN_FAC_050; break;
#endif
#ifdef CR8_G_ADD_75MS
case 75: *alpha *= PLC34_ATTEN_FAC_075; break;
#endif
case 100: *alpha *= PLC34_ATTEN_FAC_100; break;
}
}
......@@ -274,9 +256,7 @@ void processTdcApply_fl(const LC3_INT32 pitch_int,
{
gain_p = *alpha;
}
#ifdef CR9_N_SHORT_FADE_FOR_UNSTABLE_PITCH
}
#endif
/*---------------------------------------------------------------*
* Construct the harmonic part *
* Last pitch cycle of the previous frame is repeatedly copied. *
......@@ -413,11 +393,7 @@ void processTdcApply_fl(const LC3_INT32 pitch_int,
*----------------------------------------------------------*/
if (beforeNextInc != 0)
{
#ifdef CR9_I_INC_TDC_FADEOUT_LEN
if (nbLostCmpt_loc == plc_fadeout_len/10)
#else
if (nbLostCmpt_loc == PLC_FADEOUT_IN_MS/10)
#endif
{
gain_h = 1;
step = 1.0f/(LC3_FLOAT)N;
......@@ -465,13 +441,13 @@ void processTdcInverseOdft_fl(LC3_FLOAT *in, LC3_INT32 n_bands, LC3_FLOAT *out,
res.r = 0, res.i = 0;
for (k = 0; k < n_bands; k++)
{
res = cexpi((2 * M_PI * (LC3_FLOAT) (j * k)) / (LC3_FLOAT) n_bands);
res = cexpi((2 * M_PI_LC3PLUS * (LC3_FLOAT) (j * k)) / (LC3_FLOAT) n_bands);
res.r = res.r * buf[k];
res.i = res.i * buf[k];
sum = cadd(sum, res);
}
res = cexpi((LC3_FLOAT) j * M_PI / (2.0 * (LC3_FLOAT) n_bands));
res = cexpi((LC3_FLOAT) j * M_PI_LC3PLUS / (2.0 * (LC3_FLOAT) n_bands));
out[j] = (sum.r * res.r - sum.i * res.i);
}
......@@ -489,7 +465,7 @@ void processTdcPreemphasis_fl(LC3_FLOAT *in, LC3_FLOAT *pre_emph_factor, LC3_INT
for (i = 0; i < n_bands; i++)
{
in[i] = in[i] * (1.0 - 2.0 * (*pre_emph_factor) * LC3_COS(2.0 * M_PI * (0.5 + (LC3_FLOAT) i) / (2.0 * (LC3_FLOAT) n_bands)) + (*pre_emph_factor) * (*pre_emph_factor));
in[i] = in[i] * (1.0 - 2.0 * (*pre_emph_factor) * LC3_COS(2.0 * M_PI_LC3PLUS * (0.5 + (LC3_FLOAT) i) / (2.0 * (LC3_FLOAT) n_bands)) + (*pre_emph_factor) * (*pre_emph_factor));
}
}
......@@ -801,3 +777,24 @@ static void TDC_levinson(LC3_FLOAT *acf, LC3_INT32 len, LC3_FLOAT *out)
}
}
static LC3_FLOAT type_2_alpha_long(LC3_INT32 nbLostFramesInRow, LC3_INT32 frame_dms)
{
if (nbLostFramesInRow <= 3*100.0/frame_dms){
return LC3_POW(0.95,(nbLostFramesInRow + (100.0/frame_dms) - 1) * frame_dms/100.0);
}
else {
LC3_INT32 n_shift = (nbLostFramesInRow - 3*100.0/frame_dms) * 50/frame_dms;
return LC3_POW(0.7,(n_shift + 100.0/frame_dms - 1) * frame_dms/100.0);
}
}
LC3_FLOAT type_2_fadeout(LC3_INT32 nbLostFramesInRow, LC3_INT32 frame_dms)
{
LC3_FLOAT selector = PLC_FADEOUT_TYPE_2_SELECTOR * 2 * 100/frame_dms;
if (selector >= nbLostFramesInRow){
return type_2_alpha_long(nbLostFramesInRow, frame_dms);
}
else {
return LC3_POW(0.5,(nbLostFramesInRow + (100.0/frame_dms) - 1) * frame_dms/100.0);
}
}
/******************************************************************************
* ETSI TS 103 634 V1.4.3 *
* ETSI TS 103 634 V1.5.1 *
* Low Complexity Communication Codec Plus (LC3plus) *
* *
* Copyright licence is solely granted through ETSI Intellectual Property *
......@@ -7,12 +7,10 @@
* estoppel or otherwise. *
******************************************************************************/
#include "options.h"
#include "wmc_auto.h"
#include "functions.h"
void processTdcTdac_fl(const LC3_FLOAT *synth_inp, const LC3_FLOAT *win, LC3_INT32 frame_length, LC3_INT32 la_zeroes, LC3_FLOAT *ola_mem)
{
LC3_INT32 i, L, LD2, NZ, synth_len;
......
/******************************************************************************
* ETSI TS 103 634 V1.4.3 *
* ETSI TS 103 634 V1.5.1 *
* Low Complexity Communication Codec Plus (LC3plus) *
* *
* Copyright licence is solely granted through ETSI Intellectual Property *
......@@ -11,7 +11,6 @@
#include "wmc_auto.h"
#include "functions.h"
void processPlcUpdate_fl(PlcAdvSetup *PlcAdvSetup, LC3_INT32 frame_length, LC3_FLOAT *syntM, LC3_FLOAT *scf_q,
LC3_INT32 *nbLostCmpt, LC3_FLOAT *cum_alpha, LC3_INT32 bfi, LC3_INT32 *prevBfi, LC3_INT32 *prevprevBfi)
{
......
/******************************************************************************
* ETSI TS 103 634 V1.4.3 *
* ETSI TS 103 634 V1.5.1 *
* Low Complexity Communication Codec Plus (LC3plus) *
* *
* Copyright licence is solely granted through ETSI Intellectual Property *
......@@ -7,7 +7,6 @@
* estoppel or otherwise. *
******************************************************************************/
#include "options.h"
#include "wmc_auto.h"
#include "functions.h"
......@@ -66,9 +65,7 @@ void processQuantizeSpec_fl(LC3_FLOAT x[], LC3_FLOAT gain, LC3_INT xq[], LC3_INT
LC3_INT lastnz = 1, nt_half;
LC3_FLOAT offset = 0.375;
LC3_INT32 bits, bits2;
#ifdef CR9_QUANT_SPEC_REWRITE
LC3_FLOAT inv_gain;
#endif
assert(target >= 0);
......@@ -77,34 +74,22 @@ void processQuantizeSpec_fl(LC3_FLOAT x[], LC3_FLOAT gain, LC3_INT xq[], LC3_INT
nt_half = nt >> 1;
rateFlag = 0; c = 0;
if (hrmode)
{
offset = 0.5;
}
/* Quantization */
#ifdef CR9_QUANT_SPEC_REWRITE
inv_gain = 1.0 / gain;
#endif
for (i = 0; i < nt; i++) {
if (x[i] > 0)
{
#ifdef CR9_QUANT_SPEC_REWRITE
xq[i] = (LC3_INT32) ( x[i] * inv_gain + offset);
#else
xq[i] = (LC3_INT32) ( x[i] / gain + offset);
#endif
}
else
{
#ifdef CR9_QUANT_SPEC_REWRITE
xq[i] = -((LC3_INT32) (-x[i] * inv_gain + offset));
#else
xq[i] = -((LC3_INT32) (-x[i] / gain + offset));
#endif
}
if (hrmode == 0) {
assert(xq[i] <= 32767 && xq[i] >= -32768);
......
/******************************************************************************
* ETSI TS 103 634 V1.4.3 *
* ETSI TS 103 634 V1.5.1 *
* Low Complexity Communication Codec Plus (LC3plus) *
* *
* Copyright licence is solely granted through ETSI Intellectual Property *
......@@ -7,12 +7,10 @@
* estoppel or otherwise. *
******************************************************************************/
#include "options.h"
#include "wmc_auto.h"
#include "functions.h"
void processReorderBitstream_fl(LC3_UINT8* bytes, LC3_INT32 n_pccw, LC3_INT32 n_pc, LC3_INT32 b_left, LC3_INT32 len)
{
LC3_UINT8 bytes_local[MAX_NBYTES2];
......
/******************************************************************************
* ETSI TS 103 634 V1.4.3 *
* ETSI TS 103 634 V1.5.1 *
* Low Complexity Communication Codec Plus (LC3plus) *
* *
* Copyright licence is solely granted through ETSI Intellectual Property *
......@@ -7,7 +7,6 @@
* estoppel or otherwise. *
******************************************************************************/
#include "options.h"
#include "wmc_auto.h"
#include "functions.h"
......@@ -32,11 +31,9 @@ void process_resamp12k8_fl(LC3_FLOAT x[], LC3_INT x_len, LC3_FLOAT mem_in[], LC3
case 50:
len_12k8 = LEN_12K8 / 2;
break;
#ifdef CR8_G_ADD_75MS
case 75:
len_12k8 = (LEN_12K8 / 4) * 3;
break;
#endif
case 100:
len_12k8 = LEN_12K8;
break;
......