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