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

Side by Side Diff: webrtc/modules/audio_coding/codecs/ilbc/test/iLBC_test.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) 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2012 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 29 matching lines...) Expand all
40 #define ILBCNOOFWORDS_MAX 25 40 #define ILBCNOOFWORDS_MAX 25
41 41
42 42
43 int main(int argc, char* argv[]) 43 int main(int argc, char* argv[])
44 { 44 {
45 45
46 FILE *ifileid,*efileid,*ofileid, *cfileid; 46 FILE *ifileid,*efileid,*ofileid, *cfileid;
47 int16_t data[BLOCKL_MAX]; 47 int16_t data[BLOCKL_MAX];
48 uint8_t encoded_data[2 * ILBCNOOFWORDS_MAX]; 48 uint8_t encoded_data[2 * ILBCNOOFWORDS_MAX];
49 int16_t decoded_data[BLOCKL_MAX]; 49 int16_t decoded_data[BLOCKL_MAX];
50 int len; 50 int len_int, mode;
51 short pli, mode; 51 short pli;
52 int blockcount = 0; 52 int blockcount = 0;
53 int packetlosscount = 0; 53 int packetlosscount = 0;
54 int frameLen; 54 size_t frameLen, len, len_i16s;
55 size_t len_i16s;
56 int16_t speechType; 55 int16_t speechType;
57 IlbcEncoderInstance *Enc_Inst; 56 IlbcEncoderInstance *Enc_Inst;
58 IlbcDecoderInstance *Dec_Inst; 57 IlbcDecoderInstance *Dec_Inst;
59 58
60 #ifdef __ILBC_WITH_40BITACC 59 #ifdef __ILBC_WITH_40BITACC
61 /* Doublecheck that long long exists */ 60 /* Doublecheck that long long exists */
62 if (sizeof(long)>=sizeof(long long)) { 61 if (sizeof(long)>=sizeof(long long)) {
63 fprintf(stderr, "40-bit simulation is not be supported on this platform\n"); 62 fprintf(stderr, "40-bit simulation is not be supported on this platform\n");
64 exit(0); 63 exit(0);
65 } 64 }
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 145
147 /* Create structs */ 146 /* Create structs */
148 WebRtcIlbcfix_EncoderCreate(&Enc_Inst); 147 WebRtcIlbcfix_EncoderCreate(&Enc_Inst);
149 WebRtcIlbcfix_DecoderCreate(&Dec_Inst); 148 WebRtcIlbcfix_DecoderCreate(&Dec_Inst);
150 149
151 150
152 /* Initialization */ 151 /* Initialization */
153 152
154 WebRtcIlbcfix_EncoderInit(Enc_Inst, mode); 153 WebRtcIlbcfix_EncoderInit(Enc_Inst, mode);
155 WebRtcIlbcfix_DecoderInit(Dec_Inst, mode); 154 WebRtcIlbcfix_DecoderInit(Dec_Inst, mode);
156 frameLen = mode*8; 155 frameLen = (size_t)(mode*8);
157 156
158 /* loop over input blocks */ 157 /* loop over input blocks */
159 158
160 while (((int16_t)fread(data,sizeof(int16_t),frameLen,ifileid))== 159 while (fread(data,sizeof(int16_t),frameLen,ifileid) == frameLen) {
161 frameLen) {
162 160
163 blockcount++; 161 blockcount++;
164 162
165 /* encoding */ 163 /* encoding */
166 164
167 fprintf(stderr, "--- Encoding block %i --- ",blockcount); 165 fprintf(stderr, "--- Encoding block %i --- ",blockcount);
168 len = WebRtcIlbcfix_Encode(Enc_Inst, data, (int16_t)frameLen, encoded_data); 166 len_int = WebRtcIlbcfix_Encode(Enc_Inst, data, frameLen, encoded_data);
169 if (len < 0) { 167 if (len_int < 0) {
170 fprintf(stderr, "Error encoding\n"); 168 fprintf(stderr, "Error encoding\n");
171 exit(0); 169 exit(0);
172 } 170 }
171 len = (size_t)len_int;
173 fprintf(stderr, "\r"); 172 fprintf(stderr, "\r");
174 173
175 /* write byte file */ 174 /* write byte file */
176 175
177 len_i16s = (len + 1) / sizeof(int16_t); 176 len_i16s = (len + 1) / sizeof(int16_t);
178 if (fwrite(encoded_data, sizeof(int16_t), len_i16s, efileid) != len_i16s) { 177 if (fwrite(encoded_data, sizeof(int16_t), len_i16s, efileid) != len_i16s) {
179 return -1; 178 return -1;
180 } 179 }
181 180
182 /* get channel data if provided */ 181 /* get channel data if provided */
(...skipping 14 matching lines...) Expand all
197 exit(0); 196 exit(0);
198 } 197 }
199 } else { 198 } else {
200 pli=1; 199 pli=1;
201 } 200 }
202 201
203 /* decoding */ 202 /* decoding */
204 203
205 fprintf(stderr, "--- Decoding block %i --- ",blockcount); 204 fprintf(stderr, "--- Decoding block %i --- ",blockcount);
206 if (pli==1) { 205 if (pli==1) {
207 len=WebRtcIlbcfix_Decode(Dec_Inst, encoded_data, 206 len_int=WebRtcIlbcfix_Decode(Dec_Inst, encoded_data,
208 (int16_t)len, decoded_data,&speechType); 207 len, decoded_data,&speechType);
209 if (len < 0) { 208 if (len_int < 0) {
210 fprintf(stderr, "Error decoding\n"); 209 fprintf(stderr, "Error decoding\n");
211 exit(0); 210 exit(0);
212 } 211 }
212 len = (size_t)len_int;
213 } else { 213 } else {
214 len=WebRtcIlbcfix_DecodePlc(Dec_Inst, decoded_data, 1); 214 len=WebRtcIlbcfix_DecodePlc(Dec_Inst, decoded_data, 1);
215 } 215 }
216 fprintf(stderr, "\r"); 216 fprintf(stderr, "\r");
217 217
218 /* write output file */ 218 /* write output file */
219 219
220 if (fwrite(decoded_data, sizeof(int16_t), len, 220 if (fwrite(decoded_data, sizeof(int16_t), len, ofileid) != len) {
221 ofileid) != (size_t)len) {
222 return -1; 221 return -1;
223 } 222 }
224 } 223 }
225 224
226 /* close files */ 225 /* close files */
227 226
228 fclose(ifileid); fclose(efileid); fclose(ofileid); 227 fclose(ifileid); fclose(efileid); fclose(ofileid);
229 if (argc==6) { 228 if (argc==6) {
230 fclose(cfileid); 229 fclose(cfileid);
231 } 230 }
232 231
233 /* Free structs */ 232 /* Free structs */
234 WebRtcIlbcfix_EncoderFree(Enc_Inst); 233 WebRtcIlbcfix_EncoderFree(Enc_Inst);
235 WebRtcIlbcfix_DecoderFree(Dec_Inst); 234 WebRtcIlbcfix_DecoderFree(Dec_Inst);
236 235
237 236
238 printf("\nDone with simulation\n\n"); 237 printf("\nDone with simulation\n\n");
239 238
240 return(0); 239 return(0);
241 } 240 }
OLDNEW
« no previous file with comments | « webrtc/modules/audio_coding/codecs/ilbc/swap_bytes.c ('k') | webrtc/modules/audio_coding/codecs/ilbc/test/iLBC_testLib.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698