OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
11 #ifndef WEBRTC_MODULES_AUDIO_PROCESSING_CHANNEL_BUFFER_H_ | 11 #ifndef WEBRTC_MODULES_AUDIO_PROCESSING_CHANNEL_BUFFER_H_ |
12 #define WEBRTC_MODULES_AUDIO_PROCESSING_CHANNEL_BUFFER_H_ | 12 #define WEBRTC_MODULES_AUDIO_PROCESSING_CHANNEL_BUFFER_H_ |
13 | 13 |
14 #include <string.h> | 14 #include <string.h> |
15 | 15 |
| 16 #include <memory> |
| 17 |
16 #include "webrtc/base/checks.h" | 18 #include "webrtc/base/checks.h" |
17 #include "webrtc/base/gtest_prod_util.h" | 19 #include "webrtc/base/gtest_prod_util.h" |
18 #include "webrtc/base/scoped_ptr.h" | |
19 #include "webrtc/common_audio/include/audio_util.h" | 20 #include "webrtc/common_audio/include/audio_util.h" |
20 | 21 |
21 namespace webrtc { | 22 namespace webrtc { |
22 | 23 |
23 // Helper to encapsulate a contiguous data buffer, full or split into frequency | 24 // Helper to encapsulate a contiguous data buffer, full or split into frequency |
24 // bands, with access to a pointer arrays of the deinterleaved channels and | 25 // bands, with access to a pointer arrays of the deinterleaved channels and |
25 // bands. The buffer is zero initialized at creation. | 26 // bands. The buffer is zero initialized at creation. |
26 // | 27 // |
27 // The buffer structure is showed below for a 2 channel and 2 bands case: | 28 // The buffer structure is showed below for a 2 channel and 2 bands case: |
28 // | 29 // |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 size_t num_channels() const { return num_channels_; } | 119 size_t num_channels() const { return num_channels_; } |
119 size_t num_bands() const { return num_bands_; } | 120 size_t num_bands() const { return num_bands_; } |
120 size_t size() const {return num_frames_ * num_channels_; } | 121 size_t size() const {return num_frames_ * num_channels_; } |
121 | 122 |
122 void SetDataForTesting(const T* data, size_t size) { | 123 void SetDataForTesting(const T* data, size_t size) { |
123 RTC_CHECK_EQ(size, this->size()); | 124 RTC_CHECK_EQ(size, this->size()); |
124 memcpy(data_.get(), data, size * sizeof(*data)); | 125 memcpy(data_.get(), data, size * sizeof(*data)); |
125 } | 126 } |
126 | 127 |
127 private: | 128 private: |
128 rtc::scoped_ptr<T[]> data_; | 129 std::unique_ptr<T[]> data_; |
129 rtc::scoped_ptr<T* []> channels_; | 130 std::unique_ptr<T* []> channels_; |
130 rtc::scoped_ptr<T* []> bands_; | 131 std::unique_ptr<T* []> bands_; |
131 const size_t num_frames_; | 132 const size_t num_frames_; |
132 const size_t num_frames_per_band_; | 133 const size_t num_frames_per_band_; |
133 const size_t num_channels_; | 134 const size_t num_channels_; |
134 const size_t num_bands_; | 135 const size_t num_bands_; |
135 }; | 136 }; |
136 | 137 |
137 // One int16_t and one float ChannelBuffer that are kept in sync. The sync is | 138 // One int16_t and one float ChannelBuffer that are kept in sync. The sync is |
138 // broken when someone requests write access to either ChannelBuffer, and | 139 // broken when someone requests write access to either ChannelBuffer, and |
139 // reestablished when someone requests the outdated ChannelBuffer. It is | 140 // reestablished when someone requests the outdated ChannelBuffer. It is |
140 // therefore safe to use the return value of ibuf_const() and fbuf_const() | 141 // therefore safe to use the return value of ibuf_const() and fbuf_const() |
(...skipping 19 matching lines...) Expand all Loading... |
160 | 161 |
161 mutable bool ivalid_; | 162 mutable bool ivalid_; |
162 mutable ChannelBuffer<int16_t> ibuf_; | 163 mutable ChannelBuffer<int16_t> ibuf_; |
163 mutable bool fvalid_; | 164 mutable bool fvalid_; |
164 mutable ChannelBuffer<float> fbuf_; | 165 mutable ChannelBuffer<float> fbuf_; |
165 }; | 166 }; |
166 | 167 |
167 } // namespace webrtc | 168 } // namespace webrtc |
168 | 169 |
169 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_CHANNEL_BUFFER_H_ | 170 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_CHANNEL_BUFFER_H_ |
OLD | NEW |