blob: 7849de61b0a8bf4914f7eb30aeddbb6e009f0416 [file] [log] [blame]
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001/*
kjellander1afca732016-02-07 20:46:45 -08002 * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
henrike@webrtc.org28e20752013-07-10 00:45:36 +00003 *
kjellander1afca732016-02-07 20:46:45 -08004 * 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.
henrike@webrtc.org28e20752013-07-10 00:45:36 +00009 */
10
magjed@webrtc.orgcb04aa42015-03-03 09:23:47 +000011#include <string.h>
12
kwiberg686a8ef2016-02-26 03:00:35 -080013#include <memory>
14
kjellandera96e2d72016-02-04 23:52:28 -080015#include "webrtc/media/base/videoframe_unittest.h"
kjellander@webrtc.org5ad12972016-02-12 06:39:40 +010016#include "webrtc/media/engine/webrtcvideoframe.h"
Peter Boströmeb66e802015-06-05 11:08:03 +020017#include "webrtc/test/fake_texture_frame.h"
henrike@webrtc.org28e20752013-07-10 00:45:36 +000018
guoweis@webrtc.org00c509a2015-03-12 21:37:26 +000019namespace {
20
21class WebRtcVideoTestFrame : public cricket::WebRtcVideoFrame {
22 public:
nisseb17712f2016-04-14 02:29:29 -070023 // The ApplyRotationToFrame test needs this as a public method.
nissef3868762016-04-13 03:29:16 -070024 using cricket::WebRtcVideoFrame::set_rotation;
guoweis@webrtc.org00c509a2015-03-12 21:37:26 +000025
26 virtual VideoFrame* CreateEmptyFrame(int w,
27 int h,
guoweis@webrtc.org00c509a2015-03-12 21:37:26 +000028 int64_t time_stamp) const override {
29 WebRtcVideoTestFrame* frame = new WebRtcVideoTestFrame();
nisse8b1e4312016-01-18 01:46:27 -080030 frame->InitToBlack(w, h, time_stamp);
guoweis@webrtc.org00c509a2015-03-12 21:37:26 +000031 return frame;
32 }
33};
34
35} // namespace
36
henrike@webrtc.org28e20752013-07-10 00:45:36 +000037class WebRtcVideoFrameTest : public VideoFrameTest<cricket::WebRtcVideoFrame> {
38 public:
39 WebRtcVideoFrameTest() {
henrike@webrtc.org28e20752013-07-10 00:45:36 +000040 }
41
perkj@webrtc.org1d828132015-03-03 06:44:06 +000042 void TestInit(int cropped_width, int cropped_height,
43 webrtc::VideoRotation frame_rotation,
44 bool apply_rotation) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +000045 const int frame_width = 1920;
46 const int frame_height = 1080;
47
48 // Build the CapturedFrame.
49 cricket::CapturedFrame captured_frame;
50 captured_frame.fourcc = cricket::FOURCC_I420;
nisseb17712f2016-04-14 02:29:29 -070051 captured_frame.time_stamp = rtc::TimeNanos();
perkj@webrtc.org1d828132015-03-03 06:44:06 +000052 captured_frame.rotation = frame_rotation;
henrike@webrtc.org28e20752013-07-10 00:45:36 +000053 captured_frame.width = frame_width;
54 captured_frame.height = frame_height;
55 captured_frame.data_size = (frame_width * frame_height) +
56 ((frame_width + 1) / 2) * ((frame_height + 1) / 2) * 2;
kwiberg686a8ef2016-02-26 03:00:35 -080057 std::unique_ptr<uint8_t[]> captured_frame_buffer(
Peter Boström0c4e06b2015-10-07 12:23:21 +020058 new uint8_t[captured_frame.data_size]);
magjed@webrtc.orgcb04aa42015-03-03 09:23:47 +000059 // Initialize memory to satisfy DrMemory tests.
60 memset(captured_frame_buffer.get(), 0, captured_frame.data_size);
henrike@webrtc.org28e20752013-07-10 00:45:36 +000061 captured_frame.data = captured_frame_buffer.get();
62
63 // Create the new frame from the CapturedFrame.
64 cricket::WebRtcVideoFrame frame;
perkj@webrtc.org1d828132015-03-03 06:44:06 +000065 EXPECT_TRUE(
66 frame.Init(&captured_frame, cropped_width, cropped_height,
67 apply_rotation));
henrike@webrtc.org28e20752013-07-10 00:45:36 +000068
69 // Verify the new frame.
nisseb17712f2016-04-14 02:29:29 -070070 EXPECT_EQ(captured_frame.time_stamp / rtc::kNumNanosecsPerMicrosec,
71 frame.timestamp_us());
perkj@webrtc.org1d828132015-03-03 06:44:06 +000072 if (apply_rotation)
nissef3868762016-04-13 03:29:16 -070073 EXPECT_EQ(webrtc::kVideoRotation_0, frame.rotation());
perkj@webrtc.org1d828132015-03-03 06:44:06 +000074 else
nissef3868762016-04-13 03:29:16 -070075 EXPECT_EQ(frame_rotation, frame.rotation());
perkj@webrtc.org1d828132015-03-03 06:44:06 +000076 // If |apply_rotation| and the frame rotation is 90 or 270, width and
77 // height are flipped.
78 if (apply_rotation && (frame_rotation == webrtc::kVideoRotation_90
79 || frame_rotation == webrtc::kVideoRotation_270)) {
nisse71a0c2f2016-04-04 00:57:29 -070080 EXPECT_EQ(cropped_width, frame.height());
81 EXPECT_EQ(cropped_height, frame.width());
perkj@webrtc.org1d828132015-03-03 06:44:06 +000082 } else {
nisse71a0c2f2016-04-04 00:57:29 -070083 EXPECT_EQ(cropped_width, frame.width());
84 EXPECT_EQ(cropped_height, frame.height());
perkj@webrtc.org1d828132015-03-03 06:44:06 +000085 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +000086 }
87};
88
89#define TEST_WEBRTCVIDEOFRAME(X) TEST_F(WebRtcVideoFrameTest, X) { \
90 VideoFrameTest<cricket::WebRtcVideoFrame>::X(); \
91}
92
93TEST_WEBRTCVIDEOFRAME(ConstructI420)
94TEST_WEBRTCVIDEOFRAME(ConstructI422)
95TEST_WEBRTCVIDEOFRAME(ConstructYuy2)
96TEST_WEBRTCVIDEOFRAME(ConstructYuy2Unaligned)
97TEST_WEBRTCVIDEOFRAME(ConstructYuy2Wide)
98TEST_WEBRTCVIDEOFRAME(ConstructYV12)
99TEST_WEBRTCVIDEOFRAME(ConstructUyvy)
100TEST_WEBRTCVIDEOFRAME(ConstructM420)
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000101TEST_WEBRTCVIDEOFRAME(ConstructNV21)
102TEST_WEBRTCVIDEOFRAME(ConstructNV12)
103TEST_WEBRTCVIDEOFRAME(ConstructABGR)
104TEST_WEBRTCVIDEOFRAME(ConstructARGB)
105TEST_WEBRTCVIDEOFRAME(ConstructARGBWide)
106TEST_WEBRTCVIDEOFRAME(ConstructBGRA)
107TEST_WEBRTCVIDEOFRAME(Construct24BG)
108TEST_WEBRTCVIDEOFRAME(ConstructRaw)
109TEST_WEBRTCVIDEOFRAME(ConstructRGB565)
110TEST_WEBRTCVIDEOFRAME(ConstructARGB1555)
111TEST_WEBRTCVIDEOFRAME(ConstructARGB4444)
112
113TEST_WEBRTCVIDEOFRAME(ConstructI420Mirror)
114TEST_WEBRTCVIDEOFRAME(ConstructI420Rotate0)
115TEST_WEBRTCVIDEOFRAME(ConstructI420Rotate90)
116TEST_WEBRTCVIDEOFRAME(ConstructI420Rotate180)
117TEST_WEBRTCVIDEOFRAME(ConstructI420Rotate270)
118TEST_WEBRTCVIDEOFRAME(ConstructYV12Rotate0)
119TEST_WEBRTCVIDEOFRAME(ConstructYV12Rotate90)
120TEST_WEBRTCVIDEOFRAME(ConstructYV12Rotate180)
121TEST_WEBRTCVIDEOFRAME(ConstructYV12Rotate270)
122TEST_WEBRTCVIDEOFRAME(ConstructNV12Rotate0)
123TEST_WEBRTCVIDEOFRAME(ConstructNV12Rotate90)
124TEST_WEBRTCVIDEOFRAME(ConstructNV12Rotate180)
125TEST_WEBRTCVIDEOFRAME(ConstructNV12Rotate270)
126TEST_WEBRTCVIDEOFRAME(ConstructNV21Rotate0)
127TEST_WEBRTCVIDEOFRAME(ConstructNV21Rotate90)
128TEST_WEBRTCVIDEOFRAME(ConstructNV21Rotate180)
129TEST_WEBRTCVIDEOFRAME(ConstructNV21Rotate270)
130TEST_WEBRTCVIDEOFRAME(ConstructUYVYRotate0)
131TEST_WEBRTCVIDEOFRAME(ConstructUYVYRotate90)
132TEST_WEBRTCVIDEOFRAME(ConstructUYVYRotate180)
133TEST_WEBRTCVIDEOFRAME(ConstructUYVYRotate270)
134TEST_WEBRTCVIDEOFRAME(ConstructYUY2Rotate0)
135TEST_WEBRTCVIDEOFRAME(ConstructYUY2Rotate90)
136TEST_WEBRTCVIDEOFRAME(ConstructYUY2Rotate180)
137TEST_WEBRTCVIDEOFRAME(ConstructYUY2Rotate270)
138TEST_WEBRTCVIDEOFRAME(ConstructI4201Pixel)
139TEST_WEBRTCVIDEOFRAME(ConstructI4205Pixel)
140// TODO(juberti): WebRtcVideoFrame does not support horizontal crop.
141// Re-evaluate once it supports 3 independent planes, since we might want to
142// just Init normally and then crop by adjusting pointers.
143// TEST_WEBRTCVIDEOFRAME(ConstructI420CropHorizontal)
144TEST_WEBRTCVIDEOFRAME(ConstructI420CropVertical)
145// TODO(juberti): WebRtcVideoFrame is not currently refcounted.
146// TEST_WEBRTCVIDEOFRAME(ConstructCopy)
147// TEST_WEBRTCVIDEOFRAME(ConstructCopyIsRef)
148TEST_WEBRTCVIDEOFRAME(ConstructBlack)
149// TODO(fbarchard): Implement Jpeg
150// TEST_WEBRTCVIDEOFRAME(ConstructMjpgI420)
thorcarpenter@google.coma3344cf2014-09-05 16:34:13 +0000151TEST_WEBRTCVIDEOFRAME(ConstructMjpgI422)
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000152// TEST_WEBRTCVIDEOFRAME(ConstructMjpgI444)
153// TEST_WEBRTCVIDEOFRAME(ConstructMjpgI411)
154// TEST_WEBRTCVIDEOFRAME(ConstructMjpgI400)
155// TEST_WEBRTCVIDEOFRAME(ValidateMjpgI420)
156// TEST_WEBRTCVIDEOFRAME(ValidateMjpgI422)
157// TEST_WEBRTCVIDEOFRAME(ValidateMjpgI444)
158// TEST_WEBRTCVIDEOFRAME(ValidateMjpgI411)
159// TEST_WEBRTCVIDEOFRAME(ValidateMjpgI400)
160TEST_WEBRTCVIDEOFRAME(ValidateI420)
161TEST_WEBRTCVIDEOFRAME(ValidateI420SmallSize)
162TEST_WEBRTCVIDEOFRAME(ValidateI420LargeSize)
163TEST_WEBRTCVIDEOFRAME(ValidateI420HugeSize)
164// TEST_WEBRTCVIDEOFRAME(ValidateMjpgI420InvalidSize)
165// TEST_WEBRTCVIDEOFRAME(ValidateI420InvalidSize)
166
167// TODO(fbarchard): WebRtcVideoFrame does not support odd sizes.
168// Re-evaluate once WebRTC switches to libyuv
169// TEST_WEBRTCVIDEOFRAME(ConstructYuy2AllSizes)
170// TEST_WEBRTCVIDEOFRAME(ConstructARGBAllSizes)
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000171TEST_WEBRTCVIDEOFRAME(ConvertToABGRBuffer)
172TEST_WEBRTCVIDEOFRAME(ConvertToABGRBufferStride)
173TEST_WEBRTCVIDEOFRAME(ConvertToABGRBufferInverted)
174TEST_WEBRTCVIDEOFRAME(ConvertToARGB1555Buffer)
175TEST_WEBRTCVIDEOFRAME(ConvertToARGB1555BufferStride)
176TEST_WEBRTCVIDEOFRAME(ConvertToARGB1555BufferInverted)
177TEST_WEBRTCVIDEOFRAME(ConvertToARGB4444Buffer)
178TEST_WEBRTCVIDEOFRAME(ConvertToARGB4444BufferStride)
179TEST_WEBRTCVIDEOFRAME(ConvertToARGB4444BufferInverted)
180TEST_WEBRTCVIDEOFRAME(ConvertToARGBBuffer)
181TEST_WEBRTCVIDEOFRAME(ConvertToARGBBufferStride)
182TEST_WEBRTCVIDEOFRAME(ConvertToARGBBufferInverted)
183TEST_WEBRTCVIDEOFRAME(ConvertToBGRABuffer)
184TEST_WEBRTCVIDEOFRAME(ConvertToBGRABufferStride)
185TEST_WEBRTCVIDEOFRAME(ConvertToBGRABufferInverted)
186TEST_WEBRTCVIDEOFRAME(ConvertToRAWBuffer)
187TEST_WEBRTCVIDEOFRAME(ConvertToRAWBufferStride)
188TEST_WEBRTCVIDEOFRAME(ConvertToRAWBufferInverted)
189TEST_WEBRTCVIDEOFRAME(ConvertToRGB24Buffer)
190TEST_WEBRTCVIDEOFRAME(ConvertToRGB24BufferStride)
191TEST_WEBRTCVIDEOFRAME(ConvertToRGB24BufferInverted)
192TEST_WEBRTCVIDEOFRAME(ConvertToRGB565Buffer)
193TEST_WEBRTCVIDEOFRAME(ConvertToRGB565BufferStride)
194TEST_WEBRTCVIDEOFRAME(ConvertToRGB565BufferInverted)
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000195TEST_WEBRTCVIDEOFRAME(ConvertToI400Buffer)
196TEST_WEBRTCVIDEOFRAME(ConvertToI400BufferStride)
197TEST_WEBRTCVIDEOFRAME(ConvertToI400BufferInverted)
198TEST_WEBRTCVIDEOFRAME(ConvertToYUY2Buffer)
199TEST_WEBRTCVIDEOFRAME(ConvertToYUY2BufferStride)
200TEST_WEBRTCVIDEOFRAME(ConvertToYUY2BufferInverted)
201TEST_WEBRTCVIDEOFRAME(ConvertToUYVYBuffer)
202TEST_WEBRTCVIDEOFRAME(ConvertToUYVYBufferStride)
203TEST_WEBRTCVIDEOFRAME(ConvertToUYVYBufferInverted)
204TEST_WEBRTCVIDEOFRAME(ConvertFromABGRBuffer)
205TEST_WEBRTCVIDEOFRAME(ConvertFromABGRBufferStride)
206TEST_WEBRTCVIDEOFRAME(ConvertFromABGRBufferInverted)
207TEST_WEBRTCVIDEOFRAME(ConvertFromARGB1555Buffer)
208TEST_WEBRTCVIDEOFRAME(ConvertFromARGB1555BufferStride)
209TEST_WEBRTCVIDEOFRAME(ConvertFromARGB1555BufferInverted)
210TEST_WEBRTCVIDEOFRAME(ConvertFromARGB4444Buffer)
211TEST_WEBRTCVIDEOFRAME(ConvertFromARGB4444BufferStride)
212TEST_WEBRTCVIDEOFRAME(ConvertFromARGB4444BufferInverted)
213TEST_WEBRTCVIDEOFRAME(ConvertFromARGBBuffer)
214TEST_WEBRTCVIDEOFRAME(ConvertFromARGBBufferStride)
215TEST_WEBRTCVIDEOFRAME(ConvertFromARGBBufferInverted)
216TEST_WEBRTCVIDEOFRAME(ConvertFromBGRABuffer)
217TEST_WEBRTCVIDEOFRAME(ConvertFromBGRABufferStride)
218TEST_WEBRTCVIDEOFRAME(ConvertFromBGRABufferInverted)
219TEST_WEBRTCVIDEOFRAME(ConvertFromRAWBuffer)
220TEST_WEBRTCVIDEOFRAME(ConvertFromRAWBufferStride)
221TEST_WEBRTCVIDEOFRAME(ConvertFromRAWBufferInverted)
222TEST_WEBRTCVIDEOFRAME(ConvertFromRGB24Buffer)
223TEST_WEBRTCVIDEOFRAME(ConvertFromRGB24BufferStride)
224TEST_WEBRTCVIDEOFRAME(ConvertFromRGB24BufferInverted)
225TEST_WEBRTCVIDEOFRAME(ConvertFromRGB565Buffer)
226TEST_WEBRTCVIDEOFRAME(ConvertFromRGB565BufferStride)
227TEST_WEBRTCVIDEOFRAME(ConvertFromRGB565BufferInverted)
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000228TEST_WEBRTCVIDEOFRAME(ConvertFromI400Buffer)
229TEST_WEBRTCVIDEOFRAME(ConvertFromI400BufferStride)
230TEST_WEBRTCVIDEOFRAME(ConvertFromI400BufferInverted)
231TEST_WEBRTCVIDEOFRAME(ConvertFromYUY2Buffer)
232TEST_WEBRTCVIDEOFRAME(ConvertFromYUY2BufferStride)
233TEST_WEBRTCVIDEOFRAME(ConvertFromYUY2BufferInverted)
234TEST_WEBRTCVIDEOFRAME(ConvertFromUYVYBuffer)
235TEST_WEBRTCVIDEOFRAME(ConvertFromUYVYBufferStride)
236TEST_WEBRTCVIDEOFRAME(ConvertFromUYVYBufferInverted)
237// TEST_WEBRTCVIDEOFRAME(ConvertToI422Buffer)
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000238// TEST_WEBRTCVIDEOFRAME(ConstructARGBBlackWhitePixel)
239
240TEST_WEBRTCVIDEOFRAME(StretchToFrame)
241TEST_WEBRTCVIDEOFRAME(Copy)
242TEST_WEBRTCVIDEOFRAME(CopyIsRef)
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000243
244// These functions test implementation-specific details.
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000245// Tests the Init function with different cropped size.
246TEST_F(WebRtcVideoFrameTest, InitEvenSize) {
perkj@webrtc.org1d828132015-03-03 06:44:06 +0000247 TestInit(640, 360, webrtc::kVideoRotation_0, true);
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000248}
249
250TEST_F(WebRtcVideoFrameTest, InitOddWidth) {
perkj@webrtc.org1d828132015-03-03 06:44:06 +0000251 TestInit(601, 480, webrtc::kVideoRotation_0, true);
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000252}
253
254TEST_F(WebRtcVideoFrameTest, InitOddHeight) {
perkj@webrtc.org1d828132015-03-03 06:44:06 +0000255 TestInit(360, 765, webrtc::kVideoRotation_0, true);
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000256}
257
258TEST_F(WebRtcVideoFrameTest, InitOddWidthHeight) {
perkj@webrtc.org1d828132015-03-03 06:44:06 +0000259 TestInit(355, 1021, webrtc::kVideoRotation_0, true);
260}
261
262TEST_F(WebRtcVideoFrameTest, InitRotated90ApplyRotation) {
263 TestInit(640, 360, webrtc::kVideoRotation_90, true);
264}
265
266TEST_F(WebRtcVideoFrameTest, InitRotated90DontApplyRotation) {
267 TestInit(640, 360, webrtc::kVideoRotation_90, false);
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000268}
magjed@webrtc.org1af13912015-03-06 17:17:18 +0000269
270TEST_F(WebRtcVideoFrameTest, TextureInitialValues) {
Peter Boströmeb66e802015-06-05 11:08:03 +0200271 webrtc::test::FakeNativeHandle* dummy_handle =
272 new webrtc::test::FakeNativeHandle();
273 webrtc::NativeHandleBuffer* buffer =
274 new rtc::RefCountedObject<webrtc::test::FakeNativeHandleBuffer>(
275 dummy_handle, 640, 480);
nisseb17712f2016-04-14 02:29:29 -0700276 // Timestamp is converted from ns to us, so last three digits are lost.
277 cricket::WebRtcVideoFrame frame(buffer, 20000, webrtc::kVideoRotation_0);
Per9b3f56e2015-04-09 13:44:16 +0200278 EXPECT_EQ(dummy_handle, frame.GetNativeHandle());
nisse71a0c2f2016-04-04 00:57:29 -0700279 EXPECT_EQ(640, frame.width());
280 EXPECT_EQ(480, frame.height());
nisseb17712f2016-04-14 02:29:29 -0700281 EXPECT_EQ(20000, frame.GetTimeStamp());
282 EXPECT_EQ(20, frame.timestamp_us());
283 frame.set_timestamp_us(40);
284 EXPECT_EQ(40000, frame.GetTimeStamp());
285 EXPECT_EQ(40, frame.timestamp_us());
magjed@webrtc.org1af13912015-03-06 17:17:18 +0000286}
287
288TEST_F(WebRtcVideoFrameTest, CopyTextureFrame) {
Peter Boströmeb66e802015-06-05 11:08:03 +0200289 webrtc::test::FakeNativeHandle* dummy_handle =
290 new webrtc::test::FakeNativeHandle();
291 webrtc::NativeHandleBuffer* buffer =
292 new rtc::RefCountedObject<webrtc::test::FakeNativeHandleBuffer>(
293 dummy_handle, 640, 480);
nisseb17712f2016-04-14 02:29:29 -0700294 // Timestamp is converted from ns to us, so last three digits are lost.
295 cricket::WebRtcVideoFrame frame1(buffer, 20000, webrtc::kVideoRotation_0);
magjed@webrtc.org1af13912015-03-06 17:17:18 +0000296 cricket::VideoFrame* frame2 = frame1.Copy();
297 EXPECT_EQ(frame1.GetNativeHandle(), frame2->GetNativeHandle());
nisse71a0c2f2016-04-04 00:57:29 -0700298 EXPECT_EQ(frame1.width(), frame2->width());
299 EXPECT_EQ(frame1.height(), frame2->height());
magjed@webrtc.org1af13912015-03-06 17:17:18 +0000300 EXPECT_EQ(frame1.GetTimeStamp(), frame2->GetTimeStamp());
nisseb17712f2016-04-14 02:29:29 -0700301 EXPECT_EQ(frame1.timestamp_us(), frame2->timestamp_us());
magjed@webrtc.org1af13912015-03-06 17:17:18 +0000302 delete frame2;
303}
guoweis@webrtc.org00c509a2015-03-12 21:37:26 +0000304
305TEST_F(WebRtcVideoFrameTest, ApplyRotationToFrame) {
306 WebRtcVideoTestFrame applied0;
307 EXPECT_TRUE(IsNull(applied0));
kwiberg686a8ef2016-02-26 03:00:35 -0800308 std::unique_ptr<rtc::MemoryStream> ms(CreateYuvSample(kWidth, kHeight, 12));
guoweis@webrtc.org00c509a2015-03-12 21:37:26 +0000309 EXPECT_TRUE(
310 LoadFrame(ms.get(), cricket::FOURCC_I420, kWidth, kHeight, &applied0));
311
312 // Claim that this frame needs to be rotated for 90 degree.
nissef3868762016-04-13 03:29:16 -0700313 applied0.set_rotation(webrtc::kVideoRotation_90);
guoweis@webrtc.org00c509a2015-03-12 21:37:26 +0000314
315 // Apply rotation on frame 1. Output should be different from frame 1.
316 WebRtcVideoTestFrame* applied90 = const_cast<WebRtcVideoTestFrame*>(
317 static_cast<const WebRtcVideoTestFrame*>(
318 applied0.GetCopyWithRotationApplied()));
319 EXPECT_TRUE(applied90);
nissef3868762016-04-13 03:29:16 -0700320 EXPECT_EQ(applied90->rotation(), webrtc::kVideoRotation_0);
guoweis@webrtc.org00c509a2015-03-12 21:37:26 +0000321 EXPECT_FALSE(IsEqual(applied0, *applied90, 0));
322
323 // Claim the frame 2 needs to be rotated for another 270 degree. The output
324 // from frame 2 rotation should be the same as frame 1.
nissef3868762016-04-13 03:29:16 -0700325 applied90->set_rotation(webrtc::kVideoRotation_270);
guoweis@webrtc.org00c509a2015-03-12 21:37:26 +0000326 const cricket::VideoFrame* applied360 =
327 applied90->GetCopyWithRotationApplied();
328 EXPECT_TRUE(applied360);
nissef3868762016-04-13 03:29:16 -0700329 EXPECT_EQ(applied360->rotation(), webrtc::kVideoRotation_0);
guoweis@webrtc.org00c509a2015-03-12 21:37:26 +0000330 EXPECT_TRUE(IsEqual(applied0, *applied360, 0));
331}