Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(473)

Side by Side Diff: webrtc/modules/video_coding/utility/quality_scaler.cc

Issue 2789483002: Make sure we observe enough frames before scaling. (Closed)
Patch Set: Add test for new behaviour Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | webrtc/modules/video_coding/utility/quality_scaler_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2014 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 21 matching lines...) Expand all
32 static const int kMeasureMs = 2000; 32 static const int kMeasureMs = 2000;
33 static const float kSamplePeriodScaleFactor = 2.5; 33 static const float kSamplePeriodScaleFactor = 2.5;
34 static const int kFramedropPercentThreshold = 60; 34 static const int kFramedropPercentThreshold = 60;
35 // QP scaling threshold defaults: 35 // QP scaling threshold defaults:
36 static const int kLowH264QpThreshold = 24; 36 static const int kLowH264QpThreshold = 24;
37 static const int kHighH264QpThreshold = 37; 37 static const int kHighH264QpThreshold = 37;
38 // QP is obtained from VP8-bitstream for HW, so the QP corresponds to the 38 // QP is obtained from VP8-bitstream for HW, so the QP corresponds to the
39 // bitstream range of [0, 127] and not the user-level range of [0,63]. 39 // bitstream range of [0, 127] and not the user-level range of [0,63].
40 static const int kLowVp8QpThreshold = 29; 40 static const int kLowVp8QpThreshold = 29;
41 static const int kHighVp8QpThreshold = 95; 41 static const int kHighVp8QpThreshold = 95;
42 static const int kMinFramesNeededToScale = 2 * 30;
42 43
43 static VideoEncoder::QpThresholds CodecTypeToDefaultThresholds( 44 static VideoEncoder::QpThresholds CodecTypeToDefaultThresholds(
44 VideoCodecType codec_type) { 45 VideoCodecType codec_type) {
45 int low = -1; 46 int low = -1;
46 int high = -1; 47 int high = -1;
47 switch (codec_type) { 48 switch (codec_type) {
48 case kVideoCodecH264: 49 case kVideoCodecH264:
49 low = kLowH264QpThreshold; 50 low = kLowH264QpThreshold;
50 high = kHighH264QpThreshold; 51 high = kHighH264QpThreshold;
51 break; 52 break;
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 void QualityScaler::ReportQP(int qp) { 136 void QualityScaler::ReportQP(int qp) {
136 RTC_DCHECK_CALLED_SEQUENTIALLY(&task_checker_); 137 RTC_DCHECK_CALLED_SEQUENTIALLY(&task_checker_);
137 framedrop_percent_.AddSample(0); 138 framedrop_percent_.AddSample(0);
138 average_qp_.AddSample(qp); 139 average_qp_.AddSample(qp);
139 } 140 }
140 141
141 void QualityScaler::CheckQP() { 142 void QualityScaler::CheckQP() {
142 RTC_DCHECK_CALLED_SEQUENTIALLY(&task_checker_); 143 RTC_DCHECK_CALLED_SEQUENTIALLY(&task_checker_);
143 // Should be set through InitEncode -> Should be set by now. 144 // Should be set through InitEncode -> Should be set by now.
144 RTC_DCHECK_GE(thresholds_.low, 0); 145 RTC_DCHECK_GE(thresholds_.low, 0);
146
147 // If we have not observed at least this many frames we can't
148 // make a good scaling decision.
149 if (framedrop_percent_.size() < kMinFramesNeededToScale)
150 return;
151
145 // Check if we should scale down due to high frame drop. 152 // Check if we should scale down due to high frame drop.
146 const rtc::Optional<int> drop_rate = framedrop_percent_.GetAverage(); 153 const rtc::Optional<int> drop_rate = framedrop_percent_.GetAverage();
147 if (drop_rate && *drop_rate >= kFramedropPercentThreshold) { 154 if (drop_rate && *drop_rate >= kFramedropPercentThreshold) {
148 ReportQPHigh(); 155 ReportQPHigh();
149 return; 156 return;
150 } 157 }
151 158
152 // Check if we should scale up or down based on QP. 159 // Check if we should scale up or down based on QP.
153 const rtc::Optional<int> avg_qp = average_qp_.GetAverage(); 160 const rtc::Optional<int> avg_qp = average_qp_.GetAverage();
154 if (avg_qp) { 161 if (avg_qp) {
(...skipping 25 matching lines...) Expand all
180 fast_rampup_ = false; 187 fast_rampup_ = false;
181 } 188 }
182 } 189 }
183 190
184 void QualityScaler::ClearSamples() { 191 void QualityScaler::ClearSamples() {
185 RTC_DCHECK_CALLED_SEQUENTIALLY(&task_checker_); 192 RTC_DCHECK_CALLED_SEQUENTIALLY(&task_checker_);
186 framedrop_percent_.Reset(); 193 framedrop_percent_.Reset();
187 average_qp_.Reset(); 194 average_qp_.Reset();
188 } 195 }
189 } // namespace webrtc 196 } // namespace webrtc
OLDNEW
« no previous file with comments | « no previous file | webrtc/modules/video_coding/utility/quality_scaler_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698