| OLD | NEW |
| 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 |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 } | 77 } |
| 78 | 78 |
| 79 } // namespace | 79 } // namespace |
| 80 | 80 |
| 81 TEST(TestVideoFrame, InitialValues) { | 81 TEST(TestVideoFrame, InitialValues) { |
| 82 VideoFrame frame; | 82 VideoFrame frame; |
| 83 EXPECT_TRUE(frame.IsZeroSize()); | 83 EXPECT_TRUE(frame.IsZeroSize()); |
| 84 EXPECT_EQ(kVideoRotation_0, frame.rotation()); | 84 EXPECT_EQ(kVideoRotation_0, frame.rotation()); |
| 85 } | 85 } |
| 86 | 86 |
| 87 TEST(TestVideoFrame, CopiesInitialFrameWithoutCrashing) { | |
| 88 VideoFrame frame; | |
| 89 VideoFrame frame2; | |
| 90 frame2.CopyFrame(frame); | |
| 91 } | |
| 92 | |
| 93 TEST(TestVideoFrame, WidthHeightValues) { | 87 TEST(TestVideoFrame, WidthHeightValues) { |
| 94 VideoFrame frame(I420Buffer::Create(10, 10, 10, 14, 90), | 88 VideoFrame frame(I420Buffer::Create(10, 10, 10, 14, 90), |
| 95 webrtc::kVideoRotation_0, | 89 webrtc::kVideoRotation_0, |
| 96 789 * rtc::kNumMicrosecsPerMillisec); | 90 789 * rtc::kNumMicrosecsPerMillisec); |
| 97 const int valid_value = 10; | 91 const int valid_value = 10; |
| 98 EXPECT_EQ(valid_value, frame.width()); | 92 EXPECT_EQ(valid_value, frame.width()); |
| 99 EXPECT_EQ(valid_value, frame.height()); | 93 EXPECT_EQ(valid_value, frame.height()); |
| 100 frame.set_timestamp(123u); | 94 frame.set_timestamp(123u); |
| 101 EXPECT_EQ(123u, frame.timestamp()); | 95 EXPECT_EQ(123u, frame.timestamp()); |
| 102 frame.set_ntp_time_ms(456); | 96 frame.set_ntp_time_ms(456); |
| 103 EXPECT_EQ(456, frame.ntp_time_ms()); | 97 EXPECT_EQ(456, frame.ntp_time_ms()); |
| 104 EXPECT_EQ(789, frame.render_time_ms()); | 98 EXPECT_EQ(789, frame.render_time_ms()); |
| 105 } | 99 } |
| 106 | 100 |
| 107 TEST(TestVideoFrame, CopyFrame) { | |
| 108 int stride_y = 15; | |
| 109 int stride_u = 10; | |
| 110 int stride_v = 10; | |
| 111 int width = 15; | |
| 112 int height = 15; | |
| 113 // Copy frame. | |
| 114 VideoFrame small_frame; | |
| 115 const int kSizeY = 400; | |
| 116 const int kSizeU = 100; | |
| 117 const int kSizeV = 100; | |
| 118 const VideoRotation kRotation = kVideoRotation_270; | |
| 119 uint8_t buffer_y[kSizeY]; | |
| 120 uint8_t buffer_u[kSizeU]; | |
| 121 uint8_t buffer_v[kSizeV]; | |
| 122 memset(buffer_y, 16, kSizeY); | |
| 123 memset(buffer_u, 8, kSizeU); | |
| 124 memset(buffer_v, 4, kSizeV); | |
| 125 VideoFrame big_frame; | |
| 126 big_frame.CreateFrame(buffer_y, buffer_u, buffer_v, | |
| 127 width + 5, height + 5, stride_y + 5, | |
| 128 stride_u, stride_v, kRotation); | |
| 129 // Frame of smaller dimensions. | |
| 130 small_frame.CopyFrame(big_frame); | |
| 131 EXPECT_TRUE(test::FramesEqual(small_frame, big_frame)); | |
| 132 EXPECT_EQ(kRotation, small_frame.rotation()); | |
| 133 | |
| 134 // Frame of larger dimensions. | |
| 135 rtc::scoped_refptr<I420Buffer> buffer = | |
| 136 I420Buffer::Create(width, height, stride_y, stride_u, stride_v); | |
| 137 memset(buffer->MutableDataY(), 1, width * height); | |
| 138 memset(buffer->MutableDataU(), 2, ((height + 1) / 2) * stride_u); | |
| 139 memset(buffer->MutableDataV(), 3, ((height + 1) / 2) * stride_u); | |
| 140 VideoFrame other_frame(buffer, 0, 0, webrtc::kVideoRotation_0); | |
| 141 big_frame.CopyFrame(other_frame); | |
| 142 EXPECT_TRUE(test::FramesEqual(other_frame, big_frame)); | |
| 143 } | |
| 144 | |
| 145 TEST(TestVideoFrame, ShallowCopy) { | 101 TEST(TestVideoFrame, ShallowCopy) { |
| 146 uint32_t timestamp = 1; | 102 uint32_t timestamp = 1; |
| 147 int64_t ntp_time_ms = 2; | 103 int64_t ntp_time_ms = 2; |
| 148 int64_t render_time_ms = 3; | 104 int64_t render_time_ms = 3; |
| 149 int stride_y = 15; | 105 int stride_y = 15; |
| 150 int stride_u = 10; | 106 int stride_u = 10; |
| 151 int stride_v = 10; | 107 int stride_v = 10; |
| 152 int width = 15; | 108 int width = 15; |
| 153 int height = 15; | 109 int height = 15; |
| 154 | 110 |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 312 | 268 |
| 313 // Center crop to 640 x 360 (16/9 aspect), then scale down by 2. | 269 // Center crop to 640 x 360 (16/9 aspect), then scale down by 2. |
| 314 rtc::scoped_refptr<I420Buffer> scaled_buffer( | 270 rtc::scoped_refptr<I420Buffer> scaled_buffer( |
| 315 I420Buffer::Create(320, 180)); | 271 I420Buffer::Create(320, 180)); |
| 316 | 272 |
| 317 scaled_buffer->CropAndScaleFrom(buf); | 273 scaled_buffer->CropAndScaleFrom(buf); |
| 318 CheckCrop(scaled_buffer, 0.0, 0.125, 1.0, 0.75); | 274 CheckCrop(scaled_buffer, 0.0, 0.125, 1.0, 0.75); |
| 319 } | 275 } |
| 320 | 276 |
| 321 } // namespace webrtc | 277 } // namespace webrtc |
| OLD | NEW |