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