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,11 +7,11 @@
* estoppel or otherwise. *
******************************************************************************/
#ifndef IISFFT_H
#define IISFFT_H
#include "options.h"
#include "wmc_auto.h"
#include "../defines.h"
#ifndef M_PIl
......
/******************************************************************************
* 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,11 @@
* estoppel or otherwise. *
******************************************************************************/
#ifndef FUNCTIONS_H
#define FUNCTIONS_H
#include "options.h"
#include "wmc_auto.h"
#include "clib.h"
#include "defines.h"
#include "float.h"
......@@ -108,9 +108,7 @@ void processNoiseFactor_fl(LC3_INT* fac_ns_idx, LC3_FLOAT x[], LC3_INT xq[], LC3
void processNoiseFilling_fl(LC3_FLOAT xq[], LC3_INT nfseed, LC3_INT fac_ns_idx, LC3_INT bw_stopband, LC3_INT frame_dms, LC3_FLOAT fac_ns_pc, LC3_INT spec_inv_idx);
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,
#endif
LC3_INT* T0_out,LC3_FLOAT* normcorr_out, LC3_INT len, LC3_INT frame_dms);
void processTnsCoder_fl(LC3_FLOAT* x, LC3_INT bw_cutoff_idx, LC3_INT bw_fcbin, LC3_INT fs, LC3_INT N, LC3_INT frame_dms, LC3_INT nBits,
......@@ -128,11 +126,7 @@ void processSnsInterpolateScf_fl(LC3_FLOAT* gains, LC3_INT encoder_side, LC3_INT
void processDetectCutoffWarped_fl(LC3_FLOAT* d2, LC3_INT fs_idx, LC3_INT frame_dms, LC3_INT* bw_idx);
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
#ifdef CR8_E_TONE_DETECTOR
, const LC3_INT16 frame_dms, const LC3_INT16 hrmode );
#else
);
#endif
void processPerBandEnergy_fl(LC3_INT bands_number, const LC3_INT* acc_coeff_per_band, LC3_INT16 hrmode, LC3_INT16 frame_dms, LC3_FLOAT* d2, LC3_FLOAT* d);
void ProcessingIMDCT_fl(LC3_FLOAT* y, LC3_INT yLen, const LC3_FLOAT* win, LC3_INT winLen, LC3_INT last_zeros, LC3_FLOAT* mem, LC3_FLOAT* x,
......@@ -143,18 +137,14 @@ void ProcessingITDA_WIN_OLA_fl(LC3_FLOAT* x_tda, LC3_INT32 yLen, const LC3_FLOAT
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_INT* param, LC3_FLOAT* mem_norm_corr_past_past, LC3_INT* bits
#ifdef CR9_K_REDUCE_NORM_CORR_TH
, LC3_INT16 hrmode
#endif
);
void process_ltpf_decoder_fl(LC3_FLOAT* x, LC3_INT xLen, LC3_FLOAT* y, LC3_INT fs, LC3_FLOAT* mem_old_x, LC3_FLOAT* mem_old_y,
LC3_INT* mem_pitch_LC3_INT, LC3_INT* mem_pitch_fr, LC3_FLOAT* mem_gain, LC3_INT* mem_beta_idx, LC3_INT bfi,
LC3_INT* param, LC3_INT* mem_param, LC3_INT conf_beta_idx, LC3_FLOAT conf_beta, LC3_INT concealMethod, LC3_FLOAT damping
, 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
#endif
);
void process_resamp12k8_fl(LC3_FLOAT x[], LC3_INT x_len, LC3_FLOAT mem_in[], LC3_INT mem_in_len, LC3_FLOAT mem_50[], LC3_FLOAT mem_out[],
......@@ -241,17 +231,13 @@ void processPlcDampingScramblingMain_fl(LC3_INT32 *ns_seed,
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
);
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
);
void plc_phEcu_F0_refine_first(LC3_INT32 *plocs, LC3_INT32 n_plocs, LC3_FLOAT *f0est, const LC3_INT32 Xabs_len,
......@@ -278,10 +264,8 @@ void plc_phEcu_spec_ana(LC3_FLOAT* xfp, LC3_INT32 xfp_len, const LC3_FLOAT*
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, /* needed for DC muting */
LC3_INT16* nonpure_tone_flag_ptr, /* i/o: flag */
#endif
LC3_FLOAT *corr_phase_dbg,
LC3_FLOAT *X_i_new_re_dbg, LC3_FLOAT *X_i_new_im_dbg);
void plc_phEcu_rec_frame(Complex *X_in, LC3_INT32 xfp_len, LC3_INT32 Lecu, const LC3_FLOAT *whr, const LC3_FLOAT *winMDCT, LC3_INT32 Lprot,
......@@ -299,18 +283,14 @@ void plc_phEcu_tba_trans_dect_gains(LC3_INT32 burst_len, LC3_INT32 n_grp, LC3_FL
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,
LC3_FLOAT *thresh_dbg
#ifdef CR8_A_PLC_FADEOUT_TUNING
, LC3_UINT8 plc_fadeout_type
#endif
);
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
);
void plc_phEcu_hq_ecu(
LC3_FLOAT *f0binPtr, LC3_FLOAT *f0ltpGainPtr,
......@@ -325,10 +305,8 @@ void plc_phEcu_hq_ecu(
LC3_FLOAT *st_beta_mute, LC3_FLOAT *st_mag_chg_1st, LC3_FLOAT *st_Xavg, LC3_INT32 LA_ZEROS, LC3_FLOAT *x_tda, LC3_FLOAT *xsubst_dbg, Complex *X_out_m_dbg,
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
#endif
);
void processTdcPreemphasis_fl(LC3_FLOAT *in, LC3_FLOAT *pre_emph_factor, LC3_INT32 n_bands);
......@@ -339,12 +317,11 @@ void processTdcInverseOdft_fl(LC3_FLOAT *in, LC3_INT32 n_bands, LC3_FLOAT *out,
void processTdcApply_fl(const LC3_INT32 pitch_LC3_INT, const LC3_FLOAT *preemphFac, const LC3_FLOAT* A, const LC3_INT32 lpc_order, const LC3_FLOAT* pcmbufHist, const LC3_INT32 max_len_pcm_plc, const LC3_INT32 N, const LC3_INT32 frame_dms,
const LC3_INT32 SampRate, const LC3_INT32 nbLostCmpt, const LC3_INT32 overlap, const LC3_FLOAT *stabFac, LC3_FLOAT harmonicBuf[MAX_PITCH], LC3_FLOAT synthHist[M],
LC3_INT32* fract, LC3_INT16* seed, 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
);
void* balloc(void* base, size_t* base_size, size_t size);
LC3_FLOAT type_2_fadeout(LC3_INT32 nbLostFramesInRow, LC3_INT32 frame_dms);
#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,8 +7,8 @@
* estoppel or otherwise. *
******************************************************************************/
#include "options.h"
#include "wmc_auto.h"
#include "functions.h"
/* Function expects already flipped window */
......
/******************************************************************************
* 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 "lc3.h"
#include "defines.h"
#include "functions.h"
......@@ -71,9 +71,7 @@ static int lc3plus_frame_size_supported(float frame_ms)
{
case 25: /* fallthru */
case 50: /* fallthru */
#ifdef CR8_G_ADD_75MS
case 75: /* fallthru */
#endif
case 100: return 1;
default: break;
}
......@@ -111,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(samplerate==96000 && hrmode == 0, LC3PLUS_HRMODE_ERROR);
if (lfe_channel_array != NULL)
{
for (ch = 0; ch < channels; ch++)
{
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 */
}
......@@ -304,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)
{
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(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);
}
......
/******************************************************************************
* ETSI TS 103 634 V1.4.3 *
* ETSI TS 103 634 V1.5.1 *
* Low Complexity Communication Codec Plus (LC3plus) *
* *
* Copyright licence is solely granted through ETSI Intellectual Property *
......@@ -7,7 +7,6 @@
* estoppel or otherwise. *
******************************************************************************/
/*! \file lc3.h
* This header provides the API for LC3plus.
*
......@@ -26,6 +25,7 @@
#ifndef _MSC_VER
#include "options.h"
#include "wmc_auto.h"
#include <stdint.h>
#else
typedef unsigned char uint8_t;
......@@ -37,7 +37,7 @@ typedef __int32 int32_t;
#define LC3PLUS_VERSION_INT(major, minor, micro) (((major) << 16) | ((minor) << 8) | (micro))
/*! 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
* less, use lc3plus_channels_supported() to check. */
......@@ -170,6 +170,7 @@ int lc3plus_samplerate_supported(int samplerate);
* \param[in] samplerate Input sampling rate. Allowed sampling rates are:
* 8000, 16000, 24000, 32000, 44100, 48000
* \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.
*/
LC3PLUS_Error lc3plus_enc_init(LC3PLUS_Enc* encoder, int samplerate, int channels, int hrmode, int32_t lfe_channel_array[]);
......@@ -386,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
* left channel is stored in output_samples[0], the right channel in
* 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
* 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) *
* *
* 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"
#include "fft/iis_fft.c"
#include "fft/iisfft.c"
......
/******************************************************************************
* 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,13 @@
* estoppel or otherwise. *
******************************************************************************/
#include "options.h"
#include "wmc_auto.h"
#include "defines.h"
static const char *const LICENSE =
"*******************************************************************************\n"
"* ETSI TS 103 634 V1.4.3 *\n"
"* ETSI TS 103 634 V1.5.1 *\n"
"* Low Complexity Communication Codec Plus (LC3plus) *\n"
"* Floating Point Software V%i.%i.%iETSI, " __DATE__ " *\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) *
* *
* 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"
static LC3_INT searchMaxIndice(LC3_FLOAT* in, LC3_INT len);
......@@ -35,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,
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
#ifdef CR9_K_REDUCE_NORM_CORR_TH
, 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;
......@@ -48,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 pitch = 0;
#ifdef CR9_K_REDUCE_NORM_CORR_TH
LC3_FLOAT normCorrTh = 0.0f;
if (hrmode) {
normCorrTh = 0.4;
} else {
normCorrTh = 0.6;
}
#endif
/* Signal Buffer */
N = xLen - 1;
......@@ -72,11 +68,7 @@ void process_ltpf_coder_fl(LC3_FLOAT* xin, LC3_INT xLen, LC3_INT ltpf_enable, LC
pitch_search_upsamp = 4;
pitch_search_L_interpol1 = 4;
#ifdef CR9_K_REDUCE_NORM_CORR_TH
if (pitch_ol_norm_corr > normCorrTh) {
#else
if (pitch_ol_norm_corr > 0.6) {
#endif
/* Search Bounds */
t0_min = 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) *
* *
* 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 process_ltpf_decoder_fl(LC3_FLOAT* x, LC3_INT xLen, LC3_FLOAT* y, LC3_INT fs, LC3_FLOAT* mem_old_x, LC3_FLOAT* mem_old_y,
......@@ -16,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_FLOAT damping
, 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
#endif
)
{
LC3_INT i, j, n, N, L_past_x, N4, N34,
......@@ -27,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],
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;
#endif
#ifdef CR9_N_SHORT_FADE_FOR_UNSTABLE_PITCH
LC3_FLOAT pitch_fl_c_old, pitch_delta;
#endif
const LC3_FLOAT *inter_filter[4], *tilt_filter[4];
#ifdef WMOPS
push_wmops("process_ltpf_decoder_fl");
#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;
#endif
conf_alpha = 0.85;
if (bfi != 1) {
......@@ -226,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 */
#ifdef CR9_LTPF_REWRITE
fade_fac = 1. / (LC3_FLOAT) N4;
current_fade_fac_up = 0.f;
current_fade_fac_down = 1.f;
(void) p_x; (void) p_y; (void) p_a1; (void) p_b1;
#endif
if (mem_param[1] == 0 && param[1] == 0) {
memmove(&buf_y[L_past_y], &buf_x[L_past_x], sizeof(LC3_FLOAT) * N4);
......@@ -252,14 +242,9 @@ void process_ltpf_decoder_fl(LC3_FLOAT* x, LC3_INT xLen, LC3_FLOAT* y, LC3_INT f
j++;
}
#ifdef CR9_LTPF_REWRITE
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 -= 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) {
......@@ -278,12 +263,8 @@ void process_ltpf_decoder_fl(LC3_FLOAT* x, LC3_INT xLen, LC3_FLOAT* y, LC3_INT f
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;
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) {
for (n = 0; n < N4; n++) {
......@@ -304,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;
}
} else {
#ifdef CR9_LTPF_REWRITE
p_x_init = &buf_x[L_past_x];
p_y_init = &buf_y[L_past_y - p1 + inter_len - 1];
p_y2 = &buf_y[L_past_y];
......@@ -366,49 +346,8 @@ void process_ltpf_decoder_fl(LC3_FLOAT* x, LC3_INT xLen, LC3_FLOAT* y, LC3_INT f
p_y_init++;
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 */
if (param[1] == 0) {
move_float(&buf_y[L_past_y + N4], &buf_x[L_past_x + N4],
......@@ -443,31 +382,6 @@ void process_ltpf_decoder_fl(LC3_FLOAT* x, LC3_INT xLen, LC3_FLOAT* y, LC3_INT f
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 */
move_float(y, &buf_y[L_past_y], N);
......@@ -484,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_gain = gain;
*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)){
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);
}
#endif
#ifdef WMOPS
pop_wmops();
......
/******************************************************************************
* 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"
static const LC3_FLOAT* mdct_window(LC3_INT length, LC3_INT frame_dms, LC3_INT hrmode)
......@@ -31,7 +31,6 @@ static const LC3_FLOAT* mdct_window(LC3_INT length, LC3_INT frame_dms, LC3_INT h
return NULL;
}
}
#ifdef CR8_G_ADD_75MS
else if (frame_dms == 75) {
switch (length) {
case 60:
......@@ -50,7 +49,6 @@ static const LC3_FLOAT* mdct_window(LC3_INT length, LC3_INT frame_dms, LC3_INT h
return NULL;
}
}
#endif
else if (frame_dms == 50) {
switch (length) {
case 40:
......@@ -95,11 +93,9 @@ void mdct_init(Mdct* mdct, LC3_INT length, LC3_INT frame_dms, LC3_INT fs_idx, LC
if (frame_dms == 100) {
mdct->leading_zeros = MDCT_la_zeroes[fs_idx];
}
#ifdef CR8_G_ADD_75MS
else if (frame_dms == 75) {
mdct->leading_zeros = MDCT_la_zeroes_7_5ms[fs_idx];
}
#endif
else if (frame_dms == 50) {
mdct->leading_zeros = MDCT_la_zeroes_5ms[fs_idx];
}
......
/******************************************************************************
* 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 processMdctShaping_fl(LC3_FLOAT x[], LC3_FLOAT scf[], const LC3_INT bands_offset[], LC3_INT fdns_npts)
......
/******************************************************************************
* 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,21 +8,14 @@
******************************************************************************/
#include "options.h"
#include "wmc_auto.h"
#include "functions.h"
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
#ifdef CR8_E_TONE_DETECTOR
, const LC3_INT16 frame_dms, const LC3_INT16 hrmode)
#else
)
#endif
const LC3_INT bands_number, const LC3_FLOAT* ener , const LC3_INT16 frame_dms, const LC3_INT16 hrmode)
{
*near_nyquist_flag = 0;
#ifdef CR8_E_TONE_DETECTOR
if (hrmode == 0){
#endif
if (fs_idx < 4)
{
LC3_INT i = 0;
......@@ -42,7 +35,6 @@ void processNearNyquistdetector_fl(LC3_INT16* near_nyquist_flag, const LC3_INT f
*near_nyquist_flag = 1;
}
}
#ifdef CR8_E_TONE_DETECTOR
}
else // hrmode == 1
{
......@@ -88,5 +80,4 @@ void processNearNyquistdetector_fl(LC3_INT16* near_nyquist_flag, const LC3_INT f
*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) *
* *
* 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 processNoiseFactor_fl(LC3_INT* fac_ns_idx, LC3_FLOAT x[], LC3_INT xq[], LC3_FLOAT gg, LC3_INT BW_cutoff_idx, LC3_INT frame_dms,
......@@ -29,12 +29,10 @@ void processNoiseFactor_fl(LC3_INT* fac_ns_idx, LC3_FLOAT x[], LC3_INT xq[], LC3
nTransWidth = 1;
startOffset = 12;
break;
#ifdef CR8_G_ADD_75MS
case 75:
nTransWidth = 2;
startOffset = 18;
break;
#endif
case 100:
nTransWidth = 3;
startOffset = 24;
......
/******************************************************************************
* 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 processNoiseFilling_fl(LC3_FLOAT xq[], LC3_INT nfseed, LC3_INT fac_ns_idx, LC3_INT bw_stopband, LC3_INT frame_dms, LC3_FLOAT fac_ns_pc, LC3_INT spec_inv_idx)
......@@ -27,12 +27,10 @@ void processNoiseFilling_fl(LC3_FLOAT xq[], LC3_INT nfseed, LC3_INT fac_ns_idx,
nTransWidth = 1;
startOffset = 12;
break;
#ifdef CR8_G_ADD_75MS
case 75:
nTransWidth = 2;
startOffset = 18;
break;
#endif
case 100:
nTransWidth = 3;
startOffset = 24;
......
/******************************************************************************
* 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"
static void filter_olpa(LC3_FLOAT* in, LC3_FLOAT* out, const LC3_FLOAT* buf, LC3_INT32 len_input);
......@@ -46,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,
#ifdef CR9_F_PITCH_WIN_LEN_FIX
LC3_INT* pitch_flag,
#endif
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;
......@@ -56,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;
len2 = len / 2;
#ifdef CR9_F_PITCH_WIN_LEN_FIX
switch(frame_dms)
{
case 50:
......@@ -70,23 +67,12 @@ void processOlpa_fl(LC3_FLOAT* s_12k8, LC3_FLOAT* mem_s12k8, LC3_FLOAT* mem_s6k4
break;
default:
#endif
delta = 0;
acflen = len2;
#ifdef CR9_F_PITCH_WIN_LEN_FIX
}
#endif
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 */
move_float(buf, mem_s12k8, 3);
move_float(&buf[3], s_12k8, len);
......@@ -94,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);
/* Compute autocorrelation */
#ifdef CR9_F_PITCH_WIN_LEN_FIX
s6k4 = &buf[mem_in_len - delta];
move_float(&buf[mem_in_len], R0, len2);
move_float(buf, mem_s6k4, 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++) {
sum = mac_loop(s6k4, &s6k4[-i], acflen);
R0[i - MIN_PITCH_6K4] = sum;
......@@ -160,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)
{
case 50:
......@@ -188,11 +162,8 @@ void processOlpa_fl(LC3_FLOAT* s_12k8, LC3_FLOAT* mem_s12k8, LC3_FLOAT* mem_s6k4
break;
default:
#endif
*mem_old_T0 = T0;
#ifdef CR9_F_PITCH_WIN_LEN_FIX
}
#endif
*T0_out = T0 * 2.0;
*normcorr_out = norm_corr;
......
/******************************************************************************
* 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 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;
......
/******************************************************************************
* 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"
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)
......
/******************************************************************************
* 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 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;
......
/******************************************************************************
* 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 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)
{
......
/******************************************************************************
* 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 processPerBandEnergy_fl(LC3_INT bands_number, const LC3_INT* acc_coeff_per_band, LC3_INT16 hrmode, LC3_INT16 frame_dms, LC3_FLOAT* d2, LC3_FLOAT* d)
......@@ -30,21 +30,15 @@ void processPerBandEnergy_fl(LC3_INT bands_number, const LC3_INT* acc_coeff_per_
}
switch (frame_dms)
{
# ifdef ENABLE_2_5MS_MODE
case 25:
maxBwBin = maxBwBin >> 2;
break;
# endif
# ifdef ENABLE_5MS_MODE
case 50:
maxBwBin = maxBwBin >> 1;
break;
# endif
#ifdef CR8_G_ADD_75MS
case 75:
maxBwBin = (maxBwBin >> 2) * 3;
break;
#endif
}
for (i = 0; i < bands_number; i++) {
......