Skip to content
/****************************************************************************** /******************************************************************************
* ETSI TS 103 634 V1.4.3 * * ETSI TS 103 634 V1.5.1 *
* Low Complexity Communication Codec Plus (LC3plus) * * Low Complexity Communication Codec Plus (LC3plus) *
* * * *
* Copyright licence is solely granted through ETSI Intellectual Property * * Copyright licence is solely granted through ETSI Intellectual Property *
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
* estoppel or otherwise. * * estoppel or otherwise. *
******************************************************************************/ ******************************************************************************/
#include "options.h" #include "options.h"
#include "wmc_auto.h" #include "wmc_auto.h"
#include "lc3.h" #include "lc3.h"
...@@ -72,9 +71,7 @@ static int lc3plus_frame_size_supported(float frame_ms) ...@@ -72,9 +71,7 @@ static int lc3plus_frame_size_supported(float frame_ms)
{ {
case 25: /* fallthru */ case 25: /* fallthru */
case 50: /* fallthru */ case 50: /* fallthru */
#ifdef CR8_G_ADD_75MS
case 75: /* fallthru */ case 75: /* fallthru */
#endif
case 100: return 1; case 100: return 1;
default: break; default: break;
} }
...@@ -112,10 +109,13 @@ LC3PLUS_Error lc3plus_enc_init(LC3PLUS_Enc *encoder, int samplerate, int channel ...@@ -112,10 +109,13 @@ LC3PLUS_Error lc3plus_enc_init(LC3PLUS_Enc *encoder, int samplerate, int channel
RETURN_IF(!lc3plus_channels_supported(channels), LC3PLUS_CHANNELS_ERROR); RETURN_IF(!lc3plus_channels_supported(channels), LC3PLUS_CHANNELS_ERROR);
RETURN_IF(samplerate==96000 && hrmode == 0, LC3PLUS_HRMODE_ERROR); RETURN_IF(samplerate==96000 && hrmode == 0, LC3PLUS_HRMODE_ERROR);
if (lfe_channel_array != NULL)
{
for (ch = 0; ch < channels; ch++) for (ch = 0; ch < channels; ch++)
{ {
RETURN_IF(!lc3_enc_supported_lfe() && lfe_channel_array[ch], LC3PLUS_LFE_MODE_NOT_SUPPORTED); RETURN_IF(!lc3_enc_supported_lfe() && lfe_channel_array[ch], LC3PLUS_LFE_MODE_NOT_SUPPORTED);
} }
}
return FillEncSetup(encoder, samplerate, channels, hrmode, lfe_channel_array); /* real bitrate check happens here */ return FillEncSetup(encoder, samplerate, channels, hrmode, lfe_channel_array); /* real bitrate check happens here */
} }
...@@ -305,7 +305,13 @@ int lc3plus_dec_get_delay(const LC3PLUS_Dec* decoder) ...@@ -305,7 +305,13 @@ int lc3plus_dec_get_delay(const LC3PLUS_Dec* decoder)
LC3PLUS_Error lc3plus_dec_fl(LC3PLUS_Dec* decoder, void* input_bytes, int num_bytes, void** output_samples, int bps, int bfi_ext) LC3PLUS_Error lc3plus_dec_fl(LC3PLUS_Dec* decoder, void* input_bytes, int num_bytes, void** output_samples, int bps, int bfi_ext)
{ {
if (bfi_ext == 1)
{
RETURN_IF(!decoder || !output_samples, LC3PLUS_NULL_ERROR);
} else {
RETURN_IF(!decoder || !input_bytes || !output_samples, LC3PLUS_NULL_ERROR); RETURN_IF(!decoder || !input_bytes || !output_samples, LC3PLUS_NULL_ERROR);
}
RETURN_IF(null_in_list((void**)output_samples, decoder->channels), LC3PLUS_NULL_ERROR); RETURN_IF(null_in_list((void**)output_samples, decoder->channels), LC3PLUS_NULL_ERROR);
return Dec_LC3PLUS_fl(decoder, input_bytes, num_bytes, output_samples, bps, bfi_ext); return Dec_LC3PLUS_fl(decoder, input_bytes, num_bytes, output_samples, bps, bfi_ext);
} }
......
/****************************************************************************** /******************************************************************************
* ETSI TS 103 634 V1.4.3 * * ETSI TS 103 634 V1.5.1 *
* Low Complexity Communication Codec Plus (LC3plus) * * Low Complexity Communication Codec Plus (LC3plus) *
* * * *
* Copyright licence is solely granted through ETSI Intellectual Property * * Copyright licence is solely granted through ETSI Intellectual Property *
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
* estoppel or otherwise. * * estoppel or otherwise. *
******************************************************************************/ ******************************************************************************/
/*! \file lc3.h /*! \file lc3.h
* This header provides the API for LC3plus. * This header provides the API for LC3plus.
* *
...@@ -38,7 +37,7 @@ typedef __int32 int32_t; ...@@ -38,7 +37,7 @@ typedef __int32 int32_t;
#define LC3PLUS_VERSION_INT(major, minor, micro) (((major) << 16) | ((minor) << 8) | (micro)) #define LC3PLUS_VERSION_INT(major, minor, micro) (((major) << 16) | ((minor) << 8) | (micro))
/*! Version number to ensure header and binary are matching. */ /*! Version number to ensure header and binary are matching. */
#define LC3PLUS_VERSION LC3PLUS_VERSION_INT(1, 7, 2) #define LC3PLUS_VERSION LC3PLUS_VERSION_INT(1, 7, 4)
/*! Maximum number of supported channels. The actual binary might support /*! Maximum number of supported channels. The actual binary might support
* less, use lc3plus_channels_supported() to check. */ * less, use lc3plus_channels_supported() to check. */
...@@ -171,6 +170,7 @@ int lc3plus_samplerate_supported(int samplerate); ...@@ -171,6 +170,7 @@ int lc3plus_samplerate_supported(int samplerate);
* \param[in] samplerate Input sampling rate. Allowed sampling rates are: * \param[in] samplerate Input sampling rate. Allowed sampling rates are:
* 8000, 16000, 24000, 32000, 44100, 48000 * 8000, 16000, 24000, 32000, 44100, 48000
* \param[in] hrmode High resolution mode. * \param[in] hrmode High resolution mode.
* \param[in] lfe_channel_array Array containing activation of LFE mode for each individual channel. Can be NULL if LFE activation is not required.
* \return LC3PLUS_OK on success or appropriate error code. * \return LC3PLUS_OK on success or appropriate error code.
*/ */
LC3PLUS_Error lc3plus_enc_init(LC3PLUS_Enc* encoder, int samplerate, int channels, int hrmode, int32_t lfe_channel_array[]); LC3PLUS_Error lc3plus_enc_init(LC3PLUS_Enc* encoder, int samplerate, int channels, int hrmode, int32_t lfe_channel_array[]);
...@@ -387,7 +387,8 @@ LC3PLUS_Error lc3plus_dec_init(LC3PLUS_Dec* decoder, int samplerate, int channel ...@@ -387,7 +387,8 @@ LC3PLUS_Error lc3plus_dec_init(LC3PLUS_Dec* decoder, int samplerate, int channel
* should provide enough space to hold at most LC3PLUS_MAX_SAMPLES. The * should provide enough space to hold at most LC3PLUS_MAX_SAMPLES. The
* left channel is stored in output_samples[0], the right channel in * left channel is stored in output_samples[0], the right channel in
* output_samples[1]. * output_samples[1].
* \param scratch Scratch parameter only works as dummy parameter to align fixed-point and floating-point APIs * \param scratch Scratch parameter only works as dummy parameter to align fixed-point and floating-point APIs.
* \param[in] bfi_ext Bad Frame Indicator. 0: Good Frame. 1: Bad Frame, apply PLC.
* \return Returns LC3PLUS_OK on success or appropriate error code. Note there is * \return Returns LC3PLUS_OK on success or appropriate error code. Note there is
* a special case for LC3PLUS_DECODE_ERROR where the output is still valid. * a special case for LC3PLUS_DECODE_ERROR where the output is still valid.
*/ */
......
/****************************************************************************** /******************************************************************************
* ETSI TS 103 634 V1.4.3 * * ETSI TS 103 634 V1.5.1 *
* Low Complexity Communication Codec Plus (LC3plus) * * Low Complexity Communication Codec Plus (LC3plus) *
* * * *
* Copyright licence is solely granted through ETSI Intellectual Property * * Copyright licence is solely granted through ETSI Intellectual Property *
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
* estoppel or otherwise. * * estoppel or otherwise. *
******************************************************************************/ ******************************************************************************/
#include "options.h" #include "options.h"
#include "wmc_auto.h" #include "wmc_auto.h"
#include "functions.h" #include "functions.h"
......
/****************************************************************************** /******************************************************************************
* ETSI TS 103 634 V1.4.3 * * ETSI TS 103 634 V1.5.1 *
* Low Complexity Communication Codec Plus (LC3plus) * * Low Complexity Communication Codec Plus (LC3plus) *
* * * *
* Copyright licence is solely granted through ETSI Intellectual Property * * Copyright licence is solely granted through ETSI Intellectual Property *
...@@ -7,14 +7,13 @@ ...@@ -7,14 +7,13 @@
* estoppel or otherwise. * * estoppel or otherwise. *
******************************************************************************/ ******************************************************************************/
#include "options.h" #include "options.h"
#include "wmc_auto.h" #include "wmc_auto.h"
#include "defines.h" #include "defines.h"
static const char *const LICENSE = static const char *const LICENSE =
"*******************************************************************************\n" "*******************************************************************************\n"
"* ETSI TS 103 634 V1.4.3 *\n" "* ETSI TS 103 634 V1.5.1 *\n"
"* Low Complexity Communication Codec Plus (LC3plus) *\n" "* Low Complexity Communication Codec Plus (LC3plus) *\n"
"* Floating Point Software V%i.%i.%iETSI, " __DATE__ " *\n" "* Floating Point Software V%i.%i.%iETSI, " __DATE__ " *\n"
"* Copyright licence is solely granted through ETSI Intellectual Property *\n" "* Copyright licence is solely granted through ETSI Intellectual Property *\n"
......
/****************************************************************************** /******************************************************************************
* ETSI TS 103 634 V1.4.3 * * ETSI TS 103 634 V1.5.1 *
* Low Complexity Communication Codec Plus (LC3plus) * * Low Complexity Communication Codec Plus (LC3plus) *
* * * *
* Copyright licence is solely granted through ETSI Intellectual Property * * Copyright licence is solely granted through ETSI Intellectual Property *
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
* estoppel or otherwise. * * estoppel or otherwise. *
******************************************************************************/ ******************************************************************************/
#include "options.h" #include "options.h"
#include "wmc_auto.h" #include "wmc_auto.h"
#include "functions.h" #include "functions.h"
...@@ -36,9 +35,7 @@ LC3_INT searchMaxIndice(LC3_FLOAT* in, LC3_INT len) ...@@ -36,9 +35,7 @@ LC3_INT searchMaxIndice(LC3_FLOAT* in, LC3_INT len)
void process_ltpf_coder_fl(LC3_FLOAT* xin, LC3_INT xLen, LC3_INT ltpf_enable, LC3_INT pitch_ol, LC3_FLOAT pitch_ol_norm_corr, LC3_INT frame_dms, void process_ltpf_coder_fl(LC3_FLOAT* xin, LC3_INT xLen, LC3_INT ltpf_enable, LC3_INT pitch_ol, LC3_FLOAT pitch_ol_norm_corr, LC3_INT frame_dms,
LC3_FLOAT* mem_old_x, LC3_INT memLen, LC3_FLOAT* mem_norm_corr_past, LC3_INT* mem_on, LC3_FLOAT* mem_pitch, LC3_FLOAT* mem_old_x, LC3_INT memLen, LC3_FLOAT* mem_norm_corr_past, LC3_INT* mem_on, LC3_FLOAT* mem_pitch,
LC3_INT* param, LC3_FLOAT* mem_norm_corr_past_past, LC3_INT* bits LC3_INT* param, LC3_FLOAT* mem_norm_corr_past_past, LC3_INT* bits
#ifdef CR9_K_REDUCE_NORM_CORR_TH
, LC3_INT16 hrmode , LC3_INT16 hrmode
#endif
) )
{ {
LC3_FLOAT buffer[LTPF_MEMIN_LEN + LEN_12K8 + 1 + (LEN_12K8 >> 2)], sum = 0, cor_up[(MAX_PITCH_12K8 - MIN_PITCH_12K8) / 2] = {0}, *x; LC3_FLOAT buffer[LTPF_MEMIN_LEN + LEN_12K8 + 1 + (LEN_12K8 >> 2)], sum = 0, cor_up[(MAX_PITCH_12K8 - MIN_PITCH_12K8) / 2] = {0}, *x;
...@@ -49,14 +46,12 @@ void process_ltpf_coder_fl(LC3_FLOAT* xin, LC3_INT xLen, LC3_INT ltpf_enable, LC ...@@ -49,14 +46,12 @@ void process_ltpf_coder_fl(LC3_FLOAT* xin, LC3_INT xLen, LC3_INT ltpf_enable, LC
LC3_FLOAT cor_tmp, cor_int_tmp, norm_corr = 0, cor[MAX_LEN_NR], cor_int[MAX_LEN_NR], sum1 = 0, sum2 = 0, sum3 = 0; LC3_FLOAT cor_tmp, cor_int_tmp, norm_corr = 0, cor[MAX_LEN_NR], cor_int[MAX_LEN_NR], sum1 = 0, sum2 = 0, sum3 = 0;
LC3_FLOAT pitch = 0; LC3_FLOAT pitch = 0;
#ifdef CR9_K_REDUCE_NORM_CORR_TH
LC3_FLOAT normCorrTh = 0.0f; LC3_FLOAT normCorrTh = 0.0f;
if (hrmode) { if (hrmode) {
normCorrTh = 0.4; normCorrTh = 0.4;
} else { } else {
normCorrTh = 0.6; normCorrTh = 0.6;
} }
#endif
/* Signal Buffer */ /* Signal Buffer */
N = xLen - 1; N = xLen - 1;
...@@ -73,12 +68,7 @@ void process_ltpf_coder_fl(LC3_FLOAT* xin, LC3_INT xLen, LC3_INT ltpf_enable, LC ...@@ -73,12 +68,7 @@ void process_ltpf_coder_fl(LC3_FLOAT* xin, LC3_INT xLen, LC3_INT ltpf_enable, LC
pitch_search_upsamp = 4; pitch_search_upsamp = 4;
pitch_search_L_interpol1 = 4; pitch_search_L_interpol1 = 4;
#ifdef CR9_K_REDUCE_NORM_CORR_TH if (pitch_ol_norm_corr > normCorrTh) {
if (pitch_ol_norm_corr > normCorrTh)
#else
if (pitch_ol_norm_corr > 0.6)
#endif
{
/* Search Bounds */ /* Search Bounds */
t0_min = pitch_ol - pitch_search_delta; t0_min = pitch_ol - pitch_search_delta;
t0_max = pitch_ol + pitch_search_delta; t0_max = pitch_ol + pitch_search_delta;
......
/****************************************************************************** /******************************************************************************
* ETSI TS 103 634 V1.4.3 * * ETSI TS 103 634 V1.5.1 *
* Low Complexity Communication Codec Plus (LC3plus) * * Low Complexity Communication Codec Plus (LC3plus) *
* * * *
* Copyright licence is solely granted through ETSI Intellectual Property * * Copyright licence is solely granted through ETSI Intellectual Property *
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
* estoppel or otherwise. * * estoppel or otherwise. *
******************************************************************************/ ******************************************************************************/
#include "options.h" #include "options.h"
#include "wmc_auto.h" #include "wmc_auto.h"
#include "functions.h" #include "functions.h"
...@@ -17,9 +16,7 @@ void process_ltpf_decoder_fl(LC3_FLOAT* x, LC3_INT xLen, LC3_FLOAT* y, LC3_INT f ...@@ -17,9 +16,7 @@ void process_ltpf_decoder_fl(LC3_FLOAT* x, LC3_INT xLen, LC3_FLOAT* y, LC3_INT f
LC3_INT* param, LC3_INT* mem_param, LC3_INT conf_beta_idx, LC3_FLOAT conf_beta, LC3_INT concealMethod, LC3_INT* param, LC3_INT* mem_param, LC3_INT conf_beta_idx, LC3_FLOAT conf_beta, LC3_INT concealMethod,
LC3_FLOAT damping LC3_FLOAT damping
, LC3_INT *mem_ltpf_active , LC3_INT *mem_ltpf_active
#ifdef CR9_N_SHORT_FADE_FOR_UNSTABLE_PITCH
, LC3_FLOAT *rel_pitch_change, LC3_INT hrmode, LC3_INT frame_dms , LC3_FLOAT *rel_pitch_change, LC3_INT hrmode, LC3_INT frame_dms
#endif
) )
{ {
LC3_INT i, j, n, N, L_past_x, N4, N34, LC3_INT i, j, n, N, L_past_x, N4, N34,
...@@ -28,20 +25,14 @@ void process_ltpf_decoder_fl(LC3_FLOAT* x, LC3_INT xLen, LC3_FLOAT* y, LC3_INT f ...@@ -28,20 +25,14 @@ void process_ltpf_decoder_fl(LC3_FLOAT* x, LC3_INT xLen, LC3_FLOAT* y, LC3_INT f
LC3_FLOAT conf_alpha, gain, a1[12], a2[12], b1[11], b2[11], LC3_FLOAT conf_alpha, gain, a1[12], a2[12], b1[11], b2[11],
buf_x[4 * MAX_LEN], buf_y[4 * MAX_LEN], buf_z[4 * MAX_LEN], pitch, sum1, sum2; buf_x[4 * MAX_LEN], buf_y[4 * MAX_LEN], buf_z[4 * MAX_LEN], pitch, sum1, sum2;
#ifdef CR9_LTPF_REWRITE
LC3_FLOAT *p_x, *p_y, *p_y2, *p_x_init, *p_y_init, *p_a1, *p_b1, *p_a2, *p_b2, fade_fac, current_fade_fac_up, current_fade_fac_down; LC3_FLOAT *p_x, *p_y, *p_y2, *p_x_init, *p_y_init, *p_a1, *p_b1, *p_a2, *p_b2, fade_fac, current_fade_fac_up, current_fade_fac_down;
#endif
#ifdef CR9_N_SHORT_FADE_FOR_UNSTABLE_PITCH
LC3_FLOAT pitch_fl_c_old, pitch_delta; LC3_FLOAT pitch_fl_c_old, pitch_delta;
#endif
const LC3_FLOAT *inter_filter[4], *tilt_filter[4]; const LC3_FLOAT *inter_filter[4], *tilt_filter[4];
#ifdef WMOPS #ifdef WMOPS
push_wmops("process_ltpf_decoder_fl"); push_wmops("process_ltpf_decoder_fl");
#endif #endif
#ifdef CR9_N_SHORT_FADE_FOR_UNSTABLE_PITCH
pitch_fl_c_old = (LC3_FLOAT) *mem_pitch_int + (LC3_FLOAT)*mem_pitch_fr / 4.0; pitch_fl_c_old = (LC3_FLOAT) *mem_pitch_int + (LC3_FLOAT)*mem_pitch_fr / 4.0;
#endif
conf_alpha = 0.85; conf_alpha = 0.85;
if (bfi != 1) { if (bfi != 1) {
...@@ -227,12 +218,10 @@ void process_ltpf_decoder_fl(LC3_FLOAT* x, LC3_INT xLen, LC3_FLOAT* y, LC3_INT f ...@@ -227,12 +218,10 @@ void process_ltpf_decoder_fl(LC3_FLOAT* x, LC3_INT xLen, LC3_FLOAT* y, LC3_INT f
} }
/* First quarter of the current frame: cross-fading */ /* First quarter of the current frame: cross-fading */
#ifdef CR9_LTPF_REWRITE
fade_fac = 1. / (LC3_FLOAT) N4; fade_fac = 1. / (LC3_FLOAT) N4;
current_fade_fac_up = 0.f; current_fade_fac_up = 0.f;
current_fade_fac_down = 1.f; current_fade_fac_down = 1.f;
(void) p_x; (void) p_y; (void) p_a1; (void) p_b1; (void) p_x; (void) p_y; (void) p_a1; (void) p_b1;
#endif
if (mem_param[1] == 0 && param[1] == 0) { if (mem_param[1] == 0 && param[1] == 0) {
memmove(&buf_y[L_past_y], &buf_x[L_past_x], sizeof(LC3_FLOAT) * N4); memmove(&buf_y[L_past_y], &buf_x[L_past_x], sizeof(LC3_FLOAT) * N4);
...@@ -253,14 +242,9 @@ void process_ltpf_decoder_fl(LC3_FLOAT* x, LC3_INT xLen, LC3_FLOAT* y, LC3_INT f ...@@ -253,14 +242,9 @@ void process_ltpf_decoder_fl(LC3_FLOAT* x, LC3_INT xLen, LC3_FLOAT* y, LC3_INT f
j++; j++;
} }
#ifdef CR9_LTPF_REWRITE
buf_y[L_past_y + n] = buf_x[L_past_x + n] - current_fade_fac_down * sum1 + buf_y[L_past_y + n] = buf_x[L_past_x + n] - current_fade_fac_down * sum1 +
current_fade_fac_down * sum2; current_fade_fac_down * sum2;
current_fade_fac_down -= fade_fac; current_fade_fac_down -= fade_fac;
#else
buf_y[L_past_y + n] = buf_x[L_past_x + n] - (((LC3_FLOAT)N4 - (LC3_FLOAT)n) / (LC3_FLOAT)N4) * sum1 +
(((LC3_FLOAT)N4 - (LC3_FLOAT)n) / (LC3_FLOAT)N4) * sum2;
#endif
} }
} else if (mem_param[1] == 0 && param[1] == 1) { } else if (mem_param[1] == 0 && param[1] == 1) {
...@@ -279,12 +263,8 @@ void process_ltpf_decoder_fl(LC3_FLOAT* x, LC3_INT xLen, LC3_FLOAT* y, LC3_INT f ...@@ -279,12 +263,8 @@ void process_ltpf_decoder_fl(LC3_FLOAT* x, LC3_INT xLen, LC3_FLOAT* y, LC3_INT f
j++; j++;
} }
#ifdef CR9_LTPF_REWRITE
buf_y[L_past_y + n] = buf_x[L_past_x + n] - current_fade_fac_up * sum1 + current_fade_fac_up * sum2; buf_y[L_past_y + n] = buf_x[L_past_x + n] - current_fade_fac_up * sum1 + current_fade_fac_up * sum2;
current_fade_fac_up += fade_fac; current_fade_fac_up += fade_fac;
#else
buf_y[L_past_y + n] = buf_x[L_past_x + n] - ((LC3_FLOAT)n / (LC3_FLOAT)N4) * sum1 + ((LC3_FLOAT)n / (LC3_FLOAT)N4) * sum2;
#endif
} }
} else if (*mem_pitch_int == pitch_int && *mem_pitch_fr == pitch_fr) { } else if (*mem_pitch_int == pitch_int && *mem_pitch_fr == pitch_fr) {
for (n = 0; n < N4; n++) { for (n = 0; n < N4; n++) {
...@@ -305,7 +285,6 @@ void process_ltpf_decoder_fl(LC3_FLOAT* x, LC3_INT xLen, LC3_FLOAT* y, LC3_INT f ...@@ -305,7 +285,6 @@ void process_ltpf_decoder_fl(LC3_FLOAT* x, LC3_INT xLen, LC3_FLOAT* y, LC3_INT f
buf_y[L_past_y + n] = buf_x[L_past_x + n] - sum1 + sum2; buf_y[L_past_y + n] = buf_x[L_past_x + n] - sum1 + sum2;
} }
} else { } else {
#ifdef CR9_LTPF_REWRITE
p_x_init = &buf_x[L_past_x]; p_x_init = &buf_x[L_past_x];
p_y_init = &buf_y[L_past_y - p1 + inter_len - 1]; p_y_init = &buf_y[L_past_y - p1 + inter_len - 1];
p_y2 = &buf_y[L_past_y]; p_y2 = &buf_y[L_past_y];
...@@ -367,49 +346,8 @@ void process_ltpf_decoder_fl(LC3_FLOAT* x, LC3_INT xLen, LC3_FLOAT* y, LC3_INT f ...@@ -367,49 +346,8 @@ void process_ltpf_decoder_fl(LC3_FLOAT* x, LC3_INT xLen, LC3_FLOAT* y, LC3_INT f
p_y_init++; p_y_init++;
p_y2++; p_y2++;
} }
#else
for (n = 0; n < N4; n++) {
sum1 = 0;
sum2 = 0;
j = 0;
for (i = L_past_x + n; i >= L_past_x + n - tilt_len; i--) {
sum1 += b1[j] * buf_x[i];
j++;
}
j = 0;
for (i = L_past_y + n - p1 + inter_len - 1; i >= L_past_y + n - p1 - inter_len; i--) {
sum2 += a1[j] * buf_y[i];
j++;
}
buf_y[L_past_y + n] = buf_x[L_past_x + n] - (((LC3_FLOAT)N4 - (LC3_FLOAT)n) / (LC3_FLOAT)N4) * sum1 +
(((LC3_FLOAT)N4 - (LC3_FLOAT)n) / (LC3_FLOAT)N4) * sum2;
}
memmove(buf_z, buf_y, sizeof(LC3_FLOAT) * (old_y_len + xLen));
for (n = 0; n < N4; n++) {
sum1 = 0;
sum2 = 0;
j = 0;
for (i = L_past_y + n; i >= L_past_y + n - tilt_len; i--) {
sum1 += b2[j] * buf_z[i];
j++;
} }
j = 0;
for (i = L_past_y + n - p2 + inter_len - 1; i >= L_past_y + n - p2 - inter_len; i--) {
sum2 += a2[j] * buf_y[i];
j++;
}
buf_y[L_past_y + n] = buf_z[L_past_y + n] - ((LC3_FLOAT)n / (LC3_FLOAT)N4) * sum1 + ((LC3_FLOAT)n / (LC3_FLOAT)N4) * sum2;
}
#endif
}
#ifdef CR9_LTPF_REWRITE
/* Second quarter of the current frame */ /* Second quarter of the current frame */
if (param[1] == 0) { if (param[1] == 0) {
move_float(&buf_y[L_past_y + N4], &buf_x[L_past_x + N4], move_float(&buf_y[L_past_y + N4], &buf_x[L_past_x + N4],
...@@ -444,31 +382,6 @@ void process_ltpf_decoder_fl(LC3_FLOAT* x, LC3_INT xLen, LC3_FLOAT* y, LC3_INT f ...@@ -444,31 +382,6 @@ void process_ltpf_decoder_fl(LC3_FLOAT* x, LC3_INT xLen, LC3_FLOAT* y, LC3_INT f
p_y2++; p_y2++;
} }
} }
#else
/* Second quarter of the current frame */
if (param[1] == 0) {
memmove(&buf_y[L_past_y + N4], &buf_x[L_past_x + N4],
sizeof(LC3_FLOAT) * ((L_past_x + N4 + N34) - (L_past_x + N4)));
} else {
for (n = 0; n < N34; n++) {
sum1 = 0;
sum2 = 0;
j = 0;
for (i = L_past_x + N4 + n; i >= L_past_x + n + N4 - tilt_len; i--) {
sum1 += b2[j] * buf_x[i];
j++;
}
j = 0;
for (i = L_past_y + N4 + n - p2 + inter_len - 1; i >= L_past_y + N4 + n - p2 - inter_len; i--) {
sum2 += a2[j] * buf_y[i];
j++;
}
buf_y[L_past_y + N4 + n] = buf_x[L_past_x + N4 + n] - sum1 + sum2;
}
}
#endif
/* Output */ /* Output */
move_float(y, &buf_y[L_past_y], N); move_float(y, &buf_y[L_past_y], N);
...@@ -485,12 +398,10 @@ void process_ltpf_decoder_fl(LC3_FLOAT* x, LC3_INT xLen, LC3_FLOAT* y, LC3_INT f ...@@ -485,12 +398,10 @@ void process_ltpf_decoder_fl(LC3_FLOAT* x, LC3_INT xLen, LC3_FLOAT* y, LC3_INT f
*mem_pitch_fr = pitch_fr; *mem_pitch_fr = pitch_fr;
*mem_gain = gain; *mem_gain = gain;
*mem_beta_idx = conf_beta_idx; *mem_beta_idx = conf_beta_idx;
#ifdef CR9_N_SHORT_FADE_FOR_UNSTABLE_PITCH
if (bfi == 0 && hrmode == 1 && (frame_dms == 50 || frame_dms == 25)){ if (bfi == 0 && hrmode == 1 && (frame_dms == 50 || frame_dms == 25)){
pitch_delta = LC3_FABS(pitch_fl_c_old - (LC3_FLOAT)pitch_int - (LC3_FLOAT)(pitch_fr / 4.0)); pitch_delta = LC3_FABS(pitch_fl_c_old - (LC3_FLOAT)pitch_int - (LC3_FLOAT)(pitch_fr / 4.0));
*rel_pitch_change = pitch_delta / MAX(pitch_fl_c_old, 1); *rel_pitch_change = pitch_delta / MAX(pitch_fl_c_old, 1);
} }
#endif
#ifdef WMOPS #ifdef WMOPS
pop_wmops(); pop_wmops();
......
/****************************************************************************** /******************************************************************************
* ETSI TS 103 634 V1.4.3 * * ETSI TS 103 634 V1.5.1 *
* Low Complexity Communication Codec Plus (LC3plus) * * Low Complexity Communication Codec Plus (LC3plus) *
* * * *
* Copyright licence is solely granted through ETSI Intellectual Property * * Copyright licence is solely granted through ETSI Intellectual Property *
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
* estoppel or otherwise. * * estoppel or otherwise. *
******************************************************************************/ ******************************************************************************/
#include "options.h" #include "options.h"
#include "wmc_auto.h" #include "wmc_auto.h"
#include "functions.h" #include "functions.h"
...@@ -32,7 +31,6 @@ static const LC3_FLOAT* mdct_window(LC3_INT length, LC3_INT frame_dms, LC3_INT h ...@@ -32,7 +31,6 @@ static const LC3_FLOAT* mdct_window(LC3_INT length, LC3_INT frame_dms, LC3_INT h
return NULL; return NULL;
} }
} }
#ifdef CR8_G_ADD_75MS
else if (frame_dms == 75) { else if (frame_dms == 75) {
switch (length) { switch (length) {
case 60: case 60:
...@@ -51,7 +49,6 @@ static const LC3_FLOAT* mdct_window(LC3_INT length, LC3_INT frame_dms, LC3_INT h ...@@ -51,7 +49,6 @@ static const LC3_FLOAT* mdct_window(LC3_INT length, LC3_INT frame_dms, LC3_INT h
return NULL; return NULL;
} }
} }
#endif
else if (frame_dms == 50) { else if (frame_dms == 50) {
switch (length) { switch (length) {
case 40: case 40:
...@@ -96,11 +93,9 @@ void mdct_init(Mdct* mdct, LC3_INT length, LC3_INT frame_dms, LC3_INT fs_idx, LC ...@@ -96,11 +93,9 @@ void mdct_init(Mdct* mdct, LC3_INT length, LC3_INT frame_dms, LC3_INT fs_idx, LC
if (frame_dms == 100) { if (frame_dms == 100) {
mdct->leading_zeros = MDCT_la_zeroes[fs_idx]; mdct->leading_zeros = MDCT_la_zeroes[fs_idx];
} }
#ifdef CR8_G_ADD_75MS
else if (frame_dms == 75) { else if (frame_dms == 75) {
mdct->leading_zeros = MDCT_la_zeroes_7_5ms[fs_idx]; mdct->leading_zeros = MDCT_la_zeroes_7_5ms[fs_idx];
} }
#endif
else if (frame_dms == 50) { else if (frame_dms == 50) {
mdct->leading_zeros = MDCT_la_zeroes_5ms[fs_idx]; mdct->leading_zeros = MDCT_la_zeroes_5ms[fs_idx];
} }
...@@ -151,7 +146,4 @@ void mdct_apply(const LC3_FLOAT* input, LC3_FLOAT* output, Mdct* mdct) ...@@ -151,7 +146,4 @@ void mdct_apply(const LC3_FLOAT* input, LC3_FLOAT* output, Mdct* mdct)
dct4_apply(&mdct->dct, tmp, output); dct4_apply(&mdct->dct, tmp, output);
} }
void processMdct_fl(LC3_FLOAT* in, LC3_FLOAT* out, Mdct* mdctStruct) void processMdct_fl(LC3_FLOAT* in, LC3_FLOAT* out, Mdct* mdctStruct) { mdct_apply(in, out, mdctStruct); }
{
mdct_apply(in, out, mdctStruct);
}
/****************************************************************************** /******************************************************************************
* ETSI TS 103 634 V1.4.3 * * ETSI TS 103 634 V1.5.1 *
* Low Complexity Communication Codec Plus (LC3plus) * * Low Complexity Communication Codec Plus (LC3plus) *
* * * *
* Copyright licence is solely granted through ETSI Intellectual Property * * Copyright licence is solely granted through ETSI Intellectual Property *
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
* estoppel or otherwise. * * estoppel or otherwise. *
******************************************************************************/ ******************************************************************************/
#include "options.h" #include "options.h"
#include "wmc_auto.h" #include "wmc_auto.h"
#include "functions.h" #include "functions.h"
......
/****************************************************************************** /******************************************************************************
* ETSI TS 103 634 V1.4.3 * * ETSI TS 103 634 V1.5.1 *
* Low Complexity Communication Codec Plus (LC3plus) * * Low Complexity Communication Codec Plus (LC3plus) *
* * * *
* Copyright licence is solely granted through ETSI Intellectual Property * * Copyright licence is solely granted through ETSI Intellectual Property *
...@@ -11,19 +11,11 @@ ...@@ -11,19 +11,11 @@
#include "wmc_auto.h" #include "wmc_auto.h"
#include "functions.h" #include "functions.h"
void processNearNyquistdetector_fl(LC3_INT16* near_nyquist_flag, const LC3_INT fs_idx, const LC3_INT near_nyquist_index, void processNearNyquistdetector_fl(LC3_INT16* near_nyquist_flag, const LC3_INT fs_idx, const LC3_INT near_nyquist_index,
const LC3_INT bands_number, const LC3_FLOAT* ener const LC3_INT bands_number, const LC3_FLOAT* ener , const LC3_INT16 frame_dms, const LC3_INT16 hrmode)
#ifdef CR8_E_TONE_DETECTOR
, const LC3_INT16 frame_dms, const LC3_INT16 hrmode
#endif
)
{ {
*near_nyquist_flag = 0; *near_nyquist_flag = 0;
#ifdef CR8_E_TONE_DETECTOR if (hrmode == 0){
if (hrmode == 0)
#endif
{
if (fs_idx < 4) if (fs_idx < 4)
{ {
LC3_INT i = 0; LC3_INT i = 0;
...@@ -44,7 +36,6 @@ void processNearNyquistdetector_fl(LC3_INT16* near_nyquist_flag, const LC3_INT f ...@@ -44,7 +36,6 @@ void processNearNyquistdetector_fl(LC3_INT16* near_nyquist_flag, const LC3_INT f
} }
} }
} }
#ifdef CR8_E_TONE_DETECTOR
else // hrmode == 1 else // hrmode == 1
{ {
// inverse spectral flatness = mean(energy) ./ 2^(mean(log2(energy))); // inverse spectral flatness = mean(energy) ./ 2^(mean(log2(energy)));
...@@ -89,5 +80,4 @@ void processNearNyquistdetector_fl(LC3_INT16* near_nyquist_flag, const LC3_INT f ...@@ -89,5 +80,4 @@ void processNearNyquistdetector_fl(LC3_INT16* near_nyquist_flag, const LC3_INT f
*near_nyquist_flag = 1; *near_nyquist_flag = 1;
} }
} }
#endif // CR8_E_TONE_DETECTOR
} }
/****************************************************************************** /******************************************************************************
* ETSI TS 103 634 V1.4.3 * * ETSI TS 103 634 V1.5.1 *
* Low Complexity Communication Codec Plus (LC3plus) * * Low Complexity Communication Codec Plus (LC3plus) *
* * * *
* Copyright licence is solely granted through ETSI Intellectual Property * * Copyright licence is solely granted through ETSI Intellectual Property *
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
* estoppel or otherwise. * * estoppel or otherwise. *
******************************************************************************/ ******************************************************************************/
#include "options.h" #include "options.h"
#include "wmc_auto.h" #include "wmc_auto.h"
#include "functions.h" #include "functions.h"
...@@ -30,12 +29,10 @@ void processNoiseFactor_fl(LC3_INT* fac_ns_idx, LC3_FLOAT x[], LC3_INT xq[], LC3 ...@@ -30,12 +29,10 @@ void processNoiseFactor_fl(LC3_INT* fac_ns_idx, LC3_FLOAT x[], LC3_INT xq[], LC3
nTransWidth = 1; nTransWidth = 1;
startOffset = 12; startOffset = 12;
break; break;
#ifdef CR8_G_ADD_75MS
case 75: case 75:
nTransWidth = 2; nTransWidth = 2;
startOffset = 18; startOffset = 18;
break; break;
#endif
case 100: case 100:
nTransWidth = 3; nTransWidth = 3;
startOffset = 24; startOffset = 24;
......
/****************************************************************************** /******************************************************************************
* ETSI TS 103 634 V1.4.3 * * ETSI TS 103 634 V1.5.1 *
* Low Complexity Communication Codec Plus (LC3plus) * * Low Complexity Communication Codec Plus (LC3plus) *
* * * *
* Copyright licence is solely granted through ETSI Intellectual Property * * Copyright licence is solely granted through ETSI Intellectual Property *
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
* estoppel or otherwise. * * estoppel or otherwise. *
******************************************************************************/ ******************************************************************************/
#include "options.h" #include "options.h"
#include "wmc_auto.h" #include "wmc_auto.h"
#include "functions.h" #include "functions.h"
...@@ -28,12 +27,10 @@ void processNoiseFilling_fl(LC3_FLOAT xq[], LC3_INT nfseed, LC3_INT fac_ns_idx, ...@@ -28,12 +27,10 @@ void processNoiseFilling_fl(LC3_FLOAT xq[], LC3_INT nfseed, LC3_INT fac_ns_idx,
nTransWidth = 1; nTransWidth = 1;
startOffset = 12; startOffset = 12;
break; break;
#ifdef CR8_G_ADD_75MS
case 75: case 75:
nTransWidth = 2; nTransWidth = 2;
startOffset = 18; startOffset = 18;
break; break;
#endif
case 100: case 100:
nTransWidth = 3; nTransWidth = 3;
startOffset = 24; startOffset = 24;
......
/****************************************************************************** /******************************************************************************
* ETSI TS 103 634 V1.4.3 * * ETSI TS 103 634 V1.5.1 *
* Low Complexity Communication Codec Plus (LC3plus) * * Low Complexity Communication Codec Plus (LC3plus) *
* * * *
* Copyright licence is solely granted through ETSI Intellectual Property * * Copyright licence is solely granted through ETSI Intellectual Property *
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
* estoppel or otherwise. * * estoppel or otherwise. *
******************************************************************************/ ******************************************************************************/
#include "options.h" #include "options.h"
#include "wmc_auto.h" #include "wmc_auto.h"
#include "functions.h" #include "functions.h"
...@@ -47,9 +46,7 @@ LC3_INT searchMaxIndice(LC3_FLOAT* in, LC3_INT len) ...@@ -47,9 +46,7 @@ LC3_INT searchMaxIndice(LC3_FLOAT* in, LC3_INT len)
} }
void processOlpa_fl(LC3_FLOAT* s_12k8, LC3_FLOAT* mem_s12k8, LC3_FLOAT* mem_s6k4, LC3_INT* mem_old_T0, void processOlpa_fl(LC3_FLOAT* s_12k8, LC3_FLOAT* mem_s12k8, LC3_FLOAT* mem_s6k4, LC3_INT* mem_old_T0,
#ifdef CR9_F_PITCH_WIN_LEN_FIX
LC3_INT* pitch_flag, LC3_INT* pitch_flag,
#endif
LC3_INT* T0_out, LC3_FLOAT* normcorr_out, LC3_INT len, LC3_INT frame_dms) LC3_INT* T0_out, LC3_FLOAT* normcorr_out, LC3_INT len, LC3_INT frame_dms)
{ {
LC3_FLOAT norm_corr = 0, sum = 0, sum0 = 0, sum1 = 0, sum2 = 0, norm_corr2 = 0, *s6k4; LC3_FLOAT norm_corr = 0, sum = 0, sum0 = 0, sum1 = 0, sum2 = 0, norm_corr2 = 0, *s6k4;
...@@ -57,7 +54,6 @@ void processOlpa_fl(LC3_FLOAT* s_12k8, LC3_FLOAT* mem_s12k8, LC3_FLOAT* mem_s6k4 ...@@ -57,7 +54,6 @@ void processOlpa_fl(LC3_FLOAT* s_12k8, LC3_FLOAT* mem_s12k8, LC3_FLOAT* mem_s6k4
LC3_INT i = 0, len2 = 0, T0 = 0, T02 = 0, min_pitch = 0, max_pitch = 0, L = 0, mem_in_len = 0, acflen = 0, delta = 0; LC3_INT i = 0, len2 = 0, T0 = 0, T02 = 0, min_pitch = 0, max_pitch = 0, L = 0, mem_in_len = 0, acflen = 0, delta = 0;
len2 = len / 2; len2 = len / 2;
#ifdef CR9_F_PITCH_WIN_LEN_FIX
switch(frame_dms) switch(frame_dms)
{ {
case 50: case 50:
...@@ -71,23 +67,12 @@ void processOlpa_fl(LC3_FLOAT* s_12k8, LC3_FLOAT* mem_s12k8, LC3_FLOAT* mem_s6k4 ...@@ -71,23 +67,12 @@ void processOlpa_fl(LC3_FLOAT* s_12k8, LC3_FLOAT* mem_s12k8, LC3_FLOAT* mem_s6k4
break; break;
default: default:
#endif
delta = 0; delta = 0;
acflen = len2; acflen = len2;
#ifdef CR9_F_PITCH_WIN_LEN_FIX
} }
#endif
mem_in_len = MAX_PITCH_6K4 + delta; mem_in_len = MAX_PITCH_6K4 + delta;
#ifndef CR9_F_PITCH_WIN_LEN_FIX
if (frame_dms == 25)
{
mem_in_len += 16;
acflen += 16;
}
#endif
/* Downsampling */ /* Downsampling */
move_float(buf, mem_s12k8, 3); move_float(buf, mem_s12k8, 3);
move_float(&buf[3], s_12k8, len); move_float(&buf[3], s_12k8, len);
...@@ -95,21 +80,10 @@ void processOlpa_fl(LC3_FLOAT* s_12k8, LC3_FLOAT* mem_s12k8, LC3_FLOAT* mem_s6k4 ...@@ -95,21 +80,10 @@ void processOlpa_fl(LC3_FLOAT* s_12k8, LC3_FLOAT* mem_s12k8, LC3_FLOAT* mem_s6k4
filter_olpa(buf, R0, olpa_down2, len + 3); filter_olpa(buf, R0, olpa_down2, len + 3);
/* Compute autocorrelation */ /* Compute autocorrelation */
#ifdef CR9_F_PITCH_WIN_LEN_FIX
s6k4 = &buf[mem_in_len - delta]; s6k4 = &buf[mem_in_len - delta];
move_float(&buf[mem_in_len], R0, len2); move_float(&buf[mem_in_len], R0, len2);
move_float(buf, mem_s6k4, mem_in_len); move_float(buf, mem_s6k4, mem_in_len);
move_float(mem_s6k4, &buf[len2], mem_in_len); move_float(mem_s6k4, &buf[len2], mem_in_len);
#else
s6k4 = &buf[mem_in_len];
move_float(buf, mem_s6k4, mem_in_len);
move_float(s6k4, R0, len2);
move_float(mem_s6k4, &buf[len2], mem_in_len);
if (frame_dms == 25)
{
s6k4 = s6k4 - 16;
}
#endif
for (i = MIN_PITCH_6K4; i <= MAX_PITCH_6K4; i++) { for (i = MIN_PITCH_6K4; i <= MAX_PITCH_6K4; i++) {
sum = mac_loop(s6k4, &s6k4[-i], acflen); sum = mac_loop(s6k4, &s6k4[-i], acflen);
R0[i - MIN_PITCH_6K4] = sum; R0[i - MIN_PITCH_6K4] = sum;
...@@ -161,7 +135,6 @@ void processOlpa_fl(LC3_FLOAT* s_12k8, LC3_FLOAT* mem_s12k8, LC3_FLOAT* mem_s6k4 ...@@ -161,7 +135,6 @@ void processOlpa_fl(LC3_FLOAT* s_12k8, LC3_FLOAT* mem_s12k8, LC3_FLOAT* mem_s6k4
} }
} }
#ifdef CR9_F_PITCH_WIN_LEN_FIX
switch(frame_dms) switch(frame_dms)
{ {
case 50: case 50:
...@@ -189,11 +162,8 @@ void processOlpa_fl(LC3_FLOAT* s_12k8, LC3_FLOAT* mem_s12k8, LC3_FLOAT* mem_s6k4 ...@@ -189,11 +162,8 @@ void processOlpa_fl(LC3_FLOAT* s_12k8, LC3_FLOAT* mem_s12k8, LC3_FLOAT* mem_s6k4
break; break;
default: default:
#endif
*mem_old_T0 = T0; *mem_old_T0 = T0;
#ifdef CR9_F_PITCH_WIN_LEN_FIX
} }
#endif
*T0_out = T0 * 2.0; *T0_out = T0 * 2.0;
*normcorr_out = norm_corr; *normcorr_out = norm_corr;
......
/****************************************************************************** /******************************************************************************
* ETSI TS 103 634 V1.4.3 * * ETSI TS 103 634 V1.5.1 *
* Low Complexity Communication Codec Plus (LC3plus) * * Low Complexity Communication Codec Plus (LC3plus) *
* * * *
* Copyright licence is solely granted through ETSI Intellectual Property * * Copyright licence is solely granted through ETSI Intellectual Property *
...@@ -7,12 +7,10 @@ ...@@ -7,12 +7,10 @@
* estoppel or otherwise. * * estoppel or otherwise. *
******************************************************************************/ ******************************************************************************/
#include "options.h" #include "options.h"
#include "wmc_auto.h" #include "wmc_auto.h"
#include "functions.h" #include "functions.h"
void processPcApply_fl(LC3_FLOAT *q_res, LC3_FLOAT *q_old_res, LC3_FLOAT *q_d_prev, LC3_INT32 spec_inv_idx, LC3_INT32 yLen, LC3_INT32 gg_idx, LC3_INT32 gg_idx_off, LC3_FLOAT *prev_gg, LC3_FLOAT *fac, LC3_INT32 *pc_nbLostCmpt) void processPcApply_fl(LC3_FLOAT *q_res, LC3_FLOAT *q_old_res, LC3_FLOAT *q_d_prev, LC3_INT32 spec_inv_idx, LC3_INT32 yLen, LC3_INT32 gg_idx, LC3_INT32 gg_idx_off, LC3_FLOAT *prev_gg, LC3_FLOAT *fac, LC3_INT32 *pc_nbLostCmpt)
{ {
LC3_FLOAT gg, mean_nrg_low, mean_nrg_high, ener_prev, ener_curr, fac_local; LC3_FLOAT gg, mean_nrg_low, mean_nrg_high, ener_prev, ener_curr, fac_local;
......
/****************************************************************************** /******************************************************************************
* ETSI TS 103 634 V1.4.3 * * ETSI TS 103 634 V1.5.1 *
* Low Complexity Communication Codec Plus (LC3plus) * * Low Complexity Communication Codec Plus (LC3plus) *
* * * *
* Copyright licence is solely granted through ETSI Intellectual Property * * Copyright licence is solely granted through ETSI Intellectual Property *
...@@ -7,12 +7,10 @@ ...@@ -7,12 +7,10 @@
* estoppel or otherwise. * * estoppel or otherwise. *
******************************************************************************/ ******************************************************************************/
#include "options.h" #include "options.h"
#include "wmc_auto.h" #include "wmc_auto.h"
#include "functions.h" #include "functions.h"
LC3_FLOAT pc_peak_detector(LC3_FLOAT *q_d_prev, LC3_INT32 yLen); LC3_FLOAT pc_peak_detector(LC3_FLOAT *q_d_prev, LC3_INT32 yLen);
void processPcClassify_fl(LC3_INT32 pitch_present, LC3_INT32 frame_dms, LC3_FLOAT *q_d_prev, LC3_FLOAT *q_old_res, LC3_INT32 yLen, LC3_INT32 spec_inv_idx, LC3_FLOAT stab_fac, LC3_INT32 *bfi) void processPcClassify_fl(LC3_INT32 pitch_present, LC3_INT32 frame_dms, LC3_FLOAT *q_d_prev, LC3_FLOAT *q_old_res, LC3_INT32 yLen, LC3_INT32 spec_inv_idx, LC3_FLOAT stab_fac, LC3_INT32 *bfi)
......
/****************************************************************************** /******************************************************************************
* ETSI TS 103 634 V1.4.3 * * ETSI TS 103 634 V1.5.1 *
* Low Complexity Communication Codec Plus (LC3plus) * * Low Complexity Communication Codec Plus (LC3plus) *
* * * *
* Copyright licence is solely granted through ETSI Intellectual Property * * Copyright licence is solely granted through ETSI Intellectual Property *
...@@ -7,12 +7,10 @@ ...@@ -7,12 +7,10 @@
* estoppel or otherwise. * * estoppel or otherwise. *
******************************************************************************/ ******************************************************************************/
#include "options.h" #include "options.h"
#include "wmc_auto.h" #include "wmc_auto.h"
#include "functions.h" #include "functions.h"
void processPcMain_fl(LC3_INT32 *bfi, LC3PLUS_Dec* decoder, LC3_FLOAT *sqQdec, DecSetup* h_DecSetup, LC3_INT32 pitch_present, LC3_FLOAT stab_fac, LC3_INT32 gg_idx, LC3_INT32 gg_idx_off, LC3_INT32 fac_ns_idx, pcState *statePC, LC3_INT32 spec_inv_idx, LC3_INT32 yLen) void processPcMain_fl(LC3_INT32 *bfi, LC3PLUS_Dec* decoder, LC3_FLOAT *sqQdec, DecSetup* h_DecSetup, LC3_INT32 pitch_present, LC3_FLOAT stab_fac, LC3_INT32 gg_idx, LC3_INT32 gg_idx_off, LC3_INT32 fac_ns_idx, pcState *statePC, LC3_INT32 spec_inv_idx, LC3_INT32 yLen)
{ {
LC3_FLOAT fac; LC3_FLOAT fac;
......
/****************************************************************************** /******************************************************************************
* ETSI TS 103 634 V1.4.3 * * ETSI TS 103 634 V1.5.1 *
* Low Complexity Communication Codec Plus (LC3plus) * * Low Complexity Communication Codec Plus (LC3plus) *
* * * *
* Copyright licence is solely granted through ETSI Intellectual Property * * Copyright licence is solely granted through ETSI Intellectual Property *
...@@ -7,12 +7,10 @@ ...@@ -7,12 +7,10 @@
* estoppel or otherwise. * * estoppel or otherwise. *
******************************************************************************/ ******************************************************************************/
#include "options.h" #include "options.h"
#include "wmc_auto.h" #include "wmc_auto.h"
#include "functions.h" #include "functions.h"
void processPcUpdate_fl(LC3_INT32 bfi, LC3_FLOAT *q_res, LC3_INT32 gg_idx, LC3_INT32 gg_idx_off, LC3_INT32 rframe, LC3_INT32 *BW_cutoff_idx_nf, LC3_INT32 *prev_BW_cutoff_idx_nf, void processPcUpdate_fl(LC3_INT32 bfi, LC3_FLOAT *q_res, LC3_INT32 gg_idx, LC3_INT32 gg_idx_off, LC3_INT32 rframe, LC3_INT32 *BW_cutoff_idx_nf, LC3_INT32 *prev_BW_cutoff_idx_nf,
LC3_INT32 fac_ns_idx, LC3_FLOAT *prev_fac_ns, LC3_FLOAT *fac, LC3_FLOAT *q_old_res, LC3_FLOAT *prev_gg, LC3_INT32 spec_inv_idx, LC3_INT32 yLen) LC3_INT32 fac_ns_idx, LC3_FLOAT *prev_fac_ns, LC3_FLOAT *fac, LC3_FLOAT *q_old_res, LC3_FLOAT *prev_gg, LC3_INT32 spec_inv_idx, LC3_INT32 yLen)
{ {
......
/****************************************************************************** /******************************************************************************
* ETSI TS 103 634 V1.4.3 * * ETSI TS 103 634 V1.5.1 *
* Low Complexity Communication Codec Plus (LC3plus) * * Low Complexity Communication Codec Plus (LC3plus) *
* * * *
* Copyright licence is solely granted through ETSI Intellectual Property * * Copyright licence is solely granted through ETSI Intellectual Property *
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
* estoppel or otherwise. * * estoppel or otherwise. *
******************************************************************************/ ******************************************************************************/
#include "options.h" #include "options.h"
#include "wmc_auto.h" #include "wmc_auto.h"
#include "functions.h" #include "functions.h"
...@@ -31,21 +30,15 @@ void processPerBandEnergy_fl(LC3_INT bands_number, const LC3_INT* acc_coeff_per_ ...@@ -31,21 +30,15 @@ void processPerBandEnergy_fl(LC3_INT bands_number, const LC3_INT* acc_coeff_per_
} }
switch (frame_dms) switch (frame_dms)
{ {
#ifdef ENABLE_2_5MS_MODE
case 25: case 25:
maxBwBin = maxBwBin >> 2; maxBwBin = maxBwBin >> 2;
break; break;
#endif
#ifdef ENABLE_5MS_MODE
case 50: case 50:
maxBwBin = maxBwBin >> 1; maxBwBin = maxBwBin >> 1;
break; break;
#endif
#ifdef CR8_G_ADD_75MS
case 75: case 75:
maxBwBin = (maxBwBin >> 2) * 3; maxBwBin = (maxBwBin >> 2) * 3;
break; break;
#endif
} }
for (i = 0; i < bands_number; i++) { for (i = 0; i < bands_number; i++) {
......
/****************************************************************************** /******************************************************************************
* ETSI TS 103 634 V1.4.3 * * ETSI TS 103 634 V1.5.1 *
* Low Complexity Communication Codec Plus (LC3plus) * * Low Complexity Communication Codec Plus (LC3plus) *
* * * *
* Copyright licence is solely granted through ETSI Intellectual Property * * Copyright licence is solely granted through ETSI Intellectual Property *
...@@ -7,13 +7,10 @@ ...@@ -7,13 +7,10 @@
* estoppel or otherwise. * * estoppel or otherwise. *
******************************************************************************/ ******************************************************************************/
#include "options.h" #include "options.h"
#include "wmc_auto.h" #include "wmc_auto.h"
#include "functions.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) static LC3_INT32 change_bit_at_position(LC3_INT32 value, LC3_UINT8 bit_position, LC3_INT8 bit)
{ {
LC3_INT32 helper_mask = ~(1 << bit_position); LC3_INT32 helper_mask = ~(1 << bit_position);
...@@ -24,7 +21,7 @@ static LC3_INT32 change_bit_at_position(LC3_INT32 value, LC3_UINT8 bit_position, ...@@ -24,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) 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; *bit_position = 0;
...@@ -55,11 +52,7 @@ static void array_insert_and_shift(LC3_INT32 *array, LC3_UINT8 value, LC3_INT16 ...@@ -55,11 +52,7 @@ static void array_insert_and_shift(LC3_INT32 *array, LC3_UINT8 value, LC3_INT16
array[*byte_position] = current_byte; 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) 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; int i, k;
LC3_INT32 current_byte_tdc = 0, current_byte_ns = 0; LC3_INT32 current_byte_tdc = 0, current_byte_ns = 0;
...@@ -88,11 +81,7 @@ static void array_calculate(LC3_INT32 *array_tdc, LC3_INT32 *array_ns, int lengt ...@@ -88,11 +81,7 @@ static void array_calculate(LC3_INT32 *array_tdc, LC3_INT32 *array_ns, int lengt
*counter_tdc = counter_loc_tdc; *counter_tdc = counter_loc_tdc;
*counter_ns = counter_loc_ns; *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 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); 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);
...@@ -104,45 +93,27 @@ void processPlcClassify_fl(LC3_INT plcMeth, LC3_INT *concealMethod, LC3_INT32 *n ...@@ -104,45 +93,27 @@ void processPlcClassify_fl(LC3_INT plcMeth, LC3_INT *concealMethod, LC3_INT32 *n
) )
{ {
LC3_FLOAT sc, class; LC3_FLOAT sc, class;
#ifdef CR8_A_PLC_FADEOUT_TUNING
int fs_idx_tmp; int fs_idx_tmp;
#endif
if (plcAd) if (plcAd)
{ {
*xcorr = 0; *xcorr = 0;
} }
#ifdef CR8_A_PLC_FADEOUT_TUNING
fs_idx_tmp = FS2FS_IDX(fs); fs_idx_tmp = FS2FS_IDX(fs);
/* Save statistics for 24 kHz, 48 kHz and 96 kHz */ /* 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 */ 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) if (bfi == 1)
{ {
*nbLostCmpt = *nbLostCmpt + 1; *nbLostCmpt = *nbLostCmpt + 1;
} }
#else
*nbLostCmpt = *nbLostCmpt + 1;
#endif
/* Use pitch correlation at ltpf integer lag if available */ /* 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 */ 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 */ *concealMethod = 4; /* Noise Substitution */
UNUSED(plcMeth); UNUSED(plcMeth);
#else
*concealMethod = plcMeth; // this is a dangerous mapping!
#endif
/* Advanced PLC */ /* Advanced PLC */
if (pitch_int > 0) if (pitch_int > 0)
...@@ -158,46 +129,29 @@ void processPlcClassify_fl(LC3_INT plcMeth, LC3_INT *concealMethod, LC3_INT32 *n ...@@ -158,46 +129,29 @@ void processPlcClassify_fl(LC3_INT plcMeth, LC3_INT *concealMethod, LC3_INT32 *n
if (frame_dms == 100 && hrmode == 0) if (frame_dms == 100 && hrmode == 0)
{ {
*concealMethod = 2; /* PhaseEcu selected */ *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_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); 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 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_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); 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 { 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_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); 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 else
{ {
*concealMethod = 4; /* Noise Substitution */ *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_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); 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); 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); 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) * * Low Complexity Communication Codec Plus (LC3plus) *
* * * *
* Copyright licence is solely granted through ETSI Intellectual Property * * Copyright licence is solely granted through ETSI Intellectual Property *
...@@ -7,12 +7,10 @@ ...@@ -7,12 +7,10 @@
* estoppel or otherwise. * * estoppel or otherwise. *
******************************************************************************/ ******************************************************************************/
#include "options.h" #include "options.h"
#include "wmc_auto.h" #include "wmc_auto.h"
#include "functions.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); 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, 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) * * Low Complexity Communication Codec Plus (LC3plus) *
* * * *
* Copyright licence is solely granted through ETSI Intellectual Property * * Copyright licence is solely granted through ETSI Intellectual Property *
...@@ -7,21 +7,17 @@ ...@@ -7,21 +7,17 @@
* estoppel or otherwise. * * estoppel or otherwise. *
******************************************************************************/ ******************************************************************************/
#include "options.h" #include "options.h"
#include "wmc_auto.h" #include "wmc_auto.h"
#include "functions.h" #include "functions.h"
void processPlcDampingScramblingMain_fl(LC3_INT32 *ns_seed, void processPlcDampingScramblingMain_fl(LC3_INT32 *ns_seed,
LC3_INT32 *pc_seed, LC3_INT32 ns_nbLostCmpt_pc, 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_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_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_INT32 frame_dms, LC3_INT32 concealMethod, LC3_INT32 pitch_present_bfi1, LC3_INT32 pitch_present_bfi2,
LC3_FLOAT *cum_fflcAtten LC3_FLOAT *cum_fflcAtten
#ifdef CR8_A_PLC_FADEOUT_TUNING
, LC3_UINT8 plc_fadeout_type , LC3_UINT8 plc_fadeout_type
#endif
) )
{ {
...@@ -37,31 +33,25 @@ void processPlcDampingScramblingMain_fl(LC3_INT32 *ns_seed, ...@@ -37,31 +33,25 @@ void processPlcDampingScramblingMain_fl(LC3_INT32 *ns_seed,
processDampScramb = 1; processDampScramb = 1;
} }
#ifdef CR8_A_PLC_FADEOUT_TUNING
if (ns_nbLostCmpt == 1) if (ns_nbLostCmpt == 1)
{ {
*cum_fading_slow = 1; *cum_fading_slow = 1;
*cum_fading_fast = 1; *cum_fading_fast = 1;
*cum_fflcAtten = 1; *cum_fflcAtten = 1;
} }
#endif
if ( bfi == 1 ) if ( bfi == 1 )
{ {
processPlcDampingScrambling_fl(spec, yLen, ns_nbLostCmpt, stabFac, processDampScramb, cum_fflcAtten, processPlcDampingScrambling_fl(spec, yLen, ns_nbLostCmpt, stabFac, processDampScramb, cum_fflcAtten,
pitch_present_bfi1, frame_dms, cum_fading_slow, cum_fading_fast, ns_seed, 0 pitch_present_bfi1, frame_dms, cum_fading_slow, cum_fading_fast, ns_seed, 0
#ifdef CR8_A_PLC_FADEOUT_TUNING
, plc_fadeout_type , plc_fadeout_type
#endif
); );
} }
else /* bfi == 2 */ else /* bfi == 2 */
{ {
processPlcDampingScrambling_fl(spec, yLen, ns_nbLostCmpt_pc, stabFac, processDampScramb, cum_fflcAtten, 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 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 , plc_fadeout_type
#endif
); );
processPlcUpdateSpec_fl(spec_prev, spec, yLen); processPlcUpdateSpec_fl(spec_prev, spec, yLen);
} }
...@@ -71,9 +61,7 @@ void processPlcDampingScramblingMain_fl(LC3_INT32 *ns_seed, ...@@ -71,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, 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_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 LC3_FLOAT *cum_fading_fast, LC3_INT32 *seed, LC3_INT32 spec_inv_idx
#ifdef CR8_A_PLC_FADEOUT_TUNING
, LC3_UINT8 plc_fadeout_type , LC3_UINT8 plc_fadeout_type
#endif
) )
{ {
LC3_INT32 plc_start_inFrames, plc_end_inFrames, plc_duration_inFrames, x, b, i, ad_ThreshFac_start; LC3_INT32 plc_start_inFrames, plc_end_inFrames, plc_duration_inFrames, x, b, i, ad_ThreshFac_start;
...@@ -81,16 +69,6 @@ void processPlcDampingScrambling_fl(LC3_FLOAT *spec, LC3_INT32 yLen, LC3_INT32 n ...@@ -81,16 +69,6 @@ void processPlcDampingScrambling_fl(LC3_FLOAT *spec, LC3_INT32 yLen, LC3_INT32 n
frame_energy = 0; 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); slow = 0.8 + 0.2 * (*stabFac);
fast = 0.3 + 0.2 * (*stabFac); fast = 0.3 + 0.2 * (*stabFac);
...@@ -104,27 +82,20 @@ void processPlcDampingScrambling_fl(LC3_FLOAT *spec, LC3_INT32 yLen, LC3_INT32 n ...@@ -104,27 +82,20 @@ void processPlcDampingScrambling_fl(LC3_FLOAT *spec, LC3_INT32 yLen, LC3_INT32 n
slow = LC3_SQRT(slow); slow = LC3_SQRT(slow);
fast = LC3_SQRT(fast); fast = LC3_SQRT(fast);
break; break;
#ifdef CR8_G_ADD_75MS
case 75: case 75:
slow = LC3_SQRT(LC3_SQRT(slow*slow*slow)); slow = LC3_SQRT(LC3_SQRT(slow*slow*slow));
fast = LC3_SQRT(LC3_SQRT(fast*fast*fast)); fast = LC3_SQRT(LC3_SQRT(fast*fast*fast));
break; break;
#endif
} }
#ifdef CR8_A_PLC_FADEOUT_TUNING
if (plc_fadeout_type == 0) if (plc_fadeout_type == 0)
{ {
#endif
*cum_fading_slow = *cum_fading_slow * slow; *cum_fading_slow = *cum_fading_slow * slow;
*cum_fading_fast = *cum_fading_fast * fast; *cum_fading_fast = *cum_fading_fast * fast;
#ifdef CR8_A_PLC_FADEOUT_TUNING
} }
#endif
if (processDampScramb == 1) if (processDampScramb == 1)
{ {
#ifdef CR8_A_PLC_FADEOUT_TUNING
if (plc_fadeout_type != 0) if (plc_fadeout_type != 0)
{ {
if (nbLostCmpt < (4 * (100.0 / (LC3_FLOAT)frame_dms))) { if (nbLostCmpt < (4 * (100.0 / (LC3_FLOAT)frame_dms))) {
...@@ -141,7 +112,6 @@ void processPlcDampingScrambling_fl(LC3_FLOAT *spec, LC3_INT32 yLen, LC3_INT32 n ...@@ -141,7 +112,6 @@ void processPlcDampingScrambling_fl(LC3_FLOAT *spec, LC3_INT32 yLen, LC3_INT32 n
cum_fading_slow_local = *cum_fading_slow; cum_fading_slow_local = *cum_fading_slow;
} }
else { else {
#endif
fflcAtten = 1; fflcAtten = 1;
cum_fading_slow_local = *cum_fading_slow; cum_fading_slow_local = *cum_fading_slow;
cum_fading_fast_local = *cum_fading_fast; cum_fading_fast_local = *cum_fading_fast;
...@@ -159,9 +129,7 @@ void processPlcDampingScrambling_fl(LC3_FLOAT *spec, LC3_INT32 yLen, LC3_INT32 n ...@@ -159,9 +129,7 @@ void processPlcDampingScrambling_fl(LC3_FLOAT *spec, LC3_INT32 yLen, LC3_INT32 n
{ {
case 25: fflcAtten = PLC34_ATTEN_FAC_025; break; case 25: fflcAtten = PLC34_ATTEN_FAC_025; break;
case 50: fflcAtten = PLC34_ATTEN_FAC_050; break; case 50: fflcAtten = PLC34_ATTEN_FAC_050; break;
#ifdef CR8_G_ADD_75MS
case 75: fflcAtten = PLC34_ATTEN_FAC_075; break; case 75: fflcAtten = PLC34_ATTEN_FAC_075; break;
#endif
case 100: fflcAtten = PLC34_ATTEN_FAC_100; break; case 100: fflcAtten = PLC34_ATTEN_FAC_100; break;
} }
} }
...@@ -199,37 +167,25 @@ void processPlcDampingScrambling_fl(LC3_FLOAT *spec, LC3_INT32 yLen, LC3_INT32 n ...@@ -199,37 +167,25 @@ void processPlcDampingScrambling_fl(LC3_FLOAT *spec, LC3_INT32 yLen, LC3_INT32 n
} }
randThreshold = -32768 * linFuncStartStop; randThreshold = -32768 * linFuncStartStop;
#ifdef CR8_A_PLC_FADEOUT_TUNING
} }
#endif
for (i = spec_inv_idx; i < yLen; i++) for (i = spec_inv_idx; i < yLen; i++)
{ {
*seed = 16831 + *seed * 12821; *seed = 16831 + *seed * 12821;
*seed = (LC3_INT16)(*seed); *seed = (LC3_INT16)(*seed);
if (*seed == 32768)
{
*seed -= 32768;
}
if (*seed < 0) if (*seed < 0)
{ {
#ifdef CR8_A_PLC_FADEOUT_TUNING
if (plc_fadeout_type != 0 || pitch_present == 0 || *seed < randThreshold ) if (plc_fadeout_type != 0 || pitch_present == 0 || *seed < randThreshold )
#else
if (pitch_present == 0 || *seed < randThreshold)
#endif
{ {
spec[i] = -spec[i]; spec[i] = -spec[i];
} }
} }
} }
#ifdef CR8_A_PLC_FADEOUT_TUNING
if (plc_fadeout_type == 0) if (plc_fadeout_type == 0)
{ {
#endif
ad_ThreshFac_start = 10; ad_ThreshFac_start = 10;
ad_ThreshFac_end = 1.2; ad_ThreshFac_end = 1.2;
ad_threshFac = (ad_ThreshFac_start - ad_ThreshFac_end) * linFuncStartStop + ad_ThreshFac_end; ad_threshFac = (ad_ThreshFac_start - ad_ThreshFac_end) * linFuncStartStop + ad_ThreshFac_end;
...@@ -250,17 +206,11 @@ void processPlcDampingScrambling_fl(LC3_FLOAT *spec, LC3_INT32 yLen, LC3_INT32 n ...@@ -250,17 +206,11 @@ void processPlcDampingScrambling_fl(LC3_FLOAT *spec, LC3_INT32 yLen, LC3_INT32 n
energThreshold = LC3_SQRT(ad_threshFac * mean_energy); energThreshold = LC3_SQRT(ad_threshFac * mean_energy);
fac = (cum_fading_slow_local - cum_fading_fast_local) * energThreshold; 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++) for (i = spec_inv_idx; i < yLen; i++)
{ {
#ifdef CR8_A_PLC_FADEOUT_TUNING
if (plc_fadeout_type != 0 || LC3_FABS(spec[i]) < energThreshold ) if (plc_fadeout_type != 0 || LC3_FABS(spec[i]) < energThreshold )
#else
if (LC3_FABS(spec[i]) < energThreshold)
#endif
{ {
m = cum_fading_slow_local; m = cum_fading_slow_local;
n = 0; n = 0;
......