Commit f7f0b855 authored by Fabian Bauer's avatar Fabian Bauer
Browse files

straighten macros

parent 3a15a1e3
Loading
Loading
Loading
Loading
Loading
+1 −4
Original line number Diff line number Diff line
@@ -103,10 +103,7 @@
#define HARMONIZE_DCT                                   /* VA: removal of duplicated DCT functions */
#define FIX_2489_HARMONIZE_FdCng_encodeSID              /* FhG: harmonize FdCng_encodeSID_fx() and FdCng_encodeSID_ivas_fx()  */
#define FIX_1527_CMR_BITRATE_IDX                        /* Fix for incorrect bitrate idx packed in rtp CMR E-byte */
#define HARMONIZE_2508_GetAttackForTCXDecision          /* FhG: harmonize GetAttackForTCXDecision derivates for evs/ivas  */
#define HARMONIZE_2508_InitSubblockEnergies             /* FhG: harmonize InitSubblockEnergies derivates for evs/ivas  */
#define HARMONIZE_2508_InitTransientDetector            /* FhG: harmonize InitTransientDetector derivates for evs/ivas  */
#define HARMONIZE_2508_InitTransientDetection           /* FhG: harmonize InitTransientDetection derivates for evs/ivas  */
#define HARMONIZE_2508_InitTransientDetection          /* FhG: harmonize GetAttackForTCXDecision derivates for evs/ivas  */

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

+1 −1
Original line number Diff line number Diff line
@@ -160,7 +160,7 @@ typedef struct


/* Attack detection function. */
#ifdef HARMONIZE_2508_GetAttackForTCXDecision
#ifdef HARMONIZE_2508_InitTransientDetection
typedef void ( *TCheckSubblocksForAttack_fx )( Word32 const *pSubblockNrg, Word32 const *pAccSubblockNrg, Word16 nSubblocks, Word16 nPastSubblocks, Word16 attackRatioThreshold, Word16 *pbIsAttackPresent, Word16 *pAttackIndex, Word16 element_mode );
#else
typedef void ( *TCheckSubblocksForAttack_fx )( Word32 const *pSubblockNrg, Word32 const *pAccSubblockNrg, Word16 nSubblocks, Word16 nPastSubblocks, Word16 attackRatioThreshold, Word16 *pbIsAttackPresent, Word16 *pAttackIndex );
+33 −104
Original line number Diff line number Diff line
@@ -42,27 +42,21 @@
/************************************************/

