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

Unified Diff: webrtc/common_video/video_frame_buffer.cc

Issue 1822283002: New method I420Buffer::Copy. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Address compare nit. Created 4 years, 9 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/include/video_frame_buffer.h ('k') | webrtc/test/frame_utils.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..6f49e8aef9d0f1f387ff15cce119aca0699567ac 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,23 @@ 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(libyuv::I420Copy(buffer->data(kYPlane), buffer->stride(kYPlane),
+ 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) == 0);
+
+ return copy;
+}
+
NativeHandleBuffer::NativeHandleBuffer(void* native_handle,
int width,
int height)
« no previous file with comments | « webrtc/common_video/include/video_frame_buffer.h ('k') | webrtc/test/frame_utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698