From 6662ba55eef19de3d77a8dcd83ed7bd092353717 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Tue, 18 Nov 2025 12:44:18 +0100 Subject: [PATCH 1/7] compute_cov_mtx_fx_16 --- lib_enc/ivas_mcmasa_enc_fx.c | 143 ++++++++++++++++++++++++++++++++++- 1 file changed, 141 insertions(+), 2 deletions(-) diff --git a/lib_enc/ivas_mcmasa_enc_fx.c b/lib_enc/ivas_mcmasa_enc_fx.c index 280da9456..46775fb46 100644 --- a/lib_enc/ivas_mcmasa_enc_fx.c +++ b/lib_enc/ivas_mcmasa_enc_fx.c @@ -72,6 +72,28 @@ static void ivas_mcmasa_dmx_fx( const Word16 nchan_transport, const Word16 nchan_inp ); +#define FUNC_compute_cov_mtx_fx_16 +#ifdef FUNC_compute_cov_mtx_fx_16 +static void compute_cov_mtx_fx_16( + Word16 sri[MCMASA_MAX_ANA_CHANS][DIRAC_NO_FB_BANDS_MAX * 2], + const Word16 N, /* i : Number of channels */ + CovarianceMatrix *COVls, /* o : Output matrix, contains upper part of cov mtx */ + Word16 inp_exp, /*Stores exponent for temp*/ + Word16 band_grouping[], + int num_freq_bands, + int *fb_map ); + +/* RAM_ALIGN keyword causes memory alignment */ +#ifndef RAM_ALIGN +#define ALIGNMENT_DEFAULT 8 +#if defined( __GNUC__ ) +#define RAM_ALIGN __attribute__( ( aligned( ALIGNMENT_DEFAULT ) ) ) +#else +#define RAM_ALIGN +#endif +#endif + +#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 +102,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 +942,12 @@ 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; - Word16 mrange[2], brange[2]; +#ifndef FUNC_compute_cov_mtx_fx_16 + Word16 mrange[2], brange[2]; +#else + RAM_ALIGN Word16 Chnl_RealImagBuffer_fx_16[MCMASA_MAX_ANA_CHANS][DIRAC_NO_FB_BANDS_MAX * 2]; + Word16 mrange[2]; +#endif Word16 numSubFramesForRatio; CovarianceMatrix COVls[MASA_FREQUENCY_BANDS]; Word32 absCOVls_fx[MCMASA_MAX_ANA_CHANS][MCMASA_MAX_ANA_CHANS]; @@ -1007,6 +1035,19 @@ void ivas_mcmasa_param_est_enc_fx( hMasa->data.q_energy = 0; move16(); +#ifdef FUNC_compute_cov_mtx_fx_16 + /*get freq/band mapping*/ + int fb_map[DIRAC_NO_FB_BANDS_MAX]; + int const sfCorrection = 3; + FOR( int b = 0; b < num_freq_bands; b++ ) + { + FOR( int f = hMcMasa->band_grouping[b]; f < hMcMasa->band_grouping[b + 1]; f++ ) + { + fb_map[f] = b; + } + } +#endif + /* do processing over all CLDFB time slots */ FOR( block_m_idx = 0; block_m_idx < MAX_PARAM_SPATIAL_SUBFRAMES; block_m_idx++ ) { @@ -1059,12 +1100,49 @@ void ivas_mcmasa_param_est_enc_fx( sf = sub( s_min( cr_q, ci_q ), 5 ); FOR( i = 0; i < numAnalysisChannels; i++ ) { +#ifdef FUNC_compute_cov_mtx_fx_16 + { + Word32 *re = Chnl_RealBuffer_fx[i]; /*in*/ + Word32 *im = Chnl_ImagBuffer_fx[i]; /*in*/ + Word16 *x = Chnl_RealImagBuffer_fx_16[i]; /*out*/ + Word16 k; + const Word16 lg = DIRAC_NO_FB_BANDS_MAX; + const Word16 exp0 =add( sf , sfCorrection); + + if ( 0 == exp0 ) + { + k = lg; + move16(); + } + + FOR( k = 0; k < lg; k++ ) + { + /* saturation can occur here */ + x[( k << 1 ) + 0] = round_fx( L_shl( re[k], exp0 ) ); + x[( k << 1 ) + 1] = round_fx( L_shl( im[k], exp0 ) ); + move32(); + } + } +#endif scale_sig32( Chnl_RealBuffer_fx[i], DIRAC_NO_FB_BANDS_MAX, sf ); // Q-> inp_q + sf scale_sig32( Chnl_ImagBuffer_fx[i], DIRAC_NO_FB_BANDS_MAX, sf ); // Q-> inp_q + sf } inp_q = add( inp_q, sf ); /* Compute covariance matrix */ +#ifdef FUNC_compute_cov_mtx_fx_16 + compute_cov_mtx_fx_16( Chnl_RealImagBuffer_fx_16, numAnalysisChannels, COVls, sub( 31 + sfCorrection, inp_q ), hMcMasa->band_grouping, (int) num_freq_bands, fb_map ); + + 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 //FUNC_compute_cov_mtx_fx_16 FOR( i = 0; i < num_freq_bands; i++ ) { brange[0] = hMcMasa->band_grouping[i]; @@ -1083,6 +1161,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,7 +2166,66 @@ static void ivas_mcmasa_dmx_fx( return; } -/* Compute covariance matrix, i.e., xT * conj(x), and accumulate to the output */ + +#ifdef FUNC_compute_cov_mtx_fx_16 + /* Compute covariance matrix, i.e., xT * conj(x), and accumulate to the output */ +static void compute_cov_mtx_fx_16( + Word16 sri[MCMASA_MAX_ANA_CHANS][DIRAC_NO_FB_BANDS_MAX * 2], + const Word16 N, /* i : Number of channels */ + CovarianceMatrix mCOVls[], /* o : Output matrix pointer, - upper part of cov mtx */ + Word16 inp_exp, /*Stores exponent for temp*/ + Word16 band_grouping[], + int num_freq_bands, + int *fb_map ) +{ + int i, j; + Word32 temp32_1, temp32_2; + Word16 tmp_16, max_exp; + Word16 temp_exp = shl( inp_exp, 1 ); + int freq; + + + FOR( i = 0; i < N; i++ ) + { + FOR( j = i; j < N; j++ ) + { + FOR( freq = band_grouping[0]; freq < band_grouping[num_freq_bands]; freq++ ) + { + CovarianceMatrix *COVls = &( mCOVls[fb_map[freq]] ); + + temp32_1 = L_mac0( L_mult0( sri[i][freq << 1], sri[j][freq << 1] ), sri[i][( freq << 1 ) + 1], sri[j][( freq << 1 ) + 1] ); // exp:2*inp_exp + temp32_2 = COVls->xr_fx[i][j]; // exp:COVls->xr_e[i][j] + max_exp = s_max( COVls->xr_e[i][j], temp_exp ); + temp32_2 = L_shl( temp32_2, sub( COVls->xr_e[i][j], max_exp ) ); // exp:max_exp + temp32_1 = L_shl( temp32_1, sub( temp_exp, max_exp ) ); // exp:max_exp + temp32_1 = L_add( temp32_1, temp32_2 ); // exp:max_exp + tmp_16 = norm_l( temp32_1 ); + + COVls->xr_fx[i][j] = L_shl( temp32_1, tmp_16 ); // exp:max_exp-tmp_16 + COVls->xr_e[i][j] = sub( max_exp, tmp_16 ); + move32(); + move16(); + + temp32_1 = L_msu0( L_mult0( sri[i][( freq << 1 ) + 1], sri[j][freq << 1] ), sri[i][freq << 1], sri[j][(freq << 1) + 1] ); // exp :2*inp_exp + temp32_2 = COVls->xi_fx[i][j]; // exp:COVls->xi_e[i][j] + max_exp = s_max( COVls->xi_e[i][j], temp_exp ); + temp32_2 = L_shl( temp32_2, sub( COVls->xi_e[i][j], max_exp ) ); // exp:max_exp + temp32_1 = L_shl( temp32_1, sub( temp_exp, max_exp ) ); // exp:max_exp + temp32_1 = L_add( temp32_1, temp32_2 ); // exp:max_exp + tmp_16 = norm_l( temp32_1 ); + + COVls->xi_fx[i][j] = L_shl( temp32_1, tmp_16 ); // exp:max_exp-tmp_16 + COVls->xi_e[i][j] = sub( max_exp, tmp_16 ); + move32(); + } + } + } + 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) */ Word32 si[MCMASA_MAX_ANA_CHANS][DIRAC_NO_FB_BANDS_MAX], /* i : Input matrix, imag, s[ch][freq] (inp_exp) */ @@ -2133,6 +2271,7 @@ static void compute_cov_mtx_fx( } return; } +#endif static void computeIntensityVector_enc_fx( const Word16 *band_grouping, -- GitLab From 951f39b8230af5d079e4c69c5ab495655df34f52 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Tue, 18 Nov 2025 12:45:14 +0100 Subject: [PATCH 2/7] trigger pipes --- lib_enc/ivas_mcmasa_enc_fx.c | 1 - 1 file changed, 1 deletion(-) diff --git a/lib_enc/ivas_mcmasa_enc_fx.c b/lib_enc/ivas_mcmasa_enc_fx.c index 46775fb46..3f26fb867 100644 --- a/lib_enc/ivas_mcmasa_enc_fx.c +++ b/lib_enc/ivas_mcmasa_enc_fx.c @@ -2184,7 +2184,6 @@ static void compute_cov_mtx_fx_16( Word16 temp_exp = shl( inp_exp, 1 ); int freq; - FOR( i = 0; i < N; i++ ) { FOR( j = i; j < N; j++ ) -- GitLab From 6888d91fc12be483739e97e446722b2b897a151f Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Tue, 18 Nov 2025 14:10:43 +0100 Subject: [PATCH 3/7] clang format patch --- lib_enc/ivas_mcmasa_enc_fx.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/lib_enc/ivas_mcmasa_enc_fx.c b/lib_enc/ivas_mcmasa_enc_fx.c index 3f26fb867..07d57f514 100644 --- a/lib_enc/ivas_mcmasa_enc_fx.c +++ b/lib_enc/ivas_mcmasa_enc_fx.c @@ -92,7 +92,7 @@ static void compute_cov_mtx_fx_16( #define RAM_ALIGN #endif #endif - + #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] */ @@ -943,7 +943,7 @@ void ivas_mcmasa_param_est_enc_fx( Word16 renormalization_factor_diff_e[MASA_FREQUENCY_BANDS]; Word32 norm_tmp_fx; #ifndef FUNC_compute_cov_mtx_fx_16 - Word16 mrange[2], brange[2]; + Word16 mrange[2], brange[2]; #else RAM_ALIGN Word16 Chnl_RealImagBuffer_fx_16[MCMASA_MAX_ANA_CHANS][DIRAC_NO_FB_BANDS_MAX * 2]; Word16 mrange[2]; @@ -1107,7 +1107,7 @@ void ivas_mcmasa_param_est_enc_fx( Word16 *x = Chnl_RealImagBuffer_fx_16[i]; /*out*/ Word16 k; const Word16 lg = DIRAC_NO_FB_BANDS_MAX; - const Word16 exp0 =add( sf , sfCorrection); + const Word16 exp0 = add( sf, sfCorrection ); if ( 0 == exp0 ) { @@ -1142,7 +1142,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] ); } } -#else //FUNC_compute_cov_mtx_fx_16 +#else // FUNC_compute_cov_mtx_fx_16 FOR( i = 0; i < num_freq_bands; i++ ) { brange[0] = hMcMasa->band_grouping[i]; @@ -2168,12 +2168,12 @@ static void ivas_mcmasa_dmx_fx( } #ifdef FUNC_compute_cov_mtx_fx_16 - /* Compute covariance matrix, i.e., xT * conj(x), and accumulate to the output */ +/* Compute covariance matrix, i.e., xT * conj(x), and accumulate to the output */ static void compute_cov_mtx_fx_16( Word16 sri[MCMASA_MAX_ANA_CHANS][DIRAC_NO_FB_BANDS_MAX * 2], - const Word16 N, /* i : Number of channels */ - CovarianceMatrix mCOVls[], /* o : Output matrix pointer, - upper part of cov mtx */ - Word16 inp_exp, /*Stores exponent for temp*/ + const Word16 N, /* i : Number of channels */ + CovarianceMatrix mCOVls[], /* o : Output matrix pointer, - upper part of cov mtx */ + Word16 inp_exp, /*Stores exponent for temp*/ Word16 band_grouping[], int num_freq_bands, int *fb_map ) @@ -2193,7 +2193,7 @@ static void compute_cov_mtx_fx_16( CovarianceMatrix *COVls = &( mCOVls[fb_map[freq]] ); temp32_1 = L_mac0( L_mult0( sri[i][freq << 1], sri[j][freq << 1] ), sri[i][( freq << 1 ) + 1], sri[j][( freq << 1 ) + 1] ); // exp:2*inp_exp - temp32_2 = COVls->xr_fx[i][j]; // exp:COVls->xr_e[i][j] + temp32_2 = COVls->xr_fx[i][j]; // exp:COVls->xr_e[i][j] max_exp = s_max( COVls->xr_e[i][j], temp_exp ); temp32_2 = L_shl( temp32_2, sub( COVls->xr_e[i][j], max_exp ) ); // exp:max_exp temp32_1 = L_shl( temp32_1, sub( temp_exp, max_exp ) ); // exp:max_exp @@ -2205,8 +2205,8 @@ static void compute_cov_mtx_fx_16( move32(); move16(); - temp32_1 = L_msu0( L_mult0( sri[i][( freq << 1 ) + 1], sri[j][freq << 1] ), sri[i][freq << 1], sri[j][(freq << 1) + 1] ); // exp :2*inp_exp - temp32_2 = COVls->xi_fx[i][j]; // exp:COVls->xi_e[i][j] + temp32_1 = L_msu0( L_mult0( sri[i][( freq << 1 ) + 1], sri[j][freq << 1] ), sri[i][freq << 1], sri[j][( freq << 1 ) + 1] ); // exp :2*inp_exp + temp32_2 = COVls->xi_fx[i][j]; // exp:COVls->xi_e[i][j] max_exp = s_max( COVls->xi_e[i][j], temp_exp ); temp32_2 = L_shl( temp32_2, sub( COVls->xi_e[i][j], max_exp ) ); // exp:max_exp temp32_1 = L_shl( temp32_1, sub( temp_exp, max_exp ) ); // exp:max_exp @@ -2224,7 +2224,7 @@ static void compute_cov_mtx_fx_16( #else - /* Compute covariance matrix, i.e., xT * conj(x), and accumulate to the output */ +/* 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) */ -- GitLab From e2521a3a5e01aaebc296a3eb5cbdf30fde8b683f Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Wed, 19 Nov 2025 07:22:39 +0100 Subject: [PATCH 4/7] set sfcorrection 0 --- lib_enc/ivas_mcmasa_enc_fx.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib_enc/ivas_mcmasa_enc_fx.c b/lib_enc/ivas_mcmasa_enc_fx.c index 07d57f514..2a0c7abee 100644 --- a/lib_enc/ivas_mcmasa_enc_fx.c +++ b/lib_enc/ivas_mcmasa_enc_fx.c @@ -1038,7 +1038,7 @@ void ivas_mcmasa_param_est_enc_fx( #ifdef FUNC_compute_cov_mtx_fx_16 /*get freq/band mapping*/ int fb_map[DIRAC_NO_FB_BANDS_MAX]; - int const sfCorrection = 3; + int const sfCorrection = 0; FOR( int b = 0; b < num_freq_bands; b++ ) { FOR( int f = hMcMasa->band_grouping[b]; f < hMcMasa->band_grouping[b + 1]; f++ ) @@ -2216,6 +2216,7 @@ static void compute_cov_mtx_fx_16( COVls->xi_fx[i][j] = L_shl( temp32_1, tmp_16 ); // exp:max_exp-tmp_16 COVls->xi_e[i][j] = sub( max_exp, tmp_16 ); move32(); + move16(); } } } -- GitLab From 8734156c645e4f55ee145d5367eba0f5567cc037 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Wed, 19 Nov 2025 08:01:22 +0100 Subject: [PATCH 5/7] change from correctionfactor to scalefactor_c --- lib_enc/ivas_mcmasa_enc_fx.c | 43 +++++++++++++++++++++++++----------- 1 file changed, 30 insertions(+), 13 deletions(-) diff --git a/lib_enc/ivas_mcmasa_enc_fx.c b/lib_enc/ivas_mcmasa_enc_fx.c index 2a0c7abee..00988c381 100644 --- a/lib_enc/ivas_mcmasa_enc_fx.c +++ b/lib_enc/ivas_mcmasa_enc_fx.c @@ -79,6 +79,7 @@ static void compute_cov_mtx_fx_16( const Word16 N, /* i : Number of channels */ CovarianceMatrix *COVls, /* o : Output matrix, contains upper part of cov mtx */ Word16 inp_exp, /*Stores exponent for temp*/ + Word16 *sf_c, Word16 band_grouping[], int num_freq_bands, int *fb_map ); @@ -947,6 +948,7 @@ void ivas_mcmasa_param_est_enc_fx( #else RAM_ALIGN Word16 Chnl_RealImagBuffer_fx_16[MCMASA_MAX_ANA_CHANS][DIRAC_NO_FB_BANDS_MAX * 2]; Word16 mrange[2]; + Word16 sf_c[MCMASA_MAX_ANA_CHANS]; #endif Word16 numSubFramesForRatio; CovarianceMatrix COVls[MASA_FREQUENCY_BANDS]; @@ -1090,11 +1092,21 @@ void ivas_mcmasa_param_est_enc_fx( ivas_fb_mixer_update_prior_input_fx( hMcMasa->hFbMixer, pcm_in, l_ts, hMcMasa->hFbMixer->fb_cfg->num_in_chans ); - FOR( i = 0; i < numAnalysisChannels; i++ ) + FOR( i = 0; i < numAnalysisChannels; i++ ) { +#ifdef FUNC_compute_cov_mtx_fx_16 + Word16 scal_imag, scal_real; + scal_imag = L_norm_arr( Chnl_ImagBuffer_fx[i], DIRAC_NO_FB_BANDS_MAX ); + scal_real = L_norm_arr( Chnl_RealBuffer_fx[i], DIRAC_NO_FB_BANDS_MAX ); + sf_c[i] = sub( s_min( scal_real, scal_imag ), 1 ); + pcm_in[i] += l_ts; + cr_q = s_min( cr_q, scal_imag ); + ci_q = s_min( ci_q, scal_real ); +#else pcm_in[i] += l_ts; cr_q = s_min( cr_q, L_norm_arr( Chnl_ImagBuffer_fx[i], DIRAC_NO_FB_BANDS_MAX ) ); ci_q = s_min( ci_q, L_norm_arr( Chnl_RealBuffer_fx[i], DIRAC_NO_FB_BANDS_MAX ) ); +#endif } sf = sub( s_min( cr_q, ci_q ), 5 ); @@ -1105,9 +1117,9 @@ void ivas_mcmasa_param_est_enc_fx( Word32 *re = Chnl_RealBuffer_fx[i]; /*in*/ Word32 *im = Chnl_ImagBuffer_fx[i]; /*in*/ Word16 *x = Chnl_RealImagBuffer_fx_16[i]; /*out*/ - Word16 k; - const Word16 lg = DIRAC_NO_FB_BANDS_MAX; - const Word16 exp0 = add( sf, sfCorrection ); + int k; + const int lg = DIRAC_NO_FB_BANDS_MAX; + const Word16 exp0 = add( sf_c[i], 0 ); if ( 0 == exp0 ) { @@ -1127,11 +1139,12 @@ void ivas_mcmasa_param_est_enc_fx( scale_sig32( Chnl_RealBuffer_fx[i], DIRAC_NO_FB_BANDS_MAX, sf ); // Q-> inp_q + sf scale_sig32( Chnl_ImagBuffer_fx[i], DIRAC_NO_FB_BANDS_MAX, sf ); // Q-> inp_q + sf } - inp_q = add( inp_q, sf ); - /* Compute covariance matrix */ #ifdef FUNC_compute_cov_mtx_fx_16 - compute_cov_mtx_fx_16( Chnl_RealImagBuffer_fx_16, numAnalysisChannels, COVls, sub( 31 + sfCorrection, inp_q ), hMcMasa->band_grouping, (int) num_freq_bands, fb_map ); + /* Compute covariance matrix */ + compute_cov_mtx_fx_16( Chnl_RealImagBuffer_fx_16, numAnalysisChannels, COVls, sub( 31, inp_q ), sf_c, hMcMasa->band_grouping, (int) num_freq_bands, fb_map ); + + inp_q = add( inp_q, sf ); FOR( i = 0; i < num_freq_bands; i++ ) { @@ -2174,6 +2187,7 @@ static void compute_cov_mtx_fx_16( const Word16 N, /* i : Number of channels */ CovarianceMatrix mCOVls[], /* o : Output matrix pointer, - upper part of cov mtx */ Word16 inp_exp, /*Stores exponent for temp*/ + Word16 *sf_c, Word16 band_grouping[], int num_freq_bands, int *fb_map ) @@ -2181,20 +2195,22 @@ static void compute_cov_mtx_fx_16( int i, j; Word32 temp32_1, temp32_2; Word16 tmp_16, max_exp; - Word16 temp_exp = shl( inp_exp, 1 ); + Word16 temp_exp; int freq; + FOR( i = 0; i < N; i++ ) { FOR( j = i; j < N; j++ ) { + temp_exp = add( sub( inp_exp, sf_c[i] ), sub( inp_exp, sf_c[j] ) ); FOR( freq = band_grouping[0]; freq < band_grouping[num_freq_bands]; freq++ ) { CovarianceMatrix *COVls = &( mCOVls[fb_map[freq]] ); - + // Ri(Rsre-Rs[0] *Rj(Rtre-Rt[0] + Ii(Rsim-Rs[1] * Ij(Rtim-Rt[1] temp32_1 = L_mac0( L_mult0( sri[i][freq << 1], sri[j][freq << 1] ), sri[i][( freq << 1 ) + 1], sri[j][( freq << 1 ) + 1] ); // exp:2*inp_exp - temp32_2 = COVls->xr_fx[i][j]; // exp:COVls->xr_e[i][j] - max_exp = s_max( COVls->xr_e[i][j], temp_exp ); + temp32_2 = COVls->xr_fx[i][j]; // exp:COVls->xr_e[i][j] + max_exp = add( s_max( COVls->xr_e[i][j], temp_exp ), 1 ); temp32_2 = L_shl( temp32_2, sub( COVls->xr_e[i][j], max_exp ) ); // exp:max_exp temp32_1 = L_shl( temp32_1, sub( temp_exp, max_exp ) ); // exp:max_exp temp32_1 = L_add( temp32_1, temp32_2 ); // exp:max_exp @@ -2205,9 +2221,10 @@ static void compute_cov_mtx_fx_16( move32(); move16(); + // Ii(Rsim-Rs[1] * Rj(Rtre-Rt[0] - Ri(Rsre-Rs[0] * Ii(Rtim-Rt[1] temp32_1 = L_msu0( L_mult0( sri[i][( freq << 1 ) + 1], sri[j][freq << 1] ), sri[i][freq << 1], sri[j][( freq << 1 ) + 1] ); // exp :2*inp_exp - temp32_2 = COVls->xi_fx[i][j]; // exp:COVls->xi_e[i][j] - max_exp = s_max( COVls->xi_e[i][j], temp_exp ); + temp32_2 = COVls->xi_fx[i][j]; // exp:COVls->xi_e[i][j] + max_exp = add( s_max( COVls->xr_e[i][j], temp_exp ), 1 ); temp32_2 = L_shl( temp32_2, sub( COVls->xi_e[i][j], max_exp ) ); // exp:max_exp temp32_1 = L_shl( temp32_1, sub( temp_exp, max_exp ) ); // exp:max_exp temp32_1 = L_add( temp32_1, temp32_2 ); // exp:max_exp -- GitLab From d561497888e0c99144cfa877749fd3cbc8dc4032 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Wed, 19 Nov 2025 08:17:01 +0100 Subject: [PATCH 6/7] clang format patch --- lib_enc/ivas_mcmasa_enc_fx.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib_enc/ivas_mcmasa_enc_fx.c b/lib_enc/ivas_mcmasa_enc_fx.c index 00988c381..675941c8d 100644 --- a/lib_enc/ivas_mcmasa_enc_fx.c +++ b/lib_enc/ivas_mcmasa_enc_fx.c @@ -1092,7 +1092,7 @@ void ivas_mcmasa_param_est_enc_fx( ivas_fb_mixer_update_prior_input_fx( hMcMasa->hFbMixer, pcm_in, l_ts, hMcMasa->hFbMixer->fb_cfg->num_in_chans ); - FOR( i = 0; i < numAnalysisChannels; i++ ) + FOR( i = 0; i < numAnalysisChannels; i++ ) { #ifdef FUNC_compute_cov_mtx_fx_16 Word16 scal_imag, scal_real; @@ -2209,7 +2209,7 @@ static void compute_cov_mtx_fx_16( CovarianceMatrix *COVls = &( mCOVls[fb_map[freq]] ); // Ri(Rsre-Rs[0] *Rj(Rtre-Rt[0] + Ii(Rsim-Rs[1] * Ij(Rtim-Rt[1] temp32_1 = L_mac0( L_mult0( sri[i][freq << 1], sri[j][freq << 1] ), sri[i][( freq << 1 ) + 1], sri[j][( freq << 1 ) + 1] ); // exp:2*inp_exp - temp32_2 = COVls->xr_fx[i][j]; // exp:COVls->xr_e[i][j] + temp32_2 = COVls->xr_fx[i][j]; // exp:COVls->xr_e[i][j] max_exp = add( s_max( COVls->xr_e[i][j], temp_exp ), 1 ); temp32_2 = L_shl( temp32_2, sub( COVls->xr_e[i][j], max_exp ) ); // exp:max_exp temp32_1 = L_shl( temp32_1, sub( temp_exp, max_exp ) ); // exp:max_exp @@ -2223,7 +2223,7 @@ static void compute_cov_mtx_fx_16( // Ii(Rsim-Rs[1] * Rj(Rtre-Rt[0] - Ri(Rsre-Rs[0] * Ii(Rtim-Rt[1] temp32_1 = L_msu0( L_mult0( sri[i][( freq << 1 ) + 1], sri[j][freq << 1] ), sri[i][freq << 1], sri[j][( freq << 1 ) + 1] ); // exp :2*inp_exp - temp32_2 = COVls->xi_fx[i][j]; // exp:COVls->xi_e[i][j] + temp32_2 = COVls->xi_fx[i][j]; // exp:COVls->xi_e[i][j] max_exp = add( s_max( COVls->xr_e[i][j], temp_exp ), 1 ); temp32_2 = L_shl( temp32_2, sub( COVls->xi_e[i][j], max_exp ) ); // exp:max_exp temp32_1 = L_shl( temp32_1, sub( temp_exp, max_exp ) ); // exp:max_exp -- GitLab From 70dfc981176255efe0809b5e97d2dc5a924eacc0 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Wed, 19 Nov 2025 08:28:50 +0100 Subject: [PATCH 7/7] fix warning --- lib_enc/ivas_mcmasa_enc_fx.c | 1 - 1 file changed, 1 deletion(-) diff --git a/lib_enc/ivas_mcmasa_enc_fx.c b/lib_enc/ivas_mcmasa_enc_fx.c index 675941c8d..486c6b1bd 100644 --- a/lib_enc/ivas_mcmasa_enc_fx.c +++ b/lib_enc/ivas_mcmasa_enc_fx.c @@ -1040,7 +1040,6 @@ void ivas_mcmasa_param_est_enc_fx( #ifdef FUNC_compute_cov_mtx_fx_16 /*get freq/band mapping*/ int fb_map[DIRAC_NO_FB_BANDS_MAX]; - int const sfCorrection = 0; FOR( int b = 0; b < num_freq_bands; b++ ) { FOR( int f = hMcMasa->band_grouping[b]; f < hMcMasa->band_grouping[b + 1]; f++ ) -- GitLab