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/logging.h" | 7 #include "base/logging.h" |
8 #include "media/base/buffers.h" | 8 #include "media/base/buffers.h" |
9 #include "media/base/decrypt_config.h" | 9 #include "media/base/decrypt_config.h" |
10 | 10 |
11 namespace media { | 11 namespace media { |
12 | 12 |
13 // Allocates a block of memory which is padded for use with the SIMD | 13 // Allocates a block of memory which is padded for use with the SIMD |
14 // optimizations used by FFmpeg. | 14 // optimizations used by FFmpeg. |
15 static uint8* AllocateFFmpegSafeBlock(int size) { | 15 static uint8* AllocateFFmpegSafeBlock(int size) { |
16 uint8* const block = reinterpret_cast<uint8*>(base::AlignedAlloc( | 16 uint8* const block = reinterpret_cast<uint8*>(base::AlignedAlloc( |
17 size + DecoderBuffer::kPaddingSize, DecoderBuffer::kAlignmentSize)); | 17 size + DecoderBuffer::kPaddingSize, DecoderBuffer::kAlignmentSize)); |
18 memset(block + size, 0, DecoderBuffer::kPaddingSize); | 18 memset(block + size, 0, DecoderBuffer::kPaddingSize); |
19 return block; | 19 return block; |
20 } | 20 } |
21 | 21 |
22 DecoderBuffer::DecoderBuffer(int size) | 22 DecoderBuffer::DecoderBuffer(int size) |
23 : size_(size), | 23 : size_(size), |
24 side_data_size_(0), | 24 side_data_size_(0), |
25 is_key_frame_(false) { | 25 is_key_frame_(false) { |
26 Initialize(); | 26 Initialize(); |
27 } | 27 } |
28 | 28 |
29 DecoderBuffer::DecoderBuffer(const uint8* data, int size, | 29 DecoderBuffer::DecoderBuffer(const uint8* data, |
30 const uint8* side_data, int side_data_size) | 30 int size, |
| 31 const uint8* side_data, |
| 32 int side_data_size) |
31 : size_(size), | 33 : size_(size), |
32 side_data_size_(side_data_size), | 34 side_data_size_(side_data_size), |
33 is_key_frame_(false) { | 35 is_key_frame_(false) { |
34 if (!data) { | 36 if (!data) { |
35 CHECK_EQ(size_, 0); | 37 CHECK_EQ(size_, 0); |
36 CHECK(!side_data); | 38 CHECK(!side_data); |
37 return; | 39 return; |
38 } | 40 } |
39 | 41 |
40 Initialize(); | 42 Initialize(); |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 side_data_size_ = side_data_size; | 116 side_data_size_ = side_data_size; |
115 side_data_.reset(AllocateFFmpegSafeBlock(side_data_size_)); | 117 side_data_.reset(AllocateFFmpegSafeBlock(side_data_size_)); |
116 memcpy(side_data_.get(), side_data, side_data_size_); | 118 memcpy(side_data_.get(), side_data, side_data_size_); |
117 } else { | 119 } else { |
118 side_data_.reset(); | 120 side_data_.reset(); |
119 side_data_size_ = 0; | 121 side_data_size_ = 0; |
120 } | 122 } |
121 } | 123 } |
122 | 124 |
123 } // namespace media | 125 } // namespace media |
OLD | NEW |