2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
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
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
11 // ReleaseTest-API.cpp : Defines the entry point for the console application.
26 #define SEED_FILE "randseed.txt" /* Used when running decoder on garbage data */
27 #define MAX_FRAMESAMPLES 960 /* max number of samples per frame
28 (= 60 ms frame & 16 kHz) or
29 (= 30 ms frame & 32 kHz) */
30 #define FRAMESAMPLES_10ms 160 /* number of samples per 10ms frame */
31 #define SWBFRAMESAMPLES_10ms 320
32 //#define FS 16000 /* sampling frequency (Hz) */
35 #define CLOCKS_PER_SEC 1000 /* Runtime statistics */
43 int main(int argc, char* argv[])
46 char inname[100], outname[100], bottleneck_file[100], vadfile[100];
47 FILE *inp, *outp, *f_bn = NULL, *vadp = NULL, *bandwidthp;
48 int framecnt, endfile;
50 int i, errtype, VADusage = 0, packetLossPercent = 0;
52 int32_t bottleneck = 0;
53 int16_t framesize = 30; /* ms */
54 int cur_framesmpls, err;
56 /* Runtime statistics */
57 double starttime, runtime, length_file;
59 int16_t stream_len = 0;
60 int16_t declen = 0, lostFrame = 0, declenTC = 0;
62 int16_t shortdata[SWBFRAMESAMPLES_10ms];
63 int16_t vaddata[SWBFRAMESAMPLES_10ms*3];
64 int16_t decoded[MAX_FRAMESAMPLES << 1];
65 int16_t decodedTC[MAX_FRAMESAMPLES << 1];
66 uint16_t streamdata[500];
67 int16_t speechType[1];
70 int16_t payloadSize = 0;
71 int32_t payloadRate = 0;
72 int setControlBWE = 0;
74 char version_number[20];
88 short maxStreamLen30 = 0;
89 short maxStreamLen60 = 0;
90 short sampFreqKHz = 32;
94 bool doTransCoding = false;
95 int32_t rateTransCoding = 0;
96 uint16_t streamDataTransCoding[600];
97 int16_t streamLenTransCoding = 0;
98 FILE* transCodingFile = NULL;
99 FILE* transcodingBitstream = NULL;
100 uint32_t numTransCodingBytes = 0;
102 /* only one structure used for ISAC encoder */
103 ISACStruct* ISAC_main_inst = NULL;
104 ISACStruct* decoderTransCoding = NULL;
106 BottleNeckModel BN_data;
109 fy = fopen("bit_rate.dat", "w");
111 fy = fopen("bytes_frames.dat", "w");
115 /* Handling wrong input arguments in the command line */
116 if((argc<3) || (argc>17)) {
117 printf("\n\nWrong number of arguments or flag values.\n\n");
120 WebRtcIsac_version(version_number);
121 printf("iSAC-swb version %s \n\n", version_number);
123 printf("Usage:\n\n");
124 printf("./kenny.exe [-I] bottleneck_value infile outfile \n\n");
126 printf("[-FS num] : sampling frequency in kHz, valid values are 16 & 32,\n");
127 printf(" with 16 as default.\n");
128 printf("[-I] : if -I option is specified, the coder will use\n");
129 printf(" an instantaneous Bottleneck value. If not, it\n");
130 printf(" will be an adaptive Bottleneck value.\n\n");
131 printf("[-assign] : Use Assign API.\n");
132 printf("[-B num] : the value of the bottleneck provided either\n");
133 printf(" as a fixed value in bits/sec (e.g. 25000) or\n");
134 printf(" read from a file (e.g. bottleneck.txt)\n\n");
135 printf("[-INITRATE num] : Set a new value for initial rate. Note! Only used in \n");
136 printf(" adaptive mode.\n\n");
137 printf("[-FL num] : Set (initial) frame length in msec. Valid length are \n");
138 printf(" 30 and 60 msec.\n\n");
139 printf("[-FIXED_FL] : Frame length will be fixed to initial value.\n\n");
140 printf("[-MAX num] : Set the limit for the payload size of iSAC in bytes. \n");
141 printf(" Minimum 100 maximum 400.\n\n");
142 printf("[-MAXRATE num] : Set the maxrate for iSAC in bits per second. \n");
143 printf(" Minimum 32000, maximum 53400.\n\n");
144 printf("[-F num] : if -F option is specified, the test function\n");
145 printf(" will run the iSAC API fault scenario specified by the\n");
146 printf(" supplied number.\n");
147 printf(" F 1 - Call encoder prior to init encoder call\n");
148 printf(" F 2 - Call decoder prior to init decoder call\n");
149 printf(" F 3 - Call decoder prior to encoder call\n");
150 printf(" F 4 - Call decoder with a too short coded sequence\n");
151 printf(" F 5 - Call decoder with a too long coded sequence\n");
152 printf(" F 6 - Call decoder with random bit stream\n");
153 printf(" F 7 - Call init encoder/decoder at random during a call\n");
154 printf(" F 8 - Call encoder/decoder without having allocated memory \n");
155 printf(" for encoder/decoder instance\n");
156 printf(" F 9 - Call decodeB without calling decodeA\n");
157 printf(" F 10 - Call decodeB with garbage data\n");
158 printf("[-PL num] : if -PL option is specified \n");
159 printf("[-T rate file] : test trans-coding with target bottleneck 'rate' bits/sec\n");
160 printf(" the output file is written to 'file'\n");
161 printf("[-LOOP num] : number of times to repeat coding the input file for stress testing\n");
162 //printf("[-CE num] : Test of APIs used by Conference Engine.\n");
163 //printf(" CE 1 - getNewBitstream, getBWE \n");
164 //printf(" (CE 2 - RESERVED for transcoding)\n");
165 //printf(" CE 3 - getSendBWE, setSendBWE. \n\n");
166 //printf("-L filename : write the logging info into file (appending)\n");
167 printf("infile : Normal speech input file\n\n");
168 printf("outfile : Speech output file\n\n");
172 /* Print version number */
173 printf("-------------------------------------------------\n");
174 WebRtcIsac_version(version_number);
175 printf("iSAC version %s \n\n", version_number);
177 /* Loop over all command line arguments */
182 char transCodingFileName[500];
183 int16_t totFileLoop = 0;
184 int16_t numFileLoop = 0;
185 for (i = 1; i < argc-2;i++)
187 if(!strcmp("-LOOP", argv[i]))
190 totFileLoop = (int16_t)atol(argv[i]);
193 fprintf(stderr, "Invalid number of runs for the given input file, %d.", totFileLoop);
198 if(!strcmp("-T", argv[i]))
200 doTransCoding = true;
202 rateTransCoding = atoi(argv[i]);
204 strcpy(transCodingFileName, argv[i]);
207 /*Should we use assign API*/
208 if(!strcmp("-assign", argv[i]))
213 /* Set Sampling Rate */
214 if(!strcmp("-FS", argv[i]))
217 sampFreqKHz = atoi(argv[i]);
220 /* Instantaneous mode */
221 if(!strcmp ("-I", argv[i]))
223 printf("Instantaneous BottleNeck\n");
227 /* Set (initial) bottleneck value */
228 if(!strcmp ("-INITRATE", argv[i])) {
229 rateBPS = atoi(argv[i + 1]);
231 if((rateBPS < 10000) || (rateBPS > 32000))
233 printf("\n%d is not a initial rate. Valid values are in the range 10000 to 32000.\n", rateBPS);
236 printf("New initial rate: %d\n", rateBPS);
240 /* Set (initial) framelength */
241 if(!strcmp ("-FL", argv[i])) {
242 framesize = atoi(argv[i + 1]);
243 if((framesize != 30) && (framesize != 60))
245 printf("\n%d is not a valid frame length. Valid length are 30 and 60 msec.\n", framesize);
249 printf("Frame Length: %d\n", framesize);
253 /* Fixed frame length */
254 if(!strcmp ("-FIXED_FL", argv[i]))
258 printf("Fixed Frame Length\n");
261 /* Set maximum allowed payload size in bytes */
262 if(!strcmp ("-MAX", argv[i])) {
263 payloadSize = atoi(argv[i + 1]);
264 printf("Maximum Payload Size: %d\n", payloadSize);
268 /* Set maximum rate in bytes */
269 if(!strcmp ("-MAXRATE", argv[i])) {
270 payloadRate = atoi(argv[i + 1]);
271 printf("Maximum Rate in kbps: %d\n", payloadRate);
275 /* Test of fault scenarious */
276 if(!strcmp ("-F", argv[i]))
278 testNum = atoi(argv[i + 1]);
279 printf("Fault test: %d\n", testNum);
280 if(testNum < 1 || testNum > 10)
282 printf("\n%d is not a valid Fault Scenario number. Valid Fault Scenarios are numbered 1-10.\n", testNum);
288 /* Packet loss test */
289 if(!strcmp ("-PL", argv[i]))
291 if( isdigit( *argv[i+1] ) )
293 packetLossPercent = atoi( argv[i+1] );
294 if( (packetLossPercent < 0) | (packetLossPercent > 100) )
296 printf( "\nInvalid packet loss perentage \n" );
299 if( packetLossPercent > 0 )
301 printf( "Simulating %d %% of independent packet loss\n", packetLossPercent );
305 printf( "\nNo Packet Loss Is Simulated \n" );
310 plFile = fopen( argv[i+1], "rb" );
313 printf( "\n couldn't open the frameloss file: %s\n", argv[i+1] );
316 printf( "Simulating packet loss through the given channel file: %s\n", argv[i+1] );
321 /* Random packetlosses */
322 if(!strcmp ("-rnd", argv[i]))
324 srand((unsigned int)time(NULL) );
325 printf( "Random pattern in lossed packets \n" );
329 if(!strcmp ("-G", argv[i]))
331 sscanf(argv[i + 1], "%s", gns_file);
332 fp_gns = fopen(gns_file, "rb");
335 printf("Cannot read file %s.\n", gns_file);
343 /* Get Bottleneck value */
344 if(!strcmp("-B", argv[i]))
347 bottleneck = atoi(argv[i]);
350 sscanf(argv[i], "%s", bottleneck_file);
351 f_bn = fopen(bottleneck_file, "rb");
354 printf("Error No value provided for BottleNeck and cannot read file %s.\n", bottleneck_file);
359 printf("reading bottleneck rates from file %s\n\n",bottleneck_file);
360 if(fscanf(f_bn, "%d", &bottleneck) == EOF)
362 /* Set pointer to beginning of file */
363 fseek(f_bn, 0L, SEEK_SET);
364 if (fscanf(f_bn, "%d", &bottleneck) == EOF) {
369 /* Bottleneck is a cosine function
370 * Matlab code for writing the bottleneck file:
371 * BottleNeck_10ms = 20e3 + 10e3 * cos((0:5999)/5999*2*pi);
372 * fid = fopen('bottleneck.txt', 'wb');
373 * fprintf(fid, '%d\n', BottleNeck_10ms); fclose(fid);
379 printf("\nfixed bottleneck rate of %d bits/s\n\n", bottleneck);
382 /* Run Conference Engine APIs */
383 // Do not test it in the first release
385 // if(!strcmp ("-CE", argv[i]))
387 // testCE = atoi(argv[i + 1]);
391 // scale = (float)atof( argv[i+1] );
393 // else if(testCE == 2)
395 // printf("\nCE-test 2 (transcoding) not implemented.\n");
398 // else if(testCE < 1 || testCE > 3)
400 // printf("\n%d is not a valid CE-test number. Valid CE tests are 1-3.\n", testCE);
403 // printf("CE-test number: %d\n", testCE);
410 printf("\nAdaptive BottleNeck\n");
417 printf("iSAC Wideband.\n");
418 samplesIn10Ms = FRAMESAMPLES_10ms;
423 printf("iSAC Supper-Wideband.\n");
424 samplesIn10Ms = SWBFRAMESAMPLES_10ms;
428 printf("Unsupported sampling frequency %d kHz", sampFreqKHz);
435 /* Get Input and Output files */
436 sscanf(argv[argc-2], "%s", inname);
437 sscanf(argv[argc-1], "%s", outname);
438 printf("\nInput file: %s\n", inname);
439 printf("Output file: %s\n\n", outname);
440 if((inp = fopen(inname,"rb")) == NULL)
442 printf(" Error iSAC Cannot read file %s.\n", inname);
447 if((outp = fopen(outname,"wb")) == NULL)
449 printf(" Error iSAC Cannot write file %s.\n", outname);
456 if((vadp = fopen(vadfile,"rb")) == NULL)
458 printf(" Error iSAC Cannot read file %s.\n", vadfile);
464 if((bandwidthp = fopen("bwe.pcm","wb")) == NULL)
466 printf(" Error iSAC Cannot read file %s.\n", "bwe.pcm");
472 starttime = clock()/(double)CLOCKS_PER_SEC; /* Runtime statistics */
474 /* Initialize the ISAC and BN structs */
479 err =WebRtcIsac_Create(&ISAC_main_inst);
480 WebRtcIsac_SetEncSampRate(ISAC_main_inst, sampFreqKHz * 1000);
481 WebRtcIsac_SetDecSampRate(ISAC_main_inst, sampFreqKHz >= 32 ?
486 /* Test the Assign functions */
489 err = WebRtcIsac_AssignSize(&sss);
491 err = WebRtcIsac_Assign(&ISAC_main_inst, ppp);
492 WebRtcIsac_SetEncSampRate(ISAC_main_inst, sampFreqKHz * 1000);
493 WebRtcIsac_SetDecSampRate(ISAC_main_inst, sampFreqKHz >= 32 ?
499 printf("\n\n Error in create.\n\n");
504 BN_data.arrival_time = 0;
505 BN_data.sample_count = 0;
506 BN_data.rtp_number = 0;
508 /* Initialize encoder and decoder */
514 WebRtcIsac_Create(&decoderTransCoding);
515 WebRtcIsac_SetEncSampRate(decoderTransCoding, sampFreqKHz * 1000);
516 WebRtcIsac_SetDecSampRate(decoderTransCoding, sampFreqKHz >= 32 ?
518 WebRtcIsac_DecoderInit(decoderTransCoding);
519 transCodingFile = fopen(transCodingFileName, "wb");
520 if(transCodingFile == NULL)
522 printf("Could not open %s to output trans-coding.\n", transCodingFileName);
525 strcat(transCodingFileName, ".bit");
526 transcodingBitstream = fopen(transCodingFileName, "wb");
527 if(transcodingBitstream == NULL)
529 printf("Could not open %s to write the bit-stream of transcoder.\n", transCodingFileName);
536 if(WebRtcIsac_EncoderInit(ISAC_main_inst, CodingMode) < 0)
538 printf("Error could not initialize the encoder \n");
545 if(WebRtcIsac_DecoderInit(ISAC_main_inst) < 0)
547 printf("Error could not initialize the decoder \n");
554 err = WebRtcIsac_Control(ISAC_main_inst, bottleneck, framesize);
557 /* exit if returned with error */
558 errtype=WebRtcIsac_GetErrorCode(ISAC_main_inst);
559 printf("\n\n Error in initialization (control): %d.\n\n", errtype);
568 if((setControlBWE) && (CodingMode == 0))
570 err = WebRtcIsac_ControlBwe(ISAC_main_inst, rateBPS, framesize, fixedFL);
573 /* exit if returned with error */
574 errtype=WebRtcIsac_GetErrorCode(ISAC_main_inst);
576 printf("\n\n Error in Control BWE: %d.\n\n", errtype);
584 err = WebRtcIsac_SetMaxPayloadSize(ISAC_main_inst, payloadSize);
587 /* exit if returned with error */
588 errtype=WebRtcIsac_GetErrorCode(ISAC_main_inst);
589 printf("\n\n Error in SetMaxPayloadSize: %d.\n\n", errtype);
596 err = WebRtcIsac_SetMaxRate(ISAC_main_inst, payloadRate);
599 /* exit if returned with error */
600 errtype=WebRtcIsac_GetErrorCode(ISAC_main_inst);
601 printf("\n\n Error in SetMaxRateInBytes: %d.\n\n", errtype);
609 cout << "\n" << flush;
613 int16_t jitterInfoTC = 0;
616 /* Call init functions at random, fault test number 7 */
617 if(testNum == 7 && (rand()%2 == 0))
619 err = WebRtcIsac_EncoderInit(ISAC_main_inst, CodingMode);
623 errtype=WebRtcIsac_GetErrorCode(ISAC_main_inst);
624 printf("\n\n Error in encoderinit: %d.\n\n", errtype);
628 err = WebRtcIsac_DecoderInit(ISAC_main_inst);
632 errtype=WebRtcIsac_GetErrorCode(ISAC_main_inst);
633 printf("\n\n Error in decoderinit: %d.\n\n", errtype);
641 /* Read 10 ms speech block */
642 endfile = readframe(shortdata, inp, samplesIn10Ms);
647 if(numFileLoop < totFileLoop)
651 fprintf(stderr, "\n");
652 endfile = readframe(shortdata, inp, samplesIn10Ms);
658 srand((unsigned int)time(NULL));
662 if(!(testNum == 3 && framecnt == 0))
664 stream_len = WebRtcIsac_Encode(ISAC_main_inst,
666 (uint8_t*)streamdata);
667 if((payloadSize != 0) && (stream_len > payloadSize))
674 printf("\nError: Streamsize out of range %d\n", stream_len - payloadSize);
678 WebRtcIsac_GetUplinkBw(ISAC_main_inst, &sendBN);
687 /************************* Main Transcoding stream *******************************/
688 WebRtcIsac_GetDownLinkBwIndex(ISAC_main_inst, &bnIdxTC, &jitterInfoTC);
689 streamLenTransCoding = WebRtcIsac_GetNewBitStream(
690 ISAC_main_inst, bnIdxTC, jitterInfoTC, rateTransCoding,
691 (int16_t*)streamDataTransCoding, false);
692 if(streamLenTransCoding < 0)
694 fprintf(stderr, "Error in trans-coding\n");
697 auxUW8 = (uint8_t)(((streamLenTransCoding & 0xFF00) >> 8) & 0x00FF);
698 if (fwrite(&auxUW8, sizeof(uint8_t), 1,
699 transcodingBitstream) != 1) {
703 auxUW8 = (uint8_t)(streamLenTransCoding & 0x00FF);
704 if (fwrite(&auxUW8, sizeof(uint8_t),
705 1, transcodingBitstream) != 1) {
709 if (fwrite((uint8_t*)streamDataTransCoding,
711 streamLenTransCoding,
712 transcodingBitstream) !=
713 static_cast<size_t>(streamLenTransCoding)) {
717 WebRtcIsac_ReadBwIndex((int16_t*)streamDataTransCoding, &indexStream);
718 if(indexStream != bnIdxTC)
720 fprintf(stderr, "Error in inserting Bandwidth index into transcoding stream.\n");
723 numTransCodingBytes += streamLenTransCoding;
734 /* exit if returned with error */
735 errtype=WebRtcIsac_GetErrorCode(ISAC_main_inst);
736 printf("\n\nError in encoder: %d.\n\n", errtype);
739 cur_framesmpls += samplesIn10Ms;
740 /* exit encoder loop if the encoder returned a bitstream */
741 if(stream_len != 0) break;
744 /* read next bottleneck rate */
747 if(fscanf(f_bn, "%d", &bottleneck) == EOF)
749 /* Set pointer to beginning of file */
750 fseek(f_bn, 0L, SEEK_SET);
751 if (fscanf(f_bn, "%d", &bottleneck) == EOF) {
757 WebRtcIsac_Control(ISAC_main_inst, bottleneck, framesize);
761 length_file += cur_framesmpls;
762 if(cur_framesmpls == (3 * samplesIn10Ms))
764 maxStreamLen30 = (stream_len > maxStreamLen30)? stream_len:maxStreamLen30;
768 maxStreamLen60 = (stream_len > maxStreamLen60)? stream_len:maxStreamLen60;
773 lostFrame = ((rand()%100) < packetLossPercent);
783 stream_len = WebRtcIsac_GetRedPayload(ISAC_main_inst,
784 (int16_t*)streamdata);
788 streamLenTransCoding = WebRtcIsac_GetNewBitStream(
789 ISAC_main_inst, bnIdxTC, jitterInfoTC, rateTransCoding,
790 (int16_t*)streamDataTransCoding, true);
791 if(streamLenTransCoding < 0)
793 fprintf(stderr, "Error in RED trans-coding\n");
799 /* make coded sequence to short be inreasing */
800 /* the length the decoder expects */
806 /* make coded sequence to long be decreasing */
807 /* the length the decoder expects */
815 srand((unsigned int)time(NULL));
816 for(i = 0; i < stream_len; i++)
818 streamdata[i] = rand();
823 readframe(vaddata, vadp, samplesIn10Ms*3);
826 /* simulate packet handling through NetEq and the modem */
827 if(!(testNum == 3 && framecnt == 0))
829 get_arrival_time(cur_framesmpls, stream_len, bottleneck, &BN_data,
830 sampFreqKHz*1000, sampFreqKHz*1000);
833 if(VADusage && (framecnt>10 && vaddata[0]==0))
835 BN_data.rtp_number--;
839 /* Error test number 10, garbage data */
842 /* Test to run decoder with garbage data */
843 for(i = 0; i < stream_len; i++)
845 streamdata[i] = (short) (streamdata[i]) + (short) rand();
851 err = WebRtcIsac_UpdateBwEstimate(ISAC_main_inst, streamdata,
852 stream_len, BN_data.rtp_number, BN_data.sample_count,
853 BN_data.arrival_time);
857 /* exit if returned with error */
858 errtype=WebRtcIsac_GetErrorCode(ISAC_main_inst);
864 printf("Error: in decoder: %d.", errtype);
874 /* Call getFramelen, only used here for function test */
875 err = WebRtcIsac_ReadFrameLen(ISAC_main_inst,
876 (int16_t*)streamdata, &FL);
879 /* exit if returned with error */
880 errtype=WebRtcIsac_GetErrorCode(ISAC_main_inst);
885 printf(" Error: in getFrameLen %d.", errtype);
897 declen = WebRtcIsac_DecodeRcu(ISAC_main_inst, streamdata,
898 stream_len, decoded, speechType);
902 declenTC = WebRtcIsac_DecodeRcu(decoderTransCoding,
903 streamDataTransCoding, streamLenTransCoding,
904 decodedTC, speechType);
909 declen = WebRtcIsac_Decode(ISAC_main_inst, streamdata,
910 stream_len, decoded, speechType);
914 declenTC = WebRtcIsac_Decode(decoderTransCoding,
915 streamDataTransCoding, streamLenTransCoding,
916 decodedTC, speechType);
922 /* exit if returned with error */
923 errtype=WebRtcIsac_GetErrorCode(ISAC_main_inst);
928 printf(" Error: in decoder %d.", errtype);
942 printf(" Error: in decoding the transcoded stream");
951 /* Write decoded speech frame to file */
952 if((declen > 0) && (numFileLoop == 0))
954 if (fwrite(decoded, sizeof(int16_t), declen,
955 outp) != static_cast<size_t>(declen)) {
960 if((declenTC > 0) && (numFileLoop == 0))
962 if (fwrite(decodedTC, sizeof(int16_t), declen,
963 transCodingFile) != static_cast<size_t>(declen)) {
969 fprintf(stderr, "\rframe = %5d ", framecnt);
973 /* Error test number 10, garbage data */
976 // /* Test to run decoder with garbage data */
977 // if( (seedfile = fopen(SEED_FILE, "a+t") ) == NULL )
979 // fprintf(stderr, "Error: Could not open file %s\n", SEED_FILE);
983 // fprintf(seedfile, "ok\n\n");
987 /* Error test number 10, garbage data */
990 // /* Test to run decoder with garbage data */
991 // for ( i = 0; i < stream_len; i++)
993 // streamdata[i] = (short) (streamdata[i] + (short) rand());
998 totalsmpls += declen;
999 totalbits += 8 * stream_len;
1001 kbps = ((double) sampFreqKHz * 1000.) / ((double) cur_framesmpls) * 8.0 * stream_len / 1000.0;// kbits/s
1002 fy = fopen("bit_rate.dat", "a");
1003 fprintf(fy, "Frame %i = %0.14f\n", framecnt, kbps);
1010 printf("total bits = %d bits\n", totalbits);
1011 printf("measured average bitrate = %0.3f kbits/s\n",
1012 (double)totalbits *(sampFreqKHz) / totalsmpls);
1015 printf("Transcoding average bit-rate = %0.3f kbps\n",
1016 (double)numTransCodingBytes * 8.0 *(sampFreqKHz) / totalsmpls);
1017 fclose(transCodingFile);
1021 /* Runtime statistics */
1022 runtime = (double)(clock()/(double)CLOCKS_PER_SEC-starttime);
1023 length_file = length_file /(sampFreqKHz * 1000.);
1025 printf("\n\nLength of speech file: %.1f s\n", length_file);
1026 printf("Time to run iSAC: %.2f s (%.2f %% of realtime)\n\n", runtime, (100*runtime/length_file));
1028 if(maxStreamLen30 != 0)
1030 printf("Maximum payload size 30ms Frames %d bytes (%0.3f kbps)\n",
1032 maxStreamLen30 * 8 / 30.);
1034 if(maxStreamLen60 != 0)
1036 printf("Maximum payload size 60ms Frames %d bytes (%0.3f kbps)\n",
1038 maxStreamLen60 * 8 / 60.);
1040 //fprintf(stderr, "\n");
1042 fprintf(stderr, " %.1f s", length_file);
1043 fprintf(stderr, " %0.1f kbps", (double)totalbits *(sampFreqKHz) / totalsmpls);
1044 if(maxStreamLen30 != 0)
1046 fprintf(stderr, " plmax-30ms %d bytes (%0.0f kbps)",
1048 maxStreamLen30 * 8 / 30.);
1050 if(maxStreamLen60 != 0)
1052 fprintf(stderr, " plmax-60ms %d bytes (%0.0f kbps)",
1054 maxStreamLen60 * 8 / 60.);
1058 fprintf(stderr, " transcoding rate %.0f kbps",
1059 (double)numTransCodingBytes * 8.0 *(sampFreqKHz) / totalsmpls);
1064 WebRtcIsac_Free(ISAC_main_inst);