Loading lib_enc/transient_detection_fx.c +75 −2 Original line number Diff line number Diff line Loading @@ -85,7 +85,7 @@ static void GetAttackForTCXDecision( Word32 const *pSubblockNrg, Word32 const *p move16(); move16(); bIsAttackPresent = FALSE; attackIndex = -1; attackIndex = 0; /* Search for the last attack in the subblocks */ if ( s_or( (Word16) GT_32( L_shr( pSubblockNrg[-1], ATTACKTHRESHOLD_E ), Mpy_32_16_1( pAccSubblockNrg[-1], attackRatioThreshold ) ), L_sub( L_shr( pSubblockNrg[-2], ATTACKTHRESHOLD_E ), Mpy_32_16_1( pAccSubblockNrg[-2], attackRatioThreshold ) ) > 0 ) ) Loading Loading @@ -142,6 +142,79 @@ static void GetAttackForTCXDecision( Word32 const *pSubblockNrg, Word32 const *p *pbIsAttackPresent = bIsAttackPresent; } static void GetAttackForTCXDecision_ivas_fx( Word32 const *pSubblockNrg, Word32 const *pAccSubblockNrg, Word16 nSubblocks, Word16 nPastSubblocks, Word16 attackRatioThreshold, Word16 *pbIsAttackPresent, Word16 *pAttackIndex ) { Word16 i; Word16 bIsAttackPresent, attackIndex; Word16 attackRatioThreshold_1_5; (void) nPastSubblocks; (void) nSubblocks; assert( nSubblocks >= NSUBBLOCKS ); assert( nPastSubblocks >= 2 ); /* attackRatioThreshold_1_5 = attackRatioThreshold * 1.5, exponent is ATTACKTHRESHOLD_E+1 */ attackRatioThreshold_1_5 = add( shr( attackRatioThreshold, 2 ), shr( attackRatioThreshold, 1 ) ); move16(); move16(); bIsAttackPresent = FALSE; attackIndex = -1; /* Search for the last attack in the subblocks */ if ( s_or( (Word16) GT_32( L_shr( pSubblockNrg[-1], ATTACKTHRESHOLD_E ), Mpy_32_16_1( pAccSubblockNrg[-1], attackRatioThreshold ) ), L_sub( L_shr( pSubblockNrg[-2], ATTACKTHRESHOLD_E ), Mpy_32_16_1( pAccSubblockNrg[-2], attackRatioThreshold ) ) > 0 ) ) { move16(); bIsAttackPresent = TRUE; } FOR( i = 0; i < NSUBBLOCKS; i++ ) { IF( GT_32( L_shr( pSubblockNrg[i], ATTACKTHRESHOLD_E ), Mpy_32_16_1( pAccSubblockNrg[i], attackRatioThreshold ) ) ) { if ( i < 6 ) { move16(); bIsAttackPresent = TRUE; } if ( s_and( (Word16) NE_16( attackIndex, 2 ), (Word16) NE_16( attackIndex, 6 ) ) ) { move16(); attackIndex = i; } } ELSE /* no attack, but set index anyway in case of strong energy increase */ { IF( s_and( ( (Word16) GT_32( L_shr( pSubblockNrg[i], 1 + ATTACKTHRESHOLD_E ), Mpy_32_16_1( pSubblockNrg[sub( i, 1 )], attackRatioThreshold_1_5 ) ) ), ( L_sub( L_shr( pSubblockNrg[i], 1 + ATTACKTHRESHOLD_E ), Mpy_32_16_1( pSubblockNrg[sub( i, 2 )], attackRatioThreshold_1_5 ) ) > 0 ) ) ) { if ( s_and( (Word16) NE_16( attackIndex, 2 ), (Word16) NE_16( attackIndex, 6 ) ) ) { move16(); attackIndex = i; } } } } /* avoid post-echos on click sounds (very short transients) due to TNS aliasing */ if ( EQ_16( attackIndex, 4 ) ) { move16(); attackIndex = 7; } if ( EQ_16( attackIndex, 5 ) ) { move16(); attackIndex = 6; } move16(); move16(); *pAttackIndex = attackIndex; *pbIsAttackPresent = bIsAttackPresent; } void GetAttackForTCXDecision_fx( Word32 const *pSubblockNrg, Word32 const *pAccSubblockNrg, Word16 nSubblocks, Word16 nPastSubblocks, Word16 attackRatioThreshold, Word16 *pbIsAttackPresent, Word16 *pAttackIndex ) { Loading Loading @@ -257,7 +330,7 @@ void InitTransientDetection_ivas_fx( Word16 nFrameLength, /* Init a subblock energies buffer used for the TCX Short/Long decision. */ InitSubblockEnergies_ivas_fx( nFrameLength, nTCXDelay, &pTransientDetection->delayBuffer, &pTransientDetection->subblockEnergies ); /* Init the TCX Short/Long transient detector. */ InitTransientDetector_ivas_fx( &pTransientDetection->subblockEnergies, nTCXDelay, NSUBBLOCKS, GetAttackForTCXDecision, 17408 /*8.5f/(1<<ATTACKTHRESHOLD_E) Q15*/, &pTransientDetection->transientDetector ); InitTransientDetector_ivas_fx( &pTransientDetection->subblockEnergies, nTCXDelay, NSUBBLOCKS, GetAttackForTCXDecision_ivas_fx, 17408 /*8.5f/(1<<ATTACKTHRESHOLD_E) Q15*/, &pTransientDetection->transientDetector ); /* We need two past subblocks for the TCX TD and NSUBBLOCKS+1 for the temporal flatness measure FOR the TCX LTP. */ IF( ext_mem_flag ) { Loading Loading
lib_enc/transient_detection_fx.c +75 −2 Original line number Diff line number Diff line Loading @@ -85,7 +85,7 @@ static void GetAttackForTCXDecision( Word32 const *pSubblockNrg, Word32 const *p move16(); move16(); bIsAttackPresent = FALSE; attackIndex = -1; attackIndex = 0; /* Search for the last attack in the subblocks */ if ( s_or( (Word16) GT_32( L_shr( pSubblockNrg[-1], ATTACKTHRESHOLD_E ), Mpy_32_16_1( pAccSubblockNrg[-1], attackRatioThreshold ) ), L_sub( L_shr( pSubblockNrg[-2], ATTACKTHRESHOLD_E ), Mpy_32_16_1( pAccSubblockNrg[-2], attackRatioThreshold ) ) > 0 ) ) Loading Loading @@ -142,6 +142,79 @@ static void GetAttackForTCXDecision( Word32 const *pSubblockNrg, Word32 const *p *pbIsAttackPresent = bIsAttackPresent; } static void GetAttackForTCXDecision_ivas_fx( Word32 const *pSubblockNrg, Word32 const *pAccSubblockNrg, Word16 nSubblocks, Word16 nPastSubblocks, Word16 attackRatioThreshold, Word16 *pbIsAttackPresent, Word16 *pAttackIndex ) { Word16 i; Word16 bIsAttackPresent, attackIndex; Word16 attackRatioThreshold_1_5; (void) nPastSubblocks; (void) nSubblocks; assert( nSubblocks >= NSUBBLOCKS ); assert( nPastSubblocks >= 2 ); /* attackRatioThreshold_1_5 = attackRatioThreshold * 1.5, exponent is ATTACKTHRESHOLD_E+1 */ attackRatioThreshold_1_5 = add( shr( attackRatioThreshold, 2 ), shr( attackRatioThreshold, 1 ) ); move16(); move16(); bIsAttackPresent = FALSE; attackIndex = -1; /* Search for the last attack in the subblocks */ if ( s_or( (Word16) GT_32( L_shr( pSubblockNrg[-1], ATTACKTHRESHOLD_E ), Mpy_32_16_1( pAccSubblockNrg[-1], attackRatioThreshold ) ), L_sub( L_shr( pSubblockNrg[-2], ATTACKTHRESHOLD_E ), Mpy_32_16_1( pAccSubblockNrg[-2], attackRatioThreshold ) ) > 0 ) ) { move16(); bIsAttackPresent = TRUE; } FOR( i = 0; i < NSUBBLOCKS; i++ ) { IF( GT_32( L_shr( pSubblockNrg[i], ATTACKTHRESHOLD_E ), Mpy_32_16_1( pAccSubblockNrg[i], attackRatioThreshold ) ) ) { if ( i < 6 ) { move16(); bIsAttackPresent = TRUE; } if ( s_and( (Word16) NE_16( attackIndex, 2 ), (Word16) NE_16( attackIndex, 6 ) ) ) { move16(); attackIndex = i; } } ELSE /* no attack, but set index anyway in case of strong energy increase */ { IF( s_and( ( (Word16) GT_32( L_shr( pSubblockNrg[i], 1 + ATTACKTHRESHOLD_E ), Mpy_32_16_1( pSubblockNrg[sub( i, 1 )], attackRatioThreshold_1_5 ) ) ), ( L_sub( L_shr( pSubblockNrg[i], 1 + ATTACKTHRESHOLD_E ), Mpy_32_16_1( pSubblockNrg[sub( i, 2 )], attackRatioThreshold_1_5 ) ) > 0 ) ) ) { if ( s_and( (Word16) NE_16( attackIndex, 2 ), (Word16) NE_16( attackIndex, 6 ) ) ) { move16(); attackIndex = i; } } } } /* avoid post-echos on click sounds (very short transients) due to TNS aliasing */ if ( EQ_16( attackIndex, 4 ) ) { move16(); attackIndex = 7; } if ( EQ_16( attackIndex, 5 ) ) { move16(); attackIndex = 6; } move16(); move16(); *pAttackIndex = attackIndex; *pbIsAttackPresent = bIsAttackPresent; } void GetAttackForTCXDecision_fx( Word32 const *pSubblockNrg, Word32 const *pAccSubblockNrg, Word16 nSubblocks, Word16 nPastSubblocks, Word16 attackRatioThreshold, Word16 *pbIsAttackPresent, Word16 *pAttackIndex ) { Loading Loading @@ -257,7 +330,7 @@ void InitTransientDetection_ivas_fx( Word16 nFrameLength, /* Init a subblock energies buffer used for the TCX Short/Long decision. */ InitSubblockEnergies_ivas_fx( nFrameLength, nTCXDelay, &pTransientDetection->delayBuffer, &pTransientDetection->subblockEnergies ); /* Init the TCX Short/Long transient detector. */ InitTransientDetector_ivas_fx( &pTransientDetection->subblockEnergies, nTCXDelay, NSUBBLOCKS, GetAttackForTCXDecision, 17408 /*8.5f/(1<<ATTACKTHRESHOLD_E) Q15*/, &pTransientDetection->transientDetector ); InitTransientDetector_ivas_fx( &pTransientDetection->subblockEnergies, nTCXDelay, NSUBBLOCKS, GetAttackForTCXDecision_ivas_fx, 17408 /*8.5f/(1<<ATTACKTHRESHOLD_E) Q15*/, &pTransientDetection->transientDetector ); /* We need two past subblocks for the TCX TD and NSUBBLOCKS+1 for the temporal flatness measure FOR the TCX LTP. */ IF( ext_mem_flag ) { Loading