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

add macro HARMONIZE_2508_InitTransientDetector and code

parent c8c7d5d0
Loading
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -105,6 +105,7 @@
#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  */

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

+60 −2
Original line number Diff line number Diff line
@@ -48,8 +48,12 @@ static void InitSubblockEnergies_fx( const Word16 nFrameLength, const Word16 nDe
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 );
#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 );
@@ -348,10 +352,18 @@ 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;
@@ -402,18 +414,26 @@ void InitTransientDetection_ivas_fx(

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


    /* Init the TCX Short/Long transient detector. */
#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


    /* We need two past subblocks for the TCX TD and NSUBBLOCKS+1 for the temporal flatness measure FOR the TCX LTP. */
@@ -1277,6 +1297,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
static void InitTransientDetector_fx(
    SubblockEnergies *pSubblockEnergies,
    const Word16 nDelay,
@@ -1312,8 +1333,18 @@ static void InitTransientDetector_fx(

    return;
}
#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_ivas_fx(
    SubblockEnergies *pSubblockEnergies,
    const Word16 nDelay,
@@ -1321,7 +1352,25 @@ static void InitTransientDetector_ivas_fx(
    const TCheckSubblocksForAttack_fx pCheckSubblocksForAttack,
    const Word16 attackRatioThreshold,
    TransientDetector *pTransientDetector )
#endif
{
#ifdef HARMONIZE_2508_InitTransientDetector
    Word16 nMaxBuffSize;
    IF( EQ_32( element_mode, EVS_MONO ) )
    {
        nMaxBuffSize = sizeof( pSubblockEnergies->subblockNrg ) / sizeof( pSubblockEnergies->subblockNrg[0] );
    }
    ELSE
    {
        nMaxBuffSize = NSUBBLOCKS + MAX_TD_DELAY;
        move16();
    }

    assert( ( pSubblockEnergies != NULL ) && ( pSubblockEnergies->pDelayBuffer != NULL ) && ( pTransientDetector != NULL ) && ( pSubblockEnergies->pDelayBuffer->nSubblockSize != 0 ) );
    pTransientDetector->pSubblockEnergies = pSubblockEnergies;
    pTransientDetector->nDelay = idiv1616( sub( nDelay, pSubblockEnergies->nPartialDelay ), pSubblockEnergies->pDelayBuffer->nSubblockSize );
    move16();
#else
    const Word16 nMaxBuffSize = NSUBBLOCKS + MAX_TD_DELAY;
    move16();

@@ -1337,6 +1386,7 @@ static void InitTransientDetector_ivas_fx(
        pTransientDetector->nDelay = 0;
        move16();
    }
#endif
    assert( nDelay == pTransientDetector->nDelay * pSubblockEnergies->pDelayBuffer->nSubblockSize + pSubblockEnergies->nPartialDelay );
    assert( pTransientDetector->nDelay < nMaxBuffSize );
    pSubblockEnergies->nDelay = s_max( pSubblockEnergies->nDelay, pTransientDetector->nDelay );
@@ -1353,9 +1403,17 @@ static void InitTransientDetector_ivas_fx(
    move16();
    pTransientDetector->attackIndex = -1;
    move16();
#ifdef HARMONIZE_2508_InitTransientDetector
    IF( GT_32( element_mode, EVS_MONO ) )
    {
        pTransientDetector->pSubblockEnergies->ramp_up_flag = 0x0;
        move16();
    }
#else
    pTransientDetector->pSubblockEnergies->ramp_up_flag = 0x0;
    move16();

#endif
    return;
}