Loading lib_com/ivas_prot_fx.h +2 −1 Original line number Diff line number Diff line Loading @@ -1879,6 +1879,7 @@ void TonalMDCTConceal_Detect_ivas_fx( ); #ifndef HARMONIZE_FUNC void ivas_DetectTonalComponents_fx( Word16 indexOfTonalPeak[], Word16 lowerIndex[], Loading @@ -1899,7 +1900,7 @@ void ivas_DetectTonalComponents_fx( const PsychoacousticParameters *psychParamsCurrent, Word16 element_mode ); #endif ivas_error stereo_dft_dec_create_fx( STEREO_DFT_DEC_DATA_HANDLE *hStereoDft, /* i/o: decoder DFT stereo handle */ const Word32 element_brate, /* i : element bitrate */ Loading lib_com/options.h +1 −0 Original line number Diff line number Diff line Loading @@ -92,6 +92,7 @@ #define HARM_2454_TCX_RES_Q_SPEC /* FhG: harmonization of tcx_res_Q_spec_fx() and tcx_res_Q_spec_ivas_fx() */ #define FIX_FLOAT_1535_ARI_RES_Q_CLEANUP /* FhG: remove dead code from tcx_ari_res_Q_spec() */ #define FIX_2467_RENAME_GSC_FUNCTION /* VA: basop issue 2467: Removal of unused function/table and renaming of _ivas_fx versions to default ones. */ #define HARMONIZE_FUNC /* VA: basop issue 2460: Remove duplicated code: various functions */ /* #################### End BE switches ################################## */ Loading lib_com/prot_fx.h +47 −17 Original line number Diff line number Diff line Loading @@ -2308,6 +2308,7 @@ void E_UTIL_synthesis_fx( const Word16 update, const Word16 m ); #ifndef HARMONIZE_FUNC void synth_mem_updt2( const Word16 L_frame, /* i : frame length */ const Word16 last_L_frame, /* i : frame length */ Loading @@ -2317,15 +2318,18 @@ void synth_mem_updt2( Word16 mem_syn[], /* o : synthesis filter memory for find_target */ const Word16 dec /* i : flag for decoder indication */ ); void ivas_synth_mem_updt2_fx( #else void synth_mem_updt2_fx( #endif const Word16 L_frame, /* i : frame length */ const Word16 last_L_frame, /* i : frame length */ Word16 old_exc[], /* i/o: excitation buffer */ Word16 mem_syn_r[], /* i/o: synthesis filter memory */ Word16 mem_syn2[], /* o : synthesis filter memory for find_target */ Word16 mem_syn[], /* o : synthesis filter memory for find_target */ const Word16 dec ); const Word16 dec /* i : flag for decoder indication */ ); void lerp( const Word16 *f, Loading Loading @@ -5821,6 +5825,27 @@ void concealment_signal_tuning_fx( Word16 *outx_new_fx /*Qoutx_new_fx*/, const Word16 past_core ); #ifdef HARMONIZE_FUNC void DetectTonalComponents_fx( Word16 indexOfTonalPeak[], Word16 lowerIndex[], Word16 upperIndex[], Word16 *pNumIndexes, const Word32 lastPitchLag, const Word32 currentPitchLag, const Word16 lastMDCTSpectrum[], const Word16 lastMDCTSpectrum_exp, const Word16 scaleFactors[], const Word16 scaleFactors_exp[], const Word16 scaleFactors_max_e, const Word32 secondLastPowerSpectrum[], const Word16 secondLastPowerSpectrum_e, const Word16 nSamples, const Word16 nSamplesCore, Word16 floorPowerSpectrum, /* i : lower limit for power spectrum bins */ const PsychoacousticParameters *psychParamsCurrent, const Word16 element_mode ); #else void DetectTonalComponents( Word16 indexOfTonalPeak[], Word16 lowerIndex[], Loading Loading @@ -5858,8 +5883,13 @@ void RefineTonalComponents( const Word16 nSamplesCore, const Word16 floorPowerSpectrum, /* i: lower limit for power spectrum bins */ Word16 element_mode ); #endif #ifdef HARMONIZE_FUNC void RefineTonalComponents_fx( #else void ivas_RefineTonalComponents_fx( #endif Word16 indexOfTonalPeak[], Word16 lowerIndex[], Word16 upperIndex[], Loading @@ -5878,9 +5908,10 @@ void ivas_RefineTonalComponents_fx( const Word16 nSamples, const Word16 nSamplesCore, const Word16 floorPowerSpectrum, /* i: lower limit for power spectrum bins */ Word16 element_mode, const Word16 element_mode, const PsychoacousticParameters *psychParamsCurrent ); #ifndef HARMONIZE_FUNC ivas_error PsychoacousticParameters_Init( const Word32 sr_core, /* i : sampling rate of core-coder */ const Word16 nBins, /* i : Number of bins (spectral lines) */ Loading @@ -5888,8 +5919,8 @@ ivas_error PsychoacousticParameters_Init( const Word16 isTCX20, /* i : Flag indicating if the subband division is for TCX20 or TCX10 */ const Word16 isWarped, /* i : Flag indicating if the scale is linear or warped */ PsychoacousticParameters *pPsychParams ); ivas_error TonalMDCTConceal_Init( #endif ivas_error TonalMDCTConceal_Init_fx( TonalMDCTConcealPtr self, const Word16 nSamples, const Word16 nSamplesCore, Loading @@ -5906,7 +5937,7 @@ ivas_error TonalMDCTConceal_Init_ivas_fx( ); /* Must be called only when a good frame is recieved - concealment is inactive */ void TonalMDCTConceal_SaveFreqSignal( void TonalMDCTConceal_SaveFreqSignal_fx( TonalMDCTConcealPtr self, const Word32 *mdctSpectrum, const Word16 mdctSpectrum_exp, Loading @@ -5927,21 +5958,21 @@ void TonalMDCTConceal_SaveFreqSignal_ivas_fx( const Word16 gain_tcx_exp, const Word16 infoIGFStartLine ); void TonalMDCTConceal_UpdateState( void TonalMDCTConceal_UpdateState_fx( TonalMDCTConcealPtr self, Word16 nNewSamples, Word32 pitchLag, Word16 badBlock, Word8 tonalConcealmentActive ); const Word16 nNewSamples, const Word32 pitchLag, const Word16 badBlock, const Word8 tonalConcealmentActive ); void TonalMDCTConceal_Detect( void TonalMDCTConceal_Detect_fx( const TonalMDCTConcealPtr self, /*IN */ const Word32 pitchLag, /*IN */ Word16 *umIndices, /*OUT*/ Word16 element_mode /* IN */ const Word16 element_mode /* IN */ ); void TonalMDCTConceal_Apply( void TonalMDCTConceal_Apply_fx( const TonalMDCTConcealPtr hTonalMDCTConc, /*IN */ Word32 *mdctSpectrum, /*IN/OUT*/ Word16 *mdctSpectrum_exp /*IN */ Loading @@ -5967,7 +5998,7 @@ void TonalMDCTConceal_InsertNoise_ivas_fx( const Word16 cngLevelBackgroundTrace_e, const Word16 crossOverFreq ); void TonalMDCTConceal_InsertNoise( void TonalMDCTConceal_InsertNoise_fx( const TonalMDCTConcealPtr hTonalMDCTConc, /*IN */ Word32 *mdctSpectrum, /*OUT*/ Word16 *mdctSpectrum_exp, /*OUT*/ Loading @@ -5977,7 +6008,7 @@ void TonalMDCTConceal_InsertNoise( Word16 crossfadeGain, const Word16 crossOverFreq ); void TonalMDCTConceal_SaveTimeSignal( void TonalMDCTConceal_SaveTimeSignal_fx( TonalMDCTConcealPtr hTonalMDCTConc, Word16 *timeSignal, Word16 nNewSamples ); Loading Loading @@ -10597,7 +10628,6 @@ void UnmapIndex_fx( Word32 *Lag /* Q0 */ ); // #define GET_ADJ2( T, L, F ) ( ( ( L ) << ( F ) ) - ( T ) ) #define GET_ADJ2( T, L, F ) ( sub( shl( L, F ), T ) ) Word32 tcx_hm_render_fx( Loading lib_com/syn_filt_fx.c +11 −1 Original line number Diff line number Diff line Loading @@ -548,14 +548,19 @@ void E_UTIL_synthesis_fx( * Update of synthesis filter memories in case of ACELP@12k8 <-> ACELP@16k switching *--------------------------------------------------------------------*/ #ifdef HARMONIZE_FUNC void synth_mem_updt2_fx( #else void ivas_synth_mem_updt2_fx( #endif const Word16 L_frame, /* i : frame length */ const Word16 last_L_frame, /* i : frame length */ Word16 old_exc[], /* i/o: excitation buffer st->Q_syn */ Word16 mem_syn_r[], /* i/o: synthesis filter memory st->Q_syn */ Word16 mem_syn2[], /* o : synthesis filter memory for find_target st->Q_syn */ Word16 mem_syn[], /* o : synthesis filter memory for find_target st->Q_syn */ const Word16 dec ) const Word16 dec /* i : flag for decoder indication */ ) { Word16 mem_syn_r_size_old, mem_syn_r_size_new; Word32 en1, en2; Loading Loading @@ -622,7 +627,11 @@ void ivas_synth_mem_updt2_fx( { Copy( mem_syn2, mem_syn, M ); } return; } #ifndef HARMONIZE_FUNC void synth_mem_updt2( const Word16 L_frame, /* i : frame length */ const Word16 last_L_frame, /* i : frame length */ Loading Loading @@ -660,3 +669,4 @@ void synth_mem_updt2( Copy( mem_syn2, mem_syn, M ); } } #endif lib_dec/TonalComponentDetection_fx.c +138 −44 Original line number Diff line number Diff line Loading @@ -2,8 +2,6 @@ EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #define _USE_MATH_DEFINES #include <assert.h> #include <stdint.h> #include "options.h" Loading @@ -14,23 +12,35 @@ #include "prot_fx.h" #include "ivas_prot_fx.h" /*---------------------------------------------------------------------* * Local function prototypes *---------------------------------------------------------------------*/ static void calcPseudoSpec( const Word32 *mdctSpec, const Word16 mdctSpec_exp, const Word16 nSamples, Word16 floorPowerSpectrum, Word32 *powerSpec, Word16 *powerSpec_exp ); static void getEnvelope( const Word16 nSamples, const Word32 *powerSpec, Word16 F0, Word32 *envelope, Word32 *smoothedSpectrum ); static void GetF0( Word16 const nSamples, Word16 const nSamplesCore, Word32 const *const powerSpectrum, Word32 const pitchLag, Word16 *const pOrigF0, Word16 *const pF0 ); #ifndef HARMONIZE_FUNC static void ivas_GetF0_fx( Word16 const nSamples, Word16 const nSamplesCore, Word32 const *const powerSpectrum, Word32 const pitchLag, Word16 *const pOrigF0, Word16 *const pF0 ); #endif static void findStrongestHarmonics( const Word16 nSamples, const Word32 *powerSpectrum, const Word16 F0, const Word16 nTotalHarmonics, Word16 *pHarmonicIndexes, Word16 *pnHarmonics ); static void CorrectF0( const Word16 *pHarmonicIndexes, const Word16 nHarmonics, Word16 *pF0 ); #ifndef HARMONIZE_FUNC static void ivas_CorrectF0_fx( const Word16 *pHarmonicIndexes, const Word16 nHarmonics, Word16 *pF0 ); #endif static void findCandidates( const Word16 nSamples, const Word32 *MDCTSpectrum, const Word16 MDCTSpectrum_exp, Word16 *thresholdModificationNew, Word16 floorPowerSpectrum ); static void modifyThreshold( Word16 i, Word16 F0, Word16 threshold, Word16 *thresholdModification ); static void modifyThresholds( Word16 F0, Word16 origF0, Word16 *thresholdModification ); #ifdef HARMONIZE_FUNC static void RefineThresholdsUsingPitch_fx( const Word16 nSamples, const Word16 nSamplesCore, const Word32 powerSpectrum[], const Word32 lastPitchLag, const Word32 currentPitchLag, Word16 *pF0, Word16 *thresholdModification ); static void findTonalComponents_fx( Word16 *indexOfTonalPeak, Word16 *lowerIndex, Word16 *upperIndex, Word16 *numIndexes, Word16 nSamples, const Word32 *powerSpectrum, const Word16 powerSpectrum_e, Word16 F0, Word16 *thresholdModification, Word16 element_mode ); #else static void RefineThresholdsUsingPitch( const Word16 nSamples, const Word16 nSamplesCore, const Word32 powerSpectrum[], const Word32 lastPitchLag, const Word32 currentPitchLag, Word16 *pF0, Word16 *thresholdModification ); static void ivas_RefineThresholdsUsingPitch_fx( const Word16 nSamples, const Word16 nSamplesCore, const Word32 powerSpectrum[], const Word32 lastPitchLag, const Word32 currentPitchLag, Word16 *pF0, Word16 *thresholdModification ); static void findTonalComponents( Word16 *indexOfTonalPeak, Word16 *lowerIndex, Word16 *upperIndex, Word16 *numIndexes, Word16 nSamples, const Word32 *powerSpectrum, Word16 F0, Word16 *thresholdModification, Word16 element_mode ); static void ivas_findTonalComponents_fx( Word16 *indexOfTonalPeak, Word16 *lowerIndex, Word16 *upperIndex, Word16 *numIndexes, Word16 nSamples, const Word32 *powerSpectrum, const Word16 powerSpectrum_e, Word16 F0, Word16 *thresholdModification, Word16 element_mode ); #endif /*-------------------------------------------------------------------* * DetectTonalComponents() Loading @@ -41,7 +51,11 @@ static void ivas_findTonalComponents_fx( Word16 *indexOfTonalPeak, Word16 *lower * pNumIndexes accordingly. *-------------------------------------------------------------------*/ #ifdef HARMONIZE_FUNC void DetectTonalComponents_fx( #else void ivas_DetectTonalComponents_fx( #endif Word16 indexOfTonalPeak[], /*Q0*/ Word16 lowerIndex[], /*Q0*/ Word16 upperIndex[], /*Q0*/ Loading @@ -59,7 +73,11 @@ void ivas_DetectTonalComponents_fx( const Word16 nSamplesCore, Word16 floorPowerSpectrum, /* i : lower limit for power spectrum bins Q0*/ const PsychoacousticParameters *psychParamsCurrent, #ifdef HARMONIZE_FUNC const Word16 element_mode /* i : element mode */ #else Word16 element_mode /* i : element mode */ #endif ) { Word16 F0; Loading @@ -71,16 +89,29 @@ void ivas_DetectTonalComponents_fx( set32_fx( pScaledMdctSpectrum, 0, L_FRAME_MAX ); #ifdef HARMONIZE_FUNC IF( element_mode == EVS_MONO ) { mdct_shaping_16( lastMDCTSpectrum, nSamplesCore, nSamples, scaleFactors, scaleFactors_exp, scaleFactors_max_e, pScaledMdctSpectrum ); lastMDCTSpect_exp = add( lastMDCTSpectrum_exp, scaleFactors_max_e ); } ELSE { #endif FOR( Word16 i = 0; i < nSamples; i++ ) { pScaledMdctSpectrum[i] = L_shl( lastMDCTSpectrum[i], 16 ); /*15-lastMDCTSpectrum_exp+16 -> 31 - lastMDCTSpectrum_exp*/ move32(); } #ifndef HARMONIZE_FUNC FOR( Word16 i = 0; i < FDNS_NPTS; i++ ) { sns_int_scf_fx[i] = L_shl_sat( scaleFactors[i], add( 1, scaleFactors_exp[i] ) ); // Q16 move32(); } #endif IF( psychParamsCurrent == NULL ) { nBands = FDNS_NPTS; Loading @@ -91,6 +122,14 @@ void ivas_DetectTonalComponents_fx( } ELSE { #ifdef HARMONIZE_FUNC FOR( Word16 i = 0; i < FDNS_NPTS; i++ ) { sns_int_scf_fx[i] = L_shl_sat( scaleFactors[i], add( 1, scaleFactors_exp[i] ) ); // Q16 move32(); } #endif q_pScaledMdctSpectrum = sub( 31, lastMDCTSpectrum_exp ); sns_shape_spectrum_fx( pScaledMdctSpectrum, &q_pScaledMdctSpectrum, psychParamsCurrent, sns_int_scf_fx, 16, nSamplesCore, NULL ); q_pScaledMdctSpectrum = add( q_pScaledMdctSpectrum, 1 ); Loading @@ -112,19 +151,31 @@ void ivas_DetectTonalComponents_fx( /* Guard bit */ lastMDCTSpect_exp = add( lastMDCTSpect_exp, 1 ); scale_sig32( pScaledMdctSpectrum, nSamples, -1 ); /*q_pScaledMdctSpectrum - 1*/ #ifdef HARMONIZE_FUNC } #endif /* Find peak candidates in the last frame. */ findCandidates( nSamples, pScaledMdctSpectrum, lastMDCTSpect_exp, thresholdModification, floorPowerSpectrum ); /* Refine peak candidates using the pitch information */ #ifdef HARMONIZE_FUNC RefineThresholdsUsingPitch_fx( nSamples, nSamplesCore, secondLastPowerSpectrum, lastPitchLag, currentPitchLag, &F0, thresholdModification ); #else ivas_RefineThresholdsUsingPitch_fx( nSamples, nSamplesCore, secondLastPowerSpectrum, lastPitchLag, currentPitchLag, &F0, thresholdModification ); #endif /* Find peaks in the second last frame */ #ifdef HARMONIZE_FUNC findTonalComponents_fx( indexOfTonalPeak, lowerIndex, upperIndex, pNumIndexes, nSamples, secondLastPowerSpectrum, secondLastPowerSpectrum_e, F0, thresholdModification, element_mode ); #else ivas_findTonalComponents_fx( indexOfTonalPeak, lowerIndex, upperIndex, pNumIndexes, nSamples, secondLastPowerSpectrum, secondLastPowerSpectrum_e, F0, thresholdModification, element_mode ); #endif return; } #ifndef HARMONIZE_FUNC void DetectTonalComponents( Word16 indexOfTonalPeak[], /*Q0*/ Word16 lowerIndex[], /*Q0*/ Loading Loading @@ -162,6 +213,7 @@ void DetectTonalComponents( return; } #endif /*-------------------------------------------------------------------* * RefineTonalComponents() Loading @@ -173,6 +225,7 @@ void DetectTonalComponents( * then keep in indexOfTonalPeak only the tonal components that are * again detected Updates indexOfTonalPeak, lowerIndex, upperIndex, * phaseDiff, phases, pNumIndexes accordingly. */ #ifndef HARMONIZE_FUNC void RefineTonalComponents( Word16 indexOfTonalPeak[], /*Q0*/ Word16 lowerIndex[], /*Q0*/ Loading Loading @@ -258,8 +311,13 @@ void RefineTonalComponents( return; } #endif #ifdef HARMONIZE_FUNC void RefineTonalComponents_fx( #else void ivas_RefineTonalComponents_fx( #endif Word16 indexOfTonalPeak[], /*Q0*/ Word16 lowerIndex[], /*Q0*/ Word16 upperIndex[], /*Q0*/ Loading @@ -278,7 +336,7 @@ void ivas_RefineTonalComponents_fx( const Word16 nSamples, const Word16 nSamplesCore, const Word16 floorPowerSpectrum, /* i : lower limit for power spectrum bins Q0*/ Word16 element_mode, const Word16 element_mode, const PsychoacousticParameters *psychParamsCurrent ) { Word16 newIndexOfTonalPeak[MAX_NUMBER_OF_IDX]; /*Q0*/ Loading @@ -288,9 +346,15 @@ void ivas_RefineTonalComponents_fx( Word16 iNew, iOld, j; Word16 *pOldPhase, *pNewPhase; #ifdef HARMONIZE_FUNC DetectTonalComponents_fx( newIndexOfTonalPeak, newLowerIndex, newUpperIndex, &newNumIndexes, lastPitchLag, currentPitchLag, lastMDCTSpectrum, lastMDCTSpectrum_exp, scaleFactors, scaleFactors_exp, scaleFactors_max_e, secondLastPowerSpectrum, secondLastPowerSpectrum_e, nSamples, nSamplesCore, floorPowerSpectrum, psychParamsCurrent, element_mode ); #else ivas_DetectTonalComponents_fx( newIndexOfTonalPeak, newLowerIndex, newUpperIndex, &newNumIndexes, lastPitchLag, currentPitchLag, lastMDCTSpectrum, lastMDCTSpectrum_exp, scaleFactors, scaleFactors_exp, scaleFactors_max_e, secondLastPowerSpectrum, secondLastPowerSpectrum_e, nSamples, nSamplesCore, floorPowerSpectrum, psychParamsCurrent, element_mode ); #endif nPreservedPeaks = 0; move16(); Loading Loading @@ -561,7 +625,7 @@ static void GetF0( return; } #ifndef HARMONIZE_FUNC static void ivas_GetF0_fx( Word16 /*short*/ const nSamples, /*i - Q0 */ Word16 /*short*/ const nSamplesCore, /*i - Q0 */ Loading Loading @@ -620,7 +684,7 @@ static void ivas_GetF0_fx( return; } #endif static void findStrongestHarmonics( const Word16 nSamples, Loading Loading @@ -703,11 +767,13 @@ static void findStrongestHarmonics( *pnHarmonics = nPeaks; /*Q0*/ move16(); return; } /* Use new F0, for which harmonics are most common in pHarmonicIndexes */ static void CorrectF0( #ifndef HARMONIZE_FUNC const Word16 /*short*/ *pHarmonicIndexes, /*I - Q0 */ const Word16 /*short*/ nHarmonics, /*I - Q0 */ Word16 /*short*/ *pF0 ) /*I/O - Q10 range: {0}, [4..18) */ Loading Loading @@ -853,8 +919,8 @@ static void CorrectF0( return; } static void ivas_CorrectF0_fx( #endif const Word16 /*short*/ *pHarmonicIndexes, /*I - Q0 */ const Word16 /*short*/ nHarmonics, /*I - Q0 */ Word16 /*short*/ *pF0 ) /*I/O - Q10 range: {0}, [4..18) */ Loading Loading @@ -1211,7 +1277,7 @@ static void findCandidates( return; } #ifndef HARMONIZE_FUNC static void RefineThresholdsUsingPitch( const Word16 nSamples, const Word16 nSamplesCore, Loading Loading @@ -1252,9 +1318,13 @@ static void RefineThresholdsUsingPitch( return; } #endif #ifdef HARMONIZE_FUNC static void findTonalComponents_fx( #else static void ivas_findTonalComponents_fx( #endif Word16 *indexOfTonalPeak, /* OUT Q0*/ Word16 *lowerIndex, /* OUT Q0*/ Word16 *upperIndex, /* OUT Q0*/ Loading Loading @@ -1287,11 +1357,27 @@ static void ivas_findTonalComponents_fx( tmp_loop2 = sub( nSamples, 1 ); WHILE( LE_16( k, tmp_loop1 ) ) { #ifdef HARMONIZE_FUNC Word16 flag = 0; IF( element_mode == EVS_MONO && GT_32( L_shr( smoothedSpectrum[k], 1 ), L_shl( Mpy_32_16_1( envelope[k] /*Q28,powerSpec_exp*/, thresholdModification[k] /*Q10*/ ), 4 ) ) ) { flag = 1; move16(); } ELSE { #endif Word64 mult_64 = W_mult_32_16( envelope[k], thresholdModification[k] ); // (Q31-(powerSpectrum_e+LEVEL_EXP))+1+10 Word16 lshift = W_norm( mult_64 ); Word32 mult_32 = W_extract_h( W_shl( mult_64, lshift ) ); //(Q31-(powerSpectrum_e+LEVEL_EXP) + lshift )+11 -32 Word16 mult_exp = sub( Q31, sub( add( sub( Q31, add( powerSpectrum_e, LEVEL_EXP ) ), add( 10, lshift ) ), 31 ) ); #ifdef HARMONIZE_FUNC flag = BASOP_Util_Cmp_Mant32Exp( smoothedSpectrum[k], ( powerSpectrum_e + LEVEL_EXP ), mult_32, mult_exp ); } #else Word16 flag = BASOP_Util_Cmp_Mant32Exp( smoothedSpectrum[k], ( powerSpectrum_e + LEVEL_EXP ), mult_32, mult_exp ); #endif /* There is 3 bits headroom in envelope and max of thresholdModification is 16384, so shifting left for 4 would produce overflow only when the result is anyhow close to 1 */ IF( EQ_16( flag, 1 ) ) { Loading Loading @@ -1418,8 +1504,11 @@ static void ivas_findTonalComponents_fx( return; } #ifdef HARMONIZE_FUNC static void RefineThresholdsUsingPitch_fx( #else static void ivas_RefineThresholdsUsingPitch_fx( #endif const Word16 nSamples, const Word16 nSamplesCore, const Word32 powerSpectrum[], /*Qx*/ Loading @@ -1445,9 +1534,13 @@ static void ivas_RefineThresholdsUsingPitch_fx( IF( pitchIsStable ) { #ifdef HARMONIZE_FUNC GetF0( nSamples, nSamplesCore, powerSpectrum, lastPitchLag, &origF0, pF0 ); #else ivas_GetF0_fx( nSamples, nSamplesCore, powerSpectrum, lastPitchLag, &origF0, pF0 ); #endif modifyThresholds( *pF0, origF0, thresholdModification ); } Loading @@ -1459,7 +1552,7 @@ static void ivas_RefineThresholdsUsingPitch_fx( return; } #ifndef HARMONIZE_FUNC static void findTonalComponents( Word16 *indexOfTonalPeak, /* OUT Q0*/ Loading Loading @@ -1618,3 +1711,4 @@ static void findTonalComponents( return; } #endif Loading
lib_com/ivas_prot_fx.h +2 −1 Original line number Diff line number Diff line Loading @@ -1879,6 +1879,7 @@ void TonalMDCTConceal_Detect_ivas_fx( ); #ifndef HARMONIZE_FUNC void ivas_DetectTonalComponents_fx( Word16 indexOfTonalPeak[], Word16 lowerIndex[], Loading @@ -1899,7 +1900,7 @@ void ivas_DetectTonalComponents_fx( const PsychoacousticParameters *psychParamsCurrent, Word16 element_mode ); #endif ivas_error stereo_dft_dec_create_fx( STEREO_DFT_DEC_DATA_HANDLE *hStereoDft, /* i/o: decoder DFT stereo handle */ const Word32 element_brate, /* i : element bitrate */ Loading
lib_com/options.h +1 −0 Original line number Diff line number Diff line Loading @@ -92,6 +92,7 @@ #define HARM_2454_TCX_RES_Q_SPEC /* FhG: harmonization of tcx_res_Q_spec_fx() and tcx_res_Q_spec_ivas_fx() */ #define FIX_FLOAT_1535_ARI_RES_Q_CLEANUP /* FhG: remove dead code from tcx_ari_res_Q_spec() */ #define FIX_2467_RENAME_GSC_FUNCTION /* VA: basop issue 2467: Removal of unused function/table and renaming of _ivas_fx versions to default ones. */ #define HARMONIZE_FUNC /* VA: basop issue 2460: Remove duplicated code: various functions */ /* #################### End BE switches ################################## */ Loading
lib_com/prot_fx.h +47 −17 Original line number Diff line number Diff line Loading @@ -2308,6 +2308,7 @@ void E_UTIL_synthesis_fx( const Word16 update, const Word16 m ); #ifndef HARMONIZE_FUNC void synth_mem_updt2( const Word16 L_frame, /* i : frame length */ const Word16 last_L_frame, /* i : frame length */ Loading @@ -2317,15 +2318,18 @@ void synth_mem_updt2( Word16 mem_syn[], /* o : synthesis filter memory for find_target */ const Word16 dec /* i : flag for decoder indication */ ); void ivas_synth_mem_updt2_fx( #else void synth_mem_updt2_fx( #endif const Word16 L_frame, /* i : frame length */ const Word16 last_L_frame, /* i : frame length */ Word16 old_exc[], /* i/o: excitation buffer */ Word16 mem_syn_r[], /* i/o: synthesis filter memory */ Word16 mem_syn2[], /* o : synthesis filter memory for find_target */ Word16 mem_syn[], /* o : synthesis filter memory for find_target */ const Word16 dec ); const Word16 dec /* i : flag for decoder indication */ ); void lerp( const Word16 *f, Loading Loading @@ -5821,6 +5825,27 @@ void concealment_signal_tuning_fx( Word16 *outx_new_fx /*Qoutx_new_fx*/, const Word16 past_core ); #ifdef HARMONIZE_FUNC void DetectTonalComponents_fx( Word16 indexOfTonalPeak[], Word16 lowerIndex[], Word16 upperIndex[], Word16 *pNumIndexes, const Word32 lastPitchLag, const Word32 currentPitchLag, const Word16 lastMDCTSpectrum[], const Word16 lastMDCTSpectrum_exp, const Word16 scaleFactors[], const Word16 scaleFactors_exp[], const Word16 scaleFactors_max_e, const Word32 secondLastPowerSpectrum[], const Word16 secondLastPowerSpectrum_e, const Word16 nSamples, const Word16 nSamplesCore, Word16 floorPowerSpectrum, /* i : lower limit for power spectrum bins */ const PsychoacousticParameters *psychParamsCurrent, const Word16 element_mode ); #else void DetectTonalComponents( Word16 indexOfTonalPeak[], Word16 lowerIndex[], Loading Loading @@ -5858,8 +5883,13 @@ void RefineTonalComponents( const Word16 nSamplesCore, const Word16 floorPowerSpectrum, /* i: lower limit for power spectrum bins */ Word16 element_mode ); #endif #ifdef HARMONIZE_FUNC void RefineTonalComponents_fx( #else void ivas_RefineTonalComponents_fx( #endif Word16 indexOfTonalPeak[], Word16 lowerIndex[], Word16 upperIndex[], Loading @@ -5878,9 +5908,10 @@ void ivas_RefineTonalComponents_fx( const Word16 nSamples, const Word16 nSamplesCore, const Word16 floorPowerSpectrum, /* i: lower limit for power spectrum bins */ Word16 element_mode, const Word16 element_mode, const PsychoacousticParameters *psychParamsCurrent ); #ifndef HARMONIZE_FUNC ivas_error PsychoacousticParameters_Init( const Word32 sr_core, /* i : sampling rate of core-coder */ const Word16 nBins, /* i : Number of bins (spectral lines) */ Loading @@ -5888,8 +5919,8 @@ ivas_error PsychoacousticParameters_Init( const Word16 isTCX20, /* i : Flag indicating if the subband division is for TCX20 or TCX10 */ const Word16 isWarped, /* i : Flag indicating if the scale is linear or warped */ PsychoacousticParameters *pPsychParams ); ivas_error TonalMDCTConceal_Init( #endif ivas_error TonalMDCTConceal_Init_fx( TonalMDCTConcealPtr self, const Word16 nSamples, const Word16 nSamplesCore, Loading @@ -5906,7 +5937,7 @@ ivas_error TonalMDCTConceal_Init_ivas_fx( ); /* Must be called only when a good frame is recieved - concealment is inactive */ void TonalMDCTConceal_SaveFreqSignal( void TonalMDCTConceal_SaveFreqSignal_fx( TonalMDCTConcealPtr self, const Word32 *mdctSpectrum, const Word16 mdctSpectrum_exp, Loading @@ -5927,21 +5958,21 @@ void TonalMDCTConceal_SaveFreqSignal_ivas_fx( const Word16 gain_tcx_exp, const Word16 infoIGFStartLine ); void TonalMDCTConceal_UpdateState( void TonalMDCTConceal_UpdateState_fx( TonalMDCTConcealPtr self, Word16 nNewSamples, Word32 pitchLag, Word16 badBlock, Word8 tonalConcealmentActive ); const Word16 nNewSamples, const Word32 pitchLag, const Word16 badBlock, const Word8 tonalConcealmentActive ); void TonalMDCTConceal_Detect( void TonalMDCTConceal_Detect_fx( const TonalMDCTConcealPtr self, /*IN */ const Word32 pitchLag, /*IN */ Word16 *umIndices, /*OUT*/ Word16 element_mode /* IN */ const Word16 element_mode /* IN */ ); void TonalMDCTConceal_Apply( void TonalMDCTConceal_Apply_fx( const TonalMDCTConcealPtr hTonalMDCTConc, /*IN */ Word32 *mdctSpectrum, /*IN/OUT*/ Word16 *mdctSpectrum_exp /*IN */ Loading @@ -5967,7 +5998,7 @@ void TonalMDCTConceal_InsertNoise_ivas_fx( const Word16 cngLevelBackgroundTrace_e, const Word16 crossOverFreq ); void TonalMDCTConceal_InsertNoise( void TonalMDCTConceal_InsertNoise_fx( const TonalMDCTConcealPtr hTonalMDCTConc, /*IN */ Word32 *mdctSpectrum, /*OUT*/ Word16 *mdctSpectrum_exp, /*OUT*/ Loading @@ -5977,7 +6008,7 @@ void TonalMDCTConceal_InsertNoise( Word16 crossfadeGain, const Word16 crossOverFreq ); void TonalMDCTConceal_SaveTimeSignal( void TonalMDCTConceal_SaveTimeSignal_fx( TonalMDCTConcealPtr hTonalMDCTConc, Word16 *timeSignal, Word16 nNewSamples ); Loading Loading @@ -10597,7 +10628,6 @@ void UnmapIndex_fx( Word32 *Lag /* Q0 */ ); // #define GET_ADJ2( T, L, F ) ( ( ( L ) << ( F ) ) - ( T ) ) #define GET_ADJ2( T, L, F ) ( sub( shl( L, F ), T ) ) Word32 tcx_hm_render_fx( Loading
lib_com/syn_filt_fx.c +11 −1 Original line number Diff line number Diff line Loading @@ -548,14 +548,19 @@ void E_UTIL_synthesis_fx( * Update of synthesis filter memories in case of ACELP@12k8 <-> ACELP@16k switching *--------------------------------------------------------------------*/ #ifdef HARMONIZE_FUNC void synth_mem_updt2_fx( #else void ivas_synth_mem_updt2_fx( #endif const Word16 L_frame, /* i : frame length */ const Word16 last_L_frame, /* i : frame length */ Word16 old_exc[], /* i/o: excitation buffer st->Q_syn */ Word16 mem_syn_r[], /* i/o: synthesis filter memory st->Q_syn */ Word16 mem_syn2[], /* o : synthesis filter memory for find_target st->Q_syn */ Word16 mem_syn[], /* o : synthesis filter memory for find_target st->Q_syn */ const Word16 dec ) const Word16 dec /* i : flag for decoder indication */ ) { Word16 mem_syn_r_size_old, mem_syn_r_size_new; Word32 en1, en2; Loading Loading @@ -622,7 +627,11 @@ void ivas_synth_mem_updt2_fx( { Copy( mem_syn2, mem_syn, M ); } return; } #ifndef HARMONIZE_FUNC void synth_mem_updt2( const Word16 L_frame, /* i : frame length */ const Word16 last_L_frame, /* i : frame length */ Loading Loading @@ -660,3 +669,4 @@ void synth_mem_updt2( Copy( mem_syn2, mem_syn, M ); } } #endif
lib_dec/TonalComponentDetection_fx.c +138 −44 Original line number Diff line number Diff line Loading @@ -2,8 +2,6 @@ EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ #define _USE_MATH_DEFINES #include <assert.h> #include <stdint.h> #include "options.h" Loading @@ -14,23 +12,35 @@ #include "prot_fx.h" #include "ivas_prot_fx.h" /*---------------------------------------------------------------------* * Local function prototypes *---------------------------------------------------------------------*/ static void calcPseudoSpec( const Word32 *mdctSpec, const Word16 mdctSpec_exp, const Word16 nSamples, Word16 floorPowerSpectrum, Word32 *powerSpec, Word16 *powerSpec_exp ); static void getEnvelope( const Word16 nSamples, const Word32 *powerSpec, Word16 F0, Word32 *envelope, Word32 *smoothedSpectrum ); static void GetF0( Word16 const nSamples, Word16 const nSamplesCore, Word32 const *const powerSpectrum, Word32 const pitchLag, Word16 *const pOrigF0, Word16 *const pF0 ); #ifndef HARMONIZE_FUNC static void ivas_GetF0_fx( Word16 const nSamples, Word16 const nSamplesCore, Word32 const *const powerSpectrum, Word32 const pitchLag, Word16 *const pOrigF0, Word16 *const pF0 ); #endif static void findStrongestHarmonics( const Word16 nSamples, const Word32 *powerSpectrum, const Word16 F0, const Word16 nTotalHarmonics, Word16 *pHarmonicIndexes, Word16 *pnHarmonics ); static void CorrectF0( const Word16 *pHarmonicIndexes, const Word16 nHarmonics, Word16 *pF0 ); #ifndef HARMONIZE_FUNC static void ivas_CorrectF0_fx( const Word16 *pHarmonicIndexes, const Word16 nHarmonics, Word16 *pF0 ); #endif static void findCandidates( const Word16 nSamples, const Word32 *MDCTSpectrum, const Word16 MDCTSpectrum_exp, Word16 *thresholdModificationNew, Word16 floorPowerSpectrum ); static void modifyThreshold( Word16 i, Word16 F0, Word16 threshold, Word16 *thresholdModification ); static void modifyThresholds( Word16 F0, Word16 origF0, Word16 *thresholdModification ); #ifdef HARMONIZE_FUNC static void RefineThresholdsUsingPitch_fx( const Word16 nSamples, const Word16 nSamplesCore, const Word32 powerSpectrum[], const Word32 lastPitchLag, const Word32 currentPitchLag, Word16 *pF0, Word16 *thresholdModification ); static void findTonalComponents_fx( Word16 *indexOfTonalPeak, Word16 *lowerIndex, Word16 *upperIndex, Word16 *numIndexes, Word16 nSamples, const Word32 *powerSpectrum, const Word16 powerSpectrum_e, Word16 F0, Word16 *thresholdModification, Word16 element_mode ); #else static void RefineThresholdsUsingPitch( const Word16 nSamples, const Word16 nSamplesCore, const Word32 powerSpectrum[], const Word32 lastPitchLag, const Word32 currentPitchLag, Word16 *pF0, Word16 *thresholdModification ); static void ivas_RefineThresholdsUsingPitch_fx( const Word16 nSamples, const Word16 nSamplesCore, const Word32 powerSpectrum[], const Word32 lastPitchLag, const Word32 currentPitchLag, Word16 *pF0, Word16 *thresholdModification ); static void findTonalComponents( Word16 *indexOfTonalPeak, Word16 *lowerIndex, Word16 *upperIndex, Word16 *numIndexes, Word16 nSamples, const Word32 *powerSpectrum, Word16 F0, Word16 *thresholdModification, Word16 element_mode ); static void ivas_findTonalComponents_fx( Word16 *indexOfTonalPeak, Word16 *lowerIndex, Word16 *upperIndex, Word16 *numIndexes, Word16 nSamples, const Word32 *powerSpectrum, const Word16 powerSpectrum_e, Word16 F0, Word16 *thresholdModification, Word16 element_mode ); #endif /*-------------------------------------------------------------------* * DetectTonalComponents() Loading @@ -41,7 +51,11 @@ static void ivas_findTonalComponents_fx( Word16 *indexOfTonalPeak, Word16 *lower * pNumIndexes accordingly. *-------------------------------------------------------------------*/ #ifdef HARMONIZE_FUNC void DetectTonalComponents_fx( #else void ivas_DetectTonalComponents_fx( #endif Word16 indexOfTonalPeak[], /*Q0*/ Word16 lowerIndex[], /*Q0*/ Word16 upperIndex[], /*Q0*/ Loading @@ -59,7 +73,11 @@ void ivas_DetectTonalComponents_fx( const Word16 nSamplesCore, Word16 floorPowerSpectrum, /* i : lower limit for power spectrum bins Q0*/ const PsychoacousticParameters *psychParamsCurrent, #ifdef HARMONIZE_FUNC const Word16 element_mode /* i : element mode */ #else Word16 element_mode /* i : element mode */ #endif ) { Word16 F0; Loading @@ -71,16 +89,29 @@ void ivas_DetectTonalComponents_fx( set32_fx( pScaledMdctSpectrum, 0, L_FRAME_MAX ); #ifdef HARMONIZE_FUNC IF( element_mode == EVS_MONO ) { mdct_shaping_16( lastMDCTSpectrum, nSamplesCore, nSamples, scaleFactors, scaleFactors_exp, scaleFactors_max_e, pScaledMdctSpectrum ); lastMDCTSpect_exp = add( lastMDCTSpectrum_exp, scaleFactors_max_e ); } ELSE { #endif FOR( Word16 i = 0; i < nSamples; i++ ) { pScaledMdctSpectrum[i] = L_shl( lastMDCTSpectrum[i], 16 ); /*15-lastMDCTSpectrum_exp+16 -> 31 - lastMDCTSpectrum_exp*/ move32(); } #ifndef HARMONIZE_FUNC FOR( Word16 i = 0; i < FDNS_NPTS; i++ ) { sns_int_scf_fx[i] = L_shl_sat( scaleFactors[i], add( 1, scaleFactors_exp[i] ) ); // Q16 move32(); } #endif IF( psychParamsCurrent == NULL ) { nBands = FDNS_NPTS; Loading @@ -91,6 +122,14 @@ void ivas_DetectTonalComponents_fx( } ELSE { #ifdef HARMONIZE_FUNC FOR( Word16 i = 0; i < FDNS_NPTS; i++ ) { sns_int_scf_fx[i] = L_shl_sat( scaleFactors[i], add( 1, scaleFactors_exp[i] ) ); // Q16 move32(); } #endif q_pScaledMdctSpectrum = sub( 31, lastMDCTSpectrum_exp ); sns_shape_spectrum_fx( pScaledMdctSpectrum, &q_pScaledMdctSpectrum, psychParamsCurrent, sns_int_scf_fx, 16, nSamplesCore, NULL ); q_pScaledMdctSpectrum = add( q_pScaledMdctSpectrum, 1 ); Loading @@ -112,19 +151,31 @@ void ivas_DetectTonalComponents_fx( /* Guard bit */ lastMDCTSpect_exp = add( lastMDCTSpect_exp, 1 ); scale_sig32( pScaledMdctSpectrum, nSamples, -1 ); /*q_pScaledMdctSpectrum - 1*/ #ifdef HARMONIZE_FUNC } #endif /* Find peak candidates in the last frame. */ findCandidates( nSamples, pScaledMdctSpectrum, lastMDCTSpect_exp, thresholdModification, floorPowerSpectrum ); /* Refine peak candidates using the pitch information */ #ifdef HARMONIZE_FUNC RefineThresholdsUsingPitch_fx( nSamples, nSamplesCore, secondLastPowerSpectrum, lastPitchLag, currentPitchLag, &F0, thresholdModification ); #else ivas_RefineThresholdsUsingPitch_fx( nSamples, nSamplesCore, secondLastPowerSpectrum, lastPitchLag, currentPitchLag, &F0, thresholdModification ); #endif /* Find peaks in the second last frame */ #ifdef HARMONIZE_FUNC findTonalComponents_fx( indexOfTonalPeak, lowerIndex, upperIndex, pNumIndexes, nSamples, secondLastPowerSpectrum, secondLastPowerSpectrum_e, F0, thresholdModification, element_mode ); #else ivas_findTonalComponents_fx( indexOfTonalPeak, lowerIndex, upperIndex, pNumIndexes, nSamples, secondLastPowerSpectrum, secondLastPowerSpectrum_e, F0, thresholdModification, element_mode ); #endif return; } #ifndef HARMONIZE_FUNC void DetectTonalComponents( Word16 indexOfTonalPeak[], /*Q0*/ Word16 lowerIndex[], /*Q0*/ Loading Loading @@ -162,6 +213,7 @@ void DetectTonalComponents( return; } #endif /*-------------------------------------------------------------------* * RefineTonalComponents() Loading @@ -173,6 +225,7 @@ void DetectTonalComponents( * then keep in indexOfTonalPeak only the tonal components that are * again detected Updates indexOfTonalPeak, lowerIndex, upperIndex, * phaseDiff, phases, pNumIndexes accordingly. */ #ifndef HARMONIZE_FUNC void RefineTonalComponents( Word16 indexOfTonalPeak[], /*Q0*/ Word16 lowerIndex[], /*Q0*/ Loading Loading @@ -258,8 +311,13 @@ void RefineTonalComponents( return; } #endif #ifdef HARMONIZE_FUNC void RefineTonalComponents_fx( #else void ivas_RefineTonalComponents_fx( #endif Word16 indexOfTonalPeak[], /*Q0*/ Word16 lowerIndex[], /*Q0*/ Word16 upperIndex[], /*Q0*/ Loading @@ -278,7 +336,7 @@ void ivas_RefineTonalComponents_fx( const Word16 nSamples, const Word16 nSamplesCore, const Word16 floorPowerSpectrum, /* i : lower limit for power spectrum bins Q0*/ Word16 element_mode, const Word16 element_mode, const PsychoacousticParameters *psychParamsCurrent ) { Word16 newIndexOfTonalPeak[MAX_NUMBER_OF_IDX]; /*Q0*/ Loading @@ -288,9 +346,15 @@ void ivas_RefineTonalComponents_fx( Word16 iNew, iOld, j; Word16 *pOldPhase, *pNewPhase; #ifdef HARMONIZE_FUNC DetectTonalComponents_fx( newIndexOfTonalPeak, newLowerIndex, newUpperIndex, &newNumIndexes, lastPitchLag, currentPitchLag, lastMDCTSpectrum, lastMDCTSpectrum_exp, scaleFactors, scaleFactors_exp, scaleFactors_max_e, secondLastPowerSpectrum, secondLastPowerSpectrum_e, nSamples, nSamplesCore, floorPowerSpectrum, psychParamsCurrent, element_mode ); #else ivas_DetectTonalComponents_fx( newIndexOfTonalPeak, newLowerIndex, newUpperIndex, &newNumIndexes, lastPitchLag, currentPitchLag, lastMDCTSpectrum, lastMDCTSpectrum_exp, scaleFactors, scaleFactors_exp, scaleFactors_max_e, secondLastPowerSpectrum, secondLastPowerSpectrum_e, nSamples, nSamplesCore, floorPowerSpectrum, psychParamsCurrent, element_mode ); #endif nPreservedPeaks = 0; move16(); Loading Loading @@ -561,7 +625,7 @@ static void GetF0( return; } #ifndef HARMONIZE_FUNC static void ivas_GetF0_fx( Word16 /*short*/ const nSamples, /*i - Q0 */ Word16 /*short*/ const nSamplesCore, /*i - Q0 */ Loading Loading @@ -620,7 +684,7 @@ static void ivas_GetF0_fx( return; } #endif static void findStrongestHarmonics( const Word16 nSamples, Loading Loading @@ -703,11 +767,13 @@ static void findStrongestHarmonics( *pnHarmonics = nPeaks; /*Q0*/ move16(); return; } /* Use new F0, for which harmonics are most common in pHarmonicIndexes */ static void CorrectF0( #ifndef HARMONIZE_FUNC const Word16 /*short*/ *pHarmonicIndexes, /*I - Q0 */ const Word16 /*short*/ nHarmonics, /*I - Q0 */ Word16 /*short*/ *pF0 ) /*I/O - Q10 range: {0}, [4..18) */ Loading Loading @@ -853,8 +919,8 @@ static void CorrectF0( return; } static void ivas_CorrectF0_fx( #endif const Word16 /*short*/ *pHarmonicIndexes, /*I - Q0 */ const Word16 /*short*/ nHarmonics, /*I - Q0 */ Word16 /*short*/ *pF0 ) /*I/O - Q10 range: {0}, [4..18) */ Loading Loading @@ -1211,7 +1277,7 @@ static void findCandidates( return; } #ifndef HARMONIZE_FUNC static void RefineThresholdsUsingPitch( const Word16 nSamples, const Word16 nSamplesCore, Loading Loading @@ -1252,9 +1318,13 @@ static void RefineThresholdsUsingPitch( return; } #endif #ifdef HARMONIZE_FUNC static void findTonalComponents_fx( #else static void ivas_findTonalComponents_fx( #endif Word16 *indexOfTonalPeak, /* OUT Q0*/ Word16 *lowerIndex, /* OUT Q0*/ Word16 *upperIndex, /* OUT Q0*/ Loading Loading @@ -1287,11 +1357,27 @@ static void ivas_findTonalComponents_fx( tmp_loop2 = sub( nSamples, 1 ); WHILE( LE_16( k, tmp_loop1 ) ) { #ifdef HARMONIZE_FUNC Word16 flag = 0; IF( element_mode == EVS_MONO && GT_32( L_shr( smoothedSpectrum[k], 1 ), L_shl( Mpy_32_16_1( envelope[k] /*Q28,powerSpec_exp*/, thresholdModification[k] /*Q10*/ ), 4 ) ) ) { flag = 1; move16(); } ELSE { #endif Word64 mult_64 = W_mult_32_16( envelope[k], thresholdModification[k] ); // (Q31-(powerSpectrum_e+LEVEL_EXP))+1+10 Word16 lshift = W_norm( mult_64 ); Word32 mult_32 = W_extract_h( W_shl( mult_64, lshift ) ); //(Q31-(powerSpectrum_e+LEVEL_EXP) + lshift )+11 -32 Word16 mult_exp = sub( Q31, sub( add( sub( Q31, add( powerSpectrum_e, LEVEL_EXP ) ), add( 10, lshift ) ), 31 ) ); #ifdef HARMONIZE_FUNC flag = BASOP_Util_Cmp_Mant32Exp( smoothedSpectrum[k], ( powerSpectrum_e + LEVEL_EXP ), mult_32, mult_exp ); } #else Word16 flag = BASOP_Util_Cmp_Mant32Exp( smoothedSpectrum[k], ( powerSpectrum_e + LEVEL_EXP ), mult_32, mult_exp ); #endif /* There is 3 bits headroom in envelope and max of thresholdModification is 16384, so shifting left for 4 would produce overflow only when the result is anyhow close to 1 */ IF( EQ_16( flag, 1 ) ) { Loading Loading @@ -1418,8 +1504,11 @@ static void ivas_findTonalComponents_fx( return; } #ifdef HARMONIZE_FUNC static void RefineThresholdsUsingPitch_fx( #else static void ivas_RefineThresholdsUsingPitch_fx( #endif const Word16 nSamples, const Word16 nSamplesCore, const Word32 powerSpectrum[], /*Qx*/ Loading @@ -1445,9 +1534,13 @@ static void ivas_RefineThresholdsUsingPitch_fx( IF( pitchIsStable ) { #ifdef HARMONIZE_FUNC GetF0( nSamples, nSamplesCore, powerSpectrum, lastPitchLag, &origF0, pF0 ); #else ivas_GetF0_fx( nSamples, nSamplesCore, powerSpectrum, lastPitchLag, &origF0, pF0 ); #endif modifyThresholds( *pF0, origF0, thresholdModification ); } Loading @@ -1459,7 +1552,7 @@ static void ivas_RefineThresholdsUsingPitch_fx( return; } #ifndef HARMONIZE_FUNC static void findTonalComponents( Word16 *indexOfTonalPeak, /* OUT Q0*/ Loading Loading @@ -1618,3 +1711,4 @@ static void findTonalComponents( return; } #endif