From 0e52b6aef7a0777a8f3948c541fd3c07a55a3669 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Sun, 18 Aug 2024 21:20:33 +0530 Subject: [PATCH] Renderer bug fixes, precision improvements in compute mixing matrices --- apps/renderer.c | 4 +- lib_com/ivas_prot_fx.h | 12 + lib_com/ivas_tools.c | 64 ++++ lib_dec/ivas_dirac_output_synthesis_cov.c | 424 +++++++++------------- lib_dec/ivas_svd_dec.c | 75 ++-- lib_rend/lib_rend.c | 2 +- 6 files changed, 280 insertions(+), 301 deletions(-) diff --git a/apps/renderer.c b/apps/renderer.c index 3cdb5f73a..b16e32786 100644 --- a/apps/renderer.c +++ b/apps/renderer.c @@ -2688,8 +2688,8 @@ static void IsmPositionProvider_getNextFrame( /* Clamp pitch to lie within [-90, 90] range (can't be wrapped easily) */ objectMetadataBuffer->positions[objIdx].pitch = min( max( objectMetadataBuffer->positions[objIdx].pitch, -90 ), 90 ); #ifdef IVAS_FLOAT_FIXED - objectMetadataBuffer->positions[objIdx].yaw_fx = (Word32) objectMetadataBuffer->positions[objIdx].yaw * ( 1 << Q22 ); - objectMetadataBuffer->positions[objIdx].pitch_fx = (Word32) objectMetadataBuffer->positions[objIdx].pitch * ( 1 << Q22 ); + objectMetadataBuffer->positions[objIdx].yaw_fx = (Word32) ( ( objectMetadataBuffer->positions[objIdx].yaw ) * ( 1 << Q22 ) ); + objectMetadataBuffer->positions[objIdx].pitch_fx = (Word32) ( ( objectMetadataBuffer->positions[objIdx].pitch ) * ( 1 << Q22 ) ); #endif } diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index cd33b21bc..14300beac 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -1234,6 +1234,18 @@ Word16 matrix_diag_product_fx( Word32 *Z, /* o : resulting matrix after the matrix multiplication */ Word16 *Z_e ); +Word16 matrix_diag_product_fx_1( + const Word32 *X, /* i : left hand matrix */ + const Word16 *X_e, + const Word16 rowsX, /* i : number of rows of the left hand matrix */ + const Word16 colsX, /* i : number of columns of the left hand matrix */ + const Word16 transpX, /* i : flag indicating the transposition of the left hand matrix prior to the multiplication */ + const Word32 *Y, /* i : right hand diagonal matrix as vector containing the diagonal elements */ + const Word16 *Y_e, + const Word16 entriesY, /* i : number of entries in the diagonal */ + Word32 *Z, /* o : resulting matrix after the matrix multiplication */ + Word16 *Z_e ); + Word16 diag_matrix_product_fx( const Word32 *Y, /* i : left hand diagonal matrix as vector containing the diagonal elements */ Word16 Y_e, diff --git a/lib_com/ivas_tools.c b/lib_com/ivas_tools.c index 288db9193..76e84cc9a 100644 --- a/lib_com/ivas_tools.c +++ b/lib_com/ivas_tools.c @@ -2156,6 +2156,70 @@ Word16 matrix_diag_product_fx( return EXIT_SUCCESS; } + +Word16 matrix_diag_product_fx_1( + const Word32 *X, /* i : left hand matrix */ + const Word16 *X_e, + const Word16 rowsX, /* i : number of rows of the left hand matrix */ + const Word16 colsX, /* i : number of columns of the left hand matrix */ + const Word16 transpX, /* i : flag indicating the transposition of the left hand matrix prior to the multiplication */ + const Word32 *Y, /* i : right hand diagonal matrix as vector containing the diagonal elements */ + const Word16 *Y_e, + const Word16 entriesY, /* i : number of entries in the diagonal */ + Word32 *Z, /* o : resulting matrix after the matrix multiplication */ + Word16 *Z_e ) +{ + Word16 i, j; + Word32 *Zp = Z; + Word16 *Z_ep = Z_e; + Word16 tmp; + + /* Processing */ + IF( EQ_16( transpX, 1 ) ) /* We use X transpose */ + { + IF( NE_16( rowsX, entriesY ) ) + { + return EXIT_FAILURE; + } + FOR( j = 0; j < entriesY; ++j ) + { + FOR( i = 0; i < colsX; ++i ) + { + tmp = add( j, imult1616( i, rowsX ) ); + *( Zp ) = Mpy_32_32( X[tmp], Y[j] ); + move32(); + Zp++; + *( Z_ep ) = add( X_e[tmp], Y_e[j] ); + move16(); + Z_ep++; + } + } + } + ELSE /* Regular case */ + { + IF( NE_16( colsX, entriesY ) ) + { + return EXIT_FAILURE; + } + + FOR( j = 0; j < entriesY; ++j ) + { + FOR( i = 0; i < rowsX; ++i ) + { + *( Zp ) = Mpy_32_32( *( X ), Y[j] ); + move32(); + Zp++; + *( Z_ep ) = add( *( X_e ), Y_e[j] ); + move16(); + Z_ep++; + X++; + X_e++; + } + } + } + + return EXIT_SUCCESS; +} #endif #ifdef IVAS_FLOAT_FIXED diff --git a/lib_dec/ivas_dirac_output_synthesis_cov.c b/lib_dec/ivas_dirac_output_synthesis_cov.c index 2d158a705..8a98ef95a 100644 --- a/lib_dec/ivas_dirac_output_synthesis_cov.c +++ b/lib_dec/ivas_dirac_output_synthesis_cov.c @@ -1448,7 +1448,6 @@ Word16 computeMixingMatrices_fx( Word32 svd_s_buffer_fx[MAX_OUTPUT_CHANNELS]; Word16 svd_s_buffer_e[MAX_OUTPUT_CHANNELS]; - Word16 svd_s_buffer_fx_e; Word32 limit_fx; @@ -1477,7 +1476,6 @@ Word16 computeMixingMatrices_fx( Word16 Cy_hat_diag_buff_e[MAX_OUTPUT_CHANNELS]; Word32 G_hat_fx[MAX_OUTPUT_CHANNELS]; Word16 G_hat_buff_e[MAX_OUTPUT_CHANNELS]; - Word16 G_hat_e; Word16 mat_mult_buffer1_e, mat_mult_buffer2_e, mat_mult_buffer3_e; @@ -1528,17 +1526,14 @@ Word16 computeMixingMatrices_fx( mat2svdMat_fx( Cy_fx, svd_in_buffer_fx, lengthCy, lengthCy, 0 ); - svd_fx( svd_in_buffer_fx, Cy_fx_e, svd_u_buffer_fx, svd_s_buffer_fx, svd_v_buffer_fx, &svd_s_buffer_fx_e, lengthCy, lengthCy ); - - /* Computing Ky */ - + svd_fx( svd_in_buffer_fx, Cy_fx_e, svd_u_buffer_fx, svd_s_buffer_fx, svd_v_buffer_fx, svd_s_buffer_e, lengthCy, lengthCy ); /* Computing Ky */ FOR( i = 0; i < lengthCy; ++i ) { FOR( j = 0; j < lengthCy; ++j ) { - tmp_e = svd_s_buffer_fx_e; + tmp_e = svd_s_buffer_e[j]; move16(); L_tmp = Sqrt32( svd_s_buffer_fx[j], &tmp_e ); Ky_fx[add( i, imult1616( j, lengthCy ) )] = Mpy_32_32( svd_u_buffer_fx[i][j], L_tmp ); @@ -1548,26 +1543,6 @@ Word16 computeMixingMatrices_fx( } } - exp = Ky_fx_e[0]; - move16(); - FOR( i = 1; i < lengthCy * lengthCy; i++ ) - { - if ( LT_16( exp, Ky_fx_e[i] ) ) - { - exp = Ky_fx_e[i]; - move16(); - } - } - - FOR( i = 0; i < lengthCy * lengthCy; i++ ) - { - Ky_fx[i] = L_shr( Ky_fx[i], sub( exp, Ky_fx_e[i] ) ); - move32(); - Ky_fx_e[i] = exp; - move16(); - } - - /*-----------------------------------------------------------------* * Decomposition of Cx *-----------------------------------------------------------------*/ @@ -1576,13 +1551,13 @@ Word16 computeMixingMatrices_fx( mat2svdMat_fx( Cx_fx, svd_in_buffer_fx, lengthCx, lengthCx, 0 ); - svd_fx( svd_in_buffer_fx, Cx_fx_e, svd_u_buffer_fx, svd_s_buffer_fx, svd_v_buffer_fx, &svd_s_buffer_fx_e, lengthCx, lengthCx ); + svd_fx( svd_in_buffer_fx, Cx_fx_e, svd_u_buffer_fx, svd_s_buffer_fx, svd_v_buffer_fx, svd_s_buffer_e, lengthCx, lengthCx ); FOR( i = 0; i < lengthCx; ++i ) { FOR( j = 0; j < lengthCx; ++j ) { - tmp_e = svd_s_buffer_fx_e; + tmp_e = svd_s_buffer_e[j]; move16(); L_tmp = Sqrt32( svd_s_buffer_fx[j], &tmp_e ); Kx_fx[add( i, imult1616( j, lengthCx ) )] = Mpy_32_32( svd_u_buffer_fx[i][j], L_tmp ); @@ -1592,29 +1567,10 @@ Word16 computeMixingMatrices_fx( } } - exp = Kx_fx_e[0]; - move16(); - FOR( i = 1; i < lengthCx * lengthCx; i++ ) - { - if ( LT_16( exp, Kx_fx_e[i] ) ) - { - exp = Kx_fx_e[i]; - move16(); - } - } - - FOR( i = 0; i < lengthCx * lengthCx; i++ ) - { - Kx_fx[i] = L_shr( Kx_fx[i], sub( exp, Kx_fx_e[i] ) ); - move32(); - Kx_fx_e[i] = exp; - move16(); - } - FOR( i = 0; i < lengthCx; ++i ) { - tmp_e = svd_s_buffer_fx_e; + tmp_e = svd_s_buffer_e[i]; move16(); svd_s_buffer_fx[i] = Sqrt32( svd_s_buffer_fx[i], &tmp_e ); move32(); @@ -1622,45 +1578,32 @@ Word16 computeMixingMatrices_fx( move16(); } - // making the Q common - Word16 max_e; - max_e = svd_s_buffer_e[0]; + /*-----------------------------------------------------------------* + * Regularization of Sx + *-----------------------------------------------------------------*/ + + limit_fx = svd_s_buffer_fx[0]; + move32(); + limit_e = svd_s_buffer_e[0]; move16(); FOR( i = 1; i < lengthCx; i++ ) { - if ( LT_16( max_e, svd_s_buffer_e[i] ) ) + IF( BASOP_Util_Cmp_Mant32Exp( svd_s_buffer_fx[i], svd_s_buffer_e[i], limit_fx, limit_e ) > 0 ) { - max_e = svd_s_buffer_e[i]; + limit_fx = svd_s_buffer_fx[i]; + move32(); + limit_e = svd_s_buffer_e[i]; move16(); } } - FOR( i = 0; i < lengthCx; i++ ) - { - svd_s_buffer_fx[i] = L_shr( svd_s_buffer_fx[i], ( max_e - svd_s_buffer_e[i] ) ); - move32(); - } - svd_s_buffer_fx_e = max_e; - move16(); - - - /*-----------------------------------------------------------------* - * Regularization of Sx - *-----------------------------------------------------------------*/ - - maximum_l( svd_s_buffer_fx, lengthCx, &limit_fx ); - limit_e = svd_s_buffer_fx_e; - move16(); - L_tmp = Mpy_32_32( limit_fx, reg_Sx_fx ); limit_e = add( limit_e, reg_Sx_e ); limit_fx = L_add( L_tmp, EPSILON_FX ); FOR( i = 0; i < lengthCx; ++i ) { - svd_s_buffer_e[i] = svd_s_buffer_fx_e; - move16(); - IF( BASOP_Util_Cmp_Mant32Exp( svd_s_buffer_fx[i], svd_s_buffer_fx_e, limit_fx, limit_e ) < 0 ) + IF( BASOP_Util_Cmp_Mant32Exp( svd_s_buffer_fx[i], svd_s_buffer_e[i], limit_fx, limit_e ) < 0 ) { svd_s_buffer_fx[i] = limit_fx; move32(); @@ -1694,25 +1637,6 @@ Word16 computeMixingMatrices_fx( } } - exp = Kx_reg_inv_e[0]; - move16(); - FOR( i = 0; i < lengthCx * lengthCx; i++ ) - { - if ( LT_16( exp, Kx_reg_inv_e[i] ) ) - { - exp = Kx_reg_inv_e[i]; - move16(); - } - } - - FOR( i = 0; i < lengthCx * lengthCx; i++ ) - { - Kx_reg_inv_fx[i] = L_shr( Kx_reg_inv_fx[i], sub( exp, Kx_reg_inv_e[i] ) ); - move32(); - Kx_reg_inv_e[i] = exp; - move16(); - } - /*-----------------------------------------------------------------* * normalization matrix G hat *-----------------------------------------------------------------*/ @@ -1721,36 +1645,6 @@ Word16 computeMixingMatrices_fx( matrix_product_mant_exp_fx( Q_fx, Q_e, lengthCy, lengthCx, 0, Cx_fx, Cx_fx_e, lengthCx, lengthCx, 0, Q_Cx_fx, &Q_Cx_e ); - Word16 guard_bits; -#ifdef FIX_827_HIGH_MLD - guard_bits = find_guarded_bits_fx( lengthCx ); -#else - guard_bits = find_guarded_bits_fx( lengthCx + 1 ); -#endif - - FOR( i = 0; i < lengthCy * lengthCx; ++i ) - { - IF( GT_16( Q_Cx_e, Q_e ) ) - { - Q_fx[i] = L_shr( Q_fx[i], guard_bits ); - move32(); - } - ELSE - { - Q_Cx_fx[i] = L_shr( Q_Cx_fx[i], guard_bits ); - move32(); - } - } - - IF( GT_16( Q_Cx_e, Q_e ) ) - { - Q_e = add( Q_e, guard_bits ); - } - ELSE - { - Q_Cx_e = add( Q_Cx_e, guard_bits ); - } - matrix_product_diag_fx( Q_Cx_fx, Q_Cx_e, lengthCy, lengthCx, 0, Q_fx, Q_e, lengthCy, lengthCx, 1, Cy_hat_diag_fx, &Cy_hat_diag_e ); @@ -1799,38 +1693,45 @@ Word16 computeMixingMatrices_fx( move16(); } - exp = G_hat_buff_e[0]; + + /*-----------------------------------------------------------------* + * Formulate optimal P + *-----------------------------------------------------------------*/ + + /* Computing the input matrix Kx'*Q'*G_hat'*Ky */ + + Word16 mat_mult_buffer1_fx_e[MAX_OUTPUT_CHANNELS * MAX_OUTPUT_CHANNELS]; + Word16 Q_e_arr[PARAM_MC_MAX_TRANSPORT_CHANS * MAX_CICP_CHANNELS]; + set16_fx( Q_e_arr, Q_e, PARAM_MC_MAX_TRANSPORT_CHANS * MAX_CICP_CHANNELS ); + + matrix_product_mant_exp( Kx_fx, Kx_fx_e, lengthCx, lengthCx, 1, Q_fx, Q_e_arr, lengthCy, lengthCx, 1, mat_mult_buffer1_fx, mat_mult_buffer1_fx_e ); + + Word16 mat_mult_buffer2_fx_e[MAX_OUTPUT_CHANNELS * MAX_OUTPUT_CHANNELS]; + + matrix_diag_product_fx_1( mat_mult_buffer1_fx, mat_mult_buffer1_fx_e, lengthCx, lengthCy, 0, G_hat_fx, G_hat_buff_e, lengthCy, mat_mult_buffer2_fx, mat_mult_buffer2_fx_e ); + + matrix_product_mant_exp( mat_mult_buffer2_fx, mat_mult_buffer2_fx_e, lengthCx, lengthCy, 0, Ky_fx, Ky_fx_e, lengthCy, lengthCy, 0, mat_mult_buffer1_fx, mat_mult_buffer1_fx_e ); + + exp = mat_mult_buffer1_fx_e[0]; move16(); - FOR( i = 1; i < lengthCy; i++ ) + FOR( i = 1; i < lengthCy * lengthCx; i++ ) { - if ( LT_16( exp, G_hat_buff_e[i] ) ) + if ( LT_16( exp, mat_mult_buffer1_fx_e[i] ) ) { - exp = G_hat_buff_e[i]; + exp = mat_mult_buffer1_fx_e[i]; move16(); } } - FOR( i = 0; i < lengthCy; i++ ) + FOR( i = 0; i < lengthCy * lengthCx; i++ ) { - G_hat_fx[i] = L_shr( G_hat_fx[i], sub( exp, G_hat_buff_e[i] ) ); + mat_mult_buffer1_fx[i] = L_shr( mat_mult_buffer1_fx[i], sub( exp, mat_mult_buffer1_fx_e[i] ) ); move32(); } - G_hat_e = exp; + mat_mult_buffer1_e = exp; move16(); - /*-----------------------------------------------------------------* - * Formulate optimal P - *-----------------------------------------------------------------*/ - - /* Computing the input matrix Kx'*Q'*G_hat'*Ky */ - - matrix_product_mant_exp_fx( Kx_fx, Kx_fx_e[0], lengthCx, lengthCx, 1, Q_fx, Q_e, lengthCy, lengthCx, 1, mat_mult_buffer1_fx, &mat_mult_buffer1_e ); - - matrix_diag_product_fx( mat_mult_buffer1_fx, mat_mult_buffer1_e, lengthCx, lengthCy, 0, G_hat_fx, G_hat_e, lengthCy, mat_mult_buffer2_fx, &mat_mult_buffer2_e ); - - matrix_product_mant_exp_fx( mat_mult_buffer2_fx, mat_mult_buffer2_e, lengthCx, lengthCy, 0, Ky_fx, Ky_fx_e[0], lengthCy, lengthCy, 0, mat_mult_buffer1_fx, &mat_mult_buffer1_e ); - IF( LT_16( lengthCx, lengthCy ) ) { mat2svdMat_fx( mat_mult_buffer1_fx, svd_in_buffer_fx, lengthCx, lengthCy, 1 ); @@ -1838,7 +1739,7 @@ Word16 computeMixingMatrices_fx( move16(); nC = lengthCx; move16(); - svd_fx( svd_in_buffer_fx, mat_mult_buffer1_e, svd_v_buffer_fx, svd_s_buffer_fx, svd_u_buffer_fx, &svd_s_buffer_fx_e, nL, nC ); + svd_fx( svd_in_buffer_fx, mat_mult_buffer1_e, svd_v_buffer_fx, svd_s_buffer_fx, svd_u_buffer_fx, svd_s_buffer_e, nL, nC ); } ELSE { @@ -1847,7 +1748,7 @@ Word16 computeMixingMatrices_fx( move16(); nC = lengthCy; move16(); - svd_fx( svd_in_buffer_fx, mat_mult_buffer1_e, svd_u_buffer_fx, svd_s_buffer_fx, svd_v_buffer_fx, &svd_s_buffer_fx_e, nL, nC ); + svd_fx( svd_in_buffer_fx, mat_mult_buffer1_e, svd_u_buffer_fx, svd_s_buffer_fx, svd_v_buffer_fx, svd_s_buffer_e, nL, nC ); } /* Actually Processing P */ @@ -1869,9 +1770,14 @@ Word16 computeMixingMatrices_fx( /************************ Formulate M **********************/ - matrix_product_mant_exp_fx( Ky_fx, Ky_fx_e[0], lengthCy, lengthCy, 0, mat_mult_buffer3_fx, mat_mult_buffer3_e, lengthCy, lengthCx, 0, mat_mult_buffer1_fx, &mat_mult_buffer1_e ); + Word16 mat_mult_buffer3_fx_e[MAX_OUTPUT_CHANNELS * MAX_OUTPUT_CHANNELS]; + set16_fx( mat_mult_buffer3_fx_e, mat_mult_buffer3_e, MAX_OUTPUT_CHANNELS * MAX_OUTPUT_CHANNELS ); + + matrix_product_mant_exp( Ky_fx, Ky_fx_e, lengthCy, lengthCy, 0, mat_mult_buffer3_fx, mat_mult_buffer3_fx_e, lengthCy, lengthCx, 0, mat_mult_buffer1_fx, mat_mult_buffer1_fx_e ); - matrix_product_mant_exp_fx( mat_mult_buffer1_fx, mat_mult_buffer1_e, lengthCy, lengthCx, 0, Kx_reg_inv_fx, Kx_reg_inv_e[0], lengthCx, lengthCx, 0, mixing_matrix_fx, &mixing_matrix_e ); + Word16 mixing_matrix_fx_e[MAX_CICP_CHANNELS * PARAM_MC_MAX_TRANSPORT_CHANS]; + + matrix_product_mant_exp( mat_mult_buffer1_fx, mat_mult_buffer1_fx_e, lengthCy, lengthCx, 0, Kx_reg_inv_fx, Kx_reg_inv_e, lengthCx, lengthCx, 0, mixing_matrix_fx, mixing_matrix_fx_e ); /*-----------------------------------------------------------------* * Formulate Cr @@ -1880,31 +1786,42 @@ Word16 computeMixingMatrices_fx( /* Compute Cy_tilde = M*Cx*M' */ - matrix_product_mant_exp_fx( mixing_matrix_fx, mixing_matrix_e, lengthCy, lengthCx, 0, Cx_fx, Cx_fx_e, lengthCx, lengthCx, 0, mat_mult_buffer1_fx, &mat_mult_buffer1_e ); + Word16 Cx_e_arr[PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS]; + set16_fx( Cx_e_arr, Cx_fx_e, PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS ); + matrix_product_mant_exp( mixing_matrix_fx, mixing_matrix_fx_e, lengthCy, lengthCx, 0, Cx_fx, Cx_e_arr, lengthCx, lengthCx, 0, mat_mult_buffer1_fx, mat_mult_buffer1_fx_e ); - matrix_product_mant_exp_fx( mat_mult_buffer1_fx, mat_mult_buffer1_e, lengthCy, lengthCx, 0, mixing_matrix_fx, mixing_matrix_e, lengthCy, lengthCx, 1, mat_mult_buffer2_fx, &mat_mult_buffer2_e ); + matrix_product_mant_exp( mat_mult_buffer1_fx, mat_mult_buffer1_fx_e, lengthCy, lengthCx, 0, mixing_matrix_fx, mixing_matrix_fx_e, lengthCy, lengthCx, 1, mat_mult_buffer2_fx, mat_mult_buffer2_fx_e ); - Cr_p_fx = Cr_fx; - Cy_p_fx = Cy_fx; - Cy_tilde_p_fx = mat_mult_buffer2_fx; - exp = add( s_max( Cy_fx_e, mat_mult_buffer2_e ), 1 ); /* Guard bit */ - FOR( i = 0; i < lengthCy * lengthCy; i++ ) + exp = mixing_matrix_fx_e[0]; + move16(); + FOR( i = 1; i < lengthCy * lengthCx; i++ ) { - Cy_fx[i] = L_shr( Cy_p_fx[i], exp - Cy_fx_e ); - move32(); - Cy_tilde_p_fx[i] = L_shr( Cy_tilde_p_fx[i], exp - mat_mult_buffer2_e ); + if ( LT_16( exp, mixing_matrix_fx_e[i] ) ) + { + exp = mixing_matrix_fx_e[i]; + move16(); + } + } + + FOR( i = 0; i < lengthCy * lengthCx; i++ ) + { + mixing_matrix_fx[i] = L_shr( mixing_matrix_fx[i], sub( exp, mixing_matrix_fx_e[i] ) ); move32(); } - Cy_fx_e = exp; - move16(); - mat_mult_buffer2_e = exp; + + mixing_matrix_e = exp; move16(); + + Cr_p_fx = Cr_fx; + Cy_p_fx = Cy_fx; + Cy_tilde_p_fx = mat_mult_buffer2_fx; + Word16 Cr_e_arr[MAX_CICP_CHANNELS * MAX_CICP_CHANNELS]; FOR( i = 0; i < lengthCy; ++i ) { FOR( j = 0; j < lengthCy; ++j ) { - *( Cr_p_fx ) = L_sub( *( Cy_p_fx ), *( Cy_tilde_p_fx ) ); + *( Cr_p_fx ) = BASOP_Util_Add_Mant32Exp( *( Cy_p_fx ), Cy_fx_e, L_negate( *( Cy_tilde_p_fx ) ), mat_mult_buffer2_fx_e[i * lengthCy + j], &Cr_e_arr[i * lengthCy + j] ); move32(); Cr_p_fx++; Cy_p_fx++; @@ -1916,12 +1833,51 @@ Word16 computeMixingMatrices_fx( { Cr_fx[add( i, imult1616( i, lengthCy ) )] = 0; move32(); + Cr_e_arr[add( i, imult1616( i, lengthCy ) )] = 0; + move16(); + } + } + + exp = Cr_e_arr[0]; + move16(); + FOR( i = 1; i < lengthCy * lengthCy; i++ ) + { + if ( LT_16( exp, Cr_e_arr[i] ) ) + { + exp = Cr_e_arr[i]; + move16(); } } + FOR( i = 0; i < lengthCy * lengthCy; i++ ) + { + Cr_fx[i] = L_shr( Cr_fx[i], sub( exp, Cr_e_arr[i] ) ); + move32(); + } + Cr_fx_e = exp; move16(); + exp = mat_mult_buffer2_fx_e[0]; + move16(); + FOR( i = 1; i < lengthCy * lengthCy; i++ ) + { + if ( LT_16( exp, mat_mult_buffer2_fx_e[i] ) ) + { + exp = mat_mult_buffer2_fx_e[i]; + move16(); + } + } + + FOR( i = 0; i < lengthCy * lengthCy; i++ ) + { + mat_mult_buffer2_fx[i] = L_shr( mat_mult_buffer2_fx[i], sub( exp, mat_mult_buffer2_fx_e[i] ) ); + move32(); + } + + mat_mult_buffer2_e = exp; + move16(); + /*-----------------------------------------------------------------* * Energy Compensation *-----------------------------------------------------------------*/ @@ -2239,7 +2195,7 @@ Word16 computeMixingMatricesResidual_fx( #else Word32 svd_s_buffer_fx[MAX_OUTPUT_CHANNELS]; #endif - Word16 svd_s_buffer_fx_e; + Word16 svd_s_buffer_e[MAX_OUTPUT_CHANNELS]; Word32 L_tmp; Word16 tmp_e; Word16 tmp, scale; @@ -2255,7 +2211,7 @@ Word16 computeMixingMatricesResidual_fx( Word16 limit_e; Word32 Kx_reg_inv_fx[MAX_OUTPUT_CHANNELS]; - Word16 Kx_reg_inv_e[MAX_OUTPUT_CHANNELS], Kx_reg_inv_fx_e; + Word16 Kx_reg_inv_e[MAX_OUTPUT_CHANNELS]; Word32 Cy_hat_diag_fx[MAX_OUTPUT_CHANNELS]; Word16 Cy_hat_diag_e; @@ -2279,14 +2235,14 @@ Word16 computeMixingMatricesResidual_fx( /* linear array to svd buffer */ mat2svdMat_fx( Cy_fx, svd_in_buffer_fx, lengthCy, lengthCy, 0 ); - svd_fx( svd_in_buffer_fx, Cy_fx_e, svd_u_buffer_fx, svd_s_buffer_fx, svd_v_buffer_fx, &svd_s_buffer_fx_e, lengthCy, lengthCy ); + svd_fx( svd_in_buffer_fx, Cy_fx_e, svd_u_buffer_fx, svd_s_buffer_fx, svd_v_buffer_fx, svd_s_buffer_e, lengthCy, lengthCy ); /* Computing Ky */ FOR( i = 0; i < lengthCy; ++i ) { FOR( j = 0; j < lengthCy; ++j ) { - tmp_e = svd_s_buffer_fx_e; + tmp_e = svd_s_buffer_e[j]; move16(); L_tmp = Sqrt32( svd_s_buffer_fx[j], &tmp_e ); Ky_fx[i + j * lengthCy] = Mpy_32_32( svd_u_buffer_fx[i][j], L_tmp ); @@ -2296,24 +2252,6 @@ Word16 computeMixingMatricesResidual_fx( } } - exp = Ky_fx_e[0]; - move16(); - FOR( i = 1; i < lengthCy * lengthCy; i++ ) - { - if ( LT_16( exp, Ky_fx_e[i] ) ) - { - exp = Ky_fx_e[i]; - move16(); - } - } - - FOR( i = 0; i < lengthCy * lengthCy; i++ ) - { - Ky_fx[i] = L_shr( Ky_fx[i], sub( exp, Ky_fx_e[i] ) ); - Ky_fx_e[i] = exp; - move16(); - } - /*-----------------------------------------------------------------* * Decomposition of Cx *-----------------------------------------------------------------*/ @@ -2334,34 +2272,25 @@ Word16 computeMixingMatricesResidual_fx( move16(); } - exp = Kx_fx_e[0]; + /*-----------------------------------------------------------------* + * Regularization of Sx + *-----------------------------------------------------------------*/ + + limit_fx = Kx_fx[0]; + move32(); + limit_e = Kx_fx_e[0]; move16(); FOR( i = 1; i < lengthCx; i++ ) { - if ( LT_16( exp, Kx_fx_e[i] ) ) + IF( BASOP_Util_Cmp_Mant32Exp( Kx_fx[i], Kx_fx_e[i], limit_fx, limit_e ) > 0 ) { - exp = Kx_fx_e[i]; + limit_fx = Kx_fx[i]; + move32(); + limit_e = Kx_fx_e[i]; move16(); } } - FOR( i = 0; i < lengthCx; i++ ) - { - Kx_fx[i] = L_shr( Kx_fx[i], sub( exp, Kx_fx_e[i] ) ); - move32(); - Kx_fx_e[i] = exp; - move16(); - } - - - /*-----------------------------------------------------------------* - * Regularization of Sx - *-----------------------------------------------------------------*/ - - maximum_l( Kx_fx, lengthCx, &limit_fx ); - limit_e = Kx_fx_e[0]; - move16(); - L_tmp = Mpy_32_32( limit_fx, reg_Sx_fx ); L_tmp = L_add( L_tmp, EPSILLON_FX ); limit_fx = L_tmp; @@ -2370,11 +2299,11 @@ Word16 computeMixingMatricesResidual_fx( FOR( i = 0; i < lengthCx; ++i ) { - IF( BASOP_Util_Cmp_Mant32Exp( Kx_fx[i], Kx_fx_e[0], limit_fx, limit_e ) > 0 ) + IF( BASOP_Util_Cmp_Mant32Exp( Kx_fx[i], Kx_fx_e[i], limit_fx, limit_e ) > 0 ) { div_tmp = Kx_fx[i]; move32(); - exp = Kx_fx_e[0]; + exp = Kx_fx_e[i]; move16(); } ELSE @@ -2392,26 +2321,6 @@ Word16 computeMixingMatricesResidual_fx( move16(); } - exp = Kx_reg_inv_e[0]; - move16(); - FOR( i = 1; i < lengthCx; i++ ) - { - if ( LT_16( exp, Kx_reg_inv_e[i] ) ) - { - exp = Kx_reg_inv_e[i]; - move16(); - } - } - - FOR( i = 0; i < lengthCx; i++ ) - { - Kx_reg_inv_fx[i] = L_shr( Kx_reg_inv_fx[i], sub( exp, Kx_reg_inv_e[i] ) ); - move32(); - } - Kx_reg_inv_fx_e = exp; - move16(); - - limit_fx = 0; move32(); limit_e = 0; @@ -2514,7 +2423,7 @@ Word16 computeMixingMatricesResidual_fx( mat2svdMat_fx( mat_mult_buffer1_fx, svd_in_buffer_fx, lengthCx, lengthCy, 0 ); - svd_fx( svd_in_buffer_fx, mat_mult_buffer1_e, svd_u_buffer_fx, svd_s_buffer_fx, svd_v_buffer_fx, &svd_s_buffer_fx_e, lengthCx, lengthCy ); + svd_fx( svd_in_buffer_fx, mat_mult_buffer1_e, svd_u_buffer_fx, svd_s_buffer_fx, svd_v_buffer_fx, svd_s_buffer_e, lengthCx, lengthCy ); /* Actually Processing P */ @@ -2533,7 +2442,12 @@ Word16 computeMixingMatricesResidual_fx( * Formulate M *-----------------------------------------------------------------*/ - matrix_product_mant_exp_fx( Ky_fx, Ky_fx_e[0], lengthCy, lengthCy, 0, mat_mult_buffer3_fx, mat_mult_buffer3_e, lengthCy, lengthCx, 0, mat_mult_buffer1_fx, &mat_mult_buffer1_e ); + Word16 mat_mult_buffer3_fx_e[MAX_OUTPUT_CHANNELS * MAX_OUTPUT_CHANNELS]; + set16_fx( mat_mult_buffer3_fx_e, mat_mult_buffer3_e, MAX_OUTPUT_CHANNELS * MAX_OUTPUT_CHANNELS ); + + matrix_product_mant_exp( Ky_fx, Ky_fx_e, lengthCy, lengthCy, 0, mat_mult_buffer3_fx, mat_mult_buffer3_fx_e, lengthCy, lengthCx, 0, mat_mult_buffer1_fx, mat_mult_buffer1_buff_e ); + + Word16 mixing_matrix_fx_e[MAX_CICP_CHANNELS * MAX_CICP_CHANNELS]; FOR( i = 0; i < num_outputs; i++ ) { @@ -2551,7 +2465,7 @@ Word16 computeMixingMatricesResidual_fx( mixing_matrix_fx[add( j, imult1616( j, extract_l( num_outputs ) ) )] = L_tmp; #endif move32(); - mixing_matrix_e = add( mat_mult_buffer1_e, Kx_reg_inv_fx_e ); + mixing_matrix_fx_e[j + i * num_outputs] = add( mat_mult_buffer1_buff_e[j + i * num_outputs], Kx_reg_inv_e[i] ); move16(); } } @@ -2562,38 +2476,49 @@ Word16 computeMixingMatricesResidual_fx( /* Compute Cy_tilde = M*Cx*M' */ - matrix_diag_product_fx( mixing_matrix_fx, mixing_matrix_e, lengthCy, lengthCx, 0, Cx_fx, Cx_e, lengthCx, mat_mult_buffer1_fx, &mat_mult_buffer1_e ); + Word16 Cx_e_arr[MAX_CICP_CHANNELS]; + set16_fx( Cx_e_arr, Cx_e, MAX_CICP_CHANNELS ); -#ifdef FIX_827_HIGH_MLD - Word16 guard_bits; - guard_bits = find_guarded_bits_fx( lengthCx ); -#else - Word16 guard_bits = find_guarded_bits_fx( lengthCx + 1 ); -#endif + matrix_diag_product_fx_1( mixing_matrix_fx, mixing_matrix_fx_e, lengthCy, lengthCx, 0, Cx_fx, Cx_e_arr, lengthCx, mat_mult_buffer1_fx, mat_mult_buffer1_buff_e ); - FOR( i = 0; i < lengthCy * lengthCx; ++i ) + exp = mixing_matrix_fx_e[0]; + move16(); + FOR( i = 1; i < num_outputs * num_outputs; i++ ) { - IF( GT_16( mat_mult_buffer1_e, mixing_matrix_e ) ) + if ( LT_16( exp, mixing_matrix_fx_e[i] ) ) { - mixing_matrix_fx[i] = L_shr( mixing_matrix_fx[i], guard_bits ); - move32(); - } - ELSE - { - mat_mult_buffer1_fx[i] = L_shr( mat_mult_buffer1_fx[i], guard_bits ); - move32(); + exp = mixing_matrix_fx_e[i]; + move16(); } } - IF( GT_16( mat_mult_buffer1_e, mixing_matrix_e ) ) + FOR( i = 0; i < num_outputs * num_outputs; i++ ) { - mixing_matrix_e = add( mixing_matrix_e, guard_bits ); + mixing_matrix_fx[i] = L_shr( mixing_matrix_fx[i], sub( exp, mixing_matrix_fx_e[i] ) ); + move32(); } - ELSE + mixing_matrix_e = exp; + move16(); + + exp = mat_mult_buffer1_buff_e[0]; + move16(); + FOR( i = 1; i < num_outputs * num_outputs; i++ ) { - mat_mult_buffer1_e = add( mat_mult_buffer1_e, guard_bits ); + if ( LT_16( exp, mat_mult_buffer1_buff_e[i] ) ) + { + exp = mat_mult_buffer1_buff_e[i]; + move16(); + } } + FOR( i = 0; i < num_outputs * num_outputs; i++ ) + { + mat_mult_buffer1_fx[i] = L_shr( mat_mult_buffer1_fx[i], sub( exp, mat_mult_buffer1_buff_e[i] ) ); + move32(); + } + mat_mult_buffer1_e = exp; + move16(); + matrix_product_diag_fx( mat_mult_buffer1_fx, mat_mult_buffer1_e, lengthCy, lengthCx, 0, mixing_matrix_fx, mixing_matrix_e, lengthCy, lengthCx, 1, Cy_tilde_fx, &Cy_tilde_e ); /*-----------------------------------------------------------------* @@ -2697,6 +2622,7 @@ Word16 computeMixingMatricesISM_fx( Word32 svd_u_buffer_fx[MAX_OUTPUT_CHANNELS][MAX_OUTPUT_CHANNELS]; Word32 svd_s_buffer_fx[MAX_OUTPUT_CHANNELS]; Word16 svd_s_buffer_fx_e; + Word16 svd_s_buffer_e[MAX_OUTPUT_CHANNELS]; Word32 svd_v_buffer_fx[MAX_OUTPUT_CHANNELS][MAX_OUTPUT_CHANNELS]; Word16 temp_e[MAX_OUTPUT_CHANNELS]; @@ -2921,7 +2847,7 @@ Word16 computeMixingMatricesISM_fx( move16(); nC = lengthCx; move16(); - svd_fx( svd_in_buffer_fx, mat_mult_buffer1_e, svd_v_buffer_fx, svd_s_buffer_fx, svd_u_buffer_fx, &svd_s_buffer_fx_e, nL, nC ); + svd_fx( svd_in_buffer_fx, mat_mult_buffer1_e, svd_v_buffer_fx, svd_s_buffer_fx, svd_u_buffer_fx, svd_s_buffer_e, nL, nC ); } ELSE { @@ -2931,7 +2857,7 @@ Word16 computeMixingMatricesISM_fx( move16(); nC = num_responses; move16(); - svd_fx( svd_in_buffer_fx, mat_mult_buffer1_e, svd_u_buffer_fx, svd_s_buffer_fx, svd_v_buffer_fx, &svd_s_buffer_fx_e, nL, nC ); + svd_fx( svd_in_buffer_fx, mat_mult_buffer1_e, svd_u_buffer_fx, svd_s_buffer_fx, svd_v_buffer_fx, svd_s_buffer_e, nL, nC ); } /* Actually Processing P */ diff --git a/lib_dec/ivas_svd_dec.c b/lib_dec/ivas_svd_dec.c index 6a07d026c..b0d163e69 100644 --- a/lib_dec/ivas_svd_dec.c +++ b/lib_dec/ivas_svd_dec.c @@ -97,7 +97,7 @@ static void HouseholderReduction_fx( Word32 singularVectors_Right_fx[][MAX_OUTPUT_CHANNELS], Word32 secDiag_fx[MAX_OUTPUT_CHANNELS], Word16 singularVectors_Left_e, - Word16 *singularValues_fx_e, + Word16 singularValues_fx_e[MAX_OUTPUT_CHANNELS], Word16 *secDiag_fx_e, const int16_t nChannelsL, const int16_t nChannelsC, @@ -109,7 +109,7 @@ static void biDiagonalReductionLeft_fx( Word32 singularValues[MAX_OUTPUT_CHANNELS], Word32 secDiag[MAX_OUTPUT_CHANNELS], Word16 *singularVectors_e, - Word16 *singularValues_e, + Word16 singularValues_e[MAX_OUTPUT_CHANNELS], Word16 *secDiag_e, const Word16 nChannelsL, const Word16 nChannelsC, @@ -134,7 +134,7 @@ static void singularVectorsAccumulationLeft_fx( Word32 singularVectors_Left[][MAX_OUTPUT_CHANNELS], // Q31 output Word32 singularValues[MAX_OUTPUT_CHANNELS], Word16 singularVectors_e, - Word16 singularValues_e, + Word16 singularValues_e[MAX_OUTPUT_CHANNELS], const Word16 nChannelsL, const Word16 nChannelsC ); @@ -165,7 +165,7 @@ static Word16 BidagonalDiagonalisation_fx( Word32 singularValues_fx[MAX_OUTPUT_CHANNELS], /* i/o: singular values vector (S) */ Word32 singularVectors_Right_fx[][MAX_OUTPUT_CHANNELS], /* i/o: right singular vectors (V) Q31 */ Word32 secDiag_fx[MAX_OUTPUT_CHANNELS], /* i/o: */ - Word16 *singularValues_fx_e, /* i/o: singular values vector (S) */ + Word16 singularValues_fx_e[MAX_OUTPUT_CHANNELS], /* i/o: singular values vector (S) */ Word16 *secDiag_fx_e, /* i/o: */ const Word16 nChannelsL, /* i : number of rows in the matrix to be decomposed */ const Word16 nChannelsC, /* i : number of columns in the matrix to be decomposed */ @@ -396,7 +396,7 @@ Word16 svd_fx( Word32 singularVectors_Left_fx[][MAX_OUTPUT_CHANNELS], /* o : left singular vectors (U) (Q31) */ Word32 singularValues_fx[MAX_OUTPUT_CHANNELS], /* o : singular values vector (S) */ Word32 singularVectors_Right_fx[][MAX_OUTPUT_CHANNELS], /* o : right singular vectors (V) (Q31) */ - Word16 *singularValues_fx_e, + Word16 singularValues_fx_e[MAX_OUTPUT_CHANNELS], const Word16 nChannelsL, /* i : number of rows in the matrix to be decomposed */ const Word16 nChannelsC /* i : number of columns in the matrix to be decomposed */ ) @@ -412,6 +412,7 @@ Word16 svd_fx( move16(); Word16 eps_x_fx_e = 0; move16(); + Word16 temp_fx_e; push_wmops( "svd_fx" ); set32_fx( secDiag_fx, 0, MAX_OUTPUT_CHANNELS ); @@ -426,8 +427,7 @@ Word16 svd_fx( } } - *singularValues_fx_e = 0; - move16(); + set16_fx( singularValues_fx_e, 0, MAX_OUTPUT_CHANNELS ); /* Householder reduction */ HouseholderReduction_fx( singularVectors_Left_fx, singularValues_fx, singularVectors_Right_fx, secDiag_fx, InputMatrix_e, singularValues_fx_e, &secDiag_fx_e, nChannelsL, nChannelsC, &eps_x_fx, &eps_x_fx_e ); @@ -449,7 +449,7 @@ Word16 svd_fx( move16(); FOR( iCh = 0; iCh < sub( lengthSingularValues, 1 ); iCh++ ) { - IF( LT_32( singularValues_fx[iCh], singularValues_fx[iCh + 1] ) ) + IF( BASOP_Util_Cmp_Mant32Exp( singularValues_fx[iCh], singularValues_fx_e[iCh], singularValues_fx[iCh + 1], singularValues_fx_e[iCh + 1] ) < 0 ) { condition = 1; move16(); @@ -459,6 +459,12 @@ Word16 svd_fx( move32(); singularValues_fx[iCh + 1] = temp_fx; move32(); + temp_fx_e = singularValues_fx_e[iCh]; + move16(); + singularValues_fx_e[iCh] = singularValues_fx_e[iCh + 1]; + move16(); + singularValues_fx_e[iCh + 1] = temp_fx_e; + move16(); FOR( jCh = 0; jCh < nChannelsL; ++jCh ) { @@ -583,7 +589,7 @@ static Word16 BidagonalDiagonalisation_fx( Word32 singularValues_fx[MAX_OUTPUT_CHANNELS], /* i/o: singular values vector (S) */ Word32 singularVectors_Right_fx[][MAX_OUTPUT_CHANNELS], /* i/o: right singular vectors (V) Q31 */ Word32 secDiag_fx[MAX_OUTPUT_CHANNELS], /* i/o: */ - Word16 *singularValues_fx_e, /* i/o: singular values vector (S) */ + Word16 singularValues_fx_e[MAX_OUTPUT_CHANNELS], /* i/o: singular values vector (S) */ Word16 *secDiag_fx_e, /* i/o: */ const Word16 nChannelsL, /* i : number of rows in the matrix to be decomposed */ const Word16 nChannelsC, /* i : number of columns in the matrix to be decomposed */ @@ -606,7 +612,7 @@ static Word16 BidagonalDiagonalisation_fx( Word16 error = 0; move16(); Word16 singularValues_new_e[MAX_OUTPUT_CHANNELS], secDiag_new_e[MAX_OUTPUT_CHANNELS]; - set16_fx( singularValues_new_e, *singularValues_fx_e, MAX_OUTPUT_CHANNELS ); + Copy( singularValues_fx_e, singularValues_new_e, MAX_OUTPUT_CHANNELS ); set16_fx( secDiag_new_e, *secDiag_fx_e, MAX_OUTPUT_CHANNELS ); FOR( iCh = nChannelsC - 1; iCh >= 0; iCh-- ) /* nChannelsC */ @@ -745,24 +751,9 @@ static Word16 BidagonalDiagonalisation_fx( } // rescaling block - Word16 max_exp = -31; - move16(); - FOR( iCh = 0; iCh < nChannelsC; iCh++ ) - { - if ( singularValues_fx[iCh] ) - { - max_exp = s_max( max_exp, singularValues_new_e[iCh] ); - } - } - *singularValues_fx_e = max_exp; - move16(); - FOR( iCh = 0; iCh < nChannelsC; iCh++ ) - { - singularValues_fx[iCh] = L_shr_r( singularValues_fx[iCh], sub( *singularValues_fx_e, singularValues_new_e[iCh] ) ); - move32(); - } + Copy( singularValues_new_e, singularValues_fx_e, MAX_OUTPUT_CHANNELS ); - max_exp = -31; + Word16 max_exp = -31; move16(); FOR( iCh = 0; iCh < nChannelsC; iCh++ ) { @@ -1245,7 +1236,7 @@ static void HouseholderReduction_fx( Word32 singularVectors_Right_fx[][MAX_OUTPUT_CHANNELS], Word32 secDiag_fx[MAX_OUTPUT_CHANNELS], Word16 singularVectors_Left_e, - Word16 *singularValues_fx_e, + Word16 singularValues_fx_e[MAX_OUTPUT_CHANNELS], Word16 *secDiag_fx_e, const Word16 nChannelsL, const Word16 nChannelsC, @@ -1267,7 +1258,7 @@ static void HouseholderReduction_fx( biDiagonalReductionRight_fx( singularVectors_Left_fx, secDiag_fx, &singularVectors_Left_e, secDiag_fx_e, nChannelsL, nChannelsC, nCh, &sig_x_fx, &sig_x_fx_e, &g_fx ); Word16 L_temp_e; - Word32 L_temp = BASOP_Util_Add_Mant32Exp( L_abs( singularValues_fx[nCh] ), *singularValues_fx_e, L_abs( secDiag_fx[nCh] ), *secDiag_fx_e, &L_temp_e ); + Word32 L_temp = BASOP_Util_Add_Mant32Exp( L_abs( singularValues_fx[nCh] ), singularValues_fx_e[nCh], L_abs( secDiag_fx[nCh] ), *secDiag_fx_e, &L_temp_e ); IF( EQ_16( BASOP_Util_Cmp_Mant32Exp( L_temp, L_temp_e, *eps_x_fx, *eps_x_fx_e ), 1 ) ) { *eps_x_fx = L_temp; @@ -1280,7 +1271,7 @@ static void HouseholderReduction_fx( /* SingularVecotr Accumulation */ singularVectorsAccumulationRight_fx( singularVectors_Left_fx, singularVectors_Right_fx, secDiag_fx, singularVectors_Left_e, *secDiag_fx_e, nChannelsC ); - singularVectorsAccumulationLeft_fx( singularVectors_Left_fx, singularValues_fx, singularVectors_Left_e, *singularValues_fx_e, nChannelsL, nChannelsC ); + singularVectorsAccumulationLeft_fx( singularVectors_Left_fx, singularValues_fx, singularVectors_Left_e, singularValues_fx_e, nChannelsL, nChannelsC ); return; } @@ -1325,7 +1316,7 @@ static void biDiagonalReductionLeft_fx( Word32 singularValues[MAX_OUTPUT_CHANNELS], Word32 secDiag[MAX_OUTPUT_CHANNELS], Word16 *singularVectors_e, - Word16 *singularValues_e, + Word16 singularValues_e[MAX_OUTPUT_CHANNELS], Word16 *secDiag_e, const Word16 nChannelsL, const Word16 nChannelsC, @@ -1483,22 +1474,8 @@ IF( LT_16( currChannel, nChannelsL ) ) /* i <= m */ // rescaling block singularValues[currChannel] = Mpy_32_32( ( *sig_x ), ( *g ) ); move32(); - IF( GT_16( *sig_x_e, *singularValues_e ) ) - { - FOR( Word16 i = 0; i < MAX_OUTPUT_CHANNELS; i++ ){ - IF( NE_16( i, currChannel ) ){ - singularValues[i] = L_shl( singularValues[i], sub( *singularValues_e, *sig_x_e ) ); - move32(); - } -} -*singularValues_e = *sig_x_e; -move16(); -} -ELSE IF( LT_16( *sig_x_e, *singularValues_e ) ) -{ - singularValues[currChannel] = L_shr_r( singularValues[currChannel], sub( *singularValues_e, *sig_x_e ) ); - move32(); -} + singularValues_e[currChannel] = *sig_x_e; + move16(); } return; @@ -1818,7 +1795,7 @@ static void singularVectorsAccumulationLeft_fx( Word32 singularVectors_Left[][MAX_OUTPUT_CHANNELS], // Q31 output Word32 singularValues[MAX_OUTPUT_CHANNELS], Word16 singularVectors_e, - Word16 singularValues_e, + Word16 singularValues_e[MAX_OUTPUT_CHANNELS], const Word16 nChannelsL, const Word16 nChannelsC ) { @@ -1839,7 +1816,7 @@ static void singularVectorsAccumulationLeft_fx( { t_ii = singularValues[nCh]; move32(); - t_ii_e = singularValues_e; + t_ii_e = singularValues_e[nCh]; move16(); FOR( iCh = nCh + 1; iCh < nChannelsC; iCh++ ) /* nChannelsC */ diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index 22465911a..4ddf64c89 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -1530,7 +1530,7 @@ static ivas_error getMcConfigValues_fx( { case IVAS_AUDIO_CONFIG_LS_CUSTOM: *azimuth = (const Word32 *) &pInCustomLs->ls_azimuth_fx; - *elevation = (const Word32 *) &pInCustomLs->ls_azimuth_fx; + *elevation = (const Word32 *) &pInCustomLs->ls_elevation_fx; IF( pInCustomLs->num_lfe > 0 ) { *lfe_idx = pInCustomLs->lfe_idx[0]; -- GitLab