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

Side by Side Diff: webrtc/media/engine/webrtcvideoframe_unittest.cc

Issue 2315663002: Make cricket::VideoFrame inherit webrtc::VideoFrame. (Closed)
Patch Set: Add missing include of logging.h. Created 4 years, 2 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/engine/webrtcvideoframe.cc ('k') | webrtc/media/media.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
3 *
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
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11 #include <string.h>
12
13 #include <memory>
14
15 #include "webrtc/media/base/videoframe_unittest.h"
16 #include "webrtc/media/engine/webrtcvideoframe.h"
17 #include "webrtc/test/fake_texture_frame.h"
18
19 namespace cricket {
20
21 class WebRtcVideoFrameTest : public VideoFrameTest<WebRtcVideoFrame> {
22 public:
23 WebRtcVideoFrameTest() {}
24
25 void SetFrameRotation(WebRtcVideoFrame* frame,
26 webrtc::VideoRotation rotation) {
27 frame->rotation_ = rotation;
28 }
29 };
30
31 #define TEST_WEBRTCVIDEOFRAME(X) \
32 TEST_F(WebRtcVideoFrameTest, X) { VideoFrameTest<WebRtcVideoFrame>::X(); }
33
34 TEST_WEBRTCVIDEOFRAME(ConstructI420)
35 TEST_WEBRTCVIDEOFRAME(ConstructI422)
36 TEST_WEBRTCVIDEOFRAME(ConstructYuy2)
37 TEST_WEBRTCVIDEOFRAME(ConstructYuy2Unaligned)
38 TEST_WEBRTCVIDEOFRAME(ConstructYuy2Wide)
39 TEST_WEBRTCVIDEOFRAME(ConstructYV12)
40 TEST_WEBRTCVIDEOFRAME(ConstructUyvy)
41 TEST_WEBRTCVIDEOFRAME(ConstructM420)
42 TEST_WEBRTCVIDEOFRAME(ConstructNV21)
43 TEST_WEBRTCVIDEOFRAME(ConstructNV12)
44 TEST_WEBRTCVIDEOFRAME(ConstructABGR)
45 TEST_WEBRTCVIDEOFRAME(ConstructARGB)
46 TEST_WEBRTCVIDEOFRAME(ConstructARGBWide)
47 TEST_WEBRTCVIDEOFRAME(ConstructBGRA)
48 TEST_WEBRTCVIDEOFRAME(Construct24BG)
49 TEST_WEBRTCVIDEOFRAME(ConstructRaw)
50
51 TEST_WEBRTCVIDEOFRAME(ConstructI420Mirror)
52 TEST_WEBRTCVIDEOFRAME(ConstructI420Rotate0)
53 TEST_WEBRTCVIDEOFRAME(ConstructI420Rotate90)
54 TEST_WEBRTCVIDEOFRAME(ConstructI420Rotate180)
55 TEST_WEBRTCVIDEOFRAME(ConstructI420Rotate270)
56 TEST_WEBRTCVIDEOFRAME(ConstructYV12Rotate0)
57 TEST_WEBRTCVIDEOFRAME(ConstructYV12Rotate90)
58 TEST_WEBRTCVIDEOFRAME(ConstructYV12Rotate180)
59 TEST_WEBRTCVIDEOFRAME(ConstructYV12Rotate270)
60 TEST_WEBRTCVIDEOFRAME(ConstructNV12Rotate0)
61 TEST_WEBRTCVIDEOFRAME(ConstructNV12Rotate90)
62 TEST_WEBRTCVIDEOFRAME(ConstructNV12Rotate180)
63 TEST_WEBRTCVIDEOFRAME(ConstructNV12Rotate270)
64 TEST_WEBRTCVIDEOFRAME(ConstructNV21Rotate0)
65 TEST_WEBRTCVIDEOFRAME(ConstructNV21Rotate90)
66 TEST_WEBRTCVIDEOFRAME(ConstructNV21Rotate180)
67 TEST_WEBRTCVIDEOFRAME(ConstructNV21Rotate270)
68 TEST_WEBRTCVIDEOFRAME(ConstructUYVYRotate0)
69 TEST_WEBRTCVIDEOFRAME(ConstructUYVYRotate90)
70 TEST_WEBRTCVIDEOFRAME(ConstructUYVYRotate180)
71 TEST_WEBRTCVIDEOFRAME(ConstructUYVYRotate270)
72 TEST_WEBRTCVIDEOFRAME(ConstructYUY2Rotate0)
73 TEST_WEBRTCVIDEOFRAME(ConstructYUY2Rotate90)
74 TEST_WEBRTCVIDEOFRAME(ConstructYUY2Rotate180)
75 TEST_WEBRTCVIDEOFRAME(ConstructYUY2Rotate270)
76 TEST_WEBRTCVIDEOFRAME(ConstructI4201Pixel)
77 TEST_WEBRTCVIDEOFRAME(ConstructI4205Pixel)
78 // TODO(juberti): WebRtcVideoFrame does not support horizontal crop.
79 // Re-evaluate once it supports 3 independent planes, since we might want to
80 // just Init normally and then crop by adjusting pointers.
81 // TEST_WEBRTCVIDEOFRAME(ConstructI420CropHorizontal)
82 TEST_WEBRTCVIDEOFRAME(ConstructI420CropVertical)
83 // TODO(juberti): WebRtcVideoFrame is not currently refcounted.
84 // TEST_WEBRTCVIDEOFRAME(ConstructCopy)
85 // TEST_WEBRTCVIDEOFRAME(ConstructCopyIsRef)
86 // TODO(fbarchard): Implement Jpeg
87 // TEST_WEBRTCVIDEOFRAME(ConstructMjpgI420)
88 TEST_WEBRTCVIDEOFRAME(ConstructMjpgI422)
89 // TEST_WEBRTCVIDEOFRAME(ConstructMjpgI444)
90 // TEST_WEBRTCVIDEOFRAME(ConstructMjpgI411)
91 // TEST_WEBRTCVIDEOFRAME(ConstructMjpgI400)
92 // TEST_WEBRTCVIDEOFRAME(ValidateMjpgI420)
93 // TEST_WEBRTCVIDEOFRAME(ValidateMjpgI422)
94 // TEST_WEBRTCVIDEOFRAME(ValidateMjpgI444)
95 // TEST_WEBRTCVIDEOFRAME(ValidateMjpgI411)
96 // TEST_WEBRTCVIDEOFRAME(ValidateMjpgI400)
97 TEST_WEBRTCVIDEOFRAME(ValidateI420)
98 TEST_WEBRTCVIDEOFRAME(ValidateI420SmallSize)
99 TEST_WEBRTCVIDEOFRAME(ValidateI420LargeSize)
100 TEST_WEBRTCVIDEOFRAME(ValidateI420HugeSize)
101 // TEST_WEBRTCVIDEOFRAME(ValidateMjpgI420InvalidSize)
102 // TEST_WEBRTCVIDEOFRAME(ValidateI420InvalidSize)
103
104 // TODO(fbarchard): WebRtcVideoFrame does not support odd sizes.
105 // Re-evaluate once WebRTC switches to libyuv
106 // TEST_WEBRTCVIDEOFRAME(ConstructYuy2AllSizes)
107 // TEST_WEBRTCVIDEOFRAME(ConstructARGBAllSizes)
108 // TEST_WEBRTCVIDEOFRAME(ConvertToI422Buffer)
109 // TEST_WEBRTCVIDEOFRAME(ConstructARGBBlackWhitePixel)
110
111 TEST_F(WebRtcVideoFrameTest, TextureInitialValues) {
112 webrtc::test::FakeNativeHandle* dummy_handle =
113 new webrtc::test::FakeNativeHandle();
114 webrtc::NativeHandleBuffer* buffer =
115 new rtc::RefCountedObject<webrtc::test::FakeNativeHandleBuffer>(
116 dummy_handle, 640, 480);
117
118 WebRtcVideoFrame frame(buffer, webrtc::kVideoRotation_0, 20);
119 EXPECT_EQ(dummy_handle, frame.video_frame_buffer()->native_handle());
120 EXPECT_EQ(640, frame.width());
121 EXPECT_EQ(480, frame.height());
122 EXPECT_EQ(20, frame.timestamp_us());
123 frame.set_timestamp_us(40);
124 EXPECT_EQ(40, frame.timestamp_us());
125 }
126
127 TEST_F(WebRtcVideoFrameTest, ApplyRotationToFrame) {
128 WebRtcVideoFrame applied0;
129 EXPECT_TRUE(IsNull(applied0));
130 EXPECT_TRUE(LoadFrame(CreateYuvSample(kWidth, kHeight, 12).get(), FOURCC_I420,
131 kWidth, kHeight, &applied0));
132
133 // Claim that this frame needs to be rotated for 90 degree.
134 SetFrameRotation(&applied0, webrtc::kVideoRotation_90);
135 EXPECT_EQ(applied0.rotation(), webrtc::kVideoRotation_90);
136
137 // Apply rotation on frame 1. Output should be different from frame 1.
138 WebRtcVideoFrame applied90(
139 webrtc::I420Buffer::Rotate(applied0.video_frame_buffer(),
140 applied0.rotation()),
141 webrtc::kVideoRotation_0, applied0.timestamp_us());
142
143 EXPECT_EQ(applied90.rotation(), webrtc::kVideoRotation_0);
144 EXPECT_FALSE(IsEqual(applied0, applied90, 0));
145
146 // Claim the frame 2 needs to be rotated for another 270 degree. The output
147 // from frame 2 rotation should be the same as frame 1.
148 SetFrameRotation(&applied90, webrtc::kVideoRotation_270);
149 WebRtcVideoFrame applied360(
150 webrtc::I420Buffer::Rotate(applied90.video_frame_buffer(),
151 applied90.rotation()),
152 webrtc::kVideoRotation_0, applied90.timestamp_us());
153 EXPECT_EQ(applied360.rotation(), webrtc::kVideoRotation_0);
154 EXPECT_TRUE(IsEqual(applied0, applied360, 0));
155 }
156
157 } // namespace cricket
OLDNEW
« no previous file with comments | « webrtc/media/engine/webrtcvideoframe.cc ('k') | webrtc/media/media.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698