Loading lib_com/cldfb.c +349 −83 File changed.Preview size limit exceeded, changes collapsed. Show changes lib_com/cnst.h +1 −0 Original line number Diff line number Diff line Loading @@ -1666,6 +1666,7 @@ enum #define FD_CNG_JOINT_stages_25bits 4 #define OUTMAX_INV 0.000030517578125f /* 1/2^15 */ #define OUTMAX_INV_FX 65536 /* 1/2^15 (Q31) */ #define OUTMAX_SQ 1073741824.f /* 2^30 */ #define OUTMAX_SQ_INV 0.00000000093132257461547852f /* 1/2^30 */ Loading lib_com/fd_cng_com.c +148 −2 Original line number Diff line number Diff line Loading @@ -39,10 +39,14 @@ #include "options.h" #include <math.h> #include "prot.h" #include "prot_fx2.h" #include "rom_com.h" #include "wmc_auto.h" #ifdef IVAS_FLOAT_FIXED #define FFT_SCALING_512 1073741824 //Q22 #define FFT_SCALING_640 1342177280 //Q22 #endif /*------------------------------------------------------------------- * Local function prototypes *-------------------------------------------------------------------*/ Loading Loading @@ -103,6 +107,10 @@ void initFdCngCom_flt( set_f( hFdCngCom->sidNoiseEst_flt, 0.0f, NPART ); set_f( hFdCngCom->A_cng_flt, 0.0f, M + 1 ); hFdCngCom->A_cng_flt[0] = 1.f; #ifdef IVAS_FLOAT_FIXED set_s( hFdCngCom->A_cng, 0, M + 1 ); hFdCngCom->A_cng[0] = MAX_16; #endif /* Set some counters and flags */ hFdCngCom->inactive_frame_counter = 0; /* Either SID or zero frames */ Loading @@ -110,6 +118,9 @@ void initFdCngCom_flt( hFdCngCom->frame_type_previous = ACTIVE_FRAME; hFdCngCom->flag_noisy_speech = 0; hFdCngCom->likelihood_noisy_speech_flt = 0.f; #ifdef IVAS_FLOAT_FIXED hFdCngCom->likelihood_noisy_speech_32fx = 0; #endif hFdCngCom->numCoreBands = 0; hFdCngCom->stopBand = 0; hFdCngCom->startBand = 0; Loading Loading @@ -937,6 +948,115 @@ void SynthesisSTFT_flt( return; } #ifdef IVAS_FLOAT_FIXED /*------------------------------------------------------------------- * SynthesisSTFT_fx() * * STFT synthesis filterbank *-------------------------------------------------------------------*/ void SynthesisSTFT_fx( Word32 *fftBuffer, /* i : FFT bins */ Word16 Q_in, Word32 *timeDomainOutput, Word32 *olapBuffer, const Word16 *olapWin, const int16_t tcx_transition, HANDLE_FD_CNG_COM hFdCngCom, /* i/o: FD_CNG structure containing all buffers and variables */ const int16_t element_mode, /* i : element mode */ const int16_t nchan_out /* i : number of output channels */ ) { int16_t i; Word32 buf_fx[M + 1 + 320], tmp_fx; /* Perform IFFT */ RFFTN_fx( fftBuffer, hFdCngCom->fftSineTab_fx, hFdCngCom->fftlen, 1 ); /* Handle overlap in P/S domain for stereo */ IF( ( element_mode == IVAS_CPE_TD || element_mode == IVAS_CPE_DFT ) && nchan_out == 2 ) { mvl2l( olapBuffer + 3 * hFdCngCom->frameSize / 4 - ( M + 1 ), buf_fx, hFdCngCom->frameSize + M + 1 ); set_l( olapBuffer, 0, hFdCngCom->fftlen ); } ELSE { mvl2l( olapBuffer + hFdCngCom->frameSize, olapBuffer, hFdCngCom->frameSize ); set_l( olapBuffer + hFdCngCom->frameSize, 0, hFdCngCom->frameSize ); /*olapBuffer, fftBuffer, olapWin*/ } IF( tcx_transition ) { FOR( i = 0; i < 5 * hFdCngCom->frameSize / 4; i++ ) { olapBuffer[i] = fftBuffer[i]; } } ELSE { FOR( i = hFdCngCom->frameSize / 4; i < 3 * hFdCngCom->frameSize / 4; i++ ) { olapBuffer[i] = L_add( olapBuffer[i], Mpy_32_16_1( fftBuffer[i], olapWin[i - hFdCngCom->frameSize / 4] ) ); } FOR( ; i < 5 * hFdCngCom->frameSize / 4; i++ ) { olapBuffer[i] = fftBuffer[i]; } } FOR( ; i < 7 * hFdCngCom->frameSize / 4; i++ ) { olapBuffer[i] = Mpy_32_16_1( fftBuffer[i], olapWin[i - 3 * hFdCngCom->frameSize / 4] ); } FOR( ; i < hFdCngCom->fftlen; i++ ) { olapBuffer[i] = 0; } Word32 fftScale = 0; SWITCH( hFdCngCom->fftlen ) { case 640: fftScale = FFT_SCALING_640; break; case 512: fftScale = FFT_SCALING_512; break; default: assert( !"Not supported FFT length!" ); } /* Get time-domain signal */ // v_multc(olapBuffer + hFdCngCom->frameSize / 4, (float)(hFdCngCom->fftlen / 2), timeDomainOutput, hFdCngCom->frameSize); v_multc_fixed( olapBuffer + hFdCngCom->frameSize / 4, fftScale, timeDomainOutput, hFdCngCom->frameSize ); // Q_in - 9 /* Get excitation */ IF( ( element_mode == IVAS_CPE_TD || element_mode == IVAS_CPE_DFT ) && nchan_out == 2 ) { FOR( i = 0; i < hFdCngCom->frameSize / 2; i++ ) { buf_fx[i + ( M + 1 )] = L_add( buf_fx[i + ( M + 1 )], olapBuffer[i + hFdCngCom->frameSize / 4] ); } // v_multc(buf, (float)(hFdCngCom->fftlen / 2), buf, M + 1 + hFdCngCom->frameSize); v_multc_fixed( buf_fx, fftScale, buf_fx, M + 1 + hFdCngCom->frameSize ); } ELSE { // v_multc(olapBuffer + hFdCngCom->frameSize / 4 - (M + 1), (float)(hFdCngCom->fftlen / 2), buf, M + 1 + hFdCngCom->frameSize); v_multc_fixed( olapBuffer + ( hFdCngCom->frameSize / 4 ) - ( M + 1 ), fftScale, buf_fx, M + 1 + hFdCngCom->frameSize ); } tmp_fx = buf_fx[0]; // preemph(buf + 1, PREEMPH_FAC_FLT, M + hFdCngCom->frameSize, &tmp); preemph_ivas_fx( buf_fx + 1, PREEMPH_FAC, M + hFdCngCom->frameSize, &tmp_fx ); // residu(hFdCngCom->A_cng_flt, M, buf + 1 + M, hFdCngCom->exc_cng_flt, hFdCngCom->frameSize); residu_ivas_fx( hFdCngCom->A_cng, Q13, M, buf_fx + 1 + M, hFdCngCom->exc_cng_32fx, hFdCngCom->frameSize ); for ( i = 0; i < hFdCngCom->frameSize; i++ ) { hFdCngCom->exc_cng_flt[i] = fix_to_float( hFdCngCom->exc_cng_32fx[i], Q_in - 9 ); } return; } #endif /*------------------------------------------------------------------- * SynthesisSTFT_dirac_flt() Loading Loading @@ -1072,7 +1192,25 @@ float rand_gauss_flt( return temp; } #ifdef IVAS_FLOAT_FIXED Word32 rand_gauss_fx( Word32 *x, Word16 *seed, Word16 q ) { Word32 temp; temp = own_random( seed ); temp = L_add(temp, own_random( seed )); temp = L_add(temp, own_random( seed )); temp = L_shr(temp, 15 - q); *x = temp; return temp; } #endif /*------------------------------------------------------------------- * lpc_from_spectrum_flt() Loading @@ -1094,6 +1232,9 @@ void lpc_from_spectrum_flt( int16_t fftlen = hFdCngCom->fftlen; const float *fftSineTab = hFdCngCom->fftSineTab_flt; float *A = hFdCngCom->A_cng_flt; #ifdef IVAS_FLOAT_FIXED Word16 *A_fx = hFdCngCom->A_cng; #endif /* Power Spectrum */ ptr = fftBuffer; Loading Loading @@ -1147,7 +1288,12 @@ void lpc_from_spectrum_flt( /* LPC */ lev_dur( A, r, M, NULL ); #ifdef IVAS_FLOAT_FIXED for ( i = 0; i < M + 1; i++ ) { A_fx[i] = float_to_fix16( A[i], Q13 ); } #endif return; } Loading lib_com/ivas_cnst.h +2 −0 Original line number Diff line number Diff line Loading @@ -50,6 +50,8 @@ #define _180_OVER_PI_Q25 1922527233 #define PI_OVER_4_Q29 421657440 #define PI_OVER_Q29 1686629760 #define Q31_0_99 2126008811 #define Q31_0_01 21474836 #endif #define SQRT2 1.414213562373095f Loading lib_com/ivas_prot_fx.h +47 −0 Original line number Diff line number Diff line Loading @@ -942,4 +942,51 @@ void ivas_decision_matrix_dec_fx( const Word16 nchan_out /* i : Number of output channels */ ); void cmplx_matrix_square_fx( const Word32 *realX, /* i : real part of the matrix */ const Word32 *imagX, /* i : imaginary part of the matrix */ const Word16 mRows, /* i : number of rows of the matrix */ const Word16 nCols, /* i : number of columns of the matrix */ Word32 *realZ, /* o : real part of the resulting matrix */ Word32 *imagZ, /* o : imaginary part of the resulting matrix */ Word16 input_exp, Word16 *output_exp ); Word16 matrix_diag_product_fx( const Word32 *X, /* i : left hand matrix */ Word16 X_e, const Word16 rowsX, /* i : number of rows of the left hand matrix */ const Word16 colsX, /* i : number of columns of the left hand matrix */ const Word16 transpX, /* i : flag indicating the transposition of the left hand matrix prior to the multiplication */ const Word32 *Y, /* i : right hand diagonal matrix as vector containing the diagonal elements */ Word16 Y_e, const Word16 entriesY, /* i : number of entries in the diagonal */ Word32 *Z, /* o : resulting matrix after the matrix multiplication */ Word16 *Z_e ); Word16 diag_matrix_product_fx( const Word32 *Y, /* i : left hand diagonal matrix as vector containing the diagonal elements */ Word16 Y_e, const Word16 entriesY, /* i : length of the diagonal of the left hand matrix */ const Word32 *X, /* i : right hand matrix */ Word16 X_e, const Word16 rowsX, /* i : number of rows of the right hand matrix */ const Word16 colsX, /* i : number of columns of the right hand matrix */ const Word16 transpX, /* i : flag indicating the transposition of the right hand matrix prior to the multiplication */ Word32 *Z, /* o : resulting matrix after the matrix multiplication */ Word16 *Z_e ); Word16 matrix_product_diag_fx( const Word32 *X, /* i : left hand matrix */ Word16 X_e, const Word16 rowsX, /* i : number of rows of the left hand matrix */ const Word16 colsX, /* i : number of columns of the left hand matrix */ const Word16 transpX, /* i : flag indicating the transposition of the left hand matrix prior to the multiplication */ const Word32 *Y, /* i : right hand matrix */ Word16 Y_e, const Word16 rowsY, /* i : number of rows of the right hand matrix */ const Word16 colsY, /* i : number of columns of the right hand matrix */ const Word16 transpY, /* i : flag indicating the transposition of the right hand matrix prior to the multiplication */ Word32 *Z, /* o : resulting matrix after the matrix multiplication */ Word16 *Z_e ); #endif Loading
lib_com/cnst.h +1 −0 Original line number Diff line number Diff line Loading @@ -1666,6 +1666,7 @@ enum #define FD_CNG_JOINT_stages_25bits 4 #define OUTMAX_INV 0.000030517578125f /* 1/2^15 */ #define OUTMAX_INV_FX 65536 /* 1/2^15 (Q31) */ #define OUTMAX_SQ 1073741824.f /* 2^30 */ #define OUTMAX_SQ_INV 0.00000000093132257461547852f /* 1/2^30 */ Loading
lib_com/fd_cng_com.c +148 −2 Original line number Diff line number Diff line Loading @@ -39,10 +39,14 @@ #include "options.h" #include <math.h> #include "prot.h" #include "prot_fx2.h" #include "rom_com.h" #include "wmc_auto.h" #ifdef IVAS_FLOAT_FIXED #define FFT_SCALING_512 1073741824 //Q22 #define FFT_SCALING_640 1342177280 //Q22 #endif /*------------------------------------------------------------------- * Local function prototypes *-------------------------------------------------------------------*/ Loading Loading @@ -103,6 +107,10 @@ void initFdCngCom_flt( set_f( hFdCngCom->sidNoiseEst_flt, 0.0f, NPART ); set_f( hFdCngCom->A_cng_flt, 0.0f, M + 1 ); hFdCngCom->A_cng_flt[0] = 1.f; #ifdef IVAS_FLOAT_FIXED set_s( hFdCngCom->A_cng, 0, M + 1 ); hFdCngCom->A_cng[0] = MAX_16; #endif /* Set some counters and flags */ hFdCngCom->inactive_frame_counter = 0; /* Either SID or zero frames */ Loading @@ -110,6 +118,9 @@ void initFdCngCom_flt( hFdCngCom->frame_type_previous = ACTIVE_FRAME; hFdCngCom->flag_noisy_speech = 0; hFdCngCom->likelihood_noisy_speech_flt = 0.f; #ifdef IVAS_FLOAT_FIXED hFdCngCom->likelihood_noisy_speech_32fx = 0; #endif hFdCngCom->numCoreBands = 0; hFdCngCom->stopBand = 0; hFdCngCom->startBand = 0; Loading Loading @@ -937,6 +948,115 @@ void SynthesisSTFT_flt( return; } #ifdef IVAS_FLOAT_FIXED /*------------------------------------------------------------------- * SynthesisSTFT_fx() * * STFT synthesis filterbank *-------------------------------------------------------------------*/ void SynthesisSTFT_fx( Word32 *fftBuffer, /* i : FFT bins */ Word16 Q_in, Word32 *timeDomainOutput, Word32 *olapBuffer, const Word16 *olapWin, const int16_t tcx_transition, HANDLE_FD_CNG_COM hFdCngCom, /* i/o: FD_CNG structure containing all buffers and variables */ const int16_t element_mode, /* i : element mode */ const int16_t nchan_out /* i : number of output channels */ ) { int16_t i; Word32 buf_fx[M + 1 + 320], tmp_fx; /* Perform IFFT */ RFFTN_fx( fftBuffer, hFdCngCom->fftSineTab_fx, hFdCngCom->fftlen, 1 ); /* Handle overlap in P/S domain for stereo */ IF( ( element_mode == IVAS_CPE_TD || element_mode == IVAS_CPE_DFT ) && nchan_out == 2 ) { mvl2l( olapBuffer + 3 * hFdCngCom->frameSize / 4 - ( M + 1 ), buf_fx, hFdCngCom->frameSize + M + 1 ); set_l( olapBuffer, 0, hFdCngCom->fftlen ); } ELSE { mvl2l( olapBuffer + hFdCngCom->frameSize, olapBuffer, hFdCngCom->frameSize ); set_l( olapBuffer + hFdCngCom->frameSize, 0, hFdCngCom->frameSize ); /*olapBuffer, fftBuffer, olapWin*/ } IF( tcx_transition ) { FOR( i = 0; i < 5 * hFdCngCom->frameSize / 4; i++ ) { olapBuffer[i] = fftBuffer[i]; } } ELSE { FOR( i = hFdCngCom->frameSize / 4; i < 3 * hFdCngCom->frameSize / 4; i++ ) { olapBuffer[i] = L_add( olapBuffer[i], Mpy_32_16_1( fftBuffer[i], olapWin[i - hFdCngCom->frameSize / 4] ) ); } FOR( ; i < 5 * hFdCngCom->frameSize / 4; i++ ) { olapBuffer[i] = fftBuffer[i]; } } FOR( ; i < 7 * hFdCngCom->frameSize / 4; i++ ) { olapBuffer[i] = Mpy_32_16_1( fftBuffer[i], olapWin[i - 3 * hFdCngCom->frameSize / 4] ); } FOR( ; i < hFdCngCom->fftlen; i++ ) { olapBuffer[i] = 0; } Word32 fftScale = 0; SWITCH( hFdCngCom->fftlen ) { case 640: fftScale = FFT_SCALING_640; break; case 512: fftScale = FFT_SCALING_512; break; default: assert( !"Not supported FFT length!" ); } /* Get time-domain signal */ // v_multc(olapBuffer + hFdCngCom->frameSize / 4, (float)(hFdCngCom->fftlen / 2), timeDomainOutput, hFdCngCom->frameSize); v_multc_fixed( olapBuffer + hFdCngCom->frameSize / 4, fftScale, timeDomainOutput, hFdCngCom->frameSize ); // Q_in - 9 /* Get excitation */ IF( ( element_mode == IVAS_CPE_TD || element_mode == IVAS_CPE_DFT ) && nchan_out == 2 ) { FOR( i = 0; i < hFdCngCom->frameSize / 2; i++ ) { buf_fx[i + ( M + 1 )] = L_add( buf_fx[i + ( M + 1 )], olapBuffer[i + hFdCngCom->frameSize / 4] ); } // v_multc(buf, (float)(hFdCngCom->fftlen / 2), buf, M + 1 + hFdCngCom->frameSize); v_multc_fixed( buf_fx, fftScale, buf_fx, M + 1 + hFdCngCom->frameSize ); } ELSE { // v_multc(olapBuffer + hFdCngCom->frameSize / 4 - (M + 1), (float)(hFdCngCom->fftlen / 2), buf, M + 1 + hFdCngCom->frameSize); v_multc_fixed( olapBuffer + ( hFdCngCom->frameSize / 4 ) - ( M + 1 ), fftScale, buf_fx, M + 1 + hFdCngCom->frameSize ); } tmp_fx = buf_fx[0]; // preemph(buf + 1, PREEMPH_FAC_FLT, M + hFdCngCom->frameSize, &tmp); preemph_ivas_fx( buf_fx + 1, PREEMPH_FAC, M + hFdCngCom->frameSize, &tmp_fx ); // residu(hFdCngCom->A_cng_flt, M, buf + 1 + M, hFdCngCom->exc_cng_flt, hFdCngCom->frameSize); residu_ivas_fx( hFdCngCom->A_cng, Q13, M, buf_fx + 1 + M, hFdCngCom->exc_cng_32fx, hFdCngCom->frameSize ); for ( i = 0; i < hFdCngCom->frameSize; i++ ) { hFdCngCom->exc_cng_flt[i] = fix_to_float( hFdCngCom->exc_cng_32fx[i], Q_in - 9 ); } return; } #endif /*------------------------------------------------------------------- * SynthesisSTFT_dirac_flt() Loading Loading @@ -1072,7 +1192,25 @@ float rand_gauss_flt( return temp; } #ifdef IVAS_FLOAT_FIXED Word32 rand_gauss_fx( Word32 *x, Word16 *seed, Word16 q ) { Word32 temp; temp = own_random( seed ); temp = L_add(temp, own_random( seed )); temp = L_add(temp, own_random( seed )); temp = L_shr(temp, 15 - q); *x = temp; return temp; } #endif /*------------------------------------------------------------------- * lpc_from_spectrum_flt() Loading @@ -1094,6 +1232,9 @@ void lpc_from_spectrum_flt( int16_t fftlen = hFdCngCom->fftlen; const float *fftSineTab = hFdCngCom->fftSineTab_flt; float *A = hFdCngCom->A_cng_flt; #ifdef IVAS_FLOAT_FIXED Word16 *A_fx = hFdCngCom->A_cng; #endif /* Power Spectrum */ ptr = fftBuffer; Loading Loading @@ -1147,7 +1288,12 @@ void lpc_from_spectrum_flt( /* LPC */ lev_dur( A, r, M, NULL ); #ifdef IVAS_FLOAT_FIXED for ( i = 0; i < M + 1; i++ ) { A_fx[i] = float_to_fix16( A[i], Q13 ); } #endif return; } Loading
lib_com/ivas_cnst.h +2 −0 Original line number Diff line number Diff line Loading @@ -50,6 +50,8 @@ #define _180_OVER_PI_Q25 1922527233 #define PI_OVER_4_Q29 421657440 #define PI_OVER_Q29 1686629760 #define Q31_0_99 2126008811 #define Q31_0_01 21474836 #endif #define SQRT2 1.414213562373095f Loading
lib_com/ivas_prot_fx.h +47 −0 Original line number Diff line number Diff line Loading @@ -942,4 +942,51 @@ void ivas_decision_matrix_dec_fx( const Word16 nchan_out /* i : Number of output channels */ ); void cmplx_matrix_square_fx( const Word32 *realX, /* i : real part of the matrix */ const Word32 *imagX, /* i : imaginary part of the matrix */ const Word16 mRows, /* i : number of rows of the matrix */ const Word16 nCols, /* i : number of columns of the matrix */ Word32 *realZ, /* o : real part of the resulting matrix */ Word32 *imagZ, /* o : imaginary part of the resulting matrix */ Word16 input_exp, Word16 *output_exp ); Word16 matrix_diag_product_fx( const Word32 *X, /* i : left hand matrix */ Word16 X_e, const Word16 rowsX, /* i : number of rows of the left hand matrix */ const Word16 colsX, /* i : number of columns of the left hand matrix */ const Word16 transpX, /* i : flag indicating the transposition of the left hand matrix prior to the multiplication */ const Word32 *Y, /* i : right hand diagonal matrix as vector containing the diagonal elements */ Word16 Y_e, const Word16 entriesY, /* i : number of entries in the diagonal */ Word32 *Z, /* o : resulting matrix after the matrix multiplication */ Word16 *Z_e ); Word16 diag_matrix_product_fx( const Word32 *Y, /* i : left hand diagonal matrix as vector containing the diagonal elements */ Word16 Y_e, const Word16 entriesY, /* i : length of the diagonal of the left hand matrix */ const Word32 *X, /* i : right hand matrix */ Word16 X_e, const Word16 rowsX, /* i : number of rows of the right hand matrix */ const Word16 colsX, /* i : number of columns of the right hand matrix */ const Word16 transpX, /* i : flag indicating the transposition of the right hand matrix prior to the multiplication */ Word32 *Z, /* o : resulting matrix after the matrix multiplication */ Word16 *Z_e ); Word16 matrix_product_diag_fx( const Word32 *X, /* i : left hand matrix */ Word16 X_e, const Word16 rowsX, /* i : number of rows of the left hand matrix */ const Word16 colsX, /* i : number of columns of the left hand matrix */ const Word16 transpX, /* i : flag indicating the transposition of the left hand matrix prior to the multiplication */ const Word32 *Y, /* i : right hand matrix */ Word16 Y_e, const Word16 rowsY, /* i : number of rows of the right hand matrix */ const Word16 colsY, /* i : number of columns of the right hand matrix */ const Word16 transpY, /* i : flag indicating the transposition of the right hand matrix prior to the multiplication */ Word32 *Z, /* o : resulting matrix after the matrix multiplication */ Word16 *Z_e ); #endif