OLD | NEW |
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 #include "webrtc/modules/remote_bitrate_estimator/rate_statistics.h" | 11 #include "webrtc/base/rate_statistics.h" |
12 | 12 |
13 #include <assert.h> | 13 #include <assert.h> |
14 | 14 |
15 namespace webrtc { | 15 namespace webrtc { |
16 | 16 |
17 RateStatistics::RateStatistics(uint32_t window_size_ms, float scale) | 17 RateStatistics::RateStatistics(uint32_t window_size_ms, float scale) |
18 : num_buckets_(window_size_ms + 1), // N ms in (N+1) buckets. | 18 : num_buckets_(window_size_ms + 1), // N ms in (N+1) buckets. |
19 buckets_(new size_t[num_buckets_]()), | 19 buckets_(new size_t[num_buckets_]()), |
20 accumulated_count_(0), | 20 accumulated_count_(0), |
21 oldest_time_(0), | 21 oldest_time_(0), |
22 oldest_index_(0), | 22 oldest_index_(0), |
23 scale_(scale / (num_buckets_ - 1)) { | 23 scale_(scale / (num_buckets_ - 1)) {} |
24 } | |
25 | 24 |
26 RateStatistics::~RateStatistics() { | 25 RateStatistics::~RateStatistics() {} |
27 } | |
28 | 26 |
29 void RateStatistics::Reset() { | 27 void RateStatistics::Reset() { |
30 accumulated_count_ = 0; | 28 accumulated_count_ = 0; |
31 oldest_time_ = 0; | 29 oldest_time_ = 0; |
32 oldest_index_ = 0; | 30 oldest_index_ = 0; |
33 for (int i = 0; i < num_buckets_; i++) { | 31 for (int i = 0; i < num_buckets_; i++) { |
34 buckets_[i] = 0; | 32 buckets_[i] = 0; |
35 } | 33 } |
36 } | 34 } |
37 | 35 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 if (accumulated_count_ == 0) { | 74 if (accumulated_count_ == 0) { |
77 // This guarantees we go through all the buckets at most once, even if | 75 // This guarantees we go through all the buckets at most once, even if |
78 // |new_oldest_time| is far greater than |oldest_time_|. | 76 // |new_oldest_time| is far greater than |oldest_time_|. |
79 break; | 77 break; |
80 } | 78 } |
81 } | 79 } |
82 oldest_time_ = new_oldest_time; | 80 oldest_time_ = new_oldest_time; |
83 } | 81 } |
84 | 82 |
85 } // namespace webrtc | 83 } // namespace webrtc |
OLD | NEW |