| 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, |
| 42 int64_t time_stamp) const override { | 44 int64_t time_stamp) const override { |
| 43 WebRtcVideoTestFrame* frame = new WebRtcVideoTestFrame(); | 45 WebRtcVideoTestFrame* frame = new WebRtcVideoTestFrame(); |
| 44 frame->InitToBlack(w, h, time_stamp); | 46 frame->InitToBlack(w, h, pixel_width, pixel_height, time_stamp); |
| 45 return frame; | 47 return frame; |
| 46 } | 48 } |
| 47 }; | 49 }; |
| 48 | 50 |
| 49 } // namespace | 51 } // namespace |
| 50 | 52 |
| 51 class WebRtcVideoFrameTest : public VideoFrameTest<cricket::WebRtcVideoFrame> { | 53 class WebRtcVideoFrameTest : public VideoFrameTest<cricket::WebRtcVideoFrame> { |
| 52 public: | 54 public: |
| 53 WebRtcVideoFrameTest() { | 55 WebRtcVideoFrameTest() { |
| 54 } | 56 } |
| 55 | 57 |
| 56 void TestInit(int cropped_width, int cropped_height, | 58 void TestInit(int cropped_width, int cropped_height, |
| 57 webrtc::VideoRotation frame_rotation, | 59 webrtc::VideoRotation frame_rotation, |
| 58 bool apply_rotation) { | 60 bool apply_rotation) { |
| 59 const int frame_width = 1920; | 61 const int frame_width = 1920; |
| 60 const int frame_height = 1080; | 62 const int frame_height = 1080; |
| 61 | 63 |
| 62 // Build the CapturedFrame. | 64 // Build the CapturedFrame. |
| 63 cricket::CapturedFrame captured_frame; | 65 cricket::CapturedFrame captured_frame; |
| 64 captured_frame.fourcc = cricket::FOURCC_I420; | 66 captured_frame.fourcc = cricket::FOURCC_I420; |
| 67 captured_frame.pixel_width = 1; |
| 68 captured_frame.pixel_height = 1; |
| 65 captured_frame.time_stamp = 5678; | 69 captured_frame.time_stamp = 5678; |
| 66 captured_frame.rotation = frame_rotation; | 70 captured_frame.rotation = frame_rotation; |
| 67 captured_frame.width = frame_width; | 71 captured_frame.width = frame_width; |
| 68 captured_frame.height = frame_height; | 72 captured_frame.height = frame_height; |
| 69 captured_frame.data_size = (frame_width * frame_height) + | 73 captured_frame.data_size = (frame_width * frame_height) + |
| 70 ((frame_width + 1) / 2) * ((frame_height + 1) / 2) * 2; | 74 ((frame_width + 1) / 2) * ((frame_height + 1) / 2) * 2; |
| 71 rtc::scoped_ptr<uint8_t[]> captured_frame_buffer( | 75 rtc::scoped_ptr<uint8_t[]> captured_frame_buffer( |
| 72 new uint8_t[captured_frame.data_size]); | 76 new uint8_t[captured_frame.data_size]); |
| 73 // Initialize memory to satisfy DrMemory tests. | 77 // Initialize memory to satisfy DrMemory tests. |
| 74 memset(captured_frame_buffer.get(), 0, captured_frame.data_size); | 78 memset(captured_frame_buffer.get(), 0, captured_frame.data_size); |
| 75 captured_frame.data = captured_frame_buffer.get(); | 79 captured_frame.data = captured_frame_buffer.get(); |
| 76 | 80 |
| 77 // Create the new frame from the CapturedFrame. | 81 // Create the new frame from the CapturedFrame. |
| 78 cricket::WebRtcVideoFrame frame; | 82 cricket::WebRtcVideoFrame frame; |
| 79 EXPECT_TRUE( | 83 EXPECT_TRUE( |
| 80 frame.Init(&captured_frame, cropped_width, cropped_height, | 84 frame.Init(&captured_frame, cropped_width, cropped_height, |
| 81 apply_rotation)); | 85 apply_rotation)); |
| 82 | 86 |
| 83 // Verify the new frame. | 87 // Verify the new frame. |
| 88 EXPECT_EQ(1u, frame.GetPixelWidth()); |
| 89 EXPECT_EQ(1u, frame.GetPixelHeight()); |
| 84 EXPECT_EQ(5678, frame.GetTimeStamp()); | 90 EXPECT_EQ(5678, frame.GetTimeStamp()); |
| 85 if (apply_rotation) | 91 if (apply_rotation) |
| 86 EXPECT_EQ(webrtc::kVideoRotation_0, frame.GetRotation()); | 92 EXPECT_EQ(webrtc::kVideoRotation_0, frame.GetRotation()); |
| 87 else | 93 else |
| 88 EXPECT_EQ(frame_rotation, frame.GetRotation()); | 94 EXPECT_EQ(frame_rotation, frame.GetRotation()); |
| 89 // If |apply_rotation| and the frame rotation is 90 or 270, width and | 95 // If |apply_rotation| and the frame rotation is 90 or 270, width and |
| 90 // height are flipped. | 96 // height are flipped. |
| 91 if (apply_rotation && (frame_rotation == webrtc::kVideoRotation_90 | 97 if (apply_rotation && (frame_rotation == webrtc::kVideoRotation_90 |
| 92 || frame_rotation == webrtc::kVideoRotation_270)) { | 98 || frame_rotation == webrtc::kVideoRotation_270)) { |
| 93 EXPECT_EQ(static_cast<size_t>(cropped_width), frame.GetHeight()); | 99 EXPECT_EQ(static_cast<size_t>(cropped_width), frame.GetHeight()); |
| (...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 337 | 343 |
| 338 // Claim the frame 2 needs to be rotated for another 270 degree. The output | 344 // Claim the frame 2 needs to be rotated for another 270 degree. The output |
| 339 // from frame 2 rotation should be the same as frame 1. | 345 // from frame 2 rotation should be the same as frame 1. |
| 340 applied90->SetRotation(webrtc::kVideoRotation_270); | 346 applied90->SetRotation(webrtc::kVideoRotation_270); |
| 341 const cricket::VideoFrame* applied360 = | 347 const cricket::VideoFrame* applied360 = |
| 342 applied90->GetCopyWithRotationApplied(); | 348 applied90->GetCopyWithRotationApplied(); |
| 343 EXPECT_TRUE(applied360); | 349 EXPECT_TRUE(applied360); |
| 344 EXPECT_EQ(applied360->GetVideoRotation(), webrtc::kVideoRotation_0); | 350 EXPECT_EQ(applied360->GetVideoRotation(), webrtc::kVideoRotation_0); |
| 345 EXPECT_TRUE(IsEqual(applied0, *applied360, 0)); | 351 EXPECT_TRUE(IsEqual(applied0, *applied360, 0)); |
| 346 } | 352 } |
| OLD | NEW |