OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 26 matching lines...) Expand all Loading... |
37 int VCMContentMetricsProcessing::Reset() { | 37 int VCMContentMetricsProcessing::Reset() { |
38 recursive_avg_->Reset(); | 38 recursive_avg_->Reset(); |
39 uniform_avg_->Reset(); | 39 uniform_avg_->Reset(); |
40 frame_cnt_uniform_avg_ = 0; | 40 frame_cnt_uniform_avg_ = 0; |
41 avg_motion_level_ = 0.0f; | 41 avg_motion_level_ = 0.0f; |
42 avg_spatial_level_ = 0.0f; | 42 avg_spatial_level_ = 0.0f; |
43 return VCM_OK; | 43 return VCM_OK; |
44 } | 44 } |
45 | 45 |
46 void VCMContentMetricsProcessing::UpdateFrameRate(uint32_t frameRate) { | 46 void VCMContentMetricsProcessing::UpdateFrameRate(uint32_t frameRate) { |
| 47 if (frameRate == 0) |
| 48 frameRate = 1; |
47 // Update factor for recursive averaging. | 49 // Update factor for recursive averaging. |
48 recursive_avg_factor_ = static_cast<float>(1000.0f) / | 50 recursive_avg_factor_ = static_cast<float>(1000.0f) / |
49 static_cast<float>(frameRate * kQmMinIntervalMs); | 51 static_cast<float>(frameRate * kQmMinIntervalMs); |
50 } | 52 } |
51 | 53 |
52 VideoContentMetrics* VCMContentMetricsProcessing::LongTermAvgData() { | 54 VideoContentMetrics* VCMContentMetricsProcessing::LongTermAvgData() { |
53 return recursive_avg_; | 55 return recursive_avg_; |
54 } | 56 } |
55 | 57 |
56 VideoContentMetrics* VCMContentMetricsProcessing::ShortTermAvgData() { | 58 VideoContentMetrics* VCMContentMetricsProcessing::ShortTermAvgData() { |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 recursive_avg_->spatial_pred_err_v = | 117 recursive_avg_->spatial_pred_err_v = |
116 (1 - recursive_avg_factor_) * recursive_avg_->spatial_pred_err_v + | 118 (1 - recursive_avg_factor_) * recursive_avg_->spatial_pred_err_v + |
117 recursive_avg_factor_ * contentMetrics->spatial_pred_err_v; | 119 recursive_avg_factor_ * contentMetrics->spatial_pred_err_v; |
118 | 120 |
119 // Motion metric: Derived from NFD (normalized frame difference). | 121 // Motion metric: Derived from NFD (normalized frame difference). |
120 recursive_avg_->motion_magnitude = | 122 recursive_avg_->motion_magnitude = |
121 (1 - recursive_avg_factor_) * recursive_avg_->motion_magnitude + | 123 (1 - recursive_avg_factor_) * recursive_avg_->motion_magnitude + |
122 recursive_avg_factor_ * contentMetrics->motion_magnitude; | 124 recursive_avg_factor_ * contentMetrics->motion_magnitude; |
123 } | 125 } |
124 } // namespace webrtc | 126 } // namespace webrtc |
OLD | NEW |