niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2011 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 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 11 | #ifndef MODULES_VIDEO_CODING_CODEC_TIMER_H_ |
| 12 | #define MODULES_VIDEO_CODING_CODEC_TIMER_H_ |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 13 | |
magjed | 2943f01 | 2016-03-22 05:12:09 -0700 | [diff] [blame] | 14 | #include <queue> |
| 15 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 16 | #include "modules/include/module_common_types.h" |
| 17 | #include "rtc_base/numerics/percentile_filter.h" |
Mirko Bonadei | 7120742 | 2017-09-15 13:58:09 +0200 | [diff] [blame] | 18 | #include "typedefs.h" // NOLINT(build/include) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 19 | |
philipel | cce46fc | 2015-12-21 03:04:49 -0800 | [diff] [blame] | 20 | namespace webrtc { |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 21 | |
philipel | cce46fc | 2015-12-21 03:04:49 -0800 | [diff] [blame] | 22 | class VCMCodecTimer { |
| 23 | public: |
| 24 | VCMCodecTimer(); |
Niels Möller | be682d4 | 2018-03-27 08:31:45 +0200 | [diff] [blame] | 25 | ~VCMCodecTimer(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 26 | |
magjed | 2943f01 | 2016-03-22 05:12:09 -0700 | [diff] [blame] | 27 | // Add a new decode time to the filter. |
| 28 | void AddTiming(int64_t new_decode_time_ms, int64_t now_ms); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 29 | |
magjed | 2943f01 | 2016-03-22 05:12:09 -0700 | [diff] [blame] | 30 | // Get the required decode time in ms. It is the 95th percentile observed |
| 31 | // decode time within a time window. |
| 32 | int64_t RequiredDecodeTimeMs() const; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 33 | |
philipel | cce46fc | 2015-12-21 03:04:49 -0800 | [diff] [blame] | 34 | private: |
magjed | 2943f01 | 2016-03-22 05:12:09 -0700 | [diff] [blame] | 35 | struct Sample { |
| 36 | Sample(int64_t decode_time_ms, int64_t sample_time_ms); |
| 37 | int64_t decode_time_ms; |
| 38 | int64_t sample_time_ms; |
| 39 | }; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 40 | |
philipel | cce46fc | 2015-12-21 03:04:49 -0800 | [diff] [blame] | 41 | // The number of samples ignored so far. |
magjed | 2943f01 | 2016-03-22 05:12:09 -0700 | [diff] [blame] | 42 | int ignored_sample_count_; |
| 43 | // Queue with history of latest decode time values. |
| 44 | std::queue<Sample> history_; |
| 45 | // |filter_| contains the same values as |history_|, but in a data structure |
| 46 | // that allows efficient retrieval of the percentile value. |
terelius | cb861e0 | 2016-11-30 06:51:57 -0800 | [diff] [blame] | 47 | PercentileFilter<int64_t> filter_; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 48 | }; |
| 49 | |
pbos@webrtc.org | d900e8b | 2013-07-03 15:12:26 +0000 | [diff] [blame] | 50 | } // namespace webrtc |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 51 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 52 | #endif // MODULES_VIDEO_CODING_CODEC_TIMER_H_ |