OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. |
| 3 * |
| 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 |
| 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ |
| 10 |
| 11 #ifndef WEBRTC_MODULES_VIDEO_CODING_HISTOGRAM_H_ |
| 12 #define WEBRTC_MODULES_VIDEO_CODING_HISTOGRAM_H_ |
| 13 |
| 14 #include <cstddef> |
| 15 #include <vector> |
| 16 |
| 17 namespace webrtc { |
| 18 namespace video_coding { |
| 19 class Histogram { |
| 20 public: |
| 21 // A discrete histogram where every bucket with range [0, num_buckets). |
| 22 // Values greater or equal to num_buckets will be placed in the last bucket. |
| 23 Histogram(size_t num_buckets, size_t max_num_values); |
| 24 |
| 25 // Add a value to the histogram. If there already is max_num_values in the |
| 26 // histogram then the oldest value will be replaced with the new value. |
| 27 void Add(size_t value); |
| 28 |
| 29 // Calculates how many buckets have to be summed in order to accumulate at |
| 30 // least the given probability. |
| 31 size_t InverseCdf(float probability) const; |
| 32 |
| 33 // How many values that make up this histogram. |
| 34 size_t NumValues() const; |
| 35 |
| 36 private: |
| 37 // A circular buffer that holds the values that make up the histogram. |
| 38 std::vector<size_t> values_; |
| 39 std::vector<size_t> buckets_; |
| 40 size_t index_; |
| 41 }; |
| 42 |
| 43 } // namespace video_coding |
| 44 } // namespace webrtc |
| 45 |
| 46 #endif // WEBRTC_MODULES_VIDEO_CODING_HISTOGRAM_H_ |
OLD | NEW |