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

Unified Diff: media/base/video_frame.cc

Issue 1313413010: Add VideoFrame::CreateZeroInitializedFrame (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 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 2009664099cab71b3369acd92068d7e3c8f04cff..242eb2fc6e8aa30e94b2d95d6fc18d6577195964 100644
--- a/media/base/video_frame.cc
+++ b/media/base/video_frame.cc
@@ -195,6 +195,16 @@ scoped_refptr<VideoFrame> VideoFrame::CreateFrame(VideoPixelFormat format,
const gfx::Rect& visible_rect,
const gfx::Size& natural_size,
base::TimeDelta timestamp) {
+ return CreateFrame(format, coded_size, visible_rect, natural_size, timestamp,
+ false);
+}
+
+scoped_refptr<VideoFrame> VideoFrame::CreateFrame(VideoPixelFormat format,
+ const gfx::Size& coded_size,
+ const gfx::Rect& visible_rect,
+ const gfx::Size& natural_size,
+ base::TimeDelta timestamp,
+ bool zero_initialize_memory) {
if (!IsYuvPlanar(format)) {
NOTIMPLEMENTED();
return nullptr;
@@ -222,7 +232,7 @@ scoped_refptr<VideoFrame> VideoFrame::CreateFrame(VideoPixelFormat format,
scoped_refptr<VideoFrame> frame(new VideoFrame(
format, storage, new_coded_size, visible_rect, natural_size, timestamp));
- frame->AllocateYUV();
+ frame->AllocateYUV(zero_initialize_memory);
return frame;
}
@@ -897,7 +907,7 @@ VideoFrame::~VideoFrame() {
base::ResetAndReturn(&callback).Run();
}
-void VideoFrame::AllocateYUV() {
+void VideoFrame::AllocateYUV(bool zero_initialize_memory) {
DCHECK_EQ(storage_type_, STORAGE_OWNED_MEMORY);
static_assert(0 == kYPlane, "y plane data must be index 0");
@@ -923,6 +933,8 @@ void VideoFrame::AllocateYUV() {
uint8* data = reinterpret_cast<uint8*>(
base::AlignedAlloc(data_size, kFrameAddressAlignment));
+ if (zero_initialize_memory)
+ memset(data, 0, data_size);
for (size_t plane = 0; plane < NumPlanes(format_); ++plane)
data_[plane] = data + offset[plane];

Powered by Google App Engine
This is Rietveld 408576698