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

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

Issue 1900483004: Add QVGA to thresholds for initial quality. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: 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
« no previous file with comments | « no previous file | webrtc/modules/video_coding/utility/quality_scaler_unittest.cc » ('j') | 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 #include "webrtc/modules/video_coding/utility/quality_scaler.h" 10 #include "webrtc/modules/video_coding/utility/quality_scaler.h"
11 11
12 namespace webrtc { 12 namespace webrtc {
13 13
14 namespace { 14 namespace {
15 static const int kMinFps = 5; 15 static const int kMinFps = 5;
16 // Threshold constant used until first downscale (to permit fast rampup). 16 // Threshold constant used until first downscale (to permit fast rampup).
17 static const int kMeasureSecondsFastUpscale = 2; 17 static const int kMeasureSecondsFastUpscale = 2;
18 static const int kMeasureSecondsUpscale = 5; 18 static const int kMeasureSecondsUpscale = 5;
19 static const int kMeasureSecondsDownscale = 5; 19 static const int kMeasureSecondsDownscale = 5;
20 static const int kFramedropPercentThreshold = 60; 20 static const int kFramedropPercentThreshold = 60;
21 static const int kHdResolutionThreshold = 700 * 500;
22 static const int kHdBitrateThresholdKbps = 500;
23 // Min width/height to downscale to, set to not go below QVGA, but with some 21 // Min width/height to downscale to, set to not go below QVGA, but with some
24 // margin to permit "almost-QVGA" resolutions, such as QCIF. 22 // margin to permit "almost-QVGA" resolutions, such as QCIF.
25 static const int kMinDownscaleDimension = 140; 23 static const int kMinDownscaleDimension = 140;
26 } // namespace 24 } // namespace
27 25
28 QualityScaler::QualityScaler() 26 QualityScaler::QualityScaler()
29 : low_qp_threshold_(-1), framerate_down_(false) {} 27 : low_qp_threshold_(-1), framerate_down_(false) {}
30 28
31 void QualityScaler::Init(int low_qp_threshold, 29 void QualityScaler::Init(int low_qp_threshold,
32 int high_qp_threshold, 30 int high_qp_threshold,
33 bool use_framerate_reduction, 31 bool use_framerate_reduction,
34 int initial_bitrate_kbps, 32 int initial_bitrate_kbps,
35 int width, 33 int width,
36 int height, 34 int height,
37 int fps) { 35 int fps) {
38 ClearSamples(); 36 ClearSamples();
39 low_qp_threshold_ = low_qp_threshold; 37 low_qp_threshold_ = low_qp_threshold;
40 high_qp_threshold_ = high_qp_threshold; 38 high_qp_threshold_ = high_qp_threshold;
41 use_framerate_reduction_ = use_framerate_reduction; 39 use_framerate_reduction_ = use_framerate_reduction;
42 downscale_shift_ = 0; 40 downscale_shift_ = 0;
43 // Use a faster window for upscaling initially (but be more graceful later). 41 // Use a faster window for upscaling initially (but be more graceful later).
44 // This enables faster initial rampups without risking strong up-down 42 // This enables faster initial rampups without risking strong up-down
45 // behavior later. 43 // behavior later.
46 measure_seconds_upscale_ = kMeasureSecondsFastUpscale; 44 measure_seconds_upscale_ = kMeasureSecondsFastUpscale;
47 const int init_width = width; 45 const int init_width = width;
48 const int init_height = height; 46 const int init_height = height;
49 // TODO(glaznev): Investigate using thresholds for other resolutions 47 if (initial_bitrate_kbps > 0) {
50 // or threshold tables. 48 // Resolutions a bit above their actual values to permit near-VGA and
51 if (initial_bitrate_kbps > 0 && 49 // near-QVGA resolutions to use the same mechanism.
52 initial_bitrate_kbps < kHdBitrateThresholdKbps) { 50 int init_num_pixels = width * height;
53 // Start scaling to roughly VGA. 51 static const int kVgaBitrateThresholdKbps = 500;
AlexG 2016/04/18 20:30:03 Why not to keep all these constants at the start w
pbos-webrtc 2016/04/18 20:41:44 Done.
54 while (width * height > kHdResolutionThreshold) { 52 static const int kVgaNumPixels = 700 * 500; // 640x480
53 if (initial_bitrate_kbps < kVgaBitrateThresholdKbps)
54 init_num_pixels = kVgaNumPixels;
55 static const int kQvgaBitrateThresholdKbps = 250;
56 static const int kQvgaNumPixels = 400 * 300; // 320x240
57 if (initial_bitrate_kbps < kQvgaBitrateThresholdKbps)
58 init_num_pixels = kQvgaNumPixels;
59 while (width * height > init_num_pixels) {
55 ++downscale_shift_; 60 ++downscale_shift_;
56 width /= 2; 61 width /= 2;
57 height /= 2; 62 height /= 2;
58 } 63 }
59 } 64 }
60 UpdateTargetResolution(init_width, init_height); 65 UpdateTargetResolution(init_width, init_height);
61 ReportFramerate(fps); 66 ReportFramerate(fps);
62 target_framerate_ = -1; 67 target_framerate_ = -1;
63 } 68 }
64 69
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 downscale_shift_ = 0; 182 downscale_shift_ = 0;
178 if (!up) { 183 if (!up) {
179 // Hit first downscale, start using a slower threshold for going up. 184 // Hit first downscale, start using a slower threshold for going up.
180 measure_seconds_upscale_ = kMeasureSecondsUpscale; 185 measure_seconds_upscale_ = kMeasureSecondsUpscale;
181 UpdateSampleCounts(); 186 UpdateSampleCounts();
182 } 187 }
183 ClearSamples(); 188 ClearSamples();
184 } 189 }
185 190
186 } // namespace webrtc 191 } // namespace webrtc
OLDNEW
« no previous file with comments | « no previous file | webrtc/modules/video_coding/utility/quality_scaler_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698