From a6323fe09ab29184ae9a3a0ab14fe140d4d819dd Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Wed, 19 Nov 2025 11:07:39 +0100 Subject: [PATCH 01/11] addov --- lib_enc/ivas_mcmasa_enc_fx.c | 112 ++++++++++++++++++++++++++++++++++- 1 file changed, 111 insertions(+), 1 deletion(-) diff --git a/lib_enc/ivas_mcmasa_enc_fx.c b/lib_enc/ivas_mcmasa_enc_fx.c index 280da9456..3ac57ff83 100644 --- a/lib_enc/ivas_mcmasa_enc_fx.c +++ b/lib_enc/ivas_mcmasa_enc_fx.c @@ -42,7 +42,7 @@ #include "ivas_rom_enc.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" - +// #define compute_cov_mtx_fx_ADDCOV /*------------------------------------------------------------------------- * Local constants @@ -72,6 +72,17 @@ static void ivas_mcmasa_dmx_fx( const Word16 nchan_transport, const Word16 nchan_inp ); +#ifdef compute_cov_mtx_fx_ADDCOV +/* Compute covariance matrix, i.e., xT * conj(x), and accumulate to the output */ +static void compute_cov_mtx_fx( + Word32 sr[MCMASA_MAX_ANA_CHANS][DIRAC_NO_FB_BANDS_MAX], /* i : Input matrix, real, s[ch][freq] (inp_exp) */ + Word32 si[MCMASA_MAX_ANA_CHANS][DIRAC_NO_FB_BANDS_MAX], /* i : Input matrix, imag, s[ch][freq] (inp_exp) */ + Word16 num_freq_bands, + const Word16 N, /* i : Number of channels */ + CovarianceMatrix pCOVls[MASA_FREQUENCY_BANDS], /* o : Output matrix, contains upper part of cov mtx */ + Word16 inp_exp, /*Stores exponent for temp*/ + Word16 *band_grouping ); +#else static void compute_cov_mtx_fx( Word32 sr[MCMASA_MAX_ANA_CHANS][DIRAC_NO_FB_BANDS_MAX], /* i : Input matrix, real, s[ch][freq] */ Word32 si[MCMASA_MAX_ANA_CHANS][DIRAC_NO_FB_BANDS_MAX], /* i : Input matrix, imag, s[ch][freq] */ @@ -80,6 +91,7 @@ static void compute_cov_mtx_fx( CovarianceMatrix *COVls, /* o : Output matrix, contains upper part of cov mtx */ Word16 inp_exp /*Stores exponent for temp*/ ); +#endif static void computeIntensityVector_enc_fx( const Word16 *band_grouping, @@ -919,7 +931,11 @@ void ivas_mcmasa_param_est_enc_fx( Word32 renormalization_factor_diff_fx[MASA_FREQUENCY_BANDS]; // renormalization_factor_diff_e Word16 renormalization_factor_diff_e[MASA_FREQUENCY_BANDS]; Word32 norm_tmp_fx; +#ifdef compute_cov_mtx_fx_ADDCOV + Word16 mrange[2]; +#else Word16 mrange[2], brange[2]; +#endif Word16 numSubFramesForRatio; CovarianceMatrix COVls[MASA_FREQUENCY_BANDS]; Word32 absCOVls_fx[MCMASA_MAX_ANA_CHANS][MCMASA_MAX_ANA_CHANS]; @@ -1064,6 +1080,20 @@ void ivas_mcmasa_param_est_enc_fx( } inp_q = add( inp_q, sf ); +#ifdef compute_cov_mtx_fx_ADDCOV + /* Compute covariance matrix */ + compute_cov_mtx_fx( Chnl_RealBuffer_fx, Chnl_ImagBuffer_fx, num_freq_bands, numAnalysisChannels, COVls, sub( 31, inp_q ), hMcMasa->band_grouping ); + + FOR( i = 0; i < num_freq_bands; i++ ) + { + /* Store energies for guiding metadata encoding */ + FOR( j = 0; j < numAnalysisChannels; j++ ) + { + move32(); + hMasa->data.energy_fx[block_m_idx][i] = BASOP_Util_Add_Mant32Exp( hMasa->data.energy_fx[block_m_idx][i], hMasa->data.energy_e[block_m_idx][i], COVls[i].xr_fx[j][j], COVls[i].xr_e[j][j], &hMasa->data.energy_e[block_m_idx][i] ); + } + } +#else /* Compute covariance matrix */ FOR( i = 0; i < num_freq_bands; i++ ) { @@ -1076,6 +1106,7 @@ void ivas_mcmasa_param_est_enc_fx( compute_cov_mtx_fx( Chnl_RealBuffer_fx, Chnl_ImagBuffer_fx, j, numAnalysisChannels, &( COVls[i] ), sub( 31, inp_q ) ); } + /* Store energies for guiding metadata encoding */ FOR( j = 0; j < numAnalysisChannels; j++ ) { @@ -1083,6 +1114,7 @@ void ivas_mcmasa_param_est_enc_fx( hMasa->data.energy_fx[block_m_idx][i] = BASOP_Util_Add_Mant32Exp( hMasa->data.energy_fx[block_m_idx][i], hMasa->data.energy_e[block_m_idx][i], COVls[i].xr_fx[j][j], COVls[i].xr_e[j][j], &hMasa->data.energy_e[block_m_idx][i] ); } } +#endif IF( !hMcMasa->separateChannelEnabled ) { @@ -2087,6 +2119,83 @@ static void ivas_mcmasa_dmx_fx( return; } + +#ifdef compute_cov_mtx_fx_ADDCOV + +/* Compute covariance matrix, i.e., xT * conj(x), and accumulate to the output */ +static void compute_cov_mtx_fx( + Word32 sr[MCMASA_MAX_ANA_CHANS][DIRAC_NO_FB_BANDS_MAX], /* i : Input matrix, real, s[ch][freq] (inp_exp) */ + Word32 si[MCMASA_MAX_ANA_CHANS][DIRAC_NO_FB_BANDS_MAX], /* i : Input matrix, imag, s[ch][freq] (inp_exp) */ + Word16 num_freq_bands, + const Word16 N, /* i : Number of channels */ + CovarianceMatrix pCOVls[MASA_FREQUENCY_BANDS], /* o : Output matrix, contains upper part of cov mtx */ + Word16 inp_exp, /*Stores exponent for temp*/ + Word16 *band_grouping ) +{ + Word16 brange[2]; + Word16 freq; + int k; + int i, j; + Word16 max_exp_r, max_exp_i; + Word64 temp64_1_r_acc, temp64_1_i_acc; + Word64 temp64_1; + Word16 tmp_16; + Word16 temp_exp = shl( inp_exp, 1 ); + + + FOR( i = 0; i < N; i++ ) + { + FOR( j = i; j < N; j++ ) + { + FOR( k = 0; k < num_freq_bands; k++ ) + { + brange[0] = band_grouping[k]; + move16(); + brange[1] = band_grouping[k + 1]; + move16(); + CovarianceMatrix *COVls = &( pCOVls[k] ); + + temp64_1_r_acc = W_deposit32_h( COVls->xr_fx[i][j] ); + max_exp_r = s_max( COVls->xr_e[i][j], temp_exp ); + temp64_1_r_acc = W_shl( temp64_1_r_acc, sub( COVls->xr_e[i][j], max_exp_r ) ); // exp:max_exp_r + + temp64_1_i_acc = W_deposit32_h( COVls->xi_fx[i][j] ); // exp:COVls->xi_e[i][j] + max_exp_i = s_max( COVls->xi_e[i][j], temp_exp ); + temp64_1_i_acc = W_shl( temp64_1_i_acc, sub( COVls->xi_e[i][j], max_exp_i ) ); // exp:max_exp_i + + FOR( freq = brange[0]; freq < brange[1]; freq++ ) + { + temp64_1 = W_mac_32_32( W_mult_32_32( sr[i][freq], sr[j][freq] ), si[i][freq], si[j][freq] ); // exp:2*inp_exp + temp64_1 = W_shl( temp64_1, sub( temp_exp, max_exp_r ) ); // exp:max_exp_r + temp64_1_r_acc = W_add( temp64_1, temp64_1_r_acc ); // exp:max_exp_r + + temp64_1 = W_sub( W_mult_32_32( si[i][freq], sr[j][freq] ), W_mult_32_32( sr[i][freq], si[j][freq] ) ); // exp :2*inp_exp + temp64_1 = W_shl( temp64_1, sub( temp_exp, max_exp_i ) ); // exp:max_exp_i + temp64_1_i_acc = W_add( temp64_1, temp64_1_i_acc ); // exp:max_exp_i + } + + tmp_16 = W_norm( temp64_1_r_acc ); + + COVls->xr_fx[i][j] = W_extract_h( W_shl( temp64_1_r_acc, tmp_16 ) ); // exp:max_exp-tmp_16 + COVls->xr_e[i][j] = sub( max_exp_r, tmp_16 ); + move32(); + move16(); + + tmp_16 = W_norm( temp64_1_i_acc ); + + COVls->xi_fx[i][j] = W_extract_h( W_shl( temp64_1_i_acc, tmp_16 ) ); // exp:max_exp-tmp_16 + COVls->xi_e[i][j] = sub( max_exp_i, tmp_16 ); + move32(); + move16(); + + } + } + } + return; +} + + +#else /* Compute covariance matrix, i.e., xT * conj(x), and accumulate to the output */ static void compute_cov_mtx_fx( Word32 sr[MCMASA_MAX_ANA_CHANS][DIRAC_NO_FB_BANDS_MAX], /* i : Input matrix, real, s[ch][freq] (inp_exp) */ @@ -2133,6 +2242,7 @@ static void compute_cov_mtx_fx( } return; } +#endif static void computeIntensityVector_enc_fx( const Word16 *band_grouping, -- GitLab From e8387d0dfa7eee0f96e5f2bbcb1c2370d676f95c Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Wed, 19 Nov 2025 11:15:29 +0100 Subject: [PATCH 02/11] clang patch --- lib_enc/ivas_mcmasa_enc_fx.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/lib_enc/ivas_mcmasa_enc_fx.c b/lib_enc/ivas_mcmasa_enc_fx.c index 3ac57ff83..9e8c92dc3 100644 --- a/lib_enc/ivas_mcmasa_enc_fx.c +++ b/lib_enc/ivas_mcmasa_enc_fx.c @@ -2166,12 +2166,12 @@ static void compute_cov_mtx_fx( FOR( freq = brange[0]; freq < brange[1]; freq++ ) { temp64_1 = W_mac_32_32( W_mult_32_32( sr[i][freq], sr[j][freq] ), si[i][freq], si[j][freq] ); // exp:2*inp_exp - temp64_1 = W_shl( temp64_1, sub( temp_exp, max_exp_r ) ); // exp:max_exp_r - temp64_1_r_acc = W_add( temp64_1, temp64_1_r_acc ); // exp:max_exp_r + temp64_1 = W_shl( temp64_1, sub( temp_exp, max_exp_r ) ); // exp:max_exp_r + temp64_1_r_acc = W_add( temp64_1, temp64_1_r_acc ); // exp:max_exp_r temp64_1 = W_sub( W_mult_32_32( si[i][freq], sr[j][freq] ), W_mult_32_32( sr[i][freq], si[j][freq] ) ); // exp :2*inp_exp - temp64_1 = W_shl( temp64_1, sub( temp_exp, max_exp_i ) ); // exp:max_exp_i - temp64_1_i_acc = W_add( temp64_1, temp64_1_i_acc ); // exp:max_exp_i + temp64_1 = W_shl( temp64_1, sub( temp_exp, max_exp_i ) ); // exp:max_exp_i + temp64_1_i_acc = W_add( temp64_1, temp64_1_i_acc ); // exp:max_exp_i } tmp_16 = W_norm( temp64_1_r_acc ); @@ -2187,7 +2187,6 @@ static void compute_cov_mtx_fx( COVls->xi_e[i][j] = sub( max_exp_i, tmp_16 ); move32(); move16(); - } } } -- GitLab From 16d926147e9103126fe331bf58e66cf8802701c3 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Wed, 19 Nov 2025 11:30:15 +0100 Subject: [PATCH 03/11] activate addcov --- lib_enc/ivas_mcmasa_enc_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_enc/ivas_mcmasa_enc_fx.c b/lib_enc/ivas_mcmasa_enc_fx.c index 9e8c92dc3..6e4cf18f2 100644 --- a/lib_enc/ivas_mcmasa_enc_fx.c +++ b/lib_enc/ivas_mcmasa_enc_fx.c @@ -42,7 +42,7 @@ #include "ivas_rom_enc.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" -// #define compute_cov_mtx_fx_ADDCOV +#define compute_cov_mtx_fx_ADDCOV /*------------------------------------------------------------------------- * Local constants -- GitLab From 173c88ccfb4d95cabf30775041201c458622fd50 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Wed, 19 Nov 2025 13:59:20 +0100 Subject: [PATCH 04/11] put macro to options.h --- lib_com/options.h | 2 +- lib_enc/ivas_mcmasa_enc_fx.c | 9 ++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 744952c84..1ab9bb21d 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -116,7 +116,7 @@ #define NONBE_FIX_BASOP_2233_RTPDUMP_DIFFERING_BITSTREAMS /* Nokia: fix basop issue 2233: Fix differing rtpdump streams */ #define NONBE_FIX_2237_ZERO_CURR_NOISE_PROBLEM /* FhG: Modify sum of hTonalMDCTConc->curr_noise_nrg to avoid inaccurate zero */ - +#define BE_FIX_2240_COMPUTE_COV_MTC_FX_FAST /* FhG: SPeeds up covariance calculation e.g. 60 WMOPS for encoding -mc 7_1_4 24400 48 */ /* ################### End FIXES switches ########################### */ /* #################### Start BASOP porting switches ############################ */ diff --git a/lib_enc/ivas_mcmasa_enc_fx.c b/lib_enc/ivas_mcmasa_enc_fx.c index 6e4cf18f2..f88c7d4db 100644 --- a/lib_enc/ivas_mcmasa_enc_fx.c +++ b/lib_enc/ivas_mcmasa_enc_fx.c @@ -42,7 +42,6 @@ #include "ivas_rom_enc.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" -#define compute_cov_mtx_fx_ADDCOV /*------------------------------------------------------------------------- * Local constants @@ -72,7 +71,7 @@ static void ivas_mcmasa_dmx_fx( const Word16 nchan_transport, const Word16 nchan_inp ); -#ifdef compute_cov_mtx_fx_ADDCOV +#ifdef BE_FIX_2240_COMPUTE_COV_MTC_FX_FAST /* Compute covariance matrix, i.e., xT * conj(x), and accumulate to the output */ static void compute_cov_mtx_fx( Word32 sr[MCMASA_MAX_ANA_CHANS][DIRAC_NO_FB_BANDS_MAX], /* i : Input matrix, real, s[ch][freq] (inp_exp) */ @@ -931,7 +930,7 @@ void ivas_mcmasa_param_est_enc_fx( Word32 renormalization_factor_diff_fx[MASA_FREQUENCY_BANDS]; // renormalization_factor_diff_e Word16 renormalization_factor_diff_e[MASA_FREQUENCY_BANDS]; Word32 norm_tmp_fx; -#ifdef compute_cov_mtx_fx_ADDCOV +#ifdef BE_FIX_2240_COMPUTE_COV_MTC_FX_FAST Word16 mrange[2]; #else Word16 mrange[2], brange[2]; @@ -1080,7 +1079,7 @@ void ivas_mcmasa_param_est_enc_fx( } inp_q = add( inp_q, sf ); -#ifdef compute_cov_mtx_fx_ADDCOV +#ifdef BE_FIX_2240_COMPUTE_COV_MTC_FX_FAST /* Compute covariance matrix */ compute_cov_mtx_fx( Chnl_RealBuffer_fx, Chnl_ImagBuffer_fx, num_freq_bands, numAnalysisChannels, COVls, sub( 31, inp_q ), hMcMasa->band_grouping ); @@ -2120,7 +2119,7 @@ static void ivas_mcmasa_dmx_fx( return; } -#ifdef compute_cov_mtx_fx_ADDCOV +#ifdef BE_FIX_2240_COMPUTE_COV_MTC_FX_FAST /* Compute covariance matrix, i.e., xT * conj(x), and accumulate to the output */ static void compute_cov_mtx_fx( -- GitLab From 90759dca226c808d2541284e6cab62cfc387fbb3 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Thu, 20 Nov 2025 15:36:14 +0100 Subject: [PATCH 05/11] fastest version bit with no msub --- lib_enc/ivas_mcmasa_enc_fx.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/lib_enc/ivas_mcmasa_enc_fx.c b/lib_enc/ivas_mcmasa_enc_fx.c index f88c7d4db..de4637499 100644 --- a/lib_enc/ivas_mcmasa_enc_fx.c +++ b/lib_enc/ivas_mcmasa_enc_fx.c @@ -1081,6 +1081,15 @@ void ivas_mcmasa_param_est_enc_fx( #ifdef BE_FIX_2240_COMPUTE_COV_MTC_FX_FAST /* Compute covariance matrix */ + + assert( mrange[1] - mrange[0] == 1 ); + /*if this ever comes up, + 1. backup COVls to COVls_old + 2. reinitialize COVls (setzero) + 3. call compute_cov_mtx_fx(..,COVls,...) + 4. Add COVls_old to COVls + */ + compute_cov_mtx_fx( Chnl_RealBuffer_fx, Chnl_ImagBuffer_fx, num_freq_bands, numAnalysisChannels, COVls, sub( 31, inp_q ), hMcMasa->band_grouping ); FOR( i = 0; i < num_freq_bands; i++ ) @@ -2135,9 +2144,7 @@ static void compute_cov_mtx_fx( Word16 freq; int k; int i, j; - Word16 max_exp_r, max_exp_i; Word64 temp64_1_r_acc, temp64_1_i_acc; - Word64 temp64_1; Word16 tmp_16; Word16 temp_exp = shl( inp_exp, 1 ); @@ -2154,36 +2161,29 @@ static void compute_cov_mtx_fx( move16(); CovarianceMatrix *COVls = &( pCOVls[k] ); - temp64_1_r_acc = W_deposit32_h( COVls->xr_fx[i][j] ); - max_exp_r = s_max( COVls->xr_e[i][j], temp_exp ); - temp64_1_r_acc = W_shl( temp64_1_r_acc, sub( COVls->xr_e[i][j], max_exp_r ) ); // exp:max_exp_r - - temp64_1_i_acc = W_deposit32_h( COVls->xi_fx[i][j] ); // exp:COVls->xi_e[i][j] - max_exp_i = s_max( COVls->xi_e[i][j], temp_exp ); - temp64_1_i_acc = W_shl( temp64_1_i_acc, sub( COVls->xi_e[i][j], max_exp_i ) ); // exp:max_exp_i + temp64_1_r_acc = 0; + temp64_1_i_acc = 0; FOR( freq = brange[0]; freq < brange[1]; freq++ ) { - temp64_1 = W_mac_32_32( W_mult_32_32( sr[i][freq], sr[j][freq] ), si[i][freq], si[j][freq] ); // exp:2*inp_exp - temp64_1 = W_shl( temp64_1, sub( temp_exp, max_exp_r ) ); // exp:max_exp_r - temp64_1_r_acc = W_add( temp64_1, temp64_1_r_acc ); // exp:max_exp_r + temp64_1_r_acc = W_mac_32_32( temp64_1_r_acc, si[i][freq], si[j][freq] ); // exp:2*inp_exp + temp64_1_r_acc = W_mac_32_32( temp64_1_r_acc, sr[i][freq], sr[j][freq] ); // exp:2*inp_exp - temp64_1 = W_sub( W_mult_32_32( si[i][freq], sr[j][freq] ), W_mult_32_32( sr[i][freq], si[j][freq] ) ); // exp :2*inp_exp - temp64_1 = W_shl( temp64_1, sub( temp_exp, max_exp_i ) ); // exp:max_exp_i - temp64_1_i_acc = W_add( temp64_1, temp64_1_i_acc ); // exp:max_exp_i + temp64_1_i_acc = W_mac_32_32( temp64_1_i_acc, si[i][freq], sr[j][freq] ); + temp64_1_i_acc = W_sub( temp64_1_i_acc, W_mult_32_32(sr[i][freq], si[j][freq]) ); } tmp_16 = W_norm( temp64_1_r_acc ); COVls->xr_fx[i][j] = W_extract_h( W_shl( temp64_1_r_acc, tmp_16 ) ); // exp:max_exp-tmp_16 - COVls->xr_e[i][j] = sub( max_exp_r, tmp_16 ); + COVls->xr_e[i][j] = sub( temp_exp, tmp_16 ); move32(); move16(); tmp_16 = W_norm( temp64_1_i_acc ); COVls->xi_fx[i][j] = W_extract_h( W_shl( temp64_1_i_acc, tmp_16 ) ); // exp:max_exp-tmp_16 - COVls->xi_e[i][j] = sub( max_exp_i, tmp_16 ); + COVls->xi_e[i][j] = sub( temp_exp, tmp_16 ); move32(); move16(); } -- GitLab From b07d40d1eacc782ce41fcfb9d915c6fa913c197a Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Thu, 20 Nov 2025 15:55:38 +0100 Subject: [PATCH 06/11] clang format --- lib_enc/ivas_mcmasa_enc_fx.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib_enc/ivas_mcmasa_enc_fx.c b/lib_enc/ivas_mcmasa_enc_fx.c index de4637499..54b0d6028 100644 --- a/lib_enc/ivas_mcmasa_enc_fx.c +++ b/lib_enc/ivas_mcmasa_enc_fx.c @@ -1081,13 +1081,13 @@ void ivas_mcmasa_param_est_enc_fx( #ifdef BE_FIX_2240_COMPUTE_COV_MTC_FX_FAST /* Compute covariance matrix */ - - assert( mrange[1] - mrange[0] == 1 ); - /*if this ever comes up, + + assert( mrange[1] - mrange[0] == 1 ); + /*if this ever comes up, 1. backup COVls to COVls_old 2. reinitialize COVls (setzero) 3. call compute_cov_mtx_fx(..,COVls,...) - 4. Add COVls_old to COVls + 4. Add COVls_old to COVls */ compute_cov_mtx_fx( Chnl_RealBuffer_fx, Chnl_ImagBuffer_fx, num_freq_bands, numAnalysisChannels, COVls, sub( 31, inp_q ), hMcMasa->band_grouping ); @@ -2170,7 +2170,7 @@ static void compute_cov_mtx_fx( temp64_1_r_acc = W_mac_32_32( temp64_1_r_acc, sr[i][freq], sr[j][freq] ); // exp:2*inp_exp temp64_1_i_acc = W_mac_32_32( temp64_1_i_acc, si[i][freq], sr[j][freq] ); - temp64_1_i_acc = W_sub( temp64_1_i_acc, W_mult_32_32(sr[i][freq], si[j][freq]) ); + temp64_1_i_acc = W_sub( temp64_1_i_acc, W_mult_32_32( sr[i][freq], si[j][freq] ) ); } tmp_16 = W_norm( temp64_1_r_acc ); -- GitLab From d6aaa03c29a9cfa6a50afda2c5e967db1f50f229 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Tue, 25 Nov 2025 16:22:02 +0100 Subject: [PATCH 07/11] add true single cycle commands --- lib_com/basop_util.c | 9 +++++++++ lib_com/basop_util.h | 4 ++++ lib_enc/ivas_mcmasa_enc_fx.c | 16 ++++++++++++++-- 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/lib_com/basop_util.c b/lib_com/basop_util.c index 3a0a72bc3..da7f9e702 100644 --- a/lib_com/basop_util.c +++ b/lib_com/basop_util.c @@ -3071,3 +3071,12 @@ cmplx CL_mult_32x16( cmplx input, cmplx_s coeff ) #endif return result; } + +#ifndef FUNCTION_W_msu0_32_32 +Word64 W_msu0_32_32( Word64 L64_var1, Word32 L_var2, Word32 L_var3 ) +{ + /* no saturation (like hexagon) */ + L64_var1 = W_sub( L64_var1, W_mult0_32_32( L_var2, L_var3 ) ); + return L64_var1; +} +#endif \ No newline at end of file diff --git a/lib_com/basop_util.h b/lib_com/basop_util.h index 7929db932..f5725ec93 100644 --- a/lib_com/basop_util.h +++ b/lib_com/basop_util.h @@ -913,4 +913,8 @@ cmplx CL_scale_t( cmplx x, Word16 y ); cmplx CL_dscale_t( cmplx x, Word16 y1, Word16 y2 ); cmplx CL_mult_32x16( cmplx input, cmplx_s coeff ); +#ifndef FUNCTION_W_msu0_32_32 +Word64 W_msu0_32_32( Word64 L64_var1, Word32 L_var2, Word32 L_var3 ); +#endif + #endif /* __BASOP_UTIL_H__ */ diff --git a/lib_enc/ivas_mcmasa_enc_fx.c b/lib_enc/ivas_mcmasa_enc_fx.c index 54b0d6028..6cedf083b 100644 --- a/lib_enc/ivas_mcmasa_enc_fx.c +++ b/lib_enc/ivas_mcmasa_enc_fx.c @@ -2144,10 +2144,13 @@ static void compute_cov_mtx_fx( Word16 freq; int k; int i, j; - Word64 temp64_1_r_acc, temp64_1_i_acc; Word16 tmp_16; +#if 1 + Word16 temp_exp = add( 1, shl( inp_exp, 1 ) ); +#else Word16 temp_exp = shl( inp_exp, 1 ); - +#endif + Word64 temp64_1_r_acc, temp64_1_i_acc; FOR( i = 0; i < N; i++ ) { @@ -2166,11 +2169,19 @@ static void compute_cov_mtx_fx( FOR( freq = brange[0]; freq < brange[1]; freq++ ) { +#if 1 + temp64_1_r_acc = W_mac0_32_32( temp64_1_r_acc, si[i][freq], si[j][freq] ); // exp:2*inp_exp + temp64_1_r_acc = W_mac0_32_32( temp64_1_r_acc, sr[i][freq], sr[j][freq] ); // exp:2*inp_exp + + temp64_1_i_acc = W_mac0_32_32( temp64_1_i_acc, si[i][freq], sr[j][freq] ); + temp64_1_i_acc = W_msu0_32_32( temp64_1_i_acc, sr[i][freq], si[j][freq] ); +#else temp64_1_r_acc = W_mac_32_32( temp64_1_r_acc, si[i][freq], si[j][freq] ); // exp:2*inp_exp temp64_1_r_acc = W_mac_32_32( temp64_1_r_acc, sr[i][freq], sr[j][freq] ); // exp:2*inp_exp temp64_1_i_acc = W_mac_32_32( temp64_1_i_acc, si[i][freq], sr[j][freq] ); temp64_1_i_acc = W_sub( temp64_1_i_acc, W_mult_32_32( sr[i][freq], si[j][freq] ) ); +#endif } tmp_16 = W_norm( temp64_1_r_acc ); @@ -2193,6 +2204,7 @@ static void compute_cov_mtx_fx( } + #else /* Compute covariance matrix, i.e., xT * conj(x), and accumulate to the output */ static void compute_cov_mtx_fx( -- GitLab From 092a74afc8e9f40e4392352d3eaca2d5d99b17a9 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Tue, 25 Nov 2025 16:30:30 +0100 Subject: [PATCH 08/11] clang patch --- lib_com/basop_util.c | 2 +- lib_enc/ivas_mcmasa_enc_fx.c | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/lib_com/basop_util.c b/lib_com/basop_util.c index da7f9e702..0662929b6 100644 --- a/lib_com/basop_util.c +++ b/lib_com/basop_util.c @@ -3079,4 +3079,4 @@ Word64 W_msu0_32_32( Word64 L64_var1, Word32 L_var2, Word32 L_var3 ) L64_var1 = W_sub( L64_var1, W_mult0_32_32( L_var2, L_var3 ) ); return L64_var1; } -#endif \ No newline at end of file +#endif diff --git a/lib_enc/ivas_mcmasa_enc_fx.c b/lib_enc/ivas_mcmasa_enc_fx.c index 6cedf083b..b16cc770c 100644 --- a/lib_enc/ivas_mcmasa_enc_fx.c +++ b/lib_enc/ivas_mcmasa_enc_fx.c @@ -2204,7 +2204,6 @@ static void compute_cov_mtx_fx( } - #else /* Compute covariance matrix, i.e., xT * conj(x), and accumulate to the output */ static void compute_cov_mtx_fx( -- GitLab From 2d12fab1e4f33b139e28b957f585619d0a2eabd8 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Tue, 25 Nov 2025 16:47:16 +0100 Subject: [PATCH 09/11] add wmac03232 --- lib_com/basop_util.c | 8 ++++++++ lib_com/basop_util.h | 3 +++ 2 files changed, 11 insertions(+) diff --git a/lib_com/basop_util.c b/lib_com/basop_util.c index 0662929b6..9f1de3809 100644 --- a/lib_com/basop_util.c +++ b/lib_com/basop_util.c @@ -3080,3 +3080,11 @@ Word64 W_msu0_32_32( Word64 L64_var1, Word32 L_var2, Word32 L_var3 ) return L64_var1; } #endif +#ifndef FUNCTION_W_mac0_32_32 +Word64 W_mac0_32_32( Word64 L64_var1, Word32 L_var2, Word32 L_var3 ) +{ + /* no saturation (like hexagon) */ + L64_var1 = W_add( L64_var1, W_mult0_32_32( L_var2, L_var3 ) ); + return L64_var1; +} +#endif diff --git a/lib_com/basop_util.h b/lib_com/basop_util.h index f5725ec93..0dea22811 100644 --- a/lib_com/basop_util.h +++ b/lib_com/basop_util.h @@ -916,5 +916,8 @@ cmplx CL_mult_32x16( cmplx input, cmplx_s coeff ); #ifndef FUNCTION_W_msu0_32_32 Word64 W_msu0_32_32( Word64 L64_var1, Word32 L_var2, Word32 L_var3 ); #endif +#ifndef FUNCTION_W_mac0_32_32 +Word64 W_mac0_32_32( Word64 L64_var1, Word32 L_var2, Word32 L_var3 ); +#endif #endif /* __BASOP_UTIL_H__ */ -- GitLab From 8acf9bf4a3e03563af49c6db313233972cac8e6c Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Tue, 25 Nov 2025 17:12:02 +0100 Subject: [PATCH 10/11] correct instrumentation --- lib_com/basop_util.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_com/basop_util.c b/lib_com/basop_util.c index 9f1de3809..dbaa49f12 100644 --- a/lib_com/basop_util.c +++ b/lib_com/basop_util.c @@ -3076,7 +3076,7 @@ cmplx CL_mult_32x16( cmplx input, cmplx_s coeff ) Word64 W_msu0_32_32( Word64 L64_var1, Word32 L_var2, Word32 L_var3 ) { /* no saturation (like hexagon) */ - L64_var1 = W_sub( L64_var1, W_mult0_32_32( L_var2, L_var3 ) ); + L64_var1 = W_sub_nosat( L64_var1, W_mult0_32_32( L_var2, L_var3 ) ); return L64_var1; } #endif @@ -3084,7 +3084,7 @@ Word64 W_msu0_32_32( Word64 L64_var1, Word32 L_var2, Word32 L_var3 ) Word64 W_mac0_32_32( Word64 L64_var1, Word32 L_var2, Word32 L_var3 ) { /* no saturation (like hexagon) */ - L64_var1 = W_add( L64_var1, W_mult0_32_32( L_var2, L_var3 ) ); + L64_var1 = W_add_nosat( L64_var1, W_mult0_32_32( L_var2, L_var3 ) ); return L64_var1; } #endif -- GitLab From 5757e94828f08995478d063847829c1765036439 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Tue, 25 Nov 2025 17:13:04 +0100 Subject: [PATCH 11/11] use only mac0/msu0 in compute_cov_mtx_fx() --- lib_enc/ivas_mcmasa_enc_fx.c | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/lib_enc/ivas_mcmasa_enc_fx.c b/lib_enc/ivas_mcmasa_enc_fx.c index b16cc770c..6a9b80c27 100644 --- a/lib_enc/ivas_mcmasa_enc_fx.c +++ b/lib_enc/ivas_mcmasa_enc_fx.c @@ -2145,11 +2145,7 @@ static void compute_cov_mtx_fx( int k; int i, j; Word16 tmp_16; -#if 1 Word16 temp_exp = add( 1, shl( inp_exp, 1 ) ); -#else - Word16 temp_exp = shl( inp_exp, 1 ); -#endif Word64 temp64_1_r_acc, temp64_1_i_acc; FOR( i = 0; i < N; i++ ) @@ -2169,19 +2165,11 @@ static void compute_cov_mtx_fx( FOR( freq = brange[0]; freq < brange[1]; freq++ ) { -#if 1 temp64_1_r_acc = W_mac0_32_32( temp64_1_r_acc, si[i][freq], si[j][freq] ); // exp:2*inp_exp temp64_1_r_acc = W_mac0_32_32( temp64_1_r_acc, sr[i][freq], sr[j][freq] ); // exp:2*inp_exp temp64_1_i_acc = W_mac0_32_32( temp64_1_i_acc, si[i][freq], sr[j][freq] ); temp64_1_i_acc = W_msu0_32_32( temp64_1_i_acc, sr[i][freq], si[j][freq] ); -#else - temp64_1_r_acc = W_mac_32_32( temp64_1_r_acc, si[i][freq], si[j][freq] ); // exp:2*inp_exp - temp64_1_r_acc = W_mac_32_32( temp64_1_r_acc, sr[i][freq], sr[j][freq] ); // exp:2*inp_exp - - temp64_1_i_acc = W_mac_32_32( temp64_1_i_acc, si[i][freq], sr[j][freq] ); - temp64_1_i_acc = W_sub( temp64_1_i_acc, W_mult_32_32( sr[i][freq], si[j][freq] ) ); -#endif } tmp_16 = W_norm( temp64_1_r_acc ); -- GitLab