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

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: Created 5 years 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 #include <climits> 8 #include <climits>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 27 matching lines...) Expand all
38 const VideoFrame::StorageType storage_type, 38 const VideoFrame::StorageType storage_type,
39 const gfx::Size& coded_size, 39 const gfx::Size& coded_size,
40 const gfx::Rect& visible_rect, 40 const gfx::Rect& visible_rect,
41 const gfx::Size& natural_size) { 41 const gfx::Size& natural_size) {
42 return base::StringPrintf( 42 return base::StringPrintf(
43 "format:%s coded_size:%s visible_rect:%s natural_size:%s", 43 "format:%s coded_size:%s visible_rect:%s natural_size:%s",
44 VideoPixelFormatToString(format).c_str(), coded_size.ToString().c_str(), 44 VideoPixelFormatToString(format).c_str(), coded_size.ToString().c_str(),
45 visible_rect.ToString().c_str(), natural_size.ToString().c_str()); 45 visible_rect.ToString().c_str(), natural_size.ToString().c_str());
46 } 46 }
47 47
48 static std::string StorageTypeToString(
49 const VideoFrame::StorageType storage_type) {
50 switch (storage_type) {
51 case VideoFrame::STORAGE_UNKNOWN:
52 return "UNKNOWN";
53 case VideoFrame::STORAGE_OPAQUE:
54 return "OPAQUE";
55 case VideoFrame::STORAGE_UNOWNED_MEMORY:
56 return "UNOWNED_MEMORY";
57 case VideoFrame::STORAGE_OWNED_MEMORY:
58 return "OWNED_MEMORY";
59 case VideoFrame::STORAGE_SHMEM:
60 return "SHMEM";
61 #if defined(OS_LINUX)
62 case VideoFrame::STORAGE_DMABUFS:
63 return "DMABUFS";
64 #endif
65 #if defined(VIDEO_HOLE)
66 case VideoFrame::STORAGE_HOLE:
67 return "HOLE";
68 #endif
69 case VideoFrame::STORAGE_GPU_MEMORY_BUFFERS:
70 return "GPU_MEMORY_BUFFERS";
71 }
72
73 NOTREACHED() << "Invalid StorageType provided: " << storage_type;
74 return "??";
75 }
76
48 // Returns true if |plane| is a valid plane index for the given |format|. 77 // Returns true if |plane| is a valid plane index for the given |format|.
49 static bool IsValidPlane(size_t plane, VideoPixelFormat format) { 78 static bool IsValidPlane(size_t plane, VideoPixelFormat format) {
50 DCHECK_LE(VideoFrame::NumPlanes(format), 79 DCHECK_LE(VideoFrame::NumPlanes(format),
51 static_cast<size_t>(VideoFrame::kMaxPlanes)); 80 static_cast<size_t>(VideoFrame::kMaxPlanes));
52 return (plane < VideoFrame::NumPlanes(format)); 81 return (plane < VideoFrame::NumPlanes(format));
53 } 82 }
54 83
55 // Returns true if |frame| is accesible mapped in the VideoFrame memory space. 84 // Returns true if |frame| is accesible mapped in the VideoFrame memory space.
56 // static 85 // static
57 static bool IsStorageTypeMappable(VideoFrame::StorageType storage_type) { 86 static bool IsStorageTypeMappable(VideoFrame::StorageType storage_type) {
(...skipping 753 matching lines...) Expand 10 before | Expand all | Expand 10 after
811 DCHECK(HasTextures()); 840 DCHECK(HasTextures());
812 base::AutoLock locker(release_sync_token_lock_); 841 base::AutoLock locker(release_sync_token_lock_);
813 // Must wait on the previous sync point before inserting a new sync point so 842 // Must wait on the previous sync point before inserting a new sync point so
814 // that |mailbox_holders_release_cb_| guarantees the previous sync point 843 // that |mailbox_holders_release_cb_| guarantees the previous sync point
815 // occurred when it waits on |release_sync_token_|. 844 // occurred when it waits on |release_sync_token_|.
816 if (release_sync_token_.HasData()) 845 if (release_sync_token_.HasData())
817 client->WaitSyncToken(release_sync_token_); 846 client->WaitSyncToken(release_sync_token_);
818 client->GenerateSyncToken(&release_sync_token_); 847 client->GenerateSyncToken(&release_sync_token_);
819 } 848 }
820 849
850 std::string VideoFrame::AsHumanReadableString() {
851 if (metadata()->IsTrue(media::VideoFrameMetadata::END_OF_STREAM))
852 return "end of stream";
853
854 std::ostringstream s;
855 s << "format: " << VideoPixelFormatToString(format_)
856 << " storage_type: " << StorageTypeToString(storage_type_)
857 << " coded_size: " << coded_size_.ToString()
858 << " visible_rect: " << visible_rect_.ToString()
859 << " natural_size: " << natural_size_.ToString() << " strides: ";
860 for (size_t i = 0; i < NumPlanes(format_); ++i)
861 s << strides_[i] << " ";
862 s << "rows: ";
863 for (size_t i = 0; i < NumPlanes(format_); ++i)
864 s << rows(i) << " ";
865 s << "row_bytes: ";
866 for (size_t i = 0; i < NumPlanes(format_); ++i)
867 s << row_bytes(i) << " ";
xhwang 2015/12/18 23:07:43 rows and strides are no as important as other fiel
jrummell 2015/12/22 01:30:43 Removed.
868 s << "timestamp: " << timestamp_.InMicroseconds();
869 return s.str();
870 }
871
821 // static 872 // static
822 scoped_refptr<VideoFrame> VideoFrame::WrapExternalStorage( 873 scoped_refptr<VideoFrame> VideoFrame::WrapExternalStorage(
823 VideoPixelFormat format, 874 VideoPixelFormat format,
824 StorageType storage_type, 875 StorageType storage_type,
825 const gfx::Size& coded_size, 876 const gfx::Size& coded_size,
826 const gfx::Rect& visible_rect, 877 const gfx::Rect& visible_rect,
827 const gfx::Size& natural_size, 878 const gfx::Size& natural_size,
828 uint8* data, 879 uint8* data,
829 size_t data_size, 880 size_t data_size,
830 base::TimeDelta timestamp, 881 base::TimeDelta timestamp,
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
1011 if (zero_initialize_memory) 1062 if (zero_initialize_memory)
1012 memset(data, 0, data_size); 1063 memset(data, 0, data_size);
1013 1064
1014 for (size_t plane = 0; plane < NumPlanes(format_); ++plane) 1065 for (size_t plane = 0; plane < NumPlanes(format_); ++plane)
1015 data_[plane] = data + offset[plane]; 1066 data_[plane] = data + offset[plane];
1016 1067
1017 AddDestructionObserver(base::Bind(&base::AlignedFree, data)); 1068 AddDestructionObserver(base::Bind(&base::AlignedFree, data));
1018 } 1069 }
1019 1070
1020 } // namespace media 1071 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698