Chromium Code Reviews| Index: webrtc/modules/remote_bitrate_estimator/test/estimators/nada.cc |
| diff --git a/webrtc/modules/remote_bitrate_estimator/test/estimators/nada.cc b/webrtc/modules/remote_bitrate_estimator/test/estimators/nada.cc |
| index 2500679343a52c37da87f6ec6ff4fc59e0e225fe..e5ab69fc16913ba7b151fbd056a8166e9547fd55 100644 |
| --- a/webrtc/modules/remote_bitrate_estimator/test/estimators/nada.cc |
| +++ b/webrtc/modules/remote_bitrate_estimator/test/estimators/nada.cc |
| @@ -124,12 +124,21 @@ FeedbackPacket* NadaBweReceiver::GetFeedback(int64_t now_ms) { |
| derivative, RecentKbps(), corrected_send_time_ms); |
| } |
| +// If size is even, the median will be the average of the two middlemost |
| +// numbers. |
| int64_t NadaBweReceiver::MedianFilter(int64_t* last_delays_ms, int size) { |
| - // Typically, size = 5. |
| std::vector<int64_t> array_copy(last_delays_ms, last_delays_ms + size); |
| std::nth_element(array_copy.begin(), array_copy.begin() + size / 2, |
| array_copy.end()); |
|
stefan-webrtc
2015/07/22 09:21:19
Move this inside the if statement.
|
| - return array_copy.at(size / 2); |
| + // Typically, size = 5. For odd size values, right and left are equal. |
| + if (size % 2 == 1) { |
|
magalhaesc
2015/07/22 09:01:11
This "if" statement isn't necessary here. But it a
|
| + return array_copy.at(size / 2); |
| + } |
| + int64_t right = array_copy.at(size / 2); |
| + std::nth_element(array_copy.begin(), array_copy.begin() + (size - 1) / 2, |
| + array_copy.end()); |
| + int64_t left = array_copy.at((size - 1) / 2); |
| + return (left + right + 1) / 2; |
| } |
| int64_t NadaBweReceiver::ExponentialSmoothingFilter(int64_t new_value, |