blob: 3f67ec19c98b725915e26a71fcc8bab865d49f18 [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)
philipel9d3ab612015-12-21 04:12:39 -080021enum { kQmMinIntervalMs = 10000 };
niklase@google.com470e71d2011-07-07 08:21:25 +000022
23// Flag for NFD metric vs motion metric
philipel9d3ab612015-12-21 04:12:39 -080024enum { kNfdMetric = 1 };
niklase@google.com470e71d2011-07-07 08:21:25 +000025
26/**********************************/
27/* Content Metrics Processing */
28/**********************************/
marpan@webrtc.org9d76b4e2012-02-28 23:39:31 +000029class VCMContentMetricsProcessing {
30 public:
31 VCMContentMetricsProcessing();
32 ~VCMContentMetricsProcessing();
niklase@google.com470e71d2011-07-07 08:21:25 +000033
marpan@webrtc.org9d76b4e2012-02-28 23:39:31 +000034 // Update class with latest metrics.
philipel9d3ab612015-12-21 04:12:39 -080035 int UpdateContentData(const VideoContentMetrics* contentMetrics);
niklase@google.com470e71d2011-07-07 08:21:25 +000036
marpan@webrtc.org9d76b4e2012-02-28 23:39:31 +000037 // Reset the short-term averaged content data.
38 void ResetShortTermAvgData();
niklase@google.com470e71d2011-07-07 08:21:25 +000039
marpan@webrtc.org9d76b4e2012-02-28 23:39:31 +000040 // Initialize.
41 int Reset();
niklase@google.com470e71d2011-07-07 08:21:25 +000042
marpan@webrtc.org9d76b4e2012-02-28 23:39:31 +000043 // Inform class of current frame rate.
44 void UpdateFrameRate(uint32_t frameRate);
niklase@google.com470e71d2011-07-07 08:21:25 +000045
marpan@webrtc.org9d76b4e2012-02-28 23:39:31 +000046 // Returns the long-term averaged content data: recursive average over longer
47 // time scale.
48 VideoContentMetrics* LongTermAvgData();
niklase@google.com470e71d2011-07-07 08:21:25 +000049
marpan@webrtc.org9d76b4e2012-02-28 23:39:31 +000050 // Returns the short-term averaged content data: uniform average over
51 // shorter time scalE.
52 VideoContentMetrics* ShortTermAvgData();
niklase@google.com470e71d2011-07-07 08:21:25 +000053
marpan@webrtc.org9d76b4e2012-02-28 23:39:31 +000054 private:
55 // Compute working average.
philipel9d3ab612015-12-21 04:12:39 -080056 int ProcessContent(const VideoContentMetrics* contentMetrics);
niklase@google.com470e71d2011-07-07 08:21:25 +000057
marpan@webrtc.org9d76b4e2012-02-28 23:39:31 +000058 // Update the recursive averaged metrics: longer time average (~5/10 secs).
philipel9d3ab612015-12-21 04:12:39 -080059 void UpdateRecursiveAvg(const VideoContentMetrics* contentMetrics);
niklase@google.com470e71d2011-07-07 08:21:25 +000060
marpan@webrtc.org9d76b4e2012-02-28 23:39:31 +000061 // Update the uniform averaged metrics: shorter time average (~RTCP report).
philipel9d3ab612015-12-21 04:12:39 -080062 void UpdateUniformAvg(const VideoContentMetrics* contentMetrics);
niklase@google.com470e71d2011-07-07 08:21:25 +000063
marpan@webrtc.org9d76b4e2012-02-28 23:39:31 +000064 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.com470e71d2011-07-07 08:21:25 +000070};
marpan@webrtc.org9d76b4e2012-02-28 23:39:31 +000071} // namespace webrtc
72#endif // WEBRTC_MODULES_VIDEO_CODING_CONTENT_METRICS_PROCESSING_H_