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

Side by Side Diff: media/base/video_frame_pool.cc

Issue 1267003004: Revert to zero-initializing buffers for FFmpegVideoDecoder (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Zero initialize only the planes. 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 unified diff | Download patch
« no previous file with comments | « media/base/video_frame_pool.h ('k') | media/base/video_frame_pool_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "media/base/video_frame_pool.h" 5 #include "media/base/video_frame_pool.h"
6 6
7 #include <list> 7 #include <list>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
11 #include "base/synchronization/lock.h" 11 #include "base/synchronization/lock.h"
12 12
13 namespace media { 13 namespace media {
14 14
15 class VideoFramePool::PoolImpl 15 class VideoFramePool::PoolImpl
16 : public base::RefCountedThreadSafe<VideoFramePool::PoolImpl> { 16 : public base::RefCountedThreadSafe<VideoFramePool::PoolImpl> {
17 public: 17 public:
18 PoolImpl(); 18 PoolImpl();
19 19
20 // Returns a frame from the pool that matches the specified 20 // See VideoFramePool::CreateFrame() for usage.
21 // parameters or creates a new frame if no suitable frame exists in
22 // the pool. The pool is drained if no matching frame is found.
23 scoped_refptr<VideoFrame> CreateFrame(VideoPixelFormat format, 21 scoped_refptr<VideoFrame> CreateFrame(VideoPixelFormat format,
24 const gfx::Size& coded_size, 22 const gfx::Size& coded_size,
25 const gfx::Rect& visible_rect, 23 const gfx::Rect& visible_rect,
26 const gfx::Size& natural_size, 24 const gfx::Size& natural_size,
27 base::TimeDelta timestamp); 25 base::TimeDelta timestamp);
28 26
29 // Shuts down the frame pool and releases all frames in |frames_|. 27 // Shuts down the frame pool and releases all frames in |frames_|.
30 // Once this is called frames will no longer be inserted back into 28 // Once this is called frames will no longer be inserted back into
31 // |frames_|. 29 // |frames_|.
32 void Shutdown(); 30 void Shutdown();
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 pool_frame->coded_size() == coded_size && 72 pool_frame->coded_size() == coded_size &&
75 pool_frame->visible_rect() == visible_rect && 73 pool_frame->visible_rect() == visible_rect &&
76 pool_frame->natural_size() == natural_size) { 74 pool_frame->natural_size() == natural_size) {
77 frame = pool_frame; 75 frame = pool_frame;
78 frame->set_timestamp(timestamp); 76 frame->set_timestamp(timestamp);
79 break; 77 break;
80 } 78 }
81 } 79 }
82 80
83 if (!frame.get()) { 81 if (!frame.get()) {
84 frame = VideoFrame::CreateFrame( 82 frame = VideoFrame::CreateFrame(format, coded_size, visible_rect,
85 format, coded_size, visible_rect, natural_size, timestamp); 83 natural_size, timestamp);
84
85 // Zero-initialize each plane of the buffer.
86 const size_t num_planes = VideoFrame::NumPlanes(frame->format());
87 for (size_t i = 0; i < num_planes; ++i) {
88 memset(frame->data(i),
89 0,
90 VideoFrame::PlaneSize(frame->format(),
91 i,
92 frame->coded_size()).GetArea());
93 }
86 } 94 }
87 95
88 scoped_refptr<VideoFrame> wrapped_frame = VideoFrame::WrapVideoFrame( 96 scoped_refptr<VideoFrame> wrapped_frame = VideoFrame::WrapVideoFrame(
89 frame, frame->visible_rect(), frame->natural_size()); 97 frame, frame->visible_rect(), frame->natural_size());
90 wrapped_frame->AddDestructionObserver( 98 wrapped_frame->AddDestructionObserver(
91 base::Bind(&VideoFramePool::PoolImpl::FrameReleased, this, frame)); 99 base::Bind(&VideoFramePool::PoolImpl::FrameReleased, this, frame));
92 return wrapped_frame; 100 return wrapped_frame;
93 } 101 }
94 102
95 void VideoFramePool::PoolImpl::Shutdown() { 103 void VideoFramePool::PoolImpl::Shutdown() {
(...skipping 26 matching lines...) Expand all
122 base::TimeDelta timestamp) { 130 base::TimeDelta timestamp) {
123 return pool_->CreateFrame(format, coded_size, visible_rect, natural_size, 131 return pool_->CreateFrame(format, coded_size, visible_rect, natural_size,
124 timestamp); 132 timestamp);
125 } 133 }
126 134
127 size_t VideoFramePool::GetPoolSizeForTesting() const { 135 size_t VideoFramePool::GetPoolSizeForTesting() const {
128 return pool_->GetPoolSizeForTesting(); 136 return pool_->GetPoolSizeForTesting();
129 } 137 }
130 138
131 } // namespace media 139 } // namespace media
OLDNEW
« no previous file with comments | « media/base/video_frame_pool.h ('k') | media/base/video_frame_pool_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698