Line data Source code
1 : /****************************************************************************** 2 : * ETSI TS 103 634 V1.5.1 * 3 : * Low Complexity Communication Codec Plus (LC3plus) * 4 : * * 5 : * Copyright licence is solely granted through ETSI Intellectual Property * 6 : * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * 7 : * estoppel or otherwise. * 8 : ******************************************************************************/ 9 : 10 : #include "options.h" 11 : #include "wmc_auto.h" 12 : #include "functions.h" 13 : #include "fft/iis_fft.c" 14 : #include "fft/iisfft.c" 15 : #include "fft/cfft.c" 16 : 17 0 : void fft_init(Fft* fft, int length) 18 : { 19 0 : HANDLE_IIS_FFT handle = NULL; 20 0 : IIS_FFT_ERROR error = 0; 21 0 : assert(length % 2 == 0); 22 : 23 0 : fft->length = length; 24 : 25 0 : error = LC3_IIS_CFFT_Create(&handle, length, IIS_FFT_FWD); 26 : 27 0 : assert(error == IIS_FFT_NO_ERROR); 28 0 : fft->handle = handle; 29 0 : } 30 : 31 0 : void fft_free(Fft* fft) 32 : { 33 0 : IIS_FFT_ERROR error = 0; 34 : 35 0 : if (fft) { 36 0 : error = LC3_IIS_CFFT_Destroy((HANDLE_IIS_FFT *) &fft->handle); 37 : 38 0 : assert(error == IIS_FFT_NO_ERROR); 39 0 : memset(fft, 0, sizeof(*fft)); 40 : } 41 0 : } 42 : 43 0 : void real_fft_free(Fft* fft) 44 : { 45 0 : IIS_FFT_ERROR error = 0; 46 : 47 0 : if (fft) { 48 0 : error = LC3_IIS_RFFT_Destroy((HANDLE_IIS_FFT *) &fft->handle); 49 : 50 0 : assert(error == IIS_FFT_NO_ERROR); 51 0 : memset(fft, 0, sizeof(*fft)); 52 : } 53 0 : } 54 : 55 0 : void real_fft_init(Fft* fft, LC3_INT32 length, HANDLE_IIS_FFT *handle) 56 : { 57 0 : IIS_FFT_ERROR error = IIS_FFT_NO_ERROR; 58 0 : assert(length % 4 == 0); /* due to current limitation of core complex FFTs*/ 59 : 60 0 : fft->length = length; 61 : 62 0 : error = LC3_IIS_RFFT_Create(handle, length, IIS_FFT_FWD); 63 0 : assert(error == IIS_FFT_NO_ERROR); 64 0 : fft->handle = *handle; 65 0 : } 66 : 67 : 68 0 : void real_ifft_init(Fft* fft, LC3_INT32 length, HANDLE_IIS_FFT *handle) 69 : { 70 0 : IIS_FFT_ERROR error = IIS_FFT_NO_ERROR; 71 0 : assert(length % 4 == 0); /* due to current limitation of core complex FFTs*/ 72 : 73 0 : fft->length = length; 74 : 75 0 : error = LC3_IIS_RFFT_Create(handle, length, IIS_FFT_BWD); 76 : 77 0 : assert(error == IIS_FFT_NO_ERROR); 78 0 : fft->handle = *handle; 79 0 : } 80 : 81 0 : void fft_apply(Fft* fft, const Complex* input, Complex* output) 82 : { 83 0 : IIS_FFT_ERROR error = 0; 84 0 : error = LC3_IIS_FFT_Apply_CFFT(fft->handle, input, output); 85 : 86 0 : assert(error == IIS_FFT_NO_ERROR); 87 0 : } 88 : 89 : 90 0 : void real_fft_apply(Fft* fft, const LC3_FLOAT* input, LC3_FLOAT* output) 91 : { 92 0 : IIS_FFT_ERROR error = IIS_FFT_NO_ERROR; 93 : 94 : UNUSED(error); 95 : 96 0 : error = LC3_IIS_FFT_Apply_RFFT(fft->handle, input, output); 97 : 98 0 : assert(error == IIS_FFT_NO_ERROR); 99 0 : } 100 :