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

Unified Diff: webrtc/modules/audio_processing/vad/pole_zero_filter.cc

Issue 1228803003: Update audio code to use size_t more correctly, (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: Resync Created 5 years, 5 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
Index: webrtc/modules/audio_processing/vad/pole_zero_filter.cc
diff --git a/webrtc/modules/audio_processing/vad/pole_zero_filter.cc b/webrtc/modules/audio_processing/vad/pole_zero_filter.cc
index 84d0739d8c146f0c4a90eb5ff218abe003f86080..788a87da3a718dc14c93ffe0590aa49c2e02305a 100644
--- a/webrtc/modules/audio_processing/vad/pole_zero_filter.cc
+++ b/webrtc/modules/audio_processing/vad/pole_zero_filter.cc
@@ -25,14 +25,16 @@ PoleZeroFilter* PoleZeroFilter::Create(const float* numerator_coefficients,
order_denominator > kMaxFilterOrder || denominator_coefficients[0] == 0 ||
numerator_coefficients == NULL || denominator_coefficients == NULL)
return NULL;
- return new PoleZeroFilter(numerator_coefficients, order_numerator,
- denominator_coefficients, order_denominator);
+ return new PoleZeroFilter(numerator_coefficients,
+ static_cast<size_t>(order_numerator),
aluebs-webrtc 2015/07/17 01:04:42 I guess that changing the interface of PoleZeroFil
Peter Kasting 2015/07/17 18:57:40 Actually that change is easy, and I'm not sure why
aluebs-webrtc 2015/07/17 23:16:58 Awesome! :)
+ denominator_coefficients,
+ static_cast<size_t>(order_denominator));
}
PoleZeroFilter::PoleZeroFilter(const float* numerator_coefficients,
- int order_numerator,
+ size_t order_numerator,
const float* denominator_coefficients,
- int order_denominator)
+ size_t order_denominator)
: past_input_(),
past_output_(),
numerator_coefficients_(),
@@ -46,30 +48,31 @@ PoleZeroFilter::PoleZeroFilter(const float* numerator_coefficients,
sizeof(denominator_coefficients_[0]) * (order_denominator_ + 1));
if (denominator_coefficients_[0] != 1) {
- for (int n = 0; n <= order_numerator_; n++)
+ for (size_t n = 0; n <= order_numerator_; n++)
numerator_coefficients_[n] /= denominator_coefficients_[0];
- for (int n = 0; n <= order_denominator_; n++)
+ for (size_t n = 0; n <= order_denominator_; n++)
denominator_coefficients_[n] /= denominator_coefficients_[0];
}
}
template <typename T>
-static float FilterArPast(const T* past, int order, const float* coefficients) {
+static float FilterArPast(const T* past, size_t order,
+ const float* coefficients) {
float sum = 0.0f;
- int past_index = order - 1;
- for (int k = 1; k <= order; k++, past_index--)
+ size_t past_index = order - 1;
+ for (size_t k = 1; k <= order; k++, past_index--)
sum += coefficients[k] * past[past_index];
return sum;
}
int PoleZeroFilter::Filter(const int16_t* in,
- int num_input_samples,
+ size_t num_input_samples,
float* output) {
- if (in == NULL || num_input_samples < 0 || output == NULL)
+ if (in == NULL || output == NULL)
return -1;
// This is the typical case, just a memcpy.
- const int k = std::min(num_input_samples, highest_order_);
- int n;
+ const size_t k = std::min(num_input_samples, highest_order_);
+ size_t n;
for (n = 0; n < k; n++) {
output[n] = in[n] * numerator_coefficients_[0];
output[n] += FilterArPast(&past_input_[n], order_numerator_,
@@ -81,7 +84,7 @@ int PoleZeroFilter::Filter(const int16_t* in,
past_output_[n + order_denominator_] = output[n];
}
if (highest_order_ < num_input_samples) {
- for (int m = 0; n < num_input_samples; n++, m++) {
+ for (size_t m = 0; n < num_input_samples; n++, m++) {
output[n] = in[n] * numerator_coefficients_[0];
output[n] +=
FilterArPast(&in[m], order_numerator_, numerator_coefficients_);

Powered by Google App Engine
This is Rietveld 408576698