Reformat existing code. There should be no functional effects.
This includes changes like:
* Attempt to break lines at better positions
* Use "override" in more places, don't use "virtual" with it
* Use {} where the body is more than one line
* Make declaration and definition arg names match
* Eliminate unused code
* EXPECT_EQ(expected, actual) (but use (actual, expected) for e.g. _GT)
* Correct #include order
* Use anonymous namespaces in preference to "static" for file-scoping
* Eliminate unnecessary casts
* Update reference code in comments of ARM assembly sources to match actual current C code
* Fix indenting to be more style-guide compliant
* Use arraysize() in more places
* Use bool instead of int for "boolean" values (0/1)
* Shorten and simplify code
* Spaces around operators
* 80 column limit
* Use const more consistently
* Space goes after '*' in type name, not before
* Remove unnecessary return values
* Use "(var == const)", not "(const == var)"
* Spelling
* Prefer true, typed constants to "enum hack" constants
* Avoid "virtual" on non-overridden functions
* ASSERT(x == y) -> ASSERT_EQ(y, x)
BUG=none
R=andrew@webrtc.org, asapersson@webrtc.org, henrika@webrtc.org, juberti@webrtc.org, kjellander@webrtc.org, kwiberg@webrtc.org
Review URL: https://codereview.webrtc.org/1172163004
Cr-Commit-Position: refs/heads/master@{#9420}
diff --git a/webrtc/modules/audio_coding/codecs/ilbc/abs_quant_loop.c b/webrtc/modules/audio_coding/codecs/ilbc/abs_quant_loop.c
index 1a18a1d..d26fb5d 100644
--- a/webrtc/modules/audio_coding/codecs/ilbc/abs_quant_loop.c
+++ b/webrtc/modules/audio_coding/codecs/ilbc/abs_quant_loop.c
@@ -23,7 +23,7 @@
void WebRtcIlbcfix_AbsQuantLoop(int16_t *syntOutIN, int16_t *in_weightedIN,
int16_t *weightDenumIN, int16_t *quantLenIN,
int16_t *idxVecIN ) {
- int n, k1, k2;
+ int k1, k2;
int16_t index;
int32_t toQW32;
int32_t toQ32;
@@ -36,8 +36,6 @@
int16_t *quantLen = quantLenIN;
int16_t *idxVec = idxVecIN;
- n=0;
-
for(k1=0;k1<2;k1++) {
for(k2=0;k2<quantLen[k1];k2++){
@@ -81,7 +79,6 @@
*syntOut = (int16_t) (tmp16a + (int32_t)(*in_weighted) - toQW32);
- n++;
syntOut++; in_weighted++;
}
/* Update perceptual weighting filter at subframe border */
diff --git a/webrtc/modules/audio_coding/codecs/ilbc/audio_encoder_ilbc.cc b/webrtc/modules/audio_coding/codecs/ilbc/audio_encoder_ilbc.cc
index 4fea44b..66d2465 100644
--- a/webrtc/modules/audio_coding/codecs/ilbc/audio_encoder_ilbc.cc
+++ b/webrtc/modules/audio_coding/codecs/ilbc/audio_encoder_ilbc.cc
@@ -25,12 +25,9 @@
} // namespace
bool AudioEncoderIlbc::Config::IsOk() const {
- if (!(frame_size_ms == 20 || frame_size_ms == 30 || frame_size_ms == 40 ||
- frame_size_ms == 60))
- return false;
- if (kSampleRateHz / 100 * (frame_size_ms / 10) > kMaxSamplesPerPacket)
- return false;
- return true;
+ return (frame_size_ms == 20 || frame_size_ms == 30 || frame_size_ms == 40 ||
+ frame_size_ms == 60) &&
+ (kSampleRateHz / 100 * (frame_size_ms / 10)) <= kMaxSamplesPerPacket;
}
AudioEncoderIlbc::AudioEncoderIlbc(const Config& config)
diff --git a/webrtc/modules/audio_coding/codecs/ilbc/cb_mem_energy.c b/webrtc/modules/audio_coding/codecs/ilbc/cb_mem_energy.c
index f8a0933..8dfde21 100644
--- a/webrtc/modules/audio_coding/codecs/ilbc/cb_mem_energy.c
+++ b/webrtc/modules/audio_coding/codecs/ilbc/cb_mem_energy.c
@@ -35,7 +35,7 @@
int16_t *energyW16, /* (o) Energy in the CB vectors */
int16_t *energyShifts, /* (o) Shift value of the energy */
int16_t scale, /* (i) The scaling of all energy values */
- int16_t base_size /* (i) Index to where the energy values should be stored */
+ int16_t base_size /* (i) Index to where energy values should be stored */
) {
int16_t *ppi, *ppo, *pp;
int32_t energy, tmp32;
diff --git a/webrtc/modules/audio_coding/codecs/ilbc/cb_mem_energy_augmentation.c b/webrtc/modules/audio_coding/codecs/ilbc/cb_mem_energy_augmentation.c
index 7e6daf9..789d2d4 100644
--- a/webrtc/modules/audio_coding/codecs/ilbc/cb_mem_energy_augmentation.c
+++ b/webrtc/modules/audio_coding/codecs/ilbc/cb_mem_energy_augmentation.c
@@ -23,7 +23,7 @@
int16_t *interpSamples, /* (i) The interpolated samples */
int16_t *CBmem, /* (i) The CB memory */
int16_t scale, /* (i) The scaling of all energy values */
- int16_t base_size, /* (i) Index to where the energy values should be stored */
+ int16_t base_size, /* (i) Index to where energy values should be stored */
int16_t *energyW16, /* (o) Energy in the CB vectors */
int16_t *energyShifts /* (o) Shift value of the energy */
){
diff --git a/webrtc/modules/audio_coding/codecs/ilbc/cb_mem_energy_augmentation.h b/webrtc/modules/audio_coding/codecs/ilbc/cb_mem_energy_augmentation.h
index 6c181bd..9b5f85c 100644
--- a/webrtc/modules/audio_coding/codecs/ilbc/cb_mem_energy_augmentation.h
+++ b/webrtc/modules/audio_coding/codecs/ilbc/cb_mem_energy_augmentation.h
@@ -23,7 +23,7 @@
int16_t *interpSamples, /* (i) The interpolated samples */
int16_t *CBmem, /* (i) The CB memory */
int16_t scale, /* (i) The scaling of all energy values */
- int16_t base_size, /* (i) Index to where the energy values should be stored */
+ int16_t base_size, /* (i) Index to where energy values should be stored */
int16_t *energyW16, /* (o) Energy in the CB vectors */
int16_t *energyShifts /* (o) Shift value of the energy */
);
diff --git a/webrtc/modules/audio_coding/codecs/ilbc/cb_mem_energy_calc.c b/webrtc/modules/audio_coding/codecs/ilbc/cb_mem_energy_calc.c
index b1c0f8c..ec2dcaa 100644
--- a/webrtc/modules/audio_coding/codecs/ilbc/cb_mem_energy_calc.c
+++ b/webrtc/modules/audio_coding/codecs/ilbc/cb_mem_energy_calc.c
@@ -29,7 +29,7 @@
int16_t *energyW16, /* (o) Energy in the CB vectors */
int16_t *energyShifts, /* (o) Shift value of the energy */
int16_t scale, /* (i) The scaling of all energy values */
- int16_t base_size /* (i) Index to where the energy values should be stored */
+ int16_t base_size /* (i) Index to where energy values should be stored */
)
{
int16_t j,shft;
diff --git a/webrtc/modules/audio_coding/codecs/ilbc/cb_mem_energy_calc.h b/webrtc/modules/audio_coding/codecs/ilbc/cb_mem_energy_calc.h
index c7e1e54..6428269 100644
--- a/webrtc/modules/audio_coding/codecs/ilbc/cb_mem_energy_calc.h
+++ b/webrtc/modules/audio_coding/codecs/ilbc/cb_mem_energy_calc.h
@@ -27,7 +27,7 @@
int16_t *energyW16, /* (o) Energy in the CB vectors */
int16_t *energyShifts, /* (o) Shift value of the energy */
int16_t scale, /* (i) The scaling of all energy values */
- int16_t base_size /* (i) Index to where the energy values should be stored */
+ int16_t base_size /* (i) Index to where energy values should be stored */
);
#endif
diff --git a/webrtc/modules/audio_coding/codecs/ilbc/cb_search.c b/webrtc/modules/audio_coding/codecs/ilbc/cb_search.c
index 2ee9f6c..bc60149 100644
--- a/webrtc/modules/audio_coding/codecs/ilbc/cb_search.c
+++ b/webrtc/modules/audio_coding/codecs/ilbc/cb_search.c
@@ -147,7 +147,8 @@
/* Compute the CB vectors' energies for the second cb section (filtered cb) */
WebRtcIlbcfix_CbMemEnergyAugmentation(interpSamplesFilt, cbvectors,
- scale, (int16_t)(base_size+20), energyW16, energyShifts);
+ scale, (int16_t)(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
@@ -238,9 +239,12 @@
if (lTarget==SUBL) {
i=sInd;
if (sInd<20) {
- WebRtcIlbcfix_AugmentedCbCorr(target, cbvectors+lMem,
+ WebRtcIlbcfix_AugmentedCbCorr(target, cbvectors + lMem,
interpSamplesFilt, cDot,
- (int16_t)(sInd+20), (int16_t)(WEBRTC_SPL_MIN(39, (eInd+20))), scale);
+ (int16_t)(sInd + 20),
+ (int16_t)(WEBRTC_SPL_MIN(39,
+ (eInd + 20))),
+ scale);
i=20;
cDotPtr = &cDot[20 - sInd];
} else {
@@ -250,14 +254,16 @@
cb_vecPtr = cbvectors+lMem-20-i;
/* Calculate the cross correlations (main part of the filtered CB) */
- WebRtcSpl_CrossCorrelation(cDotPtr, target, cb_vecPtr, lTarget, (int16_t)(eInd-i+1), scale, -1);
+ WebRtcSpl_CrossCorrelation(cDotPtr, target, cb_vecPtr, lTarget,
+ (int16_t)(eInd - i + 1), scale, -1);
} else {
cDotPtr = cDot;
cb_vecPtr = cbvectors+lMem-lTarget-sInd;
/* Calculate the cross correlations (main part of the filtered CB) */
- WebRtcSpl_CrossCorrelation(cDotPtr, target, cb_vecPtr, lTarget, (int16_t)(eInd-sInd+1), scale, -1);
+ WebRtcSpl_CrossCorrelation(cDotPtr, target, cb_vecPtr, lTarget,
+ (int16_t)(eInd - sInd + 1), scale, -1);
}
diff --git a/webrtc/modules/audio_coding/codecs/ilbc/decode.c b/webrtc/modules/audio_coding/codecs/ilbc/decode.c
index 035460b..9918de2 100644
--- a/webrtc/modules/audio_coding/codecs/ilbc/decode.c
+++ b/webrtc/modules/audio_coding/codecs/ilbc/decode.c
@@ -103,9 +103,10 @@
WebRtcIlbcfix_DecodeResidual(iLBCdec_inst, iLBCbits_inst, decresidual, syntdenum);
/* preparing the plc for a future loss! */
- WebRtcIlbcfix_DoThePlc( PLCresidual, PLClpc, 0,
- decresidual, syntdenum + (LPC_FILTERORDER + 1)*(iLBCdec_inst->nsub - 1),
- (int16_t)(iLBCdec_inst->last_lag), iLBCdec_inst);
+ WebRtcIlbcfix_DoThePlc(
+ PLCresidual, PLClpc, 0, decresidual,
+ syntdenum + (LPC_FILTERORDER + 1) * (iLBCdec_inst->nsub - 1),
+ (int16_t)(iLBCdec_inst->last_lag), iLBCdec_inst);
/* Use the output from doThePLC */
WEBRTC_SPL_MEMCPY_W16(decresidual, PLCresidual, iLBCdec_inst->blockl);
@@ -120,8 +121,8 @@
/* packet loss conceal */
- WebRtcIlbcfix_DoThePlc( PLCresidual, PLClpc, 1,
- decresidual, syntdenum, (int16_t)(iLBCdec_inst->last_lag), iLBCdec_inst);
+ WebRtcIlbcfix_DoThePlc(PLCresidual, PLClpc, 1, decresidual, syntdenum,
+ (int16_t)(iLBCdec_inst->last_lag), iLBCdec_inst);
WEBRTC_SPL_MEMCPY_W16(decresidual, PLCresidual, iLBCdec_inst->blockl);
diff --git a/webrtc/modules/audio_coding/codecs/ilbc/enhancer_interface.c b/webrtc/modules/audio_coding/codecs/ilbc/enhancer_interface.c
index 262a564..6dca0b7 100644
--- a/webrtc/modules/audio_coding/codecs/ilbc/enhancer_interface.c
+++ b/webrtc/modules/audio_coding/codecs/ilbc/enhancer_interface.c
@@ -336,8 +336,8 @@
enh_bufPtr1,
synt,
&iLBCdec_inst->old_syntdenum[
- (iLBCdec_inst->nsub-1)*(LPC_FILTERORDER+1)],
- LPC_FILTERORDER+1, lag);
+ (iLBCdec_inst->nsub-1)*(LPC_FILTERORDER+1)],
+ LPC_FILTERORDER+1, lag);
WEBRTC_SPL_MEMCPY_W16(&synt[-LPC_FILTERORDER], &synt[lag-LPC_FILTERORDER],
LPC_FILTERORDER);
@@ -347,8 +347,8 @@
WebRtcSpl_FilterARFastQ12(
enh_bufPtr1, synt,
&iLBCdec_inst->old_syntdenum[
- (iLBCdec_inst->nsub-1)*(LPC_FILTERORDER+1)],
- LPC_FILTERORDER+1, lag);
+ (iLBCdec_inst->nsub-1)*(LPC_FILTERORDER+1)],
+ LPC_FILTERORDER+1, lag);
WEBRTC_SPL_MEMCPY_W16(iLBCdec_inst->syntMem, &synt[lag-LPC_FILTERORDER],
LPC_FILTERORDER);
diff --git a/webrtc/modules/audio_coding/codecs/ilbc/my_corr.c b/webrtc/modules/audio_coding/codecs/ilbc/my_corr.c
index ec3cf20..ab08001 100644
--- a/webrtc/modules/audio_coding/codecs/ilbc/my_corr.c
+++ b/webrtc/modules/audio_coding/codecs/ilbc/my_corr.c
@@ -23,10 +23,10 @@
*---------------------------------------------------------------*/
void WebRtcIlbcfix_MyCorr(
- int32_t *corr, /* (o) correlation of seq1 and seq2 */
- int16_t *seq1, /* (i) first sequence */
+ int32_t* corr, /* (o) correlation of seq1 and seq2 */
+ const int16_t* seq1, /* (i) first sequence */
int16_t dim1, /* (i) dimension first seq1 */
- const int16_t *seq2, /* (i) second sequence */
+ const int16_t* seq2, /* (i) second sequence */
int16_t dim2 /* (i) dimension seq2 */
){
int16_t max, scale, loops;
diff --git a/webrtc/modules/audio_coding/codecs/ilbc/my_corr.h b/webrtc/modules/audio_coding/codecs/ilbc/my_corr.h
index ee66998..a74dd1e 100644
--- a/webrtc/modules/audio_coding/codecs/ilbc/my_corr.h
+++ b/webrtc/modules/audio_coding/codecs/ilbc/my_corr.h
@@ -26,10 +26,10 @@
*---------------------------------------------------------------*/
void WebRtcIlbcfix_MyCorr(
- int32_t *corr, /* (o) correlation of seq1 and seq2 */
- int16_t *seq1, /* (i) first sequence */
+ int32_t* corr, /* (o) correlation of seq1 and seq2 */
+ const int16_t* seq1, /* (i) first sequence */
int16_t dim1, /* (i) dimension first seq1 */
- const int16_t *seq2, /* (i) second sequence */
+ const int16_t* seq2, /* (i) second sequence */
int16_t dim2 /* (i) dimension seq2 */
);
diff --git a/webrtc/modules/audio_coding/codecs/ilbc/test/iLBC_test.c b/webrtc/modules/audio_coding/codecs/ilbc/test/iLBC_test.c
index 9c42037..6ee3df4 100644
--- a/webrtc/modules/audio_coding/codecs/ilbc/test/iLBC_test.c
+++ b/webrtc/modules/audio_coding/codecs/ilbc/test/iLBC_test.c
@@ -52,6 +52,7 @@
int blockcount = 0;
int packetlosscount = 0;
int frameLen;
+ size_t len_i16s;
int16_t speechType;
IlbcEncoderInstance *Enc_Inst;
IlbcDecoderInstance *Dec_Inst;
@@ -173,9 +174,8 @@
/* write byte file */
- if (fwrite(encoded_data, sizeof(int16_t),
- ((len+1)/sizeof(int16_t)), efileid) !=
- (size_t)(((len+1)/sizeof(int16_t)))) {
+ len_i16s = (len + 1) / sizeof(int16_t);
+ if (fwrite(encoded_data, sizeof(int16_t), len_i16s, efileid) != len_i16s) {
return -1;
}
diff --git a/webrtc/modules/audio_coding/codecs/ilbc/test/iLBC_testLib.c b/webrtc/modules/audio_coding/codecs/ilbc/test/iLBC_testLib.c
index df37bec..3dcda29c 100644
--- a/webrtc/modules/audio_coding/codecs/ilbc/test/iLBC_testLib.c
+++ b/webrtc/modules/audio_coding/codecs/ilbc/test/iLBC_testLib.c
@@ -42,6 +42,7 @@
FILE *ifileid,*efileid,*ofileid, *chfileid;
short encoded_data[55], data[240], speechType;
short len, mode, pli;
+ size_t readlen;
int blockcount = 0;
IlbcEncoderInstance *Enc_Inst;
@@ -125,19 +126,16 @@
/* loop over input blocks */
#ifdef SPLIT_10MS
- while(fread(data, sizeof(short), 80, ifileid) == 80) {
+ readlen = 80;
#else
- while((short)fread(data,sizeof(short),(mode<<3),ifileid)==(mode<<3)) {
+ readlen = (size_t)(mode << 3);
#endif
+ while(fread(data, sizeof(short), readlen, ifileid) == readlen) {
blockcount++;
/* encoding */
fprintf(stderr, "--- Encoding block %i --- ",blockcount);
-#ifdef SPLIT_10MS
- len=WebRtcIlbcfix_Encode(Enc_Inst, data, 80, encoded_data);
-#else
- len=WebRtcIlbcfix_Encode(Enc_Inst, data, (short)(mode<<3), encoded_data);
-#endif
+ len=WebRtcIlbcfix_Encode(Enc_Inst, data, (short)readlen, encoded_data);
if (len < 0) {
fprintf(stderr, "Error encoding\n");
exit(0);
@@ -152,9 +150,7 @@
/* write byte file */
if(len != 0){ //len may be 0 in 10ms split case
fwrite(encoded_data,1,len,efileid);
- }
- if(len != 0){ //len may be 0 in 10ms split case
/* get channel data if provided */
if (argc==6) {
if (fread(&pli, sizeof(int16_t), 1, chfileid)) {
diff --git a/webrtc/modules/audio_coding/codecs/ilbc/xcorr_coef.c b/webrtc/modules/audio_coding/codecs/ilbc/xcorr_coef.c
index 328a5fe..53d95bf 100644
--- a/webrtc/modules/audio_coding/codecs/ilbc/xcorr_coef.c
+++ b/webrtc/modules/audio_coding/codecs/ilbc/xcorr_coef.c
@@ -57,11 +57,11 @@
if (step==1) {
max=WebRtcSpl_MaxAbsValueW16(regressor, subl + searchLen - 1);
rp_beg = regressor;
- rp_end = ®ressor[subl];
+ rp_end = regressor + subl;
} else { /* step==-1 */
- max=WebRtcSpl_MaxAbsValueW16(®ressor[-searchLen], subl + searchLen - 1);
- rp_beg = ®ressor[-1];
- rp_end = ®ressor[subl-1];
+ max = WebRtcSpl_MaxAbsValueW16(regressor - searchLen, subl + searchLen - 1);
+ rp_beg = regressor - 1;
+ rp_end = regressor + subl - 1;
}
/* Introduce a scale factor on the Energy in int32_t in