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

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: less output (+rebase) 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 "??";
xhwang 2016/01/05 17:29:11 Maybe return something like "INVALID" instead of "
jrummell 2016/01/12 20:00:36 Done.
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 755 matching lines...) Expand 10 before | Expand all | Expand 10 after
813 DCHECK(HasTextures()); 842 DCHECK(HasTextures());
814 base::AutoLock locker(release_sync_token_lock_); 843 base::AutoLock locker(release_sync_token_lock_);
815 // Must wait on the previous sync point before inserting a new sync point so 844 // Must wait on the previous sync point before inserting a new sync point so
816 // that |mailbox_holders_release_cb_| guarantees the previous sync point 845 // that |mailbox_holders_release_cb_| guarantees the previous sync point
817 // occurred when it waits on |release_sync_token_|. 846 // occurred when it waits on |release_sync_token_|.
818 if (release_sync_token_.HasData()) 847 if (release_sync_token_.HasData())
819 client->WaitSyncToken(release_sync_token_); 848 client->WaitSyncToken(release_sync_token_);
820 client->GenerateSyncToken(&release_sync_token_); 849 client->GenerateSyncToken(&release_sync_token_);
821 } 850 }
822 851
852 std::string VideoFrame::AsHumanReadableString() {
853 if (metadata()->IsTrue(media::VideoFrameMetadata::END_OF_STREAM))
854 return "end of stream";
855
856 std::ostringstream s;
857 s << "format: " << VideoPixelFormatToString(format_)
858 << " storage_type: " << StorageTypeToString(storage_type_)
859 << " coded_size: " << coded_size_.ToString()
860 << " visible_rect: " << visible_rect_.ToString()
861 << " natural_size: " << natural_size_.ToString()
862 << " timestamp: " << timestamp_.InMicroseconds();
863 return s.str();
864 }
865
823 // static 866 // static
824 scoped_refptr<VideoFrame> VideoFrame::WrapExternalStorage( 867 scoped_refptr<VideoFrame> VideoFrame::WrapExternalStorage(
825 VideoPixelFormat format, 868 VideoPixelFormat format,
826 StorageType storage_type, 869 StorageType storage_type,
827 const gfx::Size& coded_size, 870 const gfx::Size& coded_size,
828 const gfx::Rect& visible_rect, 871 const gfx::Rect& visible_rect,
829 const gfx::Size& natural_size, 872 const gfx::Size& natural_size,
830 uint8_t* data, 873 uint8_t* data,
831 size_t data_size, 874 size_t data_size,
832 base::TimeDelta timestamp, 875 base::TimeDelta timestamp,
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
1013 if (zero_initialize_memory) 1056 if (zero_initialize_memory)
1014 memset(data, 0, data_size); 1057 memset(data, 0, data_size);
1015 1058
1016 for (size_t plane = 0; plane < NumPlanes(format_); ++plane) 1059 for (size_t plane = 0; plane < NumPlanes(format_); ++plane)
1017 data_[plane] = data + offset[plane]; 1060 data_[plane] = data + offset[plane];
1018 1061
1019 AddDestructionObserver(base::Bind(&base::AlignedFree, data)); 1062 AddDestructionObserver(base::Bind(&base::AlignedFree, data));
1020 } 1063 }
1021 1064
1022 } // namespace media 1065 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698