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"
void dct2_init(Dct2* dct, int length) void dct2_init(Dct2* dct, int length)
...@@ -55,8 +55,8 @@ void dct4_init(Dct4* dct, int length) ...@@ -55,8 +55,8 @@ void dct4_init(Dct4* dct, int length)
dct->twid1 = calloc(sizeof(*dct->twid1), length / 2); dct->twid1 = calloc(sizeof(*dct->twid1), length / 2);
dct->twid2 = calloc(sizeof(*dct->twid2), length / 2); dct->twid2 = calloc(sizeof(*dct->twid2), length / 2);
for (i = 0; i < length / 2; i++) { for (i = 0; i < length / 2; i++) {
dct->twid1[i] = cexpi(-(LC3_FLOAT)M_PI * (i + (LC3_FLOAT)0.25) / length); dct->twid1[i] = cexpi(-(LC3_FLOAT)M_PI_LC3PLUS * (i + (LC3_FLOAT)0.25) / length);
dct->twid2[i] = cexpi(-(LC3_FLOAT)M_PI * i / length); dct->twid2[i] = cexpi(-(LC3_FLOAT)M_PI_LC3PLUS * i / length);
} }
fft_init(&dct->fft, length / 2); fft_init(&dct->fft, length / 2);
} }
......
/****************************************************************************** /******************************************************************************
* 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 read_bit_fl(LC3_UINT8* ptr, LC3_INT* mask_side, LC3_INT* bp_side, LC3_INT* bit); static void read_bit_fl(LC3_UINT8* ptr, LC3_INT* mask_side, LC3_INT* bp_side, LC3_INT* bit);
......
/****************************************************************************** /******************************************************************************
* 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"
static int Dec_LC3PLUS_Channel_fl(LC3PLUS_Dec* decoder, int channel, uint8_t* bs_in, void* s_out, int bps, int bfi_ext) static int Dec_LC3PLUS_Channel_fl(LC3PLUS_Dec* decoder, int channel, uint8_t* bs_in, void* s_out, int bps, int bfi_ext)
{ {
DecSetup* h_DecSetup; DecSetup* h_DecSetup;
...@@ -64,11 +63,9 @@ static int Dec_LC3PLUS_Channel_fl(LC3PLUS_Dec* decoder, int channel, uint8_t* bs ...@@ -64,11 +63,9 @@ static int Dec_LC3PLUS_Channel_fl(LC3PLUS_Dec* decoder, int channel, uint8_t* bs
case 50: case 50:
max_bw_stopband = max_bw_stopband >> 1; max_bw_stopband = max_bw_stopband >> 1;
break; break;
# ifdef CR8_G_ADD_75MS
case 75: case 75:
max_bw_stopband = 3 * (max_bw_stopband >> 2); max_bw_stopband = 3 * (max_bw_stopband >> 2);
break; break;
# endif
case 100: case 100:
break; break;
} }
...@@ -148,9 +145,7 @@ static int Dec_LC3PLUS_Channel_fl(LC3PLUS_Dec* decoder, int channel, uint8_t* bs ...@@ -148,9 +145,7 @@ static int Dec_LC3PLUS_Channel_fl(LC3PLUS_Dec* decoder, int channel, uint8_t* bs
h_DecSetup->PlcSetup.q_d_prev, h_DecSetup->sqQdec_fl, h_DecSetup->spec_inv_idx, decoder->yLen, bfi, h_DecSetup->PlcSetup.q_d_prev, h_DecSetup->sqQdec_fl, h_DecSetup->spec_inv_idx, decoder->yLen, bfi,
decoder->frame_dms, h_DecSetup->concealMethod, h_DecSetup->ltpf_mem_pitch, h_DecSetup->ltpf_param[0], decoder->frame_dms, h_DecSetup->concealMethod, h_DecSetup->ltpf_mem_pitch, h_DecSetup->ltpf_param[0],
&h_DecSetup->PlcAdvSetup->cum_fflcAtten &h_DecSetup->PlcAdvSetup->cum_fflcAtten
#ifdef CR8_A_PLC_FADEOUT_TUNING
, h_DecSetup->PlcAdvSetup->plc_fadeout_type , h_DecSetup->PlcAdvSetup->plc_fadeout_type
#endif
); );
/* IMDCT */ /* IMDCT */
...@@ -171,9 +166,7 @@ static int Dec_LC3PLUS_Channel_fl(LC3PLUS_Dec* decoder, int channel, uint8_t* bs ...@@ -171,9 +166,7 @@ static int Dec_LC3PLUS_Channel_fl(LC3PLUS_Dec* decoder, int channel, uint8_t* bs
bfi, h_DecSetup->ltpf_param, h_DecSetup->ltpf_param_mem, h_DecSetup->ltpf_conf_beta_idx, bfi, h_DecSetup->ltpf_param, h_DecSetup->ltpf_param_mem, h_DecSetup->ltpf_conf_beta_idx,
h_DecSetup->ltpf_conf_beta, h_DecSetup->concealMethod, h_DecSetup->alpha h_DecSetup->ltpf_conf_beta, h_DecSetup->concealMethod, h_DecSetup->alpha
, &h_DecSetup->ltpf_mem_active , &h_DecSetup->ltpf_mem_active
#ifdef CR9_N_SHORT_FADE_FOR_UNSTABLE_PITCH
, &h_DecSetup->rel_pitch_change, decoder->hrmode, decoder->frame_dms , &h_DecSetup->rel_pitch_change, decoder->hrmode, decoder->frame_dms
#endif
); );
{ {
...@@ -243,9 +236,12 @@ LC3PLUS_Error Dec_LC3PLUS_fl(LC3PLUS_Dec* decoder, uint8_t* input, LC3_INT32 num ...@@ -243,9 +236,12 @@ LC3PLUS_Error Dec_LC3PLUS_fl(LC3PLUS_Dec* decoder, uint8_t* input, LC3_INT32 num
} }
bfi = Dec_LC3PLUS_Channel_fl(decoder, ch, input, output[ch], bps, bfi); bfi = Dec_LC3PLUS_Channel_fl(decoder, ch, input, output[ch], bps, bfi);
if (input != NULL)
{
input += decoder->channel_setup[ch]->targetBytes; input += decoder->channel_setup[ch]->targetBytes;
} }
} }
}
else else
{ {
decoder->epmr = LC3PLUS_EPMR_HIGH_NC; decoder->epmr = LC3PLUS_EPMR_HIGH_NC;
...@@ -274,7 +270,11 @@ LC3PLUS_Error Dec_LC3PLUS_fl(LC3PLUS_Dec* decoder, uint8_t* input, LC3_INT32 num ...@@ -274,7 +270,11 @@ LC3PLUS_Error Dec_LC3PLUS_fl(LC3PLUS_Dec* decoder, uint8_t* input, LC3_INT32 num
channel_bfi = 1; channel_bfi = 1;
} }
if (input != NULL)
{
input = input + np_zero; input = input + np_zero;
}
decoder->n_pc = MAX(decoder->n_pc - (2 * np_zero), 0); decoder->n_pc = MAX(decoder->n_pc - (2 * np_zero), 0);
if (channel_bfi == 2) if (channel_bfi == 2)
...@@ -312,8 +312,11 @@ LC3PLUS_Error Dec_LC3PLUS_fl(LC3PLUS_Dec* decoder, uint8_t* input, LC3_INT32 num ...@@ -312,8 +312,11 @@ LC3PLUS_Error Dec_LC3PLUS_fl(LC3PLUS_Dec* decoder, uint8_t* input, LC3_INT32 num
channel_bfi = Dec_LC3PLUS_Channel_fl(decoder, ch, input, output[ch], bps, channel_bfi); channel_bfi = Dec_LC3PLUS_Channel_fl(decoder, ch, input, output[ch], bps, channel_bfi);
out_bfi |= channel_bfi; out_bfi |= channel_bfi;
if (input != NULL)
{
input += fec_num_bytes; input += fec_num_bytes;
} }
}
bfi = out_bfi & 1; bfi = out_bfi & 1;
} }
...@@ -359,10 +362,16 @@ LC3PLUS_Error Dec_LC3PLUS_fl(LC3PLUS_Dec* decoder, uint8_t* input, LC3_INT32 num ...@@ -359,10 +362,16 @@ LC3PLUS_Error Dec_LC3PLUS_fl(LC3PLUS_Dec* decoder, uint8_t* input, LC3_INT32 num
} }
bfi = Dec_LC3PLUS_Channel_fl(decoder, ch, input, output[ch], bps, bfi); bfi = Dec_LC3PLUS_Channel_fl(decoder, ch, input, output[ch], bps, bfi);
if (input != NULL)
{
input += decoder->channel_setup[ch]->targetBytes; input += decoder->channel_setup[ch]->targetBytes;
} }
} }
}
if (decoder->last_error == LC3PLUS_OK && bfi) decoder->last_error = LC3PLUS_DECODE_ERROR; if ((decoder->last_error == LC3PLUS_OK) && bfi)
{
decoder->last_error = LC3PLUS_DECODE_ERROR;
}
return bfi == 1 ? LC3PLUS_DECODE_ERROR : LC3PLUS_OK; return bfi == 1 ? LC3PLUS_DECODE_ERROR : LC3PLUS_OK;
} }
/****************************************************************************** /******************************************************************************
* 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 DEFINES_H #ifndef DEFINES_H
#define DEFINES_H #define DEFINES_H
#include "options.h" #include "options.h"
#include "wmc_auto.h"
#include "stdint.h" #include "stdint.h"
...@@ -25,10 +25,6 @@ typedef int8_t LC3_INT8; ...@@ -25,10 +25,6 @@ typedef int8_t LC3_INT8;
typedef uint32_t LC3_UINT32; typedef uint32_t LC3_UINT32;
/* Release defines */ /* Release defines */
#define ENABLE_2_5MS_MODE
#define ENABLE_5MS_MODE
#define ENABLE_075_DMS_MODE
#define ENABLE_10_MS_MODE
#define ENABLE_ADVANCED_PLC_FL #define ENABLE_ADVANCED_PLC_FL
#define ENABLE_ADVANCED_PLC_FL_DEFAULT #define ENABLE_ADVANCED_PLC_FL_DEFAULT
#define ENABLE_BW_CONTROLLER #define ENABLE_BW_CONTROLLER
...@@ -43,41 +39,12 @@ typedef uint32_t LC3_UINT32; ...@@ -43,41 +39,12 @@ typedef uint32_t LC3_UINT32;
#define ENABLE_FRAME_MS_FLAG #define ENABLE_FRAME_MS_FLAG
#define ENABLE_HR_MODE_FL_FLAG #define ENABLE_HR_MODE_FL_FLAG
#define CR8_G_ADD_75MS
#ifndef NO_POST_REL_CHANGES #ifndef NO_POST_REL_CHANGES
/* Post-release non-bitexact changes */ /* Post-release non-bitexact changes */
#define CR8_A_PLC_FADEOUT_TUNING /* Adapt PLC fadeout to avoid gaps in signal */
#define CR9_D_FLOATING_POINT_CODE_SIMPLIFICATIONS
#define CR9_F_PITCH_WIN_LEN_FIX /* Increase window length for pitch calculation */
#define CR9_G_IMPROVE_TDC /* summarize G,H,J,L,N */
#ifdef CR9_G_IMPROVE_TDC
# define CR9_G_PLC_NS_TDC_FIX /* Always use TDC if pitch > 0 */
# define CR9_H_REMOVE_SWITCH_TO_PLC_NS
# define CR9_J_SLOW_TDC_FADEOUT
# define CR9_L_RETRAIN_FADEOUT_TYPE_CLASSIFIER
# ifdef ENABLE_HR_MODE_FL
# ifdef PLC_TUNING_SHORT_FADEOUT
# define CR9_N_SHORT_FADE_FOR_UNSTABLE_PITCH
# endif
# endif
#endif /* CR9_G_IMPROVE_TDC */
#define CR9_I_INC_TDC_FADEOUT_LEN
#define CR9_K_REDUCE_NORM_CORR_TH
#endif /* NO_POST_REL_CHANGES */ #endif /* NO_POST_REL_CHANGES */
#ifdef CR9_D_FLOATING_POINT_CODE_SIMPLIFICATIONS
# define CR9_SIMPLIFY_LOOP
# define CR9_LTPF_REWRITE
# define CR9_QUANT_SPEC_REWRITE
# define CR9_SIMPLIFY_ARI_DECODER
#endif
#ifdef CR8_A_PLC_FADEOUT_TUNING
#define MAX_UINT8 255 #define MAX_UINT8 255
# ifdef CR9_L_RETRAIN_FADEOUT_TYPE_CLASSIFIER
# ifdef CR9_K_REDUCE_NORM_CORR_TH
#define THRESH_100_DMS_TDC_CNT 9 #define THRESH_100_DMS_TDC_CNT 9
#define THRESH_100_DMS_NS_CNT 7 #define THRESH_100_DMS_NS_CNT 7
#define THRESH_100_DMS_TDC_NS_CNT 73 #define THRESH_100_DMS_TDC_NS_CNT 73
...@@ -90,33 +57,11 @@ typedef uint32_t LC3_UINT32; ...@@ -90,33 +57,11 @@ typedef uint32_t LC3_UINT32;
#define THRESH_025_DMS_TDC_CNT 20 #define THRESH_025_DMS_TDC_CNT 20
#define THRESH_025_DMS_NS_CNT 21 #define THRESH_025_DMS_NS_CNT 21
#define THRESH_025_DMS_TDC_NS_CNT 278 #define THRESH_025_DMS_TDC_NS_CNT 278
# else
# define THRESH_100_DMS_TDC_CNT 3
# define THRESH_100_DMS_NS_CNT 35
# define THRESH_100_DMS_TDC_NS_CNT 114
# define THRESH_075_DMS_TDC_CNT 6
# define THRESH_075_DMS_NS_CNT 37
# define THRESH_075_DMS_TDC_NS_CNT 130
# define THRESH_050_DMS_TDC_CNT 12
# define THRESH_050_DMS_NS_CNT 55
# define THRESH_050_DMS_TDC_NS_CNT 227
# define THRESH_025_DMS_TDC_CNT 10
# define THRESH_025_DMS_NS_CNT 138
# define THRESH_025_DMS_TDC_NS_CNT 431
# endif
# else
# define FAC1_FADEOUT 0.2
# define FAC2_FADEOUT 1.5
# define FAC3_FADEOUT 1.75
# endif
#define REL_PITCH_THRESH 0.36 #define REL_PITCH_THRESH 0.36
#define PLC_LONGTERM_ANALYSIS_MS 200 /* Analysis window 2000 ms / 10 ms */ #define PLC_LONGTERM_ANALYSIS_MS 200 /* Analysis window 2000 ms / 10 ms */
#define PLC_LONGTERM_ANALYSIS_STARTUP_FILL 0.5f /* required buffer fill amount, set to 0.0 to not require any fill at all */ #define PLC_LONGTERM_ANALYSIS_STARTUP_FILL 0.5f /* required buffer fill amount, set to 0.0 to not require any fill at all */
#endif
/* Precision Defines */ /* Precision Defines */
#define LC3_FABS(x) (fabsf(x)) #define LC3_FABS(x) (fabsf(x))
#define LC3_POW(x, y) (powf(x, y)) #define LC3_POW(x, y) (powf(x, y))
...@@ -136,7 +81,6 @@ typedef uint32_t LC3_UINT32; ...@@ -136,7 +81,6 @@ typedef uint32_t LC3_UINT32;
#define MAX_BR_100DMS_WB 221600 /* for 100ms at 16kHz */ #define MAX_BR_100DMS_WB 221600 /* for 100ms at 16kHz */
#define MAX_BR_100DMS_SSWB 314400 /* for 100ms at 24kHz */ #define MAX_BR_100DMS_SSWB 314400 /* for 100ms at 24kHz */
#ifdef CR8_G_ADD_75MS
#define MIN_BR_075DMS_48KHZ_HR ((int)124800/ 800/2)* 800 #define MIN_BR_075DMS_48KHZ_HR ((int)124800/ 800/2)* 800
#define MIN_BR_075DMS_96KHZ_HR ((int)149600/ 800/2)* 800 #define MIN_BR_075DMS_96KHZ_HR ((int)149600/ 800/2)* 800
#define MIN_BR_075DMS 21334 /* ceil( 20 * 800 * 100/ 75) */ #define MIN_BR_075DMS 21334 /* ceil( 20 * 800 * 100/ 75) */
...@@ -144,9 +88,6 @@ typedef uint32_t LC3_UINT32; ...@@ -144,9 +88,6 @@ typedef uint32_t LC3_UINT32;
#define MAX_BR_075DMS_NB 152534 /* ceil(143 * 800 * 100/ 75) */ #define MAX_BR_075DMS_NB 152534 /* ceil(143 * 800 * 100/ 75) */
#define MAX_BR_075DMS_WB 295467 /* ceil(277 * 800 * 100/ 75) */ #define MAX_BR_075DMS_WB 295467 /* ceil(277 * 800 * 100/ 75) */
#define MAX_BR_075DMS_SSWB 419200 /* ceil(393 * 800 * 100/ 75) */ #define MAX_BR_075DMS_SSWB 419200 /* ceil(393 * 800 * 100/ 75) */
#endif
# define CR8_E_TONE_DETECTOR /* Tone detector for hrmode to deactivate TNS - improves SNR and THD+N */
typedef int32_t LC3_INT32; typedef int32_t LC3_INT32;
#if defined(__xtensa__) #if defined(__xtensa__)
...@@ -157,11 +98,6 @@ typedef int32_t LC3_INT32; ...@@ -157,11 +98,6 @@ typedef int32_t LC3_INT32;
#define ALIGNMENT_BALLOC_RED 7 #define ALIGNMENT_BALLOC_RED 7
#endif #endif
#ifndef CR8_A_PLC_FADEOUT_TUNING
# define PLC2_FADEOUT_IN_MS 30
#endif
#ifdef CR8_A_PLC_FADEOUT_TUNING
/* PLC2/PhEcu fading settings */ /* PLC2/PhEcu fading settings */
/* PLC2/PHEcu muting Table setup settings */ /* PLC2/PHEcu muting Table setup settings */
#define PLC2_FADEOUT_IN_MS_MIN 30 /* Table min */ #define PLC2_FADEOUT_IN_MS_MIN 30 /* Table min */
...@@ -170,13 +106,8 @@ typedef int32_t LC3_INT32; ...@@ -170,13 +106,8 @@ typedef int32_t LC3_INT32;
/* current active settings */ /* current active settings */
#define PLC2_FADEOUT_IN_MS 30 /* 30 P800 fadeout optimized */ #define PLC2_FADEOUT_IN_MS 30 /* 30 P800 fadeout optimized */
#if 0
# define PLC2_FADEOUT_LONG_IN_MS 50 /* 50 ABBA test */
#endif
#define PLC2_FADEOUT_LONG_IN_MS 120 /* 120 MUSHRA, && stable tonal fadeout optimized */ #define PLC2_FADEOUT_LONG_IN_MS 120 /* 120 MUSHRA, && stable tonal fadeout optimized */
#endif
#define PHECU_FRES 62.5 #define PHECU_FRES 62.5
#define PHECU_C_JACOB 1.1429 #define PHECU_C_JACOB 1.1429
#define MAX_LGW 9 /* LGW48K + 1 !! */ #define MAX_LGW 9 /* LGW48K + 1 !! */
...@@ -208,16 +139,12 @@ typedef int32_t LC3_INT32; ...@@ -208,16 +139,12 @@ typedef int32_t LC3_INT32;
#define TDC_L_FIR_HP 11 #define TDC_L_FIR_HP 11
#define PLC3_HPBLENDTHROTTLE 30 /* higher numbers increase throttled blending from hp filtered to unfiltered uv excitation (0 is no throttle) */ #define PLC3_HPBLENDTHROTTLE 30 /* higher numbers increase throttled blending from hp filtered to unfiltered uv excitation (0 is no throttle) */
#ifdef CR9_I_INC_TDC_FADEOUT_LEN
#define PLC_FADEOUT_TYPE_1_IN_MS 200 #define PLC_FADEOUT_TYPE_1_IN_MS 200
#endif
#define PLC_FADEOUT_IN_MS 60 /* fade-out to zero in ms for TD-PLC and NS, minimum value is 20 */ #define PLC_FADEOUT_IN_MS 60 /* fade-out to zero in ms for TD-PLC and NS, minimum value is 20 */
#define PLC4_TRANSIT_START_IN_MS 20 /* begin of transition time for noise substitution for voiced signals */ #define PLC4_TRANSIT_START_IN_MS 20 /* begin of transition time for noise substitution for voiced signals */
#define PLC4_TRANSIT_END_IN_MS PLC_FADEOUT_IN_MS /* end of transition time for noise substitution */ #define PLC4_TRANSIT_END_IN_MS PLC_FADEOUT_IN_MS /* end of transition time for noise substitution */
#define PLC34_ATTEN_FAC_100 0.5000 /* attenuation factor for NS and TDC @ 10 ms*/ #define PLC34_ATTEN_FAC_100 0.5000 /* attenuation factor for NS and TDC @ 10 ms*/
#ifdef CR8_G_ADD_75MS
#define PLC34_ATTEN_FAC_075 0.5946 /* attenuation factor for NS and TDC @ 7.5 ms */ #define PLC34_ATTEN_FAC_075 0.5946 /* attenuation factor for NS and TDC @ 7.5 ms */
#endif
#define PLC34_ATTEN_FAC_050 0.7071 /* attenuation factor for NS and TDC @ 5.0 ms*/ #define PLC34_ATTEN_FAC_050 0.7071 /* attenuation factor for NS and TDC @ 5.0 ms*/
#define PLC34_ATTEN_FAC_025 0.8409 /* attenuation factor for NS and TDC @ 2.5 ms*/ #define PLC34_ATTEN_FAC_025 0.8409 /* attenuation factor for NS and TDC @ 2.5 ms*/
...@@ -248,21 +175,13 @@ typedef int32_t LC3_INT32; ...@@ -248,21 +175,13 @@ typedef int32_t LC3_INT32;
#define LC3_EPS (1.1e-7f) #define LC3_EPS (1.1e-7f)
#define M_PI 3.14159265358979323846 #define M_PI_LC3PLUS 3.14159265358979323846
/* FUNCTION MACROS */ /* FUNCTION MACROS */
#define CEILING(x, y) (((x) + (y)-1) / (y)) #define CEILING(x, y) (((x) + (y)-1) / (y))
#ifdef CR8_A_PLC_FADEOUT_TUNING
#define FRAME2FS_IDX_10MS(x) (x<500 ? (x/100) : 5) /* 80 -> 0, 160 -> 1, 240 -> 2, 320 -> 3, 480 -> 4 , 960 -> 5*/ #define FRAME2FS_IDX_10MS(x) (x<500 ? (x/100) : 5) /* 80 -> 0, 160 -> 1, 240 -> 2, 320 -> 3, 480 -> 4 , 960 -> 5*/
#define FS2FS_IDX(x) ((x) == 96000 ? 5 : (x) / 10000) /* 8000 -> 0, 16000 -> 1, 24000 -> 2, 32000 -> 3, 48000 -> 4, 96000 -> 5 */ #define FS2FS_IDX(x) ((x) == 96000 ? 5 : (x) / 10000) /* 8000 -> 0, 16000 -> 1, 24000 -> 2, 32000 -> 3, 48000 -> 4, 96000 -> 5 */
#else
#define FRAME2FS_IDX(x) (x / 100) /* 80 -> 0, 160 -> 1, 240 -> 2, 320 -> 3, 480 -> 4*/
#define FS2FS_IDX(x) \
(x / 10000) /* 8000 -> 0, 16000 -> 1, 24000 -> 2, 32000 -> 3, 48000 -> 4 \
*/
#endif
#define UNUSED(x) (void)(x) /* silence unused parameter warning */ #define UNUSED(x) (void)(x) /* silence unused parameter warning */
#define MAX(a, b) ((a) > (b) ? (a) : (b)) #define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b)) #define MIN(a, b) ((a) < (b) ? (a) : (b))
......
/****************************************************************************** /******************************************************************************
* 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 processDetectCutoffWarped_fl(LC3_FLOAT* d2, LC3_INT fs_idx, LC3_INT frame_dms, LC3_INT* bw_idx) void processDetectCutoffWarped_fl(LC3_FLOAT* d2, LC3_INT fs_idx, LC3_INT frame_dms, LC3_INT* bw_idx)
...@@ -33,13 +33,11 @@ void processDetectCutoffWarped_fl(LC3_FLOAT* d2, LC3_INT fs_idx, LC3_INT frame_d ...@@ -33,13 +33,11 @@ void processDetectCutoffWarped_fl(LC3_FLOAT* d2, LC3_INT fs_idx, LC3_INT frame_d
warp_idx_stop = BW_warp_idx_stop_all_5ms[fs_idx - 1]; warp_idx_stop = BW_warp_idx_stop_all_5ms[fs_idx - 1];
bw_dist = brickwall_dist; bw_dist = brickwall_dist;
break; break;
#ifdef CR8_G_ADD_75MS
case 75: case 75:
warp_idx_start = BW_warp_idx_start_all_7_5ms[fs_idx - 1]; warp_idx_start = BW_warp_idx_start_all_7_5ms[fs_idx - 1];
warp_idx_stop = BW_warp_idx_stop_all_7_5ms[fs_idx - 1]; warp_idx_stop = BW_warp_idx_stop_all_7_5ms[fs_idx - 1];
bw_dist = brickwall_dist_7_5ms; bw_dist = brickwall_dist_7_5ms;
break; break;
#endif
case 100: case 100:
warp_idx_start = BW_warp_idx_start_all[fs_idx - 1]; warp_idx_start = BW_warp_idx_start_all[fs_idx - 1];
warp_idx_stop = BW_warp_idx_stop_all[fs_idx - 1]; warp_idx_stop = BW_warp_idx_stop_all[fs_idx - 1];
......
/****************************************************************************** /******************************************************************************
* 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 const LC3_INT gainMSBbits[4] = {1, 1, 2, 2}; static const LC3_INT gainMSBbits[4] = {1, 1, 2, 2};
......
/****************************************************************************** /******************************************************************************
* 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 Enc_LC3PLUS_Channel_fl(LC3PLUS_Enc* encoder, int channel, int32_t* s_in, uint8_t* bytes, int bps static void Enc_LC3PLUS_Channel_fl(LC3PLUS_Enc* encoder, int channel, int32_t* s_in, uint8_t* bytes, int bps
...@@ -63,9 +63,7 @@ static void Enc_LC3PLUS_Channel_fl(LC3PLUS_Enc* encoder, int channel, int32_t* s ...@@ -63,9 +63,7 @@ static void Enc_LC3PLUS_Channel_fl(LC3PLUS_Enc* encoder, int channel, int32_t* s
/* Pitch estimation */ /* Pitch estimation */
processOlpa_fl(h_EncSetup->s_12k8, h_EncSetup->olpa_mem_s12k8, h_EncSetup->olpa_mem_s6k4, processOlpa_fl(h_EncSetup->s_12k8, h_EncSetup->olpa_mem_s12k8, h_EncSetup->olpa_mem_s6k4,
&h_EncSetup->olpa_mem_pitch, &h_EncSetup->olpa_mem_pitch,
#ifdef CR9_F_PITCH_WIN_LEN_FIX
&h_EncSetup->pitch_flag, &h_EncSetup->pitch_flag,
#endif
&T0_out, &normcorr, s_12k8_len, encoder->frame_dms); &T0_out, &normcorr, s_12k8_len, encoder->frame_dms);
/* LTPF encoder */ /* LTPF encoder */
...@@ -74,9 +72,7 @@ static void Enc_LC3PLUS_Channel_fl(LC3PLUS_Enc* encoder, int channel, int32_t* s ...@@ -74,9 +72,7 @@ static void Enc_LC3PLUS_Channel_fl(LC3PLUS_Enc* encoder, int channel, int32_t* s
&h_EncSetup->ltpf_mem_normcorr, &h_EncSetup->ltpf_mem_ltpf_on, &h_EncSetup->ltpf_mem_normcorr, &h_EncSetup->ltpf_mem_ltpf_on,
&h_EncSetup->ltpf_mem_pitch, h_EncSetup->ltpf_param, &h_EncSetup->ltpf_mem_mem_normcorr, &h_EncSetup->ltpf_mem_pitch, h_EncSetup->ltpf_param, &h_EncSetup->ltpf_mem_mem_normcorr,
&ltpfBits &ltpfBits
#ifdef CR9_K_REDUCE_NORM_CORR_TH
, encoder->hrmode , encoder->hrmode
#endif
); );
/* Attack detector */ /* Attack detector */
...@@ -88,11 +84,7 @@ static void Enc_LC3PLUS_Channel_fl(LC3PLUS_Enc* encoder, int channel, int32_t* s ...@@ -88,11 +84,7 @@ static void Enc_LC3PLUS_Channel_fl(LC3PLUS_Enc* encoder, int channel, int32_t* s
processPerBandEnergy_fl(encoder->bands_number, encoder->bands_offset, encoder->hrmode, encoder->frame_dms, h_EncSetup->ener, d_fl); processPerBandEnergy_fl(encoder->bands_number, encoder->bands_offset, encoder->hrmode, encoder->frame_dms, h_EncSetup->ener, d_fl);
/* Near Nyquist detector */ /* Near Nyquist detector */
processNearNyquistdetector_fl(&encoder->near_nyquist_flag, encoder->fs_idx, encoder->near_nyquist_index, encoder->bands_number, h_EncSetup->ener processNearNyquistdetector_fl(&encoder->near_nyquist_flag, encoder->fs_idx, encoder->near_nyquist_index, encoder->bands_number, h_EncSetup->ener
#ifdef CR8_E_TONE_DETECTOR
, encoder->frame_dms, encoder->hrmode ); , encoder->frame_dms, encoder->hrmode );
#else
);
#endif
/* Disable LTPF if nyquist detector triggers or -lfe mode is active*/ /* Disable LTPF if nyquist detector triggers or -lfe mode is active*/
if (encoder->near_nyquist_flag != 0 || h_EncSetup->lfe == 1) if (encoder->near_nyquist_flag != 0 || h_EncSetup->lfe == 1)
{ {
......
/****************************************************************************** /******************************************************************************
* 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"
......
/****************************************************************************** /******************************************************************************
* 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,9 +7,8 @@ ...@@ -7,9 +7,8 @@
* estoppel or otherwise. * * estoppel or otherwise. *
******************************************************************************/ ******************************************************************************/
#include "options.h" #include "options.h"
#include "wmc_auto.h"
#include "cfft.h" #include "cfft.h"
#include "iisfft.h" /* for M_PIl */ #include "iisfft.h" /* for M_PIl */
#include <stdlib.h> /* for abs() */ #include <stdlib.h> /* for abs() */
...@@ -386,8 +385,10 @@ void LC3_cfft(LC3_FLOAT* re, LC3_FLOAT* im, LC3_INT length, LC3_INT stride, LC3_ ...@@ -386,8 +385,10 @@ void LC3_cfft(LC3_FLOAT* re, LC3_FLOAT* im, LC3_INT length, LC3_INT stride, LC3_
LC3_INT LC3_cfft_plan(Cfft* handle, LC3_INT length, LC3_INT sign) LC3_INT LC3_cfft_plan(Cfft* handle, LC3_INT length, LC3_INT sign)
{ {
/* check if length is power of two */ /* check if length is power of two */
if (!CFFT_PLAN_SUPPORT(length) || abs(sign) != 1) if (!CFFT_PLAN_SUPPORT(length) || (abs(sign) != 1))
{
return 0; return 0;
}
handle->len = length; handle->len = length;
handle->sign = sign; handle->sign = sign;
...@@ -418,5 +419,7 @@ void LC3_cfft_apply(Cfft* handle, LC3_FLOAT* re, LC3_FLOAT* im, LC3_INT stride) ...@@ -418,5 +419,7 @@ void LC3_cfft_apply(Cfft* handle, LC3_FLOAT* re, LC3_FLOAT* im, LC3_INT stride)
void LC3_cfft_free(Cfft* handle) void LC3_cfft_free(Cfft* handle)
{ {
if (handle->table) if (handle->table)
{
free(handle->table); free(handle->table);
} }
}
/****************************************************************************** /******************************************************************************
* 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,9 +7,8 @@ ...@@ -7,9 +7,8 @@
* estoppel or otherwise. * * estoppel or otherwise. *
******************************************************************************/ ******************************************************************************/
#include "options.h" #include "options.h"
#include "wmc_auto.h"
#include "../functions.h" #include "../functions.h"
#ifndef CFFT_H #ifndef CFFT_H
......
/****************************************************************************** /******************************************************************************
* ETSI TS 103 634 V1.4.3 * * ETSI TS 103 634 V1.5.1 *
* Low Complexity Communication Codec Plus (LC3plus) * * Low Complexity Communication Codec Plus (LC3plus) *
* * * *
* Copyright licence is solely granted through ETSI Intellectual Property * * Copyright licence is solely granted through ETSI Intellectual Property *
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
* estoppel or otherwise. * * estoppel or otherwise. *
******************************************************************************/ ******************************************************************************/
/* guard against unindended includes */ /* guard against unindended includes */
#ifndef INCLUDED_FROM_IISFFT_C #ifndef INCLUDED_FROM_IISFFT_C
#error "this file must not be included" #error "this file must not be included"
......
/****************************************************************************** /******************************************************************************
* ETSI TS 103 634 V1.4.3 * * ETSI TS 103 634 V1.5.1 *
* Low Complexity Communication Codec Plus (LC3plus) * * Low Complexity Communication Codec Plus (LC3plus) *
* * * *
* Copyright licence is solely granted through ETSI Intellectual Property * * Copyright licence is solely granted through ETSI Intellectual Property *
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
* estoppel or otherwise. * * estoppel or otherwise. *
******************************************************************************/ ******************************************************************************/
/* guard against unindended includes */ /* guard against unindended includes */
#ifndef INCLUDED_FROM_IISFFT_C #ifndef INCLUDED_FROM_IISFFT_C
#error "this file must not be included" #error "this file must not be included"
......
/****************************************************************************** /******************************************************************************
* ETSI TS 103 634 V1.4.3 * * ETSI TS 103 634 V1.5.1 *
* Low Complexity Communication Codec Plus (LC3plus) * * Low Complexity Communication Codec Plus (LC3plus) *
* * * *
* Copyright licence is solely granted through ETSI Intellectual Property * * Copyright licence is solely granted through ETSI Intellectual Property *
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
* estoppel or otherwise. * * estoppel or otherwise. *
******************************************************************************/ ******************************************************************************/
/* guard against unindended includes */ /* guard against unindended includes */
#ifndef INCLUDED_FROM_IISFFT_C #ifndef INCLUDED_FROM_IISFFT_C
#error "this file must not be included" #error "this file must not be included"
......
/****************************************************************************** /******************************************************************************
* ETSI TS 103 634 V1.4.3 * * ETSI TS 103 634 V1.5.1 *
* Low Complexity Communication Codec Plus (LC3plus) * * Low Complexity Communication Codec Plus (LC3plus) *
* * * *
* Copyright licence is solely granted through ETSI Intellectual Property * * Copyright licence is solely granted through ETSI Intellectual Property *
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
* estoppel or otherwise. * * estoppel or otherwise. *
******************************************************************************/ ******************************************************************************/
/* guard against unindended includes */ /* guard against unindended includes */
#ifndef INCLUDED_FROM_IISFFT_C #ifndef INCLUDED_FROM_IISFFT_C
#error "this file must not be included" #error "this file must not be included"
......
/****************************************************************************** /******************************************************************************
* ETSI TS 103 634 V1.4.3 * * ETSI TS 103 634 V1.5.1 *
* Low Complexity Communication Codec Plus (LC3plus) * * Low Complexity Communication Codec Plus (LC3plus) *
* * * *
* Copyright licence is solely granted through ETSI Intellectual Property * * Copyright licence is solely granted through ETSI Intellectual Property *
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
* estoppel or otherwise. * * estoppel or otherwise. *
******************************************************************************/ ******************************************************************************/
/* guard against unindended includes */ /* guard against unindended includes */
#ifndef INCLUDED_FROM_IISFFT_C #ifndef INCLUDED_FROM_IISFFT_C
#error "this file must not be included" #error "this file must not be included"
......
/****************************************************************************** /******************************************************************************
* ETSI TS 103 634 V1.4.3 * * ETSI TS 103 634 V1.5.1 *
* Low Complexity Communication Codec Plus (LC3plus) * * Low Complexity Communication Codec Plus (LC3plus) *
* * * *
* Copyright licence is solely granted through ETSI Intellectual Property * * Copyright licence is solely granted through ETSI Intellectual Property *
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
* estoppel or otherwise. * * estoppel or otherwise. *
******************************************************************************/ ******************************************************************************/
/* guard against unindended includes */ /* guard against unindended includes */
#ifndef INCLUDED_FROM_IISFFT_C #ifndef INCLUDED_FROM_IISFFT_C
#error "this file must not be included" #error "this file must not be included"
......
/****************************************************************************** /******************************************************************************
* ETSI TS 103 634 V1.4.3 * * ETSI TS 103 634 V1.5.1 *
* Low Complexity Communication Codec Plus (LC3plus) * * Low Complexity Communication Codec Plus (LC3plus) *
* * * *
* Copyright licence is solely granted through ETSI Intellectual Property * * Copyright licence is solely granted through ETSI Intellectual Property *
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
* estoppel or otherwise. * * estoppel or otherwise. *
******************************************************************************/ ******************************************************************************/
/* guard against unindended includes */ /* guard against unindended includes */
#ifndef INCLUDED_FROM_IISFFT_C #ifndef INCLUDED_FROM_IISFFT_C
#error "this file must not be included" #error "this file must not be included"
......
/****************************************************************************** /******************************************************************************
* 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 <assert.h> #include <assert.h>
#include <stddef.h> #include <stddef.h>
#include <stdio.h> #include <stdio.h>
...@@ -37,14 +37,20 @@ static IIS_FFT_ERROR create(HANDLE_IIS_FFT* handle, LC3_INT type, LC3_INT len, I ...@@ -37,14 +37,20 @@ static IIS_FFT_ERROR create(HANDLE_IIS_FFT* handle, LC3_INT type, LC3_INT len, I
LC3_INT trlen = (type == FFT_COMPLEX) ? len : len / 2; LC3_INT trlen = (type == FFT_COMPLEX) ? len : len / 2;
/* check argument sanity */ /* check argument sanity */
if (sign != IIS_FFT_FWD && sign != IIS_FFT_BWD) if ((sign != IIS_FFT_FWD) && (sign != IIS_FFT_BWD))
{
return IIS_FFT_INTERNAL_ERROR; return IIS_FFT_INTERNAL_ERROR;
}
if (!(*handle)) if (!(*handle))
{
(*handle) = (HANDLE_IIS_FFT)calloc(1, sizeof(IIS_FFT)); (*handle) = (HANDLE_IIS_FFT)calloc(1, sizeof(IIS_FFT));
}
if (!(*handle)) if (!(*handle))
{
return IIS_FFT_MEMORY_ERROR; return IIS_FFT_MEMORY_ERROR;
}
(*handle)->len = len; (*handle)->len = len;
(*handle)->sign = sign; (*handle)->sign = sign;
...@@ -121,7 +127,9 @@ IIS_FFT_ERROR LC3_IIS_FFT_Apply_CFFT(HANDLE_IIS_FFT handle, const Complex* input ...@@ -121,7 +127,9 @@ IIS_FFT_ERROR LC3_IIS_FFT_Apply_CFFT(HANDLE_IIS_FFT handle, const Complex* input
{ {
LC3_FLOAT* dummy; LC3_FLOAT* dummy;
if (!handle) if (!handle)
{
return IIS_FFT_INTERNAL_ERROR; return IIS_FFT_INTERNAL_ERROR;
}
/* check for inplace operation */ /* check for inplace operation */
memmove(output, input, sizeof(*input) * handle->len); memmove(output, input, sizeof(*input) * handle->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,11 +7,11 @@ ...@@ -7,11 +7,11 @@
* estoppel or otherwise. * * estoppel or otherwise. *
******************************************************************************/ ******************************************************************************/
#ifndef IIS_FFT_H #ifndef IIS_FFT_H
#define IIS_FFT_H #define IIS_FFT_H
#include "options.h" #include "options.h"
#include "wmc_auto.h"
#include "../structs.h" #include "../structs.h"
#include "../defines.h" #include "../defines.h"
#include "cfft.h" #include "cfft.h"
......
/****************************************************************************** /******************************************************************************
* ETSI TS 103 634 V1.4.3 * * ETSI TS 103 634 V1.5.1 *
* Low Complexity Communication Codec Plus (LC3plus) * * Low Complexity Communication Codec Plus (LC3plus) *
* * * *
* Copyright licence is solely granted through ETSI Intellectual Property * * Copyright licence is solely granted through ETSI Intellectual Property *
...@@ -7,9 +7,8 @@ ...@@ -7,9 +7,8 @@
* estoppel or otherwise. * * estoppel or otherwise. *
******************************************************************************/ ******************************************************************************/
#include "options.h" #include "options.h"
#include "wmc_auto.h"
#include <assert.h> #include <assert.h>
#include <string.h> /* for mmove */ #include <string.h> /* for mmove */
#include <stdio.h> #include <stdio.h>
...@@ -60,7 +59,9 @@ IIS_FFT_ERROR LC3_iisfft_plan(Iisfft* handle, LC3_INT length, LC3_INT sign) ...@@ -60,7 +59,9 @@ IIS_FFT_ERROR LC3_iisfft_plan(Iisfft* handle, LC3_INT length, LC3_INT sign)
{ {
memset(handle, 0, sizeof(Iisfft)); memset(handle, 0, sizeof(Iisfft));
if (length < 2) if (length < 2)
{
return IIS_FFT_LENGTH_ERROR; return IIS_FFT_LENGTH_ERROR;
}
handle->length = length; handle->length = length;
handle->sign = sign; handle->sign = sign;
if (need_scratch(length)) { if (need_scratch(length)) {
...@@ -68,7 +69,9 @@ IIS_FFT_ERROR LC3_iisfft_plan(Iisfft* handle, LC3_INT length, LC3_INT sign) ...@@ -68,7 +69,9 @@ IIS_FFT_ERROR LC3_iisfft_plan(Iisfft* handle, LC3_INT length, LC3_INT sign)
LC3_INT i = 0; LC3_INT i = 0;
LC3_INT lengthOfPrimeScratch = BORDER_FOR_SECOND_SCRATCH; LC3_INT lengthOfPrimeScratch = BORDER_FOR_SECOND_SCRATCH;
if (!factorize(length, &handle->num_factors, handle->factors, handle->isPrime)) if (!factorize(length, &handle->num_factors, handle->factors, handle->isPrime))
{
return IIS_FFT_LENGTH_ERROR; return IIS_FFT_LENGTH_ERROR;
}
/* create additional scratch for primeFFT() */ /* create additional scratch for primeFFT() */
for (i = 0; i < handle->num_factors; i++) { for (i = 0; i < handle->num_factors; i++) {
if (handle->isPrime[i] == 1 && handle->factors[i] > lengthOfPrimeScratch) { if (handle->isPrime[i] == 1 && handle->factors[i] > lengthOfPrimeScratch) {
...@@ -78,9 +81,11 @@ IIS_FFT_ERROR LC3_iisfft_plan(Iisfft* handle, LC3_INT length, LC3_INT sign) ...@@ -78,9 +81,11 @@ IIS_FFT_ERROR LC3_iisfft_plan(Iisfft* handle, LC3_INT length, LC3_INT sign)
if (lengthOfPrimeScratch > BORDER_FOR_SECOND_SCRATCH) { if (lengthOfPrimeScratch > BORDER_FOR_SECOND_SCRATCH) {
handle->scratch2 = (LC3_INT*)malloc(sizeof(LC3_INT) * lengthOfPrimeScratch); handle->scratch2 = (LC3_INT*)malloc(sizeof(LC3_INT) * lengthOfPrimeScratch);
if (!handle->scratch2) if (!handle->scratch2)
{
return IIS_FFT_MEMORY_ERROR; return IIS_FFT_MEMORY_ERROR;
} }
} }
}
return IIS_FFT_NO_ERROR; return IIS_FFT_NO_ERROR;
} }
...@@ -89,8 +94,10 @@ void LC3_iisfft_free(Iisfft* handle) ...@@ -89,8 +94,10 @@ void LC3_iisfft_free(Iisfft* handle)
{ {
handle->length = 0; handle->length = 0;
if (handle->scratch2) if (handle->scratch2)
{
free(handle->scratch2); free(handle->scratch2);
} }
}
......