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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 /*
2 * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved.
3 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10 #include "webrtc/modules/audio_processing/aec3/down_sampler_4khz.h"
11
12 #include "webrtc/base/checks.h"
13 #include "webrtc/modules/audio_processing/aec3/aec3_constants.h"
14 #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.
15
16 namespace webrtc {
17 namespace {
18
19 // [B,A] = butter(2,750/8000)
20 const CascadedBiQuadFilter::BiQuadCoefficients kLowPassFilterCoefficients_8kHz =
21 {{0.0179f, 0.0357f, 0.0179f}, {-1.5879f, 0.6594f}};
22
23 // [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
24 const CascadedBiQuadFilter::BiQuadCoefficients
25 kLowPassFilterCoefficients_16kHz = {{0.0179f, 0.0357f, 0.0179f},
26 {-1.5879f, 0.6594f}};
27
28 } // namespace
29
30 DownSampler4kHz::DownSampler4kHz(int sample_rate_hz)
31 : 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
32 low_pass_filter_(sample_rate_hz == 8000
33 ? kLowPassFilterCoefficients_8kHz
34 : kLowPassFilterCoefficients_16kHz,
35 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
36 RTC_DCHECK(ValidFullBandRate(sample_rate_hz));
37 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
38 }
39
40 void DownSampler4kHz::DownSample(rtc::ArrayView<const float> in,
41 rtc::ArrayView<float> out) {
42 RTC_DCHECK_EQ(kBlockSize, in.size());
43 RTC_DCHECK_EQ(kSubBlockSize, out.size());
44 float x[kBlockSize];
45
46 // Limit the frequency content of the signal to avoid aliasing.
47 low_pass_filter_.Process(in, x);
48
49 // Downsample the signal.
50 for (size_t j = 0, k = 0; j < out.size(); ++j, k += down_sampling_factor_) {
51 RTC_DCHECK_GT(kBlockSize, k);
52 out[j] = x[k];
53 }
54 }
55
56 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698