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

Unified Diff: webrtc/modules/video_coding/utility/quality_scaler.cc

Issue 1971693003: Clamp number of downscales in QualityScaler. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: zero out initial resolution Created 4 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/modules/video_coding/utility/quality_scaler.cc
diff --git a/webrtc/modules/video_coding/utility/quality_scaler.cc b/webrtc/modules/video_coding/utility/quality_scaler.cc
index 30a5776b2d05b6d92495e67dfb75743972809854..c60b50de63dcb9f46d8f922a54f6f963f35e693d 100644
--- a/webrtc/modules/video_coding/utility/quality_scaler.cc
+++ b/webrtc/modules/video_coding/utility/quality_scaler.cc
@@ -60,6 +60,10 @@ void QualityScaler::Init(int low_qp_threshold,
height /= 2;
}
}
+
+ // Zero out width/height so they can be checked against inside
+ // UpdateTargetResolution.
+ res_.width = res_.height = 0;
UpdateTargetResolution(init_width, init_height);
ReportFramerate(fps);
}
@@ -131,15 +135,24 @@ const VideoFrame& QualityScaler::GetScaledFrame(const VideoFrame& frame) {
void QualityScaler::UpdateTargetResolution(int frame_width, int frame_height) {
assert(downscale_shift_ >= 0);
- res_.width = frame_width;
- res_.height = frame_height;
+ int shifts_performed = 0;
for (int shift = downscale_shift_;
- shift > 0 && (res_.width / 2 >= kMinDownscaleDimension) &&
- (res_.height / 2 >= kMinDownscaleDimension);
- --shift) {
- res_.width /= 2;
- res_.height /= 2;
+ shift > 0 && (frame_width / 2 >= kMinDownscaleDimension) &&
+ (frame_height / 2 >= kMinDownscaleDimension);
+ --shift, ++shifts_performed) {
+ frame_width /= 2;
+ frame_height /= 2;
+ }
+ // Clamp to number of shifts actually performed to not be stuck trying to
+ // scale way beyond QVGA.
+ downscale_shift_ = shifts_performed;
+ if (res_.width == frame_width && res_.height == frame_height) {
+ // No reset done/needed, using same resolution.
+ return;
}
+ res_.width = frame_width;
+ res_.height = frame_height;
+ ClearSamples();
}
void QualityScaler::ClearSamples() {
@@ -160,11 +173,10 @@ void QualityScaler::AdjustScale(bool up) {
if (downscale_shift_ < 0)
downscale_shift_ = 0;
if (!up) {
- // Hit first downscale, start using a slower threshold for going up.
+ // First downscale hit, start using a slower threshold for going up.
measure_seconds_upscale_ = kMeasureSecondsUpscale;
UpdateSampleCounts();
}
- ClearSamples();
}
} // namespace webrtc
« 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