Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(195)

Unified Diff: webrtc/modules/audio_coding/codecs/isac/fix/source/isacfix.c

Issue 1230503003: Update a ton of audio code to use size_t more correctly and in general reduce (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: Resync Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: webrtc/modules/audio_coding/codecs/isac/fix/source/isacfix.c
diff --git a/webrtc/modules/audio_coding/codecs/isac/fix/source/isacfix.c b/webrtc/modules/audio_coding/codecs/isac/fix/source/isacfix.c
index 9b61d60215a9f0f6595f4ec637f8b74f4e5f51e2..4a663d12cf63481d8db6e45fe7be814094f59510 100644
--- a/webrtc/modules/audio_coding/codecs/isac/fix/source/isacfix.c
+++ b/webrtc/modules/audio_coding/codecs/isac/fix/source/isacfix.c
@@ -38,7 +38,7 @@ MatrixProduct2 WebRtcIsacfix_MatrixProduct2;
/* This method assumes that |stream_size_bytes| is in valid range,
* i.e. >= 0 && <= STREAM_MAXW16_60MS
*/
-static void InitializeDecoderBitstream(int stream_size_bytes,
+static void InitializeDecoderBitstream(size_t stream_size_bytes,
Bitstr_dec* bitstream) {
bitstream->W_upper = 0xFFFFFFFF;
bitstream->streamval = 0;
@@ -621,20 +621,20 @@ int16_t WebRtcIsacfix_DecoderInit(ISACFIX_MainStruct *ISAC_main_inst)
int16_t WebRtcIsacfix_UpdateBwEstimate1(ISACFIX_MainStruct *ISAC_main_inst,
const uint8_t* encoded,
- int32_t packet_size,
+ size_t packet_size,
uint16_t rtp_seq_number,
uint32_t arr_ts)
{
ISACFIX_SubStruct *ISAC_inst;
Bitstr_dec streamdata;
int16_t err;
- const int kRequiredEncodedLenBytes = 10;
+ const size_t kRequiredEncodedLenBytes = 10;
/* typecast pointer to real structure */
ISAC_inst = (ISACFIX_SubStruct *)ISAC_main_inst;
/* Sanity check of packet length */
- if (packet_size <= 0) {
+ if (packet_size == 0) {
/* return error code if the packet length is null or less */
ISAC_inst->errorcode = ISAC_EMPTY_PACKET;
return -1;
@@ -693,7 +693,7 @@ int16_t WebRtcIsacfix_UpdateBwEstimate1(ISACFIX_MainStruct *ISAC_main_inst,
int16_t WebRtcIsacfix_UpdateBwEstimate(ISACFIX_MainStruct *ISAC_main_inst,
const uint8_t* encoded,
- int32_t packet_size,
+ size_t packet_size,
uint16_t rtp_seq_number,
uint32_t send_ts,
uint32_t arr_ts)
@@ -701,13 +701,13 @@ int16_t WebRtcIsacfix_UpdateBwEstimate(ISACFIX_MainStruct *ISAC_main_inst,
ISACFIX_SubStruct *ISAC_inst;
Bitstr_dec streamdata;
int16_t err;
- const int kRequiredEncodedLenBytes = 10;
+ const size_t kRequiredEncodedLenBytes = 10;
/* typecast pointer to real structure */
ISAC_inst = (ISACFIX_SubStruct *)ISAC_main_inst;
/* Sanity check of packet length */
- if (packet_size <= 0) {
+ if (packet_size == 0) {
/* return error code if the packet length is null or less */
ISAC_inst->errorcode = ISAC_EMPTY_PACKET;
return -1;
@@ -770,15 +770,16 @@ int16_t WebRtcIsacfix_UpdateBwEstimate(ISACFIX_MainStruct *ISAC_main_inst,
int WebRtcIsacfix_Decode(ISACFIX_MainStruct* ISAC_main_inst,
const uint8_t* encoded,
- int16_t len,
+ size_t len,
int16_t* decoded,
int16_t* speechType)
{
ISACFIX_SubStruct *ISAC_inst;
/* number of samples (480 or 960), output from decoder */
/* that were actually used in the encoder/decoder (determined on the fly) */
- int16_t number_of_samples;
- int declen = 0;
+ size_t number_of_samples;
+ int declen_int = 0;
+ size_t declen;
/* typecast pointer to real structure */
ISAC_inst = (ISACFIX_SubStruct *)ISAC_main_inst;
@@ -790,7 +791,7 @@ int WebRtcIsacfix_Decode(ISACFIX_MainStruct* ISAC_main_inst,
}
/* Sanity check of packet length */
- if (len <= 0) {
+ if (len == 0) {
/* return error code if the packet length is null or less */
ISAC_inst->errorcode = ISAC_EMPTY_PACKET;
return -1;
@@ -807,14 +808,15 @@ int WebRtcIsacfix_Decode(ISACFIX_MainStruct* ISAC_main_inst,
/* added for NetEq purposes (VAD/DTX related) */
*speechType=1;
- declen = WebRtcIsacfix_DecodeImpl(decoded, &ISAC_inst->ISACdec_obj,
- &number_of_samples);
- if (declen < 0) {
+ declen_int = WebRtcIsacfix_DecodeImpl(decoded, &ISAC_inst->ISACdec_obj,
+ &number_of_samples);
+ if (declen_int < 0) {
/* Some error inside the decoder */
- ISAC_inst->errorcode = -(int16_t)declen;
+ ISAC_inst->errorcode = -(int16_t)declen_int;
memset(decoded, 0, sizeof(int16_t) * MAX_FRAMESAMPLES);
return -1;
}
+ declen = (size_t)declen_int;
/* error check */
@@ -836,7 +838,7 @@ int WebRtcIsacfix_Decode(ISACFIX_MainStruct* ISAC_main_inst,
}
}
- return number_of_samples;
+ return (int)number_of_samples;
}
@@ -865,17 +867,18 @@ int WebRtcIsacfix_Decode(ISACFIX_MainStruct* ISAC_main_inst,
*/
#ifdef WEBRTC_ISAC_FIX_NB_CALLS_ENABLED
-int WebRtcIsacfix_DecodeNb(ISACFIX_MainStruct *ISAC_main_inst,
- const uint16_t *encoded,
- int16_t len,
- int16_t *decoded,
- int16_t *speechType)
+int WebRtcIsacfix_DecodeNb(ISACFIX_MainStruct* ISAC_main_inst,
+ const uint16_t* encoded,
+ size_t len,
+ int16_t* decoded,
+ int16_t* speechType)
{
ISACFIX_SubStruct *ISAC_inst;
/* twice the number of samples (480 or 960), output from decoder */
/* that were actually used in the encoder/decoder (determined on the fly) */
- int16_t number_of_samples;
- int declen = 0;
+ size_t number_of_samples;
+ int declen_int = 0;
+ size_t declen;
int16_t dummy[FRAMESAMPLES/2];
@@ -888,7 +891,7 @@ int WebRtcIsacfix_DecodeNb(ISACFIX_MainStruct *ISAC_main_inst,
return (-1);
}
- if (len <= 0) {
+ if (len == 0) {
/* return error code if the packet length is null or less */
ISAC_inst->errorcode = ISAC_EMPTY_PACKET;
return -1;
@@ -905,14 +908,15 @@ int WebRtcIsacfix_DecodeNb(ISACFIX_MainStruct *ISAC_main_inst,
/* added for NetEq purposes (VAD/DTX related) */
*speechType=1;
- declen = WebRtcIsacfix_DecodeImpl(decoded, &ISAC_inst->ISACdec_obj,
- &number_of_samples);
- if (declen < 0) {
+ declen_int = WebRtcIsacfix_DecodeImpl(decoded, &ISAC_inst->ISACdec_obj,
+ &number_of_samples);
+ if (declen_int < 0) {
/* Some error inside the decoder */
- ISAC_inst->errorcode = -(int16_t)declen;
+ ISAC_inst->errorcode = -(int16_t)declen_int;
memset(decoded, 0, sizeof(int16_t) * FRAMESAMPLES);
return -1;
}
+ declen = (size_t)declen_int;
/* error check */
@@ -941,7 +945,7 @@ int WebRtcIsacfix_DecodeNb(ISACFIX_MainStruct *ISAC_main_inst,
dummy, &ISAC_inst->ISACdec_obj.decimatorstr_obj);
}
- return number_of_samples/2;
+ return (int)(number_of_samples / 2);
}
#endif /* WEBRTC_ISAC_FIX_NB_CALLS_ENABLED */
@@ -962,16 +966,15 @@ int WebRtcIsacfix_DecodeNb(ISACFIX_MainStruct *ISAC_main_inst,
* Output:
* - decoded : The decoded vector
*
- * Return value : >0 - number of samples in decoded PLC vector
- * -1 - Error
+ * Return value : Number of samples in decoded PLC vector
*/
#ifdef WEBRTC_ISAC_FIX_NB_CALLS_ENABLED
-int16_t WebRtcIsacfix_DecodePlcNb(ISACFIX_MainStruct *ISAC_main_inst,
- int16_t *decoded,
- int16_t noOfLostFrames )
+size_t WebRtcIsacfix_DecodePlcNb(ISACFIX_MainStruct* ISAC_main_inst,
+ int16_t* decoded,
+ size_t noOfLostFrames )
{
- int16_t no_of_samples, declen, k, ok;
+ size_t no_of_samples, declen, k;
int16_t outframeNB[FRAMESAMPLES];
int16_t outframeWB[FRAMESAMPLES];
int16_t dummy[FRAMESAMPLES/2];
@@ -1028,16 +1031,15 @@ int16_t WebRtcIsacfix_DecodePlcNb(ISACFIX_MainStruct *ISAC_main_inst,
* Output:
* - decoded : The decoded vector
*
- * Return value : >0 - number of samples in decoded PLC vector
- * -1 - Error
+ * Return value : Number of samples in decoded PLC vector
*/
-int16_t WebRtcIsacfix_DecodePlc(ISACFIX_MainStruct *ISAC_main_inst,
- int16_t *decoded,
- int16_t noOfLostFrames)
+size_t WebRtcIsacfix_DecodePlc(ISACFIX_MainStruct* ISAC_main_inst,
+ int16_t* decoded,
+ size_t noOfLostFrames)
{
- int16_t no_of_samples, declen, k;
+ size_t no_of_samples, declen, k;
int16_t outframe16[MAX_FRAMESAMPLES];
ISACFIX_SubStruct *ISAC_inst;
@@ -1272,12 +1274,12 @@ int16_t WebRtcIsacfix_UpdateUplinkBw(ISACFIX_MainStruct* ISAC_main_inst,
*/
int16_t WebRtcIsacfix_ReadFrameLen(const uint8_t* encoded,
- int encoded_len_bytes,
- int16_t* frameLength)
+ size_t encoded_len_bytes,
+ size_t* frameLength)
{
Bitstr_dec streamdata;
int16_t err;
- const int kRequiredEncodedLenBytes = 10;
+ const size_t kRequiredEncodedLenBytes = 10;
if (encoded_len_bytes < kRequiredEncodedLenBytes) {
return -1;
@@ -1311,12 +1313,12 @@ int16_t WebRtcIsacfix_ReadFrameLen(const uint8_t* encoded,
*/
int16_t WebRtcIsacfix_ReadBwIndex(const uint8_t* encoded,
- int encoded_len_bytes,
+ size_t encoded_len_bytes,
int16_t* rateIndex)
{
Bitstr_dec streamdata;
int16_t err;
- const int kRequiredEncodedLenBytes = 10;
+ const size_t kRequiredEncodedLenBytes = 10;
if (encoded_len_bytes < kRequiredEncodedLenBytes) {
return -1;
@@ -1327,7 +1329,7 @@ int16_t WebRtcIsacfix_ReadBwIndex(const uint8_t* encoded,
read_be16(encoded, kRequiredEncodedLenBytes, streamdata.stream);
/* decode frame length, needed to get to the rateIndex in the bitstream */
- int16_t frameLength;
+ size_t frameLength;
err = WebRtcIsacfix_DecodeFrameLen(&streamdata, &frameLength);
if (err<0) // error check
return err;

Powered by Google App Engine
This is Rietveld 408576698