blob: 3517f757d46ee9dad5c051c93d14205971d94b6b [file] [log] [blame]
niklase@google.com470e71d2011-07-07 08:21:25 +00001/*
marpan@webrtc.org9d76b4e2012-02-28 23:39:31 +00002 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
niklase@google.com470e71d2011-07-07 08:21:25 +00003 *
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.orga4407322013-07-16 12:32:05 +000014#include "webrtc/typedefs.h"
niklase@google.com470e71d2011-07-07 08:21:25 +000015
marpan@webrtc.org9d76b4e2012-02-28 23:39:31 +000016namespace webrtc {
niklase@google.com470e71d2011-07-07 08:21:25 +000017
18struct VideoContentMetrics;
19
20// QM interval time (in ms)
marpan@webrtc.org9d76b4e2012-02-28 23:39:31 +000021enum {
22 kQmMinIntervalMs = 10000
23};
niklase@google.com470e71d2011-07-07 08:21:25 +000024
25// Flag for NFD metric vs motion metric
marpan@webrtc.org9d76b4e2012-02-28 23:39:31 +000026enum {
27 kNfdMetric = 1
28};
niklase@google.com470e71d2011-07-07 08:21:25 +000029
30/**********************************/
31/* Content Metrics Processing */
32/**********************************/
marpan@webrtc.org9d76b4e2012-02-28 23:39:31 +000033class VCMContentMetricsProcessing {
34 public:
35 VCMContentMetricsProcessing();
36 ~VCMContentMetricsProcessing();
niklase@google.com470e71d2011-07-07 08:21:25 +000037
marpan@webrtc.org9d76b4e2012-02-28 23:39:31 +000038 // Update class with latest metrics.
39 int UpdateContentData(const VideoContentMetrics *contentMetrics);
niklase@google.com470e71d2011-07-07 08:21:25 +000040
marpan@webrtc.org9d76b4e2012-02-28 23:39:31 +000041 // Reset the short-term averaged content data.
42 void ResetShortTermAvgData();
niklase@google.com470e71d2011-07-07 08:21:25 +000043
marpan@webrtc.org9d76b4e2012-02-28 23:39:31 +000044 // Initialize.
45 int Reset();
niklase@google.com470e71d2011-07-07 08:21:25 +000046
marpan@webrtc.org9d76b4e2012-02-28 23:39:31 +000047 // Inform class of current frame rate.
48 void UpdateFrameRate(uint32_t frameRate);
niklase@google.com470e71d2011-07-07 08:21:25 +000049
marpan@webrtc.org9d76b4e2012-02-28 23:39:31 +000050 // Returns the long-term averaged content data: recursive average over longer
51 // time scale.
52 VideoContentMetrics* LongTermAvgData();
niklase@google.com470e71d2011-07-07 08:21:25 +000053
marpan@webrtc.org9d76b4e2012-02-28 23:39:31 +000054 // Returns the short-term averaged content data: uniform average over
55 // shorter time scalE.
56 VideoContentMetrics* ShortTermAvgData();
niklase@google.com470e71d2011-07-07 08:21:25 +000057
marpan@webrtc.org9d76b4e2012-02-28 23:39:31 +000058 private:
59 // Compute working average.
60 int ProcessContent(const VideoContentMetrics *contentMetrics);
niklase@google.com470e71d2011-07-07 08:21:25 +000061
marpan@webrtc.org9d76b4e2012-02-28 23:39:31 +000062 // Update the recursive averaged metrics: longer time average (~5/10 secs).
63 void UpdateRecursiveAvg(const VideoContentMetrics *contentMetrics);
niklase@google.com470e71d2011-07-07 08:21:25 +000064
marpan@webrtc.org9d76b4e2012-02-28 23:39:31 +000065 // Update the uniform averaged metrics: shorter time average (~RTCP report).
66 void UpdateUniformAvg(const VideoContentMetrics *contentMetrics);
niklase@google.com470e71d2011-07-07 08:21:25 +000067
marpan@webrtc.org9d76b4e2012-02-28 23:39:31 +000068 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_;
niklase@google.com470e71d2011-07-07 08:21:25 +000074};
marpan@webrtc.org9d76b4e2012-02-28 23:39:31 +000075} // namespace webrtc
76#endif // WEBRTC_MODULES_VIDEO_CODING_CONTENT_METRICS_PROCESSING_H_