Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(260)

Side by Side Diff: webrtc/modules/audio_processing/audio_processing_unittest.cc

Issue 2786363002: Revert of Loosening the coupling between WebRTC and //third_party/protobuf (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 13
14 #include <algorithm> 14 #include <algorithm>
15 #include <limits> 15 #include <limits>
16 #include <memory> 16 #include <memory>
17 #include <queue> 17 #include <queue>
18 18
19 #include "webrtc/base/arraysize.h" 19 #include "webrtc/base/arraysize.h"
20 #include "webrtc/base/checks.h" 20 #include "webrtc/base/checks.h"
21 #include "webrtc/base/gtest_prod_util.h" 21 #include "webrtc/base/gtest_prod_util.h"
22 #include "webrtc/base/ignore_wundef.h" 22 #include "webrtc/base/ignore_wundef.h"
23 #include "webrtc/base/protobuf_utils.h"
24 #include "webrtc/common_audio/include/audio_util.h" 23 #include "webrtc/common_audio/include/audio_util.h"
25 #include "webrtc/common_audio/resampler/include/push_resampler.h" 24 #include "webrtc/common_audio/resampler/include/push_resampler.h"
26 #include "webrtc/common_audio/resampler/push_sinc_resampler.h" 25 #include "webrtc/common_audio/resampler/push_sinc_resampler.h"
27 #include "webrtc/common_audio/signal_processing/include/signal_processing_librar y.h" 26 #include "webrtc/common_audio/signal_processing/include/signal_processing_librar y.h"
28 #include "webrtc/modules/audio_processing/audio_processing_impl.h" 27 #include "webrtc/modules/audio_processing/audio_processing_impl.h"
29 #include "webrtc/modules/audio_processing/beamformer/mock_nonlinear_beamformer.h " 28 #include "webrtc/modules/audio_processing/beamformer/mock_nonlinear_beamformer.h "
30 #include "webrtc/modules/audio_processing/common.h" 29 #include "webrtc/modules/audio_processing/common.h"
31 #include "webrtc/modules/audio_processing/include/audio_processing.h" 30 #include "webrtc/modules/audio_processing/include/audio_processing.h"
32 #include "webrtc/modules/audio_processing/level_controller/level_controller_cons tants.h" 31 #include "webrtc/modules/audio_processing/level_controller/level_controller_cons tants.h"
33 #include "webrtc/modules/audio_processing/test/protobuf_utils.h" 32 #include "webrtc/modules/audio_processing/test/protobuf_utils.h"
(...skipping 18 matching lines...) Expand all
52 // TODO(ekmeyerson): Switch to using StreamConfig and ProcessingConfig where 51 // TODO(ekmeyerson): Switch to using StreamConfig and ProcessingConfig where
53 // applicable. 52 // applicable.
54 53
55 // TODO(bjornv): This is not feasible until the functionality has been 54 // TODO(bjornv): This is not feasible until the functionality has been
56 // re-implemented; see comment at the bottom of this file. For now, the user has 55 // re-implemented; see comment at the bottom of this file. For now, the user has
57 // to hard code the |write_ref_data| value. 56 // to hard code the |write_ref_data| value.
58 // When false, this will compare the output data with the results stored to 57 // When false, this will compare the output data with the results stored to
59 // file. This is the typical case. When the file should be updated, it can 58 // file. This is the typical case. When the file should be updated, it can
60 // be set to true with the command-line switch --write_ref_data. 59 // be set to true with the command-line switch --write_ref_data.
61 bool write_ref_data = false; 60 bool write_ref_data = false;
62 const int32_t kChannels[] = {1, 2}; 61 const google::protobuf::int32 kChannels[] = {1, 2};
63 const int kSampleRates[] = {8000, 16000, 32000, 48000}; 62 const int kSampleRates[] = {8000, 16000, 32000, 48000};
64 63
65 #if defined(WEBRTC_AUDIOPROC_FIXED_PROFILE) 64 #if defined(WEBRTC_AUDIOPROC_FIXED_PROFILE)
66 // Android doesn't support 48kHz. 65 // Android doesn't support 48kHz.
67 const int kProcessSampleRates[] = {8000, 16000, 32000}; 66 const int kProcessSampleRates[] = {8000, 16000, 32000};
68 #elif defined(WEBRTC_AUDIOPROC_FLOAT_PROFILE) 67 #elif defined(WEBRTC_AUDIOPROC_FLOAT_PROFILE)
69 const int kProcessSampleRates[] = {8000, 16000, 32000, 48000}; 68 const int kProcessSampleRates[] = {8000, 16000, 32000, 48000};
70 #endif 69 #endif
71 70
72 enum StreamDirection { kForward = 0, kReverse }; 71 enum StreamDirection { kForward = 0, kReverse };
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 void WriteStatsMessage(const AudioProcessing::Statistic& output, 223 void WriteStatsMessage(const AudioProcessing::Statistic& output,
225 audioproc::Test::Statistic* msg) { 224 audioproc::Test::Statistic* msg) {
226 msg->set_instant(output.instant); 225 msg->set_instant(output.instant);
227 msg->set_average(output.average); 226 msg->set_average(output.average);
228 msg->set_maximum(output.maximum); 227 msg->set_maximum(output.maximum);
229 msg->set_minimum(output.minimum); 228 msg->set_minimum(output.minimum);
230 } 229 }
231 #endif 230 #endif
232 231
233 void OpenFileAndWriteMessage(const std::string filename, 232 void OpenFileAndWriteMessage(const std::string filename,
234 const MessageLite& msg) { 233 const ::google::protobuf::MessageLite& msg) {
235 FILE* file = fopen(filename.c_str(), "wb"); 234 FILE* file = fopen(filename.c_str(), "wb");
236 ASSERT_TRUE(file != NULL); 235 ASSERT_TRUE(file != NULL);
237 236
238 int32_t size = msg.ByteSize(); 237 int32_t size = msg.ByteSize();
239 ASSERT_GT(size, 0); 238 ASSERT_GT(size, 0);
240 std::unique_ptr<uint8_t[]> array(new uint8_t[size]); 239 std::unique_ptr<uint8_t[]> array(new uint8_t[size]);
241 ASSERT_TRUE(msg.SerializeToArray(array.get(), size)); 240 ASSERT_TRUE(msg.SerializeToArray(array.get(), size));
242 241
243 ASSERT_EQ(1u, fwrite(&size, sizeof(size), 1, file)); 242 ASSERT_EQ(1u, fwrite(&size, sizeof(size), 1, file));
244 ASSERT_EQ(static_cast<size_t>(size), 243 ASSERT_EQ(static_cast<size_t>(size),
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 if (temp_filenames[filename].empty()) 292 if (temp_filenames[filename].empty())
294 temp_filenames[filename] = test::TempFilename(test::OutputPath(), filename); 293 temp_filenames[filename] = test::TempFilename(test::OutputPath(), filename);
295 return temp_filenames[filename]; 294 return temp_filenames[filename];
296 } 295 }
297 296
298 void ClearTempFiles() { 297 void ClearTempFiles() {
299 for (auto& kv : temp_filenames) 298 for (auto& kv : temp_filenames)
300 remove(kv.second.c_str()); 299 remove(kv.second.c_str());
301 } 300 }
302 301
303 void OpenFileAndReadMessage(std::string filename, MessageLite* msg) { 302 void OpenFileAndReadMessage(std::string filename,
303 ::google::protobuf::MessageLite* msg) {
304 FILE* file = fopen(filename.c_str(), "rb"); 304 FILE* file = fopen(filename.c_str(), "rb");
305 ASSERT_TRUE(file != NULL); 305 ASSERT_TRUE(file != NULL);
306 ReadMessageFromFile(file, msg); 306 ReadMessageFromFile(file, msg);
307 fclose(file); 307 fclose(file);
308 } 308 }
309 309
310 // Reads a 10 ms chunk of int16 interleaved audio from the given (assumed 310 // Reads a 10 ms chunk of int16 interleaved audio from the given (assumed
311 // stereo) file, converts to deinterleaved float (optionally downmixing) and 311 // stereo) file, converts to deinterleaved float (optionally downmixing) and
312 // returns the result in |cb|. Returns false if the file ended (or on error) and 312 // returns the result in |cb|. Returns false if the file ended (or on error) and
313 // true otherwise. 313 // true otherwise.
(...skipping 2563 matching lines...) Expand 10 before | Expand all | Expand 10 after
2877 // TODO(peah): Remove the testing for 2877 // TODO(peah): Remove the testing for
2878 // apm->capture_nonlocked_.level_controller_enabled once the value in config_ 2878 // apm->capture_nonlocked_.level_controller_enabled once the value in config_
2879 // is instead used to activate the level controller. 2879 // is instead used to activate the level controller.
2880 EXPECT_FALSE(apm->capture_nonlocked_.level_controller_enabled); 2880 EXPECT_FALSE(apm->capture_nonlocked_.level_controller_enabled);
2881 EXPECT_NEAR(kTargetLcPeakLeveldBFS, 2881 EXPECT_NEAR(kTargetLcPeakLeveldBFS,
2882 apm->config_.level_controller.initial_peak_level_dbfs, 2882 apm->config_.level_controller.initial_peak_level_dbfs,
2883 std::numeric_limits<float>::epsilon()); 2883 std::numeric_limits<float>::epsilon());
2884 } 2884 }
2885 2885
2886 } // namespace webrtc 2886 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/audio_processing/audio_processing_impl.cc ('k') | webrtc/modules/audio_processing/test/protobuf_utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698