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

Side by Side Diff: webrtc/modules/audio_processing/audio_buffer.cc

Issue 2741733002: Make AudioBuffer::InterleaveTo const (Closed)
Patch Set: Make InterleaveTo const Created 3 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
« no previous file with comments | « webrtc/modules/audio_processing/audio_buffer.h ('k') | no next file » | 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) 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2012 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
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 proc_num_frames_(process_num_frames), 54 proc_num_frames_(process_num_frames),
55 num_proc_channels_(num_process_channels), 55 num_proc_channels_(num_process_channels),
56 output_num_frames_(output_num_frames), 56 output_num_frames_(output_num_frames),
57 num_channels_(num_process_channels), 57 num_channels_(num_process_channels),
58 num_bands_(NumBandsFromSamplesPerChannel(proc_num_frames_)), 58 num_bands_(NumBandsFromSamplesPerChannel(proc_num_frames_)),
59 num_split_frames_(rtc::CheckedDivExact(proc_num_frames_, num_bands_)), 59 num_split_frames_(rtc::CheckedDivExact(proc_num_frames_, num_bands_)),
60 mixed_low_pass_valid_(false), 60 mixed_low_pass_valid_(false),
61 reference_copied_(false), 61 reference_copied_(false),
62 activity_(AudioFrame::kVadUnknown), 62 activity_(AudioFrame::kVadUnknown),
63 keyboard_data_(NULL), 63 keyboard_data_(NULL),
64 data_(new IFChannelBuffer(proc_num_frames_, num_proc_channels_)) { 64 data_(new IFChannelBuffer(proc_num_frames_, num_proc_channels_)),
65 output_buffer_(new IFChannelBuffer(output_num_frames_, num_channels_)) {
65 RTC_DCHECK_GT(input_num_frames_, 0); 66 RTC_DCHECK_GT(input_num_frames_, 0);
66 RTC_DCHECK_GT(proc_num_frames_, 0); 67 RTC_DCHECK_GT(proc_num_frames_, 0);
67 RTC_DCHECK_GT(output_num_frames_, 0); 68 RTC_DCHECK_GT(output_num_frames_, 0);
68 RTC_DCHECK_GT(num_input_channels_, 0); 69 RTC_DCHECK_GT(num_input_channels_, 0);
69 RTC_DCHECK_GT(num_proc_channels_, 0); 70 RTC_DCHECK_GT(num_proc_channels_, 0);
70 RTC_DCHECK_LE(num_proc_channels_, num_input_channels_); 71 RTC_DCHECK_LE(num_proc_channels_, num_input_channels_);
71 72
72 if (input_num_frames_ != proc_num_frames_ || 73 if (input_num_frames_ != proc_num_frames_ ||
73 output_num_frames_ != proc_num_frames_) { 74 output_num_frames_ != proc_num_frames_) {
74 // Create an intermediate buffer for resampling. 75 // Create an intermediate buffer for resampling.
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after
409 if (input_num_frames_ != proc_num_frames_) { 410 if (input_num_frames_ != proc_num_frames_) {
410 for (size_t i = 0; i < num_proc_channels_; ++i) { 411 for (size_t i = 0; i < num_proc_channels_; ++i) {
411 input_resamplers_[i]->Resample(input_buffer_->fbuf_const()->channels()[i], 412 input_resamplers_[i]->Resample(input_buffer_->fbuf_const()->channels()[i],
412 input_num_frames_, 413 input_num_frames_,
413 data_->fbuf()->channels()[i], 414 data_->fbuf()->channels()[i],
414 proc_num_frames_); 415 proc_num_frames_);
415 } 416 }
416 } 417 }
417 } 418 }
418 419
419 void AudioBuffer::InterleaveTo(AudioFrame* frame, bool data_changed) { 420 void AudioBuffer::InterleaveTo(AudioFrame* frame, bool data_changed) const {
420 frame->vad_activity_ = activity_; 421 frame->vad_activity_ = activity_;
421 if (!data_changed) { 422 if (!data_changed) {
422 return; 423 return;
423 } 424 }
424 425
425 RTC_DCHECK(frame->num_channels_ == num_channels_ || num_channels_ == 1); 426 RTC_DCHECK(frame->num_channels_ == num_channels_ || num_channels_ == 1);
426 RTC_DCHECK_EQ(frame->samples_per_channel_, output_num_frames_); 427 RTC_DCHECK_EQ(frame->samples_per_channel_, output_num_frames_);
427 428
428 // Resample if necessary. 429 // Resample if necessary.
429 IFChannelBuffer* data_ptr = data_.get(); 430 IFChannelBuffer* data_ptr = data_.get();
430 if (proc_num_frames_ != output_num_frames_) { 431 if (proc_num_frames_ != output_num_frames_) {
431 if (!output_buffer_) {
432 output_buffer_.reset(
433 new IFChannelBuffer(output_num_frames_, num_channels_));
434 }
435 for (size_t i = 0; i < num_channels_; ++i) { 432 for (size_t i = 0; i < num_channels_; ++i) {
436 output_resamplers_[i]->Resample( 433 output_resamplers_[i]->Resample(
437 data_->fbuf()->channels()[i], proc_num_frames_, 434 data_->fbuf()->channels()[i], proc_num_frames_,
438 output_buffer_->fbuf()->channels()[i], output_num_frames_); 435 output_buffer_->fbuf()->channels()[i], output_num_frames_);
439 } 436 }
440 data_ptr = output_buffer_.get(); 437 data_ptr = output_buffer_.get();
441 } 438 }
442 439
443 if (frame->num_channels_ == num_channels_) { 440 if (frame->num_channels_ == num_channels_) {
444 Interleave(data_ptr->ibuf()->channels(), output_num_frames_, num_channels_, 441 Interleave(data_ptr->ibuf()->channels(), output_num_frames_, num_channels_,
(...skipping 22 matching lines...) Expand all
467 464
468 void AudioBuffer::SplitIntoFrequencyBands() { 465 void AudioBuffer::SplitIntoFrequencyBands() {
469 splitting_filter_->Analysis(data_.get(), split_data_.get()); 466 splitting_filter_->Analysis(data_.get(), split_data_.get());
470 } 467 }
471 468
472 void AudioBuffer::MergeFrequencyBands() { 469 void AudioBuffer::MergeFrequencyBands() {
473 splitting_filter_->Synthesis(split_data_.get(), data_.get()); 470 splitting_filter_->Synthesis(split_data_.get(), data_.get());
474 } 471 }
475 472
476 } // namespace webrtc 473 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/audio_processing/audio_buffer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698