OLD | NEW |
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 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 ComputeScale(8192, 1024, 15, &scaled_width, &scaled_height); | 159 ComputeScale(8192, 1024, 15, &scaled_width, &scaled_height); |
160 EXPECT_EQ(4096, scaled_width); | 160 EXPECT_EQ(4096, scaled_width); |
161 EXPECT_EQ(512, scaled_height); | 161 EXPECT_EQ(512, scaled_height); |
162 | 162 |
163 // Request too tall. Expect 1/4 size. | 163 // Request too tall. Expect 1/4 size. |
164 ComputeScale(1024, 8192, 15, &scaled_width, &scaled_height); | 164 ComputeScale(1024, 8192, 15, &scaled_width, &scaled_height); |
165 EXPECT_EQ(256, scaled_width); | 165 EXPECT_EQ(256, scaled_width); |
166 EXPECT_EQ(2048, scaled_height); | 166 EXPECT_EQ(2048, scaled_height); |
167 } | 167 } |
168 | 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 | 169 } // namespace cricket |
OLD | NEW |