Commit 0a01fe3d authored by Fabian Bauer's avatar Fabian Bauer
Browse files

Merge branch 'main' of ssh://forge.3gpp.org:29419/sa4/audio/ivas-basop into...

Merge branch 'main' of ssh://forge.3gpp.org:29419/sa4/audio/ivas-basop into 1578-follow-up-from-resolve-complexity-overhead-stereo-to-stereo-32kbps-fb-float-vs-basop-bitexact
parents 10325469 b3570dfe
Loading
Loading
Loading
Loading
Loading
+12 −3
Original line number Diff line number Diff line
@@ -2640,10 +2640,16 @@ Word32 BASOP_Util_Add_Mant32Exp /* o : normalized result mantissa */
    */

    if ( !a_m )
        a_e = add( b_e, 0 );
    {
        a_e = b_e;
        move16();
    }

    if ( !b_m )
        b_e = add( a_e, 0 );
    {
        b_e = a_e;
        move16();
    }

    shift = sub( a_e, b_e );
    shift = s_max( -31, shift );
@@ -2664,7 +2670,10 @@ Word32 BASOP_Util_Add_Mant32Exp /* o : normalized result mantissa */
    if ( shift )
        L_tmp = L_shl( L_tmp, shift );
    if ( L_tmp == 0 )
        a_e = add( 0, 0 );
    {
        a_e = 0;
        move16();
    }
    if ( L_tmp != 0 )
        a_e = sub( a_e, shift );
    *ptr_e = a_e;
+176 −1
Original line number Diff line number Diff line
@@ -60,6 +60,19 @@ static void cldfb_init_proto_and_twiddles( HANDLE_CLDFB_FILTER_BANK hs );

static void cldfb_init_proto_and_twiddles_enc_fx( HANDLE_CLDFB_FILTER_BANK hs );

static void GetEnergyCldfb_ivas_fx( Word32 *energyLookahead,     /*!< o: Q(*sf_energyLookahead) |   pointer to the result in the core look-ahead slot */
                                    Word16 *sf_energyLookahead,  /*!< o:         pointer to the scalefactor of the result in the core look-ahead slot  */
                                    const Word16 numLookahead,   /*!< i: Q0      the number of look-ahead time-slots */
                                    Word16 **realValues,         /*!< i: Q(sf_Values) |   the real part of the CLDFB subsamples */
                                    Word16 **imagValues,         /*!< i: Q(sf_Values) |   the imaginary part of the CLDFB subsamples */
                                    Word16 sf_Values,            /*!< i:         scalefactor of the CLDFB subcamples - apply as a negated Exponent */
                                    Word16 numberBands,          /*!< i: Q0  |   number of CLDFB bands */
                                    Word16 numberCols,           /*!< i: Q0  |   number of CLDFB subsamples */
                                    Word32 *energyHF,            /*!< o: Q31 |   pointer to HF energy */
                                    Word16 *energyHF_Exp,        /*!< o:         pointer to exponent of HF energy */
                                    Word32 *energyValuesSum,     /*!< o: Q(2*sf_Values-4) |   pointer to sum array of energy values, not initialized*/
                                    Word16 *energyValuesSum_Exp, /*!< o:         pointer to exponents of energyValuesSum, not initialized */
                                    TEC_ENC_HANDLE hTecEnc );

