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