Chromium Code Reviews| Index: media/base/video_frame.cc |
| diff --git a/media/base/video_frame.cc b/media/base/video_frame.cc |
| index f80f9aa31004328acf531bb67c511c833f476bae..d3944b7a8c050e03d1d1e7fb02d47f3c684d2779 100644 |
| --- a/media/base/video_frame.cc |
| +++ b/media/base/video_frame.cc |
| @@ -625,6 +625,18 @@ int VideoFrame::stride(size_t plane) const { |
| return strides_[plane]; |
| } |
| +size_t VideoFrame::allocated_size() const { |
| + DCHECK(IsYuvPlanar(format_)); |
| + DCHECK_EQ(storage_type_, STORAGE_OWNED_MEMORY); |
| + |
| + // If CreateFrame() method is used, return the size with alignments and |
| + // padding. |
| + if (allocated_size_) |
|
DaleCurtis
2015/08/04 19:07:44
Just default to zero in all cases except the Alloc
emircan
2015/08/04 19:54:35
Done.
|
| + return allocated_size_; |
| + |
| + return VideoFrame::AllocationSize(format_, coded_size_); |
| +} |
| + |
| int VideoFrame::row_bytes(size_t plane) const { |
| return RowBytes(plane, format_, coded_size_.width()); |
| } |
| @@ -895,11 +907,13 @@ 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 allocated_size() returns the same size as allocated here. |
| + allocated_size_ = data_size; |
| } |
| } // namespace media |