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

Side by Side Diff: webrtc/modules/audio_coding/neteq/neteq_stereo_unittest.cc

Issue 1532903002: Reenables several NetEq unittests on android. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Addressed review comments. Created 5 years 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
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 input_multi_channel_, frame_size_samples_ * num_channels_, 155 input_multi_channel_, frame_size_samples_ * num_channels_,
156 encoded_multi_channel_); 156 encoded_multi_channel_);
157 if (frame_size_samples_ * 2 * num_channels_ != multi_payload_size_bytes_) { 157 if (frame_size_samples_ * 2 * num_channels_ != multi_payload_size_bytes_) {
158 return -1; 158 return -1;
159 } 159 }
160 rtp_generator_.GetRtpHeader(kPayloadTypeMulti, frame_size_samples_, 160 rtp_generator_.GetRtpHeader(kPayloadTypeMulti, frame_size_samples_,
161 &rtp_header_); 161 &rtp_header_);
162 return next_send_time; 162 return next_send_time;
163 } 163 }
164 164
165 void VerifyOutput(size_t num_samples) { 165 virtual void VerifyOutput(size_t num_samples) {
166 for (size_t i = 0; i < num_samples; ++i) { 166 for (size_t i = 0; i < num_samples; ++i) {
167 for (int j = 0; j < num_channels_; ++j) { 167 for (int j = 0; j < num_channels_; ++j) {
168 ASSERT_EQ(output_[i], output_multi_channel_[i * num_channels_ + j]) << 168 ASSERT_EQ(output_[i], output_multi_channel_[i * num_channels_ + j]) <<
169 "Diff in sample " << i << ", channel " << j << "."; 169 "Diff in sample " << i << ", channel " << j << ".";
170 } 170 }
171 } 171 }
172 } 172 }
173 173
174 virtual int GetArrivalTime(int send_time) { 174 virtual int GetArrivalTime(int send_time) {
175 int arrival_time = last_arrival_time_ + (send_time - last_send_time_); 175 int arrival_time = last_arrival_time_ + (send_time - last_send_time_);
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 protected: 269 protected:
270 NetEqStereoTestNoJitter() 270 NetEqStereoTestNoJitter()
271 : NetEqStereoTest() { 271 : NetEqStereoTest() {
272 // Start the sender 100 ms before the receiver to pre-fill the buffer. 272 // Start the sender 100 ms before the receiver to pre-fill the buffer.
273 // This is to avoid doing preemptive expand early in the test. 273 // This is to avoid doing preemptive expand early in the test.
274 // TODO(hlundin): Mock the decision making instead to control the modes. 274 // TODO(hlundin): Mock the decision making instead to control the modes.
275 last_arrival_time_ = -100; 275 last_arrival_time_ = -100;
276 } 276 }
277 }; 277 };
278 278
279 TEST_P(NetEqStereoTestNoJitter, DISABLED_ON_ANDROID(RunTest)) { 279 TEST_P(NetEqStereoTestNoJitter, RunTest) {
280 RunTest(8); 280 RunTest(8);
281 } 281 }
282 282
283 class NetEqStereoTestPositiveDrift : public NetEqStereoTest { 283 class NetEqStereoTestPositiveDrift : public NetEqStereoTest {
284 protected: 284 protected:
285 NetEqStereoTestPositiveDrift() 285 NetEqStereoTestPositiveDrift()
286 : NetEqStereoTest(), 286 : NetEqStereoTest(),
287 drift_factor(0.9) { 287 drift_factor(0.9) {
288 // Start the sender 100 ms before the receiver to pre-fill the buffer. 288 // Start the sender 100 ms before the receiver to pre-fill the buffer.
289 // This is to avoid doing preemptive expand early in the test. 289 // This is to avoid doing preemptive expand early in the test.
290 // TODO(hlundin): Mock the decision making instead to control the modes. 290 // TODO(hlundin): Mock the decision making instead to control the modes.
291 last_arrival_time_ = -100; 291 last_arrival_time_ = -100;
292 } 292 }
293 virtual int GetArrivalTime(int send_time) { 293 virtual int GetArrivalTime(int send_time) {
294 int arrival_time = last_arrival_time_ + 294 int arrival_time = last_arrival_time_ +
295 drift_factor * (send_time - last_send_time_); 295 drift_factor * (send_time - last_send_time_);
296 last_send_time_ = send_time; 296 last_send_time_ = send_time;
297 last_arrival_time_ = arrival_time; 297 last_arrival_time_ = arrival_time;
298 return arrival_time; 298 return arrival_time;
299 } 299 }
300 300
301 double drift_factor; 301 double drift_factor;
302 }; 302 };
303 303
304 TEST_P(NetEqStereoTestPositiveDrift, DISABLED_ON_ANDROID(RunTest)) { 304 TEST_P(NetEqStereoTestPositiveDrift, RunTest) {
305 RunTest(100); 305 RunTest(100);
306 } 306 }
307 307
308 class NetEqStereoTestNegativeDrift : public NetEqStereoTestPositiveDrift { 308 class NetEqStereoTestNegativeDrift : public NetEqStereoTestPositiveDrift {
309 protected: 309 protected:
310 NetEqStereoTestNegativeDrift() 310 NetEqStereoTestNegativeDrift()
311 : NetEqStereoTestPositiveDrift() { 311 : NetEqStereoTestPositiveDrift() {
312 drift_factor = 1.1; 312 drift_factor = 1.1;
313 last_arrival_time_ = 0; 313 last_arrival_time_ = 0;
314 } 314 }
315 }; 315 };
316 316
317 TEST_P(NetEqStereoTestNegativeDrift, DISABLED_ON_ANDROID(RunTest)) { 317 TEST_P(NetEqStereoTestNegativeDrift, RunTest) {
318 RunTest(100); 318 RunTest(100);
319 } 319 }
320 320
321 class NetEqStereoTestDelays : public NetEqStereoTest { 321 class NetEqStereoTestDelays : public NetEqStereoTest {
322 protected: 322 protected:
323 static const int kDelayInterval = 10; 323 static const int kDelayInterval = 10;
324 static const int kDelay = 1000; 324 static const int kDelay = 1000;
325 NetEqStereoTestDelays() 325 NetEqStereoTestDelays()
326 : NetEqStereoTest(), 326 : NetEqStereoTest(),
327 frame_index_(0) { 327 frame_index_(0) {
328 } 328 }
329 329
330 virtual int GetArrivalTime(int send_time) { 330 virtual int GetArrivalTime(int send_time) {
331 // Deliver immediately, unless we have a back-log. 331 // Deliver immediately, unless we have a back-log.
332 int arrival_time = std::min(last_arrival_time_, send_time); 332 int arrival_time = std::min(last_arrival_time_, send_time);
333 if (++frame_index_ % kDelayInterval == 0) { 333 if (++frame_index_ % kDelayInterval == 0) {
334 // Delay this packet. 334 // Delay this packet.
335 arrival_time += kDelay; 335 arrival_time += kDelay;
336 } 336 }
337 last_send_time_ = send_time; 337 last_send_time_ = send_time;
338 last_arrival_time_ = arrival_time; 338 last_arrival_time_ = arrival_time;
339 return arrival_time; 339 return arrival_time;
340 } 340 }
341 341
342 int frame_index_; 342 int frame_index_;
343 }; 343 };
344 344
345 TEST_P(NetEqStereoTestDelays, DISABLED_ON_ANDROID(RunTest)) { 345 TEST_P(NetEqStereoTestDelays, RunTest) {
346 RunTest(1000); 346 RunTest(1000);
347 } 347 }
348 348
349 class NetEqStereoTestLosses : public NetEqStereoTest { 349 class NetEqStereoTestLosses : public NetEqStereoTest {
350 protected: 350 protected:
351 static const int kLossInterval = 10; 351 static const int kLossInterval = 10;
352 NetEqStereoTestLosses() 352 NetEqStereoTestLosses()
353 : NetEqStereoTest(), 353 : NetEqStereoTest(),
354 frame_index_(0) { 354 frame_index_(0) {
355 } 355 }
356 356
357 virtual bool Lost() { 357 virtual bool Lost() {
358 return (++frame_index_) % kLossInterval == 0; 358 return (++frame_index_) % kLossInterval == 0;
359 } 359 }
360 360
361 // TODO(hlundin): NetEq is not giving bitexact results for these cases.
362 virtual void VerifyOutput(size_t num_samples) {
363 for (size_t i = 0; i < num_samples; ++i) {
364 auto first_channel_sample = output_multi_channel_[i * num_channels_];
365 for (int j = 0; j < num_channels_; ++j) {
366 const int error_margin = 200;
minyue-webrtc 2015/12/18 15:32:29 Nit: compiler time constant can name as kErrorMagi
ivoc 2016/01/18 15:36:46 Done.
367 EXPECT_NEAR(output_[i], output_multi_channel_[i * num_channels_ + j],
368 error_margin)
369 << "Diff in sample " << i << ", channel " << j << ".";
370 EXPECT_EQ(first_channel_sample,
371 output_multi_channel_[i * num_channels_ + j]);
372 }
373 }
374 }
375
361 int frame_index_; 376 int frame_index_;
362 }; 377 };
363 378
364 TEST_P(NetEqStereoTestLosses, DISABLED_ON_ANDROID(RunTest)) { 379 TEST_P(NetEqStereoTestLosses, RunTest) {
365 RunTest(100); 380 RunTest(100);
366 } 381 }
367 382
368 383
369 // Creates a list of parameter sets. 384 // Creates a list of parameter sets.
370 std::list<TestParameters> GetTestParameters() { 385 std::list<TestParameters> GetTestParameters() {
371 std::list<TestParameters> l; 386 std::list<TestParameters> l;
372 const int sample_rates[] = {8000, 16000, 32000}; 387 const int sample_rates[] = {8000, 16000, 32000};
373 const int num_rates = sizeof(sample_rates) / sizeof(sample_rates[0]); 388 const int num_rates = sizeof(sample_rates) / sizeof(sample_rates[0]);
374 // Loop through sample rates. 389 // Loop through sample rates.
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 429
415 INSTANTIATE_TEST_CASE_P(MultiChannel, 430 INSTANTIATE_TEST_CASE_P(MultiChannel,
416 NetEqStereoTestDelays, 431 NetEqStereoTestDelays,
417 ::testing::ValuesIn(GetTestParameters())); 432 ::testing::ValuesIn(GetTestParameters()));
418 433
419 INSTANTIATE_TEST_CASE_P(MultiChannel, 434 INSTANTIATE_TEST_CASE_P(MultiChannel,
420 NetEqStereoTestLosses, 435 NetEqStereoTestLosses,
421 ::testing::ValuesIn(GetTestParameters())); 436 ::testing::ValuesIn(GetTestParameters()));
422 437
423 } // namespace webrtc 438 } // namespace webrtc
OLDNEW
« no previous file with comments | « resources/audio_coding/neteq4_universal_ref_android.pcm.sha1 ('k') | webrtc/modules/audio_coding/neteq/neteq_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698