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..ae0de4322284be31db6e9352137a1af42015fade 100644 |
--- a/webrtc/common_video/video_frame_buffer.cc |
+++ b/webrtc/common_video/video_frame_buffer.cc |
@@ -46,6 +46,42 @@ uint8_t* VideoFrameBuffer::MutableDataV() { |
VideoFrameBuffer::~VideoFrameBuffer() {} |
+// static |
+rtc::scoped_refptr<VideoFrameBuffer> VideoFrameBuffer::Rotate( |
+ const rtc::scoped_refptr<VideoFrameBuffer>& src, |
+ VideoRotation rotation) { |
+ if (rotation == webrtc::kVideoRotation_0) { |
+ return src; |
+ } |
+ |
+ int current_width = src->width(); |
magjed_webrtc
2016/08/26 12:04:15
I would prefer if you removed current_width and us
nisse-webrtc
2016/08/26 12:31:40
Done.
|
+ int current_height = src->height(); |
+ |
+ int rotated_width = current_width; |
+ int rotated_height = current_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); |
+ |
+ // TODO(guoweis): Add a function in webrtc_libyuv.cc to convert from |
magjed_webrtc
2016/08/26 12:04:15
Remove this TODO. I think guoweis has moved on fro
nisse-webrtc
2016/08/26 12:31:40
Done.
|
+ // VideoRotation to libyuv::RotationMode. |
+ 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(), |
+ current_width, current_height, |
+ static_cast<libyuv::RotationMode>(rotation)); |
+ RTC_DCHECK_EQ(res, 0); |
+ |
+ return buffer; |
+} |
+ |
I420Buffer::I420Buffer(int width, int height) |
: I420Buffer(width, height, width, (width + 1) / 2, (width + 1) / 2) { |
} |