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 // TODO(glaznev): investigate using thresholds for other resolutions | |
| 42 // ot threshold tables. | |
| 
 
sprang
2016/02/15 13:20:21
s/investigate/Investigare s/ot/or
Could we name th
 
AlexG
2016/02/16 22:26:34
Done.
 
 | |
| 43 if (initial_bitrate_kbps > 0 && initial_bitrate_kbps < 500) { | |
| 44 // Start scaling to roughly VGA. | |
| 45 while (width * height > 700 * 500) { | |
| 46 ++downscale_shift_; | |
| 47 width /= 2; | |
| 48 height /= 2; | |
| 49 } | |
| 50 } | |
| 38 target_framerate_ = -1; | 51 target_framerate_ = -1; | 
| 39 } | 52 } | 
| 40 | 53 | 
| 41 void QualityScaler::SetMinResolution(int min_width, int min_height) { | 54 void QualityScaler::SetMinResolution(int min_width, int min_height) { | 
| 42 min_width_ = min_width; | 55 min_width_ = min_width; | 
| 43 min_height_ = min_height; | 56 min_height_ = min_height; | 
| 44 } | 57 } | 
| 45 | 58 | 
| 46 // Report framerate(fps) to estimate # of samples. | 59 // Report framerate(fps) to estimate # of samples. | 
| 47 void QualityScaler::ReportFramerate(int framerate) { | 60 void QualityScaler::ReportFramerate(int framerate) { | 
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 141 } | 154 } | 
| 142 | 155 | 
| 143 void QualityScaler::AdjustScale(bool up) { | 156 void QualityScaler::AdjustScale(bool up) { | 
| 144 downscale_shift_ += up ? -1 : 1; | 157 downscale_shift_ += up ? -1 : 1; | 
| 145 if (downscale_shift_ < 0) | 158 if (downscale_shift_ < 0) | 
| 146 downscale_shift_ = 0; | 159 downscale_shift_ = 0; | 
| 147 ClearSamples(); | 160 ClearSamples(); | 
| 148 } | 161 } | 
| 149 | 162 | 
| 150 } // namespace webrtc | 163 } // namespace webrtc | 
| OLD | NEW |