Commit 27cec6e8 authored by Fabian Bauer's avatar Fabian Bauer
Browse files

fix: rename some mocros

Cleanup: push/pop wmops
parent 8cc9439e
Loading
Loading
Loading
Loading
Loading
+6 −61
Original line number Diff line number Diff line
@@ -45,8 +45,6 @@

#include "wmc_auto.h"

// MHZ NUMBERS:

Word16 slot_fx[4] = { 32767, 16384, 10922, 8192 };

/*-------------------------------------------------------------------------
@@ -506,9 +504,8 @@ void ivas_dirac_dec_binaural_render_fx(
    FOR( subframe_idx = first_sf; subframe_idx < last_sf; subframe_idx++ )
    {
        Word16 n_samples_sf = imult1616( slot_size, hSpatParamRendCom->subframe_nbslots[subframe_idx] );
        push_wmops( "IDR binaural internal (IDRBI)" );
        ivas_dirac_dec_binaural_internal_fx( st_ivas, st_ivas->hCombinedOrientationData, output_fx_local, nchan_transport, subframe_idx );
        pop_wmops(); /*push_wmops( "IDR binaural internal (IDRBI)" );*/

        FOR( ch = 0; ch < nchan_out; ch++ )
        {
            output_fx_local[ch] += n_samples_sf;
@@ -711,7 +708,6 @@ static void ivas_dirac_dec_binaural_internal_fx(
        }
    }
    /* CLDFB Analysis of input */
    push_wmops( "IDRBI CLDFB ANALYSYS" );
    FOR( slot = 0; slot < hSpatParamRendCom->subframe_nbslots[subframe]; slot++ )
    {
        FOR( ch = 0; ch < numInChannels; ch++ )
@@ -861,7 +857,6 @@ static void ivas_dirac_dec_binaural_internal_fx(
            }
        }
    }
    pop_wmops(); /*push_wmops( "IDRBI CLDFB ANALYSYS" );*/

    test();
    IF( EQ_32( config_data.ivas_format, SBA_FORMAT ) || EQ_32( config_data.ivas_format, SBA_ISM_FORMAT ) )
