Commit 59d2e43a authored by Michael Sturm's avatar Michael Sturm
Browse files

Unifies IGFEncApplyMono_fx function.

parent b3e0b22b
Loading
Loading
Loading
Loading
+44 −23
Original line number Diff line number Diff line
@@ -2962,7 +2962,7 @@ Word16 IGFEncWriteConcatenatedBitstream_ivas_fx(
    return hInstance->infoTotalBitsWritten;
}
#endif

#ifndef FIX_2346_DUPLICATED_IGF_FUNCTIONS
/**********************************************************************/ /*
apply the IGF encoder, main encoder interface
**************************************************************************/
@@ -2982,9 +2982,7 @@ void IGFEncApplyMono_fx(
{
    Word32 *pPowerSpectrumParameter;          /* If it is NULL it informs a function that specific handling is needed */
    Word32 *pPowerSpectrumParameterWhitening; /* If it is NULL it informs a function that specific handling is needed */
#ifndef FIX_2346_DUPLICATED_IGF_FUNCTIONS
    Word16 highPassEner_exp; /*exponent of highpass energy - maybe not needed*/
#endif

    pPowerSpectrumParameter = NULL;
    test();
@@ -3002,11 +3000,7 @@ void IGFEncApplyMono_fx(

    IGF_CalculateEnvelope( hInstance, pMDCTSpectrum, MDCTSpectrum_e, pPowerSpectrumParameter, PowerSpectrum_e, igfGridIdx );

#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS
    IGF_Whitening( hInstance, pPowerSpectrumParameterWhitening, &PowerSpectrum_e, igfGridIdx, ( st->hTranDet->transientDetector.bIsAttackPresent == 1 ), last_core_acelp, isTNSActive, 0, st->element_brate, st->element_mode );
#else
    IGF_Whitening( hInstance, pPowerSpectrumParameterWhitening, PowerSpectrum_e, igfGridIdx, ( st->hTranDet->transientDetector.bIsAttackPresent == 1 ), last_core_acelp );
#endif

    pPowerSpectrumParameter = NULL;
    if ( isTCX20 != 0 )
@@ -3014,15 +3008,11 @@ void IGFEncApplyMono_fx(
        pPowerSpectrumParameter = pPowerSpectrum;
    }

#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS
    IGF_ErodeSpectrum( hInstance, pMDCTSpectrum, pPowerSpectrumParameter, PowerSpectrum_e, igfGridIdx, 0, st->element_mode );
#else
    IGF_ErodeSpectrum( &highPassEner_exp, hInstance, pMDCTSpectrum, pPowerSpectrumParameter, PowerSpectrum_e, igfGridIdx );
#endif

    return;
}

#endif

ivas_error IGF_Reconfig_fx(
    IGF_ENC_INSTANCE_HANDLE *hIGFEnc, /* i/o: instance handle of IGF Encoder  */
@@ -5415,6 +5405,21 @@ void IGFEncResetTCX10BitCounter_fx(
 * apply the IGF encoder, main encoder interface
 *-------------------------------------------------------------------*/

#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS
void IGFEncApplyMono_fx(
    Encoder_State *st,             /* i  : Encoder state                                          */
    Word16 powerSpectrum_len,      /* i  : length of pPowerSpectrum_fx buffer                     */
    const Word16 igfGridIdx,       /* i  : IGF grid index                                         */
    Word32 *pMDCTSpectrum_fx,      /* i/o: MDCT spectrum                                          */
    Word16 e_mdct,                 /* i  : exponent of pMDCTspectrum                              */
    Word32 *pPowerSpectrum_fx,     /* i/o: MDCT^2 + MDST^2 spectrum, or estimate                  */
    Word16 *e_ps,                  /* i  : exponent of pPowerSpectrum                             */
    const Word16 isTCX20,          /* i  : flag indicating if the input is TCX20 or TCX10/2xTCX5  */
    const Word8 isTNSActive,       /* i  : flag indicating if the TNS is active                   */
    const Word16 sp_aud_decision0, /* i  : first stage switching decision                         */
    const Word16 vad_hover_flag    /* i  : VAD hangover flag                                      */
)
#else
void IGFEncApplyMono_ivas_fx(
    Encoder_State *st,             /* i  : Encoder state                                          */
    Word16 powerSpectrum_len,      /* i  : length of pPowerSpectrum_fx buffer                     */
@@ -5428,17 +5433,15 @@ void IGFEncApplyMono_ivas_fx(
    const Word16 sp_aud_decision0, /* i  : first stage switching decision                         */
    const Word16 vad_hover_flag    /* i  : VAD hangover flag                                      */
)
#endif
{
    Word32 *pPowerSpectrumParameter_fx;
    Word16 *pPowerSpectrumParameter_exp;
    Word16 att_fx = MAX16B;
    Word16 last_core_acelp;
    move16();

    Word32 common_pPowerSpectrum_fx[N_MAX + L_MDCT_OVLP_MAX];

    set32_fx( common_pPowerSpectrum_fx, 0, N_MAX );

    Word16 common_pPowerSpectrum_exp = MIN16B;
    move16();
    IF( st->last_core == ACELP_CORE )
@@ -5472,7 +5475,18 @@ void IGFEncApplyMono_ivas_fx(
        calculate_hangover_attenuation_gain_fx( st, &att_fx, vad_hover_flag );
    }

#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS
    IF( EQ_16( st->element_mode, EVS_MONO ) )
    {
        IGF_CalculateEnvelope( st->hIGFEnc, pMDCTSpectrum_fx, e_mdct, pPowerSpectrumParameter_fx, *e_ps, igfGridIdx );
    }
    ELSE
    {
        IGF_CalculateEnvelope_ivas_fx( st->hIGFEnc, pMDCTSpectrum_fx, e_mdct, pPowerSpectrumParameter_fx, pPowerSpectrumParameter_exp, igfGridIdx, st->hTranDet->transientDetector.bIsAttackPresent, last_core_acelp, st->element_mode, att_fx );
    }
#else
    IGF_CalculateEnvelope_ivas_fx( st->hIGFEnc, pMDCTSpectrum_fx, e_mdct, pPowerSpectrumParameter_fx, pPowerSpectrumParameter_exp, igfGridIdx, st->hTranDet->transientDetector.bIsAttackPresent, last_core_acelp, st->element_mode, att_fx );
#endif

    IF( isTCX20 )
    {
@@ -5485,25 +5499,26 @@ void IGFEncApplyMono_ivas_fx(
        pPowerSpectrumParameter_exp = NULL;
    }

    IF( EQ_16( st->element_mode, IVAS_CPE_MDCT ) )
    {
#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS
        IGF_Whitening( st->hIGFEnc, pPowerSpectrumParameter_fx, pPowerSpectrumParameter_exp, igfGridIdx, st->hTranDet->transientDetector.bIsAttackPresent, last_core_acelp, isTNSActive, sp_aud_decision0, st->element_brate, st->element_mode );
    IGF_Whitening( st->hIGFEnc, pPowerSpectrumParameter_fx, pPowerSpectrumParameter_exp, igfGridIdx, st->hTranDet->transientDetector.bIsAttackPresent, last_core_acelp, isTNSActive, sp_aud_decision0, EQ_16( st->element_mode, IVAS_CPE_MDCT ) ? st->element_brate : st->total_brate, st->element_mode );
#else
    IF( EQ_16( st->element_mode, IVAS_CPE_MDCT ) )
    {
        IGF_Whitening_ivas_fx( st->hIGFEnc, pPowerSpectrumParameter_fx, pPowerSpectrumParameter_exp, igfGridIdx, st->hTranDet->transientDetector.bIsAttackPresent, last_core_acelp, isTNSActive, sp_aud_decision0, st->element_brate, st->element_mode );
#endif
    }
    ELSE
    {
#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS
        IGF_Whitening( st->hIGFEnc, pPowerSpectrumParameter_fx, pPowerSpectrumParameter_exp, igfGridIdx, st->hTranDet->transientDetector.bIsAttackPresent, last_core_acelp, isTNSActive, sp_aud_decision0, st->total_brate, st->element_mode );
#else
        IGF_Whitening_ivas_fx( st->hIGFEnc, pPowerSpectrumParameter_fx, pPowerSpectrumParameter_exp, igfGridIdx, st->hTranDet->transientDetector.bIsAttackPresent, last_core_acelp, isTNSActive, sp_aud_decision0, st->total_brate, st->element_mode );
#endif
    }
#endif

#ifndef FIX_2346_DUPLICATED_IGF_FUNCTIONS
    IF( pPowerSpectrumParameter_fx )
    {
#else
    IF( pPowerSpectrumParameter_fx && GT_16( st->element_mode, EVS_MONO ) )
    {
#endif
        FOR( Word16 i = 0; i < powerSpectrum_len; i++ )
        {
            common_pPowerSpectrum_exp = s_max( common_pPowerSpectrum_exp, pPowerSpectrumParameter_exp[i] );
@@ -5516,6 +5531,12 @@ void IGFEncApplyMono_ivas_fx(
        }
        pPowerSpectrumParameter_fx = common_pPowerSpectrum_fx;
    }
#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS
    IF( EQ_16( st->element_mode, EVS_MONO ) )
    {
        common_pPowerSpectrum_exp = *e_ps;
    }
#endif

#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS
    IGF_ErodeSpectrum( st->hIGFEnc, pMDCTSpectrum_fx, pPowerSpectrumParameter_fx, common_pPowerSpectrum_exp, igfGridIdx, 0, st->element_mode );
+20 −1
Original line number Diff line number Diff line
@@ -1076,7 +1076,11 @@ void ProcessIGF_fx(
    Word32 pPowerSpectrum[], /**< in: MDCT^2 + MDST^2 spectrum, or estimate */
    Word16 *pPowerSpectrum_e,
    Word16 isTCX20,      /**< in: flag indicating if the i   is TCX20 or TCX10/2xTCX5 */
#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS
    Word8 isTNSActive,  /**< in: flag indicating if the TNS is active */
#else
    Word16 isTNSActive,  /**< in: flag indicating if the TNS is active */
#endif
    Word16 isTransition, /**< in: flag indicating if the i   is the transition from from ACELP to TCX20/TCX10 */
    Word16 frameno       /**< in: flag indicating index of current subframe */
);
@@ -2752,7 +2756,7 @@ void IGF_ErodeSpectrum_ivas_fx(
    const Word16 igfGridIdx,                 /* i  : IGF grid index                 */
    const Word16 mct_on );
#endif

#ifndef FIX_2346_DUPLICATED_IGF_FUNCTIONS
void IGFEncApplyMono_fx(
    const IGF_ENC_INSTANCE_HANDLE hInstance, /* i  :     | instance handle of IGF Encoder                         */
    const Word16 igfGridIdx,                 /* i  : Q0  | IGF grid index                                         */
@@ -2779,6 +2783,21 @@ void IGFEncApplyMono_ivas_fx(
    const Word16 sp_aud_decision0, /* i  : first stage switching decision                         */
    const Word16 vad_hover_flag    /* i  : VAD hangover flag                                      */
);
#else
void IGFEncApplyMono_fx(
    Encoder_State *st,             /* i  : Encoder state                                          */
    Word16 powerSpectrum_len,      /* i  : length of pPowerSpectrum_fx                            */
    const Word16 igfGridIdx,       /* i  : IGF grid index                                         */
    Word32 *pMDCTSpectrum_fx,      /* i/o: MDCT spectrum                                          */
    Word16 e_mdct,                 /* i  : exponent of pMDCTspectrum                              */
    Word32 *pPowerSpectrum_fx,     /* i/o: MDCT^2 + MDST^2 spectrum, or estimate                  */
    Word16 *e_ps,                  /* i  : exponent of pPowerSpectrum                             */
    const Word16 isTCX20,          /* i  : flag indicating if the input is TCX20 or TCX10/2xTCX5  */
    const Word8 isTNSActive,       /* i  : flag indicating if the TNS is active                   */
    const Word16 sp_aud_decision0, /* i  : first stage switching decision                         */
    const Word16 vad_hover_flag    /* i  : VAD hangover flag                                      */
);
#endif

#ifndef FIX_2346_DUPLICATED_IGF_FUNCTIONS
void IGFEncConcatenateBitstream_ivas_fx(
+12 −1
Original line number Diff line number Diff line
@@ -3764,7 +3764,11 @@ void ProcessIGF_fx(
    Word32 pPowerSpectrum[], /* i  : MDCT^2 + MDST^2 spectrum, or estimate */
    Word16 *pPowerSpectrum_e,
    Word16 isTCX20,      /* i  : flag indicating if the input is TCX20 or TCX10/2xTCX5 */
#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS
    Word8 isTNSActive,  /* i  : flag indicating if the TNS is active */
#else
    Word16 isTNSActive,  /* i  : flag indicating if the TNS is active */
#endif
    Word16 isTransition, /* i  : flag indicating if the input is the transition from from ACELP to TCX20/TCX10 */
    Word16 frameno       /* i  : flag indicating index of current subframe */
)
@@ -3804,7 +3808,9 @@ void ProcessIGF_fx(
        }
    }


#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS
    IGFEncApplyMono_fx( st, 0, igfGridIdx, pMDCTSpectrum, *pMDCTSpectrum_e, pPowerSpectrum, pPowerSpectrum_e, isTCX20, isTNSActive, 0, 0 );
#else
    IGFEncApplyMono_fx( hInstance,     /**< in: instance handle of IGF Encoder */
                        igfGridIdx,    /**< in: IGF grid index */
                        st,            /**< in: Encoder state */
@@ -3815,6 +3821,7 @@ void ProcessIGF_fx(
                        isTCX20,     /**< in: flag indicating if the input is TCX20 or TCX10/2xTCX5 */
                        isTNSActive, /**< in: flag indicating if the TNS is active */
                        ( st->last_core == ACELP_CORE ) );
#endif
    {
        const Word32 tns_predictionGain = st->hIGFEnc->tns_predictionGain;
        const Word16 startLine = st->hIGFEnc->infoStartLine;
@@ -3964,7 +3971,11 @@ void ProcessIGF_ivas_fx(

    IGFSaveSpectrumForITF_ivas_fx( hIGFEnc, igfGridIdx, pITFMDCTSpectrum, sub( Q31, q_ITFMDCTSpectrum ) );

#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS
    IGFEncApplyMono_fx( st, powerSpec_len, igfGridIdx, pMDCTSpectrum, sub( Q31, *q_spectrum ), pPowerSpectrum, exp_powerSpec, isTCX20, st->hTcxEnc->fUseTns[frameno], sp_aud_decision0, vad_hover_flag );
#else
    IGFEncApplyMono_ivas_fx( st, powerSpec_len, igfGridIdx, pMDCTSpectrum, sub( Q31, *q_spectrum ), pPowerSpectrum, exp_powerSpec, isTCX20, st->hTcxEnc->fUseTns[frameno], sp_aud_decision0, vad_hover_flag );
#endif

    curr_order = 0;
    move16();