OLD | NEW |
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 24 matching lines...) Expand all Loading... |
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 short len, mode, pli; | 44 short len, mode, pli; |
| 45 size_t readlen; |
45 int blockcount = 0; | 46 int blockcount = 0; |
46 | 47 |
47 IlbcEncoderInstance *Enc_Inst; | 48 IlbcEncoderInstance *Enc_Inst; |
48 IlbcDecoderInstance *Dec_Inst; | 49 IlbcDecoderInstance *Dec_Inst; |
49 #ifdef JUNK_DATA | 50 #ifdef JUNK_DATA |
50 int i; | 51 int i; |
51 FILE *seedfile; | 52 FILE *seedfile; |
52 unsigned int random_seed = (unsigned int) time(NULL);//1196764538 | 53 unsigned int random_seed = (unsigned int) time(NULL);//1196764538 |
53 #endif | 54 #endif |
54 | 55 |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 fclose(seedfile); | 119 fclose(seedfile); |
119 } | 120 } |
120 #endif | 121 #endif |
121 | 122 |
122 /* Initialization */ | 123 /* Initialization */ |
123 WebRtcIlbcfix_EncoderInit(Enc_Inst, mode); | 124 WebRtcIlbcfix_EncoderInit(Enc_Inst, mode); |
124 WebRtcIlbcfix_DecoderInit(Dec_Inst, mode); | 125 WebRtcIlbcfix_DecoderInit(Dec_Inst, mode); |
125 | 126 |
126 /* loop over input blocks */ | 127 /* loop over input blocks */ |
127 #ifdef SPLIT_10MS | 128 #ifdef SPLIT_10MS |
128 while(fread(data, sizeof(short), 80, ifileid) == 80) { | 129 readlen = 80; |
129 #else | 130 #else |
130 while((short)fread(data,sizeof(short),(mode<<3),ifileid)==(mode<<3)) { | 131 readlen = (size_t)(mode << 3); |
131 #endif | 132 #endif |
| 133 while(fread(data, sizeof(short), readlen, ifileid) == readlen) { |
132 blockcount++; | 134 blockcount++; |
133 | 135 |
134 /* encoding */ | 136 /* encoding */ |
135 fprintf(stderr, "--- Encoding block %i --- ",blockcount); | 137 fprintf(stderr, "--- Encoding block %i --- ",blockcount); |
136 #ifdef SPLIT_10MS | 138 len=WebRtcIlbcfix_Encode(Enc_Inst, data, (short)readlen, encoded_data); |
137 len=WebRtcIlbcfix_Encode(Enc_Inst, data, 80, encoded_data); | |
138 #else | |
139 len=WebRtcIlbcfix_Encode(Enc_Inst, data, (short)(mode<<3), encoded_data); | |
140 #endif | |
141 if (len < 0) { | 139 if (len < 0) { |
142 fprintf(stderr, "Error encoding\n"); | 140 fprintf(stderr, "Error encoding\n"); |
143 exit(0); | 141 exit(0); |
144 } | 142 } |
145 fprintf(stderr, "\r"); | 143 fprintf(stderr, "\r"); |
146 | 144 |
147 #ifdef JUNK_DATA | 145 #ifdef JUNK_DATA |
148 for ( i = 0; i < len; i++) { | 146 for ( i = 0; i < len; i++) { |
149 encoded_data[i] = (short) (encoded_data[i] + (short) rand()); | 147 encoded_data[i] = (short) (encoded_data[i] + (short) rand()); |
150 } | 148 } |
151 #endif | 149 #endif |
152 /* write byte file */ | 150 /* write byte file */ |
153 if(len != 0){ //len may be 0 in 10ms split case | 151 if(len != 0){ //len may be 0 in 10ms split case |
154 fwrite(encoded_data,1,len,efileid); | 152 fwrite(encoded_data,1,len,efileid); |
155 } | |
156 | 153 |
157 if(len != 0){ //len may be 0 in 10ms split case | |
158 /* get channel data if provided */ | 154 /* get channel data if provided */ |
159 if (argc==6) { | 155 if (argc==6) { |
160 if (fread(&pli, sizeof(int16_t), 1, chfileid)) { | 156 if (fread(&pli, sizeof(int16_t), 1, chfileid)) { |
161 if ((pli!=0)&&(pli!=1)) { | 157 if ((pli!=0)&&(pli!=1)) { |
162 fprintf(stderr, "Error in channel file\n"); | 158 fprintf(stderr, "Error in channel file\n"); |
163 exit(0); | 159 exit(0); |
164 } | 160 } |
165 if (pli==0) { | 161 if (pli==0) { |
166 /* Packet loss -> remove info from frame */ | 162 /* Packet loss -> remove info from frame */ |
167 memset(encoded_data, 0, sizeof(int16_t)*25); | 163 memset(encoded_data, 0, sizeof(int16_t)*25); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 WebRtcIlbcfix_EncoderFree(Enc_Inst); | 203 WebRtcIlbcfix_EncoderFree(Enc_Inst); |
208 WebRtcIlbcfix_DecoderFree(Dec_Inst); | 204 WebRtcIlbcfix_DecoderFree(Dec_Inst); |
209 | 205 |
210 /* close files */ | 206 /* close files */ |
211 fclose(ifileid); | 207 fclose(ifileid); |
212 fclose(efileid); | 208 fclose(efileid); |
213 fclose(ofileid); | 209 fclose(ofileid); |
214 | 210 |
215 return 0; | 211 return 0; |
216 } | 212 } |
OLD | NEW |