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"
......
/******************************************************************************
* 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"
......
/******************************************************************************
* 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"
......@@ -507,17 +506,7 @@ void process_snsQuantizesScf_Dec(LC3_INT* scf_idx, LC3_FLOAT* scf_q)
/* Gain */
/* Add stage 1 and stage 2 */
#ifdef CR9_SIMPLIFY_LOOP
for (i = 0; i < M; i++) {
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) *
* *
* Copyright licence is solely granted through ETSI Intellectual Property *
......@@ -7,7 +7,6 @@
* estoppel or otherwise. *
******************************************************************************/
#ifndef STRUCTS_H
#define STRUCTS_H
......@@ -157,9 +156,7 @@ typedef struct {
LC3_INT32 PhECU_num_plocs;
HANDLE_IIS_FFT handle_fft_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*/
#endif
} PlcPhEcuSetup;
......@@ -187,11 +184,7 @@ typedef struct {
LC3_FLOAT scf_q_old_old[M];
PlcPhEcuSetup PlcPhEcuSetup;
#ifdef CR8_A_PLC_FADEOUT_TUNING
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_analysis_counter_max; /* Maximum longterm frames number */
LC3_INT16 longterm_analysis_counter_max_bytebuffer; /* Same as above but reduced for circular bit-buffer */
......@@ -202,7 +195,6 @@ typedef struct {
LC3_INT16 overall_counter;
LC3_INT8 longterm_counter_byte_position;
LC3_INT8 longterm_counter_bit_position;
#endif
} PlcAdvSetup;
#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,7 +7,6 @@
* estoppel or otherwise. *
******************************************************************************/
#include "options.h"
#include "wmc_auto.h"
#include "functions.h"
......@@ -193,12 +192,10 @@ void processTnsCoder_fl(LC3_FLOAT* x, LC3_INT bw_cutoff_idx, LC3_INT bw_fcbin, L
maxOrder = 4;
nSubdivisions = 2.0;
break;
#ifdef CR8_G_ADD_75MS
case 75:
maxOrder = 8;
nSubdivisions = 3;
break;
#endif
case 100:
maxOrder = 8;
nSubdivisions = 3.0;
......@@ -235,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_stopfreq = floor(subdiv_len * sub) + startfreq[f] - 1;
#ifdef CR8_G_ADD_75MS
if (fs == 32000 && frame_dms == 75)
{
if (subdiv_startfreq == 83)
......@@ -258,7 +254,6 @@ void processTnsCoder_fl(LC3_FLOAT* x, LC3_INT bw_cutoff_idx, LC3_INT bw_fcbin, L
subdiv_stopfreq = 159;
}
}
#endif
sum = 0;
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) *
* *
* 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
......
......@@ -39,6 +39,9 @@
#include "wmc_auto.h"
#include "ivas_rom_rend.h"
#include "ivas_rom_binaural_crend_head.h"
#ifdef FIX_989_TD_REND_ROM
#include <math.h>
#endif
#ifdef DEBUGGING
#include "debug.h"
#endif
......@@ -386,6 +389,9 @@ static ivas_error DefaultBSplineModel(
ModelParamsITD_t *modelITD;
int16_t i, j;
ivas_error error;
#ifdef FIX_989_TD_REND_ROM
float azimSegSamples;
#endif
HrFiltSet_p->FilterMethod = TDREND_HRFILT_Method_BSplineModel;
model = &( HrFiltSet_p->ModelParams );
......@@ -396,6 +402,15 @@ static ivas_error DefaultBSplineModel(
model->modelROM = TRUE;
/* int16_t parameters */
#ifdef FIX_989_TD_REND_ROM
model->UseItdModel = defaultHRIR_rom_model_configuration[0];
model->elevDim3 = defaultHRIR_rom_model_configuration[1];
model->AlphaN = defaultHRIR_rom_model_configuration[2];
model->num_unique_azim_splines = defaultHRIR_rom_model_configuration[3];
model->elevSegSamples = defaultHRIR_rom_model_configuration[4];
model->elevBsLen = defaultHRIR_rom_elevBsLen;
model->elevBsStart = defaultHRIR_rom_elevBsStart;
#else
model->UseItdModel = 1;
model->SplineDegree = 4;
model->elevDim2 = 17;
......@@ -413,6 +428,7 @@ static ivas_error DefaultBSplineModel(
model->elevBsStart[3] = 27;
model->azimDim2 = defaultHRIR_rom_azimDim2;
#endif
model->azimDim3 = defaultHRIR_rom_azimDim3;
model->azim_start_idx = defaultHRIR_rom_azim_start_idx;
model->azimSegSamples = defaultHRIR_rom_azimSegSamples;
......@@ -429,10 +445,36 @@ static ivas_error DefaultBSplineModel(
}
model->azimBsShape[0] = (const float *) defaultHRIR_rom_azimBsShape;
#ifdef FIX_989_TD_REND_ROM
if ( ( model->azimKSeq = (float **) malloc( model->elevDim3 * sizeof( float * ) ) ) == NULL )
#else
if ( ( model->azimKSeq = (float **) malloc( 18 * sizeof( float * ) ) ) == NULL )
#endif
{
return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Binaural TD renderer\n" ) );
}
#ifdef FIX_989_TD_REND_ROM
for ( i = 0; i < model->elevDim3; i++ )
{
if ( ( model->azimKSeq[i] = (float *) malloc( ( model->azimDim3[i] + 1 ) * sizeof( float * ) ) ) == NULL )
{
return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Binaural TD renderer\n" ) );
}
if ( model->azimShapeIdx[i] < 0 )
{
azimSegSamples = 360.0f;
}
else
{
azimSegSamples = defaultHRIR_rom_azimSegSamples[model->azimShapeIdx[i]];
}
assert( azimSegSamples == 360.0f / model->azimDim3[i] );
for ( j = 0; j < model->azimDim3[i] + 1; j++ )
{
model->azimKSeq[i][j] = azimSegSamples * j;
}
}
#else
if ( ( model->azimKSeq[0] = (float *) malloc( 2 * sizeof( float * ) ) ) == NULL )
{
return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Binaural TD renderer\n" ) );
......@@ -457,6 +499,7 @@ static ivas_error DefaultBSplineModel(
model->azimKSeq[i][j] = (float) defaultHRIR_rom_azimSegSamples[0] * j;
}
}
#endif
switch ( output_Fs )
{
......@@ -465,7 +508,11 @@ static ivas_error DefaultBSplineModel(
model->AlphaR = (const float *) defaultHRIR_rom_AlphaR48;
model->EL = (const float *) defaultHRIR_rom_EL48;
model->ER = (const float *) defaultHRIR_rom_ER48;
#ifdef FIX_989_TD_REND_ROM
model->K = defaultHRIR_rom_model_configuration[5];
#else
model->K = 128;
#endif
if ( HrFiltSet_p->ModelParams.UseItdModel )
{
modelITD->resamp_factor = 1.0f;
......@@ -476,7 +523,11 @@ static ivas_error DefaultBSplineModel(
model->AlphaR = (const float *) defaultHRIR_rom_AlphaR32;
model->EL = (const float *) defaultHRIR_rom_EL32;
model->ER = (const float *) defaultHRIR_rom_ER32;
#ifdef FIX_989_TD_REND_ROM
model->K = (int16_t) ceil( RESAMPLE_FACTOR_32_48 * defaultHRIR_rom_model_configuration[5] );
#else
model->K = 86;
#endif
if ( HrFiltSet_p->ModelParams.UseItdModel )
{
modelITD->resamp_factor = RESAMPLE_FACTOR_32_48;
......@@ -487,7 +538,11 @@ static ivas_error DefaultBSplineModel(
model->AlphaR = (const float *) defaultHRIR_rom_AlphaR16;
model->EL = (const float *) defaultHRIR_rom_EL16;
model->ER = (const float *) defaultHRIR_rom_ER16;
#ifdef FIX_989_TD_REND_ROM
model->K = (int16_t) ceil( RESAMPLE_FACTOR_16_48 * defaultHRIR_rom_model_configuration[5] );
#else
model->K = 43;
#endif
if ( HrFiltSet_p->ModelParams.UseItdModel )
{
modelITD->resamp_factor = RESAMPLE_FACTOR_16_48;
......@@ -497,6 +552,14 @@ static ivas_error DefaultBSplineModel(
break;
}
#ifdef FIX_989_TD_REND_ROM
modelITD->elevDim3 = defaultHRIR_rom_ITD_model_configuration[0];
modelITD->azimDim3 = defaultHRIR_rom_ITD_model_configuration[1];
modelITD->elevSegSamples = defaultHRIR_rom_ITD_model_configuration[2];
modelITD->azimSegSamples = defaultHRIR_rom_ITD_model_configuration[3];
modelITD->elevBsLen = defaultHRIR_rom_ITD_elevBsLen;
modelITD->elevBsStart = defaultHRIR_rom_ITD_elevBsStart;
#else
modelITD->N = 4;
modelITD->elevDim2 = 20;
modelITD->elevDim3 = 18;
......@@ -511,9 +574,14 @@ static ivas_error DefaultBSplineModel(
modelITD->elevBsStart[1] = 4;
modelITD->elevBsStart[2] = 11;
modelITD->elevBsStart[3] = 21;
#endif
modelITD->elevKSeq = defaultHRIR_rom_ITD_elevKSeq;
#ifdef FIX_989_TD_REND_ROM
modelITD->azimBsLen = defaultHRIR_rom_ITD_azimBsLen;
modelITD->azimBsStart = defaultHRIR_rom_ITD_azimBsStart;
#else
modelITD->azimBsLen[0] = 11;
modelITD->azimBsLen[1] = 21;
modelITD->azimBsLen[2] = 31;
......@@ -524,6 +592,7 @@ static ivas_error DefaultBSplineModel(
modelITD->azimBsStart[3] = 63;
modelITD->azimSegSamples = 10;
#endif
modelITD->azimKSeq = defaultHRIR_rom_ITD_azimKSeq;
modelITD->W = (const float *) defaultHRIR_rom_ITD_W;
......
......@@ -50,9 +50,26 @@
*------------------------------------------------------------------------*/
/* TD renderer default HRIR model */
const float defaultHRIR_rom_latency_s = 0.000020834f;
#ifdef FIX_989_TD_REND_ROM
const int16_t defaultHRIR_rom_model_configuration[6] = {
1, /* UseItdModel */
15, /* elevDim3 */
470, /* AlphaN */
1, /* num_unique_azim_splines */
4, /* elevSegSamples */
128, /* K_48k */
};
const int16_t defaultHRIR_rom_elevBsLen[4] = {
5, 9, 13, 9,
};
const int16_t defaultHRIR_rom_elevBsStart[4] = {
0, 5, 14, 27,
};
#else
const int16_t defaultHRIR_rom_azimDim2[15] = {
1, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 1,
};
#endif
const int16_t defaultHRIR_rom_azimDim3[15] = {
1, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 1,
};
......@@ -10139,6 +10156,26 @@ const uint32_t defaultHRIR_rom_ITD_W[658] = {
0x3c678a1c,0xbdeb0ba5,0xbe2218a5,0x3e58dcde,0x3d71aaa0,0xbef80fb9,0xbf3d07e1,0x3f3485be,0x3db783c0,0x3c142933,0xbed36b04,0xbb9f1f49,0x3ebfdc23,0xbcc7652e,0xbdb4e6cd,0xbf3be092,0x3f399c4e,0x3ef2eb6a,0xbd93a618,0xbe480d88,0x3e1bd187,0x3df79a5d,0xbc53f8d6,0xbf002186,0xbd41bc42,
0x3e5c0f28,0x3f2ad402,0xbf3cc2c3,0xbedc59d1,0xbe021816,0x3ea43429,0x3d349309,0xbab986b3,
};
#ifdef FIX_989_TD_REND_ROM
const int16_t defaultHRIR_rom_ITD_model_configuration[4] = {
18, /* elevDim3 */
41, /* azimDim3 */
3, /* elevSegSamples */
10, /* azimSegSamples */
};
const int16_t defaultHRIR_rom_ITD_elevBsLen[4] = {
4, 7, 10, 7,
};
const int16_t defaultHRIR_rom_ITD_elevBsStart[4] = {
0, 4, 11, 21,
};
const int16_t defaultHRIR_rom_ITD_azimBsLen[4] = {
11, 21, 31, 21,
};
const int16_t defaultHRIR_rom_ITD_azimBsStart[4] = {
0, 11, 32, 63,
};
#endif
const uint32_t defaultHRIR_rom_ITD_azimBsShape[84] = {
0x3f800000,0x3f3a9fbe,0x3f03126f,0x3eaf9db2,0x3e5d2f1b,0x3e000000,0x3d83126f,0x3cdd2f1b,0x3c03126f,0x3a83126f,0xa5800000,0x00000000,0x3e8374bc,0x3ede353f,0x3f0ad0e5,0x3f178d50,0x3f180000,0x3f0ed917,0x3efd9168,0x3ed4fdf4,0x3ea95810,0x3e800000,0x3e3a9fbe,0x3e03126f,0x3daf9db2,
0x3d5d2f1b,0x3d000000,0x3c83126f,0x3bdd2f1b,0x3b03126f,0x3983126f,0xa6000000,0x00000000,0x3c66bdc8,0x3d57b901,0x3de1cac1,0x3e39af72,0x3e855555,0x3eaf1aa0,0x3ed756b3,0x3efb38a9,0x3f0bf7cf,0x3f155555,0x3f18aec3,0x3f16872b,0x3f0fc3ed,0x3f054a69,0x3ef00000,0x3ed19423,0x3eb11bfd,
......@@ -47,7 +47,11 @@
*------------------------------------------------------------------------*/
/* TD renderer default HRIR model */
extern const float defaultHRIR_rom_latency_s;
#ifdef FIX_989_TD_REND_ROM
extern const int16_t defaultHRIR_rom_model_configuration[6];
#else
extern const int16_t defaultHRIR_rom_azimDim2[15];
#endif
extern const int16_t defaultHRIR_rom_azimDim3[15];
extern const int16_t defaultHRIR_rom_azim_start_idx[15];
extern const int16_t defaultHRIR_rom_azimSegSamples[1];
......@@ -66,6 +70,10 @@ extern const uint32_t defaultHRIR_rom_EL32[HRTF_MODEL_N_SECTIONS * 470];
extern const uint32_t defaultHRIR_rom_ER32[HRTF_MODEL_N_SECTIONS * 470];
extern const uint32_t defaultHRIR_rom_EL16[HRTF_MODEL_N_SECTIONS * 470];
extern const uint32_t defaultHRIR_rom_ER16[HRTF_MODEL_N_SECTIONS * 470];
#ifdef FIX_989_TD_REND_ROM
extern const int16_t defaultHRIR_rom_elevBsLen[4];
extern const int16_t defaultHRIR_rom_elevBsStart[4];
#endif
extern const uint32_t defaultHRIR_rom_elevBsShape[36];
extern const uint32_t defaultHRIR_rom_azimBsShape[21];
extern const uint32_t defaultHRIR_rom_ITD_W[658];
......@@ -73,4 +81,11 @@ extern const uint32_t defaultHRIR_rom_ITD_azimBsShape[84];
extern const float defaultHRIR_rom_ITD_azimKSeq[19];
extern const uint32_t defaultHRIR_rom_ITD_elevBsShape[28];
extern const float defaultHRIR_rom_ITD_elevKSeq[16];
#ifdef FIX_989_TD_REND_ROM
extern const int16_t defaultHRIR_rom_ITD_model_configuration[4];
extern const int16_t defaultHRIR_rom_ITD_elevBsLen[4];
extern const int16_t defaultHRIR_rom_ITD_elevBsStart[4];
extern const int16_t defaultHRIR_rom_ITD_azimBsLen[4];
extern const int16_t defaultHRIR_rom_ITD_azimBsStart[4];
#endif
#endif
......@@ -926,17 +926,26 @@ typedef struct
{
int16_t modelROM; /* Flag that indicates that the model resides in ROM (controls init/dealloc). */
int16_t UseItdModel; /* Controls whether ITD model is used. */
#ifdef FIX_989_TD_REND_ROM
int16_t K; /* Length of filter */
#else
int16_t SplineDegree; /* Degree of the spline functions */
int16_t K; /* Length of filter */
int16_t elevDim2;
#endif
int16_t elevDim3;
int16_t AlphaN; /* Number of rows in Alpha matrices */
int16_t num_unique_azim_splines;
int16_t elevSegSamples;
#ifdef FIX_989_TD_REND_ROM
const int16_t *elevBsLen;
const int16_t *elevBsStart;
#else
int16_t elevBsLen[HRTF_MODEL_BSPLINE_NUM_COEFFS];
int16_t elevBsStart[HRTF_MODEL_BSPLINE_NUM_COEFFS];
const int16_t *azimDim2;
#endif
const int16_t *azimDim3;
const int16_t *azim_start_idx;
const int16_t *azimSegSamples;
......@@ -963,7 +972,12 @@ typedef struct
float *ER_dyn;
float *elevBsShape_dyn;
float *elevKSeq_dyn;
#ifdef FIX_989_TD_REND_ROM
int16_t *elevBsLen_dyn;
int16_t *elevBsStart_dyn;
#else
int16_t *azimDim2_dyn;
#endif
int16_t *azimDim3_dyn;
int16_t *azim_start_idx_dyn;
int16_t *azimSegSamples_dyn;
......@@ -975,6 +989,13 @@ typedef struct
typedef struct
{
#ifdef FIX_989_TD_REND_ROM
int16_t elevDim3;
const float *elevKSeq; /* Array, length elevDim3-2 */
int16_t azimDim3;
const float *azimKSeq; /* Array, length azimDim3-2 */
const float *W; /* Array, size (elevDim3*azimDim3) x K */
#else
int16_t N; /* Polynomial degree */
int16_t elevDim2;
......@@ -984,14 +1005,25 @@ typedef struct
int16_t azimDim3;
const float *azimKSeq; /* Array, length azimDim3-2 */
const float *W; /* Array, size (elevDim3*azimDim3) x K */
#endif
#ifdef FIX_989_TD_REND_ROM
const int16_t *azimBsLen;
const int16_t *azimBsStart;
#else
int16_t azimBsLen[HRTF_MODEL_BSPLINE_NUM_COEFFS];
int16_t azimBsStart[HRTF_MODEL_BSPLINE_NUM_COEFFS];
#endif
const float *azimBsShape;
int16_t azimSegSamples;
#ifdef FIX_989_TD_REND_ROM
const int16_t *elevBsLen;
const int16_t *elevBsStart;
#else
int16_t elevBsLen[HRTF_MODEL_BSPLINE_NUM_COEFFS];
int16_t elevBsStart[HRTF_MODEL_BSPLINE_NUM_COEFFS];
#endif
const float *elevBsShape;
int16_t elevSegSamples;
float resamp_factor;
......@@ -1002,6 +1034,12 @@ typedef struct
float *W_dyn;
float *azimBsShape_dyn;
float *elevBsShape_dyn;
#ifdef FIX_989_TD_REND_ROM
int16_t *azimBsLen_dyn;
int16_t *azimBsStart_dyn;
int16_t *elevBsLen_dyn;
int16_t *elevBsStart_dyn;
#endif
} ModelParamsITD_t;
......
......@@ -4468,7 +4468,12 @@ int16_t IVAS_REND_FeedRenderConfig(
return error;
}
}
#ifdef SPLIT_REND_WITH_HEAD_ROT
if ( pIsmInput->crendWrapper != NULL && pIsmInput->crendWrapper->hCrend[0] != NULL )
#else
if ( pIsmInput->crendWrapper != NULL && pIsmInput->crendWrapper->hCrend != NULL )
#endif
{
#ifdef SPLIT_REND_WITH_HEAD_ROT
if ( ( error = ivas_reverb_open( &pIsmInput->crendWrapper->hCrend[0]->hReverb, hIvasRend->hHrtfs.hHrtfStatistics, hRenderConfig, *pIsmInput->base.ctx.pOutSampleRate ) ) != IVAS_ERR_OK )
......
......@@ -249,6 +249,15 @@ static void LoadBSplineBinaryITD(
)
{
int16_t tmp;
#ifdef FIX_989_TD_REND_ROM
fread( &modelITD->elevDim3, sizeof( int16_t ), 1, f_hrtf );
modelITD->elevKSeq_dyn = (float *) malloc( ( modelITD->elevDim3 - 2 ) * sizeof( float ) );
fread( modelITD->elevKSeq_dyn, sizeof( float ), modelITD->elevDim3 - 2, f_hrtf );
fread( &modelITD->azimDim3, sizeof( int16_t ), 1, f_hrtf );
modelITD->azimKSeq_dyn = (float *) malloc( ( ( modelITD->azimDim3 + 1 ) / 2 - 2 ) * sizeof( float ) ); /* basis functions are flipped around 180 deg, number of basis functions above/below is (N+1)/2 */
fread( modelITD->azimKSeq_dyn, sizeof( float ), ( modelITD->azimDim3 + 1 ) / 2 - 2, f_hrtf );
#else
fread( &modelITD->N, sizeof( int16_t ), 1, f_hrtf );
fread( &modelITD->elevDim2, sizeof( int16_t ), 1, f_hrtf );
fread( &modelITD->elevDim3, sizeof( int16_t ), 1, f_hrtf );
......@@ -259,14 +268,22 @@ static void LoadBSplineBinaryITD(
fread( &modelITD->azimDim3, sizeof( int16_t ), 1, f_hrtf );
modelITD->azimKSeq_dyn = (float *) malloc( ( ( modelITD->azimDim3 + 1 ) / 2 - 2 ) * sizeof( float ) ); /* basis functions are flipped around 180 deg, number of basis functions above/below is (N+1)/2 */
fread( modelITD->azimKSeq_dyn, sizeof( float ), ( modelITD->azimDim3 + 1 ) / 2 - 2, f_hrtf );
#endif
fread( &tmp, sizeof( int16_t ), 1, f_hrtf );
modelITD->W_dyn = (float *) malloc( tmp * sizeof( float ) );
fread( modelITD->W_dyn, sizeof( float ), tmp, f_hrtf );
/* azimuth */
#ifdef FIX_989_TD_REND_ROM
modelITD->azimBsLen_dyn = (int16_t *) malloc( HRTF_MODEL_BSPLINE_NUM_COEFFS * sizeof( int16_t ) );
fread( modelITD->azimBsLen_dyn, sizeof( int16_t ), HRTF_MODEL_BSPLINE_NUM_COEFFS, f_hrtf );
modelITD->azimBsStart_dyn = (int16_t *) malloc( HRTF_MODEL_BSPLINE_NUM_COEFFS * sizeof( int16_t ) );
fread( modelITD->azimBsStart_dyn, sizeof( int16_t ), HRTF_MODEL_BSPLINE_NUM_COEFFS, f_hrtf );
#else
fread( modelITD->azimBsLen, sizeof( int16_t ), HRTF_MODEL_BSPLINE_NUM_COEFFS, f_hrtf );
fread( modelITD->azimBsStart, sizeof( int16_t ), HRTF_MODEL_BSPLINE_NUM_COEFFS, f_hrtf );
#endif
fread( &tmp, sizeof( int16_t ), 1, f_hrtf );
......@@ -276,8 +293,15 @@ static void LoadBSplineBinaryITD(
fread( &modelITD->azimSegSamples, sizeof( int16_t ), 1, f_hrtf );
/* elevation */
#ifdef FIX_989_TD_REND_ROM
modelITD->elevBsLen_dyn = (int16_t *) malloc( HRTF_MODEL_BSPLINE_NUM_COEFFS * sizeof( int16_t ) );
fread( modelITD->elevBsLen_dyn, sizeof( int16_t ), HRTF_MODEL_BSPLINE_NUM_COEFFS, f_hrtf );
modelITD->elevBsStart_dyn = (int16_t *) malloc( HRTF_MODEL_BSPLINE_NUM_COEFFS * sizeof( int16_t ) );
fread( modelITD->elevBsStart_dyn, sizeof( int16_t ), HRTF_MODEL_BSPLINE_NUM_COEFFS, f_hrtf );
#else
fread( modelITD->elevBsLen, sizeof( int16_t ), HRTF_MODEL_BSPLINE_NUM_COEFFS, f_hrtf );
fread( modelITD->elevBsStart, sizeof( int16_t ), HRTF_MODEL_BSPLINE_NUM_COEFFS, f_hrtf );
#endif
fread( &tmp, sizeof( int16_t ), 1, f_hrtf );
......@@ -291,6 +315,12 @@ static void LoadBSplineBinaryITD(
modelITD->W = (const float *) modelITD->W_dyn;
modelITD->azimBsShape = (const float *) modelITD->azimBsShape_dyn;
modelITD->elevBsShape = (const float *) modelITD->elevBsShape_dyn;
#ifdef FIX_989_TD_REND_ROM
modelITD->azimBsLen = (const int16_t *) modelITD->azimBsLen_dyn;
modelITD->azimBsStart = (const int16_t *) modelITD->azimBsStart_dyn;
modelITD->elevBsLen = (const int16_t *) modelITD->elevBsLen_dyn;
modelITD->elevBsStart = (const int16_t *) modelITD->elevBsStart_dyn;
#endif
return;
}
......@@ -347,6 +377,12 @@ static ivas_error LoadBSplineBinary(
return IVAS_ERROR( IVAS_ERR_INVALID_HRTF, "Error: HR filter file had an unsupported sampling rate (%d kHz)", tmp );
}
#ifdef FIX_989_TD_REND_ROM
fread( &model->K, sizeof( int16_t ), 1, f_hrtf );
fread( &model->elevDim3, sizeof( int16_t ), 1, f_hrtf );
model->elevKSeq_dyn = (float *) malloc( ( model->elevDim3 - 2 ) * sizeof( float ) );
fread( model->elevKSeq_dyn, sizeof( float ), model->elevDim3 - 2, f_hrtf );
#else
fread( &model->SplineDegree, sizeof( int16_t ), 1, f_hrtf );
fread( &model->K, sizeof( int16_t ), 1, f_hrtf );
......@@ -355,12 +391,15 @@ static ivas_error LoadBSplineBinary(
model->elevKSeq_dyn = (float *) malloc( ( model->elevDim3 - 2 ) * sizeof( float ) );
fread( model->elevKSeq_dyn, sizeof( float ), model->elevDim3 - 2, f_hrtf );
model->azimDim2_dyn = (int16_t *) malloc( model->elevDim3 * sizeof( int16_t ) );
#endif
model->azimDim3_dyn = (int16_t *) malloc( model->elevDim3 * sizeof( int16_t ) );
model->azim_start_idx_dyn = (int16_t *) malloc( model->elevDim3 * sizeof( int16_t ) );
model->azimKSeq = (float **) malloc( model->elevDim3 * sizeof( float * ) );
for ( i = 0; i < model->elevDim3; i++ )
{
#ifndef FIX_989_TD_REND_ROM
fread( &model->azimDim2_dyn[i], sizeof( int16_t ), 1, f_hrtf );
#endif
fread( &model->azimDim3_dyn[i], sizeof( int16_t ), 1, f_hrtf );
fread( &model->azim_start_idx_dyn[i], sizeof( int16_t ), 1, f_hrtf );
model->azimKSeq[i] = (float *) malloc( ( model->azimDim3_dyn[i] + 1 ) * sizeof( float ) );
......@@ -393,8 +432,15 @@ static ivas_error LoadBSplineBinary(
fread( model->azimShapeSampFactor_dyn, sizeof( int16_t ), model->elevDim3, f_hrtf );
/* elevation */
#ifdef FIX_989_TD_REND_ROM
model->elevBsLen_dyn = (int16_t *) malloc( HRTF_MODEL_BSPLINE_NUM_COEFFS * sizeof( int16_t ) );
fread( model->elevBsLen_dyn, sizeof( int16_t ), HRTF_MODEL_BSPLINE_NUM_COEFFS, f_hrtf );
model->elevBsStart_dyn = (int16_t *) malloc( HRTF_MODEL_BSPLINE_NUM_COEFFS * sizeof( int16_t ) );
fread( model->elevBsStart_dyn, sizeof( int16_t ), HRTF_MODEL_BSPLINE_NUM_COEFFS, f_hrtf );
#else
fread( model->elevBsLen, sizeof( int16_t ), HRTF_MODEL_BSPLINE_NUM_COEFFS, f_hrtf );
fread( model->elevBsStart, sizeof( int16_t ), HRTF_MODEL_BSPLINE_NUM_COEFFS, f_hrtf );
#endif
fread( &tmp, sizeof( int16_t ), 1, f_hrtf );
model->elevBsShape_dyn = (float *) malloc( tmp * sizeof( float ) );
fread( model->elevBsShape_dyn, sizeof( float ), tmp, f_hrtf );
......@@ -406,9 +452,15 @@ static ivas_error LoadBSplineBinary(
model->AlphaR = (const float *) model->AlphaR_dyn;
model->EL = (const float *) model->EL_dyn;
model->ER = (const float *) model->ER_dyn;
#ifdef FIX_989_TD_REND_ROM
model->elevBsLen = (const int16_t *) model->elevBsLen_dyn;
model->elevBsStart = (const int16_t *) model->elevBsStart_dyn;
#endif
model->elevBsShape = (const float *) model->elevBsShape_dyn;
model->elevKSeq = (const float *) model->elevKSeq_dyn;
#ifndef FIX_989_TD_REND_ROM
model->azimDim2 = (const int16_t *) model->azimDim2_dyn;
#endif
model->azimDim3 = (const int16_t *) model->azimDim3_dyn;
model->azim_start_idx = (const int16_t *) model->azim_start_idx_dyn;
model->azimSegSamples = (const int16_t *) model->azimSegSamples_dyn;
......@@ -777,10 +829,18 @@ void destroy_td_hrtf(
free( ( *hHrtf )->ModelParamsITD.W_dyn );
free( ( *hHrtf )->ModelParamsITD.azimBsShape_dyn );
free( ( *hHrtf )->ModelParamsITD.elevBsShape_dyn );
#ifdef FIX_989_TD_REND_ROM
free( ( *hHrtf )->ModelParamsITD.azimBsLen_dyn );
free( ( *hHrtf )->ModelParamsITD.azimBsStart_dyn );
free( ( *hHrtf )->ModelParamsITD.elevBsLen_dyn );
free( ( *hHrtf )->ModelParamsITD.elevBsStart_dyn );
#endif
}
free( ( *hHrtf )->ModelParams.elevKSeq_dyn );
free( ( *hHrtf )->ModelParams.azim_start_idx_dyn );
#ifndef FIX_989_TD_REND_ROM
free( ( *hHrtf )->ModelParams.azimDim2_dyn );
#endif
free( ( *hHrtf )->ModelParams.azimDim3_dyn );
free( ( *hHrtf )->ModelParams.AlphaL_dyn );
free( ( *hHrtf )->ModelParams.AlphaR_dyn );
......@@ -788,6 +848,10 @@ void destroy_td_hrtf(
free( ( *hHrtf )->ModelParams.azimShapeIdx_dyn );
free( ( *hHrtf )->ModelParams.azimShapeSampFactor_dyn );
#ifdef FIX_989_TD_REND_ROM
free( ( *hHrtf )->ModelParams.elevBsLen_dyn );
free( ( *hHrtf )->ModelParams.elevBsStart_dyn );
#endif
free( ( *hHrtf )->ModelParams.elevBsShape_dyn );
for ( i = 0; i < ( *hHrtf )->ModelParams.num_unique_azim_splines; i++ )
......