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

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

Issue 312803002: Android media: VideoFrame should not store so many sync points. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address reviewers' comments Created 6 years, 5 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 632 matching lines...) Expand 10 before | Expand all | Expand 10 after
643 scoped_ptr<gpu::MailboxHolder> mailbox_holder, 643 scoped_ptr<gpu::MailboxHolder> mailbox_holder,
644 base::TimeDelta timestamp, 644 base::TimeDelta timestamp,
645 bool end_of_stream) 645 bool end_of_stream)
646 : format_(format), 646 : format_(format),
647 coded_size_(coded_size), 647 coded_size_(coded_size),
648 visible_rect_(visible_rect), 648 visible_rect_(visible_rect),
649 natural_size_(natural_size), 649 natural_size_(natural_size),
650 mailbox_holder_(mailbox_holder.Pass()), 650 mailbox_holder_(mailbox_holder.Pass()),
651 shared_memory_handle_(base::SharedMemory::NULLHandle()), 651 shared_memory_handle_(base::SharedMemory::NULLHandle()),
652 timestamp_(timestamp), 652 timestamp_(timestamp),
653 release_sync_point_(0),
653 end_of_stream_(end_of_stream) { 654 end_of_stream_(end_of_stream) {
654 DCHECK(IsValidConfig(format_, coded_size_, visible_rect_, natural_size_)); 655 DCHECK(IsValidConfig(format_, coded_size_, visible_rect_, natural_size_));
655 656
656 memset(&strides_, 0, sizeof(strides_)); 657 memset(&strides_, 0, sizeof(strides_));
657 memset(&data_, 0, sizeof(data_)); 658 memset(&data_, 0, sizeof(data_));
658 } 659 }
659 660
660 VideoFrame::~VideoFrame() { 661 VideoFrame::~VideoFrame() {
661 if (!mailbox_holder_release_cb_.is_null()) { 662 if (!mailbox_holder_release_cb_.is_null()) {
662 std::vector<uint32> release_sync_points; 663 uint32 release_sync_point;
663 { 664 {
665 // To ensure that changes to |release_sync_point_| are visible on this
666 // thread (imply a memory barrier).
dshwang 2014/07/10 21:44:26 sievers@, improve this comment.
664 base::AutoLock locker(release_sync_point_lock_); 667 base::AutoLock locker(release_sync_point_lock_);
665 release_sync_points_.swap(release_sync_points); 668 release_sync_point = release_sync_point_;
666 } 669 }
667 base::ResetAndReturn(&mailbox_holder_release_cb_).Run(release_sync_points); 670 base::ResetAndReturn(&mailbox_holder_release_cb_).Run(release_sync_point);
668 } 671 }
669 if (!no_longer_needed_cb_.is_null()) 672 if (!no_longer_needed_cb_.is_null())
670 base::ResetAndReturn(&no_longer_needed_cb_).Run(); 673 base::ResetAndReturn(&no_longer_needed_cb_).Run();
671 } 674 }
672 675
673 bool VideoFrame::IsValidPlane(size_t plane) const { 676 bool VideoFrame::IsValidPlane(size_t plane) const {
674 return (plane < NumPlanes(format_)); 677 return (plane < NumPlanes(format_));
675 } 678 }
676 679
677 int VideoFrame::stride(size_t plane) const { 680 int VideoFrame::stride(size_t plane) const {
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
809 812
810 const gpu::MailboxHolder* VideoFrame::mailbox_holder() const { 813 const gpu::MailboxHolder* VideoFrame::mailbox_holder() const {
811 DCHECK_EQ(format_, NATIVE_TEXTURE); 814 DCHECK_EQ(format_, NATIVE_TEXTURE);
812 return mailbox_holder_.get(); 815 return mailbox_holder_.get();
813 } 816 }
814 817
815 base::SharedMemoryHandle VideoFrame::shared_memory_handle() const { 818 base::SharedMemoryHandle VideoFrame::shared_memory_handle() const {
816 return shared_memory_handle_; 819 return shared_memory_handle_;
817 } 820 }
818 821
819 void VideoFrame::AppendReleaseSyncPoint(uint32 sync_point) { 822 void VideoFrame::UpdateReleaseSyncPoint(SyncPointClient* client) {
820 DCHECK_EQ(format_, NATIVE_TEXTURE); 823 DCHECK_EQ(format_, NATIVE_TEXTURE);
821 if (!sync_point)
822 return;
823 base::AutoLock locker(release_sync_point_lock_); 824 base::AutoLock locker(release_sync_point_lock_);
824 release_sync_points_.push_back(sync_point); 825 // Must wait the previous sync point before inserting a new sync point so that
danakj 2014/07/10 21:49:26 nit: wait on
826 // |mailbox_holder_release_cb_| guarantees the previous sync point occurred
827 // when it waits |release_sync_point_|.
danakj 2014/07/10 21:49:26 nit: waits on
828 if (release_sync_point_)
829 client->WaitSyncPoint(release_sync_point_);
830 release_sync_point_ = client->InsertSyncPoint();
825 } 831 }
826 832
827 #if defined(OS_POSIX) 833 #if defined(OS_POSIX)
828 int VideoFrame::dmabuf_fd(size_t plane) const { 834 int VideoFrame::dmabuf_fd(size_t plane) const {
829 return dmabuf_fds_[plane].get(); 835 return dmabuf_fds_[plane].get();
830 } 836 }
831 #endif 837 #endif
832 838
833 void VideoFrame::HashFrameForTesting(base::MD5Context* context) { 839 void VideoFrame::HashFrameForTesting(base::MD5Context* context) {
834 for (int plane = 0; plane < kMaxPlanes; ++plane) { 840 for (int plane = 0; plane < kMaxPlanes; ++plane) {
835 if (!IsValidPlane(plane)) 841 if (!IsValidPlane(plane))
836 break; 842 break;
837 for (int row = 0; row < rows(plane); ++row) { 843 for (int row = 0; row < rows(plane); ++row) {
838 base::MD5Update(context, base::StringPiece( 844 base::MD5Update(context, base::StringPiece(
839 reinterpret_cast<char*>(data(plane) + stride(plane) * row), 845 reinterpret_cast<char*>(data(plane) + stride(plane) * row),
840 row_bytes(plane))); 846 row_bytes(plane)));
841 } 847 }
842 } 848 }
843 } 849 }
844 850
845 } // namespace media 851 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698