Update a ton of audio code to use size_t more correctly and in general reduce
use of int16_t/uint16_t. This is the upshot of a recommendation by henrik.lundin and kwiberg on an original small change ( https://webrtc-codereview.appspot.com/42569004/#ps1 ) to stop using int16_t just because values could fit in it, and is similar in nature to a previous "mass change to use size_t more" ( https://webrtc-codereview.appspot.com/23129004/ ) which also needed to be split up for review but to land all at once, since, like adding "const", such changes tend to cause a lot of transitive effects. This was be reviewed and approved in pieces: https://codereview.webrtc.org/1224093003 https://codereview.webrtc.org/1224123002 https://codereview.webrtc.org/1224163002 https://codereview.webrtc.org/1225133003 https://codereview.webrtc.org/1225173002 https://codereview.webrtc.org/1227163003 https://codereview.webrtc.org/1227203003 https://codereview.webrtc.org/1227213002 https://codereview.webrtc.org/1227893002 https://codereview.webrtc.org/1228793004 https://codereview.webrtc.org/1228803003 https://codereview.webrtc.org/1228823002 https://codereview.webrtc.org/1228823003 https://codereview.webrtc.org/1228843002 https://codereview.webrtc.org/1230693002 https://codereview.webrtc.org/1231713002 The change is being landed as TBR to all the folks who reviewed the above. BUG=chromium:81439 TEST=none R=andrew@webrtc.org, pbos@webrtc.org TBR=aluebs, andrew, asapersson, henrika, hlundin, jan.skoglund, kwiberg, minyue, pbos, pthatcher Review URL: https://codereview.webrtc.org/1230503003 . Cr-Commit-Position: refs/heads/master@{#9768}
This commit is contained in:
@ -47,12 +47,11 @@ int main(int argc, char* argv[])
|
||||
int16_t data[BLOCKL_MAX];
|
||||
uint8_t encoded_data[2 * ILBCNOOFWORDS_MAX];
|
||||
int16_t decoded_data[BLOCKL_MAX];
|
||||
int len;
|
||||
short pli, mode;
|
||||
int len_int, mode;
|
||||
short pli;
|
||||
int blockcount = 0;
|
||||
int packetlosscount = 0;
|
||||
int frameLen;
|
||||
size_t len_i16s;
|
||||
size_t frameLen, len, len_i16s;
|
||||
int16_t speechType;
|
||||
IlbcEncoderInstance *Enc_Inst;
|
||||
IlbcDecoderInstance *Dec_Inst;
|
||||
@ -153,23 +152,23 @@ int main(int argc, char* argv[])
|
||||
|
||||
WebRtcIlbcfix_EncoderInit(Enc_Inst, mode);
|
||||
WebRtcIlbcfix_DecoderInit(Dec_Inst, mode);
|
||||
frameLen = mode*8;
|
||||
frameLen = (size_t)(mode*8);
|
||||
|
||||
/* loop over input blocks */
|
||||
|
||||
while (((int16_t)fread(data,sizeof(int16_t),frameLen,ifileid))==
|
||||
frameLen) {
|
||||
while (fread(data,sizeof(int16_t),frameLen,ifileid) == frameLen) {
|
||||
|
||||
blockcount++;
|
||||
|
||||
/* encoding */
|
||||
|
||||
fprintf(stderr, "--- Encoding block %i --- ",blockcount);
|
||||
len = WebRtcIlbcfix_Encode(Enc_Inst, data, (int16_t)frameLen, encoded_data);
|
||||
if (len < 0) {
|
||||
len_int = WebRtcIlbcfix_Encode(Enc_Inst, data, frameLen, encoded_data);
|
||||
if (len_int < 0) {
|
||||
fprintf(stderr, "Error encoding\n");
|
||||
exit(0);
|
||||
}
|
||||
len = (size_t)len_int;
|
||||
fprintf(stderr, "\r");
|
||||
|
||||
/* write byte file */
|
||||
@ -204,12 +203,13 @@ int main(int argc, char* argv[])
|
||||
|
||||
fprintf(stderr, "--- Decoding block %i --- ",blockcount);
|
||||
if (pli==1) {
|
||||
len=WebRtcIlbcfix_Decode(Dec_Inst, encoded_data,
|
||||
(int16_t)len, decoded_data,&speechType);
|
||||
if (len < 0) {
|
||||
len_int=WebRtcIlbcfix_Decode(Dec_Inst, encoded_data,
|
||||
len, decoded_data,&speechType);
|
||||
if (len_int < 0) {
|
||||
fprintf(stderr, "Error decoding\n");
|
||||
exit(0);
|
||||
}
|
||||
len = (size_t)len_int;
|
||||
} else {
|
||||
len=WebRtcIlbcfix_DecodePlc(Dec_Inst, decoded_data, 1);
|
||||
}
|
||||
@ -217,8 +217,7 @@ int main(int argc, char* argv[])
|
||||
|
||||
/* write output file */
|
||||
|
||||
if (fwrite(decoded_data, sizeof(int16_t), len,
|
||||
ofileid) != (size_t)len) {
|
||||
if (fwrite(decoded_data, sizeof(int16_t), len, ofileid) != len) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
@ -41,15 +41,15 @@ int main(int argc, char* argv[])
|
||||
{
|
||||
FILE *ifileid,*efileid,*ofileid, *chfileid;
|
||||
short encoded_data[55], data[240], speechType;
|
||||
int len;
|
||||
short mode, pli;
|
||||
size_t readlen;
|
||||
int len_int, mode;
|
||||
short pli;
|
||||
size_t len, readlen;
|
||||
int blockcount = 0;
|
||||
|
||||
IlbcEncoderInstance *Enc_Inst;
|
||||
IlbcDecoderInstance *Dec_Inst;
|
||||
#ifdef JUNK_DATA
|
||||
int i;
|
||||
size_t i;
|
||||
FILE *seedfile;
|
||||
unsigned int random_seed = (unsigned int) time(NULL);//1196764538
|
||||
#endif
|
||||
@ -136,11 +136,12 @@ int main(int argc, char* argv[])
|
||||
|
||||
/* encoding */
|
||||
fprintf(stderr, "--- Encoding block %i --- ",blockcount);
|
||||
len=WebRtcIlbcfix_Encode(Enc_Inst, data, (short)readlen, encoded_data);
|
||||
if (len < 0) {
|
||||
len_int=WebRtcIlbcfix_Encode(Enc_Inst, data, readlen, encoded_data);
|
||||
if (len_int < 0) {
|
||||
fprintf(stderr, "Error encoding\n");
|
||||
exit(0);
|
||||
}
|
||||
len = (size_t)len_int;
|
||||
fprintf(stderr, "\r");
|
||||
|
||||
#ifdef JUNK_DATA
|
||||
@ -174,12 +175,13 @@ int main(int argc, char* argv[])
|
||||
/* decoding */
|
||||
fprintf(stderr, "--- Decoding block %i --- ",blockcount);
|
||||
if (pli==1) {
|
||||
len=WebRtcIlbcfix_Decode(Dec_Inst, encoded_data, (int16_t)len, data,
|
||||
&speechType);
|
||||
if (len < 0) {
|
||||
len_int = WebRtcIlbcfix_Decode(Dec_Inst, encoded_data, len, data,
|
||||
&speechType);
|
||||
if (len_int < 0) {
|
||||
fprintf(stderr, "Error decoding\n");
|
||||
exit(0);
|
||||
}
|
||||
len = (size_t)len_int;
|
||||
} else {
|
||||
len=WebRtcIlbcfix_DecodePlc(Dec_Inst, data, 1);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user