From 281b7983dbe3f9687e699ebda3490996ce50f5b1 Mon Sep 17 00:00:00 2001 From: "bjornv@webrtc.org" Date: Wed, 30 May 2012 07:41:57 +0000 Subject: [PATCH] Resolved Coverity warnings. This CL includes changes to resolve Coverity warnings 14086, 14110 and 14111. Tested with trybots and audioproc_unittests. BUG=None TEST=None Review URL: https://webrtc-codereview.appspot.com/606004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@2321 4adac7df-926f-26a2-2b94-8c16560cd09d --- src/modules/audio_processing/aec/aec_core.c | 2 +- .../audio_processing/aec/aec_resampler.c | 29 ++++++++++--------- .../audio_processing/aec/aec_resampler.h | 14 ++++----- .../audio_processing/aec/echo_cancellation.c | 7 ++--- src/modules/audio_processing/agc/analog_agc.c | 3 +- 5 files changed, 27 insertions(+), 28 deletions(-) diff --git a/src/modules/audio_processing/aec/aec_core.c b/src/modules/audio_processing/aec/aec_core.c index 49c0d13f3a..2defba0917 100644 --- a/src/modules/audio_processing/aec/aec_core.c +++ b/src/modules/audio_processing/aec/aec_core.c @@ -777,7 +777,7 @@ static void ProcessBlock(aec_t* aec) { memcpy(aec->xfBuf[1] + aec->xfBufBlockPos * PART_LEN1, &xf_ptr[PART_LEN1], sizeof(float) * PART_LEN1); - memset(yf[0], 0, sizeof(float) * (PART_LEN1 * 2)); + memset(yf, 0, sizeof(yf)); // Filter far WebRtcAec_FilterFar(aec, yf); diff --git a/src/modules/audio_processing/aec/aec_resampler.c b/src/modules/audio_processing/aec/aec_resampler.c index ea980cd96a..126a2094e6 100644 --- a/src/modules/audio_processing/aec/aec_resampler.c +++ b/src/modules/audio_processing/aec/aec_resampler.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. + * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source @@ -71,21 +71,24 @@ int WebRtcAec_FreeResampler(void *resampInst) return 0; } -int WebRtcAec_ResampleLinear(void *resampInst, - const short *inspeech, - int size, - float skew, - short *outspeech) +void WebRtcAec_ResampleLinear(void *resampInst, + const short *inspeech, + int size, + float skew, + short *outspeech, + int *size_out) { resampler_t *obj = (resampler_t*) resampInst; short *y; float be, tnew, interp; - int tn, outsize, mm; + int tn, mm; - if (size < 0 || size > 2 * FRAME_LEN) { - return -1; - } + assert(!(size < 0 || size > 2 * FRAME_LEN)); + assert(resampInst != NULL); + assert(inspeech != NULL); + assert(outspeech != NULL); + assert(size_out != NULL); // Add new frame data in lookahead memcpy(&obj->buffer[FRAME_LEN + kResamplingDelay], @@ -121,15 +124,13 @@ int WebRtcAec_ResampleLinear(void *resampInst, tn = (int) tnew; } - outsize = mm; - obj->position += outsize * be - size; + *size_out = mm; + obj->position += (*size_out) * be - size; // Shift buffer memmove(obj->buffer, &obj->buffer[size], (kResamplerBufferSize - size) * sizeof(short)); - - return outsize; } int WebRtcAec_GetSkew(void *resampInst, int rawSkew, float *skewEst) diff --git a/src/modules/audio_processing/aec/aec_resampler.h b/src/modules/audio_processing/aec/aec_resampler.h index ab4cc6ecf2..acf8cce894 100644 --- a/src/modules/audio_processing/aec/aec_resampler.h +++ b/src/modules/audio_processing/aec/aec_resampler.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. + * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source @@ -25,11 +25,11 @@ int WebRtcAec_FreeResampler(void *resampInst); int WebRtcAec_GetSkew(void *resampInst, int rawSkew, float *skewEst); // Resamples input using linear interpolation. -// Returns size of resampled array. -int WebRtcAec_ResampleLinear(void *resampInst, - const short *inspeech, - int size, - float skew, - short *outspeech); +void WebRtcAec_ResampleLinear(void *resampInst, + const short *inspeech, + int size, + float skew, + short *outspeech, + int *size_out); #endif // WEBRTC_MODULES_AUDIO_PROCESSING_AEC_AEC_RESAMPLER_H_ diff --git a/src/modules/audio_processing/aec/echo_cancellation.c b/src/modules/audio_processing/aec/echo_cancellation.c index bd9d2c5b99..065d2de73d 100644 --- a/src/modules/audio_processing/aec/echo_cancellation.c +++ b/src/modules/audio_processing/aec/echo_cancellation.c @@ -276,11 +276,8 @@ WebRtc_Word32 WebRtcAec_BufferFarend(void *aecInst, const WebRtc_Word16 *farend, if (aecpc->skewMode == kAecTrue && aecpc->resample == kAecTrue) { // Resample and get a new number of samples - newNrOfSamples = WebRtcAec_ResampleLinear(aecpc->resampler, - farend, - nrOfSamples, - skew, - newFarend); + WebRtcAec_ResampleLinear(aecpc->resampler, farend, nrOfSamples, skew, + newFarend, &newNrOfSamples); farend_ptr = (const int16_t*) newFarend; } diff --git a/src/modules/audio_processing/agc/analog_agc.c b/src/modules/audio_processing/agc/analog_agc.c index 558a6cba8e..d60b4b9e8d 100644 --- a/src/modules/audio_processing/agc/analog_agc.c +++ b/src/modules/audio_processing/agc/analog_agc.c @@ -1650,9 +1650,10 @@ int WebRtcAgc_Init(void *agcInst, WebRtc_Word32 minLevel, WebRtc_Word32 maxLevel { stt->Rxx16w32_array[0][i] = 0; } - for (i = 0; i < 20; i++) + for (i = 0; i < 10; i++) { stt->env[0][i] = 0; + stt->env[1][i] = 0; } stt->inQueue = 0;