From a8b335c709b244685345cfabb3b72ce672a09d96 Mon Sep 17 00:00:00 2001 From: Peter Kasting Date: Thu, 11 Jun 2015 18:51:20 -0700 Subject: [PATCH] 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} --- .../codecs/ilbc/augmented_cb_corr.c | 2 +- .../codecs/ilbc/augmented_cb_corr.h | 3 +- .../audio_coding/codecs/ilbc/cb_mem_energy.c | 2 +- .../audio_coding/codecs/ilbc/cb_mem_energy.h | 2 +- .../codecs/ilbc/cb_mem_energy_augmentation.c | 2 +- .../codecs/ilbc/cb_mem_energy_augmentation.h | 2 +- .../codecs/ilbc/cb_mem_energy_calc.c | 2 +- .../codecs/ilbc/cb_mem_energy_calc.h | 2 +- .../audio_coding/codecs/ilbc/cb_search.c | 4 +- .../codecs/ilbc/enhancer_interface.c | 8 ++-- .../modules/audio_coding/codecs/ilbc/ilbc.c | 38 +++++++++---------- .../audio_coding/codecs/ilbc/init_decode.c | 2 +- .../audio_coding/codecs/ilbc/init_decode.h | 2 +- .../audio_coding/codecs/ilbc/init_encode.c | 2 +- .../audio_coding/codecs/ilbc/init_encode.h | 2 +- .../audio_coding/codecs/ilbc/interface/ilbc.h | 30 +++++++-------- .../audio_coding/codecs/ilbc/my_corr.c | 5 ++- .../codecs/ilbc/test/iLBC_testLib.c | 5 ++- 18 files changed, 59 insertions(+), 56 deletions(-) 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 d8f8c93a8..c24b4a6ac 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 @@ void WebRtcIlbcfix_AugmentedCbCorr( 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 533d0a49e..a0435c434 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 @@ void WebRtcIlbcfix_AugmentedCbCorr( 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 8dfde213d..1b8c506fc 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 @@ void WebRtcIlbcfix_CbMemEnergy( 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 1b50c0b4e..68dd7dac5 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 @@ void WebRtcIlbcfix_CbMemEnergy( 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 789d2d49f..2f3c299f6 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 9b5f85c73..46fb2fdc1 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 ec2dcaa8f..481dfbac0 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 @@ void WebRtcIlbcfix_CbMemEnergyCalc( 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 64282695a..7f0cadf6e 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 @@ void WebRtcIlbcfix_CbMemEnergyCalc( 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 bc601492e..d502cf0c3 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 @@ void WebRtcIlbcfix_CbSearch( 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 6dca0b7ba..c630dd5af 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 @@ int WebRtcIlbcfix_EnhancerInterface( /* (o) Estimated lag in end of in[] */ 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 @@ int WebRtcIlbcfix_EnhancerInterface( /* (o) Estimated lag in end of in[] */ 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 88ad33b5a..e41c095f8 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_EncoderInit(IlbcEncoderInstance* iLBCenc_inst, } } -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_Decoderinit30Ms(IlbcDecoderInstance *iLBCdec_inst) { } -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 @@ int16_t WebRtcIlbcfix_Decode(IlbcDecoderInstance* iLBCdec_inst, 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 @@ int16_t WebRtcIlbcfix_Decode20Ms(IlbcDecoderInstance* iLBCdec_inst, 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 d903ac7e8..0659e5005 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 4871b5c1a..cdd219207 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 1a2fa0892..9c562dbfc 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 2eea27c8e..7154661fb 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 b7e1735e5..493496848 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 @@ extern "C" { * -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 @@ extern "C" { * -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, 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); /**************************************************************************** * 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 ab08001fc..326101525 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 @@ void WebRtcIlbcfix_MyCorr( 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 @@ void WebRtcIlbcfix_MyCorr( 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 3dcda29c8..b4e36b629 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 @@ int main(int argc, char* argv[]) { 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 @@ int main(int argc, char* argv[]) /* 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");