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

Side by Side Diff: webrtc/common_video/i420_video_frame_unittest.cc

Issue 2517173004: Move VideoFrame and related declarations to webrtc/api/video. (Closed)
Patch Set: Rebased. 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) 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2012 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
11 #include <math.h> 11 #include <math.h>
12 #include <string.h> 12 #include <string.h>
13 13
14 #include "webrtc/api/video/video_frame.h"
14 #include "webrtc/base/bind.h" 15 #include "webrtc/base/bind.h"
16 #include "webrtc/base/timeutils.h"
15 #include "webrtc/test/fake_texture_frame.h" 17 #include "webrtc/test/fake_texture_frame.h"
16 #include "webrtc/test/frame_utils.h" 18 #include "webrtc/test/frame_utils.h"
17 #include "webrtc/test/gtest.h" 19 #include "webrtc/test/gtest.h"
18 #include "webrtc/video_frame.h"
19 20
20 namespace webrtc { 21 namespace webrtc {
21 22
22 namespace { 23 namespace {
23 24
24 rtc::scoped_refptr<I420Buffer> CreateGradient(int width, int height) { 25 rtc::scoped_refptr<I420Buffer> CreateGradient(int width, int height) {
25 rtc::scoped_refptr<I420Buffer> buffer( 26 rtc::scoped_refptr<I420Buffer> buffer(
26 I420Buffer::Create(width, height)); 27 I420Buffer::Create(width, height));
27 // Initialize with gradient, Y = 128(x/w + y/h), U = 256 x/w, V = 256 y/h 28 // Initialize with gradient, Y = 128(x/w + y/h), U = 256 x/w, V = 256 y/h
28 for (int x = 0; x < width; x++) { 29 for (int x = 0; x < width; x++) {
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 scaled_buffer->CropAndScaleFrom(*buf); 280 scaled_buffer->CropAndScaleFrom(*buf);
280 CheckCrop(*scaled_buffer, 0.0, 0.125, 1.0, 0.75); 281 CheckCrop(*scaled_buffer, 0.0, 0.125, 1.0, 0.75);
281 } 282 }
282 283
283 class TestI420BufferRotate 284 class TestI420BufferRotate
284 : public ::testing::TestWithParam<webrtc::VideoRotation> {}; 285 : public ::testing::TestWithParam<webrtc::VideoRotation> {};
285 286
286 TEST_P(TestI420BufferRotate, Rotates) { 287 TEST_P(TestI420BufferRotate, Rotates) {
287 rtc::scoped_refptr<VideoFrameBuffer> buffer = CreateGradient(640, 480); 288 rtc::scoped_refptr<VideoFrameBuffer> buffer = CreateGradient(640, 480);
288 rtc::scoped_refptr<VideoFrameBuffer> rotated_buffer = 289 rtc::scoped_refptr<VideoFrameBuffer> rotated_buffer =
289 I420Buffer::Rotate(buffer, GetParam()); 290 I420Buffer::Rotate(*buffer, GetParam());
290 CheckRotate(640, 480, GetParam(), *rotated_buffer); 291 CheckRotate(640, 480, GetParam(), *rotated_buffer);
291 } 292 }
292 293
293 INSTANTIATE_TEST_CASE_P(Rotate, TestI420BufferRotate, 294 INSTANTIATE_TEST_CASE_P(Rotate, TestI420BufferRotate,
294 ::testing::Values(kVideoRotation_0, 295 ::testing::Values(kVideoRotation_0,
295 kVideoRotation_90, 296 kVideoRotation_90,
296 kVideoRotation_180, 297 kVideoRotation_180,
297 kVideoRotation_270)); 298 kVideoRotation_270));
298 299
300 class TestI420BufferRotateOld
301 : public ::testing::TestWithParam<webrtc::VideoRotation> {};
302
303 TEST_P(TestI420BufferRotateOld, Rotates) {
304 rtc::scoped_refptr<VideoFrameBuffer> buffer = CreateGradient(640, 480);
305 rtc::scoped_refptr<VideoFrameBuffer> rotated_buffer =
306 I420Buffer::Rotate(buffer, GetParam());
307 CheckRotate(640, 480, GetParam(), *rotated_buffer);
308 }
309
310 INSTANTIATE_TEST_CASE_P(Rotate, TestI420BufferRotateOld,
311 ::testing::Values(kVideoRotation_0,
312 kVideoRotation_90,
313 kVideoRotation_180,
314 kVideoRotation_270));
315
299 } // namespace webrtc 316 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698