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

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

Issue 2204533004: Revert "Add QVGA to thresholds for initial quality." Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 4 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
« no previous file with comments | « webrtc/modules/video_coding/utility/quality_scaler.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
11 #include "webrtc/modules/video_coding/utility/quality_scaler.h" 11 #include "webrtc/modules/video_coding/utility/quality_scaler.h"
12 12
13 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
14 14
15 namespace webrtc { 15 namespace webrtc {
16 namespace { 16 namespace {
17 static const int kNumSeconds = 10; 17 static const int kNumSeconds = 10;
18 static const int kWidth = 1920; 18 static const int kWidth = 1920;
19 static const int kWidthVga = 640;
20 static const int kHalfWidth = kWidth / 2;
21 static const int kWidthVga = 640;
19 static const int kHeight = 1080; 22 static const int kHeight = 1080;
23 static const int kHeightVga = 480;
20 static const int kFramerate = 30; 24 static const int kFramerate = 30;
21 static const int kLowQp = 15; 25 static const int kLowQp = 15;
22 static const int kNormalQp = 30; 26 static const int kNormalQp = 30;
23 static const int kLowQpThreshold = 18; 27 static const int kLowQpThreshold = 18;
24 static const int kHighQp = 40; 28 static const int kHighQp = 40;
25 static const int kDisabledBadQpThreshold = 64; 29 static const int kDisabledBadQpThreshold = 64;
26 static const int kLowInitialBitrateKbps = 300; 30 static const int kLowInitialBitrateKbps = 300;
27 // These values need to be in sync with corresponding constants 31 // These values need to be in sync with corresponding constants
28 // in quality_scaler.cc 32 // in quality_scaler.cc
29 static const int kMeasureSecondsFastUpscale = 2; 33 static const int kMeasureSecondsFastUpscale = 2;
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 DoesNotDownscaleFrameDimensions( 253 DoesNotDownscaleFrameDimensions(
250 2 * kMinDownscaleDimension - 1, 1000); 254 2 * kMinDownscaleDimension - 1, 1000);
251 } 255 }
252 256
253 TEST_F(QualityScalerTest, DoesNotDownscaleBelow2xDefaultMinDimensionsHeight) { 257 TEST_F(QualityScalerTest, DoesNotDownscaleBelow2xDefaultMinDimensionsHeight) {
254 DoesNotDownscaleFrameDimensions( 258 DoesNotDownscaleFrameDimensions(
255 1000, 2 * kMinDownscaleDimension - 1); 259 1000, 2 * kMinDownscaleDimension - 1);
256 } 260 }
257 261
258 TEST_F(QualityScalerTest, DownscaleToVgaOnLowInitialBitrate) { 262 TEST_F(QualityScalerTest, DownscaleToVgaOnLowInitialBitrate) {
259 static const int kWidth720p = 1280; 263 qs_.Init(kLowQpThreshold, kDisabledBadQpThreshold, true,
260 static const int kHeight720p = 720; 264 kLowInitialBitrateKbps, kWidth, kHeight, kFramerate);
261 static const int kInitialBitrateKbps = 300; 265 qs_.OnEncodeFrame(input_frame_);
262 input_frame_ = I420Buffer::Create(kWidth720p, kHeight720p);
263 qs_.Init(kLowQpThreshold, kDisabledBadQpThreshold, kInitialBitrateKbps,
264 kWidth720p, kHeight720p, kFramerate);
265 qs_.OnEncodeFrame(input_frame_->width(), input_frame_->height());
266 int init_width = qs_.GetScaledResolution().width; 266 int init_width = qs_.GetScaledResolution().width;
267 int init_height = qs_.GetScaledResolution().height; 267 int init_height = qs_.GetScaledResolution().height;
268 EXPECT_EQ(640, init_width); 268 EXPECT_LE(init_width, kWidthVga);
269 EXPECT_EQ(360, init_height); 269 EXPECT_LE(init_height, kHeightVga);
270 }
271
272 TEST_F(QualityScalerTest, DownscaleToQvgaOnLowerInitialBitrate) {
273 static const int kWidth720p = 1280;
274 static const int kHeight720p = 720;
275 static const int kInitialBitrateKbps = 200;
276 input_frame_ = I420Buffer::Create(kWidth720p, kHeight720p);
277 qs_.Init(kLowQpThreshold, kDisabledBadQpThreshold, kInitialBitrateKbps,
278 kWidth720p, kHeight720p, kFramerate);
279 qs_.OnEncodeFrame(input_frame_->width(), input_frame_->height());
280 int init_width = qs_.GetScaledResolution().width;
281 int init_height = qs_.GetScaledResolution().height;
282 EXPECT_EQ(320, init_width);
283 EXPECT_EQ(180, init_height);
284 } 270 }
285 271
286 TEST_F(QualityScalerTest, DownscaleAfterMeasuredSecondsThenSlowerBackUp) { 272 TEST_F(QualityScalerTest, DownscaleAfterMeasuredSecondsThenSlowerBackUp) {
287 qs_.Init(kLowQpThreshold, kHighQp, 0, kWidth, kHeight, kFramerate); 273 qs_.Init(kLowQpThreshold, kHighQp, 0, kWidth, kHeight, kFramerate);
288 qs_.OnEncodeFrame(input_frame_->width(), input_frame_->height()); 274 qs_.OnEncodeFrame(input_frame_->width(), input_frame_->height());
289 QualityScaler::Resolution initial_res = qs_.GetScaledResolution(); 275 QualityScaler::Resolution initial_res = qs_.GetScaledResolution();
290 276
291 // Should not downscale if less than kMeasureSecondsDownscale seconds passed. 277 // Should not downscale if less than kMeasureSecondsDownscale seconds passed.
292 for (int i = 0; i < kFramerate * kMeasureSecondsDownscale - 1; ++i) { 278 for (int i = 0; i < kFramerate * kMeasureSecondsDownscale - 1; ++i) {
293 qs_.ReportQP(kHighQp + 1); 279 qs_.ReportQP(kHighQp + 1);
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 363
378 TEST_F(QualityScalerTest, DownscalesFrom1280x720To320x180) { 364 TEST_F(QualityScalerTest, DownscalesFrom1280x720To320x180) {
379 DownscaleEndsAt(1280, 720, 320, 180); 365 DownscaleEndsAt(1280, 720, 320, 180);
380 } 366 }
381 367
382 TEST_F(QualityScalerTest, DoesntDownscaleInitialQvga) { 368 TEST_F(QualityScalerTest, DoesntDownscaleInitialQvga) {
383 DownscaleEndsAt(320, 180, 320, 180); 369 DownscaleEndsAt(320, 180, 320, 180);
384 } 370 }
385 371
386 } // namespace webrtc 372 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/video_coding/utility/quality_scaler.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698