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

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

Issue 2558243003: Reland of Add ability to scale to arbitrary factors (Closed)
Patch Set: revert changes to vie_encoder 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 unified diff | Download patch
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 933 matching lines...) Expand 10 before | Expand all | Expand 10 after
944 &out_width_, &out_height_)); 944 &out_width_, &out_height_));
945 945
946 // Instead of getting the exact aspect ratio with cropped resolution 640x360, 946 // Instead of getting the exact aspect ratio with cropped resolution 640x360,
947 // the resolution should be adjusted to get a perfect scale factor instead. 947 // the resolution should be adjusted to get a perfect scale factor instead.
948 EXPECT_EQ(640, cropped_width_); 948 EXPECT_EQ(640, cropped_width_);
949 EXPECT_EQ(368, cropped_height_); 949 EXPECT_EQ(368, cropped_height_);
950 EXPECT_EQ(120, out_width_); 950 EXPECT_EQ(120, out_width_);
951 EXPECT_EQ(69, out_height_); 951 EXPECT_EQ(69, out_height_);
952 } 952 }
953 953
954 TEST_F(VideoAdapterTest, TestAdaptToVerySmallResolution) {
955 // Ask for 1920x1080 (16:9 aspect), with 1/16 scaling.
956 const int w = 1920;
957 const int h = 1080;
958 adapter_.OnOutputFormatRequest(VideoFormat(w, h, 0, FOURCC_I420));
959 adapter_.OnResolutionRequest(rtc::Optional<int>(w * h * 1 / 16 * 1 / 16),
960 rtc::Optional<int>());
961
962 // Send 1920x1080 (16:9 aspect).
963 EXPECT_TRUE(adapter_.AdaptFrameResolution(
964 w, h, 0, &cropped_width_, &cropped_height_, &out_width_, &out_height_));
965
966 // Instead of getting the exact aspect ratio with cropped resolution 1920x1080
967 // the resolution should be adjusted to get a perfect scale factor instead.
968 EXPECT_EQ(1920, cropped_width_);
969 EXPECT_EQ(1072, cropped_height_);
970 EXPECT_EQ(120, out_width_);
971 EXPECT_EQ(67, out_height_);
972
973 // Adapt back up one step to 3/32.
974 adapter_.OnResolutionRequest(rtc::Optional<int>(),
975 rtc::Optional<int>(w * h * 1 / 16 * 1 / 16));
976
977 // Send 1920x1080 (16:9 aspect).
978 EXPECT_TRUE(adapter_.AdaptFrameResolution(
979 w, h, 0, &cropped_width_, &cropped_height_, &out_width_, &out_height_));
980
981 EXPECT_EQ(180, out_width_);
982 EXPECT_EQ(99, out_height_);
983 }
984
985 TEST_F(VideoAdapterTest, AdaptFrameResolutionDropWithResolutionRequest) {
986 VideoFormat output_format = capture_format_;
987 output_format.width = 0;
988 output_format.height = 0;
989 adapter_.OnOutputFormatRequest(output_format);
990 EXPECT_FALSE(adapter_.AdaptFrameResolution(
991 capture_format_.width, capture_format_.height, 0,
992 &cropped_width_, &cropped_height_,
993 &out_width_, &out_height_));
994
995 adapter_.OnResolutionRequest(rtc::Optional<int>(),
996 rtc::Optional<int>(640 * 480));
997
998 // Still expect all frames to be dropped
999 EXPECT_FALSE(adapter_.AdaptFrameResolution(
1000 capture_format_.width, capture_format_.height, 0,
1001 &cropped_width_, &cropped_height_,
1002 &out_width_, &out_height_));
1003
1004 adapter_.OnResolutionRequest(rtc::Optional<int>(640 * 480 - 1),
1005 rtc::Optional<int>());
1006
1007 // Still expect all frames to be dropped
1008 EXPECT_FALSE(adapter_.AdaptFrameResolution(
1009 capture_format_.width, capture_format_.height, 0,
1010 &cropped_width_, &cropped_height_,
1011 &out_width_, &out_height_));
1012 }
1013
954 } // namespace cricket 1014 } // namespace cricket
OLDNEW
« no previous file with comments | « webrtc/media/base/videoadapter.cc ('k') | webrtc/sdk/android/src/jni/androidvideotracksource.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698