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..320758d1ecce9d9443446e3ed8fb350b431afac2 100644 |
--- a/webrtc/common_video/video_frame_buffer.cc |
+++ b/webrtc/common_video/video_frame_buffer.cc |
@@ -46,6 +46,37 @@ uint8_t* VideoFrameBuffer::MutableDataV() { |
VideoFrameBuffer::~VideoFrameBuffer() {} |
+// static |
+rtc::scoped_refptr<VideoFrameBuffer> VideoFrameBuffer::Rotate( |
+ const rtc::scoped_refptr<VideoFrameBuffer>& src, |
+ VideoRotation rotation) { |
perkj_webrtc
2016/08/26 15:22:17
please dcheck that src->DataY and U and V returns
|
+ 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; |
+} |
+ |
I420Buffer::I420Buffer(int width, int height) |
: I420Buffer(width, height, width, (width + 1) / 2, (width + 1) / 2) { |
} |