From d8de2d6b09896951ebe0824647d035d03259866b Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Thu, 22 Aug 2024 19:07:25 +0530 Subject: [PATCH] Fix for few high MLD cases [x] Bug in HQ_ecu (OMASA 2Dir2TC 3ISM at 80 kbps, 32kHz in, 16kHz out, 5.1.4 out) fixed [x] Fix for stv original- Multi-channel 7_1_4 bitrate switching from 13.2 kbps to 512 kbps, 48kHz in, 48kHz out, HOA3 out MLD [x] assignment of exp_tcxltp_mem_in and exp_tcxltp_mem_out in the function cpy_tcx_ltp_data_fx which were missed [x] high mld fix for the case [stv-SBA at 48 kbps, 32kHz in, 32kHz out, BINAURAL ROOM IR out, HR, OT] --- lib_dec/FEC_HQ_phase_ecu_fx.c | 2 +- lib_dec/ivas_stereo_switching_dec.c | 6 +- lib_rend/ivas_dirac_output_synthesis_dec.c | 11 +--- lib_rend/ivas_dirac_rend.c | 19 ++++-- lib_rend/ivas_orient_trk.c | 67 ++++++---------------- 5 files changed, 40 insertions(+), 65 deletions(-) diff --git a/lib_dec/FEC_HQ_phase_ecu_fx.c b/lib_dec/FEC_HQ_phase_ecu_fx.c index 99dfd8be5..0b79c49a1 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 dd44d2091..853a2ff80 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 3fca74b27..e65d811c1 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 f406c48b9..0d79c6014 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 6f308742c..7ef937cc3 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; } -- GitLab