OLD | NEW |
---|---|
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 #include <climits> | 8 #include <climits> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 839 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
850 storage_type_ = STORAGE_SHMEM; | 850 storage_type_ = STORAGE_SHMEM; |
851 shared_memory_handle_ = handle; | 851 shared_memory_handle_ = handle; |
852 } | 852 } |
853 | 853 |
854 #if defined(OS_MACOSX) | 854 #if defined(OS_MACOSX) |
855 CVPixelBufferRef VideoFrame::cv_pixel_buffer() const { | 855 CVPixelBufferRef VideoFrame::cv_pixel_buffer() const { |
856 return cv_pixel_buffer_.get(); | 856 return cv_pixel_buffer_.get(); |
857 } | 857 } |
858 #endif | 858 #endif |
859 | 859 |
860 bool VideoFrame::DropYV12AAlphaChannel() { | |
861 if (format_ != PIXEL_FORMAT_YV12A) { | |
862 LOG(DFATAL) << "Only PIXEL_FORMAT_YV12A format supported: " | |
863 << VideoPixelFormatToString(format_); | |
864 return false; | |
865 } | |
866 if (storage_type_ != STORAGE_OWNED_MEMORY) { | |
867 LOG(DFATAL) << "Only STORAGE_OWNED_MEMORY format supported."; | |
mcasas
2016/02/25 22:06:25
What about ShMeM? I'd say either
consider all cas
emircan
2016/02/26 01:33:08
Adding DCHECKs for supported types.
| |
868 return false; | |
869 } | |
870 format_ = PIXEL_FORMAT_I420; | |
871 data_[kAPlane] = nullptr; | |
872 strides_[kAPlane] = 0; | |
873 return true; | |
874 } | |
875 | |
860 void VideoFrame::AddDestructionObserver(const base::Closure& callback) { | 876 void VideoFrame::AddDestructionObserver(const base::Closure& callback) { |
861 DCHECK(!callback.is_null()); | 877 DCHECK(!callback.is_null()); |
862 done_callbacks_.push_back(callback); | 878 done_callbacks_.push_back(callback); |
863 } | 879 } |
864 | 880 |
865 void VideoFrame::UpdateReleaseSyncToken(SyncTokenClient* client) { | 881 void VideoFrame::UpdateReleaseSyncToken(SyncTokenClient* client) { |
866 DCHECK(HasTextures()); | 882 DCHECK(HasTextures()); |
867 base::AutoLock locker(release_sync_token_lock_); | 883 base::AutoLock locker(release_sync_token_lock_); |
868 // Must wait on the previous sync point before inserting a new sync point so | 884 // Must wait on the previous sync point before inserting a new sync point so |
869 // that |mailbox_holders_release_cb_| guarantees the previous sync point | 885 // that |mailbox_holders_release_cb_| guarantees the previous sync point |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1080 if (zero_initialize_memory) | 1096 if (zero_initialize_memory) |
1081 memset(data, 0, data_size); | 1097 memset(data, 0, data_size); |
1082 | 1098 |
1083 for (size_t plane = 0; plane < NumPlanes(format_); ++plane) | 1099 for (size_t plane = 0; plane < NumPlanes(format_); ++plane) |
1084 data_[plane] = data + offset[plane]; | 1100 data_[plane] = data + offset[plane]; |
1085 | 1101 |
1086 AddDestructionObserver(base::Bind(&base::AlignedFree, data)); | 1102 AddDestructionObserver(base::Bind(&base::AlignedFree, data)); |
1087 } | 1103 } |
1088 | 1104 |
1089 } // namespace media | 1105 } // namespace media |
OLD | NEW |