/*-------------------------------------------------------------------*
 * cplxMult()
@@ -1552,6 +1565,168 @@ void resampleCldfb_ivas_fx(
    return;
}

static void GetEnergyCldfb_ivas_fx( Word32 *energyLookahead,     /*!< o: Q(*sf_energyLookahead) |   pointer to the result in the core look-ahead slot */
                                    Word16 *sf_energyLookahead,  /*!< o:         pointer to the scalefactor of the result in the core look-ahead slot  */
                                    const Word16 numLookahead,   /*!< i: Q0      the number of look-ahead time-slots */
                                    Word16 **realValues,         /*!< i: Q(sf_Values) |   the real part of the CLDFB subsamples */
                                    Word16 **imagValues,         /*!< i: Q(sf_Values) |   the imaginary part of the CLDFB subsamples */
                                    Word16 sf_Values,            /*!< i:         scalefactor of the CLDFB subcamples - apply as a negated Exponent */
                                    Word16 numberBands,          /*!< i: Q0  |   number of CLDFB bands */
                                    Word16 numberCols,           /*!< i: Q0  |   number of CLDFB subsamples */
                                    Word32 *energyHF,            /*!< o: Q31 |   pointer to HF energy */
                                    Word16 *energyHF_Exp,        /*!< o:         pointer to exponent of HF energy */
                                    Word32 *energyValuesSum,     /*!< o: Q(2*sf_Values-4) |   pointer to sum array of energy values, not initialized*/
                                    Word16 *energyValuesSum_Exp, /*!< o:         pointer to exponents of energyValuesSum, not initialized */
                                    TEC_ENC_HANDLE hTecEnc )
{
    Word16 j;
    Word16 k;
    Word16 s;
    Word16 sm;
    Word32 nrg;
    Word16 numberColsL;
    Word16 numberBandsM;
    Word16 numberBandsM20;
    Word32 energyValues[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX];
    Word16 energyValuesSumE[CLDFB_NO_CHANNELS_MAX];
    // Word16 freqTable[2] = {20, 40};
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
    Flag Overflow = 0;
    move32();
#endif

    FOR( k = 0; k < numberCols; k++ )
    {
        FOR( j = 0; j < numberBands; j++ )
        {
            nrg = L_mult0( realValues[k][j], realValues[k][j] );     // Q(2*sf_Values)
            nrg = L_mac0( nrg, imagValues[k][j], imagValues[k][j] ); // Q(2*sf_Values)

            energyValues[k][j] = nrg;
            move32();
        }
    }

    IF( GE_16( numberBands, freqTable[1] ) && hTecEnc != NULL )
    {
        Word32 *tempEnergyValuesArry[CLDFB_NO_COL_MAX];
        Word16 ScaleX2;
        assert( numberCols == CLDFB_NO_COL_MAX );
        FOR( j = 0; j < numberCols; j++ )
        {
            tempEnergyValuesArry[j] = &energyValues[j][0];
        }

        ScaleX2 = shl( sf_Values, 1 );
        calcHiEnvLoBuff_Fix(
            numberCols,
            freqTable,
            1,
            tempEnergyValuesArry,
            hTecEnc->loBuffer,
            hTecEnc->hiTempEnv,
            ScaleX2 );
    }

    FOR( j = 0; j < numberBands; j++ )
    {
        energyValuesSum[j] = 0;
        move32();
        energyValuesSumE[j] = 31;
        move16();
        FOR( k = 0; k < CLDFB_NO_COL_MAX; k++ )
        {
            nrg = L_shr_r( energyValues[k][j], sub( energyValuesSumE[j], 31 ) ); // Q(2*sf_Values - (energyValuesSumE[j]-31))
            IF( LT_32( L_sub( maxWord32, nrg ), energyValuesSum[j] ) )
            {
                energyValuesSumE[j] = add( energyValuesSumE[j], 1 );
                move16();
                energyValuesSum[j] = L_shr_r( energyValuesSum[j], 1 );
                move32();
                nrg = L_shr_r( nrg, 1 );
            }
            energyValuesSum[j] = L_add( energyValuesSum[j], nrg );
            move32();
        }
        test();
        if ( j == 0 || GT_16( energyValuesSumE[j], *energyValuesSum_Exp ) )
        {
            *energyValuesSum_Exp = energyValuesSumE[j];
            move16();
        }
    }
    FOR( j = 0; j < numberBands; j++ )
    {
        energyValuesSum[j] = L_shr_r( energyValuesSum[j], sub( *energyValuesSum_Exp, energyValuesSumE[j] ) ); // Q(energyValuesSum_Exp - (2*sf_Values))
        move32();
    }
    *energyValuesSum_Exp = sub( *energyValuesSum_Exp, shl( sf_Values, 1 ) );
    move16();

    IF( GT_16( numberBands, 20 ) )
    {
        numberBandsM = s_min( numberBands, 40 );
        numberBandsM20 = sub( numberBandsM, 20 );

        numberColsL = sub( numberCols, numLookahead );

        /* sum up CLDFB energy above 8 kHz */
        s = BASOP_util_norm_s_bands2shift( i_mult( numberColsL, numberBandsM20 ) );
        s = sub( s, 4 );
        nrg = 0;
        move32();
        FOR( k = 0; k < numberColsL; k++ )
        {
            FOR( j = 20; j < numberBandsM; j++ )
            {
                nrg = L_add_o( nrg, L_shr_o( energyValues[k][j], s, &Overflow ), &Overflow );
            }
        }

        s = sub( sub( shl( sf_Values, 1 ), 1 ), s );
        sm = sub( s_min( s, *sf_energyLookahead ), 1 );

        *energyHF = L_add( L_shr( nrg, limitScale32( sub( s, sm ) ) ),
                           L_shr( *energyLookahead, sub( *sf_energyLookahead, sm ) ) ); // Q(31-(-nm))
        move32();

        *energyHF_Exp = negate( sm );
        move16();

        /* process look-ahead region */
        s = BASOP_util_norm_s_bands2shift( i_mult( numLookahead, numberBandsM20 ) );
        s = sub( s, 2 );
        nrg = 0;
        move32();
        FOR( k = numberColsL; k < numberCols; k++ )
        {
            FOR( j = 20; j < numberBandsM; j++ )
            {
                nrg = L_add_o( nrg, L_shr_o( energyValues[k][j], s, &Overflow ), &Overflow );
            }
        }

        s = sub( shl( sf_Values, 1 ), s );
        sm = sub( s_min( s, 44 ), 1 );
        BASOP_SATURATE_WARNING_OFF_EVS
        /* nrg + 6.1e-5f => value 0x40000000, scale 44 */
        *energyLookahead = L_add_sat( L_shr_sat( nrg, sub( s, sm ) ),
                                      L_shr_sat( 0x40000000, s_max( -31, s_min( 31, sub( 44, sm ) ) ) ) );
        move32();
        BASOP_SATURATE_WARNING_ON_EVS
        *sf_energyLookahead = sm;
        move16();

        return;
    }


    *energyHF = 0x40000000;
    move32();
    *energyHF_Exp = 17;
    move16();
}


