Upconvert various types to int.
Per comments from HL/kwiberg on https://webrtc-codereview.appspot.com/42569004 , when there is existing usage of mixed types (int16_t, int, etc.), we'd prefer to standardize on larger types like int and phase out use of int16_t.
Specifically, "Using int16 just because we're sure all reasonable values will fit in 16 bits isn't usually meaningful in C."
This converts some existing uses of int16_t (and, in a few cases, other types such as uint16_t) to int (or, in a few places, int32_t). Other locations will be converted to size_t in a separate change.
BUG=none
R=andrew@webrtc.org, kwiberg@webrtc.org
Review URL: https://webrtc-codereview.appspot.com/54629004
Cr-Commit-Position: refs/heads/master@{#9405}
diff --git a/webrtc/modules/audio_coding/codecs/ilbc/augmented_cb_corr.c b/webrtc/modules/audio_coding/codecs/ilbc/augmented_cb_corr.c
index d8f8c93..c24b4a6 100644
--- a/webrtc/modules/audio_coding/codecs/ilbc/augmented_cb_corr.c
+++ b/webrtc/modules/audio_coding/codecs/ilbc/augmented_cb_corr.c
@@ -31,7 +31,7 @@
int16_t low, /* (i) Lag to start from (typically
20) */
int16_t high, /* (i) Lag to end at (typically 39) */
- int16_t scale) /* (i) Scale factor to use for
+ int scale) /* (i) Scale factor to use for
the crossDot */
{
int lagcount;
diff --git a/webrtc/modules/audio_coding/codecs/ilbc/augmented_cb_corr.h b/webrtc/modules/audio_coding/codecs/ilbc/augmented_cb_corr.h
index 533d0a4..a0435c4 100644
--- a/webrtc/modules/audio_coding/codecs/ilbc/augmented_cb_corr.h
+++ b/webrtc/modules/audio_coding/codecs/ilbc/augmented_cb_corr.h
@@ -36,7 +36,6 @@
int16_t low, /* (i) Lag to start from (typically
20) */
int16_t high, /* (i) Lag to end at (typically 39 */
- int16_t scale); /* (i) Scale factor to use for
- the crossDot */
+ int scale); /* (i) Scale factor to use for the crossDot */
#endif
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..2b7e082 100644
--- a/webrtc/modules/audio_coding/codecs/ilbc/cb_mem_energy.c
+++ b/webrtc/modules/audio_coding/codecs/ilbc/cb_mem_energy.c
@@ -34,7 +34,7 @@
int16_t lTarget, /* (i) Length of the target vector */
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 */
+ int scale, /* (i) The scaling of all energy values */
int16_t base_size /* (i) Index to where the energy values should be stored */
) {
int16_t *ppi, *ppo, *pp;
diff --git a/webrtc/modules/audio_coding/codecs/ilbc/cb_mem_energy.h b/webrtc/modules/audio_coding/codecs/ilbc/cb_mem_energy.h
index 1b50c0b..68dd7da 100644
--- a/webrtc/modules/audio_coding/codecs/ilbc/cb_mem_energy.h
+++ b/webrtc/modules/audio_coding/codecs/ilbc/cb_mem_energy.h
@@ -27,7 +27,7 @@
int16_t lTarget, /* (i) Length of the target vector */
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 */
+ int scale, /* (i) The scaling of all energy values */
int16_t base_size /* (i) Index to where the energy values should be stored */
);
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..39f18c2 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
@@ -22,7 +22,7 @@
void WebRtcIlbcfix_CbMemEnergyAugmentation(
int16_t *interpSamples, /* (i) The interpolated samples */
int16_t *CBmem, /* (i) The CB memory */
- int16_t scale, /* (i) The scaling of all energy values */
+ int scale, /* (i) The scaling of all energy values */
int16_t base_size, /* (i) Index to where the 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..e73d414 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
@@ -22,7 +22,7 @@
void WebRtcIlbcfix_CbMemEnergyAugmentation(
int16_t *interpSamples, /* (i) The interpolated samples */
int16_t *CBmem, /* (i) The CB memory */
- int16_t scale, /* (i) The scaling of all energy values */
+ int scale, /* (i) The scaling of all energy values */
int16_t base_size, /* (i) Index to where the 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 e5d1424..b675441 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
@@ -28,7 +28,7 @@
int16_t *ppo, /* (i) input pointer 2 */
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 */
+ int scale, /* (i) The scaling of all energy values */
int16_t base_size /* (i) Index to where the energy values should be stored */
)
{
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..c7bf929 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
@@ -26,7 +26,7 @@
int16_t *ppo, /* (i) input pointer 2 */
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 */
+ int scale, /* (i) The scaling of all energy values */
int16_t base_size /* (i) Index to where the energy values should be stored */
);
diff --git a/webrtc/modules/audio_coding/codecs/ilbc/cb_search.c b/webrtc/modules/audio_coding/codecs/ilbc/cb_search.c
index 4c6196b..2a77f4f 100644
--- a/webrtc/modules/audio_coding/codecs/ilbc/cb_search.c
+++ b/webrtc/modules/audio_coding/codecs/ilbc/cb_search.c
@@ -46,7 +46,9 @@
int16_t block /* (i) the subblock number */
) {
int16_t i, j, stage, range;
- int16_t *pp, scale, tmp;
+ int16_t *pp;
+ int16_t tmp;
+ int scale;
int16_t bits, temp1, temp2;
int16_t base_size;
int32_t codedEner, targetEner;
diff --git a/webrtc/modules/audio_coding/codecs/ilbc/enhancer_interface.c b/webrtc/modules/audio_coding/codecs/ilbc/enhancer_interface.c
index fde5414..db4b8d4 100644
--- a/webrtc/modules/audio_coding/codecs/ilbc/enhancer_interface.c
+++ b/webrtc/modules/audio_coding/codecs/ilbc/enhancer_interface.c
@@ -121,8 +121,8 @@
shifts = WEBRTC_SPL_MAX(0, shifts);
/* compute cross correlation */
- WebRtcSpl_CrossCorrelation(corr32, target, regressor,
- ENH_BLOCKL_HALF, 50, (int16_t)shifts, -1);
+ WebRtcSpl_CrossCorrelation(corr32, target, regressor, ENH_BLOCKL_HALF, 50,
+ shifts, -1);
/* Find 3 highest correlations that should be compared for the
highest (corr*corr)/ener */
@@ -207,8 +207,8 @@
shifts=0;
/* compute cross correlation */
- WebRtcSpl_CrossCorrelation(corr32, target, regressor,
- plc_blockl, 3, (int16_t)shifts, 1);
+ WebRtcSpl_CrossCorrelation(corr32, target, regressor, plc_blockl, 3, shifts,
+ 1);
/* find lag */
lag=WebRtcSpl_MaxIndexW32(corr32, 3);
diff --git a/webrtc/modules/audio_coding/codecs/ilbc/ilbc.c b/webrtc/modules/audio_coding/codecs/ilbc/ilbc.c
index 88ad33b..e41c095 100644
--- a/webrtc/modules/audio_coding/codecs/ilbc/ilbc.c
+++ b/webrtc/modules/audio_coding/codecs/ilbc/ilbc.c
@@ -88,10 +88,10 @@
}
}
-int16_t WebRtcIlbcfix_Encode(IlbcEncoderInstance* iLBCenc_inst,
- const int16_t* speechIn,
- int16_t len,
- uint8_t* encoded) {
+int WebRtcIlbcfix_Encode(IlbcEncoderInstance* iLBCenc_inst,
+ const int16_t* speechIn,
+ int16_t len,
+ uint8_t* encoded) {
int16_t pos = 0;
int16_t encpos = 0;
@@ -141,11 +141,11 @@
}
-int16_t WebRtcIlbcfix_Decode(IlbcDecoderInstance* iLBCdec_inst,
- const uint8_t* encoded,
- int16_t len,
- int16_t* decoded,
- int16_t* speechType)
+int WebRtcIlbcfix_Decode(IlbcDecoderInstance* iLBCdec_inst,
+ const uint8_t* encoded,
+ int16_t len,
+ int16_t* decoded,
+ int16_t* speechType)
{
int i=0;
/* Allow for automatic switching between the frame sizes
@@ -194,11 +194,11 @@
return(i*((IlbcDecoder*)iLBCdec_inst)->blockl);
}
-int16_t WebRtcIlbcfix_Decode20Ms(IlbcDecoderInstance* iLBCdec_inst,
- const uint8_t* encoded,
- int16_t len,
- int16_t* decoded,
- int16_t* speechType)
+int WebRtcIlbcfix_Decode20Ms(IlbcDecoderInstance* iLBCdec_inst,
+ const uint8_t* encoded,
+ int16_t len,
+ int16_t* decoded,
+ int16_t* speechType)
{
int i=0;
if ((len==((IlbcDecoder*)iLBCdec_inst)->no_of_bytes)||
@@ -222,11 +222,11 @@
return(i*((IlbcDecoder*)iLBCdec_inst)->blockl);
}
-int16_t WebRtcIlbcfix_Decode30Ms(IlbcDecoderInstance* iLBCdec_inst,
- const uint8_t* encoded,
- int16_t len,
- int16_t* decoded,
- int16_t* speechType)
+int WebRtcIlbcfix_Decode30Ms(IlbcDecoderInstance* iLBCdec_inst,
+ const uint8_t* encoded,
+ int16_t len,
+ int16_t* decoded,
+ int16_t* speechType)
{
int i=0;
if ((len==((IlbcDecoder*)iLBCdec_inst)->no_of_bytes)||
diff --git a/webrtc/modules/audio_coding/codecs/ilbc/init_decode.c b/webrtc/modules/audio_coding/codecs/ilbc/init_decode.c
index d903ac7..0659e50 100644
--- a/webrtc/modules/audio_coding/codecs/ilbc/init_decode.c
+++ b/webrtc/modules/audio_coding/codecs/ilbc/init_decode.c
@@ -23,7 +23,7 @@
* Initiation of decoder instance.
*---------------------------------------------------------------*/
-int16_t WebRtcIlbcfix_InitDecode( /* (o) Number of decoded samples */
+int WebRtcIlbcfix_InitDecode( /* (o) Number of decoded samples */
IlbcDecoder *iLBCdec_inst, /* (i/o) Decoder instance */
int16_t mode, /* (i) frame size mode */
int use_enhancer) { /* (i) 1: use enhancer, 0: no enhancer */
diff --git a/webrtc/modules/audio_coding/codecs/ilbc/init_decode.h b/webrtc/modules/audio_coding/codecs/ilbc/init_decode.h
index 4871b5c..cdd2192 100644
--- a/webrtc/modules/audio_coding/codecs/ilbc/init_decode.h
+++ b/webrtc/modules/audio_coding/codecs/ilbc/init_decode.h
@@ -25,7 +25,7 @@
* Initiation of decoder instance.
*---------------------------------------------------------------*/
-int16_t WebRtcIlbcfix_InitDecode( /* (o) Number of decoded samples */
+int WebRtcIlbcfix_InitDecode( /* (o) Number of decoded samples */
IlbcDecoder *iLBCdec_inst, /* (i/o) Decoder instance */
int16_t mode, /* (i) frame size mode */
int use_enhancer /* (i) 1 to use enhancer
diff --git a/webrtc/modules/audio_coding/codecs/ilbc/init_encode.c b/webrtc/modules/audio_coding/codecs/ilbc/init_encode.c
index 1a2fa08..9c562db 100644
--- a/webrtc/modules/audio_coding/codecs/ilbc/init_encode.c
+++ b/webrtc/modules/audio_coding/codecs/ilbc/init_encode.c
@@ -23,7 +23,7 @@
* Initiation of encoder instance.
*---------------------------------------------------------------*/
-int16_t WebRtcIlbcfix_InitEncode( /* (o) Number of bytes encoded */
+int WebRtcIlbcfix_InitEncode( /* (o) Number of bytes encoded */
IlbcEncoder *iLBCenc_inst, /* (i/o) Encoder instance */
int16_t mode) { /* (i) frame size mode */
iLBCenc_inst->mode = mode;
diff --git a/webrtc/modules/audio_coding/codecs/ilbc/init_encode.h b/webrtc/modules/audio_coding/codecs/ilbc/init_encode.h
index 2eea27c..7154661 100644
--- a/webrtc/modules/audio_coding/codecs/ilbc/init_encode.h
+++ b/webrtc/modules/audio_coding/codecs/ilbc/init_encode.h
@@ -25,7 +25,7 @@
* Initiation of encoder instance.
*---------------------------------------------------------------*/
-int16_t WebRtcIlbcfix_InitEncode( /* (o) Number of bytes encoded */
+int WebRtcIlbcfix_InitEncode( /* (o) Number of bytes encoded */
IlbcEncoder *iLBCenc_inst, /* (i/o) Encoder instance */
int16_t mode /* (i) frame size mode */
);
diff --git a/webrtc/modules/audio_coding/codecs/ilbc/interface/ilbc.h b/webrtc/modules/audio_coding/codecs/ilbc/interface/ilbc.h
index b7e1735..4934968 100644
--- a/webrtc/modules/audio_coding/codecs/ilbc/interface/ilbc.h
+++ b/webrtc/modules/audio_coding/codecs/ilbc/interface/ilbc.h
@@ -135,10 +135,10 @@
* -1 - Error
*/
- int16_t WebRtcIlbcfix_Encode(IlbcEncoderInstance *iLBCenc_inst,
- const int16_t *speechIn,
- int16_t len,
- uint8_t* encoded);
+ int WebRtcIlbcfix_Encode(IlbcEncoderInstance *iLBCenc_inst,
+ const int16_t *speechIn,
+ int16_t len,
+ uint8_t* encoded);
/****************************************************************************
* WebRtcIlbcfix_DecoderInit(...)
@@ -180,21 +180,21 @@
* -1 - Error
*/
- int16_t WebRtcIlbcfix_Decode(IlbcDecoderInstance* iLBCdec_inst,
+ int WebRtcIlbcfix_Decode(IlbcDecoderInstance* iLBCdec_inst,
+ const uint8_t* encoded,
+ int16_t len,
+ int16_t* decoded,
+ int16_t* speechType);
+ int WebRtcIlbcfix_Decode20Ms(IlbcDecoderInstance* iLBCdec_inst,
const uint8_t* encoded,
int16_t len,
int16_t* decoded,
int16_t* speechType);
- int16_t WebRtcIlbcfix_Decode20Ms(IlbcDecoderInstance* iLBCdec_inst,
- const uint8_t* encoded,
- int16_t len,
- int16_t* decoded,
- int16_t* speechType);
- int16_t WebRtcIlbcfix_Decode30Ms(IlbcDecoderInstance* iLBCdec_inst,
- const uint8_t* encoded,
- int16_t len,
- int16_t* decoded,
- int16_t* speechType);
+ int WebRtcIlbcfix_Decode30Ms(IlbcDecoderInstance* iLBCdec_inst,
+ const uint8_t* encoded,
+ int16_t len,
+ int16_t* decoded,
+ int16_t* speechType);
/****************************************************************************
* WebRtcIlbcfix_DecodePlc(...)
diff --git a/webrtc/modules/audio_coding/codecs/ilbc/my_corr.c b/webrtc/modules/audio_coding/codecs/ilbc/my_corr.c
index 048745a..0da6d54 100644
--- a/webrtc/modules/audio_coding/codecs/ilbc/my_corr.c
+++ b/webrtc/modules/audio_coding/codecs/ilbc/my_corr.c
@@ -29,7 +29,8 @@
const int16_t *seq2, /* (i) second sequence */
int16_t dim2 /* (i) dimension seq2 */
){
- int16_t max, scale, loops;
+ int16_t max, loops;
+ int scale;
/* Calculate correlation between the two sequences. Scale the
result of the multiplcication to maximum 26 bits in order
@@ -37,7 +38,7 @@
max=WebRtcSpl_MaxAbsValueW16(seq1, dim1);
scale=WebRtcSpl_GetSizeInBits(max);
- scale = (int16_t)(2 * scale - 26);
+ scale = 2 * scale - 26;
if (scale<0) {
scale=0;
}
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 370bf9d..1e966a7 100644
--- a/webrtc/modules/audio_coding/codecs/ilbc/test/iLBC_testLib.c
+++ b/webrtc/modules/audio_coding/codecs/ilbc/test/iLBC_testLib.c
@@ -41,7 +41,8 @@
{
FILE *ifileid,*efileid,*ofileid, *chfileid;
short encoded_data[55], data[240], speechType;
- short len, mode, pli;
+ int len;
+ short mode, pli;
int blockcount = 0;
IlbcEncoderInstance *Enc_Inst;
@@ -173,7 +174,8 @@
/* decoding */
fprintf(stderr, "--- Decoding block %i --- ",blockcount);
if (pli==1) {
- len=WebRtcIlbcfix_Decode(Dec_Inst, encoded_data, len, data, &speechType);
+ len=WebRtcIlbcfix_Decode(Dec_Inst, encoded_data, (int16_t)len, data,
+ &speechType);
} else {
len=WebRtcIlbcfix_DecodePlc(Dec_Inst, data, 1);
}