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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 blockcount++; | 163 blockcount++; |
163 | 164 |
164 /* encoding */ | 165 /* encoding */ |
165 | 166 |
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 fprintf(stderr, "\r"); | 169 fprintf(stderr, "\r"); |
169 | 170 |
170 /* write byte file */ | 171 /* write byte file */ |
171 | 172 |
172 if (fwrite(encoded_data, sizeof(int16_t), | 173 len_i16s = (len + 1) / sizeof(int16_t); |
173 ((len+1)/sizeof(int16_t)), efileid) != | 174 if (fwrite(encoded_data, sizeof(int16_t), len_i16s, efileid) != len_i16s) { |
174 (size_t)(((len+1)/sizeof(int16_t)))) { | |
175 return -1; | 175 return -1; |
176 } | 176 } |
177 | 177 |
178 /* get channel data if provided */ | 178 /* get channel data if provided */ |
179 if (argc==6) { | 179 if (argc==6) { |
180 if (fread(&pli, sizeof(int16_t), 1, cfileid)) { | 180 if (fread(&pli, sizeof(int16_t), 1, cfileid)) { |
181 if ((pli!=0)&&(pli!=1)) { | 181 if ((pli!=0)&&(pli!=1)) { |
182 fprintf(stderr, "Error in channel file\n"); | 182 fprintf(stderr, "Error in channel file\n"); |
183 exit(0); | 183 exit(0); |
184 } | 184 } |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 | 224 |
225 /* Free structs */ | 225 /* Free structs */ |
226 WebRtcIlbcfix_EncoderFree(Enc_Inst); | 226 WebRtcIlbcfix_EncoderFree(Enc_Inst); |
227 WebRtcIlbcfix_DecoderFree(Dec_Inst); | 227 WebRtcIlbcfix_DecoderFree(Dec_Inst); |
228 | 228 |
229 | 229 |
230 printf("\nDone with simulation\n\n"); | 230 printf("\nDone with simulation\n\n"); |
231 | 231 |
232 return(0); | 232 return(0); |
233 } | 233 } |
OLD | NEW |