Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(357)

Side by Side Diff: webrtc/modules/video_coding/utility/quality_scaler_unittest.cc

Issue 1867643003: Make QualityScaler not downscale below QVGA. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: feedback Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 14 matching lines...) Expand all
25 static const int kNormalQp = 30; 25 static const int kNormalQp = 30;
26 static const int kHighQp = 40; 26 static const int kHighQp = 40;
27 static const int kMaxQp = 56; 27 static const int kMaxQp = 56;
28 static const int kDisabledBadQpThreshold = kMaxQp + 1; 28 static const int kDisabledBadQpThreshold = kMaxQp + 1;
29 static const int kLowInitialBitrateKbps = 300; 29 static const int kLowInitialBitrateKbps = 300;
30 // These values need to be in sync with corresponding constants 30 // These values need to be in sync with corresponding constants
31 // in quality_scaler.cc 31 // in quality_scaler.cc
32 static const int kMeasureSecondsDownscale = 3; 32 static const int kMeasureSecondsDownscale = 3;
33 static const int kMeasureSecondsFastUpscale = 2; 33 static const int kMeasureSecondsFastUpscale = 2;
34 static const int kMeasureSecondsUpscale = 5; 34 static const int kMeasureSecondsUpscale = 5;
35 static const int kMinDownscaleDimension = 160;
35 } // namespace 36 } // namespace
36 37
37 class QualityScalerTest : public ::testing::Test { 38 class QualityScalerTest : public ::testing::Test {
38 public: 39 public:
39 // Temporal and spatial resolution. 40 // Temporal and spatial resolution.
40 struct Resolution { 41 struct Resolution {
41 int framerate; 42 int framerate;
42 int width; 43 int width;
43 int height; 44 int height;
44 }; 45 };
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 } 194 }
194 } 195 }
195 196
196 void QualityScalerTest::ContinuouslyDownscalesByHalfDimensionsAndBackUp() { 197 void QualityScalerTest::ContinuouslyDownscalesByHalfDimensionsAndBackUp() {
197 const int initial_min_dimension = input_frame_.width() < input_frame_.height() 198 const int initial_min_dimension = input_frame_.width() < input_frame_.height()
198 ? input_frame_.width() 199 ? input_frame_.width()
199 : input_frame_.height(); 200 : input_frame_.height();
200 int min_dimension = initial_min_dimension; 201 int min_dimension = initial_min_dimension;
201 int current_shift = 0; 202 int current_shift = 0;
202 // Drop all frames to force-trigger downscaling. 203 // Drop all frames to force-trigger downscaling.
203 while (min_dimension >= 2 * QualityScaler::kDefaultMinDownscaleDimension) { 204 while (min_dimension >= 2 * kMinDownscaleDimension) {
204 EXPECT_TRUE(TriggerScale(kScaleDown)) << "No downscale within " 205 EXPECT_TRUE(TriggerScale(kScaleDown)) << "No downscale within "
205 << kNumSeconds << " seconds."; 206 << kNumSeconds << " seconds.";
206 qs_.OnEncodeFrame(input_frame_); 207 qs_.OnEncodeFrame(input_frame_);
207 QualityScaler::Resolution res = qs_.GetScaledResolution(); 208 QualityScaler::Resolution res = qs_.GetScaledResolution();
208 min_dimension = res.width < res.height ? res.width : res.height; 209 min_dimension = res.width < res.height ? res.width : res.height;
209 ++current_shift; 210 ++current_shift;
210 ASSERT_EQ(input_frame_.width() >> current_shift, res.width); 211 ASSERT_EQ(input_frame_.width() >> current_shift, res.width);
211 ASSERT_EQ(input_frame_.height() >> current_shift, res.height); 212 ASSERT_EQ(input_frame_.height() >> current_shift, res.height);
212 ExpectScaleUsingReportedResolution(); 213 ExpectScaleUsingReportedResolution();
213 } 214 }
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 365
365 // When starting from a low framerate, only spatial size will be changed. 366 // When starting from a low framerate, only spatial size will be changed.
366 TEST_F(QualityScalerTest, ChangeSpatialSizeOnly) { 367 TEST_F(QualityScalerTest, ChangeSpatialSizeOnly) {
367 qs_.ReportFramerate(kFramerate >> 1); 368 qs_.ReportFramerate(kFramerate >> 1);
368 VerifyQualityAdaptation(kFramerate >> 1, kMeasureSecondsDownscale * 2, 369 VerifyQualityAdaptation(kFramerate >> 1, kMeasureSecondsDownscale * 2,
369 kMeasureSecondsUpscale * 2, true, false); 370 kMeasureSecondsUpscale * 2, true, false);
370 } 371 }
371 372
372 TEST_F(QualityScalerTest, DoesNotDownscaleBelow2xDefaultMinDimensionsWidth) { 373 TEST_F(QualityScalerTest, DoesNotDownscaleBelow2xDefaultMinDimensionsWidth) {
373 DoesNotDownscaleFrameDimensions( 374 DoesNotDownscaleFrameDimensions(
374 2 * QualityScaler::kDefaultMinDownscaleDimension - 1, 1000); 375 2 * kMinDownscaleDimension - 1, 1000);
375 } 376 }
376 377
377 TEST_F(QualityScalerTest, DoesNotDownscaleBelow2xDefaultMinDimensionsHeight) { 378 TEST_F(QualityScalerTest, DoesNotDownscaleBelow2xDefaultMinDimensionsHeight) {
378 DoesNotDownscaleFrameDimensions( 379 DoesNotDownscaleFrameDimensions(
379 1000, 2 * QualityScaler::kDefaultMinDownscaleDimension - 1); 380 1000, 2 * kMinDownscaleDimension - 1);
380 } 381 }
381 382
382 TEST_F(QualityScalerTest, DownscaleToVgaOnLowInitialBitrate) { 383 TEST_F(QualityScalerTest, DownscaleToVgaOnLowInitialBitrate) {
383 qs_.Init(kMaxQp / QualityScaler::kDefaultLowQpDenominator, 384 qs_.Init(kMaxQp / QualityScaler::kDefaultLowQpDenominator,
384 kDisabledBadQpThreshold, true, 385 kDisabledBadQpThreshold, true,
385 kLowInitialBitrateKbps, kWidth, kHeight, kFramerate); 386 kLowInitialBitrateKbps, kWidth, kHeight, kFramerate);
386 qs_.OnEncodeFrame(input_frame_); 387 qs_.OnEncodeFrame(input_frame_);
387 int init_width = qs_.GetScaledResolution().width; 388 int init_width = qs_.GetScaledResolution().width;
388 int init_height = qs_.GetScaledResolution().height; 389 int init_height = qs_.GetScaledResolution().height;
389 EXPECT_LE(init_width, kWidthVga); 390 EXPECT_LE(init_width, kWidthVga);
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
473 EXPECT_EQ(last_height, res.height); 474 EXPECT_EQ(last_height, res.height);
474 EXPECT_EQ(end_width, res.width); 475 EXPECT_EQ(end_width, res.width);
475 EXPECT_EQ(end_height, res.height); 476 EXPECT_EQ(end_height, res.height);
476 break; 477 break;
477 } 478 }
478 last_width = res.width; 479 last_width = res.width;
479 last_height = res.height; 480 last_height = res.height;
480 } 481 }
481 } 482 }
482 483
483 TEST_F(QualityScalerTest, DefaultDownscalesTo160x90) { 484 TEST_F(QualityScalerTest, DownscalesTo320x180) {
484 DownscaleEndsAt(320, 180, 160, 90); 485 DownscaleEndsAt(640, 360, 320, 180);
485 } 486 }
486 487
487 TEST_F(QualityScalerTest, DefaultDownscalesTo90x160) { 488 TEST_F(QualityScalerTest, DownscalesTo180x320) {
488 DownscaleEndsAt(180, 320, 90, 160); 489 DownscaleEndsAt(360, 640, 180, 320);
489 } 490 }
490 491
491 TEST_F(QualityScalerTest, DefaultDownscalesFrom1280x720To160x90) { 492 TEST_F(QualityScalerTest, DownscalesFrom1280x720To320x180) {
492 DownscaleEndsAt(1280, 720, 160, 90); 493 DownscaleEndsAt(1280, 720, 320, 180);
493 } 494 }
494 495
495 TEST_F(QualityScalerTest, DefaultDoesntDownscaleBelow160x90) { 496 TEST_F(QualityScalerTest, DoesntDownscaleInitialQvga) {
496 DownscaleEndsAt(320 - 1, 180 - 1, 320 - 1, 180 - 1); 497 DownscaleEndsAt(320, 180, 320, 180);
497 }
498
499 TEST_F(QualityScalerTest, DefaultDoesntDownscaleBelow90x160) {
500 DownscaleEndsAt(180 - 1, 320 - 1, 180 - 1, 320 - 1);
501 }
502
503 TEST_F(QualityScalerTest, RespectsMinResolutionWidth) {
504 // Should end at 200x100, as width can't go lower.
505 qs_.SetMinResolution(200, 10);
506 DownscaleEndsAt(1600, 800, 200, 100);
507 }
508
509 TEST_F(QualityScalerTest, RespectsMinResolutionHeight) {
510 // Should end at 100x200, as height can't go lower.
511 qs_.SetMinResolution(10, 200);
512 DownscaleEndsAt(800, 1600, 100, 200);
513 } 498 }
514 499
515 } // namespace webrtc 500 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698