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