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

Side by Side Diff: webrtc/modules/audio_coding/codecs/ilbc/test/iLBC_testLib.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, 3 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 23 matching lines...) Expand all
34 * 34 *
35 * Usage: 35 * Usage:
36 * exefile_name.exe <infile> <bytefile> <outfile> 36 * exefile_name.exe <infile> <bytefile> <outfile>
37 * 37 *
38 *---------------------------------------------------------------*/ 38 *---------------------------------------------------------------*/
39 39
40 int main(int argc, char* argv[]) 40 int main(int argc, char* argv[])
41 { 41 {
42 FILE *ifileid,*efileid,*ofileid, *chfileid; 42 FILE *ifileid,*efileid,*ofileid, *chfileid;
43 short encoded_data[55], data[240], speechType; 43 short encoded_data[55], data[240], speechType;
44 int len; 44 int len_int, mode;
45 short mode, pli; 45 short pli;
46 size_t readlen; 46 size_t len, readlen;
47 int blockcount = 0; 47 int blockcount = 0;
48 48
49 IlbcEncoderInstance *Enc_Inst; 49 IlbcEncoderInstance *Enc_Inst;
50 IlbcDecoderInstance *Dec_Inst; 50 IlbcDecoderInstance *Dec_Inst;
51 #ifdef JUNK_DATA 51 #ifdef JUNK_DATA
52 int i; 52 size_t i;
53 FILE *seedfile; 53 FILE *seedfile;
54 unsigned int random_seed = (unsigned int) time(NULL);//1196764538 54 unsigned int random_seed = (unsigned int) time(NULL);//1196764538
55 #endif 55 #endif
56 56
57 /* Create structs */ 57 /* Create structs */
58 WebRtcIlbcfix_EncoderCreate(&Enc_Inst); 58 WebRtcIlbcfix_EncoderCreate(&Enc_Inst);
59 WebRtcIlbcfix_DecoderCreate(&Dec_Inst); 59 WebRtcIlbcfix_DecoderCreate(&Dec_Inst);
60 60
61 /* get arguments and open files */ 61 /* get arguments and open files */
62 62
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 #ifdef SPLIT_10MS 129 #ifdef SPLIT_10MS
130 readlen = 80; 130 readlen = 80;
131 #else 131 #else
132 readlen = (size_t)(mode << 3); 132 readlen = (size_t)(mode << 3);
133 #endif 133 #endif
134 while(fread(data, sizeof(short), readlen, ifileid) == readlen) { 134 while(fread(data, sizeof(short), readlen, ifileid) == readlen) {
135 blockcount++; 135 blockcount++;
136 136
137 /* encoding */ 137 /* encoding */
138 fprintf(stderr, "--- Encoding block %i --- ",blockcount); 138 fprintf(stderr, "--- Encoding block %i --- ",blockcount);
139 len=WebRtcIlbcfix_Encode(Enc_Inst, data, (short)readlen, encoded_data); 139 len_int=WebRtcIlbcfix_Encode(Enc_Inst, data, readlen, encoded_data);
140 if (len < 0) { 140 if (len_int < 0) {
141 fprintf(stderr, "Error encoding\n"); 141 fprintf(stderr, "Error encoding\n");
142 exit(0); 142 exit(0);
143 } 143 }
144 len = (size_t)len_int;
144 fprintf(stderr, "\r"); 145 fprintf(stderr, "\r");
145 146
146 #ifdef JUNK_DATA 147 #ifdef JUNK_DATA
147 for ( i = 0; i < len; i++) { 148 for ( i = 0; i < len; i++) {
148 encoded_data[i] = (short) (encoded_data[i] + (short) rand()); 149 encoded_data[i] = (short) (encoded_data[i] + (short) rand());
149 } 150 }
150 #endif 151 #endif
151 /* write byte file */ 152 /* write byte file */
152 if(len != 0){ //len may be 0 in 10ms split case 153 if(len != 0){ //len may be 0 in 10ms split case
153 fwrite(encoded_data,1,len,efileid); 154 fwrite(encoded_data,1,len,efileid);
(...skipping 13 matching lines...) Expand all
167 fprintf(stderr, "Error. Channel file too short\n"); 168 fprintf(stderr, "Error. Channel file too short\n");
168 exit(0); 169 exit(0);
169 } 170 }
170 } else { 171 } else {
171 pli=1; 172 pli=1;
172 } 173 }
173 174
174 /* decoding */ 175 /* decoding */
175 fprintf(stderr, "--- Decoding block %i --- ",blockcount); 176 fprintf(stderr, "--- Decoding block %i --- ",blockcount);
176 if (pli==1) { 177 if (pli==1) {
177 len=WebRtcIlbcfix_Decode(Dec_Inst, encoded_data, (int16_t)len, data, 178 len_int = WebRtcIlbcfix_Decode(Dec_Inst, encoded_data, len, data,
178 &speechType); 179 &speechType);
179 if (len < 0) { 180 if (len_int < 0) {
180 fprintf(stderr, "Error decoding\n"); 181 fprintf(stderr, "Error decoding\n");
181 exit(0); 182 exit(0);
182 } 183 }
184 len = (size_t)len_int;
183 } else { 185 } else {
184 len=WebRtcIlbcfix_DecodePlc(Dec_Inst, data, 1); 186 len=WebRtcIlbcfix_DecodePlc(Dec_Inst, data, 1);
185 } 187 }
186 fprintf(stderr, "\r"); 188 fprintf(stderr, "\r");
187 189
188 /* write output file */ 190 /* write output file */
189 fwrite(data,sizeof(short),len,ofileid); 191 fwrite(data,sizeof(short),len,ofileid);
190 } 192 }
191 } 193 }
192 194
(...skipping 11 matching lines...) Expand all
204 WebRtcIlbcfix_EncoderFree(Enc_Inst); 206 WebRtcIlbcfix_EncoderFree(Enc_Inst);
205 WebRtcIlbcfix_DecoderFree(Dec_Inst); 207 WebRtcIlbcfix_DecoderFree(Dec_Inst);
206 208
207 /* close files */ 209 /* close files */
208 fclose(ifileid); 210 fclose(ifileid);
209 fclose(efileid); 211 fclose(efileid);
210 fclose(ofileid); 212 fclose(ofileid);
211 213
212 return 0; 214 return 0;
213 } 215 }
OLDNEW
« no previous file with comments | « webrtc/modules/audio_coding/codecs/ilbc/test/iLBC_test.c ('k') | webrtc/modules/audio_coding/codecs/ilbc/window32_w32.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698