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

Unified Diff: webrtc/media/base/videoadapter_unittest.cc

Issue 2558243003: Reland of Add ability to scale to arbitrary factors (Closed)
Patch Set: Fix bug and add test Created 4 years 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
Index: webrtc/media/base/videoadapter_unittest.cc
diff --git a/webrtc/media/base/videoadapter_unittest.cc b/webrtc/media/base/videoadapter_unittest.cc
index 7f660ef37f2f3086ff438b782e04ff4e9dcceec5..d306298638e58546f08e3e56876eb7ccf5aaf70b 100644
--- a/webrtc/media/base/videoadapter_unittest.cc
+++ b/webrtc/media/base/videoadapter_unittest.cc
@@ -951,4 +951,35 @@ TEST_F(VideoAdapterTest, TestCroppingOddResolution) {
EXPECT_EQ(69, out_height_);
}
+TEST_F(VideoAdapterTest, TestAdaptToVerySmallResolution) {
+ // Ask for 1920x1080 (16:9 aspect), with 1/16 scaling.
+ const int w = 1920;
+ const int h = 1080;
+ adapter_.OnOutputFormatRequest(VideoFormat(w, h, 0, FOURCC_I420));
+ adapter_.OnResolutionRequest(rtc::Optional<int>(w * h * 1 / 16 * 1 / 16),
+ rtc::Optional<int>());
+
+ // Send 1920x1080 (16:9 aspect).
+ EXPECT_TRUE(adapter_.AdaptFrameResolution(
+ w, h, 0, &cropped_width_, &cropped_height_, &out_width_, &out_height_));
+
+ // Instead of getting the exact aspect ratio with cropped resolution 1920x1080
+ // the resolution should be adjusted to get a perfect scale factor instead.
+ EXPECT_EQ(1920, cropped_width_);
+ EXPECT_EQ(1072, cropped_height_);
+ EXPECT_EQ(120, out_width_);
+ EXPECT_EQ(67, out_height_);
+
+ // Adapt back up one step to 3/32.
+ adapter_.OnResolutionRequest(rtc::Optional<int>(),
+ rtc::Optional<int>(w * h * 1 / 16 * 1 / 16));
+
+ // Send 1920x1080 (16:9 aspect).
+ EXPECT_TRUE(adapter_.AdaptFrameResolution(
+ w, h, 0, &cropped_width_, &cropped_height_, &out_width_, &out_height_));
+
+ EXPECT_EQ(180, out_width_);
+ EXPECT_EQ(99, out_height_);
+}
+
} // namespace cricket

Powered by Google App Engine
This is Rietveld 408576698