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

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

Issue 101623006: Created VideoFramePool to avoid unnecessary VideoFrame alloc/free. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add PoolImpl destructor to make clang on the bots happy. Created 7 years 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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.h" 5 #include "media/base/video_frame.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback_helpers.h" 10 #include "base/callback_helpers.h"
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 frame->strides_[kUPlane] = u_stride; 174 frame->strides_[kUPlane] = u_stride;
175 frame->strides_[kVPlane] = v_stride; 175 frame->strides_[kVPlane] = v_stride;
176 frame->data_[kYPlane] = y_data; 176 frame->data_[kYPlane] = y_data;
177 frame->data_[kUPlane] = u_data; 177 frame->data_[kUPlane] = u_data;
178 frame->data_[kVPlane] = v_data; 178 frame->data_[kVPlane] = v_data;
179 frame->no_longer_needed_cb_ = no_longer_needed_cb; 179 frame->no_longer_needed_cb_ = no_longer_needed_cb;
180 return frame; 180 return frame;
181 } 181 }
182 182
183 // static 183 // static
184 scoped_refptr<VideoFrame> VideoFrame::WrapVideoFrame(
185 const scoped_refptr<VideoFrame>& frame,
186 const WrapperDestroyedCB& wrapper_destroyed_cb) {
187
DaleCurtis 2013/12/09 20:48:25 Extra line.
acolwell GONE FROM CHROMIUM 2013/12/09 21:42:11 Done.
188 scoped_refptr<VideoFrame> wrapped_frame(new VideoFrame(
189 frame->format(), frame->coded_size(), frame->visible_rect(),
190 frame->natural_size(), frame->GetTimestamp(), frame->end_of_stream()));
191
192 for (size_t i = 0; i < NumPlanes(frame->format()); ++i) {
193 wrapped_frame->strides_[i] = frame->stride(i);
194 wrapped_frame->data_[i] = frame->data(i);
195 }
196
197 wrapped_frame->no_longer_needed_cb_ = base::Bind(wrapper_destroyed_cb, frame);
198 return wrapped_frame;
199 }
200
201 // static
184 scoped_refptr<VideoFrame> VideoFrame::CreateEOSFrame() { 202 scoped_refptr<VideoFrame> VideoFrame::CreateEOSFrame() {
185 return new VideoFrame(VideoFrame::UNKNOWN, 203 return new VideoFrame(VideoFrame::UNKNOWN,
186 gfx::Size(), 204 gfx::Size(),
187 gfx::Rect(), 205 gfx::Rect(),
188 gfx::Size(), 206 gfx::Size(),
189 kNoTimestamp(), 207 kNoTimestamp(),
190 true); 208 true);
191 } 209 }
192 210
193 // static 211 // static
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
503 : mailbox_(mailbox), 521 : mailbox_(mailbox),
504 sync_point_(sync_point), 522 sync_point_(sync_point),
505 release_callback_(release_callback) {} 523 release_callback_(release_callback) {}
506 524
507 VideoFrame::MailboxHolder::~MailboxHolder() { 525 VideoFrame::MailboxHolder::~MailboxHolder() {
508 if (!release_callback_.is_null()) 526 if (!release_callback_.is_null())
509 release_callback_.Run(sync_point_); 527 release_callback_.Run(sync_point_);
510 } 528 }
511 529
512 } // namespace media 530 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698