Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(102)

Side by Side Diff: webrtc/modules/audio_coding/codecs/isac/main/test/ReleaseTest-API/ReleaseTest-API.cc

Issue 2685783014: Replace NULL with nullptr in all C++ files. (Closed)
Patch Set: Fixing android. Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 24 matching lines...) Expand all
35 #ifdef WIN32 35 #ifdef WIN32
36 #ifndef CLOCKS_PER_SEC 36 #ifndef CLOCKS_PER_SEC
37 #define CLOCKS_PER_SEC 1000 /* Runtime statistics */ 37 #define CLOCKS_PER_SEC 1000 /* Runtime statistics */
38 #endif 38 #endif
39 #endif 39 #endif
40 40
41 using namespace std; 41 using namespace std;
42 42
43 int main(int argc, char* argv[]) { 43 int main(int argc, char* argv[]) {
44 char inname[100], outname[100], bottleneck_file[100], vadfile[100]; 44 char inname[100], outname[100], bottleneck_file[100], vadfile[100];
45 FILE* inp, *outp, * f_bn = NULL, * vadp = NULL, *bandwidthp; 45 FILE *inp, *outp, *f_bn = nullptr, *vadp = nullptr, *bandwidthp;
46 int framecnt, endfile; 46 int framecnt, endfile;
47 47
48 size_t i; 48 size_t i;
49 int errtype, VADusage = 0, packetLossPercent = 0; 49 int errtype, VADusage = 0, packetLossPercent = 0;
50 int16_t CodingMode; 50 int16_t CodingMode;
51 int32_t bottleneck = 0; 51 int32_t bottleneck = 0;
52 int framesize = 30; /* ms */ 52 int framesize = 30; /* ms */
53 int cur_framesmpls, err; 53 int cur_framesmpls, err;
54 54
55 /* Runtime statistics */ 55 /* Runtime statistics */
(...skipping 20 matching lines...) Expand all
76 int32_t sendBN; 76 int32_t sendBN;
77 77
78 #if !defined(NDEBUG) 78 #if !defined(NDEBUG)
79 FILE* fy; 79 FILE* fy;
80 double kbps; 80 double kbps;
81 #endif 81 #endif
82 size_t totalbits = 0; 82 size_t totalbits = 0;
83 int totalsmpls = 0; 83 int totalsmpls = 0;
84 84
85 /* If use GNS file */ 85 /* If use GNS file */
86 FILE* fp_gns = NULL; 86 FILE* fp_gns = nullptr;
87 char gns_file[100]; 87 char gns_file[100];
88 size_t maxStreamLen30 = 0; 88 size_t maxStreamLen30 = 0;
89 size_t maxStreamLen60 = 0; 89 size_t maxStreamLen60 = 0;
90 short sampFreqKHz = 32; 90 short sampFreqKHz = 32;
91 short samplesIn10Ms; 91 short samplesIn10Ms;
92 short useAssign = 0; 92 short useAssign = 0;
93 // FILE logFile; 93 // FILE logFile;
94 bool doTransCoding = false; 94 bool doTransCoding = false;
95 int32_t rateTransCoding = 0; 95 int32_t rateTransCoding = 0;
96 uint8_t streamDataTransCoding[1200]; 96 uint8_t streamDataTransCoding[1200];
97 size_t streamLenTransCoding = 0; 97 size_t streamLenTransCoding = 0;
98 FILE* transCodingFile = NULL; 98 FILE* transCodingFile = nullptr;
99 FILE* transcodingBitstream = NULL; 99 FILE* transcodingBitstream = nullptr;
100 size_t numTransCodingBytes = 0; 100 size_t numTransCodingBytes = 0;
101 101
102 /* only one structure used for ISAC encoder */ 102 /* only one structure used for ISAC encoder */
103 ISACStruct* ISAC_main_inst = NULL; 103 ISACStruct* ISAC_main_inst = nullptr;
104 ISACStruct* decoderTransCoding = NULL; 104 ISACStruct* decoderTransCoding = nullptr;
105 105
106 BottleNeckModel BN_data; 106 BottleNeckModel BN_data;
107 107
108 #if !defined(NDEBUG) 108 #if !defined(NDEBUG)
109 fy = fopen("bit_rate.dat", "w"); 109 fy = fopen("bit_rate.dat", "w");
110 fclose(fy); 110 fclose(fy);
111 fy = fopen("bytes_frames.dat", "w"); 111 fy = fopen("bytes_frames.dat", "w");
112 fclose(fy); 112 fclose(fy);
113 #endif 113 #endif
114 114
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 178
179 /* Print version number */ 179 /* Print version number */
180 printf("-------------------------------------------------\n"); 180 printf("-------------------------------------------------\n");
181 WebRtcIsac_version(version_number); 181 WebRtcIsac_version(version_number);
182 printf("iSAC version %s \n\n", version_number); 182 printf("iSAC version %s \n\n", version_number);
183 183
184 /* Loop over all command line arguments */ 184 /* Loop over all command line arguments */
185 CodingMode = 0; 185 CodingMode = 0;
186 testNum = 0; 186 testNum = 0;
187 useAssign = 0; 187 useAssign = 0;
188 // logFile = NULL; 188 // logFile = null;
189 char transCodingFileName[500]; 189 char transCodingFileName[500];
190 int16_t totFileLoop = 0; 190 int16_t totFileLoop = 0;
191 int16_t numFileLoop = 0; 191 int16_t numFileLoop = 0;
192 for (i = 1; i + 2 < static_cast<size_t>(argc); i++) { 192 for (i = 1; i + 2 < static_cast<size_t>(argc); i++) {
193 if (!strcmp("-LOOP", argv[i])) { 193 if (!strcmp("-LOOP", argv[i])) {
194 i++; 194 i++;
195 totFileLoop = (int16_t)atol(argv[i]); 195 totFileLoop = (int16_t)atol(argv[i]);
196 if (totFileLoop <= 0) { 196 if (totFileLoop <= 0) {
197 fprintf(stderr, "Invalid number of runs for the given input file, %d.", 197 fprintf(stderr, "Invalid number of runs for the given input file, %d.",
198 totFileLoop); 198 totFileLoop);
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 exit(0); 293 exit(0);
294 } 294 }
295 if (packetLossPercent > 0) { 295 if (packetLossPercent > 0) {
296 printf("Simulating %d %% of independent packet loss\n", 296 printf("Simulating %d %% of independent packet loss\n",
297 packetLossPercent); 297 packetLossPercent);
298 } else { 298 } else {
299 printf("\nNo Packet Loss Is Simulated \n"); 299 printf("\nNo Packet Loss Is Simulated \n");
300 } 300 }
301 } else { 301 } else {
302 plFile = fopen(argv[i + 1], "rb"); 302 plFile = fopen(argv[i + 1], "rb");
303 if (plFile == NULL) { 303 if (plFile == nullptr) {
304 printf("\n couldn't open the frameloss file: %s\n", argv[i + 1]); 304 printf("\n couldn't open the frameloss file: %s\n", argv[i + 1]);
305 exit(0); 305 exit(0);
306 } 306 }
307 printf("Simulating packet loss through the given channel file: %s\n", 307 printf("Simulating packet loss through the given channel file: %s\n",
308 argv[i + 1]); 308 argv[i + 1]);
309 } 309 }
310 i++; 310 i++;
311 } 311 }
312 312
313 /* Random packetlosses */ 313 /* Random packetlosses */
314 if (!strcmp("-rnd", argv[i])) { 314 if (!strcmp("-rnd", argv[i])) {
315 srand((unsigned int)time(NULL)); 315 srand((unsigned int)time(nullptr));
316 printf("Random pattern in lossed packets \n"); 316 printf("Random pattern in lossed packets \n");
317 } 317 }
318 318
319 /* Use gns file */ 319 /* Use gns file */
320 if (!strcmp("-G", argv[i])) { 320 if (!strcmp("-G", argv[i])) {
321 sscanf(argv[i + 1], "%s", gns_file); 321 sscanf(argv[i + 1], "%s", gns_file);
322 fp_gns = fopen(gns_file, "rb"); 322 fp_gns = fopen(gns_file, "rb");
323 if (fp_gns == NULL) { 323 if (fp_gns == nullptr) {
324 printf("Cannot read file %s.\n", gns_file); 324 printf("Cannot read file %s.\n", gns_file);
325 exit(0); 325 exit(0);
326 } 326 }
327 i++; 327 i++;
328 } 328 }
329 329
330 // make it with '-B' 330 // make it with '-B'
331 /* Get Bottleneck value */ 331 /* Get Bottleneck value */
332 if (!strcmp("-B", argv[i])) { 332 if (!strcmp("-B", argv[i])) {
333 i++; 333 i++;
334 bottleneck = atoi(argv[i]); 334 bottleneck = atoi(argv[i]);
335 if (bottleneck == 0) { 335 if (bottleneck == 0) {
336 sscanf(argv[i], "%s", bottleneck_file); 336 sscanf(argv[i], "%s", bottleneck_file);
337 f_bn = fopen(bottleneck_file, "rb"); 337 f_bn = fopen(bottleneck_file, "rb");
338 if (f_bn == NULL) { 338 if (f_bn == nullptr) {
339 printf("Error No value provided for BottleNeck and cannot read file " 339 printf("Error No value provided for BottleNeck and cannot read file "
340 "%s.\n", bottleneck_file); 340 "%s.\n", bottleneck_file);
341 exit(0); 341 exit(0);
342 } else { 342 } else {
343 printf("reading bottleneck rates from file %s\n\n", bottleneck_file); 343 printf("reading bottleneck rates from file %s\n\n", bottleneck_file);
344 if (fscanf(f_bn, "%d", &bottleneck) == EOF) { 344 if (fscanf(f_bn, "%d", &bottleneck) == EOF) {
345 /* Set pointer to beginning of file */ 345 /* Set pointer to beginning of file */
346 fseek(f_bn, 0L, SEEK_SET); 346 fseek(f_bn, 0L, SEEK_SET);
347 if (fscanf(f_bn, "%d", &bottleneck) == EOF) { 347 if (fscanf(f_bn, "%d", &bottleneck) == EOF) {
348 exit(0); 348 exit(0);
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 default: 405 default:
406 printf("Unsupported sampling frequency %d kHz", sampFreqKHz); 406 printf("Unsupported sampling frequency %d kHz", sampFreqKHz);
407 exit(0); 407 exit(0);
408 } 408 }
409 409
410 /* Get Input and Output files */ 410 /* Get Input and Output files */
411 sscanf(argv[argc - 2], "%s", inname); 411 sscanf(argv[argc - 2], "%s", inname);
412 sscanf(argv[argc - 1], "%s", outname); 412 sscanf(argv[argc - 1], "%s", outname);
413 printf("\nInput file: %s\n", inname); 413 printf("\nInput file: %s\n", inname);
414 printf("Output file: %s\n\n", outname); 414 printf("Output file: %s\n\n", outname);
415 if ((inp = fopen(inname, "rb")) == NULL) { 415 if ((inp = fopen(inname, "rb")) == nullptr) {
416 printf(" Error iSAC Cannot read file %s.\n", inname); 416 printf(" Error iSAC Cannot read file %s.\n", inname);
417 cout << flush; 417 cout << flush;
418 exit(1); 418 exit(1);
419 } 419 }
420 420
421 if ((outp = fopen(outname, "wb")) == NULL) { 421 if ((outp = fopen(outname, "wb")) == nullptr) {
422 printf(" Error iSAC Cannot write file %s.\n", outname); 422 printf(" Error iSAC Cannot write file %s.\n", outname);
423 cout << flush; 423 cout << flush;
424 getc(stdin); 424 getc(stdin);
425 exit(1); 425 exit(1);
426 } 426 }
427 if (VADusage) { 427 if (VADusage) {
428 if ((vadp = fopen(vadfile, "rb")) == NULL) { 428 if ((vadp = fopen(vadfile, "rb")) == nullptr) {
429 printf(" Error iSAC Cannot read file %s.\n", vadfile); 429 printf(" Error iSAC Cannot read file %s.\n", vadfile);
430 cout << flush; 430 cout << flush;
431 exit(1); 431 exit(1);
432 } 432 }
433 } 433 }
434 434
435 if ((bandwidthp = fopen("bwe.pcm", "wb")) == NULL) { 435 if ((bandwidthp = fopen("bwe.pcm", "wb")) == nullptr) {
436 printf(" Error iSAC Cannot read file %s.\n", "bwe.pcm"); 436 printf(" Error iSAC Cannot read file %s.\n", "bwe.pcm");
437 cout << flush; 437 cout << flush;
438 exit(1); 438 exit(1);
439 } 439 }
440 440
441 starttime = clock() / (double)CLOCKS_PER_SEC; /* Runtime statistics */ 441 starttime = clock() / (double)CLOCKS_PER_SEC; /* Runtime statistics */
442 442
443 /* Initialize the ISAC and BN structs */ 443 /* Initialize the ISAC and BN structs */
444 if (testNum != 8) { 444 if (testNum != 8) {
445 if (!useAssign) { 445 if (!useAssign) {
(...skipping 27 matching lines...) Expand all
473 framecnt = 0; 473 framecnt = 0;
474 endfile = 0; 474 endfile = 0;
475 475
476 if (doTransCoding) { 476 if (doTransCoding) {
477 WebRtcIsac_Create(&decoderTransCoding); 477 WebRtcIsac_Create(&decoderTransCoding);
478 WebRtcIsac_SetEncSampRate(decoderTransCoding, sampFreqKHz * 1000); 478 WebRtcIsac_SetEncSampRate(decoderTransCoding, sampFreqKHz * 1000);
479 WebRtcIsac_SetDecSampRate(decoderTransCoding, 479 WebRtcIsac_SetDecSampRate(decoderTransCoding,
480 sampFreqKHz >= 32 ? 32000 : 16000); 480 sampFreqKHz >= 32 ? 32000 : 16000);
481 WebRtcIsac_DecoderInit(decoderTransCoding); 481 WebRtcIsac_DecoderInit(decoderTransCoding);
482 transCodingFile = fopen(transCodingFileName, "wb"); 482 transCodingFile = fopen(transCodingFileName, "wb");
483 if (transCodingFile == NULL) { 483 if (transCodingFile == nullptr) {
484 printf("Could not open %s to output trans-coding.\n", 484 printf("Could not open %s to output trans-coding.\n",
485 transCodingFileName); 485 transCodingFileName);
486 exit(0); 486 exit(0);
487 } 487 }
488 strcat(transCodingFileName, ".bit"); 488 strcat(transCodingFileName, ".bit");
489 transcodingBitstream = fopen(transCodingFileName, "wb"); 489 transcodingBitstream = fopen(transCodingFileName, "wb");
490 if (transcodingBitstream == NULL) { 490 if (transcodingBitstream == nullptr) {
491 printf("Could not open %s to write the bit-stream of transcoder.\n", 491 printf("Could not open %s to write the bit-stream of transcoder.\n",
492 transCodingFileName); 492 transCodingFileName);
493 exit(0); 493 exit(0);
494 } 494 }
495 } 495 }
496 496
497 if (testNum != 1) { 497 if (testNum != 1) {
498 if (WebRtcIsac_EncoderInit(ISAC_main_inst, CodingMode) < 0) { 498 if (WebRtcIsac_EncoderInit(ISAC_main_inst, CodingMode) < 0) {
499 printf("Error could not initialize the encoder \n"); 499 printf("Error could not initialize the encoder \n");
500 cout << flush; 500 cout << flush;
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
581 numFileLoop++; 581 numFileLoop++;
582 if (numFileLoop < totFileLoop) { 582 if (numFileLoop < totFileLoop) {
583 rewind(inp); 583 rewind(inp);
584 framecnt = 0; 584 framecnt = 0;
585 fprintf(stderr, "\n"); 585 fprintf(stderr, "\n");
586 endfile = readframe(shortdata, inp, samplesIn10Ms); 586 endfile = readframe(shortdata, inp, samplesIn10Ms);
587 } 587 }
588 } 588 }
589 589
590 if (testNum == 7) { 590 if (testNum == 7) {
591 srand((unsigned int)time(NULL)); 591 srand((unsigned int)time(nullptr));
592 } 592 }
593 593
594 /* iSAC encoding */ 594 /* iSAC encoding */
595 if (!(testNum == 3 && framecnt == 0)) { 595 if (!(testNum == 3 && framecnt == 0)) {
596 stream_len_int = 596 stream_len_int =
597 WebRtcIsac_Encode(ISAC_main_inst, shortdata, (uint8_t*)streamdata); 597 WebRtcIsac_Encode(ISAC_main_inst, shortdata, (uint8_t*)streamdata);
598 if ((payloadSize != 0) && (stream_len_int > payloadSize)) { 598 if ((payloadSize != 0) && (stream_len_int > payloadSize)) {
599 if (testNum == 0) { 599 if (testNum == 0) {
600 printf("\n\n"); 600 printf("\n\n");
601 } 601 }
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
665 } 665 }
666 stream_len = static_cast<size_t>(stream_len_int); 666 stream_len = static_cast<size_t>(stream_len_int);
667 667
668 cur_framesmpls += samplesIn10Ms; 668 cur_framesmpls += samplesIn10Ms;
669 /* exit encoder loop if the encoder returned a bitstream */ 669 /* exit encoder loop if the encoder returned a bitstream */
670 if (stream_len != 0) 670 if (stream_len != 0)
671 break; 671 break;
672 } 672 }
673 673
674 /* read next bottleneck rate */ 674 /* read next bottleneck rate */
675 if (f_bn != NULL) { 675 if (f_bn != nullptr) {
676 if (fscanf(f_bn, "%d", &bottleneck) == EOF) { 676 if (fscanf(f_bn, "%d", &bottleneck) == EOF) {
677 /* Set pointer to beginning of file */ 677 /* Set pointer to beginning of file */
678 fseek(f_bn, 0L, SEEK_SET); 678 fseek(f_bn, 0L, SEEK_SET);
679 if (fscanf(f_bn, "%d", &bottleneck) == EOF) { 679 if (fscanf(f_bn, "%d", &bottleneck) == EOF) {
680 exit(0); 680 exit(0);
681 } 681 }
682 } 682 }
683 if (CodingMode == 1) { 683 if (CodingMode == 1) {
684 WebRtcIsac_Control(ISAC_main_inst, bottleneck, framesize); 684 WebRtcIsac_Control(ISAC_main_inst, bottleneck, framesize);
685 } 685 }
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
729 stream_len += 10; 729 stream_len += 10;
730 } 730 }
731 731
732 /* make coded sequence to long be decreasing */ 732 /* make coded sequence to long be decreasing */
733 /* the length the decoder expects */ 733 /* the length the decoder expects */
734 if (testNum == 5) { 734 if (testNum == 5) {
735 stream_len -= 10; 735 stream_len -= 10;
736 } 736 }
737 737
738 if (testNum == 6) { 738 if (testNum == 6) {
739 srand((unsigned int)time(NULL)); 739 srand((unsigned int)time(nullptr));
740 for (i = 0; i < stream_len; i++) { 740 for (i = 0; i < stream_len; i++) {
741 streamdata[i] = rand(); 741 streamdata[i] = rand();
742 } 742 }
743 } 743 }
744 744
745 if (VADusage) { 745 if (VADusage) {
746 readframe(vaddata, vadp, samplesIn10Ms * 3); 746 readframe(vaddata, vadp, samplesIn10Ms * 3);
747 } 747 }
748 748
749 /* simulate packet handling through NetEq and the modem */ 749 /* simulate packet handling through NetEq and the modem */
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
863 } 863 }
864 864
865 fprintf(stderr, "\rframe = %5d ", framecnt); 865 fprintf(stderr, "\rframe = %5d ", framecnt);
866 fflush(stderr); 866 fflush(stderr);
867 framecnt++; 867 framecnt++;
868 868
869 /* Error test number 10, garbage data */ 869 /* Error test number 10, garbage data */
870 // if (testNum == 10) 870 // if (testNum == 10)
871 // { 871 // {
872 // /* Test to run decoder with garbage data */ 872 // /* Test to run decoder with garbage data */
873 // if ((seedfile = fopen(SEED_FILE, "a+t")) == NULL) { 873 // if ((seedfile = fopen(SEED_FILE, "a+t")) == null) {
874 // fprintf(stderr, "Error: Could not open file %s\n", SEED_FILE); 874 // fprintf(stderr, "Error: Could not open file %s\n", SEED_FILE);
875 // } else { 875 // } else {
876 // fprintf(seedfile, "ok\n\n"); 876 // fprintf(seedfile, "ok\n\n");
877 // fclose(seedfile); 877 // fclose(seedfile);
878 // } 878 // }
879 // } 879 // }
880 /* Error test number 10, garbage data */ 880 /* Error test number 10, garbage data */
881 // if (testNum == 10) { 881 // if (testNum == 10) {
882 // /* Test to run decoder with garbage data */ 882 // /* Test to run decoder with garbage data */
883 // for (i = 0; i < stream_len; i++) { 883 // for (i = 0; i < stream_len; i++) {
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
940 fprintf(stderr, " transcoding rate %.0f kbps", 940 fprintf(stderr, " transcoding rate %.0f kbps",
941 (double)numTransCodingBytes * 8.0 * (sampFreqKHz) / totalsmpls); 941 (double)numTransCodingBytes * 8.0 * (sampFreqKHz) / totalsmpls);
942 } 942 }
943 943
944 fclose(inp); 944 fclose(inp);
945 fclose(outp); 945 fclose(outp);
946 WebRtcIsac_Free(ISAC_main_inst); 946 WebRtcIsac_Free(ISAC_main_inst);
947 947
948 exit(0); 948 exit(0);
949 } 949 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698