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> | |
nisse-webrtc
2016/09/15 08:22:12
Why switching from cmath to math.h? Just to drop t
kthelgason
2016/09/15 08:25:15
Yep.
| |
14 | |
13 #include <algorithm> | 15 #include <algorithm> |
14 #include <cmath> | 16 |
17 // Android does not support log2 | |
nisse-webrtc
2016/09/15 08:22:12
[citation needed]
Is there any documentation or b
kthelgason
2016/09/15 08:25:15
I found some references to this on the internet, i
| |
18 #if defined(WEBRTC_ANDROID) | |
19 #define log2(x) (log(x) / log(2)) | |
20 #endif | |
15 | 21 |
16 namespace webrtc { | 22 namespace webrtc { |
17 | 23 |
18 namespace { | 24 namespace { |
19 // Threshold constant used until first downscale (to permit fast rampup). | 25 // Threshold constant used until first downscale (to permit fast rampup). |
20 static const int kMeasureSecondsFastUpscale = 2; | 26 static const int kMeasureSecondsFastUpscale = 2; |
21 static const int kMeasureSecondsUpscale = 5; | 27 static const int kMeasureSecondsUpscale = 5; |
22 static const int kMeasureSecondsDownscale = 5; | 28 static const int kMeasureSecondsDownscale = 5; |
23 static const int kFramedropPercentThreshold = 60; | 29 static const int kFramedropPercentThreshold = 60; |
24 // Min width/height to downscale to, set to not go below QVGA, but with some | 30 // 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); | 181 scaled_buffer->ScaleFrom(frame); |
176 | 182 |
177 return scaled_buffer; | 183 return scaled_buffer; |
178 } | 184 } |
179 | 185 |
180 void QualityScaler::UpdateTargetResolution(int width, int height) { | 186 void QualityScaler::UpdateTargetResolution(int width, int height) { |
181 if (width < kMinDownscaleDimension || height < kMinDownscaleDimension) { | 187 if (width < kMinDownscaleDimension || height < kMinDownscaleDimension) { |
182 maximum_shift_ = 0; | 188 maximum_shift_ = 0; |
183 } else { | 189 } else { |
184 maximum_shift_ = static_cast<int>( | 190 maximum_shift_ = static_cast<int>( |
185 std::log2(std::min(width, height) / kMinDownscaleDimension)); | 191 log2(std::min(width, height) / kMinDownscaleDimension)); |
186 } | 192 } |
187 target_res_ = Resolution{width, height}; | 193 target_res_ = Resolution{width, height}; |
188 } | 194 } |
189 | 195 |
190 void QualityScaler::ClearSamples() { | 196 void QualityScaler::ClearSamples() { |
191 framedrop_percent_.Reset(); | 197 framedrop_percent_.Reset(); |
192 average_qp_.Reset(); | 198 average_qp_.Reset(); |
193 } | 199 } |
194 | 200 |
195 | 201 |
196 } // namespace webrtc | 202 } // namespace webrtc |
OLD | NEW |