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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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; |
51 short pli, mode; | 51 short pli, mode; |
52 int blockcount = 0; | 52 int blockcount = 0; |
53 int packetlosscount = 0; | 53 int packetlosscount = 0; |
54 int frameLen; | 54 int frameLen; |
| 55 size_t len_i16s; |
55 int16_t speechType; | 56 int16_t speechType; |
56 IlbcEncoderInstance *Enc_Inst; | 57 IlbcEncoderInstance *Enc_Inst; |
57 IlbcDecoderInstance *Dec_Inst; | 58 IlbcDecoderInstance *Dec_Inst; |
58 | 59 |
59 #ifdef __ILBC_WITH_40BITACC | 60 #ifdef __ILBC_WITH_40BITACC |
60 /* Doublecheck that long long exists */ | 61 /* Doublecheck that long long exists */ |
61 if (sizeof(long)>=sizeof(long long)) { | 62 if (sizeof(long)>=sizeof(long long)) { |
62 fprintf(stderr, "40-bit simulation is not be supported on this platform\n"); | 63 fprintf(stderr, "40-bit simulation is not be supported on this platform\n"); |
63 exit(0); | 64 exit(0); |
64 } | 65 } |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 fprintf(stderr, "--- Encoding block %i --- ",blockcount); | 167 fprintf(stderr, "--- Encoding block %i --- ",blockcount); |
167 len = WebRtcIlbcfix_Encode(Enc_Inst, data, (int16_t)frameLen, encoded_data); | 168 len = WebRtcIlbcfix_Encode(Enc_Inst, data, (int16_t)frameLen, encoded_data); |
168 if (len < 0) { | 169 if (len < 0) { |
169 fprintf(stderr, "Error encoding\n"); | 170 fprintf(stderr, "Error encoding\n"); |
170 exit(0); | 171 exit(0); |
171 } | 172 } |
172 fprintf(stderr, "\r"); | 173 fprintf(stderr, "\r"); |
173 | 174 |
174 /* write byte file */ | 175 /* write byte file */ |
175 | 176 |
176 if (fwrite(encoded_data, sizeof(int16_t), | 177 len_i16s = (len + 1) / sizeof(int16_t); |
177 ((len+1)/sizeof(int16_t)), efileid) != | 178 if (fwrite(encoded_data, sizeof(int16_t), len_i16s, efileid) != len_i16s) { |
178 (size_t)(((len+1)/sizeof(int16_t)))) { | |
179 return -1; | 179 return -1; |
180 } | 180 } |
181 | 181 |
182 /* get channel data if provided */ | 182 /* get channel data if provided */ |
183 if (argc==6) { | 183 if (argc==6) { |
184 if (fread(&pli, sizeof(int16_t), 1, cfileid)) { | 184 if (fread(&pli, sizeof(int16_t), 1, cfileid)) { |
185 if ((pli!=0)&&(pli!=1)) { | 185 if ((pli!=0)&&(pli!=1)) { |
186 fprintf(stderr, "Error in channel file\n"); | 186 fprintf(stderr, "Error in channel file\n"); |
187 exit(0); | 187 exit(0); |
188 } | 188 } |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 | 232 |
233 /* Free structs */ | 233 /* Free structs */ |
234 WebRtcIlbcfix_EncoderFree(Enc_Inst); | 234 WebRtcIlbcfix_EncoderFree(Enc_Inst); |
235 WebRtcIlbcfix_DecoderFree(Dec_Inst); | 235 WebRtcIlbcfix_DecoderFree(Dec_Inst); |
236 | 236 |
237 | 237 |
238 printf("\nDone with simulation\n\n"); | 238 printf("\nDone with simulation\n\n"); |
239 | 239 |
240 return(0); | 240 return(0); |
241 } | 241 } |
OLD | NEW |