andrew@webrtc.org | 08df9b2 | 2014-12-16 20:57:15 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2014 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 | |
Per Åhgren | 6ee75fd | 2019-04-26 11:33:37 +0200 | [diff] [blame] | 11 | #include "modules/audio_processing/test/audioproc_float_impl.h" |
| 12 | |
Ivo Creusen | 2cb4105 | 2018-03-15 12:22:52 +0100 | [diff] [blame] | 13 | #include <string.h> |
| 14 | |
aluebs | b0ad43b | 2015-11-20 00:11:53 -0800 | [diff] [blame] | 15 | #include <iostream> |
kwiberg | 62eaacf | 2016-02-17 06:39:05 -0800 | [diff] [blame] | 16 | #include <memory> |
Ivo Creusen | 2cb4105 | 2018-03-15 12:22:52 +0100 | [diff] [blame] | 17 | #include <string> |
| 18 | #include <utility> |
Alessio Bazzica | 6817038 | 2018-11-20 12:27:20 +0100 | [diff] [blame] | 19 | #include <vector> |
andrew@webrtc.org | 08df9b2 | 2014-12-16 20:57:15 +0000 | [diff] [blame] | 20 | |
Mirko Bonadei | 2ab97f6 | 2019-07-18 13:44:12 +0200 | [diff] [blame] | 21 | #include "absl/flags/flag.h" |
| 22 | #include "absl/flags/parse.h" |
Alessio Bazzica | 6817038 | 2018-11-20 12:27:20 +0100 | [diff] [blame] | 23 | #include "absl/strings/string_view.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 24 | #include "modules/audio_processing/include/audio_processing.h" |
| 25 | #include "modules/audio_processing/test/aec_dump_based_simulator.h" |
| 26 | #include "modules/audio_processing/test/audio_processing_simulator.h" |
| 27 | #include "modules/audio_processing/test/wav_based_simulator.h" |
Alessio Bazzica | 6817038 | 2018-11-20 12:27:20 +0100 | [diff] [blame] | 28 | #include "rtc_base/checks.h" |
Alessio Bazzica | 6817038 | 2018-11-20 12:27:20 +0100 | [diff] [blame] | 29 | #include "rtc_base/strings/string_builder.h" |
andrew@webrtc.org | 08df9b2 | 2014-12-16 20:57:15 +0000 | [diff] [blame] | 30 | |
Mirko Bonadei | 2ab97f6 | 2019-07-18 13:44:12 +0200 | [diff] [blame] | 31 | constexpr int kParameterNotSpecifiedValue = -10000; |
| 32 | |
| 33 | ABSL_FLAG(std::string, dump_input, "", "Aec dump input filename"); |
| 34 | ABSL_FLAG(std::string, dump_output, "", "Aec dump output filename"); |
| 35 | ABSL_FLAG(std::string, i, "", "Forward stream input wav filename"); |
| 36 | ABSL_FLAG(std::string, o, "", "Forward stream output wav filename"); |
| 37 | ABSL_FLAG(std::string, ri, "", "Reverse stream input wav filename"); |
| 38 | ABSL_FLAG(std::string, ro, "", "Reverse stream output wav filename"); |
| 39 | ABSL_FLAG(std::string, |
| 40 | artificial_nearend, |
| 41 | "", |
| 42 | "Artificial nearend wav filename"); |
Per Åhgren | c20a19c | 2019-11-13 11:12:29 +0100 | [diff] [blame] | 43 | ABSL_FLAG(std::string, linear_aec_output, "", "Linear AEC output wav filename"); |
Mirko Bonadei | 2ab97f6 | 2019-07-18 13:44:12 +0200 | [diff] [blame] | 44 | ABSL_FLAG(int, |
| 45 | output_num_channels, |
| 46 | kParameterNotSpecifiedValue, |
| 47 | "Number of forward stream output channels"); |
| 48 | ABSL_FLAG(int, |
| 49 | reverse_output_num_channels, |
| 50 | kParameterNotSpecifiedValue, |
| 51 | "Number of Reverse stream output channels"); |
| 52 | ABSL_FLAG(int, |
| 53 | output_sample_rate_hz, |
| 54 | kParameterNotSpecifiedValue, |
| 55 | "Forward stream output sample rate in Hz"); |
| 56 | ABSL_FLAG(int, |
| 57 | reverse_output_sample_rate_hz, |
| 58 | kParameterNotSpecifiedValue, |
| 59 | "Reverse stream output sample rate in Hz"); |
| 60 | ABSL_FLAG(bool, |
| 61 | fixed_interface, |
| 62 | false, |
| 63 | "Use the fixed interface when operating on wav files"); |
| 64 | ABSL_FLAG(int, |
| 65 | aec, |
| 66 | kParameterNotSpecifiedValue, |
| 67 | "Activate (1) or deactivate(0) the echo canceller"); |
| 68 | ABSL_FLAG(int, |
| 69 | aecm, |
| 70 | kParameterNotSpecifiedValue, |
| 71 | "Activate (1) or deactivate(0) the mobile echo controller"); |
| 72 | ABSL_FLAG(int, |
| 73 | ed, |
| 74 | kParameterNotSpecifiedValue, |
| 75 | "Activate (1) or deactivate (0) the residual echo detector"); |
| 76 | ABSL_FLAG(std::string, |
| 77 | ed_graph, |
| 78 | "", |
| 79 | "Output filename for graph of echo likelihood"); |
| 80 | ABSL_FLAG(int, |
| 81 | agc, |
| 82 | kParameterNotSpecifiedValue, |
| 83 | "Activate (1) or deactivate(0) the AGC"); |
| 84 | ABSL_FLAG(int, |
| 85 | agc2, |
| 86 | kParameterNotSpecifiedValue, |
| 87 | "Activate (1) or deactivate(0) the AGC2"); |
| 88 | ABSL_FLAG(int, |
| 89 | pre_amplifier, |
| 90 | kParameterNotSpecifiedValue, |
| 91 | "Activate (1) or deactivate(0) the pre amplifier"); |
| 92 | ABSL_FLAG(int, |
| 93 | hpf, |
| 94 | kParameterNotSpecifiedValue, |
| 95 | "Activate (1) or deactivate(0) the high-pass filter"); |
| 96 | ABSL_FLAG(int, |
| 97 | ns, |
| 98 | kParameterNotSpecifiedValue, |
| 99 | "Activate (1) or deactivate(0) the noise suppressor"); |
| 100 | ABSL_FLAG(int, |
| 101 | ts, |
| 102 | kParameterNotSpecifiedValue, |
| 103 | "Activate (1) or deactivate(0) the transient suppressor"); |
| 104 | ABSL_FLAG(int, |
| 105 | vad, |
| 106 | kParameterNotSpecifiedValue, |
| 107 | "Activate (1) or deactivate(0) the voice activity detector"); |
| 108 | ABSL_FLAG(int, |
| 109 | le, |
| 110 | kParameterNotSpecifiedValue, |
| 111 | "Activate (1) or deactivate(0) the level estimator"); |
| 112 | ABSL_FLAG(bool, |
| 113 | all_default, |
| 114 | false, |
| 115 | "Activate all of the default components (will be overridden by any " |
| 116 | "other settings)"); |
| 117 | ABSL_FLAG(int, |
Per Åhgren | 0cbb58e | 2019-10-29 22:59:44 +0100 | [diff] [blame] | 118 | use_legacy_ns, |
| 119 | kParameterNotSpecifiedValue, |
Per Åhgren | 62ea0aa | 2019-12-09 10:18:44 +0100 | [diff] [blame] | 120 | "Activate (1) or deactivate(0) the legacy NS"); |
Per Åhgren | 0cbb58e | 2019-10-29 22:59:44 +0100 | [diff] [blame] | 121 | ABSL_FLAG(int, |
Mirko Bonadei | 2ab97f6 | 2019-07-18 13:44:12 +0200 | [diff] [blame] | 122 | experimental_agc, |
| 123 | kParameterNotSpecifiedValue, |
| 124 | "Activate (1) or deactivate(0) the experimental AGC"); |
| 125 | ABSL_FLAG(int, |
| 126 | experimental_agc_disable_digital_adaptive, |
| 127 | kParameterNotSpecifiedValue, |
| 128 | "Force-deactivate (1) digital adaptation in " |
| 129 | "experimental AGC. Digital adaptation is active by default (0)."); |
| 130 | ABSL_FLAG(int, |
| 131 | experimental_agc_analyze_before_aec, |
| 132 | kParameterNotSpecifiedValue, |
| 133 | "Make level estimation happen before AEC" |
| 134 | " in the experimental AGC. After AEC is the default (0)"); |
| 135 | ABSL_FLAG(int, |
| 136 | experimental_agc_agc2_level_estimator, |
| 137 | kParameterNotSpecifiedValue, |
| 138 | "AGC2 level estimation" |
| 139 | " in the experimental AGC. AGC1 level estimation is the default (0)"); |
Mirko Bonadei | 2ab97f6 | 2019-07-18 13:44:12 +0200 | [diff] [blame] | 140 | ABSL_FLAG(int, |
| 141 | agc_mode, |
| 142 | kParameterNotSpecifiedValue, |
| 143 | "Specify the AGC mode (0-2)"); |
| 144 | ABSL_FLAG(int, |
| 145 | agc_target_level, |
| 146 | kParameterNotSpecifiedValue, |
| 147 | "Specify the AGC target level (0-31)"); |
| 148 | ABSL_FLAG(int, |
| 149 | agc_limiter, |
| 150 | kParameterNotSpecifiedValue, |
| 151 | "Activate (1) or deactivate(0) the level estimator"); |
| 152 | ABSL_FLAG(int, |
| 153 | agc_compression_gain, |
| 154 | kParameterNotSpecifiedValue, |
| 155 | "Specify the AGC compression gain (0-90)"); |
| 156 | ABSL_FLAG(int, |
| 157 | agc2_enable_adaptive_gain, |
| 158 | kParameterNotSpecifiedValue, |
| 159 | "Activate (1) or deactivate(0) the AGC2 adaptive gain"); |
| 160 | ABSL_FLAG(float, |
| 161 | agc2_fixed_gain_db, |
| 162 | kParameterNotSpecifiedValue, |
| 163 | "AGC2 fixed gain (dB) to apply"); |
| 164 | ABSL_FLAG(std::string, |
| 165 | agc2_adaptive_level_estimator, |
| 166 | "RMS", |
| 167 | "AGC2 adaptive digital level estimator to use [RMS, peak]"); |
| 168 | ABSL_FLAG(float, |
| 169 | pre_amplifier_gain_factor, |
| 170 | kParameterNotSpecifiedValue, |
| 171 | "Pre-amplifier gain factor (linear) to apply"); |
| 172 | ABSL_FLAG(int, |
Mirko Bonadei | 2ab97f6 | 2019-07-18 13:44:12 +0200 | [diff] [blame] | 173 | ns_level, |
| 174 | kParameterNotSpecifiedValue, |
| 175 | "Specify the NS level (0-3)"); |
| 176 | ABSL_FLAG(int, |
Per Åhgren | 2e8e1c6 | 2019-12-20 00:42:22 +0100 | [diff] [blame^] | 177 | ns_analysis_on_linear_aec_output, |
| 178 | kParameterNotSpecifiedValue, |
| 179 | "Specifies whether the noise suppression analysis is done on the " |
| 180 | "linear AEC output"); |
| 181 | ABSL_FLAG(int, |
Per Åhgren | fcbe407 | 2019-09-15 00:27:58 +0200 | [diff] [blame] | 182 | maximum_internal_processing_rate, |
| 183 | kParameterNotSpecifiedValue, |
| 184 | "Set a maximum internal processing rate (32000 or 48000) to override " |
| 185 | "the default rate"); |
| 186 | ABSL_FLAG(int, |
Mirko Bonadei | 2ab97f6 | 2019-07-18 13:44:12 +0200 | [diff] [blame] | 187 | stream_delay, |
| 188 | kParameterNotSpecifiedValue, |
| 189 | "Specify the stream delay in ms to use"); |
| 190 | ABSL_FLAG(int, |
| 191 | use_stream_delay, |
| 192 | kParameterNotSpecifiedValue, |
| 193 | "Activate (1) or deactivate(0) reporting the stream delay"); |
| 194 | ABSL_FLAG(int, |
| 195 | stream_drift_samples, |
| 196 | kParameterNotSpecifiedValue, |
| 197 | "Specify the number of stream drift samples to use"); |
| 198 | ABSL_FLAG(int, initial_mic_level, 100, "Initial mic level (0-255)"); |
| 199 | ABSL_FLAG(int, |
| 200 | simulate_mic_gain, |
| 201 | 0, |
| 202 | "Activate (1) or deactivate(0) the analog mic gain simulation"); |
| 203 | ABSL_FLAG(int, |
Per Åhgren | e14cb99 | 2019-11-27 09:34:22 +0100 | [diff] [blame] | 204 | multi_channel_render, |
Sam Zackrisson | feee1e4 | 2019-09-20 07:50:35 +0200 | [diff] [blame] | 205 | kParameterNotSpecifiedValue, |
Per Åhgren | e14cb99 | 2019-11-27 09:34:22 +0100 | [diff] [blame] | 206 | "Activate (1) or deactivate(0) multi-channel render processing in " |
| 207 | "APM pipeline"); |
| 208 | ABSL_FLAG(int, |
| 209 | multi_channel_capture, |
| 210 | kParameterNotSpecifiedValue, |
| 211 | "Activate (1) or deactivate(0) multi-channel capture processing in " |
| 212 | "APM pipeline"); |
Sam Zackrisson | feee1e4 | 2019-09-20 07:50:35 +0200 | [diff] [blame] | 213 | ABSL_FLAG(int, |
Mirko Bonadei | 2ab97f6 | 2019-07-18 13:44:12 +0200 | [diff] [blame] | 214 | simulated_mic_kind, |
| 215 | kParameterNotSpecifiedValue, |
| 216 | "Specify which microphone kind to use for microphone simulation"); |
| 217 | ABSL_FLAG(bool, performance_report, false, "Report the APM performance "); |
| 218 | ABSL_FLAG(std::string, |
| 219 | performance_report_output_file, |
| 220 | "", |
| 221 | "Generate a CSV file with the API call durations"); |
| 222 | ABSL_FLAG(bool, verbose, false, "Produce verbose output"); |
| 223 | ABSL_FLAG(bool, |
| 224 | quiet, |
| 225 | false, |
| 226 | "Avoid producing information about the progress."); |
| 227 | ABSL_FLAG(bool, |
| 228 | bitexactness_report, |
| 229 | false, |
| 230 | "Report bitexactness for aec dump result reproduction"); |
| 231 | ABSL_FLAG(bool, |
| 232 | discard_settings_in_aecdump, |
| 233 | false, |
| 234 | "Discard any config settings specified in the aec dump"); |
| 235 | ABSL_FLAG(bool, |
| 236 | store_intermediate_output, |
| 237 | false, |
| 238 | "Creates new output files after each init"); |
| 239 | ABSL_FLAG(std::string, |
| 240 | custom_call_order_file, |
| 241 | "", |
| 242 | "Custom process API call order file"); |
| 243 | ABSL_FLAG(std::string, |
| 244 | output_custom_call_order_file, |
| 245 | "", |
| 246 | "Generate custom process API call order file from AEC dump"); |
| 247 | ABSL_FLAG(bool, |
| 248 | print_aec_parameter_values, |
| 249 | false, |
| 250 | "Print parameter values used in AEC in JSON-format"); |
| 251 | ABSL_FLAG(std::string, |
| 252 | aec_settings, |
| 253 | "", |
| 254 | "File in JSON-format with custom AEC settings"); |
| 255 | ABSL_FLAG(bool, |
| 256 | dump_data, |
| 257 | false, |
| 258 | "Dump internal data during the call (requires build flag)"); |
| 259 | ABSL_FLAG(std::string, |
| 260 | dump_data_output_dir, |
| 261 | "", |
| 262 | "Internal data dump output directory"); |
| 263 | |
peah | 60a189f | 2016-05-24 20:54:40 -0700 | [diff] [blame] | 264 | namespace webrtc { |
| 265 | namespace test { |
Peter Kasting | 6955870 | 2016-01-12 16:26:35 -0800 | [diff] [blame] | 266 | namespace { |
| 267 | |
peah | 60a189f | 2016-05-24 20:54:40 -0700 | [diff] [blame] | 268 | const char kUsageDescription[] = |
| 269 | "Usage: audioproc_f [options] -i <input.wav>\n" |
| 270 | " or\n" |
| 271 | " audioproc_f [options] -dump_input <aec_dump>\n" |
| 272 | "\n\n" |
| 273 | "Command-line tool to simulate a call using the audio " |
| 274 | "processing module, either based on wav files or " |
oprypin | 6e09d87 | 2017-08-31 03:21:39 -0700 | [diff] [blame] | 275 | "protobuf debug dump recordings.\n"; |
peah | 60a189f | 2016-05-24 20:54:40 -0700 | [diff] [blame] | 276 | |
Alessio Bazzica | 6817038 | 2018-11-20 12:27:20 +0100 | [diff] [blame] | 277 | std::vector<std::string> GetAgc2AdaptiveLevelEstimatorNames() { |
| 278 | return {"RMS", "peak"}; |
| 279 | } |
peah | 60a189f | 2016-05-24 20:54:40 -0700 | [diff] [blame] | 280 | |
Alex Loiko | 890988c | 2017-08-31 10:25:48 +0200 | [diff] [blame] | 281 | void SetSettingIfSpecified(const std::string& value, |
Danil Chapovalov | db9f7ab | 2018-06-19 10:50:11 +0200 | [diff] [blame] | 282 | absl::optional<std::string>* parameter) { |
peah | 60a189f | 2016-05-24 20:54:40 -0700 | [diff] [blame] | 283 | if (value.compare("") != 0) { |
Oskar Sundbom | aa8b67d | 2017-11-17 14:34:48 +0100 | [diff] [blame] | 284 | *parameter = value; |
peah | 60a189f | 2016-05-24 20:54:40 -0700 | [diff] [blame] | 285 | } |
| 286 | } |
| 287 | |
Danil Chapovalov | db9f7ab | 2018-06-19 10:50:11 +0200 | [diff] [blame] | 288 | void SetSettingIfSpecified(int value, absl::optional<int>* parameter) { |
peah | 60a189f | 2016-05-24 20:54:40 -0700 | [diff] [blame] | 289 | if (value != kParameterNotSpecifiedValue) { |
Oskar Sundbom | aa8b67d | 2017-11-17 14:34:48 +0100 | [diff] [blame] | 290 | *parameter = value; |
peah | 60a189f | 2016-05-24 20:54:40 -0700 | [diff] [blame] | 291 | } |
| 292 | } |
| 293 | |
Per Åhgren | ef34960 | 2019-04-12 16:26:34 +0200 | [diff] [blame] | 294 | void SetSettingIfSpecified(float value, absl::optional<float>* parameter) { |
| 295 | constexpr float kFloatParameterNotSpecifiedValue = |
| 296 | kParameterNotSpecifiedValue; |
| 297 | if (value != kFloatParameterNotSpecifiedValue) { |
| 298 | *parameter = value; |
| 299 | } |
| 300 | } |
| 301 | |
Danil Chapovalov | db9f7ab | 2018-06-19 10:50:11 +0200 | [diff] [blame] | 302 | void SetSettingIfFlagSet(int32_t flag, absl::optional<bool>* parameter) { |
peah | 60a189f | 2016-05-24 20:54:40 -0700 | [diff] [blame] | 303 | if (flag == 0) { |
Oskar Sundbom | aa8b67d | 2017-11-17 14:34:48 +0100 | [diff] [blame] | 304 | *parameter = false; |
peah | 60a189f | 2016-05-24 20:54:40 -0700 | [diff] [blame] | 305 | } else if (flag == 1) { |
Oskar Sundbom | aa8b67d | 2017-11-17 14:34:48 +0100 | [diff] [blame] | 306 | *parameter = true; |
peah | 60a189f | 2016-05-24 20:54:40 -0700 | [diff] [blame] | 307 | } |
| 308 | } |
| 309 | |
Alessio Bazzica | 6817038 | 2018-11-20 12:27:20 +0100 | [diff] [blame] | 310 | AudioProcessing::Config::GainController2::LevelEstimator |
| 311 | MapAgc2AdaptiveLevelEstimator(absl::string_view name) { |
| 312 | if (name.compare("RMS") == 0) { |
| 313 | return AudioProcessing::Config::GainController2::LevelEstimator::kRms; |
| 314 | } |
| 315 | if (name.compare("peak") == 0) { |
| 316 | return AudioProcessing::Config::GainController2::LevelEstimator::kPeak; |
| 317 | } |
| 318 | auto concat_strings = |
| 319 | [](const std::vector<std::string>& strings) -> std::string { |
| 320 | rtc::StringBuilder ss; |
| 321 | for (const auto& s : strings) { |
| 322 | ss << " " << s; |
| 323 | } |
| 324 | return ss.Release(); |
| 325 | }; |
| 326 | RTC_CHECK(false) |
| 327 | << "Invalid value for agc2_adaptive_level_estimator, valid options:" |
| 328 | << concat_strings(GetAgc2AdaptiveLevelEstimatorNames()) << "."; |
| 329 | } |
| 330 | |
peah | 60a189f | 2016-05-24 20:54:40 -0700 | [diff] [blame] | 331 | SimulationSettings CreateSettings() { |
| 332 | SimulationSettings settings; |
Mirko Bonadei | 2ab97f6 | 2019-07-18 13:44:12 +0200 | [diff] [blame] | 333 | if (absl::GetFlag(FLAGS_all_default)) { |
Oskar Sundbom | aa8b67d | 2017-11-17 14:34:48 +0100 | [diff] [blame] | 334 | settings.use_le = true; |
| 335 | settings.use_vad = true; |
Oskar Sundbom | aa8b67d | 2017-11-17 14:34:48 +0100 | [diff] [blame] | 336 | settings.use_ts = true; |
| 337 | settings.use_ns = true; |
| 338 | settings.use_hpf = true; |
| 339 | settings.use_agc = true; |
| 340 | settings.use_agc2 = false; |
Alex Loiko | 5feb30e | 2018-04-16 13:52:32 +0200 | [diff] [blame] | 341 | settings.use_pre_amplifier = false; |
Oskar Sundbom | aa8b67d | 2017-11-17 14:34:48 +0100 | [diff] [blame] | 342 | settings.use_aec = true; |
| 343 | settings.use_aecm = false; |
| 344 | settings.use_ed = false; |
peah | 60a189f | 2016-05-24 20:54:40 -0700 | [diff] [blame] | 345 | } |
Mirko Bonadei | 2ab97f6 | 2019-07-18 13:44:12 +0200 | [diff] [blame] | 346 | SetSettingIfSpecified(absl::GetFlag(FLAGS_dump_input), |
| 347 | &settings.aec_dump_input_filename); |
| 348 | SetSettingIfSpecified(absl::GetFlag(FLAGS_dump_output), |
| 349 | &settings.aec_dump_output_filename); |
| 350 | SetSettingIfSpecified(absl::GetFlag(FLAGS_i), &settings.input_filename); |
| 351 | SetSettingIfSpecified(absl::GetFlag(FLAGS_o), &settings.output_filename); |
| 352 | SetSettingIfSpecified(absl::GetFlag(FLAGS_ri), |
| 353 | &settings.reverse_input_filename); |
| 354 | SetSettingIfSpecified(absl::GetFlag(FLAGS_ro), |
| 355 | &settings.reverse_output_filename); |
| 356 | SetSettingIfSpecified(absl::GetFlag(FLAGS_artificial_nearend), |
peah | df80fd1 | 2016-12-09 02:43:40 -0800 | [diff] [blame] | 357 | &settings.artificial_nearend_filename); |
Per Åhgren | c20a19c | 2019-11-13 11:12:29 +0100 | [diff] [blame] | 358 | SetSettingIfSpecified(absl::GetFlag(FLAGS_linear_aec_output), |
| 359 | &settings.linear_aec_output_filename); |
Mirko Bonadei | 2ab97f6 | 2019-07-18 13:44:12 +0200 | [diff] [blame] | 360 | SetSettingIfSpecified(absl::GetFlag(FLAGS_output_num_channels), |
peah | 60a189f | 2016-05-24 20:54:40 -0700 | [diff] [blame] | 361 | &settings.output_num_channels); |
Mirko Bonadei | 2ab97f6 | 2019-07-18 13:44:12 +0200 | [diff] [blame] | 362 | SetSettingIfSpecified(absl::GetFlag(FLAGS_reverse_output_num_channels), |
peah | 60a189f | 2016-05-24 20:54:40 -0700 | [diff] [blame] | 363 | &settings.reverse_output_num_channels); |
Mirko Bonadei | 2ab97f6 | 2019-07-18 13:44:12 +0200 | [diff] [blame] | 364 | SetSettingIfSpecified(absl::GetFlag(FLAGS_output_sample_rate_hz), |
peah | 60a189f | 2016-05-24 20:54:40 -0700 | [diff] [blame] | 365 | &settings.output_sample_rate_hz); |
Mirko Bonadei | 2ab97f6 | 2019-07-18 13:44:12 +0200 | [diff] [blame] | 366 | SetSettingIfSpecified(absl::GetFlag(FLAGS_reverse_output_sample_rate_hz), |
peah | 60a189f | 2016-05-24 20:54:40 -0700 | [diff] [blame] | 367 | &settings.reverse_output_sample_rate_hz); |
Mirko Bonadei | 2ab97f6 | 2019-07-18 13:44:12 +0200 | [diff] [blame] | 368 | SetSettingIfFlagSet(absl::GetFlag(FLAGS_aec), &settings.use_aec); |
| 369 | SetSettingIfFlagSet(absl::GetFlag(FLAGS_aecm), &settings.use_aecm); |
| 370 | SetSettingIfFlagSet(absl::GetFlag(FLAGS_ed), &settings.use_ed); |
| 371 | SetSettingIfSpecified(absl::GetFlag(FLAGS_ed_graph), |
| 372 | &settings.ed_graph_output_filename); |
| 373 | SetSettingIfFlagSet(absl::GetFlag(FLAGS_agc), &settings.use_agc); |
| 374 | SetSettingIfFlagSet(absl::GetFlag(FLAGS_agc2), &settings.use_agc2); |
| 375 | SetSettingIfFlagSet(absl::GetFlag(FLAGS_pre_amplifier), |
| 376 | &settings.use_pre_amplifier); |
| 377 | SetSettingIfFlagSet(absl::GetFlag(FLAGS_hpf), &settings.use_hpf); |
| 378 | SetSettingIfFlagSet(absl::GetFlag(FLAGS_ns), &settings.use_ns); |
| 379 | SetSettingIfFlagSet(absl::GetFlag(FLAGS_ts), &settings.use_ts); |
| 380 | SetSettingIfFlagSet(absl::GetFlag(FLAGS_vad), &settings.use_vad); |
| 381 | SetSettingIfFlagSet(absl::GetFlag(FLAGS_le), &settings.use_le); |
Per Åhgren | 0cbb58e | 2019-10-29 22:59:44 +0100 | [diff] [blame] | 382 | SetSettingIfFlagSet(absl::GetFlag(FLAGS_use_legacy_ns), |
| 383 | &settings.use_legacy_ns); |
Mirko Bonadei | 2ab97f6 | 2019-07-18 13:44:12 +0200 | [diff] [blame] | 384 | SetSettingIfFlagSet(absl::GetFlag(FLAGS_experimental_agc), |
| 385 | &settings.use_experimental_agc); |
| 386 | SetSettingIfFlagSet( |
| 387 | absl::GetFlag(FLAGS_experimental_agc_disable_digital_adaptive), |
| 388 | &settings.experimental_agc_disable_digital_adaptive); |
| 389 | SetSettingIfFlagSet(absl::GetFlag(FLAGS_experimental_agc_analyze_before_aec), |
Alex Loiko | d934244 | 2018-09-10 13:59:41 +0200 | [diff] [blame] | 390 | &settings.experimental_agc_analyze_before_aec); |
Mirko Bonadei | 2ab97f6 | 2019-07-18 13:44:12 +0200 | [diff] [blame] | 391 | SetSettingIfFlagSet( |
| 392 | absl::GetFlag(FLAGS_experimental_agc_agc2_level_estimator), |
| 393 | &settings.use_experimental_agc_agc2_level_estimator); |
| 394 | SetSettingIfSpecified(absl::GetFlag(FLAGS_agc_mode), &settings.agc_mode); |
| 395 | SetSettingIfSpecified(absl::GetFlag(FLAGS_agc_target_level), |
| 396 | &settings.agc_target_level); |
| 397 | SetSettingIfFlagSet(absl::GetFlag(FLAGS_agc_limiter), |
| 398 | &settings.use_agc_limiter); |
| 399 | SetSettingIfSpecified(absl::GetFlag(FLAGS_agc_compression_gain), |
peah | 60a189f | 2016-05-24 20:54:40 -0700 | [diff] [blame] | 400 | &settings.agc_compression_gain); |
Mirko Bonadei | 2ab97f6 | 2019-07-18 13:44:12 +0200 | [diff] [blame] | 401 | SetSettingIfFlagSet(absl::GetFlag(FLAGS_agc2_enable_adaptive_gain), |
Per Åhgren | e4d23b1 | 2018-10-02 23:40:07 +0200 | [diff] [blame] | 402 | &settings.agc2_use_adaptive_gain); |
Mirko Bonadei | 2ab97f6 | 2019-07-18 13:44:12 +0200 | [diff] [blame] | 403 | SetSettingIfSpecified(absl::GetFlag(FLAGS_agc2_fixed_gain_db), |
| 404 | &settings.agc2_fixed_gain_db); |
| 405 | settings.agc2_adaptive_level_estimator = MapAgc2AdaptiveLevelEstimator( |
| 406 | absl::GetFlag(FLAGS_agc2_adaptive_level_estimator)); |
| 407 | SetSettingIfSpecified(absl::GetFlag(FLAGS_pre_amplifier_gain_factor), |
Per Åhgren | ef34960 | 2019-04-12 16:26:34 +0200 | [diff] [blame] | 408 | &settings.pre_amplifier_gain_factor); |
Mirko Bonadei | 2ab97f6 | 2019-07-18 13:44:12 +0200 | [diff] [blame] | 409 | SetSettingIfSpecified(absl::GetFlag(FLAGS_ns_level), &settings.ns_level); |
Per Åhgren | 2e8e1c6 | 2019-12-20 00:42:22 +0100 | [diff] [blame^] | 410 | SetSettingIfFlagSet(absl::GetFlag(FLAGS_ns_analysis_on_linear_aec_output), |
| 411 | &settings.ns_analysis_on_linear_aec_output); |
Per Åhgren | fcbe407 | 2019-09-15 00:27:58 +0200 | [diff] [blame] | 412 | SetSettingIfSpecified(absl::GetFlag(FLAGS_maximum_internal_processing_rate), |
| 413 | &settings.maximum_internal_processing_rate); |
Mirko Bonadei | 2ab97f6 | 2019-07-18 13:44:12 +0200 | [diff] [blame] | 414 | SetSettingIfSpecified(absl::GetFlag(FLAGS_stream_delay), |
| 415 | &settings.stream_delay); |
| 416 | SetSettingIfFlagSet(absl::GetFlag(FLAGS_use_stream_delay), |
| 417 | &settings.use_stream_delay); |
Mirko Bonadei | 2ab97f6 | 2019-07-18 13:44:12 +0200 | [diff] [blame] | 418 | SetSettingIfSpecified(absl::GetFlag(FLAGS_custom_call_order_file), |
Ivo Creusen | 9a66d5e | 2019-03-13 13:55:12 +0100 | [diff] [blame] | 419 | &settings.call_order_input_filename); |
Mirko Bonadei | 2ab97f6 | 2019-07-18 13:44:12 +0200 | [diff] [blame] | 420 | SetSettingIfSpecified(absl::GetFlag(FLAGS_output_custom_call_order_file), |
Ivo Creusen | 9a66d5e | 2019-03-13 13:55:12 +0100 | [diff] [blame] | 421 | &settings.call_order_output_filename); |
Mirko Bonadei | 2ab97f6 | 2019-07-18 13:44:12 +0200 | [diff] [blame] | 422 | SetSettingIfSpecified(absl::GetFlag(FLAGS_aec_settings), |
| 423 | &settings.aec_settings_filename); |
| 424 | settings.initial_mic_level = absl::GetFlag(FLAGS_initial_mic_level); |
Per Åhgren | e14cb99 | 2019-11-27 09:34:22 +0100 | [diff] [blame] | 425 | SetSettingIfFlagSet(absl::GetFlag(FLAGS_multi_channel_render), |
| 426 | &settings.multi_channel_render); |
| 427 | SetSettingIfFlagSet(absl::GetFlag(FLAGS_multi_channel_capture), |
| 428 | &settings.multi_channel_capture); |
Mirko Bonadei | 2ab97f6 | 2019-07-18 13:44:12 +0200 | [diff] [blame] | 429 | settings.simulate_mic_gain = absl::GetFlag(FLAGS_simulate_mic_gain); |
| 430 | SetSettingIfSpecified(absl::GetFlag(FLAGS_simulated_mic_kind), |
| 431 | &settings.simulated_mic_kind); |
| 432 | settings.report_performance = absl::GetFlag(FLAGS_performance_report); |
| 433 | SetSettingIfSpecified(absl::GetFlag(FLAGS_performance_report_output_file), |
Per Åhgren | ada9b89 | 2019-04-03 16:06:42 +0200 | [diff] [blame] | 434 | &settings.performance_report_output_filename); |
Mirko Bonadei | 2ab97f6 | 2019-07-18 13:44:12 +0200 | [diff] [blame] | 435 | settings.use_verbose_logging = absl::GetFlag(FLAGS_verbose); |
| 436 | settings.use_quiet_output = absl::GetFlag(FLAGS_quiet); |
| 437 | settings.report_bitexactness = absl::GetFlag(FLAGS_bitexactness_report); |
| 438 | settings.discard_all_settings_in_aecdump = |
| 439 | absl::GetFlag(FLAGS_discard_settings_in_aecdump); |
| 440 | settings.fixed_interface = absl::GetFlag(FLAGS_fixed_interface); |
| 441 | settings.store_intermediate_output = |
| 442 | absl::GetFlag(FLAGS_store_intermediate_output); |
| 443 | settings.print_aec_parameter_values = |
| 444 | absl::GetFlag(FLAGS_print_aec_parameter_values); |
| 445 | settings.dump_internal_data = absl::GetFlag(FLAGS_dump_data); |
| 446 | SetSettingIfSpecified(absl::GetFlag(FLAGS_dump_data_output_dir), |
Alessio Bazzica | 4bc6045 | 2018-11-20 12:44:15 +0100 | [diff] [blame] | 447 | &settings.dump_internal_data_output_dir); |
peah | 60a189f | 2016-05-24 20:54:40 -0700 | [diff] [blame] | 448 | |
| 449 | return settings; |
| 450 | } |
| 451 | |
Alex Loiko | 890988c | 2017-08-31 10:25:48 +0200 | [diff] [blame] | 452 | void ReportConditionalErrorAndExit(bool condition, const std::string& message) { |
peah | 60a189f | 2016-05-24 20:54:40 -0700 | [diff] [blame] | 453 | if (condition) { |
| 454 | std::cerr << message << std::endl; |
| 455 | exit(1); |
| 456 | } |
| 457 | } |
| 458 | |
| 459 | void PerformBasicParameterSanityChecks(const SimulationSettings& settings) { |
| 460 | if (settings.input_filename || settings.reverse_input_filename) { |
Sonia-Florina Horchidan | b75d14c | 2019-08-12 09:57:01 +0200 | [diff] [blame] | 461 | ReportConditionalErrorAndExit( |
| 462 | !!settings.aec_dump_input_filename, |
| 463 | "Error: The aec dump file cannot be specified " |
| 464 | "together with input wav files!\n"); |
| 465 | |
| 466 | ReportConditionalErrorAndExit( |
| 467 | !!settings.aec_dump_input_string, |
| 468 | "Error: The aec dump input string cannot be specified " |
| 469 | "together with input wav files!\n"); |
peah | 60a189f | 2016-05-24 20:54:40 -0700 | [diff] [blame] | 470 | |
peah | df80fd1 | 2016-12-09 02:43:40 -0800 | [diff] [blame] | 471 | ReportConditionalErrorAndExit(!!settings.artificial_nearend_filename, |
| 472 | "Error: The artificial nearend cannot be " |
| 473 | "specified together with input wav files!\n"); |
| 474 | |
peah | 60a189f | 2016-05-24 20:54:40 -0700 | [diff] [blame] | 475 | ReportConditionalErrorAndExit(!settings.input_filename, |
| 476 | "Error: When operating at wav files, the " |
| 477 | "input wav filename must be " |
| 478 | "specified!\n"); |
| 479 | |
| 480 | ReportConditionalErrorAndExit( |
| 481 | settings.reverse_output_filename && !settings.reverse_input_filename, |
| 482 | "Error: When operating at wav files, the reverse input wav filename " |
| 483 | "must be specified if the reverse output wav filename is specified!\n"); |
| 484 | } else { |
Sonia-Florina Horchidan | b75d14c | 2019-08-12 09:57:01 +0200 | [diff] [blame] | 485 | ReportConditionalErrorAndExit( |
| 486 | !settings.aec_dump_input_filename && !settings.aec_dump_input_string, |
| 487 | "Error: Either the aec dump input file, the wav " |
| 488 | "input file or the aec dump input string must be specified!\n"); |
| 489 | ReportConditionalErrorAndExit( |
| 490 | settings.aec_dump_input_filename && settings.aec_dump_input_string, |
| 491 | "Error: The aec dump input file cannot be specified together with the " |
| 492 | "aec dump input string!\n"); |
peah | 60a189f | 2016-05-24 20:54:40 -0700 | [diff] [blame] | 493 | } |
| 494 | |
Per Åhgren | c20a19c | 2019-11-13 11:12:29 +0100 | [diff] [blame] | 495 | ReportConditionalErrorAndExit(settings.use_aec && !(*settings.use_aec) && |
| 496 | settings.linear_aec_output_filename, |
| 497 | "Error: The linear AEC ouput filename cannot " |
| 498 | "be specified without the AEC being active"); |
| 499 | |
| 500 | ReportConditionalErrorAndExit( |
peah | 60a189f | 2016-05-24 20:54:40 -0700 | [diff] [blame] | 501 | settings.use_aec && *settings.use_aec && settings.use_aecm && |
| 502 | *settings.use_aecm, |
| 503 | "Error: The AEC and the AECM cannot be activated at the same time!\n"); |
| 504 | |
| 505 | ReportConditionalErrorAndExit( |
| 506 | settings.output_sample_rate_hz && *settings.output_sample_rate_hz <= 0, |
| 507 | "Error: --output_sample_rate_hz must be positive!\n"); |
| 508 | |
| 509 | ReportConditionalErrorAndExit( |
| 510 | settings.reverse_output_sample_rate_hz && |
| 511 | settings.output_sample_rate_hz && |
| 512 | *settings.output_sample_rate_hz <= 0, |
| 513 | "Error: --reverse_output_sample_rate_hz must be positive!\n"); |
| 514 | |
| 515 | ReportConditionalErrorAndExit( |
| 516 | settings.output_num_channels && *settings.output_num_channels <= 0, |
| 517 | "Error: --output_num_channels must be positive!\n"); |
| 518 | |
| 519 | ReportConditionalErrorAndExit( |
| 520 | settings.reverse_output_num_channels && |
| 521 | *settings.reverse_output_num_channels <= 0, |
| 522 | "Error: --reverse_output_num_channels must be positive!\n"); |
| 523 | |
peah | 60a189f | 2016-05-24 20:54:40 -0700 | [diff] [blame] | 524 | ReportConditionalErrorAndExit( |
peah | 60a189f | 2016-05-24 20:54:40 -0700 | [diff] [blame] | 525 | settings.agc_target_level && ((*settings.agc_target_level) < 0 || |
| 526 | (*settings.agc_target_level) > 31), |
| 527 | "Error: --agc_target_level must be specified between 0 and 31.\n"); |
| 528 | |
| 529 | ReportConditionalErrorAndExit( |
| 530 | settings.agc_compression_gain && ((*settings.agc_compression_gain) < 0 || |
| 531 | (*settings.agc_compression_gain) > 90), |
| 532 | "Error: --agc_compression_gain must be specified between 0 and 90.\n"); |
| 533 | |
| 534 | ReportConditionalErrorAndExit( |
Per Åhgren | 6ee75fd | 2019-04-26 11:33:37 +0200 | [diff] [blame] | 535 | settings.agc2_fixed_gain_db && ((*settings.agc2_fixed_gain_db) < 0 || |
| 536 | (*settings.agc2_fixed_gain_db) > 90), |
Alessio Bazzica | 270f7b5 | 2017-10-13 11:05:17 +0200 | [diff] [blame] | 537 | "Error: --agc2_fixed_gain_db must be specified between 0 and 90.\n"); |
| 538 | |
| 539 | ReportConditionalErrorAndExit( |
peah | 60a189f | 2016-05-24 20:54:40 -0700 | [diff] [blame] | 540 | settings.ns_level && |
| 541 | ((*settings.ns_level) < 0 || (*settings.ns_level) > 3), |
| 542 | "Error: --ns_level must be specified between 0 and 3.\n"); |
| 543 | |
| 544 | ReportConditionalErrorAndExit( |
| 545 | settings.report_bitexactness && !settings.aec_dump_input_filename, |
| 546 | "Error: --bitexactness_report can only be used when operating on an " |
| 547 | "aecdump\n"); |
| 548 | |
peah | 5ad5de3 | 2016-12-09 03:18:22 -0800 | [diff] [blame] | 549 | ReportConditionalErrorAndExit( |
Ivo Creusen | 9a66d5e | 2019-03-13 13:55:12 +0100 | [diff] [blame] | 550 | settings.call_order_input_filename && settings.aec_dump_input_filename, |
peah | 5ad5de3 | 2016-12-09 03:18:22 -0800 | [diff] [blame] | 551 | "Error: --custom_call_order_file cannot be used when operating on an " |
| 552 | "aecdump\n"); |
| 553 | |
Alessio Bazzica | ca90a55 | 2017-09-27 11:51:10 +0200 | [diff] [blame] | 554 | ReportConditionalErrorAndExit( |
| 555 | (settings.initial_mic_level < 0 || settings.initial_mic_level > 255), |
| 556 | "Error: --initial_mic_level must be specified between 0 and 255.\n"); |
| 557 | |
| 558 | ReportConditionalErrorAndExit( |
| 559 | settings.simulated_mic_kind && !settings.simulate_mic_gain, |
| 560 | "Error: --simulated_mic_kind cannot be specified when mic simulation is " |
| 561 | "disabled\n"); |
| 562 | |
| 563 | ReportConditionalErrorAndExit( |
| 564 | !settings.simulated_mic_kind && settings.simulate_mic_gain, |
| 565 | "Error: --simulated_mic_kind must be specified when mic simulation is " |
| 566 | "enabled\n"); |
| 567 | |
peah | 60a189f | 2016-05-24 20:54:40 -0700 | [diff] [blame] | 568 | auto valid_wav_name = [](const std::string& wav_file_name) { |
| 569 | if (wav_file_name.size() < 5) { |
| 570 | return false; |
| 571 | } |
| 572 | if ((wav_file_name.compare(wav_file_name.size() - 4, 4, ".wav") == 0) || |
| 573 | (wav_file_name.compare(wav_file_name.size() - 4, 4, ".WAV") == 0)) { |
| 574 | return true; |
| 575 | } |
| 576 | return false; |
| 577 | }; |
| 578 | |
| 579 | ReportConditionalErrorAndExit( |
| 580 | settings.input_filename && (!valid_wav_name(*settings.input_filename)), |
| 581 | "Error: --i must be a valid .wav file name.\n"); |
| 582 | |
| 583 | ReportConditionalErrorAndExit( |
| 584 | settings.output_filename && (!valid_wav_name(*settings.output_filename)), |
| 585 | "Error: --o must be a valid .wav file name.\n"); |
| 586 | |
| 587 | ReportConditionalErrorAndExit( |
| 588 | settings.reverse_input_filename && |
| 589 | (!valid_wav_name(*settings.reverse_input_filename)), |
| 590 | "Error: --ri must be a valid .wav file name.\n"); |
| 591 | |
| 592 | ReportConditionalErrorAndExit( |
| 593 | settings.reverse_output_filename && |
| 594 | (!valid_wav_name(*settings.reverse_output_filename)), |
| 595 | "Error: --ro must be a valid .wav file name.\n"); |
peah | df80fd1 | 2016-12-09 02:43:40 -0800 | [diff] [blame] | 596 | |
| 597 | ReportConditionalErrorAndExit( |
| 598 | settings.artificial_nearend_filename && |
| 599 | !valid_wav_name(*settings.artificial_nearend_filename), |
| 600 | "Error: --artifical_nearend must be a valid .wav file name.\n"); |
Per Åhgren | 7a95e0f | 2018-10-25 09:56:49 +0200 | [diff] [blame] | 601 | |
| 602 | ReportConditionalErrorAndExit( |
Per Åhgren | c20a19c | 2019-11-13 11:12:29 +0100 | [diff] [blame] | 603 | settings.linear_aec_output_filename && |
| 604 | (!valid_wav_name(*settings.linear_aec_output_filename)), |
| 605 | "Error: --linear_aec_output must be a valid .wav file name.\n"); |
| 606 | |
| 607 | ReportConditionalErrorAndExit( |
Per Åhgren | 7a95e0f | 2018-10-25 09:56:49 +0200 | [diff] [blame] | 608 | WEBRTC_APM_DEBUG_DUMP == 0 && settings.dump_internal_data, |
| 609 | "Error: --dump_data cannot be set without proper build support.\n"); |
Alessio Bazzica | 4bc6045 | 2018-11-20 12:44:15 +0100 | [diff] [blame] | 610 | |
| 611 | ReportConditionalErrorAndExit( |
| 612 | !settings.dump_internal_data && |
| 613 | settings.dump_internal_data_output_dir.has_value(), |
| 614 | "Error: --dump_data_output_dir cannot be set without --dump_data.\n"); |
Ivo Creusen | 9a66d5e | 2019-03-13 13:55:12 +0100 | [diff] [blame] | 615 | |
| 616 | ReportConditionalErrorAndExit( |
| 617 | !settings.aec_dump_input_filename && |
| 618 | settings.call_order_output_filename.has_value(), |
| 619 | "Error: --output_custom_call_order_file needs an AEC dump input file.\n"); |
Per Åhgren | ef34960 | 2019-04-12 16:26:34 +0200 | [diff] [blame] | 620 | |
| 621 | ReportConditionalErrorAndExit( |
| 622 | (!settings.use_pre_amplifier || !(*settings.use_pre_amplifier)) && |
| 623 | settings.pre_amplifier_gain_factor.has_value(), |
| 624 | "Error: --pre_amplifier_gain_factor needs --pre_amplifier to be " |
| 625 | "specified and set.\n"); |
Peter Kasting | 6955870 | 2016-01-12 16:26:35 -0800 | [diff] [blame] | 626 | } |
| 627 | |
| 628 | } // namespace |
| 629 | |
Ivo Creusen | 2cb4105 | 2018-03-15 12:22:52 +0100 | [diff] [blame] | 630 | int AudioprocFloatImpl(std::unique_ptr<AudioProcessingBuilder> ap_builder, |
| 631 | int argc, |
Sonia-Florina Horchidan | b75d14c | 2019-08-12 09:57:01 +0200 | [diff] [blame] | 632 | char* argv[], |
| 633 | absl::string_view input_aecdump, |
| 634 | std::vector<float>* processed_capture_samples) { |
Mirko Bonadei | 2ab97f6 | 2019-07-18 13:44:12 +0200 | [diff] [blame] | 635 | std::vector<char*> args = absl::ParseCommandLine(argc, argv); |
| 636 | if (args.size() != 1) { |
oprypin | 6e09d87 | 2017-08-31 03:21:39 -0700 | [diff] [blame] | 637 | printf("%s", kUsageDescription); |
oprypin | 6e09d87 | 2017-08-31 03:21:39 -0700 | [diff] [blame] | 638 | return 1; |
| 639 | } |
andrew@webrtc.org | 08df9b2 | 2014-12-16 20:57:15 +0000 | [diff] [blame] | 640 | |
peah | 60a189f | 2016-05-24 20:54:40 -0700 | [diff] [blame] | 641 | SimulationSettings settings = CreateSettings(); |
Sonia-Florina Horchidan | b75d14c | 2019-08-12 09:57:01 +0200 | [diff] [blame] | 642 | if (!input_aecdump.empty()) { |
| 643 | settings.aec_dump_input_string = input_aecdump; |
| 644 | settings.processed_capture_samples = processed_capture_samples; |
| 645 | RTC_CHECK(settings.processed_capture_samples); |
| 646 | } |
peah | 60a189f | 2016-05-24 20:54:40 -0700 | [diff] [blame] | 647 | PerformBasicParameterSanityChecks(settings); |
| 648 | std::unique_ptr<AudioProcessingSimulator> processor; |
andrew@webrtc.org | 08df9b2 | 2014-12-16 20:57:15 +0000 | [diff] [blame] | 649 | |
Sonia-Florina Horchidan | b75d14c | 2019-08-12 09:57:01 +0200 | [diff] [blame] | 650 | if (settings.aec_dump_input_filename || settings.aec_dump_input_string) { |
Ivo Creusen | 8c812f3 | 2018-03-09 17:33:04 +0100 | [diff] [blame] | 651 | processor.reset(new AecDumpBasedSimulator(settings, std::move(ap_builder))); |
aluebs | b0ad43b | 2015-11-20 00:11:53 -0800 | [diff] [blame] | 652 | } else { |
Ivo Creusen | 8c812f3 | 2018-03-09 17:33:04 +0100 | [diff] [blame] | 653 | processor.reset(new WavBasedSimulator(settings, std::move(ap_builder))); |
andrew | bdafe31 | 2015-10-29 23:42:54 -0700 | [diff] [blame] | 654 | } |
| 655 | |
peah | 60a189f | 2016-05-24 20:54:40 -0700 | [diff] [blame] | 656 | processor->Process(); |
aluebs | b0ad43b | 2015-11-20 00:11:53 -0800 | [diff] [blame] | 657 | |
peah | 60a189f | 2016-05-24 20:54:40 -0700 | [diff] [blame] | 658 | if (settings.report_performance) { |
Per Åhgren | ada9b89 | 2019-04-03 16:06:42 +0200 | [diff] [blame] | 659 | processor->GetApiCallStatistics().PrintReport(); |
| 660 | } |
| 661 | if (settings.performance_report_output_filename) { |
| 662 | processor->GetApiCallStatistics().WriteReportToFile( |
| 663 | *settings.performance_report_output_filename); |
peah | 60a189f | 2016-05-24 20:54:40 -0700 | [diff] [blame] | 664 | } |
| 665 | |
| 666 | if (settings.report_bitexactness && settings.aec_dump_input_filename) { |
| 667 | if (processor->OutputWasBitexact()) { |
| 668 | std::cout << "The processing was bitexact."; |
| 669 | } else { |
| 670 | std::cout << "The processing was not bitexact."; |
| 671 | } |
Alejandro Luebs | 5d22c00 | 2015-04-15 11:26:40 -0700 | [diff] [blame] | 672 | } |
aluebs | b0ad43b | 2015-11-20 00:11:53 -0800 | [diff] [blame] | 673 | |
andrew@webrtc.org | 08df9b2 | 2014-12-16 20:57:15 +0000 | [diff] [blame] | 674 | return 0; |
| 675 | } |
| 676 | |
peah | 60a189f | 2016-05-24 20:54:40 -0700 | [diff] [blame] | 677 | } // namespace test |
andrew@webrtc.org | 08df9b2 | 2014-12-16 20:57:15 +0000 | [diff] [blame] | 678 | } // namespace webrtc |