Reland "Upconvert various types to int.", ilbc portion.
This reverts portions of commit cb180976dd0e9672cde4523d87b5f4857478b5e9, which
reverted commit 83ad33a8aed1fb00e422b6abd33c3e8942821c24. Specifically, the
files in webrtc/modules/audio_coding/codecs/ilbc/ are relanded.
The original commit message is below:
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
TBR=kwiberg
Review URL: https://codereview.webrtc.org/1184643002
Cr-Commit-Position: refs/heads/master@{#9423}
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 8dfde21..1b8c506 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 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 789d2d4..2f3c299 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 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 9b5f85c..46fb2fd 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 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 ec2dcaa..481dfba 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 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 6428269..7f0cadf 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 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 bc60149..d502cf0 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 6dca0b7..c630dd5 100644
--- a/webrtc/modules/audio_coding/codecs/ilbc/enhancer_interface.c
+++ b/webrtc/modules/audio_coding/codecs/ilbc/enhancer_interface.c
@@ -119,8 +119,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 */
@@ -205,8 +205,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 ab08001..3261015 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 3dcda29c..b4e36b6 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;
size_t readlen;
int blockcount = 0;
@@ -173,7 +174,7 @@
/* decoding */
fprintf(stderr, "--- Decoding block %i --- ",blockcount);
if (pli==1) {
- len=WebRtcIlbcfix_Decode(Dec_Inst, encoded_data, len, data,
+ len=WebRtcIlbcfix_Decode(Dec_Inst, encoded_data, (int16_t)len, data,
&speechType);
if (len < 0) {
fprintf(stderr, "Error decoding\n");