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..9f3a822416c052b6efdc6002e9cbcb0fbf19640f 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,24 @@ rtc::scoped_refptr<VideoFrameBuffer> I420Buffer::NativeToI420Buffer() { |
return nullptr; |
} |
+rtc::scoped_refptr<I420Buffer> I420Buffer::Copy( |
+ const rtc::scoped_refptr<VideoFrameBuffer>& buffer) { |
+ int width = buffer->width(); |
+ int height = buffer->height(); |
+ rtc::scoped_refptr<I420Buffer> copy = |
+ new rtc::RefCountedObject<I420Buffer>(width, height); |
+ RTC_CHECK(0 == |
+ libyuv::I420Copy(buffer->data(kYPlane), buffer->stride(kYPlane), |
pbos-webrtc
2016/03/29 14:00:37
pref RTC_CHECK_EQ or == 0 after
|
+ buffer->data(kUPlane), buffer->stride(kUPlane), |
+ buffer->data(kVPlane), buffer->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) |