From 94ea94f708e31e70838305058d3493fe285df3e4 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Tue, 2 Jan 2024 17:37:52 +0530 Subject: [PATCH] Warning fixes and clean up in FFT and MDCT fix-pt files [x] Warning fixes in fft_fx.c, fft_cldfb_fx.c, decoder.c, ivas_mdct_imdct_fx.c files. [x] Few other related clean-ups like moving function declarations from .c files to appropriate header file. [x] Testing: Unit tests for FFT/IFFT and MDCT/IMDCT. --- apps/decoder.c | 2 +- lib_com/fft_cldfb_fx.c | 4 +- lib_com/ivas_mdct_imdct_fx.c | 38 ++++++------------ lib_com/ivas_prot_fx.h | 56 ++++++++++++++++++++++----- lib_com/prot_fx2.h | 75 ++++++++++++++++++++++++++++++++++++ lib_util/test_fft.c | 15 ++++---- lib_util/test_mdct.c | 2 + 7 files changed, 146 insertions(+), 46 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index a5b1949b0..f9f681bd4 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -175,7 +175,7 @@ int main( { run_fft_unit_test(); run_mdct_unit_test(); - return; + return 0; } if ( !parseCmdlIVAS_dec( (int16_t) argc, argv, &arg ) ) diff --git a/lib_com/fft_cldfb_fx.c b/lib_com/fft_cldfb_fx.c index 0aa46d605..1e407d762 100644 --- a/lib_com/fft_cldfb_fx.c +++ b/lib_com/fft_cldfb_fx.c @@ -37,7 +37,7 @@ #include #include "options.h" #include -#include "prot.h" +#include "prot_fx2.h" #include "ivas_cnst.h" #include "wmc_auto.h" #include "basop_util.h" @@ -1030,7 +1030,7 @@ static void fft30_with_cmplx_data(cmplx * inp) } /*-------------------------------------------------------------------* - * fft_cldfb() + * fft_cldfb_fx() * * Interface functions FFT subroutines *--------------------------------------------------------------------*/ diff --git a/lib_com/ivas_mdct_imdct_fx.c b/lib_com/ivas_mdct_imdct_fx.c index 82e22a6b8..1212b51e0 100644 --- a/lib_com/ivas_mdct_imdct_fx.c +++ b/lib_com/ivas_mdct_imdct_fx.c @@ -32,8 +32,8 @@ #include #include "options.h" -#include "prot.h" -#include "prot_fx1.h" +#include "prot_fx2.h" +#include "ivas_prot_fx.h" #include "ivas_rom_com_fx.h" #ifdef DEBUGGING #include "debug.h" @@ -41,20 +41,6 @@ #include "ivas_stat_com.h" #include "wmc_auto.h" -void ivas_get_twid_factors_fx1( - const Word16 length, - const Word16 **pTwid_re, - const Word16 **pTwid_im ); - -void DoFFT_fx( - Word32 *re2, - Word32 *im2, - const Word16 length ); - -Word32 ivas_get_mdct_scaling_gain_fx( - const Word16 dct_len_by_2 ); - - /*------------------------------------------------------------------------------------------* * Local constants *------------------------------------------------------------------------------------------*/ @@ -119,7 +105,7 @@ void ivas_dct_windowing_fx( Copy32( pTemp_lfe, ( pOut_buf + fade_len + zero_pad_len ), dct_len ); - set_l(pOut_buf, zero_pad_len, 0); + set32_fx(pOut_buf, 0, zero_pad_len); Copy32( ( pOut_buf + full_len - fade_len ), pBuffer_prev, fade_len ); @@ -135,7 +121,7 @@ void ivas_dct_windowing_fx( pOut_buf[zero_pad_len * 3 + fade_len + i] = Mult_32_32(pOut_buf[zero_pad_len * 3 + fade_len + i], pWindow_coeffs[fade_len - i - 1]); } - set_l(&pOut_buf[full_len], frame_len - full_len, 0); + set32_fx(&pOut_buf[full_len], 0, frame_len - full_len); return; } @@ -333,23 +319,23 @@ void ivas_get_twid_factors_fx1( { IF ( EQ_16(length, 480) ) { - *pTwid_re = (Word16 *)&ivas_cos_twiddle_480_fx[0]; - *pTwid_im = (Word16 *)&ivas_sin_twiddle_480_fx[0]; + *pTwid_re = (const Word16 *)&ivas_cos_twiddle_480_fx[0]; + *pTwid_im = (const Word16 *)&ivas_sin_twiddle_480_fx[0]; } ELSE IF ( EQ_16(length, 320) ) { - *pTwid_re = (Word16 *)&ivas_cos_twiddle_320_fx[0]; - *pTwid_im = (Word16 *)&ivas_sin_twiddle_320_fx[0]; + *pTwid_re = (const Word16 *)&ivas_cos_twiddle_320_fx[0]; + *pTwid_im = (const Word16 *)&ivas_sin_twiddle_320_fx[0]; } ELSE IF ( EQ_16(length, 160) ) { - *pTwid_re = (Word16 *)&ivas_cos_twiddle_160_fx[0]; - *pTwid_im = (Word16 *)&ivas_sin_twiddle_160_fx[0]; + *pTwid_re = (const Word16 *)&ivas_cos_twiddle_160_fx[0]; + *pTwid_im = (const Word16 *)&ivas_sin_twiddle_160_fx[0]; } ELSE IF ( EQ_16(length, 80 ) ) { - *pTwid_re = (Word16 *)&ivas_cos_twiddle_80_fx[0]; - *pTwid_im = (Word16 *)&ivas_sin_twiddle_80_fx[0]; + *pTwid_re = (const Word16 *)&ivas_cos_twiddle_80_fx[0]; + *pTwid_im = (const Word16 *)&ivas_sin_twiddle_80_fx[0]; } ELSE { diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index 0f25cadb6..8460ede6e 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -45,15 +45,51 @@ #include "ivas_stat_com.h" #include "ivas_error_utils.h" - - - - - - - - - - +void ivas_dct_windowing_fx( + const Word16 fade_len, + const Word16 full_len, + const Word16 dct_len, + const Word16 zero_pad_len, + const Word32 *pWindow_coeffs, + const Word16 frame_len, + Word32 *pOut_buf, + Word32 *pBuffer_prev, + Word32 *pTemp_lfe +); + +void ivas_get_twid_factors_fx1( + const Word16 length, + const Word16 **pTwid_re, + const Word16 **pTwid_im +); + +Word32 ivas_get_mdct_scaling_gain_fx( + const Word16 dct_len_by_2 ); + +void ivas_imdct_fx( + const Word32 *pIn, + Word32 *pOut, + const Word16 length, + Word16 *q_out +); + +void ivas_mdct_fx( + const Word32 *pIn, + Word32 *pOut, + const Word16 length, + Word16 *q_out +); + +void ivas_itda_fx( + const Word32 *re, /* i : time alised signal after IDCT */ + Word32 *pOut, /* o : time domain buffer of size 2*length */ + const Word16 length /* i : length of time alised signal buffer */ +); + +void ivas_tda_fx( + const Word32 *pIn, /* i : time domain buffer of size 2*length */ + Word32 *pOut, /* o : time domain buffer of size length */ + const Word16 length /* i : length of time alised signal buffer */ +); #endif \ No newline at end of file diff --git a/lib_com/prot_fx2.h b/lib_com/prot_fx2.h index 041bc3068..3476aea98 100644 --- a/lib_com/prot_fx2.h +++ b/lib_com/prot_fx2.h @@ -3685,6 +3685,76 @@ void DoRTFTn_fx( Word32 *y, /* i/o : imaginary part of i and output data */ const Word16 n /* i : size of the FFT up to 1024 */ ); + +void DoRTFT480_fx( + Word32 *x, /* i/o: real part of input and output data */ + Word32 *y /* i/o: imaginary part of input and output data */ +); + +void DoRTFT320_fx( + Word32 *x, /* i/o: real part of input and output data */ + Word32 *y /* i/o: imaginary part of input and output data */ +); + +void DoRTFT160_fx( + Word32 x[], /* i/o: real part of input and output data */ + Word32 y[] /* i/o: imaginary part of input and output data */ +); + +void DoRTFT128_fx( + Word32 *x, /* i/o: real part of input and output data */ + Word32 *y /* i/o: imaginary part of input and output data */ +); + +void DoRTFT120_fx( + Word32 *x, /* i/o: real part of input and output data */ + Word32 *y /* i/o: imaginary part of input and output data */ +); + +void DoRTFT80_fx( + Word32 *x, /* i/o: real part of input and output data */ + Word32 *y /* i/o: imaginary part of input and output data */ +); + +void DoRTFT40_fx( + Word32 *x, /* i/o: real part of input and output data */ + Word32 *y /* i/o: imaginary part of input and output data */ +); + +void DoRTFT20_fx( + Word32 *x, /* i/o: real part of input and output data */ + Word32 *y /* i/o: imaginary part of input and output data */ +); + +Word16 RFFTN_fx( + Word32 *data, + const Word16 *sine_table, + const Word16 len, + const Word16 sign +); + +void DoFFT_fx( + Word32 *re2, + Word32 *im2, + const Word16 length +); + +void fft_fx( + Word32 *re, /* i/o: real part */ + Word32 *im, /* i/o: imag part */ + const Word16 length, /* i : length of fft */ + const Word16 s /* i : sign */ +); + +void edct2_fx_ivas( + const Word16 n, + const Word16 isgn, + Word32 *in, + Word32 *a, + const Word16 *ip, + const Word16 *w +); + void edct2_fx( Word16 n, Word16 isgn, @@ -7539,4 +7609,9 @@ ivas_error evs_dec_fx( Word16 output_sp[], /* o : output synthesis signal */ frameMode_fx frameMode /* i : Decoder frame mode */ ); + +void fft_cldfb_fx( + Word32 *data, /* i/o: input/output vector */ + const Word16 size /* size of fft operation */ +); #endif \ No newline at end of file diff --git a/lib_util/test_fft.c b/lib_util/test_fft.c index 3a8d97f8a..8d70e78df 100644 --- a/lib_util/test_fft.c +++ b/lib_util/test_fft.c @@ -40,10 +40,6 @@ #include "assert.h" #include "basop32.h" -typedef int Word32; -typedef short Word16; -typedef short int16_t; - #define ALLOWED_DEVIATION ( 0.005 ) #define Q31 ( 2147483647.0f ) @@ -120,6 +116,8 @@ void ifft3( const int16_t n /* i : block length (must be radix 3) */ ); +void run_fft_unit_test( void ); + extern const Word16 fftSineTab640_fx[321]; #if 0 @@ -177,6 +175,9 @@ void BASOP_cfft_fx( Word16 *scale /* i : scalefactor */ ); +void populate_input_interleave( Word32 *in32, float *fIn, Word16 N ); +void populate_input_interleave_16( Word16 *in16, float *fIn, Word16 N ); + #define print_output( fRe, fIm, iRe, iIm ) \ printf( "Real = %.2f %d Imag = %.2f %d\n", fRe, iRe, fIm, iIm ) @@ -191,7 +192,7 @@ void BASOP_cfft_fx( #define TYPE_fft_ifft3 ( 8 ) #define TYPE_BASOP_cfft ( 9 ) -Word16 find_guarded_bits_fx( Word32 n ) +static Word16 find_guarded_bits_fx( Word32 n ) { return n <= 1 ? 0 : n <= 2 ? 1 : n <= 4 ? 2 @@ -206,7 +207,7 @@ Word16 find_guarded_bits_fx( Word32 n ) : 11; } -Word16 L_norm_arr( Word32 *arr, int size ) +static Word16 L_norm_arr( Word32 *arr, int size ) { Word16 q = 31; for ( int i = 0; i < size; i++ ) @@ -217,7 +218,7 @@ Word16 L_norm_arr( Word32 *arr, int size ) return q; } -Word16 norm_arr( Word16 *arr, int size ) +static Word16 norm_arr( Word16 *arr, int size ) { Word16 q = 15; for ( int i = 0; i < size; i++ ) diff --git a/lib_util/test_mdct.c b/lib_util/test_mdct.c index 13ada376a..036679786 100644 --- a/lib_util/test_mdct.c +++ b/lib_util/test_mdct.c @@ -92,6 +92,8 @@ void ivas_imdct_fx( const Word16 length, Word16 *q_out); +void run_mdct_unit_test(void); + void populate_input_interleave(Word32 *in32, float *fIn, Word16 N); void populate_input_interleave_16(Word16 *in16, float *fIn, Word16 N); -- GitLab