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

Side by Side Diff: webrtc/media/base/videoadapter.cc

Issue 2713683002: Fix issue where video scaling gets stuck at low resolution (Closed)
Patch Set: Created 3 years, 10 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/media/base/videoadapter_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) 2010 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2010 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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 53
54 // Don't scale up original. 54 // Don't scale up original.
55 if (target_pixels >= input_pixels) 55 if (target_pixels >= input_pixels)
56 return Fraction{1, 1}; 56 return Fraction{1, 1};
57 57
58 Fraction current_scale = Fraction{1, 1}; 58 Fraction current_scale = Fraction{1, 1};
59 Fraction best_scale = Fraction{1, 1}; 59 Fraction best_scale = Fraction{1, 1};
60 // The minimum (absolute) difference between the number of output pixels and 60 // The minimum (absolute) difference between the number of output pixels and
61 // the target pixel count. 61 // the target pixel count.
62 int min_pixel_diff = std::numeric_limits<int>::max(); 62 int min_pixel_diff = std::numeric_limits<int>::max();
63 if (input_pixels < max_pixels) { 63 if (input_pixels <= max_pixels) {
64 // Start condition for 1/1 case, if it is less than max. 64 // Start condition for 1/1 case, if it is less than max.
65 min_pixel_diff = std::abs(input_pixels - target_pixels); 65 min_pixel_diff = std::abs(input_pixels - target_pixels);
66 } 66 }
67 67
68 // Alternately scale down by 2/3 and 3/4. This results in fractions which are 68 // Alternately scale down by 2/3 and 3/4. This results in fractions which are
69 // effectively scalable. For instance, starting at 1280x720 will result in 69 // effectively scalable. For instance, starting at 1280x720 will result in
70 // the series (3/4) => 960x540, (1/2) => 640x360, (3/8) => 480x270, 70 // the series (3/4) => 960x540, (1/2) => 640x360, (3/8) => 480x270,
71 // (1/4) => 320x180, (3/16) => 240x125, (1/8) => 160x90. 71 // (1/4) => 320x180, (3/16) => 240x125, (1/8) => 160x90.
72 while (current_scale.scale_pixel_count(input_pixels) > target_pixels) { 72 while (current_scale.scale_pixel_count(input_pixels) > target_pixels) {
73 if (current_scale.numerator % 3 == 0 && 73 if (current_scale.numerator % 3 == 0 &&
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 const rtc::Optional<int>& target_pixel_count, 253 const rtc::Optional<int>& target_pixel_count,
254 const rtc::Optional<int>& max_pixel_count) { 254 const rtc::Optional<int>& max_pixel_count) {
255 rtc::CritScope cs(&critical_section_); 255 rtc::CritScope cs(&critical_section_);
256 resolution_request_max_pixel_count_ = 256 resolution_request_max_pixel_count_ =
257 max_pixel_count.value_or(std::numeric_limits<int>::max()); 257 max_pixel_count.value_or(std::numeric_limits<int>::max());
258 resolution_request_target_pixel_count_ = 258 resolution_request_target_pixel_count_ =
259 target_pixel_count.value_or(resolution_request_max_pixel_count_); 259 target_pixel_count.value_or(resolution_request_max_pixel_count_);
260 } 260 }
261 261
262 } // namespace cricket 262 } // namespace cricket
OLDNEW
« no previous file with comments | « no previous file | webrtc/media/base/videoadapter_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698