diff options
author | Allan Sandfeld Jensen <allan.jensen@theqtcompany.com> | 2015-10-13 13:24:50 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@theqtcompany.com> | 2015-10-14 10:57:25 +0000 |
commit | af3d4809763ef308f08ced947a73b624729ac7ea (patch) | |
tree | 4402b911e30383f6c6dace1e8cf3b8e85355db3a /chromium/third_party/webrtc/modules/audio_processing/aec/aec_core.c | |
parent | 0e8ff63a407fe323e215bb1a2c423c09a4747c8a (diff) | |
download | qtwebengine-chromium-af3d4809763ef308f08ced947a73b624729ac7ea.tar.gz |
BASELINE: Update Chromium to 47.0.2526.14
Also adding in sources needed for spellchecking.
Change-Id: Idd44170fa1616f26315188970a8d5ba7d472b18a
Reviewed-by: Michael BrĂ¼ning <michael.bruning@theqtcompany.com>
Diffstat (limited to 'chromium/third_party/webrtc/modules/audio_processing/aec/aec_core.c')
-rw-r--r-- | chromium/third_party/webrtc/modules/audio_processing/aec/aec_core.c | 98 |
1 files changed, 47 insertions, 51 deletions
diff --git a/chromium/third_party/webrtc/modules/audio_processing/aec/aec_core.c b/chromium/third_party/webrtc/modules/audio_processing/aec/aec_core.c index 70927074f8e..b2162ac0b91 100644 --- a/chromium/third_party/webrtc/modules/audio_processing/aec/aec_core.c +++ b/chromium/third_party/webrtc/modules/audio_processing/aec/aec_core.c @@ -29,10 +29,12 @@ #include "webrtc/modules/audio_processing/aec/aec_common.h" #include "webrtc/modules/audio_processing/aec/aec_core_internal.h" #include "webrtc/modules/audio_processing/aec/aec_rdft.h" +#include "webrtc/modules/audio_processing/logging/aec_logging.h" #include "webrtc/modules/audio_processing/utility/delay_estimator_wrapper.h" #include "webrtc/system_wrappers/interface/cpu_features_wrapper.h" #include "webrtc/typedefs.h" + // Buffer size (samples) static const size_t kBufSizePartitions = 250; // 1 second of audio in 16 kHz. @@ -818,8 +820,11 @@ static void UpdateDelayMetrics(AecCore* self) { // negative (anti-causal system) or larger than the AEC filter length. { int num_delays_out_of_bounds = self->num_delay_values; + const int histogram_length = sizeof(self->delay_histogram) / + sizeof(self->delay_histogram[0]); for (i = lookahead; i < lookahead + self->num_partitions; ++i) { - num_delays_out_of_bounds -= self->delay_histogram[i]; + if (i < histogram_length) + num_delays_out_of_bounds -= self->delay_histogram[i]; } self->fraction_poor_delays = (float)num_delays_out_of_bounds / self->num_delay_values; @@ -945,7 +950,8 @@ static void NonLinearProcessing(AecCore* aec, float fft[PART_LEN2]; float scale, dtmp; float nlpGainHband; - int i, j; + int i; + size_t j; // Coherence and non-linear filter float cohde[PART_LEN1], cohxd[PART_LEN1]; @@ -1160,8 +1166,8 @@ static void NonLinearProcessing(AecCore* aec, memcpy(aec->eBuf, aec->eBuf + PART_LEN, sizeof(float) * PART_LEN); // Copy the current block to the old position for H band - for (i = 0; i < aec->num_bands - 1; ++i) { - memcpy(aec->dBufH[i], aec->dBufH[i] + PART_LEN, sizeof(float) * PART_LEN); + for (j = 0; j < aec->num_bands - 1; ++j) { + memcpy(aec->dBufH[j], aec->dBufH[j] + PART_LEN, sizeof(float) * PART_LEN); } memmove(aec->xfwBuf + PART_LEN1, @@ -1170,7 +1176,7 @@ static void NonLinearProcessing(AecCore* aec, } static void ProcessBlock(AecCore* aec) { - int i; + size_t i; float y[PART_LEN], e[PART_LEN]; float scale; @@ -1219,8 +1225,8 @@ static void ProcessBlock(AecCore* aec) { float farend[PART_LEN]; float* farend_ptr = NULL; WebRtc_ReadBuffer(aec->far_time_buf, (void**)&farend_ptr, farend, 1); - rtc_WavWriteSamples(aec->farFile, farend_ptr, PART_LEN); - rtc_WavWriteSamples(aec->nearFile, nearend_ptr, PART_LEN); + RTC_AEC_DEBUG_WAV_WRITE(aec->farFile, farend_ptr, PART_LEN); + RTC_AEC_DEBUG_WAV_WRITE(aec->nearFile, nearend_ptr, PART_LEN); } #endif @@ -1347,6 +1353,10 @@ static void ProcessBlock(AecCore* aec) { ef[1][i] = fft[2 * i + 1]; } + RTC_AEC_DEBUG_RAW_WRITE(aec->e_fft_file, + &ef[0][0], + sizeof(ef[0][0]) * PART_LEN1 * 2); + if (aec->metricsMode == 1) { // Note that the first PART_LEN samples in fft (before transformation) are // zero. Hence, the scaling by two in UpdateLevel() should not be @@ -1373,10 +1383,8 @@ static void ProcessBlock(AecCore* aec) { WebRtc_WriteBuffer(aec->outFrBufH[i], outputH[i], PART_LEN); } -#ifdef WEBRTC_AEC_DEBUG_DUMP - rtc_WavWriteSamples(aec->outLinearFile, e, PART_LEN); - rtc_WavWriteSamples(aec->outFile, output, PART_LEN); -#endif + RTC_AEC_DEBUG_WAV_WRITE(aec->outLinearFile, e, PART_LEN); + RTC_AEC_DEBUG_WAV_WRITE(aec->outFile, output, PART_LEN); } AecCore* WebRtcAec_CreateAec() { @@ -1511,40 +1519,19 @@ void WebRtcAec_FreeAec(AecCore* aec) { WebRtc_FreeBuffer(aec->far_buf_windowed); #ifdef WEBRTC_AEC_DEBUG_DUMP WebRtc_FreeBuffer(aec->far_time_buf); - rtc_WavClose(aec->farFile); - rtc_WavClose(aec->nearFile); - rtc_WavClose(aec->outFile); - rtc_WavClose(aec->outLinearFile); #endif + RTC_AEC_DEBUG_WAV_CLOSE(aec->farFile); + RTC_AEC_DEBUG_WAV_CLOSE(aec->nearFile); + RTC_AEC_DEBUG_WAV_CLOSE(aec->outFile); + RTC_AEC_DEBUG_WAV_CLOSE(aec->outLinearFile); + RTC_AEC_DEBUG_RAW_CLOSE(aec->e_fft_file); + WebRtc_FreeDelayEstimator(aec->delay_estimator); WebRtc_FreeDelayEstimatorFarend(aec->delay_estimator_farend); free(aec); } -#ifdef WEBRTC_AEC_DEBUG_DUMP -// Open a new Wav file for writing. If it was already open with a different -// sample frequency, close it first. -static void ReopenWav(rtc_WavWriter** wav_file, - const char* name, - int seq1, - int seq2, - int sample_rate) { - int written ATTRIBUTE_UNUSED; - char filename[64]; - if (*wav_file) { - if (rtc_WavSampleRate(*wav_file) == sample_rate) - return; - rtc_WavClose(*wav_file); - } - written = snprintf(filename, sizeof(filename), "%s%d-%d.wav", - name, seq1, seq2); - assert(written >= 0); // no output error - assert((size_t)written < sizeof(filename)); // buffer was large enough - *wav_file = rtc_WavOpen(filename, sample_rate, 1); -} -#endif // WEBRTC_AEC_DEBUG_DUMP - int WebRtcAec_InitAec(AecCore* aec, int sampFreq) { int i; @@ -1557,7 +1544,7 @@ int WebRtcAec_InitAec(AecCore* aec, int sampFreq) { } else { aec->normal_mu = 0.5f; aec->normal_error_threshold = 1.5e-6f; - aec->num_bands = sampFreq / 16000; + aec->num_bands = (size_t)(sampFreq / 16000); } WebRtc_InitBuffer(aec->nearFrBuf); @@ -1574,15 +1561,24 @@ int WebRtcAec_InitAec(AecCore* aec, int sampFreq) { WebRtc_InitBuffer(aec->far_time_buf); { int process_rate = sampFreq > 16000 ? 16000 : sampFreq; - ReopenWav(&aec->farFile, "aec_far", - aec->instance_index, aec->debug_dump_count, process_rate); - ReopenWav(&aec->nearFile, "aec_near", - aec->instance_index, aec->debug_dump_count, process_rate); - ReopenWav(&aec->outFile, "aec_out", - aec->instance_index, aec->debug_dump_count, process_rate); - ReopenWav(&aec->outLinearFile, "aec_out_linear", - aec->instance_index, aec->debug_dump_count, process_rate); - } + RTC_AEC_DEBUG_WAV_REOPEN("aec_far", aec->instance_index, + aec->debug_dump_count, process_rate, + &aec->farFile ); + RTC_AEC_DEBUG_WAV_REOPEN("aec_near", aec->instance_index, + aec->debug_dump_count, process_rate, + &aec->nearFile); + RTC_AEC_DEBUG_WAV_REOPEN("aec_out", aec->instance_index, + aec->debug_dump_count, process_rate, + &aec->outFile ); + RTC_AEC_DEBUG_WAV_REOPEN("aec_out_linear", aec->instance_index, + aec->debug_dump_count, process_rate, + &aec->outLinearFile); + } + + RTC_AEC_DEBUG_RAW_OPEN("aec_e_fft", + aec->debug_dump_count, + &aec->e_fft_file); + ++aec->debug_dump_count; #endif aec->system_delay = 0; @@ -1731,11 +1727,11 @@ int WebRtcAec_MoveFarReadPtr(AecCore* aec, int elements) { void WebRtcAec_ProcessFrames(AecCore* aec, const float* const* nearend, - int num_bands, - int num_samples, + size_t num_bands, + size_t num_samples, int knownDelay, float* const* out) { - int i, j; + size_t i, j; int out_elements = 0; aec->frame_count++; |