Commit 25e9bebe authored by Jan Kiene's avatar Jan Kiene
Browse files

Accept HARMONIZE_2564_GetEnergyCldfb

parent f4b3cc16
Loading
Loading
Loading
Loading
+0 −12
Original line number Diff line number Diff line
@@ -1216,12 +1216,8 @@ void analysisCldfbEncoder_fx(
        &enerScale.lb_scale16 );

    /* get the energy */
#ifdef HARMONIZE_2564_GetEnergyCldfb
    GetEnergyCldfb(
        EVS_MONO,
#else
    GetEnergyCldfb(
#endif
        &st_fx->energyCoreLookahead_Fx,
        &st_fx->sf_energyCoreLookahead_Fx,
        num_slots,
@@ -1240,12 +1236,8 @@ void analysisCldfbEncoder_fx(
}


#ifdef HARMONIZE_2564_GetEnergyCldfb
void GetEnergyCldfb(
    Word16 element_mode, /*!< i:     |   Is IVAS or EVS?  */
#else
void GetEnergyCldfb(
#endif
    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 */
@@ -1320,15 +1312,11 @@ void GetEnergyCldfb(
                move16();
                energyValuesSum[j] = L_shr_r( energyValuesSum[j], 1 );
                move32();
#ifdef HARMONIZE_2564_GetEnergyCldfb
                nrg = L_shr_r( nrg, 1 );
                if ( EQ_16( element_mode, EVS_MONO ) )
                {
#endif
                    nrg = L_shr_r( energyValues[k][j], 1 );
#ifdef HARMONIZE_2564_GetEnergyCldfb
                }
#endif
            }
            energyValuesSum[j] = L_add( energyValuesSum[j], nrg );
            move32();
+0 −179
Original line number Diff line number Diff line
@@ -55,21 +55,6 @@

static void cldfb_init_proto_and_twiddles( HANDLE_CLDFB_FILTER_BANK hs );

#ifndef HARMONIZE_2564_GetEnergyCldfb
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 );
#endif

/*-------------------------------------------------------------------*
 * cldfbAnalysis_ivas()
@@ -1456,166 +1441,6 @@ void resampleCldfb_ivas_fx(
    return;
}

#ifndef HARMONIZE_2564_GetEnergyCldfb
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};

    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_sat( nrg, L_shr_sat( energyValues[k][j], s ) );
            }
        }

        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_sat( nrg, L_shr_sat( energyValues[k][j], s ) );
            }
        }

        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();
}
#endif


void analysisCldfbEncoder_ivas_fx(
@@ -1677,11 +1502,7 @@ void analysisCldfbEncoder_ivas_fx(
    move16();

    AnalysisPostSpectrumScaling_Fx( st->cldfbAnaEnc, ppBuf_Real, ppBuf_Imag, ppBuf_Real16, ppBuf_Imag16, &enerScale.lb_scale16 );
#ifdef HARMONIZE_2564_GetEnergyCldfb
    GetEnergyCldfb( st->element_mode, &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 );
#else
    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 );
#endif

    return;
}
+0 −1
Original line number Diff line number Diff line
@@ -92,7 +92,6 @@
#define NONBE_FIX_ISSUE_2206_AVOID_OVERFLOW_MSVQ_Interpol_Tran_fx /* FhG: Fix saturation crash in MSVQ_Interpol_Tran_fx() */
#define NONBE_FIX_ISSUE_2206_SWB_EXPERIMENT_FIX_2527    /* Fix crash from issue #2527 */
#define FIX_FLOAT_1539_G192_FORMAT_SWITCH               /* VA/Nokia: reintroduce format switching for g192 bitstreams */
#define HARMONIZE_2564_GetEnergyCldfb                   /* FhG: harmonize GetEnergyCldfb derivates for evs/ivas  */
#define FIX_BASOP_2555_FRAMELEN_CALC                    /* FhG: BASOP issue 2555: Simplify (sub-)framelength calculation in ivas_mdct_core_tns_ns_fx() */
#define FIX_BASOP_2095_REMOVE_TABLES_PT01               /* FhG: BASOP issue 2095: remove unused tables, part 01 */
#define FIX_2346_DUPLICATED_IGF_FUNCTIONS_2             /* FhG: part 2 of basop issue 2346: Review potentially duplicated IGF functions */
+0 −4
Original line number Diff line number Diff line
@@ -4104,12 +4104,8 @@ void analysisCldfbEncoder_fx(
    Word16 *enerBuffSum_exp,
    CLDFB_SCALE_FACTOR *scale );

#ifdef HARMONIZE_2564_GetEnergyCldfb
void GetEnergyCldfb(
    Word16 element_mode, /*!< i:     |   Is IVAS or EVS?  */
#else
void GetEnergyCldfb(
#endif
    Word32 *energyLookahead,     /*!< o: Q31 |   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  - apply as negative exponent*/
    const Word16 numLookahead,   /*!< i: Q0      the number of look-ahead time-slots */