Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(231)

Side by Side Diff: webrtc/common_video/i420_video_frame_unittest.cc

Issue 2378003002: Delete webrtc::VideoFrame::CreateEmptyFrame. (Closed)
Patch Set: Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | webrtc/common_video/video_frame.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 EXPECT_EQ(kVideoRotation_0, frame.rotation()); 84 EXPECT_EQ(kVideoRotation_0, frame.rotation());
85 } 85 }
86 86
87 TEST(TestVideoFrame, CopiesInitialFrameWithoutCrashing) { 87 TEST(TestVideoFrame, CopiesInitialFrameWithoutCrashing) {
88 VideoFrame frame; 88 VideoFrame frame;
89 VideoFrame frame2; 89 VideoFrame frame2;
90 frame2.CopyFrame(frame); 90 frame2.CopyFrame(frame);
91 } 91 }
92 92
93 TEST(TestVideoFrame, WidthHeightValues) { 93 TEST(TestVideoFrame, WidthHeightValues) {
94 VideoFrame frame; 94 VideoFrame frame(I420Buffer::Create(10, 10, 10, 14, 90),
95 webrtc::kVideoRotation_0,
96 789 * rtc::kNumMicrosecsPerMillisec);
95 const int valid_value = 10; 97 const int valid_value = 10;
96 frame.CreateEmptyFrame(10, 10, 10, 14, 90);
97 EXPECT_EQ(valid_value, frame.width()); 98 EXPECT_EQ(valid_value, frame.width());
98 EXPECT_EQ(valid_value, frame.height()); 99 EXPECT_EQ(valid_value, frame.height());
99 frame.set_timestamp(123u); 100 frame.set_timestamp(123u);
100 EXPECT_EQ(123u, frame.timestamp()); 101 EXPECT_EQ(123u, frame.timestamp());
101 frame.set_ntp_time_ms(456); 102 frame.set_ntp_time_ms(456);
102 EXPECT_EQ(456, frame.ntp_time_ms()); 103 EXPECT_EQ(456, frame.ntp_time_ms());
103 frame.set_render_time_ms(789);
104 EXPECT_EQ(789, frame.render_time_ms()); 104 EXPECT_EQ(789, frame.render_time_ms());
105 } 105 }
106 106
107 TEST(TestVideoFrame, CopyFrame) { 107 TEST(TestVideoFrame, CopyFrame) {
108 uint32_t timestamp = 1;
109 int64_t ntp_time_ms = 2;
110 int64_t render_time_ms = 3;
111 int stride_y = 15; 108 int stride_y = 15;
112 int stride_u = 10; 109 int stride_u = 10;
113 int stride_v = 10; 110 int stride_v = 10;
114 int width = 15; 111 int width = 15;
115 int height = 15; 112 int height = 15;
116 // Copy frame. 113 // Copy frame.
117 VideoFrame small_frame; 114 VideoFrame small_frame;
magjed_webrtc 2016/09/28 14:03:04 Don't you need to create an I420Buffer here?
nisse-webrtc 2016/09/29 06:32:44 No, CopyFrame allocates a new buffer. Which makes
magjed_webrtc 2016/09/29 15:39:04 I see.
118 small_frame.CreateEmptyFrame(width, height,
119 stride_y, stride_u, stride_v);
120 small_frame.set_timestamp(timestamp);
121 small_frame.set_ntp_time_ms(ntp_time_ms);
122 small_frame.set_render_time_ms(render_time_ms);
123 const int kSizeY = 400; 115 const int kSizeY = 400;
124 const int kSizeU = 100; 116 const int kSizeU = 100;
125 const int kSizeV = 100; 117 const int kSizeV = 100;
126 const VideoRotation kRotation = kVideoRotation_270; 118 const VideoRotation kRotation = kVideoRotation_270;
127 uint8_t buffer_y[kSizeY]; 119 uint8_t buffer_y[kSizeY];
128 uint8_t buffer_u[kSizeU]; 120 uint8_t buffer_u[kSizeU];
129 uint8_t buffer_v[kSizeV]; 121 uint8_t buffer_v[kSizeV];
130 memset(buffer_y, 16, kSizeY); 122 memset(buffer_y, 16, kSizeY);
131 memset(buffer_u, 8, kSizeU); 123 memset(buffer_u, 8, kSizeU);
132 memset(buffer_v, 4, kSizeV); 124 memset(buffer_v, 4, kSizeV);
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 } 199 }
208 200
209 TEST(TestVideoFrame, CopyBuffer) { 201 TEST(TestVideoFrame, CopyBuffer) {
210 VideoFrame frame1, frame2; 202 VideoFrame frame1, frame2;
211 int width = 15; 203 int width = 15;
212 int height = 15; 204 int height = 15;
213 int stride_y = 15; 205 int stride_y = 15;
214 int stride_uv = 10; 206 int stride_uv = 10;
215 const int kSizeY = 225; 207 const int kSizeY = 225;
216 const int kSizeUv = 80; 208 const int kSizeUv = 80;
217 frame2.CreateEmptyFrame(width, height, 209
magjed_webrtc 2016/09/28 14:03:03 ditto: don't you need to create the I40Buffer?
nisse-webrtc 2016/09/29 06:32:44 No, .CreateFrame(various pointers) always allocate
218 stride_y, stride_uv, stride_uv);
219 uint8_t buffer_y[kSizeY]; 210 uint8_t buffer_y[kSizeY];
220 uint8_t buffer_u[kSizeUv]; 211 uint8_t buffer_u[kSizeUv];
221 uint8_t buffer_v[kSizeUv]; 212 uint8_t buffer_v[kSizeUv];
222 memset(buffer_y, 16, kSizeY); 213 memset(buffer_y, 16, kSizeY);
223 memset(buffer_u, 8, kSizeUv); 214 memset(buffer_u, 8, kSizeUv);
224 memset(buffer_v, 4, kSizeUv); 215 memset(buffer_v, 4, kSizeUv);
225 frame2.CreateFrame(buffer_y, buffer_u, buffer_v, 216 frame2.CreateFrame(buffer_y, buffer_u, buffer_v,
226 width, height, stride_y, stride_uv, stride_uv, 217 width, height, stride_y, stride_uv, stride_uv,
227 kVideoRotation_0); 218 kVideoRotation_0);
228 // Expect exactly the same pixel data. 219 // Expect exactly the same pixel data.
229 EXPECT_TRUE(test::EqualPlane(buffer_y, frame2.video_frame_buffer()->DataY(), 220 EXPECT_TRUE(test::EqualPlane(buffer_y, frame2.video_frame_buffer()->DataY(),
230 stride_y, 15, 15)); 221 stride_y, 15, 15));
231 EXPECT_TRUE(test::EqualPlane(buffer_u, frame2.video_frame_buffer()->DataU(), 222 EXPECT_TRUE(test::EqualPlane(buffer_u, frame2.video_frame_buffer()->DataU(),
232 stride_uv, 8, 8)); 223 stride_uv, 8, 8));
233 EXPECT_TRUE(test::EqualPlane(buffer_v, frame2.video_frame_buffer()->DataV(), 224 EXPECT_TRUE(test::EqualPlane(buffer_v, frame2.video_frame_buffer()->DataV(),
234 stride_uv, 8, 8)); 225 stride_uv, 8, 8));
235 } 226 }
236 227
237 TEST(TestVideoFrame, FailToReuseAllocation) {
238 VideoFrame frame1;
239 frame1.CreateEmptyFrame(640, 320, 640, 320, 320);
240 const uint8_t* y = frame1.video_frame_buffer()->DataY();
241 const uint8_t* u = frame1.video_frame_buffer()->DataU();
242 const uint8_t* v = frame1.video_frame_buffer()->DataV();
243 // Make a shallow copy of |frame1|.
244 VideoFrame frame2(frame1.video_frame_buffer(), 0, 0, kVideoRotation_0);
245 frame1.CreateEmptyFrame(640, 320, 640, 320, 320);
246 EXPECT_NE(y, frame1.video_frame_buffer()->DataY());
247 EXPECT_NE(u, frame1.video_frame_buffer()->DataU());
248 EXPECT_NE(v, frame1.video_frame_buffer()->DataV());
249 }
250
251 TEST(TestVideoFrame, TextureInitialValues) { 228 TEST(TestVideoFrame, TextureInitialValues) {
252 test::FakeNativeHandle* handle = new test::FakeNativeHandle(); 229 test::FakeNativeHandle* handle = new test::FakeNativeHandle();
253 VideoFrame frame = test::FakeNativeHandle::CreateFrame( 230 VideoFrame frame = test::FakeNativeHandle::CreateFrame(
254 handle, 640, 480, 100, 10, webrtc::kVideoRotation_0); 231 handle, 640, 480, 100, 10, webrtc::kVideoRotation_0);
255 EXPECT_EQ(640, frame.width()); 232 EXPECT_EQ(640, frame.width());
256 EXPECT_EQ(480, frame.height()); 233 EXPECT_EQ(480, frame.height());
257 EXPECT_EQ(100u, frame.timestamp()); 234 EXPECT_EQ(100u, frame.timestamp());
258 EXPECT_EQ(10, frame.render_time_ms()); 235 EXPECT_EQ(10, frame.render_time_ms());
259 ASSERT_TRUE(frame.video_frame_buffer() != nullptr); 236 ASSERT_TRUE(frame.video_frame_buffer() != nullptr);
260 EXPECT_EQ(handle, frame.video_frame_buffer()->native_handle()); 237 EXPECT_EQ(handle, frame.video_frame_buffer()->native_handle());
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 312
336 // Center crop to 640 x 360 (16/9 aspect), then scale down by 2. 313 // Center crop to 640 x 360 (16/9 aspect), then scale down by 2.
337 rtc::scoped_refptr<I420Buffer> scaled_buffer( 314 rtc::scoped_refptr<I420Buffer> scaled_buffer(
338 I420Buffer::Create(320, 180)); 315 I420Buffer::Create(320, 180));
339 316
340 scaled_buffer->CropAndScaleFrom(buf); 317 scaled_buffer->CropAndScaleFrom(buf);
341 CheckCrop(scaled_buffer, 0.0, 0.125, 1.0, 0.75); 318 CheckCrop(scaled_buffer, 0.0, 0.125, 1.0, 0.75);
342 } 319 }
343 320
344 } // namespace webrtc 321 } // namespace webrtc
OLDNEW
« no previous file with comments | « no previous file | webrtc/common_video/video_frame.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698