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

Unified Diff: webrtc/modules/audio_coding/codecs/ilbc/cb_search.c

Issue 1230693002: Update audio code to use size_t more correctly, (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: Review comments 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/codecs/ilbc/cb_search.c
diff --git a/webrtc/modules/audio_coding/codecs/ilbc/cb_search.c b/webrtc/modules/audio_coding/codecs/ilbc/cb_search.c
index d502cf0c32b91b3ec80506539f0f08b85dd51f3c..be9495144965af843f8febcffaf77e857e914c90 100644
--- a/webrtc/modules/audio_coding/codecs/ilbc/cb_search.c
+++ b/webrtc/modules/audio_coding/codecs/ilbc/cb_search.c
@@ -40,29 +40,31 @@ void WebRtcIlbcfix_CbSearch(
int16_t *gain_index, /* (o) Gain quantization indices */
int16_t *intarget, /* (i) Target vector for encoding */
int16_t *decResidual,/* (i) Decoded residual for codebook construction */
- int16_t lMem, /* (i) Length of buffer */
- int16_t lTarget, /* (i) Length of vector */
+ size_t lMem, /* (i) Length of buffer */
+ size_t lTarget, /* (i) Length of vector */
int16_t *weightDenum,/* (i) weighting filter coefficients in Q12 */
- int16_t block /* (i) the subblock number */
+ size_t block /* (i) the subblock number */
) {
- int16_t i, j, stage, range;
+ size_t i, range;
+ int16_t ii, j, stage;
int16_t *pp;
int16_t tmp;
int scale;
int16_t bits, temp1, temp2;
- int16_t base_size;
+ size_t base_size;
int32_t codedEner, targetEner;
int16_t gains[CB_NSTAGES+1];
int16_t *cb_vecPtr;
- int16_t indexOffset, sInd, eInd;
+ size_t indexOffset, sInd, eInd;
int32_t CritMax=0;
int16_t shTotMax=WEBRTC_SPL_WORD16_MIN;
- int16_t bestIndex=0;
+ size_t bestIndex=0;
int16_t bestGain=0;
- int16_t indexNew, CritNewSh;
+ size_t indexNew;
+ int16_t CritNewSh;
int32_t CritNew;
int32_t *cDotPtr;
- int16_t noOfZeros;
+ size_t noOfZeros;
int16_t *gainPtr;
int32_t t32, tmpW32;
int16_t *WebRtcIlbcfix_kGainSq5_ptr;
@@ -148,9 +150,9 @@ void WebRtcIlbcfix_CbSearch(
scale, 20, energyW16, energyShifts);
/* Compute the CB vectors' energies for the second cb section (filtered cb) */
- WebRtcIlbcfix_CbMemEnergyAugmentation(interpSamplesFilt, cbvectors,
- scale, (int16_t)(base_size + 20),
- energyW16, energyShifts);
+ WebRtcIlbcfix_CbMemEnergyAugmentation(interpSamplesFilt, cbvectors, scale,
+ base_size + 20, energyW16,
+ energyShifts);
/* Compute the CB vectors' energies and store them in the vector
* energyW16. Also the corresponding shift values are stored. The
@@ -224,7 +226,7 @@ void WebRtcIlbcfix_CbSearch(
/* Update the global best index and the corresponding gain */
WebRtcIlbcfix_CbUpdateBestIndex(
- CritNew, CritNewSh, (int16_t)(indexNew+indexOffset), cDot[indexNew+indexOffset],
+ CritNew, CritNewSh, indexNew+indexOffset, cDot[indexNew+indexOffset],
inverseEnergy[indexNew+indexOffset], inverseEnergyShifts[indexNew+indexOffset],
&CritMax, &shTotMax, &bestIndex, &bestGain);
@@ -242,11 +244,8 @@ void WebRtcIlbcfix_CbSearch(
i=sInd;
if (sInd<20) {
WebRtcIlbcfix_AugmentedCbCorr(target, cbvectors + lMem,
- interpSamplesFilt, cDot,
- (int16_t)(sInd + 20),
- (int16_t)(WEBRTC_SPL_MIN(39,
- (eInd + 20))),
- scale);
+ interpSamplesFilt, cDot, sInd + 20,
+ WEBRTC_SPL_MIN(39, (eInd + 20)), scale);
i=20;
cDotPtr = &cDot[20 - sInd];
} else {
@@ -257,7 +256,7 @@ void WebRtcIlbcfix_CbSearch(
/* Calculate the cross correlations (main part of the filtered CB) */
WebRtcSpl_CrossCorrelation(cDotPtr, target, cb_vecPtr, lTarget,
- (int16_t)(eInd - i + 1), scale, -1);
+ eInd - i + 1, scale, -1);
} else {
cDotPtr = cDot;
@@ -265,7 +264,7 @@ void WebRtcIlbcfix_CbSearch(
/* Calculate the cross correlations (main part of the filtered CB) */
WebRtcSpl_CrossCorrelation(cDotPtr, target, cb_vecPtr, lTarget,
- (int16_t)(eInd - sInd + 1), scale, -1);
+ eInd - sInd + 1, scale, -1);
}
@@ -274,17 +273,17 @@ void WebRtcIlbcfix_CbSearch(
/* Search for best index in this part of the vector */
WebRtcIlbcfix_CbSearchCore(
- cDot, (int16_t)(eInd-sInd+1), stage, inverseEnergy+indexOffset,
+ cDot, eInd-sInd+1, stage, inverseEnergy+indexOffset,
inverseEnergyShifts+indexOffset, Crit,
&indexNew, &CritNew, &CritNewSh);
/* Update the global best index and the corresponding gain */
WebRtcIlbcfix_CbUpdateBestIndex(
- CritNew, CritNewSh, (int16_t)(indexNew+indexOffset), cDot[indexNew],
+ CritNew, CritNewSh, indexNew+indexOffset, cDot[indexNew],
inverseEnergy[indexNew+indexOffset], inverseEnergyShifts[indexNew+indexOffset],
&CritMax, &shTotMax, &bestIndex, &bestGain);
- index[stage] = bestIndex;
+ index[stage] = (int16_t)bestIndex;
bestGain = WebRtcIlbcfix_GainQuant(bestGain,
@@ -297,7 +296,7 @@ void WebRtcIlbcfix_CbSearch(
if(lTarget==(STATE_LEN-iLBCenc_inst->state_short_len)) {
- if(index[stage]<base_size) {
+ if((size_t)index[stage]<base_size) {
pp=buf+lMem-lTarget-index[stage];
} else {
pp=cbvectors+lMem-lTarget-
@@ -306,16 +305,16 @@ void WebRtcIlbcfix_CbSearch(
} else {
- if (index[stage]<base_size) {
+ if ((size_t)index[stage]<base_size) {
if (index[stage]>=20) {
/* Adjust index and extract vector */
index[stage]-=20;
pp=buf+lMem-lTarget-index[stage];
} else {
/* Adjust index and extract vector */
- index[stage]+=(base_size-20);
+ index[stage]+=(int16_t)(base_size-20);
- WebRtcIlbcfix_CreateAugmentedVec((int16_t)(index[stage]-base_size+40),
+ WebRtcIlbcfix_CreateAugmentedVec(index[stage]-base_size+40,
buf+lMem, aug_vec);
pp = aug_vec;
@@ -329,8 +328,8 @@ void WebRtcIlbcfix_CbSearch(
index[stage]+base_size;
} else {
/* Adjust index and extract vector */
- index[stage]+=(base_size-20);
- WebRtcIlbcfix_CreateAugmentedVec((int16_t)(index[stage]-2*base_size+40),
+ index[stage]+=(int16_t)(base_size-20);
+ WebRtcIlbcfix_CreateAugmentedVec(index[stage]-2*base_size+40,
cbvectors+lMem, aug_vec);
pp = aug_vec;
}
@@ -381,7 +380,7 @@ void WebRtcIlbcfix_CbSearch(
WebRtcIlbcfix_kGainSq5_ptr = (int16_t*)&WebRtcIlbcfix_kGainSq5[j];
/* targetEner and codedEner are in Q(-2*scale) */
- for (i=gain_index[0];i<32;i++) {
+ for (ii=gain_index[0];ii<32;ii++) {
/* Change the index if
(codedEnergy*gainTbl[i]*gainTbl[i])<(targetEn*gain[0]*gain[0]) AND
@@ -392,8 +391,8 @@ void WebRtcIlbcfix_CbSearch(
t32 = t32 - targetEner;
if (t32 < 0) {
if ((*WebRtcIlbcfix_kGainSq5_ptr) < tmpW32) {
- j=i;
- WebRtcIlbcfix_kGainSq5_ptr = (int16_t*)&WebRtcIlbcfix_kGainSq5[i];
+ j=ii;
+ WebRtcIlbcfix_kGainSq5_ptr = (int16_t*)&WebRtcIlbcfix_kGainSq5[ii];
}
}
gainPtr++;
« no previous file with comments | « webrtc/modules/audio_coding/codecs/ilbc/cb_search.h ('k') | webrtc/modules/audio_coding/codecs/ilbc/cb_search_core.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698