Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(299)

Unified Diff: media/base/video_frame.cc

Issue 1267003004: Revert to zero-initializing buffers for FFmpegVideoDecoder (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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

Powered by Google App Engine
This is Rietveld 408576698