Chromium Code Reviews| OLD | NEW |
|---|---|
| 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" | |
| 8 | |
| 7 namespace media { | 9 namespace media { |
| 8 | 10 |
| 9 // 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 |
| 10 // optimizations used by FFmpeg. | 12 // optimizations used by FFmpeg. |
| 11 static uint8_t* AllocateFFmpegSafeBlock(int size) { | 13 static uint8_t* AllocateFFmpegSafeBlock(int size) { |
| 12 uint8_t* const block = reinterpret_cast<uint8_t*>(base::AlignedAlloc( | 14 uint8_t* const block = reinterpret_cast<uint8_t*>(base::AlignedAlloc( |
| 13 size + DecoderBuffer::kPaddingSize, DecoderBuffer::kAlignmentSize)); | 15 size + DecoderBuffer::kPaddingSize, DecoderBuffer::kAlignmentSize)); |
| 14 memset(block + size, 0, DecoderBuffer::kPaddingSize); | 16 memset(block + size, 0, DecoderBuffer::kPaddingSize); |
| 15 return block; | 17 return block; |
| 16 } | 18 } |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 82 return make_scoped_refptr(new DecoderBuffer(NULL, 0, NULL, 0)); | 84 return make_scoped_refptr(new DecoderBuffer(NULL, 0, NULL, 0)); |
| 83 } | 85 } |
| 84 | 86 |
| 85 std::string DecoderBuffer::AsHumanReadableString() { | 87 std::string DecoderBuffer::AsHumanReadableString() { |
| 86 if (end_of_stream()) { | 88 if (end_of_stream()) { |
| 87 return "end of stream"; | 89 return "end of stream"; |
| 88 } | 90 } |
| 89 | 91 |
| 90 std::ostringstream s; | 92 std::ostringstream s; |
| 91 s << "timestamp: " << timestamp_.InMicroseconds() | 93 s << "timestamp: " << timestamp_.InMicroseconds() |
| 92 << " duration: " << duration_.InMicroseconds() | 94 << " duration: " << duration_.InMicroseconds() << " size: " << size_ |
| 93 << " size: " << size_ | 95 << " data: "; |
| 94 << " side_data_size: " << side_data_size_ | 96 if (size_ == 0 || !data_) |
| 97 s << "<null>"; | |
| 98 else if (size_ < 17) | |
| 99 s << base::HexEncode(data_.get(), size_); | |
| 100 else { | |
| 101 s << base::HexEncode(data_.get(), 8) << "..." | |
| 102 << base::HexEncode(data_.get() + size_ - 8, 8); | |
|
xhwang
2016/01/05 17:29:11
I still don't see a general use case for dumping t
jrummell
2016/01/12 20:00:36
Done.
| |
| 103 } | |
| 104 s << " side_data_size: " << side_data_size_ | |
| 95 << " is_key_frame: " << is_key_frame_ | 105 << " is_key_frame: " << is_key_frame_ |
| 96 << " encrypted: " << (decrypt_config_ != NULL) | 106 << " encrypted: " << (decrypt_config_ != NULL) << " discard_padding (ms): (" |
| 97 << " discard_padding (ms): (" << discard_padding_.first.InMilliseconds() | 107 << discard_padding_.first.InMilliseconds() << ", " |
| 98 << ", " << discard_padding_.second.InMilliseconds() << ")"; | 108 << discard_padding_.second.InMilliseconds() << ")"; |
| 99 | 109 |
| 100 if (decrypt_config_) | 110 if (decrypt_config_) |
| 101 s << " decrypt:" << (*decrypt_config_); | 111 s << " decrypt:" << (*decrypt_config_); |
| 102 | 112 |
| 103 return s.str(); | 113 return s.str(); |
| 104 } | 114 } |
| 105 | 115 |
| 106 void DecoderBuffer::set_timestamp(base::TimeDelta timestamp) { | 116 void DecoderBuffer::set_timestamp(base::TimeDelta timestamp) { |
| 107 DCHECK(!end_of_stream()); | 117 DCHECK(!end_of_stream()); |
| 108 timestamp_ = timestamp; | 118 timestamp_ = timestamp; |
| 109 } | 119 } |
| 110 | 120 |
| 111 void DecoderBuffer::CopySideDataFrom(const uint8_t* side_data, | 121 void DecoderBuffer::CopySideDataFrom(const uint8_t* side_data, |
| 112 int side_data_size) { | 122 int side_data_size) { |
| 113 if (side_data_size > 0) { | 123 if (side_data_size > 0) { |
| 114 side_data_size_ = side_data_size; | 124 side_data_size_ = side_data_size; |
| 115 side_data_.reset(AllocateFFmpegSafeBlock(side_data_size_)); | 125 side_data_.reset(AllocateFFmpegSafeBlock(side_data_size_)); |
| 116 memcpy(side_data_.get(), side_data, side_data_size_); | 126 memcpy(side_data_.get(), side_data, side_data_size_); |
| 117 } else { | 127 } else { |
| 118 side_data_.reset(); | 128 side_data_.reset(); |
| 119 side_data_size_ = 0; | 129 side_data_size_ = 0; |
| 120 } | 130 } |
| 121 } | 131 } |
| 122 | 132 |
| 123 } // namespace media | 133 } // namespace media |
| OLD | NEW |