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 |
11 #include <stdio.h> | 11 #include <stdio.h> |
12 #include <stdlib.h> | 12 #include <stdlib.h> |
13 #include <string.h> | 13 #include <string.h> |
14 #include <time.h> | 14 #include <time.h> |
15 #include <ctype.h> | 15 #include <ctype.h> |
16 | 16 |
17 #include "webrtc/modules/audio_coding/codecs/isac/fix/include/isacfix.h" | 17 #include "webrtc/modules/audio_coding/codecs/isac/fix/include/isacfix.h" |
| 18 #include "webrtc/test/gtest.h" |
18 #include "webrtc/test/testsupport/perf_test.h" | 19 #include "webrtc/test/testsupport/perf_test.h" |
19 | 20 |
20 // TODO(kma): Clean up the code and change benchmarking the whole codec to | 21 // TODO(kma): Clean up the code and change benchmarking the whole codec to |
21 // separate encoder and decoder. | 22 // separate encoder and decoder. |
22 | 23 |
23 /* Defines */ | 24 /* Defines */ |
24 #define SEED_FILE "randseed.txt" /* Used when running decoder on garbage data *
/ | 25 #define SEED_FILE "randseed.txt" /* Used when running decoder on garbage data *
/ |
25 #define MAX_FRAMESAMPLES 960 /* max number of samples per frame (= 60 ms fr
ame) */ | 26 #define MAX_FRAMESAMPLES 960 /* max number of samples per frame (= 60 ms fr
ame) */ |
26 #define FRAMESAMPLES_10ms 160 /* number of samples per 10ms frame */ | 27 #define FRAMESAMPLES_10ms 160 /* number of samples per 10ms frame */ |
27 #define FS 16000 /* sampling frequency (Hz) */ | 28 #define FS 16000 /* sampling frequency (Hz) */ |
28 | 29 |
29 /* Function for reading audio data from PCM file */ | 30 /* Function for reading audio data from PCM file */ |
30 int readframe(int16_t *data, FILE *inp, int length) { | 31 int readframe(int16_t *data, FILE *inp, int length) { |
31 | 32 |
32 short k, rlen, status = 0; | 33 short k, rlen, status = 0; |
33 | 34 |
34 rlen = fread(data, sizeof(int16_t), length, inp); | 35 rlen = fread(data, sizeof(int16_t), length, inp); |
35 if (rlen < length) { | 36 if (rlen < length) { |
36 for (k = rlen; k < length; k++) | 37 for (k = rlen; k < length; k++) |
37 data[k] = 0; | 38 data[k] = 0; |
38 status = 1; | 39 status = 1; |
39 } | 40 } |
40 | 41 |
41 return status; | 42 return status; |
42 } | 43 } |
43 | 44 |
| 45 // Globals needed because gtest does not provide access to argv. |
| 46 // This should be reworked to use flags. |
| 47 static int global_argc; |
| 48 static char **global_argv; |
| 49 |
44 /* Struct for bottleneck model */ | 50 /* Struct for bottleneck model */ |
45 typedef struct { | 51 typedef struct { |
46 uint32_t send_time; /* samples */ | 52 uint32_t send_time; /* samples */ |
47 uint32_t arrival_time; /* samples */ | 53 uint32_t arrival_time; /* samples */ |
48 uint32_t sample_count; /* samples */ | 54 uint32_t sample_count; /* samples */ |
49 uint16_t rtp_number; | 55 uint16_t rtp_number; |
50 } BottleNeckModel; | 56 } BottleNeckModel; |
51 | 57 |
52 void get_arrival_time(int current_framesamples, /* samples */ | 58 void get_arrival_time(int current_framesamples, /* samples */ |
53 size_t packet_size, /* bytes */ | 59 size_t packet_size, /* bytes */ |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 { | 91 { |
86 // | 92 // |
87 BN_data->arrival_time += (current_framesamples + ((FS/1000) * current_delay)
); | 93 BN_data->arrival_time += (current_framesamples + ((FS/1000) * current_delay)
); |
88 } | 94 } |
89 //else | 95 //else |
90 //current packet has same timestamp as previous packet | 96 //current packet has same timestamp as previous packet |
91 | 97 |
92 BN_data->rtp_number++; | 98 BN_data->rtp_number++; |
93 } | 99 } |
94 | 100 |
95 int main(int argc, char* argv[]) | 101 TEST(IsacFixTest, Kenny) { |
96 { | 102 int argc = global_argc; |
| 103 char **argv = global_argv; |
97 | 104 |
98 char inname[100], outname[100], outbitsname[100], bottleneck_file[100]; | 105 char inname[100], outname[100], outbitsname[100], bottleneck_file[100]; |
99 FILE *inp, *outp, *f_bn, *outbits; | 106 FILE *inp, *outp, *f_bn, *outbits; |
100 int endfile; | 107 int endfile; |
101 | 108 |
102 size_t i; | 109 size_t i; |
103 int errtype, h = 0, k, packetLossPercent = 0; | 110 int errtype, h = 0, k, packetLossPercent = 0; |
104 int16_t CodingMode; | 111 int16_t CodingMode; |
105 int16_t bottleneck; | 112 int16_t bottleneck; |
106 int framesize = 30; /* ms */ | 113 int framesize = 30; /* ms */ |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 " getNewBitstream \n"); | 223 " getNewBitstream \n"); |
217 printf(" CE 2 - transcode, getBWE \n"); | 224 printf(" CE 2 - transcode, getBWE \n"); |
218 printf(" CE 3 - getSendBWE, setSendBWE. \n\n"); | 225 printf(" CE 3 - getSendBWE, setSendBWE. \n\n"); |
219 printf("[-RTP_INIT num] : if -RTP_INIT option is specified num will be" | 226 printf("[-RTP_INIT num] : if -RTP_INIT option is specified num will be" |
220 " the initial\n"); | 227 " the initial\n"); |
221 printf(" value of the rtp sequence number.\n\n"); | 228 printf(" value of the rtp sequence number.\n\n"); |
222 printf("infile : Normal speech input file\n\n"); | 229 printf("infile : Normal speech input file\n\n"); |
223 printf("outfile : Speech output file\n\n"); | 230 printf("outfile : Speech output file\n\n"); |
224 printf("Example usage : \n\n"); | 231 printf("Example usage : \n\n"); |
225 printf("%s -I bottleneck.txt speechIn.pcm speechOut.pcm\n\n", argv[0]); | 232 printf("%s -I bottleneck.txt speechIn.pcm speechOut.pcm\n\n", argv[0]); |
226 exit(0); | 233 exit(1); |
227 | 234 |
228 } | 235 } |
229 | 236 |
230 /* Print version number */ | 237 /* Print version number */ |
231 WebRtcIsacfix_version(version_number); | 238 WebRtcIsacfix_version(version_number); |
232 printf("iSAC version %s \n\n", version_number); | 239 printf("iSAC version %s \n\n", version_number); |
233 | 240 |
234 /* Loop over all command line arguments */ | 241 /* Loop over all command line arguments */ |
235 CodingMode = 0; | 242 CodingMode = 0; |
236 testNum = 0; | 243 testNum = 0; |
237 testCE = 0; | 244 testCE = 0; |
238 for (i = 1; i + 2 < static_cast<size_t>(argc); i++) { | 245 for (i = 1; i + 2 < static_cast<size_t>(argc); i++) { |
239 /* Instantaneous mode */ | 246 /* Instantaneous mode */ |
240 if (!strcmp ("-I", argv[i])) { | 247 if (!strcmp ("-I", argv[i])) { |
241 printf("\nInstantaneous BottleNeck\n"); | 248 printf("\nInstantaneous BottleNeck\n"); |
242 CodingMode = 1; | 249 CodingMode = 1; |
243 i++; | 250 i++; |
244 } | 251 } |
245 | 252 |
246 /* Set (initial) bottleneck value */ | 253 /* Set (initial) bottleneck value */ |
247 if (!strcmp ("-INITRATE", argv[i])) { | 254 if (!strcmp ("-INITRATE", argv[i])) { |
248 rateBPS = atoi(argv[i + 1]); | 255 rateBPS = atoi(argv[i + 1]); |
249 setControlBWE = 1; | 256 setControlBWE = 1; |
250 if ((rateBPS < 10000) || (rateBPS > 32000)) { | 257 if ((rateBPS < 10000) || (rateBPS > 32000)) { |
251 printf("\n%d is not a initial rate. " | 258 printf("\n%d is not a initial rate. " |
252 "Valid values are in the range 10000 to 32000.\n", rateBPS); | 259 "Valid values are in the range 10000 to 32000.\n", rateBPS); |
253 exit(0); | 260 exit(1); |
254 } | 261 } |
255 printf("\nNew initial rate: %d\n", rateBPS); | 262 printf("\nNew initial rate: %d\n", rateBPS); |
256 i++; | 263 i++; |
257 } | 264 } |
258 | 265 |
259 /* Set (initial) framelength */ | 266 /* Set (initial) framelength */ |
260 if (!strcmp ("-FL", argv[i])) { | 267 if (!strcmp ("-FL", argv[i])) { |
261 framesize = atoi(argv[i + 1]); | 268 framesize = atoi(argv[i + 1]); |
262 if ((framesize != 30) && (framesize != 60)) { | 269 if ((framesize != 30) && (framesize != 60)) { |
263 printf("\n%d is not a valid frame length. " | 270 printf("\n%d is not a valid frame length. " |
264 "Valid length are 30 and 60 msec.\n", framesize); | 271 "Valid length are 30 and 60 msec.\n", framesize); |
265 exit(0); | 272 exit(1); |
266 } | 273 } |
267 printf("\nFrame Length: %d\n", framesize); | 274 printf("\nFrame Length: %d\n", framesize); |
268 i++; | 275 i++; |
269 } | 276 } |
270 | 277 |
271 /* Fixed frame length */ | 278 /* Fixed frame length */ |
272 if (!strcmp ("-FIXED_FL", argv[i])) { | 279 if (!strcmp ("-FIXED_FL", argv[i])) { |
273 fixedFL = 1; | 280 fixedFL = 1; |
274 setControlBWE = 1; | 281 setControlBWE = 1; |
275 } | 282 } |
(...skipping 12 matching lines...) Expand all Loading... |
288 i++; | 295 i++; |
289 } | 296 } |
290 | 297 |
291 /* Test of fault scenarious */ | 298 /* Test of fault scenarious */ |
292 if (!strcmp ("-F", argv[i])) { | 299 if (!strcmp ("-F", argv[i])) { |
293 testNum = atoi(argv[i + 1]); | 300 testNum = atoi(argv[i + 1]); |
294 printf("\nFault test: %d\n", testNum); | 301 printf("\nFault test: %d\n", testNum); |
295 if (testNum < 1 || testNum > 10) { | 302 if (testNum < 1 || testNum > 10) { |
296 printf("\n%d is not a valid Fault Scenario number." | 303 printf("\n%d is not a valid Fault Scenario number." |
297 " Valid Fault Scenarios are numbered 1-10.\n", testNum); | 304 " Valid Fault Scenarios are numbered 1-10.\n", testNum); |
298 exit(0); | 305 exit(1); |
299 } | 306 } |
300 i++; | 307 i++; |
301 } | 308 } |
302 | 309 |
303 /* Packet loss test */ | 310 /* Packet loss test */ |
304 if (!strcmp ("-PL", argv[i])) { | 311 if (!strcmp ("-PL", argv[i])) { |
305 if( isdigit( *argv[i+1] ) ) { | 312 if( isdigit( *argv[i+1] ) ) { |
306 packetLossPercent = atoi( argv[i+1] ); | 313 packetLossPercent = atoi( argv[i+1] ); |
307 if( (packetLossPercent < 0) | (packetLossPercent > 100) ) { | 314 if( (packetLossPercent < 0) | (packetLossPercent > 100) ) { |
308 printf( "\nInvalid packet loss perentage \n" ); | 315 printf( "\nInvalid packet loss perentage \n" ); |
309 exit( 0 ); | 316 exit( 1 ); |
310 } | 317 } |
311 if( packetLossPercent > 0 ) { | 318 if( packetLossPercent > 0 ) { |
312 printf( "\nSimulating %d %% of independent packet loss\n", | 319 printf( "\nSimulating %d %% of independent packet loss\n", |
313 packetLossPercent ); | 320 packetLossPercent ); |
314 } else { | 321 } else { |
315 printf( "\nNo Packet Loss Is Simulated \n" ); | 322 printf( "\nNo Packet Loss Is Simulated \n" ); |
316 } | 323 } |
317 readLoss = 0; | 324 readLoss = 0; |
318 } else { | 325 } else { |
319 readLoss = 1; | 326 readLoss = 1; |
320 plFile = fopen( argv[i+1], "rb" ); | 327 plFile = fopen( argv[i+1], "rb" ); |
321 if( plFile == NULL ) { | 328 if( plFile == NULL ) { |
322 printf( "\n couldn't open the frameloss file: %s\n", argv[i+1] ); | 329 FAIL() << "Couldn't open the frameloss file: " << argv[i+1]; |
323 exit( 0 ); | |
324 } | 330 } |
325 printf( "\nSimulating packet loss through the given " | 331 printf( "\nSimulating packet loss through the given " |
326 "channel file: %s\n", argv[i+1] ); | 332 "channel file: %s\n", argv[i+1] ); |
327 } | 333 } |
328 i++; | 334 i++; |
329 } | 335 } |
330 | 336 |
331 /* Random packetlosses */ | 337 /* Random packetlosses */ |
332 if (!strcmp ("-rnd", argv[i])) { | 338 if (!strcmp ("-rnd", argv[i])) { |
333 srand(time(NULL) ); | 339 srand(time(NULL) ); |
334 printf( "\n Random pattern in lossed packets \n" ); | 340 printf( "\n Random pattern in lossed packets \n" ); |
335 } | 341 } |
336 | 342 |
337 /* Use gns file */ | 343 /* Use gns file */ |
338 if (!strcmp ("-G", argv[i])) { | 344 if (!strcmp ("-G", argv[i])) { |
339 sscanf(argv[i + 1], "%s", gns_file); | 345 sscanf(argv[i + 1], "%s", gns_file); |
340 fp_gns = fopen(gns_file, "rb"); | 346 fp_gns = fopen(gns_file, "rb"); |
341 if (fp_gns == NULL) { | 347 if (fp_gns == NULL) { |
342 printf("Cannot read file %s.\n", gns_file); | 348 FAIL() << "Cannot read file " << gns_file << "."; |
343 exit(0); | |
344 } | 349 } |
345 gns = 1; | 350 gns = 1; |
346 i++; | 351 i++; |
347 } | 352 } |
348 | 353 |
349 /* Run Narrowband interfaces (either encoder or decoder) */ | 354 /* Run Narrowband interfaces (either encoder or decoder) */ |
350 if (!strcmp ("-NB", argv[i])) { | 355 if (!strcmp ("-NB", argv[i])) { |
351 nbTest = atoi(argv[i + 1]); | 356 nbTest = atoi(argv[i + 1]); |
352 i++; | 357 i++; |
353 } | 358 } |
354 | 359 |
355 /* Run Conference Engine APIs */ | 360 /* Run Conference Engine APIs */ |
356 if (!strcmp ("-CE", argv[i])) { | 361 if (!strcmp ("-CE", argv[i])) { |
357 testCE = atoi(argv[i + 1]); | 362 testCE = atoi(argv[i + 1]); |
358 if (testCE==1 || testCE==2) { | 363 if (testCE==1 || testCE==2) { |
359 i++; | 364 i++; |
360 scale = (float)atof( argv[i+1] ); | 365 scale = (float)atof( argv[i+1] ); |
361 } else if (testCE < 1 || testCE > 3) { | 366 } else if (testCE < 1 || testCE > 3) { |
362 printf("\n%d is not a valid CE-test number, valid Fault " | 367 printf("\n%d is not a valid CE-test number, valid Fault " |
363 "Scenarios are numbered 1-3\n", testCE); | 368 "Scenarios are numbered 1-3\n", testCE); |
364 exit(0); | 369 exit(1); |
365 } | 370 } |
366 i++; | 371 i++; |
367 } | 372 } |
368 | 373 |
369 /* Set initial RTP number */ | 374 /* Set initial RTP number */ |
370 if (!strcmp ("-RTP_INIT", argv[i])) { | 375 if (!strcmp ("-RTP_INIT", argv[i])) { |
371 i++; | 376 i++; |
372 } | 377 } |
373 } | 378 } |
374 | 379 |
375 /* Get Bottleneck value */ | 380 /* Get Bottleneck value */ |
376 /* Gns files and bottleneck should not and can not be used simultaneously */ | 381 /* Gns files and bottleneck should not and can not be used simultaneously */ |
377 bottleneck = atoi(argv[CodingMode+1]); | 382 bottleneck = atoi(argv[CodingMode+1]); |
378 if (bottleneck == 0 && gns == 0) { | 383 if (bottleneck == 0 && gns == 0) { |
379 sscanf(argv[CodingMode+1], "%s", bottleneck_file); | 384 sscanf(argv[CodingMode+1], "%s", bottleneck_file); |
380 f_bn = fopen(bottleneck_file, "rb"); | 385 f_bn = fopen(bottleneck_file, "rb"); |
381 if (f_bn == NULL) { | 386 if (f_bn == NULL) { |
382 printf("No value provided for BottleNeck and cannot read file %s\n", | 387 printf("No value provided for BottleNeck and cannot read file %s\n", |
383 bottleneck_file); | 388 bottleneck_file); |
384 exit(0); | 389 exit(0); // TODO(oprypin): don't silence this error |
| 390 // FAIL() << "Cannot read file " << bottleneck_file; |
385 } else { | 391 } else { |
386 int aux_var; | 392 int aux_var; |
387 printf("reading bottleneck rates from file %s\n\n",bottleneck_file); | 393 printf("reading bottleneck rates from file %s\n\n",bottleneck_file); |
388 if (fscanf(f_bn, "%d", &aux_var) == EOF) { | 394 if (fscanf(f_bn, "%d", &aux_var) == EOF) { |
389 /* Set pointer to beginning of file */ | 395 /* Set pointer to beginning of file */ |
390 fseek(f_bn, 0L, SEEK_SET); | 396 fseek(f_bn, 0L, SEEK_SET); |
391 if (fscanf(f_bn, "%d", &aux_var) == EOF) { | 397 if (fscanf(f_bn, "%d", &aux_var) == EOF) { |
392 exit(0); | 398 FAIL(); |
393 } | 399 } |
394 } | 400 } |
395 bottleneck = (int16_t)aux_var; | 401 bottleneck = (int16_t)aux_var; |
396 /* Bottleneck is a cosine function | 402 /* Bottleneck is a cosine function |
397 * Matlab code for writing the bottleneck file: | 403 * Matlab code for writing the bottleneck file: |
398 * BottleNeck_10ms = 20e3 + 10e3 * cos((0:5999)/5999*2*pi); | 404 * BottleNeck_10ms = 20e3 + 10e3 * cos((0:5999)/5999*2*pi); |
399 * fid = fopen('bottleneck.txt', 'wb'); | 405 * fid = fopen('bottleneck.txt', 'wb'); |
400 * fprintf(fid, '%d\n', BottleNeck_10ms); fclose(fid); | 406 * fprintf(fid, '%d\n', BottleNeck_10ms); fclose(fid); |
401 */ | 407 */ |
402 } | 408 } |
(...skipping 13 matching lines...) Expand all Loading... |
416 /* Add '.bit' to output bitstream file */ | 422 /* Add '.bit' to output bitstream file */ |
417 while ((int)outname[h] != 0) { | 423 while ((int)outname[h] != 0) { |
418 outbitsname[h] = outname[h]; | 424 outbitsname[h] = outname[h]; |
419 h++; | 425 h++; |
420 } | 426 } |
421 for (k=0; k<5; k++) { | 427 for (k=0; k<5; k++) { |
422 outbitsname[h] = tmpBit[k]; | 428 outbitsname[h] = tmpBit[k]; |
423 h++; | 429 h++; |
424 } | 430 } |
425 if ((inp = fopen(inname,"rb")) == NULL) { | 431 if ((inp = fopen(inname,"rb")) == NULL) { |
426 printf(" iSAC: Cannot read file %s\n", inname); | 432 FAIL() << " iSAC: Cannot read file " << inname; |
427 exit(1); | |
428 } | 433 } |
429 if ((outp = fopen(outname,"wb")) == NULL) { | 434 if ((outp = fopen(outname,"wb")) == NULL) { |
430 printf(" iSAC: Cannot write file %s\n", outname); | 435 FAIL() << " iSAC: Cannot write file " << outname; |
431 exit(1); | |
432 } | 436 } |
433 | 437 |
434 if ((outbits = fopen(outbitsname,"wb")) == NULL) { | 438 if ((outbits = fopen(outbitsname,"wb")) == NULL) { |
435 printf(" iSAC: Cannot write file %s\n", outbitsname); | 439 FAIL() << " iSAC: Cannot write file " << outbitsname; |
436 exit(1); | |
437 } | 440 } |
438 printf("\nInput:%s\nOutput:%s\n\n", inname, outname); | 441 printf("\nInput:%s\nOutput:%s\n\n", inname, outname); |
439 | 442 |
440 /* Error test number 10, garbage data */ | 443 /* Error test number 10, garbage data */ |
441 if (testNum == 10) { | 444 if (testNum == 10) { |
442 /* Test to run decoder with garbage data */ | 445 /* Test to run decoder with garbage data */ |
443 srand(random_seed); | 446 srand(random_seed); |
444 | 447 |
445 if ( (seedfile = fopen(SEED_FILE, "a+t") ) == NULL ) { | 448 if ( (seedfile = fopen(SEED_FILE, "a+t") ) == NULL ) { |
446 printf("Error: Could not open file %s\n", SEED_FILE); | 449 printf("Error: Could not open file %s\n", SEED_FILE); |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
505 } | 508 } |
506 } else if(setControlBWE == 1) { | 509 } else if(setControlBWE == 1) { |
507 err = WebRtcIsacfix_ControlBwe(ISAC_main_inst, rateBPS, framesize, fixedFL); | 510 err = WebRtcIsacfix_ControlBwe(ISAC_main_inst, rateBPS, framesize, fixedFL); |
508 } | 511 } |
509 | 512 |
510 if (payloadSize != 0) { | 513 if (payloadSize != 0) { |
511 err = WebRtcIsacfix_SetMaxPayloadSize(ISAC_main_inst, payloadSize); | 514 err = WebRtcIsacfix_SetMaxPayloadSize(ISAC_main_inst, payloadSize); |
512 if (err < 0) { | 515 if (err < 0) { |
513 /* exit if returned with error */ | 516 /* exit if returned with error */ |
514 errtype=WebRtcIsacfix_GetErrorCode(ISAC_main_inst); | 517 errtype=WebRtcIsacfix_GetErrorCode(ISAC_main_inst); |
515 printf("\n\n Error in SetMaxPayloadSize: %d.\n\n", errtype); | 518 FAIL() << "Error in SetMaxPayloadSize: " << errtype; |
516 exit(EXIT_FAILURE); | |
517 } | 519 } |
518 } | 520 } |
519 if (payloadRate != 0) { | 521 if (payloadRate != 0) { |
520 err = WebRtcIsacfix_SetMaxRate(ISAC_main_inst, payloadRate); | 522 err = WebRtcIsacfix_SetMaxRate(ISAC_main_inst, payloadRate); |
521 if (err < 0) { | 523 if (err < 0) { |
522 /* exit if returned with error */ | 524 /* exit if returned with error */ |
523 errtype=WebRtcIsacfix_GetErrorCode(ISAC_main_inst); | 525 errtype=WebRtcIsacfix_GetErrorCode(ISAC_main_inst); |
524 printf("\n\n Error in SetMaxRateInBytes: %d.\n\n", errtype); | 526 FAIL() << "Error in SetMaxRateInBytes: " << errtype; |
525 exit(EXIT_FAILURE); | |
526 } | 527 } |
527 } | 528 } |
528 | 529 |
529 *speechType = 1; | 530 *speechType = 1; |
530 | 531 |
531 | 532 |
532 while (endfile == 0) { | 533 while (endfile == 0) { |
533 | 534 |
534 if(testNum == 7 && (rand()%2 == 0)) { | 535 if(testNum == 7 && (rand()%2 == 0)) { |
535 err = WebRtcIsacfix_EncoderInit(ISAC_main_inst, CodingMode); | 536 err = WebRtcIsacfix_EncoderInit(ISAC_main_inst, CodingMode); |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
617 } | 618 } |
618 | 619 |
619 if (stream_len_int < 0 || err < 0) { | 620 if (stream_len_int < 0 || err < 0) { |
620 /* exit if returned with error */ | 621 /* exit if returned with error */ |
621 errtype=WebRtcIsacfix_GetErrorCode(ISAC_main_inst); | 622 errtype=WebRtcIsacfix_GetErrorCode(ISAC_main_inst); |
622 printf("\nError in encoder: %d.\n", errtype); | 623 printf("\nError in encoder: %d.\n", errtype); |
623 } else { | 624 } else { |
624 stream_len = static_cast<size_t>(stream_len_int); | 625 stream_len = static_cast<size_t>(stream_len_int); |
625 if (fwrite(streamdata, sizeof(char), stream_len, outbits) != | 626 if (fwrite(streamdata, sizeof(char), stream_len, outbits) != |
626 stream_len) { | 627 stream_len) { |
627 return -1; | 628 FAIL(); |
628 } | 629 } |
629 } | 630 } |
630 | 631 |
631 cur_framesmpls += FRAMESAMPLES_10ms; | 632 cur_framesmpls += FRAMESAMPLES_10ms; |
632 | 633 |
633 /* read next bottleneck rate */ | 634 /* read next bottleneck rate */ |
634 if (f_bn != NULL) { | 635 if (f_bn != NULL) { |
635 int aux_var; | 636 int aux_var; |
636 if (fscanf(f_bn, "%d", &aux_var) == EOF) { | 637 if (fscanf(f_bn, "%d", &aux_var) == EOF) { |
637 /* Set pointer to beginning of file */ | 638 /* Set pointer to beginning of file */ |
638 fseek(f_bn, 0L, SEEK_SET); | 639 fseek(f_bn, 0L, SEEK_SET); |
639 if (fscanf(f_bn, "%d", &aux_var) == EOF) { | 640 if (fscanf(f_bn, "%d", &aux_var) == EOF) { |
640 exit(0); | 641 FAIL(); |
641 } | 642 } |
642 } | 643 } |
643 bottleneck = (int16_t)aux_var; | 644 bottleneck = (int16_t)aux_var; |
644 if (CodingMode == 1) { | 645 if (CodingMode == 1) { |
645 WebRtcIsacfix_Control(ISAC_main_inst, bottleneck, framesize); | 646 WebRtcIsacfix_Control(ISAC_main_inst, bottleneck, framesize); |
646 } | 647 } |
647 } | 648 } |
648 | 649 |
649 /* exit encoder loop if the encoder returned a bitstream */ | 650 /* exit encoder loop if the encoder returned a bitstream */ |
650 if (stream_len != 0) break; | 651 if (stream_len != 0) break; |
(...skipping 16 matching lines...) Expand all Loading... |
667 for (i = 0; i < stream_len; i++ ) { | 668 for (i = 0; i < stream_len; i++ ) { |
668 streamdata[i] = rand(); | 669 streamdata[i] = rand(); |
669 } | 670 } |
670 } | 671 } |
671 | 672 |
672 /* set pointer to beginning of file */ | 673 /* set pointer to beginning of file */ |
673 if (fp_gns != NULL) { | 674 if (fp_gns != NULL) { |
674 if (fscanf(fp_gns, "%d", &cur_delay) == EOF) { | 675 if (fscanf(fp_gns, "%d", &cur_delay) == EOF) { |
675 fseek(fp_gns, 0L, SEEK_SET); | 676 fseek(fp_gns, 0L, SEEK_SET); |
676 if (fscanf(fp_gns, "%d", &cur_delay) == EOF) { | 677 if (fscanf(fp_gns, "%d", &cur_delay) == EOF) { |
677 exit(0); | 678 FAIL(); |
678 } | 679 } |
679 } | 680 } |
680 } | 681 } |
681 | 682 |
682 /* simulate packet handling through NetEq and the modem */ | 683 /* simulate packet handling through NetEq and the modem */ |
683 if (!(testNum == 3 && framecnt == 0)) { | 684 if (!(testNum == 3 && framecnt == 0)) { |
684 if (gns == 0) { | 685 if (gns == 0) { |
685 get_arrival_time(cur_framesmpls, stream_len, bottleneck, | 686 get_arrival_time(cur_framesmpls, stream_len, bottleneck, |
686 &BN_data); | 687 &BN_data); |
687 } else { | 688 } else { |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
776 | 777 |
777 if (declen <= 0) { | 778 if (declen <= 0) { |
778 /* exit if returned with error */ | 779 /* exit if returned with error */ |
779 errtype=WebRtcIsacfix_GetErrorCode(ISAC_main_inst); | 780 errtype=WebRtcIsacfix_GetErrorCode(ISAC_main_inst); |
780 printf("\nError in decoder: %d.\n", errtype); | 781 printf("\nError in decoder: %d.\n", errtype); |
781 } | 782 } |
782 | 783 |
783 /* Write decoded speech frame to file */ | 784 /* Write decoded speech frame to file */ |
784 if (fwrite(decoded, sizeof(int16_t), | 785 if (fwrite(decoded, sizeof(int16_t), |
785 declen, outp) != (size_t)declen) { | 786 declen, outp) != (size_t)declen) { |
786 return -1; | 787 FAIL(); |
787 } | 788 } |
788 // fprintf( ratefile, "%f \n", stream_len / ( ((double)declen)/ | 789 // fprintf( ratefile, "%f \n", stream_len / ( ((double)declen)/ |
789 // ((double)FS) ) * 8 ); | 790 // ((double)FS) ) * 8 ); |
790 } else { | 791 } else { |
791 lostPackets++; | 792 lostPackets++; |
792 } | 793 } |
793 framecnt++; | 794 framecnt++; |
794 | 795 |
795 totalsmpls += declen; | 796 totalsmpls += declen; |
796 totalbits += static_cast<int>(8 * stream_len); | 797 totalbits += static_cast<int>(8 * stream_len); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
828 (runtime * 10000) / length_file, "us", false); | 829 (runtime * 10000) / length_file, "us", false); |
829 | 830 |
830 fclose(inp); | 831 fclose(inp); |
831 fclose(outp); | 832 fclose(outp); |
832 fclose(outbits); | 833 fclose(outbits); |
833 | 834 |
834 if ( testCE == 1) { | 835 if ( testCE == 1) { |
835 WebRtcIsacfix_FreeInternal(ISAC_main_inst); | 836 WebRtcIsacfix_FreeInternal(ISAC_main_inst); |
836 } | 837 } |
837 WebRtcIsacfix_Free(ISAC_main_inst); | 838 WebRtcIsacfix_Free(ISAC_main_inst); |
838 return 0; | |
839 } | 839 } |
| 840 |
| 841 int main(int argc, char* argv[]) { |
| 842 ::testing::InitGoogleTest(&argc, argv); |
| 843 global_argc = argc; |
| 844 global_argv = argv; |
| 845 |
| 846 return RUN_ALL_TESTS(); |
| 847 } |
OLD | NEW |