OLD | NEW |
1 /* | 1 /* |
2 * libjingle | 2 * libjingle |
3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 Google Inc. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are met: | 6 * modification, are permitted provided that the following conditions are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright notice, | 8 * 1. Redistributions of source code must retain the above copyright notice, |
9 * this list of conditions and the following disclaimer. | 9 * this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright notice, | 10 * 2. Redistributions in binary form must reproduce the above copyright notice, |
(...skipping 21 matching lines...) Expand all Loading... |
32 #include "webrtc/test/fake_texture_frame.h" | 32 #include "webrtc/test/fake_texture_frame.h" |
33 | 33 |
34 namespace { | 34 namespace { |
35 | 35 |
36 class WebRtcVideoTestFrame : public cricket::WebRtcVideoFrame { | 36 class WebRtcVideoTestFrame : public cricket::WebRtcVideoFrame { |
37 public: | 37 public: |
38 using cricket::WebRtcVideoFrame::SetRotation; | 38 using cricket::WebRtcVideoFrame::SetRotation; |
39 | 39 |
40 virtual VideoFrame* CreateEmptyFrame(int w, | 40 virtual VideoFrame* CreateEmptyFrame(int w, |
41 int h, | 41 int h, |
42 size_t pixel_width, | |
43 size_t pixel_height, | |
44 int64_t time_stamp) const override { | 42 int64_t time_stamp) const override { |
45 WebRtcVideoTestFrame* frame = new WebRtcVideoTestFrame(); | 43 WebRtcVideoTestFrame* frame = new WebRtcVideoTestFrame(); |
46 frame->InitToBlack(w, h, pixel_width, pixel_height, time_stamp); | 44 frame->InitToBlack(w, h, time_stamp); |
47 return frame; | 45 return frame; |
48 } | 46 } |
49 }; | 47 }; |
50 | 48 |
51 } // namespace | 49 } // namespace |
52 | 50 |
53 class WebRtcVideoFrameTest : public VideoFrameTest<cricket::WebRtcVideoFrame> { | 51 class WebRtcVideoFrameTest : public VideoFrameTest<cricket::WebRtcVideoFrame> { |
54 public: | 52 public: |
55 WebRtcVideoFrameTest() { | 53 WebRtcVideoFrameTest() { |
56 } | 54 } |
57 | 55 |
58 void TestInit(int cropped_width, int cropped_height, | 56 void TestInit(int cropped_width, int cropped_height, |
59 webrtc::VideoRotation frame_rotation, | 57 webrtc::VideoRotation frame_rotation, |
60 bool apply_rotation) { | 58 bool apply_rotation) { |
61 const int frame_width = 1920; | 59 const int frame_width = 1920; |
62 const int frame_height = 1080; | 60 const int frame_height = 1080; |
63 | 61 |
64 // Build the CapturedFrame. | 62 // Build the CapturedFrame. |
65 cricket::CapturedFrame captured_frame; | 63 cricket::CapturedFrame captured_frame; |
66 captured_frame.fourcc = cricket::FOURCC_I420; | 64 captured_frame.fourcc = cricket::FOURCC_I420; |
67 captured_frame.pixel_width = 1; | |
68 captured_frame.pixel_height = 1; | |
69 captured_frame.time_stamp = 5678; | 65 captured_frame.time_stamp = 5678; |
70 captured_frame.rotation = frame_rotation; | 66 captured_frame.rotation = frame_rotation; |
71 captured_frame.width = frame_width; | 67 captured_frame.width = frame_width; |
72 captured_frame.height = frame_height; | 68 captured_frame.height = frame_height; |
73 captured_frame.data_size = (frame_width * frame_height) + | 69 captured_frame.data_size = (frame_width * frame_height) + |
74 ((frame_width + 1) / 2) * ((frame_height + 1) / 2) * 2; | 70 ((frame_width + 1) / 2) * ((frame_height + 1) / 2) * 2; |
75 rtc::scoped_ptr<uint8_t[]> captured_frame_buffer( | 71 rtc::scoped_ptr<uint8_t[]> captured_frame_buffer( |
76 new uint8_t[captured_frame.data_size]); | 72 new uint8_t[captured_frame.data_size]); |
77 // Initialize memory to satisfy DrMemory tests. | 73 // Initialize memory to satisfy DrMemory tests. |
78 memset(captured_frame_buffer.get(), 0, captured_frame.data_size); | 74 memset(captured_frame_buffer.get(), 0, captured_frame.data_size); |
79 captured_frame.data = captured_frame_buffer.get(); | 75 captured_frame.data = captured_frame_buffer.get(); |
80 | 76 |
81 // Create the new frame from the CapturedFrame. | 77 // Create the new frame from the CapturedFrame. |
82 cricket::WebRtcVideoFrame frame; | 78 cricket::WebRtcVideoFrame frame; |
83 EXPECT_TRUE( | 79 EXPECT_TRUE( |
84 frame.Init(&captured_frame, cropped_width, cropped_height, | 80 frame.Init(&captured_frame, cropped_width, cropped_height, |
85 apply_rotation)); | 81 apply_rotation)); |
86 | 82 |
87 // Verify the new frame. | 83 // Verify the new frame. |
88 EXPECT_EQ(1u, frame.GetPixelWidth()); | |
89 EXPECT_EQ(1u, frame.GetPixelHeight()); | |
90 EXPECT_EQ(5678, frame.GetTimeStamp()); | 84 EXPECT_EQ(5678, frame.GetTimeStamp()); |
91 if (apply_rotation) | 85 if (apply_rotation) |
92 EXPECT_EQ(webrtc::kVideoRotation_0, frame.GetRotation()); | 86 EXPECT_EQ(webrtc::kVideoRotation_0, frame.GetRotation()); |
93 else | 87 else |
94 EXPECT_EQ(frame_rotation, frame.GetRotation()); | 88 EXPECT_EQ(frame_rotation, frame.GetRotation()); |
95 // If |apply_rotation| and the frame rotation is 90 or 270, width and | 89 // If |apply_rotation| and the frame rotation is 90 or 270, width and |
96 // height are flipped. | 90 // height are flipped. |
97 if (apply_rotation && (frame_rotation == webrtc::kVideoRotation_90 | 91 if (apply_rotation && (frame_rotation == webrtc::kVideoRotation_90 |
98 || frame_rotation == webrtc::kVideoRotation_270)) { | 92 || frame_rotation == webrtc::kVideoRotation_270)) { |
99 EXPECT_EQ(static_cast<size_t>(cropped_width), frame.GetHeight()); | 93 EXPECT_EQ(static_cast<size_t>(cropped_width), frame.GetHeight()); |
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
343 | 337 |
344 // Claim the frame 2 needs to be rotated for another 270 degree. The output | 338 // Claim the frame 2 needs to be rotated for another 270 degree. The output |
345 // from frame 2 rotation should be the same as frame 1. | 339 // from frame 2 rotation should be the same as frame 1. |
346 applied90->SetRotation(webrtc::kVideoRotation_270); | 340 applied90->SetRotation(webrtc::kVideoRotation_270); |
347 const cricket::VideoFrame* applied360 = | 341 const cricket::VideoFrame* applied360 = |
348 applied90->GetCopyWithRotationApplied(); | 342 applied90->GetCopyWithRotationApplied(); |
349 EXPECT_TRUE(applied360); | 343 EXPECT_TRUE(applied360); |
350 EXPECT_EQ(applied360->GetVideoRotation(), webrtc::kVideoRotation_0); | 344 EXPECT_EQ(applied360->GetVideoRotation(), webrtc::kVideoRotation_0); |
351 EXPECT_TRUE(IsEqual(applied0, *applied360, 0)); | 345 EXPECT_TRUE(IsEqual(applied0, *applied360, 0)); |
352 } | 346 } |
OLD | NEW |