static void InitDelayBuffer( const Word16 nFrameLength, const Word16 nDelay, DelayBuffer *pDelayBuffer );
#ifdef HARMONIZE_2508_InitSubblockEnergies
#ifdef HARMONIZE_2508_InitTransientDetection
static void InitSubblockEnergies_fx( const Word16 nFrameLength, const Word16 nDelay, DelayBuffer *pDelayBuffer, SubblockEnergies *pSubblockEnergies, Word16 element_mode );
static void InitTransientDetector_fx( SubblockEnergies *pSubblockEnergies, const Word16 nDelay, const Word16 nSubblocksToCheck, const TCheckSubblocksForAttack_fx pCheckSubblocksForAttack, const Word16 attackRatioThreshold, TransientDetector *pTransientDetector, Word16 element_mode );
static void RunTransientDetector_fx( TransientDetector *pTransientDetector, Word16 element_mode );
#else
static void InitSubblockEnergies( const Word16 nFrameLength, const Word16 nDelay, DelayBuffer *pDelayBuffer, SubblockEnergies *pSubblockEnergies );
static void InitSubblockEnergies_ivas_fx( const Word16 nFrameLength, const Word16 nDelay, DelayBuffer *pDelayBuffer, SubblockEnergies *pSubblockEnergies );
#endif
#ifdef HARMONIZE_2508_InitTransientDetector
static void InitTransientDetector_fx( SubblockEnergies *pSubblockEnergies, const Word16 nDelay, const Word16 nSubblocksToCheck, const TCheckSubblocksForAttack_fx pCheckSubblocksForAttack, const Word16 attackRatioThreshold, TransientDetector *pTransientDetector, Word16 element_mode );
#else
static void InitTransientDetector_fx( SubblockEnergies *pSubblockEnergies, const Word16 nDelay, const Word16 nSubblocksToCheck, const TCheckSubblocksForAttack_fx pCheckSubblocksForAttack, const Word16 attackRatioThreshold, TransientDetector *pTransientDetector );
static void InitTransientDetector_ivas_fx( SubblockEnergies *pSubblockEnergies, const Word16 nDelay, const Word16 nSubblocksToCheck, const TCheckSubblocksForAttack_fx pCheckSubblocksForAttack, const Word16 attackRatioThreshold, TransientDetector *pTransientDetector );
static void RunTransientDetector_fx( TransientDetector *pTransientDetector );
#endif
static void UpdateDelayBuffer( Word16 const *input, const Word16 nSamplesAvailable, DelayBuffer *pDelayBuffer );
static void HighPassFilter_fx( Word16 const *input, const Word16 length, Word16 *pFirState1, Word16 *pFirState2, Word16 *output );
static void UpdateSubblockEnergies( Word16 const *input, const Word16 nSamplesAvailable, SubblockEnergies *pSubblockEnergies );
static void CalculateSubblockEnergies( Word16 const *input, const Word16 nSamplesAvailable, SubblockEnergies *pSubblockEnergies );
#ifdef HARMONIZE_2508_GetAttackForTCXDecision
static void RunTransientDetector_fx( TransientDetector *pTransientDetector, Word16 element_mode );
#else
static void RunTransientDetector_fx( TransientDetector *pTransientDetector );
#endif
static void CalculateSubblockEnergies_ivas_fx( Word16 const *input, const Word16 nSamplesAvailable, SubblockEnergies *pSubblockEnergies );
static void UpdateSubblockEnergies_ivas_fx( Word16 const *input, const Word16 nSamplesAvailable, SubblockEnergies *pSubblockEnergies );

