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 #ifndef WEBRTC_MODULES_AUDIO_CODING_NETEQ_EXPAND_H_ | 11 #ifndef WEBRTC_MODULES_AUDIO_CODING_NETEQ_EXPAND_H_ |
12 #define WEBRTC_MODULES_AUDIO_CODING_NETEQ_EXPAND_H_ | 12 #define WEBRTC_MODULES_AUDIO_CODING_NETEQ_EXPAND_H_ |
13 | 13 |
14 #include <assert.h> | 14 #include <assert.h> |
15 | 15 |
16 #include "webrtc/base/constructormagic.h" | 16 #include "webrtc/base/constructormagic.h" |
17 #include "webrtc/base/scoped_ptr.h" | 17 #include "webrtc/base/scoped_ptr.h" |
18 #include "webrtc/modules/audio_coding/neteq/audio_multi_vector.h" | 18 #include "webrtc/modules/audio_coding/neteq/audio_multi_vector.h" |
19 #include "webrtc/typedefs.h" | 19 #include "webrtc/typedefs.h" |
20 | 20 |
21 namespace webrtc { | 21 namespace webrtc { |
22 | 22 |
23 // Forward declarations. | 23 // Forward declarations. |
24 class BackgroundNoise; | 24 class BackgroundNoise; |
25 class RandomVector; | 25 class RandomVector; |
| 26 class StatisticsCalculator; |
26 class SyncBuffer; | 27 class SyncBuffer; |
27 | 28 |
28 // This class handles extrapolation of audio data from the sync_buffer to | 29 // This class handles extrapolation of audio data from the sync_buffer to |
29 // produce packet-loss concealment. | 30 // produce packet-loss concealment. |
30 // TODO(hlundin): Refactor this class to divide the long methods into shorter | 31 // TODO(hlundin): Refactor this class to divide the long methods into shorter |
31 // ones. | 32 // ones. |
32 class Expand { | 33 class Expand { |
33 public: | 34 public: |
34 Expand(BackgroundNoise* background_noise, | 35 Expand(BackgroundNoise* background_noise, |
35 SyncBuffer* sync_buffer, | 36 SyncBuffer* sync_buffer, |
36 RandomVector* random_vector, | 37 RandomVector* random_vector, |
| 38 StatisticsCalculator* statistics, |
37 int fs, | 39 int fs, |
38 size_t num_channels); | 40 size_t num_channels); |
39 | 41 |
40 virtual ~Expand(); | 42 virtual ~Expand(); |
41 | 43 |
42 // Resets the object. | 44 // Resets the object. |
43 virtual void Reset(); | 45 virtual void Reset(); |
44 | 46 |
45 // The main method to produce concealment data. The data is appended to the | 47 // The main method to produce concealment data. The data is appended to the |
46 // end of |output|. | 48 // end of |output|. |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 | 81 |
80 // Initializes member variables at the beginning of an expand period. | 82 // Initializes member variables at the beginning of an expand period. |
81 void InitializeForAnExpandPeriod(); | 83 void InitializeForAnExpandPeriod(); |
82 | 84 |
83 bool TooManyExpands(); | 85 bool TooManyExpands(); |
84 | 86 |
85 // Analyzes the signal history in |sync_buffer_|, and set up all parameters | 87 // Analyzes the signal history in |sync_buffer_|, and set up all parameters |
86 // necessary to produce concealment data. | 88 // necessary to produce concealment data. |
87 void AnalyzeSignal(int16_t* random_vector); | 89 void AnalyzeSignal(int16_t* random_vector); |
88 | 90 |
89 RandomVector* random_vector_; | 91 RandomVector* const random_vector_; |
90 SyncBuffer* sync_buffer_; | 92 SyncBuffer* const sync_buffer_; |
91 bool first_expand_; | 93 bool first_expand_; |
92 const int fs_hz_; | 94 const int fs_hz_; |
93 const size_t num_channels_; | 95 const size_t num_channels_; |
94 int consecutive_expands_; | 96 int consecutive_expands_; |
95 | 97 |
96 private: | 98 private: |
97 static const int kUnvoicedLpcOrder = 6; | 99 static const int kUnvoicedLpcOrder = 6; |
98 static const int kNumCorrelationCandidates = 3; | 100 static const int kNumCorrelationCandidates = 3; |
99 static const int kDistortionLength = 20; | 101 static const int kDistortionLength = 20; |
100 static const int kLpcAnalysisLength = 160; | 102 static const int kLpcAnalysisLength = 160; |
(...skipping 19 matching lines...) Expand all Loading... |
120 // samples. The correlation is calculated from a downsampled version of | 122 // samples. The correlation is calculated from a downsampled version of |
121 // |input|, and is written to |output|. The scale factor is written to | 123 // |input|, and is written to |output|. The scale factor is written to |
122 // |output_scale|. | 124 // |output_scale|. |
123 void Correlation(const int16_t* input, | 125 void Correlation(const int16_t* input, |
124 size_t input_length, | 126 size_t input_length, |
125 int16_t* output, | 127 int16_t* output, |
126 int* output_scale) const; | 128 int* output_scale) const; |
127 | 129 |
128 void UpdateLagIndex(); | 130 void UpdateLagIndex(); |
129 | 131 |
130 BackgroundNoise* background_noise_; | 132 BackgroundNoise* const background_noise_; |
| 133 StatisticsCalculator* const statistics_; |
131 const size_t overlap_length_; | 134 const size_t overlap_length_; |
132 int16_t max_lag_; | 135 int16_t max_lag_; |
133 size_t expand_lags_[kNumLags]; | 136 size_t expand_lags_[kNumLags]; |
134 int lag_index_direction_; | 137 int lag_index_direction_; |
135 int current_lag_index_; | 138 int current_lag_index_; |
136 bool stop_muting_; | 139 bool stop_muting_; |
| 140 size_t expand_duration_samples_; |
137 rtc::scoped_ptr<ChannelParameters[]> channel_parameters_; | 141 rtc::scoped_ptr<ChannelParameters[]> channel_parameters_; |
138 | 142 |
139 DISALLOW_COPY_AND_ASSIGN(Expand); | 143 DISALLOW_COPY_AND_ASSIGN(Expand); |
140 }; | 144 }; |
141 | 145 |
142 struct ExpandFactory { | 146 struct ExpandFactory { |
143 ExpandFactory() {} | 147 ExpandFactory() {} |
144 virtual ~ExpandFactory() {} | 148 virtual ~ExpandFactory() {} |
145 | 149 |
146 virtual Expand* Create(BackgroundNoise* background_noise, | 150 virtual Expand* Create(BackgroundNoise* background_noise, |
147 SyncBuffer* sync_buffer, | 151 SyncBuffer* sync_buffer, |
148 RandomVector* random_vector, | 152 RandomVector* random_vector, |
| 153 StatisticsCalculator* statistics, |
149 int fs, | 154 int fs, |
150 size_t num_channels) const; | 155 size_t num_channels) const; |
151 }; | 156 }; |
152 | 157 |
153 } // namespace webrtc | 158 } // namespace webrtc |
154 #endif // WEBRTC_MODULES_AUDIO_CODING_NETEQ_EXPAND_H_ | 159 #endif // WEBRTC_MODULES_AUDIO_CODING_NETEQ_EXPAND_H_ |
OLD | NEW |