OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 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 |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
103 // region. | 103 // region. |
104 virtual void CrossFade(const AudioVector& append_this, size_t fade_length); | 104 virtual void CrossFade(const AudioVector& append_this, size_t fade_length); |
105 | 105 |
106 // Returns the number of elements in this AudioVector. | 106 // Returns the number of elements in this AudioVector. |
107 virtual size_t Size() const; | 107 virtual size_t Size() const; |
108 | 108 |
109 // Returns true if this AudioVector is empty. | 109 // Returns true if this AudioVector is empty. |
110 virtual bool Empty() const; | 110 virtual bool Empty() const; |
111 | 111 |
112 // Accesses and modifies an element of AudioVector. | 112 // Accesses and modifies an element of AudioVector. |
113 const int16_t& operator[](size_t index) const; | 113 inline const int16_t& operator[](size_t index) const { |
kwiberg-webrtc
2017/02/07 14:04:15
The "inline" keyword isn't necessary---functions d
| |
114 int16_t& operator[](size_t index); | 114 return array_[(begin_index_ + index) % capacity_]; |
the sun
2017/02/02 19:29:55
Integer division is still surprisingly expensive o
kwiberg-webrtc
2017/02/07 14:04:15
Alternatively, can we be sure that 0 <= begin_inde
hlundin-webrtc
2017/02/13 14:21:13
I did something along those lines.
| |
115 } | |
116 | |
117 inline int16_t& operator[](size_t index) { | |
118 return array_[(begin_index_ + index) % capacity_]; | |
119 } | |
115 | 120 |
116 private: | 121 private: |
117 static const size_t kDefaultInitialSize = 10; | 122 static const size_t kDefaultInitialSize = 10; |
118 | 123 |
119 void Reserve(size_t n); | 124 void Reserve(size_t n); |
120 | 125 |
121 void InsertByPushBack(const int16_t* insert_this, size_t length, | 126 void InsertByPushBack(const int16_t* insert_this, size_t length, |
122 size_t position); | 127 size_t position); |
123 | 128 |
124 void InsertByPushFront(const int16_t* insert_this, size_t length, | 129 void InsertByPushFront(const int16_t* insert_this, size_t length, |
(...skipping 12 matching lines...) Expand all Loading... | |
137 size_t begin_index_; | 142 size_t begin_index_; |
138 | 143 |
139 // The index of the sample after the last sample in |array_|. | 144 // The index of the sample after the last sample in |array_|. |
140 size_t end_index_; | 145 size_t end_index_; |
141 | 146 |
142 RTC_DISALLOW_COPY_AND_ASSIGN(AudioVector); | 147 RTC_DISALLOW_COPY_AND_ASSIGN(AudioVector); |
143 }; | 148 }; |
144 | 149 |
145 } // namespace webrtc | 150 } // namespace webrtc |
146 #endif // WEBRTC_MODULES_AUDIO_CODING_NETEQ_AUDIO_VECTOR_H_ | 151 #endif // WEBRTC_MODULES_AUDIO_CODING_NETEQ_AUDIO_VECTOR_H_ |
OLD | NEW |