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

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

Issue 859313002: Pepper: Define PPB_VideoEncoder API + Implementation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 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.h ('k') | native_client_sdk/src/libraries/ppapi/library.dsc » ('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 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 272
273 // static 273 // static
274 scoped_refptr<VideoFrame> VideoFrame::WrapExternalPackedMemory( 274 scoped_refptr<VideoFrame> VideoFrame::WrapExternalPackedMemory(
275 Format format, 275 Format format,
276 const gfx::Size& coded_size, 276 const gfx::Size& coded_size,
277 const gfx::Rect& visible_rect, 277 const gfx::Rect& visible_rect,
278 const gfx::Size& natural_size, 278 const gfx::Size& natural_size,
279 uint8* data, 279 uint8* data,
280 size_t data_size, 280 size_t data_size,
281 base::SharedMemoryHandle handle, 281 base::SharedMemoryHandle handle,
282 size_t data_offset,
282 base::TimeDelta timestamp, 283 base::TimeDelta timestamp,
283 const base::Closure& no_longer_needed_cb) { 284 const base::Closure& no_longer_needed_cb) {
284 const gfx::Size new_coded_size = AdjustCodedSize(format, coded_size); 285 const gfx::Size new_coded_size = AdjustCodedSize(format, coded_size);
285 286
286 if (!IsValidConfig(format, new_coded_size, visible_rect, natural_size)) 287 if (!IsValidConfig(format, new_coded_size, visible_rect, natural_size))
287 return NULL; 288 return NULL;
288 if (data_size < AllocationSize(format, new_coded_size)) 289 if (data_size < AllocationSize(format, new_coded_size))
289 return NULL; 290 return NULL;
290 291
291 switch (format) { 292 switch (format) {
292 case VideoFrame::I420: { 293 case VideoFrame::I420: {
293 scoped_refptr<VideoFrame> frame( 294 scoped_refptr<VideoFrame> frame(
294 new VideoFrame(format, 295 new VideoFrame(format,
295 new_coded_size, 296 new_coded_size,
296 visible_rect, 297 visible_rect,
297 natural_size, 298 natural_size,
298 scoped_ptr<gpu::MailboxHolder>(), 299 scoped_ptr<gpu::MailboxHolder>(),
299 timestamp, 300 timestamp,
300 false)); 301 false));
301 frame->shared_memory_handle_ = handle; 302 frame->shared_memory_handle_ = handle;
303 frame->shared_memory_offset_ = data_offset;
302 frame->strides_[kYPlane] = new_coded_size.width(); 304 frame->strides_[kYPlane] = new_coded_size.width();
303 frame->strides_[kUPlane] = new_coded_size.width() / 2; 305 frame->strides_[kUPlane] = new_coded_size.width() / 2;
304 frame->strides_[kVPlane] = new_coded_size.width() / 2; 306 frame->strides_[kVPlane] = new_coded_size.width() / 2;
305 frame->data_[kYPlane] = data; 307 frame->data_[kYPlane] = data;
306 frame->data_[kUPlane] = data + new_coded_size.GetArea(); 308 frame->data_[kUPlane] = data + new_coded_size.GetArea();
307 frame->data_[kVPlane] = data + (new_coded_size.GetArea() * 5 / 4); 309 frame->data_[kVPlane] = data + (new_coded_size.GetArea() * 5 / 4);
308 frame->no_longer_needed_cb_ = no_longer_needed_cb; 310 frame->no_longer_needed_cb_ = no_longer_needed_cb;
309 return frame; 311 return frame;
310 } 312 }
311 default: 313 default:
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after
669 const gfx::Size& natural_size, 671 const gfx::Size& natural_size,
670 scoped_ptr<gpu::MailboxHolder> mailbox_holder, 672 scoped_ptr<gpu::MailboxHolder> mailbox_holder,
671 base::TimeDelta timestamp, 673 base::TimeDelta timestamp,
672 bool end_of_stream) 674 bool end_of_stream)
673 : format_(format), 675 : format_(format),
674 coded_size_(coded_size), 676 coded_size_(coded_size),
675 visible_rect_(visible_rect), 677 visible_rect_(visible_rect),
676 natural_size_(natural_size), 678 natural_size_(natural_size),
677 mailbox_holder_(mailbox_holder.Pass()), 679 mailbox_holder_(mailbox_holder.Pass()),
678 shared_memory_handle_(base::SharedMemory::NULLHandle()), 680 shared_memory_handle_(base::SharedMemory::NULLHandle()),
681 shared_memory_offset_(0),
679 timestamp_(timestamp), 682 timestamp_(timestamp),
680 release_sync_point_(0), 683 release_sync_point_(0),
681 end_of_stream_(end_of_stream) { 684 end_of_stream_(end_of_stream) {
682 DCHECK(IsValidConfig(format_, coded_size_, visible_rect_, natural_size_)); 685 DCHECK(IsValidConfig(format_, coded_size_, visible_rect_, natural_size_));
683 686
684 memset(&strides_, 0, sizeof(strides_)); 687 memset(&strides_, 0, sizeof(strides_));
685 memset(&data_, 0, sizeof(data_)); 688 memset(&data_, 0, sizeof(data_));
686 } 689 }
687 690
688 VideoFrame::~VideoFrame() { 691 VideoFrame::~VideoFrame() {
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
774 777
775 const gpu::MailboxHolder* VideoFrame::mailbox_holder() const { 778 const gpu::MailboxHolder* VideoFrame::mailbox_holder() const {
776 DCHECK_EQ(format_, NATIVE_TEXTURE); 779 DCHECK_EQ(format_, NATIVE_TEXTURE);
777 return mailbox_holder_.get(); 780 return mailbox_holder_.get();
778 } 781 }
779 782
780 base::SharedMemoryHandle VideoFrame::shared_memory_handle() const { 783 base::SharedMemoryHandle VideoFrame::shared_memory_handle() const {
781 return shared_memory_handle_; 784 return shared_memory_handle_;
782 } 785 }
783 786
787 size_t VideoFrame::shared_memory_offset() const {
788 return shared_memory_offset_;
789 }
790
784 void VideoFrame::UpdateReleaseSyncPoint(SyncPointClient* client) { 791 void VideoFrame::UpdateReleaseSyncPoint(SyncPointClient* client) {
785 DCHECK_EQ(format_, NATIVE_TEXTURE); 792 DCHECK_EQ(format_, NATIVE_TEXTURE);
786 base::AutoLock locker(release_sync_point_lock_); 793 base::AutoLock locker(release_sync_point_lock_);
787 // Must wait on the previous sync point before inserting a new sync point so 794 // Must wait on the previous sync point before inserting a new sync point so
788 // that |mailbox_holder_release_cb_| guarantees the previous sync point 795 // that |mailbox_holder_release_cb_| guarantees the previous sync point
789 // occurred when it waits on |release_sync_point_|. 796 // occurred when it waits on |release_sync_point_|.
790 if (release_sync_point_) 797 if (release_sync_point_)
791 client->WaitSyncPoint(release_sync_point_); 798 client->WaitSyncPoint(release_sync_point_);
792 release_sync_point_ = client->InsertSyncPoint(); 799 release_sync_point_ = client->InsertSyncPoint();
793 } 800 }
(...skipping 14 matching lines...) Expand all
808 for (size_t plane = 0; plane < NumPlanes(format_); ++plane) { 815 for (size_t plane = 0; plane < NumPlanes(format_); ++plane) {
809 for (int row = 0; row < rows(plane); ++row) { 816 for (int row = 0; row < rows(plane); ++row) {
810 base::MD5Update(context, base::StringPiece( 817 base::MD5Update(context, base::StringPiece(
811 reinterpret_cast<char*>(data(plane) + stride(plane) * row), 818 reinterpret_cast<char*>(data(plane) + stride(plane) * row),
812 row_bytes(plane))); 819 row_bytes(plane)));
813 } 820 }
814 } 821 }
815 } 822 }
816 823
817 } // namespace media 824 } // namespace media
OLDNEW
« no previous file with comments | « media/base/video_frame.h ('k') | native_client_sdk/src/libraries/ppapi/library.dsc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698