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

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: Make VideoFrame keep only one sync point per client Created 6 years, 6 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 timestamp_(timestamp), 643 timestamp_(timestamp),
644 end_of_stream_(end_of_stream) { 644 end_of_stream_(end_of_stream) {
645 DCHECK(IsValidConfig(format_, coded_size_, visible_rect_, natural_size_)); 645 DCHECK(IsValidConfig(format_, coded_size_, visible_rect_, natural_size_));
646 646
647 memset(&strides_, 0, sizeof(strides_)); 647 memset(&strides_, 0, sizeof(strides_));
648 memset(&data_, 0, sizeof(data_)); 648 memset(&data_, 0, sizeof(data_));
649 } 649 }
650 650
651 VideoFrame::~VideoFrame() { 651 VideoFrame::~VideoFrame() {
652 if (!mailbox_holder_release_cb_.is_null()) { 652 if (!mailbox_holder_release_cb_.is_null()) {
653 std::vector<uint32> release_sync_points; 653 std::map<uintptr_t, uint32> release_sync_points;
654 { 654 {
655 base::AutoLock locker(release_sync_point_lock_); 655 base::AutoLock locker(release_sync_point_lock_);
656 release_sync_points_.swap(release_sync_points); 656 release_sync_point_map_.swap(release_sync_points);
657 } 657 }
658 base::ResetAndReturn(&mailbox_holder_release_cb_).Run(release_sync_points); 658 base::ResetAndReturn(&mailbox_holder_release_cb_).Run(release_sync_points);
659 } 659 }
660 if (!no_longer_needed_cb_.is_null()) 660 if (!no_longer_needed_cb_.is_null())
661 base::ResetAndReturn(&no_longer_needed_cb_).Run(); 661 base::ResetAndReturn(&no_longer_needed_cb_).Run();
662 } 662 }
663 663
664 bool VideoFrame::IsValidPlane(size_t plane) const { 664 bool VideoFrame::IsValidPlane(size_t plane) const {
665 return (plane < NumPlanes(format_)); 665 return (plane < NumPlanes(format_));
666 } 666 }
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
800 800
801 const gpu::MailboxHolder* VideoFrame::mailbox_holder() const { 801 const gpu::MailboxHolder* VideoFrame::mailbox_holder() const {
802 DCHECK_EQ(format_, NATIVE_TEXTURE); 802 DCHECK_EQ(format_, NATIVE_TEXTURE);
803 return mailbox_holder_.get(); 803 return mailbox_holder_.get();
804 } 804 }
805 805
806 base::SharedMemoryHandle VideoFrame::shared_memory_handle() const { 806 base::SharedMemoryHandle VideoFrame::shared_memory_handle() const {
807 return shared_memory_handle_; 807 return shared_memory_handle_;
808 } 808 }
809 809
810 void VideoFrame::AppendReleaseSyncPoint(uint32 sync_point) { 810 void VideoFrame::AppendReleaseSyncPoint(uintptr_t client, uint32 sync_point) {
811 DCHECK_EQ(format_, NATIVE_TEXTURE); 811 DCHECK_EQ(format_, NATIVE_TEXTURE);
812 if (!sync_point) 812 if (!sync_point)
813 return; 813 return;
814 base::AutoLock locker(release_sync_point_lock_); 814 base::AutoLock locker(release_sync_point_lock_);
815 release_sync_points_.push_back(sync_point); 815 release_sync_point_map_[client] = sync_point;
816 } 816 }
817 817
818 #if defined(OS_POSIX) 818 #if defined(OS_POSIX)
819 int VideoFrame::dmabuf_fd(size_t plane) const { 819 int VideoFrame::dmabuf_fd(size_t plane) const {
820 return dmabuf_fds_[plane].get(); 820 return dmabuf_fds_[plane].get();
821 } 821 }
822 #endif 822 #endif
823 823
824 void VideoFrame::HashFrameForTesting(base::MD5Context* context) { 824 void VideoFrame::HashFrameForTesting(base::MD5Context* context) {
825 for (int plane = 0; plane < kMaxPlanes; ++plane) { 825 for (int plane = 0; plane < kMaxPlanes; ++plane) {
826 if (!IsValidPlane(plane)) 826 if (!IsValidPlane(plane))
827 break; 827 break;
828 for (int row = 0; row < rows(plane); ++row) { 828 for (int row = 0; row < rows(plane); ++row) {
829 base::MD5Update(context, base::StringPiece( 829 base::MD5Update(context, base::StringPiece(
830 reinterpret_cast<char*>(data(plane) + stride(plane) * row), 830 reinterpret_cast<char*>(data(plane) + stride(plane) * row),
831 row_bytes(plane))); 831 row_bytes(plane)));
832 } 832 }
833 } 833 }
834 } 834 }
835 835
836 } // namespace media 836 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698