Chromium Code Reviews| 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 static const int kMinFps = 10; | 14 static const int kMinFps = 10; |
| 15 static const int kMeasureSeconds = 5; | 15 static const int kMeasureSeconds = 5; |
| 16 static const int kFramedropPercentThreshold = 60; | 16 static const int kFramedropPercentThreshold = 60; |
| 17 static const int kHDResolutionThreshold = 700 * 500; | |
| 18 static const int kHDBitrateThresholdKbps = 500; | |
|
stefan-webrtc
2016/02/19 10:29:32
kHd... (lower case "d") for both these constants.
AlexG
2016/02/19 20:07:46
Done.
| |
| 17 | 19 |
| 18 const int QualityScaler::kDefaultLowQpDenominator = 3; | 20 const int QualityScaler::kDefaultLowQpDenominator = 3; |
| 19 // Note that this is the same for width and height to permit 120x90 in both | 21 // Note that this is the same for width and height to permit 120x90 in both |
| 20 // portrait and landscape mode. | 22 // portrait and landscape mode. |
| 21 const int QualityScaler::kDefaultMinDownscaleDimension = 90; | 23 const int QualityScaler::kDefaultMinDownscaleDimension = 90; |
| 22 | 24 |
| 23 QualityScaler::QualityScaler() | 25 QualityScaler::QualityScaler() |
| 24 : num_samples_(0), | 26 : num_samples_(0), |
| 25 low_qp_threshold_(-1), | 27 low_qp_threshold_(-1), |
| 26 downscale_shift_(0), | 28 downscale_shift_(0), |
| 27 framerate_down_(false), | 29 framerate_down_(false), |
| 28 min_width_(kDefaultMinDownscaleDimension), | 30 min_width_(kDefaultMinDownscaleDimension), |
| 29 min_height_(kDefaultMinDownscaleDimension) {} | 31 min_height_(kDefaultMinDownscaleDimension) {} |
| 30 | 32 |
| 31 void QualityScaler::Init(int low_qp_threshold, | 33 void QualityScaler::Init(int low_qp_threshold, |
| 32 int high_qp_threshold, | 34 int high_qp_threshold, |
| 33 bool use_framerate_reduction) { | 35 bool use_framerate_reduction, |
| 36 int initial_bitrate_kbps, | |
| 37 int width, | |
| 38 int height) { | |
| 34 ClearSamples(); | 39 ClearSamples(); |
| 35 low_qp_threshold_ = low_qp_threshold; | 40 low_qp_threshold_ = low_qp_threshold; |
| 36 high_qp_threshold_ = high_qp_threshold; | 41 high_qp_threshold_ = high_qp_threshold; |
| 37 use_framerate_reduction_ = use_framerate_reduction; | 42 use_framerate_reduction_ = use_framerate_reduction; |
| 43 // TODO(glaznev): Investigate using thresholds for other resolutions | |
| 44 // or threshold tables. | |
| 45 if (initial_bitrate_kbps > 0 && | |
| 46 initial_bitrate_kbps < kHDBitrateThresholdKbps) { | |
| 47 // Start scaling to roughly VGA. | |
| 48 while (width * height > kHDResolutionThreshold) { | |
| 49 ++downscale_shift_; | |
| 50 width /= 2; | |
| 51 height /= 2; | |
| 52 } | |
| 53 } | |
| 38 target_framerate_ = -1; | 54 target_framerate_ = -1; |
| 39 } | 55 } |
| 40 | 56 |
| 41 void QualityScaler::SetMinResolution(int min_width, int min_height) { | 57 void QualityScaler::SetMinResolution(int min_width, int min_height) { |
| 42 min_width_ = min_width; | 58 min_width_ = min_width; |
| 43 min_height_ = min_height; | 59 min_height_ = min_height; |
| 44 } | 60 } |
| 45 | 61 |
| 46 // Report framerate(fps) to estimate # of samples. | 62 // Report framerate(fps) to estimate # of samples. |
| 47 void QualityScaler::ReportFramerate(int framerate) { | 63 void QualityScaler::ReportFramerate(int framerate) { |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 141 } | 157 } |
| 142 | 158 |
| 143 void QualityScaler::AdjustScale(bool up) { | 159 void QualityScaler::AdjustScale(bool up) { |
| 144 downscale_shift_ += up ? -1 : 1; | 160 downscale_shift_ += up ? -1 : 1; |
| 145 if (downscale_shift_ < 0) | 161 if (downscale_shift_ < 0) |
| 146 downscale_shift_ = 0; | 162 downscale_shift_ = 0; |
| 147 ClearSamples(); | 163 ClearSamples(); |
| 148 } | 164 } |
| 149 | 165 |
| 150 } // namespace webrtc | 166 } // namespace webrtc |
| OLD | NEW |