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

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

Issue 1364253002: Implement a high-QP threshold for Android H.264. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: feedback Created 5 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
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/include/quality_scaler.h" 10 #include "webrtc/modules/video_coding/utility/include/quality_scaler.h"
(...skipping 11 matching lines...) Expand all
22 22
23 QualityScaler::QualityScaler() 23 QualityScaler::QualityScaler()
24 : num_samples_(0), 24 : num_samples_(0),
25 low_qp_threshold_(-1), 25 low_qp_threshold_(-1),
26 downscale_shift_(0), 26 downscale_shift_(0),
27 framerate_down_(false), 27 framerate_down_(false),
28 min_width_(kDefaultMinDownscaleDimension), 28 min_width_(kDefaultMinDownscaleDimension),
29 min_height_(kDefaultMinDownscaleDimension) { 29 min_height_(kDefaultMinDownscaleDimension) {
30 } 30 }
31 31
32 void QualityScaler::Init(int low_qp_threshold, bool use_framerate_reduction) { 32 void QualityScaler::Init(int low_qp_threshold,
33 int high_qp_threshold,
34 bool use_framerate_reduction) {
33 ClearSamples(); 35 ClearSamples();
34 low_qp_threshold_ = low_qp_threshold; 36 low_qp_threshold_ = low_qp_threshold;
37 high_qp_threshold_ = high_qp_threshold;
35 use_framerate_reduction_ = use_framerate_reduction; 38 use_framerate_reduction_ = use_framerate_reduction;
36 target_framerate_ = -1; 39 target_framerate_ = -1;
37 } 40 }
38 41
39 void QualityScaler::SetMinResolution(int min_width, int min_height) { 42 void QualityScaler::SetMinResolution(int min_width, int min_height) {
40 min_width_ = min_width; 43 min_width_ = min_width;
41 min_height_ = min_height; 44 min_height_ = min_height;
42 } 45 }
43 46
44 // Report framerate(fps) to estimate # of samples. 47 // Report framerate(fps) to estimate # of samples.
(...skipping 18 matching lines...) Expand all
63 assert(num_samples_ > 0); 66 assert(num_samples_ > 0);
64 res_.width = frame.width(); 67 res_.width = frame.width();
65 res_.height = frame.height(); 68 res_.height = frame.height();
66 69
67 // Update scale factor. 70 // Update scale factor.
68 int avg_drop = 0; 71 int avg_drop = 0;
69 int avg_qp = 0; 72 int avg_qp = 0;
70 73
71 // When encoder consistently overshoots, framerate reduction and spatial 74 // When encoder consistently overshoots, framerate reduction and spatial
72 // resizing will be triggered to get a smoother video. 75 // resizing will be triggered to get a smoother video.
73 if (framedrop_percent_.GetAverage(num_samples_, &avg_drop) && 76 if ((framedrop_percent_.GetAverage(num_samples_, &avg_drop) &&
74 avg_drop >= kFramedropPercentThreshold) { 77 avg_drop >= kFramedropPercentThreshold) ||
78 (average_qp_.GetAverage(num_samples_, &avg_qp) &&
79 avg_qp > high_qp_threshold_)) {
75 // Reducing frame rate before spatial resolution change. 80 // Reducing frame rate before spatial resolution change.
76 // Reduce frame rate only when it is above a certain number. 81 // Reduce frame rate only when it is above a certain number.
77 // Only one reduction is allowed for now. 82 // Only one reduction is allowed for now.
78 // TODO(jackychen): Allow more than one framerate reduction. 83 // TODO(jackychen): Allow more than one framerate reduction.
79 if (use_framerate_reduction_ && !framerate_down_ && framerate_ >= 20) { 84 if (use_framerate_reduction_ && !framerate_down_ && framerate_ >= 20) {
80 target_framerate_ = framerate_ / 2; 85 target_framerate_ = framerate_ / 2;
81 framerate_down_ = true; 86 framerate_down_ = true;
82 // If frame rate has been updated, clear the buffer. We don't want 87 // If frame rate has been updated, clear the buffer. We don't want
83 // spatial resolution to change right after frame rate change. 88 // spatial resolution to change right after frame rate change.
84 ClearSamples(); 89 ClearSamples();
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 } 147 }
143 148
144 void QualityScaler::AdjustScale(bool up) { 149 void QualityScaler::AdjustScale(bool up) {
145 downscale_shift_ += up ? -1 : 1; 150 downscale_shift_ += up ? -1 : 1;
146 if (downscale_shift_ < 0) 151 if (downscale_shift_ < 0)
147 downscale_shift_ = 0; 152 downscale_shift_ = 0;
148 ClearSamples(); 153 ClearSamples();
149 } 154 }
150 155
151 } // namespace webrtc 156 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698