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

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

Issue 877353002: media: VideoFrame: add offset for shared memory buffers (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add gpu-process ipc modification Created 5 years, 10 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
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 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 277
278 // static 278 // static
279 scoped_refptr<VideoFrame> VideoFrame::WrapExternalPackedMemory( 279 scoped_refptr<VideoFrame> VideoFrame::WrapExternalPackedMemory(
280 Format format, 280 Format format,
281 const gfx::Size& coded_size, 281 const gfx::Size& coded_size,
282 const gfx::Rect& visible_rect, 282 const gfx::Rect& visible_rect,
283 const gfx::Size& natural_size, 283 const gfx::Size& natural_size,
284 uint8* data, 284 uint8* data,
285 size_t data_size, 285 size_t data_size,
286 base::SharedMemoryHandle handle, 286 base::SharedMemoryHandle handle,
287 size_t data_offset,
287 base::TimeDelta timestamp, 288 base::TimeDelta timestamp,
288 const base::Closure& no_longer_needed_cb) { 289 const base::Closure& no_longer_needed_cb) {
289 const gfx::Size new_coded_size = AdjustCodedSize(format, coded_size); 290 const gfx::Size new_coded_size = AdjustCodedSize(format, coded_size);
290 291
291 if (!IsValidConfig(format, new_coded_size, visible_rect, natural_size)) 292 if (!IsValidConfig(format, new_coded_size, visible_rect, natural_size))
292 return NULL; 293 return NULL;
293 if (data_size < AllocationSize(format, new_coded_size)) 294 if (data_size < AllocationSize(format, new_coded_size))
294 return NULL; 295 return NULL;
295 296
296 switch (format) { 297 switch (format) {
297 case VideoFrame::I420: { 298 case VideoFrame::I420: {
298 scoped_refptr<VideoFrame> frame( 299 scoped_refptr<VideoFrame> frame(
299 new VideoFrame(format, 300 new VideoFrame(format,
300 new_coded_size, 301 new_coded_size,
301 visible_rect, 302 visible_rect,
302 natural_size, 303 natural_size,
303 scoped_ptr<gpu::MailboxHolder>(), 304 scoped_ptr<gpu::MailboxHolder>(),
304 timestamp, 305 timestamp,
305 false)); 306 false));
306 frame->shared_memory_handle_ = handle; 307 frame->shared_memory_handle_ = handle;
308 frame->shared_memory_offset_ = data_offset;
307 frame->strides_[kYPlane] = new_coded_size.width(); 309 frame->strides_[kYPlane] = new_coded_size.width();
308 frame->strides_[kUPlane] = new_coded_size.width() / 2; 310 frame->strides_[kUPlane] = new_coded_size.width() / 2;
309 frame->strides_[kVPlane] = new_coded_size.width() / 2; 311 frame->strides_[kVPlane] = new_coded_size.width() / 2;
310 frame->data_[kYPlane] = data; 312 frame->data_[kYPlane] = data;
311 frame->data_[kUPlane] = data + new_coded_size.GetArea(); 313 frame->data_[kUPlane] = data + new_coded_size.GetArea();
312 frame->data_[kVPlane] = data + (new_coded_size.GetArea() * 5 / 4); 314 frame->data_[kVPlane] = data + (new_coded_size.GetArea() * 5 / 4);
313 frame->no_longer_needed_cb_ = no_longer_needed_cb; 315 frame->no_longer_needed_cb_ = no_longer_needed_cb;
314 return frame; 316 return frame;
315 } 317 }
316 default: 318 default:
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after
676 const gfx::Size& natural_size, 678 const gfx::Size& natural_size,
677 scoped_ptr<gpu::MailboxHolder> mailbox_holder, 679 scoped_ptr<gpu::MailboxHolder> mailbox_holder,
678 base::TimeDelta timestamp, 680 base::TimeDelta timestamp,
679 bool end_of_stream) 681 bool end_of_stream)
680 : format_(format), 682 : format_(format),
681 coded_size_(coded_size), 683 coded_size_(coded_size),
682 visible_rect_(visible_rect), 684 visible_rect_(visible_rect),
683 natural_size_(natural_size), 685 natural_size_(natural_size),
684 mailbox_holder_(mailbox_holder.Pass()), 686 mailbox_holder_(mailbox_holder.Pass()),
685 shared_memory_handle_(base::SharedMemory::NULLHandle()), 687 shared_memory_handle_(base::SharedMemory::NULLHandle()),
688 shared_memory_offset_(0),
686 timestamp_(timestamp), 689 timestamp_(timestamp),
687 release_sync_point_(0), 690 release_sync_point_(0),
688 end_of_stream_(end_of_stream) { 691 end_of_stream_(end_of_stream) {
689 DCHECK(IsValidConfig(format_, coded_size_, visible_rect_, natural_size_)); 692 DCHECK(IsValidConfig(format_, coded_size_, visible_rect_, natural_size_));
690 693
691 memset(&strides_, 0, sizeof(strides_)); 694 memset(&strides_, 0, sizeof(strides_));
692 memset(&data_, 0, sizeof(data_)); 695 memset(&data_, 0, sizeof(data_));
693 } 696 }
694 697
695 VideoFrame::~VideoFrame() { 698 VideoFrame::~VideoFrame() {
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
781 784
782 const gpu::MailboxHolder* VideoFrame::mailbox_holder() const { 785 const gpu::MailboxHolder* VideoFrame::mailbox_holder() const {
783 DCHECK_EQ(format_, NATIVE_TEXTURE); 786 DCHECK_EQ(format_, NATIVE_TEXTURE);
784 return mailbox_holder_.get(); 787 return mailbox_holder_.get();
785 } 788 }
786 789
787 base::SharedMemoryHandle VideoFrame::shared_memory_handle() const { 790 base::SharedMemoryHandle VideoFrame::shared_memory_handle() const {
788 return shared_memory_handle_; 791 return shared_memory_handle_;
789 } 792 }
790 793
794 size_t VideoFrame::shared_memory_offset() const {
dcheng 2015/02/02 20:56:23 Simple accessors like this should be inlined.
llandwerlin-old 2015/02/03 16:35:06 Done.
795 return shared_memory_offset_;
796 }
797
791 void VideoFrame::UpdateReleaseSyncPoint(SyncPointClient* client) { 798 void VideoFrame::UpdateReleaseSyncPoint(SyncPointClient* client) {
792 DCHECK_EQ(format_, NATIVE_TEXTURE); 799 DCHECK_EQ(format_, NATIVE_TEXTURE);
793 base::AutoLock locker(release_sync_point_lock_); 800 base::AutoLock locker(release_sync_point_lock_);
794 // Must wait on the previous sync point before inserting a new sync point so 801 // Must wait on the previous sync point before inserting a new sync point so
795 // that |mailbox_holder_release_cb_| guarantees the previous sync point 802 // that |mailbox_holder_release_cb_| guarantees the previous sync point
796 // occurred when it waits on |release_sync_point_|. 803 // occurred when it waits on |release_sync_point_|.
797 if (release_sync_point_) 804 if (release_sync_point_)
798 client->WaitSyncPoint(release_sync_point_); 805 client->WaitSyncPoint(release_sync_point_);
799 release_sync_point_ = client->InsertSyncPoint(); 806 release_sync_point_ = client->InsertSyncPoint();
800 } 807 }
(...skipping 14 matching lines...) Expand all
815 for (size_t plane = 0; plane < NumPlanes(format_); ++plane) { 822 for (size_t plane = 0; plane < NumPlanes(format_); ++plane) {
816 for (int row = 0; row < rows(plane); ++row) { 823 for (int row = 0; row < rows(plane); ++row) {
817 base::MD5Update(context, base::StringPiece( 824 base::MD5Update(context, base::StringPiece(
818 reinterpret_cast<char*>(data(plane) + stride(plane) * row), 825 reinterpret_cast<char*>(data(plane) + stride(plane) * row),
819 row_bytes(plane))); 826 row_bytes(plane)));
820 } 827 }
821 } 828 }
822 } 829 }
823 830
824 } // namespace media 831 } // namespace media
OLDNEW
« content/common/gpu/media/gpu_video_encode_accelerator.cc ('K') | « media/base/video_frame.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698