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

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

Issue 2024993004: AudioBus: Add a ToInterleavedFloat() method to AudioBus (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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
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_bus.h" 5 #include "media/base/audio_bus.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <limits> 10 #include <limits>
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 void AudioBus::FromInterleaved(const void* source, int frames, 293 void AudioBus::FromInterleaved(const void* source, int frames,
294 int bytes_per_sample) { 294 int bytes_per_sample) {
295 FromInterleavedPartial(source, 0, frames, bytes_per_sample); 295 FromInterleavedPartial(source, 0, frames, bytes_per_sample);
296 } 296 }
297 297
298 void AudioBus::ToInterleaved(int frames, int bytes_per_sample, 298 void AudioBus::ToInterleaved(int frames, int bytes_per_sample,
299 void* dest) const { 299 void* dest) const {
300 ToInterleavedPartial(0, frames, bytes_per_sample, dest); 300 ToInterleavedPartial(0, frames, bytes_per_sample, dest);
301 } 301 }
302 302
303 // Interleaves |audio_bus| channels() of floats into a single output linear
304 // |buffer|.
305 void AudioBus::ToInterleavedFloat(int source_offset,
306 int destination_offset,
307 int num_samples,
308 float* buffer) const {
309 CheckOverflow(source_offset, destination_offset, num_samples);
310 for (int ch = 0; ch < channels(); ++ch) {
311 const float* src = channel(ch) + source_offset;
312 const float* const src_end = src + num_samples;
313 float* dest = buffer + destination_offset + ch;
314 for (; src < src_end; ++src, dest += channels())
mcasas 2016/06/02 01:13:14 nit: every cycle counts, so get channels() evaluat
chfremer 2016/06/02 18:13:33 As per the discussion in the corresponding bug ent
315 *dest = *src;
316 }
317 }
318
303 // TODO(dalecurtis): See if intrinsic optimizations help any here. 319 // TODO(dalecurtis): See if intrinsic optimizations help any here.
304 void AudioBus::ToInterleavedPartial(int start_frame, int frames, 320 void AudioBus::ToInterleavedPartial(int start_frame, int frames,
305 int bytes_per_sample, void* dest) const { 321 int bytes_per_sample, void* dest) const {
306 CheckOverflow(start_frame, frames, frames_); 322 CheckOverflow(start_frame, frames, frames_);
307 switch (bytes_per_sample) { 323 switch (bytes_per_sample) {
308 case 1: 324 case 1:
309 ToInterleavedInternal<uint8_t, int16_t, kUint8Bias>( 325 ToInterleavedInternal<uint8_t, int16_t, kUint8Bias>(
310 this, start_frame, frames, dest, std::numeric_limits<int8_t>::min(), 326 this, start_frame, frames, dest, std::numeric_limits<int8_t>::min(),
311 std::numeric_limits<int8_t>::max()); 327 std::numeric_limits<int8_t>::max());
312 break; 328 break;
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 return scoped_refptr<AudioBusRefCounted>( 385 return scoped_refptr<AudioBusRefCounted>(
370 new AudioBusRefCounted(channels, frames)); 386 new AudioBusRefCounted(channels, frames));
371 } 387 }
372 388
373 AudioBusRefCounted::AudioBusRefCounted(int channels, int frames) 389 AudioBusRefCounted::AudioBusRefCounted(int channels, int frames)
374 : AudioBus(channels, frames) {} 390 : AudioBus(channels, frames) {}
375 391
376 AudioBusRefCounted::~AudioBusRefCounted() {} 392 AudioBusRefCounted::~AudioBusRefCounted() {}
377 393
378 } // namespace media 394 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698