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

Unified Diff: webrtc/common_video/video_frame_buffer.cc

Issue 2285693002: New static I420Buffer::Rotate method, to replace GetCopyWithRotationApplied. (Closed)
Patch Set: Change back to static method, now in I420Buffer. Created 4 years, 4 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
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 fd20e564f5e5bf855a331393d4f443975f3e8867..2d7e7f45653f98585026adc3044b1478d3ee1f87 100644
--- a/webrtc/common_video/video_frame_buffer.cc
+++ b/webrtc/common_video/video_frame_buffer.cc
@@ -216,6 +216,7 @@ void I420Buffer::ScaleFrom(const rtc::scoped_refptr<VideoFrameBuffer>& src) {
CropAndScaleFrom(src, 0, 0, src->width(), src->height());
}
+// static
rtc::scoped_refptr<I420Buffer> I420Buffer::CopyKeepStride(
const rtc::scoped_refptr<VideoFrameBuffer>& source) {
int width = source->width();
@@ -236,6 +237,41 @@ rtc::scoped_refptr<I420Buffer> I420Buffer::CopyKeepStride(
return target;
}
+// static
+rtc::scoped_refptr<VideoFrameBuffer> I420Buffer::Rotate(
+ const rtc::scoped_refptr<VideoFrameBuffer>& src,
+ VideoRotation rotation) {
+ RTC_DCHECK(src->DataY());
+ RTC_DCHECK(src->DataU());
+ RTC_DCHECK(src->DataV());
+
+ if (rotation == webrtc::kVideoRotation_0) {
+ return src;
+ }
+
+ int rotated_width = src->width();
+ int rotated_height = src->height();
+ if (rotation == webrtc::kVideoRotation_90 ||
+ rotation == webrtc::kVideoRotation_270) {
+ std::swap(rotated_width, rotated_height);
+ }
+
+ rtc::scoped_refptr<webrtc::I420Buffer> buffer =
+ I420Buffer::Create(rotated_width, rotated_height);
+
+ int res = libyuv::I420Rotate(
+ src->DataY(), src->StrideY(),
+ src->DataU(), src->StrideU(),
+ src->DataV(), src->StrideV(),
+ buffer->MutableDataY(), buffer->StrideY(), buffer->MutableDataU(),
+ buffer->StrideU(), buffer->MutableDataV(), buffer->StrideV(),
+ src->width(), src->height(),
+ static_cast<libyuv::RotationMode>(rotation));
+ RTC_DCHECK_EQ(res, 0);
+
+ return buffer;
+}
+
NativeHandleBuffer::NativeHandleBuffer(void* native_handle,
int width,
int height)
« no previous file with comments | « webrtc/common_video/include/video_frame_buffer.h ('k') | webrtc/examples/peerconnection/client/linux/main_wnd.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698