| 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 1ec451cb7971f8efff47eed9ac6bc4adb6f18d6b..7e3ba48922e7a56002f46af798ebdda31503f8ca 100644
|
| --- a/webrtc/common_video/i420_video_frame_unittest.cc
|
| +++ b/webrtc/common_video/i420_video_frame_unittest.cc
|
| @@ -17,13 +17,44 @@
|
| #include "webrtc/test/fake_texture_frame.h"
|
| #include "webrtc/video_frame.h"
|
|
|
| -namespace webrtc {
|
| -
|
| +namespace {
|
| bool EqualPlane(const uint8_t* data1,
|
| const uint8_t* data2,
|
| int stride,
|
| int width,
|
| - int height);
|
| + int height) {
|
| + for (int y = 0; y < height; ++y) {
|
| + if (memcmp(data1, data2, width) != 0)
|
| + return false;
|
| + data1 += stride;
|
| + data2 += stride;
|
| + }
|
| + return true;
|
| +}
|
| +bool FramesEqual(const webrtc::VideoFrame& f1, const webrtc::VideoFrame& f2) {
|
| + if (f1.width() != f2.width() || f1.height() != f2.height() ||
|
| + f1.stride(webrtc::kYPlane) != f2.stride(webrtc::kYPlane) ||
|
| + f1.stride(webrtc::kUPlane) != f2.stride(webrtc::kUPlane) ||
|
| + f1.stride(webrtc::kVPlane) != f2.stride(webrtc::kVPlane) ||
|
| + f1.timestamp() != f2.timestamp() ||
|
| + f1.ntp_time_ms() != f2.ntp_time_ms() ||
|
| + f1.render_time_ms() != f2.render_time_ms()) {
|
| + return false;
|
| + }
|
| + const int half_width = (f1.width() + 1) / 2;
|
| + const int half_height = (f1.height() + 1) / 2;
|
| + return EqualPlane(f1.buffer(webrtc::kYPlane), f2.buffer(webrtc::kYPlane),
|
| + f1.stride(webrtc::kYPlane), f1.width(), f1.height()) &&
|
| + EqualPlane(f1.buffer(webrtc::kUPlane), f2.buffer(webrtc::kUPlane),
|
| + f1.stride(webrtc::kUPlane), half_width, half_height) &&
|
| + EqualPlane(f1.buffer(webrtc::kVPlane), f2.buffer(webrtc::kVPlane),
|
| + f1.stride(webrtc::kVPlane), half_width, half_height);
|
| +}
|
| +
|
| +}
|
| +
|
| +namespace webrtc {
|
| +
|
| int ExpectedSize(int plane_stride, int image_height, PlaneType type);
|
|
|
| TEST(TestVideoFrame, InitialValues) {
|
| @@ -41,7 +72,7 @@ TEST(TestVideoFrame, CopiesInitialFrameWithoutCrashing) {
|
| TEST(TestVideoFrame, WidthHeightValues) {
|
| VideoFrame frame;
|
| const int valid_value = 10;
|
| - EXPECT_EQ(0, frame.CreateEmptyFrame(10, 10, 10, 14, 90));
|
| + frame.CreateEmptyFrame(10, 10, 10, 14, 90);
|
| EXPECT_EQ(valid_value, frame.width());
|
| EXPECT_EQ(valid_value, frame.height());
|
| frame.set_timestamp(123u);
|
| @@ -54,7 +85,7 @@ TEST(TestVideoFrame, WidthHeightValues) {
|
|
|
| TEST(TestVideoFrame, SizeAllocation) {
|
| VideoFrame frame;
|
| - EXPECT_EQ(0, frame. CreateEmptyFrame(10, 10, 12, 14, 220));
|
| + frame. CreateEmptyFrame(10, 10, 12, 14, 220);
|
| int height = frame.height();
|
| int stride_y = frame.stride(kYPlane);
|
| int stride_u = frame.stride(kUPlane);
|
| @@ -79,8 +110,8 @@ TEST(TestVideoFrame, CopyFrame) {
|
| int height = 15;
|
| // Copy frame.
|
| VideoFrame small_frame;
|
| - EXPECT_EQ(0, small_frame.CreateEmptyFrame(width, height,
|
| - stride_y, stride_u, stride_v));
|
| + small_frame.CreateEmptyFrame(width, height,
|
| + stride_y, stride_u, stride_v);
|
| small_frame.set_timestamp(timestamp);
|
| small_frame.set_ntp_time_ms(ntp_time_ms);
|
| small_frame.set_render_time_ms(render_time_ms);
|
| @@ -95,23 +126,22 @@ TEST(TestVideoFrame, CopyFrame) {
|
| memset(buffer_u, 8, kSizeU);
|
| memset(buffer_v, 4, kSizeV);
|
| VideoFrame big_frame;
|
| - EXPECT_EQ(0,
|
| - big_frame.CreateFrame(buffer_y, buffer_u, buffer_v,
|
| - width + 5, height + 5, stride_y + 5,
|
| - stride_u, stride_v, kRotation));
|
| + 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.
|
| - EXPECT_EQ(0, small_frame.CopyFrame(big_frame));
|
| - EXPECT_TRUE(small_frame.EqualsFrame(big_frame));
|
| + small_frame.CopyFrame(big_frame);
|
| + EXPECT_TRUE(FramesEqual(small_frame, big_frame));
|
| EXPECT_EQ(kRotation, small_frame.rotation());
|
|
|
| // Frame of larger dimensions.
|
| - EXPECT_EQ(0, small_frame.CreateEmptyFrame(width, height,
|
| - stride_y, stride_u, stride_v));
|
| + small_frame.CreateEmptyFrame(width, height,
|
| + stride_y, stride_u, stride_v);
|
| memset(small_frame.buffer(kYPlane), 1, small_frame.allocated_size(kYPlane));
|
| memset(small_frame.buffer(kUPlane), 2, small_frame.allocated_size(kUPlane));
|
| memset(small_frame.buffer(kVPlane), 3, small_frame.allocated_size(kVPlane));
|
| - EXPECT_EQ(0, big_frame.CopyFrame(small_frame));
|
| - EXPECT_TRUE(small_frame.EqualsFrame(big_frame));
|
| + big_frame.CopyFrame(small_frame);
|
| + EXPECT_TRUE(FramesEqual(small_frame, big_frame));
|
| }
|
|
|
| TEST(TestVideoFrame, ShallowCopy) {
|
| @@ -135,8 +165,8 @@ TEST(TestVideoFrame, ShallowCopy) {
|
| memset(buffer_u, 8, kSizeU);
|
| memset(buffer_v, 4, kSizeV);
|
| VideoFrame frame1;
|
| - EXPECT_EQ(0, frame1.CreateFrame(buffer_y, buffer_u, buffer_v, width, height,
|
| - stride_y, stride_u, stride_v, kRotation));
|
| + frame1.CreateFrame(buffer_y, buffer_u, buffer_v, width, height,
|
| + stride_y, stride_u, stride_v, kRotation);
|
| frame1.set_timestamp(timestamp);
|
| frame1.set_ntp_time_ms(ntp_time_ms);
|
| frame1.set_render_time_ms(render_time_ms);
|
| @@ -172,7 +202,7 @@ TEST(TestVideoFrame, ShallowCopy) {
|
|
|
| TEST(TestVideoFrame, Reset) {
|
| VideoFrame frame;
|
| - ASSERT_EQ(frame.CreateEmptyFrame(5, 5, 5, 5, 5), 0);
|
| + frame.CreateEmptyFrame(5, 5, 5, 5, 5);
|
| frame.set_ntp_time_ms(1);
|
| frame.set_timestamp(2);
|
| frame.set_render_time_ms(3);
|
| @@ -193,8 +223,8 @@ TEST(TestVideoFrame, CopyBuffer) {
|
| int stride_uv = 10;
|
| const int kSizeY = 225;
|
| const int kSizeUv = 80;
|
| - EXPECT_EQ(0, frame2.CreateEmptyFrame(width, height,
|
| - stride_y, stride_uv, stride_uv));
|
| + frame2.CreateEmptyFrame(width, height,
|
| + stride_y, stride_uv, stride_uv);
|
| uint8_t buffer_y[kSizeY];
|
| uint8_t buffer_u[kSizeUv];
|
| uint8_t buffer_v[kSizeUv];
|
| @@ -202,7 +232,8 @@ TEST(TestVideoFrame, CopyBuffer) {
|
| memset(buffer_u, 8, kSizeUv);
|
| memset(buffer_v, 4, kSizeUv);
|
| frame2.CreateFrame(buffer_y, buffer_u, buffer_v,
|
| - width, height, stride_y, stride_uv, stride_uv);
|
| + width, height, stride_y, stride_uv, stride_uv,
|
| + kVideoRotation_0);
|
| // Expect exactly the same pixel data.
|
| EXPECT_TRUE(EqualPlane(buffer_y, frame2.buffer(kYPlane), stride_y, 15, 15));
|
| EXPECT_TRUE(EqualPlane(buffer_u, frame2.buffer(kUPlane), stride_uv, 8, 8));
|
|
|