OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2013 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 "webrtc/modules/audio_processing/transient/wpd_tree.h" | 11 #include "webrtc/modules/audio_processing/transient/wpd_tree.h" |
12 | 12 |
| 13 #include <memory> |
13 #include <sstream> | 14 #include <sstream> |
14 #include <string> | 15 #include <string> |
15 | 16 |
16 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
17 #include "webrtc/base/scoped_ptr.h" | |
18 #include "webrtc/modules/audio_processing/transient/daubechies_8_wavelet_coeffs.
h" | 18 #include "webrtc/modules/audio_processing/transient/daubechies_8_wavelet_coeffs.
h" |
19 #include "webrtc/modules/audio_processing/transient/file_utils.h" | 19 #include "webrtc/modules/audio_processing/transient/file_utils.h" |
20 #include "webrtc/system_wrappers/include/file_wrapper.h" | 20 #include "webrtc/system_wrappers/include/file_wrapper.h" |
21 #include "webrtc/test/testsupport/fileutils.h" | 21 #include "webrtc/test/testsupport/fileutils.h" |
22 | 22 |
23 namespace webrtc { | 23 namespace webrtc { |
24 | 24 |
25 TEST(WPDTreeTest, Construction) { | 25 TEST(WPDTreeTest, Construction) { |
26 const size_t kTestBufferSize = 100; | 26 const size_t kTestBufferSize = 100; |
27 const int kLevels = 5; | 27 const int kLevels = 5; |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 const int kLevels = 3; | 78 const int kLevels = 3; |
79 const int kLeaves = 1 << kLevels; | 79 const int kLeaves = 1 << kLevels; |
80 const size_t kLeavesSamples = kTestBufferSize >> kLevels; | 80 const size_t kLeavesSamples = kTestBufferSize >> kLevels; |
81 // Create tree with Discrete Meyer Wavelet Coefficients. | 81 // Create tree with Discrete Meyer Wavelet Coefficients. |
82 WPDTree tree(kTestBufferSize, | 82 WPDTree tree(kTestBufferSize, |
83 kDaubechies8HighPassCoefficients, | 83 kDaubechies8HighPassCoefficients, |
84 kDaubechies8LowPassCoefficients, | 84 kDaubechies8LowPassCoefficients, |
85 kDaubechies8CoefficientsLength, | 85 kDaubechies8CoefficientsLength, |
86 kLevels); | 86 kLevels); |
87 // Allocate and open all matlab and out files. | 87 // Allocate and open all matlab and out files. |
88 rtc::scoped_ptr<FileWrapper> matlab_files_data[kLeaves]; | 88 std::unique_ptr<FileWrapper> matlab_files_data[kLeaves]; |
89 rtc::scoped_ptr<FileWrapper> out_files_data[kLeaves]; | 89 std::unique_ptr<FileWrapper> out_files_data[kLeaves]; |
90 | 90 |
91 for (int i = 0; i < kLeaves; ++i) { | 91 for (int i = 0; i < kLeaves; ++i) { |
92 // Matlab files. | 92 // Matlab files. |
93 matlab_files_data[i].reset(FileWrapper::Create()); | 93 matlab_files_data[i].reset(FileWrapper::Create()); |
94 | 94 |
95 std::ostringstream matlab_stream; | 95 std::ostringstream matlab_stream; |
96 matlab_stream << "audio_processing/transient/wpd" << i; | 96 matlab_stream << "audio_processing/transient/wpd" << i; |
97 std::string matlab_string = test::ResourcePath(matlab_stream.str(), "dat"); | 97 std::string matlab_string = test::ResourcePath(matlab_stream.str(), "dat"); |
98 matlab_files_data[i]->OpenFile(matlab_string.c_str(), | 98 matlab_files_data[i]->OpenFile(matlab_string.c_str(), |
99 true, // Read only. | 99 true, // Read only. |
(...skipping 16 matching lines...) Expand all Loading... |
116 false); // No text. | 116 false); // No text. |
117 | 117 |
118 file_opened = out_files_data[i]->Open(); | 118 file_opened = out_files_data[i]->Open(); |
119 ASSERT_TRUE(file_opened) << "File could not be opened.\n" << out_string; | 119 ASSERT_TRUE(file_opened) << "File could not be opened.\n" << out_string; |
120 } | 120 } |
121 | 121 |
122 // Prepare the test file. | 122 // Prepare the test file. |
123 std::string test_file_name = test::ResourcePath( | 123 std::string test_file_name = test::ResourcePath( |
124 "audio_processing/transient/ajm-macbook-1-spke16m", "pcm"); | 124 "audio_processing/transient/ajm-macbook-1-spke16m", "pcm"); |
125 | 125 |
126 rtc::scoped_ptr<FileWrapper> test_file(FileWrapper::Create()); | 126 std::unique_ptr<FileWrapper> test_file(FileWrapper::Create()); |
127 | 127 |
128 test_file->OpenFile(test_file_name.c_str(), | 128 test_file->OpenFile(test_file_name.c_str(), |
129 true, // Read only. | 129 true, // Read only. |
130 false, // No loop. | 130 false, // No loop. |
131 false); // No text. | 131 false); // No text. |
132 | 132 |
133 bool file_opened = test_file->Open(); | 133 bool file_opened = test_file->Open(); |
134 ASSERT_TRUE(file_opened) << "File could not be opened.\n" << test_file_name; | 134 ASSERT_TRUE(file_opened) << "File could not be opened.\n" << test_file_name; |
135 | 135 |
136 float test_buffer[kTestBufferSize]; | 136 float test_buffer[kTestBufferSize]; |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 // Close all matlab and out files. | 193 // Close all matlab and out files. |
194 for (int i = 0; i < kLeaves; ++i) { | 194 for (int i = 0; i < kLeaves; ++i) { |
195 matlab_files_data[i]->CloseFile(); | 195 matlab_files_data[i]->CloseFile(); |
196 out_files_data[i]->CloseFile(); | 196 out_files_data[i]->CloseFile(); |
197 } | 197 } |
198 | 198 |
199 test_file->CloseFile(); | 199 test_file->CloseFile(); |
200 } | 200 } |
201 | 201 |
202 } // namespace webrtc | 202 } // namespace webrtc |
OLD | NEW |