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 namespace media { | 7 namespace media { |
8 | 8 |
9 // Allocates a block of memory which is padded for use with the SIMD | 9 // Allocates a block of memory which is padded for use with the SIMD |
10 // optimizations used by FFmpeg. | 10 // optimizations used by FFmpeg. |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 CHECK(side_data); | 71 CHECK(side_data); |
72 return make_scoped_refptr(new DecoderBuffer(data, data_size, | 72 return make_scoped_refptr(new DecoderBuffer(data, data_size, |
73 side_data, side_data_size)); | 73 side_data, side_data_size)); |
74 } | 74 } |
75 | 75 |
76 // static | 76 // static |
77 scoped_refptr<DecoderBuffer> DecoderBuffer::CreateEOSBuffer() { | 77 scoped_refptr<DecoderBuffer> DecoderBuffer::CreateEOSBuffer() { |
78 return make_scoped_refptr(new DecoderBuffer(NULL, 0, NULL, 0)); | 78 return make_scoped_refptr(new DecoderBuffer(NULL, 0, NULL, 0)); |
79 } | 79 } |
80 | 80 |
81 std::string DecoderBuffer::AsHumanReadableString() { | 81 std::string DecoderBuffer::AsHumanReadableString(int flags) { |
82 if (end_of_stream()) { | 82 if (end_of_stream()) { |
83 return "end of stream"; | 83 return "end of stream"; |
84 } | 84 } |
85 | 85 |
86 std::ostringstream s; | 86 std::ostringstream s; |
87 s << "timestamp: " << timestamp_.InMicroseconds() | 87 if ((flags & kShortFormat) == kShortFormat) { |
88 << " duration: " << duration_.InMicroseconds() | 88 s << "timestamp: " << timestamp_; |
89 << " size: " << size_ | 89 if (is_key_frame_) |
90 << " side_data_size: " << side_data_size_ | 90 s << " KEY"; |
91 << " is_key_frame: " << is_key_frame_ | 91 } else { |
92 << " encrypted: " << (decrypt_config_ != NULL) | 92 s << "timestamp: " << timestamp_.InMicroseconds() |
93 << " discard_padding (ms): (" << discard_padding_.first.InMilliseconds() | 93 << " duration: " << duration_.InMicroseconds() << " size: " << size_ |
94 << ", " << discard_padding_.second.InMilliseconds() << ")"; | 94 << " side_data_size: " << side_data_size_ |
| 95 << " is_key_frame: " << is_key_frame_ |
| 96 << " encrypted: " << (decrypt_config_ != NULL) |
| 97 << " discard_padding (ms): (" << discard_padding_.first.InMilliseconds() |
| 98 << ", " << discard_padding_.second.InMilliseconds() << ")"; |
| 99 } |
95 | 100 |
96 if (decrypt_config_) | 101 if (decrypt_config_) |
97 s << " decrypt:" << (*decrypt_config_); | 102 s << " decrypt:" << (*decrypt_config_); |
98 | 103 |
99 return s.str(); | 104 return s.str(); |
100 } | 105 } |
101 | 106 |
102 void DecoderBuffer::set_timestamp(base::TimeDelta timestamp) { | 107 void DecoderBuffer::set_timestamp(base::TimeDelta timestamp) { |
103 DCHECK(!end_of_stream()); | 108 DCHECK(!end_of_stream()); |
104 timestamp_ = timestamp; | 109 timestamp_ = timestamp; |
105 } | 110 } |
106 | 111 |
107 void DecoderBuffer::CopySideDataFrom(const uint8_t* side_data, | 112 void DecoderBuffer::CopySideDataFrom(const uint8_t* side_data, |
108 size_t side_data_size) { | 113 size_t side_data_size) { |
109 if (side_data_size > 0) { | 114 if (side_data_size > 0) { |
110 side_data_size_ = side_data_size; | 115 side_data_size_ = side_data_size; |
111 side_data_.reset(AllocateFFmpegSafeBlock(side_data_size_)); | 116 side_data_.reset(AllocateFFmpegSafeBlock(side_data_size_)); |
112 memcpy(side_data_.get(), side_data, side_data_size_); | 117 memcpy(side_data_.get(), side_data, side_data_size_); |
113 } else { | 118 } else { |
114 side_data_.reset(); | 119 side_data_.reset(); |
115 side_data_size_ = 0; | 120 side_data_size_ = 0; |
116 } | 121 } |
117 } | 122 } |
118 | 123 |
119 } // namespace media | 124 } // namespace media |
OLD | NEW |