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
11 #include "modules/audio_processing/aec3/aec3_fft.h"
12
13 #include <algorithm>
14
15 #include "rtc_base/checks.h"
16
17 namespace webrtc {
18
19 // TODO(peah): Change x to be std::array once the rest of the code allows this.
ZeroPaddedFft(rtc::ArrayView<const float> x,FftData * X) const20 void Aec3Fft::ZeroPaddedFft(rtc::ArrayView<const float> x, FftData* X) const {
21 RTC_DCHECK(X);
22 RTC_DCHECK_EQ(kFftLengthBy2, x.size());
23 std::array<float, kFftLength> fft;
24 std::fill(fft.begin(), fft.begin() + kFftLengthBy2, 0.f);
25 std::copy(x.begin(), x.end(), fft.begin() + kFftLengthBy2);
26 Fft(&fft, X);
27 }
28
PaddedFft(rtc::ArrayView<const float> x,rtc::ArrayView<float> x_old,FftData * X) const29 void Aec3Fft::PaddedFft(rtc::ArrayView<const float> x,
30 rtc::ArrayView<float> x_old,
31 FftData* X) const {
32 RTC_DCHECK(X);
33 RTC_DCHECK_EQ(kFftLengthBy2, x.size());
34 RTC_DCHECK_EQ(kFftLengthBy2, x_old.size());
35 std::array<float, kFftLength> fft;
36 std::copy(x_old.begin(), x_old.end(), fft.begin());
37 std::copy(x.begin(), x.end(), fft.begin() + x_old.size());
38 std::copy(x.begin(), x.end(), x_old.begin());
39 Fft(&fft, X);
40 }
41
42 } // namespace webrtc
43