Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(231)

Side by Side Diff: webrtc/modules/audio_coding/neteq/audio_vector.h

Issue 2670643007: Make AudioVector::operator[] inline and modify index calculation (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | webrtc/modules/audio_coding/neteq/audio_vector.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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_
OLDNEW
« no previous file with comments | « no previous file | webrtc/modules/audio_coding/neteq/audio_vector.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698