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

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

Issue 2652893015: Rename adaptation api methods, extended vie_encoder unit test. (Closed)
Patch Set: Created 3 years, 10 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
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 const ScalingObserverInterface::ScaleReason scale_reason_ = 42 const AdaptationObserverInterface::AdaptReason scale_reason_ =
nisse-webrtc 2017/01/30 09:16:45 Would it make sense to rename member too, scale_re
sprang_webrtc 2017/01/30 09:55:05 This one was actually just used as an alias in two
nisse-webrtc 2017/01/30 10:07:13 Nice.
43 ScalingObserverInterface::ScaleReason::kQuality; 43 AdaptationObserverInterface::AdaptReason::kQuality;
44 44
45 static VideoEncoder::QpThresholds CodecTypeToDefaultThresholds( 45 static VideoEncoder::QpThresholds CodecTypeToDefaultThresholds(
46 VideoCodecType codec_type) { 46 VideoCodecType codec_type) {
47 int low = -1; 47 int low = -1;
48 int high = -1; 48 int high = -1;
49 switch (codec_type) { 49 switch (codec_type) {
50 case kVideoCodecH264: 50 case kVideoCodecH264:
51 low = kLowH264QpThreshold; 51 low = kLowH264QpThreshold;
52 high = kHighH264QpThreshold; 52 high = kHighH264QpThreshold;
53 break; 53 break;
(...skipping 30 matching lines...) Expand all
84 rtc::TaskQueue::Current()->PostDelayedTask( 84 rtc::TaskQueue::Current()->PostDelayedTask(
85 std::unique_ptr<rtc::QueuedTask>(this), scaler_->GetSamplingPeriodMs()); 85 std::unique_ptr<rtc::QueuedTask>(this), scaler_->GetSamplingPeriodMs());
86 return false; // Retain the task in order to reuse it. 86 return false; // Retain the task in order to reuse it.
87 } 87 }
88 88
89 QualityScaler* const scaler_; 89 QualityScaler* const scaler_;
90 bool stop_ = false; 90 bool stop_ = false;
91 rtc::SequencedTaskChecker task_checker_; 91 rtc::SequencedTaskChecker task_checker_;
92 }; 92 };
93 93
94 QualityScaler::QualityScaler(ScalingObserverInterface* observer, 94 QualityScaler::QualityScaler(AdaptationObserverInterface* observer,
95 VideoCodecType codec_type) 95 VideoCodecType codec_type)
96 : QualityScaler(observer, CodecTypeToDefaultThresholds(codec_type)) {} 96 : QualityScaler(observer, CodecTypeToDefaultThresholds(codec_type)) {}
97 97
98 QualityScaler::QualityScaler(ScalingObserverInterface* observer, 98 QualityScaler::QualityScaler(AdaptationObserverInterface* observer,
99 VideoEncoder::QpThresholds thresholds) 99 VideoEncoder::QpThresholds thresholds)
100 : QualityScaler(observer, thresholds, kMeasureMs) {} 100 : QualityScaler(observer, thresholds, kMeasureMs) {}
101 101
102 // Protected ctor, should not be called directly. 102 // Protected ctor, should not be called directly.
103 QualityScaler::QualityScaler(ScalingObserverInterface* observer, 103 QualityScaler::QualityScaler(AdaptationObserverInterface* observer,
104 VideoEncoder::QpThresholds thresholds, 104 VideoEncoder::QpThresholds thresholds,
105 int64_t sampling_period) 105 int64_t sampling_period)
106 : check_qp_task_(nullptr), 106 : check_qp_task_(nullptr),
107 observer_(observer), 107 observer_(observer),
108 sampling_period_ms_(sampling_period), 108 sampling_period_ms_(sampling_period),
109 fast_rampup_(true), 109 fast_rampup_(true),
110 // Arbitrarily choose size based on 30 fps for 5 seconds. 110 // Arbitrarily choose size based on 30 fps for 5 seconds.
111 average_qp_(5 * 30), 111 average_qp_(5 * 30),
112 framedrop_percent_(5 * 30), 112 framedrop_percent_(5 * 30),
113 thresholds_(thresholds) { 113 thresholds_(thresholds) {
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 // QP has been low. We want to try a higher resolution. 160 // QP has been low. We want to try a higher resolution.
161 ReportQPLow(); 161 ReportQPLow();
162 return; 162 return;
163 } 163 }
164 } 164 }
165 165
166 void QualityScaler::ReportQPLow() { 166 void QualityScaler::ReportQPLow() {
167 RTC_DCHECK_CALLED_SEQUENTIALLY(&task_checker_); 167 RTC_DCHECK_CALLED_SEQUENTIALLY(&task_checker_);
168 LOG(LS_INFO) << "QP has been low, asking for higher resolution."; 168 LOG(LS_INFO) << "QP has been low, asking for higher resolution.";
169 ClearSamples(); 169 ClearSamples();
170 observer_->ScaleUp(scale_reason_); 170 observer_->AdaptUp(scale_reason_);
171 } 171 }
172 172
173 void QualityScaler::ReportQPHigh() { 173 void QualityScaler::ReportQPHigh() {
174 RTC_DCHECK_CALLED_SEQUENTIALLY(&task_checker_); 174 RTC_DCHECK_CALLED_SEQUENTIALLY(&task_checker_);
175 LOG(LS_INFO) << "QP has been high , asking for lower resolution."; 175 LOG(LS_INFO) << "QP has been high , asking for lower resolution.";
176 ClearSamples(); 176 ClearSamples();
177 observer_->ScaleDown(scale_reason_); 177 observer_->AdaptDown(scale_reason_);
178 // If we've scaled down, wait longer before scaling up again. 178 // If we've scaled down, wait longer before scaling up again.
179 if (fast_rampup_) { 179 if (fast_rampup_) {
180 fast_rampup_ = false; 180 fast_rampup_ = false;
181 } 181 }
182 } 182 }
183 183
184 void QualityScaler::ClearSamples() { 184 void QualityScaler::ClearSamples() {
185 RTC_DCHECK_CALLED_SEQUENTIALLY(&task_checker_); 185 RTC_DCHECK_CALLED_SEQUENTIALLY(&task_checker_);
186 framedrop_percent_.Reset(); 186 framedrop_percent_.Reset();
187 average_qp_.Reset(); 187 average_qp_.Reset();
188 } 188 }
189 } // namespace webrtc 189 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698