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

Side by Side Diff: webrtc/modules/audio_processing/beamformer/nonlinear_beamformer_test.cc

Issue 2110503002: Revert "Pull out the PostFilter to its own NonlinearBeamformer API" (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 5 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
1 /* 1 /*
2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 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 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 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 25 matching lines...) Expand all
36 "in as a single band, unlike the audio processing interface which splits\n" 36 "in as a single band, unlike the audio processing interface which splits\n"
37 "signals into multiple bands."; 37 "signals into multiple bands.";
38 38
39 } // namespace 39 } // namespace
40 40
41 int main(int argc, char* argv[]) { 41 int main(int argc, char* argv[]) {
42 google::SetUsageMessage(kUsage); 42 google::SetUsageMessage(kUsage);
43 google::ParseCommandLineFlags(&argc, &argv, true); 43 google::ParseCommandLineFlags(&argc, &argv, true);
44 44
45 WavReader in_file(FLAGS_i); 45 WavReader in_file(FLAGS_i);
46 WavWriter out_file(FLAGS_o, in_file.sample_rate(), in_file.num_channels()); 46 WavWriter out_file(FLAGS_o, in_file.sample_rate(), 1);
47 47
48 const size_t num_mics = in_file.num_channels(); 48 const size_t num_mics = in_file.num_channels();
49 const std::vector<Point> array_geometry = 49 const std::vector<Point> array_geometry =
50 ParseArrayGeometry(FLAGS_mic_positions, num_mics); 50 ParseArrayGeometry(FLAGS_mic_positions, num_mics);
51 RTC_CHECK_EQ(array_geometry.size(), num_mics); 51 RTC_CHECK_EQ(array_geometry.size(), num_mics);
52 52
53 NonlinearBeamformer bf(array_geometry, array_geometry.size()); 53 NonlinearBeamformer bf(array_geometry);
54 bf.Initialize(kChunkSizeMs, in_file.sample_rate()); 54 bf.Initialize(kChunkSizeMs, in_file.sample_rate());
55 55
56 printf("Input file: %s\nChannels: %" PRIuS ", Sample rate: %d Hz\n\n", 56 printf("Input file: %s\nChannels: %" PRIuS ", Sample rate: %d Hz\n\n",
57 FLAGS_i.c_str(), in_file.num_channels(), in_file.sample_rate()); 57 FLAGS_i.c_str(), in_file.num_channels(), in_file.sample_rate());
58 printf("Output file: %s\nChannels: %" PRIuS ", Sample rate: %d Hz\n\n", 58 printf("Output file: %s\nChannels: %" PRIuS ", Sample rate: %d Hz\n\n",
59 FLAGS_o.c_str(), out_file.num_channels(), out_file.sample_rate()); 59 FLAGS_o.c_str(), out_file.num_channels(), out_file.sample_rate());
60 60
61 ChannelBuffer<float> buf( 61 ChannelBuffer<float> in_buf(
62 rtc::CheckedDivExact(in_file.sample_rate(), kChunksPerSecond), 62 rtc::CheckedDivExact(in_file.sample_rate(), kChunksPerSecond),
63 in_file.num_channels()); 63 in_file.num_channels());
64 ChannelBuffer<float> out_buf(
65 rtc::CheckedDivExact(out_file.sample_rate(), kChunksPerSecond),
66 out_file.num_channels());
64 67
65 std::vector<float> interleaved(buf.size()); 68 std::vector<float> interleaved(in_buf.size());
66 while (in_file.ReadSamples(interleaved.size(), 69 while (in_file.ReadSamples(interleaved.size(),
67 &interleaved[0]) == interleaved.size()) { 70 &interleaved[0]) == interleaved.size()) {
68 FloatS16ToFloat(&interleaved[0], interleaved.size(), &interleaved[0]); 71 FloatS16ToFloat(&interleaved[0], interleaved.size(), &interleaved[0]);
69 Deinterleave(&interleaved[0], buf.num_frames(), 72 Deinterleave(&interleaved[0], in_buf.num_frames(),
70 buf.num_channels(), buf.channels()); 73 in_buf.num_channels(), in_buf.channels());
71 74
72 bf.AnalyzeChunk(buf); 75 bf.ProcessChunk(in_buf, &out_buf);
73 bf.PostFilter(&buf);
74 76
75 Interleave(buf.channels(), buf.num_frames(), 77 Interleave(out_buf.channels(), out_buf.num_frames(),
76 buf.num_channels(), &interleaved[0]); 78 out_buf.num_channels(), &interleaved[0]);
77 FloatToFloatS16(&interleaved[0], interleaved.size(), &interleaved[0]); 79 FloatToFloatS16(&interleaved[0], interleaved.size(), &interleaved[0]);
78 out_file.WriteSamples(&interleaved[0], interleaved.size()); 80 out_file.WriteSamples(&interleaved[0], interleaved.size());
79 } 81 }
80 82
81 return 0; 83 return 0;
82 } 84 }
83 85
84 } // namespace webrtc 86 } // namespace webrtc
85 87
86 int main(int argc, char* argv[]) { 88 int main(int argc, char* argv[]) {
87 return webrtc::main(argc, argv); 89 return webrtc::main(argc, argv);
88 } 90 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698