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

Unified Diff: webrtc/modules/remote_bitrate_estimator/test/estimators/nada.cc

Issue 1246083006: Median filter (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Comment addressed Created 5 years, 5 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | webrtc/modules/remote_bitrate_estimator/test/estimators/nada_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..d77447f1ea11cddab05cf8d7f1997ca2e8d90dd3 100644
--- a/webrtc/modules/remote_bitrate_estimator/test/estimators/nada.cc
+++ b/webrtc/modules/remote_bitrate_estimator/test/estimators/nada.cc
@@ -124,12 +124,20 @@ FeedbackPacket* NadaBweReceiver::GetFeedback(int64_t now_ms) {
derivative, RecentKbps(), corrected_send_time_ms);
}
+// If size is even, the median is 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());
- return array_copy.at(size / 2);
+ if (size % 2 == 1) {
+ // Typically, size = 5. For odd size values, right and left are equal.
+ 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,
« no previous file with comments | « no previous file | webrtc/modules/remote_bitrate_estimator/test/estimators/nada_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698