OLD | NEW |
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 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
349 EXPECT_EQ(nada_feedback->derivative(), 0.0f); | 349 EXPECT_EQ(nada_feedback->derivative(), 0.0f); |
350 } | 350 } |
351 | 351 |
352 TEST_F(NadaReceiverSideTest, FeedbackIncreasingDelay) { | 352 TEST_F(NadaReceiverSideTest, FeedbackIncreasingDelay) { |
353 // Since packets are 100ms apart, each one corresponds to a feedback. | 353 // Since packets are 100ms apart, each one corresponds to a feedback. |
354 const int64_t kTimeGapMs = 100; // Between each packet. | 354 const int64_t kTimeGapMs = 100; // Between each packet. |
355 | 355 |
356 // Raw delays are = [10 20 30 40 50 60 70 80] ms. | 356 // Raw delays are = [10 20 30 40 50 60 70 80] ms. |
357 // Baseline delay will be 50 ms. | 357 // Baseline delay will be 50 ms. |
358 // Delay signals should be: [0 10 20 30 40 50 60 70] ms. | 358 // Delay signals should be: [0 10 20 30 40 50 60 70] ms. |
359 const int64_t kMedianFilteredDelaysMs[] = {0, 10, 10, 20, 20, 30, 40, 50}; | 359 const int64_t kMedianFilteredDelaysMs[] = {0, 5, 10, 15, 20, 30, 40, 50}; |
360 const int kNumPackets = ARRAY_SIZE(kMedianFilteredDelaysMs); | 360 const int kNumPackets = ARRAY_SIZE(kMedianFilteredDelaysMs); |
361 const float kAlpha = 0.1f; // Used for exponential smoothing. | 361 const float kAlpha = 0.1f; // Used for exponential smoothing. |
362 | 362 |
363 int64_t exp_smoothed_delays_ms[kNumPackets]; | 363 int64_t exp_smoothed_delays_ms[kNumPackets]; |
364 exp_smoothed_delays_ms[0] = kMedianFilteredDelaysMs[0]; | 364 exp_smoothed_delays_ms[0] = kMedianFilteredDelaysMs[0]; |
365 | 365 |
366 for (int i = 1; i < kNumPackets; ++i) { | 366 for (int i = 1; i < kNumPackets; ++i) { |
367 exp_smoothed_delays_ms[i] = static_cast<int64_t>( | 367 exp_smoothed_delays_ms[i] = static_cast<int64_t>( |
368 kAlpha * kMedianFilteredDelaysMs[i] + | 368 kAlpha * kMedianFilteredDelaysMs[i] + |
369 (1.0f - kAlpha) * exp_smoothed_delays_ms[i - 1] + 0.5f); | 369 (1.0f - kAlpha) * exp_smoothed_delays_ms[i - 1] + 0.5f); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
418 } | 418 } |
419 | 419 |
420 TEST_F(NadaReceiverSideTest, FeedbackWarpedDelay) { | 420 TEST_F(NadaReceiverSideTest, FeedbackWarpedDelay) { |
421 // Since packets are 100ms apart, each one corresponds to a feedback. | 421 // Since packets are 100ms apart, each one corresponds to a feedback. |
422 const int64_t kTimeGapMs = 100; // Between each packet. | 422 const int64_t kTimeGapMs = 100; // Between each packet. |
423 | 423 |
424 // Raw delays are = [50 250 450 650 850 1050 1250 1450] ms. | 424 // Raw delays are = [50 250 450 650 850 1050 1250 1450] ms. |
425 // Baseline delay will be 50 ms. | 425 // Baseline delay will be 50 ms. |
426 // Delay signals should be: [0 200 400 600 800 1000 1200 1400] ms. | 426 // Delay signals should be: [0 200 400 600 800 1000 1200 1400] ms. |
427 const int64_t kMedianFilteredDelaysMs[] = { | 427 const int64_t kMedianFilteredDelaysMs[] = { |
428 0, 200, 200, 400, 400, 600, 800, 1000}; | 428 0, 100, 200, 300, 400, 600, 800, 1000}; |
429 const int kNumPackets = ARRAY_SIZE(kMedianFilteredDelaysMs); | 429 const int kNumPackets = ARRAY_SIZE(kMedianFilteredDelaysMs); |
430 const float kAlpha = 0.1f; // Used for exponential smoothing. | 430 const float kAlpha = 0.1f; // Used for exponential smoothing. |
431 | 431 |
432 int64_t exp_smoothed_delays_ms[kNumPackets]; | 432 int64_t exp_smoothed_delays_ms[kNumPackets]; |
433 exp_smoothed_delays_ms[0] = kMedianFilteredDelaysMs[0]; | 433 exp_smoothed_delays_ms[0] = kMedianFilteredDelaysMs[0]; |
434 | 434 |
435 for (int i = 1; i < kNumPackets; ++i) { | 435 for (int i = 1; i < kNumPackets; ++i) { |
436 exp_smoothed_delays_ms[i] = static_cast<int64_t>( | 436 exp_smoothed_delays_ms[i] = static_cast<int64_t>( |
437 kAlpha * kMedianFilteredDelaysMs[i] + | 437 kAlpha * kMedianFilteredDelaysMs[i] + |
438 (1.0f - kAlpha) * exp_smoothed_delays_ms[i - 1] + 0.5f); | 438 (1.0f - kAlpha) * exp_smoothed_delays_ms[i - 1] + 0.5f); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
486 for (int i = 1; i < kNumElements; ++i) { | 486 for (int i = 1; i < kNumElements; ++i) { |
487 EXPECT_EQ( | 487 EXPECT_EQ( |
488 exp_smoothed[i], | 488 exp_smoothed[i], |
489 static_cast<int64_t>(exp_smoothed[i - 1] * (1.0f - kAlpha) + 0.5f)); | 489 static_cast<int64_t>(exp_smoothed[i - 1] * (1.0f - kAlpha) + 0.5f)); |
490 } | 490 } |
491 } | 491 } |
492 | 492 |
493 } // namespace bwe | 493 } // namespace bwe |
494 } // namespace testing | 494 } // namespace testing |
495 } // namespace webrtc | 495 } // namespace webrtc |
OLD | NEW |