| Index: webrtc/media/base/videoframe_unittest.h
|
| diff --git a/webrtc/media/base/videoframe_unittest.h b/webrtc/media/base/videoframe_unittest.h
|
| index f19d0325d6a103b5e2f87d68fbcc21ac1ab0b10f..2ca0192ccc9648a2cf61fb42697ec27779c11efa 100644
|
| --- a/webrtc/media/base/videoframe_unittest.h
|
| +++ b/webrtc/media/base/videoframe_unittest.h
|
| @@ -453,7 +453,6 @@ class VideoFrameTest : public testing::Test {
|
| static bool IsEqual(const cricket::VideoFrame& frame,
|
| int width,
|
| int height,
|
| - int64_t time_stamp,
|
| const uint8_t* y,
|
| uint32_t ypitch,
|
| const uint8_t* u,
|
| @@ -461,7 +460,7 @@ class VideoFrameTest : public testing::Test {
|
| const uint8_t* v,
|
| uint32_t vpitch,
|
| int max_error) {
|
| - return IsSize(frame, width, height) && frame.GetTimeStamp() == time_stamp &&
|
| + return IsSize(frame, width, height) &&
|
| IsPlaneEqual("y", frame.video_frame_buffer()->DataY(),
|
| frame.video_frame_buffer()->StrideY(), y, ypitch,
|
| static_cast<uint32_t>(width),
|
| @@ -479,9 +478,9 @@ class VideoFrameTest : public testing::Test {
|
| static bool IsEqual(const cricket::VideoFrame& frame1,
|
| const cricket::VideoFrame& frame2,
|
| int max_error) {
|
| - return IsEqual(frame1,
|
| + return frame1.GetTimeStamp() == frame2.GetTimeStamp() &&
|
| + IsEqual(frame1,
|
| frame2.width(), frame2.height(),
|
| - frame2.GetTimeStamp(),
|
| frame2.video_frame_buffer()->DataY(),
|
| frame2.video_frame_buffer()->StrideY(),
|
| frame2.video_frame_buffer()->DataU(),
|
| @@ -491,15 +490,27 @@ class VideoFrameTest : public testing::Test {
|
| max_error);
|
| }
|
|
|
| + static bool IsEqual(
|
| + const cricket::VideoFrame& frame1,
|
| + const rtc::scoped_refptr<webrtc::VideoFrameBuffer>& buffer,
|
| + int max_error) {
|
| + return IsEqual(frame1,
|
| + buffer->width(), buffer->height(),
|
| + buffer->DataY(), buffer->StrideY(),
|
| + buffer->DataU(), buffer->StrideU(),
|
| + buffer->DataV(), buffer->StrideV(),
|
| + max_error);
|
| + }
|
| +
|
| static bool IsEqualWithCrop(const cricket::VideoFrame& frame1,
|
| const cricket::VideoFrame& frame2,
|
| int hcrop, int vcrop, int max_error) {
|
| return frame1.width() <= frame2.width() &&
|
| frame1.height() <= frame2.height() &&
|
| + frame1.GetTimeStamp() == frame2.GetTimeStamp() &&
|
| IsEqual(frame1,
|
| frame2.width() - hcrop * 2,
|
| frame2.height() - vcrop * 2,
|
| - frame2.GetTimeStamp(),
|
| frame2.video_frame_buffer()->DataY()
|
| + vcrop * frame2.video_frame_buffer()->StrideY()
|
| + hcrop,
|
| @@ -538,8 +549,8 @@ class VideoFrameTest : public testing::Test {
|
| const uint8_t* y = reinterpret_cast<uint8_t*>(ms.get()->GetBuffer());
|
| const uint8_t* u = y + kWidth * kHeight;
|
| const uint8_t* v = u + kWidth * kHeight / 4;
|
| - EXPECT_TRUE(IsEqual(frame, kWidth, kHeight, 0, y, kWidth, u,
|
| - kWidth / 2, v, kWidth / 2, 0));
|
| + EXPECT_TRUE(IsEqual(frame, kWidth, kHeight, y, kWidth, u, kWidth / 2, v,
|
| + kWidth / 2, 0));
|
| }
|
|
|
| // Test constructing an image from a YV12 buffer.
|
| @@ -553,8 +564,8 @@ class VideoFrameTest : public testing::Test {
|
| const uint8_t* y = reinterpret_cast<uint8_t*>(ms.get()->GetBuffer());
|
| const uint8_t* v = y + kWidth * kHeight;
|
| const uint8_t* u = v + kWidth * kHeight / 4;
|
| - EXPECT_TRUE(IsEqual(frame, kWidth, kHeight, 0, y, kWidth, u,
|
| - kWidth / 2, v, kWidth / 2, 0));
|
| + EXPECT_TRUE(IsEqual(frame, kWidth, kHeight, y, kWidth, u, kWidth / 2, v,
|
| + kWidth / 2, 0));
|
| }
|
|
|
| // Test constructing an image from a I422 buffer.
|
| @@ -819,7 +830,8 @@ class VideoFrameTest : public testing::Test {
|
| // Macro to help test different rotations
|
| #define TEST_MIRROR(FOURCC, BPP) \
|
| void Construct##FOURCC##Mirror() { \
|
| - T frame1, frame2, frame3; \
|
| + T frame1, frame2; \
|
| + rtc::scoped_refptr<webrtc::I420Buffer> res_buffer; \
|
| std::unique_ptr<rtc::MemoryStream> ms( \
|
| CreateYuvSample(kWidth, kHeight, BPP)); \
|
| ASSERT_TRUE(ms.get() != NULL); \
|
| @@ -835,21 +847,18 @@ class VideoFrameTest : public testing::Test {
|
| data_size, 0, webrtc::kVideoRotation_0)); \
|
| int width_rotate = frame1.width(); \
|
| int height_rotate = frame1.height(); \
|
| - frame3.InitToEmptyBuffer(width_rotate, height_rotate); \
|
| + res_buffer = webrtc::I420Buffer::Create(width_rotate, height_rotate); \
|
| libyuv::I420Mirror(frame2.video_frame_buffer()->DataY(), \
|
| frame2.video_frame_buffer()->StrideY(), \
|
| frame2.video_frame_buffer()->DataU(), \
|
| frame2.video_frame_buffer()->StrideU(), \
|
| frame2.video_frame_buffer()->DataV(), \
|
| frame2.video_frame_buffer()->StrideV(), \
|
| - frame3.video_frame_buffer()->MutableDataY(), \
|
| - frame3.video_frame_buffer()->StrideY(), \
|
| - frame3.video_frame_buffer()->MutableDataU(), \
|
| - frame3.video_frame_buffer()->StrideU(), \
|
| - frame3.video_frame_buffer()->MutableDataV(), \
|
| - frame3.video_frame_buffer()->StrideV(), kWidth, \
|
| - kHeight); \
|
| - EXPECT_TRUE(IsEqual(frame1, frame3, 0)); \
|
| + res_buffer->MutableDataY(), res_buffer->StrideY(), \
|
| + res_buffer->MutableDataU(), res_buffer->StrideU(), \
|
| + res_buffer->MutableDataV(), res_buffer->StrideV(), \
|
| + kWidth, kHeight); \
|
| + EXPECT_TRUE(IsEqual(frame1, res_buffer, 0)); \
|
| }
|
|
|
| TEST_MIRROR(I420, 420)
|
| @@ -857,7 +866,8 @@ class VideoFrameTest : public testing::Test {
|
| // Macro to help test different rotations
|
| #define TEST_ROTATE(FOURCC, BPP, ROTATE) \
|
| void Construct##FOURCC##Rotate##ROTATE() { \
|
| - T frame1, frame2, frame3; \
|
| + T frame1, frame2; \
|
| + rtc::scoped_refptr<webrtc::I420Buffer> res_buffer; \
|
| std::unique_ptr<rtc::MemoryStream> ms( \
|
| CreateYuvSample(kWidth, kHeight, BPP)); \
|
| ASSERT_TRUE(ms.get() != NULL); \
|
| @@ -873,21 +883,18 @@ class VideoFrameTest : public testing::Test {
|
| data_size, 0, webrtc::kVideoRotation_0)); \
|
| int width_rotate = frame1.width(); \
|
| int height_rotate = frame1.height(); \
|
| - frame3.InitToEmptyBuffer(width_rotate, height_rotate); \
|
| + res_buffer = webrtc::I420Buffer::Create(width_rotate, height_rotate); \
|
| libyuv::I420Rotate(frame2.video_frame_buffer()->DataY(), \
|
| frame2.video_frame_buffer()->StrideY(), \
|
| frame2.video_frame_buffer()->DataU(), \
|
| frame2.video_frame_buffer()->StrideU(), \
|
| frame2.video_frame_buffer()->DataV(), \
|
| frame2.video_frame_buffer()->StrideV(), \
|
| - frame3.video_frame_buffer()->MutableDataY(), \
|
| - frame3.video_frame_buffer()->StrideY(), \
|
| - frame3.video_frame_buffer()->MutableDataU(), \
|
| - frame3.video_frame_buffer()->StrideU(), \
|
| - frame3.video_frame_buffer()->MutableDataV(), \
|
| - frame3.video_frame_buffer()->StrideV(), kWidth, \
|
| - kHeight, libyuv::kRotate##ROTATE); \
|
| - EXPECT_TRUE(IsEqual(frame1, frame3, 0)); \
|
| + res_buffer->MutableDataY(), res_buffer->StrideY(), \
|
| + res_buffer->MutableDataU(), res_buffer->StrideU(), \
|
| + res_buffer->MutableDataV(), res_buffer->StrideV(), \
|
| + kWidth, kHeight, libyuv::kRotate##ROTATE); \
|
| + EXPECT_TRUE(IsEqual(frame1, res_buffer, 0)); \
|
| }
|
|
|
| // Test constructing an image with rotation.
|
| @@ -991,7 +998,7 @@ class VideoFrameTest : public testing::Test {
|
| const uint8_t* y = pixel;
|
| const uint8_t* u = y + 1;
|
| const uint8_t* v = u + 1;
|
| - EXPECT_TRUE(IsEqual(frame, 1, 1, 0, y, 1, u, 1, v, 1, 0));
|
| + EXPECT_TRUE(IsEqual(frame, 1, 1, y, 1, u, 1, v, 1, 0));
|
| }
|
|
|
| // Test 5 pixel edge case image.
|
| @@ -1458,7 +1465,8 @@ class VideoFrameTest : public testing::Test {
|
| int dst_stride_v,
|
| int width,
|
| int height)) {
|
| - T frame1, frame2;
|
| + T frame1;
|
| + rtc::scoped_refptr<webrtc::I420Buffer> res_buffer;
|
| int repeat_to = (to_from == TO) ? repeat_ : 1;
|
| int repeat_from = (to_from == FROM) ? repeat_ : 1;
|
|
|
| @@ -1480,15 +1488,12 @@ class VideoFrameTest : public testing::Test {
|
| out,
|
| out_size, stride));
|
| }
|
| - frame2.InitToEmptyBuffer(kWidth, kHeight);
|
| + res_buffer = webrtc::I420Buffer::Create(kWidth, kHeight);
|
| for (int i = 0; i < repeat_from; ++i) {
|
| EXPECT_EQ(0, RGBToI420(out, stride,
|
| - frame2.video_frame_buffer()->MutableDataY(),
|
| - frame2.video_frame_buffer()->StrideY(),
|
| - frame2.video_frame_buffer()->MutableDataU(),
|
| - frame2.video_frame_buffer()->StrideU(),
|
| - frame2.video_frame_buffer()->MutableDataV(),
|
| - frame2.video_frame_buffer()->StrideV(),
|
| + res_buffer->MutableDataY(), res_buffer->StrideY(),
|
| + res_buffer->MutableDataU(), res_buffer->StrideU(),
|
| + res_buffer->MutableDataV(), res_buffer->StrideV(),
|
| kWidth, kHeight));
|
| }
|
| if (rowpad) {
|
| @@ -1498,7 +1503,7 @@ class VideoFrameTest : public testing::Test {
|
| EXPECT_NE(0, outtop[kWidth * bpp]); // Expect something to be here.
|
| }
|
| EXPECT_EQ(0, outtop[out_size]); // Ensure no overrun.
|
| - EXPECT_TRUE(IsEqual(frame1, frame2, error));
|
| + EXPECT_TRUE(IsEqual(frame1, res_buffer, error));
|
| }
|
|
|
| static const int kError = 20;
|
|
|