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

Unified Diff: media/base/video_frame_pool.cc

Issue 1227383003: Remove memset from VideoFrame and mark buffer as unpoisoned (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: dalecurtis@ comments. Created 5 years, 5 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_pool.cc
diff --git a/media/base/video_frame_pool.cc b/media/base/video_frame_pool.cc
index ac021348c14e82d6fe6e2fcd011838fc23c0a58a..3211b5101dca6cd3c3ea2ca9bba1358910c9fa2b 100644
--- a/media/base/video_frame_pool.cc
+++ b/media/base/video_frame_pool.cc
@@ -20,11 +20,14 @@ class VideoFramePool::PoolImpl
// Returns a frame from the pool that matches the specified
// parameters or creates a new frame if no suitable frame exists in
// the pool. The pool is drained if no matching frame is found.
+ // If it is to create a new frame and |zero_init_new_allocations| is
DaleCurtis 2015/07/09 23:29:44 nit: If a new frame must be created and |zero_new_
emircan 2015/07/10 00:22:53 Done.
+ // true, it will zero initialize the buffer after allocation.
scoped_refptr<VideoFrame> CreateFrame(VideoFrame::Format format,
const gfx::Size& coded_size,
const gfx::Rect& visible_rect,
const gfx::Size& natural_size,
- base::TimeDelta timestamp);
+ base::TimeDelta timestamp,
+ bool zero_init_new_allocations);
// Shuts down the frame pool and releases all frames in |frames_|.
// Once this is called frames will no longer be inserted back into
@@ -60,7 +63,8 @@ scoped_refptr<VideoFrame> VideoFramePool::PoolImpl::CreateFrame(
const gfx::Size& coded_size,
const gfx::Rect& visible_rect,
const gfx::Size& natural_size,
- base::TimeDelta timestamp) {
+ base::TimeDelta timestamp,
+ bool zero_init_new_allocations) {
base::AutoLock auto_lock(lock_);
DCHECK(!is_shutdown_);
@@ -83,6 +87,8 @@ scoped_refptr<VideoFrame> VideoFramePool::PoolImpl::CreateFrame(
if (!frame.get()) {
frame = VideoFrame::CreateFrame(
format, coded_size, visible_rect, natural_size, timestamp);
+ if (zero_init_new_allocations)
+ memset(frame->data(0), 0, VideoFrame::AlignedAllocationSize(frame));
}
scoped_refptr<VideoFrame> wrapped_frame = VideoFrame::WrapVideoFrame(
@@ -119,9 +125,10 @@ scoped_refptr<VideoFrame> VideoFramePool::CreateFrame(
const gfx::Size& coded_size,
const gfx::Rect& visible_rect,
const gfx::Size& natural_size,
- base::TimeDelta timestamp) {
+ base::TimeDelta timestamp,
+ bool zero_init_new_allocations) {
return pool_->CreateFrame(format, coded_size, visible_rect, natural_size,
- timestamp);
+ timestamp, zero_init_new_allocations);
}
size_t VideoFramePool::GetPoolSizeForTesting() const {

Powered by Google App Engine
This is Rietveld 408576698