Commit b71ebe3a authored by Michael Sturm's avatar Michael Sturm
Browse files

Unifies IGF_calc and IGFCommonFuncsMDCTSquareSpec EVS and IVAS functions.

parent 54e021ae
Loading
Loading
Loading
Loading
+19 −1
Original line number Diff line number Diff line
@@ -1148,7 +1148,12 @@ void IGFCommonFuncsMDCTSquareSpec( const Word16 sqrtBgn, /**< in
                                   const Word16 mdctSpec_e,              /**< in:     | exponent of mdctSpectrum       */
                                   Word32 *mdctSquareSpec,               /**< out:    | MDCT square spectrum           */
                                   Word16 *mdctSquareSpec_e,             /**< out:    | exponent of mdctSquareSpec     */
#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS
                                   Word16 indexOffset,                   /**< in: Q0  | index offset                   */
                                   const Word16 element_mode             /**< in:     | IVAS element mode type         */
#else
                                   Word16 indexOffset                    /**< in: Q0  | index offset                   */
#endif
)
{
    Word16 i;
@@ -1170,12 +1175,24 @@ void IGFCommonFuncsMDCTSquareSpec( const Word16 sqrtBgn, /**< in

    FOR( i = sqrtBgn; i < sqrtEnd; i++ )
    {
#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS
        IF(EQ_16(element_mode, EVS_MONO))
        {
            tmp = round_fx_sat( L_shl_sat( mdctSpec[i], s1 ) ); /*(15 - mdctSpec_e)+ S1*/
        }
        ELSE
        {
            tmp = extract_h( L_shl( mdctSpec[i], s1 ) );        /*(15 - mdctSpec_e)+ S1*/
        }
#else
        tmp = round_fx_sat( L_shl_sat( mdctSpec[i], s1 ) ); /*(15 - mdctSpec_e)+ S1*/
#endif
        mdctSquareSpec[j++] = L_mult0( tmp, tmp );              /*31 - mdctSquareSpec_e*/
        move32();
    }
}