void analysisCldfbEncoder_ivas_fx(
    Encoder_State *st, /* i/o: encoder state structure   */
@@ -1613,7 +1788,7 @@ void analysisCldfbEncoder_ivas_fx(

    AnalysisPostSpectrumScaling_Fx( st->cldfbAnaEnc, ppBuf_Real, ppBuf_Imag, ppBuf_Real16, ppBuf_Imag16, &enerScale.lb_scale16 );

    GetEnergyCldfb( &st->energyCoreLookahead_Fx, &st->sf_energyCoreLookahead_Fx, 1, ppBuf_Real16, ppBuf_Imag16, enerScale.lb_scale16, st->cldfbAnaEnc->no_channels, st->cldfbAnaEnc->no_col, &st->currEnergyHF_fx, &st->currEnergyHF_e_fx, ppBuf_Ener, enerBuffSum_exp, st->hTECEnc );
    GetEnergyCldfb_ivas_fx( &st->energyCoreLookahead_Fx, &st->sf_energyCoreLookahead_Fx, 1, ppBuf_Real16, ppBuf_Imag16, enerScale.lb_scale16, st->cldfbAnaEnc->no_channels, st->cldfbAnaEnc->no_col, &st->currEnergyHF_fx, &st->currEnergyHF_e_fx, ppBuf_Ener, enerBuffSum_exp, st->hTECEnc );

    return;
}
+1 −1
Original line number Diff line number Diff line
@@ -3341,7 +3341,7 @@ void mctStereoIGF_enc_fx(
    Word32 powerSpec_fx[MCT_MAX_CHANNELS][L_FRAME48k],   /* i/o: MDCT^2 + MDST^2 spectrum,or estimate       */
    Word16 q_powerSpec[MCT_MAX_CHANNELS],                /* i  : Q for powSpec_fx                           */
    Word32 *powerSpecMsInv_fx[MCT_MAX_CHANNELS][NB_DIV], /* i  : same as powerSpec_fx but for inverse spect.*/
    Word16 q_powerSpecMsInv[MCT_MAX_CHANNELS],           /* i  : Q for powSpecMsInv_fx                      */
    Word16 *q_powerSpecMsInv[MCT_MAX_CHANNELS][NB_DIV],  /* i  : Q for powSpecMsInv_fx                      */
    Word32 *inv_spectrum_fx[MCT_MAX_CHANNELS][NB_DIV],   /* i  : inverse spectrum                           */
    const Word16 sp_aud_decision0[MCT_MAX_CHANNELS]      /* i  : speech audio decision                      */
);
+23 −23
Original line number Diff line number Diff line
@@ -10844,7 +10844,7 @@ void ProcessStereoIGF_fx(
    Word32 *pPowerSpectrum_fx[CPE_CHANNELS],                /* i/o: MDCT^2 + MDST^2 spectrum, or estimate   */
    Word16 exp_pPowerSpectrum_fx[CPE_CHANNELS],             /* i/o: exp of pPowerSpectrum_fx                */
    Word32 *pPowerSpectrumMsInv_fx[CPE_CHANNELS][NB_DIV],   /* i  : inverse power spectrum                  */
    Word16 exp_pPowerSpectrumMsInv_fx[CPE_CHANNELS],      /* i/o: exp of pPowerSpectrumMsInv_fx           */
    Word16 *q_pPowerSpectrumMsInv_fx[CPE_CHANNELS][NB_DIV], /* i/o: Q of pPowerSpectrumMsInv_fx           */
    Word32 *inv_spectrum_fx[CPE_CHANNELS][NB_DIV],          /* i  : inverse spectrum                        */
    Word16 exp_inv_spectrum_fx[CPE_CHANNELS],               /* i/o: exp of inv_spectrum_fx                  */
    const Word16 frameno,                                   /* i  : flag indicating index of current subfr. */
@@ -10861,7 +10861,7 @@ void IGFEncApplyStereo_fx(
    Word32 *pPowerSpectrum_fx[CPE_CHANNELS],                /* i/o: MDCT^2 + MDST^2 spectrum, or estimate   */
    Word16 exp_pPowerSpectrum_fx[CPE_CHANNELS],             /* i/o: exp of pPowerSpectrum_fx                */
    Word32 *pPowerSpectrumMsInv_fx[CPE_CHANNELS][NB_DIV],   /* i/o: inverse power spectrum                  */
    Word16 exp_pPowerSpectrumMsInv_fx[CPE_CHANNELS],      /* i/o: exp of pPowerSpectrumMsInv_fx           */
    Word16 *q_pPowerSpectrumMsInv_fx[CPE_CHANNELS][NB_DIV], /* i/o: Q of pPowerSpectrumMsInv_fx           */
    Word32 *inv_spectrum_fx[CPE_CHANNELS][NB_DIV],          /* i  : inverse spectrum                        */
    Word16 exp_inv_spectrum_fx[CPE_CHANNELS],               /* i  : exp of inverse spectrum                 */
    const Word16 frameno,                                   /* i  : flag indicating index of current subfr. */
+1 −1
Original line number Diff line number Diff line
@@ -6366,7 +6366,7 @@ void wb_tbe_extras_reset_synth_fx(

void elliptic_bpf_48k_generic_fx(
#ifdef FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic_STAGE2
    int16_t element_mode,
    const int16_t element_mode,
#endif
#ifdef FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic
    Word16 IsUpsampled3,
Loading