OLD | NEW |
---|---|
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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
105 observer_(observer), | 105 observer_(observer), |
106 sampling_period_ms_(sampling_period), | 106 sampling_period_ms_(sampling_period), |
107 fast_rampup_(true), | 107 fast_rampup_(true), |
108 // Arbitrarily choose size based on 30 fps for 5 seconds. | 108 // Arbitrarily choose size based on 30 fps for 5 seconds. |
109 average_qp_(5 * 30), | 109 average_qp_(5 * 30), |
110 framedrop_percent_(5 * 30), | 110 framedrop_percent_(5 * 30), |
111 thresholds_(thresholds) { | 111 thresholds_(thresholds) { |
112 RTC_DCHECK_CALLED_SEQUENTIALLY(&task_checker_); | 112 RTC_DCHECK_CALLED_SEQUENTIALLY(&task_checker_); |
113 RTC_DCHECK(observer_ != nullptr); | 113 RTC_DCHECK(observer_ != nullptr); |
114 check_qp_task_ = new CheckQPTask(this); | 114 check_qp_task_ = new CheckQPTask(this); |
115 LOG(LS_INFO) << "QP thresholds: low: " << thresholds_.low | |
116 << ", high: " << thresholds_.high; | |
115 } | 117 } |
116 | 118 |
117 QualityScaler::~QualityScaler() { | 119 QualityScaler::~QualityScaler() { |
118 RTC_DCHECK_CALLED_SEQUENTIALLY(&task_checker_); | 120 RTC_DCHECK_CALLED_SEQUENTIALLY(&task_checker_); |
119 check_qp_task_->Stop(); | 121 check_qp_task_->Stop(); |
120 } | 122 } |
121 | 123 |
122 int64_t QualityScaler::GetSamplingPeriodMs() const { | 124 int64_t QualityScaler::GetSamplingPeriodMs() const { |
123 RTC_DCHECK_CALLED_SEQUENTIALLY(&task_checker_); | 125 RTC_DCHECK_CALLED_SEQUENTIALLY(&task_checker_); |
124 return fast_rampup_ ? sampling_period_ms_ | 126 return fast_rampup_ ? sampling_period_ms_ |
(...skipping 12 matching lines...) Expand all Loading... | |
137 } | 139 } |
138 | 140 |
139 void QualityScaler::CheckQP() { | 141 void QualityScaler::CheckQP() { |
140 RTC_DCHECK_CALLED_SEQUENTIALLY(&task_checker_); | 142 RTC_DCHECK_CALLED_SEQUENTIALLY(&task_checker_); |
141 // Should be set through InitEncode -> Should be set by now. | 143 // Should be set through InitEncode -> Should be set by now. |
142 RTC_DCHECK_GE(thresholds_.low, 0); | 144 RTC_DCHECK_GE(thresholds_.low, 0); |
143 LOG(LS_INFO) << "Checking if average QP exceeds threshold"; | 145 LOG(LS_INFO) << "Checking if average QP exceeds threshold"; |
144 // Check if we should scale down due to high frame drop. | 146 // Check if we should scale down due to high frame drop. |
145 const rtc::Optional<int> drop_rate = framedrop_percent_.GetAverage(); | 147 const rtc::Optional<int> drop_rate = framedrop_percent_.GetAverage(); |
146 if (drop_rate && *drop_rate >= kFramedropPercentThreshold) { | 148 if (drop_rate && *drop_rate >= kFramedropPercentThreshold) { |
149 LOG(LS_INFO) << "Drop rate " << *drop_rate | |
150 << " has been high , asking for lower resolution."; | |
kthelgason
2017/03/22 07:38:58
There is a bug here (https://bugs.chromium.org/p/w
AlexG
2017/03/22 19:53:45
I am not sure regarding the proper logging here. P
stefan-webrtc
2017/03/23 17:58:04
I think the current logging is confusing, so I'd p
AlexG
2017/03/23 19:25:08
Done. I removed "asking for lower/higher resolutio
| |
147 ReportQPHigh(); | 151 ReportQPHigh(); |
148 return; | 152 return; |
149 } | 153 } |
150 | 154 |
151 // Check if we should scale up or down based on QP. | 155 // Check if we should scale up or down based on QP. |
152 const rtc::Optional<int> avg_qp = average_qp_.GetAverage(); | 156 const rtc::Optional<int> avg_qp = average_qp_.GetAverage(); |
153 if (avg_qp && *avg_qp > thresholds_.high) { | 157 if (avg_qp && *avg_qp > thresholds_.high) { |
158 LOG(LS_INFO) << "QP " << *avg_qp | |
159 << " has been high , asking for lower resolution."; | |
154 ReportQPHigh(); | 160 ReportQPHigh(); |
155 return; | 161 return; |
156 } | 162 } |
157 if (avg_qp && *avg_qp <= thresholds_.low) { | 163 if (avg_qp && *avg_qp <= thresholds_.low) { |
158 // QP has been low. We want to try a higher resolution. | 164 // QP has been low. We want to try a higher resolution. |
165 LOG(LS_INFO) << "QP " << *avg_qp | |
166 << " has been low, asking for higher resolution."; | |
159 ReportQPLow(); | 167 ReportQPLow(); |
160 return; | 168 return; |
161 } | 169 } |
162 } | 170 } |
163 | 171 |
164 void QualityScaler::ReportQPLow() { | 172 void QualityScaler::ReportQPLow() { |
165 RTC_DCHECK_CALLED_SEQUENTIALLY(&task_checker_); | 173 RTC_DCHECK_CALLED_SEQUENTIALLY(&task_checker_); |
166 LOG(LS_INFO) << "QP has been low, asking for higher resolution."; | |
167 ClearSamples(); | 174 ClearSamples(); |
168 observer_->AdaptUp(AdaptationObserverInterface::AdaptReason::kQuality); | 175 observer_->AdaptUp(AdaptationObserverInterface::AdaptReason::kQuality); |
169 } | 176 } |
170 | 177 |
171 void QualityScaler::ReportQPHigh() { | 178 void QualityScaler::ReportQPHigh() { |
172 RTC_DCHECK_CALLED_SEQUENTIALLY(&task_checker_); | 179 RTC_DCHECK_CALLED_SEQUENTIALLY(&task_checker_); |
173 LOG(LS_INFO) << "QP has been high , asking for lower resolution."; | |
174 ClearSamples(); | 180 ClearSamples(); |
175 observer_->AdaptDown(AdaptationObserverInterface::AdaptReason::kQuality); | 181 observer_->AdaptDown(AdaptationObserverInterface::AdaptReason::kQuality); |
176 // If we've scaled down, wait longer before scaling up again. | 182 // If we've scaled down, wait longer before scaling up again. |
177 if (fast_rampup_) { | 183 if (fast_rampup_) { |
178 fast_rampup_ = false; | 184 fast_rampup_ = false; |
179 } | 185 } |
180 } | 186 } |
181 | 187 |
182 void QualityScaler::ClearSamples() { | 188 void QualityScaler::ClearSamples() { |
183 RTC_DCHECK_CALLED_SEQUENTIALLY(&task_checker_); | 189 RTC_DCHECK_CALLED_SEQUENTIALLY(&task_checker_); |
184 framedrop_percent_.Reset(); | 190 framedrop_percent_.Reset(); |
185 average_qp_.Reset(); | 191 average_qp_.Reset(); |
186 } | 192 } |
187 } // namespace webrtc | 193 } // namespace webrtc |
OLD | NEW |