niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 1 | /* |
marpan@webrtc.org | 9d76b4e | 2012-02-28 23:39:31 | [diff] [blame] | 2 | * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 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_CONTENT_METRICS_PROCESSING_H_ |
| 12 | #define WEBRTC_MODULES_VIDEO_CODING_CONTENT_METRICS_PROCESSING_H_ |
| 13 | |
pbos@webrtc.org | a440732 | 2013-07-16 12:32:05 | [diff] [blame] | 14 | #include "webrtc/typedefs.h" |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 15 | |
marpan@webrtc.org | 9d76b4e | 2012-02-28 23:39:31 | [diff] [blame] | 16 | namespace webrtc { |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 17 | |
| 18 | struct VideoContentMetrics; |
| 19 | |
| 20 | // QM interval time (in ms) |
philipel | 9d3ab61 | 2015-12-21 12:12:39 | [diff] [blame] | 21 | enum { kQmMinIntervalMs = 10000 }; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 22 | |
| 23 | // Flag for NFD metric vs motion metric |
philipel | 9d3ab61 | 2015-12-21 12:12:39 | [diff] [blame] | 24 | enum { kNfdMetric = 1 }; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 25 | |
| 26 | /**********************************/ |
| 27 | /* Content Metrics Processing */ |
| 28 | /**********************************/ |
marpan@webrtc.org | 9d76b4e | 2012-02-28 23:39:31 | [diff] [blame] | 29 | class VCMContentMetricsProcessing { |
| 30 | public: |
| 31 | VCMContentMetricsProcessing(); |
| 32 | ~VCMContentMetricsProcessing(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 33 | |
marpan@webrtc.org | 9d76b4e | 2012-02-28 23:39:31 | [diff] [blame] | 34 | // Update class with latest metrics. |
philipel | 9d3ab61 | 2015-12-21 12:12:39 | [diff] [blame] | 35 | int UpdateContentData(const VideoContentMetrics* contentMetrics); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 36 | |
marpan@webrtc.org | 9d76b4e | 2012-02-28 23:39:31 | [diff] [blame] | 37 | // Reset the short-term averaged content data. |
| 38 | void ResetShortTermAvgData(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 39 | |
marpan@webrtc.org | 9d76b4e | 2012-02-28 23:39:31 | [diff] [blame] | 40 | // Initialize. |
| 41 | int Reset(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 42 | |
marpan@webrtc.org | 9d76b4e | 2012-02-28 23:39:31 | [diff] [blame] | 43 | // Inform class of current frame rate. |
| 44 | void UpdateFrameRate(uint32_t frameRate); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 45 | |
marpan@webrtc.org | 9d76b4e | 2012-02-28 23:39:31 | [diff] [blame] | 46 | // Returns the long-term averaged content data: recursive average over longer |
| 47 | // time scale. |
| 48 | VideoContentMetrics* LongTermAvgData(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 49 | |
marpan@webrtc.org | 9d76b4e | 2012-02-28 23:39:31 | [diff] [blame] | 50 | // Returns the short-term averaged content data: uniform average over |
| 51 | // shorter time scalE. |
| 52 | VideoContentMetrics* ShortTermAvgData(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 53 | |
marpan@webrtc.org | 9d76b4e | 2012-02-28 23:39:31 | [diff] [blame] | 54 | private: |
| 55 | // Compute working average. |
philipel | 9d3ab61 | 2015-12-21 12:12:39 | [diff] [blame] | 56 | int ProcessContent(const VideoContentMetrics* contentMetrics); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 57 | |
marpan@webrtc.org | 9d76b4e | 2012-02-28 23:39:31 | [diff] [blame] | 58 | // Update the recursive averaged metrics: longer time average (~5/10 secs). |
philipel | 9d3ab61 | 2015-12-21 12:12:39 | [diff] [blame] | 59 | void UpdateRecursiveAvg(const VideoContentMetrics* contentMetrics); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 60 | |
marpan@webrtc.org | 9d76b4e | 2012-02-28 23:39:31 | [diff] [blame] | 61 | // Update the uniform averaged metrics: shorter time average (~RTCP report). |
philipel | 9d3ab61 | 2015-12-21 12:12:39 | [diff] [blame] | 62 | void UpdateUniformAvg(const VideoContentMetrics* contentMetrics); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 63 | |
marpan@webrtc.org | 9d76b4e | 2012-02-28 23:39:31 | [diff] [blame] | 64 | VideoContentMetrics* recursive_avg_; |
| 65 | VideoContentMetrics* uniform_avg_; |
| 66 | float recursive_avg_factor_; |
| 67 | uint32_t frame_cnt_uniform_avg_; |
| 68 | float avg_motion_level_; |
| 69 | float avg_spatial_level_; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 70 | }; |
marpan@webrtc.org | 9d76b4e | 2012-02-28 23:39:31 | [diff] [blame] | 71 | } // namespace webrtc |
| 72 | #endif // WEBRTC_MODULES_VIDEO_CODING_CONTENT_METRICS_PROCESSING_H_ |