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

Unified Diff: webrtc/common_audio/vad/vad_filterbank.c

Issue 1230503003: Update a ton of audio code to use size_t more correctly and in general reduce (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: Resync 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webrtc/common_audio/vad/vad_filterbank.h ('k') | webrtc/common_audio/vad/vad_filterbank_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/common_audio/vad/vad_filterbank.c
diff --git a/webrtc/common_audio/vad/vad_filterbank.c b/webrtc/common_audio/vad/vad_filterbank.c
index 4094f91b1a53f06a39ff90648247f32360fe57d0..8b9df93b00c791296941117d3b594f4af4bec7a6 100644
--- a/webrtc/common_audio/vad/vad_filterbank.c
+++ b/webrtc/common_audio/vad/vad_filterbank.c
@@ -38,9 +38,9 @@ static const int16_t kOffsetVector[6] = { 368, 368, 272, 176, 176, 176 };
// - filter_state [i/o] : State of the filter.
// - data_out [o] : Output audio data in the frequency interval
// 80 - 250 Hz.
-static void HighPassFilter(const int16_t* data_in, int data_length,
+static void HighPassFilter(const int16_t* data_in, size_t data_length,
int16_t* filter_state, int16_t* data_out) {
- int i;
+ size_t i;
const int16_t* in_ptr = data_in;
int16_t* out_ptr = data_out;
int32_t tmp32 = 0;
@@ -80,7 +80,7 @@ static void HighPassFilter(const int16_t* data_in, int data_length,
// - filter_coefficient [i] : Given in Q15.
// - filter_state [i/o] : State of the filter given in Q(-1).
// - data_out [o] : Output audio signal given in Q(-1).
-static void AllPassFilter(const int16_t* data_in, int data_length,
+static void AllPassFilter(const int16_t* data_in, size_t data_length,
int16_t filter_coefficient, int16_t* filter_state,
int16_t* data_out) {
// The filter can only cause overflow (in the w16 output variable)
@@ -89,7 +89,7 @@ static void AllPassFilter(const int16_t* data_in, int data_length,
// First 6 taps of the impulse response:
// 0.6399 0.5905 -0.3779 0.2418 -0.1547 0.0990
- int i;
+ size_t i;
int16_t tmp16 = 0;
int32_t tmp32 = 0;
int32_t state32 = ((int32_t) (*filter_state) << 16); // Q15
@@ -117,11 +117,11 @@ static void AllPassFilter(const int16_t* data_in, int data_length,
// The length is |data_length| / 2.
// - lp_data_out [o] : Output audio data of the lower half of the spectrum.
// The length is |data_length| / 2.
-static void SplitFilter(const int16_t* data_in, int data_length,
+static void SplitFilter(const int16_t* data_in, size_t data_length,
int16_t* upper_state, int16_t* lower_state,
int16_t* hp_data_out, int16_t* lp_data_out) {
- int i;
- int half_length = data_length >> 1; // Downsampling by 2.
+ size_t i;
+ size_t half_length = data_length >> 1; // Downsampling by 2.
int16_t tmp_out;
// All-pass filtering upper branch.
@@ -151,7 +151,7 @@ static void SplitFilter(const int16_t* data_in, int data_length,
// NOTE: |total_energy| is only updated if
// |total_energy| <= |kMinEnergy|.
// - log_energy [o] : 10 * log10("energy of |data_in|") given in Q4.
-static void LogOfEnergy(const int16_t* data_in, int data_length,
+static void LogOfEnergy(const int16_t* data_in, size_t data_length,
int16_t offset, int16_t* total_energy,
int16_t* log_energy) {
// |tot_rshifts| accumulates the number of right shifts performed on |energy|.
@@ -243,7 +243,7 @@ static void LogOfEnergy(const int16_t* data_in, int data_length,
}
int16_t WebRtcVad_CalculateFeatures(VadInstT* self, const int16_t* data_in,
- int data_length, int16_t* features) {
+ size_t data_length, int16_t* features) {
int16_t total_energy = 0;
// We expect |data_length| to be 80, 160 or 240 samples, which corresponds to
// 10, 20 or 30 ms in 8 kHz. Therefore, the intermediate downsampled data will
@@ -251,9 +251,9 @@ int16_t WebRtcVad_CalculateFeatures(VadInstT* self, const int16_t* data_in,
// the second split.
int16_t hp_120[120], lp_120[120];
int16_t hp_60[60], lp_60[60];
- const int half_data_length = data_length >> 1;
- int length = half_data_length; // |data_length| / 2, corresponds to
- // bandwidth = 2000 Hz after downsampling.
+ const size_t half_data_length = data_length >> 1;
+ size_t length = half_data_length; // |data_length| / 2, corresponds to
+ // bandwidth = 2000 Hz after downsampling.
// Initialize variables for the first SplitFilter().
int frequency_band = 0;
@@ -261,7 +261,6 @@ int16_t WebRtcVad_CalculateFeatures(VadInstT* self, const int16_t* data_in,
int16_t* hp_out_ptr = hp_120; // [2000 - 4000] Hz.
int16_t* lp_out_ptr = lp_120; // [0 - 2000] Hz.
- assert(data_length >= 0);
assert(data_length <= 240);
assert(4 < kNumChannels - 1); // Checking maximum |frequency_band|.
« no previous file with comments | « webrtc/common_audio/vad/vad_filterbank.h ('k') | webrtc/common_audio/vad/vad_filterbank_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698