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

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

Issue 2434803002: QualityScaler reset bugfix (Closed)
Patch Set: Created 4 years, 2 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 | 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
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 int high_qp_threshold, 81 int high_qp_threshold,
82 int initial_bitrate_kbps, 82 int initial_bitrate_kbps,
83 int width, 83 int width,
84 int height, 84 int height,
85 int fps) { 85 int fps) {
86 ClearSamples(); 86 ClearSamples();
87 low_qp_threshold_ = low_qp_threshold; 87 low_qp_threshold_ = low_qp_threshold;
88 high_qp_threshold_ = high_qp_threshold; 88 high_qp_threshold_ = high_qp_threshold;
89 downscale_shift_ = 0; 89 downscale_shift_ = 0;
90 fast_rampup_ = true; 90 fast_rampup_ = true;
91 ReportFramerate(fps);
92 91
93 const int init_width = width; 92 const int init_width = width;
94 const int init_height = height; 93 const int init_height = height;
95 if (initial_bitrate_kbps > 0) { 94 if (initial_bitrate_kbps > 0) {
96 int init_num_pixels = width * height; 95 int init_num_pixels = width * height;
97 if (initial_bitrate_kbps < kVgaBitrateThresholdKbps) 96 if (initial_bitrate_kbps < kVgaBitrateThresholdKbps)
98 init_num_pixels = kVgaNumPixels; 97 init_num_pixels = kVgaNumPixels;
99 if (initial_bitrate_kbps < kQvgaBitrateThresholdKbps) 98 if (initial_bitrate_kbps < kQvgaBitrateThresholdKbps)
100 init_num_pixels = kQvgaNumPixels; 99 init_num_pixels = kQvgaNumPixels;
101 while (width * height > init_num_pixels) { 100 while (width * height > init_num_pixels) {
102 ++downscale_shift_; 101 ++downscale_shift_;
103 width /= 2; 102 width /= 2;
104 height /= 2; 103 height /= 2;
105 } 104 }
106 } 105 }
107 UpdateTargetResolution(init_width, init_height); 106 UpdateTargetResolution(init_width, init_height);
108 ReportFramerate(fps); 107 ReportFramerate(fps);
109 } 108 }
110 109
111 // Report framerate(fps) to estimate # of samples. 110 // Report framerate(fps) to estimate # of samples.
112 void QualityScaler::ReportFramerate(int framerate) { 111 void QualityScaler::ReportFramerate(int framerate) {
113 // Use a faster window for upscaling initially. 112 // Use a faster window for upscaling initially.
114 // This enables faster initial rampups without risking strong up-down 113 // This enables faster initial rampups without risking strong up-down
115 // behavior later. 114 // behavior later.
116 num_samples_upscale_ = framerate * (fast_rampup_ ? kMeasureSecondsFastUpscale 115 num_samples_upscale_ = framerate * (fast_rampup_ ? kMeasureSecondsFastUpscale
117 : kMeasureSecondsUpscale); 116 : kMeasureSecondsUpscale);
118 num_samples_downscale_ = framerate * kMeasureSecondsDownscale; 117 num_samples_downscale_ = framerate * kMeasureSecondsDownscale;
119
120 average_qp_ =
121 MovingAverage(std::max(num_samples_upscale_, num_samples_downscale_));
122 framedrop_percent_ =
123 MovingAverage(std::max(num_samples_upscale_, num_samples_downscale_));
124 } 118 }
125 119
126 void QualityScaler::ReportQP(int qp) { 120 void QualityScaler::ReportQP(int qp) {
127 framedrop_percent_.AddSample(0); 121 framedrop_percent_.AddSample(0);
128 average_qp_.AddSample(qp); 122 average_qp_.AddSample(qp);
129 } 123 }
130 124
131 void QualityScaler::ReportDroppedFrame() { 125 void QualityScaler::ReportDroppedFrame() {
132 framedrop_percent_.AddSample(100); 126 framedrop_percent_.AddSample(100);
133 } 127 }
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 target_res_ = Resolution{width, height}; 202 target_res_ = Resolution{width, height};
209 } 203 }
210 204
211 void QualityScaler::ClearSamples() { 205 void QualityScaler::ClearSamples() {
212 framedrop_percent_.Reset(); 206 framedrop_percent_.Reset();
213 average_qp_.Reset(); 207 average_qp_.Reset();
214 } 208 }
215 209
216 210
217 } // namespace webrtc 211 } // namespace webrtc
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698