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

Unified Diff: webrtc/modules/audio_coding/neteq/dsp_helper.cc

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
Index: webrtc/modules/audio_coding/neteq/dsp_helper.cc
diff --git a/webrtc/modules/audio_coding/neteq/dsp_helper.cc b/webrtc/modules/audio_coding/neteq/dsp_helper.cc
index 3e5c61d87b559586b889ef0826527c278c677ecd..4188914c86c9bec701c40d92de3ee11be43569bc 100644
--- a/webrtc/modules/audio_coding/neteq/dsp_helper.cc
+++ b/webrtc/modules/audio_coding/neteq/dsp_helper.cc
@@ -99,13 +99,13 @@ int DspHelper::RampSignal(AudioMultiVector* signal,
return end_factor;
}
-void DspHelper::PeakDetection(int16_t* data, int data_length,
- int num_peaks, int fs_mult,
- int* peak_index, int16_t* peak_value) {
- int16_t min_index = 0;
- int16_t max_index = 0;
+void DspHelper::PeakDetection(int16_t* data, size_t data_length,
+ size_t num_peaks, int fs_mult,
+ size_t* peak_index, int16_t* peak_value) {
+ size_t min_index = 0;
+ size_t max_index = 0;
- for (int i = 0; i <= num_peaks - 1; i++) {
+ for (size_t i = 0; i <= num_peaks - 1; i++) {
if (num_peaks == 1) {
// Single peak. The parabola fit assumes that an extra point is
// available; worst case it gets a zero on the high end of the signal.
@@ -148,7 +148,7 @@ void DspHelper::PeakDetection(int16_t* data, int data_length,
}
void DspHelper::ParabolicFit(int16_t* signal_points, int fs_mult,
- int* peak_index, int16_t* peak_value) {
+ size_t* peak_index, int16_t* peak_value) {
uint16_t fit_index[13];
if (fs_mult == 1) {
fit_index[0] = 0;
@@ -235,16 +235,16 @@ void DspHelper::ParabolicFit(int16_t* signal_points, int fs_mult,
}
}
-int DspHelper::MinDistortion(const int16_t* signal, int min_lag,
- int max_lag, int length,
- int32_t* distortion_value) {
- int best_index = 0;
+size_t DspHelper::MinDistortion(const int16_t* signal, size_t min_lag,
+ size_t max_lag, size_t length,
+ int32_t* distortion_value) {
+ size_t best_index = 0;
int32_t min_distortion = WEBRTC_SPL_WORD32_MAX;
- for (int i = min_lag; i <= max_lag; i++) {
+ for (size_t i = min_lag; i <= max_lag; i++) {
int32_t sum_diff = 0;
const int16_t* data1 = signal;
const int16_t* data2 = signal - i;
- for (int j = 0; j < length; j++) {
+ for (size_t j = 0; j < length; j++) {
sum_diff += WEBRTC_SPL_ABS_W32(data1[j] - data2[j]);
}
// Compare with previous minimum.
@@ -293,15 +293,15 @@ void DspHelper::MuteSignal(int16_t* signal, int mute_slope, size_t length) {
}
int DspHelper::DownsampleTo4kHz(const int16_t* input, size_t input_length,
- int output_length, int input_rate_hz,
+ size_t output_length, int input_rate_hz,
bool compensate_delay, int16_t* output) {
// Set filter parameters depending on input frequency.
// NOTE: The phase delay values are wrong compared to the true phase delay
// of the filters. However, the error is preserved (through the +1 term) for
// consistency.
const int16_t* filter_coefficients; // Filter coefficients.
- int16_t filter_length; // Number of coefficients.
- int16_t filter_delay; // Phase delay in samples.
+ size_t filter_length; // Number of coefficients.
+ size_t filter_delay; // Phase delay in samples.
int16_t factor; // Conversion rate (inFsHz / 8000).
switch (input_rate_hz) {
case 8000: {
@@ -345,9 +345,8 @@ int DspHelper::DownsampleTo4kHz(const int16_t* input, size_t input_length,
// Returns -1 if input signal is too short; 0 otherwise.
return WebRtcSpl_DownsampleFast(
- &input[filter_length - 1], static_cast<int>(input_length) -
- (filter_length - 1), output, output_length, filter_coefficients,
- filter_length, factor, filter_delay);
+ &input[filter_length - 1], input_length - filter_length + 1, output,
+ output_length, filter_coefficients, filter_length, factor, filter_delay);
}
} // namespace webrtc
« no previous file with comments | « webrtc/modules/audio_coding/neteq/dsp_helper.h ('k') | webrtc/modules/audio_coding/neteq/dtmf_tone_generator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698