@@ -77,7 +71,7 @@ static void UpdateSubblockEnergies_ivas_fx( Word16 const *input, const Word16 nS
 * See TCheckSubblocksForAttack_fx FOR definition of parameters.
 * It is assumed that the delay of MDCT overlap was not taken into account, so that the last subblock corresponds to the newest input subblock.
 */
#ifndef HARMONIZE_2508_GetAttackForTCXDecision
#ifndef HARMONIZE_2508_InitTransientDetection
static void GetAttackForTCXDecision(
    Word32 const *pSubblockNrg,
    Word32 const *pAccSubblockNrg,
@@ -162,7 +156,7 @@ static void GetAttackForTCXDecision(


/* GetAttackForTCXDecision() version using 32-bit for energy change values */
#ifndef HARMONIZE_2508_GetAttackForTCXDecision
#ifndef HARMONIZE_2508_InitTransientDetection
static void GetAttackForTCXDecision_ivas_fx(
    Word32 const *pSubblockNrg,
    Word32 const *pAccSubblockNrg,
@@ -187,7 +181,7 @@ static void GetAttackForTCXDecision_fx(
    Word16 bIsAttackPresent, attackIndex;
    Word16 attackRatioThreshold_1_5;
    Word64 W_tmp1, W_tmp2, W_tmp3;
#ifdef HARMONIZE_2508_GetAttackForTCXDecision
#ifdef HARMONIZE_2508_InitTransientDetection
    Word32 L_tmp1, L_tmp2, L_tmp3;
#endif

@@ -200,7 +194,7 @@ static void GetAttackForTCXDecision_fx(
    move16();
    move16();
    bIsAttackPresent = FALSE;
#ifdef HARMONIZE_2508_GetAttackForTCXDecision
#ifdef HARMONIZE_2508_InitTransientDetection
    attackIndex = EQ_16( element_mode, EVS_MONO ) ? 0 : -1;
#else
    attackIndex = -1;
@@ -211,7 +205,7 @@ static void GetAttackForTCXDecision_fx(
    {
        move16();
        bIsAttackPresent = TRUE;
#ifdef HARMONIZE_2508_GetAttackForTCXDecision
#ifdef HARMONIZE_2508_InitTransientDetection
        if ( GT_32( element_mode, EVS_MONO ) )
        {
            attackIndex = 0;
@@ -226,7 +220,7 @@ static void GetAttackForTCXDecision_fx(

    FOR( i = 0; i < NSUBBLOCKS; i++ )
    {
#ifdef HARMONIZE_2508_GetAttackForTCXDecision
#ifdef HARMONIZE_2508_InitTransientDetection
        int condition;
        IF( EQ_16( element_mode, EVS_MONO ) )
        {
@@ -258,7 +252,7 @@ static void GetAttackForTCXDecision_fx(
            {
                move16();
                attackIndex = i;
#ifdef HARMONIZE_2508_GetAttackForTCXDecision
#ifdef HARMONIZE_2508_InitTransientDetection
                IF( GT_16( element_mode, EVS_MONO ) )
                {
#endif
@@ -269,14 +263,14 @@ static void GetAttackForTCXDecision_fx(
                    {
                        attackIndex = add( attackIndex, 1 ); /* avoid minimum overlap to prevent clicks */
                    }
#ifdef HARMONIZE_2508_GetAttackForTCXDecision
#ifdef HARMONIZE_2508_InitTransientDetection
                }
#endif
            }
        }
        ELSE /* no attack, but set index anyway in case of strong energy increase */
        {
#ifdef HARMONIZE_2508_GetAttackForTCXDecision
#ifdef HARMONIZE_2508_InitTransientDetection
            IF( EQ_16( element_mode, EVS_MONO ) )
            {
                L_tmp2 = Mpy_32_16_1( pSubblockNrg[i - 1], attackRatioThreshold_1_5 );
@@ -290,7 +284,7 @@ static void GetAttackForTCXDecision_fx(
                W_tmp2 = W_shr( W_mult_32_16( pSubblockNrg[i - 1], attackRatioThreshold_1_5 ), 1 );
                W_tmp1 = W_shl( pSubblockNrg[i], ( 15 - ( ATTACKTHRESHOLD_E + 1 ) ) );
                W_tmp3 = W_shr( W_mult_32_16( pSubblockNrg[i - 2], attackRatioThreshold_1_5 ), 1 );
#ifdef HARMONIZE_2508_GetAttackForTCXDecision
#ifdef HARMONIZE_2508_InitTransientDetection
                condition = s_and( ( (Word16) GT_64( W_tmp1, W_tmp2 ) ), ( W_sub( W_tmp1, W_tmp3 ) > 0 ) );
            }

@@ -303,7 +297,7 @@ static void GetAttackForTCXDecision_fx(
                    move16();
                    attackIndex = i;

#ifdef HARMONIZE_2508_GetAttackForTCXDecision
#ifdef HARMONIZE_2508_InitTransientDetection
                    IF( GT_32( element_mode, EVS_MONO ) )
                    {
#endif
@@ -316,7 +310,7 @@ static void GetAttackForTCXDecision_fx(
                        {
                            attackIndex = add( attackIndex, 1 ); /* avoid minimum overlap to prevent clicks */
                        }
#ifdef HARMONIZE_2508_GetAttackForTCXDecision
#ifdef HARMONIZE_2508_InitTransientDetection
                    }
#endif
                }
@@ -344,6 +338,7 @@ static void GetAttackForTCXDecision_fx(
}


#ifndef HARMONIZE_2508_InitTransientDetection
/** Initialize TCX transient detector.
 * See InitTransientDetector_fx for definition of parameters.
 */
@@ -352,22 +347,10 @@ static void InitTCXTransientDetector(
    SubblockEnergies *pSubblockEnergies,
    TransientDetector *pTransientDetector )
{
#ifdef HARMONIZE_2508_InitTransientDetector
#ifdef HARMONIZE_2508_GetAttackForTCXDecision
    InitTransientDetector_fx( pSubblockEnergies, nDelay, NSUBBLOCKS, GetAttackForTCXDecision_fx, 17408 /*8.5f/(1<<ATTACKTHRESHOLD_E) Q15*/, pTransientDetector, EVS_MONO );
#else
    InitTransientDetector_fx( pSubblockEnergies, nDelay, NSUBBLOCKS, GetAttackForTCXDecision, 17408 /*8.5f/(1<<ATTACKTHRESHOLD_E) Q15*/, pTransientDetector, EVS_MONO );
#endif
#else
#ifdef HARMONIZE_2508_GetAttackForTCXDecision
    InitTransientDetector_fx( pSubblockEnergies, nDelay, NSUBBLOCKS, GetAttackForTCXDecision_fx, 17408 /*8.5f/(1<<ATTACKTHRESHOLD_E) Q15*/, pTransientDetector );
#else
    InitTransientDetector_fx( pSubblockEnergies, nDelay, NSUBBLOCKS, GetAttackForTCXDecision, 17408 /*8.5f/(1<<ATTACKTHRESHOLD_E) Q15*/, pTransientDetector );
#endif
#endif

    return;
}
#endif


/************************************************/
@@ -385,11 +368,7 @@ void InitTransientDetection_fx(
    InitDelayBuffer( nFrameLength, nTCXDelay, &hTranDet->delayBuffer );

    /* Init a subblock energies buffer used for the TCX Short/Long decision. */
#ifdef HARMONIZE_2508_InitSubblockEnergies
    InitSubblockEnergies_fx( nFrameLength, nTCXDelay, &hTranDet->delayBuffer, &hTranDet->subblockEnergies, EVS_MONO );
#else
    InitSubblockEnergies( nFrameLength, nTCXDelay, &hTranDet->delayBuffer, &hTranDet->subblockEnergies );
#endif

    /* Init the TCX Short/Long transient detector. */
    InitTCXTransientDetector( nTCXDelay, &hTranDet->subblockEnergies, &hTranDet->transientDetector );
@@ -422,66 +401,16 @@ void InitTransientDetection_ivas_fx(

    /* Init a subblock energies buffer used for the TCX Short/Long decision. */
#ifdef HARMONIZE_2508_InitTransientDetection
    IF( EQ_16( element_mode, EVS_MONO ) )
    {
#ifdef HARMONIZE_2508_InitSubblockEnergies
        InitSubblockEnergies_fx( nFrameLength, nTCXDelay, &hTranDet->delayBuffer, &hTranDet->subblockEnergies, EVS_MONO );
#else
        InitSubblockEnergies( nFrameLength, nTCXDelay, &hTranDet->delayBuffer, &hTranDet->subblockEnergies );
#endif
    }
    ELSE
    {
#ifdef HARMONIZE_2508_InitSubblockEnergies
        InitSubblockEnergies_fx( nFrameLength, nTCXDelay, &hTranDet->delayBuffer, &hTranDet->subblockEnergies, 1 /*signal non-evs*/ );
#else
        InitSubblockEnergies_ivas_fx( nFrameLength, nTCXDelay, &hTranDet->delayBuffer, &hTranDet->subblockEnergies );
#endif
    }
#else
#ifdef HARMONIZE_2508_InitSubblockEnergies
    InitSubblockEnergies_fx( nFrameLength, nTCXDelay, &hTranDet->delayBuffer, &hTranDet->subblockEnergies, 1 /*signal non-evs*/ );
    InitSubblockEnergies_fx( nFrameLength, nTCXDelay, &hTranDet->delayBuffer, &hTranDet->subblockEnergies, element_mode );
#else
    InitSubblockEnergies_ivas_fx( nFrameLength, nTCXDelay, &hTranDet->delayBuffer, &hTranDet->subblockEnergies );
#endif
#endif

    /* Init the TCX Short/Long transient detector. */
#ifdef HARMONIZE_2508_InitTransientDetection
    IF( EQ_16( element_mode, EVS_MONO ) )
    {
        InitTCXTransientDetector( nTCXDelay, &hTranDet->subblockEnergies, &hTranDet->transientDetector );
    }
    ELSE
    {
#ifdef HARMONIZE_2508_InitTransientDetector
#ifdef HARMONIZE_2508_GetAttackForTCXDecision
        InitTransientDetector_fx( &hTranDet->subblockEnergies, nTCXDelay, NSUBBLOCKS, GetAttackForTCXDecision_fx, 17408 /*8.5f/(1<<ATTACKTHRESHOLD_E) Q15*/, &hTranDet->transientDetector, 1 /*signal non-evs*/ );
#else
        InitTransientDetector_fx( &hTranDet->subblockEnergies, nTCXDelay, NSUBBLOCKS, GetAttackForTCXDecision_ivas_fx, 17408 /*8.5f/(1<<ATTACKTHRESHOLD_E) Q15*/, &hTranDet->transientDetector, 1 /*signal non-evs*/ );
#endif
#else
#ifdef HARMONIZE_2508_GetAttackForTCXDecision
        InitTransientDetector_ivas_fx( &hTranDet->subblockEnergies, nTCXDelay, NSUBBLOCKS, GetAttackForTCXDecision_fx, 17408 /*8.5f/(1<<ATTACKTHRESHOLD_E) Q15*/, &hTranDet->transientDetector );
#else
        InitTransientDetector_ivas_fx( &hTranDet->subblockEnergies, nTCXDelay, NSUBBLOCKS, GetAttackForTCXDecision_ivas_fx, 17408 /*8.5f/(1<<ATTACKTHRESHOLD_E) Q15*/, &hTranDet->transientDetector );
#endif
#endif
    }
#else
#ifdef HARMONIZE_2508_InitTransientDetector
#ifdef HARMONIZE_2508_GetAttackForTCXDecision
    InitTransientDetector_fx( &hTranDet->subblockEnergies, nTCXDelay, NSUBBLOCKS, GetAttackForTCXDecision_fx, 17408 /*8.5f/(1<<ATTACKTHRESHOLD_E) Q15*/, &hTranDet->transientDetector, 1 /*signal non-evs*/ );
#else
    InitTransientDetector_fx( &hTranDet->subblockEnergies, nTCXDelay, NSUBBLOCKS, GetAttackForTCXDecision_ivas_fx, 17408 /*8.5f/(1<<ATTACKTHRESHOLD_E) Q15*/, &hTranDet->transientDetector, 1 /*signal non-evs*/ );
#endif
#else
#ifdef HARMONIZE_2508_GetAttackForTCXDecision
    InitTransientDetector_ivas_fx( &hTranDet->subblockEnergies, nTCXDelay, NSUBBLOCKS, GetAttackForTCXDecision_fx, 17408 /*8.5f/(1<<ATTACKTHRESHOLD_E) Q15*/, &hTranDet->transientDetector );
    InitTransientDetector_fx( &hTranDet->subblockEnergies, nTCXDelay, NSUBBLOCKS, GetAttackForTCXDecision_fx, 17408 /*8.5f/(1<<ATTACKTHRESHOLD_E) Q15*/, &hTranDet->transientDetector, element_mode );
#else
    InitTransientDetector_ivas_fx( &hTranDet->subblockEnergies, nTCXDelay, NSUBBLOCKS, GetAttackForTCXDecision_ivas_fx, 17408 /*8.5f/(1<<ATTACKTHRESHOLD_E) Q15*/, &hTranDet->transientDetector );
#endif
#endif
#endif /*HARMONIZE_2508_InitTransientDetection*/


@@ -788,7 +717,7 @@ void RunTransientDetection_fx(
    UpdateSubblockEnergies( filteredInput, nSamplesAvailable, pSubblockEnergies );

    /* Run transient detectors. */
#ifdef HARMONIZE_2508_GetAttackForTCXDecision
#ifdef HARMONIZE_2508_InitTransientDetection
    RunTransientDetector_fx( pTransientDetector, EVS_MONO );
#else
    RunTransientDetector_fx( pTransientDetector );
@@ -863,8 +792,8 @@ void RunTransientDetection_ivas_fx(
    UpdateSubblockEnergies_ivas_fx( filteredInput_fx, length, pSubblockEnergies );

    /* Run transient detectors. */
#ifdef HARMONIZE_2508_GetAttackForTCXDecision
    RunTransientDetector_fx( pTransientDetector, 1 );
#ifdef HARMONIZE_2508_InitTransientDetection
    RunTransientDetector_fx( pTransientDetector, 1 /*signal non-EVS*/ );
#else
    RunTransientDetector_fx( pTransientDetector );
#endif
@@ -1253,7 +1182,7 @@ static void InitDelayBuffer(
    return;
}

#ifndef HARMONIZE_2508_InitSubblockEnergies
#ifndef HARMONIZE_2508_InitTransientDetection
static void InitSubblockEnergies(
    const Word16 nFrameLength,
    const Word16 nDelay,
@@ -1288,7 +1217,7 @@ static void InitSubblockEnergies(
#endif


#ifdef HARMONIZE_2508_InitSubblockEnergies
#ifdef HARMONIZE_2508_InitTransientDetection
static void InitSubblockEnergies_fx(
    const Word16 nFrameLength,
    const Word16 nDelay,
@@ -1307,7 +1236,7 @@ static void InitSubblockEnergies_ivas_fx(

    Word16 nMaxBuffSize;

#ifdef HARMONIZE_2508_InitSubblockEnergies
#ifdef HARMONIZE_2508_InitTransientDetection
    IF( EQ_16( element_mode, EVS_MONO ) )
    {
        nMaxBuffSize = sizeof( pSubblockEnergies->subblockNrg ) / sizeof( pSubblockEnergies->subblockNrg[0] );
@@ -1330,7 +1259,7 @@ static void InitSubblockEnergies_ivas_fx(
        set16_fx( pSubblockEnergies->subblockNrgChange_exp, 16, nMaxBuffSize );
        pSubblockEnergies->q_firState = 15;
        move16();
#ifdef HARMONIZE_2508_InitSubblockEnergies
#ifdef HARMONIZE_2508_InitTransientDetection
    }
#endif
    pSubblockEnergies->nDelay = idiv1616_1( nDelay, pDelayBuffer->nSubblockSize );
@@ -1361,7 +1290,7 @@ static void InitSubblockEnergies_ivas_fx(
 * @param attackRatioThreshold Attack ratio threshold with exponent ATTACKTHRESHOLD_E.
 * @param pTransientDetector Structure to be initialized.
 */
#ifndef HARMONIZE_2508_InitTransientDetector
#ifndef HARMONIZE_2508_InitTransientDetection
static void InitTransientDetector_fx(
    SubblockEnergies *pSubblockEnergies,
    const Word16 nDelay,
@@ -1399,7 +1328,7 @@ static void InitTransientDetector_fx(
}
#endif

#ifdef HARMONIZE_2508_InitTransientDetector
#ifdef HARMONIZE_2508_InitTransientDetection
static void InitTransientDetector_fx(
    SubblockEnergies *pSubblockEnergies,
    const Word16 nDelay,
@@ -1418,7 +1347,7 @@ static void InitTransientDetector_ivas_fx(
    TransientDetector *pTransientDetector )
#endif
{
#ifdef HARMONIZE_2508_InitTransientDetector
#ifdef HARMONIZE_2508_InitTransientDetection
    Word16 nMaxBuffSize;
    IF( EQ_16( element_mode, EVS_MONO ) )
    {
@@ -1479,7 +1408,7 @@ static void InitTransientDetector_ivas_fx(
    move16();
    pTransientDetector->attackIndex = -1;
    move16();
#ifdef HARMONIZE_2508_InitTransientDetector
#ifdef HARMONIZE_2508_InitTransientDetection
    IF( GT_16( element_mode, EVS_MONO ) )
    {
        pTransientDetector->pSubblockEnergies->ramp_up_flag = 0x0;
@@ -1535,7 +1464,7 @@ static void HighPassFilter_fx(
    return;
}

#ifdef HARMONIZE_2508_GetAttackForTCXDecision
#ifdef HARMONIZE_2508_InitTransientDetection
static void RunTransientDetector_fx(
    TransientDetector *pTransientDetector,
    Word16 element_mode )
@@ -1557,7 +1486,7 @@ static void RunTransientDetector_fx(
    assert( ( pTransientDetector->CheckSubblocksForAttack_fx != NULL ) );

#define WMC_TOOL_SKIP
#ifdef HARMONIZE_2508_GetAttackForTCXDecision
#ifdef HARMONIZE_2508_InitTransientDetection
    pTransientDetector->CheckSubblocksForAttack_fx( pSubblockNrg, pAccSubblockNrg,
                                                    NSUBBLOCKS + nDelay, nRelativeDelay,
                                                    attackRatioThreshold,