Index: webrtc/common_video/video_frame.cc |
diff --git a/webrtc/common_video/video_frame.cc b/webrtc/common_video/video_frame.cc |
index cf6b9c82af30fc0eb7d5a41a160e4d81075ebf92..fa23cc15899978c19fb8aa4b88e93c62d1948983 100644 |
--- a/webrtc/common_video/video_frame.cc |
+++ b/webrtc/common_video/video_frame.cc |
@@ -69,10 +69,8 @@ |
if (video_frame_buffer_ && video_frame_buffer_->IsMutable() && |
!video_frame_buffer_->native_handle() && |
width == video_frame_buffer_->width() && |
- height == video_frame_buffer_->height() && |
- stride_y == video_frame_buffer_->StrideY() && |
- stride_u == video_frame_buffer_->StrideU() && |
- stride_v == video_frame_buffer_->StrideV()) { |
+ height == video_frame_buffer_->height() && stride_y == stride(kYPlane) && |
+ stride_u == stride(kUPlane) && stride_v == stride(kVPlane)) { |
return; |
} |
@@ -95,9 +93,9 @@ |
const int expected_size_u = half_height * stride_u; |
const int expected_size_v = half_height * stride_v; |
CreateEmptyFrame(width, height, stride_y, stride_u, stride_v); |
- memcpy(video_frame_buffer_->MutableDataY(), buffer_y, expected_size_y); |
- memcpy(video_frame_buffer_->MutableDataU(), buffer_u, expected_size_u); |
- memcpy(video_frame_buffer_->MutableDataV(), buffer_v, expected_size_v); |
+ memcpy(buffer(kYPlane), buffer_y, expected_size_y); |
+ memcpy(buffer(kUPlane), buffer_u, expected_size_u); |
+ memcpy(buffer(kVPlane), buffer_v, expected_size_v); |
rotation_ = rotation; |
} |
@@ -132,26 +130,22 @@ |
rotation_ = videoFrame.rotation_; |
} |
-// TODO(nisse): Delete. Besides test code, only one use, in |
-// webrtcvideoengine2.cc:CreateBlackFrame. |
+uint8_t* VideoFrame::buffer(PlaneType type) { |
+ return video_frame_buffer_ ? video_frame_buffer_->MutableData(type) |
+ : nullptr; |
+} |
+ |
+const uint8_t* VideoFrame::buffer(PlaneType type) const { |
+ return video_frame_buffer_ ? video_frame_buffer_->data(type) : nullptr; |
+} |
+ |
int VideoFrame::allocated_size(PlaneType type) const { |
const int plane_height = (type == kYPlane) ? height() : (height() + 1) / 2; |
- int stride; |
- switch (type) { |
- case kYPlane: |
- stride = video_frame_buffer_->StrideY(); |
- break; |
- case kUPlane: |
- stride = video_frame_buffer_->StrideU(); |
- break; |
- case kVPlane: |
- stride = video_frame_buffer_->StrideV(); |
- break; |
- default: |
- RTC_NOTREACHED(); |
- return 0; |
- } |
- return plane_height * stride; |
+ return plane_height * stride(type); |
+} |
+ |
+int VideoFrame::stride(PlaneType type) const { |
+ return video_frame_buffer_ ? video_frame_buffer_->stride(type) : 0; |
} |
int VideoFrame::width() const { |
@@ -166,8 +160,7 @@ |
return !video_frame_buffer_; |
} |
-const rtc::scoped_refptr<VideoFrameBuffer>& VideoFrame::video_frame_buffer() |
- const { |
+rtc::scoped_refptr<VideoFrameBuffer> VideoFrame::video_frame_buffer() const { |
return video_frame_buffer_; |
} |