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

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

Issue 1934503002: Delete unused video capture code for cropping, non-square pixels, and ARGB. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Delete test case VideoCapturerTest.ScreencastScaledSuperLarge. 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 unified diff | Download patch
« no previous file with comments | « webrtc/media/base/videocommon.cc ('k') | no next file » | 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) 2008 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2008 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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 84
85 format2 = format; 85 format2 = format;
86 format2.interval /= 2; 86 format2.interval /= 2;
87 EXPECT_TRUE(format.IsPixelRateLess(format2)); 87 EXPECT_TRUE(format.IsPixelRateLess(format2));
88 88
89 format2 = format; 89 format2 = format;
90 format2.width *= 2; 90 format2.width *= 2;
91 EXPECT_TRUE(format.IsPixelRateLess(format2)); 91 EXPECT_TRUE(format.IsPixelRateLess(format2));
92 } 92 }
93 93
94 TEST(VideoCommonTest, TestComputeScaleWithLowFps) {
95 int scaled_width, scaled_height;
96
97 // Request small enough. Expect no change.
98 ComputeScale(2560, 1600, 5, &scaled_width, &scaled_height);
99 EXPECT_EQ(2560, scaled_width);
100 EXPECT_EQ(1600, scaled_height);
101
102 // Request too many pixels. Expect 1/2 size.
103 ComputeScale(4096, 2560, 5, &scaled_width, &scaled_height);
104 EXPECT_EQ(2048, scaled_width);
105 EXPECT_EQ(1280, scaled_height);
106
107 // Request too many pixels and too wide and tall. Expect 1/4 size.
108 ComputeScale(16000, 10000, 5, &scaled_width, &scaled_height);
109 EXPECT_EQ(2000, scaled_width);
110 EXPECT_EQ(1250, scaled_height);
111
112 // Request too wide. (two 30 inch monitors). Expect 1/2 size.
113 ComputeScale(5120, 1600, 5, &scaled_width, &scaled_height);
114 EXPECT_EQ(2560, scaled_width);
115 EXPECT_EQ(800, scaled_height);
116
117 // Request too wide but not too many pixels. Expect 1/2 size.
118 ComputeScale(8192, 1024, 5, &scaled_width, &scaled_height);
119 EXPECT_EQ(4096, scaled_width);
120 EXPECT_EQ(512, scaled_height);
121
122 // Request too tall. Expect 1/4 size.
123 ComputeScale(1024, 8192, 5, &scaled_width, &scaled_height);
124 EXPECT_EQ(256, scaled_width);
125 EXPECT_EQ(2048, scaled_height);
126 }
127
128 // Same as TestComputeScale but with 15 fps instead of 5 fps.
129 // Disabled for UBSan: https://bugs.chromium.org/p/webrtc/issues/detail?id=5487
130 #ifdef UNDEFINED_SANITIZER
131 #define MAYBE_TestComputeScaleWithHighFps DISABLED_TestComputeScaleWithHighFps
132 #else
133 #define MAYBE_TestComputeScaleWithHighFps TestComputeScaleWithHighFps
134 #endif
135 TEST(VideoCommonTest, MAYBE_TestComputeScaleWithHighFps) {
136 int scaled_width, scaled_height;
137
138 // Request small enough but high fps. Expect 1/2 size.
139 ComputeScale(2560, 1600, 15, &scaled_width, &scaled_height);
140 EXPECT_EQ(1280, scaled_width);
141 EXPECT_EQ(800, scaled_height);
142
143 // Request too many pixels. Expect 1/2 size.
144 ComputeScale(4096, 2560, 15, &scaled_width, &scaled_height);
145 EXPECT_EQ(2048, scaled_width);
146 EXPECT_EQ(1280, scaled_height);
147
148 // Request too many pixels and too wide and tall. Expect 1/16 size.
149 ComputeScale(64000, 40000, 15, &scaled_width, &scaled_height);
150 EXPECT_EQ(4000, scaled_width);
151 EXPECT_EQ(2500, scaled_height);
152
153 // Request too wide. (two 30 inch monitors). Expect 1/2 size.
154 ComputeScale(5120, 1600, 15, &scaled_width, &scaled_height);
155 EXPECT_EQ(2560, scaled_width);
156 EXPECT_EQ(800, scaled_height);
157
158 // Request too wide but not too many pixels. Expect 1/2 size.
159 ComputeScale(8192, 1024, 15, &scaled_width, &scaled_height);
160 EXPECT_EQ(4096, scaled_width);
161 EXPECT_EQ(512, scaled_height);
162
163 // Request too tall. Expect 1/4 size.
164 ComputeScale(1024, 8192, 15, &scaled_width, &scaled_height);
165 EXPECT_EQ(256, scaled_width);
166 EXPECT_EQ(2048, scaled_height);
167 }
168
169 TEST(VideoCommonTest, TestComputeCrop) {
170 int cropped_width, cropped_height;
171
172 // Request 16:9 to 16:9. Expect no cropping.
173 ComputeCrop(1280, 720, // Crop size 16:9
174 640, 360, // Frame is 4:3
175 1, 1, // Normal 1:1 pixels
176 0,
177 &cropped_width, &cropped_height);
178 EXPECT_EQ(640, cropped_width);
179 EXPECT_EQ(360, cropped_height);
180
181 // Request 4:3 to 16:9. Expect vertical.
182 ComputeCrop(640, 360, // Crop size 16:9
183 640, 480, // Frame is 4:3
184 1, 1, // Normal 1:1 pixels
185 0,
186 &cropped_width, &cropped_height);
187 EXPECT_EQ(640, cropped_width);
188 EXPECT_EQ(360, cropped_height);
189
190 // Request 16:9 to 4:3. Expect horizontal crop.
191 ComputeCrop(640, 480, // Crop size 4:3
192 640, 360, // Frame is 16:9
193 1, 1, // Normal 1:1 pixels
194 0,
195 &cropped_width, &cropped_height);
196 EXPECT_EQ(480, cropped_width);
197 EXPECT_EQ(360, cropped_height);
198
199 // Request 16:9 but VGA has 3:8 pixel aspect ratio. Expect no crop.
200 // This occurs on HP4110 on OSX 10.5/10.6/10.7
201 ComputeCrop(640, 360, // Crop size 16:9
202 640, 480, // Frame is 4:3
203 3, 8, // Pixel aspect ratio is tall
204 0,
205 &cropped_width, &cropped_height);
206 EXPECT_EQ(640, cropped_width);
207 EXPECT_EQ(480, cropped_height);
208
209 // Request 16:9 but QVGA has 15:11 pixel aspect ratio. Expect horizontal crop.
210 // This occurs on Logitech B910 on OSX 10.5/10.6/10.7 in Hangouts.
211 ComputeCrop(640, 360, // Crop size 16:9
212 320, 240, // Frame is 4:3
213 15, 11, // Pixel aspect ratio is wide
214 0,
215 &cropped_width, &cropped_height);
216 EXPECT_EQ(312, cropped_width);
217 EXPECT_EQ(240, cropped_height);
218
219 // Request 16:10 but QVGA has 15:11 pixel aspect ratio.
220 // Expect horizontal crop.
221 // This occurs on Logitech B910 on OSX 10.5/10.6/10.7 in gmail.
222 ComputeCrop(640, 400, // Crop size 16:10
223 320, 240, // Frame is 4:3
224 15, 11, // Pixel aspect ratio is wide
225 0,
226 &cropped_width, &cropped_height);
227 EXPECT_EQ(280, cropped_width);
228 EXPECT_EQ(240, cropped_height);
229
230 // Request 16:9 but VGA has 6:5 pixel aspect ratio. Expect vertical crop.
231 // This occurs on Logitech QuickCam Pro C9000 on OSX
232 ComputeCrop(640, 360, // Crop size 16:9
233 640, 480, // Frame is 4:3
234 6, 5, // Pixel aspect ratio is wide
235 0,
236 &cropped_width, &cropped_height);
237 EXPECT_EQ(640, cropped_width);
238 EXPECT_EQ(432, cropped_height);
239
240 // Request 16:10 but HD is 16:9. Expect horizontal crop.
241 // This occurs in settings and local preview with HD experiment.
242 ComputeCrop(1280, 800, // Crop size 16:10
243 1280, 720, // Frame is 4:3
244 1, 1, // Pixel aspect ratio is wide
245 0,
246 &cropped_width, &cropped_height);
247 EXPECT_EQ(1152, cropped_width);
248 EXPECT_EQ(720, cropped_height);
249
250 // Request 16:9 but HD has 3:4 pixel aspect ratio. Expect vertical crop.
251 // This occurs on Logitech B910 on OSX 10.5/10.6.7 but not OSX 10.6.8 or 10.7
252 ComputeCrop(1280, 720, // Crop size 16:9
253 1280, 720, // Frame is 4:3
254 3, 4, // Pixel aspect ratio is wide
255 0,
256 &cropped_width, &cropped_height);
257 EXPECT_EQ(1280, cropped_width);
258 EXPECT_EQ(540, cropped_height);
259
260 // Request 16:9 to 3:4 (portrait). Expect no cropping.
261 ComputeCrop(640, 360, // Crop size 16:9
262 640, 480, // Frame is 3:4 portrait
263 1, 1, // Normal 1:1 pixels
264 90,
265 &cropped_width, &cropped_height);
266 EXPECT_EQ(640, cropped_width);
267 EXPECT_EQ(480, cropped_height);
268
269 // Request 9:16 from VGA rotated (portrait). Expect crop.
270 ComputeCrop(360, 640, // Crop size 9:16
271 640, 480, // Frame is 3:4 portrait
272 1, 1, // Normal 1:1 pixels
273 90,
274 &cropped_width, &cropped_height);
275 EXPECT_EQ(640, cropped_width);
276 EXPECT_EQ(360, cropped_height);
277
278 // Cropped size 0x0. Expect no cropping.
279 // This is used when adding multiple capturers
280 ComputeCrop(0, 0, // Crop size 0x0
281 1024, 768, // Frame is 3:4 portrait
282 1, 1, // Normal 1:1 pixels
283 0,
284 &cropped_width, &cropped_height);
285 EXPECT_EQ(1024, cropped_width);
286 EXPECT_EQ(768, cropped_height);
287 }
288
289 TEST(VideoCommonTest, TestComputeScaleToSquarePixels) {
290 int scaled_width, scaled_height;
291
292 // Pixel aspect ratio is 4:3. Logical aspect ratio is 16:9. Expect scale
293 // to square pixels with physical aspect ratio of 16:9.
294 ComputeScaleToSquarePixels(640, 480,
295 4, 3, // 4 x 3 pixel aspect ratio
296 &scaled_width, &scaled_height);
297 EXPECT_EQ(640, scaled_width);
298 EXPECT_EQ(360, scaled_height);
299
300 // Pixel aspect ratio is 3:8. Physical aspect ratio is 4:3. Expect scale
301 // to square pixels with logical aspect ratio of 1:2.
302 // Note that 640x1280 will be scaled down by video adapter to view request
303 // of 640*360 and will end up using 320x640.
304 ComputeScaleToSquarePixels(640, 480,
305 3, 8, // 4 x 3 pixel aspect ratio
306 &scaled_width, &scaled_height);
307 EXPECT_EQ(640, scaled_width);
308 EXPECT_EQ(1280, scaled_height);
309 }
310
311 } // namespace cricket 94 } // namespace cricket
OLDNEW
« no previous file with comments | « webrtc/media/base/videocommon.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698