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

Unified Diff: webrtc/common_video/i420_video_frame_unittest.cc

Issue 2397943003: Revert of Delete webrtc::VideoFrame::CopyFrame. (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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | webrtc/common_video/video_frame.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/common_video/i420_video_frame_unittest.cc
diff --git a/webrtc/common_video/i420_video_frame_unittest.cc b/webrtc/common_video/i420_video_frame_unittest.cc
index f9dcc66827d475e72a1d1dda2dde552bb12b3af0..c10fefdbfe593e535b876f096b464b63ea4eaee3 100644
--- a/webrtc/common_video/i420_video_frame_unittest.cc
+++ b/webrtc/common_video/i420_video_frame_unittest.cc
@@ -84,6 +84,12 @@
EXPECT_EQ(kVideoRotation_0, frame.rotation());
}
+TEST(TestVideoFrame, CopiesInitialFrameWithoutCrashing) {
+ VideoFrame frame;
+ VideoFrame frame2;
+ frame2.CopyFrame(frame);
+}
+
TEST(TestVideoFrame, WidthHeightValues) {
VideoFrame frame(I420Buffer::Create(10, 10, 10, 14, 90),
webrtc::kVideoRotation_0,
@@ -96,6 +102,44 @@
frame.set_ntp_time_ms(456);
EXPECT_EQ(456, frame.ntp_time_ms());
EXPECT_EQ(789, frame.render_time_ms());
+}
+
+TEST(TestVideoFrame, CopyFrame) {
+ int stride_y = 15;
+ int stride_u = 10;
+ int stride_v = 10;
+ int width = 15;
+ int height = 15;
+ // Copy frame.
+ VideoFrame small_frame;
+ const int kSizeY = 400;
+ const int kSizeU = 100;
+ const int kSizeV = 100;
+ const VideoRotation kRotation = kVideoRotation_270;
+ uint8_t buffer_y[kSizeY];
+ uint8_t buffer_u[kSizeU];
+ uint8_t buffer_v[kSizeV];
+ memset(buffer_y, 16, kSizeY);
+ memset(buffer_u, 8, kSizeU);
+ memset(buffer_v, 4, kSizeV);
+ VideoFrame big_frame;
+ big_frame.CreateFrame(buffer_y, buffer_u, buffer_v,
+ width + 5, height + 5, stride_y + 5,
+ stride_u, stride_v, kRotation);
+ // Frame of smaller dimensions.
+ small_frame.CopyFrame(big_frame);
+ EXPECT_TRUE(test::FramesEqual(small_frame, big_frame));
+ EXPECT_EQ(kRotation, small_frame.rotation());
+
+ // Frame of larger dimensions.
+ rtc::scoped_refptr<I420Buffer> buffer =
+ I420Buffer::Create(width, height, stride_y, stride_u, stride_v);
+ memset(buffer->MutableDataY(), 1, width * height);
+ memset(buffer->MutableDataU(), 2, ((height + 1) / 2) * stride_u);
+ memset(buffer->MutableDataV(), 3, ((height + 1) / 2) * stride_u);
+ VideoFrame other_frame(buffer, 0, 0, webrtc::kVideoRotation_0);
+ big_frame.CopyFrame(other_frame);
+ EXPECT_TRUE(test::FramesEqual(other_frame, big_frame));
}
TEST(TestVideoFrame, ShallowCopy) {
« 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