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}
This commit is contained in:
Peter Kasting 2015-06-11 18:51:20 -07:00
parent aba07ef6d9
commit a8b335c709
18 changed files with 59 additions and 56 deletions

View File

@ -31,7 +31,7 @@ void WebRtcIlbcfix_AugmentedCbCorr(
int16_t low, /* (i) Lag to start from (typically int16_t low, /* (i) Lag to start from (typically
20) */ 20) */
int16_t high, /* (i) Lag to end at (typically 39) */ 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 */ the crossDot */
{ {
int lagcount; int lagcount;

View File

@ -36,7 +36,6 @@ void WebRtcIlbcfix_AugmentedCbCorr(
int16_t low, /* (i) Lag to start from (typically int16_t low, /* (i) Lag to start from (typically
20) */ 20) */
int16_t high, /* (i) Lag to end at (typically 39 */ 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 */
the crossDot */
#endif #endif

View File

@ -34,7 +34,7 @@ void WebRtcIlbcfix_CbMemEnergy(
int16_t lTarget, /* (i) Length of the target vector */ int16_t lTarget, /* (i) Length of the target vector */
int16_t *energyW16, /* (o) Energy in the CB vectors */ int16_t *energyW16, /* (o) Energy in the CB vectors */
int16_t *energyShifts, /* (o) Shift value of the energy */ 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 base_size /* (i) Index to where energy values should be stored */
) { ) {
int16_t *ppi, *ppo, *pp; int16_t *ppi, *ppo, *pp;

View File

@ -27,7 +27,7 @@ void WebRtcIlbcfix_CbMemEnergy(
int16_t lTarget, /* (i) Length of the target vector */ int16_t lTarget, /* (i) Length of the target vector */
int16_t *energyW16, /* (o) Energy in the CB vectors */ int16_t *energyW16, /* (o) Energy in the CB vectors */
int16_t *energyShifts, /* (o) Shift value of the energy */ 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 base_size /* (i) Index to where the energy values should be stored */
); );

View File

@ -22,7 +22,7 @@
void WebRtcIlbcfix_CbMemEnergyAugmentation( void WebRtcIlbcfix_CbMemEnergyAugmentation(
int16_t *interpSamples, /* (i) The interpolated samples */ int16_t *interpSamples, /* (i) The interpolated samples */
int16_t *CBmem, /* (i) The CB memory */ 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 base_size, /* (i) Index to where energy values should be stored */
int16_t *energyW16, /* (o) Energy in the CB vectors */ int16_t *energyW16, /* (o) Energy in the CB vectors */
int16_t *energyShifts /* (o) Shift value of the energy */ int16_t *energyShifts /* (o) Shift value of the energy */

View File

@ -22,7 +22,7 @@
void WebRtcIlbcfix_CbMemEnergyAugmentation( void WebRtcIlbcfix_CbMemEnergyAugmentation(
int16_t *interpSamples, /* (i) The interpolated samples */ int16_t *interpSamples, /* (i) The interpolated samples */
int16_t *CBmem, /* (i) The CB memory */ 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 base_size, /* (i) Index to where energy values should be stored */
int16_t *energyW16, /* (o) Energy in the CB vectors */ int16_t *energyW16, /* (o) Energy in the CB vectors */
int16_t *energyShifts /* (o) Shift value of the energy */ int16_t *energyShifts /* (o) Shift value of the energy */

View File

@ -28,7 +28,7 @@ void WebRtcIlbcfix_CbMemEnergyCalc(
int16_t *ppo, /* (i) input pointer 2 */ int16_t *ppo, /* (i) input pointer 2 */
int16_t *energyW16, /* (o) Energy in the CB vectors */ int16_t *energyW16, /* (o) Energy in the CB vectors */
int16_t *energyShifts, /* (o) Shift value of the energy */ 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 base_size /* (i) Index to where energy values should be stored */
) )
{ {

View File

@ -26,7 +26,7 @@ void WebRtcIlbcfix_CbMemEnergyCalc(
int16_t *ppo, /* (i) input pointer 2 */ int16_t *ppo, /* (i) input pointer 2 */
int16_t *energyW16, /* (o) Energy in the CB vectors */ int16_t *energyW16, /* (o) Energy in the CB vectors */
int16_t *energyShifts, /* (o) Shift value of the energy */ 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 base_size /* (i) Index to where energy values should be stored */
); );

View File

@ -46,7 +46,9 @@ void WebRtcIlbcfix_CbSearch(
int16_t block /* (i) the subblock number */ int16_t block /* (i) the subblock number */
) { ) {
int16_t i, j, stage, range; 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 bits, temp1, temp2;
int16_t base_size; int16_t base_size;
int32_t codedEner, targetEner; int32_t codedEner, targetEner;

View File

@ -119,8 +119,8 @@ int WebRtcIlbcfix_EnhancerInterface( /* (o) Estimated lag in end of in[] */
shifts = WEBRTC_SPL_MAX(0, shifts); shifts = WEBRTC_SPL_MAX(0, shifts);
/* compute cross correlation */ /* compute cross correlation */
WebRtcSpl_CrossCorrelation(corr32, target, regressor, WebRtcSpl_CrossCorrelation(corr32, target, regressor, ENH_BLOCKL_HALF, 50,
ENH_BLOCKL_HALF, 50, (int16_t)shifts, -1); shifts, -1);
/* Find 3 highest correlations that should be compared for the /* Find 3 highest correlations that should be compared for the
highest (corr*corr)/ener */ highest (corr*corr)/ener */
@ -205,8 +205,8 @@ int WebRtcIlbcfix_EnhancerInterface( /* (o) Estimated lag in end of in[] */
shifts=0; shifts=0;
/* compute cross correlation */ /* compute cross correlation */
WebRtcSpl_CrossCorrelation(corr32, target, regressor, WebRtcSpl_CrossCorrelation(corr32, target, regressor, plc_blockl, 3, shifts,
plc_blockl, 3, (int16_t)shifts, 1); 1);
/* find lag */ /* find lag */
lag=WebRtcSpl_MaxIndexW32(corr32, 3); lag=WebRtcSpl_MaxIndexW32(corr32, 3);

View File

@ -88,10 +88,10 @@ int16_t WebRtcIlbcfix_EncoderInit(IlbcEncoderInstance* iLBCenc_inst,
} }
} }
int16_t WebRtcIlbcfix_Encode(IlbcEncoderInstance* iLBCenc_inst, int WebRtcIlbcfix_Encode(IlbcEncoderInstance* iLBCenc_inst,
const int16_t* speechIn, const int16_t* speechIn,
int16_t len, int16_t len,
uint8_t* encoded) { uint8_t* encoded) {
int16_t pos = 0; int16_t pos = 0;
int16_t encpos = 0; int16_t encpos = 0;
@ -141,11 +141,11 @@ int16_t WebRtcIlbcfix_Decoderinit30Ms(IlbcDecoderInstance *iLBCdec_inst) {
} }
int16_t WebRtcIlbcfix_Decode(IlbcDecoderInstance* iLBCdec_inst, int WebRtcIlbcfix_Decode(IlbcDecoderInstance* iLBCdec_inst,
const uint8_t* encoded, const uint8_t* encoded,
int16_t len, int16_t len,
int16_t* decoded, int16_t* decoded,
int16_t* speechType) int16_t* speechType)
{ {
int i=0; int i=0;
/* Allow for automatic switching between the frame sizes /* Allow for automatic switching between the frame sizes
@ -194,11 +194,11 @@ int16_t WebRtcIlbcfix_Decode(IlbcDecoderInstance* iLBCdec_inst,
return(i*((IlbcDecoder*)iLBCdec_inst)->blockl); return(i*((IlbcDecoder*)iLBCdec_inst)->blockl);
} }
int16_t WebRtcIlbcfix_Decode20Ms(IlbcDecoderInstance* iLBCdec_inst, int WebRtcIlbcfix_Decode20Ms(IlbcDecoderInstance* iLBCdec_inst,
const uint8_t* encoded, const uint8_t* encoded,
int16_t len, int16_t len,
int16_t* decoded, int16_t* decoded,
int16_t* speechType) int16_t* speechType)
{ {
int i=0; int i=0;
if ((len==((IlbcDecoder*)iLBCdec_inst)->no_of_bytes)|| if ((len==((IlbcDecoder*)iLBCdec_inst)->no_of_bytes)||
@ -222,11 +222,11 @@ int16_t WebRtcIlbcfix_Decode20Ms(IlbcDecoderInstance* iLBCdec_inst,
return(i*((IlbcDecoder*)iLBCdec_inst)->blockl); return(i*((IlbcDecoder*)iLBCdec_inst)->blockl);
} }
int16_t WebRtcIlbcfix_Decode30Ms(IlbcDecoderInstance* iLBCdec_inst, int WebRtcIlbcfix_Decode30Ms(IlbcDecoderInstance* iLBCdec_inst,
const uint8_t* encoded, const uint8_t* encoded,
int16_t len, int16_t len,
int16_t* decoded, int16_t* decoded,
int16_t* speechType) int16_t* speechType)
{ {
int i=0; int i=0;
if ((len==((IlbcDecoder*)iLBCdec_inst)->no_of_bytes)|| if ((len==((IlbcDecoder*)iLBCdec_inst)->no_of_bytes)||

View File

@ -23,7 +23,7 @@
* Initiation of decoder instance. * 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 */ IlbcDecoder *iLBCdec_inst, /* (i/o) Decoder instance */
int16_t mode, /* (i) frame size mode */ int16_t mode, /* (i) frame size mode */
int use_enhancer) { /* (i) 1: use enhancer, 0: no enhancer */ int use_enhancer) { /* (i) 1: use enhancer, 0: no enhancer */

View File

@ -25,7 +25,7 @@
* Initiation of decoder instance. * 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 */ IlbcDecoder *iLBCdec_inst, /* (i/o) Decoder instance */
int16_t mode, /* (i) frame size mode */ int16_t mode, /* (i) frame size mode */
int use_enhancer /* (i) 1 to use enhancer int use_enhancer /* (i) 1 to use enhancer

View File

@ -23,7 +23,7 @@
* Initiation of encoder instance. * 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 */ IlbcEncoder *iLBCenc_inst, /* (i/o) Encoder instance */
int16_t mode) { /* (i) frame size mode */ int16_t mode) { /* (i) frame size mode */
iLBCenc_inst->mode = mode; iLBCenc_inst->mode = mode;

View File

@ -25,7 +25,7 @@
* Initiation of encoder instance. * 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 */ IlbcEncoder *iLBCenc_inst, /* (i/o) Encoder instance */
int16_t mode /* (i) frame size mode */ int16_t mode /* (i) frame size mode */
); );

View File

@ -135,10 +135,10 @@ extern "C" {
* -1 - Error * -1 - Error
*/ */
int16_t WebRtcIlbcfix_Encode(IlbcEncoderInstance *iLBCenc_inst, int WebRtcIlbcfix_Encode(IlbcEncoderInstance *iLBCenc_inst,
const int16_t *speechIn, const int16_t *speechIn,
int16_t len, int16_t len,
uint8_t* encoded); uint8_t* encoded);
/**************************************************************************** /****************************************************************************
* WebRtcIlbcfix_DecoderInit(...) * WebRtcIlbcfix_DecoderInit(...)
@ -180,21 +180,21 @@ extern "C" {
* -1 - Error * -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);
int WebRtcIlbcfix_Decode30Ms(IlbcDecoderInstance* iLBCdec_inst,
const uint8_t* encoded, const uint8_t* encoded,
int16_t len, int16_t len,
int16_t* decoded, int16_t* decoded,
int16_t* speechType); 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);
/**************************************************************************** /****************************************************************************
* WebRtcIlbcfix_DecodePlc(...) * WebRtcIlbcfix_DecodePlc(...)

View File

@ -29,7 +29,8 @@ void WebRtcIlbcfix_MyCorr(
const int16_t* seq2, /* (i) second sequence */ const int16_t* seq2, /* (i) second sequence */
int16_t dim2 /* (i) dimension seq2 */ 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 /* Calculate correlation between the two sequences. Scale the
result of the multiplcication to maximum 26 bits in order result of the multiplcication to maximum 26 bits in order
@ -37,7 +38,7 @@ void WebRtcIlbcfix_MyCorr(
max=WebRtcSpl_MaxAbsValueW16(seq1, dim1); max=WebRtcSpl_MaxAbsValueW16(seq1, dim1);
scale=WebRtcSpl_GetSizeInBits(max); scale=WebRtcSpl_GetSizeInBits(max);
scale = (int16_t)(2 * scale - 26); scale = 2 * scale - 26;
if (scale<0) { if (scale<0) {
scale=0; scale=0;
} }

View File

@ -41,7 +41,8 @@ int main(int argc, char* argv[])
{ {
FILE *ifileid,*efileid,*ofileid, *chfileid; FILE *ifileid,*efileid,*ofileid, *chfileid;
short encoded_data[55], data[240], speechType; short encoded_data[55], data[240], speechType;
short len, mode, pli; int len;
short mode, pli;
size_t readlen; size_t readlen;
int blockcount = 0; int blockcount = 0;
@ -173,7 +174,7 @@ int main(int argc, char* argv[])
/* decoding */ /* decoding */
fprintf(stderr, "--- Decoding block %i --- ",blockcount); fprintf(stderr, "--- Decoding block %i --- ",blockcount);
if (pli==1) { if (pli==1) {
len=WebRtcIlbcfix_Decode(Dec_Inst, encoded_data, len, data, len=WebRtcIlbcfix_Decode(Dec_Inst, encoded_data, (int16_t)len, data,
&speechType); &speechType);
if (len < 0) { if (len < 0) {
fprintf(stderr, "Error decoding\n"); fprintf(stderr, "Error decoding\n");