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,8 +7,8 @@ ...@@ -7,8 +7,8 @@
* estoppel or otherwise. * * estoppel or otherwise. *
******************************************************************************/ ******************************************************************************/
#include "options.h" #include "options.h"
#include "wmc_auto.h"
#include "functions.h" #include "functions.h"
LC3_INT32 find_last_nz_pair(LC3_INT32 x[], LC3_INT32 length); LC3_INT32 find_last_nz_pair(LC3_INT32 x[], LC3_INT32 length);
...@@ -65,9 +65,7 @@ void processQuantizeSpec_fl(LC3_FLOAT x[], LC3_FLOAT gain, LC3_INT xq[], LC3_INT ...@@ -65,9 +65,7 @@ void processQuantizeSpec_fl(LC3_FLOAT x[], LC3_FLOAT gain, LC3_INT xq[], LC3_INT
LC3_INT lastnz = 1, nt_half; LC3_INT lastnz = 1, nt_half;
LC3_FLOAT offset = 0.375; LC3_FLOAT offset = 0.375;
LC3_INT32 bits, bits2; LC3_INT32 bits, bits2;
#ifdef CR9_QUANT_SPEC_REWRITE
LC3_FLOAT inv_gain; LC3_FLOAT inv_gain;
#endif
assert(target >= 0); assert(target >= 0);
...@@ -76,34 +74,22 @@ void processQuantizeSpec_fl(LC3_FLOAT x[], LC3_FLOAT gain, LC3_INT xq[], LC3_INT ...@@ -76,34 +74,22 @@ void processQuantizeSpec_fl(LC3_FLOAT x[], LC3_FLOAT gain, LC3_INT xq[], LC3_INT
nt_half = nt >> 1; nt_half = nt >> 1;
rateFlag = 0; c = 0; rateFlag = 0; c = 0;
if (hrmode) if (hrmode)
{ {
offset = 0.5; offset = 0.5;
} }
/* Quantization */ /* Quantization */
#ifdef CR9_QUANT_SPEC_REWRITE
inv_gain = 1.0 / gain; inv_gain = 1.0 / gain;
#endif
for (i = 0; i < nt; i++) { for (i = 0; i < nt; i++) {
if (x[i] > 0) if (x[i] > 0)
{ {
#ifdef CR9_QUANT_SPEC_REWRITE
xq[i] = (LC3_INT32) ( x[i] * inv_gain + offset); xq[i] = (LC3_INT32) ( x[i] * inv_gain + offset);
#else
xq[i] = (LC3_INT32) ( x[i] / gain + offset);
#endif
} }
else else
{ {
#ifdef CR9_QUANT_SPEC_REWRITE
xq[i] = -((LC3_INT32) (-x[i] * inv_gain + offset)); xq[i] = -((LC3_INT32) (-x[i] * inv_gain + offset));
#else
xq[i] = -((LC3_INT32) (-x[i] / gain + offset));
#endif
} }
if (hrmode == 0) { if (hrmode == 0) {
assert(xq[i] <= 32767 && xq[i] >= -32768); assert(xq[i] <= 32767 && xq[i] >= -32768);
......
/****************************************************************************** /******************************************************************************
* ETSI TS 103 634 V1.4.3 * * ETSI TS 103 634 V1.5.1 *
* Low Complexity Communication Codec Plus (LC3plus) * * 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,11 +7,10 @@ ...@@ -7,11 +7,10 @@
* estoppel or otherwise. * * estoppel or otherwise. *
******************************************************************************/ ******************************************************************************/
#include "options.h" #include "options.h"
#include "wmc_auto.h"
#include "functions.h" #include "functions.h"
void processReorderBitstream_fl(LC3_UINT8* bytes, LC3_INT32 n_pccw, LC3_INT32 n_pc, LC3_INT32 b_left, LC3_INT32 len) void processReorderBitstream_fl(LC3_UINT8* bytes, LC3_INT32 n_pccw, LC3_INT32 n_pc, LC3_INT32 b_left, LC3_INT32 len)
{ {
LC3_UINT8 bytes_local[MAX_NBYTES2]; LC3_UINT8 bytes_local[MAX_NBYTES2];
......
/****************************************************************************** /******************************************************************************
* ETSI TS 103 634 V1.4.3 * * ETSI TS 103 634 V1.5.1 *
* Low Complexity Communication Codec Plus (LC3plus) * * 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,8 +7,8 @@ ...@@ -7,8 +7,8 @@
* estoppel or otherwise. * * estoppel or otherwise. *
******************************************************************************/ ******************************************************************************/
#include "options.h" #include "options.h"
#include "wmc_auto.h"
#include "functions.h" #include "functions.h"
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[], 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[],
...@@ -31,11 +31,9 @@ void process_resamp12k8_fl(LC3_FLOAT x[], LC3_INT x_len, LC3_FLOAT mem_in[], LC3 ...@@ -31,11 +31,9 @@ void process_resamp12k8_fl(LC3_FLOAT x[], LC3_INT x_len, LC3_FLOAT mem_in[], LC3
case 50: case 50:
len_12k8 = LEN_12K8 / 2; len_12k8 = LEN_12K8 / 2;
break; break;
#ifdef CR8_G_ADD_75MS
case 75: case 75:
len_12k8 = (LEN_12K8 / 4) * 3; len_12k8 = (LEN_12K8 / 4) * 3;
break; break;
#endif
case 100: case 100:
len_12k8 = LEN_12K8; len_12k8 = LEN_12K8;
break; break;
......
/****************************************************************************** /******************************************************************************
* 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,8 +7,8 @@ ...@@ -7,8 +7,8 @@
* estoppel or otherwise. * * estoppel or otherwise. *
******************************************************************************/ ******************************************************************************/
#include "options.h" #include "options.h"
#include "wmc_auto.h"
#include "functions.h" #include "functions.h"
void processResidualCoding_fl(LC3_FLOAT x[], LC3_INT xq[], LC3_FLOAT gain, LC3_INT L_spec, LC3_INT targetBits, LC3_INT nBits, uint8_t* resBits, LC3_INT* numResBits void processResidualCoding_fl(LC3_FLOAT x[], LC3_INT xq[], LC3_FLOAT gain, LC3_INT L_spec, LC3_INT targetBits, LC3_INT nBits, uint8_t* resBits, LC3_INT* numResBits
......
/****************************************************************************** /******************************************************************************
* 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,8 +7,8 @@ ...@@ -7,8 +7,8 @@
* estoppel or otherwise. * * estoppel or otherwise. *
******************************************************************************/ ******************************************************************************/
#include "options.h" #include "options.h"
#include "wmc_auto.h"
#include "functions.h" #include "functions.h"
void processResidualDecoding_fl(LC3_INT* bitsRead, LC3_FLOAT x[], LC3_INT L_spec, uint8_t prm[], LC3_INT resQBits void processResidualDecoding_fl(LC3_INT* bitsRead, LC3_FLOAT x[], LC3_INT L_spec, uint8_t prm[], LC3_INT resQBits
......
/****************************************************************************** /******************************************************************************
* 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 *
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
******************************************************************************/ ******************************************************************************/
#include "options.h" #include "options.h"
#include "wmc_auto.h"
#include "functions.h" #include "functions.h"
LC3_FLOAT array_max_abs(LC3_FLOAT *in, LC3_INT32 len) LC3_FLOAT array_max_abs(LC3_FLOAT *in, LC3_INT32 len)
......
/****************************************************************************** /******************************************************************************
* 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,8 +7,8 @@ ...@@ -7,8 +7,8 @@
* estoppel or otherwise. * * estoppel or otherwise. *
******************************************************************************/ ******************************************************************************/
#include "options.h" #include "options.h"
#include "wmc_auto.h"
#include "setup_dec_lc3.h" #include "setup_dec_lc3.h"
#include "functions.h" #include "functions.h"
#include <stdio.h> #include <stdio.h>
...@@ -35,10 +35,8 @@ int alloc_decoder(LC3PLUS_Dec* decoder, int samplerate, int channels) ...@@ -35,10 +35,8 @@ int alloc_decoder(LC3PLUS_Dec* decoder, int samplerate, int channels)
HANDLE_IIS_FFT handle_ifft_phaseecu; HANDLE_IIS_FFT handle_ifft_phaseecu;
LC3_FLOAT *q_old_res; LC3_FLOAT *q_old_res;
#ifdef CR8_A_PLC_FADEOUT_TUNING
LC3_INT32 * plc_longterm_advc_tdc = NULL, *plc_longterm_advc_ns = NULL; 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; LC3_INT16 longterm_analysis_counter_max = 0, longterm_analysis_counter_max_bytebuffer = 0;
#endif
for (ch = 0; ch < channels; ch++) { for (ch = 0; ch < channels; ch++) {
DecSetup* setup = balloc(decoder, &size, sizeof(DecSetup)); DecSetup* setup = balloc(decoder, &size, sizeof(DecSetup));
...@@ -63,14 +61,11 @@ int alloc_decoder(LC3PLUS_Dec* decoder, int samplerate, int channels) ...@@ -63,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_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)); 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 = plc_fadeout_param_maxlen[0];
longterm_analysis_counter_max_bytebuffer = plc_fadeout_param_maxbytes[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_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); 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); q_old_res = balloc(decoder, &size, sizeof(LC3_FLOAT) * frame_len);
...@@ -95,13 +90,11 @@ int alloc_decoder(LC3PLUS_Dec* decoder, int samplerate, int channels) ...@@ -95,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_fft_phaseecu->sine_table = sine_table1_phecu;
setup->PlcAdvSetup->PlcPhEcuSetup.handle_ifft_phaseecu->sine_table = sine_table2_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 = longterm_analysis_counter_max;
setup->PlcAdvSetup->longterm_analysis_counter_max_bytebuffer = longterm_analysis_counter_max_bytebuffer; 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_tdc = plc_longterm_advc_tdc;
setup->PlcAdvSetup->plc_longterm_advc_ns = plc_longterm_advc_ns; setup->PlcAdvSetup->plc_longterm_advc_ns = plc_longterm_advc_ns;
#endif
setup->PlcAdvSetup->PlcPhEcuSetup.PhECU_Lprot = (CODEC_FS(samplerate) * 16) / 1000; 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)); real_fft_init(&(setup->PlcAdvSetup->PlcPhEcuSetup.PhEcu_Fft), setup->PlcAdvSetup->PlcPhEcuSetup.PhECU_Lprot, &(setup->PlcAdvSetup->PlcPhEcuSetup.handle_fft_phaseecu));
...@@ -127,11 +120,6 @@ LC3PLUS_Error FillDecSetup(LC3PLUS_Dec* decoder, int samplerate, int channels, L ...@@ -127,11 +120,6 @@ LC3PLUS_Error FillDecSetup(LC3PLUS_Dec* decoder, int samplerate, int channels, L
decoder->hrmode = hrmode != 0; decoder->hrmode = hrmode != 0;
#ifndef CR8_A_PLC_FADEOUT_TUNING
if (decoder->fs_idx > 4) {
decoder->fs_idx = 5;
}
#endif
decoder->channels = channels; decoder->channels = channels;
decoder->frame_ms = 10; decoder->frame_ms = 10;
decoder->frame_dms = 100; decoder->frame_dms = 100;
...@@ -163,6 +151,7 @@ LC3PLUS_Error FillDecSetup(LC3PLUS_Dec* decoder, int samplerate, int channels, L ...@@ -163,6 +151,7 @@ LC3PLUS_Error FillDecSetup(LC3PLUS_Dec* decoder, int samplerate, int channels, L
void set_dec_frame_params(LC3PLUS_Dec* decoder) void set_dec_frame_params(LC3PLUS_Dec* decoder)
{ {
int ch = 0; int ch = 0;
int n;
if (decoder->fs_idx == 5) if (decoder->fs_idx == 5)
{ {
...@@ -199,7 +188,6 @@ void set_dec_frame_params(LC3PLUS_Dec* decoder) ...@@ -199,7 +188,6 @@ void set_dec_frame_params(LC3PLUS_Dec* decoder)
decoder->yLen /= 2; decoder->yLen /= 2;
decoder->bands_number = bands_number_5ms[decoder->fs_idx]; decoder->bands_number = bands_number_5ms[decoder->fs_idx];
} }
#ifdef CR8_G_ADD_75MS
if (decoder->frame_ms == 7.5) if (decoder->frame_ms == 7.5)
{ {
decoder->frame_length = (decoder->frame_length >> 2) * 3; decoder->frame_length = (decoder->frame_length >> 2) * 3;
...@@ -213,7 +201,6 @@ void set_dec_frame_params(LC3PLUS_Dec* decoder) ...@@ -213,7 +201,6 @@ void set_dec_frame_params(LC3PLUS_Dec* decoder)
decoder->bands_number = bands_number_7_5ms[decoder->fs_idx]; decoder->bands_number = bands_number_7_5ms[decoder->fs_idx];
} }
} }
# endif
if (decoder->hrmode) if (decoder->hrmode)
{ {
...@@ -260,7 +247,6 @@ void set_dec_frame_params(LC3PLUS_Dec* decoder) ...@@ -260,7 +247,6 @@ void set_dec_frame_params(LC3PLUS_Dec* decoder)
} }
decoder->cutoffBins = BW_cutoff_bin_all_5ms; decoder->cutoffBins = BW_cutoff_bin_all_5ms;
} }
#ifdef CR8_G_ADD_75MS
else if (decoder->frame_ms == 7.5) else if (decoder->frame_ms == 7.5)
{ {
if (decoder->hrmode) if (decoder->hrmode)
...@@ -273,7 +259,6 @@ void set_dec_frame_params(LC3PLUS_Dec* decoder) ...@@ -273,7 +259,6 @@ void set_dec_frame_params(LC3PLUS_Dec* decoder)
} }
decoder->cutoffBins = BW_cutoff_bin_all_7_5ms; decoder->cutoffBins = BW_cutoff_bin_all_7_5ms;
} }
# endif
decoder->n_bandsPLC = MIN(decoder->frame_length, 80); decoder->n_bandsPLC = MIN(decoder->frame_length, 80);
...@@ -299,18 +284,15 @@ void set_dec_frame_params(LC3PLUS_Dec* decoder) ...@@ -299,18 +284,15 @@ void set_dec_frame_params(LC3PLUS_Dec* decoder)
decoder->n_bandsPLC = 60; decoder->n_bandsPLC = 60;
} }
} }
# ifdef CR8_G_ADD_75MS
else if (decoder->frame_ms == 7.5) else if (decoder->frame_ms == 7.5)
{ {
decoder->bands_offsetPLC = ACC_COEFF_PER_BAND_PLC_7_5ms[decoder->fs_idx]; decoder->bands_offsetPLC = ACC_COEFF_PER_BAND_PLC_7_5ms[decoder->fs_idx];
if (decoder->fs != 32000 && decoder->fs != 96000) if (decoder->fs != 32000 && decoder->fs != 96000)
if (decoder->fs != 32000)
{ {
decoder->n_bandsPLC = 60; decoder->n_bandsPLC = 60;
} }
} }
# endif
assert(decoder->bands_offsetPLC); assert(decoder->bands_offsetPLC);
...@@ -329,13 +311,11 @@ void set_dec_frame_params(LC3PLUS_Dec* decoder) ...@@ -329,13 +311,11 @@ void set_dec_frame_params(LC3PLUS_Dec* decoder)
decoder->imdct_laZeros = MDCT_la_zeroes_5ms[decoder->fs_idx]; decoder->imdct_laZeros = MDCT_la_zeroes_5ms[decoder->fs_idx];
decoder->imdct_winLen = MDCT_WINDOWS_LENGTHS_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) { else if (decoder->frame_ms == 7.5) {
decoder->imdct_win = MDCT_WINS_7_5ms[decoder->hrmode][decoder->fs_idx]; 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_laZeros = MDCT_la_zeroes_7_5ms[decoder->fs_idx];
decoder->imdct_winLen = MDCT_WINDOWS_LENGTHS_7_5ms[decoder->fs_idx]; decoder->imdct_winLen = MDCT_WINDOWS_LENGTHS_7_5ms[decoder->fs_idx];
} }
# endif
decoder->la_zeroes = decoder->imdct_laZeros; decoder->la_zeroes = decoder->imdct_laZeros;
...@@ -381,10 +361,8 @@ void set_dec_frame_params(LC3PLUS_Dec* decoder) ...@@ -381,10 +361,8 @@ void set_dec_frame_params(LC3PLUS_Dec* decoder)
setup->PlcAdvSetup->cum_fading_slow = 1; setup->PlcAdvSetup->cum_fading_slow = 1;
setup->PlcAdvSetup->cum_fflcAtten = 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 = 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]; 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) if (decoder->fs_idx <= 4 && decoder->frame_dms == 100)
{ {
...@@ -418,12 +396,13 @@ void set_dec_frame_params(LC3PLUS_Dec* decoder) ...@@ -418,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_short_flag_prev = 0; /* fullband transient */
setup->PlcAdvSetup->PlcPhEcuSetup.PhECU_num_plocs = 0; 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 */ 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) LC3PLUS_Error update_dec_bitrate(LC3PLUS_Dec* decoder, int ch, int nBytes)
...@@ -443,12 +422,10 @@ LC3PLUS_Error update_dec_bitrate(LC3PLUS_Dec* decoder, int ch, int nBytes) ...@@ -443,12 +422,10 @@ LC3PLUS_Error update_dec_bitrate(LC3PLUS_Dec* decoder, int ch, int nBytes)
maxBytes = 375; maxBytes = 375;
minBytes = MIN_NBYTES; minBytes = MIN_NBYTES;
break; break;
#ifdef CR8_G_ADD_75MS
case 75: case 75:
maxBytes = 625; maxBytes = 625;
minBytes = MIN_NBYTES; minBytes = MIN_NBYTES;
break; break;
#endif
case 100: case 100:
maxBytes = 625; maxBytes = 625;
minBytes = MIN_NBYTES; minBytes = MIN_NBYTES;
...@@ -460,7 +437,7 @@ LC3PLUS_Error update_dec_bitrate(LC3PLUS_Dec* decoder, int ch, int nBytes) ...@@ -460,7 +437,7 @@ LC3PLUS_Error update_dec_bitrate(LC3PLUS_Dec* decoder, int ch, int nBytes)
else else
{ {
minBytes = MIN_NBYTES; 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; channel_bytes = nBytes;
...@@ -493,12 +470,10 @@ LC3PLUS_Error update_dec_bitrate(LC3PLUS_Dec* decoder, int ch, int nBytes) ...@@ -493,12 +470,10 @@ LC3PLUS_Error update_dec_bitrate(LC3PLUS_Dec* decoder, int ch, int nBytes)
setup->enable_lpc_weighting = (setup->total_bits < 240); setup->enable_lpc_weighting = (setup->total_bits < 240);
totalBits = setup->total_bits * 2 - 160; totalBits = setup->total_bits * 2 - 160;
} }
# ifdef CR8_G_ADD_75MS
if (decoder->frame_ms == 7.5) { if (decoder->frame_ms == 7.5) {
setup->enable_lpc_weighting = (setup->total_bits < 360); setup->enable_lpc_weighting = (setup->total_bits < 360);
totalBits = round(setup->total_bits * 10 / 7.5); totalBits = round(setup->total_bits * 10 / 7.5);
} }
# endif
if (decoder->frame_length > 40 * ((LC3_FLOAT) (decoder->frame_dms) / 10.0)) { if (decoder->frame_length > 40 * ((LC3_FLOAT) (decoder->frame_dms) / 10.0)) {
setup->N_red_tns = 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) * * 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,11 +7,11 @@ ...@@ -7,11 +7,11 @@
* estoppel or otherwise. * * estoppel or otherwise. *
******************************************************************************/ ******************************************************************************/
#ifndef SETUP_DEC_LC3_FL_H #ifndef SETUP_DEC_LC3_FL_H
#define SETUP_DEC_LC3_FL_H #define SETUP_DEC_LC3_FL_H
#include "options.h" #include "options.h"
#include "wmc_auto.h"
#include "constants.h" #include "constants.h"
/* Channel state and bitrate-derived values go in this struct */ /* Channel state and bitrate-derived values go in this struct */
...@@ -50,10 +50,7 @@ typedef struct { ...@@ -50,10 +50,7 @@ typedef struct {
LC3_FLOAT x_fl[MAX_LEN]; LC3_FLOAT x_fl[MAX_LEN];
LC3_FLOAT imdct_mem[MAX_LEN]; LC3_FLOAT imdct_mem[MAX_LEN];
LC3_FLOAT alpha; LC3_FLOAT alpha;
#ifdef CR9_N_SHORT_FADE_FOR_UNSTABLE_PITCH
LC3_FLOAT rel_pitch_change; LC3_FLOAT rel_pitch_change;
#endif
Dct4 dct4structImdct; Dct4 dct4structImdct;
PlcSetup PlcSetup; PlcSetup PlcSetup;
...@@ -65,6 +62,7 @@ typedef struct { ...@@ -65,6 +62,7 @@ typedef struct {
/* Constants and sampling rate derived values go in this struct */ /* Constants and sampling rate derived values go in this struct */
struct LC3PLUS_Dec { struct LC3PLUS_Dec {
LC3_FLOAT alpha_type_2_table[PLC_FADEOUT_TYPE_1_IN_MS*10/25]; /* [80] */
DecSetup* channel_setup[MAX_CHANNELS]; DecSetup* channel_setup[MAX_CHANNELS];
const LC3_INT* W_fx; const LC3_INT* W_fx;
const LC3_INT* bands_offset; 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) * * 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,8 +7,8 @@ ...@@ -7,8 +7,8 @@
* estoppel or otherwise. * * estoppel or otherwise. *
******************************************************************************/ ******************************************************************************/
#include "options.h" #include "options.h"
#include "wmc_auto.h"
#include "setup_enc_lc3.h" #include "setup_enc_lc3.h"
#include "functions.h" #include "functions.h"
#include <stdio.h> #include <stdio.h>
...@@ -43,11 +43,9 @@ LC3PLUS_Error FillEncSetup(LC3PLUS_Enc* encoder, int samplerate, int channels ...@@ -43,11 +43,9 @@ LC3PLUS_Error FillEncSetup(LC3PLUS_Enc* encoder, int samplerate, int channels
encoder->fs_idx = FS2FS_IDX(encoder->fs); encoder->fs_idx = FS2FS_IDX(encoder->fs);
encoder->frame_dms = 100; encoder->frame_dms = 100;
#ifndef CR8_A_PLC_FADEOUT_TUNING
if (encoder->fs_idx > 4) { if (encoder->fs_idx > 4) {
encoder->fs_idx = 5; encoder->fs_idx = 5;
} }
#endif
encoder->hrmode = hrmode != 0; encoder->hrmode = hrmode != 0;
...@@ -61,10 +59,13 @@ LC3PLUS_Error FillEncSetup(LC3PLUS_Enc* encoder, int samplerate, int channels ...@@ -61,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_in_len = 2 * 8 * encoder->fs / 12800;
encoder->r12k8_mem_out_len = 24; encoder->r12k8_mem_out_len = 24;
if (lfe_channel_array != NULL)
{
for (ch = 0; ch < encoder->channels; ch++) for (ch = 0; ch < encoder->channels; ch++)
{ {
encoder->channel_setup[ch]->lfe = lfe_channel_array[ch] != 0; encoder->channel_setup[ch]->lfe = lfe_channel_array[ch] != 0;
} }
}
encoder->bw_ctrl_active = 0; encoder->bw_ctrl_active = 0;
encoder->bandwidth = encoder->fs / 2; encoder->bandwidth = encoder->fs / 2;
...@@ -144,7 +145,6 @@ void set_enc_frame_params(LC3PLUS_Enc* encoder) ...@@ -144,7 +145,6 @@ void set_enc_frame_params(LC3PLUS_Enc* encoder)
encoder->attdec_damping = 0.5; encoder->attdec_damping = 0.5;
encoder->attdec_hangover_thresh = 2; encoder->attdec_hangover_thresh = 2;
} }
#ifdef CR8_G_ADD_75MS
else if (encoder->frame_ms == 7.5) { else if (encoder->frame_ms == 7.5) {
if (encoder->hrmode) if (encoder->hrmode)
{ {
...@@ -176,7 +176,6 @@ void set_enc_frame_params(LC3PLUS_Enc* encoder) ...@@ -176,7 +176,6 @@ void set_enc_frame_params(LC3PLUS_Enc* encoder)
encoder->near_nyquist_index = encoder->bands_number - 4; 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); 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) { else if (encoder->frame_ms == 5) {
encoder->frame_length = encoder->frame_length >> 1; encoder->frame_length = encoder->frame_length >> 1;
encoder->yLen /= 2; encoder->yLen /= 2;
...@@ -227,9 +226,7 @@ void set_enc_frame_params(LC3PLUS_Enc* encoder) ...@@ -227,9 +226,7 @@ void set_enc_frame_params(LC3PLUS_Enc* encoder)
setup = encoder->channel_setup[ch]; setup = encoder->channel_setup[ch];
setup->olpa_mem_pitch = 17; setup->olpa_mem_pitch = 17;
#ifdef CR9_F_PITCH_WIN_LEN_FIX
setup->pitch_flag = 0; setup->pitch_flag = 0;
#endif
if (setup->mdctStruct.mem != NULL) { if (setup->mdctStruct.mem != NULL) {
mdct_free(&setup->mdctStruct); mdct_free(&setup->mdctStruct);
mdct_init(&setup->mdctStruct, encoder->frame_length, encoder->frame_dms, encoder->fs_idx, encoder->hrmode); mdct_init(&setup->mdctStruct, encoder->frame_length, encoder->frame_dms, encoder->fs_idx, encoder->hrmode);
...@@ -268,14 +265,12 @@ LC3PLUS_Error update_enc_bitrate(LC3PLUS_Enc* encoder, int bitrate) ...@@ -268,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 if (encoder->fs == 96000) {minBR = MIN_BR_50MS_96KHZ_HR;}
else { return LC3PLUS_HRMODE_ERROR;} else { return LC3PLUS_HRMODE_ERROR;}
break; break;
#ifdef CR8_G_ADD_75MS
case 75: case 75:
maxBR = 500000; maxBR = 500000;
if (encoder->fs == 48000) {minBR = MIN_BR_075DMS_48KHZ_HR;} if (encoder->fs == 48000) {minBR = MIN_BR_075DMS_48KHZ_HR;}
else if (encoder->fs == 96000) {minBR = MIN_BR_075DMS_96KHZ_HR;} else if (encoder->fs == 96000) {minBR = MIN_BR_075DMS_96KHZ_HR;}
else {return LC3PLUS_HRMODE_ERROR;} else {return LC3PLUS_HRMODE_ERROR;}
break; break;
#endif
case 100: case 100:
maxBR = 500000; maxBR = 500000;
if (encoder->fs == 48000) {minBR = MIN_BR_100MS_48KHZ_HR;} if (encoder->fs == 48000) {minBR = MIN_BR_100MS_48KHZ_HR;}
...@@ -308,7 +303,6 @@ LC3PLUS_Error update_enc_bitrate(LC3PLUS_Enc* encoder, int bitrate) ...@@ -308,7 +303,6 @@ LC3PLUS_Error update_enc_bitrate(LC3PLUS_Enc* encoder, int bitrate)
default: break; default: break;
} }
break; break;
#ifdef CR8_G_ADD_75MS
case 75: case 75:
minBR = MIN_BR_075DMS; minBR = MIN_BR_075DMS;
maxBR = MAX_BR_075DMS; maxBR = MAX_BR_075DMS;
...@@ -321,7 +315,6 @@ LC3PLUS_Error update_enc_bitrate(LC3PLUS_Enc* encoder, int bitrate) ...@@ -321,7 +315,6 @@ LC3PLUS_Error update_enc_bitrate(LC3PLUS_Enc* encoder, int bitrate)
default: break; default: break;
} }
break; break;
#endif
case 100: case 100:
/* have additional limitations for 10ms */ /* have additional limitations for 10ms */
minBR = MIN_BR_100DMS; minBR = MIN_BR_100DMS;
...@@ -442,11 +435,9 @@ LC3PLUS_Error update_enc_bitrate(LC3PLUS_Enc* encoder, int bitrate) ...@@ -442,11 +435,9 @@ LC3PLUS_Error update_enc_bitrate(LC3PLUS_Enc* encoder, int bitrate)
setup->targetBitsAri = setup->total_bits; setup->targetBitsAri = setup->total_bits;
setup->enable_lpc_weighting = setup->total_bits < 480; setup->enable_lpc_weighting = setup->total_bits < 480;
#ifdef CR8_G_ADD_75MS
if (encoder->frame_ms == 7.5) { if (encoder->frame_ms == 7.5) {
setup->enable_lpc_weighting = setup->total_bits < 360; setup->enable_lpc_weighting = setup->total_bits < 360;
} }
#endif
if (encoder->frame_ms == 5) { if (encoder->frame_ms == 5) {
setup->enable_lpc_weighting = setup->total_bits < 240; setup->enable_lpc_weighting = setup->total_bits < 240;
} }
...@@ -492,11 +483,9 @@ LC3PLUS_Error update_enc_bitrate(LC3PLUS_Enc* encoder, int bitrate) ...@@ -492,11 +483,9 @@ LC3PLUS_Error update_enc_bitrate(LC3PLUS_Enc* encoder, int bitrate)
if (encoder->frame_ms == 5) { if (encoder->frame_ms == 5) {
bitsTmp = bitsTmp * 2 - 160; bitsTmp = bitsTmp * 2 - 160;
} }
#ifdef CR8_G_ADD_75MS
if (encoder->frame_ms == 7.5) { if (encoder->frame_ms == 7.5) {
bitsTmp = round(bitsTmp * 10 / 7.5); bitsTmp = round(bitsTmp * 10 / 7.5);
} }
#endif
if (bitsTmp < 400 + (encoder->fs_idx - 1) * 80) { if (bitsTmp < 400 + (encoder->fs_idx - 1) * 80) {
setup->ltpf_enable = 1; setup->ltpf_enable = 1;
...@@ -525,14 +514,12 @@ LC3PLUS_Error update_enc_bitrate(LC3PLUS_Enc* encoder, int bitrate) ...@@ -525,14 +514,12 @@ LC3PLUS_Error update_enc_bitrate(LC3PLUS_Enc* encoder, int bitrate)
encoder->sns_damping = 6881.0/32768.0; encoder->sns_damping = 6881.0/32768.0;
} }
} }
#ifdef CR8_G_ADD_75MS
if (encoder->frame_ms == 7.5) if (encoder->frame_ms == 7.5)
{ {
if (setup->total_bits > 3*4400/4) { if (setup->total_bits > 3*4400/4) {
encoder->sns_damping = 5898.0/32768.0; encoder->sns_damping = 5898.0/32768.0;
} }
} }
#endif
if (encoder->frame_ms == 5) if (encoder->frame_ms == 5)
{ {
if (setup->total_bits > 4600/2) { if (setup->total_bits > 4600/2) {
...@@ -559,12 +546,10 @@ LC3PLUS_Error update_enc_bitrate(LC3PLUS_Enc* encoder, int bitrate) ...@@ -559,12 +546,10 @@ LC3PLUS_Error update_enc_bitrate(LC3PLUS_Enc* encoder, int bitrate)
{ {
setup->regBits +=2; setup->regBits +=2;
} }
#ifdef CR8_G_ADD_75MS
if (encoder->frame_ms == 7.5) if (encoder->frame_ms == 7.5)
{ {
setup->regBits +=1; setup->regBits +=1;
} }
#endif
if (encoder->frame_ms == 2.5) if (encoder->frame_ms == 2.5)
{ {
setup->regBits -= 6; setup->regBits -= 6;
...@@ -580,12 +565,10 @@ LC3PLUS_Error update_enc_bitrate(LC3PLUS_Enc* encoder, int bitrate) ...@@ -580,12 +565,10 @@ LC3PLUS_Error update_enc_bitrate(LC3PLUS_Enc* encoder, int bitrate)
{ {
setup->regBits += 0; setup->regBits += 0;
} }
#ifdef CR8_G_ADD_75MS
if (encoder->frame_ms == 7.5) if (encoder->frame_ms == 7.5)
{ {
setup->regBits +=2; setup->regBits +=2;
} }
#endif
if (encoder->frame_ms == 10) if (encoder->frame_ms == 10)
{ {
setup->regBits += 5; setup->regBits += 5;
...@@ -622,11 +605,6 @@ void update_enc_bandwidth(LC3PLUS_Enc* encoder, int bandwidth) ...@@ -622,11 +605,6 @@ void update_enc_bandwidth(LC3PLUS_Enc* encoder, int bandwidth)
{ {
encoder->bandwidth = bandwidth; encoder->bandwidth = bandwidth;
index = FS2FS_IDX(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]; 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) * * 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,11 +7,11 @@ ...@@ -7,11 +7,11 @@
* estoppel or otherwise. * * estoppel or otherwise. *
******************************************************************************/ ******************************************************************************/
#ifndef SETUP_ENC_LC3_FL_H #ifndef SETUP_ENC_LC3_FL_H
#define SETUP_ENC_LC3_FL_H #define SETUP_ENC_LC3_FL_H
#include "options.h" #include "options.h"
#include "wmc_auto.h"
#include "constants.h" #include "constants.h"
/* Channel state and bitrate-derived values go in this struct */ /* Channel state and bitrate-derived values go in this struct */
...@@ -23,11 +23,7 @@ typedef struct { ...@@ -23,11 +23,7 @@ typedef struct {
LC3_FLOAT attdec_acc_energy; LC3_FLOAT attdec_acc_energy;
LC3_FLOAT r12k8_mem_50[2]; LC3_FLOAT r12k8_mem_50[2];
LC3_FLOAT r12k8_mem_in[120]; LC3_FLOAT r12k8_mem_in[120];
#ifdef CR8_G_ADD_75MS
LC3_FLOAT r12k8_mem_out[44]; LC3_FLOAT r12k8_mem_out[44];
#else
LC3_FLOAT r12k8_mem_out[24];
#endif
LC3_FLOAT olpa_mem_s12k8[3]; LC3_FLOAT olpa_mem_s12k8[3];
LC3_FLOAT olpa_mem_s6k4[LEN_6K4 + MAX_PITCH_6K4 + 16]; LC3_FLOAT olpa_mem_s6k4[LEN_6K4 + MAX_PITCH_6K4 + 16];
LC3_FLOAT ltpf_mem_in[LTPF_MEMIN_LEN + LEN_12K8 + 1]; LC3_FLOAT ltpf_mem_in[LTPF_MEMIN_LEN + LEN_12K8 + 1];
...@@ -49,9 +45,7 @@ typedef struct { ...@@ -49,9 +45,7 @@ typedef struct {
LC3_INT tns_bits; LC3_INT tns_bits;
LC3_INT targetBitsQuant; LC3_INT targetBitsQuant;
LC3_INT olpa_mem_pitch; LC3_INT olpa_mem_pitch;
#ifdef CR9_F_PITCH_WIN_LEN_FIX
LC3_INT pitch_flag; LC3_INT pitch_flag;
#endif
LC3_INT ltpf_mem_ltpf_on; LC3_INT ltpf_mem_ltpf_on;
LC3_INT mem_targetBits; LC3_INT mem_targetBits;
LC3_INT mem_specBits; LC3_INT mem_specBits;
......
/****************************************************************************** /******************************************************************************
* 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,8 +7,8 @@ ...@@ -7,8 +7,8 @@
* estoppel or otherwise. * * estoppel or otherwise. *
******************************************************************************/ ******************************************************************************/
#include "options.h" #include "options.h"
#include "wmc_auto.h"
#include "functions.h" #include "functions.h"
void processSnsComputeScf_fl(LC3_FLOAT* x, LC3_INT xLen, LC3_FLOAT* gains, LC3_INT smooth, LC3_FLOAT sns_damping, LC3_FLOAT attdec_damping_factor, LC3_INT fs_idx) void processSnsComputeScf_fl(LC3_FLOAT* x, LC3_INT xLen, LC3_FLOAT* gains, LC3_INT smooth, LC3_FLOAT sns_damping, LC3_FLOAT attdec_damping_factor, LC3_INT fs_idx)
......
/****************************************************************************** /******************************************************************************
* 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,8 +7,8 @@ ...@@ -7,8 +7,8 @@
* estoppel or otherwise. * * estoppel or otherwise. *
******************************************************************************/ ******************************************************************************/
#include "options.h" #include "options.h"
#include "wmc_auto.h"
#include "functions.h" #include "functions.h"
void processSnsInterpolateScf_fl(LC3_FLOAT* gains, LC3_INT encoder_side, LC3_INT bands_number, LC3_FLOAT* gains_int) void processSnsInterpolateScf_fl(LC3_FLOAT* gains, LC3_INT encoder_side, LC3_INT bands_number, LC3_FLOAT* gains_int)
......
/****************************************************************************** /******************************************************************************
* 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,8 +7,8 @@ ...@@ -7,8 +7,8 @@
* estoppel or otherwise. * * estoppel or otherwise. *
******************************************************************************/ ******************************************************************************/
#include "options.h" #include "options.h"
#include "wmc_auto.h"
#include "functions.h" #include "functions.h"
static void pvq_dec(LC3_INT k, LC3_INT m, LC3_INT LS_ind, LC3_INT MPVQ_ind, LC3_INT* pulses); static void pvq_dec(LC3_INT k, LC3_INT m, LC3_INT LS_ind, LC3_INT MPVQ_ind, LC3_INT* pulses);
...@@ -506,17 +506,7 @@ void process_snsQuantizesScf_Dec(LC3_INT* scf_idx, LC3_FLOAT* scf_q) ...@@ -506,17 +506,7 @@ void process_snsQuantizesScf_Dec(LC3_INT* scf_idx, LC3_FLOAT* scf_q)
/* Gain */ /* Gain */
/* Add stage 1 and stage 2 */ /* Add stage 1 and stage 2 */
#ifdef CR9_SIMPLIFY_LOOP
for (i = 0; i < M; i++) { for (i = 0; i < M; i++) {
scf_q[i] += st2_vector_idct[i] * sns_dec_gains[submode][scf_idx[3]]; scf_q[i] += st2_vector_idct[i] * sns_dec_gains[submode][scf_idx[3]];
} }
#else
for (i = 0; i < M; i++) {
st2_vector_idct[i] = st2_vector_idct[i] * sns_dec_gains[submode][scf_idx[3]];
}
for (i = 0; i < M; i++) {
scf_q[i] = scf_q[i] + st2_vector_idct[i];
}
#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,11 +7,11 @@ ...@@ -7,11 +7,11 @@
* estoppel or otherwise. * * estoppel or otherwise. *
******************************************************************************/ ******************************************************************************/
#ifndef STRUCTS_H #ifndef STRUCTS_H
#define STRUCTS_H #define STRUCTS_H
#include "options.h" #include "options.h"
#include "wmc_auto.h"
#include "defines.h" #include "defines.h"
#include "fft/iisfft.h" #include "fft/iisfft.h"
...@@ -156,9 +156,7 @@ typedef struct { ...@@ -156,9 +156,7 @@ typedef struct {
LC3_INT32 PhECU_num_plocs; LC3_INT32 PhECU_num_plocs;
HANDLE_IIS_FFT handle_fft_phaseecu; HANDLE_IIS_FFT handle_fft_phaseecu;
HANDLE_IIS_FFT handle_ifft_phaseecu; HANDLE_IIS_FFT handle_ifft_phaseecu;
#ifdef CR8_A_PLC_FADEOUT_TUNING
LC3_INT16 PhECU_nonpure_tone_flag; /* BASOP Word16 PhECU_nonpure_tone_flag*/ LC3_INT16 PhECU_nonpure_tone_flag; /* BASOP Word16 PhECU_nonpure_tone_flag*/
#endif
} PlcPhEcuSetup; } PlcPhEcuSetup;
...@@ -186,11 +184,7 @@ typedef struct { ...@@ -186,11 +184,7 @@ typedef struct {
LC3_FLOAT scf_q_old_old[M]; LC3_FLOAT scf_q_old_old[M];
PlcPhEcuSetup PlcPhEcuSetup; PlcPhEcuSetup PlcPhEcuSetup;
#ifdef CR8_A_PLC_FADEOUT_TUNING
LC3_INT16 longterm_counter_plcTdc; LC3_INT16 longterm_counter_plcTdc;
# ifndef CR9_L_RETRAIN_FADEOUT_TYPE_CLASSIFIER
LC3_INT16 longterm_counter_plcPhaseEcu;
# endif
LC3_INT16 longterm_counter_plcNsAdv; LC3_INT16 longterm_counter_plcNsAdv;
LC3_INT16 longterm_analysis_counter_max; /* Maximum longterm frames number */ LC3_INT16 longterm_analysis_counter_max; /* Maximum longterm frames number */
LC3_INT16 longterm_analysis_counter_max_bytebuffer; /* Same as above but reduced for circular bit-buffer */ LC3_INT16 longterm_analysis_counter_max_bytebuffer; /* Same as above but reduced for circular bit-buffer */
...@@ -201,7 +195,6 @@ typedef struct { ...@@ -201,7 +195,6 @@ typedef struct {
LC3_INT16 overall_counter; LC3_INT16 overall_counter;
LC3_INT8 longterm_counter_byte_position; LC3_INT8 longterm_counter_byte_position;
LC3_INT8 longterm_counter_bit_position; LC3_INT8 longterm_counter_bit_position;
#endif
} PlcAdvSetup; } PlcAdvSetup;
#endif #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,8 +7,8 @@ ...@@ -7,8 +7,8 @@
* estoppel or otherwise. * * estoppel or otherwise. *
******************************************************************************/ ******************************************************************************/
#include "options.h" #include "options.h"
#include "wmc_auto.h"
#include "functions.h" #include "functions.h"
static void xcorr(LC3_FLOAT* in, LC3_FLOAT* out, LC3_INT lag, LC3_INT inLen); static void xcorr(LC3_FLOAT* in, LC3_FLOAT* out, LC3_INT lag, LC3_INT inLen);
...@@ -192,12 +192,10 @@ void processTnsCoder_fl(LC3_FLOAT* x, LC3_INT bw_cutoff_idx, LC3_INT bw_fcbin, L ...@@ -192,12 +192,10 @@ void processTnsCoder_fl(LC3_FLOAT* x, LC3_INT bw_cutoff_idx, LC3_INT bw_fcbin, L
maxOrder = 4; maxOrder = 4;
nSubdivisions = 2.0; nSubdivisions = 2.0;
break; break;
#ifdef CR8_G_ADD_75MS
case 75: case 75:
maxOrder = 8; maxOrder = 8;
nSubdivisions = 3; nSubdivisions = 3;
break; break;
#endif
case 100: case 100:
maxOrder = 8; maxOrder = 8;
nSubdivisions = 3.0; nSubdivisions = 3.0;
...@@ -234,7 +232,6 @@ void processTnsCoder_fl(LC3_FLOAT* x, LC3_INT bw_cutoff_idx, LC3_INT bw_fcbin, L ...@@ -234,7 +232,6 @@ void processTnsCoder_fl(LC3_FLOAT* x, LC3_INT bw_cutoff_idx, LC3_INT bw_fcbin, L
subdiv_startfreq = floor(subdiv_len * (sub - 1)) + startfreq[f] - 1; subdiv_startfreq = floor(subdiv_len * (sub - 1)) + startfreq[f] - 1;
subdiv_stopfreq = floor(subdiv_len * sub) + startfreq[f] - 1; subdiv_stopfreq = floor(subdiv_len * sub) + startfreq[f] - 1;
#ifdef CR8_G_ADD_75MS
if (fs == 32000 && frame_dms == 75) if (fs == 32000 && frame_dms == 75)
{ {
if (subdiv_startfreq == 83) if (subdiv_startfreq == 83)
...@@ -257,7 +254,6 @@ void processTnsCoder_fl(LC3_FLOAT* x, LC3_INT bw_cutoff_idx, LC3_INT bw_fcbin, L ...@@ -257,7 +254,6 @@ void processTnsCoder_fl(LC3_FLOAT* x, LC3_INT bw_cutoff_idx, LC3_INT bw_fcbin, L
subdiv_stopfreq = 159; subdiv_stopfreq = 159;
} }
} }
#endif
sum = 0; sum = 0;
for (i = subdiv_startfreq; i < subdiv_stopfreq; i++) { for (i = subdiv_startfreq; i < subdiv_stopfreq; 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,8 +7,8 @@ ...@@ -7,8 +7,8 @@
* estoppel or otherwise. * * estoppel or otherwise. *
******************************************************************************/ ******************************************************************************/
#include "options.h" #include "options.h"
#include "wmc_auto.h"
#include "functions.h" #include "functions.h"
void processTnsDecoder_fl(LC3_FLOAT* x, LC3_INT* rc_idx, LC3_INT* order, LC3_INT numfilters, LC3_INT bw_fcbin, LC3_INT N, LC3_INT fs) void processTnsDecoder_fl(LC3_FLOAT* x, LC3_INT* rc_idx, LC3_INT* order, LC3_INT numfilters, LC3_INT bw_fcbin, LC3_INT N, LC3_INT fs)
......
/****************************************************************************** /******************************************************************************
* 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,11 +7,11 @@ ...@@ -7,11 +7,11 @@
* estoppel or otherwise. * * estoppel or otherwise. *
******************************************************************************/ ******************************************************************************/
#ifndef UTIL_H #ifndef UTIL_H
#define UTIL_H #define UTIL_H
#include "options.h" #include "options.h"
#include "wmc_auto.h"
#include "clib.h" #include "clib.h"
#include "math.h" #include "math.h"
......
...@@ -2036,8 +2036,8 @@ ivas_error ivas_rend_crendProcessSplitBin( ...@@ -2036,8 +2036,8 @@ ivas_error ivas_rend_crendProcessSplitBin(
const AUDIO_CONFIG inConfig, const AUDIO_CONFIG inConfig,
const AUDIO_CONFIG outConfig, const AUDIO_CONFIG outConfig,
const MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, const MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData,
DECODER_CONFIG_HANDLE hDecoderConfig, const DECODER_CONFIG_HANDLE hDecoderConfig,
COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, const COMBINED_ORIENTATION_HANDLE hCombinedOrientationData,
const IVAS_OUTPUT_SETUP_HANDLE hIntSetup, const IVAS_OUTPUT_SETUP_HANDLE hIntSetup,
EFAP_HANDLE hEFAPdata, EFAP_HANDLE hEFAPdata,
float *output[], float *output[],
...@@ -2071,7 +2071,7 @@ ivas_error ivas_rend_crendProcessSplitBin( ...@@ -2071,7 +2071,7 @@ ivas_error ivas_rend_crendProcessSplitBin(
/* save current head positions */ /* save current head positions */
pCombinedOrientationDataLocal = hCombinedOrientationData; pCombinedOrientationDataLocal = hCombinedOrientationData;
combinedOrientationDataLocal = *pCombinedOrientationDataLocal; combinedOrientationDataLocal = *pCombinedOrientationDataLocal;
if ( pMultiBinPoseData->poseCorrectionMode == IVAS_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB ) if ( pMultiBinPoseData->poseCorrectionMode == ISAR_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB )
{ {
for ( sf = 1; sf < hCombinedOrientationData->num_subframes; ++sf ) for ( sf = 1; sf < hCombinedOrientationData->num_subframes; ++sf )
{ {
...@@ -2166,9 +2166,8 @@ ivas_error ivas_rend_crendProcessSplitBin( ...@@ -2166,9 +2166,8 @@ ivas_error ivas_rend_crendProcessSplitBin(
return IVAS_ERR_OK; return IVAS_ERR_OK;
} }
#endif
#ifdef SPLIT_REND_WITH_HEAD_ROT
/*-----------------------------------------------------------------------------------------* /*-----------------------------------------------------------------------------------------*
* Function ivas_rend_crend_ProcessSubframesSplitBin() * Function ivas_rend_crend_ProcessSubframesSplitBin()
* *
...@@ -2225,7 +2224,7 @@ ivas_error ivas_rend_crendProcessSubframesSplitBin( ...@@ -2225,7 +2224,7 @@ ivas_error ivas_rend_crendProcessSubframesSplitBin(
/* save current head positions */ /* save current head positions */
pCombinedOrientationDataLocal = hCombinedOrientationData; pCombinedOrientationDataLocal = hCombinedOrientationData;
combinedOrientationDataLocal = *pCombinedOrientationDataLocal; combinedOrientationDataLocal = *pCombinedOrientationDataLocal;
if ( pMultiBinPoseData->poseCorrectionMode == IVAS_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB ) if ( pMultiBinPoseData->poseCorrectionMode == ISAR_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB )
{ {
for ( sf = 1; sf < hCombinedOrientationData->num_subframes; ++sf ) for ( sf = 1; sf < hCombinedOrientationData->num_subframes; ++sf )
{ {
......
...@@ -99,8 +99,9 @@ static void ivas_dirac_dec_binaural_internal( Decoder_Struct *st_ivas, COMBINED_ ...@@ -99,8 +99,9 @@ static void ivas_dirac_dec_binaural_internal( Decoder_Struct *st_ivas, COMBINED_
static void ivas_dirac_dec_decorrelate_slot( DIRAC_DEC_BIN_HANDLE hDiracDecBin, const int16_t num_freq_bands, const int16_t slot, float inRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], float inIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], float decRe[][CLDFB_NO_CHANNELS_MAX], float decIm[][CLDFB_NO_CHANNELS_MAX] ); static void ivas_dirac_dec_decorrelate_slot( DIRAC_DEC_BIN_HANDLE hDiracDecBin, const int16_t num_freq_bands, const int16_t slot, float inRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], float inIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], float decRe[][CLDFB_NO_CHANNELS_MAX], float decIm[][CLDFB_NO_CHANNELS_MAX] );
#ifdef SPLIT_REND_WITH_HEAD_ROT #ifdef SPLIT_REND_WITH_HEAD_ROT
static void ivas_dirac_dec_binaural_formulate_input_covariance_matrices( DIRAC_DEC_BIN_HANDLE hDiracDecBin, SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, PARAMBIN_REND_CONFIG_HANDLE hConfig, float inRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], float inIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], const int16_t subframe, float *subFrameTotalEne, float *IIReneLimiter ); static void ivas_dirac_dec_binaural_formulate_input_covariance_matrices( DIRAC_DEC_BIN_HANDLE hDiracDecBin, const SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, const PARAMBIN_REND_CONFIG_HANDLE hConfig, float inRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], float inIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], const int16_t subframe, float *subFrameTotalEne, float *IIReneLimiter );
static void ivas_dirac_dec_binaural_formulate_target_covariance_matrices( DIRAC_DEC_BIN_HANDLE hDiracDecBin, SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, PARAMBIN_REND_CONFIG_HANDLE hConfig, float Rmat[3][3], const int16_t subframe, const int16_t isHeadtracked, const float *subFrameTotalEne, const float *IIReneLimiter, const MASA_ISM_DATA_HANDLE hMasaIsmData );
static void ivas_dirac_dec_binaural_formulate_target_covariance_matrices( DIRAC_DEC_BIN_HANDLE hDiracDecBin, const SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, const PARAMBIN_REND_CONFIG_HANDLE hConfig, float Rmat[3][3], const int16_t subframe, const int16_t isHeadtracked, const float *subFrameTotalEne, const float *IIReneLimiter, const MASA_ISM_DATA_HANDLE hMasaIsmData );
#else #else
static void ivas_dirac_dec_binaural_formulate_input_and_target_covariance_matrices( DIRAC_DEC_BIN_HANDLE hDiracDecBin, SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, PARAMBIN_REND_CONFIG_HANDLE hConfig, float inRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], float inIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], float Rmat[3][3], const int16_t subframe, const int16_t isHeadtracked, const MASA_ISM_DATA_HANDLE hMasaIsmData ); static void ivas_dirac_dec_binaural_formulate_input_and_target_covariance_matrices( DIRAC_DEC_BIN_HANDLE hDiracDecBin, SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, PARAMBIN_REND_CONFIG_HANDLE hConfig, float inRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], float inIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], float Rmat[3][3], const int16_t subframe, const int16_t isHeadtracked, const MASA_ISM_DATA_HANDLE hMasaIsmData );
#endif #endif
...@@ -153,9 +154,15 @@ ivas_error ivas_dirac_dec_init_binaural_data( ...@@ -153,9 +154,15 @@ ivas_error ivas_dirac_dec_init_binaural_data(
ivas_error error; ivas_error error;
float frequency_axis[CLDFB_NO_CHANNELS_MAX]; float frequency_axis[CLDFB_NO_CHANNELS_MAX];
#ifdef SPLIT_REND_WITH_HEAD_ROT #ifdef SPLIT_REND_WITH_HEAD_ROT
int16_t pos_idx; int16_t num_poses, pos_idx;
num_poses = 1;
if ( st_ivas->hSplitBinRend != NULL )
{
num_poses = st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses;
}
for ( pos_idx = 0; pos_idx < st_ivas->hSplitBinRend.splitrend.multiBinPoseData.num_poses; pos_idx++ ) for ( pos_idx = 0; pos_idx < num_poses; pos_idx++ )
{ {
hDiracDecBin = st_ivas->hDiracDecBin[pos_idx]; hDiracDecBin = st_ivas->hDiracDecBin[pos_idx];
#else #else
...@@ -801,7 +808,7 @@ static void ivas_dirac_dec_binaural_internal( ...@@ -801,7 +808,7 @@ static void ivas_dirac_dec_binaural_internal(
subFrameTotalEne, IIReneLimiter ); subFrameTotalEne, IIReneLimiter );
ivas_dirac_dec_binaural_formulate_target_covariance_matrices( hDiracDecBin, hSpatParamRendCom, &config_data, Rmat, subframe, ivas_dirac_dec_binaural_formulate_target_covariance_matrices( hDiracDecBin, hSpatParamRendCom, &config_data, Rmat, subframe,
hCombinedOrientationData && hCombinedOrientationData->enableCombinedOrientation[subframe] > 0, subFrameTotalEne, IIReneLimiter, st_ivas->hMasaIsmData ); hCombinedOrientationData && hCombinedOrientationData->enableCombinedOrientation[hCombinedOrientationData->subframe_idx] > 0, subFrameTotalEne, IIReneLimiter, st_ivas->hMasaIsmData );
#endif #endif
nchanSeparateChannels = 0; nchanSeparateChannels = 0;
...@@ -818,7 +825,11 @@ static void ivas_dirac_dec_binaural_internal( ...@@ -818,7 +825,11 @@ static void ivas_dirac_dec_binaural_internal(
hCombinedOrientationData && hCombinedOrientationData->enableCombinedOrientation[hCombinedOrientationData->subframe_idx] > 0, nchanSeparateChannels, st_ivas->hMasaIsmData ); hCombinedOrientationData && hCombinedOrientationData->enableCombinedOrientation[hCombinedOrientationData->subframe_idx] > 0, nchanSeparateChannels, st_ivas->hMasaIsmData );
#ifdef SPLIT_REND_WITH_HEAD_ROT #ifdef SPLIT_REND_WITH_HEAD_ROT
pMultiBinPoseData = &st_ivas->hSplitBinRend.splitrend.multiBinPoseData; pMultiBinPoseData = NULL;
if ( st_ivas->hSplitBinRend != NULL )
{
pMultiBinPoseData = &st_ivas->hSplitBinRend->splitrend.multiBinPoseData;
}
#ifdef SPLIT_REND_WITH_HEAD_ROT #ifdef SPLIT_REND_WITH_HEAD_ROT
if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM )
...@@ -832,10 +843,10 @@ static void ivas_dirac_dec_binaural_internal( ...@@ -832,10 +843,10 @@ static void ivas_dirac_dec_binaural_internal(
for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ )
{ {
for ( i = 0; i < CLDFB_SLOTS_PER_SUBFRAME; i++ ) for ( i = 0; i < hSpatParamRendCom->subframe_nbslots[subframe]; i++ )
{ {
mvr2r( tmp_Cldfb_out_re[ch][i], st_ivas->hSplitBinRend.hMultiBinCldfbData->Cldfb_RealBuffer_Binaural[ch][subframe * CLDFB_SLOTS_PER_SUBFRAME + i], CLDFB_NO_CHANNELS_MAX ); mvr2r( tmp_Cldfb_out_re[ch][i], st_ivas->hSplitBinRend->hMultiBinCldfbData->Cldfb_RealBuffer_Binaural[ch][hSpatParamRendCom->slots_rendered + i], CLDFB_NO_CHANNELS_MAX );
mvr2r( tmp_Cldfb_out_im[ch][i], st_ivas->hSplitBinRend.hMultiBinCldfbData->Cldfb_ImagBuffer_Binaural[ch][subframe * CLDFB_SLOTS_PER_SUBFRAME + i], CLDFB_NO_CHANNELS_MAX ); mvr2r( tmp_Cldfb_out_im[ch][i], st_ivas->hSplitBinRend->hMultiBinCldfbData->Cldfb_ImagBuffer_Binaural[ch][hSpatParamRendCom->slots_rendered + i], CLDFB_NO_CHANNELS_MAX );
} }
} }
} }
...@@ -905,10 +916,10 @@ static void ivas_dirac_dec_binaural_internal( ...@@ -905,10 +916,10 @@ static void ivas_dirac_dec_binaural_internal(
/* copy from temporary buffer to the main split rendering buffer */ /* copy from temporary buffer to the main split rendering buffer */
for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ )
{ {
for ( i = 0; i < CLDFB_SLOTS_PER_SUBFRAME; i++ ) for ( i = 0; i < hSpatParamRendCom->subframe_nbslots[subframe]; i++ )
{ {
mvr2r( tmp_Cldfb_out_re[ch][i], st_ivas->hSplitBinRend.hMultiBinCldfbData->Cldfb_RealBuffer_Binaural[pos_idx * BINAURAL_CHANNELS + ch][subframe * CLDFB_SLOTS_PER_SUBFRAME + i], CLDFB_NO_CHANNELS_MAX ); mvr2r( tmp_Cldfb_out_re[ch][i], st_ivas->hSplitBinRend->hMultiBinCldfbData->Cldfb_RealBuffer_Binaural[pos_idx * BINAURAL_CHANNELS + ch][hSpatParamRendCom->slots_rendered + i], CLDFB_NO_CHANNELS_MAX );
mvr2r( tmp_Cldfb_out_im[ch][i], st_ivas->hSplitBinRend.hMultiBinCldfbData->Cldfb_ImagBuffer_Binaural[pos_idx * BINAURAL_CHANNELS + ch][subframe * CLDFB_SLOTS_PER_SUBFRAME + i], CLDFB_NO_CHANNELS_MAX ); mvr2r( tmp_Cldfb_out_im[ch][i], st_ivas->hSplitBinRend->hMultiBinCldfbData->Cldfb_ImagBuffer_Binaural[pos_idx * BINAURAL_CHANNELS + ch][hSpatParamRendCom->slots_rendered + i], CLDFB_NO_CHANNELS_MAX );
} }
} }
...@@ -984,8 +995,8 @@ static void ivas_dirac_dec_decorrelate_slot( ...@@ -984,8 +995,8 @@ static void ivas_dirac_dec_decorrelate_slot(
#ifdef SPLIT_REND_WITH_HEAD_ROT #ifdef SPLIT_REND_WITH_HEAD_ROT
static void ivas_dirac_dec_binaural_formulate_input_covariance_matrices( static void ivas_dirac_dec_binaural_formulate_input_covariance_matrices(
DIRAC_DEC_BIN_HANDLE hDiracDecBin, DIRAC_DEC_BIN_HANDLE hDiracDecBin,
SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, const SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom,
PARAMBIN_REND_CONFIG_HANDLE hConfig, const PARAMBIN_REND_CONFIG_HANDLE hConfig,
float inRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], float inRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX],
float inIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], float inIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX],
const int16_t subframe, const int16_t subframe,
...@@ -1148,8 +1159,8 @@ static void ivas_dirac_dec_binaural_formulate_input_covariance_matrices( ...@@ -1148,8 +1159,8 @@ static void ivas_dirac_dec_binaural_formulate_input_covariance_matrices(
static void ivas_dirac_dec_binaural_formulate_target_covariance_matrices( static void ivas_dirac_dec_binaural_formulate_target_covariance_matrices(
DIRAC_DEC_BIN_HANDLE hDiracDecBin, DIRAC_DEC_BIN_HANDLE hDiracDecBin,
SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, const SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom,
PARAMBIN_REND_CONFIG_HANDLE hConfig, const PARAMBIN_REND_CONFIG_HANDLE hConfig,
float Rmat[3][3], float Rmat[3][3],
const int16_t subframe, const int16_t subframe,
const int16_t isHeadtracked, const int16_t isHeadtracked,
...@@ -3373,10 +3384,11 @@ static void ivas_masa_ext_rend_parambin_internal( ...@@ -3373,10 +3384,11 @@ static void ivas_masa_ext_rend_parambin_internal(
const int16_t subframe, const int16_t subframe,
const SPLIT_REND_WRAPPER *hSplitRendWrapper, const SPLIT_REND_WRAPPER *hSplitRendWrapper,
float Cldfb_Out_Real[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], float Cldfb_Out_Real[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX],
float Cldfb_Out_Imag[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX] ) float Cldfb_Out_Imag[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]
#else #else
const int16_t subframe ) const int16_t subframe
#endif #endif
)
{ {
DIRAC_DEC_BIN_HANDLE hDiracDecBin; DIRAC_DEC_BIN_HANDLE hDiracDecBin;
SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom; SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom;
...@@ -3619,10 +3631,11 @@ void ivas_masa_ext_rend_parambin_render( ...@@ -3619,10 +3631,11 @@ void ivas_masa_ext_rend_parambin_render(
const int16_t num_subframes, /* i : number of subframes to render */ const int16_t num_subframes, /* i : number of subframes to render */
const SPLIT_REND_WRAPPER *hSplitRendWrapper, /* i : split rendering orientation data */ const SPLIT_REND_WRAPPER *hSplitRendWrapper, /* i : split rendering orientation data */
float Cldfb_Out_Real[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* o : rendered orientations for split rend. real part of cldfb */ float Cldfb_Out_Real[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* o : rendered orientations for split rend. real part of cldfb */
float Cldfb_Out_Imag[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX] ) /* o : rendered orientations for split rend. imag part of cldfb */ float Cldfb_Out_Imag[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX] /* o : rendered orientations for split rend. imag part of cldfb */
#else #else
const int16_t num_subframes ) /* i : number of subframes to render */ const int16_t num_subframes /* i : number of subframes to render */
#endif #endif
)
{ {
int16_t subframe; int16_t subframe;
SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom; SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom;
......
...@@ -36,9 +36,6 @@ ...@@ -36,9 +36,6 @@
#include "prot.h" #include "prot.h"
#include "ivas_prot.h" #include "ivas_prot.h"
#include "ivas_prot_rend.h" #include "ivas_prot_rend.h"
#ifdef SPLIT_REND_WITH_HEAD_ROT
#include "ivas_prot.h"
#endif
#include <math.h> #include <math.h>
#include "ivas_rom_com.h" #include "ivas_rom_com.h"
#ifdef DEBUGGING #ifdef DEBUGGING
...@@ -69,6 +66,9 @@ ivas_error ivas_td_binaural_open_unwrap( ...@@ -69,6 +66,9 @@ ivas_error ivas_td_binaural_open_unwrap(
const IVAS_FORMAT ivas_format, /* i : IVAS format (ISM/MC) */ const IVAS_FORMAT ivas_format, /* i : IVAS format (ISM/MC) */
const AUDIO_CONFIG transport_config, /* i : Transport configuration */ const AUDIO_CONFIG transport_config, /* i : Transport configuration */
const float *directivity, /* i : Directivity pattern (used for ISM) */ const float *directivity, /* i : Directivity pattern (used for ISM) */
#ifdef CONF_DISTATT
const float *distAtt, /* i : Distance attenuation (used for ISM) */
#endif
const IVAS_OUTPUT_SETUP hTransSetup, /* i : Loudspeaker layout */ const IVAS_OUTPUT_SETUP hTransSetup, /* i : Loudspeaker layout */
BINAURAL_TD_OBJECT_RENDERER_HANDLE *hBinRendererTd, /* o : TD renderer handle */ BINAURAL_TD_OBJECT_RENDERER_HANDLE *hBinRendererTd, /* o : TD renderer handle */
int32_t *binaural_latency_ns /* i : Binauralization delay */ int32_t *binaural_latency_ns /* i : Binauralization delay */
...@@ -82,6 +82,9 @@ ivas_error ivas_td_binaural_open_unwrap( ...@@ -82,6 +82,9 @@ ivas_error ivas_td_binaural_open_unwrap(
float Pos[3]; float Pos[3];
float Dir[3]; float Dir[3];
TDREND_DirAtten_t *DirAtten_p; TDREND_DirAtten_t *DirAtten_p;
#ifdef CONF_DISTATT
TDREND_DistAtten_t DistAtten;
#endif
int16_t nchan_rend; int16_t nchan_rend;
ivas_error error; ivas_error error;
...@@ -187,6 +190,13 @@ ivas_error ivas_td_binaural_open_unwrap( ...@@ -187,6 +190,13 @@ ivas_error ivas_td_binaural_open_unwrap(
DirAtten_p->ConeOuterAngle = 360.0f; DirAtten_p->ConeOuterAngle = 360.0f;
DirAtten_p->ConeOuterGain = 1.0f; DirAtten_p->ConeOuterGain = 1.0f;
#ifdef CONF_DISTATT
DistAtten.DistAttenModel = TDREND_DIST_ATTEN_MODEL_INV_DIST_CLAMPED;
DistAtten.MaxDist = 15.75f;
DistAtten.RefDist = 1.0f;
DistAtten.RollOffFactor = 1.0f;
#endif
if ( ( error = TDREND_MIX_SRC_SetPos( pBinRendTd, nS, Pos ) ) != IVAS_ERR_OK ) if ( ( error = TDREND_MIX_SRC_SetPos( pBinRendTd, nS, Pos ) ) != IVAS_ERR_OK )
{ {
return error; return error;
...@@ -206,6 +216,12 @@ ivas_error ivas_td_binaural_open_unwrap( ...@@ -206,6 +216,12 @@ ivas_error ivas_td_binaural_open_unwrap(
{ {
return error; return error;
} }
#ifdef CONF_DISTATT
if ( ( error = TDREND_MIX_SRC_SetDistAtten( pBinRendTd, nS, &DistAtten ) ) != IVAS_ERR_OK )
{
return error;
}
#endif
} }
} }
...@@ -227,11 +243,32 @@ ivas_error ivas_td_binaural_open_unwrap( ...@@ -227,11 +243,32 @@ ivas_error ivas_td_binaural_open_unwrap(
DirAtten_p->ConeOuterAngle = directivity[nS * 3 + 1]; DirAtten_p->ConeOuterAngle = directivity[nS * 3 + 1];
DirAtten_p->ConeOuterGain = directivity[nS * 3 + 2]; DirAtten_p->ConeOuterGain = directivity[nS * 3 + 2];
} }
#ifdef CONF_DISTATT
if ( NULL == distAtt )
{
DistAtten.DistAttenModel = TDREND_DIST_ATTEN_MODEL_INV_DIST_CLAMPED;
DistAtten.MaxDist = 15.75f;
DistAtten.RefDist = 1.0f;
DistAtten.RollOffFactor = 1.0f;
}
else
{
DistAtten.DistAttenModel = TDREND_DIST_ATTEN_MODEL_INV_DIST_CLAMPED;
DistAtten.MaxDist = distAtt[0];
DistAtten.RefDist = distAtt[1];
DistAtten.RollOffFactor = distAtt[2];
}
#endif
if ( ( error = TDREND_MIX_SRC_SetDirAtten( pBinRendTd, nS, DirAtten_p ) ) != IVAS_ERR_OK ) if ( ( error = TDREND_MIX_SRC_SetDirAtten( pBinRendTd, nS, DirAtten_p ) ) != IVAS_ERR_OK )
{ {
return error; return error;
} }
#ifdef CONF_DISTATT
if ( ( error = TDREND_MIX_SRC_SetDistAtten( pBinRendTd, nS, &DistAtten ) ) != IVAS_ERR_OK )
{
return error;
}
#endif
} }
} }
...@@ -641,6 +678,9 @@ ivas_error ivas_td_binaural_open_ext( ...@@ -641,6 +678,9 @@ ivas_error ivas_td_binaural_open_ext(
IVAS_OUTPUT_SETUP hTransSetup; IVAS_OUTPUT_SETUP hTransSetup;
ivas_error error; ivas_error error;
#ifdef CONF_DISTATT
float *distAtt = NULL;
#endif
float *directivity = NULL; float *directivity = NULL;
if ( inConfig != IVAS_AUDIO_CONFIG_LS_CUSTOM ) if ( inConfig != IVAS_AUDIO_CONFIG_LS_CUSTOM )
...@@ -670,9 +710,16 @@ ivas_error ivas_td_binaural_open_ext( ...@@ -670,9 +710,16 @@ ivas_error ivas_td_binaural_open_ext(
if ( NULL != hRendCfg ) if ( NULL != hRendCfg )
{ {
directivity = hRendCfg->directivity; directivity = hRendCfg->directivity;
#ifdef CONF_DISTATT
distAtt = hRendCfg->distAtt;
#endif
} }
#ifdef CONF_DISTATT
return ivas_td_binaural_open_unwrap( pTDRend->hHrtfTD, outFs, nchan_transport, ivas_format, transport_config, directivity, distAtt, hTransSetup, &pTDRend->hBinRendererTd, &pTDRend->binaural_latency_ns );
#else
return ivas_td_binaural_open_unwrap( pTDRend->hHrtfTD, outFs, nchan_transport, ivas_format, transport_config, directivity, hTransSetup, &pTDRend->hBinRendererTd, &pTDRend->binaural_latency_ns ); return ivas_td_binaural_open_unwrap( pTDRend->hHrtfTD, outFs, nchan_transport, ivas_format, transport_config, directivity, hTransSetup, &pTDRend->hBinRendererTd, &pTDRend->binaural_latency_ns );
#endif
} }
...@@ -762,153 +809,6 @@ ivas_error ivas_td_binaural_renderer_ext( ...@@ -762,153 +809,6 @@ ivas_error ivas_td_binaural_renderer_ext(
} }
#ifdef SPLIT_REND_WITH_HEAD_ROT
/*---------------------------------------------------------------------*
* ObjRenderIvasFrame_splitBinaural()
*
* Render to multiple binaural pairs based on relative head positions for split rendering.
*---------------------------------------------------------------------*/
ivas_error ObjRenderIvasFrame_splitBinaural(
Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */
float *output[], /* i/o: SCE channels / Binaural synthesis */
const int16_t output_frame /* i : output frame length */
)
{
int16_t i;
float tmpProcessing[MAX_OUTPUT_CHANNELS][L_FRAME48k];
float tmpBinaural[MAX_HEAD_ROT_POSES * 2][L_FRAME48k];
float *p_tmpProcessing[MAX_OUTPUT_CHANNELS];
int16_t pos_idx;
IVAS_QUATERNION originalHeadRot[MAX_PARAM_SPATIAL_SUBFRAMES];
MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData;
BINAURAL_TD_OBJECT_RENDERER_HANDLE tmpTdRendHandle;
ivas_error error;
push_wmops( "ObjRenderIvasFrame_splitBinaural" );
pMultiBinPoseData = &st_ivas->hSplitBinRend.splitrend.multiBinPoseData;
/* If not yet allocated, open additional instances of TD renderer */
for ( i = 0; i < pMultiBinPoseData->num_poses - 1; ++i )
{
if ( st_ivas->hSplitBinRend.splitrend.hTdRendHandles[i] != NULL )
{
continue;
}
if ( ( error = ivas_td_binaural_open_unwrap( &st_ivas->hHrtfTD,
st_ivas->hDecoderConfig->output_Fs,
st_ivas->nchan_transport,
st_ivas->ivas_format,
st_ivas->transport_config,
st_ivas->hRenderConfig->directivity,
st_ivas->hTransSetup,
&st_ivas->hSplitBinRend.splitrend.hTdRendHandles[i],
&st_ivas->binaural_latency_ns ) ) != IVAS_ERR_OK )
{
return error;
}
}
/* Save current head positions */
for ( i = 0; i < st_ivas->hCombinedOrientationData->num_subframes; ++i )
{
originalHeadRot[i] = st_ivas->hCombinedOrientationData->Quaternions[i];
}
/* Copy input audio to a processing buffer. Cannot render in-place because binaurally rendered
* audio would overwrite original material, which is still needed for rendering next head pose. */
for ( i = 0; i < st_ivas->nchan_transport; ++i )
{
mvr2r( output[i], tmpProcessing[i], output_frame );
}
for ( pos_idx = 0; pos_idx < pMultiBinPoseData->num_poses; pos_idx++ )
{
/* Update head positions */
if ( pos_idx != 0 )
{
for ( i = 0; i < st_ivas->hCombinedOrientationData->num_subframes; ++i )
{
if ( originalHeadRot[i].w == -3.0f )
{
st_ivas->hCombinedOrientationData->Quaternions[i].w = -3.0f;
st_ivas->hCombinedOrientationData->Quaternions[i].x = originalHeadRot[i].x + pMultiBinPoseData->relative_head_poses[pos_idx][0];
st_ivas->hCombinedOrientationData->Quaternions[i].y = originalHeadRot[i].y + pMultiBinPoseData->relative_head_poses[pos_idx][1];
st_ivas->hCombinedOrientationData->Quaternions[i].z = originalHeadRot[i].z + pMultiBinPoseData->relative_head_poses[pos_idx][2];
}
else
{
st_ivas->hCombinedOrientationData->Quaternions[i].w = -3.0f;
Quat2EulerDegree( originalHeadRot[i], /* TODO tmu : fix bug with ordering*/
&st_ivas->hCombinedOrientationData->Quaternions[i].z,
&st_ivas->hCombinedOrientationData->Quaternions[i].y,
&st_ivas->hCombinedOrientationData->Quaternions[i].x );
st_ivas->hCombinedOrientationData->Quaternions[i].x += pMultiBinPoseData->relative_head_poses[pos_idx][0];
st_ivas->hCombinedOrientationData->Quaternions[i].y += pMultiBinPoseData->relative_head_poses[pos_idx][1];
st_ivas->hCombinedOrientationData->Quaternions[i].z += pMultiBinPoseData->relative_head_poses[pos_idx][2];
}
}
}
/* Handle the 1 ISM case where there is only one channel in the input buffer */
for ( i = 0; i < max( st_ivas->nchan_transport, BINAURAL_CHANNELS ); ++i )
{
p_tmpProcessing[i] = tmpProcessing[i];
}
/* Render */
if ( pos_idx == 0 )
{
if ( ( error = ivas_td_binaural_renderer_sf( st_ivas, p_tmpProcessing, output_frame ) ) != IVAS_ERR_OK )
{
return error;
}
}
else
{
/* Tmp swap renderer handles for rendering call */
tmpTdRendHandle = st_ivas->hBinRendererTd;
st_ivas->hBinRendererTd = st_ivas->hSplitBinRend.splitrend.hTdRendHandles[pos_idx - 1];
if ( ( error = ivas_td_binaural_renderer_sf( st_ivas, p_tmpProcessing, output_frame ) ) != IVAS_ERR_OK )
{
return error;
}
st_ivas->hBinRendererTd = tmpTdRendHandle;
}
/* Copy rendered audio to tmp storage buffer. Copying directly to output would
* overwrite original audio, which is still needed for rendering next head pose. */
mvr2r( tmpProcessing[0], tmpBinaural[2 * pos_idx], output_frame );
mvr2r( tmpProcessing[1], tmpBinaural[2 * pos_idx + 1], output_frame );
/* Overwrite first 2 channels with original input audio again */
mvr2r( output[0], tmpProcessing[0], output_frame );
mvr2r( output[1], tmpProcessing[1], output_frame );
}
/* Copy from storage buffer to output */
for ( i = 0; i < pMultiBinPoseData->num_poses * BINAURAL_CHANNELS; ++i )
{
mvr2r( tmpBinaural[i], output[i], output_frame );
}
/* Restore original head rotation */
for ( i = 0; i < st_ivas->hCombinedOrientationData->num_subframes; ++i )
{
st_ivas->hCombinedOrientationData->Quaternions[i] = originalHeadRot[i];
}
pop_wmops();
return IVAS_ERR_OK;
}
#endif
/*---------------------------------------------------------------------* /*---------------------------------------------------------------------*
* angles_to_vec() * angles_to_vec()
* *
......