Reland "Upconvert various types to int.", isac portion.

This reverts portions of commit cb180976dd, which
reverted commit 83ad33a8ae.  Specifically, the
files in webrtc/modules/audio_coding/codecs/isac/ 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/1179093002

Cr-Commit-Position: refs/heads/master@{#9422}
This commit is contained in:
Peter Kasting 2015-06-11 18:19:24 -07:00
parent 7faba36f79
commit aba07ef6d9
21 changed files with 138 additions and 137 deletions

View file

@ -184,7 +184,7 @@ int AudioEncoderDecoderIsacT<T>::DecodeInternal(const uint8_t* encoded,
decoder_sample_rate_hz_ = sample_rate_hz; decoder_sample_rate_hz_ = sample_rate_hz;
} }
int16_t temp_type = 1; // Default is speech. int16_t temp_type = 1; // Default is speech.
int16_t ret = int ret =
T::DecodeInternal(isac_state_, encoded, static_cast<int16_t>(encoded_len), T::DecodeInternal(isac_state_, encoded, static_cast<int16_t>(encoded_len),
decoded, &temp_type); decoded, &temp_type);
*speech_type = ConvertSpeechType(temp_type); *speech_type = ConvertSpeechType(temp_type);

View file

@ -25,12 +25,12 @@ struct IsacFix {
static const uint16_t kFixSampleRate = 16000; static const uint16_t kFixSampleRate = 16000;
static inline int16_t Control(instance_type* inst, static inline int16_t Control(instance_type* inst,
int32_t rate, int32_t rate,
int16_t framesize) { int framesize) {
return WebRtcIsacfix_Control(inst, rate, framesize); return WebRtcIsacfix_Control(inst, rate, framesize);
} }
static inline int16_t ControlBwe(instance_type* inst, static inline int16_t ControlBwe(instance_type* inst,
int32_t rate_bps, int32_t rate_bps,
int16_t frame_size_ms, int frame_size_ms,
int16_t enforce_frame_size) { int16_t enforce_frame_size) {
return WebRtcIsacfix_ControlBwe(inst, rate_bps, frame_size_ms, return WebRtcIsacfix_ControlBwe(inst, rate_bps, frame_size_ms,
enforce_frame_size); enforce_frame_size);
@ -38,7 +38,7 @@ struct IsacFix {
static inline int16_t Create(instance_type** inst) { static inline int16_t Create(instance_type** inst) {
return WebRtcIsacfix_Create(inst); return WebRtcIsacfix_Create(inst);
} }
static inline int16_t DecodeInternal(instance_type* inst, static inline int DecodeInternal(instance_type* inst,
const uint8_t* encoded, const uint8_t* encoded,
int16_t len, int16_t len,
int16_t* decoded, int16_t* decoded,
@ -53,7 +53,7 @@ struct IsacFix {
static inline int16_t DecoderInit(instance_type* inst) { static inline int16_t DecoderInit(instance_type* inst) {
return WebRtcIsacfix_DecoderInit(inst); return WebRtcIsacfix_DecoderInit(inst);
} }
static inline int16_t Encode(instance_type* inst, static inline int Encode(instance_type* inst,
const int16_t* speech_in, const int16_t* speech_in,
uint8_t* encoded) { uint8_t* encoded) {
return WebRtcIsacfix_Encode(inst, speech_in, encoded); return WebRtcIsacfix_Encode(inst, speech_in, encoded);

View file

@ -128,7 +128,7 @@ extern "C" {
* -1 - Error * -1 - Error
*/ */
int16_t WebRtcIsacfix_Encode(ISACFIX_MainStruct *ISAC_main_inst, int WebRtcIsacfix_Encode(ISACFIX_MainStruct *ISAC_main_inst,
const int16_t *speechIn, const int16_t *speechIn,
uint8_t* encoded); uint8_t* encoded);
@ -251,7 +251,7 @@ extern "C" {
* -1 - Error * -1 - Error
*/ */
int16_t WebRtcIsacfix_Decode(ISACFIX_MainStruct *ISAC_main_inst, int WebRtcIsacfix_Decode(ISACFIX_MainStruct *ISAC_main_inst,
const uint8_t* encoded, const uint8_t* encoded,
int16_t len, int16_t len,
int16_t *decoded, int16_t *decoded,
@ -280,7 +280,7 @@ extern "C" {
*/ */
#ifdef WEBRTC_ISAC_FIX_NB_CALLS_ENABLED #ifdef WEBRTC_ISAC_FIX_NB_CALLS_ENABLED
int16_t WebRtcIsacfix_DecodeNb(ISACFIX_MainStruct *ISAC_main_inst, int WebRtcIsacfix_DecodeNb(ISACFIX_MainStruct *ISAC_main_inst,
const uint16_t *encoded, const uint16_t *encoded,
int16_t len, int16_t len,
int16_t *decoded, int16_t *decoded,
@ -379,7 +379,7 @@ extern "C" {
int16_t WebRtcIsacfix_Control(ISACFIX_MainStruct *ISAC_main_inst, int16_t WebRtcIsacfix_Control(ISACFIX_MainStruct *ISAC_main_inst,
int16_t rate, int16_t rate,
int16_t framesize); int framesize);
@ -407,7 +407,7 @@ extern "C" {
int16_t WebRtcIsacfix_ControlBwe(ISACFIX_MainStruct *ISAC_main_inst, int16_t WebRtcIsacfix_ControlBwe(ISACFIX_MainStruct *ISAC_main_inst,
int16_t rateBPS, int16_t rateBPS,
int16_t frameSizeMs, int frameSizeMs,
int16_t enforceFrameSize); int16_t enforceFrameSize);

View file

@ -226,7 +226,7 @@ int WebRtcIsacfix_EncLogisticMulti2(Bitstr_enc *streamData,
* Return value : number of bytes in the stream so far * Return value : number of bytes in the stream so far
* -1 if error detected * -1 if error detected
*/ */
int16_t WebRtcIsacfix_DecLogisticMulti2(int16_t *dataQ7, int WebRtcIsacfix_DecLogisticMulti2(int16_t *dataQ7,
Bitstr_dec *streamData, Bitstr_dec *streamData,
const int32_t *envQ8, const int32_t *envQ8,
const int16_t lenData) const int16_t lenData)

View file

@ -74,7 +74,7 @@ int16_t WebRtcIsacfix_EncTerminate(Bitstr_enc *streamData);
* Return value : number of bytes in the stream so far * Return value : number of bytes in the stream so far
* <0 if error detected * <0 if error detected
*/ */
int16_t WebRtcIsacfix_DecLogisticMulti2( int WebRtcIsacfix_DecLogisticMulti2(
int16_t *data, int16_t *data,
Bitstr_dec *streamData, Bitstr_dec *streamData,
const int32_t *env, const int32_t *env,

View file

@ -32,7 +32,7 @@ int WebRtcIsacfix_EstimateBandwidth(BwEstimatorstr* bwest_str,
uint32_t send_ts, uint32_t send_ts,
uint32_t arr_ts); uint32_t arr_ts);
int16_t WebRtcIsacfix_DecodeImpl(int16_t* signal_out16, int WebRtcIsacfix_DecodeImpl(int16_t* signal_out16,
IsacFixDecoderInstance* ISACdec_obj, IsacFixDecoderInstance* ISACdec_obj,
int16_t* current_framesamples); int16_t* current_framesamples);

View file

@ -27,14 +27,14 @@
int16_t WebRtcIsacfix_DecodeImpl(int16_t *signal_out16, int WebRtcIsacfix_DecodeImpl(int16_t *signal_out16,
IsacFixDecoderInstance *ISACdec_obj, IsacFixDecoderInstance *ISACdec_obj,
int16_t *current_framesamples) int16_t *current_framesamples)
{ {
int k; int k;
int err; int err;
int16_t BWno; int16_t BWno;
int16_t len = 0; int len = 0;
int16_t model; int16_t model;

View file

@ -450,7 +450,7 @@ static void GenerateDitherQ7(int16_t *bufQ7,
* function to decode the complex spectrum from the bitstream * function to decode the complex spectrum from the bitstream
* returns the total number of bytes in the stream * returns the total number of bytes in the stream
*/ */
int16_t WebRtcIsacfix_DecodeSpec(Bitstr_dec *streamdata, int WebRtcIsacfix_DecodeSpec(Bitstr_dec *streamdata,
int16_t *frQ7, int16_t *frQ7,
int16_t *fiQ7, int16_t *fiQ7,
int16_t AvgPitchGain_Q12) int16_t AvgPitchGain_Q12)
@ -461,7 +461,7 @@ int16_t WebRtcIsacfix_DecodeSpec(Bitstr_dec *streamdata,
int16_t RCQ15[AR_ORDER]; int16_t RCQ15[AR_ORDER];
int16_t gainQ10; int16_t gainQ10;
int32_t gain2_Q10; int32_t gain2_Q10;
int16_t len; int len;
int k; int k;
/* create dither signal */ /* create dither signal */

View file

@ -22,7 +22,7 @@
#include "structs.h" #include "structs.h"
/* decode complex spectrum (return number of bytes in stream) */ /* decode complex spectrum (return number of bytes in stream) */
int16_t WebRtcIsacfix_DecodeSpec(Bitstr_dec *streamdata, int WebRtcIsacfix_DecodeSpec(Bitstr_dec *streamdata,
int16_t *frQ7, int16_t *frQ7,
int16_t *fiQ7, int16_t *fiQ7,
int16_t AvgPitchGain_Q12); int16_t AvgPitchGain_Q12);

View file

@ -399,12 +399,12 @@ static void write_be16(const uint16_t* src, size_t nbytes, uint8_t* dest) {
* : -1 - Error * : -1 - Error
*/ */
int16_t WebRtcIsacfix_Encode(ISACFIX_MainStruct *ISAC_main_inst, int WebRtcIsacfix_Encode(ISACFIX_MainStruct *ISAC_main_inst,
const int16_t *speechIn, const int16_t *speechIn,
uint8_t* encoded) uint8_t* encoded)
{ {
ISACFIX_SubStruct *ISAC_inst; ISACFIX_SubStruct *ISAC_inst;
int16_t stream_len; int stream_len;
/* typecast pointer to rela structure */ /* typecast pointer to rela structure */
ISAC_inst = (ISACFIX_SubStruct *)ISAC_main_inst; ISAC_inst = (ISACFIX_SubStruct *)ISAC_main_inst;
@ -421,7 +421,7 @@ int16_t WebRtcIsacfix_Encode(ISACFIX_MainStruct *ISAC_main_inst,
&ISAC_inst->bwestimator_obj, &ISAC_inst->bwestimator_obj,
ISAC_inst->CodingMode); ISAC_inst->CodingMode);
if (stream_len<0) { if (stream_len<0) {
ISAC_inst->errorcode = - stream_len; ISAC_inst->errorcode = -(int16_t)stream_len;
return -1; return -1;
} }
@ -767,7 +767,7 @@ int16_t WebRtcIsacfix_UpdateBwEstimate(ISACFIX_MainStruct *ISAC_main_inst,
*/ */
int16_t WebRtcIsacfix_Decode(ISACFIX_MainStruct* ISAC_main_inst, int WebRtcIsacfix_Decode(ISACFIX_MainStruct* ISAC_main_inst,
const uint8_t* encoded, const uint8_t* encoded,
int16_t len, int16_t len,
int16_t* decoded, int16_t* decoded,
@ -777,7 +777,7 @@ int16_t WebRtcIsacfix_Decode(ISACFIX_MainStruct* ISAC_main_inst,
/* number of samples (480 or 960), output from decoder */ /* number of samples (480 or 960), output from decoder */
/* that were actually used in the encoder/decoder (determined on the fly) */ /* that were actually used in the encoder/decoder (determined on the fly) */
int16_t number_of_samples; int16_t number_of_samples;
int16_t declen = 0; int declen = 0;
/* typecast pointer to real structure */ /* typecast pointer to real structure */
ISAC_inst = (ISACFIX_SubStruct *)ISAC_main_inst; ISAC_inst = (ISACFIX_SubStruct *)ISAC_main_inst;
@ -810,7 +810,7 @@ int16_t WebRtcIsacfix_Decode(ISACFIX_MainStruct* ISAC_main_inst,
if (declen < 0) { if (declen < 0) {
/* Some error inside the decoder */ /* Some error inside the decoder */
ISAC_inst->errorcode = -declen; ISAC_inst->errorcode = -(int16_t)declen;
memset(decoded, 0, sizeof(int16_t) * MAX_FRAMESAMPLES); memset(decoded, 0, sizeof(int16_t) * MAX_FRAMESAMPLES);
return -1; return -1;
} }
@ -860,7 +860,7 @@ int16_t WebRtcIsacfix_Decode(ISACFIX_MainStruct* ISAC_main_inst,
*/ */
#ifdef WEBRTC_ISAC_FIX_NB_CALLS_ENABLED #ifdef WEBRTC_ISAC_FIX_NB_CALLS_ENABLED
int16_t WebRtcIsacfix_DecodeNb(ISACFIX_MainStruct *ISAC_main_inst, int WebRtcIsacfix_DecodeNb(ISACFIX_MainStruct *ISAC_main_inst,
const uint16_t *encoded, const uint16_t *encoded,
int16_t len, int16_t len,
int16_t *decoded, int16_t *decoded,
@ -870,7 +870,7 @@ int16_t WebRtcIsacfix_DecodeNb(ISACFIX_MainStruct *ISAC_main_inst,
/* twice the number of samples (480 or 960), output from decoder */ /* twice the number of samples (480 or 960), output from decoder */
/* that were actually used in the encoder/decoder (determined on the fly) */ /* that were actually used in the encoder/decoder (determined on the fly) */
int16_t number_of_samples; int16_t number_of_samples;
int16_t declen = 0; int declen = 0;
int16_t dummy[FRAMESAMPLES/2]; int16_t dummy[FRAMESAMPLES/2];
@ -904,7 +904,7 @@ int16_t WebRtcIsacfix_DecodeNb(ISACFIX_MainStruct *ISAC_main_inst,
if (declen < 0) { if (declen < 0) {
/* Some error inside the decoder */ /* Some error inside the decoder */
ISAC_inst->errorcode = -declen; ISAC_inst->errorcode = -(int16_t)declen;
memset(decoded, 0, sizeof(int16_t) * FRAMESAMPLES); memset(decoded, 0, sizeof(int16_t) * FRAMESAMPLES);
return -1; return -1;
} }
@ -1076,7 +1076,7 @@ int16_t WebRtcIsacfix_DecodePlc(ISACFIX_MainStruct *ISAC_main_inst,
int16_t WebRtcIsacfix_Control(ISACFIX_MainStruct *ISAC_main_inst, int16_t WebRtcIsacfix_Control(ISACFIX_MainStruct *ISAC_main_inst,
int16_t rate, int16_t rate,
int16_t framesize) int framesize)
{ {
ISACFIX_SubStruct *ISAC_inst; ISACFIX_SubStruct *ISAC_inst;
/* typecast pointer to real structure */ /* typecast pointer to real structure */
@ -1100,7 +1100,7 @@ int16_t WebRtcIsacfix_Control(ISACFIX_MainStruct *ISAC_main_inst,
if (framesize == 30 || framesize == 60) if (framesize == 30 || framesize == 60)
ISAC_inst->ISACenc_obj.new_framelength = (FS/1000) * framesize; ISAC_inst->ISACenc_obj.new_framelength = (int16_t)((FS/1000) * framesize);
else { else {
ISAC_inst->errorcode = ISAC_DISALLOWED_FRAME_LENGTH; ISAC_inst->errorcode = ISAC_DISALLOWED_FRAME_LENGTH;
return -1; return -1;
@ -1135,7 +1135,7 @@ int16_t WebRtcIsacfix_Control(ISACFIX_MainStruct *ISAC_main_inst,
int16_t WebRtcIsacfix_ControlBwe(ISACFIX_MainStruct *ISAC_main_inst, int16_t WebRtcIsacfix_ControlBwe(ISACFIX_MainStruct *ISAC_main_inst,
int16_t rateBPS, int16_t rateBPS,
int16_t frameSizeMs, int frameSizeMs,
int16_t enforceFrameSize) int16_t enforceFrameSize)
{ {
ISACFIX_SubStruct *ISAC_inst; ISACFIX_SubStruct *ISAC_inst;
@ -1169,7 +1169,7 @@ int16_t WebRtcIsacfix_ControlBwe(ISACFIX_MainStruct *ISAC_main_inst,
/* Set initial framesize. If enforceFrameSize is set the frame size will not change */ /* Set initial framesize. If enforceFrameSize is set the frame size will not change */
if ((frameSizeMs == 30) || (frameSizeMs == 60)) { if ((frameSizeMs == 30) || (frameSizeMs == 60)) {
ISAC_inst->ISACenc_obj.new_framelength = (FS/1000) * frameSizeMs; ISAC_inst->ISACenc_obj.new_framelength = (int16_t)((FS/1000) * frameSizeMs);
} else { } else {
ISAC_inst->errorcode = ISAC_DISALLOWED_FRAME_LENGTH; ISAC_inst->errorcode = ISAC_DISALLOWED_FRAME_LENGTH;
return -1; return -1;

View file

@ -102,14 +102,15 @@ int main(int argc, char* argv[])
int i, errtype, h = 0, k, packetLossPercent = 0; int i, errtype, h = 0, k, packetLossPercent = 0;
int16_t CodingMode; int16_t CodingMode;
int16_t bottleneck; int16_t bottleneck;
int16_t framesize = 30; /* ms */ int framesize = 30; /* ms */
int cur_framesmpls, err = 0, lostPackets = 0; int cur_framesmpls, err = 0, lostPackets = 0;
/* Runtime statistics */ /* Runtime statistics */
double starttime, runtime, length_file; double starttime, runtime, length_file;
int16_t stream_len = 0; int16_t stream_len = 0;
int16_t framecnt, declen = 0; int16_t framecnt;
int declen = 0;
int16_t shortdata[FRAMESAMPLES_10ms]; int16_t shortdata[FRAMESAMPLES_10ms];
int16_t decoded[MAX_FRAMESAMPLES]; int16_t decoded[MAX_FRAMESAMPLES];
uint16_t streamdata[500]; uint16_t streamdata[500];
@ -767,7 +768,7 @@ int main(int argc, char* argv[])
#else #else
declen = -1; declen = -1;
#endif #endif
prevFrameSize = declen/240; prevFrameSize = static_cast<int16_t>(declen / 240);
} }
} }

View file

@ -88,8 +88,8 @@ int main(int argc, char* argv[]) {
int16_t CodingMode; int16_t CodingMode;
int16_t bottleneck; int16_t bottleneck;
int16_t framesize = 30; /* ms */ int framesize = 30; /* ms */
// int16_t framesize = 60; /* To invoke cisco complexity case at frame 2252 */ // int framesize = 60; /* To invoke cisco complexity case at frame 2252 */
int cur_framesmpls, err; int cur_framesmpls, err;
@ -99,7 +99,7 @@ int main(int argc, char* argv[]) {
double length_file; double length_file;
int16_t stream_len = 0; int16_t stream_len = 0;
int16_t declen; int declen;
int16_t shortdata[FRAMESAMPLES_10ms]; int16_t shortdata[FRAMESAMPLES_10ms];
int16_t decoded[MAX_FRAMESAMPLES]; int16_t decoded[MAX_FRAMESAMPLES];

View file

@ -24,12 +24,12 @@ struct IsacFloat {
static const bool has_swb = true; static const bool has_swb = true;
static inline int16_t Control(instance_type* inst, static inline int16_t Control(instance_type* inst,
int32_t rate, int32_t rate,
int16_t framesize) { int framesize) {
return WebRtcIsac_Control(inst, rate, framesize); return WebRtcIsac_Control(inst, rate, framesize);
} }
static inline int16_t ControlBwe(instance_type* inst, static inline int16_t ControlBwe(instance_type* inst,
int32_t rate_bps, int32_t rate_bps,
int16_t frame_size_ms, int frame_size_ms,
int16_t enforce_frame_size) { int16_t enforce_frame_size) {
return WebRtcIsac_ControlBwe(inst, rate_bps, frame_size_ms, return WebRtcIsac_ControlBwe(inst, rate_bps, frame_size_ms,
enforce_frame_size); enforce_frame_size);
@ -37,7 +37,7 @@ struct IsacFloat {
static inline int16_t Create(instance_type** inst) { static inline int16_t Create(instance_type** inst) {
return WebRtcIsac_Create(inst); return WebRtcIsac_Create(inst);
} }
static inline int16_t DecodeInternal(instance_type* inst, static inline int DecodeInternal(instance_type* inst,
const uint8_t* encoded, const uint8_t* encoded,
int16_t len, int16_t len,
int16_t* decoded, int16_t* decoded,
@ -53,7 +53,7 @@ struct IsacFloat {
static inline int16_t DecoderInit(instance_type* inst) { static inline int16_t DecoderInit(instance_type* inst) {
return WebRtcIsac_DecoderInit(inst); return WebRtcIsac_DecoderInit(inst);
} }
static inline int16_t Encode(instance_type* inst, static inline int Encode(instance_type* inst,
const int16_t* speech_in, const int16_t* speech_in,
uint8_t* encoded) { uint8_t* encoded) {
return WebRtcIsac_Encode(inst, speech_in, encoded); return WebRtcIsac_Encode(inst, speech_in, encoded);

View file

@ -144,7 +144,7 @@ extern "C" {
* : -1 - Error * : -1 - Error
*/ */
int16_t WebRtcIsac_Encode( int WebRtcIsac_Encode(
ISACStruct* ISAC_main_inst, ISACStruct* ISAC_main_inst,
const int16_t* speechIn, const int16_t* speechIn,
uint8_t* encoded); uint8_t* encoded);
@ -214,7 +214,7 @@ extern "C" {
* -1 - Error. * -1 - Error.
*/ */
int16_t WebRtcIsac_Decode( int WebRtcIsac_Decode(
ISACStruct* ISAC_main_inst, ISACStruct* ISAC_main_inst,
const uint8_t* encoded, const uint8_t* encoded,
int16_t len, int16_t len,
@ -269,7 +269,7 @@ extern "C" {
int16_t WebRtcIsac_Control( int16_t WebRtcIsac_Control(
ISACStruct* ISAC_main_inst, ISACStruct* ISAC_main_inst,
int32_t rate, int32_t rate,
int16_t framesize); int framesize);
/****************************************************************************** /******************************************************************************
@ -300,7 +300,7 @@ extern "C" {
int16_t WebRtcIsac_ControlBwe( int16_t WebRtcIsac_ControlBwe(
ISACStruct* ISAC_main_inst, ISACStruct* ISAC_main_inst,
int32_t rateBPS, int32_t rateBPS,
int16_t frameSizeMs, int frameSizeMs,
int16_t enforceFrameSize); int16_t enforceFrameSize);
@ -701,7 +701,7 @@ extern "C" {
* Return value : >0 - number of samples in decoded vector * Return value : >0 - number of samples in decoded vector
* -1 - Error * -1 - Error
*/ */
int16_t WebRtcIsac_DecodeRcu( int WebRtcIsac_DecodeRcu(
ISACStruct* ISAC_main_inst, ISACStruct* ISAC_main_inst,
const uint8_t* encoded, const uint8_t* encoded,
int16_t len, int16_t len,

View file

@ -80,8 +80,8 @@ static const uint32_t kCrcTable[256] = {
* -1 - Error * -1 - Error
*/ */
int16_t WebRtcIsac_GetCrc(const int16_t* bitstream, int WebRtcIsac_GetCrc(const int16_t* bitstream,
int16_t len_bitstream_in_bytes, int len_bitstream_in_bytes,
uint32_t* crc) uint32_t* crc)
{ {
uint8_t* bitstream_ptr_uw8; uint8_t* bitstream_ptr_uw8;

View file

@ -36,9 +36,9 @@
* -1 - Error * -1 - Error
*/ */
int16_t WebRtcIsac_GetCrc( int WebRtcIsac_GetCrc(
const int16_t* encoded, const int16_t* encoded,
int16_t no_of_word8s, int no_of_word8s,
uint32_t* crc); uint32_t* crc);

View file

@ -494,15 +494,15 @@ int16_t WebRtcIsac_EncoderInit(ISACStruct* ISAC_main_inst,
* samples. * samples.
* : -1 - Error * : -1 - Error
*/ */
int16_t WebRtcIsac_Encode(ISACStruct* ISAC_main_inst, int WebRtcIsac_Encode(ISACStruct* ISAC_main_inst,
const int16_t* speechIn, const int16_t* speechIn,
uint8_t* encoded) { uint8_t* encoded) {
float inFrame[FRAMESAMPLES_10ms]; float inFrame[FRAMESAMPLES_10ms];
int16_t speechInLB[FRAMESAMPLES_10ms]; int16_t speechInLB[FRAMESAMPLES_10ms];
int16_t speechInUB[FRAMESAMPLES_10ms]; int16_t speechInUB[FRAMESAMPLES_10ms];
int16_t streamLenLB = 0; int streamLenLB = 0;
int16_t streamLenUB = 0; int streamLenUB = 0;
int16_t streamLen = 0; int streamLen = 0;
int16_t k = 0; int16_t k = 0;
uint8_t garbageLen = 0; uint8_t garbageLen = 0;
int32_t bottleneck = 0; int32_t bottleneck = 0;
@ -601,8 +601,8 @@ int16_t WebRtcIsac_Encode(ISACStruct* ISAC_main_inst,
/* Tell to upper-band the number of bytes used so far. /* Tell to upper-band the number of bytes used so far.
* This is for payload limitation. */ * This is for payload limitation. */
instUB->ISACencUB_obj.numBytesUsed = streamLenLB + 1 + instUB->ISACencUB_obj.numBytesUsed =
LEN_CHECK_SUM_WORD8; (int16_t)(streamLenLB + 1 + LEN_CHECK_SUM_WORD8);
/* Encode upper-band. */ /* Encode upper-band. */
switch (instISAC->bandwidthKHz) { switch (instISAC->bandwidthKHz) {
case isac12kHz: { case isac12kHz: {
@ -1045,7 +1045,7 @@ int16_t WebRtcIsac_UpdateBwEstimate(ISACStruct* ISAC_main_inst,
return 0; return 0;
} }
static int16_t Decode(ISACStruct* ISAC_main_inst, static int Decode(ISACStruct* ISAC_main_inst,
const uint8_t* encoded, const uint8_t* encoded,
int16_t lenEncodedBytes, int16_t lenEncodedBytes,
int16_t* decoded, int16_t* decoded,
@ -1060,8 +1060,8 @@ static int16_t Decode(ISACStruct* ISAC_main_inst,
float outFrame[MAX_FRAMESAMPLES]; float outFrame[MAX_FRAMESAMPLES];
int16_t outFrameLB[MAX_FRAMESAMPLES]; int16_t outFrameLB[MAX_FRAMESAMPLES];
int16_t outFrameUB[MAX_FRAMESAMPLES]; int16_t outFrameUB[MAX_FRAMESAMPLES];
int16_t numDecodedBytesLB; int numDecodedBytesLB;
int16_t numDecodedBytesUB; int numDecodedBytesUB;
int16_t lenEncodedLBBytes; int16_t lenEncodedLBBytes;
int16_t validChecksum = 1; int16_t validChecksum = 1;
int16_t k; int16_t k;
@ -1350,7 +1350,7 @@ static int16_t Decode(ISACStruct* ISAC_main_inst,
* -1 - Error * -1 - Error
*/ */
int16_t WebRtcIsac_Decode(ISACStruct* ISAC_main_inst, int WebRtcIsac_Decode(ISACStruct* ISAC_main_inst,
const uint8_t* encoded, const uint8_t* encoded,
int16_t lenEncodedBytes, int16_t lenEncodedBytes,
int16_t* decoded, int16_t* decoded,
@ -1382,7 +1382,7 @@ int16_t WebRtcIsac_Decode(ISACStruct* ISAC_main_inst,
int16_t WebRtcIsac_DecodeRcu(ISACStruct* ISAC_main_inst, int WebRtcIsac_DecodeRcu(ISACStruct* ISAC_main_inst,
const uint8_t* encoded, const uint8_t* encoded,
int16_t lenEncodedBytes, int16_t lenEncodedBytes,
int16_t* decoded, int16_t* decoded,
@ -1485,7 +1485,7 @@ static int16_t ControlUb(ISACUBStruct* instISAC, double rate) {
int16_t WebRtcIsac_Control(ISACStruct* ISAC_main_inst, int16_t WebRtcIsac_Control(ISACStruct* ISAC_main_inst,
int32_t bottleneckBPS, int32_t bottleneckBPS,
int16_t frameSize) { int frameSize) {
ISACMainStruct* instISAC = (ISACMainStruct*)ISAC_main_inst; ISACMainStruct* instISAC = (ISACMainStruct*)ISAC_main_inst;
int16_t status; int16_t status;
double rateLB; double rateLB;
@ -1526,7 +1526,7 @@ int16_t WebRtcIsac_Control(ISACStruct* ISAC_main_inst,
return -1; return -1;
} }
status = ControlLb(&instISAC->instLB, rateLB, frameSize); status = ControlLb(&instISAC->instLB, rateLB, (int16_t)frameSize);
if (status < 0) { if (status < 0) {
instISAC->errorCode = -status; instISAC->errorCode = -status;
return -1; return -1;
@ -1594,7 +1594,7 @@ int16_t WebRtcIsac_Control(ISACStruct* ISAC_main_inst,
*/ */
int16_t WebRtcIsac_ControlBwe(ISACStruct* ISAC_main_inst, int16_t WebRtcIsac_ControlBwe(ISACStruct* ISAC_main_inst,
int32_t bottleneckBPS, int32_t bottleneckBPS,
int16_t frameSizeMs, int frameSizeMs,
int16_t enforceFrameSize) { int16_t enforceFrameSize) {
ISACMainStruct* instISAC = (ISACMainStruct*)ISAC_main_inst; ISACMainStruct* instISAC = (ISACMainStruct*)ISAC_main_inst;
enum ISACBandwidth bandwidth; enum ISACBandwidth bandwidth;
@ -1641,8 +1641,8 @@ int16_t WebRtcIsac_ControlBwe(ISACStruct* ISAC_main_inst,
* will not change */ * will not change */
if (frameSizeMs != 0) { if (frameSizeMs != 0) {
if ((frameSizeMs == 30) || (frameSizeMs == 60)) { if ((frameSizeMs == 30) || (frameSizeMs == 60)) {
instISAC->instLB.ISACencLB_obj.new_framelength = (FS / 1000) * instISAC->instLB.ISACencLB_obj.new_framelength =
frameSizeMs; (int16_t)((FS / 1000) * frameSizeMs);
} else { } else {
instISAC->errorCode = ISAC_DISALLOWED_FRAME_LENGTH; instISAC->errorCode = ISAC_DISALLOWED_FRAME_LENGTH;
return -1; return -1;

View file

@ -80,7 +80,7 @@ TEST_F(IsacTest, DISABLED_ON_IOS(IsacUpdateBWE)) {
WebRtcIsac_EncoderInit(isac_codec_, 0); WebRtcIsac_EncoderInit(isac_codec_, 0);
WebRtcIsac_DecoderInit(isac_codec_); WebRtcIsac_DecoderInit(isac_codec_);
int16_t encoded_bytes; int encoded_bytes;
// Test with call with a small packet (sync packet). // Test with call with a small packet (sync packet).
EXPECT_EQ(-1, WebRtcIsac_UpdateBwEstimate(isac_codec_, bitstream_small_, 7, 1, EXPECT_EQ(-1, WebRtcIsac_UpdateBwEstimate(isac_codec_, bitstream_small_, 7, 1,

View file

@ -45,14 +45,14 @@ int main(int argc, char* argv[]) {
int i, errtype, VADusage = 0, packetLossPercent = 0; int i, errtype, VADusage = 0, packetLossPercent = 0;
int16_t CodingMode; int16_t CodingMode;
int32_t bottleneck = 0; int32_t bottleneck = 0;
int16_t framesize = 30; /* ms */ int framesize = 30; /* ms */
int cur_framesmpls, err; int cur_framesmpls, err;
/* Runtime statistics */ /* Runtime statistics */
double starttime, runtime, length_file; double starttime, runtime, length_file;
int16_t stream_len = 0; int16_t stream_len = 0;
int16_t declen = 0, declenTC = 0; int declen = 0, declenTC = 0;
bool lostFrame = false; bool lostFrame = false;
int16_t shortdata[SWBFRAMESAMPLES_10ms]; int16_t shortdata[SWBFRAMESAMPLES_10ms];

View file

@ -191,7 +191,7 @@ int main(int argc, char* argv[])
short streamLen; short streamLen;
short numSamplesRead; short numSamplesRead;
short lenDecodedAudio; int lenDecodedAudio;
short senderIdx; short senderIdx;
short receiverIdx; short receiverIdx;

View file

@ -62,7 +62,7 @@ int main(int argc, char* argv[]) {
unsigned long totalsmpls = 0; unsigned long totalsmpls = 0;
int32_t bottleneck = 39; int32_t bottleneck = 39;
int16_t frameSize = 30; /* ms */ int frameSize = 30; /* ms */
int16_t codingMode = 1; int16_t codingMode = 1;
int16_t shortdata[FRAMESAMPLES_SWB_10ms]; int16_t shortdata[FRAMESAMPLES_SWB_10ms];
int16_t decoded[MAX_FRAMESAMPLES_SWB]; int16_t decoded[MAX_FRAMESAMPLES_SWB];
@ -73,9 +73,9 @@ int main(int argc, char* argv[]) {
ISACStruct* ISAC_main_inst; ISACStruct* ISAC_main_inst;
int16_t stream_len = 0; int16_t stream_len = 0;
int16_t declen = 0; int declen = 0;
int16_t err; int16_t err;
int16_t cur_framesmpls; int cur_framesmpls;
int endfile; int endfile;
#ifdef WIN32 #ifdef WIN32
double length_file; double length_file;