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

Side by Side Diff: webrtc/common_audio/audio_converter.cc

Issue 1460043002: Don't call the Pass methods of rtc::Buffer, rtc::scoped_ptr, and rtc::ScopedVector (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Restore the Pass methods Created 5 years 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 | « webrtc/base/scoped_ptr.h ('k') | webrtc/modules/audio_coding/acm2/rent_a_codec.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) 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 #include "webrtc/common_audio/audio_converter.h" 11 #include "webrtc/common_audio/audio_converter.h"
12 12
13 #include <cstring> 13 #include <cstring>
14 #include <utility>
14 15
15 #include "webrtc/base/checks.h" 16 #include "webrtc/base/checks.h"
16 #include "webrtc/base/safe_conversions.h" 17 #include "webrtc/base/safe_conversions.h"
17 #include "webrtc/common_audio/channel_buffer.h" 18 #include "webrtc/common_audio/channel_buffer.h"
18 #include "webrtc/common_audio/resampler/push_sinc_resampler.h" 19 #include "webrtc/common_audio/resampler/push_sinc_resampler.h"
19 #include "webrtc/system_wrappers/include/scoped_vector.h" 20 #include "webrtc/system_wrappers/include/scoped_vector.h"
20 21
21 using rtc::checked_cast; 22 using rtc::checked_cast;
22 23
23 namespace webrtc { 24 namespace webrtc {
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 99
99 private: 100 private:
100 ScopedVector<PushSincResampler> resamplers_; 101 ScopedVector<PushSincResampler> resamplers_;
101 }; 102 };
102 103
103 // Apply a vector of converters in serial, in the order given. At least two 104 // Apply a vector of converters in serial, in the order given. At least two
104 // converters must be provided. 105 // converters must be provided.
105 class CompositionConverter : public AudioConverter { 106 class CompositionConverter : public AudioConverter {
106 public: 107 public:
107 CompositionConverter(ScopedVector<AudioConverter> converters) 108 CompositionConverter(ScopedVector<AudioConverter> converters)
108 : converters_(converters.Pass()) { 109 : converters_(std::move(converters)) {
109 RTC_CHECK_GE(converters_.size(), 2u); 110 RTC_CHECK_GE(converters_.size(), 2u);
110 // We need an intermediate buffer after every converter. 111 // We need an intermediate buffer after every converter.
111 for (auto it = converters_.begin(); it != converters_.end() - 1; ++it) 112 for (auto it = converters_.begin(); it != converters_.end() - 1; ++it)
112 buffers_.push_back(new ChannelBuffer<float>((*it)->dst_frames(), 113 buffers_.push_back(new ChannelBuffer<float>((*it)->dst_frames(),
113 (*it)->dst_channels())); 114 (*it)->dst_channels()));
114 } 115 }
115 ~CompositionConverter() override {}; 116 ~CompositionConverter() override {};
116 117
117 void Convert(const float* const* src, size_t src_size, float* const* dst, 118 void Convert(const float* const* src, size_t src_size, float* const* dst,
118 size_t dst_capacity) override { 119 size_t dst_capacity) override {
(...skipping 21 matching lines...) Expand all
140 int dst_channels, 141 int dst_channels,
141 size_t dst_frames) { 142 size_t dst_frames) {
142 rtc::scoped_ptr<AudioConverter> sp; 143 rtc::scoped_ptr<AudioConverter> sp;
143 if (src_channels > dst_channels) { 144 if (src_channels > dst_channels) {
144 if (src_frames != dst_frames) { 145 if (src_frames != dst_frames) {
145 ScopedVector<AudioConverter> converters; 146 ScopedVector<AudioConverter> converters;
146 converters.push_back(new DownmixConverter(src_channels, src_frames, 147 converters.push_back(new DownmixConverter(src_channels, src_frames,
147 dst_channels, src_frames)); 148 dst_channels, src_frames));
148 converters.push_back(new ResampleConverter(dst_channels, src_frames, 149 converters.push_back(new ResampleConverter(dst_channels, src_frames,
149 dst_channels, dst_frames)); 150 dst_channels, dst_frames));
150 sp.reset(new CompositionConverter(converters.Pass())); 151 sp.reset(new CompositionConverter(std::move(converters)));
151 } else { 152 } else {
152 sp.reset(new DownmixConverter(src_channels, src_frames, dst_channels, 153 sp.reset(new DownmixConverter(src_channels, src_frames, dst_channels,
153 dst_frames)); 154 dst_frames));
154 } 155 }
155 } else if (src_channels < dst_channels) { 156 } else if (src_channels < dst_channels) {
156 if (src_frames != dst_frames) { 157 if (src_frames != dst_frames) {
157 ScopedVector<AudioConverter> converters; 158 ScopedVector<AudioConverter> converters;
158 converters.push_back(new ResampleConverter(src_channels, src_frames, 159 converters.push_back(new ResampleConverter(src_channels, src_frames,
159 src_channels, dst_frames)); 160 src_channels, dst_frames));
160 converters.push_back(new UpmixConverter(src_channels, dst_frames, 161 converters.push_back(new UpmixConverter(src_channels, dst_frames,
161 dst_channels, dst_frames)); 162 dst_channels, dst_frames));
162 sp.reset(new CompositionConverter(converters.Pass())); 163 sp.reset(new CompositionConverter(std::move(converters)));
163 } else { 164 } else {
164 sp.reset(new UpmixConverter(src_channels, src_frames, dst_channels, 165 sp.reset(new UpmixConverter(src_channels, src_frames, dst_channels,
165 dst_frames)); 166 dst_frames));
166 } 167 }
167 } else if (src_frames != dst_frames) { 168 } else if (src_frames != dst_frames) {
168 sp.reset(new ResampleConverter(src_channels, src_frames, dst_channels, 169 sp.reset(new ResampleConverter(src_channels, src_frames, dst_channels,
169 dst_frames)); 170 dst_frames));
170 } else { 171 } else {
171 sp.reset(new CopyConverter(src_channels, src_frames, dst_channels, 172 sp.reset(new CopyConverter(src_channels, src_frames, dst_channels,
172 dst_frames)); 173 dst_frames));
173 } 174 }
174 175
175 return sp.Pass(); 176 return sp;
176 } 177 }
177 178
178 // For CompositionConverter. 179 // For CompositionConverter.
179 AudioConverter::AudioConverter() 180 AudioConverter::AudioConverter()
180 : src_channels_(0), 181 : src_channels_(0),
181 src_frames_(0), 182 src_frames_(0),
182 dst_channels_(0), 183 dst_channels_(0),
183 dst_frames_(0) {} 184 dst_frames_(0) {}
184 185
185 AudioConverter::AudioConverter(int src_channels, size_t src_frames, 186 AudioConverter::AudioConverter(int src_channels, size_t src_frames,
186 int dst_channels, size_t dst_frames) 187 int dst_channels, size_t dst_frames)
187 : src_channels_(src_channels), 188 : src_channels_(src_channels),
188 src_frames_(src_frames), 189 src_frames_(src_frames),
189 dst_channels_(dst_channels), 190 dst_channels_(dst_channels),
190 dst_frames_(dst_frames) { 191 dst_frames_(dst_frames) {
191 RTC_CHECK(dst_channels == src_channels || dst_channels == 1 || 192 RTC_CHECK(dst_channels == src_channels || dst_channels == 1 ||
192 src_channels == 1); 193 src_channels == 1);
193 } 194 }
194 195
195 void AudioConverter::CheckSizes(size_t src_size, size_t dst_capacity) const { 196 void AudioConverter::CheckSizes(size_t src_size, size_t dst_capacity) const {
196 RTC_CHECK_EQ(src_size, src_channels() * src_frames()); 197 RTC_CHECK_EQ(src_size, src_channels() * src_frames());
197 RTC_CHECK_GE(dst_capacity, dst_channels() * dst_frames()); 198 RTC_CHECK_GE(dst_capacity, dst_channels() * dst_frames());
198 } 199 }
199 200
200 } // namespace webrtc 201 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/base/scoped_ptr.h ('k') | webrtc/modules/audio_coding/acm2/rent_a_codec.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698