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 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 stride_uv, 8, 8)); | 193 stride_uv, 8, 8)); |
194 EXPECT_TRUE(test::EqualPlane(buffer_v, frame2.video_frame_buffer()->DataV(), | 194 EXPECT_TRUE(test::EqualPlane(buffer_v, frame2.video_frame_buffer()->DataV(), |
195 stride_uv, 8, 8)); | 195 stride_uv, 8, 8)); |
196 | 196 |
197 // Compare size. | 197 // Compare size. |
198 EXPECT_LE(kSizeY, frame2.allocated_size(kYPlane)); | 198 EXPECT_LE(kSizeY, frame2.allocated_size(kYPlane)); |
199 EXPECT_LE(kSizeUv, frame2.allocated_size(kUPlane)); | 199 EXPECT_LE(kSizeUv, frame2.allocated_size(kUPlane)); |
200 EXPECT_LE(kSizeUv, frame2.allocated_size(kVPlane)); | 200 EXPECT_LE(kSizeUv, frame2.allocated_size(kVPlane)); |
201 } | 201 } |
202 | 202 |
203 TEST(TestVideoFrame, ReuseAllocation) { | |
204 VideoFrame frame; | |
205 frame.CreateEmptyFrame(640, 320, 640, 320, 320); | |
206 const uint8_t* y = frame.video_frame_buffer()->DataY(); | |
207 const uint8_t* u = frame.video_frame_buffer()->DataU(); | |
208 const uint8_t* v = frame.video_frame_buffer()->DataV(); | |
209 frame.CreateEmptyFrame(640, 320, 640, 320, 320); | |
210 EXPECT_EQ(y, frame.video_frame_buffer()->DataY()); | |
211 EXPECT_EQ(u, frame.video_frame_buffer()->DataU()); | |
212 EXPECT_EQ(v, frame.video_frame_buffer()->DataV()); | |
213 } | |
214 | |
215 TEST(TestVideoFrame, FailToReuseAllocation) { | 203 TEST(TestVideoFrame, FailToReuseAllocation) { |
216 VideoFrame frame1; | 204 VideoFrame frame1; |
217 frame1.CreateEmptyFrame(640, 320, 640, 320, 320); | 205 frame1.CreateEmptyFrame(640, 320, 640, 320, 320); |
218 const uint8_t* y = frame1.video_frame_buffer()->DataY(); | 206 const uint8_t* y = frame1.video_frame_buffer()->DataY(); |
219 const uint8_t* u = frame1.video_frame_buffer()->DataU(); | 207 const uint8_t* u = frame1.video_frame_buffer()->DataU(); |
220 const uint8_t* v = frame1.video_frame_buffer()->DataV(); | 208 const uint8_t* v = frame1.video_frame_buffer()->DataV(); |
221 // Make a shallow copy of |frame1|. | 209 // Make a shallow copy of |frame1|. |
222 VideoFrame frame2(frame1.video_frame_buffer(), 0, 0, kVideoRotation_0); | 210 VideoFrame frame2(frame1.video_frame_buffer(), 0, 0, kVideoRotation_0); |
223 frame1.CreateEmptyFrame(640, 320, 640, 320, 320); | 211 frame1.CreateEmptyFrame(640, 320, 640, 320, 320); |
224 EXPECT_NE(y, frame1.video_frame_buffer()->DataY()); | 212 EXPECT_NE(y, frame1.video_frame_buffer()->DataY()); |
(...skipping 22 matching lines...) Expand all Loading... |
247 rtc::scoped_refptr<I420Buffer> buf1( | 235 rtc::scoped_refptr<I420Buffer> buf1( |
248 new rtc::RefCountedObject<I420Buffer>(20, 10)); | 236 new rtc::RefCountedObject<I420Buffer>(20, 10)); |
249 memset(buf1->MutableDataY(), 1, 200); | 237 memset(buf1->MutableDataY(), 1, 200); |
250 memset(buf1->MutableDataU(), 2, 50); | 238 memset(buf1->MutableDataU(), 2, 50); |
251 memset(buf1->MutableDataV(), 3, 50); | 239 memset(buf1->MutableDataV(), 3, 50); |
252 rtc::scoped_refptr<I420Buffer> buf2 = I420Buffer::Copy(buf1); | 240 rtc::scoped_refptr<I420Buffer> buf2 = I420Buffer::Copy(buf1); |
253 EXPECT_TRUE(test::FrameBufsEqual(buf1, buf2)); | 241 EXPECT_TRUE(test::FrameBufsEqual(buf1, buf2)); |
254 } | 242 } |
255 | 243 |
256 } // namespace webrtc | 244 } // namespace webrtc |
OLD | NEW |