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

Unified Diff: webrtc/modules/audio_processing/ns/ns_core.c

Issue 1227213002: Update audio code to use size_t more correctly, webrtc/modules/audio_processing/ (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
« no previous file with comments | « webrtc/modules/audio_processing/ns/ns_core.h ('k') | webrtc/modules/audio_processing/ns/nsx_core.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/modules/audio_processing/ns/ns_core.c
diff --git a/webrtc/modules/audio_processing/ns/ns_core.c b/webrtc/modules/audio_processing/ns/ns_core.c
index 652f0fea00a3ff07443c9ca2ac70b6efa9885a0f..1d6091400e8984a7da11400390863cb7af1bf6b4 100644
--- a/webrtc/modules/audio_processing/ns/ns_core.c
+++ b/webrtc/modules/audio_processing/ns/ns_core.c
@@ -217,7 +217,7 @@ int WebRtcNs_InitCore(NoiseSuppressionC* self, uint32_t fs) {
static void NoiseEstimation(NoiseSuppressionC* self,
float* magn,
float* noise) {
- int i, s, offset;
+ size_t i, s, offset;
float lmagn[HALF_ANAL_BLOCKL], delta;
if (self->updates < END_STARTUP_LONG) {
@@ -522,8 +522,8 @@ static void FeatureParameterExtraction(NoiseSuppressionC* self, int flag) {
// Spectral flatness is returned in self->featureData[0].
static void ComputeSpectralFlatness(NoiseSuppressionC* self,
const float* magnIn) {
- int i;
- int shiftLP = 1; // Option to remove first bin(s) from spectral measures.
+ size_t i;
+ size_t shiftLP = 1; // Option to remove first bin(s) from spectral measures.
float avgSpectralFlatnessNum, avgSpectralFlatnessDen, spectralTmp;
// Compute spectral measures.
@@ -568,7 +568,7 @@ static void ComputeSnr(const NoiseSuppressionC* self,
const float* noise,
float* snrLocPrior,
float* snrLocPost) {
- int i;
+ size_t i;
for (i = 0; i < self->magnLen; i++) {
// Previous post SNR.
@@ -596,7 +596,7 @@ static void ComputeSpectralDifference(NoiseSuppressionC* self,
const float* magnIn) {
// avgDiffNormMagn = var(magnIn) - cov(magnIn, magnAvgPause)^2 /
// var(magnAvgPause)
- int i;
+ size_t i;
float avgPause, avgMagn, covMagnPause, varPause, varMagn, avgDiffNormMagn;
avgPause = 0.0;
@@ -643,7 +643,8 @@ static void SpeechNoiseProb(NoiseSuppressionC* self,
float* probSpeechFinal,
const float* snrLocPrior,
const float* snrLocPost) {
- int i, sgnMap;
+ size_t i;
+ int sgnMap;
float invLrt, gainPrior, indPrior;
float logLrtTimeAvgKsum, besselTmp;
float indicator0, indicator1, indicator2;
@@ -802,7 +803,7 @@ static void UpdateNoiseEstimate(NoiseSuppressionC* self,
const float* snrLocPrior,
const float* snrLocPost,
float* noise) {
- int i;
+ size_t i;
float probSpeech, probNonSpeech;
// Time-avg parameter for noise update.
float gammaNoiseTmp = NOISE_UPDATE;
@@ -853,8 +854,8 @@ static void UpdateNoiseEstimate(NoiseSuppressionC* self,
// Output:
// * |buffer| is the updated buffer.
static void UpdateBuffer(const float* frame,
- int frame_length,
- int buffer_length,
+ size_t frame_length,
+ size_t buffer_length,
float* buffer) {
assert(buffer_length < 2 * frame_length);
@@ -885,12 +886,12 @@ static void UpdateBuffer(const float* frame,
// * |magn| is the calculated signal magnitude in the frequency domain.
static void FFT(NoiseSuppressionC* self,
float* time_data,
- int time_data_length,
- int magnitude_length,
+ size_t time_data_length,
+ size_t magnitude_length,
float* real,
float* imag,
float* magn) {
- int i;
+ size_t i;
assert(magnitude_length == time_data_length / 2 + 1);
@@ -923,10 +924,10 @@ static void FFT(NoiseSuppressionC* self,
static void IFFT(NoiseSuppressionC* self,
const float* real,
const float* imag,
- int magnitude_length,
- int time_data_length,
+ size_t magnitude_length,
+ size_t time_data_length,
float* time_data) {
- int i;
+ size_t i;
assert(time_data_length == 2 * (magnitude_length - 1));
@@ -948,8 +949,8 @@ static void IFFT(NoiseSuppressionC* self,
// * |buffer| is the buffer over which the energy is calculated.
// * |length| is the length of the buffer.
// Returns the calculated energy.
-static float Energy(const float* buffer, int length) {
- int i;
+static float Energy(const float* buffer, size_t length) {
+ size_t i;
float energy = 0.f;
for (i = 0; i < length; ++i) {
@@ -968,9 +969,9 @@ static float Energy(const float* buffer, int length) {
// * |data_windowed| is the windowed data.
static void Windowing(const float* window,
const float* data,
- int length,
+ size_t length,
float* data_windowed) {
- int i;
+ size_t i;
for (i = 0; i < length; ++i) {
data_windowed[i] = window[i] * data[i];
@@ -985,7 +986,7 @@ static void Windowing(const float* window,
static void ComputeDdBasedWienerFilter(const NoiseSuppressionC* self,
const float* magn,
float* theFilter) {
- int i;
+ size_t i;
float snrPrior, previousEstimateStsa, currentEstimateStsa;
for (i = 0; i < self->magnLen; i++) {
@@ -1041,8 +1042,8 @@ int WebRtcNs_set_policy_core(NoiseSuppressionC* self, int mode) {
}
void WebRtcNs_AnalyzeCore(NoiseSuppressionC* self, const float* speechFrame) {
- int i;
- const int kStartBand = 5; // Skip first frequency bins during estimation.
+ size_t i;
+ const size_t kStartBand = 5; // Skip first frequency bins during estimation.
int updateParsFlag;
float energy;
float signalEnergy = 0.f;
@@ -1182,11 +1183,11 @@ void WebRtcNs_AnalyzeCore(NoiseSuppressionC* self, const float* speechFrame) {
void WebRtcNs_ProcessCore(NoiseSuppressionC* self,
const float* const* speechFrame,
- int num_bands,
+ size_t num_bands,
float* const* outFrame) {
// Main routine for noise reduction.
int flagHB = 0;
- int i, j;
+ size_t i, j;
float energy1, energy2, gain, factor, factor1, factor2;
float fout[BLOCKL_MAX];
@@ -1210,7 +1211,7 @@ void WebRtcNs_ProcessCore(NoiseSuppressionC* self,
const float* const* speechFrameHB = NULL;
float* const* outFrameHB = NULL;
- int num_high_bands = 0;
+ size_t num_high_bands = 0;
if (num_bands > 1) {
speechFrameHB = &speechFrame[1];
outFrameHB = &outFrame[1];
« no previous file with comments | « webrtc/modules/audio_processing/ns/ns_core.h ('k') | webrtc/modules/audio_processing/ns/nsx_core.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698