Skip to content
/******************************************************************************
* ETSI TS 103 634 V1.4.3 *
* ETSI TS 103 634 V1.5.1 *
* Low Complexity Communication Codec Plus (LC3plus) *
* *
* Copyright licence is solely granted through ETSI Intellectual Property *
......@@ -7,7 +7,6 @@
* estoppel or otherwise. *
******************************************************************************/
#include "options.h"
#include "wmc_auto.h"
#include "functions.h"
......@@ -32,11 +31,9 @@ void process_resamp12k8_fl(LC3_FLOAT x[], LC3_INT x_len, LC3_FLOAT mem_in[], LC3
case 50:
len_12k8 = LEN_12K8 / 2;
break;
#ifdef CR8_G_ADD_75MS
case 75:
len_12k8 = (LEN_12K8 / 4) * 3;
break;
#endif
case 100:
len_12k8 = LEN_12K8;
break;
......
/******************************************************************************
* ETSI TS 103 634 V1.4.3 *
* ETSI TS 103 634 V1.5.1 *
* Low Complexity Communication Codec Plus (LC3plus) *
* *
* Copyright licence is solely granted through ETSI Intellectual Property *
......@@ -7,7 +7,6 @@
* estoppel or otherwise. *
******************************************************************************/
#include "options.h"
#include "wmc_auto.h"
#include "functions.h"
......
/******************************************************************************
* ETSI TS 103 634 V1.4.3 *
* ETSI TS 103 634 V1.5.1 *
* Low Complexity Communication Codec Plus (LC3plus) *
* *
* Copyright licence is solely granted through ETSI Intellectual Property *
......@@ -7,7 +7,6 @@
* estoppel or otherwise. *
******************************************************************************/
#include "options.h"
#include "wmc_auto.h"
#include "functions.h"
......
/******************************************************************************
* 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 *
......
/******************************************************************************
* ETSI TS 103 634 V1.4.3 *
* ETSI TS 103 634 V1.5.1 *
* Low Complexity Communication Codec Plus (LC3plus) *
* *
* Copyright licence is solely granted through ETSI Intellectual Property *
......@@ -7,7 +7,6 @@
* estoppel or otherwise. *
******************************************************************************/
#include "options.h"
#include "wmc_auto.h"
#include "setup_dec_lc3.h"
......@@ -36,10 +35,8 @@ int alloc_decoder(LC3PLUS_Dec* decoder, int samplerate, int channels)
HANDLE_IIS_FFT handle_ifft_phaseecu;
LC3_FLOAT *q_old_res;
#ifdef CR8_A_PLC_FADEOUT_TUNING
LC3_INT32 * plc_longterm_advc_tdc = NULL, *plc_longterm_advc_ns = NULL;
LC3_INT16 longterm_analysis_counter_max = 0, longterm_analysis_counter_max_bytebuffer = 0;
#endif
for (ch = 0; ch < channels; ch++) {
DecSetup* setup = balloc(decoder, &size, sizeof(DecSetup));
......@@ -64,14 +61,11 @@ int alloc_decoder(LC3PLUS_Dec* decoder, int samplerate, int channels)
sine_table1_phecu = balloc(decoder, &size, sizeof(LC3_FLOAT) * (((CODEC_FS(samplerate) * 16) / 1000) / 2 + 1));
sine_table2_phecu = balloc(decoder, &size, sizeof(LC3_FLOAT) * (((CODEC_FS(samplerate) * 16) / 1000) / 2 + 1));
#ifdef CR8_A_PLC_FADEOUT_TUNING
longterm_analysis_counter_max = plc_fadeout_param_maxlen[0];
longterm_analysis_counter_max_bytebuffer = plc_fadeout_param_maxbytes[0];
plc_longterm_advc_tdc = balloc(decoder, &size, sizeof(LC3_INT32) * longterm_analysis_counter_max_bytebuffer);
plc_longterm_advc_ns = balloc(decoder, &size, sizeof(LC3_INT32) * longterm_analysis_counter_max_bytebuffer);
#endif
q_old_res = balloc(decoder, &size, sizeof(LC3_FLOAT) * frame_len);
......@@ -96,13 +90,11 @@ int alloc_decoder(LC3PLUS_Dec* decoder, int samplerate, int channels)
setup->PlcAdvSetup->PlcPhEcuSetup.handle_fft_phaseecu->sine_table = sine_table1_phecu;
setup->PlcAdvSetup->PlcPhEcuSetup.handle_ifft_phaseecu->sine_table = sine_table2_phecu;
#ifdef CR8_A_PLC_FADEOUT_TUNING
setup->PlcAdvSetup->longterm_analysis_counter_max = longterm_analysis_counter_max;
setup->PlcAdvSetup->longterm_analysis_counter_max_bytebuffer = longterm_analysis_counter_max_bytebuffer;
setup->PlcAdvSetup->plc_longterm_advc_tdc = plc_longterm_advc_tdc;
setup->PlcAdvSetup->plc_longterm_advc_ns = plc_longterm_advc_ns;
#endif
setup->PlcAdvSetup->PlcPhEcuSetup.PhECU_Lprot = (CODEC_FS(samplerate) * 16) / 1000;
real_fft_init(&(setup->PlcAdvSetup->PlcPhEcuSetup.PhEcu_Fft), setup->PlcAdvSetup->PlcPhEcuSetup.PhECU_Lprot, &(setup->PlcAdvSetup->PlcPhEcuSetup.handle_fft_phaseecu));
......@@ -128,11 +120,6 @@ LC3PLUS_Error FillDecSetup(LC3PLUS_Dec* decoder, int samplerate, int channels, L
decoder->hrmode = hrmode != 0;
#ifndef CR8_A_PLC_FADEOUT_TUNING
if (decoder->fs_idx > 4) {
decoder->fs_idx = 5;
}
#endif
decoder->channels = channels;
decoder->frame_ms = 10;
decoder->frame_dms = 100;
......@@ -164,6 +151,7 @@ LC3PLUS_Error FillDecSetup(LC3PLUS_Dec* decoder, int samplerate, int channels, L
void set_dec_frame_params(LC3PLUS_Dec* decoder)
{
int ch = 0;
int n;
if (decoder->fs_idx == 5)
{
......@@ -200,7 +188,6 @@ void set_dec_frame_params(LC3PLUS_Dec* decoder)
decoder->yLen /= 2;
decoder->bands_number = bands_number_5ms[decoder->fs_idx];
}
#ifdef CR8_G_ADD_75MS
if (decoder->frame_ms == 7.5)
{
decoder->frame_length = (decoder->frame_length >> 2) * 3;
......@@ -214,7 +201,6 @@ void set_dec_frame_params(LC3PLUS_Dec* decoder)
decoder->bands_number = bands_number_7_5ms[decoder->fs_idx];
}
}
#endif
if (decoder->hrmode)
{
......@@ -261,7 +247,6 @@ void set_dec_frame_params(LC3PLUS_Dec* decoder)
}
decoder->cutoffBins = BW_cutoff_bin_all_5ms;
}
#ifdef CR8_G_ADD_75MS
else if (decoder->frame_ms == 7.5)
{
if (decoder->hrmode)
......@@ -274,7 +259,6 @@ void set_dec_frame_params(LC3PLUS_Dec* decoder)
}
decoder->cutoffBins = BW_cutoff_bin_all_7_5ms;
}
#endif
decoder->n_bandsPLC = MIN(decoder->frame_length, 80);
......@@ -300,22 +284,15 @@ void set_dec_frame_params(LC3PLUS_Dec* decoder)
decoder->n_bandsPLC = 60;
}
}
#ifdef CR8_G_ADD_75MS
else if (decoder->frame_ms == 7.5)
{
decoder->bands_offsetPLC = ACC_COEFF_PER_BAND_PLC_7_5ms[decoder->fs_idx];
#ifdef FIX_1082_INSTRUM_FAILED_LC3PLUS
if (decoder->fs != 32000 && decoder->fs != 96000)
#else
if (decoder->fs != 32000 && decoder->fs != 96000)
if (decoder->fs != 32000)
#endif
{
decoder->n_bandsPLC = 60;
}
}
#endif
assert(decoder->bands_offsetPLC);
......@@ -334,13 +311,11 @@ void set_dec_frame_params(LC3PLUS_Dec* decoder)
decoder->imdct_laZeros = MDCT_la_zeroes_5ms[decoder->fs_idx];
decoder->imdct_winLen = MDCT_WINDOWS_LENGTHS_5ms[decoder->fs_idx];
}
#ifdef CR8_G_ADD_75MS
else if (decoder->frame_ms == 7.5) {
decoder->imdct_win = MDCT_WINS_7_5ms[decoder->hrmode][decoder->fs_idx];
decoder->imdct_laZeros = MDCT_la_zeroes_7_5ms[decoder->fs_idx];
decoder->imdct_winLen = MDCT_WINDOWS_LENGTHS_7_5ms[decoder->fs_idx];
}
#endif
decoder->la_zeroes = decoder->imdct_laZeros;
......@@ -386,10 +361,8 @@ void set_dec_frame_params(LC3PLUS_Dec* decoder)
setup->PlcAdvSetup->cum_fading_slow = 1;
setup->PlcAdvSetup->cum_fflcAtten = 1;
#ifdef CR8_A_PLC_FADEOUT_TUNING
setup->PlcAdvSetup->longterm_analysis_counter_max = plc_fadeout_param_maxlen[(decoder->frame_dms / 25) - 1];
setup->PlcAdvSetup->longterm_analysis_counter_max_bytebuffer = plc_fadeout_param_maxbytes[(decoder->frame_dms / 25) - 1];
#endif
if (decoder->fs_idx <= 4 && decoder->frame_dms == 100)
{
......@@ -423,12 +396,13 @@ void set_dec_frame_params(LC3PLUS_Dec* decoder)
}
setup->PlcAdvSetup->PlcPhEcuSetup.PhECU_short_flag_prev = 0; /* fullband transient */
setup->PlcAdvSetup->PlcPhEcuSetup.PhECU_num_plocs = 0;
#ifdef CR8_A_PLC_FADEOUT_TUNING
setup->PlcAdvSetup->PlcPhEcuSetup.PhECU_nonpure_tone_flag = -1; /* nonpure tone flag, -1==new calc., 0==pure, 1==nonpure */
#endif
}
}
}
for (n=0; n < LC3_ROUND(PLC_FADEOUT_TYPE_1_IN_MS*10/decoder->frame_dms);n++){
decoder->alpha_type_2_table[n] = type_2_fadeout(n, decoder->frame_dms);
}
}
LC3PLUS_Error update_dec_bitrate(LC3PLUS_Dec* decoder, int ch, int nBytes)
......@@ -448,12 +422,10 @@ LC3PLUS_Error update_dec_bitrate(LC3PLUS_Dec* decoder, int ch, int nBytes)
maxBytes = 375;
minBytes = MIN_NBYTES;
break;
#ifdef CR8_G_ADD_75MS
case 75:
maxBytes = 625;
minBytes = MIN_NBYTES;
break;
#endif
case 100:
maxBytes = 625;
minBytes = MIN_NBYTES;
......@@ -465,7 +437,7 @@ LC3PLUS_Error update_dec_bitrate(LC3PLUS_Dec* decoder, int ch, int nBytes)
else
{
minBytes = MIN_NBYTES;
maxBytes = MAX_NBYTES_100; // for backward compatibility, MAX_NBYTES_100 is used for all frame lengths
maxBytes = MAX_NBYTES_100; /* for backward compatibility, MAX_NBYTES_100 is used for all frame lengths */
}
channel_bytes = nBytes;
......@@ -498,12 +470,10 @@ LC3PLUS_Error update_dec_bitrate(LC3PLUS_Dec* decoder, int ch, int nBytes)
setup->enable_lpc_weighting = (setup->total_bits < 240);
totalBits = setup->total_bits * 2 - 160;
}
#ifdef CR8_G_ADD_75MS
if (decoder->frame_ms == 7.5) {
setup->enable_lpc_weighting = (setup->total_bits < 360);
totalBits = round(setup->total_bits * 10 / 7.5);
}
#endif
if (decoder->frame_length > 40 * ((LC3_FLOAT) (decoder->frame_dms) / 10.0)) {
setup->N_red_tns = 40 * ((LC3_FLOAT) (decoder->frame_dms) / 10.0);
......
/******************************************************************************
* ETSI TS 103 634 V1.4.3 *
* ETSI TS 103 634 V1.5.1 *
* Low Complexity Communication Codec Plus (LC3plus) *
* *
* Copyright licence is solely granted through ETSI Intellectual Property *
......@@ -7,7 +7,6 @@
* estoppel or otherwise. *
******************************************************************************/
#ifndef SETUP_DEC_LC3_FL_H
#define SETUP_DEC_LC3_FL_H
......@@ -51,10 +50,7 @@ typedef struct {
LC3_FLOAT x_fl[MAX_LEN];
LC3_FLOAT imdct_mem[MAX_LEN];
LC3_FLOAT alpha;
#ifdef CR9_N_SHORT_FADE_FOR_UNSTABLE_PITCH
LC3_FLOAT rel_pitch_change;
#endif
Dct4 dct4structImdct;
PlcSetup PlcSetup;
......@@ -66,6 +62,7 @@ typedef struct {
/* Constants and sampling rate derived values go in this struct */
struct LC3PLUS_Dec {
LC3_FLOAT alpha_type_2_table[PLC_FADEOUT_TYPE_1_IN_MS*10/25]; /* [80] */
DecSetup* channel_setup[MAX_CHANNELS];
const LC3_INT* W_fx;
const LC3_INT* bands_offset;
......
/******************************************************************************
* ETSI TS 103 634 V1.4.3 *
* ETSI TS 103 634 V1.5.1 *
* Low Complexity Communication Codec Plus (LC3plus) *
* *
* Copyright licence is solely granted through ETSI Intellectual Property *
......@@ -7,7 +7,6 @@
* estoppel or otherwise. *
******************************************************************************/
#include "options.h"
#include "wmc_auto.h"
#include "setup_enc_lc3.h"
......@@ -44,11 +43,9 @@ LC3PLUS_Error FillEncSetup(LC3PLUS_Enc* encoder, int samplerate, int channels
encoder->fs_idx = FS2FS_IDX(encoder->fs);
encoder->frame_dms = 100;
#ifndef CR8_A_PLC_FADEOUT_TUNING
if (encoder->fs_idx > 4) {
encoder->fs_idx = 5;
}
#endif
encoder->hrmode = hrmode != 0;
......@@ -62,10 +59,13 @@ LC3PLUS_Error FillEncSetup(LC3PLUS_Enc* encoder, int samplerate, int channels
encoder->r12k8_mem_in_len = 2 * 8 * encoder->fs / 12800;
encoder->r12k8_mem_out_len = 24;
if (lfe_channel_array != NULL)
{
for (ch = 0; ch < encoder->channels; ch++)
{
encoder->channel_setup[ch]->lfe = lfe_channel_array[ch] != 0;
}
}
encoder->bw_ctrl_active = 0;
encoder->bandwidth = encoder->fs / 2;
......@@ -145,7 +145,6 @@ void set_enc_frame_params(LC3PLUS_Enc* encoder)
encoder->attdec_damping = 0.5;
encoder->attdec_hangover_thresh = 2;
}
#ifdef CR8_G_ADD_75MS
else if (encoder->frame_ms == 7.5) {
if (encoder->hrmode)
{
......@@ -177,7 +176,6 @@ void set_enc_frame_params(LC3PLUS_Enc* encoder)
encoder->near_nyquist_index = encoder->bands_number - 4;
encoder->r12k8_mem_out_len = ceil(2.0 * ((LC3_FLOAT) encoder->frame_length / 2.0 - (LC3_FLOAT) encoder->la_zeroes) * 12800.0 / (LC3_FLOAT) encoder->fs - 8.0);
}
#endif
else if (encoder->frame_ms == 5) {
encoder->frame_length = encoder->frame_length >> 1;
encoder->yLen /= 2;
......@@ -228,9 +226,7 @@ void set_enc_frame_params(LC3PLUS_Enc* encoder)
setup = encoder->channel_setup[ch];
setup->olpa_mem_pitch = 17;
#ifdef CR9_F_PITCH_WIN_LEN_FIX
setup->pitch_flag = 0;
#endif
if (setup->mdctStruct.mem != NULL) {
mdct_free(&setup->mdctStruct);
mdct_init(&setup->mdctStruct, encoder->frame_length, encoder->frame_dms, encoder->fs_idx, encoder->hrmode);
......@@ -269,14 +265,12 @@ LC3PLUS_Error update_enc_bitrate(LC3PLUS_Enc* encoder, int bitrate)
else if (encoder->fs == 96000) {minBR = MIN_BR_50MS_96KHZ_HR;}
else { return LC3PLUS_HRMODE_ERROR;}
break;
#ifdef CR8_G_ADD_75MS
case 75:
maxBR = 500000;
if (encoder->fs == 48000) {minBR = MIN_BR_075DMS_48KHZ_HR;}
else if (encoder->fs == 96000) {minBR = MIN_BR_075DMS_96KHZ_HR;}
else {return LC3PLUS_HRMODE_ERROR;}
break;
#endif
case 100:
maxBR = 500000;
if (encoder->fs == 48000) {minBR = MIN_BR_100MS_48KHZ_HR;}
......@@ -309,7 +303,6 @@ LC3PLUS_Error update_enc_bitrate(LC3PLUS_Enc* encoder, int bitrate)
default: break;
}
break;
#ifdef CR8_G_ADD_75MS
case 75:
minBR = MIN_BR_075DMS;
maxBR = MAX_BR_075DMS;
......@@ -322,7 +315,6 @@ LC3PLUS_Error update_enc_bitrate(LC3PLUS_Enc* encoder, int bitrate)
default: break;
}
break;
#endif
case 100:
/* have additional limitations for 10ms */
minBR = MIN_BR_100DMS;
......@@ -443,11 +435,9 @@ LC3PLUS_Error update_enc_bitrate(LC3PLUS_Enc* encoder, int bitrate)
setup->targetBitsAri = setup->total_bits;
setup->enable_lpc_weighting = setup->total_bits < 480;
#ifdef CR8_G_ADD_75MS
if (encoder->frame_ms == 7.5) {
setup->enable_lpc_weighting = setup->total_bits < 360;
}
#endif
if (encoder->frame_ms == 5) {
setup->enable_lpc_weighting = setup->total_bits < 240;
}
......@@ -493,11 +483,9 @@ LC3PLUS_Error update_enc_bitrate(LC3PLUS_Enc* encoder, int bitrate)
if (encoder->frame_ms == 5) {
bitsTmp = bitsTmp * 2 - 160;
}
#ifdef CR8_G_ADD_75MS
if (encoder->frame_ms == 7.5) {
bitsTmp = round(bitsTmp * 10 / 7.5);
}
#endif
if (bitsTmp < 400 + (encoder->fs_idx - 1) * 80) {
setup->ltpf_enable = 1;
......@@ -526,14 +514,12 @@ LC3PLUS_Error update_enc_bitrate(LC3PLUS_Enc* encoder, int bitrate)
encoder->sns_damping = 6881.0/32768.0;
}
}
#ifdef CR8_G_ADD_75MS
if (encoder->frame_ms == 7.5)
{
if (setup->total_bits > 3*4400/4) {
encoder->sns_damping = 5898.0/32768.0;
}
}
#endif
if (encoder->frame_ms == 5)
{
if (setup->total_bits > 4600/2) {
......@@ -560,12 +546,10 @@ LC3PLUS_Error update_enc_bitrate(LC3PLUS_Enc* encoder, int bitrate)
{
setup->regBits +=2;
}
#ifdef CR8_G_ADD_75MS
if (encoder->frame_ms == 7.5)
{
setup->regBits +=1;
}
#endif
if (encoder->frame_ms == 2.5)
{
setup->regBits -= 6;
......@@ -581,12 +565,10 @@ LC3PLUS_Error update_enc_bitrate(LC3PLUS_Enc* encoder, int bitrate)
{
setup->regBits += 0;
}
#ifdef CR8_G_ADD_75MS
if (encoder->frame_ms == 7.5)
{
setup->regBits +=2;
}
#endif
if (encoder->frame_ms == 10)
{
setup->regBits += 5;
......@@ -623,11 +605,6 @@ void update_enc_bandwidth(LC3PLUS_Enc* encoder, int bandwidth)
{
encoder->bandwidth = bandwidth;
index = FS2FS_IDX(bandwidth);
#ifndef CR8_A_PLC_FADEOUT_TUNING
if (index > 4) {
index = 5;
}
#endif
encoder->bw_ctrl_cutoff_bin = encoder->cutoffBins[index];
}
}
/******************************************************************************
* 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. *
******************************************************************************/
#ifndef SETUP_ENC_LC3_FL_H
#define SETUP_ENC_LC3_FL_H
......@@ -24,11 +23,7 @@ typedef struct {
LC3_FLOAT attdec_acc_energy;
LC3_FLOAT r12k8_mem_50[2];
LC3_FLOAT r12k8_mem_in[120];
#ifdef CR8_G_ADD_75MS
LC3_FLOAT r12k8_mem_out[44];
#else
LC3_FLOAT r12k8_mem_out[24];
#endif
LC3_FLOAT olpa_mem_s12k8[3];
LC3_FLOAT olpa_mem_s6k4[LEN_6K4 + MAX_PITCH_6K4 + 16];
LC3_FLOAT ltpf_mem_in[LTPF_MEMIN_LEN + LEN_12K8 + 1];
......@@ -50,9 +45,7 @@ typedef struct {
LC3_INT tns_bits;
LC3_INT targetBitsQuant;
LC3_INT olpa_mem_pitch;
#ifdef CR9_F_PITCH_WIN_LEN_FIX
LC3_INT pitch_flag;
#endif
LC3_INT ltpf_mem_ltpf_on;
LC3_INT mem_targetBits;
LC3_INT mem_specBits;
......
/******************************************************************************
* ETSI TS 103 634 V1.4.3 *
* ETSI TS 103 634 V1.5.1 *
* Low Complexity Communication Codec Plus (LC3plus) *
* *
* Copyright licence is solely granted through ETSI Intellectual Property *
......@@ -7,7 +7,6 @@
* estoppel or otherwise. *
******************************************************************************/
#include "options.h"
#include "wmc_auto.h"
#include "functions.h"
......
/******************************************************************************
* ETSI TS 103 634 V1.4.3 *
* ETSI TS 103 634 V1.5.1 *
* Low Complexity Communication Codec Plus (LC3plus) *
* *
* Copyright licence is solely granted through ETSI Intellectual Property *
......@@ -7,7 +7,6 @@
* estoppel or otherwise. *
******************************************************************************/
#include "options.h"
#include "wmc_auto.h"
#include "functions.h"
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
/******************************************************************************
* ETSI TS 103 634 V1.4.3 *
* ETSI TS 103 634 V1.5.1 *
* Low Complexity Communication Codec Plus (LC3plus) *
* *
* Copyright licence is solely granted through ETSI Intellectual Property *
......@@ -7,7 +7,6 @@
* estoppel or otherwise. *
******************************************************************************/
#include "options.h"
#include "wmc_auto.h"
#include "functions.h"
......
/******************************************************************************
* 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. *
******************************************************************************/
#ifndef UTIL_H
#define UTIL_H
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.