OLD | NEW |
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 Loading... |
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 Loading... |
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 Loading... |
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 } |
OLD | NEW |