| OLD | NEW |
| 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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 WavWriter out_file(FLAGS_o, out_sample_rate, out_channels); | 98 WavWriter out_file(FLAGS_o, out_sample_rate, out_channels); |
| 99 | 99 |
| 100 Config config; | 100 Config config; |
| 101 config.Set<ExperimentalNs>(new ExperimentalNs(FLAGS_ts || FLAGS_all)); | 101 config.Set<ExperimentalNs>(new ExperimentalNs(FLAGS_ts || FLAGS_all)); |
| 102 config.Set<Intelligibility>(new Intelligibility(FLAGS_ie || FLAGS_all)); | 102 config.Set<Intelligibility>(new Intelligibility(FLAGS_ie || FLAGS_all)); |
| 103 | 103 |
| 104 if (FLAGS_bf || FLAGS_all) { | 104 if (FLAGS_bf || FLAGS_all) { |
| 105 const size_t num_mics = in_file.num_channels(); | 105 const size_t num_mics = in_file.num_channels(); |
| 106 const std::vector<Point> array_geometry = | 106 const std::vector<Point> array_geometry = |
| 107 ParseArrayGeometry(FLAGS_mic_positions, num_mics); | 107 ParseArrayGeometry(FLAGS_mic_positions, num_mics); |
| 108 CHECK_EQ(array_geometry.size(), num_mics); | 108 RTC_CHECK_EQ(array_geometry.size(), num_mics); |
| 109 | 109 |
| 110 config.Set<Beamforming>(new Beamforming(true, array_geometry)); | 110 config.Set<Beamforming>(new Beamforming(true, array_geometry)); |
| 111 } | 111 } |
| 112 | 112 |
| 113 rtc::scoped_ptr<AudioProcessing> ap(AudioProcessing::Create(config)); | 113 rtc::scoped_ptr<AudioProcessing> ap(AudioProcessing::Create(config)); |
| 114 if (!FLAGS_dump.empty()) { | 114 if (!FLAGS_dump.empty()) { |
| 115 CHECK_EQ(kNoErr, ap->echo_cancellation()->Enable(FLAGS_aec || FLAGS_all)); | 115 RTC_CHECK_EQ(kNoErr, |
| 116 ap->echo_cancellation()->Enable(FLAGS_aec || FLAGS_all)); |
| 116 } else if (FLAGS_aec) { | 117 } else if (FLAGS_aec) { |
| 117 fprintf(stderr, "-aec requires a -dump file.\n"); | 118 fprintf(stderr, "-aec requires a -dump file.\n"); |
| 118 return -1; | 119 return -1; |
| 119 } | 120 } |
| 120 bool process_reverse = !FLAGS_i_rev.empty(); | 121 bool process_reverse = !FLAGS_i_rev.empty(); |
| 121 CHECK_EQ(kNoErr, ap->gain_control()->Enable(FLAGS_agc || FLAGS_all)); | 122 RTC_CHECK_EQ(kNoErr, ap->gain_control()->Enable(FLAGS_agc || FLAGS_all)); |
| 122 CHECK_EQ(kNoErr, ap->gain_control()->set_mode(GainControl::kFixedDigital)); | 123 RTC_CHECK_EQ(kNoErr, |
| 123 CHECK_EQ(kNoErr, ap->high_pass_filter()->Enable(FLAGS_hpf || FLAGS_all)); | 124 ap->gain_control()->set_mode(GainControl::kFixedDigital)); |
| 124 CHECK_EQ(kNoErr, ap->noise_suppression()->Enable(FLAGS_ns || FLAGS_all)); | 125 RTC_CHECK_EQ(kNoErr, ap->high_pass_filter()->Enable(FLAGS_hpf || FLAGS_all)); |
| 126 RTC_CHECK_EQ(kNoErr, ap->noise_suppression()->Enable(FLAGS_ns || FLAGS_all)); |
| 125 if (FLAGS_ns_level != -1) | 127 if (FLAGS_ns_level != -1) |
| 126 CHECK_EQ(kNoErr, ap->noise_suppression()->set_level( | 128 RTC_CHECK_EQ(kNoErr, |
| 127 static_cast<NoiseSuppression::Level>(FLAGS_ns_level))); | 129 ap->noise_suppression()->set_level( |
| 130 static_cast<NoiseSuppression::Level>(FLAGS_ns_level))); |
| 128 | 131 |
| 129 printf("Input file: %s\nChannels: %d, Sample rate: %d Hz\n\n", | 132 printf("Input file: %s\nChannels: %d, Sample rate: %d Hz\n\n", |
| 130 FLAGS_i.c_str(), in_file.num_channels(), in_file.sample_rate()); | 133 FLAGS_i.c_str(), in_file.num_channels(), in_file.sample_rate()); |
| 131 printf("Output file: %s\nChannels: %d, Sample rate: %d Hz\n\n", | 134 printf("Output file: %s\nChannels: %d, Sample rate: %d Hz\n\n", |
| 132 FLAGS_o.c_str(), out_file.num_channels(), out_file.sample_rate()); | 135 FLAGS_o.c_str(), out_file.num_channels(), out_file.sample_rate()); |
| 133 | 136 |
| 134 ChannelBuffer<float> in_buf( | 137 ChannelBuffer<float> in_buf( |
| 135 rtc::CheckedDivExact(in_file.sample_rate(), kChunksPerSecond), | 138 rtc::CheckedDivExact(in_file.sample_rate(), kChunksPerSecond), |
| 136 in_file.num_channels()); | 139 in_file.num_channels()); |
| 137 ChannelBuffer<float> out_buf( | 140 ChannelBuffer<float> out_buf( |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 in_rev_interleaved.data()); | 192 in_rev_interleaved.data()); |
| 190 FloatS16ToFloat(in_rev_interleaved.data(), in_rev_interleaved.size(), | 193 FloatS16ToFloat(in_rev_interleaved.data(), in_rev_interleaved.size(), |
| 191 in_rev_interleaved.data()); | 194 in_rev_interleaved.data()); |
| 192 Deinterleave(in_rev_interleaved.data(), in_rev_buf->num_frames(), | 195 Deinterleave(in_rev_interleaved.data(), in_rev_buf->num_frames(), |
| 193 in_rev_buf->num_channels(), in_rev_buf->channels()); | 196 in_rev_buf->num_channels(), in_rev_buf->channels()); |
| 194 } | 197 } |
| 195 | 198 |
| 196 if (FLAGS_perf) { | 199 if (FLAGS_perf) { |
| 197 processing_start_time = TickTime::Now(); | 200 processing_start_time = TickTime::Now(); |
| 198 } | 201 } |
| 199 CHECK_EQ(kNoErr, ap->ProcessStream(in_buf.channels(), input_config, | 202 RTC_CHECK_EQ(kNoErr, ap->ProcessStream(in_buf.channels(), input_config, |
| 200 output_config, out_buf.channels())); | 203 output_config, out_buf.channels())); |
| 201 if (process_reverse) { | 204 if (process_reverse) { |
| 202 CHECK_EQ(kNoErr, ap->ProcessReverseStream( | 205 RTC_CHECK_EQ(kNoErr, ap->ProcessReverseStream( |
| 203 in_rev_buf->channels(), reverse_input_config, | 206 in_rev_buf->channels(), reverse_input_config, |
| 204 reverse_output_config, out_rev_buf->channels())); | 207 reverse_output_config, out_rev_buf->channels())); |
| 205 } | 208 } |
| 206 if (FLAGS_perf) { | 209 if (FLAGS_perf) { |
| 207 accumulated_time += TickTime::Now() - processing_start_time; | 210 accumulated_time += TickTime::Now() - processing_start_time; |
| 208 } | 211 } |
| 209 | 212 |
| 210 Interleave(out_buf.channels(), out_buf.num_frames(), | 213 Interleave(out_buf.channels(), out_buf.num_frames(), |
| 211 out_buf.num_channels(), &out_interleaved[0]); | 214 out_buf.num_channels(), &out_interleaved[0]); |
| 212 FloatToFloatS16(&out_interleaved[0], out_interleaved.size(), | 215 FloatToFloatS16(&out_interleaved[0], out_interleaved.size(), |
| 213 &out_interleaved[0]); | 216 &out_interleaved[0]); |
| 214 out_file.WriteSamples(&out_interleaved[0], out_interleaved.size()); | 217 out_file.WriteSamples(&out_interleaved[0], out_interleaved.size()); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 230 execution_time_ms * 1.f / num_chunks); | 233 execution_time_ms * 1.f / num_chunks); |
| 231 } | 234 } |
| 232 return 0; | 235 return 0; |
| 233 } | 236 } |
| 234 | 237 |
| 235 } // namespace webrtc | 238 } // namespace webrtc |
| 236 | 239 |
| 237 int main(int argc, char* argv[]) { | 240 int main(int argc, char* argv[]) { |
| 238 return webrtc::main(argc, argv); | 241 return webrtc::main(argc, argv); |
| 239 } | 242 } |
| OLD | NEW |