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

Side by Side Diff: webrtc/modules/audio_processing/test/test_utils.cc

Issue 1423693008: Revert of Add aecdump support to audioproc_f. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Rebased Created 5 years, 1 month 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) 2015 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2015 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
(...skipping 13 matching lines...) Expand all
24 #ifndef WEBRTC_ARCH_LITTLE_ENDIAN 24 #ifndef WEBRTC_ARCH_LITTLE_ENDIAN
25 #error "Need to convert samples to little-endian when writing to PCM file" 25 #error "Need to convert samples to little-endian when writing to PCM file"
26 #endif 26 #endif
27 fwrite(samples, sizeof(*samples), num_samples, file_handle_); 27 fwrite(samples, sizeof(*samples), num_samples, file_handle_);
28 } 28 }
29 29
30 void RawFile::WriteSamples(const float* samples, size_t num_samples) { 30 void RawFile::WriteSamples(const float* samples, size_t num_samples) {
31 fwrite(samples, sizeof(*samples), num_samples, file_handle_); 31 fwrite(samples, sizeof(*samples), num_samples, file_handle_);
32 } 32 }
33 33
34 ChannelBufferWavReader::ChannelBufferWavReader(rtc::scoped_ptr<WavReader> file)
35 : file_(file.Pass()) {}
36
37 bool ChannelBufferWavReader::Read(ChannelBuffer<float>* buffer) {
38 RTC_CHECK_EQ(file_->num_channels(), buffer->num_channels());
39 interleaved_.resize(buffer->size());
40 if (file_->ReadSamples(interleaved_.size(), &interleaved_[0]) !=
41 interleaved_.size()) {
42 return false;
43 }
44
45 FloatS16ToFloat(&interleaved_[0], interleaved_.size(), &interleaved_[0]);
46 Deinterleave(&interleaved_[0], buffer->num_frames(), buffer->num_channels(),
47 buffer->channels());
48 return true;
49 }
50
51 ChannelBufferWavWriter::ChannelBufferWavWriter(rtc::scoped_ptr<WavWriter> file)
52 : file_(file.Pass()) {}
53
54 void ChannelBufferWavWriter::Write(const ChannelBuffer<float>& buffer) {
55 RTC_CHECK_EQ(file_->num_channels(), buffer.num_channels());
56 interleaved_.resize(buffer.size());
57 Interleave(buffer.channels(), buffer.num_frames(), buffer.num_channels(),
58 &interleaved_[0]);
59 FloatToFloatS16(&interleaved_[0], interleaved_.size(), &interleaved_[0]);
60 file_->WriteSamples(&interleaved_[0], interleaved_.size());
61 }
62
63 void WriteIntData(const int16_t* data, 34 void WriteIntData(const int16_t* data,
64 size_t length, 35 size_t length,
65 WavWriter* wav_file, 36 WavWriter* wav_file,
66 RawFile* raw_file) { 37 RawFile* raw_file) {
67 if (wav_file) { 38 if (wav_file) {
68 wav_file->WriteSamples(data, length); 39 wav_file->WriteSamples(data, length);
69 } 40 }
70 if (raw_file) { 41 if (raw_file) {
71 raw_file->WriteSamples(data, length); 42 raw_file->WriteSamples(data, length);
72 } 43 }
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 sample_rate_hz / 1000; 85 sample_rate_hz / 1000;
115 } 86 }
116 87
117 AudioProcessing::ChannelLayout LayoutFromChannels(int num_channels) { 88 AudioProcessing::ChannelLayout LayoutFromChannels(int num_channels) {
118 switch (num_channels) { 89 switch (num_channels) {
119 case 1: 90 case 1:
120 return AudioProcessing::kMono; 91 return AudioProcessing::kMono;
121 case 2: 92 case 2:
122 return AudioProcessing::kStereo; 93 return AudioProcessing::kStereo;
123 default: 94 default:
124 RTC_CHECK(false); 95 assert(false);
125 return AudioProcessing::kMono; 96 return AudioProcessing::kMono;
126 } 97 }
127 } 98 }
128 99
129 std::vector<Point> ParseArrayGeometry(const std::string& mic_positions) { 100 std::vector<Point> ParseArrayGeometry(const std::string& mic_positions,
101 size_t num_mics) {
130 const std::vector<float> values = ParseList<float>(mic_positions); 102 const std::vector<float> values = ParseList<float>(mic_positions);
131 const size_t num_mics = 103 RTC_CHECK_EQ(values.size(), 3 * num_mics)
132 rtc::CheckedDivExact(values.size(), static_cast<size_t>(3)); 104 << "Could not parse mic_positions or incorrect number of points.";
133 RTC_CHECK_GT(num_mics, 0u) << "mic_positions is not large enough.";
134 105
135 std::vector<Point> result; 106 std::vector<Point> result;
136 result.reserve(num_mics); 107 result.reserve(num_mics);
137 for (size_t i = 0; i < values.size(); i += 3) { 108 for (size_t i = 0; i < values.size(); i += 3) {
138 result.push_back(Point(values[i + 0], values[i + 1], values[i + 2])); 109 double x = values[i + 0];
110 double y = values[i + 1];
111 double z = values[i + 2];
112 result.push_back(Point(x, y, z));
139 } 113 }
140 114
141 return result; 115 return result;
142 } 116 }
143 117
144 std::vector<Point> ParseArrayGeometry(const std::string& mic_positions,
145 size_t num_mics) {
146 std::vector<Point> result = ParseArrayGeometry(mic_positions);
147 RTC_CHECK_EQ(result.size(), num_mics)
148 << "Could not parse mic_positions or incorrect number of points.";
149 return result;
150 }
151 118
152 } // namespace webrtc 119 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/audio_processing/test/test_utils.h ('k') | webrtc/system_wrappers/include/tick_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698