New method I420Buffer::Copy.
Needed to replace cricket::VideoFrame::MakeExclusive in chromium.
BUG=webrtc:5682
Review URL: https://codereview.webrtc.org/1822283002
Cr-Original-Commit-Position: refs/heads/master@{#12155}
Cr-Mirrored-From: https://chromium.googlesource.com/external/webrtc
Cr-Mirrored-Commit: 7cc9cc0460b9828fa5c139ecb79cf568824e6dac
diff --git a/test/frame_utils.cc b/test/frame_utils.cc
index 13f358a..0f41144 100644
--- a/test/frame_utils.cc
+++ b/test/frame_utils.cc
@@ -47,5 +47,23 @@
f1.stride(webrtc::kVPlane), half_width, half_height);
}
+bool FrameBufsEqual(const rtc::scoped_refptr<webrtc::VideoFrameBuffer>& f1,
+ const rtc::scoped_refptr<webrtc::VideoFrameBuffer>& 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)) {
+ return false;
+ }
+ const int half_width = (f1->width() + 1) / 2;
+ const int half_height = (f1->height() + 1) / 2;
+ return EqualPlane(f1->data(webrtc::kYPlane), f2->data(webrtc::kYPlane),
+ f1->stride(webrtc::kYPlane), f1->width(), f1->height()) &&
+ EqualPlane(f1->data(webrtc::kUPlane), f2->data(webrtc::kUPlane),
+ f1->stride(webrtc::kUPlane), half_width, half_height) &&
+ EqualPlane(f1->data(webrtc::kVPlane), f2->data(webrtc::kVPlane),
+ f1->stride(webrtc::kVPlane), half_width, half_height);
+}
+
} // namespace test
} // namespace webrtc
diff --git a/test/frame_utils.h b/test/frame_utils.h
index 42e2cba..668d999 100644
--- a/test/frame_utils.h
+++ b/test/frame_utils.h
@@ -11,9 +11,11 @@
#define WEBRTC_TEST_FRAME_UTILS_H_
#include "webrtc/base/basictypes.h"
+#include "webrtc/base/scoped_ref_ptr.h"
namespace webrtc {
class VideoFrame;
+class VideoFrameBuffer;
namespace test {
bool EqualPlane(const uint8_t* data1,
@@ -24,6 +26,9 @@
bool FramesEqual(const webrtc::VideoFrame& f1, const webrtc::VideoFrame& f2);
+bool FrameBufsEqual(const rtc::scoped_refptr<webrtc::VideoFrameBuffer>& f1,
+ const rtc::scoped_refptr<webrtc::VideoFrameBuffer>& f2);
+
} // namespace test
} // namespace webrtc