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

Unified Diff: webrtc/modules/video_coding/distribution.cc

Issue 1715673002: Implement the NackModule as part of the new jitter buffer. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Implemented reordering statistics in separate class. Created 4 years, 10 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
Index: webrtc/modules/video_coding/distribution.cc
diff --git a/webrtc/modules/video_coding/distribution.cc b/webrtc/modules/video_coding/distribution.cc
new file mode 100644
index 0000000000000000000000000000000000000000..f433b1fb70afbc47987b0cecae3f15cc4f90b766
--- /dev/null
+++ b/webrtc/modules/video_coding/distribution.cc
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
+ *
+ * Use of this source code is governed by a BSD-style license
+ * that can be found in the LICENSE file in the root of the source
+ * tree. An additional intellectual property rights grant can be found
+ * in the file PATENTS. All contributing project authors may
+ * be found in the AUTHORS file in the root of the source tree.
+ */
+
+#include <algorithm>
+
+#include "webrtc/modules/video_coding/distribution.h"
stefan-webrtc 2016/03/01 08:52:10 this one should be first
philipel 2016/03/01 10:27:05 Done.
+
+#include "webrtc/base/mod_ops.h"
+
+namespace webrtc {
+
+Distribution::Distribution(int num_buckets, int max_num_values) {
+ buckets_.resize(num_buckets);
+ values_.reserve(max_num_values);
+ index_ = 0;
+}
+
+void Distribution::AddValue(int value) {
+ RTC_DCHECK_LE(0, value);
+ value = std::min<int>(value, buckets_.size() - 1);
+ if (index_ < values_.size()) {
+ buckets_[values_[index_]]--;
stefan-webrtc 2016/03/01 08:52:10 --buckets_...;
philipel 2016/03/01 10:27:05 Done.
+ values_[index_] = value;
+ } else {
+ values_.emplace_back(value);
+ }
+
+ buckets_[value]++;
stefan-webrtc 2016/03/01 08:52:10 ++buckets_...;
philipel 2016/03/01 10:27:05 Done.
+ index_ = (index_ + 1) % values_.capacity();
+}
+
+size_t Distribution::InverseCDF(float probability) const {
+ RTC_DCHECK_LE(1.f, probability);
+ RTC_DCHECK_GE(0.f, probability);
+ RTC_DCHECK_LE(0ul, values_.size());
+
+ size_t bucket = 0;
+ float accumulated_probability = 0;
+ while (accumulated_probability < probability &&
+ bucket < buckets_.size()) {
stefan-webrtc 2016/03/01 08:52:10 git cl format
philipel 2016/03/01 10:27:05 Done.
+ accumulated_probability += static_cast<float>(buckets_[bucket])/
+ values_.size();
+ ++bucket;
+ }
+ return bucket;
+}
+
+size_t Distribution::NumValues() const {
+ return values_.size();
+}
+
+} // namespace webrtc

Powered by Google App Engine
This is Rietveld 408576698