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

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

Issue 1316523002: Convert channel counts to size_t. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: Fix compile Created 4 years, 11 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) 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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 if (wav_file) { 69 if (wav_file) {
70 wav_file->WriteSamples(data, length); 70 wav_file->WriteSamples(data, length);
71 } 71 }
72 if (raw_file) { 72 if (raw_file) {
73 raw_file->WriteSamples(data, length); 73 raw_file->WriteSamples(data, length);
74 } 74 }
75 } 75 }
76 76
77 void WriteFloatData(const float* const* data, 77 void WriteFloatData(const float* const* data,
78 size_t samples_per_channel, 78 size_t samples_per_channel,
79 int num_channels, 79 size_t num_channels,
80 WavWriter* wav_file, 80 WavWriter* wav_file,
81 RawFile* raw_file) { 81 RawFile* raw_file) {
82 size_t length = num_channels * samples_per_channel; 82 size_t length = num_channels * samples_per_channel;
83 rtc::scoped_ptr<float[]> buffer(new float[length]); 83 rtc::scoped_ptr<float[]> buffer(new float[length]);
84 Interleave(data, samples_per_channel, num_channels, buffer.get()); 84 Interleave(data, samples_per_channel, num_channels, buffer.get());
85 if (raw_file) { 85 if (raw_file) {
86 raw_file->WriteSamples(buffer.get(), length); 86 raw_file->WriteSamples(buffer.get(), length);
87 } 87 }
88 // TODO(aluebs): Use ScaleToInt16Range() from audio_util 88 // TODO(aluebs): Use ScaleToInt16Range() from audio_util
89 for (size_t i = 0; i < length; ++i) { 89 for (size_t i = 0; i < length; ++i) {
(...skipping 19 matching lines...) Expand all
109 return static_cast<size_t>(AudioProcessing::kChunkSizeMs * rate / 1000); 109 return static_cast<size_t>(AudioProcessing::kChunkSizeMs * rate / 1000);
110 } 110 }
111 111
112 void SetFrameSampleRate(AudioFrame* frame, 112 void SetFrameSampleRate(AudioFrame* frame,
113 int sample_rate_hz) { 113 int sample_rate_hz) {
114 frame->sample_rate_hz_ = sample_rate_hz; 114 frame->sample_rate_hz_ = sample_rate_hz;
115 frame->samples_per_channel_ = AudioProcessing::kChunkSizeMs * 115 frame->samples_per_channel_ = AudioProcessing::kChunkSizeMs *
116 sample_rate_hz / 1000; 116 sample_rate_hz / 1000;
117 } 117 }
118 118
119 AudioProcessing::ChannelLayout LayoutFromChannels(int num_channels) { 119 AudioProcessing::ChannelLayout LayoutFromChannels(size_t num_channels) {
120 switch (num_channels) { 120 switch (num_channels) {
121 case 1: 121 case 1:
122 return AudioProcessing::kMono; 122 return AudioProcessing::kMono;
123 case 2: 123 case 2:
124 return AudioProcessing::kStereo; 124 return AudioProcessing::kStereo;
125 default: 125 default:
126 RTC_CHECK(false); 126 RTC_CHECK(false);
127 return AudioProcessing::kMono; 127 return AudioProcessing::kMono;
128 } 128 }
129 } 129 }
(...skipping 15 matching lines...) Expand all
145 145
146 std::vector<Point> ParseArrayGeometry(const std::string& mic_positions, 146 std::vector<Point> ParseArrayGeometry(const std::string& mic_positions,
147 size_t num_mics) { 147 size_t num_mics) {
148 std::vector<Point> result = ParseArrayGeometry(mic_positions); 148 std::vector<Point> result = ParseArrayGeometry(mic_positions);
149 RTC_CHECK_EQ(result.size(), num_mics) 149 RTC_CHECK_EQ(result.size(), num_mics)
150 << "Could not parse mic_positions or incorrect number of points."; 150 << "Could not parse mic_positions or incorrect number of points.";
151 return result; 151 return result;
152 } 152 }
153 153
154 } // namespace webrtc 154 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/audio_processing/test/test_utils.h ('k') | webrtc/modules/audio_processing/test/unpack.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698