| 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 |
| 11 #include "webrtc/modules/video_coding/utility/quality_scaler.h" | 11 #include "webrtc/modules/video_coding/utility/quality_scaler.h" |
| 12 | 12 |
| 13 #include <math.h> |
| 14 |
| 13 #include <algorithm> | 15 #include <algorithm> |
| 14 #include <cmath> | 16 |
| 17 // TODO(kthelgason): Some versions of Android have issues with log2. |
| 18 // See https://code.google.com/p/android/issues/detail?id=212634 for details |
| 19 #if defined(WEBRTC_ANDROID) |
| 20 #define log2(x) (log(x) / log(2)) |
| 21 #endif |
| 15 | 22 |
| 16 namespace webrtc { | 23 namespace webrtc { |
| 17 | 24 |
| 18 namespace { | 25 namespace { |
| 19 // Threshold constant used until first downscale (to permit fast rampup). | 26 // Threshold constant used until first downscale (to permit fast rampup). |
| 20 static const int kMeasureSecondsFastUpscale = 2; | 27 static const int kMeasureSecondsFastUpscale = 2; |
| 21 static const int kMeasureSecondsUpscale = 5; | 28 static const int kMeasureSecondsUpscale = 5; |
| 22 static const int kMeasureSecondsDownscale = 5; | 29 static const int kMeasureSecondsDownscale = 5; |
| 23 static const int kFramedropPercentThreshold = 60; | 30 static const int kFramedropPercentThreshold = 60; |
| 24 // Min width/height to downscale to, set to not go below QVGA, but with some | 31 // Min width/height to downscale to, set to not go below QVGA, but with some |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 scaled_buffer->ScaleFrom(frame); | 182 scaled_buffer->ScaleFrom(frame); |
| 176 | 183 |
| 177 return scaled_buffer; | 184 return scaled_buffer; |
| 178 } | 185 } |
| 179 | 186 |
| 180 void QualityScaler::UpdateTargetResolution(int width, int height) { | 187 void QualityScaler::UpdateTargetResolution(int width, int height) { |
| 181 if (width < kMinDownscaleDimension || height < kMinDownscaleDimension) { | 188 if (width < kMinDownscaleDimension || height < kMinDownscaleDimension) { |
| 182 maximum_shift_ = 0; | 189 maximum_shift_ = 0; |
| 183 } else { | 190 } else { |
| 184 maximum_shift_ = static_cast<int>( | 191 maximum_shift_ = static_cast<int>( |
| 185 std::log2(std::min(width, height) / kMinDownscaleDimension)); | 192 log2(std::min(width, height) / kMinDownscaleDimension)); |
| 186 } | 193 } |
| 187 target_res_ = Resolution{width, height}; | 194 target_res_ = Resolution{width, height}; |
| 188 } | 195 } |
| 189 | 196 |
| 190 void QualityScaler::ClearSamples() { | 197 void QualityScaler::ClearSamples() { |
| 191 framedrop_percent_.Reset(); | 198 framedrop_percent_.Reset(); |
| 192 average_qp_.Reset(); | 199 average_qp_.Reset(); |
| 193 } | 200 } |
| 194 | 201 |
| 195 | 202 |
| 196 } // namespace webrtc | 203 } // namespace webrtc |
| OLD | NEW |