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 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 | 58 |
59 ++num_of_deltas_; | 59 ++num_of_deltas_; |
60 if (num_of_deltas_ > kDeltaCounterMax) { | 60 if (num_of_deltas_ > kDeltaCounterMax) { |
61 num_of_deltas_ = kDeltaCounterMax; | 61 num_of_deltas_ = kDeltaCounterMax; |
62 } | 62 } |
63 | 63 |
64 // Update the Kalman filter. | 64 // Update the Kalman filter. |
65 E_[0][0] += process_noise_[0]; | 65 E_[0][0] += process_noise_[0]; |
66 E_[1][1] += process_noise_[1]; | 66 E_[1][1] += process_noise_[1]; |
67 | 67 |
68 if ((current_hypothesis == kBwOverusing && offset_ < prev_offset_) || | 68 if ((current_hypothesis == BandwidthUsage::kBwOverusing && |
69 (current_hypothesis == kBwUnderusing && offset_ > prev_offset_)) { | 69 offset_ < prev_offset_) || |
| 70 (current_hypothesis == BandwidthUsage::kBwUnderusing && |
| 71 offset_ > prev_offset_)) { |
70 E_[1][1] += 10 * process_noise_[1]; | 72 E_[1][1] += 10 * process_noise_[1]; |
71 } | 73 } |
72 | 74 |
73 const double h[2] = {fs_delta, 1.0}; | 75 const double h[2] = {fs_delta, 1.0}; |
74 const double Eh[2] = {E_[0][0]*h[0] + E_[0][1]*h[1], | 76 const double Eh[2] = {E_[0][0]*h[0] + E_[0][1]*h[1], |
75 E_[1][0]*h[0] + E_[1][1]*h[1]}; | 77 E_[1][0]*h[0] + E_[1][1]*h[1]}; |
76 | 78 |
77 BWE_TEST_LOGGING_PLOT(1, "d_ms", now_ms, slope_ * h[0] - offset_); | 79 BWE_TEST_LOGGING_PLOT(1, "d_ms", now_ms, slope_ * h[0] - offset_); |
78 | 80 |
79 const double residual = t_ts_delta - slope_*h[0] - offset_; | 81 const double residual = t_ts_delta - slope_*h[0] - offset_; |
80 | 82 |
81 const bool in_stable_state = (current_hypothesis == kBwNormal); | 83 const bool in_stable_state = |
| 84 (current_hypothesis == BandwidthUsage::kBwNormal); |
82 const double max_residual = 3.0 * sqrt(var_noise_); | 85 const double max_residual = 3.0 * sqrt(var_noise_); |
83 // We try to filter out very late frames. For instance periodic key | 86 // We try to filter out very late frames. For instance periodic key |
84 // frames doesn't fit the Gaussian model well. | 87 // frames doesn't fit the Gaussian model well. |
85 if (fabs(residual) < max_residual) { | 88 if (fabs(residual) < max_residual) { |
86 UpdateNoiseEstimate(residual, min_frame_period, in_stable_state); | 89 UpdateNoiseEstimate(residual, min_frame_period, in_stable_state); |
87 } else { | 90 } else { |
88 UpdateNoiseEstimate(residual < 0 ? -max_residual : max_residual, | 91 UpdateNoiseEstimate(residual < 0 ? -max_residual : max_residual, |
89 min_frame_period, in_stable_state); | 92 min_frame_period, in_stable_state); |
90 } | 93 } |
91 | 94 |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 const double beta = pow(1 - alpha, ts_delta * 30.0 / 1000.0); | 157 const double beta = pow(1 - alpha, ts_delta * 30.0 / 1000.0); |
155 avg_noise_ = beta * avg_noise_ | 158 avg_noise_ = beta * avg_noise_ |
156 + (1 - beta) * residual; | 159 + (1 - beta) * residual; |
157 var_noise_ = beta * var_noise_ | 160 var_noise_ = beta * var_noise_ |
158 + (1 - beta) * (avg_noise_ - residual) * (avg_noise_ - residual); | 161 + (1 - beta) * (avg_noise_ - residual) * (avg_noise_ - residual); |
159 if (var_noise_ < 1) { | 162 if (var_noise_ < 1) { |
160 var_noise_ = 1; | 163 var_noise_ = 1; |
161 } | 164 } |
162 } | 165 } |
163 } // namespace webrtc | 166 } // namespace webrtc |
OLD | NEW |