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

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

Issue 2781283002: Rename functions in video frame to comply with Style Guide (Closed)
Patch Set: Created 3 years, 8 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
« media/base/video_frame.h ('K') | « media/base/video_frame.h ('k') | no next file » | 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 #include <climits> 8 #include <climits>
9 9
10 #include "base/atomic_sequence_num.h" 10 #include "base/atomic_sequence_num.h"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 return "UNKNOWN"; 47 return "UNKNOWN";
48 case VideoFrame::STORAGE_OPAQUE: 48 case VideoFrame::STORAGE_OPAQUE:
49 return "OPAQUE"; 49 return "OPAQUE";
50 case VideoFrame::STORAGE_UNOWNED_MEMORY: 50 case VideoFrame::STORAGE_UNOWNED_MEMORY:
51 return "UNOWNED_MEMORY"; 51 return "UNOWNED_MEMORY";
52 case VideoFrame::STORAGE_OWNED_MEMORY: 52 case VideoFrame::STORAGE_OWNED_MEMORY:
53 return "OWNED_MEMORY"; 53 return "OWNED_MEMORY";
54 case VideoFrame::STORAGE_SHMEM: 54 case VideoFrame::STORAGE_SHMEM:
55 return "SHMEM"; 55 return "SHMEM";
56 #if defined(OS_LINUX) 56 #if defined(OS_LINUX)
57 case VideoFrame::STORAGE_DMABUFS: 57 case VideoFrame::STORAGE_NATIVE:
58 return "DMABUFS"; 58 return "DMABUFS";
59 #endif 59 #endif
60 case VideoFrame::STORAGE_MOJO_SHARED_BUFFER: 60 case VideoFrame::STORAGE_MOJO_SHARED_BUFFER:
61 return "MOJO_SHARED_BUFFER"; 61 return "MOJO_SHARED_BUFFER";
62 } 62 }
63 63
64 NOTREACHED() << "Invalid StorageType provided: " << storage_type; 64 NOTREACHED() << "Invalid StorageType provided: " << storage_type;
65 return "INVALID"; 65 return "INVALID";
66 } 66 }
67 67
68 // Returns true if |frame| is accesible mapped in the VideoFrame memory space. 68 // Returns true if |frame| is accesible mapped in the VideoFrame memory space.
69 // static 69 // static
70 static bool IsStorageTypeMappable(VideoFrame::StorageType storage_type) { 70 static bool IsStorageTypeMappable(VideoFrame::StorageType storage_type) {
71 return 71 return
72 #if defined(OS_LINUX) 72 #if defined(OS_LINUX)
73 // This is not strictly needed but makes explicit that, at VideoFrame 73 // This is not strictly needed but makes explicit that, at VideoFrame
74 // level, DmaBufs are not mappable from userspace. 74 // level, DmaBufs are not mappable from userspace.
75 storage_type != VideoFrame::STORAGE_DMABUFS && 75 storage_type != VideoFrame::STORAGE_NATIVE &&
76 #endif 76 #endif
77 (storage_type == VideoFrame::STORAGE_UNOWNED_MEMORY || 77 (storage_type == VideoFrame::STORAGE_UNOWNED_MEMORY ||
78 storage_type == VideoFrame::STORAGE_OWNED_MEMORY || 78 storage_type == VideoFrame::STORAGE_OWNED_MEMORY ||
79 storage_type == VideoFrame::STORAGE_SHMEM || 79 storage_type == VideoFrame::STORAGE_SHMEM ||
80 storage_type == VideoFrame::STORAGE_MOJO_SHARED_BUFFER); 80 storage_type == VideoFrame::STORAGE_MOJO_SHARED_BUFFER);
81 } 81 }
82 82
83 // Checks if |source_format| can be wrapped into a |target_format| frame. 83 // Checks if |source_format| can be wrapped into a |target_format| frame.
84 static bool AreValidPixelFormatsForWrap(VideoPixelFormat source_format, 84 static bool AreValidPixelFormatsForWrap(VideoPixelFormat source_format,
85 VideoPixelFormat target_format) { 85 VideoPixelFormat target_format) {
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
326 326
327 #if defined(OS_LINUX) 327 #if defined(OS_LINUX)
328 // static 328 // static
329 scoped_refptr<VideoFrame> VideoFrame::WrapExternalDmabufs( 329 scoped_refptr<VideoFrame> VideoFrame::WrapExternalDmabufs(
330 VideoPixelFormat format, 330 VideoPixelFormat format,
331 const gfx::Size& coded_size, 331 const gfx::Size& coded_size,
332 const gfx::Rect& visible_rect, 332 const gfx::Rect& visible_rect,
333 const gfx::Size& natural_size, 333 const gfx::Size& natural_size,
334 const std::vector<int>& dmabuf_fds, 334 const std::vector<int>& dmabuf_fds,
335 base::TimeDelta timestamp) { 335 base::TimeDelta timestamp) {
336 const StorageType storage = STORAGE_DMABUFS; 336 const StorageType storage = STORAGE_NATIVE;
337 if (!IsValidConfig(format, storage, coded_size, visible_rect, natural_size)) { 337 if (!IsValidConfig(format, storage, coded_size, visible_rect, natural_size)) {
338 LOG(DFATAL) << __func__ << " Invalid config." 338 LOG(DFATAL) << __func__ << " Invalid config."
339 << ConfigToString(format, storage, coded_size, visible_rect, 339 << ConfigToString(format, storage, coded_size, visible_rect,
340 natural_size); 340 natural_size);
341 return nullptr; 341 return nullptr;
342 } 342 }
343 343
344 gpu::MailboxHolder mailbox_holders[kMaxPlanes]; 344 gpu::MailboxHolder mailbox_holders[kMaxPlanes];
345 scoped_refptr<VideoFrame> frame = 345 scoped_refptr<VideoFrame> frame =
346 new VideoFrame(format, storage, coded_size, visible_rect, natural_size, 346 new VideoFrame(format, storage, coded_size, visible_rect, natural_size,
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
431 // Copy all metadata to the wrapped frame. 431 // Copy all metadata to the wrapped frame.
432 wrapping_frame->metadata()->MergeMetadataFrom(frame->metadata()); 432 wrapping_frame->metadata()->MergeMetadataFrom(frame->metadata());
433 433
434 for (size_t i = 0; i < NumPlanes(format); ++i) { 434 for (size_t i = 0; i < NumPlanes(format); ++i) {
435 wrapping_frame->strides_[i] = frame->stride(i); 435 wrapping_frame->strides_[i] = frame->stride(i);
436 wrapping_frame->data_[i] = frame->data(i); 436 wrapping_frame->data_[i] = frame->data(i);
437 } 437 }
438 438
439 #if defined(OS_LINUX) 439 #if defined(OS_LINUX)
440 // If there are any |dmabuf_fds_| plugged in, we should duplicate them. 440 // If there are any |dmabuf_fds_| plugged in, we should duplicate them.
441 if (frame->storage_type() == STORAGE_DMABUFS) { 441 if (frame->storage_type() == STORAGE_NATIVE) {
442 std::vector<int> original_fds; 442 std::vector<int> original_fds;
443 for (size_t i = 0; i < kMaxPlanes; ++i) 443 for (size_t i = 0; i < kMaxPlanes; ++i)
444 original_fds.push_back(frame->dmabuf_fd(i)); 444 original_fds.push_back(frame->DmabufFd(i));
445 if (!wrapping_frame->DuplicateFileDescriptors(original_fds)) { 445 if (!wrapping_frame->DuplicateFileDescriptors(original_fds)) {
446 LOG(DFATAL) << __func__ << " Couldn't duplicate fds."; 446 LOG(DFATAL) << __func__ << " Couldn't duplicate fds.";
447 return nullptr; 447 return nullptr;
448 } 448 }
449 } 449 }
450 #endif 450 #endif
451 451
452 if (frame->storage_type() == STORAGE_SHMEM) 452 if (frame->storage_type() == STORAGE_SHMEM)
453 wrapping_frame->AddSharedMemoryHandle(frame->shared_memory_handle_); 453 wrapping_frame->AddSharedMemoryHandle(frame->shared_memory_handle_);
454 454
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
716 return shared_memory_handle_; 716 return shared_memory_handle_;
717 } 717 }
718 718
719 size_t VideoFrame::shared_memory_offset() const { 719 size_t VideoFrame::shared_memory_offset() const {
720 DCHECK_EQ(storage_type_, STORAGE_SHMEM); 720 DCHECK_EQ(storage_type_, STORAGE_SHMEM);
721 DCHECK(shared_memory_handle_ != base::SharedMemory::NULLHandle()); 721 DCHECK(shared_memory_handle_ != base::SharedMemory::NULLHandle());
722 return shared_memory_offset_; 722 return shared_memory_offset_;
723 } 723 }
724 724
725 #if defined(OS_LINUX) 725 #if defined(OS_LINUX)
726 int VideoFrame::dmabuf_fd(size_t plane) const { 726 int VideoFrame::DmabufFd(size_t plane) const {
727 DCHECK_EQ(storage_type_, STORAGE_DMABUFS); 727 DCHECK_EQ(storage_type_, STORAGE_NATIVE);
728 DCHECK(IsValidPlane(plane, format_)); 728 DCHECK(IsValidPlane(plane, format_));
729 return dmabuf_fds_[plane].get(); 729 return dmabuf_fds_[plane].get();
730 } 730 }
731 731
732 bool VideoFrame::DuplicateFileDescriptors(const std::vector<int>& in_fds) { 732 bool VideoFrame::DuplicateFileDescriptors(const std::vector<int>& in_fds) {
733 // TODO(mcasas): Support offsets for e.g. multiplanar inside a single |in_fd|. 733 // TODO(mcasas): Support offsets for e.g. multiplanar inside a single |in_fd|.
734 734
735 storage_type_ = STORAGE_DMABUFS; 735 storage_type_ = STORAGE_NATIVE;
736 // TODO(posciak): This is not exactly correct, it's possible for one 736 // TODO(posciak): This is not exactly correct, it's possible for one
737 // buffer to contain more than one plane. 737 // buffer to contain more than one plane.
738 if (in_fds.size() != NumPlanes(format_)) { 738 if (in_fds.size() != NumPlanes(format_)) {
739 LOG(FATAL) << "Not enough dmabuf fds provided, got: " << in_fds.size() 739 LOG(FATAL) << "Not enough dmabuf fds provided, got: " << in_fds.size()
740 << ", expected: " << NumPlanes(format_); 740 << ", expected: " << NumPlanes(format_);
741 return false; 741 return false;
742 } 742 }
743 743
744 // Make sure that all fds are closed if any dup() fails, 744 // Make sure that all fds are closed if any dup() fails,
745 base::ScopedFD temp_dmabuf_fds[kMaxPlanes]; 745 base::ScopedFD temp_dmabuf_fds[kMaxPlanes];
(...skipping 10 matching lines...) Expand all
756 return true; 756 return true;
757 } 757 }
758 #endif 758 #endif
759 759
760 void VideoFrame::AddSharedMemoryHandle(base::SharedMemoryHandle handle) { 760 void VideoFrame::AddSharedMemoryHandle(base::SharedMemoryHandle handle) {
761 storage_type_ = STORAGE_SHMEM; 761 storage_type_ = STORAGE_SHMEM;
762 shared_memory_handle_ = handle; 762 shared_memory_handle_ = handle;
763 } 763 }
764 764
765 #if defined(OS_MACOSX) 765 #if defined(OS_MACOSX)
766 CVPixelBufferRef VideoFrame::cv_pixel_buffer() const { 766 CVPixelBufferRef VideoFrame::CvPixelBuffer() const {
767 return cv_pixel_buffer_.get(); 767 return cv_pixel_buffer_.get();
768 } 768 }
769 #endif 769 #endif
770 770
771 void VideoFrame::SetReleaseMailboxCB( 771 void VideoFrame::SetReleaseMailboxCB(
772 const ReleaseMailboxCB& release_mailbox_cb) { 772 const ReleaseMailboxCB& release_mailbox_cb) {
773 DCHECK(!release_mailbox_cb.is_null()); 773 DCHECK(!release_mailbox_cb.is_null());
774 DCHECK(mailbox_holders_release_cb_.is_null()); 774 DCHECK(mailbox_holders_release_cb_.is_null());
775 mailbox_holders_release_cb_ = release_mailbox_cb; 775 mailbox_holders_release_cb_ = release_mailbox_cb;
776 } 776 }
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after
1206 if (zero_initialize_memory) 1206 if (zero_initialize_memory)
1207 memset(data, 0, data_size); 1207 memset(data, 0, data_size);
1208 1208
1209 for (size_t plane = 0; plane < NumPlanes(format_); ++plane) 1209 for (size_t plane = 0; plane < NumPlanes(format_); ++plane)
1210 data_[plane] = data + offset[plane]; 1210 data_[plane] = data + offset[plane];
1211 1211
1212 AddDestructionObserver(base::Bind(&base::AlignedFree, data)); 1212 AddDestructionObserver(base::Bind(&base::AlignedFree, data));
1213 } 1213 }
1214 1214
1215 } // namespace media 1215 } // namespace media
OLDNEW
« media/base/video_frame.h ('K') | « media/base/video_frame.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698