Loading lib_com/core_com_config.c +1 −5 Original line number Diff line number Diff line Loading @@ -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 */ Loading Loading @@ -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, Loading @@ -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(); Loading lib_com/float_to_fix_ops.c +13 −0 Original line number Diff line number Diff line Loading @@ -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) Loading lib_com/ivas_prot.h +49 −2 Original line number Diff line number Diff line Loading @@ -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 */ Loading @@ -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 */ Loading @@ -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 */ Loading Loading @@ -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 */ Loading lib_com/ivas_tools.c +323 −5 Original line number Diff line number Diff line Loading @@ -41,6 +41,9 @@ #include "ivas_rom_com.h" #include "prot_fx1.h" #include "prot_fx2.h" #ifndef IVAS_FLOAT_FIXED #include <basop32.h> #endif #define ANGLE_90_DEG_Q22 377487360 #define ANGLE_180_DEG_Q22 754974720 Loading Loading @@ -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() * Loading @@ -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]; Loading @@ -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() * Loading @@ -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() * Loading @@ -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; } Loading Loading @@ -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() * Loading @@ -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; Loading @@ -478,7 +797,7 @@ void v_mult_mat( } mvr2r( tmp_y, y, Nc ); #endif return; } Loading Loading @@ -595,7 +914,6 @@ int16_t check_bounds_s( return value_adj; } /*-------------------------------------------------------------------* * check_bounds_l() * Loading lib_com/prot_fx2.h +0 −4 Original line number Diff line number Diff line Loading @@ -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 */ Loading @@ -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, Loading Loading
lib_com/core_com_config.c +1 −5 Original line number Diff line number Diff line Loading @@ -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 */ Loading Loading @@ -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, Loading @@ -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(); Loading
lib_com/float_to_fix_ops.c +13 −0 Original line number Diff line number Diff line Loading @@ -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) Loading
lib_com/ivas_prot.h +49 −2 Original line number Diff line number Diff line Loading @@ -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 */ Loading @@ -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 */ Loading @@ -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 */ Loading Loading @@ -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 */ Loading
lib_com/ivas_tools.c +323 −5 Original line number Diff line number Diff line Loading @@ -41,6 +41,9 @@ #include "ivas_rom_com.h" #include "prot_fx1.h" #include "prot_fx2.h" #ifndef IVAS_FLOAT_FIXED #include <basop32.h> #endif #define ANGLE_90_DEG_Q22 377487360 #define ANGLE_180_DEG_Q22 754974720 Loading Loading @@ -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() * Loading @@ -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]; Loading @@ -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() * Loading @@ -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() * Loading @@ -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; } Loading Loading @@ -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() * Loading @@ -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; Loading @@ -478,7 +797,7 @@ void v_mult_mat( } mvr2r( tmp_y, y, Nc ); #endif return; } Loading Loading @@ -595,7 +914,6 @@ int16_t check_bounds_s( return value_adj; } /*-------------------------------------------------------------------* * check_bounds_l() * Loading
lib_com/prot_fx2.h +0 −4 Original line number Diff line number Diff line Loading @@ -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 */ Loading @@ -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, Loading