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

Side by Side Diff: webrtc/modules/audio_coding/neteq/neteq_stereo_unittest.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) 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 // Test to verify correct stereo and multi-channel operation. 11 // Test to verify correct stereo and multi-channel operation.
12 12
13 #include <algorithm> 13 #include <algorithm>
14 #include <string> 14 #include <string>
15 #include <list> 15 #include <list>
16 16
17 #include "testing/gtest/include/gtest/gtest.h" 17 #include "testing/gtest/include/gtest/gtest.h"
18 #include "webrtc/base/scoped_ptr.h" 18 #include "webrtc/base/scoped_ptr.h"
19 #include "webrtc/modules/audio_coding/codecs/pcm16b/pcm16b.h" 19 #include "webrtc/modules/audio_coding/codecs/pcm16b/pcm16b.h"
20 #include "webrtc/modules/audio_coding/neteq/include/neteq.h" 20 #include "webrtc/modules/audio_coding/neteq/include/neteq.h"
21 #include "webrtc/modules/audio_coding/neteq/tools/input_audio_file.h" 21 #include "webrtc/modules/audio_coding/neteq/tools/input_audio_file.h"
22 #include "webrtc/modules/audio_coding/neteq/tools/rtp_generator.h" 22 #include "webrtc/modules/audio_coding/neteq/tools/rtp_generator.h"
23 #include "webrtc/test/testsupport/fileutils.h" 23 #include "webrtc/test/testsupport/fileutils.h"
24 24
25 namespace webrtc { 25 namespace webrtc {
26 26
27 struct TestParameters { 27 struct TestParameters {
28 int frame_size; 28 int frame_size;
29 int sample_rate; 29 int sample_rate;
30 int num_channels; 30 size_t num_channels;
31 }; 31 };
32 32
33 // This is a parameterized test. The test parameters are supplied through a 33 // This is a parameterized test. The test parameters are supplied through a
34 // TestParameters struct, which is obtained through the GetParam() method. 34 // TestParameters struct, which is obtained through the GetParam() method.
35 // 35 //
36 // The objective of the test is to create a mono input signal and a 36 // The objective of the test is to create a mono input signal and a
37 // multi-channel input signal, where each channel is identical to the mono 37 // multi-channel input signal, where each channel is identical to the mono
38 // input channel. The two input signals are processed through their respective 38 // input channel. The two input signals are processed through their respective
39 // NetEq instances. After that, the output signals are compared. The expected 39 // NetEq instances. After that, the output signals are compared. The expected
40 // result is that each channel in the multi-channel output is identical to the 40 // result is that each channel in the multi-channel output is identical to the
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 if (frame_size_samples_ * 2 * num_channels_ != multi_payload_size_bytes_) { 156 if (frame_size_samples_ * 2 * num_channels_ != multi_payload_size_bytes_) {
157 return -1; 157 return -1;
158 } 158 }
159 rtp_generator_.GetRtpHeader(kPayloadTypeMulti, frame_size_samples_, 159 rtp_generator_.GetRtpHeader(kPayloadTypeMulti, frame_size_samples_,
160 &rtp_header_); 160 &rtp_header_);
161 return next_send_time; 161 return next_send_time;
162 } 162 }
163 163
164 void VerifyOutput(size_t num_samples) { 164 void VerifyOutput(size_t num_samples) {
165 for (size_t i = 0; i < num_samples; ++i) { 165 for (size_t i = 0; i < num_samples; ++i) {
166 for (int j = 0; j < num_channels_; ++j) { 166 for (size_t j = 0; j < num_channels_; ++j) {
167 ASSERT_EQ(output_[i], output_multi_channel_[i * num_channels_ + j]) << 167 ASSERT_EQ(output_[i], output_multi_channel_[i * num_channels_ + j]) <<
168 "Diff in sample " << i << ", channel " << j << "."; 168 "Diff in sample " << i << ", channel " << j << ".";
169 } 169 }
170 } 170 }
171 } 171 }
172 172
173 virtual int GetArrivalTime(int send_time) { 173 virtual int GetArrivalTime(int send_time) {
174 int arrival_time = last_arrival_time_ + (send_time - last_send_time_); 174 int arrival_time = last_arrival_time_ + (send_time - last_send_time_);
175 last_send_time_ = send_time; 175 last_send_time_ = send_time;
176 last_arrival_time_ = arrival_time; 176 last_arrival_time_ = arrival_time;
(...skipping 30 matching lines...) Expand all
207 // Get next input packets (mono and multi-channel). 207 // Get next input packets (mono and multi-channel).
208 do { 208 do {
209 next_send_time = GetNewPackets(); 209 next_send_time = GetNewPackets();
210 ASSERT_NE(-1, next_send_time); 210 ASSERT_NE(-1, next_send_time);
211 next_arrival_time = GetArrivalTime(next_send_time); 211 next_arrival_time = GetArrivalTime(next_send_time);
212 } while (Lost()); // If lost, immediately read the next packet. 212 } while (Lost()); // If lost, immediately read the next packet.
213 } 213 }
214 NetEqOutputType output_type; 214 NetEqOutputType output_type;
215 // Get audio from mono instance. 215 // Get audio from mono instance.
216 size_t samples_per_channel; 216 size_t samples_per_channel;
217 int num_channels; 217 size_t num_channels;
218 EXPECT_EQ(NetEq::kOK, 218 EXPECT_EQ(NetEq::kOK,
219 neteq_mono_->GetAudio(kMaxBlockSize, output_, 219 neteq_mono_->GetAudio(kMaxBlockSize, output_,
220 &samples_per_channel, &num_channels, 220 &samples_per_channel, &num_channels,
221 &output_type)); 221 &output_type));
222 EXPECT_EQ(1, num_channels); 222 EXPECT_EQ(1u, num_channels);
223 EXPECT_EQ(output_size_samples_, samples_per_channel); 223 EXPECT_EQ(output_size_samples_, samples_per_channel);
224 // Get audio from multi-channel instance. 224 // Get audio from multi-channel instance.
225 ASSERT_EQ(NetEq::kOK, 225 ASSERT_EQ(NetEq::kOK,
226 neteq_->GetAudio(kMaxBlockSize * num_channels_, 226 neteq_->GetAudio(kMaxBlockSize * num_channels_,
227 output_multi_channel_, 227 output_multi_channel_,
228 &samples_per_channel, &num_channels, 228 &samples_per_channel, &num_channels,
229 &output_type)); 229 &output_type));
230 EXPECT_EQ(num_channels_, num_channels); 230 EXPECT_EQ(num_channels_, num_channels);
231 EXPECT_EQ(output_size_samples_, samples_per_channel); 231 EXPECT_EQ(output_size_samples_, samples_per_channel);
232 std::ostringstream ss; 232 std::ostringstream ss;
233 ss << "Lap number " << k << "."; 233 ss << "Lap number " << k << ".";
234 SCOPED_TRACE(ss.str()); // Print out the parameter values on failure. 234 SCOPED_TRACE(ss.str()); // Print out the parameter values on failure.
235 // Compare mono and multi-channel. 235 // Compare mono and multi-channel.
236 ASSERT_NO_FATAL_FAILURE(VerifyOutput(output_size_samples_)); 236 ASSERT_NO_FATAL_FAILURE(VerifyOutput(output_size_samples_));
237 237
238 time_now += kTimeStepMs; 238 time_now += kTimeStepMs;
239 } 239 }
240 } 240 }
241 241
242 const int num_channels_; 242 const size_t num_channels_;
243 const int sample_rate_hz_; 243 const int sample_rate_hz_;
244 const int samples_per_ms_; 244 const int samples_per_ms_;
245 const int frame_size_ms_; 245 const int frame_size_ms_;
246 const size_t frame_size_samples_; 246 const size_t frame_size_samples_;
247 const size_t output_size_samples_; 247 const size_t output_size_samples_;
248 NetEq* neteq_mono_; 248 NetEq* neteq_mono_;
249 NetEq* neteq_; 249 NetEq* neteq_;
250 test::RtpGenerator rtp_generator_mono_; 250 test::RtpGenerator rtp_generator_mono_;
251 test::RtpGenerator rtp_generator_; 251 test::RtpGenerator rtp_generator_;
252 int16_t* input_; 252 int16_t* input_;
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
421 421
422 INSTANTIATE_TEST_CASE_P(MultiChannel, 422 INSTANTIATE_TEST_CASE_P(MultiChannel,
423 NetEqStereoTestDelays, 423 NetEqStereoTestDelays,
424 ::testing::ValuesIn(GetTestParameters())); 424 ::testing::ValuesIn(GetTestParameters()));
425 425
426 INSTANTIATE_TEST_CASE_P(MultiChannel, 426 INSTANTIATE_TEST_CASE_P(MultiChannel,
427 NetEqStereoTestLosses, 427 NetEqStereoTestLosses,
428 ::testing::ValuesIn(GetTestParameters())); 428 ::testing::ValuesIn(GetTestParameters()));
429 429
430 } // namespace webrtc 430 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/audio_coding/neteq/neteq_impl_unittest.cc ('k') | webrtc/modules/audio_coding/neteq/neteq_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698