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" |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 23 QualityScaler::QualityScaler() | 23 QualityScaler::QualityScaler() |
| 24 : num_samples_(0), | 24 : num_samples_(0), |
| 25 low_qp_threshold_(-1), | 25 low_qp_threshold_(-1), |
| 26 downscale_shift_(0), | 26 downscale_shift_(0), |
| 27 framerate_down_(false), | 27 framerate_down_(false), |
| 28 min_width_(kDefaultMinDownscaleDimension), | 28 min_width_(kDefaultMinDownscaleDimension), |
| 29 min_height_(kDefaultMinDownscaleDimension) {} | 29 min_height_(kDefaultMinDownscaleDimension) {} |
| 30 | 30 |
| 31 void QualityScaler::Init(int low_qp_threshold, | 31 void QualityScaler::Init(int low_qp_threshold, |
| 32 int high_qp_threshold, | 32 int high_qp_threshold, |
| 33 bool use_framerate_reduction) { | 33 bool use_framerate_reduction, |
| 34 int initial_bitrate_kbps, | |
| 35 int width, | |
| 36 int height) { | |
| 34 ClearSamples(); | 37 ClearSamples(); |
| 35 low_qp_threshold_ = low_qp_threshold; | 38 low_qp_threshold_ = low_qp_threshold; |
| 36 high_qp_threshold_ = high_qp_threshold; | 39 high_qp_threshold_ = high_qp_threshold; |
| 37 use_framerate_reduction_ = use_framerate_reduction; | 40 use_framerate_reduction_ = use_framerate_reduction; |
| 41 if (initial_bitrate_kbps > 0 && initial_bitrate_kbps < 500) { | |
|
pbos-webrtc
2016/02/10 13:43:21
Add a TODO here to investigate other thresholds.
AlexG
2016/02/10 19:07:17
Done.
| |
| 42 // Start scaling to roughly VGA. | |
| 43 while (width * height > 700 * 500) { | |
| 44 ++downscale_shift_; | |
| 45 width /= 2; | |
| 46 height /= 2; | |
| 47 } | |
| 48 } | |
| 38 target_framerate_ = -1; | 49 target_framerate_ = -1; |
| 39 } | 50 } |
| 40 | 51 |
| 41 void QualityScaler::SetMinResolution(int min_width, int min_height) { | 52 void QualityScaler::SetMinResolution(int min_width, int min_height) { |
| 42 min_width_ = min_width; | 53 min_width_ = min_width; |
| 43 min_height_ = min_height; | 54 min_height_ = min_height; |
| 44 } | 55 } |
| 45 | 56 |
| 46 // Report framerate(fps) to estimate # of samples. | 57 // Report framerate(fps) to estimate # of samples. |
| 47 void QualityScaler::ReportFramerate(int framerate) { | 58 void QualityScaler::ReportFramerate(int framerate) { |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 141 } | 152 } |
| 142 | 153 |
| 143 void QualityScaler::AdjustScale(bool up) { | 154 void QualityScaler::AdjustScale(bool up) { |
| 144 downscale_shift_ += up ? -1 : 1; | 155 downscale_shift_ += up ? -1 : 1; |
| 145 if (downscale_shift_ < 0) | 156 if (downscale_shift_ < 0) |
| 146 downscale_shift_ = 0; | 157 downscale_shift_ = 0; |
| 147 ClearSamples(); | 158 ClearSamples(); |
| 148 } | 159 } |
| 149 | 160 |
| 150 } // namespace webrtc | 161 } // namespace webrtc |
| OLD | NEW |