diff --git a/webrtc/modules/audio_processing/aec/aec_core.cc b/webrtc/modules/audio_processing/aec/aec_core.cc index a3be9e48b7..56ff2336a2 100644 --- a/webrtc/modules/audio_processing/aec/aec_core.cc +++ b/webrtc/modules/audio_processing/aec/aec_core.cc @@ -132,7 +132,8 @@ WebRtcAecFilterFar WebRtcAec_FilterFar; WebRtcAecScaleErrorSignal WebRtcAec_ScaleErrorSignal; WebRtcAecFilterAdaptation WebRtcAec_FilterAdaptation; WebRtcAecOverdriveAndSuppress WebRtcAec_OverdriveAndSuppress; -WebRtcAecSubBandCoherence WebRtcAec_SubbandCoherence; +WebRtcAecComputeCoherence WebRtcAec_ComputeCoherence; +WebRtcAecUpdateCoherenceSpectra WebRtcAec_UpdateCoherenceSpectra; WebRtcAecStoreAsComplex WebRtcAec_StoreAsComplex; WebRtcAecPartitionDelay WebRtcAec_PartitionDelay; WebRtcAecWindowData WebRtcAec_WindowData; @@ -396,7 +397,7 @@ static void UpdateLogRatioMetric(Stats* metric, float numerator, // Threshold to protect against the ill-effects of a zero far-end. const float WebRtcAec_kMinFarendPSD = 15; -// Updates the following smoothed Power Spectral Densities (PSD): +// Updates the following smoothed Power Spectral Densities (PSD): // - sd : near-end // - se : residual echo // - sx : far-end @@ -405,14 +406,14 @@ const float WebRtcAec_kMinFarendPSD = 15; // // In addition to updating the PSDs, also the filter diverge state is // determined. -static void SmoothedPSD(int mult, - bool extended_filter_enabled, - float efw[2][PART_LEN1], - float dfw[2][PART_LEN1], - float xfw[2][PART_LEN1], - CoherenceState* coherence_state, - short* filter_divergence_state, - int* extreme_filter_divergence) { +static void UpdateCoherenceSpectra(int mult, + bool extended_filter_enabled, + float efw[2][PART_LEN1], + float dfw[2][PART_LEN1], + float xfw[2][PART_LEN1], + CoherenceState* coherence_state, + short* filter_divergence_state, + int* extreme_filter_divergence) { // Power estimate smoothing coefficients. const float* ptrGCoh = extended_filter_enabled @@ -489,24 +490,11 @@ __inline static void StoreAsComplex(const float* data, data_complex[1][PART_LEN] = 0; } -static void SubbandCoherence(int mult, - bool extended_filter_enabled, - float efw[2][PART_LEN1], - float dfw[2][PART_LEN1], - float xfw[2][PART_LEN1], - float* fft, +static void ComputeCoherence(const CoherenceState* coherence_state, float* cohde, - float* cohxd, - CoherenceState* coherence_state, - short* filter_divergence_state, - int* extreme_filter_divergence) { - int i; - - SmoothedPSD(mult, extended_filter_enabled, efw, dfw, xfw, coherence_state, - filter_divergence_state, extreme_filter_divergence); - + float* cohxd) { // Subband coherence - for (i = 0; i < PART_LEN1; i++) { + for (int i = 0; i < PART_LEN1; i++) { cohde[i] = (coherence_state->sde[i][0] * coherence_state->sde[i][0] + coherence_state->sde[i][1] * coherence_state->sde[i][1]) / (coherence_state->sd[i] * coherence_state->se[i] + 1e-10f); @@ -1062,10 +1050,12 @@ static void EchoSuppression(AecCore* aec, memcpy(xfw, aec->xfwBuf + aec->delayIdx * PART_LEN1, sizeof(xfw[0][0]) * 2 * PART_LEN1); - WebRtcAec_SubbandCoherence(aec->mult, aec->extended_filter_enabled == 1, efw, - dfw, xfw, fft, cohde, cohxd, &aec->coherence_state, - &aec->divergeState, - &aec->extreme_filter_divergence); + WebRtcAec_UpdateCoherenceSpectra(aec->mult, aec->extended_filter_enabled == 1, + efw, dfw, xfw, &aec->coherence_state, + &aec->divergeState, + &aec->extreme_filter_divergence); + + WebRtcAec_ComputeCoherence(&aec->coherence_state, cohde, cohxd); // Select the microphone signal as output if the filter is deemed to have // diverged. @@ -1488,7 +1478,8 @@ AecCore* WebRtcAec_CreateAec(int instance_count) { WebRtcAec_ScaleErrorSignal = ScaleErrorSignal; WebRtcAec_FilterAdaptation = FilterAdaptation; WebRtcAec_OverdriveAndSuppress = OverdriveAndSuppress; - WebRtcAec_SubbandCoherence = SubbandCoherence; + WebRtcAec_ComputeCoherence = ComputeCoherence; + WebRtcAec_UpdateCoherenceSpectra = UpdateCoherenceSpectra; WebRtcAec_StoreAsComplex = StoreAsComplex; WebRtcAec_PartitionDelay = PartitionDelay; WebRtcAec_WindowData = WindowData; diff --git a/webrtc/modules/audio_processing/aec/aec_core_internal.h b/webrtc/modules/audio_processing/aec/aec_core_internal.h index b5c9d58fc8..b8921ff232 100644 --- a/webrtc/modules/audio_processing/aec/aec_core_internal.h +++ b/webrtc/modules/audio_processing/aec/aec_core_internal.h @@ -221,18 +221,20 @@ typedef void (*WebRtcAecOverdriveAndSuppress)(float overdrive_scaling, float efw[2][PART_LEN1]); extern WebRtcAecOverdriveAndSuppress WebRtcAec_OverdriveAndSuppress; -typedef void (*WebRtcAecSubBandCoherence)(int mult, - bool extended_filter_enabled, - float efw[2][PART_LEN1], - float dfw[2][PART_LEN1], - float xfw[2][PART_LEN1], - float* fft, +typedef void (*WebRtcAecComputeCoherence)(const CoherenceState* coherence_state, float* cohde, - float* cohxd, - CoherenceState* coherence_state, - short* filter_divergence_state, - int* extreme_filter_divergence); -extern WebRtcAecSubBandCoherence WebRtcAec_SubbandCoherence; + float* cohxd); +extern WebRtcAecComputeCoherence WebRtcAec_ComputeCoherence; + +typedef void (*WebRtcAecUpdateCoherenceSpectra)(int mult, + bool extended_filter_enabled, + float efw[2][PART_LEN1], + float dfw[2][PART_LEN1], + float xfw[2][PART_LEN1], + CoherenceState* coherence_state, + short* filter_divergence_state, + int* extreme_filter_divergence); +extern WebRtcAecUpdateCoherenceSpectra WebRtcAec_UpdateCoherenceSpectra; typedef int (*WebRtcAecPartitionDelay)( int num_partitions, diff --git a/webrtc/modules/audio_processing/aec/aec_core_neon.cc b/webrtc/modules/audio_processing/aec/aec_core_neon.cc index 06743b5410..5ff81496d5 100644 --- a/webrtc/modules/audio_processing/aec/aec_core_neon.cc +++ b/webrtc/modules/audio_processing/aec/aec_core_neon.cc @@ -504,14 +504,14 @@ static int PartitionDelayNEON( // // In addition to updating the PSDs, also the filter diverge state is determined // upon actions are taken. -static void SmoothedPSD(int mult, - bool extended_filter_enabled, - float efw[2][PART_LEN1], - float dfw[2][PART_LEN1], - float xfw[2][PART_LEN1], - CoherenceState* coherence_state, - short* filter_divergence_state, - int* extreme_filter_divergence) { +static void UpdateCoherenceSpectraNEON(int mult, + bool extended_filter_enabled, + float efw[2][PART_LEN1], + float dfw[2][PART_LEN1], + float xfw[2][PART_LEN1], + CoherenceState* coherence_state, + short* filter_divergence_state, + int* extreme_filter_divergence) { // Power estimate smoothing coefficients. const float* ptrGCoh = extended_filter_enabled @@ -679,22 +679,11 @@ static void StoreAsComplexNEON(const float* data, data_complex[0][PART_LEN] = data[1]; } -static void SubbandCoherenceNEON(int mult, - bool extended_filter_enabled, - float efw[2][PART_LEN1], - float dfw[2][PART_LEN1], - float xfw[2][PART_LEN1], - float* fft, +static void ComputeCoherenceNEON(const CoherenceState* coherence_state, float* cohde, - float* cohxd, - CoherenceState* coherence_state, - short* filter_divergence_state, - int* extreme_filter_divergence) { + float* cohxd) { int i; - SmoothedPSD(mult, extended_filter_enabled, efw, dfw, xfw, coherence_state, - filter_divergence_state, extreme_filter_divergence); - { const float32x4_t vec_1eminus10 = vdupq_n_f32(1e-10f); @@ -734,7 +723,8 @@ void WebRtcAec_InitAec_neon(void) { WebRtcAec_ScaleErrorSignal = ScaleErrorSignalNEON; WebRtcAec_FilterAdaptation = FilterAdaptationNEON; WebRtcAec_OverdriveAndSuppress = OverdriveAndSuppressNEON; - WebRtcAec_SubbandCoherence = SubbandCoherenceNEON; + WebRtcAec_ComputeCoherence = ComputeCoherenceNEON; + WebRtcAec_UpdateCoherenceSpectra = UpdateCoherenceSpectraNEON; WebRtcAec_StoreAsComplex = StoreAsComplexNEON; WebRtcAec_PartitionDelay = PartitionDelayNEON; WebRtcAec_WindowData = WindowDataNEON; diff --git a/webrtc/modules/audio_processing/aec/aec_core_sse2.cc b/webrtc/modules/audio_processing/aec/aec_core_sse2.cc index ec466f6c2a..47167eca63 100644 --- a/webrtc/modules/audio_processing/aec/aec_core_sse2.cc +++ b/webrtc/modules/audio_processing/aec/aec_core_sse2.cc @@ -497,14 +497,14 @@ static int PartitionDelaySSE2( // // In addition to updating the PSDs, also the filter diverge state is determined // upon actions are taken. -static void SmoothedPSD(int mult, - bool extended_filter_enabled, - float efw[2][PART_LEN1], - float dfw[2][PART_LEN1], - float xfw[2][PART_LEN1], - CoherenceState* coherence_state, - short* filter_divergence_state, - int* extreme_filter_divergence) { +static void UpdateCoherenceSpectraSSE2(int mult, + bool extended_filter_enabled, + float efw[2][PART_LEN1], + float dfw[2][PART_LEN1], + float xfw[2][PART_LEN1], + CoherenceState* coherence_state, + short* filter_divergence_state, + int* extreme_filter_divergence) { // Power estimate smoothing coefficients. const float* ptrGCoh = extended_filter_enabled @@ -680,22 +680,11 @@ static void StoreAsComplexSSE2(const float* data, data_complex[0][PART_LEN] = data[1]; } -static void SubbandCoherenceSSE2(int mult, - bool extended_filter_enabled, - float efw[2][PART_LEN1], - float dfw[2][PART_LEN1], - float xfw[2][PART_LEN1], - float* fft, +static void ComputeCoherenceSSE2(const CoherenceState* coherence_state, float* cohde, - float* cohxd, - CoherenceState* coherence_state, - short* filter_divergence_state, - int* extreme_filter_divergence) { + float* cohxd) { int i; - SmoothedPSD(mult, extended_filter_enabled, efw, dfw, xfw, coherence_state, - filter_divergence_state, extreme_filter_divergence); - { const __m128 vec_1eminus10 = _mm_set1_ps(1e-10f); @@ -747,7 +736,8 @@ void WebRtcAec_InitAec_SSE2(void) { WebRtcAec_ScaleErrorSignal = ScaleErrorSignalSSE2; WebRtcAec_FilterAdaptation = FilterAdaptationSSE2; WebRtcAec_OverdriveAndSuppress = OverdriveAndSuppressSSE2; - WebRtcAec_SubbandCoherence = SubbandCoherenceSSE2; + WebRtcAec_ComputeCoherence = ComputeCoherenceSSE2; + WebRtcAec_UpdateCoherenceSpectra = UpdateCoherenceSpectraSSE2; WebRtcAec_StoreAsComplex = StoreAsComplexSSE2; WebRtcAec_PartitionDelay = PartitionDelaySSE2; WebRtcAec_WindowData = WindowDataSSE2;