Index: webrtc/common_video/video_frame_buffer.cc |
diff --git a/webrtc/common_video/video_frame_buffer.cc b/webrtc/common_video/video_frame_buffer.cc |
index 19e44febaf37b9591e3790269909496b2f41225d..8720793b67da63603d033658e9967933306fb54c 100644 |
--- a/webrtc/common_video/video_frame_buffer.cc |
+++ b/webrtc/common_video/video_frame_buffer.cc |
@@ -12,6 +12,7 @@ |
#include "webrtc/base/checks.h" |
#include "webrtc/base/keep_ref_until_done.h" |
+#include "libyuv/convert.h" |
// Aligning pointer to 64 bytes for improved performance, e.g. use SIMD. |
static const int kBufferAlignment = 64; |
@@ -117,6 +118,21 @@ rtc::scoped_refptr<VideoFrameBuffer> I420Buffer::NativeToI420Buffer() { |
return nullptr; |
} |
+rtc::scoped_refptr<I420Buffer> I420Buffer::Copy() { |
+ rtc::scoped_refptr<I420Buffer> copy = |
+ new rtc::RefCountedObject<I420Buffer>(width(), height()); |
+ RTC_CHECK(0 == libyuv::I420Copy( |
+ data(kYPlane), stride(kYPlane), |
+ data(kUPlane), stride(kUPlane), |
+ data(kVPlane), stride(kVPlane), |
+ copy->MutableData(kYPlane), copy->stride(kYPlane), |
+ copy->MutableData(kUPlane), copy->stride(kUPlane), |
+ copy->MutableData(kVPlane), copy->stride(kVPlane), |
+ width(), height())); |
+ |
+ return copy; |
+} |
+ |
NativeHandleBuffer::NativeHandleBuffer(void* native_handle, |
int width, |
int height) |