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 | 10 |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 39 kKeepScaleAtHighQp, | 39 kKeepScaleAtHighQp, |
| 40 kScaleDown, | 40 kScaleDown, |
| 41 kScaleDownAboveHighQp, | 41 kScaleDownAboveHighQp, |
| 42 kScaleUp | 42 kScaleUp |
| 43 }; | 43 }; |
| 44 enum BadQualityMetric { kDropFrame, kReportLowQP }; | 44 enum BadQualityMetric { kDropFrame, kReportLowQP }; |
| 45 | 45 |
| 46 QualityScalerTest() { | 46 QualityScalerTest() { |
| 47 input_frame_.CreateEmptyFrame(kWidth, kHeight, kWidth, kHalfWidth, | 47 input_frame_.CreateEmptyFrame(kWidth, kHeight, kWidth, kHalfWidth, |
| 48 kHalfWidth); | 48 kHalfWidth); |
| 49 qs_.Init(kMaxQp / QualityScaler::kDefaultLowQpDenominator, kHighQp, false); | 49 qs_.Init(kMaxQp / QualityScaler::kDefaultLowQpDenominator, kHighQp, false, |
| 50 0, 0, 0); | |
|
pbos-webrtc
2016/02/10 13:43:21
Add tests for this with non-zero values.
AlexG
2016/02/10 19:07:17
Done.
| |
| 50 qs_.ReportFramerate(kFramerate); | 51 qs_.ReportFramerate(kFramerate); |
| 51 qs_.OnEncodeFrame(input_frame_); | 52 qs_.OnEncodeFrame(input_frame_); |
| 52 } | 53 } |
| 53 | 54 |
| 54 bool TriggerScale(ScaleDirection scale_direction) { | 55 bool TriggerScale(ScaleDirection scale_direction) { |
| 55 qs_.OnEncodeFrame(input_frame_); | 56 qs_.OnEncodeFrame(input_frame_); |
| 56 int initial_width = qs_.GetScaledResolution().width; | 57 int initial_width = qs_.GetScaledResolution().width; |
| 57 for (int i = 0; i < kFramerate * kNumSeconds; ++i) { | 58 for (int i = 0; i < kFramerate * kNumSeconds; ++i) { |
| 58 switch (scale_direction) { | 59 switch (scale_direction) { |
| 59 case kScaleUp: | 60 case kScaleUp: |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 291 return res; | 292 return res; |
| 292 } | 293 } |
| 293 | 294 |
| 294 void QualityScalerTest::VerifyQualityAdaptation( | 295 void QualityScalerTest::VerifyQualityAdaptation( |
| 295 int initial_framerate, | 296 int initial_framerate, |
| 296 int seconds, | 297 int seconds, |
| 297 bool expect_spatial_resize, | 298 bool expect_spatial_resize, |
| 298 bool expect_framerate_reduction) { | 299 bool expect_framerate_reduction) { |
| 299 const int kDisabledBadQpThreshold = kMaxQp + 1; | 300 const int kDisabledBadQpThreshold = kMaxQp + 1; |
| 300 qs_.Init(kMaxQp / QualityScaler::kDefaultLowQpDenominator, | 301 qs_.Init(kMaxQp / QualityScaler::kDefaultLowQpDenominator, |
| 301 kDisabledBadQpThreshold, true); | 302 kDisabledBadQpThreshold, true, 0, 0, 0); |
| 302 qs_.OnEncodeFrame(input_frame_); | 303 qs_.OnEncodeFrame(input_frame_); |
| 303 int init_width = qs_.GetScaledResolution().width; | 304 int init_width = qs_.GetScaledResolution().width; |
| 304 int init_height = qs_.GetScaledResolution().height; | 305 int init_height = qs_.GetScaledResolution().height; |
| 305 | 306 |
| 306 // Test reducing framerate by dropping frame continuously. | 307 // Test reducing framerate by dropping frame continuously. |
| 307 QualityScalerTest::Resolution res = | 308 QualityScalerTest::Resolution res = |
| 308 TriggerResolutionChange(kDropFrame, seconds, initial_framerate); | 309 TriggerResolutionChange(kDropFrame, seconds, initial_framerate); |
| 309 | 310 |
| 310 if (expect_framerate_reduction) { | 311 if (expect_framerate_reduction) { |
| 311 EXPECT_LT(res.framerate, initial_framerate); | 312 EXPECT_LT(res.framerate, initial_framerate); |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 416 DownscaleEndsAt(1600, 800, 200, 100); | 417 DownscaleEndsAt(1600, 800, 200, 100); |
| 417 } | 418 } |
| 418 | 419 |
| 419 TEST_F(QualityScalerTest, RespectsMinResolutionHeight) { | 420 TEST_F(QualityScalerTest, RespectsMinResolutionHeight) { |
| 420 // Should end at 100x200, as height can't go lower. | 421 // Should end at 100x200, as height can't go lower. |
| 421 qs_.SetMinResolution(10, 200); | 422 qs_.SetMinResolution(10, 200); |
| 422 DownscaleEndsAt(800, 1600, 100, 200); | 423 DownscaleEndsAt(800, 1600, 100, 200); |
| 423 } | 424 } |
| 424 | 425 |
| 425 } // namespace webrtc | 426 } // namespace webrtc |
| OLD | NEW |