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

Side by Side Diff: media/base/audio_converter.cc

Issue 13726011: Add vector_math::FMUL. Replace audio_util::AdjustVolume. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix volume == 1 case. Created 7 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « media/base/audio_bus_unittest.cc ('k') | media/base/simd/vector_math_sse.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 // 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 #include "media/base/audio_converter.h" 5 #include "media/base/audio_converter.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 it != transform_inputs_.end(); ++it) { 171 it != transform_inputs_.end(); ++it) {
172 InputCallback* input = *it; 172 InputCallback* input = *it;
173 173
174 float volume = input->ProvideInput( 174 float volume = input->ProvideInput(
175 mixer_input_audio_bus_.get(), buffer_delay); 175 mixer_input_audio_bus_.get(), buffer_delay);
176 176
177 // Optimize the most common single input, full volume case. 177 // Optimize the most common single input, full volume case.
178 if (it == transform_inputs_.begin()) { 178 if (it == transform_inputs_.begin()) {
179 if (volume == 1.0f) { 179 if (volume == 1.0f) {
180 mixer_input_audio_bus_->CopyTo(temp_dest); 180 mixer_input_audio_bus_->CopyTo(temp_dest);
181 continue; 181 } else if (volume > 0) {
182 for (int i = 0; i < mixer_input_audio_bus_->channels(); ++i) {
183 vector_math::FMUL(
184 mixer_input_audio_bus_->channel(i), volume,
185 mixer_input_audio_bus_->frames(), temp_dest->channel(i));
186 }
187 } else {
188 // Zero |temp_dest| otherwise, so we're mixing into a clean buffer.
189 temp_dest->Zero();
182 } 190 }
183 191
184 // Zero |temp_dest| otherwise, so we're mixing into a clean buffer. 192 continue;
185 temp_dest->Zero();
186 } 193 }
187 194
188 // Volume adjust and mix each mixer input into |temp_dest| after rendering. 195 // Volume adjust and mix each mixer input into |temp_dest| after rendering.
189 if (volume > 0) { 196 if (volume > 0) {
190 for (int i = 0; i < mixer_input_audio_bus_->channels(); ++i) { 197 for (int i = 0; i < mixer_input_audio_bus_->channels(); ++i) {
191 vector_math::FMAC( 198 vector_math::FMAC(
192 mixer_input_audio_bus_->channel(i), volume, 199 mixer_input_audio_bus_->channel(i), volume,
193 mixer_input_audio_bus_->frames(), temp_dest->channel(i)); 200 mixer_input_audio_bus_->frames(), temp_dest->channel(i));
194 } 201 }
195 } 202 }
196 } 203 }
197 204
198 if (needs_downmix) { 205 if (needs_downmix) {
199 DCHECK_EQ(temp_dest->frames(), dest->frames()); 206 DCHECK_EQ(temp_dest->frames(), dest->frames());
200 channel_mixer_->Transform(temp_dest, dest); 207 channel_mixer_->Transform(temp_dest, dest);
201 } 208 }
202 } 209 }
203 210
204 void AudioConverter::ProvideInput(int resampler_frame_delay, AudioBus* dest) { 211 void AudioConverter::ProvideInput(int resampler_frame_delay, AudioBus* dest) {
205 resampler_frame_delay_ = resampler_frame_delay; 212 resampler_frame_delay_ = resampler_frame_delay;
206 if (audio_fifo_) 213 if (audio_fifo_)
207 audio_fifo_->Consume(dest, dest->frames()); 214 audio_fifo_->Consume(dest, dest->frames());
208 else 215 else
209 SourceCallback(0, dest); 216 SourceCallback(0, dest);
210 } 217 }
211 218
212 } // namespace media 219 } // namespace media
OLDNEW
« no previous file with comments | « media/base/audio_bus_unittest.cc ('k') | media/base/simd/vector_math_sse.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698