Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(77)

Unified Diff: webrtc/modules/audio_processing/aec3/down_sampler_4khz.cc

Issue 2644123002: Adding full initial version of delay estimation functionality in echo canceller 3 (Closed)
Patch Set: Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: webrtc/modules/audio_processing/aec3/down_sampler_4khz.cc
diff --git a/webrtc/modules/audio_processing/aec3/down_sampler_4khz.cc b/webrtc/modules/audio_processing/aec3/down_sampler_4khz.cc
new file mode 100644
index 0000000000000000000000000000000000000000..96f9641be33086c0a778541788f24ad3039e4ad4
--- /dev/null
+++ b/webrtc/modules/audio_processing/aec3/down_sampler_4khz.cc
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved.
+ *
+ * Use of this source code is governed by a BSD-style license
+ * that can be found in the LICENSE file in the root of the source
+ * tree. An additional intellectual property rights grant can be found
+ * in the file PATENTS. All contributing project authors may
+ * be found in the AUTHORS file in the root of the source tree.
+ */
+#include "webrtc/modules/audio_processing/aec3/down_sampler_4khz.h"
+
+#include "webrtc/base/checks.h"
+#include "webrtc/modules/audio_processing/aec3/aec3_constants.h"
+#include "webrtc/modules/audio_processing/aec3/cascaded_biquad_filter.h"
aleloi 2017/01/27 15:37:47 included i parent header.
peah-webrtc 2017/02/02 14:04:46 Done.
+
+namespace webrtc {
+namespace {
+
+// [B,A] = butter(2,750/8000)
+const CascadedBiQuadFilter::BiQuadCoefficients kLowPassFilterCoefficients_8kHz =
+ {{0.0179f, 0.0357f, 0.0179f}, {-1.5879f, 0.6594f}};
+
+// [B,A] = butter(2,1500/16000)
aleloi 2017/01/27 15:37:47 Should the second argument be the same as for 8kHz
hlundin-webrtc 2017/02/01 08:30:01 I ask the same. The resulting coefficients are ide
peah-webrtc 2017/02/02 14:04:46 Oups! Yes, this became quite mixed up. Please see
peah-webrtc 2017/02/02 14:04:46 Oups! Yes, this became quite mixed up. Please see
+const CascadedBiQuadFilter::BiQuadCoefficients
+ kLowPassFilterCoefficients_16kHz = {{0.0179f, 0.0357f, 0.0179f},
+ {-1.5879f, 0.6594f}};
+
+} // namespace
+
+DownSampler4kHz::DownSampler4kHz(int sample_rate_hz)
+ : down_sampling_factor_(rtc::CheckedDivExact(kBlockSize, kSubBlockSize)),
hlundin-webrtc 2017/02/01 08:30:01 I would have expected the downsampling factor to b
peah-webrtc 2017/02/02 14:04:46 Yes, you are fully correct. Since the downsampling
+ low_pass_filter_(sample_rate_hz == 8000
+ ? kLowPassFilterCoefficients_8kHz
+ : kLowPassFilterCoefficients_16kHz,
+ 3) {
aleloi 2017/01/27 15:37:47 IIUC, the number 3 is the number of cascaded filte
peah-webrtc 2017/02/02 14:04:46 My purpose of aec3_constants is that it should con
+ RTC_DCHECK(ValidFullBandRate(sample_rate_hz));
+ RTC_DCHECK_EQ(4, down_sampling_factor_);
aleloi 2017/01/27 15:37:47 I seem to be missing something... Why does the dow
hlundin-webrtc 2017/02/01 08:30:01 ... but the name of the class would be misleading.
peah-webrtc 2017/02/02 14:04:46 You are totally correct. I changed this now. PTAL
peah-webrtc 2017/02/02 14:04:46 Agree. PTAL
+}
+
+void DownSampler4kHz::DownSample(rtc::ArrayView<const float> in,
+ rtc::ArrayView<float> out) {
+ RTC_DCHECK_EQ(kBlockSize, in.size());
+ RTC_DCHECK_EQ(kSubBlockSize, out.size());
+ float x[kBlockSize];
+
+ // Limit the frequency content of the signal to avoid aliasing.
+ low_pass_filter_.Process(in, x);
+
+ // Downsample the signal.
+ for (size_t j = 0, k = 0; j < out.size(); ++j, k += down_sampling_factor_) {
+ RTC_DCHECK_GT(kBlockSize, k);
+ out[j] = x[k];
+ }
+}
+
+} // namespace webrtc

Powered by Google App Engine
This is Rietveld 408576698