| 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 DCHECK_GT(side_data_size_, 0u); | 43 DCHECK_GT(side_data_size_, 0u); |
| 44 memcpy(side_data_.get(), side_data, side_data_size_); | 44 memcpy(side_data_.get(), side_data, side_data_size_); |
| 45 } | 45 } |
| 46 | 46 |
| 47 DecoderBuffer::~DecoderBuffer() {} | 47 DecoderBuffer::~DecoderBuffer() {} |
| 48 | 48 |
| 49 void DecoderBuffer::Initialize() { | 49 void DecoderBuffer::Initialize() { |
| 50 data_.reset(AllocateFFmpegSafeBlock(size_)); | 50 data_.reset(AllocateFFmpegSafeBlock(size_)); |
| 51 if (side_data_size_ > 0) | 51 if (side_data_size_ > 0) |
| 52 side_data_.reset(AllocateFFmpegSafeBlock(side_data_size_)); | 52 side_data_.reset(AllocateFFmpegSafeBlock(side_data_size_)); |
| 53 splice_timestamp_ = kNoTimestamp; | |
| 54 } | 53 } |
| 55 | 54 |
| 56 // static | 55 // static |
| 57 scoped_refptr<DecoderBuffer> DecoderBuffer::CopyFrom(const uint8_t* data, | 56 scoped_refptr<DecoderBuffer> DecoderBuffer::CopyFrom(const uint8_t* data, |
| 58 size_t data_size) { | 57 size_t data_size) { |
| 59 // If you hit this CHECK you likely have a bug in a demuxer. Go fix it. | 58 // If you hit this CHECK you likely have a bug in a demuxer. Go fix it. |
| 60 CHECK(data); | 59 CHECK(data); |
| 61 return make_scoped_refptr(new DecoderBuffer(data, data_size, NULL, 0)); | 60 return make_scoped_refptr(new DecoderBuffer(data, data_size, NULL, 0)); |
| 62 } | 61 } |
| 63 | 62 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 81 bool DecoderBuffer::MatchesForTesting(const DecoderBuffer& buffer) const { | 80 bool DecoderBuffer::MatchesForTesting(const DecoderBuffer& buffer) const { |
| 82 if (end_of_stream() != buffer.end_of_stream()) | 81 if (end_of_stream() != buffer.end_of_stream()) |
| 83 return false; | 82 return false; |
| 84 | 83 |
| 85 // It is illegal to call any member function if eos is true. | 84 // It is illegal to call any member function if eos is true. |
| 86 if (end_of_stream()) | 85 if (end_of_stream()) |
| 87 return true; | 86 return true; |
| 88 | 87 |
| 89 if (timestamp() != buffer.timestamp() || duration() != buffer.duration() || | 88 if (timestamp() != buffer.timestamp() || duration() != buffer.duration() || |
| 90 is_key_frame() != buffer.is_key_frame() || | 89 is_key_frame() != buffer.is_key_frame() || |
| 91 splice_timestamp() != buffer.splice_timestamp() || | |
| 92 discard_padding() != buffer.discard_padding() || | 90 discard_padding() != buffer.discard_padding() || |
| 93 data_size() != buffer.data_size() || | 91 data_size() != buffer.data_size() || |
| 94 side_data_size() != buffer.side_data_size()) { | 92 side_data_size() != buffer.side_data_size()) { |
| 95 return false; | 93 return false; |
| 96 } | 94 } |
| 97 | 95 |
| 98 if (memcmp(data(), buffer.data(), data_size()) != 0 || | 96 if (memcmp(data(), buffer.data(), data_size()) != 0 || |
| 99 memcmp(side_data(), buffer.side_data(), side_data_size()) != 0) { | 97 memcmp(side_data(), buffer.side_data(), side_data_size()) != 0) { |
| 100 return false; | 98 return false; |
| 101 } | 99 } |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 side_data_size_ = side_data_size; | 137 side_data_size_ = side_data_size; |
| 140 side_data_.reset(AllocateFFmpegSafeBlock(side_data_size_)); | 138 side_data_.reset(AllocateFFmpegSafeBlock(side_data_size_)); |
| 141 memcpy(side_data_.get(), side_data, side_data_size_); | 139 memcpy(side_data_.get(), side_data, side_data_size_); |
| 142 } else { | 140 } else { |
| 143 side_data_.reset(); | 141 side_data_.reset(); |
| 144 side_data_size_ = 0; | 142 side_data_size_ = 0; |
| 145 } | 143 } |
| 146 } | 144 } |
| 147 | 145 |
| 148 } // namespace media | 146 } // namespace media |
| OLD | NEW |