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 492bc495876a6a21b080252686991c89a2f5840b..19e44febaf37b9591e3790269909496b2f41225d 100644 |
--- a/webrtc/common_video/video_frame_buffer.cc |
+++ b/webrtc/common_video/video_frame_buffer.cc |
@@ -18,6 +18,14 @@ static const int kBufferAlignment = 64; |
namespace webrtc { |
+namespace { |
+ |
+int I420DataSize(int height, int stride_y, int stride_u, int stride_v) { |
+ return stride_y * height + (stride_u + stride_v) * ((height + 1) / 2); |
+} |
+ |
+} // namespace |
+ |
uint8_t* VideoFrameBuffer::MutableData(PlaneType type) { |
RTC_NOTREACHED(); |
return nullptr; |
@@ -40,7 +48,7 @@ I420Buffer::I420Buffer(int width, |
stride_u_(stride_u), |
stride_v_(stride_v), |
data_(static_cast<uint8_t*>(AlignedMalloc( |
- stride_y * height + (stride_u + stride_v) * ((height + 1) / 2), |
+ I420DataSize(height, stride_y, stride_u, stride_v), |
kBufferAlignment))) { |
RTC_DCHECK_GT(width, 0); |
RTC_DCHECK_GT(height, 0); |
@@ -52,6 +60,11 @@ I420Buffer::I420Buffer(int width, |
I420Buffer::~I420Buffer() { |
} |
+void I420Buffer::InitializeData() { |
+ memset(data_.get(), 0, |
+ I420DataSize(height_, stride_y_, stride_u_, stride_v_)); |
+} |
+ |
int I420Buffer::width() const { |
return width_; |
} |