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

Side by Side Diff: webrtc/modules/congestion_controller/median_slope_estimator.h

Issue 2572353003: Revert of Avoid precision loss in MedianSlopeEstimator from int64_t -> double conversion (Closed)
Patch Set: Created 4 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
« no previous file with comments | « no previous file | webrtc/modules/congestion_controller/median_slope_estimator.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2016 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 #ifndef WEBRTC_MODULES_CONGESTION_CONTROLLER_MEDIAN_SLOPE_ESTIMATOR_H_ 10 #ifndef WEBRTC_MODULES_CONGESTION_CONTROLLER_MEDIAN_SLOPE_ESTIMATOR_H_
11 #define WEBRTC_MODULES_CONGESTION_CONTROLLER_MEDIAN_SLOPE_ESTIMATOR_H_ 11 #define WEBRTC_MODULES_CONGESTION_CONTROLLER_MEDIAN_SLOPE_ESTIMATOR_H_
12 12
13 #include <stddef.h>
14 #include <stdint.h>
15
16 #include <list> 13 #include <list>
14 #include <utility>
17 #include <vector> 15 #include <vector>
18 16
19 #include "webrtc/base/analytics/percentile_filter.h" 17 #include "webrtc/base/analytics/percentile_filter.h"
20 #include "webrtc/base/constructormagic.h" 18 #include "webrtc/base/constructormagic.h"
19 #include "webrtc/common_types.h"
21 20
22 namespace webrtc { 21 namespace webrtc {
23 22
24 class MedianSlopeEstimator { 23 class MedianSlopeEstimator {
25 public: 24 public:
26 // |window_size| is the number of points required to compute a trend line. 25 // |window_size| is the number of points required to compute a trend line.
27 // |threshold_gain| is used to scale the trendline slope for comparison to 26 // |threshold_gain| is used to scale the trendline slope for comparison to
28 // the old threshold. Once the old estimator has been removed (or the 27 // the old threshold. Once the old estimator has been removed (or the
29 // thresholds been merged into the estimators), we can just set the 28 // thresholds been merged into the estimators), we can just set the
30 // threshold instead of setting a gain. 29 // threshold instead of setting a gain.
31 MedianSlopeEstimator(size_t window_size, double threshold_gain); 30 MedianSlopeEstimator(size_t window_size, double threshold_gain);
32 ~MedianSlopeEstimator(); 31 ~MedianSlopeEstimator();
33 32
34 // Update the estimator with a new sample. The deltas should represent deltas 33 // Update the estimator with a new sample. The deltas should represent deltas
35 // between timestamp groups as defined by the InterArrival class. 34 // between timestamp groups as defined by the InterArrival class.
36 void Update(double recv_delta_ms, 35 void Update(double recv_delta_ms, double send_delta_ms, double now_ms);
37 double send_delta_ms,
38 int64_t arrival_time_ms);
39 36
40 // Returns the estimated trend k multiplied by some gain. 37 // Returns the estimated trend k multiplied by some gain.
41 // 0 < k < 1 -> the delay increases, queues are filling up 38 // 0 < k < 1 -> the delay increases, queues are filling up
42 // k == 0 -> the delay does not change 39 // k == 0 -> the delay does not change
43 // k < 0 -> the delay decreases, queues are being emptied 40 // k < 0 -> the delay decreases, queues are being emptied
44 double trendline_slope() const { return trendline_ * threshold_gain_; } 41 double trendline_slope() const { return trendline_ * threshold_gain_; }
45 42
46 // Returns the number of deltas which the current estimator state is based on. 43 // Returns the number of deltas which the current estimator state is based on.
47 unsigned int num_of_deltas() const { return num_of_deltas_; } 44 unsigned int num_of_deltas() const { return num_of_deltas_; }
48 45
49 private: 46 private:
50 struct DelayInfo { 47 struct DelayInfo {
51 DelayInfo(int64_t time, double delay, size_t slope_count) 48 DelayInfo(double time, double delay, size_t slope_count)
52 : time(time), delay(delay) { 49 : time(time), delay(delay) {
53 slopes.reserve(slope_count); 50 slopes.reserve(slope_count);
54 } 51 }
55 int64_t time; 52 double time;
56 double delay; 53 double delay;
57 std::vector<double> slopes; 54 std::vector<double> slopes;
58 }; 55 };
59 // Parameters. 56 // Parameters.
60 const size_t window_size_; 57 const size_t window_size_;
61 const double threshold_gain_; 58 const double threshold_gain_;
62 // Used by the existing threshold. 59 // Used by the existing threshold.
63 unsigned int num_of_deltas_; 60 unsigned int num_of_deltas_;
64 // Theil-Sen robust line fitting 61 // Theil-Sen robust line fitting
65 double accumulated_delay_; 62 double accumulated_delay_;
66 std::list<DelayInfo> delay_hist_; 63 std::list<DelayInfo> delay_hist_;
67 PercentileFilter<double> median_filter_; 64 PercentileFilter<double> median_filter_;
68 double trendline_; 65 double trendline_;
69 66
70 RTC_DISALLOW_COPY_AND_ASSIGN(MedianSlopeEstimator); 67 RTC_DISALLOW_COPY_AND_ASSIGN(MedianSlopeEstimator);
71 }; 68 };
72 } // namespace webrtc 69 } // namespace webrtc
73 70
74 #endif // WEBRTC_MODULES_CONGESTION_CONTROLLER_MEDIAN_SLOPE_ESTIMATOR_H_ 71 #endif // WEBRTC_MODULES_CONGESTION_CONTROLLER_MEDIAN_SLOPE_ESTIMATOR_H_
OLDNEW
« no previous file with comments | « no previous file | webrtc/modules/congestion_controller/median_slope_estimator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698