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

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

Issue 1769373003: AudioBus: Add a ToInterleavedFloat() method to AudioBus (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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
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 279 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 void AudioBus::FromInterleaved(const void* source, int frames, 290 void AudioBus::FromInterleaved(const void* source, int frames,
291 int bytes_per_sample) { 291 int bytes_per_sample) {
292 FromInterleavedPartial(source, 0, frames, bytes_per_sample); 292 FromInterleavedPartial(source, 0, frames, bytes_per_sample);
293 } 293 }
294 294
295 void AudioBus::ToInterleaved(int frames, int bytes_per_sample, 295 void AudioBus::ToInterleaved(int frames, int bytes_per_sample,
296 void* dest) const { 296 void* dest) const {
297 ToInterleavedPartial(0, frames, bytes_per_sample, dest); 297 ToInterleavedPartial(0, frames, bytes_per_sample, dest);
298 } 298 }
299 299
300 // Interleaves |audio_bus| channels() of floats into a single output linear
301 // |buffer|.
302 void AudioBus::ToInterleavedFloat(int source_offset,
303 int destination_offset,
304 int num_samples,
mcasas 2016/04/11 23:47:08 This parameter is called |int num_channels| in the
305 float* buffer) const {
306 CheckOverflow(source_offset, destination_offset, num_samples);
307 for (int ch = 0; ch < channels(); ++ch) {
308 const float* src = channel(ch) + source_offset;
309 const float* const src_end = src + num_samples;
310 float* dest = buffer + destination_offset + ch;
311 for (; src < src_end; ++src, dest += channels())
312 *dest = *src;
313 }
314 }
315
300 // TODO(dalecurtis): See if intrinsic optimizations help any here. 316 // TODO(dalecurtis): See if intrinsic optimizations help any here.
301 void AudioBus::ToInterleavedPartial(int start_frame, int frames, 317 void AudioBus::ToInterleavedPartial(int start_frame, int frames,
302 int bytes_per_sample, void* dest) const { 318 int bytes_per_sample, void* dest) const {
303 CheckOverflow(start_frame, frames, frames_); 319 CheckOverflow(start_frame, frames, frames_);
304 switch (bytes_per_sample) { 320 switch (bytes_per_sample) {
305 case 1: 321 case 1:
306 ToInterleavedInternal<uint8_t, int16_t, kUint8Bias>( 322 ToInterleavedInternal<uint8_t, int16_t, kUint8Bias>(
307 this, start_frame, frames, dest, std::numeric_limits<int8_t>::min(), 323 this, start_frame, frames, dest, std::numeric_limits<int8_t>::min(),
308 std::numeric_limits<int8_t>::max()); 324 std::numeric_limits<int8_t>::max());
309 break; 325 break;
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 return scoped_refptr<AudioBusRefCounted>( 382 return scoped_refptr<AudioBusRefCounted>(
367 new AudioBusRefCounted(channels, frames)); 383 new AudioBusRefCounted(channels, frames));
368 } 384 }
369 385
370 AudioBusRefCounted::AudioBusRefCounted(int channels, int frames) 386 AudioBusRefCounted::AudioBusRefCounted(int channels, int frames)
371 : AudioBus(channels, frames) {} 387 : AudioBus(channels, frames) {}
372 388
373 AudioBusRefCounted::~AudioBusRefCounted() {} 389 AudioBusRefCounted::~AudioBusRefCounted() {}
374 390
375 } // namespace media 391 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698