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 #include "webrtc/modules/video_coding/utility/quality_scaler.h" | 10 #include "webrtc/modules/video_coding/utility/quality_scaler.h" |
11 | 11 |
12 namespace webrtc { | 12 namespace webrtc { |
13 | 13 |
14 namespace { | 14 namespace { |
15 static const int kMinFps = 5; | 15 static const int kMinFps = 5; |
16 static const int kMeasureSecondsDownscale = 3; | 16 static const int kMeasureSecondsDownscale = 3; |
17 // Threshold constant used until first downscale (to permit fast rampup). | 17 // Threshold constant used until first downscale (to permit fast rampup). |
18 static const int kMeasureSecondsFastUpscale = 2; | 18 static const int kMeasureSecondsFastUpscale = 2; |
19 static const int kMeasureSecondsUpscale = 5; | 19 static const int kMeasureSecondsUpscale = 5; |
20 static const int kFramedropPercentThreshold = 60; | 20 static const int kFramedropPercentThreshold = 60; |
21 static const int kHdResolutionThreshold = 700 * 500; | 21 static const int kHdResolutionThreshold = 700 * 500; |
22 static const int kHdBitrateThresholdKbps = 500; | 22 static const int kHdBitrateThresholdKbps = 500; |
23 // Min width/height to downscale to, set to not go below QVGA, but with some | 23 // Min width/height to downscale to, set to not go below QVGA, but with some |
24 // margin to permit "almost-QVGA" resolutions, such as QCIF. | 24 // margin to permit "almost-QVGA" resolutions, such as QCIF. |
25 static const int kMinDownscaleDimension = 140; | 25 static const int kMinDownscaleDimension = 140; |
26 } // namespace | 26 } // namespace |
27 | 27 |
28 const int QualityScaler::kDefaultLowQpDenominator = 3; | |
29 | |
30 QualityScaler::QualityScaler() | 28 QualityScaler::QualityScaler() |
31 : low_qp_threshold_(-1), framerate_down_(false) {} | 29 : low_qp_threshold_(-1), framerate_down_(false) {} |
32 | 30 |
33 void QualityScaler::Init(int low_qp_threshold, | 31 void QualityScaler::Init(int low_qp_threshold, |
34 int high_qp_threshold, | 32 int high_qp_threshold, |
35 bool use_framerate_reduction, | 33 bool use_framerate_reduction, |
36 int initial_bitrate_kbps, | 34 int initial_bitrate_kbps, |
37 int width, | 35 int width, |
38 int height, | 36 int height, |
39 int fps) { | 37 int fps) { |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 downscale_shift_ = 0; | 177 downscale_shift_ = 0; |
180 if (!up) { | 178 if (!up) { |
181 // Hit first downscale, start using a slower threshold for going up. | 179 // Hit first downscale, start using a slower threshold for going up. |
182 measure_seconds_upscale_ = kMeasureSecondsUpscale; | 180 measure_seconds_upscale_ = kMeasureSecondsUpscale; |
183 UpdateSampleCounts(); | 181 UpdateSampleCounts(); |
184 } | 182 } |
185 ClearSamples(); | 183 ClearSamples(); |
186 } | 184 } |
187 | 185 |
188 } // namespace webrtc | 186 } // namespace webrtc |
OLD | NEW |