OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 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 |
11 #include <math.h> | 11 #include <math.h> |
12 #include <stdio.h> | 12 #include <stdio.h> |
13 #include <string.h> | 13 #include <string.h> |
14 #ifdef WEBRTC_ANDROID | 14 #ifdef WEBRTC_ANDROID |
15 #include <sys/stat.h> | 15 #include <sys/stat.h> |
16 #endif | 16 #endif |
17 | 17 |
18 #include <algorithm> | 18 #include <algorithm> |
| 19 #include <memory> |
19 | 20 |
20 #include "webrtc/base/format_macros.h" | 21 #include "webrtc/base/format_macros.h" |
21 #include "webrtc/base/scoped_ptr.h" | |
22 #include "webrtc/common.h" | 22 #include "webrtc/common.h" |
23 #include "webrtc/modules/audio_processing/include/audio_processing.h" | 23 #include "webrtc/modules/audio_processing/include/audio_processing.h" |
24 #include "webrtc/modules/audio_processing/test/protobuf_utils.h" | 24 #include "webrtc/modules/audio_processing/test/protobuf_utils.h" |
25 #include "webrtc/modules/audio_processing/test/test_utils.h" | 25 #include "webrtc/modules/audio_processing/test/test_utils.h" |
26 #include "webrtc/modules/include/module_common_types.h" | 26 #include "webrtc/modules/include/module_common_types.h" |
27 #include "webrtc/system_wrappers/include/cpu_features_wrapper.h" | 27 #include "webrtc/system_wrappers/include/cpu_features_wrapper.h" |
28 #include "webrtc/system_wrappers/include/tick_util.h" | 28 #include "webrtc/system_wrappers/include/tick_util.h" |
29 #include "webrtc/test/testsupport/fileutils.h" | 29 #include "webrtc/test/testsupport/fileutils.h" |
30 #include "webrtc/test/testsupport/perf_test.h" | 30 #include "webrtc/test/testsupport/perf_test.h" |
31 #ifdef WEBRTC_ANDROID_PLATFORM_BUILD | 31 #ifdef WEBRTC_ANDROID_PLATFORM_BUILD |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 if (argc > 1 && strcmp(argv[1], "--help") == 0) { | 139 if (argc > 1 && strcmp(argv[1], "--help") == 0) { |
140 usage(); | 140 usage(); |
141 return; | 141 return; |
142 } | 142 } |
143 | 143 |
144 if (argc < 2) { | 144 if (argc < 2) { |
145 printf("Did you mean to run without arguments?\n"); | 145 printf("Did you mean to run without arguments?\n"); |
146 printf("Try `process_test --help' for more information.\n\n"); | 146 printf("Try `process_test --help' for more information.\n\n"); |
147 } | 147 } |
148 | 148 |
149 rtc::scoped_ptr<AudioProcessing> apm(AudioProcessing::Create()); | 149 std::unique_ptr<AudioProcessing> apm(AudioProcessing::Create()); |
150 ASSERT_TRUE(apm.get() != NULL); | 150 ASSERT_TRUE(apm.get() != NULL); |
151 | 151 |
152 const char* pb_filename = NULL; | 152 const char* pb_filename = NULL; |
153 const char* far_filename = NULL; | 153 const char* far_filename = NULL; |
154 const char* near_filename = NULL; | 154 const char* near_filename = NULL; |
155 std::string out_filename; | 155 std::string out_filename; |
156 const char* vad_out_filename = NULL; | 156 const char* vad_out_filename = NULL; |
157 const char* ns_prob_filename = NULL; | 157 const char* ns_prob_filename = NULL; |
158 const char* aecm_echo_path_in_filename = NULL; | 158 const char* aecm_echo_path_in_filename = NULL; |
159 const char* aecm_echo_path_out_filename = NULL; | 159 const char* aecm_echo_path_out_filename = NULL; |
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
484 FILE* far_file = NULL; | 484 FILE* far_file = NULL; |
485 FILE* near_file = NULL; | 485 FILE* near_file = NULL; |
486 FILE* event_file = NULL; | 486 FILE* event_file = NULL; |
487 FILE* delay_file = NULL; | 487 FILE* delay_file = NULL; |
488 FILE* drift_file = NULL; | 488 FILE* drift_file = NULL; |
489 FILE* vad_out_file = NULL; | 489 FILE* vad_out_file = NULL; |
490 FILE* ns_prob_file = NULL; | 490 FILE* ns_prob_file = NULL; |
491 FILE* aecm_echo_path_in_file = NULL; | 491 FILE* aecm_echo_path_in_file = NULL; |
492 FILE* aecm_echo_path_out_file = NULL; | 492 FILE* aecm_echo_path_out_file = NULL; |
493 | 493 |
494 rtc::scoped_ptr<WavWriter> output_wav_file; | 494 std::unique_ptr<WavWriter> output_wav_file; |
495 rtc::scoped_ptr<RawFile> output_raw_file; | 495 std::unique_ptr<RawFile> output_raw_file; |
496 | 496 |
497 if (pb_filename) { | 497 if (pb_filename) { |
498 pb_file = OpenFile(pb_filename, "rb"); | 498 pb_file = OpenFile(pb_filename, "rb"); |
499 } else { | 499 } else { |
500 if (far_filename) { | 500 if (far_filename) { |
501 far_file = OpenFile(far_filename, "rb"); | 501 far_file = OpenFile(far_filename, "rb"); |
502 } | 502 } |
503 | 503 |
504 near_file = OpenFile(near_filename, "rb"); | 504 near_file = OpenFile(near_filename, "rb"); |
505 if (!simulating) { | 505 if (!simulating) { |
(...skipping 21 matching lines...) Expand all Loading... |
527 | 527 |
528 if (apm->noise_suppression()->is_enabled()) { | 528 if (apm->noise_suppression()->is_enabled()) { |
529 ns_prob_file = OpenFile(ns_prob_filename, "wb"); | 529 ns_prob_file = OpenFile(ns_prob_filename, "wb"); |
530 } | 530 } |
531 | 531 |
532 if (aecm_echo_path_in_filename != NULL) { | 532 if (aecm_echo_path_in_filename != NULL) { |
533 aecm_echo_path_in_file = OpenFile(aecm_echo_path_in_filename, "rb"); | 533 aecm_echo_path_in_file = OpenFile(aecm_echo_path_in_filename, "rb"); |
534 | 534 |
535 const size_t path_size = | 535 const size_t path_size = |
536 apm->echo_control_mobile()->echo_path_size_bytes(); | 536 apm->echo_control_mobile()->echo_path_size_bytes(); |
537 rtc::scoped_ptr<char[]> echo_path(new char[path_size]); | 537 std::unique_ptr<char[]> echo_path(new char[path_size]); |
538 ASSERT_EQ(path_size, fread(echo_path.get(), | 538 ASSERT_EQ(path_size, fread(echo_path.get(), |
539 sizeof(char), | 539 sizeof(char), |
540 path_size, | 540 path_size, |
541 aecm_echo_path_in_file)); | 541 aecm_echo_path_in_file)); |
542 EXPECT_EQ(apm->kNoError, | 542 EXPECT_EQ(apm->kNoError, |
543 apm->echo_control_mobile()->SetEchoPath(echo_path.get(), | 543 apm->echo_control_mobile()->SetEchoPath(echo_path.get(), |
544 path_size)); | 544 path_size)); |
545 fclose(aecm_echo_path_in_file); | 545 fclose(aecm_echo_path_in_file); |
546 aecm_echo_path_in_file = NULL; | 546 aecm_echo_path_in_file = NULL; |
547 } | 547 } |
(...skipping 21 matching lines...) Expand all Loading... |
569 TickTime t1 = t0; | 569 TickTime t1 = t0; |
570 int64_t max_time_us = 0; | 570 int64_t max_time_us = 0; |
571 int64_t max_time_reverse_us = 0; | 571 int64_t max_time_reverse_us = 0; |
572 int64_t min_time_us = 1e6; | 572 int64_t min_time_us = 1e6; |
573 int64_t min_time_reverse_us = 1e6; | 573 int64_t min_time_reverse_us = 1e6; |
574 | 574 |
575 // TODO(ajm): Ideally we would refactor this block into separate functions, | 575 // TODO(ajm): Ideally we would refactor this block into separate functions, |
576 // but for now we want to share the variables. | 576 // but for now we want to share the variables. |
577 if (pb_file) { | 577 if (pb_file) { |
578 Event event_msg; | 578 Event event_msg; |
579 rtc::scoped_ptr<ChannelBuffer<float> > reverse_cb; | 579 std::unique_ptr<ChannelBuffer<float> > reverse_cb; |
580 rtc::scoped_ptr<ChannelBuffer<float> > primary_cb; | 580 std::unique_ptr<ChannelBuffer<float> > primary_cb; |
581 int output_sample_rate = 32000; | 581 int output_sample_rate = 32000; |
582 AudioProcessing::ChannelLayout output_layout = AudioProcessing::kMono; | 582 AudioProcessing::ChannelLayout output_layout = AudioProcessing::kMono; |
583 while (ReadMessageFromFile(pb_file, &event_msg)) { | 583 while (ReadMessageFromFile(pb_file, &event_msg)) { |
584 std::ostringstream trace_stream; | 584 std::ostringstream trace_stream; |
585 trace_stream << "Processed frames: " << reverse_count << " (reverse), " | 585 trace_stream << "Processed frames: " << reverse_count << " (reverse), " |
586 << primary_count << " (primary)"; | 586 << primary_count << " (primary)"; |
587 SCOPED_TRACE(trace_stream.str()); | 587 SCOPED_TRACE(trace_stream.str()); |
588 | 588 |
589 if (event_msg.type() == Event::INIT) { | 589 if (event_msg.type() == Event::INIT) { |
590 ASSERT_TRUE(event_msg.has_init()); | 590 ASSERT_TRUE(event_msg.has_init()); |
(...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1054 } | 1054 } |
1055 } | 1055 } |
1056 } | 1056 } |
1057 if (progress) { | 1057 if (progress) { |
1058 printf("100%% complete\r"); | 1058 printf("100%% complete\r"); |
1059 } | 1059 } |
1060 | 1060 |
1061 if (aecm_echo_path_out_file != NULL) { | 1061 if (aecm_echo_path_out_file != NULL) { |
1062 const size_t path_size = | 1062 const size_t path_size = |
1063 apm->echo_control_mobile()->echo_path_size_bytes(); | 1063 apm->echo_control_mobile()->echo_path_size_bytes(); |
1064 rtc::scoped_ptr<char[]> echo_path(new char[path_size]); | 1064 std::unique_ptr<char[]> echo_path(new char[path_size]); |
1065 apm->echo_control_mobile()->GetEchoPath(echo_path.get(), path_size); | 1065 apm->echo_control_mobile()->GetEchoPath(echo_path.get(), path_size); |
1066 ASSERT_EQ(path_size, fwrite(echo_path.get(), | 1066 ASSERT_EQ(path_size, fwrite(echo_path.get(), |
1067 sizeof(char), | 1067 sizeof(char), |
1068 path_size, | 1068 path_size, |
1069 aecm_echo_path_out_file)); | 1069 aecm_echo_path_out_file)); |
1070 fclose(aecm_echo_path_out_file); | 1070 fclose(aecm_echo_path_out_file); |
1071 aecm_echo_path_out_file = NULL; | 1071 aecm_echo_path_out_file = NULL; |
1072 } | 1072 } |
1073 | 1073 |
1074 if (verbose) { | 1074 if (verbose) { |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1146 } // namespace | 1146 } // namespace |
1147 } // namespace webrtc | 1147 } // namespace webrtc |
1148 | 1148 |
1149 int main(int argc, char* argv[]) { | 1149 int main(int argc, char* argv[]) { |
1150 webrtc::void_main(argc, argv); | 1150 webrtc::void_main(argc, argv); |
1151 | 1151 |
1152 // Optional, but removes memory leak noise from Valgrind. | 1152 // Optional, but removes memory leak noise from Valgrind. |
1153 google::protobuf::ShutdownProtobufLibrary(); | 1153 google::protobuf::ShutdownProtobufLibrary(); |
1154 return 0; | 1154 return 0; |
1155 } | 1155 } |
OLD | NEW |