@@ -926,9 +921,7 @@ static void ivas_dirac_dec_binaural_internal_fx(
    }

    test();
    push_wmops( "IDRBI cov matrices (IDRBCM)" );
    ivas_dirac_dec_binaural_formulate_input_and_target_covariance_matrices_fx( hDiracDecBin, hSpatParamRendCom, &config_data, Cldfb_RealBuffer_in_fx, Cldfb_ImagBuffer_in_fx, Rmat_fx, subframe, hCombinedOrientationData && hCombinedOrientationData->enableCombinedOrientation[hCombinedOrientationData->subframe_idx] > 0, st_ivas->hMasaIsmData, q_inp );
    pop_wmops(); /*push_wmops( "IDRBI cov matrices (IDRBCM)" );*/

    IF( EQ_32( config_data.ivas_format, ISM_FORMAT ) )
    {
@@ -966,9 +959,7 @@ static void ivas_dirac_dec_binaural_internal_fx(
        move16();
    }

    push_wmops( "IDRBI proc matrices (IRDBI pm)" );
    ivas_dirac_dec_binaural_determine_processing_matrices_fx( hDiracDecBin, hSpatParamRendCom, &config_data, max_band_decorr, Rmat_fx, subframe, hCombinedOrientationData && hCombinedOrientationData->enableCombinedOrientation[hCombinedOrientationData->subframe_idx] > 0, nchanSeparateChannels, st_ivas->hMasaIsmData );
    pop_wmops(); /*push_wmops( "IDRBI proc matrices (IRDBI pm)" );*/

    q_inp = Q6;
    move16();
@@ -1014,10 +1005,8 @@ static void ivas_dirac_dec_binaural_internal_fx(
    hDiracDecBin->q_processMtxDecPrev = q_mat;
    move16();

    push_wmops( "IDRBI processOutput" );
    ivas_dirac_dec_binaural_process_output_fx( hDiracDecBin, hSpatParamRendCom, st_ivas->cldfbSynDec, output_fx, &q_out, Cldfb_RealBuffer_in_fx, Cldfb_ImagBuffer_in_fx, q_inp, max_band_decorr, numInChannels, config_data.processReverb, subframe, q_mat );
    pop_wmops(); /*push_wmops( "IDRBI processOutput" );
                  */

    hDiracDecBin->hDiffuseDist = NULL;

    hSpatParamRendCom->slots_rendered = add( hSpatParamRendCom->slots_rendered, hSpatParamRendCom->subframe_nbslots[subframe] );
@@ -1151,7 +1140,7 @@ static void ivas_dirac_dec_binaural_formulate_input_and_target_covariance_matric

    nBins = hSpatParamRendCom->num_freq_bands; /* Actually bins */
    move16();
    push_wmops( "IDRBCM inits" );

    q_earlyPartEneCorrection = s_min( Q31, add( getScaleFactor32( hDiracDecBin->earlyPartEneCorrection_fx, nBins ), hDiracDecBin->q_earlyPartEneCorrection ) );
    scale_sig32( hDiracDecBin->earlyPartEneCorrection_fx, nBins, sub( q_earlyPartEneCorrection, hDiracDecBin->q_earlyPartEneCorrection ) );
    hDiracDecBin->q_earlyPartEneCorrection = q_earlyPartEneCorrection;
@@ -1185,7 +1174,6 @@ static void ivas_dirac_dec_binaural_formulate_input_and_target_covariance_matric
        gainCache[idx].azi = -1000; /* Use -1000 as value for uninitialized cache. */
        move16();
    }
    pop_wmops(); /*push_wmops( "IDRBCM inits" );*/

    /* Determine EQ for low bit rates (13.2 and 16.4 kbps) */
    applyLowBitRateEQ = 0;
@@ -1198,13 +1186,11 @@ static void ivas_dirac_dec_binaural_formulate_input_and_target_covariance_matric
        move16();
        IF( EQ_32( ivas_total_brate, IVAS_16k4 ) )
        {
            push_wmops( "IDRBCM Determine EQ_low_rates" );
            FOR( bin = 0; bin < LOW_BIT_RATE_BINAURAL_EQ_BINS; bin++ )
            {
                lowBitRateEQ_fx[bin + LOW_BIT_RATE_BINAURAL_EQ_OFFSET] = L_add( L_shr( lowBitRateBinauralEQ_fx[bin], 1 ), ONE_IN_Q30 ); // Q31
                move32();
            }
            pop_wmops(); /*push_wmops( "IDRBCM Determine EQ_low_rates" );*/
        }
        ELSE
        {
@@ -1223,7 +1209,6 @@ static void ivas_dirac_dec_binaural_formulate_input_and_target_covariance_matric

    exp = sub( 63, shl( q, 1 ) ); // exp for the energy (inRe_fx * inRe_fx + inIm_fx * inIm_fx) computed below

    push_wmops( "IDRBCM input Matrix" );
    /* Calculate input covariance matrix */
    FOR( slot = 0; slot < hSpatParamRendCom->subframe_nbslots[subframe]; slot++ )
    {
@@ -1258,9 +1243,7 @@ static void ivas_dirac_dec_binaural_formulate_input_and_target_covariance_matric
            move32();
        }
    }
    pop_wmops(); /*push_wmops( "IDRBCM input Matrix" );*/

    push_wmops( "IDRBCM apply EQ_low" );
    /* Apply EQ at low bit rates */
    IF( applyLowBitRateEQ != 0 )
    {
@@ -1313,9 +1296,7 @@ static void ivas_dirac_dec_binaural_formulate_input_and_target_covariance_matric
            }
        }
    }
    pop_wmops(); /*push_wmops( "IDRBCM apply EQ_low" );*/

    push_wmops( "IDRBCM target matrix (IDRBCMtm)" );
    /* Determine target covariance matrix containing target binaural properties */
    FOR( bin = 0; bin < nBins; bin++ )
    {
@@ -1341,7 +1322,6 @@ static void ivas_dirac_dec_binaural_formulate_input_and_target_covariance_matric
        meanEnePerCh_fx = Mpy_32_32( hDiracDecBin->earlyPartEneCorrection_fx[bin], subFrameTotalEne_fx[bin] ); // Q( q_meanEnePerCh )
        q_meanEnePerCh = add( sub( q_earlyPartEneCorrection, subFrameTotalEne_e[bin] ), 1 );                   // q_earlyPartEneCorrection + 31 - subFrameTotalEne_e[bin] - 31 + Q1(0.5f)
        /* Determine direct part target covariance matrix (for 1 or 2 directions) */
        push_wmops( "IDRBCMtm LOOP1" );
        FOR( dirIndex = 0; dirIndex < hSpatParamRendCom->numSimultaneousDirections; dirIndex++ )
        {
            Word16 aziDeg, eleDeg;
@@ -1624,7 +1604,6 @@ static void ivas_dirac_dec_binaural_formulate_input_and_target_covariance_matric
            move32();
            move32();
        }
        pop_wmops(); // push_wmops( "IDRBCMtm LOOP1" );

        /* Add diffuse / ambient part covariance matrix */
        diffuseness_fx = L_max( 0, diffuseness_fx );               // Q30
@@ -1699,7 +1678,6 @@ static void ivas_dirac_dec_binaural_formulate_input_and_target_covariance_matric
        hDiracDecBin->frameMeanDiffuseness_fx[bin] = L_shl( frameMeanDiffuseness, sub( exp, 2 ) ); // Q29
        move32();
    }
    pop_wmops(); /*push_wmops( "IDRBCM target matrix (IDRBCMtm)" );;*/

    test();
    /* Temporal IIR-type smoothing of covariance matrices. Also apply encoding quality based smoothing factor. */
