Commit 3a15a1e3 authored by Fabian Bauer's avatar Fabian Bauer
Browse files

added macro HARMONIZE_2508_InitTransientDetection and code

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

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

+17 −0
Original line number Diff line number Diff line
@@ -1200,6 +1200,22 @@ ivas_error init_encoder_fx(
        return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Transient Detection\n" ) );
    }

#ifdef HARMONIZE_2508_InitTransientDetection
    {
        Word16 nTCXDelay = 0;
        move16();
        Word16 ext_mem_flag = 1;
        move16();

        IF( EQ_16( st->element_mode, EVS_MONO ) )
        {
            nTCXDelay = NS2SA_FX2( st->input_Fs, DELAY_FIR_RESAMPL_NS );
            ext_mem_flag = 0;
        }

        InitTransientDetection_fx( input_frame, nTCXDelay, st->hTranDet, ext_mem_flag, st->element_mode );
    }
#else
    IF( GT_16( st->element_mode, EVS_MONO ) )
    {
        InitTransientDetection_ivas_fx( input_frame, 0, st->hTranDet, 1 );
@@ -1208,6 +1224,7 @@ ivas_error init_encoder_fx(
    {
        InitTransientDetection_fx( input_frame, NS2SA_FX2( st->input_Fs, DELAY_FIR_RESAMPL_NS ), st->hTranDet );
    }
#endif

    /*-----------------------------------------------------------------*
     * IVAS parameters
+4 −1
Original line number Diff line number Diff line
@@ -1184,8 +1184,11 @@ static ivas_error ivas_mc_enc_reconfig_fx(
            {
                return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Transient Detection\n" ) );
            }

#ifdef HARMONIZE_2508_InitTransientDetection
            InitTransientDetection_fx( extract_l( Mult_32_16( st->input_Fs, INV_FRAME_PER_SEC_Q15 ) ), NS2SA_FX2( st->input_Fs, DELAY_FIR_RESAMPL_NS ), st->hTranDet, 0, st->element_mode );
#else
            InitTransientDetection_ivas_fx( extract_l( Mult_32_16( st->input_Fs, INV_FRAME_PER_SEC_Q15 ) ), NS2SA_FX2( st->input_Fs, DELAY_FIR_RESAMPL_NS ), st->hTranDet, 0 );
#endif
        }

        IF( st->hIGFEnc == NULL )
+9 −0
Original line number Diff line number Diff line
@@ -878,6 +878,14 @@ void calculate_hangover_attenuation_gain_fx(
 *        Don't include the delay of the MDCT overlap.
 * @param pTransientDetection Structure to be initialized. It contains all transient detectors to be used.
 */
#ifdef HARMONIZE_2508_InitTransientDetection
void InitTransientDetection_fx(
    const Word16 nFrameLength,
    const Word16 nTCXDelay,
    TRAN_DET_HANDLE hTranDet,
    const Word16 ext_mem_flag,
    Word16 element_mode );
#else
void InitTransientDetection_fx(
    const Word16 nFrameLength,
    const Word16 nTCXDelay,
@@ -888,6 +896,7 @@ void InitTransientDetection_ivas_fx(
    const Word16 nTCXDelay,
    TRAN_DET_HANDLE hTranDet,
    const Word16 ext_mem_flag );
#endif

/** Runs transient detection.
 * Runs all transient detectors defined in pTransientDetection
+68 −4
Original line number Diff line number Diff line
@@ -375,7 +375,7 @@ static void InitTCXTransientDetector(
/*              Interface functions             */
/*                                              */
/************************************************/

#ifndef HARMONIZE_2508_InitTransientDetection
void InitTransientDetection_fx(
    const Word16 nFrameLength,
    const Word16 nTCXDelay,
@@ -400,27 +400,75 @@ void InitTransientDetection_fx(

    return;
}
#endif


#ifdef HARMONIZE_2508_InitTransientDetection
void InitTransientDetection_fx(
    const Word16 nFrameLength,
    const Word16 nTCXDelay,
    TRAN_DET_HANDLE hTranDet,
    const Word16 ext_mem_flag,
    Word16 element_mode )
#else
void InitTransientDetection_ivas_fx(
    const Word16 nFrameLength,
    const Word16 nTCXDelay,
    TRAN_DET_HANDLE hTranDet,
    const Word16 ext_mem_flag )
#endif
{
    /* Init the delay buffer. */
    InitDelayBuffer( nFrameLength, nTCXDelay, &hTranDet->delayBuffer );


    /* 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*/ );
#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*/ );
@@ -434,9 +482,24 @@ void InitTransientDetection_ivas_fx(
    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*/


    /* We need two past subblocks for the TCX TD and NSUBBLOCKS+1 for the temporal flatness measure FOR the TCX LTP. */
#ifdef HARMONIZE_2508_InitTransientDetection
    IF( ext_mem_flag && GT_32( element_mode, EVS_MONO ) )
    {
        hTranDet->transientDetector.pSubblockEnergies->nDelay =
            add( hTranDet->transientDetector.pSubblockEnergies->nDelay, add( ( NSUBBLOCKS + 1 ), ( NSUBBLOCKS_SHIFT + 1 ) ) );
        move16();
    }
    ELSE
    {
        hTranDet->transientDetector.pSubblockEnergies->nDelay =
            add( hTranDet->transientDetector.pSubblockEnergies->nDelay, NSUBBLOCKS + 1 );
        move16();
    }
#else
    IF( ext_mem_flag )
    {
        hTranDet->transientDetector.pSubblockEnergies->nDelay =
@@ -449,6 +512,7 @@ void InitTransientDetection_ivas_fx(
            add( hTranDet->transientDetector.pSubblockEnergies->nDelay, NSUBBLOCKS + 1 );
        move16();
    }
#endif

    return;
}