Fix issue where video scaling gets stuck at low resolution

This CL fixes issue 7211 as well as adding a test that would have
caught the issue.

BUG=webrtc:7211,webrtc:6850,b/35471214
R=sprang@webrtc.org
TBR=kthelgason, sprang

Review-Url: https://codereview.webrtc.org/2713683002 .
Cr-Commit-Position: refs/heads/master@{#16778}
This commit is contained in:
Magnus Jedvert
2017-02-22 18:30:27 +01:00
parent 6f08d7d68d
commit 6d230d7b1d
2 changed files with 14 additions and 1 deletions

View File

@ -60,7 +60,7 @@ Fraction FindScale(int input_pixels, int target_pixels, int max_pixels) {
// The minimum (absolute) difference between the number of output pixels and
// the target pixel count.
int min_pixel_diff = std::numeric_limits<int>::max();
if (input_pixels < max_pixels) {
if (input_pixels <= max_pixels) {
// Start condition for 1/1 case, if it is less than max.
min_pixel_diff = std::abs(input_pixels - target_pixels);
}

View File

@ -1016,4 +1016,17 @@ TEST_F(VideoAdapterTest, AdaptFrameResolutionDropWithResolutionRequest) {
&out_width_, &out_height_));
}
// Test that we will adapt to max given a target pixel count close to max.
TEST_F(VideoAdapterTest, TestAdaptToMax) {
adapter_.OnOutputFormatRequest(VideoFormat(640, 360, 0, FOURCC_I420));
adapter_.OnResolutionRequest(rtc::Optional<int>(640 * 360 - 1) /* target */,
rtc::Optional<int>());
EXPECT_TRUE(adapter_.AdaptFrameResolution(640, 360, 0, &cropped_width_,
&cropped_height_, &out_width_,
&out_height_));
EXPECT_EQ(640, out_width_);
EXPECT_EQ(360, out_height_);
}
} // namespace cricket