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

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

Issue 1536783003: Improve logging output for DecoderBuffer and VideoFrame (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 11 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
« no previous file with comments | « media/base/video_frame.h ('k') | media/cdm/cdm_adapter.cc » ('j') | 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/bind.h" 10 #include "base/bind.h"
(...skipping 29 matching lines...) Expand all
40 const VideoFrame::StorageType storage_type, 40 const VideoFrame::StorageType storage_type,
41 const gfx::Size& coded_size, 41 const gfx::Size& coded_size,
42 const gfx::Rect& visible_rect, 42 const gfx::Rect& visible_rect,
43 const gfx::Size& natural_size) { 43 const gfx::Size& natural_size) {
44 return base::StringPrintf( 44 return base::StringPrintf(
45 "format:%s coded_size:%s visible_rect:%s natural_size:%s", 45 "format:%s coded_size:%s visible_rect:%s natural_size:%s",
46 VideoPixelFormatToString(format).c_str(), coded_size.ToString().c_str(), 46 VideoPixelFormatToString(format).c_str(), coded_size.ToString().c_str(),
47 visible_rect.ToString().c_str(), natural_size.ToString().c_str()); 47 visible_rect.ToString().c_str(), natural_size.ToString().c_str());
48 } 48 }
49 49
50 static std::string StorageTypeToString(
51 const VideoFrame::StorageType storage_type) {
52 switch (storage_type) {
53 case VideoFrame::STORAGE_UNKNOWN:
54 return "UNKNOWN";
55 case VideoFrame::STORAGE_OPAQUE:
56 return "OPAQUE";
57 case VideoFrame::STORAGE_UNOWNED_MEMORY:
58 return "UNOWNED_MEMORY";
59 case VideoFrame::STORAGE_OWNED_MEMORY:
60 return "OWNED_MEMORY";
61 case VideoFrame::STORAGE_SHMEM:
62 return "SHMEM";
63 #if defined(OS_LINUX)
64 case VideoFrame::STORAGE_DMABUFS:
65 return "DMABUFS";
66 #endif
67 #if defined(VIDEO_HOLE)
68 case VideoFrame::STORAGE_HOLE:
69 return "HOLE";
70 #endif
71 case VideoFrame::STORAGE_GPU_MEMORY_BUFFERS:
72 return "GPU_MEMORY_BUFFERS";
73 }
74
75 NOTREACHED() << "Invalid StorageType provided: " << storage_type;
76 return "INVALID";
77 }
78
50 // Returns true if |plane| is a valid plane index for the given |format|. 79 // Returns true if |plane| is a valid plane index for the given |format|.
51 static bool IsValidPlane(size_t plane, VideoPixelFormat format) { 80 static bool IsValidPlane(size_t plane, VideoPixelFormat format) {
52 DCHECK_LE(VideoFrame::NumPlanes(format), 81 DCHECK_LE(VideoFrame::NumPlanes(format),
53 static_cast<size_t>(VideoFrame::kMaxPlanes)); 82 static_cast<size_t>(VideoFrame::kMaxPlanes));
54 return (plane < VideoFrame::NumPlanes(format)); 83 return (plane < VideoFrame::NumPlanes(format));
55 } 84 }
56 85
57 // Returns true if |frame| is accesible mapped in the VideoFrame memory space. 86 // Returns true if |frame| is accesible mapped in the VideoFrame memory space.
58 // static 87 // static
59 static bool IsStorageTypeMappable(VideoFrame::StorageType storage_type) { 88 static bool IsStorageTypeMappable(VideoFrame::StorageType storage_type) {
(...skipping 759 matching lines...) Expand 10 before | Expand all | Expand 10 after
819 DCHECK(HasTextures()); 848 DCHECK(HasTextures());
820 base::AutoLock locker(release_sync_token_lock_); 849 base::AutoLock locker(release_sync_token_lock_);
821 // Must wait on the previous sync point before inserting a new sync point so 850 // Must wait on the previous sync point before inserting a new sync point so
822 // that |mailbox_holders_release_cb_| guarantees the previous sync point 851 // that |mailbox_holders_release_cb_| guarantees the previous sync point
823 // occurred when it waits on |release_sync_token_|. 852 // occurred when it waits on |release_sync_token_|.
824 if (release_sync_token_.HasData()) 853 if (release_sync_token_.HasData())
825 client->WaitSyncToken(release_sync_token_); 854 client->WaitSyncToken(release_sync_token_);
826 client->GenerateSyncToken(&release_sync_token_); 855 client->GenerateSyncToken(&release_sync_token_);
827 } 856 }
828 857
858 std::string VideoFrame::AsHumanReadableString() {
859 if (metadata()->IsTrue(media::VideoFrameMetadata::END_OF_STREAM))
860 return "end of stream";
861
862 std::ostringstream s;
863 s << "format: " << VideoPixelFormatToString(format_)
864 << " storage_type: " << StorageTypeToString(storage_type_)
865 << " coded_size: " << coded_size_.ToString()
866 << " visible_rect: " << visible_rect_.ToString()
867 << " natural_size: " << natural_size_.ToString()
868 << " timestamp: " << timestamp_.InMicroseconds();
869 return s.str();
870 }
871
829 // static 872 // static
830 scoped_refptr<VideoFrame> VideoFrame::WrapExternalStorage( 873 scoped_refptr<VideoFrame> VideoFrame::WrapExternalStorage(
831 VideoPixelFormat format, 874 VideoPixelFormat format,
832 StorageType storage_type, 875 StorageType storage_type,
833 const gfx::Size& coded_size, 876 const gfx::Size& coded_size,
834 const gfx::Rect& visible_rect, 877 const gfx::Rect& visible_rect,
835 const gfx::Size& natural_size, 878 const gfx::Size& natural_size,
836 uint8_t* data, 879 uint8_t* data,
837 size_t data_size, 880 size_t data_size,
838 base::TimeDelta timestamp, 881 base::TimeDelta timestamp,
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
1019 if (zero_initialize_memory) 1062 if (zero_initialize_memory)
1020 memset(data, 0, data_size); 1063 memset(data, 0, data_size);
1021 1064
1022 for (size_t plane = 0; plane < NumPlanes(format_); ++plane) 1065 for (size_t plane = 0; plane < NumPlanes(format_); ++plane)
1023 data_[plane] = data + offset[plane]; 1066 data_[plane] = data + offset[plane];
1024 1067
1025 AddDestructionObserver(base::Bind(&base::AlignedFree, data)); 1068 AddDestructionObserver(base::Bind(&base::AlignedFree, data));
1026 } 1069 }
1027 1070
1028 } // namespace media 1071 } // namespace media
OLDNEW
« no previous file with comments | « media/base/video_frame.h ('k') | media/cdm/cdm_adapter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698