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

Side by Side Diff: webrtc/modules/remote_bitrate_estimator/overuse_detector_unittest.cc

Issue 1457023002: Rewrote the PRNG using an xorshift* algorithm and moved the files from test/ to base/. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Rebase 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) 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2012 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 <math.h> 11 #include <math.h>
12 #include <cmath> 12 #include <cmath>
13 #include <cstdlib> 13 #include <cstdlib>
14 14
15 #include "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
16 16
17 #include "webrtc/base/random.h"
17 #include "webrtc/base/scoped_ptr.h" 18 #include "webrtc/base/scoped_ptr.h"
18 #include "webrtc/common_types.h" 19 #include "webrtc/common_types.h"
19 #include "webrtc/modules/remote_bitrate_estimator/inter_arrival.h" 20 #include "webrtc/modules/remote_bitrate_estimator/inter_arrival.h"
20 #include "webrtc/modules/remote_bitrate_estimator/overuse_detector.h" 21 #include "webrtc/modules/remote_bitrate_estimator/overuse_detector.h"
21 #include "webrtc/modules/remote_bitrate_estimator/overuse_estimator.h" 22 #include "webrtc/modules/remote_bitrate_estimator/overuse_estimator.h"
22 #include "webrtc/modules/remote_bitrate_estimator/rate_statistics.h" 23 #include "webrtc/modules/remote_bitrate_estimator/rate_statistics.h"
23 #include "webrtc/test/field_trial.h" 24 #include "webrtc/test/field_trial.h"
24 #include "webrtc/test/random.h"
25 #include "webrtc/test/testsupport/gtest_disable.h" 25 #include "webrtc/test/testsupport/gtest_disable.h"
26 26
27 namespace webrtc { 27 namespace webrtc {
28 namespace testing { 28 namespace testing {
29 29
30 const double kRtpTimestampToMs = 1.0 / 90.0; 30 const double kRtpTimestampToMs = 1.0 / 90.0;
31 31
32 class OveruseDetectorTest : public ::testing::Test { 32 class OveruseDetectorTest : public ::testing::Test {
33 public: 33 public:
34 OveruseDetectorTest() 34 OveruseDetectorTest()
35 : now_ms_(0), 35 : now_ms_(0),
36 receive_time_ms_(0), 36 receive_time_ms_(0),
37 rtp_timestamp_(10 * 90), 37 rtp_timestamp_(10 * 90),
38 overuse_detector_(), 38 overuse_detector_(),
39 overuse_estimator_(new OveruseEstimator(options_)), 39 overuse_estimator_(new OveruseEstimator(options_)),
40 inter_arrival_(new InterArrival(5 * 90, kRtpTimestampToMs, true)), 40 inter_arrival_(new InterArrival(5 * 90, kRtpTimestampToMs, true)),
41 random_(1234) {} 41 random_(123456789) {}
42 42
43 protected: 43 protected:
44 void SetUp() override { 44 void SetUp() override {
45 overuse_detector_.reset(new OveruseDetector(options_)); 45 overuse_detector_.reset(new OveruseDetector(options_));
46 } 46 }
47 47
48 int Run100000Samples(int packets_per_frame, size_t packet_size, int mean_ms, 48 int Run100000Samples(int packets_per_frame, size_t packet_size, int mean_ms,
49 int standard_deviation_ms) { 49 int standard_deviation_ms) {
50 int unique_overuse = 0; 50 int unique_overuse = 0;
51 int last_overuse = -1; 51 int last_overuse = -1;
52 for (int i = 0; i < 100000; ++i) { 52 for (int i = 0; i < 100000; ++i) {
53 for (int j = 0; j < packets_per_frame; ++j) { 53 for (int j = 0; j < packets_per_frame; ++j) {
54 UpdateDetector(rtp_timestamp_, receive_time_ms_, packet_size); 54 UpdateDetector(rtp_timestamp_, receive_time_ms_, packet_size);
55 } 55 }
56 rtp_timestamp_ += mean_ms * 90; 56 rtp_timestamp_ += mean_ms * 90;
57 now_ms_ += mean_ms; 57 now_ms_ += mean_ms;
58 receive_time_ms_ = 58 receive_time_ms_ = std::max<int64_t>(
59 std::max(receive_time_ms_, 59 receive_time_ms_,
60 now_ms_ + random_.Gaussian(0, standard_deviation_ms)); 60 now_ms_ + static_cast<int64_t>(
61 random_.Gaussian(0, standard_deviation_ms) + 0.5));
61 if (kBwOverusing == overuse_detector_->State()) { 62 if (kBwOverusing == overuse_detector_->State()) {
62 if (last_overuse + 1 != i) { 63 if (last_overuse + 1 != i) {
63 unique_overuse++; 64 unique_overuse++;
64 } 65 }
65 last_overuse = i; 66 last_overuse = i;
66 } 67 }
67 } 68 }
68 return unique_overuse; 69 return unique_overuse;
69 } 70 }
70 71
71 int RunUntilOveruse(int packets_per_frame, size_t packet_size, int mean_ms, 72 int RunUntilOveruse(int packets_per_frame, size_t packet_size, int mean_ms,
72 int standard_deviation_ms, int drift_per_frame_ms) { 73 int standard_deviation_ms, int drift_per_frame_ms) {
73 // Simulate a higher send pace, that is too high. 74 // Simulate a higher send pace, that is too high.
74 for (int i = 0; i < 1000; ++i) { 75 for (int i = 0; i < 1000; ++i) {
75 for (int j = 0; j < packets_per_frame; ++j) { 76 for (int j = 0; j < packets_per_frame; ++j) {
76 UpdateDetector(rtp_timestamp_, receive_time_ms_, packet_size); 77 UpdateDetector(rtp_timestamp_, receive_time_ms_, packet_size);
77 } 78 }
78 rtp_timestamp_ += mean_ms * 90; 79 rtp_timestamp_ += mean_ms * 90;
79 now_ms_ += mean_ms + drift_per_frame_ms; 80 now_ms_ += mean_ms + drift_per_frame_ms;
80 receive_time_ms_ = 81 receive_time_ms_ = std::max<int64_t>(
81 std::max(receive_time_ms_, 82 receive_time_ms_,
82 now_ms_ + random_.Gaussian(0, standard_deviation_ms)); 83 now_ms_ + static_cast<int64_t>(
84 random_.Gaussian(0, standard_deviation_ms) + 0.5));
83 if (kBwOverusing == overuse_detector_->State()) { 85 if (kBwOverusing == overuse_detector_->State()) {
84 return i + 1; 86 return i + 1;
85 } 87 }
86 } 88 }
87 return -1; 89 return -1;
88 } 90 }
89 91
90 void UpdateDetector(uint32_t rtp_timestamp, int64_t receive_time_ms, 92 void UpdateDetector(uint32_t rtp_timestamp, int64_t receive_time_ms,
91 size_t packet_size) { 93 size_t packet_size) {
92 uint32_t timestamp_delta; 94 uint32_t timestamp_delta;
(...skipping 14 matching lines...) Expand all
107 } 109 }
108 } 110 }
109 111
110 int64_t now_ms_; 112 int64_t now_ms_;
111 int64_t receive_time_ms_; 113 int64_t receive_time_ms_;
112 uint32_t rtp_timestamp_; 114 uint32_t rtp_timestamp_;
113 OverUseDetectorOptions options_; 115 OverUseDetectorOptions options_;
114 rtc::scoped_ptr<OveruseDetector> overuse_detector_; 116 rtc::scoped_ptr<OveruseDetector> overuse_detector_;
115 rtc::scoped_ptr<OveruseEstimator> overuse_estimator_; 117 rtc::scoped_ptr<OveruseEstimator> overuse_estimator_;
116 rtc::scoped_ptr<InterArrival> inter_arrival_; 118 rtc::scoped_ptr<InterArrival> inter_arrival_;
117 test::Random random_; 119 Random random_;
118 }; 120 };
119 121
120 TEST_F(OveruseDetectorTest, GaussianRandom) { 122 TEST_F(OveruseDetectorTest, GaussianRandom) {
121 int buckets[100]; 123 int buckets[100];
122 memset(buckets, 0, sizeof(buckets)); 124 memset(buckets, 0, sizeof(buckets));
123 for (int i = 0; i < 100000; ++i) { 125 for (int i = 0; i < 100000; ++i) {
124 int index = random_.Gaussian(49, 10); 126 int index = random_.Gaussian(49, 10);
125 if (index >= 0 && index < 100) 127 if (index >= 0 && index < 100)
126 buckets[index]++; 128 buckets[index]++;
127 } 129 }
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 uint32_t drift_per_frame_ms = 10; 217 uint32_t drift_per_frame_ms = 10;
216 uint32_t rtp_timestamp = frame_duration_ms * 90; 218 uint32_t rtp_timestamp = frame_duration_ms * 90;
217 size_t packet_size = 1200; 219 size_t packet_size = 1200;
218 int offset = 10; 220 int offset = 10;
219 221
220 // Run 1000 samples to reach steady state. 222 // Run 1000 samples to reach steady state.
221 for (int i = 0; i < 1000; ++i) { 223 for (int i = 0; i < 1000; ++i) {
222 UpdateDetector(rtp_timestamp, now_ms_, packet_size); 224 UpdateDetector(rtp_timestamp, now_ms_, packet_size);
223 rtp_timestamp += frame_duration_ms * 90; 225 rtp_timestamp += frame_duration_ms * 90;
224 if (i % 2) { 226 if (i % 2) {
225 offset = rand() % 50; 227 offset = random_.Rand(0, 49);
226 now_ms_ += frame_duration_ms - offset; 228 now_ms_ += frame_duration_ms - offset;
227 } else { 229 } else {
228 now_ms_ += frame_duration_ms + offset; 230 now_ms_ += frame_duration_ms + offset;
229 } 231 }
230 EXPECT_EQ(kBwNormal, overuse_detector_->State()); 232 EXPECT_EQ(kBwNormal, overuse_detector_->State());
231 } 233 }
232 // Simulate a higher send pace, that is too high. 234 // Simulate a higher send pace, that is too high.
233 // Above noise generate a standard deviation of approximately 28 ms. 235 // Above noise generate a standard deviation of approximately 28 ms.
234 // Total build up of 150 ms. 236 // Total build up of 150 ms.
235 for (int j = 0; j < 15; ++j) { 237 for (int j = 0; j < 15; ++j) {
(...skipping 11 matching lines...) Expand all
247 uint32_t drift_per_frame_ms = 1; 249 uint32_t drift_per_frame_ms = 1;
248 uint32_t rtp_timestamp = frame_duration_ms * 90; 250 uint32_t rtp_timestamp = frame_duration_ms * 90;
249 size_t packet_size = 1200; 251 size_t packet_size = 1200;
250 int offset = 10; 252 int offset = 10;
251 253
252 // Run 1000 samples to reach steady state. 254 // Run 1000 samples to reach steady state.
253 for (int i = 0; i < 1000; ++i) { 255 for (int i = 0; i < 1000; ++i) {
254 UpdateDetector(rtp_timestamp, now_ms_, packet_size); 256 UpdateDetector(rtp_timestamp, now_ms_, packet_size);
255 rtp_timestamp += frame_duration_ms * 90; 257 rtp_timestamp += frame_duration_ms * 90;
256 if (i % 2) { 258 if (i % 2) {
257 offset = rand() % 2; 259 offset = random_.Rand(0, 1);
258 now_ms_ += frame_duration_ms - offset; 260 now_ms_ += frame_duration_ms - offset;
259 } else { 261 } else {
260 now_ms_ += frame_duration_ms + offset; 262 now_ms_ += frame_duration_ms + offset;
261 } 263 }
262 EXPECT_EQ(kBwNormal, overuse_detector_->State()); 264 EXPECT_EQ(kBwNormal, overuse_detector_->State());
263 } 265 }
264 // Simulate a higher send pace, that is too high. 266 // Simulate a higher send pace, that is too high.
265 // Total build up of 6 ms. 267 // Total build up of 6 ms.
266 for (int j = 0; j < 6; ++j) { 268 for (int j = 0; j < 6; ++j) {
267 UpdateDetector(rtp_timestamp, now_ms_, packet_size); 269 UpdateDetector(rtp_timestamp, now_ms_, packet_size);
(...skipping 15 matching lines...) Expand all
283 // Run 1000 samples to reach steady state. 285 // Run 1000 samples to reach steady state.
284 for (int i = 0; i < 1000; ++i) { 286 for (int i = 0; i < 1000; ++i) {
285 UpdateDetector(rtp_timestamp, now_ms_, packet_size); 287 UpdateDetector(rtp_timestamp, now_ms_, packet_size);
286 UpdateDetector(rtp_timestamp, now_ms_, packet_size); 288 UpdateDetector(rtp_timestamp, now_ms_, packet_size);
287 UpdateDetector(rtp_timestamp, now_ms_, packet_size); 289 UpdateDetector(rtp_timestamp, now_ms_, packet_size);
288 UpdateDetector(rtp_timestamp, now_ms_, packet_size); 290 UpdateDetector(rtp_timestamp, now_ms_, packet_size);
289 UpdateDetector(rtp_timestamp, now_ms_, packet_size); 291 UpdateDetector(rtp_timestamp, now_ms_, packet_size);
290 UpdateDetector(rtp_timestamp, now_ms_, packet_size); 292 UpdateDetector(rtp_timestamp, now_ms_, packet_size);
291 rtp_timestamp += frame_duration_ms * 90; 293 rtp_timestamp += frame_duration_ms * 90;
292 if (i % 2) { 294 if (i % 2) {
293 offset = rand() % 2; 295 offset = random_.Rand(0, 1);
294 now_ms_ += frame_duration_ms - offset; 296 now_ms_ += frame_duration_ms - offset;
295 } else { 297 } else {
296 now_ms_ += frame_duration_ms + offset; 298 now_ms_ += frame_duration_ms + offset;
297 } 299 }
298 EXPECT_EQ(kBwNormal, overuse_detector_->State()); 300 EXPECT_EQ(kBwNormal, overuse_detector_->State());
299 } 301 }
300 // Simulate a higher send pace, that is too high. 302 // Simulate a higher send pace, that is too high.
301 // Total build up of 30 ms. 303 // Total build up of 30 ms.
302 for (int j = 0; j < 5; ++j) { 304 for (int j = 0; j < 5; ++j) {
303 UpdateDetector(rtp_timestamp, now_ms_, packet_size); 305 UpdateDetector(rtp_timestamp, now_ms_, packet_size);
(...skipping 12 matching lines...) Expand all
316 318
317 TEST_F(OveruseDetectorTest, 319 TEST_F(OveruseDetectorTest,
318 DISABLED_ON_ANDROID(LowGaussianVariance30Kbit3fps)) { 320 DISABLED_ON_ANDROID(LowGaussianVariance30Kbit3fps)) {
319 size_t packet_size = 1200; 321 size_t packet_size = 1200;
320 int packets_per_frame = 1; 322 int packets_per_frame = 1;
321 int frame_duration_ms = 333; 323 int frame_duration_ms = 333;
322 int drift_per_frame_ms = 1; 324 int drift_per_frame_ms = 1;
323 int sigma_ms = 3; 325 int sigma_ms = 3;
324 int unique_overuse = Run100000Samples(packets_per_frame, packet_size, 326 int unique_overuse = Run100000Samples(packets_per_frame, packet_size,
325 frame_duration_ms, sigma_ms); 327 frame_duration_ms, sigma_ms);
326 EXPECT_EQ(13, unique_overuse); 328 EXPECT_EQ(1, unique_overuse);
327 int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size, 329 int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size,
328 frame_duration_ms, sigma_ms, drift_per_frame_ms); 330 frame_duration_ms, sigma_ms, drift_per_frame_ms);
329 EXPECT_EQ(14, frames_until_overuse); 331 EXPECT_EQ(13, frames_until_overuse);
330 } 332 }
331 333
332 TEST_F(OveruseDetectorTest, LowGaussianVarianceFastDrift30Kbit3fps) { 334 TEST_F(OveruseDetectorTest, LowGaussianVarianceFastDrift30Kbit3fps) {
333 size_t packet_size = 1200; 335 size_t packet_size = 1200;
334 int packets_per_frame = 1; 336 int packets_per_frame = 1;
335 int frame_duration_ms = 333; 337 int frame_duration_ms = 333;
336 int drift_per_frame_ms = 100; 338 int drift_per_frame_ms = 100;
337 int sigma_ms = 3; 339 int sigma_ms = 3;
338 int unique_overuse = Run100000Samples(packets_per_frame, packet_size, 340 int unique_overuse = Run100000Samples(packets_per_frame, packet_size,
339 frame_duration_ms, sigma_ms); 341 frame_duration_ms, sigma_ms);
340 EXPECT_EQ(13, unique_overuse); 342 EXPECT_EQ(1, unique_overuse);
341 int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size, 343 int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size,
342 frame_duration_ms, sigma_ms, drift_per_frame_ms); 344 frame_duration_ms, sigma_ms, drift_per_frame_ms);
343 EXPECT_EQ(4, frames_until_overuse); 345 EXPECT_EQ(4, frames_until_overuse);
344 } 346 }
345 347
346 TEST_F(OveruseDetectorTest, HighGaussianVariance30Kbit3fps) { 348 TEST_F(OveruseDetectorTest, HighGaussianVariance30Kbit3fps) {
347 size_t packet_size = 1200; 349 size_t packet_size = 1200;
348 int packets_per_frame = 1; 350 int packets_per_frame = 1;
349 int frame_duration_ms = 333; 351 int frame_duration_ms = 333;
350 int drift_per_frame_ms = 1; 352 int drift_per_frame_ms = 1;
351 int sigma_ms = 10; 353 int sigma_ms = 10;
352 int unique_overuse = Run100000Samples(packets_per_frame, packet_size, 354 int unique_overuse = Run100000Samples(packets_per_frame, packet_size,
353 frame_duration_ms, sigma_ms); 355 frame_duration_ms, sigma_ms);
354 EXPECT_EQ(46, unique_overuse); 356 EXPECT_EQ(1, unique_overuse);
355 int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size, 357 int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size,
356 frame_duration_ms, sigma_ms, drift_per_frame_ms); 358 frame_duration_ms, sigma_ms, drift_per_frame_ms);
357 EXPECT_EQ(42, frames_until_overuse); 359 EXPECT_EQ(32, frames_until_overuse);
358 } 360 }
359 361
360 TEST_F(OveruseDetectorTest, HighGaussianVarianceFastDrift30Kbit3fps) { 362 TEST_F(OveruseDetectorTest, HighGaussianVarianceFastDrift30Kbit3fps) {
361 size_t packet_size = 1200; 363 size_t packet_size = 1200;
362 int packets_per_frame = 1; 364 int packets_per_frame = 1;
363 int frame_duration_ms = 333; 365 int frame_duration_ms = 333;
364 int drift_per_frame_ms = 100; 366 int drift_per_frame_ms = 100;
365 int sigma_ms = 10; 367 int sigma_ms = 10;
366 int unique_overuse = Run100000Samples(packets_per_frame, packet_size, 368 int unique_overuse = Run100000Samples(packets_per_frame, packet_size,
367 frame_duration_ms, sigma_ms); 369 frame_duration_ms, sigma_ms);
368 EXPECT_EQ(46, unique_overuse); 370 EXPECT_EQ(1, unique_overuse);
369 int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size, 371 int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size,
370 frame_duration_ms, sigma_ms, drift_per_frame_ms); 372 frame_duration_ms, sigma_ms, drift_per_frame_ms);
371 EXPECT_EQ(4, frames_until_overuse); 373 EXPECT_EQ(4, frames_until_overuse);
372 } 374 }
373 375
374 TEST_F(OveruseDetectorTest, 376 TEST_F(OveruseDetectorTest,
375 DISABLED_ON_ANDROID(LowGaussianVariance100Kbit5fps)) { 377 DISABLED_ON_ANDROID(LowGaussianVariance100Kbit5fps)) {
376 size_t packet_size = 1200; 378 size_t packet_size = 1200;
377 int packets_per_frame = 2; 379 int packets_per_frame = 2;
378 int frame_duration_ms = 200; 380 int frame_duration_ms = 200;
379 int drift_per_frame_ms = 1; 381 int drift_per_frame_ms = 1;
380 int sigma_ms = 3; 382 int sigma_ms = 3;
381 int unique_overuse = Run100000Samples(packets_per_frame, packet_size, 383 int unique_overuse = Run100000Samples(packets_per_frame, packet_size,
382 frame_duration_ms, sigma_ms); 384 frame_duration_ms, sigma_ms);
383 EXPECT_EQ(12, unique_overuse); 385 EXPECT_EQ(0, unique_overuse);
384 int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size, 386 int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size,
385 frame_duration_ms, sigma_ms, drift_per_frame_ms); 387 frame_duration_ms, sigma_ms, drift_per_frame_ms);
386 EXPECT_EQ(12, frames_until_overuse); 388 EXPECT_EQ(13, frames_until_overuse);
387 } 389 }
388 390
389 TEST_F(OveruseDetectorTest, 391 TEST_F(OveruseDetectorTest,
390 DISABLED_ON_ANDROID(HighGaussianVariance100Kbit5fps)) { 392 DISABLED_ON_ANDROID(HighGaussianVariance100Kbit5fps)) {
391 size_t packet_size = 1200; 393 size_t packet_size = 1200;
392 int packets_per_frame = 2; 394 int packets_per_frame = 2;
393 int frame_duration_ms = 200; 395 int frame_duration_ms = 200;
394 int drift_per_frame_ms = 1; 396 int drift_per_frame_ms = 1;
395 int sigma_ms = 10; 397 int sigma_ms = 10;
396 int unique_overuse = Run100000Samples(packets_per_frame, packet_size, 398 int unique_overuse = Run100000Samples(packets_per_frame, packet_size,
397 frame_duration_ms, sigma_ms); 399 frame_duration_ms, sigma_ms);
398 EXPECT_EQ(16, unique_overuse); 400 EXPECT_EQ(1, unique_overuse);
399 int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size, 401 int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size,
400 frame_duration_ms, sigma_ms, drift_per_frame_ms); 402 frame_duration_ms, sigma_ms, drift_per_frame_ms);
401 EXPECT_EQ(37, frames_until_overuse); 403 EXPECT_EQ(32, frames_until_overuse);
402 } 404 }
403 405
404 TEST_F(OveruseDetectorTest, 406 TEST_F(OveruseDetectorTest,
405 DISABLED_ON_ANDROID(LowGaussianVariance100Kbit10fps)) { 407 DISABLED_ON_ANDROID(LowGaussianVariance100Kbit10fps)) {
406 size_t packet_size = 1200; 408 size_t packet_size = 1200;
407 int packets_per_frame = 1; 409 int packets_per_frame = 1;
408 int frame_duration_ms = 100; 410 int frame_duration_ms = 100;
409 int drift_per_frame_ms = 1; 411 int drift_per_frame_ms = 1;
410 int sigma_ms = 3; 412 int sigma_ms = 3;
411 int unique_overuse = Run100000Samples(packets_per_frame, packet_size, 413 int unique_overuse = Run100000Samples(packets_per_frame, packet_size,
412 frame_duration_ms, sigma_ms); 414 frame_duration_ms, sigma_ms);
413 EXPECT_EQ(12, unique_overuse); 415 EXPECT_EQ(1, unique_overuse);
414 int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size, 416 int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size,
415 frame_duration_ms, sigma_ms, drift_per_frame_ms); 417 frame_duration_ms, sigma_ms, drift_per_frame_ms);
416 EXPECT_EQ(12, frames_until_overuse); 418 EXPECT_EQ(13, frames_until_overuse);
417 } 419 }
418 420
419 TEST_F(OveruseDetectorTest, 421 TEST_F(OveruseDetectorTest,
420 DISABLED_ON_ANDROID(HighGaussianVariance100Kbit10fps)) { 422 DISABLED_ON_ANDROID(HighGaussianVariance100Kbit10fps)) {
421 size_t packet_size = 1200; 423 size_t packet_size = 1200;
422 int packets_per_frame = 1; 424 int packets_per_frame = 1;
423 int frame_duration_ms = 100; 425 int frame_duration_ms = 100;
424 int drift_per_frame_ms = 1; 426 int drift_per_frame_ms = 1;
425 int sigma_ms = 10; 427 int sigma_ms = 10;
426 int unique_overuse = Run100000Samples(packets_per_frame, packet_size, 428 int unique_overuse = Run100000Samples(packets_per_frame, packet_size,
427 frame_duration_ms, sigma_ms); 429 frame_duration_ms, sigma_ms);
428 EXPECT_EQ(12, unique_overuse); 430 EXPECT_EQ(0, unique_overuse);
429 int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size, 431 int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size,
430 frame_duration_ms, sigma_ms, drift_per_frame_ms); 432 frame_duration_ms, sigma_ms, drift_per_frame_ms);
431 EXPECT_EQ(37, frames_until_overuse); 433 EXPECT_EQ(32, frames_until_overuse);
432 } 434 }
433 435
434 TEST_F(OveruseDetectorTest, 436 TEST_F(OveruseDetectorTest,
435 DISABLED_ON_ANDROID(LowGaussianVariance300Kbit30fps)) { 437 DISABLED_ON_ANDROID(LowGaussianVariance300Kbit30fps)) {
436 size_t packet_size = 1200; 438 size_t packet_size = 1200;
437 int packets_per_frame = 1; 439 int packets_per_frame = 1;
438 int frame_duration_ms = 33; 440 int frame_duration_ms = 33;
439 int drift_per_frame_ms = 1; 441 int drift_per_frame_ms = 1;
440 int sigma_ms = 3; 442 int sigma_ms = 3;
441 int unique_overuse = Run100000Samples(packets_per_frame, packet_size, 443 int unique_overuse = Run100000Samples(packets_per_frame, packet_size,
442 frame_duration_ms, sigma_ms); 444 frame_duration_ms, sigma_ms);
443 EXPECT_EQ(0, unique_overuse); 445 EXPECT_EQ(0, unique_overuse);
444 int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size, 446 int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size,
445 frame_duration_ms, sigma_ms, drift_per_frame_ms); 447 frame_duration_ms, sigma_ms, drift_per_frame_ms);
446 EXPECT_EQ(14, frames_until_overuse); 448 EXPECT_EQ(15, frames_until_overuse);
447 } 449 }
448 450
449 TEST_F(OveruseDetectorTest, LowGaussianVarianceFastDrift300Kbit30fps) { 451 TEST_F(OveruseDetectorTest, LowGaussianVarianceFastDrift300Kbit30fps) {
450 size_t packet_size = 1200; 452 size_t packet_size = 1200;
451 int packets_per_frame = 1; 453 int packets_per_frame = 1;
452 int frame_duration_ms = 33; 454 int frame_duration_ms = 33;
453 int drift_per_frame_ms = 10; 455 int drift_per_frame_ms = 10;
454 int sigma_ms = 3; 456 int sigma_ms = 3;
455 int unique_overuse = Run100000Samples(packets_per_frame, packet_size, 457 int unique_overuse = Run100000Samples(packets_per_frame, packet_size,
456 frame_duration_ms, sigma_ms); 458 frame_duration_ms, sigma_ms);
457 EXPECT_EQ(0, unique_overuse); 459 EXPECT_EQ(0, unique_overuse);
458 int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size, 460 int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size,
459 frame_duration_ms, sigma_ms, drift_per_frame_ms); 461 frame_duration_ms, sigma_ms, drift_per_frame_ms);
460 EXPECT_EQ(6, frames_until_overuse); 462 EXPECT_EQ(6, frames_until_overuse);
461 } 463 }
462 464
463 TEST_F(OveruseDetectorTest, HighGaussianVariance300Kbit30fps) { 465 TEST_F(OveruseDetectorTest, HighGaussianVariance300Kbit30fps) {
464 size_t packet_size = 1200; 466 size_t packet_size = 1200;
465 int packets_per_frame = 1; 467 int packets_per_frame = 1;
466 int frame_duration_ms = 33; 468 int frame_duration_ms = 33;
467 int drift_per_frame_ms = 1; 469 int drift_per_frame_ms = 1;
468 int sigma_ms = 10; 470 int sigma_ms = 10;
469 int unique_overuse = Run100000Samples(packets_per_frame, packet_size, 471 int unique_overuse = Run100000Samples(packets_per_frame, packet_size,
470 frame_duration_ms, sigma_ms); 472 frame_duration_ms, sigma_ms);
471 EXPECT_EQ(0, unique_overuse); 473 EXPECT_EQ(0, unique_overuse);
472 int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size, 474 int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size,
473 frame_duration_ms, sigma_ms, drift_per_frame_ms); 475 frame_duration_ms, sigma_ms, drift_per_frame_ms);
474 EXPECT_EQ(49, frames_until_overuse); 476 EXPECT_EQ(41, frames_until_overuse);
475 } 477 }
476 478
477 TEST_F(OveruseDetectorTest, HighGaussianVarianceFastDrift300Kbit30fps) { 479 TEST_F(OveruseDetectorTest, HighGaussianVarianceFastDrift300Kbit30fps) {
478 size_t packet_size = 1200; 480 size_t packet_size = 1200;
479 int packets_per_frame = 1; 481 int packets_per_frame = 1;
480 int frame_duration_ms = 33; 482 int frame_duration_ms = 33;
481 int drift_per_frame_ms = 10; 483 int drift_per_frame_ms = 10;
482 int sigma_ms = 10; 484 int sigma_ms = 10;
483 int unique_overuse = Run100000Samples(packets_per_frame, packet_size, 485 int unique_overuse = Run100000Samples(packets_per_frame, packet_size,
484 frame_duration_ms, sigma_ms); 486 frame_duration_ms, sigma_ms);
485 EXPECT_EQ(0, unique_overuse); 487 EXPECT_EQ(0, unique_overuse);
486 int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size, 488 int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size,
487 frame_duration_ms, sigma_ms, drift_per_frame_ms); 489 frame_duration_ms, sigma_ms, drift_per_frame_ms);
488 EXPECT_EQ(8, frames_until_overuse); 490 EXPECT_EQ(10, frames_until_overuse);
489 } 491 }
490 492
491 TEST_F(OveruseDetectorTest, 493 TEST_F(OveruseDetectorTest,
492 DISABLED_ON_ANDROID(LowGaussianVariance1000Kbit30fps)) { 494 DISABLED_ON_ANDROID(LowGaussianVariance1000Kbit30fps)) {
493 size_t packet_size = 1200; 495 size_t packet_size = 1200;
494 int packets_per_frame = 3; 496 int packets_per_frame = 3;
495 int frame_duration_ms = 33; 497 int frame_duration_ms = 33;
496 int drift_per_frame_ms = 1; 498 int drift_per_frame_ms = 1;
497 int sigma_ms = 3; 499 int sigma_ms = 3;
498 int unique_overuse = Run100000Samples(packets_per_frame, packet_size, 500 int unique_overuse = Run100000Samples(packets_per_frame, packet_size,
499 frame_duration_ms, sigma_ms); 501 frame_duration_ms, sigma_ms);
500 EXPECT_EQ(0, unique_overuse); 502 EXPECT_EQ(0, unique_overuse);
501 int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size, 503 int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size,
502 frame_duration_ms, sigma_ms, drift_per_frame_ms); 504 frame_duration_ms, sigma_ms, drift_per_frame_ms);
503 EXPECT_EQ(14, frames_until_overuse); 505 EXPECT_EQ(15, frames_until_overuse);
504 } 506 }
505 507
506 TEST_F(OveruseDetectorTest, LowGaussianVarianceFastDrift1000Kbit30fps) { 508 TEST_F(OveruseDetectorTest, LowGaussianVarianceFastDrift1000Kbit30fps) {
507 size_t packet_size = 1200; 509 size_t packet_size = 1200;
508 int packets_per_frame = 3; 510 int packets_per_frame = 3;
509 int frame_duration_ms = 33; 511 int frame_duration_ms = 33;
510 int drift_per_frame_ms = 10; 512 int drift_per_frame_ms = 10;
511 int sigma_ms = 3; 513 int sigma_ms = 3;
512 int unique_overuse = Run100000Samples(packets_per_frame, packet_size, 514 int unique_overuse = Run100000Samples(packets_per_frame, packet_size,
513 frame_duration_ms, sigma_ms); 515 frame_duration_ms, sigma_ms);
514 EXPECT_EQ(0, unique_overuse); 516 EXPECT_EQ(0, unique_overuse);
515 int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size, 517 int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size,
516 frame_duration_ms, sigma_ms, drift_per_frame_ms); 518 frame_duration_ms, sigma_ms, drift_per_frame_ms);
517 EXPECT_EQ(6, frames_until_overuse); 519 EXPECT_EQ(6, frames_until_overuse);
518 } 520 }
519 521
520 TEST_F(OveruseDetectorTest, HighGaussianVariance1000Kbit30fps) { 522 TEST_F(OveruseDetectorTest, HighGaussianVariance1000Kbit30fps) {
521 size_t packet_size = 1200; 523 size_t packet_size = 1200;
522 int packets_per_frame = 3; 524 int packets_per_frame = 3;
523 int frame_duration_ms = 33; 525 int frame_duration_ms = 33;
524 int drift_per_frame_ms = 1; 526 int drift_per_frame_ms = 1;
525 int sigma_ms = 10; 527 int sigma_ms = 10;
526 int unique_overuse = Run100000Samples(packets_per_frame, packet_size, 528 int unique_overuse = Run100000Samples(packets_per_frame, packet_size,
527 frame_duration_ms, sigma_ms); 529 frame_duration_ms, sigma_ms);
528 EXPECT_EQ(0, unique_overuse); 530 EXPECT_EQ(0, unique_overuse);
529 int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size, 531 int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size,
530 frame_duration_ms, sigma_ms, drift_per_frame_ms); 532 frame_duration_ms, sigma_ms, drift_per_frame_ms);
531 EXPECT_EQ(49, frames_until_overuse); 533 EXPECT_EQ(41, frames_until_overuse);
532 } 534 }
533 535
534 TEST_F(OveruseDetectorTest, HighGaussianVarianceFastDrift1000Kbit30fps) { 536 TEST_F(OveruseDetectorTest, HighGaussianVarianceFastDrift1000Kbit30fps) {
535 size_t packet_size = 1200; 537 size_t packet_size = 1200;
536 int packets_per_frame = 3; 538 int packets_per_frame = 3;
537 int frame_duration_ms = 33; 539 int frame_duration_ms = 33;
538 int drift_per_frame_ms = 10; 540 int drift_per_frame_ms = 10;
539 int sigma_ms = 10; 541 int sigma_ms = 10;
540 int unique_overuse = Run100000Samples(packets_per_frame, packet_size, 542 int unique_overuse = Run100000Samples(packets_per_frame, packet_size,
541 frame_duration_ms, sigma_ms); 543 frame_duration_ms, sigma_ms);
542 EXPECT_EQ(0, unique_overuse); 544 EXPECT_EQ(0, unique_overuse);
543 int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size, 545 int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size,
544 frame_duration_ms, sigma_ms, drift_per_frame_ms); 546 frame_duration_ms, sigma_ms, drift_per_frame_ms);
545 EXPECT_EQ(8, frames_until_overuse); 547 EXPECT_EQ(10, frames_until_overuse);
546 } 548 }
547 549
548 TEST_F(OveruseDetectorTest, 550 TEST_F(OveruseDetectorTest,
549 DISABLED_ON_ANDROID(LowGaussianVariance2000Kbit30fps)) { 551 DISABLED_ON_ANDROID(LowGaussianVariance2000Kbit30fps)) {
550 size_t packet_size = 1200; 552 size_t packet_size = 1200;
551 int packets_per_frame = 6; 553 int packets_per_frame = 6;
552 int frame_duration_ms = 33; 554 int frame_duration_ms = 33;
553 int drift_per_frame_ms = 1; 555 int drift_per_frame_ms = 1;
554 int sigma_ms = 3; 556 int sigma_ms = 3;
555 int unique_overuse = Run100000Samples(packets_per_frame, packet_size, 557 int unique_overuse = Run100000Samples(packets_per_frame, packet_size,
556 frame_duration_ms, sigma_ms); 558 frame_duration_ms, sigma_ms);
557 EXPECT_EQ(0, unique_overuse); 559 EXPECT_EQ(0, unique_overuse);
558 int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size, 560 int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size,
559 frame_duration_ms, sigma_ms, drift_per_frame_ms); 561 frame_duration_ms, sigma_ms, drift_per_frame_ms);
560 EXPECT_EQ(14, frames_until_overuse); 562 EXPECT_EQ(15, frames_until_overuse);
561 } 563 }
562 564
563 TEST_F(OveruseDetectorTest, LowGaussianVarianceFastDrift2000Kbit30fps) { 565 TEST_F(OveruseDetectorTest, LowGaussianVarianceFastDrift2000Kbit30fps) {
564 size_t packet_size = 1200; 566 size_t packet_size = 1200;
565 int packets_per_frame = 6; 567 int packets_per_frame = 6;
566 int frame_duration_ms = 33; 568 int frame_duration_ms = 33;
567 int drift_per_frame_ms = 10; 569 int drift_per_frame_ms = 10;
568 int sigma_ms = 3; 570 int sigma_ms = 3;
569 int unique_overuse = Run100000Samples(packets_per_frame, packet_size, 571 int unique_overuse = Run100000Samples(packets_per_frame, packet_size,
570 frame_duration_ms, sigma_ms); 572 frame_duration_ms, sigma_ms);
571 EXPECT_EQ(0, unique_overuse); 573 EXPECT_EQ(0, unique_overuse);
572 int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size, 574 int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size,
573 frame_duration_ms, sigma_ms, drift_per_frame_ms); 575 frame_duration_ms, sigma_ms, drift_per_frame_ms);
574 EXPECT_EQ(6, frames_until_overuse); 576 EXPECT_EQ(6, frames_until_overuse);
575 } 577 }
576 578
577 TEST_F(OveruseDetectorTest, HighGaussianVariance2000Kbit30fps) { 579 TEST_F(OveruseDetectorTest, HighGaussianVariance2000Kbit30fps) {
578 size_t packet_size = 1200; 580 size_t packet_size = 1200;
579 int packets_per_frame = 6; 581 int packets_per_frame = 6;
580 int frame_duration_ms = 33; 582 int frame_duration_ms = 33;
581 int drift_per_frame_ms = 1; 583 int drift_per_frame_ms = 1;
582 int sigma_ms = 10; 584 int sigma_ms = 10;
583 int unique_overuse = Run100000Samples(packets_per_frame, packet_size, 585 int unique_overuse = Run100000Samples(packets_per_frame, packet_size,
584 frame_duration_ms, sigma_ms); 586 frame_duration_ms, sigma_ms);
585 EXPECT_EQ(0, unique_overuse); 587 EXPECT_EQ(0, unique_overuse);
586 int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size, 588 int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size,
587 frame_duration_ms, sigma_ms, drift_per_frame_ms); 589 frame_duration_ms, sigma_ms, drift_per_frame_ms);
588 EXPECT_EQ(49, frames_until_overuse); 590 EXPECT_EQ(41, frames_until_overuse);
589 } 591 }
590 592
591 TEST_F(OveruseDetectorTest, HighGaussianVarianceFastDrift2000Kbit30fps) { 593 TEST_F(OveruseDetectorTest, HighGaussianVarianceFastDrift2000Kbit30fps) {
592 size_t packet_size = 1200; 594 size_t packet_size = 1200;
593 int packets_per_frame = 6; 595 int packets_per_frame = 6;
594 int frame_duration_ms = 33; 596 int frame_duration_ms = 33;
595 int drift_per_frame_ms = 10; 597 int drift_per_frame_ms = 10;
596 int sigma_ms = 10; 598 int sigma_ms = 10;
597 int unique_overuse = Run100000Samples(packets_per_frame, packet_size, 599 int unique_overuse = Run100000Samples(packets_per_frame, packet_size,
598 frame_duration_ms, sigma_ms); 600 frame_duration_ms, sigma_ms);
599 EXPECT_EQ(0, unique_overuse); 601 EXPECT_EQ(0, unique_overuse);
600 int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size, 602 int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size,
601 frame_duration_ms, sigma_ms, drift_per_frame_ms); 603 frame_duration_ms, sigma_ms, drift_per_frame_ms);
602 EXPECT_EQ(8, frames_until_overuse); 604 EXPECT_EQ(10, frames_until_overuse);
603 } 605 }
604 606
605 class OveruseDetectorExperimentTest : public OveruseDetectorTest { 607 class OveruseDetectorExperimentTest : public OveruseDetectorTest {
606 public: 608 public:
607 OveruseDetectorExperimentTest() 609 OveruseDetectorExperimentTest()
608 : override_field_trials_( 610 : override_field_trials_(
609 "WebRTC-AdaptiveBweThreshold/Enabled-0.01,0.00018/") {} 611 "WebRTC-AdaptiveBweThreshold/Enabled-0.01,0.00018/") {}
610 612
611 protected: 613 protected:
612 void SetUp() override { 614 void SetUp() override {
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
731 if (overuse_state == kBwOverusing) { 733 if (overuse_state == kBwOverusing) {
732 overuse_detected = true; 734 overuse_detected = true;
733 } 735 }
734 ++num_deltas; 736 ++num_deltas;
735 now_ms += 5; 737 now_ms += 5;
736 } 738 }
737 EXPECT_TRUE(overuse_detected); 739 EXPECT_TRUE(overuse_detected);
738 } 740 }
739 } // namespace testing 741 } // namespace testing
740 } // namespace webrtc 742 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/remote_bitrate_estimator/bwe_simulations.cc ('k') | webrtc/modules/remote_bitrate_estimator/test/bwe_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698