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

Side by Side Diff: webrtc/modules/remote_bitrate_estimator/test/estimators/nada_unittest.cc

Issue 1405023016: Convert usage of ARRAY_SIZE to arraysize. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: static_cast<int> 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
11 #include "webrtc/modules/remote_bitrate_estimator/test/estimators/nada.h" 11 #include "webrtc/modules/remote_bitrate_estimator/test/estimators/nada.h"
12 12
13 #include <algorithm> 13 #include <algorithm>
14 #include <numeric> 14 #include <numeric>
15 15
16 #include "webrtc/base/arraysize.h"
16 #include "webrtc/base/common.h" 17 #include "webrtc/base/common.h"
17 #include "webrtc/base/scoped_ptr.h" 18 #include "webrtc/base/scoped_ptr.h"
18 #include "webrtc/modules/remote_bitrate_estimator/test/bwe_test_framework.h" 19 #include "webrtc/modules/remote_bitrate_estimator/test/bwe_test_framework.h"
19 #include "webrtc/modules/remote_bitrate_estimator/test/packet.h" 20 #include "webrtc/modules/remote_bitrate_estimator/test/packet.h"
20 #include "testing/gtest/include/gtest/gtest.h" 21 #include "testing/gtest/include/gtest/gtest.h"
21 #include "webrtc/base/constructormagic.h" 22 #include "webrtc/base/constructormagic.h"
22 #include "webrtc/modules/remote_bitrate_estimator/test/packet_sender.h" 23 #include "webrtc/modules/remote_bitrate_estimator/test/packet_sender.h"
23 #include "webrtc/test/testsupport/fileutils.h" 24 #include "webrtc/test/testsupport/fileutils.h"
24 25
25 namespace webrtc { 26 namespace webrtc {
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 } 351 }
351 352
352 TEST_F(NadaReceiverSideTest, FeedbackIncreasingDelay) { 353 TEST_F(NadaReceiverSideTest, FeedbackIncreasingDelay) {
353 // Since packets are 100ms apart, each one corresponds to a feedback. 354 // Since packets are 100ms apart, each one corresponds to a feedback.
354 const int64_t kTimeGapMs = 100; // Between each packet. 355 const int64_t kTimeGapMs = 100; // Between each packet.
355 356
356 // Raw delays are = [10 20 30 40 50 60 70 80] ms. 357 // Raw delays are = [10 20 30 40 50 60 70 80] ms.
357 // Baseline delay will be 50 ms. 358 // Baseline delay will be 50 ms.
358 // Delay signals should be: [0 10 20 30 40 50 60 70] ms. 359 // Delay signals should be: [0 10 20 30 40 50 60 70] ms.
359 const int64_t kMedianFilteredDelaysMs[] = {0, 5, 10, 15, 20, 30, 40, 50}; 360 const int64_t kMedianFilteredDelaysMs[] = {0, 5, 10, 15, 20, 30, 40, 50};
360 const int kNumPackets = ARRAY_SIZE(kMedianFilteredDelaysMs); 361 const int kNumPackets = arraysize(kMedianFilteredDelaysMs);
361 const float kAlpha = 0.1f; // Used for exponential smoothing. 362 const float kAlpha = 0.1f; // Used for exponential smoothing.
362 363
363 int64_t exp_smoothed_delays_ms[kNumPackets]; 364 int64_t exp_smoothed_delays_ms[kNumPackets];
364 exp_smoothed_delays_ms[0] = kMedianFilteredDelaysMs[0]; 365 exp_smoothed_delays_ms[0] = kMedianFilteredDelaysMs[0];
365 366
366 for (int i = 1; i < kNumPackets; ++i) { 367 for (int i = 1; i < kNumPackets; ++i) {
367 exp_smoothed_delays_ms[i] = static_cast<int64_t>( 368 exp_smoothed_delays_ms[i] = static_cast<int64_t>(
368 kAlpha * kMedianFilteredDelaysMs[i] + 369 kAlpha * kMedianFilteredDelaysMs[i] +
369 (1.0f - kAlpha) * exp_smoothed_delays_ms[i - 1] + 0.5f); 370 (1.0f - kAlpha) * exp_smoothed_delays_ms[i - 1] + 0.5f);
370 } 371 }
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
419 420
420 TEST_F(NadaReceiverSideTest, FeedbackWarpedDelay) { 421 TEST_F(NadaReceiverSideTest, FeedbackWarpedDelay) {
421 // Since packets are 100ms apart, each one corresponds to a feedback. 422 // Since packets are 100ms apart, each one corresponds to a feedback.
422 const int64_t kTimeGapMs = 100; // Between each packet. 423 const int64_t kTimeGapMs = 100; // Between each packet.
423 424
424 // Raw delays are = [50 250 450 650 850 1050 1250 1450] ms. 425 // Raw delays are = [50 250 450 650 850 1050 1250 1450] ms.
425 // Baseline delay will be 50 ms. 426 // Baseline delay will be 50 ms.
426 // Delay signals should be: [0 200 400 600 800 1000 1200 1400] ms. 427 // Delay signals should be: [0 200 400 600 800 1000 1200 1400] ms.
427 const int64_t kMedianFilteredDelaysMs[] = { 428 const int64_t kMedianFilteredDelaysMs[] = {
428 0, 100, 200, 300, 400, 600, 800, 1000}; 429 0, 100, 200, 300, 400, 600, 800, 1000};
429 const int kNumPackets = ARRAY_SIZE(kMedianFilteredDelaysMs); 430 const int kNumPackets = arraysize(kMedianFilteredDelaysMs);
430 const float kAlpha = 0.1f; // Used for exponential smoothing. 431 const float kAlpha = 0.1f; // Used for exponential smoothing.
431 432
432 int64_t exp_smoothed_delays_ms[kNumPackets]; 433 int64_t exp_smoothed_delays_ms[kNumPackets];
433 exp_smoothed_delays_ms[0] = kMedianFilteredDelaysMs[0]; 434 exp_smoothed_delays_ms[0] = kMedianFilteredDelaysMs[0];
434 435
435 for (int i = 1; i < kNumPackets; ++i) { 436 for (int i = 1; i < kNumPackets; ++i) {
436 exp_smoothed_delays_ms[i] = static_cast<int64_t>( 437 exp_smoothed_delays_ms[i] = static_cast<int64_t>(
437 kAlpha * kMedianFilteredDelaysMs[i] + 438 kAlpha * kMedianFilteredDelaysMs[i] +
438 (1.0f - kAlpha) * exp_smoothed_delays_ms[i - 1] + 0.5f); 439 (1.0f - kAlpha) * exp_smoothed_delays_ms[i - 1] + 0.5f);
439 } 440 }
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
473 TEST_F(FilterTest, ExponentialSmoothingConstantArray) { 474 TEST_F(FilterTest, ExponentialSmoothingConstantArray) {
474 int64_t exp_smoothed[kNumElements]; 475 int64_t exp_smoothed[kNumElements];
475 ExponentialSmoothingConstantArray(exp_smoothed); 476 ExponentialSmoothingConstantArray(exp_smoothed);
476 for (int i = 0; i < kNumElements; ++i) { 477 for (int i = 0; i < kNumElements; ++i) {
477 EXPECT_EQ(exp_smoothed[i], kSignalValue); 478 EXPECT_EQ(exp_smoothed[i], kSignalValue);
478 } 479 }
479 } 480 }
480 481
481 TEST_F(FilterTest, ExponentialSmoothingInitialPertubation) { 482 TEST_F(FilterTest, ExponentialSmoothingInitialPertubation) {
482 const int64_t kSignal[] = {90000, 0, 0, 0, 0, 0}; 483 const int64_t kSignal[] = {90000, 0, 0, 0, 0, 0};
483 const int kNumElements = ARRAY_SIZE(kSignal); 484 const int kNumElements = arraysize(kSignal);
484 int64_t exp_smoothed[kNumElements]; 485 int64_t exp_smoothed[kNumElements];
485 ExponentialSmoothingFilter(kSignal, kNumElements, exp_smoothed); 486 ExponentialSmoothingFilter(kSignal, kNumElements, exp_smoothed);
486 for (int i = 1; i < kNumElements; ++i) { 487 for (int i = 1; i < kNumElements; ++i) {
487 EXPECT_EQ( 488 EXPECT_EQ(
488 exp_smoothed[i], 489 exp_smoothed[i],
489 static_cast<int64_t>(exp_smoothed[i - 1] * (1.0f - kAlpha) + 0.5f)); 490 static_cast<int64_t>(exp_smoothed[i - 1] * (1.0f - kAlpha) + 0.5f));
490 } 491 }
491 } 492 }
492 493
493 } // namespace bwe 494 } // namespace bwe
494 } // namespace testing 495 } // namespace testing
495 } // namespace webrtc 496 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698