From 0288d39e52a9dc7ad3e2d5fcba72a7ddbb4bd332 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Thu, 8 May 2025 16:18:54 +0530 Subject: [PATCH] Fix for complexity measurement CI pipeline crashes --- lib_com/gs_noisefill_fx.c | 3 +- lib_com/lpc_tools_fx.c | 2 +- lib_dec/tonalMDCTconcealment_fx.c | 43 ++++++----------------- lib_rend/ivas_objectRenderer_hrFilt_fx.c | 2 +- lib_rend/ivas_objectRenderer_sfx_fx.c | 20 +++++------ lib_rend/ivas_objectRenderer_sources_fx.c | 20 +++++------ lib_rend/ivas_prot_rend_fx.h | 6 ++-- lib_rend/ivas_stat_rend.h | 4 +-- 8 files changed, 40 insertions(+), 60 deletions(-) diff --git a/lib_com/gs_noisefill_fx.c b/lib_com/gs_noisefill_fx.c index 61aa1333c..1198fb793 100644 --- a/lib_com/gs_noisefill_fx.c +++ b/lib_com/gs_noisefill_fx.c @@ -1418,7 +1418,8 @@ void highband_exc_dct_in_ivas_fx( envelop_modify_fx( exc_diffQ, seed_tcx, last_bin, Ener_per_bd_iQ, *Q_exc, &Q_hb_exc ); #ifdef REMOVE_EVS_DUPLICATES test(); - IF( GT_16( *Q_exc, Q_hb_exc ) && GT_16( element_mode, EVS_MONO ) ) + test(); + IF( GT_16( *Q_exc, Q_hb_exc ) && GT_16( element_mode, EVS_MONO ) && exc_wo_nf != NULL ) #else IF( GT_16( *Q_exc, Q_hb_exc ) ) #endif diff --git a/lib_com/lpc_tools_fx.c b/lib_com/lpc_tools_fx.c index bde05b4f4..1035f017a 100644 --- a/lib_com/lpc_tools_fx.c +++ b/lib_com/lpc_tools_fx.c @@ -1114,7 +1114,7 @@ static void lsp_reorder( { lsp[i] = s_max( lsp[i], lsp_min ); move16(); - lsp_min = add( lsp[i], min_dist ); + lsp_min = add_sat( lsp[i], min_dist ); } /* Reverify the LSF ordering and minimum GAP in the reverse order (security) */ diff --git a/lib_dec/tonalMDCTconcealment_fx.c b/lib_dec/tonalMDCTconcealment_fx.c index 5afceff55..f33a6c84f 100644 --- a/lib_dec/tonalMDCTconcealment_fx.c +++ b/lib_dec/tonalMDCTconcealment_fx.c @@ -450,17 +450,16 @@ void TonalMDCTConceal_SaveFreqSignal_ivas_fx( IF( ( nNewSamples > 0 ) && ( LE_16( nNewSamples, 2 * L_FRAME_MAX ) ) ) { /* Store new data */ - hTonalMDCTConc->last_block_nrg = 0; - move32(); - + Word64 W_tmp = 0; + move64(); FOR( i = 0; i < infoIGFStartLine; i++ ) { - Word16 tmp = extract_h( mdctSpectrum[i] ); - hTonalMDCTConc->last_block_nrg = L_add( hTonalMDCTConc->last_block_nrg, - L_shr( L_mult0( tmp, tmp ), 16 ) ); // Q31-last_block_nrg_exp - move32(); + W_tmp = W_mac_32_16( W_tmp, Mpy_32_32( mdctSpectrum[i], mdctSpectrum[i] ), 1 ); // exp: mdctSpectrum_exp + mdctSpectrum_exp - 1 } - hTonalMDCTConc->last_block_nrg_exp = sub( 31, sub( shl( sub( 15, mdctSpectrum_exp ), 1 ), 16 ) ); + s = W_norm( W_tmp ); + hTonalMDCTConc->last_block_nrg = W_extract_h( W_shl( W_tmp, s ) ); // exp:add( sub( shl( mdctSpectrum_exp, 1 ), s ), 31 ) + move32(); + hTonalMDCTConc->last_block_nrg_exp = add( sub( shl( mdctSpectrum_exp, 1 ), s ), 31 ); move16(); /* Store new data */ @@ -1765,32 +1764,12 @@ void TonalMDCTConceal_InsertNoise_ivas_fx( test(); IF( GT_32( hTonalMDCTConc->faded_signal_nrg, 0 ) && flag ) { - Word16 num_exp, den_exp; - Word32 num, den; + Word16 num_exp; + Word32 num; num = BASOP_Util_Add_Mant32Exp( hTonalMDCTConc->last_block_nrg, hTonalMDCTConc->last_block_nrg_exp, L_negate( last_block_nrg_correct ), last_block_nrg_correct_e, &num_exp ); // Q31-num_exp - - den = hTonalMDCTConc->faded_signal_nrg; // Q31 - hTonalMDCTConc->faded_signal_nrg_exp - move32(); - den_exp = hTonalMDCTConc->faded_signal_nrg_exp; - move16(); - - ld = norm_l( num ); - num = L_shl( num, ld ); // Q31-num_exp + ld - num_exp = sub( num_exp, ld ); - - ld = norm_l( den ); - den = L_shl( den, ld ); // Q31-den_exp + ld - den_exp = sub( den_exp, ld ); - - exp = sub( num_exp, den_exp ); - - IF( GT_32( num, den ) ) - { - num = L_shr( num, 1 ); // Q31- exp -1 - exp = add( exp, 1 ); - } - tmp = div_l( num, extract_h( den ) ); + tmp = BASOP_Util_Divide3232_Scale( num, hTonalMDCTConc->faded_signal_nrg, &exp ); + exp = add( exp, sub( num_exp, hTonalMDCTConc->faded_signal_nrg_exp ) ); tmp = Sqrt16( tmp, &exp ); FOR( i = 0; i < crossOverFreq; i++ ) diff --git a/lib_rend/ivas_objectRenderer_hrFilt_fx.c b/lib_rend/ivas_objectRenderer_hrFilt_fx.c index 30bf8f00a..a098aaa25 100644 --- a/lib_rend/ivas_objectRenderer_hrFilt_fx.c +++ b/lib_rend/ivas_objectRenderer_hrFilt_fx.c @@ -97,7 +97,7 @@ ivas_error TDREND_REND_RenderSourceHRFilt_fx( TDREND_firfilt_fx( RightOutputFrame_fx, Src_p->hrf_right_prev_fx, right_filter_e, hrf_right_delta_fx, intp_count, Src_p->mem_hrf_right_fx, subframe_length, Src_p->filterlength, Src_p->Gain_fx, Src_p->prevGain_fx ); Src_p->prevGain_fx = Src_p->Gain_fx; - move16(); + move32(); /* Copy to accumulative output frame */ v_add_32( LeftOutputFrame_fx, output_buf_fx[0], output_buf_fx[0], subframe_length ); // Same Q as Src_p->InputFrame_p_fx Q11 diff --git a/lib_rend/ivas_objectRenderer_sfx_fx.c b/lib_rend/ivas_objectRenderer_sfx_fx.c index 210706d5b..a570273cf 100644 --- a/lib_rend/ivas_objectRenderer_sfx_fx.c +++ b/lib_rend/ivas_objectRenderer_sfx_fx.c @@ -278,8 +278,8 @@ void TDREND_firfilt_fx( Word32 *mem_fx, /* i/o: filter memory Qx */ const Word16 subframe_length, /* i : Length of signal Q0 */ const Word16 filterlength, /* i : Filter length Q0 */ - const Word16 Gain_fx, /* i : Gain Q14 */ - const Word16 prevGain_fx /* i : Previous gain Q14 */ + const Word32 Gain_fx, /* i : Gain Q30 */ + const Word32 prevGain_fx /* i : Previous gain Q30 */ ) { /* NOTE: this function is implemented with the assumption that the exponent/Q-factor of input signal will not change. */ @@ -289,15 +289,15 @@ void TDREND_firfilt_fx( Word32 *p_filter_fx; // exp(filter_e) Word16 i, j; Word32 tmp_fx; - Word16 step_fx /* Q15 */, gain_tmp_fx /* Q15 */, gain_delta_fx /* Q14 */; + Word32 step_fx /* Q31 */, gain_tmp_fx /* Q31 */, gain_delta_fx /* Q30 */; Word16 tmp_e; Word64 tmp64_fx; - gain_delta_fx = sub( Gain_fx, prevGain_fx ); // Q14 - step_fx = BASOP_Util_Divide1616_Scale( gain_delta_fx, subframe_length, &tmp_e ); // exp(tmp_e) - tmp_e = sub( tmp_e, Q14 ); - step_fx = shl_sat( step_fx, tmp_e ); // Q15 - gain_tmp_fx = shl_sat( prevGain_fx, 1 ); // Q15 + gain_delta_fx = L_sub( Gain_fx, prevGain_fx ); // Q30 + step_fx = L_deposit_h( BASOP_Util_Divide3232_Scale( gain_delta_fx, subframe_length, &tmp_e ) ); // exp(tmp_e) + tmp_e = sub( tmp_e, Q30 ); + step_fx = L_shl_sat( step_fx, tmp_e ); // Q31 + gain_tmp_fx = L_shl_sat( prevGain_fx, 1 ); // Q31 /* Handle memory */ p_signal_fx = buffer_fx + sub( filterlength, 1 ); // Qx @@ -328,8 +328,8 @@ void TDREND_firfilt_fx( tmp_fx = W_extract_h( tmp64_fx ); // Qx /* Apply linear gain interpolation in case of abrupt gain changes */ - gain_tmp_fx = add( gain_tmp_fx, step_fx ); // Q15 - signal_fx[i] = Mpy_32_16_1( tmp_fx, gain_tmp_fx ); // Qx + gain_tmp_fx = L_add_sat( gain_tmp_fx, step_fx ); /* Saturating values which just exceeds 1, Q31*/ + signal_fx[i] = Mpy_32_32( tmp_fx, gain_tmp_fx ); // Qx move32(); IF( LT_16( i, intp_count ) ) { diff --git a/lib_rend/ivas_objectRenderer_sources_fx.c b/lib_rend/ivas_objectRenderer_sources_fx.c index 7e35b80b2..cdb2d9847 100644 --- a/lib_rend/ivas_objectRenderer_sources_fx.c +++ b/lib_rend/ivas_objectRenderer_sources_fx.c @@ -275,8 +275,8 @@ void TDREND_SRC_REND_UpdateFiltersFromSpatialParams_fx( /* o : Length of filters */ // Q0 Word16 *itd, /* o : ITD value */ // Q0 - Word16 *Gain, - /* o : Gain value */ // Q14 + Word32 *Gain, + /* o : Gain value */ // Q30 TDREND_SRC_t *Src_p, /* i/o: Source pointer */ const Word16 subframe_update_flag ) { @@ -368,8 +368,8 @@ void TDREND_SRC_REND_UpdateFiltersFromSpatialParams_fx( /* Update total gains */ - *Gain = extract_h( L_shl( Mpy_32_32( L_shl( L_mult( *SrcRend_p->SrcGain_p_fx, *SrcRend_p->DirGain_p_fx ), 1 ), L_shl( L_mult( *SrcRend_p->DistGain_p_fx, hBinRendererTd->Gain_fx ), 1 ) ), 1 ) ); // Q14 - move16(); + *Gain = L_shl( Mpy_32_32( L_shl( L_mult( *SrcRend_p->SrcGain_p_fx, *SrcRend_p->DirGain_p_fx ), 1 ), L_shl( L_mult( *SrcRend_p->DistGain_p_fx, hBinRendererTd->Gain_fx ), 1 ) ), 1 ); // Q30 + move32(); /* Delta for interpolation, in case the angular step exceeds MAX_ANGULAR_STEP */ Word32 ele_tmp = Src_p->elev_prev_fx; // Q22 move32(); @@ -417,8 +417,8 @@ void TDREND_SRC_REND_UpdateFiltersFromSpatialParams_fx( { *itd = 0; // Q0 move16(); - *Gain = ONE_IN_Q14; // Q14 - move16(); + *Gain = ONE_IN_Q30; // Q30 + move32(); set32_fx( hrf_left, 0, *filterlength ); set32_fx( hrf_right, 0, *filterlength ); hrf_left[0] = L_shr( L_add( SrcSpatial_p->Pos_p_fx[1], ONE_IN_Q25 ), 1 ); // Q25 @@ -886,9 +886,9 @@ void TDREND_SRC_Init_fx( move32(); Src_p->elev_prev_fx = 0; // Q22 move32(); - Src_p->Gain_fx = ONE_IN_Q14; // Q14 - move16(); - Src_p->prevGain_fx = ONE_IN_Q14; // Q14 - move16(); + Src_p->Gain_fx = ONE_IN_Q30; // Q30 + move32(); + Src_p->prevGain_fx = ONE_IN_Q30; // Q30 + move32(); return; } diff --git a/lib_rend/ivas_prot_rend_fx.h b/lib_rend/ivas_prot_rend_fx.h index 983c814aa..7cd547cb8 100644 --- a/lib_rend/ivas_prot_rend_fx.h +++ b/lib_rend/ivas_prot_rend_fx.h @@ -755,7 +755,7 @@ void TDREND_SRC_REND_UpdateFiltersFromSpatialParams_fx( Word16 *intp_count, /* o : Interpolation count */ Word16 *filterlength, /* o : Length of filters */ Word16 *itd, /* o : ITD value */ - Word16 *Gain, /* o : Gain value */ + Word32 *Gain, /* o : Gain value Q30 */ TDREND_SRC_t *Src_p, /* i/o: Source pointer */ const Word16 subframe_update_flag); @@ -842,8 +842,8 @@ void TDREND_firfilt_fx( Word32 *mem_fx, /* i/o: filter memory Qx */ const Word16 subframe_length, /* i : Length of signal */ const Word16 filterlength, /* i : Filter length */ - const Word16 Gain_fx, /* i : Gain Q14 */ - const Word16 prevGain_fx /* i : Previous gain Q14 */ + const Word32 Gain_fx, /* i : Gain Q30 */ + const Word32 prevGain_fx /* i : Previous gain Q30 */ ); diff --git a/lib_rend/ivas_stat_rend.h b/lib_rend/ivas_stat_rend.h index 17474bfe7..90e4f5d69 100644 --- a/lib_rend/ivas_stat_rend.h +++ b/lib_rend/ivas_stat_rend.h @@ -1259,8 +1259,8 @@ typedef struct Word16 hrf_right_prev_e; Word32 azim_prev_fx; Word32 elev_prev_fx; - Word16 Gain_fx; // Q14 - Word16 prevGain_fx; // Q14 + Word32 Gain_fx; // Q30 + Word32 prevGain_fx; // Q30 } TDREND_SRC_t; -- GitLab