| 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 #ifndef WEBRTC_MODULES_AUDIO_PROCESSING_TRANSIENT_TRANSIENT_DETECTOR_H_ | 11 #ifndef WEBRTC_MODULES_AUDIO_PROCESSING_TRANSIENT_TRANSIENT_DETECTOR_H_ |
| 12 #define WEBRTC_MODULES_AUDIO_PROCESSING_TRANSIENT_TRANSIENT_DETECTOR_H_ | 12 #define WEBRTC_MODULES_AUDIO_PROCESSING_TRANSIENT_TRANSIENT_DETECTOR_H_ |
| 13 | 13 |
| 14 #include <deque> | 14 #include <deque> |
| 15 #include <memory> |
| 15 | 16 |
| 16 #include "webrtc/base/scoped_ptr.h" | |
| 17 #include "webrtc/modules/audio_processing/transient/moving_moments.h" | 17 #include "webrtc/modules/audio_processing/transient/moving_moments.h" |
| 18 #include "webrtc/modules/audio_processing/transient/wpd_tree.h" | 18 #include "webrtc/modules/audio_processing/transient/wpd_tree.h" |
| 19 | 19 |
| 20 namespace webrtc { | 20 namespace webrtc { |
| 21 | 21 |
| 22 // This is an implementation of the transient detector described in "Causal | 22 // This is an implementation of the transient detector described in "Causal |
| 23 // Wavelet based transient detector". | 23 // Wavelet based transient detector". |
| 24 // Calculates the log-likelihood of a transient to happen on a signal at any | 24 // Calculates the log-likelihood of a transient to happen on a signal at any |
| 25 // given time based on the previous samples; it uses a WPD tree to analyze the | 25 // given time based on the previous samples; it uses a WPD tree to analyze the |
| 26 // signal. It preserves its state, so it can be multiple-called. | 26 // signal. It preserves its state, so it can be multiple-called. |
| (...skipping 21 matching lines...) Expand all Loading... |
| 48 bool using_reference() { return using_reference_; } | 48 bool using_reference() { return using_reference_; } |
| 49 | 49 |
| 50 private: | 50 private: |
| 51 float ReferenceDetectionValue(const float* data, size_t length); | 51 float ReferenceDetectionValue(const float* data, size_t length); |
| 52 | 52 |
| 53 static const size_t kLevels = 3; | 53 static const size_t kLevels = 3; |
| 54 static const size_t kLeaves = 1 << kLevels; | 54 static const size_t kLeaves = 1 << kLevels; |
| 55 | 55 |
| 56 size_t samples_per_chunk_; | 56 size_t samples_per_chunk_; |
| 57 | 57 |
| 58 rtc::scoped_ptr<WPDTree> wpd_tree_; | 58 std::unique_ptr<WPDTree> wpd_tree_; |
| 59 size_t tree_leaves_data_length_; | 59 size_t tree_leaves_data_length_; |
| 60 | 60 |
| 61 // A MovingMoments object is needed for each leaf in the WPD tree. | 61 // A MovingMoments object is needed for each leaf in the WPD tree. |
| 62 rtc::scoped_ptr<MovingMoments> moving_moments_[kLeaves]; | 62 std::unique_ptr<MovingMoments> moving_moments_[kLeaves]; |
| 63 | 63 |
| 64 rtc::scoped_ptr<float[]> first_moments_; | 64 std::unique_ptr<float[]> first_moments_; |
| 65 rtc::scoped_ptr<float[]> second_moments_; | 65 std::unique_ptr<float[]> second_moments_; |
| 66 | 66 |
| 67 // Stores the last calculated moments from the previous detection. | 67 // Stores the last calculated moments from the previous detection. |
| 68 float last_first_moment_[kLeaves]; | 68 float last_first_moment_[kLeaves]; |
| 69 float last_second_moment_[kLeaves]; | 69 float last_second_moment_[kLeaves]; |
| 70 | 70 |
| 71 // We keep track of the previous results from the previous chunks, so it can | 71 // We keep track of the previous results from the previous chunks, so it can |
| 72 // be used to effectively give results according to the |transient_length|. | 72 // be used to effectively give results according to the |transient_length|. |
| 73 std::deque<float> previous_results_; | 73 std::deque<float> previous_results_; |
| 74 | 74 |
| 75 // Number of chunks that are going to return only zeros at the beginning of | 75 // Number of chunks that are going to return only zeros at the beginning of |
| 76 // the detection. It helps to avoid infs and nans due to the lack of | 76 // the detection. It helps to avoid infs and nans due to the lack of |
| 77 // information. | 77 // information. |
| 78 int chunks_at_startup_left_to_delete_; | 78 int chunks_at_startup_left_to_delete_; |
| 79 | 79 |
| 80 float reference_energy_; | 80 float reference_energy_; |
| 81 | 81 |
| 82 bool using_reference_; | 82 bool using_reference_; |
| 83 }; | 83 }; |
| 84 | 84 |
| 85 } // namespace webrtc | 85 } // namespace webrtc |
| 86 | 86 |
| 87 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_TRANSIENT_TRANSIENT_DETECTOR_H_ | 87 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_TRANSIENT_TRANSIENT_DETECTOR_H_ |
| OLD | NEW |