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

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: Change SimpleFormatChange test so it can pass on Android. 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
« no previous file with comments | « media/base/video_frame.h ('k') | media/base/video_frame_pool.h » ('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 (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 base::Closure& no_longer_needed_cb) {
187 scoped_refptr<VideoFrame> wrapped_frame(new VideoFrame(
188 frame->format(), frame->coded_size(), frame->visible_rect(),
189 frame->natural_size(), frame->GetTimestamp(), frame->end_of_stream()));
190
191 for (size_t i = 0; i < NumPlanes(frame->format()); ++i) {
192 wrapped_frame->strides_[i] = frame->stride(i);
193 wrapped_frame->data_[i] = frame->data(i);
194 }
195
196 wrapped_frame->no_longer_needed_cb_ = no_longer_needed_cb;
197 return wrapped_frame;
198 }
199
200 // static
184 scoped_refptr<VideoFrame> VideoFrame::CreateEOSFrame() { 201 scoped_refptr<VideoFrame> VideoFrame::CreateEOSFrame() {
185 return new VideoFrame(VideoFrame::UNKNOWN, 202 return new VideoFrame(VideoFrame::UNKNOWN,
186 gfx::Size(), 203 gfx::Size(),
187 gfx::Rect(), 204 gfx::Rect(),
188 gfx::Size(), 205 gfx::Size(),
189 kNoTimestamp(), 206 kNoTimestamp(),
190 true); 207 true);
191 } 208 }
192 209
193 // static 210 // static
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
503 : mailbox_(mailbox), 520 : mailbox_(mailbox),
504 sync_point_(sync_point), 521 sync_point_(sync_point),
505 release_callback_(release_callback) {} 522 release_callback_(release_callback) {}
506 523
507 VideoFrame::MailboxHolder::~MailboxHolder() { 524 VideoFrame::MailboxHolder::~MailboxHolder() {
508 if (!release_callback_.is_null()) 525 if (!release_callback_.is_null())
509 release_callback_.Run(sync_point_); 526 release_callback_.Run(sync_point_);
510 } 527 }
511 528
512 } // namespace media 529 } // namespace media
OLDNEW
« no previous file with comments | « media/base/video_frame.h ('k') | media/base/video_frame_pool.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698