diff --git a/lib_com/core_com_config.c b/lib_com/core_com_config.c index 90974ba841325df0d57751f54d4b8b0384b51683..e99e2323b9455c0a5156ad9720b47dc6617f00f8 100644 --- a/lib_com/core_com_config.c +++ b/lib_com/core_com_config.c @@ -1334,8 +1334,6 @@ void init_tcx_window_cfg_fx( const Word32 input_Fs, /* i : input/output SR */ const Word16 L_frame, /* i : L_frame at sr_core */ const Word16 L_frameTCX, /* i : L_frame at i/o SR */ - const Word16 encoderLookahead_enc, /* i : encoder LA at sr_core */ - const Word16 encoderLookahead_FB, /* i : encoder LA at i/o SR */ const Word16 mdctWindowLength, /* i : window length at sr_core */ const Word16 mdctWindowLengthFB, /* i : window length at i/o SR */ const Word16 element_mode /* i : mode of CPE/SCE */ @@ -1433,8 +1431,6 @@ void init_tcx_cfg_fx( const Word16 bwidth, const Word16 L_frameTCX, const Word16 fscale, - const Word16 encoderLookahead_enc, - const Word16 encoderLookahead_FB, const Word16 preemph_fac, const Word16 tcxonly, const Word16 rf_mode, @@ -1460,7 +1456,7 @@ void init_tcx_cfg_fx( move16(); mdctWindowLength = getMdctWindowLength_fx( fscale ); mdctWindowLengthFB = getMdctWindowLength_fx(fscaleFB); - init_tcx_window_cfg_fx( hTcxCfg, sr_core, input_Fs, L_frame, L_frameTCX, encoderLookahead_enc, encoderLookahead_FB, mdctWindowLength, mdctWindowLengthFB, element_mode ); + init_tcx_window_cfg_fx( hTcxCfg, sr_core, input_Fs, L_frame, L_frameTCX, mdctWindowLength, mdctWindowLengthFB, element_mode ); /* SQ deadzone & memory quantization*/ hTcxCfg->sq_rounding = 12288 /*0.375f Q15*/; /*deadzone of 1.25->rounding=1-1.25/2 (No deadzone=0.5)*/ move16(); diff --git a/lib_com/float_to_fix_ops.c b/lib_com/float_to_fix_ops.c index 797dcd063212626353b42a7781f1bd09af2f27fd..b3c6b63bbe1c33fab98fbcc84b9fd475a019af36 100644 --- a/lib_com/float_to_fix_ops.c +++ b/lib_com/float_to_fix_ops.c @@ -33,7 +33,20 @@ void floatToFixed_arr(float *f, Word16 *i, Word16 Q, Word16 l) { for (int j = 0; j < l; j++) { +#if 0 i[j] = (Word16)floatToFixed(f[j], Q); +#else + Word32 i32_val = floatToFixed(f[j], Q); + IF (i32_val > MAX_16) + { + i32_val = MAX_16; + } + ELSE IF (i32_val < MIN_16) + { + i32_val = MIN_16; + } + i[j] = (Word16)i32_val; +#endif } } void fixedToFloat_arrL(Word32 *i, float *f, Word16 Q, Word16 l) diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index a180ac8f705f85584c6e6ca2eb98a3a315133600..de33739c3b9a3c52e82aae26a99aa860ca2b901c 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -381,8 +381,8 @@ ivas_error ivas_corecoder_dec_reconfig( ); #ifdef IVAS_FLOAT_FIXED ivas_error ivas_hp20_dec_reconfig_fx( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const Word16 nchan_hp20_old /* i : number of HP20 filters in previous frame*/ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + const Word16 nchan_hp20_old /* i : number of HP20 filters in previous frame*/ ); #endif // IVAS_FLOAT_FIXED @@ -2986,6 +2986,21 @@ void v_add_inc( const int16_t N /* i : Vector length */ ); +#ifdef IVAS_FLOAT_FIXED +void v_mult_inc_fx( + const Word32 x1_fx[], /* i : Input vector 1 */ + Word16 *x1_q_fx, + const Word16 x1_inc, /* i : Increment for input vector 1 */ + const Word32 x2_fx[], /* i : Input vector 2 */ + Word16 *x2_q_fx, + const Word16 x2_inc, /* i : Increment for input vector 1 */ + Word32 y_fx[], /* o : Output vector that contains vector 1 .* vector 2 */ + Word16 *y_q_fx, + const Word16 y_inc, /* i : increment for vector y[i] */ + const Word16 N /* i : Vector length */ +); +#endif + void v_mult_inc( const float x1[], /* i : Input vector 1 */ const int16_t x1_inc, /* i : Increment for input vector 1 */ @@ -2996,6 +3011,14 @@ void v_mult_inc( const int16_t N /* i : Vector length */ ); +#ifdef IVAS_FLOAT_FIXED +void v_addc_fx( + const Word32 x_fx[], /* i : Input vector */ + const Word32 c_fx, /* i : Constant */ + Word32 y_fx[], /* o : Output vector that contains c*x */ + const Word16 N /* i : Vector length */ +); +#endif void v_addc( const float x[], /* i : Input vector */ const float c, /* i : Constant */ @@ -3003,6 +3026,17 @@ void v_addc( const int16_t N /* i : Vector length */ ); +#ifdef IVAS_FLOAT_FIXED +void v_min_fx( + const Word32 x1_fx[], /* i : Input vector 1 */ + Word16 *x1_q_fx, + const Word32 x2_fx[], /* i : Input vector 2 */ + Word16 *x2_q_fx, + Word32 y_fx[], /* o : Output vector that contains vector 1 .* vector 2 */ + Word16 *y_q_fx, + const Word16 N /* i : Vector length */ +); +#endif void v_min( const float x1[], /* i : Input vector 1 */ const float x2[], /* i : Input vector 2 */ @@ -3035,6 +3069,19 @@ float dot_product_cholesky( const int16_t N /* i : vector & matrix size */ ); +#ifdef IVAS_FLOAT_FIXED +void v_mult_mat_fx( + Word32 *y_fx, /* o : the product x*A */ + Word16 *y_q_fx, + const Word32 *x_fx, /* i : vector x */ + Word16 *x_q_fx, + const Word32 *A_fx, /* i : matrix A */ + Word16 *A_q_fx, + const Word16 N, /* i : number of rows */ + const Word16 C /* i : number of columns */ +); +#endif + void v_mult_mat( float *y, /* o : the product x*A */ const float *x, /* i : vector x */ diff --git a/lib_com/ivas_tools.c b/lib_com/ivas_tools.c index e4e7c53ae1394a6dddaa3546dd4aaa0f8936d75d..42e34e7df1a93ae562c150a4e46d736e34ccc042 100644 --- a/lib_com/ivas_tools.c +++ b/lib_com/ivas_tools.c @@ -41,6 +41,9 @@ #include "ivas_rom_com.h" #include "prot_fx1.h" #include "prot_fx2.h" +#ifndef IVAS_FLOAT_FIXED +#include +#endif #define ANGLE_90_DEG_Q22 377487360 #define ANGLE_180_DEG_Q22 754974720 @@ -262,6 +265,44 @@ void v_add_inc( } +#ifdef IVAS_FLOAT_FIXED +/*-------------------------------------------------------------------* + * v_mult_inc_fx() + * + * Multiplication of two vectors with explicit increments + *-------------------------------------------------------------------*/ + +void v_mult_inc_fx( + const Word32 x1_fx[], /* i : Input vector 1 */ + Word16 *x1_q_fx, + const Word16 x1_inc, /* i : Increment for input vector 1 */ + const Word32 x2_fx[], /* i : Input vector 2 */ + Word16 *x2_q_fx, + const Word16 x2_inc, /* i : Increment for input vector 1 */ + Word32 y_fx[], /* o : Output vector that contains vector 1 .* vector 2 */ + Word16 *y_q_fx, + const Word16 y_inc, /* i : increment for vector y[i] */ + const Word16 N /* i : Vector length */ +) +{ + Word16 i; + Word16 ix1 = 0; + Word16 ix2 = 0; + Word16 iy = 0; + + FOR( i = 0; i < N; i++ ) + { + y_fx[iy] = Mpy_32_32( x1_fx[ix1], x2_fx[ix2] ); + y_q_fx[iy] = sub( add( x1_q_fx[ix1], x2_q_fx[ix2] ), 31 ); + + ix1 = add( ix1, x1_inc ); + ix2 = add( ix2, x2_inc ); + iy = add( iy, y_inc ); + } + + return; +} +#endif /*-------------------------------------------------------------------* * v_mult_inc() * @@ -283,6 +324,44 @@ void v_mult_inc( int16_t ix2 = 0; int16_t iy = 0; +#ifdef IVAS_FLOAT_FIXED + ///////////////// to be removed //////////////////////////////// + Word32 x1_fx[2 * MAX_OUTPUT_CHANNELS * CLDFB_NO_CHANNELS_MAX]; + Word32 x2_fx[2 * MAX_OUTPUT_CHANNELS * CLDFB_NO_CHANNELS_MAX]; + Word32 y_fx[2 * MAX_OUTPUT_CHANNELS * CLDFB_NO_CHANNELS_MAX]; + Word16 y_q_fx[2 * MAX_OUTPUT_CHANNELS * CLDFB_NO_CHANNELS_MAX]; + Word16 x1_q_fx[2 * MAX_OUTPUT_CHANNELS * CLDFB_NO_CHANNELS_MAX]; + Word16 x2_q_fx[2 * MAX_OUTPUT_CHANNELS * CLDFB_NO_CHANNELS_MAX]; + FOR( i = 0; i < N; i++ ) + { + x1_q_fx[ix1] = Q_factor_L( x1[ix1] ); + x1_fx[ix1] = (Word32) ( x1[ix1] * ( W_shl( 1, x1_q_fx[ix1] ) ) ); + x2_q_fx[ix2] = Q_factor_L( x2[ix2] ); + x2_fx[ix2] = (Word32) ( x2[ix2] * ( W_shl( 1, x2_q_fx[ix2] ) ) ); + ix1 = add( ix1, x1_inc ); + ix2 = add( ix2, x2_inc ); + iy = add( iy, y_inc ); + } + //////////////////////////////////////////////////////////////////// + + v_mult_inc_fx( x1_fx, x1_q_fx, x1_inc, x2_fx, x2_q_fx, x2_inc, y_fx, y_q_fx, y_inc, N ); + + /////////////////////// to be removed /////////////////////////////// + iy = 0; + FOR( i = 0; i < N; i++ ) + { + IF( LT_16( y_q_fx[iy], 0 ) ) + { + y[iy] = (Float32) y_fx[iy] * ( W_shl( 1, ( -y_q_fx[iy] ) ) ); + } + ELSE + { + y[iy] = (Float32) y_fx[iy] / ( W_shl( 1, y_q_fx[iy] ) ); + } + iy = add( iy, y_inc ); + } + /////////////////////////////////////////////////////////////////////// +#else for ( i = 0; i < N; i++ ) { y[iy] = x1[ix1] * x2[ix2]; @@ -290,10 +369,34 @@ void v_mult_inc( ix2 += x2_inc; iy += y_inc; } - +#endif return; } +#ifdef IVAS_FLOAT_FIXED +/*-------------------------------------------------------------------* + * v_addc_fx() + * + * Addition of constant to vector + *-------------------------------------------------------------------*/ + +void v_addc_fx( + const Word32 x_fx[], /* i : Input vector */ + const Word32 c_fx, /* i : Constant */ + Word32 y_fx[], /* o : Output vector that contains c*x */ + const Word16 N /* i : Vector length */ +) +{ + Word16 i; + + FOR( i = 0; i < N; i++ ) + { + y_fx[i] = L_add( c_fx, x_fx[i] ); + } + + return; +} +#endif /*-------------------------------------------------------------------* * v_addc() * @@ -309,14 +412,87 @@ void v_addc( { int16_t i; +#ifdef IVAS_FLOAT_FIXED + Word32 x_fx[CLDFB_NO_CHANNELS_MAX]; + Word32 y_fx[CLDFB_NO_CHANNELS_MAX]; + const Word32 c_fx = (Word32) ( c * L_shl( 1, 29 ) ); + + //////////////////////////// to be removed ////////////////////// + FOR( i = 0; i < N; i++ ) + { + x_fx[i] = (Word32) ( x[i] * L_shl( 1, 29 ) ); + } + ///////////////////////////////////////////////////////////////// + + v_addc_fx( (const Word32 *) x_fx, c_fx, y_fx, N ); + + ///////////////////////////// to be removed ////////////////////// + FOR( i = 0; i < N; i++ ) + { + y[i] = (Float32) y_fx[i] / L_shl( 1, 29 ); + } + /////////////////////////////////////////////////////////////////// +#else for ( i = 0; i < N; i++ ) { y[i] = c + x[i]; } - +#endif return; } +#ifdef IVAS_FLOAT_FIXED +/*-------------------------------------------------------------------* + * v_min_fx() + * + * minimum of two vectors + *-------------------------------------------------------------------*/ + +void v_min_fx( + const Word32 x1_fx[], /* i : Input vector 1 */ + Word16 *x1_q_fx, + const Word32 x2_fx[], /* i : Input vector 2 */ + Word16 *x2_q_fx, + Word32 y_fx[], /* o : Output vector that contains vector 1 .* vector 2 */ + Word16 *y_q_fx, + const Word16 N /* i : Vector length */ +) +{ + Word16 i; + + FOR( i = 0; i < N; i++ ) + { + IF( GT_16( x1_q_fx[i], x2_q_fx[i] ) ) + { + IF( LT_32( L_shr( x1_fx[i], sub( x1_q_fx[i], x2_q_fx[i] ) ), x2_fx[i] ) ) + { + y_fx[i] = x1_fx[i]; + y_q_fx[i] = x1_q_fx[i]; + } + ELSE + { + y_fx[i] = x2_fx[i]; + y_q_fx[i] = x2_q_fx[i]; + } + } + ELSE + { + IF( LT_32( x1_fx[i], L_shr( x2_fx[i], sub( x2_q_fx[i], x1_q_fx[i] ) ) ) ) + { + y_fx[i] = x1_fx[i]; + y_q_fx[i] = x1_q_fx[i]; + } + ELSE + { + y_fx[i] = x2_fx[i]; + y_q_fx[i] = x2_q_fx[i]; + } + } + } + + return; +} +#endif /*-------------------------------------------------------------------* * v_min() * @@ -332,11 +508,37 @@ void v_min( { int16_t i; +#ifdef IVAS_FLOAT_FIXED + //////////////////////// to be removed /////////////////////////////// + Word32 x1_fx[MASA_FREQUENCY_BANDS]; + Word32 x2_fx[MASA_FREQUENCY_BANDS]; + Word32 y_fx[MASA_FREQUENCY_BANDS]; + Word16 x1_q_fx[MASA_FREQUENCY_BANDS]; + Word16 x2_q_fx[MASA_FREQUENCY_BANDS]; + Word16 y_q_fx[MASA_FREQUENCY_BANDS]; + FOR( i = 0; i < N; i++ ) + { + x1_q_fx[i] = Q_factor_L( x1[i] ); + x1_fx[i] = (Word32) ( x1[i] * ( W_shl( 1, x1_q_fx[i] ) ) ); + x2_q_fx[i] = Q_factor_L( x2[i] ); + x2_fx[i] = (Word32) ( x2[i] * ( W_shl( 1, x2_q_fx[i] ) ) ); + } + ///////////////////////////////////////////////////////////////////////// + + v_min_fx( (const Word32 *) x1_fx, x1_q_fx, (const Word32 *) x2_fx, x2_q_fx, y_fx, y_q_fx, N ); + + //////////////////////// to be removed //////////////////////////////// + FOR( i = 0; i < N; i++ ) + { + y[i] = (Float32) y_fx[i] / ( W_shl( 1, y_q_fx[i] ) ); + } + /////////////////////////////////////////////////////////////////////// +#else for ( i = 0; i < N; i++ ) { y[i] = ( x1[i] < x2[i] ) ? x1[i] : x2[i]; } - +#endif return; } @@ -443,6 +645,72 @@ float dot_product_cholesky( return suma; } +#ifdef IVAS_FLOAT_FIXED +/*---------------------------------------------------------------------* + * v_mult_mat_fx() + * + * Multiplication of row vector x by matrix A, where x has size Nr and + * A has size Nr x Nc ans it is stored column-wise in memory. + * The resulting row vector y has size Nc + *---------------------------------------------------------------------*/ + +void v_mult_mat_fx( + Word32 *y_fx, /* o : the product x*A */ + Word16 *y_q_fx, + const Word32 *x_fx, /* i : vector x */ + Word16 *x_q_fx, + const Word32 *A_fx, /* i : matrix A */ + Word16 *A_q_fx, + const Word16 Nr, /* i : number of rows */ + const Word16 Nc /* i : number of columns */ +) +{ + Word16 i, j; + const Word32 *pt_x_fx, *pt_A_fx; + Word32 *pt_y_fx; + Word32 tmp_y_fx[MAX_V_MULT_MAT]; + Word32 temp; + Word16 temp_q; + + pt_y_fx = tmp_y_fx; + pt_A_fx = A_fx; + pt_x_fx = x_fx; + + FOR( i = 0; i < Nc; i++ ) + { + pt_x_fx = x_fx; + *pt_y_fx = 0; + y_q_fx[i] = 0; + FOR( j = 0; j < Nr; j++ ) + { + temp = Mpy_32_32( *pt_x_fx++, *pt_A_fx++ ); + temp_q = sub( add( x_q_fx[j], A_q_fx[Nr * i + j] ), 31 ); + IF( EQ_16( j, 0 ) ) + { + *pt_y_fx = temp; + y_q_fx[i] = temp_q; + } + ELSE + { + IF( GT_16( y_q_fx[i], temp_q ) ) + { + *pt_y_fx = L_add( L_shr( *pt_y_fx, sub( y_q_fx[i], temp_q ) ), temp ); + y_q_fx[i] = temp_q; + } + ELSE + { + *pt_y_fx = L_add( *pt_y_fx, L_shr( temp, sub( temp_q, y_q_fx[i] ) ) ); + } + } + } + pt_y_fx++; + } + + mvr2r_Word32( tmp_y_fx, y_fx, Nc ); + + return; +} +#endif /*---------------------------------------------------------------------* * v_mult_mat() * @@ -460,12 +728,63 @@ void v_mult_mat( ) { int16_t i, j; + +#ifdef IVAS_FLOAT_FIXED + //////////////////// to be removed ////////////////////// + Word32 y_fx[NB_MEL_BANDS]; + Word32 x_fx[NB_MEL_BANDS]; + Word32 A_fx[NB_MEL_BANDS * NB_MEL_COEF]; + Word16 y_q_fx[NB_MEL_BANDS]; + Word16 x_q_fx[NB_MEL_BANDS]; + Word16 A_q_fx[NB_MEL_BANDS * NB_MEL_COEF]; + Word32 *pt_x_fx, *pt_A_fx; + const Float32 *pt_x, *pt_A; + Word16 *pt_x_q_fx, *pt_A_q_fx; + + pt_A_fx = A_fx; + pt_A_q_fx = A_q_fx; + pt_A = A; + + FOR( i = 0; i < Nc; i++ ) + { + pt_x = x; + pt_x_fx = x_fx; + pt_x_q_fx = x_q_fx; + FOR( j = 0; j < Nr; j++ ) + { + IF( EQ_16( i, 0 ) ) + { + *pt_x_q_fx = sub( Q_factor_L( *pt_x ), 3 ); + *pt_x_fx++ = (Word32) ( *pt_x++ * ( W_shl( 1, *pt_x_q_fx++ ) ) ); + } + *pt_A_q_fx = sub( Q_factor_L( *pt_A ), 3 ); + *pt_A_fx++ = (Word32) ( *pt_A++ * ( W_shl( 1, *pt_A_q_fx++ ) ) ); + } + } + + v_mult_mat_fx( y_fx, y_q_fx, (const Word32 *) x_fx, x_q_fx, (const Word32 *) A_fx, A_q_fx, Nr, Nc ); + + ////////////////////////////// to be removed //////////////////////// + FOR( i = 0; i < Nc; i++ ) + { + IF( LT_16( y_q_fx[i], 0 ) ) + { + y[i] = (Float32) y_fx[i] * W_shl( 1, -y_q_fx[i] ); + } + ELSE + { + y[i] = (Float32) y_fx[i] / W_shl( 1, y_q_fx[i] ); + } + } + //////////////////////////////////////////////////////////////////// +#else const float *pt_x, *pt_A; float tmp_y[MAX_V_MULT_MAT]; float *pt_y; pt_y = tmp_y; pt_A = A; + for ( i = 0; i < Nc; i++ ) { pt_x = x; @@ -478,7 +797,7 @@ void v_mult_mat( } mvr2r( tmp_y, y, Nc ); - +#endif return; } @@ -595,7 +914,6 @@ int16_t check_bounds_s( return value_adj; } - /*-------------------------------------------------------------------* * check_bounds_l() * diff --git a/lib_com/prot_fx2.h b/lib_com/prot_fx2.h index c3d460aaff486e9943d0a9d673d53c0435d991e6..f28e18fa1b29cb3588fd527fd2bca1a13b070d55 100644 --- a/lib_com/prot_fx2.h +++ b/lib_com/prot_fx2.h @@ -5877,8 +5877,6 @@ void init_tcx_window_cfg_fx( const Word32 input_Fs, /* i : input/output SR */ const Word16 L_frame, /* i : L_frame at sr_core */ const Word16 L_frameTCX, /* i : L_frame at i/o SR */ - const Word16 encoderLookahead_enc, /* i : encoder LA at sr_core */ - const Word16 encoderLookahead_FB, /* i : encoder LA at i/o SR */ const Word16 mdctWindowLength, /* i : window length at sr_core */ const Word16 mdctWindowLengthFB, /* i : window length at i/o SR */ const Word16 element_mode /* i : mode of CPE/SCE */ @@ -5893,8 +5891,6 @@ void init_tcx_cfg_fx( const Word16 bwidth, const Word16 L_frameTCX, const Word16 fscale, - const Word16 encoderLookahead_enc, - const Word16 encoderLookahead_FB, const Word16 preemph_fac, const Word16 tcxonly, const Word16 rf_mode, diff --git a/lib_com/swb_bwe_com_fx.c b/lib_com/swb_bwe_com_fx.c index 8f69bfebd035b2d798da3c6a2ee4938e152d3456..d940637b153ff029fcade514b19aecd03a8ab696 100644 --- a/lib_com/swb_bwe_com_fx.c +++ b/lib_com/swb_bwe_com_fx.c @@ -748,7 +748,7 @@ Word32 ivas_calc_tilt_bwe_fx( /* o : Tilt in Q24 */ FOR(j = shr(N, 5); j > 0; j--) { #ifdef BASOP_NOGLOB /* Critical Overflow and all those below*/ - Word16 tmp = mult_ro(*ptr++, 8192, &Overflow); /* Divide by 4 */ + Word16 tmp = mult_ro( (Word16) *ptr++, 8192, &Overflow ); /* Divide by 4 */ #else tmp1 = mult_r(*ptr++, 8192); /* Divide by 4 */ #endif diff --git a/lib_dec/acelp_core_dec.c b/lib_dec/acelp_core_dec.c index 7887e88e71785063fa110e9751745f425a11f57a..bb771d3ee62aabb09893e1ff2ce5e51507cc6f52 100644 --- a/lib_dec/acelp_core_dec.c +++ b/lib_dec/acelp_core_dec.c @@ -111,7 +111,6 @@ ivas_error acelp_core_dec( float *realBuffer[CLDFB_NO_COL_MAX], *imagBuffer[CLDFB_NO_COL_MAX]; #ifdef IVAS_FLOAT_FIXED Word32 *realBuffer_fx[CLDFB_NO_COL_MAX], *imagBuffer_fx[CLDFB_NO_COL_MAX]; - Word16 buffer_scale; Word32 realBufferTmp_fx[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; Word32 imagBufferTmp_fx[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; #endif // IVAS_FLOAT_FIXED diff --git a/lib_dec/core_dec_init.c b/lib_dec/core_dec_init.c index 609c0fa8ed27a3b1a96574c3d721591fb5b8c742..8fca8c89243dfd4fb01717d23911b57a2d5c4f06 100644 --- a/lib_dec/core_dec_init.c +++ b/lib_dec/core_dec_init.c @@ -188,7 +188,7 @@ void open_decoder_LPD_flt( if (!is_init || st->element_mode != IVAS_CPE_MDCT) { #ifdef IVAS_FLOAT_FIXED - init_tcx_cfg_fx( st->hTcxCfg, total_brate, st->sr_core, st->output_Fs, st->L_frame, st->bwidth, st->hTcxDec->L_frameTCX, st->fscale, encoderLookahead, encoderLookaheadFB, st->preemph_fac, st->tcxonly, st->rf_flag, st->igf, st->hIGFDec->infoIGFStopFreq, st->element_mode, st->ini_frame, MCT_flag, fscaleFB ); + init_tcx_cfg_fx( st->hTcxCfg, total_brate, st->sr_core, st->output_Fs, st->L_frame, st->bwidth, st->hTcxDec->L_frameTCX, st->fscale, st->preemph_fac, st->tcxonly, st->rf_flag, st->igf, st->hIGFDec->infoIGFStopFreq, st->element_mode, st->ini_frame, MCT_flag, fscaleFB ); st->hTcxCfg->preemph_fac_flt = st->preemph_fac_float; st->hTcxCfg->sq_rounding_flt = fix16_to_float( st->hTcxCfg->sq_rounding, 15 ); st->hTcxCfg->bandwidth_flt = fix16_to_float( st->hTcxCfg->bandwidth, 15 ); diff --git a/lib_dec/core_dec_init_fx.c b/lib_dec/core_dec_init_fx.c index 6614736904d6d011189b3b871a50fd10b8e2c736..be86427088d140d837ef373a52ef682805d485e6 100644 --- a/lib_dec/core_dec_init_fx.c +++ b/lib_dec/core_dec_init_fx.c @@ -1266,7 +1266,7 @@ void open_decoder_LPD_ivas_fx( { IF( !is_init || NE_16( st->element_mode, IVAS_CPE_MDCT ) ) { - init_tcx_cfg_fx( st->hTcxCfg, total_brate, st->sr_core, st->output_Fs, st->L_frame, st->bwidth, st->hTcxDec->L_frameTCX, st->fscale, encoderLookahead, encoderLookaheadFB, st->preemph_fac, st->tcxonly, st->rf_flag, st->igf, st->hIGFDec->infoIGFStopFreq, st->element_mode, st->ini_frame, MCT_flag, fscaleFB ); + init_tcx_cfg_fx( st->hTcxCfg, total_brate, st->sr_core, st->output_Fs, st->L_frame, st->bwidth, st->hTcxDec->L_frameTCX, st->fscale, st->preemph_fac, st->tcxonly, st->rf_flag, st->igf, st->hIGFDec->infoIGFStopFreq, st->element_mode, st->ini_frame, MCT_flag, fscaleFB ); } ELSE { diff --git a/lib_dec/dec_tcx.c b/lib_dec/dec_tcx.c index f011ec80ca30d7b6f0fdcd5a2f59a2337e0441bc..1f7aae46999e6253bf119e523ae7cdede127e529 100644 --- a/lib_dec/dec_tcx.c +++ b/lib_dec/dec_tcx.c @@ -2004,10 +2004,9 @@ void decoder_tcx_imdct_fx( Word32 xn_bufFB_fx[L_MDCT_OVLP_MAX + L_FRAME_PLUS + L_MDCT_OVLP_MAX]; float acelp_zir[L_FRAME_MAX / 2]; Word32 x_itf_fx[N_MAX_TCX - IGF_START_MN]; - float x_itf[N_MAX_TCX - IGF_START_MN]; float A_itf[ITF_MAX_FILTER_ORDER + 1]; float predictionGain; - int16_t index, proc; + int16_t index, proc = 0; TCX_LTP_DEC_HANDLE hTcxLtpDec = st->hTcxLtpDec; TCX_DEC_HANDLE hTcxDec = st->hTcxDec; TCX_CONFIG_HANDLE hTcxCfg = st->hTcxCfg; @@ -2189,6 +2188,7 @@ void decoder_tcx_imdct_fx( me2f_buf(xn_bufFB_fx, x_e, xn_bufFB, L_MDCT_OVLP_MAX + L_FRAME_PLUS + L_MDCT_OVLP_MAX ); predictionGain = fix16_to_float(predictionGain_fx, 15); #else + float x_itf[N_MAX_TCX - IGF_START_MN]; /*-----------------------------------------------------------------* * Initializations *-----------------------------------------------------------------*/ diff --git a/lib_dec/hq_core_dec.c b/lib_dec/hq_core_dec.c index 7fee85f69e7ab459aa11775706a8cb1af5d559f8..4299340c85186378262e9dfe7d24121358de5e6f 100644 --- a/lib_dec/hq_core_dec.c +++ b/lib_dec/hq_core_dec.c @@ -365,7 +365,7 @@ void hq_core_dec( st->last_core = HQ_CORE; /* Needed to decode non-transition frame */ } - init_tcx_window_cfg_fx( tcx_cfg, st->sr_core, st->output_Fs, st->L_frame, hTcxDec->L_frameTCX, encoderLookahead, encoderLookaheadFB, mdctWindowLength, mdctWindowLengthFB, st->element_mode ); + init_tcx_window_cfg_fx( tcx_cfg, st->sr_core, st->output_Fs, st->L_frame, hTcxDec->L_frameTCX, mdctWindowLength, mdctWindowLengthFB, st->element_mode ); init_tcx_info_fx( st, L_frame_glob, L_frameTCX_glob, 0, st->bfi, &tcx_offset, &tcx_offsetFB, &L_frame, &L_frameTCX, &left_rect, &L_spec ); diff --git a/lib_dec/hq_core_dec_fx.c b/lib_dec/hq_core_dec_fx.c index bcb57e436fb32fe3c30bbf5225ba9c93ae74c441..9eaecbc200891dc94c66f21db752af9e33a28035 100644 --- a/lib_dec/hq_core_dec_fx.c +++ b/lib_dec/hq_core_dec_fx.c @@ -945,7 +945,7 @@ void ivas_hq_core_dec_fx( move16(); } - init_tcx_window_cfg_fx( tcx_cfg, st_fx->sr_core, st_fx->output_Fs, st_fx->L_frame, hTcxDec->L_frameTCX, encoderLookahead, encoderLookaheadFB, mdctWindowLength, mdctWindowLengthFB, st_fx->element_mode ); + init_tcx_window_cfg_fx( tcx_cfg, st_fx->sr_core, st_fx->output_Fs, st_fx->L_frame, hTcxDec->L_frameTCX, mdctWindowLength, mdctWindowLengthFB, st_fx->element_mode ); init_tcx_info_fx( st_fx, L_frame_glob, L_frameTCX_glob, 0, st_fx->bfi, &tcx_offset, &tcx_offsetFB, &L_frame, &L_frameTCX, &left_rect, &L_spec ); diff --git a/lib_dec/ivas_dirac_output_synthesis_cov.c b/lib_dec/ivas_dirac_output_synthesis_cov.c index 164b6225a9627956b3ed33a6a93bbb2aadc4ab35..39e295f33683558e93a5dbb483f5178e3c4b329a 100644 --- a/lib_dec/ivas_dirac_output_synthesis_cov.c +++ b/lib_dec/ivas_dirac_output_synthesis_cov.c @@ -1306,7 +1306,6 @@ int16_t computeMixingMatricesISM( float Kx[MAX_TRANSPORT_CHANNELS]; float Ky[MAX_OUTPUT_CHANNELS * MAX_OUTPUT_CHANNELS]; float Kx_reg_inv[MAX_TRANSPORT_CHANNELS]; - float Q_Cx[MAX_OUTPUT_CHANNELS * MAX_OUTPUT_CHANNELS]; float Cy_hat_diag[MAX_OUTPUT_CHANNELS]; float G_hat[MAX_OUTPUT_CHANNELS]; float mat_mult_buffer1[MAX_OUTPUT_CHANNELS * MAX_OUTPUT_CHANNELS]; @@ -1337,6 +1336,8 @@ int16_t computeMixingMatricesISM( Word16 mat_mult_buffer1_fx_e; Word16 svd_u_buffer_fx_e[MAX_OUTPUT_CHANNELS]; Word16 svd_v_buffer_fx_e[MAX_OUTPUT_CHANNELS]; +#else + float Q_Cx[MAX_OUTPUT_CHANNELS * MAX_OUTPUT_CHANNELS]; #endif push_wmops( "dirac_cov_mix_mat" ); diff --git a/lib_dec/ivas_ism_dtx_dec.c b/lib_dec/ivas_ism_dtx_dec.c index 4f8027b3ec304fcb4357c92356122d6318f11546..2d81aae62e42ecef970931824a814b0995049479 100644 --- a/lib_dec/ivas_ism_dtx_dec.c +++ b/lib_dec/ivas_ism_dtx_dec.c @@ -304,8 +304,8 @@ void ivas_ism_dtx_limit_noise_energy_for_near_silence_fx( Word16 *Q_cngNoiseLevel /* i : stores Q factor of hFdCngCom->cngNoiseLevel for various channels*/ ) { - Word32 fac_fx, cng_noise_nrg_obj_fx, cng_noise_nrg_dominant_fx, Q_fac; - Word16 ch, cng_noise_level_len, Q_cng_noise_nrg_dominant; + Word32 fac_fx, cng_noise_nrg_obj_fx, cng_noise_nrg_dominant_fx; + Word16 ch, cng_noise_level_len, Q_cng_noise_nrg_dominant, Q_fac; HANDLE_FD_CNG_COM hFdCngCom; hFdCngCom = hSCE[sce_id_dtx]->hCoreCoder[0]->hFdCngDec->hFdCngCom; cng_noise_level_len = sub(hFdCngCom->stopFFTbin , hFdCngCom->startBand); diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index 9fcb1028b4ba2ddbd0a757c379937ce3cb6a8736..f6a6dbb2a61ec379f099202da932754188ba23eb 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -82,6 +82,7 @@ ivas_error ivas_jbm_dec_tc( float *p_output[MAX_TRANSPORT_CHANNELS]; /* 'float' buffer for output synthesis */ #ifdef IVAS_FLOAT_FIXED Word32 *p_output_fix[MAX_TRANSPORT_CHANNELS]; /* 'float' buffer for output synthesis */ + Word32 *p_output_fx[MAX_TRANSPORT_CHANNELS + MAX_NUM_OBJECTS]; /* 'float' buffer for output synthesis */ #endif int16_t nchan_remapped; int16_t nb_bits_metadata[MAX_SCE + 1]; @@ -190,7 +191,6 @@ ivas_error ivas_jbm_dec_tc( { #ifdef IVAS_FLOAT_FIXED Word16 i, j, q = Q16; - Word32 *p_output_fx[12]; q = q - find_guarded_bits_fx( st_ivas->nchan_transport ); FOR( i = 0; i < max(st_ivas->hDecoderConfig->nchan_out, st_ivas->nchan_transport); ++i ) { @@ -1075,7 +1075,6 @@ ivas_error ivas_jbm_dec_tc( if ( st_ivas->renderer_type == RENDERER_MONO_DOWNMIX ) { #ifdef IVAS_FLOAT_FIXED - Word32 *p_output_fx[12]; for ( int lp = 0; lp < 12; lp++ ) { if ( p_output[lp] != NULL ) @@ -1302,7 +1301,6 @@ ivas_error ivas_jbm_dec_tc( else if ( st_ivas->renderer_type == RENDERER_MONO_DOWNMIX && st_ivas->ism_mode == ISM_SBA_MODE_DISC ) { #ifdef IVAS_FLOAT_FIXED - Word32 *p_output_fx[12]; for ( int lp = 0; lp < 12; lp++ ) { if ( p_output[lp] != NULL ) @@ -1352,17 +1350,17 @@ ivas_error ivas_jbm_dec_tc( { /* LFE channel decoder */ #ifdef IVAS_FLOAT_FIXED - Word32 *p_output_fx; + Word32 *p_output_fx1; - p_output_fx = (Word32 *) malloc( ( 48000 / FRAMES_PER_SEC ) * sizeof( Word32 ) ); + p_output_fx1 = (Word32 *) malloc( ( 48000 / FRAMES_PER_SEC ) * sizeof( Word32 ) ); - ivas_lfe_dec_fx( st_ivas->hLFE, st, output_frame, st_ivas->bfi, p_output_fx ); + ivas_lfe_dec_fx( st_ivas->hLFE, st, output_frame, st_ivas->bfi, p_output_fx1 ); for ( int p = 0; p < 960; p++ ) { - p_output[LFE_CHANNEL][p] = (float) p_output_fx[p] / ONE_IN_Q9; + p_output[LFE_CHANNEL][p] = (float) p_output_fx1[p] / ONE_IN_Q9; } - free( p_output_fx ); + free( p_output_fx1 ); #else ivas_lfe_dec( st_ivas->hLFE, st, output_frame, st_ivas->bfi, p_output[LFE_CHANNEL] ); #endif // IVAS_FLOAT_FIXED @@ -1395,7 +1393,6 @@ ivas_error ivas_jbm_dec_tc( { #ifdef IVAS_FLOAT_FIXED Word16 i, j, q = Q16; - Word32 *p_output_fx[12]; q = q - find_guarded_bits_fx( st_ivas->nchan_transport ); FOR( i = 0; i < max(st_ivas->hDecoderConfig->nchan_out, st_ivas->nchan_transport); ++i ) { @@ -1429,17 +1426,17 @@ ivas_error ivas_jbm_dec_tc( { /* LFE channel decoder */ #ifdef IVAS_FLOAT_FIXED - Word32 *p_output_fx; + Word32 *p_output_fx1; - p_output_fx = (Word32 *) malloc( ( 48000 / FRAMES_PER_SEC ) * sizeof( Word32 ) ); + p_output_fx1 = (Word32 *) malloc( ( 48000 / FRAMES_PER_SEC ) * sizeof( Word32 ) ); - ivas_lfe_dec_fx( st_ivas->hLFE, st, output_frame, st_ivas->bfi, p_output_fx ); + ivas_lfe_dec_fx( st_ivas->hLFE, st, output_frame, st_ivas->bfi, p_output_fx1 ); for ( int p = 0; p < 960; p++ ) { - p_output[LFE_CHANNEL][p] = (float) p_output_fx[p] / ONE_IN_Q9; + p_output[LFE_CHANNEL][p] = (float) p_output_fx1[p] / ONE_IN_Q9; } - free( p_output_fx ); + free( p_output_fx1 ); #else ivas_lfe_dec( st_ivas->hLFE, st, output_frame, st_ivas->bfi, p_output[LFE_CHANNEL] ); #endif // IVAS_FLOAT_FIXED @@ -1473,7 +1470,6 @@ ivas_error ivas_jbm_dec_tc( { #ifdef IVAS_FLOAT_FIXED Word16 i, j, q = Q16, nchan_transport; - Word32 *p_output_fx[12]; nchan_transport = audioCfg2channels( IVAS_AUDIO_CONFIG_5_1_2 ); q = q - find_guarded_bits_fx( nchan_transport ); FOR( i = 0; i < max(st_ivas->hDecoderConfig->nchan_out, nchan_transport); ++i ) @@ -1554,7 +1550,6 @@ ivas_error ivas_jbm_dec_tc( { #ifdef IVAS_FLOAT_FIXED Word16 i, j, q = Q16; - Word32 *p_output_fx[12]; q = q - find_guarded_bits_fx( st_ivas->nchan_transport ); FOR( i = 0; i < max(st_ivas->hDecoderConfig->nchan_out, st_ivas->nchan_transport); ++i ) { @@ -1857,7 +1852,6 @@ ivas_error ivas_jbm_dec_tc( if ( st_ivas->renderer_type == RENDERER_MCMASA_MONO_STEREO ) { #ifdef IVAS_FLOAT_FIXED - Word32 *p_output_fx[12]; for ( int lp = 0; lp < 12; lp++ ) { if ( p_output[lp] != NULL ) @@ -2205,7 +2199,6 @@ ivas_error ivas_jbm_dec_render( *nSamplesRendered = min( st_ivas->hTcBuffer->n_samples_available, nSamplesAskedLocal ); #ifdef IVAS_FLOAT_FIXED Word16 q = Q16; - Word32 *p_output_fx[20]; Word32 *p_tc_fx[16]; q = q - find_guarded_bits_fx( st_ivas->nchan_transport ); FOR( i = 0; i < st_ivas->nchan_transport; ++i ) @@ -2754,7 +2747,6 @@ ivas_error ivas_jbm_dec_render( *nSamplesRendered = min( st_ivas->hTcBuffer->n_samples_available, nSamplesAskedLocal ); #ifdef IVAS_FLOAT_FIXED Word16 q = Q16; - Word32 *p_output_fx[20]; Word32 *p_tc_fx[16]; q = q - find_guarded_bits_fx( st_ivas->nchan_transport ); FOR( i = 0; i < st_ivas->nchan_transport; ++i ) @@ -2817,7 +2809,6 @@ ivas_error ivas_jbm_dec_render( { #ifdef IVAS_FLOAT_FIXED Word16 q = Q16; - Word32 *p_output_fx[20]; q = q - find_guarded_bits_fx( MC_PARAMUPMIX_MAX_INPUT_CHANS ); FOR( i = 0; i < max(st_ivas->hDecoderConfig->nchan_out, MC_PARAMUPMIX_MAX_INPUT_CHANS); ++i ) { diff --git a/lib_dec/ivas_lfe_dec_fx.c b/lib_dec/ivas_lfe_dec_fx.c index c541a2d58f3f51b87f5e73a2911120e0901847dd..bd4a7399711c2ba9e57c2f459d9d551f415fd1cb 100644 --- a/lib_dec/ivas_lfe_dec_fx.c +++ b/lib_dec/ivas_lfe_dec_fx.c @@ -441,7 +441,7 @@ ivas_error ivas_create_lfe_dec_fx( lfe_addl_delay_s = s_max( 0, lfe_addl_delay_s ); add_delay_sa = (Word16) W_round64_L( W_mult0_32_32( L_shl( binauralization_delay_ns, 1 ), output_fs_fx ) ); hLFE->lfe_addl_delay = add( (Word16) L_shr( ( (Word32) lfe_addl_delay_s * (Word32) output_Fs ), 15 ), add_delay_sa ); - hLFE->lfe_block_delay_s_fx = add(hLFE->lfe_block_delay_s_fx, add( lfe_addl_delay_s, add_delay_sa / output_Fs )); + hLFE->lfe_block_delay_s_fx = add( hLFE->lfe_block_delay_s_fx, add( lfe_addl_delay_s, (Word16) ( add_delay_sa / output_Fs ) ) ); IF( GT_16( hLFE->lfe_addl_delay, 0 ) ) { diff --git a/lib_dec/ivas_sce_dec_fx.c b/lib_dec/ivas_sce_dec_fx.c index d89aab4cfe66c2e3a34c9a6e3f4eb733e2d5faba..62b6fbdada848385127f5cf64b526894f5bb9bd4 100644 --- a/lib_dec/ivas_sce_dec_fx.c +++ b/lib_dec/ivas_sce_dec_fx.c @@ -431,13 +431,13 @@ ivas_error create_sce_dec( { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for stereo output\n" ) ); } - set_zero( hSCE->save_synth_fx, output_frame ); + set_zero_fx( hSCE->save_synth_fx, output_frame ); IF( ( hSCE->save_hb_synth_fx = (Word32 *) malloc( sizeof( *(hSCE->save_hb_synth_fx) ) * output_frame ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate HB memory for stereo output\n" ) ); } - set_zero( hSCE->save_hb_synth_fx, output_frame ); + set_zero_fx( hSCE->save_hb_synth_fx, output_frame ); #endif } ELSE diff --git a/lib_dec/ivas_spar_decoder.c b/lib_dec/ivas_spar_decoder.c index fa896149a8624cd80bab091ae847efa9083be366..25180c379ba26f6c3f2a4ea2c6412230ba75d38a 100644 --- a/lib_dec/ivas_spar_decoder.c +++ b/lib_dec/ivas_spar_decoder.c @@ -768,7 +768,7 @@ void ivas_spar_get_cldfb_gains_fx( /* compute time-domain cross-fade for considered time slots*/ tmp_idx = sub( cf_start, imult1616( cf_cldfb_start, stride ) ); Word32 pFilterbank_cross_fade_fx[192];// Temporarily added to stored fixed value of hSpar->hFbMixer->pFilterbank_cross_fade_fx - floatToFixed_arrL( hSpar->hFbMixer->pFilterbank_cross_fade, pFilterbank_cross_fade_fx, 31, cf_len ); + floatToFixed_arrL( (Float32 *) hSpar->hFbMixer->pFilterbank_cross_fade, pFilterbank_cross_fade_fx, 31, cf_len ); FOR( sample = 0; sample < cf_len; sample++ ) { tgt_fx[tmp_idx++] = pFilterbank_cross_fade_fx[sample]; diff --git a/lib_dec/ivas_stereo_dft_dec.c b/lib_dec/ivas_stereo_dft_dec.c index 6a76026bdbc31caf0b71f33211d893674cff9dd5..195ab3ace77fc8e9ff180f3135489bb8d59e1ac2 100644 --- a/lib_dec/ivas_stereo_dft_dec.c +++ b/lib_dec/ivas_stereo_dft_dec.c @@ -578,7 +578,7 @@ void stereo_dft_dec_reset( set_zero( hStereoDft->g_state, STEREO_DFT_BAND_MAX ); #ifdef IVAS_FLOAT_FIXED - set_val_Word32( hStereoDft->g_state_fx, 0, STEREO_DFT_BAND_MAX ); + set_val_Word16( hStereoDft->g_state_fx, 0, STEREO_DFT_BAND_MAX ); init_basic_allpass( &hStereoDft->ap1, dft_ap_gains[0], dft_ap_gains_fx[0], dft_ap_delays[0] ); init_basic_allpass( &hStereoDft->ap2, dft_ap_gains[1], dft_ap_gains_fx[1], dft_ap_delays[1] ); init_basic_allpass( &hStereoDft->ap3, dft_ap_gains[2], dft_ap_gains_fx[2], dft_ap_delays[2] ); diff --git a/lib_dec/ivas_stereo_mdct_core_dec_fx.c b/lib_dec/ivas_stereo_mdct_core_dec_fx.c index 0d51291eb32614b22deb23abc89cbb66f446317b..07f059e960ff73f5f405386b6216675982e22ed0 100644 --- a/lib_dec/ivas_stereo_mdct_core_dec_fx.c +++ b/lib_dec/ivas_stereo_mdct_core_dec_fx.c @@ -708,7 +708,6 @@ static void apply_dmx_weights_fx( Word16 q_sum_nrg_L = 23 + min_norm - 32; Word16 q_sum_nrg_R = 23 + min_norm - 32; Word16 q_dot_prod_real = 23 + min_norm - 32; - Word16 q_dot_prod_imag = 23 + min_norm - 32; Word16 E_sum_nrg_l = 31 - q_sum_nrg_L; Word16 E_sum_nrg_R = 31 - q_sum_nrg_R; @@ -734,7 +733,7 @@ static void apply_dmx_weights_fx( { e_full_w = E_num; } - Word32 full_w_up; + Word16 full_w_up; IF( num_sqrt == 0 && sum_abs == 0 ) { full_w_up = 6364; // 0.776887059 in Q13 @@ -755,7 +754,7 @@ static void apply_dmx_weights_fx( { e_full_down = E_sum_nrg_Mid; } - Word32 full_w_down; + Word16 full_w_down; IF( sum_nrg_Mid_sqrt == 0 && sum_abs == 0 ) { full_w_down = 6364; @@ -766,7 +765,7 @@ static void apply_dmx_weights_fx( } ELSE { - full_w_down = L_shr( divide3232( L_shr( sum_nrg_Mid_sqrt, e_full_down - E_sum_nrg_Mid ), L_shr( sum_abs, e_full_down - max_e_sum_abs ) ), 1 ); + full_w_down = shr( divide3232( L_shr( sum_nrg_Mid_sqrt, e_full_down - E_sum_nrg_Mid ), L_shr( sum_abs, e_full_down - max_e_sum_abs ) ), 1 ); } IF( hCPE->hStereoMdct->reverse_dmx == 0 ) @@ -971,7 +970,7 @@ static void run_min_stats_fx( st->hFdCngDec->msNoiseEst_float[p] = ( (float) st->hFdCngDec->msNoiseEst[p] / ( 1u << ( 31 - st->hFdCngDec->msNoiseEst_exp ) ) ); } - st->hTcxDec->CngLevelBackgroundTrace_bfi = (float) ( st->hTcxDec->CngLevelBackgroundTrace_bfi_fx / powf( 2, ( 31 - st->hTcxDec->CngLevelBackgroundTrace_bfi_exp ) ) ); + st->hTcxDec->CngLevelBackgroundTrace_bfi = (float) ( st->hTcxDec->CngLevelBackgroundTrace_bfi_fx / powf( 2.f, (Float32)( 31 - st->hTcxDec->CngLevelBackgroundTrace_bfi_exp ) ) ); st->cngTDLevel_float = fix16_to_float( st->cngTDLevel, ( 15 - st->cngTDLevel_e ) ); for ( int p = 0; p < ( st->hFdCngDec->hFdCngCom->stopFFTbin - st->hFdCngDec->hFdCngCom->startBand ); p++ ) diff --git a/lib_dec/ivas_stereo_switching_dec.c b/lib_dec/ivas_stereo_switching_dec.c index 60f15c5086950077b5a450124bf10e5cbbb48bb7..d45bd3d2e15306df5c1333fc9e436fa337ed69a9 100644 --- a/lib_dec/ivas_stereo_switching_dec.c +++ b/lib_dec/ivas_stereo_switching_dec.c @@ -1599,7 +1599,7 @@ void synchro_synthesis_fx( { for ( n = 0; n < CPE_CHANNELS; n++ ) { - p_output_mem[n] = hCPE->output_mem[n]; + p_output_mem[n] = (Word32 *) hCPE->output_mem[n]; } } @@ -1614,7 +1614,7 @@ void synchro_synthesis_fx( { for ( i = delay_comp_DFT; i < delay_comp_TD; i++ ) { - sts[0]->prev_synth_buffer[i] = p_output_mem[0][i - delay_comp_DFT]; + sts[0]->prev_synth_buffer[i] = (Float32) ( p_output_mem[0][i - delay_comp_DFT] ); } for ( i = delay_comp_TD; i < delay_comp_TD + delay_cldfb; i++ ) @@ -1664,7 +1664,7 @@ void synchro_synthesis_fx( { if ( ( hCPE->last_element_mode != IVAS_CPE_DFT && !sba_dirac_stereo_flag && dft_mono_brate_switch != -1 ) || dft_mono_brate_switch == 1 ) { - Word16 *pPrev_synth; + Word32 *pPrev_synth; Word16 inv_fade_len = 1.f / delay_diff; /* cross-fading between TD synchro memory and the DFT output */ @@ -1692,12 +1692,12 @@ void synchro_synthesis_fx( for ( i = 0; i < delay_diff; i++ ) { - output[0][i + delay_comp_DFT] = ( output[0][i + delay_comp_DFT] * ( delay_diff - i ) + p_output_mem[0][i] * i ) * inv_fade_len_1; + output[0][i + delay_comp_DFT] = (Word32) ( ( output[0][i + delay_comp_DFT] * ( delay_diff - i ) + p_output_mem[0][i] * i ) * inv_fade_len_1 ); } for ( i = 0; i < delay_cldfb; i++ ) { - output[0][i + delay_comp_TD] = ( tmp_out[0][i] * ( delay_cldfb - i ) + output[0][i + delay_comp_TD] * i ) * inv_fade_len_2; + output[0][i + delay_comp_TD] = (Word32) ( ( tmp_out[0][i] * ( delay_cldfb - i ) + output[0][i + delay_comp_TD] * i ) * inv_fade_len_2 ); } } } @@ -1722,7 +1722,7 @@ void synchro_synthesis_fx( { for ( i = delay_comp_DFT; i < delay_comp_TD; i++ ) { - sts[n]->prev_synth_buffer[i] = p_output_mem[n][i - delay_comp_DFT]; + sts[n]->prev_synth_buffer[i] = (Float32) p_output_mem[n][i - delay_comp_DFT]; } for ( i = delay_comp_TD; i < delay_comp_TD + delay_cldfb; i++ ) @@ -1760,7 +1760,7 @@ void synchro_synthesis_fx( /* use TCX synchro memory (perfect signal is available) */ for ( i = delay_diff; i < dft32ms_ovl; i++ ) { - tmp_out_TD[n][i] = sts[n]->delay_buf_out[i - delay_diff]; + tmp_out_TD[n][i] = (Word32) sts[n]->delay_buf_out[i - delay_diff]; } } } diff --git a/lib_dec/ivas_td_low_rate_dec.c b/lib_dec/ivas_td_low_rate_dec.c index 8c1314a8f3d87766d98e628c44e166fdf5c6e841..36c994464756125cf1b969e2f8877cbbb27cc6af 100644 --- a/lib_dec/ivas_td_low_rate_dec.c +++ b/lib_dec/ivas_td_low_rate_dec.c @@ -551,8 +551,8 @@ void decod_gen_2sbfr( Word16 bwe_exc_fx[L_FRAME32k], * p_bwe_exc_fx; Word16 gain_buf_fx[NB_SUBFR16k]; Word16 tdm_Pri_pitch_buf_fx[NB_SUBFR]; - floatToFixed_arr(Aq, Aq_fx, Q14, NB_SUBFR16k * (M + 1)); - floatToFixed_arr(tdm_Pri_pitch_buf, tdm_Pri_pitch_buf_fx, Q6, NB_SUBFR); + floatToFixed_arr((Float32 *)Aq, Aq_fx, Q14, NB_SUBFR16k * (M + 1)); + floatToFixed_arr((Float32 *)tdm_Pri_pitch_buf, tdm_Pri_pitch_buf_fx, Q6, NB_SUBFR); floatToFixed_arr(exc - L_EXC_MEM_DEC, old_exc_fx, Q8, L_EXC_DEC); exc_fx = old_exc_fx + L_EXC_MEM_DEC; floatToFixed_arr(exc2 - L_EXC_MEM, old_exc2_fx, Q8, L_FRAME16k + L_EXC_MEM); diff --git a/lib_enc/guided_plc_enc_fx.c b/lib_enc/guided_plc_enc_fx.c index ab1bcc5f5441451ef079e3ff9f0fa96da05b45ef..4b1decb7e2897184848d976aaa65339bf2a7928c 100644 --- a/lib_enc/guided_plc_enc_fx.c +++ b/lib_enc/guided_plc_enc_fx.c @@ -249,7 +249,7 @@ void encoderSideLossSimulation_fx( PLC_ENC_EVS_HANDLE hPlc_Ext, Word16 *lsf_q, /* Q1*1.28 */ const Word16 stab_fac, /* Q15 */ - const Word8 calcOnlyISF, + const Word16 calcOnlyISF, const Word16 L_frame ) { diff --git a/lib_enc/ivas_core_pre_proc_front.c b/lib_enc/ivas_core_pre_proc_front.c index b9d3b003f344143daf9f50a3e886d525f9d8c182..b9511bc6b2d683f88eb3d939ff927400dcde0081 100644 --- a/lib_enc/ivas_core_pre_proc_front.c +++ b/lib_enc/ivas_core_pre_proc_front.c @@ -869,7 +869,7 @@ static void calculate_energy_buffer_fx( chan_width_bins_fx = L_shl( (Word32) div_s( chan_width_f_fx, band_res_dft_fx ), ( sub( add( temp_q1, 1 ), temp_q2 ) ) ); // Q16 pDFT_DMX_fx = hCPE->hStereoDft->DFT_fx[0]; - pDFT_DMX_q_fx = hCPE->hStereoDft->DFT_q_fx[0]; + pDFT_DMX_q_fx = hCPE->hStereoDft->DFT_q_fx; start = 1; p_nrg_DMX_fx = nrg_DMX_fx; @@ -924,8 +924,8 @@ static void calculate_energy_buffer( Word32 chan_width_bins_fx; Word16 band_res_dft_fx, chan_width_f_fx, start, stop; - Word32 temp_q1 = norm_l( input_Fs ) - 1; - Word32 temp_q2 = norm_s( hCPE->hStereoDft->NFFT ); + Word16 temp_q1 = norm_l( input_Fs ) - 1; + Word16 temp_q2 = norm_s( hCPE->hStereoDft->NFFT ); band_res_dft_fx = div_l( L_shl( input_Fs, temp_q1 ), shl( hCPE->hStereoDft->NFFT, temp_q2 ) ); chan_width_f_fx = div_l( 24000, CLDFB_NO_CHANNELS_MAX ); diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index d01e86829210fe025d45b5dc0f20923384a1dd04..7b5d33540313119c55333c929f6ba144054d9443 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -998,7 +998,7 @@ void lpc_quantization_fx( Word16 lspq_ind[], Word16 clip_var[], const Word16 coder_type, - const Word8 acelp_midLpc, + const Word16 acelp_midLpc, Word16 param_lpc[], Word16 nbits_lpc[], Word16* bits_param_lpc, @@ -1741,7 +1741,7 @@ void encoderSideLossSimulation_fx( PLC_ENC_EVS_HANDLE hPlc_Ext, Word16* lsf_q, /* Q1*1.28 */ const Word16 stab_fac, /* Q15 */ - const Word8 calcOnlyISF, + const Word16 calcOnlyISF, const Word16 L_frame ); @@ -1805,7 +1805,7 @@ Word16 vlpc_1st_cod_fx(const Word16 *lsf, /* i : vector to quantize , Word16 rf_mode ); -void tcx_ltp_encode_fx(Word8 tcxltp_on, +void tcx_ltp_encode_fx(Word16 tcxltp_on, Word8 tcxOnly, Word16 tcxMode, Word16 L_frame, diff --git a/lib_enc/qlpc_stoch_fx.c b/lib_enc/qlpc_stoch_fx.c index ea5bf12e767d4f068c8d44477b04d9ba1c79f7f7..1392b693882d8ddbadde5aef42bc01347d3741c5 100644 --- a/lib_enc/qlpc_stoch_fx.c +++ b/lib_enc/qlpc_stoch_fx.c @@ -39,7 +39,7 @@ void lpc_quantization_fx( Word16 lspq_ind[], Word16 clip_var[], const Word16 coder_type, - const Word8 acelp_midLpc, + const Word16 acelp_midLpc, Word16 param_lpc[], Word16 nbits_lpc[], Word16 * bits_param_lpc, diff --git a/lib_enc/stat_enc.h b/lib_enc/stat_enc.h index 1b924450bc1fac78801398cca6c4556a3dbea171..1dfe1cbe735104951d42d9be52ca9f59018bc4db 100644 --- a/lib_enc/stat_enc.h +++ b/lib_enc/stat_enc.h @@ -2604,7 +2604,7 @@ typedef struct Encoder_State_fx /* b = 0/1 : TCX20 on/off*/ /* c = 0/1 : TCX40 on/off*/ /* d = 0/1 : TCX80 on/off*/ - Word8 restrictedMode; + Word16 restrictedMode; /* Framing */ Word16 nb_subfr; diff --git a/lib_enc/tcx_ltp_enc_fx.c b/lib_enc/tcx_ltp_enc_fx.c index e214f9f6fa9825dfc6b9aa101aed1c79ecc9a3d3..b96627f97ee1d1116563e104c5cc5deef3d02dae 100644 --- a/lib_enc/tcx_ltp_enc_fx.c +++ b/lib_enc/tcx_ltp_enc_fx.c @@ -339,7 +339,7 @@ static void tcx_ltp_find_gain( Word16 *speech, Word16 *pred_speech, Word16 L_fra } -void tcx_ltp_encode_fx( Word8 tcxltp_on, +void tcx_ltp_encode_fx( Word16 tcxltp_on, Word8 tcxOnly, Word16 tcxMode, Word16 L_frame,