diff --git a/lib_dec/FEC_HQ_phase_ecu_fx.c b/lib_dec/FEC_HQ_phase_ecu_fx.c index 99dfd8be50fe62573c0c717ca13c4704815fb357..0b79c49a1196db07582355b6b3463384d92fc111 100644 --- a/lib_dec/FEC_HQ_phase_ecu_fx.c +++ b/lib_dec/FEC_HQ_phase_ecu_fx.c @@ -1720,7 +1720,7 @@ static void ivas_spec_ana_fx( { nJacob = n; move16(); - if ( sub( endPlocs, plocs[sub( *num_plocs, 1 )] <= 0 ) ) + if ( sub( endPlocs, plocs[sub( *num_plocs, 1 )] ) <= 0 ) { nJacob = sub( nJacob, 1 ); } diff --git a/lib_dec/ivas_stereo_switching_dec.c b/lib_dec/ivas_stereo_switching_dec.c index dd44d2091d47fdc5cf69535a6f6c5155af621c46..853a2ff80361e4968ca1d2d1322b277f7c7e83c9 100644 --- a/lib_dec/ivas_stereo_switching_dec.c +++ b/lib_dec/ivas_stereo_switching_dec.c @@ -561,7 +561,7 @@ static void cpy_tcx_ltp_data( static void cpy_tcx_ltp_data_fx( TCX_LTP_DEC_HANDLE hTcxLtpDecOld, /* i : TCX-LTP structure to copy from */ TCX_LTP_DEC_HANDLE hTcxLtpDecNew, /* o : TCX-LTP structure to copy to */ - const int32_t output_Fs /* i : output sampling rate */ + const Word32 output_Fs /* i : output sampling rate */ ) { Word16 sz; @@ -577,10 +577,14 @@ static void cpy_tcx_ltp_data_fx( sz = extract_l( Mpy_32_32_r( TCXLTP_MAX_DELAY * output_Fs, 44739 /* 1 / 48000 in Q31 */ ) ); Copy( hTcxLtpDecOld->tcxltp_mem_in, hTcxLtpDecNew->tcxltp_mem_in, sz ); // TODO: One of these will be removed later Copy32( hTcxLtpDecOld->tcxltp_mem_in_32, hTcxLtpDecNew->tcxltp_mem_in_32, sz ); + hTcxLtpDecNew->exp_tcxltp_mem_in = hTcxLtpDecOld->exp_tcxltp_mem_in; + move16(); /* (int16_t) ( ( L_FRAME48k * output_Fs ) / 48000 ) */ sz = extract_l( Mpy_32_32_r( L_FRAME48k * output_Fs, 44739 /* 1 / 48000 in Q31 */ ) ); Copy( hTcxLtpDecOld->tcxltp_mem_out, hTcxLtpDecNew->tcxltp_mem_out, sz ); // TODO: One of these will be removed later Copy32( hTcxLtpDecOld->tcxltp_mem_out_32, hTcxLtpDecNew->tcxltp_mem_out_32, sz ); + hTcxLtpDecNew->exp_tcxltp_mem_out = hTcxLtpDecOld->exp_tcxltp_mem_out; + move16(); return; } diff --git a/lib_rend/ivas_dirac_output_synthesis_dec.c b/lib_rend/ivas_dirac_output_synthesis_dec.c index 3fca74b272a12ebeeb1dfefbe1d51ef308093b15..e65d811c18c8fba4903672c53c7aa7f5111e9ca5 100644 --- a/lib_rend/ivas_dirac_output_synthesis_dec.c +++ b/lib_rend/ivas_dirac_output_synthesis_dec.c @@ -3229,7 +3229,7 @@ void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls_fx( IF( EQ_32( *( p_power_smooth_prev ), EPSILON_FX ) ) { p_power_smooth_prev++; - L_tmp = BASOP_Util_Divide3232_Scale_cadence( ONE_IN_Q31, 4612, &exp ); // 1e-15 in Q62 is 4612 + L_tmp = BASOP_Util_Divide3232_Scale_cadence( ONE_IN_Q31, EPSILON_FX, &exp ); exp_arr[add( i_mult( k, num_freq_bands ), l )] = exp; move16(); @@ -3276,14 +3276,7 @@ void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls_fx( *p_power_smooth = L_shr( *p_power_smooth, sub( min_exp, exp_arr[add( i_mult( k, num_freq_bands ), l )] ) ); move32(); p_power_smooth++; - IF( EQ_32( *( p_power_smooth_prev ), EPSILON_FX ) ) - { - q_tmp = add( sub( Q31, min_exp ), Q31 - 62 ); - } - ELSE - { - q_tmp = add( sub( Q31, min_exp ), sub( Q31, h_dirac_output_synthesis_state->proto_power_smooth_q ) ); - } + q_tmp = add( sub( Q31, min_exp ), sub( Q31, h_dirac_output_synthesis_state->proto_power_smooth_q ) ); } } diff --git a/lib_rend/ivas_dirac_rend.c b/lib_rend/ivas_dirac_rend.c index f406c48b93ff8f9fb2eb86b08e834f56aea451d5..0d79c6014b4024feab798e1e3622cba926d8e4c0 100644 --- a/lib_rend/ivas_dirac_rend.c +++ b/lib_rend/ivas_dirac_rend.c @@ -3103,11 +3103,20 @@ void protoSignalComputation2_fx( move32(); } - sum_total_ratio_fx[l] = BASOP_Util_Divide3232_Scale( stereo_type_detect->sum_power_fx[l], L_add( stereo_type_detect->total_power_fx[l], EPSILON_FX ), &exp ); - move32(); - q_sum_total_ratio = add( sub( 15, exp ), sub( s_min( stereo_type_detect->q_sum_power, q_temp2 ), s_min( stereo_type_detect->q_total_power, q_temp ) ) ); - sum_total_ratio_fx[l] = L_shl( sum_total_ratio_fx[l], sub( Q15, q_sum_total_ratio ) ); - move32(); + test(); + IF( ( stereo_type_detect->sum_power_fx[l] == 0 ) && ( stereo_type_detect->total_power_fx[l] == 0 ) ) + { + sum_total_ratio_fx[l] = MAX_16; + move32(); + } + ELSE + { + sum_total_ratio_fx[l] = BASOP_Util_Divide3232_Scale( stereo_type_detect->sum_power_fx[l], L_add( stereo_type_detect->total_power_fx[l], EPSILON_FX ), &exp ); + move32(); + q_sum_total_ratio = add( sub( 15, exp ), sub( s_min( stereo_type_detect->q_sum_power, q_temp2 ), s_min( stereo_type_detect->q_total_power, q_temp ) ) ); + sum_total_ratio_fx[l] = L_shl( sum_total_ratio_fx[l], sub( Q15, q_sum_total_ratio ) ); + move32(); + } } IF( l == 0 ) diff --git a/lib_rend/ivas_orient_trk.c b/lib_rend/ivas_orient_trk.c index 6f308742c4ac7f605cdf6f61b5b5cd637bdb21bb..7ef937cc3f0641769267d4be21f5b93aef13c90e 100644 --- a/lib_rend/ivas_orient_trk.c +++ b/lib_rend/ivas_orient_trk.c @@ -509,56 +509,25 @@ static Word32 QuaternionAngle_fx( QuaternionConjugate_fx( q1, &q12 ); QuaternionProduct_fx( q12, q2, &q12 ); // q12:Q25, q2:Q29, q1: Q27// - IF( q12.w_fx < 0 ) - { - Word32 temp = 0; - move32(); - Word16 q_dot, result_e = 0; - move16(); - temp = q12.w_fx; - move32(); - q12.w_fx = 0; - move32(); - Word32 result = 0; - move32(); - result = QuaternionDotProduct_fx( q12, q12, &q_dot ); - result_e = sub( 31, q_dot ); - result = Sqrt32( result, &result_e ); - q12.w_fx = temp; - move32(); + Word32 temp = 0; + move32(); + Word16 q_dot, result_e = 0; + move16(); + temp = q12.w_fx; + move32(); + q12.w_fx = 0; + move32(); + Word32 result = 0; + move32(); + result = QuaternionDotProduct_fx( q12, q12, &q_dot ); + result_e = sub( 31, q_dot ); + result = Sqrt32( result, &result_e ); + q12.w_fx = temp; + move32(); - // Converting numerator to same Q as denominator// - IF( 0 > result_e ) - { - result = L_shr( L_shr( result, negate( result_e ) ), sub( 31, q12.q_fact ) ); // Q25 - } - ELSE - { - IF( GT_32( result_e, sub( Q31, q12.q_fact ) ) ) - { - result = L_shl( result, sub( result_e, sub( Q31, q12.q_fact ) ) ); - } - ELSE - { - result = L_shr( result, sub( sub( Q31, q12.q_fact ), result_e ) ); - } - } - IF( GT_32( q12.w_fx, result ) ) - { - Word16 tan_result = BASOP_util_atan2( result, q12.w_fx, 0 ); - result = L_deposit_h( tan_result ); // Q29 - return result; - } - ELSE - { - return PI_OVER_Q29; - } - } - ELSE - { - angle = PI_OVER_Q29; - move32(); - } + Word16 tan_result = BASOP_util_atan2( result, q12.w_fx, sub( result_e, sub( 31, q12.q_fact ) ) ); + result = L_deposit_h( tan_result ); // Q29 + return result; return angle; }