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

Side by Side Diff: webrtc/modules/audio_processing/aec3/fft_buffer_unittest.cc

Issue 2678423005: Finalization of the first version of EchoCanceller 3 (Closed)
Patch Set: Fixed compilation error Created 3 years, 10 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
11 #include "webrtc/modules/audio_processing/aec3/fft_buffer.h"
12
13 #include <algorithm>
14 #include <functional>
15 #include <vector>
16
17 #include "webrtc/test/gtest.h"
18
19 namespace webrtc {
20 namespace {} // namespace
21
22 #if RTC_DCHECK_IS_ON && GTEST_HAS_DEATH_TEST && !defined(WEBRTC_ANDROID)
23
24 // Verifies that the check for that the provided numbers of Ffts to include in
25 // the spectral sum is equal to the one supported works.
26 TEST(FftBuffer, TooLargeNumberOfSpectralSums) {
27 EXPECT_DEATH(FftBuffer(Aec3Optimization::kNone, 1, std::vector<size_t>(2, 1)),
aleloi 2017/02/23 15:16:01 This FftBuffer(Aec3Optimization::kNone, 1, {1, 1})
28 "");
29 }
30
31 TEST(FftBuffer, TooSmallNumberOfSpectralSums) {
32 EXPECT_DEATH(FftBuffer(Aec3Optimization::kNone, 1, std::vector<size_t>()),
aleloi 2017/02/23 15:16:01 Same here.
33 "");
34 }
35
36 // Verifies that the check for that the provided number of Ffts to to include in
37 // the spectral is feasible works.
38 TEST(FftBuffer, FeasibleNumberOfFftsInSum) {
aleloi 2017/02/23 15:16:01 Perhaps Feasible -> InFeasible ? Otherwise naming
39 EXPECT_DEATH(FftBuffer(Aec3Optimization::kNone, 1, std::vector<size_t>(1, 2)),
aleloi 2017/02/23 15:16:01 And here.
40 "");
41 }
42
43 #endif
44
45 // Verify the basic usage of the FftBuffer.
46 TEST(FftBuffer, NormalUsage) {
47 constexpr int kBufferSize = 10;
48 FftBuffer buffer(Aec3Optimization::kNone, kBufferSize,
49 std::vector<size_t>(1, kBufferSize));
aleloi 2017/02/23 15:16:01 vector<...>(...) --> {kBufferSize}
50 FftData X;
51 std::vector<std::array<float, kFftLengthBy2Plus1>> buffer_ref(kBufferSize);
52
53 for (int k = 0; k < 30; ++k) {
54 std::array<float, kFftLengthBy2Plus1> X2_sum_ref;
55 X2_sum_ref.fill(0.f);
56 for (size_t j = 0; j < buffer.Buffer().size(); ++j) {
57 const std::array<float, kFftLengthBy2Plus1>& X2 = buffer.Spectrum(j);
58 const std::array<float, kFftLengthBy2Plus1>& X2_ref = buffer_ref[j];
59 EXPECT_EQ(X2_ref, X2);
60
61 std::transform(X2_ref.begin(), X2_ref.end(), X2_sum_ref.begin(),
62 X2_sum_ref.begin(), std::plus<float>());
63 }
64 EXPECT_EQ(X2_sum_ref, buffer.SpectralSum(kBufferSize));
65
66 std::array<float, kFftLengthBy2Plus1> X2;
67 X.re.fill(k);
68 X.im.fill(k);
69 X.Spectrum(Aec3Optimization::kNone, &X2);
70 buffer.Insert(X);
71 buffer_ref.pop_back();
72 buffer_ref.insert(buffer_ref.begin(), X2);
73 }
74 }
75
76 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698