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 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 VideoFrame big_frame; | 155 VideoFrame big_frame; |
156 big_frame.CreateFrame(buffer_y, buffer_u, buffer_v, | 156 big_frame.CreateFrame(buffer_y, buffer_u, buffer_v, |
157 width + 5, height + 5, stride_y + 5, | 157 width + 5, height + 5, stride_y + 5, |
158 stride_u, stride_v, kRotation); | 158 stride_u, stride_v, kRotation); |
159 // Frame of smaller dimensions. | 159 // Frame of smaller dimensions. |
160 small_frame.CopyFrame(big_frame); | 160 small_frame.CopyFrame(big_frame); |
161 EXPECT_TRUE(test::FramesEqual(small_frame, big_frame)); | 161 EXPECT_TRUE(test::FramesEqual(small_frame, big_frame)); |
162 EXPECT_EQ(kRotation, small_frame.rotation()); | 162 EXPECT_EQ(kRotation, small_frame.rotation()); |
163 | 163 |
164 // Frame of larger dimensions. | 164 // Frame of larger dimensions. |
165 small_frame.CreateEmptyFrame(width, height, | 165 rtc::scoped_refptr<I420Buffer> buffer = |
166 stride_y, stride_u, stride_v); | 166 I420Buffer::Create(width, height, stride_y, stride_u, stride_v); |
167 memset(small_frame.video_frame_buffer()->MutableDataY(), 1, | 167 memset(buffer->MutableDataY(), 1, width * height); |
168 small_frame.allocated_size(kYPlane)); | 168 memset(buffer->MutableDataU(), 2, ((height + 1) / 2) * stride_u); |
169 memset(small_frame.video_frame_buffer()->MutableDataU(), 2, | 169 memset(buffer->MutableDataV(), 3, ((height + 1) / 2) * stride_u); |
170 small_frame.allocated_size(kUPlane)); | 170 VideoFrame other_frame(buffer, 0, 0, webrtc::kVideoRotation_0); |
171 memset(small_frame.video_frame_buffer()->MutableDataV(), 3, | 171 big_frame.CopyFrame(other_frame); |
172 small_frame.allocated_size(kVPlane)); | 172 EXPECT_TRUE(test::FramesEqual(other_frame, big_frame)); |
173 big_frame.CopyFrame(small_frame); | |
174 EXPECT_TRUE(test::FramesEqual(small_frame, big_frame)); | |
175 } | 173 } |
176 | 174 |
177 TEST(TestVideoFrame, ShallowCopy) { | 175 TEST(TestVideoFrame, ShallowCopy) { |
178 uint32_t timestamp = 1; | 176 uint32_t timestamp = 1; |
179 int64_t ntp_time_ms = 2; | 177 int64_t ntp_time_ms = 2; |
180 int64_t render_time_ms = 3; | 178 int64_t render_time_ms = 3; |
181 int stride_y = 15; | 179 int stride_y = 15; |
182 int stride_u = 10; | 180 int stride_u = 10; |
183 int stride_v = 10; | 181 int stride_v = 10; |
184 int width = 15; | 182 int width = 15; |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
364 | 362 |
365 // Center crop to 640 x 360 (16/9 aspect), then scale down by 2. | 363 // Center crop to 640 x 360 (16/9 aspect), then scale down by 2. |
366 rtc::scoped_refptr<I420Buffer> scaled_buffer( | 364 rtc::scoped_refptr<I420Buffer> scaled_buffer( |
367 I420Buffer::Create(320, 180)); | 365 I420Buffer::Create(320, 180)); |
368 | 366 |
369 scaled_buffer->CropAndScaleFrom(buf); | 367 scaled_buffer->CropAndScaleFrom(buf); |
370 CheckCrop(scaled_buffer, 0.0, 0.125, 1.0, 0.75); | 368 CheckCrop(scaled_buffer, 0.0, 0.125, 1.0, 0.75); |
371 } | 369 } |
372 | 370 |
373 } // namespace webrtc | 371 } // namespace webrtc |
OLD | NEW |