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,12 +7,10 @@
* estoppel or otherwise. *
******************************************************************************/
#include "options.h"
#include "wmc_auto.h"
#include "functions.h"
#ifdef CR8_A_PLC_FADEOUT_TUNING
static LC3_INT32 change_bit_at_position(LC3_INT32 value, LC3_UINT8 bit_position, LC3_INT8 bit)
{
LC3_INT32 helper_mask = ~(1 << bit_position);
......@@ -23,7 +21,7 @@ static LC3_INT32 change_bit_at_position(LC3_INT32 value, LC3_UINT8 bit_position,
static void update_bit_and_byte_positions(LC3_INT16 longterm_analysis_counter_max_bytebuffer, LC3_INT8 *byte_position, LC3_INT8 *bit_position)
{
if (*bit_position == 30)
if (*bit_position == 29)
{
*bit_position = 0;
......@@ -54,11 +52,7 @@ static void array_insert_and_shift(LC3_INT32 *array, LC3_UINT8 value, LC3_INT16
array[*byte_position] = current_byte;
}
#ifdef CR9_L_RETRAIN_FADEOUT_TYPE_CLASSIFIER
static void array_calculate(LC3_INT32 *array_tdc, LC3_INT32 *array_ns, int length, LC3_INT16 *counter_tdc, LC3_INT16 *counter_ns, LC3_INT16 longterm_analysis_counter_max)
#else
static void array_calculate(LC3_INT32 *array_tdc, LC3_INT32 *array_ns, int length, LC3_INT16 *counter_tdc, LC3_INT16 *counter_ns, LC3_INT16 *counter_phecu, LC3_INT16 overall_counter, LC3_INT16 longterm_analysis_counter_max)
#endif
{
int i, k;
LC3_INT32 current_byte_tdc = 0, current_byte_ns = 0;
......@@ -87,11 +81,7 @@ static void array_calculate(LC3_INT32 *array_tdc, LC3_INT32 *array_ns, int lengt
*counter_tdc = counter_loc_tdc;
*counter_ns = counter_loc_ns;
#ifndef CR9_L_RETRAIN_FADEOUT_TYPE_CLASSIFIER
*counter_phecu = overall_counter - counter_loc_tdc - counter_loc_ns;
#endif
}
#endif
static void plc_xcorr_lc(LC3_FLOAT *pcmbufHist, LC3_INT32 max_len_pcm_plc, LC3_INT32 pitch_int, LC3_INT32 framelength, LC3_INT32 frame_dms, LC3_INT32 fs, LC3_FLOAT *xcorr);
static void spectral_centroid_lc(LC3_FLOAT *gains, LC3_INT32 tilt, const LC3_INT *bands_offset, LC3_INT32 bands_number, LC3_INT32 framelength, LC3_INT32 fs, LC3_FLOAT *sc);
......@@ -103,45 +93,27 @@ void processPlcClassify_fl(LC3_INT plcMeth, LC3_INT *concealMethod, LC3_INT32 *n
)
{
LC3_FLOAT sc, class;
#ifdef CR8_A_PLC_FADEOUT_TUNING
int fs_idx_tmp;
#endif
if (plcAd)
{
*xcorr = 0;
}
#ifdef CR8_A_PLC_FADEOUT_TUNING
fs_idx_tmp = FS2FS_IDX(fs);
/* Save statistics for 24 kHz, 48 kHz and 96 kHz */
if ((bfi == 1) || ((bfi >= 0) && (bfi <= 2) && ((fs_idx_tmp == 2) || (fs_idx_tmp == 4) || (fs_idx_tmp == 5)))) /* Partial Concealment PC(bfi==2) requires allowing value 2 to pass thru as well */
#else
if (bfi == 1)
#endif
{
#ifdef CR8_A_PLC_FADEOUT_TUNING
if (bfi == 1)
{
*nbLostCmpt = *nbLostCmpt + 1;
}
#else
*nbLostCmpt = *nbLostCmpt + 1;
#endif
/* Use pitch correlation at ltpf integer lag if available */
#ifdef CR8_A_PLC_FADEOUT_TUNING
if ((*nbLostCmpt == 1) || (bfi != 1) )/* PC(bfi==2) requires allowing 2 to pass thru as well */
#else
if (*nbLostCmpt == 1)
#endif
{
#ifdef CR8_A_PLC_FADEOUT_TUNING
*concealMethod = 4; /* Noise Substitution */
UNUSED(plcMeth);
#else
*concealMethod = plcMeth; // this is a dangerous mapping!
#endif
/* Advanced PLC */
if (pitch_int > 0)
......@@ -157,46 +129,29 @@ void processPlcClassify_fl(LC3_INT plcMeth, LC3_INT *concealMethod, LC3_INT32 *n
if (frame_dms == 100 && hrmode == 0)
{
*concealMethod = 2; /* PhaseEcu selected */
#ifdef CR8_A_PLC_FADEOUT_TUNING
array_insert_and_shift(plcAd->plc_longterm_advc_tdc, 0, plcAd->longterm_analysis_counter_max, &plcAd->overall_counter, &plcAd->longterm_counter_byte_position, &plcAd->longterm_counter_bit_position);
array_insert_and_shift(plcAd->plc_longterm_advc_ns, 0, plcAd->longterm_analysis_counter_max, NULL, &plcAd->longterm_counter_byte_position, &plcAd->longterm_counter_bit_position);
#endif
}
else
{
#ifndef CR9_G_PLC_NS_TDC_FIX
*concealMethod = 4; /* Noise Substitution */
#endif
#ifdef CR8_A_PLC_FADEOUT_TUNING
array_insert_and_shift(plcAd->plc_longterm_advc_tdc, 0, plcAd->longterm_analysis_counter_max, &plcAd->overall_counter, &plcAd->longterm_counter_byte_position, &plcAd->longterm_counter_bit_position);
array_insert_and_shift(plcAd->plc_longterm_advc_ns, 0, plcAd->longterm_analysis_counter_max, NULL, &plcAd->longterm_counter_byte_position, &plcAd->longterm_counter_bit_position);
#endif
}
}
#ifdef CR8_A_PLC_FADEOUT_TUNING
else {
array_insert_and_shift(plcAd->plc_longterm_advc_tdc, 1, plcAd->longterm_analysis_counter_max, &plcAd->overall_counter, &plcAd->longterm_counter_byte_position, &plcAd->longterm_counter_bit_position);
array_insert_and_shift(plcAd->plc_longterm_advc_ns, 0, plcAd->longterm_analysis_counter_max, NULL, &plcAd->longterm_counter_byte_position, &plcAd->longterm_counter_bit_position);
}
#endif
}
else
{
*concealMethod = 4; /* Noise Substitution */
#ifdef CR8_A_PLC_FADEOUT_TUNING
array_insert_and_shift(plcAd->plc_longterm_advc_tdc, 0, plcAd->longterm_analysis_counter_max, &plcAd->overall_counter, &plcAd->longterm_counter_byte_position, &plcAd->longterm_counter_bit_position);
array_insert_and_shift(plcAd->plc_longterm_advc_ns, 1, plcAd->longterm_analysis_counter_max, NULL, &plcAd->longterm_counter_byte_position, &plcAd->longterm_counter_bit_position);
#endif
}
#ifdef CR8_A_PLC_FADEOUT_TUNING
# ifdef CR9_L_RETRAIN_FADEOUT_TYPE_CLASSIFIER
array_calculate(plcAd->plc_longterm_advc_tdc, plcAd->plc_longterm_advc_ns, plcAd->longterm_analysis_counter_max_bytebuffer, &plcAd->longterm_counter_plcTdc, &plcAd->longterm_counter_plcNsAdv, plcAd->longterm_analysis_counter_max);
# else
array_calculate(plcAd->plc_longterm_advc_tdc, plcAd->plc_longterm_advc_ns, plcAd->longterm_analysis_counter_max_bytebuffer, &plcAd->longterm_counter_plcTdc, &plcAd->longterm_counter_plcNsAdv, &plcAd->longterm_counter_plcPhaseEcu, plcAd->overall_counter, plcAd->longterm_analysis_counter_max);
# endif
update_bit_and_byte_positions(plcAd->longterm_analysis_counter_max_bytebuffer, &plcAd->longterm_counter_byte_position, &plcAd->longterm_counter_bit_position);
#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,11 +7,10 @@
* estoppel or otherwise. *
******************************************************************************/
#include "options.h"
#include "wmc_auto.h"
#include "functions.h"
static void processPlcComputeStabFac_fl(LC3_FLOAT *scf_q, LC3_FLOAT *old_scf_q, LC3_INT32 prev_bfi, LC3_FLOAT *stab_fac);
void processPlcComputeStabFacMain_fl(LC3_FLOAT *scf_q, LC3_FLOAT *old_scf_q, LC3_FLOAT *old_old_scf_q, LC3_INT32 bfi, LC3_INT32 prev_bfi,
......
/******************************************************************************
* 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,20 +7,17 @@
* estoppel or otherwise. *
******************************************************************************/
#include "options.h"
#include "wmc_auto.h"
#include "functions.h"
void processPlcDampingScramblingMain_fl(LC3_INT32 *ns_seed,
LC3_INT32 *pc_seed, LC3_INT32 ns_nbLostCmpt_pc,
LC3_INT32 ns_nbLostCmpt, LC3_FLOAT *stabFac, LC3_FLOAT *cum_fading_slow, LC3_FLOAT *cum_fading_fast,
LC3_FLOAT *spec_prev, LC3_FLOAT *spec, LC3_INT32 spec_inv_idx, LC3_INT32 yLen, LC3_INT32 bfi,
LC3_INT32 frame_dms, LC3_INT32 concealMethod, LC3_INT32 pitch_present_bfi1, LC3_INT32 pitch_present_bfi2,
LC3_FLOAT *cum_fflcAtten
#ifdef CR8_A_PLC_FADEOUT_TUNING
, LC3_UINT8 plc_fadeout_type
#endif
)
{
......@@ -36,31 +33,25 @@ void processPlcDampingScramblingMain_fl(LC3_INT32 *ns_seed,
processDampScramb = 1;
}
#ifdef CR8_A_PLC_FADEOUT_TUNING
if (ns_nbLostCmpt == 1)
{
*cum_fading_slow = 1;
*cum_fading_fast = 1;
*cum_fflcAtten = 1;
}
#endif
if ( bfi == 1 )
{
processPlcDampingScrambling_fl(spec, yLen, ns_nbLostCmpt, stabFac, processDampScramb, cum_fflcAtten,
pitch_present_bfi1, frame_dms, cum_fading_slow, cum_fading_fast, ns_seed, 0
#ifdef CR8_A_PLC_FADEOUT_TUNING
, plc_fadeout_type
#endif
);
}
else /* bfi == 2 */
{
processPlcDampingScrambling_fl(spec, yLen, ns_nbLostCmpt_pc, stabFac, processDampScramb, cum_fflcAtten,
pitch_present_bfi2, frame_dms, cum_fading_slow, cum_fading_fast, pc_seed, spec_inv_idx
#ifdef CR8_A_PLC_FADEOUT_TUNING
, plc_fadeout_type
#endif
);
processPlcUpdateSpec_fl(spec_prev, spec, yLen);
}
......@@ -70,9 +61,7 @@ void processPlcDampingScramblingMain_fl(LC3_INT32 *ns_seed,
void processPlcDampingScrambling_fl(LC3_FLOAT *spec, LC3_INT32 yLen, LC3_INT32 nbLostCmpt, LC3_FLOAT *stabFac, LC3_INT32 processDampScramb,
LC3_FLOAT *cum_fflcAtten, LC3_INT32 pitch_present, LC3_INT32 frame_dms, LC3_FLOAT *cum_fading_slow,
LC3_FLOAT *cum_fading_fast, LC3_INT32 *seed, LC3_INT32 spec_inv_idx
#ifdef CR8_A_PLC_FADEOUT_TUNING
, LC3_UINT8 plc_fadeout_type
#endif
)
{
LC3_INT32 plc_start_inFrames, plc_end_inFrames, plc_duration_inFrames, x, b, i, ad_ThreshFac_start;
......@@ -80,16 +69,6 @@ void processPlcDampingScrambling_fl(LC3_FLOAT *spec, LC3_INT32 yLen, LC3_INT32 n
frame_energy = 0;
#ifndef CR8_A_PLC_FADEOUT_TUNING
/* Main process */
if (nbLostCmpt == 1)
{
*cum_fading_slow = 1;
*cum_fading_fast = 1;
*cum_fflcAtten = 1;
}
#endif
slow = 0.8 + 0.2 * (*stabFac);
fast = 0.3 + 0.2 * (*stabFac);
......@@ -103,27 +82,20 @@ void processPlcDampingScrambling_fl(LC3_FLOAT *spec, LC3_INT32 yLen, LC3_INT32 n
slow = LC3_SQRT(slow);
fast = LC3_SQRT(fast);
break;
#ifdef CR8_G_ADD_75MS
case 75:
slow = LC3_SQRT(LC3_SQRT(slow*slow*slow));
fast = LC3_SQRT(LC3_SQRT(fast*fast*fast));
break;
#endif
}
#ifdef CR8_A_PLC_FADEOUT_TUNING
if (plc_fadeout_type == 0)
{
#endif
*cum_fading_slow = *cum_fading_slow * slow;
*cum_fading_fast = *cum_fading_fast * fast;
#ifdef CR8_A_PLC_FADEOUT_TUNING
}
#endif
if (processDampScramb == 1)
{
#ifdef CR8_A_PLC_FADEOUT_TUNING
if (plc_fadeout_type != 0)
{
if (nbLostCmpt < (4 * (100.0 / (LC3_FLOAT)frame_dms))) {
......@@ -140,7 +112,6 @@ void processPlcDampingScrambling_fl(LC3_FLOAT *spec, LC3_INT32 yLen, LC3_INT32 n
cum_fading_slow_local = *cum_fading_slow;
}
else {
#endif
fflcAtten = 1;
cum_fading_slow_local = *cum_fading_slow;
cum_fading_fast_local = *cum_fading_fast;
......@@ -158,9 +129,7 @@ void processPlcDampingScrambling_fl(LC3_FLOAT *spec, LC3_INT32 yLen, LC3_INT32 n
{
case 25: fflcAtten = PLC34_ATTEN_FAC_025; break;
case 50: fflcAtten = PLC34_ATTEN_FAC_050; break;
#ifdef CR8_G_ADD_75MS
case 75: fflcAtten = PLC34_ATTEN_FAC_075; break;
#endif
case 100: fflcAtten = PLC34_ATTEN_FAC_100; break;
}
}
......@@ -198,37 +167,25 @@ void processPlcDampingScrambling_fl(LC3_FLOAT *spec, LC3_INT32 yLen, LC3_INT32 n
}
randThreshold = -32768 * linFuncStartStop;
#ifdef CR8_A_PLC_FADEOUT_TUNING
}
#endif
for (i = spec_inv_idx; i < yLen; i++)
{
*seed = 16831 + *seed * 12821;
*seed = (LC3_INT16)(*seed);
if (*seed == 32768)
{
*seed -= 32768;
}
if (*seed < 0)
{
#ifdef CR8_A_PLC_FADEOUT_TUNING
if (plc_fadeout_type != 0 || pitch_present == 0 || *seed < randThreshold )
#else
if (pitch_present == 0 || *seed < randThreshold)
#endif
{
spec[i] = -spec[i];
}
}
}
#ifdef CR8_A_PLC_FADEOUT_TUNING
if (plc_fadeout_type == 0)
{
#endif
ad_ThreshFac_start = 10;
ad_ThreshFac_end = 1.2;
ad_threshFac = (ad_ThreshFac_start - ad_ThreshFac_end) * linFuncStartStop + ad_ThreshFac_end;
......@@ -249,17 +206,11 @@ void processPlcDampingScrambling_fl(LC3_FLOAT *spec, LC3_INT32 yLen, LC3_INT32 n
energThreshold = LC3_SQRT(ad_threshFac * mean_energy);
fac = (cum_fading_slow_local - cum_fading_fast_local) * energThreshold;
#ifdef CR8_A_PLC_FADEOUT_TUNING
}
#endif
for (i = spec_inv_idx; i < yLen; i++)
{
#ifdef CR8_A_PLC_FADEOUT_TUNING
if (plc_fadeout_type != 0 || LC3_FABS(spec[i]) < energThreshold )
#else
if (LC3_FABS(spec[i]) < energThreshold)
#endif
{
m = cum_fading_slow_local;
n = 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,8 +7,8 @@
* estoppel or otherwise. *
******************************************************************************/
#include "options.h"
#include "wmc_auto.h"
#include "functions.h"
void processPlcMain_fl(LC3_FLOAT *q_d_fl_c, LC3_FLOAT *syntM_fl_c, LC3PLUS_Dec* decoder, DecSetup* h_DecSetup, LC3_INT bfi,
......@@ -25,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)
......@@ -49,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,
......@@ -63,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;
}
......@@ -113,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 )
......@@ -158,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:
......@@ -175,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;
......@@ -265,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
);
......@@ -294,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,11 +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,12 +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,12 +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,13 +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,
......@@ -26,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
)
{
......@@ -77,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);
......@@ -102,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
);
}
......@@ -120,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,12 +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,12 +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,
......@@ -52,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,12 +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,15 +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,8 +7,8 @@
* estoppel or otherwise. *
******************************************************************************/
#include "options.h"
#include "wmc_auto.h"
#include "defines.h"
#include "functions.h"
#include "constants.h"
......@@ -17,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) {
......@@ -43,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);
......@@ -58,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)
{
......@@ -83,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) {
......@@ -99,10 +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
#if 0
/* align DC fs/2 muting to BASOP */
#endif
/* 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);
......@@ -124,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++) {
......@@ -145,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);
......@@ -164,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) {
......@@ -196,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)));
}
......@@ -212,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
{
......@@ -234,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);
......@@ -258,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
{
......@@ -297,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)
{
......@@ -417,12 +396,6 @@ static LC3_INT16 plc_phEcu_nonpure_tone_ana(const LC3_INT32* plocs, const LC3_I
{
/* delta taper-off analysis solution, less sensitive to input bandwidth limitation and levels */
#if 0
/* note: in BASOP the Xavg ratios below are calculated in log2 domain on a maximally upshifted Xavg vector.
if Xavg is an all zero vector in BASOP, then the nonpure_tone_detect flag is or'ed with 0x100 ,
to trigger normal valley noise generation */
#endif
/* verify that an assumed clean sine does not have any odd HF content indications by thresholding the accumulated delta rise in LF/HF side lobes */
for (i = (sineband_ind_high + 1); i < (N_grp - 1); i++) {
tmp = (Xavg[i + 1] + LC3_EPS) / (Xavg[i] + LC3_EPS);
......@@ -460,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,12 +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,12 +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,24 +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 */
......@@ -40,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 */
......@@ -60,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,
......@@ -99,11 +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
#if 0
/* POW_ATT_TABLES now ordered logically based on initial slow muting phase time */
/* POW_ATT_TABLES[ind] is used after the initial gain==1.0 no energy muting phase */
#endif
const LC3_INT32 *const POW_ATT_TABLES[1 + 12] =
{ NULL,
/*0.3dB col , 0.4dB col */
......@@ -115,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
......@@ -133,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
)
{
......@@ -148,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 */
......@@ -168,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 */
......@@ -221,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)
......@@ -292,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) )
{
......@@ -335,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,21 +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];
......@@ -47,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,15 +7,15 @@
* estoppel or otherwise. *
******************************************************************************/
/***************************************************************************\
* contents/description: Main function for Time domain concealment
\***************************************************************************/
#include "options.h"
#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);
......@@ -32,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},
......@@ -61,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;
......@@ -80,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));
......@@ -97,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;
......@@ -218,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)
{
......@@ -257,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;
}
}
......@@ -273,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. *
......@@ -412,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;
......@@ -464,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);
}
......@@ -488,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));
}
}
......@@ -800,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,11 +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 *
......@@ -8,9 +8,9 @@
******************************************************************************/
#include "options.h"
#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)
{
......