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

Side by Side Diff: media/base/decoder_buffer.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
« no previous file with comments | « no previous file | media/base/video_frame.h » ('j') | media/base/video_frame.cc » ('J')
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/decoder_buffer.h" 5 #include "media/base/decoder_buffer.h"
6 6
7 #include "base/strings/string_number_conversions.h"
7 8
8 namespace media { 9 namespace media {
9 10
10 // Allocates a block of memory which is padded for use with the SIMD 11 // Allocates a block of memory which is padded for use with the SIMD
11 // optimizations used by FFmpeg. 12 // optimizations used by FFmpeg.
12 static uint8* AllocateFFmpegSafeBlock(int size) { 13 static uint8* AllocateFFmpegSafeBlock(int size) {
13 uint8* const block = reinterpret_cast<uint8*>(base::AlignedAlloc( 14 uint8* const block = reinterpret_cast<uint8*>(base::AlignedAlloc(
14 size + DecoderBuffer::kPaddingSize, DecoderBuffer::kAlignmentSize)); 15 size + DecoderBuffer::kPaddingSize, DecoderBuffer::kAlignmentSize));
15 memset(block + size, 0, DecoderBuffer::kPaddingSize); 16 memset(block + size, 0, DecoderBuffer::kPaddingSize);
16 return block; 17 return block;
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 return make_scoped_refptr(new DecoderBuffer(NULL, 0, NULL, 0)); 86 return make_scoped_refptr(new DecoderBuffer(NULL, 0, NULL, 0));
86 } 87 }
87 88
88 std::string DecoderBuffer::AsHumanReadableString() { 89 std::string DecoderBuffer::AsHumanReadableString() {
89 if (end_of_stream()) { 90 if (end_of_stream()) {
90 return "end of stream"; 91 return "end of stream";
91 } 92 }
92 93
93 std::ostringstream s; 94 std::ostringstream s;
94 s << "timestamp: " << timestamp_.InMicroseconds() 95 s << "timestamp: " << timestamp_.InMicroseconds()
95 << " duration: " << duration_.InMicroseconds() 96 << " duration: " << duration_.InMicroseconds() << " size: " << size_
96 << " size: " << size_ 97 << " data: ";
97 << " side_data_size: " << side_data_size_ 98 if (size_ == 0 || !data_)
99 s << "<null>";
100 else if (size_ < 32)
101 s << base::HexEncode(data_.get(), size_);
102 else {
103 s << base::HexEncode(data_.get(), 16) << "..."
104 << base::HexEncode(data_.get() + size_ - 16, 16);
xhwang 2015/12/18 23:07:43 I am not sure whether we want to log this by defau
jrummell 2015/12/22 01:30:43 Reduced the string to just 35 characters, so it wo
105 }
106 s << " side_data_size: " << side_data_size_
98 << " is_key_frame: " << is_key_frame_ 107 << " is_key_frame: " << is_key_frame_
99 << " encrypted: " << (decrypt_config_ != NULL) 108 << " encrypted: " << (decrypt_config_ != NULL) << " discard_padding (ms): ("
100 << " discard_padding (ms): (" << discard_padding_.first.InMilliseconds() 109 << discard_padding_.first.InMilliseconds() << ", "
101 << ", " << discard_padding_.second.InMilliseconds() << ")"; 110 << discard_padding_.second.InMilliseconds() << ")";
102 111
103 if (decrypt_config_) 112 if (decrypt_config_)
104 s << " decrypt:" << (*decrypt_config_); 113 s << " decrypt:" << (*decrypt_config_);
105 114
106 return s.str(); 115 return s.str();
107 } 116 }
108 117
109 void DecoderBuffer::set_timestamp(base::TimeDelta timestamp) { 118 void DecoderBuffer::set_timestamp(base::TimeDelta timestamp) {
110 DCHECK(!end_of_stream()); 119 DCHECK(!end_of_stream());
111 timestamp_ = timestamp; 120 timestamp_ = timestamp;
112 } 121 }
113 122
114 void DecoderBuffer::CopySideDataFrom(const uint8* side_data, 123 void DecoderBuffer::CopySideDataFrom(const uint8* side_data,
115 int side_data_size) { 124 int side_data_size) {
116 if (side_data_size > 0) { 125 if (side_data_size > 0) {
117 side_data_size_ = side_data_size; 126 side_data_size_ = side_data_size;
118 side_data_.reset(AllocateFFmpegSafeBlock(side_data_size_)); 127 side_data_.reset(AllocateFFmpegSafeBlock(side_data_size_));
119 memcpy(side_data_.get(), side_data, side_data_size_); 128 memcpy(side_data_.get(), side_data, side_data_size_);
120 } else { 129 } else {
121 side_data_.reset(); 130 side_data_.reset();
122 side_data_size_ = 0; 131 side_data_size_ = 0;
123 } 132 }
124 } 133 }
125 134
126 } // namespace media 135 } // namespace media
OLDNEW
« no previous file with comments | « no previous file | media/base/video_frame.h » ('j') | media/base/video_frame.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698