| Index: media/base/video_frame.cc
|
| diff --git a/media/base/video_frame.cc b/media/base/video_frame.cc
|
| index f80f9aa31004328acf531bb67c511c833f476bae..9459a0cb2024ed0a798fe40cbe73a4b09507106b 100644
|
| --- a/media/base/video_frame.cc
|
| +++ b/media/base/video_frame.cc
|
| @@ -538,6 +538,23 @@ size_t VideoFrame::AllocationSize(VideoPixelFormat format,
|
| }
|
|
|
| // static
|
| +size_t VideoFrame::AlignedAllocationSize(
|
| + 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(VideoPixelFormat format,
|
| size_t plane,
|
| const gfx::Size& coded_size) {
|
| @@ -895,11 +912,14 @@ void VideoFrame::AllocateYUV() {
|
|
|
| uint8* data = reinterpret_cast<uint8*>(
|
| base::AlignedAlloc(data_size, kFrameAddressAlignment));
|
| -
|
| for (size_t plane = 0; plane < NumPlanes(format_); ++plane)
|
| data_[plane] = data + offset[plane];
|
|
|
| AddDestructionObserver(base::Bind(&base::AlignedFree, data));
|
| +
|
| + // Make sure that AlignedAllocationSize() returns the same size as allocated
|
| + // here.
|
| + DCHECK_EQ(data_size, VideoFrame::AlignedAllocationSize(this));
|
| }
|
|
|
| } // namespace media
|
|
|