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

Unified Diff: webrtc/media/base/videoframe_unittest.h

Issue 2278883002: Move MutableDataY{,U,V} methods to I420Buffer only. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Delete unused variable. Created 4 years, 3 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 | « webrtc/common_video/video_frame_buffer.cc ('k') | webrtc/media/engine/webrtcvideoengine2_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/media/base/videoframe_unittest.h
diff --git a/webrtc/media/base/videoframe_unittest.h b/webrtc/media/base/videoframe_unittest.h
index 9658f878f59137d87264c44d645a92bfbbf6bcb2..42936bbefe923f4f80de169164fe77d2a04da67f 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 timestamp_us,
const uint8_t* y,
uint32_t ypitch,
const uint8_t* u,
@@ -462,7 +461,6 @@ class VideoFrameTest : public testing::Test {
uint32_t vpitch,
int max_error) {
return IsSize(frame, width, height) &&
- frame.timestamp_us() == timestamp_us &&
IsPlaneEqual("y", frame.video_frame_buffer()->DataY(),
frame.video_frame_buffer()->StrideY(), y, ypitch,
static_cast<uint32_t>(width),
@@ -480,15 +478,25 @@ class VideoFrameTest : public testing::Test {
static bool IsEqual(const cricket::VideoFrame& frame1,
const cricket::VideoFrame& frame2,
int max_error) {
- return IsEqual(frame1,
+ return frame1.timestamp_us() == frame2.timestamp_us() &&
+ IsEqual(frame1,
frame2.width(), frame2.height(),
- frame2.timestamp_us(),
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(),
+ frame2.video_frame_buffer()->StrideV(), 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);
}
@@ -497,10 +505,10 @@ class VideoFrameTest : public testing::Test {
int hcrop, int vcrop, int max_error) {
return frame1.width() <= frame2.width() &&
frame1.height() <= frame2.height() &&
+ frame1.timestamp_us() == frame2.timestamp_us() &&
IsEqual(frame1,
frame2.width() - hcrop * 2,
frame2.height() - vcrop * 2,
- frame2.timestamp_us(),
frame2.video_frame_buffer()->DataY()
+ vcrop * frame2.video_frame_buffer()->StrideY()
+ hcrop,
@@ -539,8 +547,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.
@@ -554,8 +562,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.
@@ -772,7 +780,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); \
@@ -788,21 +797,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)
@@ -810,7 +816,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); \
@@ -826,21 +833,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.
@@ -944,7 +948,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.
« no previous file with comments | « webrtc/common_video/video_frame_buffer.cc ('k') | webrtc/media/engine/webrtcvideoengine2_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698