From 9fed219c0060d9e4d7f7effa32ccc88c519c58b5 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Thu, 29 Aug 2024 12:48:45 +0530 Subject: [PATCH 1/2] MSAN and USAN fixes --- lib_com/basop_util.c | 6 ++--- lib_com/bitstream_fx.c | 4 ++-- lib_com/enh64.c | 4 ++-- lib_com/enhUL32.c | 2 +- lib_com/hq_tools_fx.c | 16 ++++++------- lib_com/logqnorm_fx.c | 2 +- lib_com/longarith.c | 2 +- lib_com/lsf_tools_fx.c | 2 +- lib_com/pvq_com_fx.c | 2 +- lib_com/rom_basop_util.c | 2 +- lib_com/tcq_position_arith_fx.c | 2 +- lib_com/window_ola_fx.c | 2 +- lib_dec/FEC_HQ_phase_ecu_fx.c | 2 +- lib_dec/ari_dec_fx.c | 2 +- lib_dec/dec4t64_fx.c | 8 +++---- lib_dec/dec_acelp_fx.c | 16 ++++++------- lib_dec/dec_pit_exc_fx.c | 10 ++++++-- lib_dec/dec_prm_fx.c | 2 +- lib_dec/dec_tcx_fx.c | 4 ++-- lib_dec/er_sync_exc_fx.c | 2 +- lib_dec/hdecnrm_fx.c | 6 ++--- lib_dec/hq_core_dec_fx.c | 2 +- lib_dec/igf_dec_fx.c | 2 +- lib_dec/inov_dec_fx.c | 4 ++-- lib_dec/ivas_ism_renderer.c | 2 +- lib_dec/ivas_masa_dec.c | 2 +- lib_dec/ivas_mc_param_dec.c | 2 +- lib_dec/ivas_svd_dec.c | 12 +++++----- lib_dec/lib_dec_fx.c | 2 +- lib_dec/post_dec_fx.c | 2 +- lib_enc/hq_hr_enc.c | 4 ++++ lib_enc/ivas_cpe_enc.c | 25 +++++++++----------- lib_enc/ivas_front_vad.c | 5 ++-- lib_enc/ivas_mct_core_enc.c | 9 ++++++- lib_enc/ivas_stereo_dft_enc.c | 16 +++++++++++++ lib_enc/ivas_stereo_dft_enc_itd.c | 4 ++++ lib_enc/ivas_stereo_mdct_igf_enc.c | 7 ++++++ lib_rend/ivas_dirac_dec_binaural_functions.c | 4 ++-- lib_rend/ivas_reflections.c | 2 +- 39 files changed, 123 insertions(+), 81 deletions(-) diff --git a/lib_com/basop_util.c b/lib_com/basop_util.c index fcaff0505..27ed4cabd 100644 --- a/lib_com/basop_util.c +++ b/lib_com/basop_util.c @@ -872,7 +872,7 @@ Word16 divide3232( Word32 L_num, Word32 L_denom ) #endif - sign = L_and( L_xor( L_num, L_denom ), 0x80000000 ); + sign = L_and( L_xor( L_num, L_denom ), (Word32) 0x80000000 ); L_num = L_abs( L_num ); L_denom = L_abs( L_denom ); @@ -1520,7 +1520,7 @@ Word32 imult3216( Word32 x, Word16 y ) Mpy_32_16_ss( x, y, &mh, &ml ); mh = L_shl( mh, 15 ); - ml = lshr( ml, 1 ); + ml = (UWord16) lshr( (Word16) ml, 1 ); return L_or( mh, L_deposit_l( ml ) ); } @@ -2459,7 +2459,7 @@ Word16 BASOP_util_atan2( /* o: atan2(y,x) [-pi,pi] Q13 */ } /* --- division */ - L_sign = L_and( L_xor( x, y ), 0x80000000 ); + L_sign = L_and( L_xor( x, y ), (Word32) 0x80000000 ); q = 32767 /*1.0f Q15*/; /* y/x = neg/zero = -Inf */ sf = 0; diff --git a/lib_com/bitstream_fx.c b/lib_com/bitstream_fx.c index 67f959a1d..e73734fee 100644 --- a/lib_com/bitstream_fx.c +++ b/lib_com/bitstream_fx.c @@ -422,8 +422,8 @@ UWord16 get_next_indice_fx( /* o : value of the indice */ FOR( i = 0; i < nb_bits; i++ ) { - value = lshl( value, 1 ); - value = add( value, st_fx->bit_stream[add( st_fx->next_bit_pos, i )] ); + value = (UWord16) L_shl( value, 1 ); + value = (UWord16)L_add( value, st_fx->bit_stream[add( st_fx->next_bit_pos, i )] ); } /* update the position in the bitstream */ diff --git a/lib_com/enh64.c b/lib_com/enh64.c index 0571277fe..a5c0879c0 100644 --- a/lib_com/enh64.c +++ b/lib_com/enh64.c @@ -707,7 +707,7 @@ Word32 W_sat_l( Word64 L64_var ) } else if ( L64_var < (int) 0x80000000 ) { - L_var_out = 0x80000000; + L_var_out = (Word32) 0x80000000; } else { @@ -1201,7 +1201,7 @@ Word32 W_round48_L( Word64 L64_var1 ) Word32 L_result; Word64 L64_var2 = 0x80000000; - Word64 L64_MIN = 0x8000000000000000LL; + Word64 L64_MIN = (Word64) 0x8000000000000000LL; Word64 L64_MAX = 0x7FFFFFFFFFFFFFFFLL; L64_var1 = W_shl( L64_var1, 16 ); diff --git a/lib_com/enhUL32.c b/lib_com/enhUL32.c index ff1c68425..0fe4c304b 100644 --- a/lib_com/enhUL32.c +++ b/lib_com/enhUL32.c @@ -401,7 +401,7 @@ UWord16 u_extract_h( UWord32 UL_var1 ) UWord16 u_extract_l( UWord32 UL_var1 ) { - return (UWord32) extract_l( (Word32) UL_var1 ); + return (UWord16) extract_l( (Word32) UL_var1 ); } /* enable convenient reuse of Non-saturating UL_subNs , UL_addNs while "D"iscarding the sgn/wrap output flags */ diff --git a/lib_com/hq_tools_fx.c b/lib_com/hq_tools_fx.c index 7b18fd127..7077f9924 100644 --- a/lib_com/hq_tools_fx.c +++ b/lib_com/hq_tools_fx.c @@ -676,7 +676,7 @@ void hvq_bwe_fine_fx( Mpy_32_16_ss( L_coeff[i], tmp, &L_tmp, &lsb ); /* 12+33-s+1-16=Q(30-s) */ shift2 = add( shift, 1 ); tmp = round_fx( L_shl( L_tmp, shift2 ) ); /* 30-s+s+1-16=Q(15) */ - SWB_signal[i] = add( tmp, lshr( lsb, sub( 32, shift2 ) ) ); + SWB_signal[i] = add( tmp, extract_l( L_shr( lsb, sub( 32, shift2 ) ) ) ); move16(); /* Q15 */ /*SWB_signal[i] = round_fx(L_shl(L_tmp, add(shift, 1))); // 30-s+s+1-16=Q(15) */ } @@ -1369,13 +1369,13 @@ void hvq_bwe_fx( tmp = s_min( norm_l( L_tmp0 ), tmp ); tmp = sub( tmp, 1 ); - L_tmp0 = L_add( L_shl( L_tmp0, tmp ), L_deposit_l( lshr( lsb, sub( 16, tmp ) ) ) ); /* Qin+2+tmp */ + L_tmp0 = L_add( L_shl( L_tmp0, tmp ), L_shr( lsb, sub( 16, tmp ) ) ); /* Qin+2+tmp */ L_tmp0 = L_add( L_tmp0, L_shr( L_mult0( noise_level[0], Random( bwe_seed ) ), sub( 30 - ( qin + 2 ), tmp ) ) ); /* Qin+2+tmp */ tmp = round_fx( L_shl( L_tmp0, 27 - ( qin + 2 ) - tmp ) ); /* Q11 (Qin+2+tmp+27-qin-2-tmp-16) */ Mpy_32_16_ss( L_tmp1, tmp, &L_tmp0, &lsb ); /* Q10 (14+11+1-16) */ - L_coeff_out[i] = L_add( L_shl( L_tmp0, qout - 10 ), L_deposit_l( lshr( lsb, 10 + 16 - qout ) ) ); + L_coeff_out[i] = L_add( L_shl( L_tmp0, qout - 10 ), L_shr( lsb, 10 + 16 - qout ) ); move32(); /* Qout (10+qout-10) */ } ELSE @@ -1626,12 +1626,12 @@ void noise_mix_fx( tmp = s_min( norm_l( L_tmp0 ), tmp ); tmp = sub( tmp, 1 ); - L_tmp0 = L_add( L_shl( L_tmp0, tmp ), L_deposit_l( lshr( lsb, sub( 16, tmp ) ) ) ); /* Qin+2+tmp */ + L_tmp0 = L_add( L_shl( L_tmp0, tmp ), L_shr( lsb, sub( 16, tmp ) ) ); /* Qin+2+tmp */ L_tmp0 = L_add( L_tmp0, L_shr( L_mult0( noise_level, Random( seed ) ), sub( 30 - ( qin + 2 ), tmp ) ) ); /* Qin+2+tmp */ tmp = round_fx( L_shl( L_tmp0, sub( sub( 27, add( qin, 2 ) ), tmp ) ) ); /* Q11 (Qin+2+tmp+27-qin-2-tmp-16) */ Mpy_32_16_ss( L_normq, tmp, &L_tmp0, &lsb ); /* Q10 (14+11+1-16) */ - L_coeff_out[i] = L_add( L_shl( L_tmp0, qout - 10 ), L_deposit_l( lshr( lsb, 10 + 16 - qout ) ) ); + L_coeff_out[i] = L_add( L_shl( L_tmp0, qout - 10 ), L_shr( lsb, 10 + 16 - qout ) ); move32(); /* Qout (10+qout-10) */ } ELSE @@ -2609,7 +2609,7 @@ void apply_envelope_fx( { /*coeff_out[i] = coeff[i]*normq; */ Mpy_32_16_ss( normq, coeff[i], &L_tmp, &lsb ); - coeff_out[i] = L_add( L_shl( L_tmp, 1 ), lshr( lsb, 15 ) ); + coeff_out[i] = L_add( L_shl( L_tmp, 1 ), L_shr( lsb, 15 ) ); move32(); /* Q12 (14+12+1-16)+1 */ } } @@ -2631,7 +2631,7 @@ void apply_envelope_fx( { /*coeff_out[i] = coeff[i]*normq; */ Mpy_32_16_ss( normq, coeff[i], &L_tmp, &lsb ); - coeff_out[i] = L_add( L_shl( L_tmp, 1 ), lshr( lsb, 15 ) ); + coeff_out[i] = L_add( L_shl( L_tmp, 1 ), L_shr( lsb, 15 ) ); move32(); /* Q12 (14+12+1-16)+1 */ } } @@ -2647,7 +2647,7 @@ void apply_envelope_fx( { /*coeff_out1[i] = coeff_out1[i]*normq; */ Mpy_32_16_ss( normq, coeff1[i], &L_tmp, &lsb ); - coeff_out1[i] = L_add( L_shl( L_tmp, 1 ), lshr( lsb, 15 ) ); + coeff_out1[i] = L_add( L_shl( L_tmp, 1 ), L_shr( lsb, 15 ) ); move32(); /* Q12 (14+12+1-16)+1 */ } } diff --git a/lib_com/logqnorm_fx.c b/lib_com/logqnorm_fx.c index fbbf2a464..8d542b6be 100644 --- a/lib_com/logqnorm_fx.c +++ b/lib_com/logqnorm_fx.c @@ -93,7 +93,7 @@ void logqnorm_fx( temp_shift = norm_l( L_temp ); m = add( temp_shift, power_shift ); - L_temp1 = L_add( L_shl( L_temp, temp_shift ), lshr( lsb, sub( 16, temp_shift ) ) ); + L_temp1 = L_add( L_shl( L_temp, temp_shift ), L_shr( lsb, sub( 16, temp_shift ) ) ); m = add( offset, m ); test(); diff --git a/lib_com/longarith.c b/lib_com/longarith.c index 65070f093..94a3adfe8 100644 --- a/lib_com/longarith.c +++ b/lib_com/longarith.c @@ -150,7 +150,7 @@ void longshr( len = sub( len, 1 ); FOR( k = 0; k < len; k++ ) { - a[k] = L_or( L_lshr( a[k], bits ), L_lshl( a[k + 1], fracb_u ) ); + a[k] = UL_or( (UWord32) W_shr( a[k], bits ), UL_lshl( a[k + 1], fracb_u ) ); move32(); } a[k] = L_lshr( a[k], bits ); diff --git a/lib_com/lsf_tools_fx.c b/lib_com/lsf_tools_fx.c index a5e3f8669..c3fb62b86 100644 --- a/lib_com/lsf_tools_fx.c +++ b/lib_com/lsf_tools_fx.c @@ -3485,7 +3485,7 @@ void lsp_convolve_fx( d2l = extract_l( p1[i] ); /* Lacc=L_mult_su( d1h,d2l); */ - Lacc = L_mult0( d1h, (UWord16) d2l ); + Lacc = L_mult0( d1h, d2l ); Lacc = L_mac0( Lacc, d2h, d1l ); Lacc = L_add( L_shr( Lacc, 16 ), L_shr( L_mult( d1h, d2h ), 1 ) ); /* Lacc=p1[i]* x, Q16 */ diff --git a/lib_com/pvq_com_fx.c b/lib_com/pvq_com_fx.c index b97cd6767..16892d5e5 100644 --- a/lib_com/pvq_com_fx.c +++ b/lib_com/pvq_com_fx.c @@ -351,7 +351,7 @@ void densityAngle2RmsProjDec_fx( Word16 phiQ14q; Word16 oppTail, nearTail; - phiQ14q = (Word16) intLimCDivPos_fx( L_shl( L_deposit_l( indexphi ), 13 ), shr( D, 1 ) ); + phiQ14q = (Word16) intLimCDivPos_fx( (UWord32) L_shl( L_deposit_l( indexphi ), 13 ), shr( D, 1 ) ); move16(); if ( indexphi < 0 ) { diff --git a/lib_com/rom_basop_util.c b/lib_com/rom_basop_util.c index 350543b8c..9bb6f0a93 100644 --- a/lib_com/rom_basop_util.c +++ b/lib_com/rom_basop_util.c @@ -1434,7 +1434,7 @@ void BASOP_getTables( const PWord16 **ptwiddle, const PWord16 **sin_twiddle, Wor ld2_length = sub( 16 - 1 - 1, norm_s( length ) ); /* Extract sort of "eigenvalue" (the 5 left most bits) of length. */ - SWITCH( (unsigned short) lshl( length, sub( 15, ld2_length ) ) ) + SWITCH( (unsigned short) L_shl( length, sub( 15, ld2_length ) ) ) { case 0xa000: /* 640 */ move16(); diff --git a/lib_com/tcq_position_arith_fx.c b/lib_com/tcq_position_arith_fx.c index 8c4b9a582..f72017940 100644 --- a/lib_com/tcq_position_arith_fx.c +++ b/lib_com/tcq_position_arith_fx.c @@ -17,7 +17,7 @@ Word32 ar_div( Word32 varout; Word32 sign; - sign = L_and( L_xor( num, denum ), 0x80000000 ); + sign = L_and( L_xor( num, denum ), (Word32) 0x80000000 ); num = L_abs( num ); denum = L_abs( denum ); diff --git a/lib_com/window_ola_fx.c b/lib_com/window_ola_fx.c index 40c31f8fd..938ee92fb 100644 --- a/lib_com/window_ola_fx.c +++ b/lib_com/window_ola_fx.c @@ -240,7 +240,7 @@ void window_ola_fx( p4 = SS2 + sub( temp, 1 ); p1 = wret2; p2 = win_left + ( L_FRAME16k - N16_CORE_SW ) * 3 - 1 - 1; - p3 = win_int_left + L_FRAME16k - N16_CORE_SW - 1; + p3 = win_int_left + ( L_FRAME16k - N16_CORE_SW - 1 ); temp_len = sub( shr( L, 1 ), n ); FOR( i = 0; i < temp_len; i += 2 ) diff --git a/lib_dec/FEC_HQ_phase_ecu_fx.c b/lib_dec/FEC_HQ_phase_ecu_fx.c index 4ca1ad94c..8070f5d24 100644 --- a/lib_dec/FEC_HQ_phase_ecu_fx.c +++ b/lib_dec/FEC_HQ_phase_ecu_fx.c @@ -3418,7 +3418,7 @@ static Word32 mult_32_32_q( const Word32 a, const Word32 b, const Word16 q ) Mpy_32_32_ss( a, b, &hi, &lo ); #ifdef BASOP_NOGLOB - return L_or( L_shl_o( hi, sub( 32 - 1, q ), &Overflow ), L_lshr( lo, add( q, 1 ) ) ); + return L_or( L_shl_o( hi, sub( 32 - 1, q ), &Overflow ), L_lshr( (Word32) lo, add( q, 1 ) ) ); #else return L_or( L_shl( hi, 32 - q - 1 ), L_lshr( lo, q + 1 ) ); #endif diff --git a/lib_dec/ari_dec_fx.c b/lib_dec/ari_dec_fx.c index c1fe88809..294bffc6a 100644 --- a/lib_dec/ari_dec_fx.c +++ b/lib_dec/ari_dec_fx.c @@ -30,7 +30,7 @@ void ari_start_decoding_14bits_fx( { Word32 val; - val = L_and( L_deposit_l( get_next_indice_fx( st, cbitsnew ) ), 0xffffL ); + val = L_and( L_deposit_l( (Word16) get_next_indice_fx( st, cbitsnew ) ), 0xffffL ); s->low = L_deposit_l( 0 ); move32(); diff --git a/lib_dec/dec4t64_fx.c b/lib_dec/dec4t64_fx.c index 23561f305..517b4f0b2 100644 --- a/lib_dec/dec4t64_fx.c +++ b/lib_dec/dec4t64_fx.c @@ -112,12 +112,12 @@ void dec_acelp_4t64_fx( bitcnt = s_and( nbbits, 15 ); FOR( i = 0; i < wordcnt; i++ ) { - indexing_indices[i] = get_next_indice_fx( st_fx, 16 ); + indexing_indices[i] = extract_l( get_next_indice_fx( st_fx, 16 ) ); move16(); } IF( bitcnt ) { - indexing_indices[i] = get_next_indice_fx( st_fx, bitcnt ); + indexing_indices[i] = extract_l( get_next_indice_fx( st_fx, bitcnt ) ); move16(); } @@ -770,9 +770,9 @@ void D_ACELP_decode_43bit_fx( UWord16 idxs[], Word16 code[], Word16 *pulsestrack set16_fx( code, 0, L_SUBFR ); - ps[3] = L_deposit_l( s_and( idxs[0], 0x1ff ) ); + ps[3] = L_and( idxs[0], 0x1ff ); move32(); - ps[2] = L_add( L_shl( s_and( idxs[1], 3 ), 7 ), L_shr( idxs[0], 9 ) ); + ps[2] = L_add( L_shl( L_and( idxs[1], 3 ), 7 ), L_shr( idxs[0], 9 ) ); move32(); joint_index = L_shr( L_add( L_shl( (Word32) idxs[2], 16 ), (Word32) idxs[1] ), 2 ); diff --git a/lib_dec/dec_acelp_fx.c b/lib_dec/dec_acelp_fx.c index 16e7f882d..8379eec7e 100644 --- a/lib_dec/dec_acelp_fx.c +++ b/lib_dec/dec_acelp_fx.c @@ -48,7 +48,7 @@ void D_ACELP_indexing_fx( idxs = (UWord16 *) idxs32; FOR( k = 0; k < wordcnt; k++ ) { - idxs[k] = index[k]; + idxs[k] = (UWord16) index[k]; move16(); } idxs[wordcnt] = 0; @@ -64,7 +64,7 @@ void D_ACELP_indexing_fx( { case TRACKPOS_FREE_THREE: /* Find track with less pulses */ - trackpos = s_and( idxs[0], 3 ); + trackpos = extract_l( L_and( idxs[0], 3 ) ); longshr( idxs32, 2, wordcnt32 ); /* set number of pulses per track */ @@ -75,7 +75,7 @@ void D_ACELP_indexing_fx( BREAK; case TRACKPOS_FREE_ONE: /* Find track with more pulses */ - trackpos = s_and( idxs[0], 3 ); + trackpos = extract_l( L_and( idxs[0], 3 ) ); longshr( idxs32, 2, wordcnt32 ); /* set number of pulses per track */ @@ -110,7 +110,7 @@ void D_ACELP_indexing_fx( case TRACKPOS_FIXED_TWO: /* 1100, 0110, 0011, 1001 */ /* Find track with less pulses */ - trackpos = s_and( idxs[0], 3 ); + trackpos = extract_l( L_and( idxs[0], 3 ) ); longshr( idxs32, 2, wordcnt32 ); /* set number of pulses per track */ @@ -170,7 +170,7 @@ void D_ACELP_indexing_fx( move16(); /* safety check in case of bit errors */ - IF( GE_32( s, pulsestostates[16][pulses - 1] ) ) + IF( GE_64( s, pulsestostates[16][pulses - 1] ) ) { set16_fx( code, 0, L_SUBFR ); *BER_detect = 1; @@ -364,15 +364,15 @@ void fcb_pulse_track_joint_decode_fx( UWord16 *idxs, Word16 wordcnt, UWord32 *in index = L_deposit_l( 0 ); FOR( track = sub( wordcnt, 1 ); track >= 0; track-- ) { - index = L_add( L_lshl( index, 16 ), (UWord32) idxs[track] ); + index = (UWord32) W_add( UL_lshl( index, 16 ), (UWord32) idxs[track] ); } FOR( track = 3; track > 0; track-- ) { pulse_num1 = pulse_num[track]; move16(); - index_n[track] = L_and( index, index_mask_ACELP[pulse_num1] ); + index_n[track] = UL_and( index, index_mask_ACELP[pulse_num1] ); move32(); - index = L_lshr( index, index_len[pulse_num1] ); + index = UL_lshr( index, index_len[pulse_num1] ); } index_n[0] = index; move32(); diff --git a/lib_dec/dec_pit_exc_fx.c b/lib_dec/dec_pit_exc_fx.c index 17abcbfc8..3328839ea 100644 --- a/lib_dec/dec_pit_exc_fx.c +++ b/lib_dec/dec_pit_exc_fx.c @@ -500,7 +500,6 @@ void dec_pit_exc_ivas_fx( Word16 i_subfr_fx, i; /* tmp variables */ Word32 Local_BR_fx, Pitch_BR_fx; Word16 pitch_limit_flag, Pitch_CT_fx; - Word16 exc2_bidon[L_SUBFR * 2]; Word16 *pt_gain; /* Pointer to Word16 gain values for each subframe */ Word16 gain_code16, gain_pitx2; @@ -712,7 +711,14 @@ void dec_pit_exc_ivas_fx( IF( NE_16( use_fcb, 0 ) ) { - Acelp_dec_total_exc( exc_fx, exc2_bidon - i_subfr_fx, gain_code16, gain_pit_fx, i_subfr_fx, code_fx, L_subfr_fx ); + FOR( i = 0; i < L_subfr_fx; i++ ) + { + L_tmp = L_shl_sat( L_mult( gain_pit_fx, exc_fx[i + i_subfr_fx] ), 1 ); /*Q16+Q_exc*/ + L_tmp = L_add_sat( L_tmp, L_shl_sat( L_mult( gain_code16, code_fx[i] ), 6 ) ); /*Q16+Q_exc*/ + exc_fx[i + i_subfr_fx] = round_fx_sat( L_tmp ); /*Q_exc*/ + move16(); + move16(); + } } ELSE { diff --git a/lib_dec/dec_prm_fx.c b/lib_dec/dec_prm_fx.c index de346a501..7b923ab72 100644 --- a/lib_dec/dec_prm_fx.c +++ b/lib_dec/dec_prm_fx.c @@ -1115,7 +1115,7 @@ void dec_prm_fx( FOR( ix = 0; ix < wordcnt; ix++ ) { - prm[j] = get_next_indice_fx( st, 16 ); + prm[j] = (Word16) get_next_indice_fx( st, 16 ); j = add( j, 1 ); move16(); } diff --git a/lib_dec/dec_tcx_fx.c b/lib_dec/dec_tcx_fx.c index e5cede1e3..89f70f960 100644 --- a/lib_dec/dec_tcx_fx.c +++ b/lib_dec/dec_tcx_fx.c @@ -432,7 +432,7 @@ void decoder_tcx_fx( tmp32 = L_shl( L_mult0( index, 0x797D ), 7 ); /* 6Q25; 0x797D -> log2(10)/28 (Q18) */ gain_tcx_e = add( extract_l( L_shr( tmp32, 25 ) ), 1 ); /* get exponent */ - gain_tcx = round_fx( BASOP_Util_InvLog2( L_or( tmp32, 0xFE000000 ) ) ); + gain_tcx = round_fx( BASOP_Util_InvLog2( L_or( tmp32, (Word32) 0xFE000000 ) ) ); #ifdef BASOP_NOGLOB tmp1 = mult_r( shl_sat( L_spec, 5 ), 26214 /*128.f/NORM_MDCT_FACTOR Q15*/ ); @@ -2831,7 +2831,7 @@ void IMDCT_ivas_fx( IF( st->element_mode != EVS_MONO && ( frame_cnt == 0 ) && ( bfi == 0 ) && ( st->prev_bfi != 0 ) && ( EQ_16( st->last_core_bfi, TCX_20_CORE ) || EQ_16( st->last_core_bfi, TCX_10_CORE ) ) && ( hTcxCfg->last_aldo == 0 ) ) { Word16 fac; - fac = shl( mult_r( hTcxDec->conceal_eof_gain, st->last_concealed_gain_syn_deemph ), 1 ); + fac = shl_sat( mult_r( hTcxDec->conceal_eof_gain, st->last_concealed_gain_syn_deemph ), 1 ); FOR( Word16 ind = 0; ind < overlap; ind++ ) { old_syn_overl_fx[ind] = mult_r( old_syn_overl_fx[ind], fac ); diff --git a/lib_dec/er_sync_exc_fx.c b/lib_dec/er_sync_exc_fx.c index 6d8b2e8a2..268476821 100644 --- a/lib_dec/er_sync_exc_fx.c +++ b/lib_dec/er_sync_exc_fx.c @@ -327,7 +327,7 @@ void PulseResynchronization_fx( T0 = FindMaxPeak_fx( src_exc, roundedPitchStart ); /*Q0*/ /* Get the index of the last pulse in the resynchronized frame */ /*k = (int)ceil((nFrameLength-nSamplesDelta-T0)*freqStart - 1);*/ - tmp32 = BASOP_Util_Add_Mant32Exp( L_mult( sub( nFrameLength, add( nSamplesDelta, T0 ) ), freqStart ) /*Q16*/, add( freqStart_e, 31 - 16 ), 0x80000000 /*-1.f Q31*/, 0, &tmp_e ); + tmp32 = BASOP_Util_Add_Mant32Exp( L_mult( sub( nFrameLength, add( nSamplesDelta, T0 ) ), freqStart ) /*Q16*/, add( freqStart_e, 31 - 16 ), (Word32) 0x80000000 /*-1.f Q31*/, 0, &tmp_e ); tmp32 = L_shl( tmp32, sub( tmp_e, 31 - 16 ) ) /*Q16*/; tmp32 = L_add( tmp32, 65536l /*1.f Q16*/ ); k = extract_h( tmp32 ); diff --git a/lib_dec/hdecnrm_fx.c b/lib_dec/hdecnrm_fx.c index 2ecb3a3b5..9c8b6fa01 100644 --- a/lib_dec/hdecnrm_fx.c +++ b/lib_dec/hdecnrm_fx.c @@ -264,9 +264,9 @@ void huff_dec_fx( FOR( i = 0; i < N; i++ ) { last_bits = sub( buffer_len, j ); - val = lshl( val, last_bits ); - val = s_and( val, sub( lshl( 1, buffer_len ), 1 ) ); - val = s_or( val, get_next_indice_fx( st_fx, last_bits ) ); + val = (UWord16) L_shl( val, last_bits ); + val = (UWord16) L_and( val, sub( lshl( 1, buffer_len ), 1 ) ); + val = (UWord16) L_or( val, get_next_indice_fx( st_fx, last_bits ) ); /* Find codeword length */ j = sub( num_lengths, 1 ); diff --git a/lib_dec/hq_core_dec_fx.c b/lib_dec/hq_core_dec_fx.c index f0a31655f..d25aaf286 100644 --- a/lib_dec/hq_core_dec_fx.c +++ b/lib_dec/hq_core_dec_fx.c @@ -259,7 +259,7 @@ void hq_core_dec_fx( /*t_audio_q[i] *= ener_match;*/ Mpy_32_16_ss( t_audio_q[i], ener_match, &L_tmp, &lsb ); /*12+13-15=10 */ #ifdef BASOP_NOGLOB - t_audio_q[i] = L_add_sat( L_shl_sat( L_tmp, 2 ), lshr( lsb, 14 ) ); + t_audio_q[i] = L_add_sat( L_shl_sat( L_tmp, 2 ), L_shr( lsb, 14 ) ); #else t_audio_q[i] = L_add( L_shl( L_tmp, 2 ), lshr( lsb, 14 ) ); #endif diff --git a/lib_dec/igf_dec_fx.c b/lib_dec/igf_dec_fx.c index 95c0454b5..df96b379b 100644 --- a/lib_dec/igf_dec_fx.c +++ b/lib_dec/igf_dec_fx.c @@ -1932,7 +1932,7 @@ static void IGF_appl( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in tileIdx = add( tileIdx, 1 ); } /*do a test multiplication with the highest possible value*/ - L_tmp = Mpy_32_16_1( 0xFFFF8000 /*igf_spec occupies only the 16LSBs */, gain[sfb] ); + L_tmp = Mpy_32_16_1( (Word32)0xFFFF8000 /*igf_spec occupies only the 16LSBs */, gain[sfb] ); L_tmp_e = add( igf_spec_e[tileIdx], gain_e[sfb] ); /*check whether overflow would occur and calculate Headroom, needed*/ shift = sub( L_tmp_e, *spectrum_e ); diff --git a/lib_dec/inov_dec_fx.c b/lib_dec/inov_dec_fx.c index eb7134db5..b1f405004 100644 --- a/lib_dec/inov_dec_fx.c +++ b/lib_dec/inov_dec_fx.c @@ -117,12 +117,12 @@ void inov_decode_fx( // PMT("CONDITION above is missing -> idchan") FOR( i = 0; i < wordcnt; i++ ) { - indexing_indices[i] = get_next_indice_fx( st_fx, 16 ); + indexing_indices[i] = extract_l(get_next_indice_fx( st_fx, 16 )); move16(); } IF( bitcnt ) { - indexing_indices[i] = get_next_indice_fx( st_fx, bitcnt ); + indexing_indices[i] = extract_l(get_next_indice_fx( st_fx, bitcnt )); move16(); } config = PulseConfTable[st_fx->acelp_cfg.fixed_cdk_index[i_subfr / L_SUBFR]]; diff --git a/lib_dec/ivas_ism_renderer.c b/lib_dec/ivas_ism_renderer.c index d50c3196c..b910052d8 100644 --- a/lib_dec/ivas_ism_renderer.c +++ b/lib_dec/ivas_ism_renderer.c @@ -457,7 +457,7 @@ void ivas_ism_render_sf_fx( test(); IF( ( st_ivas->hIntSetup.num_lfe > 0 ) && EQ_16( st_ivas->hIntSetup.index_lfe[lfe_index], j ) ) { - IF( LE_16( lfe_index, sub( st_ivas->hIntSetup.num_lfe, 1 ) ) ) + IF( LT_16( lfe_index, sub( st_ivas->hIntSetup.num_lfe, 1 ) ) ) { lfe_index = add( lfe_index, 1 ); j2 = add( j2, 1 ); diff --git a/lib_dec/ivas_masa_dec.c b/lib_dec/ivas_masa_dec.c index b882eda3d..f38ffb289 100644 --- a/lib_dec/ivas_masa_dec.c +++ b/lib_dec/ivas_masa_dec.c @@ -4417,7 +4417,7 @@ static void create_masa_ext_out_meta_fx( { UWord8 tmp = (UWord8) L_shr( hQMetaData->q_direction[dir].band_data[b_old].energy_ratio_fx[sf], Q30 - 8 ); move16(); - extOutMeta->diffuseToTotalRatio[sf][b_new] -= tmp; + extOutMeta->diffuseToTotalRatio[sf][b_new] = (UWord8) sub( extOutMeta->diffuseToTotalRatio[sf][b_new], tmp ); move16(); } } diff --git a/lib_dec/ivas_mc_param_dec.c b/lib_dec/ivas_mc_param_dec.c index 09cacd4f1..0514559ae 100644 --- a/lib_dec/ivas_mc_param_dec.c +++ b/lib_dec/ivas_mc_param_dec.c @@ -1326,7 +1326,7 @@ ivas_error ivas_param_mc_dec_reconfig_fx( *p_ild_new_fx = add( *p_ild_new_fx, mult( p_ild_new_tmp, parameter_band_mapping.source_band_factor_fx[new_param_band_idx][source_param_idx] ) ); move16(); } - *p_ild_new_fx = extract_l( L_shr( Mpy_32_16_1( L_add( BASOP_Util_Log2( *p_ild_new_fx ), L_add( 16 << Q25, p_ild_new_e << 25 ) ), 24660 ), 15 ) ); + *p_ild_new_fx = extract_l( L_shr( Mpy_32_16_1( L_add( BASOP_Util_Log2( *p_ild_new_fx ), L_add( 16 << Q25, L_shl( p_ild_new_e, 25 ) ) ), 24660 ), 15 ) ); move16(); p_ild_new_fx++; } diff --git a/lib_dec/ivas_svd_dec.c b/lib_dec/ivas_svd_dec.c index b0d163e69..e33ad58e3 100644 --- a/lib_dec/ivas_svd_dec.c +++ b/lib_dec/ivas_svd_dec.c @@ -955,9 +955,9 @@ static void ApplyQRTransform_fx( // d = (x_split + x_kk) * (x_split - x_kk) + (g + r) * (g - r); L_temp1 = BASOP_Util_Add_Mant32Exp( x_split, x_split_e, x_kk, x_kk_e, &L_temp1_e ); - L_temp2 = BASOP_Util_Add_Mant32Exp( x_split, x_split_e, -x_kk, x_kk_e, &L_temp2_e ); + L_temp2 = BASOP_Util_Add_Mant32Exp( x_split, x_split_e, L_negate( x_kk ), x_kk_e, &L_temp2_e ); L_temp3 = BASOP_Util_Add_Mant32Exp( g, g_e, r, r_e, &L_temp3_e ); - L_temp4 = BASOP_Util_Add_Mant32Exp( g, g_e, -r, r_e, &L_temp4_e ); + L_temp4 = BASOP_Util_Add_Mant32Exp( g, g_e, L_negate( r ), r_e, &L_temp4_e ); d = BASOP_Util_Add_Mant32Exp( Mpy_32_32( L_temp1, L_temp2 ), add( L_temp1_e, L_temp2_e ), Mpy_32_32( L_temp3, L_temp4 ), add( L_temp3_e, L_temp4_e ), &d_e ); // d /= maxWithSign((r + r) * x_split); @@ -984,11 +984,11 @@ static void ApplyQRTransform_fx( L_temp2 = maxWithSign_fx( BASOP_Util_Add_Mant32Exp( d, d_e, L_temp1, L_temp1_e, &L_temp2_e ) ); mu = BASOP_Util_Divide3232_Scale_cadence( x_split, L_temp2, &mu_e ); mu_e = add( mu_e, sub( x_split_e, L_temp2_e ) ); - mu = BASOP_Util_Add_Mant32Exp( mu, mu_e, -r, r_e, &mu_e ); + mu = BASOP_Util_Add_Mant32Exp( mu, mu_e, L_negate( r ), r_e, &mu_e ); // d = ((x_ii + x_kk) * (x_ii - x_kk) + r * mu) / maxWithSign(x_ii); L_temp1 = BASOP_Util_Add_Mant32Exp( x_ii, x_ii_e, x_kk, x_kk_e, &L_temp1_e ); - L_temp2 = BASOP_Util_Add_Mant32Exp( x_ii, x_ii_e, -x_kk, x_kk_e, &L_temp2_e ); + L_temp2 = BASOP_Util_Add_Mant32Exp( x_ii, x_ii_e, L_negate( x_kk ), x_kk_e, &L_temp2_e ); d = BASOP_Util_Add_Mant32Exp( Mpy_32_32( L_temp1, L_temp2 ), add( L_temp1_e, L_temp2_e ), Mpy_32_32( r, mu ), add( r_e, mu_e ), &d_e ); d = BASOP_Util_Divide3232_Scale_cadence( d, maxWithSign_fx( x_ii ), &temp_exp ); d_e = add( temp_exp, sub( d_e, x_ii_e ) ); @@ -1172,7 +1172,7 @@ static void ApplyRotation_fx( *d = BASOP_Util_Add_Mant32Exp( Mpy_32_32( c, x11 ), add( c_e, x11_e ), Mpy_32_32( s, x12 ), add( s_e, x12_e ), d_e ); move32(); - *g = BASOP_Util_Add_Mant32Exp( Mpy_32_32( c, x12 ), add( c_e, x12_e ), Mpy_32_32( -s, x11 ), add( s_e, x11_e ), g_e ); + *g = BASOP_Util_Add_Mant32Exp( Mpy_32_32( c, x12 ), add( c_e, x12_e ), Mpy_32_32( L_negate( s ), x11 ), add( s_e, x11_e ), g_e ); move32(); FOR( ch = 0; ch < nChannels; ch++ ) @@ -1185,7 +1185,7 @@ static void ApplyRotation_fx( move32(); singularVector[ch][currentIndex2] = L_shl_sat( singularVector[ch][currentIndex2], temp_exp ); move32(); - singularVector[ch][currentIndex1] = BASOP_Util_Add_Mant32Exp( Mpy_32_32( c, x12 ), c_e, Mpy_32_32( -s, x11 ), s_e, &temp_exp ); + singularVector[ch][currentIndex1] = BASOP_Util_Add_Mant32Exp( Mpy_32_32( c, x12 ), c_e, Mpy_32_32( L_negate( s ), x11 ), s_e, &temp_exp ); move32(); singularVector[ch][currentIndex1] = L_shl_sat( singularVector[ch][currentIndex1], temp_exp ); move32(); diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 153491732..4dec71a19 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -2639,7 +2639,7 @@ ivas_error IVAS_DEC_VoIP_FeedFrame( dataUnit->silenceIndicator = 0; /* there are no partial copies for SID frames */ dataUnit->timeScale = 1000; dataUnit->rcvTime = rcvTime_ms; - dataUnit->timeStamp = L_sub( rtpTimeStamp, imult3216( dataUnit->duration, partialCopyOffset ) ); + dataUnit->timeStamp = (UWord32) W_sub( rtpTimeStamp, imult3216( dataUnit->duration, partialCopyOffset ) ); move32(); dataUnit->partial_frame = 1; dataUnit->partialCopyOffset = partialCopyOffset; diff --git a/lib_dec/post_dec_fx.c b/lib_dec/post_dec_fx.c index 5f4d5e195..bf9e51a87 100644 --- a/lib_dec/post_dec_fx.c +++ b/lib_dec/post_dec_fx.c @@ -531,7 +531,7 @@ static void bass_pf_1sf_delay( } ELSE { - ener2 = L_add( 0xFFF95B2C, 0 ); /* log2(0.01) (15Q16) */ + ener2 = L_add( (Word32) 0xFFF95B2C, 0 ); /* log2(0.01) (15Q16) */ } *lp_error_ener = L_add( Mpy_32_16_1( L_sub( *lp_error_ener, ener2 ), 32440 /*0.99f Q15*/ ), ener2 ); /* 15Q16 */ diff --git a/lib_enc/hq_hr_enc.c b/lib_enc/hq_hr_enc.c index 63f671379..506a90e43 100644 --- a/lib_enc/hq_hr_enc.c +++ b/lib_enc/hq_hr_enc.c @@ -367,7 +367,11 @@ void hq_hr_enc( if ( hqswb_clas == HQ_GEN_SWB || hqswb_clas == HQ_GEN_FB ) { #ifdef IVAS_FLOAT_FIXED +#ifdef MSAN_FIX + floatToFixed_arrL32( t_audio, t_audio_fx, Q12, L_FRAME48k ); +#else floatToFixed_arrL32( t_audio, t_audio_fx, Q12, L_FRAME48k_EXT ); +#endif hq_generic_hf_encoding_fx( t_audio_fx, hq_generic_fenv_fx, hq_generic_offset, st, &hq_generic_exc_clas, length ); fixedToFloat_arr( hq_generic_fenv_fx, hq_generic_fenv, Q1, HQ_FB_FENV ); #else diff --git a/lib_enc/ivas_cpe_enc.c b/lib_enc/ivas_cpe_enc.c index 50eb83ee5..b0cdf76d2 100644 --- a/lib_enc/ivas_cpe_enc.c +++ b/lib_enc/ivas_cpe_enc.c @@ -412,23 +412,18 @@ ivas_error ivas_cpe_enc( stereo_dft_hybrid_ITD_flag( hCPE->hStereoDft->hConfig, input_Fs, hCPE->hStereoDft->hItd->hybrid_itd_max ); #ifdef IVAS_FLOAT_FIXED /* flt2fix: to be removed */ - // Word16 input_fx[CPE_CHANNELS][1965]; FOR( int i = 0; i < CPE_CHANNELS; i++ ) { - // sts[i]->input_fx = &input_fx[i][0]; - // sts[i]->q_inp = Q_factor_arr(sts[i]->input, 1965); - // sts[i]->q_old_inp = sts[i]->q_inp = Q_factor_arr( sts[i]->old_input_signal, 1965 ); // check length sts[i]->q_inp = Q_factor_arr( sts[i]->old_input_signal, 1965 ); // check length +#ifndef MSAN_FIX hCPE->hStereoDft->q_input_mem_itd[i] = Q_factor_arr( &hCPE->hStereoDft->input_mem_itd[i][0], STEREO_DFT_OVL_MAX ); - // hCPE->hStereoDft->DFT_q_fx[i] = Q_factor_arrL(&hCPE->hStereoDft->DFT[i][0], STEREO_DFT_N_MAX_ENC); - // f2me_buf( hCPE->hStereoDft->DFT[i], hCPE->hStereoDft->DFT_fx[i], &hCPE->hStereoDft->DFT_fx_e[i], STEREO_DFT_N_MAX_ENC ); +#endif // MSAN_FIX hCPE->q_input_mem[i] = Q_factor_arr( &hCPE->input_mem[i][0], NS2SA( input_Fs, STEREO_DFT_OVL_NS ) ); - // floatToFixed_arr(sts[i]->old_input_signal, sts[i]->old_input_signal_fx, sts[i]->q_old_inp, 1965); floatToFixed_arr( sts[i]->old_input_signal, sts[i]->old_input_signal_fx, sts[i]->q_inp, 1965 ); - // floatToFixed_arr(sts[i]->input, sts[i]->input_fx, sts[i]->q_inp, 1965); - // floatToFixed_arrL(&hCPE->hStereoDft->DFT[i][0], &hCPE->hStereoDft->DFT_fx[i][0], hCPE->hStereoDft->DFT_q_fx[i], STEREO_DFT_N_MAX_ENC); floatToFixed_arr( &hCPE->input_mem[i][0], &hCPE->input_mem_fx[i][0], hCPE->q_input_mem[i], NS2SA( input_Fs, STEREO_DFT_OVL_NS ) ); +#ifndef MSAN_FIX floatToFixed_arr( &hCPE->hStereoDft->input_mem_itd[i][0], &hCPE->hStereoDft->input_mem_itd_fx[i][0], hCPE->hStereoDft->q_input_mem_itd[i], STEREO_DFT_OVL_MAX ); +#endif // MSAN_FIX } floatToFixed_arrL( hCPE->hStereoDft->side_gain, hCPE->hStereoDft->side_gain_fx, Q31, STEREO_DFT_ENC_DFT_NB * STEREO_DFT_BAND_MAX ); floatToFixed_arrL( hCPE->hStereoDft->res_pred_gain, hCPE->hStereoDft->res_pred_gain_fx, Q31, STEREO_DFT_ENC_DFT_NB * STEREO_DFT_BAND_MAX ); @@ -437,11 +432,6 @@ ivas_error ivas_cpe_enc( floatToFixed_arrL( hCPE->hStereoDft->hItd->deltaItd, hCPE->hStereoDft->hItd->deltaItd_fx, Q16, STEREO_DFT_ENC_DFT_NB ); /* flt2fix end */ - /*FOR(int i = 0; i < 2; i++) - { - hCPE->hStereoDft->hItd->deltaItd_fx[i] = float_to_fix(hCPE->hStereoDft->hItd->deltaItd[i], hCPE->hStereoDft->hItd->q_itd); - hCPE->hStereoDft->hItd->itd_fx[i] = float_to_fix(hCPE->hStereoDft->hItd->itd[i], hCPE->hStereoDft->hItd->q_itd); - }*/ /* Time Domain ITD compensation using extrapolation */ stereo_td_itd_fx( hCPE->hStereoDft->hItd, hCPE->hStereoDft->input_mem_itd_fx, hCPE->hStereoDft->q_input_mem_itd, hCPE->hStereoDft->hConfig->hybrid_itd_flag, hCPE->hStereoDft->dft_ovl, sts, input_frame, hCPE->input_mem_fx, hCPE->q_input_mem ); @@ -473,7 +463,14 @@ ivas_error ivas_cpe_enc( fixedToFloat_arr( &hCPE->input_mem_fx[i][0], &hCPE->input_mem[i][0], hCPE->q_input_mem[i], NS2SA( input_Fs, STEREO_DFT_OVL_NS ) ); // fixedToFloat_arrL( &hCPE->hStereoDft->DFT_fx[i][0], &hCPE->hStereoDft->DFT[i][0], hCPE->hStereoDft->DFT_q_fx[i], STEREO_DFT_N_MAX_ENC ); me2f_buf( hCPE->hStereoDft->DFT_fx[i], hCPE->hStereoDft->DFT_fx_e[i], hCPE->hStereoDft->DFT[i], STEREO_DFT_N_MAX_ENC ); +#ifdef MSAN_FIX + IF( hCPE->hStereoDft->hItd->td_itd[STEREO_DFT_OFFSET] != 0 && EQ_16( sts[0]->element_mode, IVAS_CPE_DFT ) ) + { + fixedToFloat_arr( &hCPE->hStereoDft->input_mem_itd_fx[i][0], &hCPE->hStereoDft->input_mem_itd[i][0], hCPE->hStereoDft->q_input_mem_itd[i], hCPE->hStereoDft->dft_ovl ); + } +#else fixedToFloat_arr( &hCPE->hStereoDft->input_mem_itd_fx[i][0], &hCPE->hStereoDft->input_mem_itd[i][0], hCPE->hStereoDft->q_input_mem_itd[i], STEREO_DFT_OVL_MAX ); +#endif // MSAN_FIX } /* fix2flt end */ diff --git a/lib_enc/ivas_front_vad.c b/lib_enc/ivas_front_vad.c index 78e265baa..95ead975a 100644 --- a/lib_enc/ivas_front_vad.c +++ b/lib_enc/ivas_front_vad.c @@ -808,8 +808,9 @@ ivas_error front_vad_spar( hSpMusClas->relE_attack_sum_fx = (Word16) ( hSpMusClas->relE_attack_sum * ONE_IN_Q9 ); Word16 Qfact_PS = Q_factor_arrL( PS, 128 ); floatToFixed_arr32( PS, PS_fx, Qfact_PS, 128 ); - Word16 Q_esp = Q_factor_arrL( epsP, M + 1 ); - floatToFixed_arrL( epsP, epsP_fx, Q_esp, M + 1 ); + Word16 Q_esp, e_esp; + f2me_buf( epsP, epsP_fx, &e_esp, M + 1 ); + Q_esp = sub( 31, e_esp ); Word16 Qfact_PS_past = Q_factor_arrL( hSpMusClas->past_PS, 67 ); floatToFixed_arr32( hSpMusClas->past_PS, hSpMusClas->past_PS_fx, Qfact_PS_past, 67 ); #endif diff --git a/lib_enc/ivas_mct_core_enc.c b/lib_enc/ivas_mct_core_enc.c index 51fbabf1e..775dbbfff 100644 --- a/lib_enc/ivas_mct_core_enc.c +++ b/lib_enc/ivas_mct_core_enc.c @@ -798,9 +798,16 @@ void ivas_mct_core_enc( nCPE = add( nCPE, 1 ); } +#ifdef MSAN_FIX + FOR( ch = 0; ch < MCT_MAX_CHANNELS; ch++ ) + { + set32_fx( powerSpecMsInv_long_fx[ch], 0, L_FRAME48k ); + q_powSpec[ch] = 0; + } +#endif // MSAN_FIX FOR( ch = 0; ch < nChannels; ch++ ) { -#if 1 // Float initialization to be removed +#if 1 // Float initialization to be removed inv_mdst_spectrum[ch][0] = powerSpecMsInv[ch][0] = powerSpecMsInv_long[ch]; inv_mdst_spectrum[ch][1] = powerSpecMsInv[ch][1] = powerSpecMsInv_long[ch] + N_TCX10_MAX; inv_spectrum[ch][0] = inv_spectrum_long[ch]; diff --git a/lib_enc/ivas_stereo_dft_enc.c b/lib_enc/ivas_stereo_dft_enc.c index 78503c938..08bb661e0 100644 --- a/lib_enc/ivas_stereo_dft_enc.c +++ b/lib_enc/ivas_stereo_dft_enc.c @@ -1462,7 +1462,11 @@ void stereo_dft_enc_analyze_fx( { FOR( n = 0; n < n_channels; n++ ) { +#ifdef MSAN_FIX + Scale_sig( hStereoDft->input_mem_itd_fx[n], dft_ovl, sub( sts[n]->q_inp, hStereoDft->q_input_mem_itd[n] ) ); +#else Scale_sig( hStereoDft->input_mem_itd_fx[n], STEREO_DFT_OVL_MAX, sts[n]->q_inp - hStereoDft->q_input_mem_itd[n] ); +#endif // MSAN_FIX hStereoDft->q_input_mem_itd[n] = sts[n]->q_inp; move16(); Copy( hStereoDft->input_mem_itd_fx[n], input_mem[n], dft_ovl ); @@ -2723,13 +2727,25 @@ void stereo_dft_enc_process( hStereoDft->hItd->prev_m1_fx = floatToFixed( hStereoDft->hItd->prev_m1, 31 ); hStereoDft->hItd->prev_m2_fx = floatToFixed( hStereoDft->hItd->prev_m2, 31 ); f2me( hStereoDft->hItd->currFlatness, &hStereoDft->hItd->currFlatness_fx, &hStereoDft->hItd->currFlatness_fx_e ); +#ifdef MSAN_FIX + hCPE->hStereoClassif->prev_IPD_fx = floatToFixed( hCPE->hStereoClassif->prev_IPD, Q29 ); + hCPE->hStereoClassif->prev_g_IPD_fx = floatToFixed( hCPE->hStereoClassif->prev_g_IPD, Q29 ); + hCPE->hStereoClassif->prev_ratio_m1_m2_fx = floatToFixed( hCPE->hStereoClassif->prev_ratio_m1_m2, Q31 ); +#endif + +#ifndef MSAN_FIX hCPE->hStereoClassif->xtalk_score_fx = floatToFixed( hCPE->hStereoClassif->xtalk_score, 31 ); +#endif // !MSAN_FIX floatToFixed_arrL( hCPE->hStereoClassif->xtalk_score_buf, hCPE->hStereoClassif->xtalk_score_buf_fx, 31, XTALK_SCORE_BUF_LEN ); hCPE->hStereoClassif->xtalk_wscore_fx = floatToFixed( hCPE->hStereoClassif->xtalk_wscore, 31 ); stereo_dft_enc_compute_itd_fx( hCPE, pDFT_L_fx, hStereoDft->DFT_fx_e[0], pDFT_R_fx, hStereoDft->DFT_fx_e[1], k_offset, input_frame, vad_flag_dtx, vad_hover_flag, bin_nrgL_fx, bin_nrgL_fx_e, bin_nrgR_fx, bin_nrgR_fx_e ); /*fix2flt*/ +#ifdef MSAN_FIX + hCPE->hStereoClassif->prev_ratio_m1_m2 = fixedToFloat( hCPE->hStereoClassif->prev_ratio_m1_m2_fx, Q31 ); + hCPE->hStereoClassif->prev_IPD = fixedToFloat( hCPE->hStereoClassif->prev_IPD_fx, Q29 ); +#endif hStereoDft->sfm = fixedToFloat( hStereoDft->sfm_fx, 31 ); me2f_buf( hStereoDft->xspec_smooth_fx, hStereoDft->xspec_smooth_fx_e, hStereoDft->xspec_smooth, STEREO_DFT_N_32k_ENC ); me2f_buf( hStereoDft->Spd_L_smooth_fx, hStereoDft->Spd_L_smooth_fx_e, hStereoDft->Spd_L_smooth, STEREO_DFT_N_32k_ENC / 2 ); diff --git a/lib_enc/ivas_stereo_dft_enc_itd.c b/lib_enc/ivas_stereo_dft_enc_itd.c index b470b8309..e97e32f91 100644 --- a/lib_enc/ivas_stereo_dft_enc_itd.c +++ b/lib_enc/ivas_stereo_dft_enc_itd.c @@ -1473,7 +1473,11 @@ void stereo_dft_enc_compute_itd_fx( pDFT_L = DFT_L; pDFT_R = DFT_R; +#ifdef MSAN_FIX + FOR( i = 0; i < NFFT; i++ ) +#else FOR( i = 0; i < STEREO_DFT_N_MAX_ENC; i++ ) +#endif // MSAN_FIX { L_temp_e = norm_l( pDFT_L[i] ); pDFT_L[i] = L_shl( pDFT_L[i], L_temp_e ); diff --git a/lib_enc/ivas_stereo_mdct_igf_enc.c b/lib_enc/ivas_stereo_mdct_igf_enc.c index 51862db72..30b53d7d0 100644 --- a/lib_enc/ivas_stereo_mdct_igf_enc.c +++ b/lib_enc/ivas_stereo_mdct_igf_enc.c @@ -336,6 +336,13 @@ static void IGF_MsStereoDecision_fx( Word16 pc_target_e, pc_src_e; Word16 tmp1, tmp1_e, tmp2, tmp2_e; +#ifdef MSAN_FIX + pc_target_e = 0; + pc_src_e = 0; + move16(); + move16(); +#endif // MSAN_FIX + Word16 coh_src = calcCoh_fx( &specL_fx[strt_cpy], &specR_fx[strt_cpy], q_spec, width, &cc_src_fx, &cc_src_e, &pc_src_fx, &pc_src_e ); Word16 coh_target = calcCoh_fx( &specL_fx[hGrid->swb_offset[sfb]], &specR_fx[hGrid->swb_offset[sfb]], q_spec, width, &cc_target_fx, &cc_target_e, &pc_target_fx, &pc_target_e ); tmp1_e = BASOP_Util_Add_MantExp( pc_target_fx, pc_target_e, negate( pc_src_fx ), pc_src_e, &tmp1 ); diff --git a/lib_rend/ivas_dirac_dec_binaural_functions.c b/lib_rend/ivas_dirac_dec_binaural_functions.c index 70d24c2a2..f9d1bdfa0 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions.c @@ -3346,7 +3346,7 @@ static void ivas_dirac_dec_binaural_determine_processing_matrices_fx( move32(); CxIm_fx[1][0] = L_shr( hDiracDecBin->ChCrossIm_fx[bin], sub( hDiracDecBin->q_ChCross, hDiracDecBin->q_ChEne ) ); move32(); - CxIm_fx[0][1] = L_shr( -hDiracDecBin->ChCrossIm_fx[bin], sub( hDiracDecBin->q_ChCross, hDiracDecBin->q_ChEne ) ); + CxIm_fx[0][1] = L_shr( L_negate( hDiracDecBin->ChCrossIm_fx[bin] ), sub( hDiracDecBin->q_ChCross, hDiracDecBin->q_ChEne ) ); move32(); q_Cx = hDiracDecBin->q_ChEne; move16(); @@ -3367,7 +3367,7 @@ static void ivas_dirac_dec_binaural_determine_processing_matrices_fx( move32(); CxIm_fx[1][0] = hDiracDecBin->ChCrossIm_fx[bin]; move32(); - CxIm_fx[0][1] = -hDiracDecBin->ChCrossIm_fx[bin]; + CxIm_fx[0][1] = L_negate( hDiracDecBin->ChCrossIm_fx[bin] ); move32(); q_Cx = hDiracDecBin->q_ChCross; move16(); diff --git a/lib_rend/ivas_reflections.c b/lib_rend/ivas_reflections.c index 8a8bc44ca..00d4d0ef9 100644 --- a/lib_rend/ivas_reflections.c +++ b/lib_rend/ivas_reflections.c @@ -756,7 +756,7 @@ ivas_error ivas_er_compute_reflections( FOR( j = 0; j < reflections->shoebox_data.n_ref; j++ ) { tmp_fx = reflections->shoebox_data.times.data_fx[add( j, i_mult( i, reflections->shoebox_data.n_ref ) )]; - tmp_fx_lo = extract_l( tmp_fx ); + tmp_fx_lo = u_extract_l( tmp_fx ); Mpy_32_16_uu( tmp_fx, (UWord16) reflections->output_Fs_fx, &tmp_fx1, &tmp_fx_lo ); tmp_fx1 = (UWord32) L_add( tmp_fx1, 0x20 ); tmp_fx1 = L_shr( tmp_fx1, 6 ); -- GitLab From c4f4b3557ed0bbde68ac98c5238a486eb5459de3 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Thu, 29 Aug 2024 16:38:08 +0530 Subject: [PATCH 2/2] Clang formatting changes --- lib_com/bitstream_fx.c | 2 +- lib_dec/igf_dec_fx.c | 2 +- lib_dec/inov_dec_fx.c | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib_com/bitstream_fx.c b/lib_com/bitstream_fx.c index e73734fee..2dc3d9c76 100644 --- a/lib_com/bitstream_fx.c +++ b/lib_com/bitstream_fx.c @@ -423,7 +423,7 @@ UWord16 get_next_indice_fx( /* o : value of the indice */ FOR( i = 0; i < nb_bits; i++ ) { value = (UWord16) L_shl( value, 1 ); - value = (UWord16)L_add( value, st_fx->bit_stream[add( st_fx->next_bit_pos, i )] ); + value = (UWord16) L_add( value, st_fx->bit_stream[add( st_fx->next_bit_pos, i )] ); } /* update the position in the bitstream */ diff --git a/lib_dec/igf_dec_fx.c b/lib_dec/igf_dec_fx.c index df96b379b..fed5ee9fb 100644 --- a/lib_dec/igf_dec_fx.c +++ b/lib_dec/igf_dec_fx.c @@ -1932,7 +1932,7 @@ static void IGF_appl( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in tileIdx = add( tileIdx, 1 ); } /*do a test multiplication with the highest possible value*/ - L_tmp = Mpy_32_16_1( (Word32)0xFFFF8000 /*igf_spec occupies only the 16LSBs */, gain[sfb] ); + L_tmp = Mpy_32_16_1( (Word32) 0xFFFF8000 /*igf_spec occupies only the 16LSBs */, gain[sfb] ); L_tmp_e = add( igf_spec_e[tileIdx], gain_e[sfb] ); /*check whether overflow would occur and calculate Headroom, needed*/ shift = sub( L_tmp_e, *spectrum_e ); diff --git a/lib_dec/inov_dec_fx.c b/lib_dec/inov_dec_fx.c index b1f405004..05f7f9809 100644 --- a/lib_dec/inov_dec_fx.c +++ b/lib_dec/inov_dec_fx.c @@ -117,12 +117,12 @@ void inov_decode_fx( // PMT("CONDITION above is missing -> idchan") FOR( i = 0; i < wordcnt; i++ ) { - indexing_indices[i] = extract_l(get_next_indice_fx( st_fx, 16 )); + indexing_indices[i] = extract_l( get_next_indice_fx( st_fx, 16 ) ); move16(); } IF( bitcnt ) { - indexing_indices[i] = extract_l(get_next_indice_fx( st_fx, bitcnt )); + indexing_indices[i] = extract_l( get_next_indice_fx( st_fx, bitcnt ) ); move16(); } config = PulseConfTable[st_fx->acelp_cfg.fixed_cdk_index[i_subfr / L_SUBFR]]; -- GitLab