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

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: move constants 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;
24 // Initial resolutions corresponding to a bitrate. Aa bit above their actual
25 // values to permit near-VGA and near-QVGA resolutions to use the same
26 // mechanism.
27 static const int kVgaBitrateThresholdKbps = 500;
28 static const int kVgaNumPixels = 700 * 500; // 640x480
29 static const int kQvgaBitrateThresholdKbps = 250;
30 static const int kQvgaNumPixels = 400 * 300; // 320x240
26 } // namespace 31 } // namespace
27 32
28 QualityScaler::QualityScaler() 33 QualityScaler::QualityScaler()
29 : low_qp_threshold_(-1), framerate_down_(false) {} 34 : low_qp_threshold_(-1), framerate_down_(false) {}
30 35
31 void QualityScaler::Init(int low_qp_threshold, 36 void QualityScaler::Init(int low_qp_threshold,
32 int high_qp_threshold, 37 int high_qp_threshold,
33 bool use_framerate_reduction, 38 bool use_framerate_reduction,
34 int initial_bitrate_kbps, 39 int initial_bitrate_kbps,
35 int width, 40 int width,
36 int height, 41 int height,
37 int fps) { 42 int fps) {
38 ClearSamples(); 43 ClearSamples();
39 low_qp_threshold_ = low_qp_threshold; 44 low_qp_threshold_ = low_qp_threshold;
40 high_qp_threshold_ = high_qp_threshold; 45 high_qp_threshold_ = high_qp_threshold;
41 use_framerate_reduction_ = use_framerate_reduction; 46 use_framerate_reduction_ = use_framerate_reduction;
42 downscale_shift_ = 0; 47 downscale_shift_ = 0;
43 // Use a faster window for upscaling initially (but be more graceful later). 48 // Use a faster window for upscaling initially (but be more graceful later).
44 // This enables faster initial rampups without risking strong up-down 49 // This enables faster initial rampups without risking strong up-down
45 // behavior later. 50 // behavior later.
46 measure_seconds_upscale_ = kMeasureSecondsFastUpscale; 51 measure_seconds_upscale_ = kMeasureSecondsFastUpscale;
47 const int init_width = width; 52 const int init_width = width;
48 const int init_height = height; 53 const int init_height = height;
49 // TODO(glaznev): Investigate using thresholds for other resolutions 54 if (initial_bitrate_kbps > 0) {
50 // or threshold tables. 55 int init_num_pixels = width * height;
51 if (initial_bitrate_kbps > 0 && 56 if (initial_bitrate_kbps < kVgaBitrateThresholdKbps)
52 initial_bitrate_kbps < kHdBitrateThresholdKbps) { 57 init_num_pixels = kVgaNumPixels;
53 // Start scaling to roughly VGA. 58 if (initial_bitrate_kbps < kQvgaBitrateThresholdKbps)
54 while (width * height > kHdResolutionThreshold) { 59 init_num_pixels = kQvgaNumPixels;
60 while (width * height > init_num_pixels) {
55 ++downscale_shift_; 61 ++downscale_shift_;
56 width /= 2; 62 width /= 2;
57 height /= 2; 63 height /= 2;
58 } 64 }
59 } 65 }
60 UpdateTargetResolution(init_width, init_height); 66 UpdateTargetResolution(init_width, init_height);
61 ReportFramerate(fps); 67 ReportFramerate(fps);
62 target_framerate_ = -1; 68 target_framerate_ = -1;
63 } 69 }
64 70
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 downscale_shift_ = 0; 183 downscale_shift_ = 0;
178 if (!up) { 184 if (!up) {
179 // Hit first downscale, start using a slower threshold for going up. 185 // Hit first downscale, start using a slower threshold for going up.
180 measure_seconds_upscale_ = kMeasureSecondsUpscale; 186 measure_seconds_upscale_ = kMeasureSecondsUpscale;
181 UpdateSampleCounts(); 187 UpdateSampleCounts();
182 } 188 }
183 ClearSamples(); 189 ClearSamples();
184 } 190 }
185 191
186 } // namespace webrtc 192 } // 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