@@ -1865,7 +1843,6 @@ static void ivas_dirac_dec_binaural_determine_processing_matrices_fx(
        move16();
    }

    push_wmops( "IRDBI pm LOOP1 (IDRBI pm LOOP1)" );
    FOR( bin = 0; bin < nBins; bin++ )
    {
        Word32 tmpMtxRe_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], tmpMtxIm_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], resultMtxRe_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], resultMtxIm_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], gain_fx;
@@ -1889,7 +1866,6 @@ static void ivas_dirac_dec_binaural_determine_processing_matrices_fx(
        q_CrEne = Q31;
        move16();

        push_wmops( "IDRBI pm LOOP1 sec A (formulate2x2MixingMatrix)" );
        IF( GT_16( hDiracDecBin->ChEne_e[0][bin], hDiracDecBin->ChEne_e[1][bin] ) )
        {
            hDiracDecBin->ChEne_fx[1][bin] = L_shr( hDiracDecBin->ChEne_fx[1][bin], sub( hDiracDecBin->ChEne_e[0][bin], hDiracDecBin->ChEne_e[1][bin] ) );
@@ -1959,9 +1935,7 @@ static void ivas_dirac_dec_binaural_determine_processing_matrices_fx(
                                     hDiracDecBin->ChCrossReOut_fx[bin], hDiracDecBin->ChCrossImOut_fx[bin],
                                     hDiracDecBin->q_ChCrossOut,
                                     prototypeMtx_fx, Mre_fx, Mim_fx, &q_M, hDiracDecBin->reqularizationFactor_fx );
        pop_wmops(); /*push_wmops( "IDRBI pm LOOP1 sec A (formulate2x2MixingMatrix)" );*/

        push_wmops( "IDRBI pm LOOP1 sec B" );
        IF( LT_16( hDiracDecBin->q_ChEne, hDiracDecBin->q_ChCross ) )
        {
            CxRe_fx[0][0] = hDiracDecBin->ChEne_fx[0][bin];
@@ -2015,13 +1989,9 @@ static void ivas_dirac_dec_binaural_determine_processing_matrices_fx(
#endif
            resultMtxRe_fx, resultMtxIm_fx, &q_res );

        pop_wmops(); /*push_wmops( "IDRBI pm LOOP1 sec B" );*/

        /* 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
         * signal energy to synthesize a signal with the target covariance matrix from the non-decorrelated signals */

        push_wmops( "IDRBI pm LOOP1 sec C" );
        IF( LT_16( bin, max_band_decorr ) )
        {
            Word32 decorrelationReductionFactor_fx;
@@ -2137,9 +2107,7 @@ static void ivas_dirac_dec_binaural_determine_processing_matrices_fx(
            q_Mdec = Q31;
            move16();
        }
        pop_wmops(); /*push_wmops( "IDRBI pm LOOP1 sec C" );*/

        push_wmops( "IDRBI pm LOOP1 sec D" );
        /* The regularizations at determining mixing matrices cause signal energy to be lost to some degree, which is compensated for here */
        tmp1 = L_add( CrEneL_fx, CrEneR_fx );
        exp = sub( get_min_scalefactor( resultMtxRe_fx[0][0], resultMtxRe_fx[1][1] ), 2 );
@@ -2274,10 +2242,7 @@ static void ivas_dirac_dec_binaural_determine_processing_matrices_fx(
        move16();
        q_processMtxDec[bin] = sub( q_Mdec, 16 );
        move16();
        pop_wmops(); /*push_wmops( "IDRBI pm LOOP1 sec D" );*/


        push_wmops( "IDRBI pm LOOP1 sec E" );
        IF( separateCenterChannelRendering )
        {
            /* The rendering of the separate center channel in masa + mono mode.
@@ -2367,10 +2332,7 @@ static void ivas_dirac_dec_binaural_determine_processing_matrices_fx(
                }
            }
        }
        pop_wmops(); /*push_wmops( "IDRBI pm LOOP1 sec E" );*/
    }
    pop_wmops(); /*push_wmops( "IRDBI pm LOOP1 (IDRBI pm LOOP1)" );*/

    /* Aligning Q-factors of all bins in the processing matrices to a common Q-factor */
    minimum_s( q_processMtx, nBins, &hDiracDecBin->q_processMtx );
    minimum_s( q_processMtxPrev, nBins, &hDiracDecBin->q_processMtxPrev );
@@ -2390,7 +2352,6 @@ static void ivas_dirac_dec_binaural_determine_processing_matrices_fx(
    minimum_s( q_processMtxDec, nBins, &hDiracDecBin->q_processMtxDec );
    minimum_s( q_processMtxDecPrev, nBins, &hDiracDecBin->q_processMtxDecPrev );

    push_wmops( "IRDBI pm LOOP2" );
    FOR( bin = 0; bin < nBins; bin++ )
    {
        FOR( chA = 0; chA < BINAURAL_CHANNELS; chA++ )
@@ -2430,7 +2391,6 @@ static void ivas_dirac_dec_binaural_determine_processing_matrices_fx(
            }
        }
    }
    pop_wmops(); /*push_wmops( "IRDBI pm LOOP2" );*/

    return;
}
@@ -3393,6 +3353,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 1
            tmp2 = BASOP_Util_Divide3232_Scale_cadence( ONE_IN_Q30, tmp3, &exp );
            exp = sub( exp, sub( Q30, sub( 31, exp_tmp3 ) ) );
@@ -3464,7 +3425,6 @@ static void eig2x2_fx(
            tmp2 = Mpy_32_32( s_fx, s_fx );
            q_tmp2 = sub( add( q_tmp1, q_tmp1 ), 31 );


            tmp2 = BASOP_Util_Add_Mant32Exp( crossSquare_fx, sub( 31, q_crossSquare ), tmp2, sub( 31, q_tmp2 ), &q_tmp2 );
            q_tmp2 = sub( 31, q_tmp2 );

@@ -3533,7 +3493,7 @@ static void eig2x2_fx(
            move16();
        }
    }
#ifdef FIX_1326_SPEEDUP_18
#ifdef FIX_1326_SPEEDUP_eig2x2_fx
    if ( q_U_1 != 0 )
    {
        *q_U = q_U_1;
@@ -4455,12 +4415,9 @@ static void formulate2x2MixingMatrix_fx(
    Cout_im = Mpy_32_32( Cout_im, maxEneDiv_fx );
    q_cout = sub( add( q_cout, q_maxEneDiv ), 31 );

    push_wmops( "formulate2x2MixingMatrix cholesky" );
    /* 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 );
    pop_wmops(); /*push_wmops( "formulate2x2MixingMatrix cholesky" );*/

    push_wmops( "formulate2x2MixingMatrix Eigendecomp" );
    /* 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 );

@@ -4478,9 +4435,7 @@ static void formulate2x2MixingMatrix_fx(
    move32();

    matrixDiagMul_fx( Uxre_fx, Uxim_fx, q_Ux, Sx_fx, q_Sx, Kxre_fx, Kxim_fx, &q_Kx );
    pop_wmops(); /*push_wmops( "formulate2x2MixingMatrix Eigendecomp" );*/

    push_wmops( "formulate2x2MixingMatrix RegSMInv" );
    /* Regularize the diagonal Sx for matrix inversion */
    Sx_fx[0] = L_max( L_shr( Sx_fx[0], 1 ), Mpy_32_16_1( Sx_fx[1], regularizationFactor_fx ) );
    Sx_fx[1] = L_max( L_shr( Sx_fx[1], 1 ), L_shl( Mpy_32_16_1( Sx_fx[0], regularizationFactor_fx ), 1 ) );
@@ -4570,7 +4525,6 @@ static void formulate2x2MixingMatrix_fx(
    move32();
    Ghat_fx[1] = L_shr( Ghat_fx[1], sub( sub( 31, exp1 ), q_Ghat ) ); // q_Ghat
    move32();
    pop_wmops(); /*push_wmops( "formulate2x2MixingMatrix RegSMInv" );*/

    /* Matrix multiplication, tmp = Ky' * G_hat * Q */
    FOR( chA = 0; chA < BINAURAL_CHANNELS; chA++ )
@@ -4603,17 +4557,12 @@ static void formulate2x2MixingMatrix_fx(
    /* A = Ky' * G_hat * Q * Kx (see publication) */
    matrixMul_fx( tmpRe_fx, tmpIm_fx, &q_temp, Kxre_fx, Kxim_fx, &q_Kx, Are_fx, Aim_fx, &q_A );

    push_wmops( "formulate2x2MixingMatrix nrst orthonrm PtoA (oPtoA)" );
    /* Find nearest orthonormal matrix P to A = Ky' * G_hat * Q * Kx
       For matrix A that is P = A(A'A)^0.5 */
    push_wmops( "oPtoA MT1M" );
    matrixTransp1Mul_fx( Are_fx, Aim_fx, q_A, Are_fx, Aim_fx, q_A, tmpRe_fx, tmpIm_fx, &q_temp );

    eig2x2_fx( tmpRe_fx[0][0], tmpRe_fx[1][1], q_temp, tmpRe_fx[1][0], tmpIm_fx[1][0], q_temp, Ure_fx, Uim_fx, &q_U, D_fx, &q_D );

    pop_wmops(); /*push_wmops( "oPtoA MT1M" );*/


    IF( D_fx[0] == 0 )
    {
#ifndef FIX_1009_REPLACE_DIV_SQRT_BY_ISQRT_LC
@@ -4634,7 +4583,7 @@ static void formulate2x2MixingMatrix_fx(
    div_fx[0] = Sqrt32( temp, &exp ); // Q = 31 - exp
    move32();

#ifdef FIX_1326_SPEEDUP_08
#ifdef FIX_1326_SUBSTITUTE_DIV_SQRT_IOSQRT
    //Sqrt(1)
    div_fx[1] = L_add( 0, 2047986068 ); // Q = 31 - exp1
    exp1 = add( 0, 20 ); 
@@ -4760,9 +4709,7 @@ static void formulate2x2MixingMatrix_fx(
                         0 /*int Bscale*/,
#endif
                         Pre_fx, Pim_fx, &q_P ); /* Nearest orthonormal matrix P to matrix A formulated */
    pop_wmops();                                 /*push_wmops( "formulate2x2MixingMatrix nrst orthonrm PtoA (oPtoA)" );*/

    push_wmops( "formulate2x2MixingMatrix Ky P Kx^-1" );
    /* 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++ )
@@ -4916,8 +4863,6 @@ static void formulate2x2MixingMatrix_fx(
                         0 /*int Bscale*/,
#endif
                         Mre_fx, Mim_fx, q_M );
    pop_wmops(); /*push_wmops( "formulate2x2MixingMatrix Ky P Kx^-1" );*/

    return;
}