Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 */ |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 117 latest->send_time_ms + now_ms - latest->arrival_time_ms; | 117 latest->send_time_ms + now_ms - latest->arrival_time_ms; |
| 118 } | 118 } |
| 119 | 119 |
| 120 // Sends a tuple containing latest values of <d_hat_n, d_tilde_n, x_n, x'_n, | 120 // Sends a tuple containing latest values of <d_hat_n, d_tilde_n, x_n, x'_n, |
| 121 // R_r> and additional information. | 121 // R_r> and additional information. |
| 122 return new NadaFeedback(flow_id_, now_ms * 1000, exp_smoothed_delay_ms_, | 122 return new NadaFeedback(flow_id_, now_ms * 1000, exp_smoothed_delay_ms_, |
| 123 est_queuing_delay_signal_ms_, congestion_signal_ms, | 123 est_queuing_delay_signal_ms_, congestion_signal_ms, |
| 124 derivative, RecentKbps(), corrected_send_time_ms); | 124 derivative, RecentKbps(), corrected_send_time_ms); |
| 125 } | 125 } |
| 126 | 126 |
| 127 // If size is even, the median will be the average of the two middlemost | |
| 128 // numbers. | |
| 127 int64_t NadaBweReceiver::MedianFilter(int64_t* last_delays_ms, int size) { | 129 int64_t NadaBweReceiver::MedianFilter(int64_t* last_delays_ms, int size) { |
| 128 // Typically, size = 5. | |
| 129 std::vector<int64_t> array_copy(last_delays_ms, last_delays_ms + size); | 130 std::vector<int64_t> array_copy(last_delays_ms, last_delays_ms + size); |
| 130 std::nth_element(array_copy.begin(), array_copy.begin() + size / 2, | 131 std::nth_element(array_copy.begin(), array_copy.begin() + size / 2, |
| 131 array_copy.end()); | 132 array_copy.end()); |
|
stefan-webrtc
2015/07/22 09:21:19
Move this inside the if statement.
| |
| 132 return array_copy.at(size / 2); | 133 // Typically, size = 5. For odd size values, right and left are equal. |
| 134 if (size % 2 == 1) { | |
|
magalhaesc
2015/07/22 09:01:11
This "if" statement isn't necessary here. But it a
| |
| 135 return array_copy.at(size / 2); | |
| 136 } | |
| 137 int64_t right = array_copy.at(size / 2); | |
| 138 std::nth_element(array_copy.begin(), array_copy.begin() + (size - 1) / 2, | |
| 139 array_copy.end()); | |
| 140 int64_t left = array_copy.at((size - 1) / 2); | |
| 141 return (left + right + 1) / 2; | |
| 133 } | 142 } |
| 134 | 143 |
| 135 int64_t NadaBweReceiver::ExponentialSmoothingFilter(int64_t new_value, | 144 int64_t NadaBweReceiver::ExponentialSmoothingFilter(int64_t new_value, |
| 136 int64_t last_smoothed_value, | 145 int64_t last_smoothed_value, |
| 137 float alpha) { | 146 float alpha) { |
| 138 if (last_smoothed_value < 0) { | 147 if (last_smoothed_value < 0) { |
| 139 return new_value; // Handling initial case. | 148 return new_value; // Handling initial case. |
| 140 } | 149 } |
| 141 return static_cast<int64_t>(alpha * new_value + | 150 return static_cast<int64_t>(alpha * new_value + |
| 142 (1.0f - alpha) * last_smoothed_value + 0.5f); | 151 (1.0f - alpha) * last_smoothed_value + 0.5f); |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 270 (kTheta - (bitrate_kbps_ - kMinBitrateKbps) * x_hat)) / | 279 (kTheta - (bitrate_kbps_ - kMinBitrateKbps) * x_hat)) / |
| 271 (kTauOMs * kTauOMs) + | 280 (kTauOMs * kTauOMs) + |
| 272 0.5f); | 281 0.5f); |
| 273 | 282 |
| 274 bitrate_kbps_ = bitrate_kbps_ + smoothing_factor * original_increase; | 283 bitrate_kbps_ = bitrate_kbps_ + smoothing_factor * original_increase; |
| 275 } | 284 } |
| 276 | 285 |
| 277 } // namespace bwe | 286 } // namespace bwe |
| 278 } // namespace testing | 287 } // namespace testing |
| 279 } // namespace webrtc | 288 } // namespace webrtc |
| OLD | NEW |