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 // A specialized buffer for interfacing with audio / video decoders. | 5 // A specialized buffer for interfacing with audio / video decoders. |
| 6 // | 6 // |
| 7 // Specifically ensures that data is aligned and padded as necessary by the | 7 // Specifically ensures that data is aligned and padded as necessary by the |
| 8 // underlying decoding framework. On desktop platforms this means memory is | 8 // underlying decoding framework. On desktop platforms this means memory is |
| 9 // allocated using FFmpeg with particular alignment and padding requirements. | 9 // allocated using FFmpeg with particular alignment and padding requirements. |
| 10 // | 10 // |
| 11 // Also includes decoder specific functionality for decryption. | 11 // Also includes decoder specific functionality for decryption. |
| 12 | 12 |
| 13 #ifndef MEDIA_BASE_DECODER_BUFFER_H_ | 13 #ifndef MEDIA_BASE_DECODER_BUFFER_H_ |
| 14 #define MEDIA_BASE_DECODER_BUFFER_H_ | 14 #define MEDIA_BASE_DECODER_BUFFER_H_ |
| 15 | 15 |
| 16 #include "base/memory/aligned_memory.h" | |
| 16 #include "base/memory/scoped_ptr.h" | 17 #include "base/memory/scoped_ptr.h" |
| 17 #include "build/build_config.h" | 18 #include "build/build_config.h" |
| 18 #include "media/base/buffers.h" | 19 #include "media/base/buffers.h" |
| 19 #include "media/base/decrypt_config.h" | 20 #include "media/base/decrypt_config.h" |
| 20 | 21 |
| 21 namespace media { | 22 namespace media { |
| 22 | 23 |
| 24 struct AlignedFreeDeleter { | |
|
DaleCurtis
2012/12/21 01:11:44
Just use ScopedPtrAlignedFree from base/memory/ali
xhwang
2012/12/21 01:31:05
Indeed. Thanks for pointing that out.
| |
| 25 inline void operator()(void* ptr) const { | |
| 26 base::AlignedFree(ptr); | |
| 27 } | |
| 28 }; | |
| 29 | |
| 23 class MEDIA_EXPORT DecoderBuffer : public Buffer { | 30 class MEDIA_EXPORT DecoderBuffer : public Buffer { |
| 24 public: | 31 public: |
| 25 enum { | 32 enum { |
| 26 kPaddingSize = 16, | 33 kPaddingSize = 16, |
| 27 #if defined(ARCH_CPU_ARM_FAMILY) | 34 #if defined(ARCH_CPU_ARM_FAMILY) |
| 28 kAlignmentSize = 16 | 35 kAlignmentSize = 16 |
| 29 #else | 36 #else |
| 30 kAlignmentSize = 32 | 37 kAlignmentSize = 32 |
| 31 #endif | 38 #endif |
| 32 }; | 39 }; |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 55 | 62 |
| 56 protected: | 63 protected: |
| 57 // Allocates a buffer of size |size| >= 0 and copies |data| into it. Buffer | 64 // Allocates a buffer of size |size| >= 0 and copies |data| into it. Buffer |
| 58 // will be padded and aligned as necessary. If |data| is NULL then |data_| is | 65 // will be padded and aligned as necessary. If |data| is NULL then |data_| is |
| 59 // set to NULL and |buffer_size_| to 0. | 66 // set to NULL and |buffer_size_| to 0. |
| 60 DecoderBuffer(const uint8* data, int size); | 67 DecoderBuffer(const uint8* data, int size); |
| 61 virtual ~DecoderBuffer(); | 68 virtual ~DecoderBuffer(); |
| 62 | 69 |
| 63 private: | 70 private: |
| 64 int buffer_size_; | 71 int buffer_size_; |
| 65 uint8* data_; | 72 scoped_ptr<uint8[], AlignedFreeDeleter> data_; |
| 66 scoped_ptr<DecryptConfig> decrypt_config_; | 73 scoped_ptr<DecryptConfig> decrypt_config_; |
| 67 | 74 |
| 68 // Constructor helper method for memory allocations. | 75 // Constructor helper method for memory allocations. |
| 69 void Initialize(); | 76 void Initialize(); |
| 70 | 77 |
| 71 DISALLOW_COPY_AND_ASSIGN(DecoderBuffer); | 78 DISALLOW_COPY_AND_ASSIGN(DecoderBuffer); |
| 72 }; | 79 }; |
| 73 | 80 |
| 74 } // namespace media | 81 } // namespace media |
| 75 | 82 |
| 76 #endif // MEDIA_BASE_DECODER_BUFFER_H_ | 83 #endif // MEDIA_BASE_DECODER_BUFFER_H_ |
| OLD | NEW |