Chromium Code Reviews| Index: media/base/video_frame.cc |
| diff --git a/media/base/video_frame.cc b/media/base/video_frame.cc |
| index e0367c83a649f8ec4c34a7d822ee2a97e6d9b119..07858d7b8cf6b6e92800d6a66c99f09fac8df055 100644 |
| --- a/media/base/video_frame.cc |
| +++ b/media/base/video_frame.cc |
| @@ -548,6 +548,23 @@ size_t VideoFrame::AllocationSize(Format format, const gfx::Size& coded_size) { |
| } |
| // static |
| +size_t VideoFrame::AlignedAllocationSize( |
|
DaleCurtis
2015/07/09 22:21:16
This logic shouldn't be duplicated relative to the
emircan
2015/07/09 23:16:27
I added a DCHECK at the end of AllocateYUV() to en
|
| + const scoped_refptr<VideoFrame>& frame) { |
| + DCHECK(IsYuvPlanar(frame->format())); |
| + DCHECK_EQ(frame->storage_type(), STORAGE_OWNED_MEMORY); |
| + |
| + // This method is expected to called only after CreateFrame(). Therefore, the |
| + // buffer size needs to the same as the allocated size of AllocateYUV(). |
| + size_t data_size = 0; |
| + for (size_t plane = 0; plane < NumPlanes(frame->format()); ++plane) { |
| + const size_t height = RoundUp(frame->rows(plane), kFrameSizeAlignment * 2); |
| + data_size += height * frame->stride(plane); |
| + } |
| + data_size += frame->stride(kUPlane) + kFrameSizePadding; |
| + return data_size; |
| +} |
| + |
| +// static |
| gfx::Size VideoFrame::PlaneSize(Format format, |
| size_t plane, |
| const gfx::Size& coded_size) { |
| @@ -900,12 +917,8 @@ void VideoFrame::AllocateYUV() { |
| DCHECK(IsValidPlane(kUPlane, format_)); |
| data_size += strides_[kUPlane] + kFrameSizePadding; |
| - // FFmpeg expects the initialize allocation to be zero-initialized. Failure |
| - // to do so can lead to unitialized value usage. See http://crbug.com/390941 |
| uint8* data = reinterpret_cast<uint8*>( |
| base::AlignedAlloc(data_size, kFrameAddressAlignment)); |
| - memset(data, 0, data_size); |
| - |
| for (size_t plane = 0; plane < NumPlanes(format_); ++plane) |
| data_[plane] = data + offset[plane]; |