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

Side by Side Diff: webrtc/modules/audio_coding/codecs/isac/main/test/simpleKenny.c

Issue 2065353002: Delete unused code. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Trivial rebase. Created 4 years, 6 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 11 matching lines...) Expand all
22 #endif 22 #endif
23 #endif 23 #endif
24 24
25 #include <ctype.h> 25 #include <ctype.h>
26 #include <math.h> 26 #include <math.h>
27 27
28 /* include API */ 28 /* include API */
29 #include "isac.h" 29 #include "isac.h"
30 #include "utility.h" 30 #include "utility.h"
31 #include "webrtc/base/format_macros.h" 31 #include "webrtc/base/format_macros.h"
32 //#include "commonDefs.h"
33 32
34 /* max number of samples per frame (= 60 ms frame) */ 33 /* max number of samples per frame (= 60 ms frame) */
35 #define MAX_FRAMESAMPLES_SWB 1920 34 #define MAX_FRAMESAMPLES_SWB 1920
36 /* number of samples per 10ms frame */ 35 /* number of samples per 10ms frame */
37 #define FRAMESAMPLES_SWB_10ms 320 36 #define FRAMESAMPLES_SWB_10ms 320
38 #define FRAMESAMPLES_WB_10ms 160 37 #define FRAMESAMPLES_WB_10ms 160
39 38
40 /* sampling frequency (Hz) */ 39 /* sampling frequency (Hz) */
41 #define FS_SWB 32000 40 #define FS_SWB 32000
42 #define FS_WB 16000 41 #define FS_WB 16000
43 42
44 //#define CHANGE_OUTPUT_NAME
45
46 #ifdef HAVE_DEBUG_INFO
47 #include "debugUtility.h"
48 debugStruct debugInfo;
49 #endif
50
51 unsigned long framecnt = 0; 43 unsigned long framecnt = 0;
52 44
53 int main(int argc, char* argv[]) { 45 int main(int argc, char* argv[]) {
54 //--- File IO ---- 46 //--- File IO ----
55 FILE* inp; 47 FILE* inp;
56 FILE* outp; 48 FILE* outp;
57 char inname[500]; 49 char inname[500];
58 char outname[500]; 50 char outname[500];
59 51
60 /* Runtime statistics */ 52 /* Runtime statistics */
61 double rate; 53 double rate;
62 double rateRCU; 54 double rateRCU;
63 size_t totalbits = 0; 55 size_t totalbits = 0;
64 unsigned long totalBitsRCU = 0; 56 unsigned long totalBitsRCU = 0;
65 unsigned long totalsmpls = 0; 57 unsigned long totalsmpls = 0;
66 58
67 int32_t bottleneck = 39; 59 int32_t bottleneck = 39;
68 int frameSize = 30; /* ms */ 60 int frameSize = 30; /* ms */
69 int16_t codingMode = 1; 61 int16_t codingMode = 1;
70 int16_t shortdata[FRAMESAMPLES_SWB_10ms]; 62 int16_t shortdata[FRAMESAMPLES_SWB_10ms];
71 int16_t decoded[MAX_FRAMESAMPLES_SWB]; 63 int16_t decoded[MAX_FRAMESAMPLES_SWB];
72 // uint16_t streamdata[1000];
73 int16_t speechType[1]; 64 int16_t speechType[1];
74 int16_t payloadLimit; 65 int16_t payloadLimit;
75 int32_t rateLimit; 66 int32_t rateLimit;
76 ISACStruct* ISAC_main_inst; 67 ISACStruct* ISAC_main_inst;
77 68
78 size_t stream_len = 0; 69 size_t stream_len = 0;
79 int declen = 0; 70 int declen = 0;
80 int16_t err; 71 int16_t err;
81 int cur_framesmpls; 72 int cur_framesmpls;
82 int endfile; 73 int endfile;
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 framecnt = 0; 241 framecnt = 0;
251 endfile = 0; 242 endfile = 0;
252 243
253 /* Initialize encoder and decoder */ 244 /* Initialize encoder and decoder */
254 if (WebRtcIsac_EncoderInit(ISAC_main_inst, codingMode) < 0) { 245 if (WebRtcIsac_EncoderInit(ISAC_main_inst, codingMode) < 0) {
255 printf("cannot initialize encoder\n"); 246 printf("cannot initialize encoder\n");
256 return -1; 247 return -1;
257 } 248 }
258 WebRtcIsac_DecoderInit(ISAC_main_inst); 249 WebRtcIsac_DecoderInit(ISAC_main_inst);
259 250
260 // {
261 // int32_t b1, b2;
262 // FILE* fileID = fopen("GetBNTest.txt", "w");
263 // b2 = 32100;
264 // while (b2 <= 52000) {
265 // WebRtcIsac_Control(ISAC_main_inst, b2, frameSize);
266 // WebRtcIsac_GetUplinkBw(ISAC_main_inst, &b1);
267 // fprintf(fileID, "%5d %5d\n", b2, b1);
268 // b2 += 10;
269 // }
270 // }
271
272 if (codingMode == 1) { 251 if (codingMode == 1) {
273 if (WebRtcIsac_Control(ISAC_main_inst, bottleneck, frameSize) < 0) { 252 if (WebRtcIsac_Control(ISAC_main_inst, bottleneck, frameSize) < 0) {
274 printf("cannot set bottleneck\n"); 253 printf("cannot set bottleneck\n");
275 return -1; 254 return -1;
276 } 255 }
277 } else { 256 } else {
278 if (WebRtcIsac_ControlBwe(ISAC_main_inst, 15000, 30, 1) < 0) { 257 if (WebRtcIsac_ControlBwe(ISAC_main_inst, 15000, 30, 1) < 0) {
279 printf("cannot configure BWE\n"); 258 printf("cannot configure BWE\n");
280 return -1; 259 return -1;
281 } 260 }
282 } 261 }
283 262
284 if (WebRtcIsac_SetMaxPayloadSize(ISAC_main_inst, payloadLimit) < 0) { 263 if (WebRtcIsac_SetMaxPayloadSize(ISAC_main_inst, payloadLimit) < 0) {
285 printf("cannot set maximum payload size %d.\n", payloadLimit); 264 printf("cannot set maximum payload size %d.\n", payloadLimit);
286 return -1; 265 return -1;
287 } 266 }
288 267
289 if (rateLimit < 106800) { 268 if (rateLimit < 106800) {
290 if (WebRtcIsac_SetMaxRate(ISAC_main_inst, rateLimit) < 0) { 269 if (WebRtcIsac_SetMaxRate(ISAC_main_inst, rateLimit) < 0) {
291 printf("cannot set the maximum rate %d.\n", rateLimit); 270 printf("cannot set the maximum rate %d.\n", rateLimit);
292 return -1; 271 return -1;
293 } 272 }
294 } 273 }
295 274
296 //=====================================
297 //#ifdef HAVE_DEBUG_INFO
298 // if(setupDebugStruct(&debugInfo) < 0)
299 // {
300 // exit(1);
301 // }
302 //#endif
303
304 while (endfile == 0) { 275 while (endfile == 0) {
305 fprintf(stderr, " \rframe = %7li", framecnt); 276 fprintf(stderr, " \rframe = %7li", framecnt);
306 277
307 //============== Readind from the file and encoding ================= 278 //============== Readind from the file and encoding =================
308 cur_framesmpls = 0; 279 cur_framesmpls = 0;
309 stream_len = 0; 280 stream_len = 0;
310 281
311 if (onlyDecode) { 282 if (onlyDecode) {
312 uint8_t auxUW8; 283 uint8_t auxUW8;
313 if (fread(&auxUW8, sizeof(uint8_t), 1, inp) < 1) { 284 if (fread(&auxUW8, sizeof(uint8_t), 1, inp) < 1) {
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
438 409
439 rate = ((double)totalbits * (sampFreqKHz)) / (double)totalsmpls; 410 rate = ((double)totalbits * (sampFreqKHz)) / (double)totalsmpls;
440 rateRCU = ((double)totalBitsRCU * (sampFreqKHz)) / (double)totalsmpls; 411 rateRCU = ((double)totalBitsRCU * (sampFreqKHz)) / (double)totalsmpls;
441 412
442 printf("\n\n"); 413 printf("\n\n");
443 printf("Sampling Rate............... %d kHz\n", sampFreqKHz); 414 printf("Sampling Rate............... %d kHz\n", sampFreqKHz);
444 printf("Payload Limit............... %d bytes \n", payloadLimit); 415 printf("Payload Limit............... %d bytes \n", payloadLimit);
445 printf("Rate Limit.................. %d bits/sec \n", rateLimit); 416 printf("Rate Limit.................. %d bits/sec \n", rateLimit);
446 417
447 #ifdef WIN32 418 #ifdef WIN32
448 #ifdef HAVE_DEBUG_INFO
449 rateLB =
450 ((double)debugInfo.lbBytes * 8. * (sampFreqKHz)) / (double)totalsmpls;
451 rateUB =
452 ((double)debugInfo.ubBytes * 8. * (sampFreqKHz)) / (double)totalsmpls;
453 #endif
454
455 fprintf(bitrateFile, "%d %10u %d %6.3f %6.3f %6.3f\n", 419 fprintf(bitrateFile, "%d %10u %d %6.3f %6.3f %6.3f\n",
456 sampFreqKHz, framecnt, bottleneck, rateLB, rateUB, rate); 420 sampFreqKHz, framecnt, bottleneck, rateLB, rateUB, rate);
457 fclose(bitrateFile); 421 fclose(bitrateFile);
458 #endif // WIN32 422 #endif // WIN32
459 423
460 printf("\n"); 424 printf("\n");
461 printf("Measured bit-rate........... %0.3f kbps\n", rate); 425 printf("Measured bit-rate........... %0.3f kbps\n", rate);
462 printf("Measured RCU bit-ratre...... %0.3f kbps\n", rateRCU); 426 printf("Measured RCU bit-ratre...... %0.3f kbps\n", rateRCU);
463 printf("Maximum bit-rate/payloadsize %0.3f / %" PRIuS "\n", 427 printf("Maximum bit-rate/payloadsize %0.3f / %" PRIuS "\n",
464 maxStreamLen * 8 / 0.03, maxStreamLen); 428 maxStreamLen * 8 / 0.03, maxStreamLen);
465 printf("Measured packet-loss........ %0.1f%% \n", 429 printf("Measured packet-loss........ %0.1f%% \n",
466 100.0f * (float)lostPacketCntr / (float)packetCntr); 430 100.0f * (float)lostPacketCntr / (float)packetCntr);
467 431
468 // #ifdef HAVE_DEBUG_INFO
469 // printf("Measured lower-band bit-rate %0.3f kbps (%.0f%%)\n",
470 // rateLB, (double)(rateLB) * 100. /(double)(rate));
471 // printf("Measured upper-band bit-rate %0.3f kbps (%.0f%%)\n",
472 // rateUB, (double)(rateUB) * 100. /(double)(rate));
473 //
474 // printf("Maximum payload lower-band.. %d bytes (%0.3f kbps)\n",
475 // debugInfo.maxPayloadLB, debugInfo.maxPayloadLB * 8.0 / 0.03);
476 // printf("Maximum payload upper-band.. %d bytes (%0.3f kbps)\n",
477 // debugInfo.maxPayloadUB, debugInfo.maxPayloadUB * 8.0 / 0.03);
478 // #endif
479
480 printf("\n"); 432 printf("\n");
481 433
482 /* Runtime statistics */ 434 /* Runtime statistics */
483 #ifdef WIN32 435 #ifdef WIN32
484 runtime = (double)(clock() / (double)CLOCKS_PER_SEC - starttime); 436 runtime = (double)(clock() / (double)CLOCKS_PER_SEC - starttime);
485 length_file = ((double)framecnt * (double)declen / (sampFreqKHz * 1000)); 437 length_file = ((double)framecnt * (double)declen / (sampFreqKHz * 1000));
486 printf("Length of speech file....... %.1f s\n", length_file); 438 printf("Length of speech file....... %.1f s\n", length_file);
487 printf("Time to run iSAC............ %.2f s (%.2f %% of realtime)\n\n", 439 printf("Time to run iSAC............ %.2f s (%.2f %% of realtime)\n\n",
488 runtime, (100 * runtime / length_file)); 440 runtime, (100 * runtime / length_file));
489 #endif 441 #endif
(...skipping 14 matching lines...) Expand all
504 } 456 }
505 fprintf(averageFile, "\n"); 457 fprintf(averageFile, "\n");
506 fclose(averageFile); 458 fclose(averageFile);
507 } 459 }
508 460
509 fclose(inp); 461 fclose(inp);
510 fclose(outp); 462 fclose(outp);
511 463
512 WebRtcIsac_Free(ISAC_main_inst); 464 WebRtcIsac_Free(ISAC_main_inst);
513 465
514 #ifdef CHANGE_OUTPUT_NAME
515 {
516 char* p;
517 char myExt[50];
518 char bitRateStr[10];
519 char newOutName[500];
520 strcpy(newOutName, outname);
521
522 myExt[0] = '\0';
523 p = strchr(newOutName, '.');
524 if (p != NULL) {
525 strcpy(myExt, p);
526 *p = '_';
527 p++;
528 *p = '\0';
529 } else {
530 strcat(newOutName, "_");
531 }
532 sprintf(bitRateStr, "%0.0fkbps", rate);
533 strcat(newOutName, bitRateStr);
534 strcat(newOutName, myExt);
535 rename(outname, newOutName);
536 }
537 #endif
538 exit(0); 466 exit(0);
539 } 467 }
540
541 #ifdef HAVE_DEBUG_INFO
542 int setupDebugStruct(debugStruct* str) {
543 str->prevPacketLost = 0;
544 str->currPacketLost = 0;
545
546 OPEN_FILE_WB(str->res0to4FilePtr, "Res0to4.dat");
547 OPEN_FILE_WB(str->res4to8FilePtr, "Res4to8.dat");
548 OPEN_FILE_WB(str->res8to12FilePtr, "Res8to12.dat");
549 OPEN_FILE_WB(str->res8to16FilePtr, "Res8to16.dat");
550
551 OPEN_FILE_WB(str->res0to4DecFilePtr, "Res0to4Dec.dat");
552 OPEN_FILE_WB(str->res4to8DecFilePtr, "Res4to8Dec.dat");
553 OPEN_FILE_WB(str->res8to12DecFilePtr, "Res8to12Dec.dat");
554 OPEN_FILE_WB(str->res8to16DecFilePtr, "Res8to16Dec.dat");
555
556 OPEN_FILE_WB(str->in0to4FilePtr, "in0to4.dat");
557 OPEN_FILE_WB(str->in4to8FilePtr, "in4to8.dat");
558 OPEN_FILE_WB(str->in8to12FilePtr, "in8to12.dat");
559 OPEN_FILE_WB(str->in8to16FilePtr, "in8to16.dat");
560
561 OPEN_FILE_WB(str->out0to4FilePtr, "out0to4.dat");
562 OPEN_FILE_WB(str->out4to8FilePtr, "out4to8.dat");
563 OPEN_FILE_WB(str->out8to12FilePtr, "out8to12.dat");
564 OPEN_FILE_WB(str->out8to16FilePtr, "out8to16.dat");
565 OPEN_FILE_WB(str->fftFilePtr, "riFFT.dat");
566 OPEN_FILE_WB(str->fftDecFilePtr, "riFFTDec.dat");
567
568 OPEN_FILE_WB(str->arrivalTime, NULL /*"ArivalTime.dat"*/);
569 str->lastArrivalTime = 0;
570
571 str->maxPayloadLB = 0;
572 str->maxPayloadUB = 0;
573 str->lbBytes = 0;
574 str->ubBytes = 0;
575
576 return 0;
577 };
578 #endif
OLDNEW
« no previous file with comments | « webrtc/modules/audio_coding/codecs/isac/main/test/debugUtility.h ('k') | webrtc/modules/audio_coding/test/TimedTrace.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698