OLD | NEW |
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 |
11 #include "webrtc/modules/audio_processing/audio_buffer.h" | 11 #include "webrtc/modules/audio_processing/audio_buffer.h" |
12 | 12 |
13 #include "webrtc/common_audio/include/audio_util.h" | 13 #include "webrtc/common_audio/include/audio_util.h" |
14 #include "webrtc/common_audio/resampler/push_sinc_resampler.h" | 14 #include "webrtc/common_audio/resampler/push_sinc_resampler.h" |
15 #include "webrtc/common_audio/signal_processing/include/signal_processing_librar
y.h" | 15 #include "webrtc/common_audio/signal_processing/include/signal_processing_librar
y.h" |
16 #include "webrtc/common_audio/channel_buffer.h" | 16 #include "webrtc/common_audio/channel_buffer.h" |
17 #include "webrtc/modules/audio_processing/common.h" | 17 #include "webrtc/modules/audio_processing/common.h" |
18 | 18 |
19 namespace webrtc { | 19 namespace webrtc { |
20 namespace { | 20 namespace { |
21 | 21 |
22 enum { | 22 const int kSamplesPer16kHzChannel = 160; |
23 kSamplesPer16kHzChannel = 160, | 23 const int kSamplesPer32kHzChannel = 320; |
24 kSamplesPer32kHzChannel = 320, | 24 const int kSamplesPer48kHzChannel = 480; |
25 kSamplesPer48kHzChannel = 480 | |
26 }; | |
27 | 25 |
28 bool HasKeyboardChannel(AudioProcessing::ChannelLayout layout) { | 26 bool HasKeyboardChannel(AudioProcessing::ChannelLayout layout) { |
29 switch (layout) { | 27 switch (layout) { |
30 case AudioProcessing::kMono: | 28 case AudioProcessing::kMono: |
31 case AudioProcessing::kStereo: | 29 case AudioProcessing::kStereo: |
32 return false; | 30 return false; |
33 case AudioProcessing::kMonoAndKeyboard: | 31 case AudioProcessing::kMonoAndKeyboard: |
34 case AudioProcessing::kStereoAndKeyboard: | 32 case AudioProcessing::kStereoAndKeyboard: |
35 return true; | 33 return true; |
36 } | 34 } |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 int process_num_frames, | 75 int process_num_frames, |
78 int num_process_channels, | 76 int num_process_channels, |
79 int output_num_frames) | 77 int output_num_frames) |
80 : input_num_frames_(input_num_frames), | 78 : input_num_frames_(input_num_frames), |
81 num_input_channels_(num_input_channels), | 79 num_input_channels_(num_input_channels), |
82 proc_num_frames_(process_num_frames), | 80 proc_num_frames_(process_num_frames), |
83 num_proc_channels_(num_process_channels), | 81 num_proc_channels_(num_process_channels), |
84 output_num_frames_(output_num_frames), | 82 output_num_frames_(output_num_frames), |
85 num_channels_(num_process_channels), | 83 num_channels_(num_process_channels), |
86 num_bands_(NumBandsFromSamplesPerChannel(proc_num_frames_)), | 84 num_bands_(NumBandsFromSamplesPerChannel(proc_num_frames_)), |
87 num_split_frames_(rtc::CheckedDivExact( | 85 num_split_frames_(rtc::CheckedDivExact(proc_num_frames_, num_bands_)), |
88 proc_num_frames_, num_bands_)), | |
89 mixed_low_pass_valid_(false), | 86 mixed_low_pass_valid_(false), |
90 reference_copied_(false), | 87 reference_copied_(false), |
91 activity_(AudioFrame::kVadUnknown), | 88 activity_(AudioFrame::kVadUnknown), |
92 keyboard_data_(NULL), | 89 keyboard_data_(NULL), |
93 data_(new IFChannelBuffer(proc_num_frames_, num_proc_channels_)) { | 90 data_(new IFChannelBuffer(proc_num_frames_, num_proc_channels_)) { |
94 assert(input_num_frames_ > 0); | 91 assert(input_num_frames_ > 0); |
95 assert(proc_num_frames_ > 0); | 92 assert(proc_num_frames_ > 0); |
96 assert(output_num_frames_ > 0); | 93 assert(output_num_frames_ > 0); |
97 assert(num_input_channels_ > 0 && num_input_channels_ <= 2); | 94 assert(num_input_channels_ > 0 && num_input_channels_ <= 2); |
98 assert(num_proc_channels_ > 0 && num_proc_channels_ <= num_input_channels_); | 95 assert(num_proc_channels_ > 0 && num_proc_channels_ <= num_input_channels_); |
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
392 return input_num_frames_; | 389 return input_num_frames_; |
393 } | 390 } |
394 | 391 |
395 int AudioBuffer::num_bands() const { | 392 int AudioBuffer::num_bands() const { |
396 return num_bands_; | 393 return num_bands_; |
397 } | 394 } |
398 | 395 |
399 // The resampler is only for supporting 48kHz to 16kHz in the reverse stream. | 396 // The resampler is only for supporting 48kHz to 16kHz in the reverse stream. |
400 void AudioBuffer::DeinterleaveFrom(AudioFrame* frame) { | 397 void AudioBuffer::DeinterleaveFrom(AudioFrame* frame) { |
401 assert(frame->num_channels_ == num_input_channels_); | 398 assert(frame->num_channels_ == num_input_channels_); |
402 assert(frame->samples_per_channel_ == input_num_frames_); | 399 assert(frame->samples_per_channel_ == input_num_frames_); |
403 InitForNewData(); | 400 InitForNewData(); |
404 // Initialized lazily because there's a different condition in CopyFrom. | 401 // Initialized lazily because there's a different condition in CopyFrom. |
405 if ((input_num_frames_ != proc_num_frames_) && !input_buffer_) { | 402 if ((input_num_frames_ != proc_num_frames_) && !input_buffer_) { |
406 input_buffer_.reset( | 403 input_buffer_.reset( |
407 new IFChannelBuffer(input_num_frames_, num_proc_channels_)); | 404 new IFChannelBuffer(input_num_frames_, num_proc_channels_)); |
408 } | 405 } |
409 activity_ = frame->vad_activity_; | 406 activity_ = frame->vad_activity_; |
410 | 407 |
411 int16_t* const* deinterleaved; | 408 int16_t* const* deinterleaved; |
412 if (input_num_frames_ == proc_num_frames_) { | 409 if (input_num_frames_ == proc_num_frames_) { |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
473 | 470 |
474 void AudioBuffer::SplitIntoFrequencyBands() { | 471 void AudioBuffer::SplitIntoFrequencyBands() { |
475 splitting_filter_->Analysis(data_.get(), split_data_.get()); | 472 splitting_filter_->Analysis(data_.get(), split_data_.get()); |
476 } | 473 } |
477 | 474 |
478 void AudioBuffer::MergeFrequencyBands() { | 475 void AudioBuffer::MergeFrequencyBands() { |
479 splitting_filter_->Synthesis(split_data_.get(), data_.get()); | 476 splitting_filter_->Synthesis(split_data_.get(), data_.get()); |
480 } | 477 } |
481 | 478 |
482 } // namespace webrtc | 479 } // namespace webrtc |
OLD | NEW |