OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2013 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/transient/transient_suppressor.h" | 11 #include "webrtc/modules/audio_processing/transient/transient_suppressor.h" |
12 | 12 |
13 #include <math.h> | 13 #include <math.h> |
14 #include <string.h> | 14 #include <string.h> |
15 #include <cmath> | 15 #include <cmath> |
16 #include <complex> | 16 #include <complex> |
17 #include <deque> | 17 #include <deque> |
18 #include <set> | 18 #include <set> |
19 | 19 |
20 #include "webrtc/base/checks.h" | |
21 #include "webrtc/common_audio/fft4g.h" | 20 #include "webrtc/common_audio/fft4g.h" |
22 #include "webrtc/common_audio/include/audio_util.h" | 21 #include "webrtc/common_audio/include/audio_util.h" |
23 #include "webrtc/common_audio/signal_processing/include/signal_processing_librar
y.h" | 22 #include "webrtc/common_audio/signal_processing/include/signal_processing_librar
y.h" |
24 #include "webrtc/modules/audio_processing/transient/common.h" | 23 #include "webrtc/modules/audio_processing/transient/common.h" |
25 #include "webrtc/modules/audio_processing/transient/transient_detector.h" | 24 #include "webrtc/modules/audio_processing/transient/transient_detector.h" |
26 #include "webrtc/modules/audio_processing/ns/windows_private.h" | 25 #include "webrtc/modules/audio_processing/ns/windows_private.h" |
27 #include "webrtc/system_wrappers/include/logging.h" | 26 #include "webrtc/system_wrappers/include/logging.h" |
28 #include "webrtc/typedefs.h" | 27 #include "webrtc/typedefs.h" |
29 | 28 |
30 namespace webrtc { | 29 namespace webrtc { |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 detection_rate_hz != ts::kSampleRate48kHz) { | 93 detection_rate_hz != ts::kSampleRate48kHz) { |
95 return -1; | 94 return -1; |
96 } | 95 } |
97 if (num_channels <= 0) { | 96 if (num_channels <= 0) { |
98 return -1; | 97 return -1; |
99 } | 98 } |
100 | 99 |
101 detector_.reset(new TransientDetector(detection_rate_hz)); | 100 detector_.reset(new TransientDetector(detection_rate_hz)); |
102 data_length_ = sample_rate_hz * ts::kChunkSizeMs / 1000; | 101 data_length_ = sample_rate_hz * ts::kChunkSizeMs / 1000; |
103 if (data_length_ > analysis_length_) { | 102 if (data_length_ > analysis_length_) { |
104 RTC_NOTREACHED(); | 103 assert(false); |
105 return -1; | 104 return -1; |
106 } | 105 } |
107 buffer_delay_ = analysis_length_ - data_length_; | 106 buffer_delay_ = analysis_length_ - data_length_; |
108 | 107 |
109 complex_analysis_length_ = analysis_length_ / 2 + 1; | 108 complex_analysis_length_ = analysis_length_ / 2 + 1; |
110 RTC_DCHECK_GE(complex_analysis_length_, kMaxVoiceBin); | 109 assert(complex_analysis_length_ >= kMaxVoiceBin); |
111 num_channels_ = num_channels; | 110 num_channels_ = num_channels; |
112 in_buffer_.reset(new float[analysis_length_ * num_channels_]); | 111 in_buffer_.reset(new float[analysis_length_ * num_channels_]); |
113 memset(in_buffer_.get(), | 112 memset(in_buffer_.get(), |
114 0, | 113 0, |
115 analysis_length_ * num_channels_ * sizeof(in_buffer_[0])); | 114 analysis_length_ * num_channels_ * sizeof(in_buffer_[0])); |
116 detection_length_ = detection_rate_hz * ts::kChunkSizeMs / 1000; | 115 detection_length_ = detection_rate_hz * ts::kChunkSizeMs / 1000; |
117 detection_buffer_.reset(new float[detection_length_]); | 116 detection_buffer_.reset(new float[detection_length_]); |
118 memset(detection_buffer_.get(), | 117 memset(detection_buffer_.get(), |
119 0, | 118 0, |
120 detection_length_ * sizeof(detection_buffer_[0])); | 119 detection_length_ * sizeof(detection_buffer_[0])); |
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
415 const float magnitude_ratio = new_magnitude / magnitudes_[i]; | 414 const float magnitude_ratio = new_magnitude / magnitudes_[i]; |
416 | 415 |
417 fft_buffer_[i * 2] *= magnitude_ratio; | 416 fft_buffer_[i * 2] *= magnitude_ratio; |
418 fft_buffer_[i * 2 + 1] *= magnitude_ratio; | 417 fft_buffer_[i * 2 + 1] *= magnitude_ratio; |
419 magnitudes_[i] = new_magnitude; | 418 magnitudes_[i] = new_magnitude; |
420 } | 419 } |
421 } | 420 } |
422 } | 421 } |
423 | 422 |
424 } // namespace webrtc | 423 } // namespace webrtc |
OLD | NEW |