Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(268)

Side by Side Diff: webrtc/modules/audio_coding/neteq/background_noise.h

Issue 1228843002: Update audio code to use size_t more correctly, (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: Review comments Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
(...skipping 11 matching lines...) Expand all
22 namespace webrtc { 22 namespace webrtc {
23 23
24 // Forward declarations. 24 // Forward declarations.
25 class PostDecodeVad; 25 class PostDecodeVad;
26 26
27 // This class handles estimation of background noise parameters. 27 // This class handles estimation of background noise parameters.
28 class BackgroundNoise { 28 class BackgroundNoise {
29 public: 29 public:
30 // TODO(hlundin): For 48 kHz support, increase kMaxLpcOrder to 10. 30 // TODO(hlundin): For 48 kHz support, increase kMaxLpcOrder to 10.
31 // Will work anyway, but probably sound a little worse. 31 // Will work anyway, but probably sound a little worse.
32 static const int kMaxLpcOrder = 8; // 32000 / 8000 + 4. 32 static const size_t kMaxLpcOrder = 8; // 32000 / 8000 + 4.
33 33
34 explicit BackgroundNoise(size_t num_channels); 34 explicit BackgroundNoise(size_t num_channels);
35 virtual ~BackgroundNoise(); 35 virtual ~BackgroundNoise();
36 36
37 void Reset(); 37 void Reset();
38 38
39 // Updates the parameter estimates based on the signal currently in the 39 // Updates the parameter estimates based on the signal currently in the
40 // |sync_buffer|, and on the latest decision in |vad| if it is running. 40 // |sync_buffer|, and on the latest decision in |vad| if it is running.
41 void Update(const AudioMultiVector& sync_buffer, 41 void Update(const AudioMultiVector& sync_buffer,
42 const PostDecodeVad& vad); 42 const PostDecodeVad& vad);
(...skipping 26 matching lines...) Expand all
69 // Accessors. 69 // Accessors.
70 bool initialized() const { return initialized_; } 70 bool initialized() const { return initialized_; }
71 NetEq::BackgroundNoiseMode mode() const { return mode_; } 71 NetEq::BackgroundNoiseMode mode() const { return mode_; }
72 72
73 // Sets the mode of the background noise playout for cases when there is long 73 // Sets the mode of the background noise playout for cases when there is long
74 // duration of packet loss. 74 // duration of packet loss.
75 void set_mode(NetEq::BackgroundNoiseMode mode) { mode_ = mode; } 75 void set_mode(NetEq::BackgroundNoiseMode mode) { mode_ = mode; }
76 76
77 private: 77 private:
78 static const int kThresholdIncrement = 229; // 0.0035 in Q16. 78 static const int kThresholdIncrement = 229; // 0.0035 in Q16.
79 static const int kVecLen = 256; 79 static const size_t kVecLen = 256;
80 static const int kLogVecLen = 8; // log2(kVecLen). 80 static const int kLogVecLen = 8; // log2(kVecLen).
81 static const int kResidualLength = 64; 81 static const size_t kResidualLength = 64;
82 static const int16_t kLogResidualLength = 6; // log2(kResidualLength) 82 static const int16_t kLogResidualLength = 6; // log2(kResidualLength)
83 83
84 struct ChannelParameters { 84 struct ChannelParameters {
85 // Constructor. 85 // Constructor.
86 ChannelParameters() { 86 ChannelParameters() {
87 Reset(); 87 Reset();
88 } 88 }
89 89
90 void Reset() { 90 void Reset() {
91 energy = 2500; 91 energy = 2500;
(...skipping 13 matching lines...) Expand all
105 int32_t energy_update_threshold; 105 int32_t energy_update_threshold;
106 int32_t low_energy_update_threshold; 106 int32_t low_energy_update_threshold;
107 int16_t filter_state[kMaxLpcOrder]; 107 int16_t filter_state[kMaxLpcOrder];
108 int16_t filter[kMaxLpcOrder + 1]; 108 int16_t filter[kMaxLpcOrder + 1];
109 int16_t mute_factor; 109 int16_t mute_factor;
110 int16_t scale; 110 int16_t scale;
111 int16_t scale_shift; 111 int16_t scale_shift;
112 }; 112 };
113 113
114 int32_t CalculateAutoCorrelation(const int16_t* signal, 114 int32_t CalculateAutoCorrelation(const int16_t* signal,
115 int length, 115 size_t length,
116 int32_t* auto_correlation) const; 116 int32_t* auto_correlation) const;
117 117
118 // Increments the energy threshold by a factor 1 + |kThresholdIncrement|. 118 // Increments the energy threshold by a factor 1 + |kThresholdIncrement|.
119 void IncrementEnergyThreshold(size_t channel, int32_t sample_energy); 119 void IncrementEnergyThreshold(size_t channel, int32_t sample_energy);
120 120
121 // Updates the filter parameters. 121 // Updates the filter parameters.
122 void SaveParameters(size_t channel, 122 void SaveParameters(size_t channel,
123 const int16_t* lpc_coefficients, 123 const int16_t* lpc_coefficients,
124 const int16_t* filter_state, 124 const int16_t* filter_state,
125 int32_t sample_energy, 125 int32_t sample_energy,
126 int32_t residual_energy); 126 int32_t residual_energy);
127 127
128 size_t num_channels_; 128 size_t num_channels_;
129 rtc::scoped_ptr<ChannelParameters[]> channel_parameters_; 129 rtc::scoped_ptr<ChannelParameters[]> channel_parameters_;
130 bool initialized_; 130 bool initialized_;
131 NetEq::BackgroundNoiseMode mode_; 131 NetEq::BackgroundNoiseMode mode_;
132 132
133 DISALLOW_COPY_AND_ASSIGN(BackgroundNoise); 133 DISALLOW_COPY_AND_ASSIGN(BackgroundNoise);
134 }; 134 };
135 135
136 } // namespace webrtc 136 } // namespace webrtc
137 #endif // WEBRTC_MODULES_AUDIO_CODING_NETEQ_BACKGROUND_NOISE_H_ 137 #endif // WEBRTC_MODULES_AUDIO_CODING_NETEQ_BACKGROUND_NOISE_H_
OLDNEW
« no previous file with comments | « webrtc/modules/audio_coding/neteq/audio_decoder_unittest.cc ('k') | webrtc/modules/audio_coding/neteq/background_noise.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698