#ifndef FIX_2346_DUPLICATED_IGF_FUNCTIONS
/**********************************************************************/ /*
calculate the MDCT square spectrum in the IGF range (for IVAS)
**************************************************************************/
@@ -1212,6 +1229,7 @@ void IGFCommonFuncsMDCTSquareSpec_ivas( const Word16 sqrtBgn, /**< in
        move32();
    }
}
#endif


/**********************************************************************/ /*
+1 −0
Original line number Diff line number Diff line
@@ -91,6 +91,7 @@
#define HARM_2456_APPLY_SCALE                           /* FhG basop issue 2456: Harmonize apply_scale_ind(), apply_scale_ivas_fx() */
#define HARM_2454_TCX_RES_Q_SPEC                        /* FhG: harmonization of tcx_res_Q_spec_fx() and tcx_res_Q_spec_ivas_fx() */
#define FIX_FLOAT_1535_ARI_RES_Q_CLEANUP                /* FhG: remove dead code from tcx_ari_res_Q_spec() */
#define FIX_2346_DUPLICATED_IGF_FUNCTIONS               /* FhG: basop issue 2346: Review potentially duplicated IGF functions */

/* #################### End BE switches ################################## */

+7 −0
Original line number Diff line number Diff line
@@ -5332,9 +5332,15 @@ void IGFCommonFuncsMDCTSquareSpec(
    const Word16 mdctSpec_e,  /**< in:     | exponent of mdctSpectrum       */
    Word32 *mdctSquareSpec,   /**< out:    | MDCT square spectrum           */
    Word16 *mdctSquareSpec_e, /**< out:    | exponent of mdctSquareSpec     */
#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS
    Word16 indexOffset,       /**< in: Q0  | index offset                   */
    const Word16 element_mode /**< in:     | IVAS element mode type         */
#else
    Word16 indexOffset        /**< in: Q0  | index offset                   */
#endif
);

#ifndef FIX_2346_DUPLICATED_IGF_FUNCTIONS
void IGFCommonFuncsMDCTSquareSpec_ivas(
    const Word16 sqrtBgn,     /**< in: Q0  | start MDCT subband index       */
    const Word16 sqrtEnd,     /**< in: Q0  | stop  MDCT subband index       */
@@ -5344,6 +5350,7 @@ void IGFCommonFuncsMDCTSquareSpec_ivas(
    Word16 *mdctSquareSpec_e, /**< out:    | exponent of mdctSquareSpec     */
    Word16 indexOffset        /**< in: Q0  | index offset                   */
);
#endif

Word16 IGFCommonFuncsIGFConfiguration(
    const Word32 total_brate,  /* i  : bitrate in bs e.g. 9600 for 9.6kbs  */
+65 −1
Original line number Diff line number Diff line
@@ -1269,7 +1269,12 @@ static void IGF_calc( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in
                      const Word32 *spectrum,                            /**< in: Q31 | MDCT spectrum                                        */
                      const Word16 spectrum_e,                           /**< in:     | exponent of pSpectralData                            */
                      Word32 *igf_spec,                                  /**< in: Q31 | prepared IGF spectrum                                */
#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS
                      Word16 *igf_spec_e,                                /**< in:     | array exponents of igf_spec, one exponent per tile   */
                      const Word16 element_mode                          /**< in:     | IVAS element mode type                               */
#else
                      Word16 *igf_spec_e                                 /**< in:     | array exponents of igf_spec, one exponent per tile   */
#endif
)
{
    H_IGF_GRID hGrid;
@@ -1299,7 +1304,12 @@ static void IGF_calc( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in
                                  spectrum_e,
                                  squaredSpectra,
                                  squaredSpectra_e,
#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS
                                  0,
                                  element_mode );
#else
                                  0 );
#endif

    /* calculate the energy per SFB of the survied subbands */
    IGFCommonFuncsCalcSfbEnergyPowerSpec( hGrid->startSfb,
@@ -1320,7 +1330,12 @@ static void IGF_calc( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in
                                      igf_spec_e[i],
                                      squaredSpectra,
                                      &squaredSpectra_e[i],
#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS
                                      0,
                                      element_mode );
#else
                                      0 );
#endif

        /* set all squared values to 0, if the core contains survied lines */
        IGF_setLinesToZero( hGrid->tile[i],
@@ -1339,7 +1354,7 @@ static void IGF_calc( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in
    }
}


#ifndef FIX_2346_DUPLICATED_IGF_FUNCTIONS
/**********************************************************************/ /*
calculates IGF energies (for IVAS)
**************************************************************************/
@@ -1417,6 +1432,7 @@ static void IGF_calc_ivas( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in
                                              igf_pN_e );
    }
}
#endif

/**********************************************************************/ /*
apply IGF
@@ -1558,7 +1574,12 @@ static void IGF_appl( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in
                                  *spectrum_e,
                                  energyTmp,
                                  &dE_e,
#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS
                                  negate( tmp ),
                                  EVS_MONO );
#else
                                  negate( tmp ) );
#endif

    L_tmp = sum_array_norm( energyTmp, 24, &shift );
    /* float: dE = (float)sqrt(dE / 24.f); basop: */
@@ -2222,6 +2243,16 @@ static void IGF_appl_ivas( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in

    /* collect energy below hGrid->startLine: */
    tmp = sub( hGrid->startLine, 24 );
#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS
    IGFCommonFuncsMDCTSquareSpec( tmp,
                                  hGrid->startLine,
                                  spectrum,
                                  *spectrum_e,
                                  energyTmp,
                                  &dE_e,
                                  negate( tmp ),
                                  IVAS_CPE_MDCT );
#else
    IGFCommonFuncsMDCTSquareSpec_ivas( tmp,
                                       hGrid->startLine,
                                       spectrum,
@@ -2229,6 +2260,7 @@ static void IGF_appl_ivas( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in
                                       energyTmp,
                                       &dE_e,
                                       negate( tmp ) );
#endif

    L_tmp = sum_array_norm( energyTmp, 24, &shift );
    /* float: dE = (float)sqrt(dE / 24.f); basop: */
@@ -3359,7 +3391,12 @@ void IGFDecApplyMono( const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in
                  spectrum,
                  *spectrum_e,
                  igf_spec,
#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS
                  igf_spec_e,
                  EVS_MONO );
#else
                  igf_spec_e );
#endif
        IGF_appl( hPrivateData,
                  igfGridIdx,
                  spectrum,
@@ -3531,12 +3568,22 @@ void IGFDecApplyMono_ivas( const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in
                       hPrivateData->pSpecFlat_exp,
                       specMed_e,
                       element_mode );
#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS
        IGF_calc( hPrivateData,
                  igfGridIdx,
                  spectrum,
                  *spectrum_e,
                  igf_spec,
                  igf_spec_e,
                  element_mode );
#else
        IGF_calc_ivas( hPrivateData,
                       igfGridIdx,
                       spectrum,
                       *spectrum_e,
                       igf_spec,
                       igf_spec_e );
#endif
        IGF_appl_ivas( hPrivateData,
                       igfGridIdx,
                       spectrum,
@@ -3806,6 +3853,22 @@ void IGFDecApplyStereo(
            igf_specR_e_arr,
            igf_specR_e );

#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS
        IGF_calc( hPrivateDataL,
                  igfGridIdx,
                  spectrumL_fx,
                  *spectrumL_e,
                  igf_specL_fx,
                  igf_specL_e,
                  IVAS_CPE_MDCT );
        IGF_calc( hPrivateDataR,
                  igfGridIdx,
                  spectrumR_fx,
                  *spectrumR_e,
                  igf_specR_fx,
                  igf_specR_e,
                  IVAS_CPE_MDCT );
#else
        IGF_calc_ivas( hPrivateDataL,
                       igfGridIdx,
                       spectrumL_fx,
@@ -3818,6 +3881,7 @@ void IGFDecApplyStereo(
                       *spectrumR_e,
                       igf_specR_fx,
                       igf_specR_e );
#endif
        IGF_appl_ivas( hPrivateDataL,
                       igfGridIdx,
                       spectrumL_fx,

lib_enc/igf_enc_fx.c

100755 → 100644
+8 −0
Original line number Diff line number Diff line
@@ -141,13 +141,21 @@ static void IGF_CalculateEnvelope(

        IGFCommonFuncsCalcSfbEnergyPowerSpec( hGrid->startSfb, hGrid->stopSfb, hGrid->swb_offset, LFPowerSpectrum, &PowerSpectrum_e, sfbEnergyTileC, sfbEnergyTileC_exp );

#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS
        IGFCommonFuncsMDCTSquareSpec( hGrid->startLine, hGrid->stopLine, LFMDCTSpectrum, MDCTSpectrum_e, LFMDCTSpectrum, &LFMDCTSpectrum_exp, 0, EVS_MONO );
#else
        IGFCommonFuncsMDCTSquareSpec( hGrid->startLine, hGrid->stopLine, LFMDCTSpectrum, MDCTSpectrum_e, LFMDCTSpectrum, &LFMDCTSpectrum_exp, 0 );
#endif

        IGFCommonFuncsCalcSfbEnergyPowerSpec( hGrid->startSfb, hGrid->stopSfb, hGrid->swb_offset, LFMDCTSpectrum, &LFMDCTSpectrum_exp, sfbEnergyTileR, sfbEnergyTileR_exp );
    }
    ELSE
    {
#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS
        IGFCommonFuncsMDCTSquareSpec( hGrid->startLine, hGrid->stopLine, pMDCTSpectrum, MDCTSpectrum_e, LFMDCTSpectrum, &LFMDCTSpectrum_exp, 0, EVS_MONO );
#else
        IGFCommonFuncsMDCTSquareSpec( hGrid->startLine, hGrid->stopLine, pMDCTSpectrum, MDCTSpectrum_e, LFMDCTSpectrum, &LFMDCTSpectrum_exp, 0 );
#endif

        IGFCommonFuncsCalcSfbEnergyPowerSpec( hGrid->startSfb, hGrid->stopSfb, hGrid->swb_offset, LFMDCTSpectrum, &LFMDCTSpectrum_exp, sfbEnergyR, sfbEnergyR_exp );
    }