From 267ec305aca39037677145fe1d314a8c7533266f Mon Sep 17 00:00:00 2001 From: Nicolas Roussin Date: Mon, 3 Nov 2025 14:57:23 +0000 Subject: [PATCH 1/7] Implement W_negate function. --- lib_basop/enh64.c | 43 +++++++++++++++++++++++++++++++++++++++++++ lib_basop/enh64.h | 1 + lib_debug/wmc_auto.c | 2 +- lib_debug/wmc_auto.h | 1 + 4 files changed, 46 insertions(+), 1 deletion(-) diff --git a/lib_basop/enh64.c b/lib_basop/enh64.c index 8bffb620c..08534c8dc 100644 --- a/lib_basop/enh64.c +++ b/lib_basop/enh64.c @@ -128,6 +128,49 @@ Word64 W_sub_nosat( Word64 L64_var1, Word64 L64_var2 ) } +/*__________________________________________________________________________________ + | | + | Function Name : W_negate | + | | + | Purpose : | + | | + | Negate the 64 bit variable L64_var1 with saturation; saturate in the case | + | where input is 0x8000 0000 0000 0000. | + | | + | Complexity weight : 1 | + | | + | Inputs : | + | | + | L64_var1 64 bit long signed integer (Word64) whose value falls in the range: | + | 0x8000 0000 0000 0000 <= L64_var1 <= 0x7fff ffff ffff ffff. | + | | + | Outputs : | + | | + | none | + | | + | Return Value : | + | | + | L64_var_out | + | 64 bit long signed integer (Word64) whose value falls in the range: | + | 0x8000 0000 0000 0000 <= L_var_out <= 0x7fff ffff ffff ffff. | + |_________________________________________________________________________________| +*/ +Word64 W_negate( Word64 L64_var1 ) +{ + Word64 L64_var_out; + + L64_var_out = ( L64_var1 == MIN_64 ) ? MAX_64 : -L64_var1; + +#ifdef WMOPS + multiCounter[currCounter].W_negate++; +#endif + + BASOP_CHECK(); + + return ( L64_var_out ); +} + + /*___________________________________________________________________________ | | | Function Name : W_shl | diff --git a/lib_basop/enh64.h b/lib_basop/enh64.h index c3896bb0d..7358fc56b 100644 --- a/lib_basop/enh64.h +++ b/lib_basop/enh64.h @@ -23,6 +23,7 @@ #ifdef ENH_64_BIT_OPERATOR Word64 W_add_nosat( Word64 L64_var1, Word64 L64_var2 ); Word64 W_sub_nosat( Word64 L64_var1, Word64 L64_var2 ); +Word64 W_negate( Word64 L64_var1 ); Word64 W_shl( Word64 L64_var1, Word16 var2 ); Word64 W_shr( Word64 L64_var1, Word16 var2 ); Word64 W_shl_nosat( Word64 L64_var1, Word16 var2 ); diff --git a/lib_debug/wmc_auto.c b/lib_debug/wmc_auto.c index 5afd9de16..e7cc88031 100644 --- a/lib_debug/wmc_auto.c +++ b/lib_debug/wmc_auto.c @@ -133,7 +133,7 @@ static BASIC_OP op_weight = { #ifdef ENH_64_BIT_OPERATOR /* Weights of new 64 bit basops */ , - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 #endif /* #ifdef ENH_64_BIT_OPERATOR */ #ifdef ENH_32_BIT_OPERATOR diff --git a/lib_debug/wmc_auto.h b/lib_debug/wmc_auto.h index 64e2c751a..a1465df58 100644 --- a/lib_debug/wmc_auto.h +++ b/lib_debug/wmc_auto.h @@ -879,6 +879,7 @@ typedef struct unsigned int move64; /* Complexity Weight of 1 */ unsigned int W_add_nosat; /* Complexity Weight of 1 */ unsigned int W_sub_nosat; /* Complexity Weight of 1 */ + unsigned int W_negate; /* Complexity Weight of 1 */ unsigned int W_shl; /* Complexity Weight of 1 */ unsigned int W_shr; /* Complexity Weight of 1 */ unsigned int W_shl_nosat; /* Complexity Weight of 1 */ -- GitLab From 297ef63119fb51b2509b20bd884deeacf31885d2 Mon Sep 17 00:00:00 2001 From: Nicolas Roussin Date: Mon, 3 Nov 2025 14:57:23 +0000 Subject: [PATCH 2/7] Optimize matrixTransp1Mul_fx. --- lib_com/options.h | 6 +++ .../ivas_dirac_dec_binaural_functions_fx.c | 39 +++++++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/lib_com/options.h b/lib_com/options.h index c967fd233..729e366af 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -138,4 +138,10 @@ /* #################### End BASOP porting switches ############################ */ +/* #################### Start BASOP optimization switches ############################ */ + +#define OPT_2181_MATRIX_TRANSP_1_MUL /* Dolby: Issue 2181, optimize matrixTransp1Mul_fx. */ + +/* #################### End BASOP optimization switches ############################ */ + #endif diff --git a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c index 60bbce7a9..10085a477 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c @@ -3997,6 +3997,44 @@ static void matrixTransp1Mul_fx( Word64 tmp_outRe_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; Word64 tmp_outIm_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; +#ifdef OPT_2181_MATRIX_TRANSP_1_MUL + Word64 tmp64; + Word16 common_lsh; + common_lsh = 63; + move16(); + + FOR( chA = 0; chA < BINAURAL_CHANNELS; chA++ ) + { + FOR( chB = 0; chB < BINAURAL_CHANNELS; chB++ ) + { + tmp64 = W_mult_32_32( Are_fx[0][chA], Bre_fx[0][chB] ); + tmp64 = W_mac_32_32( tmp64, Are_fx[1][chA], Bre_fx[1][chB] ); + tmp64 = W_mac_32_32( tmp64, Aim_fx[0][chA], Bim_fx[0][chB] ); + tmp_outRe_fx[chA][chB] = tmp64 = W_mac_32_32( tmp64, Aim_fx[1][chA], Bim_fx[1][chB] ); + move64(); + common_lsh = s_min( common_lsh, W_norm( tmp64 ) ); + + tmp64 = W_mult_32_32( Aim_fx[0][chA], Bre_fx[0][chB] ); + tmp64 = W_mac_32_32( tmp64, Aim_fx[1][chA], Bre_fx[1][chB] ); + tmp64 = W_mac_32_32( W_negate( tmp64 ), Are_fx[0][chA], Bim_fx[0][chB] ); + tmp_outIm_fx[chA][chB] = tmp64 = W_mac_32_32( tmp64, Are_fx[1][chA], Bim_fx[1][chB] ); + move64(); + common_lsh = s_min( common_lsh, W_norm( tmp64 ) ); + } + } + FOR( chA = 0; chA < BINAURAL_CHANNELS; chA++ ) + { + FOR( chB = 0; chB < BINAURAL_CHANNELS; chB++ ) + { + outRe_fx[chA][chB] = W_extract_h( W_shl( tmp_outRe_fx[chA][chB], common_lsh ) ); + move32(); + outIm_fx[chA][chB] = W_extract_h( W_shl( tmp_outIm_fx[chA][chB], common_lsh ) ); + move32(); + } + } + *q_out = add( add( add( q_A, q_B ), 1 ), common_lsh ); + move16(); +#else Word16 q_tmp_outRe_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; Word16 q_tmp_outIm_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; Word64 tmp64_1, tmp64_2; @@ -4043,6 +4081,7 @@ static void matrixTransp1Mul_fx( } *q_out = sub( q_common, 32 ); move16(); +#endif if ( L_and( is_zero_arr( outRe_fx[0], size ), is_zero_arr( outIm_fx[0], size ) ) ) { *q_out = Q31; -- GitLab From a8316e76a9c61199420ebf403e19d10ebaeb2b02 Mon Sep 17 00:00:00 2001 From: Nicolas Roussin Date: Mon, 3 Nov 2025 16:01:44 +0000 Subject: [PATCH 3/7] Fix q_out. --- lib_rend/ivas_dirac_dec_binaural_functions_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c index 10085a477..93b9778a6 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c @@ -4032,7 +4032,7 @@ static void matrixTransp1Mul_fx( move32(); } } - *q_out = add( add( add( q_A, q_B ), 1 ), common_lsh ); + *q_out = sub( add( add( add( q_A, q_B ), 1 ), common_lsh ), 32 ); move16(); #else Word16 q_tmp_outRe_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; -- GitLab From d1225c4dfa009961d7dda2b164e47f5b5af62b2f Mon Sep 17 00:00:00 2001 From: Nicolas Roussin Date: Mon, 3 Nov 2025 17:11:09 +0000 Subject: [PATCH 4/7] Fix common left shift initial value. --- lib_rend/ivas_dirac_dec_binaural_functions_fx.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c index 93b9778a6..fda10d47c 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c @@ -3999,8 +3999,9 @@ static void matrixTransp1Mul_fx( Word64 tmp_outIm_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; #ifdef OPT_2181_MATRIX_TRANSP_1_MUL Word64 tmp64; - Word16 common_lsh; - common_lsh = 63; + Word16 common_lsh, q; + q = add( add( q_A, q_B ), 1 ); + common_lsh = sub( 63, q ); move16(); FOR( chA = 0; chA < BINAURAL_CHANNELS; chA++ ) @@ -4032,7 +4033,7 @@ static void matrixTransp1Mul_fx( move32(); } } - *q_out = sub( add( add( add( q_A, q_B ), 1 ), common_lsh ), 32 ); + *q_out = sub( add( q, common_lsh ), 32 ); move16(); #else Word16 q_tmp_outRe_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; -- GitLab From eb67ffb1702aa8401cef4589f888f18a8474a420 Mon Sep 17 00:00:00 2001 From: Nicolas Roussin Date: Mon, 3 Nov 2025 18:37:41 +0000 Subject: [PATCH 5/7] Move scale operations outside mul operations. --- lib_com/options.h | 1 + .../ivas_dirac_dec_binaural_functions_fx.c | 83 ++++++++++++++++++- 2 files changed, 83 insertions(+), 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index 729e366af..c6c962f3d 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -141,6 +141,7 @@ /* #################### Start BASOP optimization switches ############################ */ #define OPT_2181_MATRIX_TRANSP_1_MUL /* Dolby: Issue 2181, optimize matrixTransp1Mul_fx. */ +#define OPT_2182_MATRIX_SCALE_OPS /* Dolby: Issue 2181, move matrix scale operations outside mul operations. */ /* #################### End BASOP optimization switches ############################ */ diff --git a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c index fda10d47c..fb8a12a29 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c @@ -118,9 +118,17 @@ static void ivas_masa_ext_rend_parambin_internal_fx( MASA_EXT_REND_HANDLE hMasaE static void formulate2x2MixingMatrix_fx( Word32 Ein1_fx /*q_Ein*/, Word32 Ein2_fx /*q_Ein*/, Word16 q_Ein, Word32 CinRe_fx /*q_Cin*/, Word32 CinIm_fx /*q_Cin*/, Word16 q_Cin, Word32 Eout1_fx /*q_Eout*/, Word32 Eout2_fx /*q_Eout*/, Word16 q_Eout, Word32 CoutRe_fx /*q_Cout*/, Word32 CoutIm_fx /*q_Cout*/, Word16 q_Cout, Word32 Q_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*Q31*/, Word32 Mre_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_M*/, Word32 Mim_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_M*/, Word16 *q_M, const Word16 regularizationFactor_fx /*Q14*/ ); +#ifdef OPT_2182_MATRIX_SCALE_OPS +static void matrixScale_fx( Word32 Are_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_A*/, Word32 Aim_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_A*/, Word16 *q_A ); +#endif + static void matrixMul_fx( Word32 Are[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_A*/, Word32 Aim[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_A*/, Word16 *q_A, Word32 Bre[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_B*/, Word32 Bim[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_B*/, Word16 *q_B, Word32 outRe[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_out*/, Word32 outIm[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_out*/, Word16 *q_out ); +#ifdef OPT_2182_MATRIX_SCALE_OPS +static void matrixTransp2Mul_fx( Word32 Are[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_A*/, Word32 Aim[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_A*/, Word16 *q_A, Word32 Bre[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_B*/, Word32 Bim[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_B*/, Word16 *q_B, Word32 outRe[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_out*/, Word32 outIm[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_out*/, Word16 *q_out ); +#else static void matrixTransp2Mul_fx( Word32 Are[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_A*/, Word32 Aim[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_A*/, Word16 *q_A, Word32 Bre[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_B*/, Word32 Bim[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_B*/, Word16 *q_B, Word32 Ascale, Word32 Bscale, Word32 outRe[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_out*/, Word32 outIm[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_out*/, Word16 *q_out ); +#endif /*------------------------------------------------------------------------- @@ -2260,12 +2268,23 @@ static void ivas_dirac_dec_binaural_determine_processing_matrices_fx( } /* Make matrix multiplication M*Cx*M' to determine resulting covariance matrix of processing input with M */ +#ifdef OPT_2182_MATRIX_SCALE_OPS + matrixScale_fx( Mre_fx, Mim_fx, &q_M ); + matrixScale_fx( CxRe_fx, CxIm_fx, &q_Cx ); +#endif matrixMul_fx( Mre_fx, Mim_fx, &q_M, CxRe_fx, CxIm_fx, &q_Cx, tmpMtxRe_fx, tmpMtxIm_fx, &q_tmp ); +#ifdef OPT_2182_MATRIX_SCALE_OPS + matrixScale_fx( tmpMtxRe_fx, tmpMtxIm_fx, &q_tmp ); + matrixTransp2Mul_fx( + tmpMtxRe_fx, tmpMtxIm_fx, &q_tmp, Mre_fx, Mim_fx, &q_M, + resultMtxRe_fx, resultMtxIm_fx, &q_res ); +#else matrixTransp2Mul_fx( tmpMtxRe_fx, tmpMtxIm_fx, &q_tmp, Mre_fx, Mim_fx, &q_M, 1 /*int Ascale*/, 0 /*int Bscale*/, resultMtxRe_fx, resultMtxIm_fx, &q_res ); +#endif /* When below the frequency limit where decorrelation is applied, we inject the decorrelated * residual (or missing) signal component. The procedure is active when there are not enough independent @@ -3914,6 +3933,22 @@ static void matrixDiagMul_fx( return; } +#ifdef OPT_2182_MATRIX_SCALE_OPS +static void matrixScale_fx( + Word32 Are_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], /*q_A*/ + Word32 Aim_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], /*q_A*/ + Word16 *q_A ) +{ + Word16 shift; + Word16 size = i_mult( BINAURAL_CHANNELS, BINAURAL_CHANNELS ); + shift = sub( s_min( L_norm_arr( Are_fx[0], size ), L_norm_arr( Aim_fx[0], size ) ), 1 ); + scale_sig32( Are_fx[0], size, shift ); + scale_sig32( Aim_fx[0], size, shift ); + *q_A = add( *q_A, shift ); + move16(); +} +#endif + static void matrixMul_fx( Word32 Are_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], /*q_A*/ Word32 Aim_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], /*q_A*/ @@ -3925,6 +3960,10 @@ static void matrixMul_fx( Word32 outIm_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], /*q_out*/ Word16 *q_out ) { +#ifdef OPT_2182_MATRIX_SCALE_OPS + Word16 chA, chB; + Word16 size = i_mult( BINAURAL_CHANNELS, BINAURAL_CHANNELS ); +#else Word16 chA, chB; Word16 min_q_shift1, min_q_shift2; Word16 size = i_mult( BINAURAL_CHANNELS, BINAURAL_CHANNELS ); @@ -3941,6 +3980,7 @@ static void matrixMul_fx( *q_B = add( *q_B, min_q_shift2 ); move16(); move16(); +#endif FOR( chA = 0; chA < BINAURAL_CHANNELS; chA++ ) { @@ -4092,6 +4132,18 @@ static void matrixTransp1Mul_fx( return; } +#ifdef OPT_2182_MATRIX_SCALE_OPS +static void matrixTransp2Mul_fx( + Word32 Are_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], /*q_A*/ + Word32 Aim_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], /*q_A*/ + Word16 *q_A, + Word32 Bre_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], /*q_B*/ + Word32 Bim_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], /*q_B*/ + Word16 *q_B, + Word32 outRe_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], /*q_out*/ + Word32 outIm_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], /*q_out*/ + Word16 *q_out ) +#else static void matrixTransp2Mul_fx( Word32 Are_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], /*q_A*/ Word32 Aim_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], /*q_A*/ @@ -4104,7 +4156,12 @@ static void matrixTransp2Mul_fx( Word32 outRe_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], /*q_out*/ Word32 outIm_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], /*q_out*/ Word16 *q_out ) +#endif { +#ifdef OPT_2182_MATRIX_SCALE_OPS + Word16 chA, chB; + Word16 size = BINAURAL_CHANNELS * BINAURAL_CHANNELS; +#else Word16 chA, chB; Word16 min_q_shift; Word16 size = BINAURAL_CHANNELS * BINAURAL_CHANNELS; @@ -4126,6 +4183,7 @@ static void matrixTransp2Mul_fx( *q_B = add( *q_B, min_q_shift ); move16(); } +#endif FOR( chA = 0; chA < BINAURAL_CHANNELS; chA++ ) { @@ -4663,6 +4721,10 @@ static void formulate2x2MixingMatrix_fx( q_temp = sub( add( q_ky, q_GhatQ ), 31 ); /* A = Ky' * G_hat * Q * Kx (see publication) */ +#ifdef OPT_2182_MATRIX_SCALE_OPS + matrixScale_fx( tmpRe_fx, tmpIm_fx, &q_temp ); + matrixScale_fx( Kxre_fx, Kxim_fx, &q_Kx ); +#endif matrixMul_fx( tmpRe_fx, tmpIm_fx, &q_temp, Kxre_fx, Kxim_fx, &q_Kx, Are_fx, Aim_fx, &q_A ); /* Find nearest orthonormal matrix P to A = Ky' * G_hat * Q * Kx @@ -4720,6 +4782,10 @@ static void formulate2x2MixingMatrix_fx( div_fx[0] = L_min( div_fx[0], thresh ); // q_div div_fx[1] = L_min( div_fx[1], thresh ); // q_div +#ifdef OPT_2182_MATRIX_SCALE_OPS + matrixScale_fx( Are_fx, Aim_fx, &q_A ); + matrixScale_fx( Ure_fx, Uim_fx, &q_U ); +#endif matrixMul_fx( Are_fx, Aim_fx, &q_A, Ure_fx, Uim_fx, &q_U, tmpRe_fx, tmpIm_fx, &q_temp ); exp = L_norm_arr( div_fx, BINAURAL_CHANNELS ); @@ -4783,10 +4849,15 @@ static void formulate2x2MixingMatrix_fx( } } +#ifdef OPT_2182_MATRIX_SCALE_OPS + matrixTransp2Mul_fx( tmpRe_fx, tmpIm_fx, &q_temp, Ure_fx, Uim_fx, &q_U, + Pre_fx, Pim_fx, &q_P ); /* Nearest orthonormal matrix P to matrix A formulated */ +#else matrixTransp2Mul_fx( tmpRe_fx, tmpIm_fx, &q_temp, Ure_fx, Uim_fx, &q_U, 0 /*int Ascale*/, 0 /*int Bscale*/, Pre_fx, Pim_fx, &q_P ); /* Nearest orthonormal matrix P to matrix A formulated */ +#endif /* These are the final formulas of the JAES publication M = Ky P Kx^(-1) */ #if ( BINAURAL_CHANNELS != 2 ) @@ -4917,12 +4988,22 @@ static void formulate2x2MixingMatrix_fx( } } +#ifdef OPT_2182_MATRIX_SCALE_OPS + matrixScale_fx( KyRe_fx, KyIm_fx, &q_ky ); + matrixScale_fx( Pre_fx, Pim_fx, &q_P ); +#endif matrixMul_fx( KyRe_fx, KyIm_fx, &q_ky, Pre_fx, Pim_fx, &q_P, tmpRe_fx, tmpIm_fx, &q_temp ); - +#ifdef OPT_2182_MATRIX_SCALE_OPS + matrixScale_fx( tmpRe_fx, tmpIm_fx, &q_temp ); + matrixTransp2Mul_fx( tmpRe_fx, tmpIm_fx, &q_temp, Uxre_fx, Uxim_fx, &q_Ux, + Mre_fx, Mim_fx, q_M ); +#else matrixTransp2Mul_fx( tmpRe_fx, tmpIm_fx, &q_temp, Uxre_fx, Uxim_fx, &q_Ux, 1 /*int Ascale*/, 0 /*int Bscale*/, Mre_fx, Mim_fx, q_M ); +#endif + return; } -- GitLab From 24c1c3724a1a46256b537595b0f2e8c9b14e877f Mon Sep 17 00:00:00 2001 From: Nicolas Roussin Date: Wed, 5 Nov 2025 13:59:43 +0000 Subject: [PATCH 6/7] Use W_neg instead of W_negate. --- lib_basop/enh64.c | 43 ------------------- lib_basop/enh64.h | 1 - lib_debug/wmc_auto.c | 2 +- lib_debug/wmc_auto.h | 1 - .../ivas_dirac_dec_binaural_functions_fx.c | 2 +- 5 files changed, 2 insertions(+), 47 deletions(-) diff --git a/lib_basop/enh64.c b/lib_basop/enh64.c index 08534c8dc..8bffb620c 100644 --- a/lib_basop/enh64.c +++ b/lib_basop/enh64.c @@ -128,49 +128,6 @@ Word64 W_sub_nosat( Word64 L64_var1, Word64 L64_var2 ) } -/*__________________________________________________________________________________ - | | - | Function Name : W_negate | - | | - | Purpose : | - | | - | Negate the 64 bit variable L64_var1 with saturation; saturate in the case | - | where input is 0x8000 0000 0000 0000. | - | | - | Complexity weight : 1 | - | | - | Inputs : | - | | - | L64_var1 64 bit long signed integer (Word64) whose value falls in the range: | - | 0x8000 0000 0000 0000 <= L64_var1 <= 0x7fff ffff ffff ffff. | - | | - | Outputs : | - | | - | none | - | | - | Return Value : | - | | - | L64_var_out | - | 64 bit long signed integer (Word64) whose value falls in the range: | - | 0x8000 0000 0000 0000 <= L_var_out <= 0x7fff ffff ffff ffff. | - |_________________________________________________________________________________| -*/ -Word64 W_negate( Word64 L64_var1 ) -{ - Word64 L64_var_out; - - L64_var_out = ( L64_var1 == MIN_64 ) ? MAX_64 : -L64_var1; - -#ifdef WMOPS - multiCounter[currCounter].W_negate++; -#endif - - BASOP_CHECK(); - - return ( L64_var_out ); -} - - /*___________________________________________________________________________ | | | Function Name : W_shl | diff --git a/lib_basop/enh64.h b/lib_basop/enh64.h index 7358fc56b..c3896bb0d 100644 --- a/lib_basop/enh64.h +++ b/lib_basop/enh64.h @@ -23,7 +23,6 @@ #ifdef ENH_64_BIT_OPERATOR Word64 W_add_nosat( Word64 L64_var1, Word64 L64_var2 ); Word64 W_sub_nosat( Word64 L64_var1, Word64 L64_var2 ); -Word64 W_negate( Word64 L64_var1 ); Word64 W_shl( Word64 L64_var1, Word16 var2 ); Word64 W_shr( Word64 L64_var1, Word16 var2 ); Word64 W_shl_nosat( Word64 L64_var1, Word16 var2 ); diff --git a/lib_debug/wmc_auto.c b/lib_debug/wmc_auto.c index e7cc88031..5afd9de16 100644 --- a/lib_debug/wmc_auto.c +++ b/lib_debug/wmc_auto.c @@ -133,7 +133,7 @@ static BASIC_OP op_weight = { #ifdef ENH_64_BIT_OPERATOR /* Weights of new 64 bit basops */ , - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 #endif /* #ifdef ENH_64_BIT_OPERATOR */ #ifdef ENH_32_BIT_OPERATOR diff --git a/lib_debug/wmc_auto.h b/lib_debug/wmc_auto.h index a1465df58..64e2c751a 100644 --- a/lib_debug/wmc_auto.h +++ b/lib_debug/wmc_auto.h @@ -879,7 +879,6 @@ typedef struct unsigned int move64; /* Complexity Weight of 1 */ unsigned int W_add_nosat; /* Complexity Weight of 1 */ unsigned int W_sub_nosat; /* Complexity Weight of 1 */ - unsigned int W_negate; /* Complexity Weight of 1 */ unsigned int W_shl; /* Complexity Weight of 1 */ unsigned int W_shr; /* Complexity Weight of 1 */ unsigned int W_shl_nosat; /* Complexity Weight of 1 */ diff --git a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c index 154e75762..416a8a71c 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c @@ -4041,7 +4041,7 @@ static void matrixTransp1Mul_fx( tmp64 = W_mult_32_32( Aim_fx[0][chA], Bre_fx[0][chB] ); tmp64 = W_mac_32_32( tmp64, Aim_fx[1][chA], Bre_fx[1][chB] ); - tmp64 = W_mac_32_32( W_negate( tmp64 ), Are_fx[0][chA], Bim_fx[0][chB] ); + tmp64 = W_mac_32_32( W_neg( tmp64 ), Are_fx[0][chA], Bim_fx[0][chB] ); tmp_outIm_fx[chA][chB] = tmp64 = W_mac_32_32( tmp64, Are_fx[1][chA], Bim_fx[1][chB] ); move64(); common_lsh = s_min( common_lsh, W_norm( tmp64 ) ); -- GitLab From b916c938510d273a1bc04f45666f44ddcac6852e Mon Sep 17 00:00:00 2001 From: Nicolas Roussin Date: Wed, 5 Nov 2025 14:03:17 +0000 Subject: [PATCH 7/7] Fix build failure. --- lib_dec/ivas_ism_metadata_dec_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/ivas_ism_metadata_dec_fx.c b/lib_dec/ivas_ism_metadata_dec_fx.c index 54cc5da15..4d3c06b9c 100644 --- a/lib_dec/ivas_ism_metadata_dec_fx.c +++ b/lib_dec/ivas_ism_metadata_dec_fx.c @@ -30,7 +30,6 @@ *******************************************************************************************************/ -#include "move.h" #include #include "options.h" #include "ivas_cnst.h" @@ -40,6 +39,7 @@ #include "ivas_stat_enc.h" #include #include "wmc_auto.h" +#include "move.h" #include "ivas_prot_fx.h" -- GitLab