Loading lib_rend/ivas_dirac_dec_binaural_functions.c +28 −0 Original line number Diff line number Diff line Loading @@ -1639,6 +1639,7 @@ static void ivas_dirac_dec_binaural_internal_fx( st_ivas->cldfbSynDec[ch]->Q_cldfb_state = Q11; move16(); } return; } #endif Loading Loading @@ -2388,6 +2389,7 @@ static void ivas_dirac_dec_binaural_formulate_input_and_target_covariance_matric move32(); } } /* Apply EQ at low bit rates */ IF( applyLowBitRateEQ != 0 ) { Loading @@ -2404,6 +2406,7 @@ static void ivas_dirac_dec_binaural_formulate_input_and_target_covariance_matric move32(); } } test(); test(); IF( ( EQ_32( ivas_format, SBA_FORMAT ) || EQ_32( ivas_format, SBA_ISM_FORMAT ) ) && EQ_16( nchan_transport, 2 ) ) Loading Loading @@ -2439,6 +2442,7 @@ static void ivas_dirac_dec_binaural_formulate_input_and_target_covariance_matric } } } /* Determine target covariance matrix containing target binaural properties */ FOR( bin = 0; bin < nBins; bin++ ) { Loading Loading @@ -2534,6 +2538,7 @@ static void ivas_dirac_dec_binaural_formulate_input_and_target_covariance_matric move16(); gainCacheBaseIndex = add( 6, ismDirIndex ); } diffuseness_fx = L_sub( diffuseness_fx, ratio_fx ); /* diffuseness = 1 - ratio1 - ratio2 */ if ( diffuseness_fx < 0 ) Loading Loading @@ -2578,7 +2583,9 @@ static void ivas_dirac_dec_binaural_formulate_input_and_target_covariance_matric altSpreadCoh_fx = sub( 32767, shl_sat( div_s( numr, denr ), sub( den_e, num_e ) ) ); // 4289 = pi/6 in Q13 spreadCoh_fx = s_max( spreadCoh_fx, altSpreadCoh_fx ); } getDirectPartGains_fx( bin, aziDeg, eleDeg, &lRealp_fx, &lImagp_fx, &rRealp_fx, &rImagp_fx, hDiracDecBin->renderStereoOutputInsteadOfBinaural, Rmat_fx, &gainCache[gainCacheBaseIndex], isHeadtracked ); Word16 q_lr = Q28; move16(); if ( hDiracDecBin->renderStereoOutputInsteadOfBinaural ) Loading @@ -2588,6 +2595,7 @@ static void ivas_dirac_dec_binaural_formulate_input_and_target_covariance_matric spreadCoh_fx = 0; move32(); } IF( spreadCoh_fx > 0 ) { Word32 centerMul_fx, sidesMul_fx; Loading Loading @@ -2640,6 +2648,7 @@ static void ivas_dirac_dec_binaural_formulate_input_and_target_covariance_matric /* Apply the gain for the right source of the three coherent sources. * -30 degrees to 330 wrapping due to internal functions. */ getDirectPartGains_fx( bin, aziDeg + 330, eleDeg, &lRealpTmp_fx, &lImagpTmp_fx, &rRealpTmp_fx, &rImagpTmp_fx, hDiracDecBin->renderStereoOutputInsteadOfBinaural, Rmat_fx, &gainCache[gainCacheBaseIndex + 2], isHeadtracked ); hrtfEneSides_fx = L_add( hrtfEneSides_fx, Loading @@ -2661,6 +2670,7 @@ static void ivas_dirac_dec_binaural_formulate_input_and_target_covariance_matric eneCorrectionFactor_fx = BASOP_Util_Divide3232_Scale( L_add( Mpy_32_32( hrtfEneSides_fx, Mpy_32_32( sidesMul_fx, sidesMul_fx ) ), Mpy_32_32( hrtfEneCenter_fx, Mpy_32_32( centerMul_fx, centerMul_fx ) ) ), L_max( 1, hrtfEneRealized_fx ), &eneCorrectionFactor_e ); /* Weighting factors to determine appropriate target spectrum for spread coherent sound */ IF( LT_16( spreadCoh_fx, 16384 ) ) { Loading Loading @@ -2717,6 +2727,7 @@ static void ivas_dirac_dec_binaural_formulate_input_and_target_covariance_matric q_lr = Q23; move16(); } hrtfEne_fx[0] = L_add( Mpy_32_32( lRealp_fx, lRealp_fx ), Mpy_32_32( lImagp_fx, lImagp_fx ) ); // Q( 2*q_lr - 31 ) hrtfEne_fx[1] = L_add( Mpy_32_32( rRealp_fx, rRealp_fx ), Mpy_32_32( rImagp_fx, rImagp_fx ) ); // Q( 2*q_lr - 31 ) move32(); Loading Loading @@ -2801,6 +2812,7 @@ static void ivas_dirac_dec_binaural_formulate_input_and_target_covariance_matric } move32(); } /* Store parameters for formulating average diffuseness over frame */ Word32 frameMeanDiffuseness = BASOP_Util_Add_Mant32Exp( hDiracDecBin->frameMeanDiffuseness_fx[bin], 2 /*Q29*/, diffEneValForDecorrelationReduction_fx, sub( 31, q_diffEneValForDecorrelationReduction ), &exp1 ); // exp = exp1 frameMeanDiffusenessEneWeight_fx[bin] = L_add( frameMeanDiffusenessEneWeight_fx[bin], meanEnePerCh_fx ); Loading @@ -2812,6 +2824,7 @@ static void ivas_dirac_dec_binaural_formulate_input_and_target_covariance_matric hDiracDecBin->frameMeanDiffuseness_fx[bin] = L_shl( frameMeanDiffuseness, sub( exp, 2 ) ); // Q29 move32(); } test(); /* Temporal IIR-type smoothing of covariance matrices. Also apply encoding quality based smoothing factor. */ IF( EQ_32( ivas_format, MASA_FORMAT ) && LT_32( ivas_total_brate, MASA_STEREO_MIN_BITRATE ) ) Loading Loading @@ -2914,6 +2927,7 @@ static void ivas_dirac_dec_binaural_formulate_input_and_target_covariance_matric move16(); } } return; } #endif Loading Loading @@ -3145,6 +3159,7 @@ static void ivas_dirac_dec_binaural_determine_processing_matrices( } } } return; } #else Loading Loading @@ -3289,6 +3304,7 @@ static void ivas_dirac_dec_binaural_determine_processing_matrices_fx( } move32(); move16(); formulate2x2MixingMatrix_fx( hDiracDecBin->ChEne_fx[0][bin], hDiracDecBin->ChEne_fx[1][bin], hDiracDecBin->q_ChEne, hDiracDecBin->ChCrossRe_fx[bin], hDiracDecBin->ChCrossIm_fx[bin], Loading Loading @@ -3698,6 +3714,7 @@ static void ivas_dirac_dec_binaural_determine_processing_matrices_fx( move16(); minimum_s( q_processMtxDec, nBins, &hDiracDecBin->q_processMtxDec ); minimum_s( q_processMtxDecPrev, nBins, &hDiracDecBin->q_processMtxDecPrev ); FOR( bin = 0; bin < nBins; bin++ ) { FOR( chA = 0; chA < BINAURAL_CHANNELS; chA++ ) Loading Loading @@ -3737,6 +3754,7 @@ static void ivas_dirac_dec_binaural_determine_processing_matrices_fx( } } } return; } #endif Loading Loading @@ -5069,6 +5087,7 @@ static void eig2x2_fx( move32(); *q_U = Q31; move16(); return; } Loading @@ -5085,6 +5104,7 @@ static void eig2x2_fx( move32(); *q_U = Q30; move16(); return; } } Loading @@ -5098,9 +5118,11 @@ static void eig2x2_fx( move32(); *q_U = Q30; move16(); return; } } q_U_1 = 0; q_U_2 = 0; move16(); Loading Loading @@ -5137,6 +5159,7 @@ static void eig2x2_fx( q_tmp2 = sub( 31, q_tmp2 ); tmp3 = BASOP_Util_Add_Mant32Exp( tmp2, sub( 31, q_tmp2 ), epsilon_mant, epsilon_exp, &exp_tmp3 ); #if !defined( FIX_1009_REPLACE_DIV_SQRT_BY_ISQRT_LC ) || 1 tmp2 = BASOP_Util_Divide3232_Scale_cadence( ONE_IN_Q30, tmp3, &exp ); exp = sub( exp, sub( Q30, sub( 31, exp_tmp3 ) ) ); Loading @@ -5148,6 +5171,7 @@ static void eig2x2_fx( normVal_fx = ISqrt32( tmp3, &exp ); q_tmp2 = sub( 31, exp ); #endif IF( LT_16( q_tmp1, q_c ) ) { c_re = L_shr( c_re, sub( q_c, q_tmp1 ) ); Loading Loading @@ -5271,6 +5295,7 @@ static void eig2x2_fx( move16(); } } IF( q_U_1 != 0 ) *q_U = q_U_1; ELSE Loading Loading @@ -6150,6 +6175,7 @@ static void formulate2x2MixingMatrix_fx( /* Cholesky decomposition of target / output covariance matrix */ chol2x2_fx( E_out1, E_out2, q_eout, Cout_re, Cout_im, q_cout, KyRe_fx, KyIm_fx, &q_ky ); /* Eigendecomposition of input covariance matrix */ eig2x2_fx( E_in1, E_in2, q_ein, Cin_re, Cin_im, q_cin, Uxre_fx, Uxim_fx, &q_Ux, Sx_fx, &q_Sx ); Loading Loading @@ -6403,6 +6429,7 @@ static void formulate2x2MixingMatrix_fx( } 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 */ /* These are the final formulas of the JAES publication M = Ky P Kx^(-1) */ #if ( BINAURAL_CHANNELS != 2 ) FOR( chA = 0; chA < BINAURAL_CHANNELS; chA++ ) Loading Loading @@ -6540,6 +6567,7 @@ static void formulate2x2MixingMatrix_fx( } matrixMul_fx( KyRe_fx, KyIm_fx, &q_ky, Pre_fx, Pim_fx, &q_P, 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 ); return; Loading Loading
lib_rend/ivas_dirac_dec_binaural_functions.c +28 −0 Original line number Diff line number Diff line Loading @@ -1639,6 +1639,7 @@ static void ivas_dirac_dec_binaural_internal_fx( st_ivas->cldfbSynDec[ch]->Q_cldfb_state = Q11; move16(); } return; } #endif Loading Loading @@ -2388,6 +2389,7 @@ static void ivas_dirac_dec_binaural_formulate_input_and_target_covariance_matric move32(); } } /* Apply EQ at low bit rates */ IF( applyLowBitRateEQ != 0 ) { Loading @@ -2404,6 +2406,7 @@ static void ivas_dirac_dec_binaural_formulate_input_and_target_covariance_matric move32(); } } test(); test(); IF( ( EQ_32( ivas_format, SBA_FORMAT ) || EQ_32( ivas_format, SBA_ISM_FORMAT ) ) && EQ_16( nchan_transport, 2 ) ) Loading Loading @@ -2439,6 +2442,7 @@ static void ivas_dirac_dec_binaural_formulate_input_and_target_covariance_matric } } } /* Determine target covariance matrix containing target binaural properties */ FOR( bin = 0; bin < nBins; bin++ ) { Loading Loading @@ -2534,6 +2538,7 @@ static void ivas_dirac_dec_binaural_formulate_input_and_target_covariance_matric move16(); gainCacheBaseIndex = add( 6, ismDirIndex ); } diffuseness_fx = L_sub( diffuseness_fx, ratio_fx ); /* diffuseness = 1 - ratio1 - ratio2 */ if ( diffuseness_fx < 0 ) Loading Loading @@ -2578,7 +2583,9 @@ static void ivas_dirac_dec_binaural_formulate_input_and_target_covariance_matric altSpreadCoh_fx = sub( 32767, shl_sat( div_s( numr, denr ), sub( den_e, num_e ) ) ); // 4289 = pi/6 in Q13 spreadCoh_fx = s_max( spreadCoh_fx, altSpreadCoh_fx ); } getDirectPartGains_fx( bin, aziDeg, eleDeg, &lRealp_fx, &lImagp_fx, &rRealp_fx, &rImagp_fx, hDiracDecBin->renderStereoOutputInsteadOfBinaural, Rmat_fx, &gainCache[gainCacheBaseIndex], isHeadtracked ); Word16 q_lr = Q28; move16(); if ( hDiracDecBin->renderStereoOutputInsteadOfBinaural ) Loading @@ -2588,6 +2595,7 @@ static void ivas_dirac_dec_binaural_formulate_input_and_target_covariance_matric spreadCoh_fx = 0; move32(); } IF( spreadCoh_fx > 0 ) { Word32 centerMul_fx, sidesMul_fx; Loading Loading @@ -2640,6 +2648,7 @@ static void ivas_dirac_dec_binaural_formulate_input_and_target_covariance_matric /* Apply the gain for the right source of the three coherent sources. * -30 degrees to 330 wrapping due to internal functions. */ getDirectPartGains_fx( bin, aziDeg + 330, eleDeg, &lRealpTmp_fx, &lImagpTmp_fx, &rRealpTmp_fx, &rImagpTmp_fx, hDiracDecBin->renderStereoOutputInsteadOfBinaural, Rmat_fx, &gainCache[gainCacheBaseIndex + 2], isHeadtracked ); hrtfEneSides_fx = L_add( hrtfEneSides_fx, Loading @@ -2661,6 +2670,7 @@ static void ivas_dirac_dec_binaural_formulate_input_and_target_covariance_matric eneCorrectionFactor_fx = BASOP_Util_Divide3232_Scale( L_add( Mpy_32_32( hrtfEneSides_fx, Mpy_32_32( sidesMul_fx, sidesMul_fx ) ), Mpy_32_32( hrtfEneCenter_fx, Mpy_32_32( centerMul_fx, centerMul_fx ) ) ), L_max( 1, hrtfEneRealized_fx ), &eneCorrectionFactor_e ); /* Weighting factors to determine appropriate target spectrum for spread coherent sound */ IF( LT_16( spreadCoh_fx, 16384 ) ) { Loading Loading @@ -2717,6 +2727,7 @@ static void ivas_dirac_dec_binaural_formulate_input_and_target_covariance_matric q_lr = Q23; move16(); } hrtfEne_fx[0] = L_add( Mpy_32_32( lRealp_fx, lRealp_fx ), Mpy_32_32( lImagp_fx, lImagp_fx ) ); // Q( 2*q_lr - 31 ) hrtfEne_fx[1] = L_add( Mpy_32_32( rRealp_fx, rRealp_fx ), Mpy_32_32( rImagp_fx, rImagp_fx ) ); // Q( 2*q_lr - 31 ) move32(); Loading Loading @@ -2801,6 +2812,7 @@ static void ivas_dirac_dec_binaural_formulate_input_and_target_covariance_matric } move32(); } /* Store parameters for formulating average diffuseness over frame */ Word32 frameMeanDiffuseness = BASOP_Util_Add_Mant32Exp( hDiracDecBin->frameMeanDiffuseness_fx[bin], 2 /*Q29*/, diffEneValForDecorrelationReduction_fx, sub( 31, q_diffEneValForDecorrelationReduction ), &exp1 ); // exp = exp1 frameMeanDiffusenessEneWeight_fx[bin] = L_add( frameMeanDiffusenessEneWeight_fx[bin], meanEnePerCh_fx ); Loading @@ -2812,6 +2824,7 @@ static void ivas_dirac_dec_binaural_formulate_input_and_target_covariance_matric hDiracDecBin->frameMeanDiffuseness_fx[bin] = L_shl( frameMeanDiffuseness, sub( exp, 2 ) ); // Q29 move32(); } test(); /* Temporal IIR-type smoothing of covariance matrices. Also apply encoding quality based smoothing factor. */ IF( EQ_32( ivas_format, MASA_FORMAT ) && LT_32( ivas_total_brate, MASA_STEREO_MIN_BITRATE ) ) Loading Loading @@ -2914,6 +2927,7 @@ static void ivas_dirac_dec_binaural_formulate_input_and_target_covariance_matric move16(); } } return; } #endif Loading Loading @@ -3145,6 +3159,7 @@ static void ivas_dirac_dec_binaural_determine_processing_matrices( } } } return; } #else Loading Loading @@ -3289,6 +3304,7 @@ static void ivas_dirac_dec_binaural_determine_processing_matrices_fx( } move32(); move16(); formulate2x2MixingMatrix_fx( hDiracDecBin->ChEne_fx[0][bin], hDiracDecBin->ChEne_fx[1][bin], hDiracDecBin->q_ChEne, hDiracDecBin->ChCrossRe_fx[bin], hDiracDecBin->ChCrossIm_fx[bin], Loading Loading @@ -3698,6 +3714,7 @@ static void ivas_dirac_dec_binaural_determine_processing_matrices_fx( move16(); minimum_s( q_processMtxDec, nBins, &hDiracDecBin->q_processMtxDec ); minimum_s( q_processMtxDecPrev, nBins, &hDiracDecBin->q_processMtxDecPrev ); FOR( bin = 0; bin < nBins; bin++ ) { FOR( chA = 0; chA < BINAURAL_CHANNELS; chA++ ) Loading Loading @@ -3737,6 +3754,7 @@ static void ivas_dirac_dec_binaural_determine_processing_matrices_fx( } } } return; } #endif Loading Loading @@ -5069,6 +5087,7 @@ static void eig2x2_fx( move32(); *q_U = Q31; move16(); return; } Loading @@ -5085,6 +5104,7 @@ static void eig2x2_fx( move32(); *q_U = Q30; move16(); return; } } Loading @@ -5098,9 +5118,11 @@ static void eig2x2_fx( move32(); *q_U = Q30; move16(); return; } } q_U_1 = 0; q_U_2 = 0; move16(); Loading Loading @@ -5137,6 +5159,7 @@ static void eig2x2_fx( q_tmp2 = sub( 31, q_tmp2 ); tmp3 = BASOP_Util_Add_Mant32Exp( tmp2, sub( 31, q_tmp2 ), epsilon_mant, epsilon_exp, &exp_tmp3 ); #if !defined( FIX_1009_REPLACE_DIV_SQRT_BY_ISQRT_LC ) || 1 tmp2 = BASOP_Util_Divide3232_Scale_cadence( ONE_IN_Q30, tmp3, &exp ); exp = sub( exp, sub( Q30, sub( 31, exp_tmp3 ) ) ); Loading @@ -5148,6 +5171,7 @@ static void eig2x2_fx( normVal_fx = ISqrt32( tmp3, &exp ); q_tmp2 = sub( 31, exp ); #endif IF( LT_16( q_tmp1, q_c ) ) { c_re = L_shr( c_re, sub( q_c, q_tmp1 ) ); Loading Loading @@ -5271,6 +5295,7 @@ static void eig2x2_fx( move16(); } } IF( q_U_1 != 0 ) *q_U = q_U_1; ELSE Loading Loading @@ -6150,6 +6175,7 @@ static void formulate2x2MixingMatrix_fx( /* Cholesky decomposition of target / output covariance matrix */ chol2x2_fx( E_out1, E_out2, q_eout, Cout_re, Cout_im, q_cout, KyRe_fx, KyIm_fx, &q_ky ); /* Eigendecomposition of input covariance matrix */ eig2x2_fx( E_in1, E_in2, q_ein, Cin_re, Cin_im, q_cin, Uxre_fx, Uxim_fx, &q_Ux, Sx_fx, &q_Sx ); Loading Loading @@ -6403,6 +6429,7 @@ static void formulate2x2MixingMatrix_fx( } 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 */ /* These are the final formulas of the JAES publication M = Ky P Kx^(-1) */ #if ( BINAURAL_CHANNELS != 2 ) FOR( chA = 0; chA < BINAURAL_CHANNELS; chA++ ) Loading Loading @@ -6540,6 +6567,7 @@ static void formulate2x2MixingMatrix_fx( } matrixMul_fx( KyRe_fx, KyIm_fx, &q_ky, Pre_fx, Pim_fx, &q_P, 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 ); return; Loading