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

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, 9 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 void AudioBus::ToInterleavedFloat(int source_offset,
301 int destination_offset,
302 int num_samples,
303 int num_channels,
304 float* buffer) const {
mcasas 2016/03/09 00:24:18 DCHECK_EQ(num_channels, channels()); ? Also chec
305 for (int ch = 0; ch < this->channels(); ++ch) {
mcasas 2016/03/09 00:24:18 No |this|.
eklavyamirani 2016/03/15 03:48:13 Done.
306 const float* src = this->channel(ch) + source_offset;
307 const float* const src_end = src + num_samples;
308 float* dest = buffer + destination_offset + ch;
309 for (; src < src_end; ++src, dest += num_channels)
310 *dest = *src;
311 }
312 }
313
300 // TODO(dalecurtis): See if intrinsic optimizations help any here. 314 // TODO(dalecurtis): See if intrinsic optimizations help any here.
301 void AudioBus::ToInterleavedPartial(int start_frame, int frames, 315 void AudioBus::ToInterleavedPartial(int start_frame, int frames,
302 int bytes_per_sample, void* dest) const { 316 int bytes_per_sample, void* dest) const {
303 CheckOverflow(start_frame, frames, frames_); 317 CheckOverflow(start_frame, frames, frames_);
304 switch (bytes_per_sample) { 318 switch (bytes_per_sample) {
305 case 1: 319 case 1:
306 ToInterleavedInternal<uint8_t, int16_t, kUint8Bias>( 320 ToInterleavedInternal<uint8_t, int16_t, kUint8Bias>(
307 this, start_frame, frames, dest, std::numeric_limits<int8_t>::min(), 321 this, start_frame, frames, dest, std::numeric_limits<int8_t>::min(),
308 std::numeric_limits<int8_t>::max()); 322 std::numeric_limits<int8_t>::max());
309 break; 323 break;
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 return scoped_refptr<AudioBusRefCounted>( 380 return scoped_refptr<AudioBusRefCounted>(
367 new AudioBusRefCounted(channels, frames)); 381 new AudioBusRefCounted(channels, frames));
368 } 382 }
369 383
370 AudioBusRefCounted::AudioBusRefCounted(int channels, int frames) 384 AudioBusRefCounted::AudioBusRefCounted(int channels, int frames)
371 : AudioBus(channels, frames) {} 385 : AudioBus(channels, frames) {}
372 386
373 AudioBusRefCounted::~AudioBusRefCounted() {} 387 AudioBusRefCounted::~AudioBusRefCounted() {}
374 388
375 } // namespace media 389 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698