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

Side by Side Diff: webrtc/modules/audio_coding/neteq/test/RTPencode.cc

Issue 1424083002: Make an enum class out of NetEqDecoder, and hide the neteq_decoders_ table (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: rebase Created 5 years, 1 month 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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 int* bitrate, 83 int* bitrate,
84 int* useRed); 84 int* useRed);
85 int NetEQTest_init_coders(webrtc::NetEqDecoder coder, 85 int NetEQTest_init_coders(webrtc::NetEqDecoder coder,
86 size_t enc_frameSize, 86 size_t enc_frameSize,
87 int bitrate, 87 int bitrate,
88 int sampfreq, 88 int sampfreq,
89 int vad, 89 int vad,
90 size_t numChannels); 90 size_t numChannels);
91 void defineCodecs(webrtc::NetEqDecoder* usedCodec, int* noOfCodecs); 91 void defineCodecs(webrtc::NetEqDecoder* usedCodec, int* noOfCodecs);
92 int NetEQTest_free_coders(webrtc::NetEqDecoder coder, size_t numChannels); 92 int NetEQTest_free_coders(webrtc::NetEqDecoder coder, size_t numChannels);
93 size_t NetEQTest_encode(int coder, 93 size_t NetEQTest_encode(webrtc::NetEqDecoder coder,
94 int16_t* indata, 94 int16_t* indata,
95 size_t frameLen, 95 size_t frameLen,
96 unsigned char* encoded, 96 unsigned char* encoded,
97 int sampleRate, 97 int sampleRate,
98 int* vad, 98 int* vad,
99 int useVAD, 99 int useVAD,
100 int bitrate, 100 int bitrate,
101 size_t numChannels); 101 size_t numChannels);
102 void makeRTPheader(unsigned char* rtp_data, 102 void makeRTPheader(unsigned char* rtp_data,
103 int payloadType, 103 int payloadType,
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after
481 defined(CODEC_CNGCODEC32) || defined(CODEC_CNGCODEC48)) 481 defined(CODEC_CNGCODEC32) || defined(CODEC_CNGCODEC48))
482 if (useVAD != 0) { 482 if (useVAD != 0) {
483 printf("Error: this simulation does not support VAD/DTX/CNG\n"); 483 printf("Error: this simulation does not support VAD/DTX/CNG\n");
484 } 484 }
485 #endif 485 #endif
486 486
487 // check stereo type 487 // check stereo type
488 if (usingStereo) { 488 if (usingStereo) {
489 switch (usedCodec) { 489 switch (usedCodec) {
490 // sample based codecs 490 // sample based codecs
491 case webrtc::kDecoderPCMu: 491 case webrtc::NetEqDecoder::kDecoderPCMu:
492 case webrtc::kDecoderPCMa: 492 case webrtc::NetEqDecoder::kDecoderPCMa:
493 case webrtc::kDecoderG722: { 493 case webrtc::NetEqDecoder::kDecoderG722: {
494 // 1 octet per sample 494 // 1 octet per sample
495 stereoMode = STEREO_MODE_SAMPLE_1; 495 stereoMode = STEREO_MODE_SAMPLE_1;
496 break; 496 break;
497 } 497 }
498 case webrtc::kDecoderPCM16B: 498 case webrtc::NetEqDecoder::kDecoderPCM16B:
499 case webrtc::kDecoderPCM16Bwb: 499 case webrtc::NetEqDecoder::kDecoderPCM16Bwb:
500 case webrtc::kDecoderPCM16Bswb32kHz: 500 case webrtc::NetEqDecoder::kDecoderPCM16Bswb32kHz:
501 case webrtc::kDecoderPCM16Bswb48kHz: { 501 case webrtc::NetEqDecoder::kDecoderPCM16Bswb48kHz: {
502 // 2 octets per sample 502 // 2 octets per sample
503 stereoMode = STEREO_MODE_SAMPLE_2; 503 stereoMode = STEREO_MODE_SAMPLE_2;
504 break; 504 break;
505 } 505 }
506 506
507 // fixed-rate frame codecs (with internal VAD) 507 // fixed-rate frame codecs (with internal VAD)
508 default: { 508 default: {
509 printf("Cannot use codec %s as stereo codec\n", argv[4]); 509 printf("Cannot use codec %s as stereo codec\n", argv[4]);
510 exit(0); 510 exit(0);
511 } 511 }
512 } 512 }
513 } 513 }
514 514
515 if ((usedCodec == webrtc::kDecoderISAC) || 515 if ((usedCodec == webrtc::NetEqDecoder::kDecoderISAC) ||
516 (usedCodec == webrtc::kDecoderISACswb)) { 516 (usedCodec == webrtc::NetEqDecoder::kDecoderISACswb)) {
517 if (argc != 7) { 517 if (argc != 7) {
518 if (usedCodec == webrtc::kDecoderISAC) { 518 if (usedCodec == webrtc::NetEqDecoder::kDecoderISAC) {
519 bitrate = 32000; 519 bitrate = 32000;
520 printf("Running iSAC at default bitrate of 32000 bps (to specify " 520 printf("Running iSAC at default bitrate of 32000 bps (to specify "
521 "explicitly add the bps as last parameter)\n"); 521 "explicitly add the bps as last parameter)\n");
522 } else // (usedCodec==webrtc::kDecoderISACswb) 522 } else // (usedCodec==webrtc::kDecoderISACswb)
523 { 523 {
524 bitrate = 56000; 524 bitrate = 56000;
525 printf("Running iSAC at default bitrate of 56000 bps (to specify " 525 printf("Running iSAC at default bitrate of 56000 bps (to specify "
526 "explicitly add the bps as last parameter)\n"); 526 "explicitly add the bps as last parameter)\n");
527 } 527 }
528 } else { 528 } else {
529 bitrate = atoi(argv[6]); 529 bitrate = atoi(argv[6]);
530 if (usedCodec == webrtc::kDecoderISAC) { 530 if (usedCodec == webrtc::NetEqDecoder::kDecoderISAC) {
531 if ((bitrate < 10000) || (bitrate > 32000)) { 531 if ((bitrate < 10000) || (bitrate > 32000)) {
532 printf("Error: iSAC bitrate must be between 10000 and 32000 bps (%i " 532 printf("Error: iSAC bitrate must be between 10000 and 32000 bps (%i "
533 "is invalid)\n", bitrate); 533 "is invalid)\n", bitrate);
534 exit(0); 534 exit(0);
535 } 535 }
536 printf("Running iSAC at bitrate of %i bps\n", bitrate); 536 printf("Running iSAC at bitrate of %i bps\n", bitrate);
537 } else // (usedCodec==webrtc::kDecoderISACswb) 537 } else // (usedCodec==webrtc::kDecoderISACswb)
538 { 538 {
539 if ((bitrate < 32000) || (bitrate > 56000)) { 539 if ((bitrate < 32000) || (bitrate > 56000)) {
540 printf("Error: iSAC SWB bitrate must be between 32000 and 56000 bps " 540 printf("Error: iSAC SWB bitrate must be between 32000 and 56000 bps "
541 "(%i is invalid)\n", bitrate); 541 "(%i is invalid)\n", bitrate);
542 exit(0); 542 exit(0);
543 } 543 }
544 } 544 }
545 } 545 }
546 } else { 546 } else {
547 if (argc == 7) { 547 if (argc == 7) {
548 printf("Error: Bitrate parameter can only be specified for iSAC, G.723, " 548 printf("Error: Bitrate parameter can only be specified for iSAC, G.723, "
549 "and G.729.1\n"); 549 "and G.729.1\n");
550 exit(0); 550 exit(0);
551 } 551 }
552 } 552 }
553 553
554 if (useRed) { 554 if (useRed) {
555 printf("Redundancy engaged. "); 555 printf("Redundancy engaged. ");
556 } 556 }
557 printf("Used codec: %i\n", usedCodec); 557 printf("Used codec: %i\n", static_cast<int>(usedCodec));
558 printf("Payload type: %i\n", payloadType); 558 printf("Payload type: %i\n", payloadType);
559 559
560 NetEQTest_init_coders(usedCodec, packet_size, bitrate, fs, useVAD, 560 NetEQTest_init_coders(usedCodec, packet_size, bitrate, fs, useVAD,
561 numChannels); 561 numChannels);
562 562
563 /* write file header */ 563 /* write file header */
564 // fprintf(out_file, "#!RTPencode%s\n", "1.0"); 564 // fprintf(out_file, "#!RTPencode%s\n", "1.0");
565 fprintf(out_file, "#!rtpplay%s \n", 565 fprintf(out_file, "#!rtpplay%s \n",
566 "1.0"); // this is the string that rtpplay needs 566 "1.0"); // this is the string that rtpplay needs
567 uint32_t dummy_variable = 0; // should be converted to network endian format, 567 uint32_t dummy_variable = 0; // should be converted to network endian format,
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
770 old_enc_len = enc_len; 770 old_enc_len = enc_len;
771 first_old_packet = 0; 771 first_old_packet = 0;
772 packet_age = 0; 772 packet_age = 0;
773 } 773 }
774 packet_age += packet_size; 774 packet_age += packet_size;
775 #endif 775 #endif
776 776
777 if (useRed) { 777 if (useRed) {
778 /* move data to redundancy store */ 778 /* move data to redundancy store */
779 #ifdef CODEC_ISAC 779 #ifdef CODEC_ISAC
780 if (usedCodec == webrtc::kDecoderISAC) { 780 if (usedCodec == webrtc::NetEqDecoder::kDecoderISAC) {
781 assert(!usingStereo); // Cannot handle stereo yet 781 assert(!usingStereo); // Cannot handle stereo yet
782 red_len[0] = WebRtcIsac_GetRedPayload(ISAC_inst[0], red_data); 782 red_len[0] = WebRtcIsac_GetRedPayload(ISAC_inst[0], red_data);
783 } else { 783 } else {
784 #endif 784 #endif
785 memcpy(red_data, &rtp_data[RTPheaderLen + red_len[0]], enc_len); 785 memcpy(red_data, &rtp_data[RTPheaderLen + red_len[0]], enc_len);
786 red_len[0] = red_len[1]; 786 red_len[0] = red_len[1];
787 #ifdef CODEC_ISAC 787 #ifdef CODEC_ISAC
788 } 788 }
789 #endif 789 #endif
790 red_TS[0] = red_TS[1]; 790 red_TS[0] = red_TS[1];
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
823 webrtc::NetEqDecoder* codec, 823 webrtc::NetEqDecoder* codec,
824 int* PT, 824 int* PT,
825 size_t frameLen, 825 size_t frameLen,
826 int* fs, 826 int* fs,
827 int* bitrate, 827 int* bitrate,
828 int* useRed) { 828 int* useRed) {
829 *bitrate = 0; /* Default bitrate setting */ 829 *bitrate = 0; /* Default bitrate setting */
830 *useRed = 0; /* Default no redundancy */ 830 *useRed = 0; /* Default no redundancy */
831 831
832 if (!strcmp(name, "pcmu")) { 832 if (!strcmp(name, "pcmu")) {
833 *codec = webrtc::kDecoderPCMu; 833 *codec = webrtc::NetEqDecoder::kDecoderPCMu;
834 *PT = NETEQ_CODEC_PCMU_PT; 834 *PT = NETEQ_CODEC_PCMU_PT;
835 *fs = 8000; 835 *fs = 8000;
836 } else if (!strcmp(name, "pcma")) { 836 } else if (!strcmp(name, "pcma")) {
837 *codec = webrtc::kDecoderPCMa; 837 *codec = webrtc::NetEqDecoder::kDecoderPCMa;
838 *PT = NETEQ_CODEC_PCMA_PT; 838 *PT = NETEQ_CODEC_PCMA_PT;
839 *fs = 8000; 839 *fs = 8000;
840 } else if (!strcmp(name, "pcm16b")) { 840 } else if (!strcmp(name, "pcm16b")) {
841 *codec = webrtc::kDecoderPCM16B; 841 *codec = webrtc::NetEqDecoder::kDecoderPCM16B;
842 *PT = NETEQ_CODEC_PCM16B_PT; 842 *PT = NETEQ_CODEC_PCM16B_PT;
843 *fs = 8000; 843 *fs = 8000;
844 } else if (!strcmp(name, "pcm16b_wb")) { 844 } else if (!strcmp(name, "pcm16b_wb")) {
845 *codec = webrtc::kDecoderPCM16Bwb; 845 *codec = webrtc::NetEqDecoder::kDecoderPCM16Bwb;
846 *PT = NETEQ_CODEC_PCM16B_WB_PT; 846 *PT = NETEQ_CODEC_PCM16B_WB_PT;
847 *fs = 16000; 847 *fs = 16000;
848 } else if (!strcmp(name, "pcm16b_swb32")) { 848 } else if (!strcmp(name, "pcm16b_swb32")) {
849 *codec = webrtc::kDecoderPCM16Bswb32kHz; 849 *codec = webrtc::NetEqDecoder::kDecoderPCM16Bswb32kHz;
850 *PT = NETEQ_CODEC_PCM16B_SWB32KHZ_PT; 850 *PT = NETEQ_CODEC_PCM16B_SWB32KHZ_PT;
851 *fs = 32000; 851 *fs = 32000;
852 } else if (!strcmp(name, "pcm16b_swb48")) { 852 } else if (!strcmp(name, "pcm16b_swb48")) {
853 *codec = webrtc::kDecoderPCM16Bswb48kHz; 853 *codec = webrtc::NetEqDecoder::kDecoderPCM16Bswb48kHz;
854 *PT = NETEQ_CODEC_PCM16B_SWB48KHZ_PT; 854 *PT = NETEQ_CODEC_PCM16B_SWB48KHZ_PT;
855 *fs = 48000; 855 *fs = 48000;
856 } else if (!strcmp(name, "g722")) { 856 } else if (!strcmp(name, "g722")) {
857 *codec = webrtc::kDecoderG722; 857 *codec = webrtc::NetEqDecoder::kDecoderG722;
858 *PT = NETEQ_CODEC_G722_PT; 858 *PT = NETEQ_CODEC_G722_PT;
859 *fs = 16000; 859 *fs = 16000;
860 } else if ((!strcmp(name, "ilbc")) && 860 } else if ((!strcmp(name, "ilbc")) &&
861 ((frameLen % 240 == 0) || (frameLen % 160 == 0))) { 861 ((frameLen % 240 == 0) || (frameLen % 160 == 0))) {
862 *fs = 8000; 862 *fs = 8000;
863 *codec = webrtc::kDecoderILBC; 863 *codec = webrtc::NetEqDecoder::kDecoderILBC;
864 *PT = NETEQ_CODEC_ILBC_PT; 864 *PT = NETEQ_CODEC_ILBC_PT;
865 } else if (!strcmp(name, "isac")) { 865 } else if (!strcmp(name, "isac")) {
866 *fs = 16000; 866 *fs = 16000;
867 *codec = webrtc::kDecoderISAC; 867 *codec = webrtc::NetEqDecoder::kDecoderISAC;
868 *PT = NETEQ_CODEC_ISAC_PT; 868 *PT = NETEQ_CODEC_ISAC_PT;
869 } else if (!strcmp(name, "isacswb")) { 869 } else if (!strcmp(name, "isacswb")) {
870 *fs = 32000; 870 *fs = 32000;
871 *codec = webrtc::kDecoderISACswb; 871 *codec = webrtc::NetEqDecoder::kDecoderISACswb;
872 *PT = NETEQ_CODEC_ISACSWB_PT; 872 *PT = NETEQ_CODEC_ISACSWB_PT;
873 } else if (!strcmp(name, "red_pcm")) { 873 } else if (!strcmp(name, "red_pcm")) {
874 *codec = webrtc::kDecoderPCMa; 874 *codec = webrtc::NetEqDecoder::kDecoderPCMa;
875 *PT = NETEQ_CODEC_PCMA_PT; /* this will be the PT for the sub-headers */ 875 *PT = NETEQ_CODEC_PCMA_PT; /* this will be the PT for the sub-headers */
876 *fs = 8000; 876 *fs = 8000;
877 *useRed = 1; 877 *useRed = 1;
878 } else if (!strcmp(name, "red_isac")) { 878 } else if (!strcmp(name, "red_isac")) {
879 *codec = webrtc::kDecoderISAC; 879 *codec = webrtc::NetEqDecoder::kDecoderISAC;
880 *PT = NETEQ_CODEC_ISAC_PT; /* this will be the PT for the sub-headers */ 880 *PT = NETEQ_CODEC_ISAC_PT; /* this will be the PT for the sub-headers */
881 *fs = 16000; 881 *fs = 16000;
882 *useRed = 1; 882 *useRed = 1;
883 } else { 883 } else {
884 printf("Error: Not a supported codec (%s)\n", name); 884 printf("Error: Not a supported codec (%s)\n", name);
885 exit(0); 885 exit(0);
886 } 886 }
887 } 887 }
888 888
889 int NetEQTest_init_coders(webrtc::NetEqDecoder coder, 889 int NetEQTest_init_coders(webrtc::NetEqDecoder coder,
(...skipping 28 matching lines...) Expand all
918 if (ok == -1) { 918 if (ok == -1) {
919 printf("Error: Initialization of CNG struct failed. Error code %d\n", 919 printf("Error: Initialization of CNG struct failed. Error code %d\n",
920 WebRtcCng_GetErrorCodeEnc(CNGenc_inst[k])); 920 WebRtcCng_GetErrorCodeEnc(CNGenc_inst[k]));
921 exit(0); 921 exit(0);
922 } 922 }
923 } 923 }
924 #endif 924 #endif
925 925
926 switch (coder) { 926 switch (coder) {
927 #ifdef CODEC_PCM16B 927 #ifdef CODEC_PCM16B
928 case webrtc::kDecoderPCM16B: 928 case webrtc::NetEqDecoder::kDecoderPCM16B:
929 #endif 929 #endif
930 #ifdef CODEC_PCM16B_WB 930 #ifdef CODEC_PCM16B_WB
931 case webrtc::kDecoderPCM16Bwb: 931 case webrtc::NetEqDecoder::kDecoderPCM16Bwb:
932 #endif 932 #endif
933 #ifdef CODEC_PCM16B_32KHZ 933 #ifdef CODEC_PCM16B_32KHZ
934 case webrtc::kDecoderPCM16Bswb32kHz: 934 case webrtc::NetEqDecoder::kDecoderPCM16Bswb32kHz:
935 #endif 935 #endif
936 #ifdef CODEC_PCM16B_48KHZ 936 #ifdef CODEC_PCM16B_48KHZ
937 case webrtc::kDecoderPCM16Bswb48kHz: 937 case webrtc::NetEqDecoder::kDecoderPCM16Bswb48kHz:
938 #endif 938 #endif
939 #ifdef CODEC_G711 939 #ifdef CODEC_G711
940 case webrtc::kDecoderPCMu: 940 case webrtc::NetEqDecoder::kDecoderPCMu:
941 case webrtc::kDecoderPCMa: 941 case webrtc::NetEqDecoder::kDecoderPCMa:
942 #endif 942 #endif
943 // do nothing 943 // do nothing
944 break; 944 break;
945 #ifdef CODEC_G729 945 #ifdef CODEC_G729
946 case webrtc::kDecoderG729: 946 case webrtc::kDecoderG729:
947 if (sampfreq == 8000) { 947 if (sampfreq == 8000) {
948 if ((enc_frameSize == 80) || (enc_frameSize == 160) || 948 if ((enc_frameSize == 80) || (enc_frameSize == 160) ||
949 (enc_frameSize == 240) || (enc_frameSize == 320) || 949 (enc_frameSize == 240) || (enc_frameSize == 320) ||
950 (enc_frameSize == 400) || (enc_frameSize == 480)) { 950 (enc_frameSize == 400) || (enc_frameSize == 480)) {
951 ok = WebRtcG729_CreateEnc(&G729enc_inst[k]); 951 ok = WebRtcG729_CreateEnc(&G729enc_inst[k]);
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
1181 } 1181 }
1182 WebRtcG7221C_EncoderInit48( 1182 WebRtcG7221C_EncoderInit48(
1183 (G722_1C_48_encinst_t*)G722_1C_48enc_inst[k]); 1183 (G722_1C_48_encinst_t*)G722_1C_48enc_inst[k]);
1184 } else { 1184 } else {
1185 printf("\nError - G722.1 C is only developed for 32kHz \n"); 1185 printf("\nError - G722.1 C is only developed for 32kHz \n");
1186 exit(0); 1186 exit(0);
1187 } 1187 }
1188 break; 1188 break;
1189 #endif 1189 #endif
1190 #ifdef CODEC_G722 1190 #ifdef CODEC_G722
1191 case webrtc::kDecoderG722: 1191 case webrtc::NetEqDecoder::kDecoderG722:
1192 if (sampfreq == 16000) { 1192 if (sampfreq == 16000) {
1193 if (enc_frameSize % 2 == 0) { 1193 if (enc_frameSize % 2 == 0) {
1194 } else { 1194 } else {
1195 printf( 1195 printf(
1196 "\nError - g722 frames must have an even number of " 1196 "\nError - g722 frames must have an even number of "
1197 "enc_frameSize\n"); 1197 "enc_frameSize\n");
1198 exit(0); 1198 exit(0);
1199 } 1199 }
1200 WebRtcG722_CreateEncoder(&g722EncState[k]); 1200 WebRtcG722_CreateEncoder(&g722EncState[k]);
1201 WebRtcG722_EncoderInit(g722EncState[k]); 1201 WebRtcG722_EncoderInit(g722EncState[k]);
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
1264 } 1264 }
1265 WebRtcAmrWb_EncodeBitmode(AMRWBenc_inst[k], AMRBandwidthEfficient); 1265 WebRtcAmrWb_EncodeBitmode(AMRWBenc_inst[k], AMRBandwidthEfficient);
1266 1266
1267 } else { 1267 } else {
1268 printf("\nError - AMRwb is only developed for 16kHz \n"); 1268 printf("\nError - AMRwb is only developed for 16kHz \n");
1269 exit(0); 1269 exit(0);
1270 } 1270 }
1271 break; 1271 break;
1272 #endif 1272 #endif
1273 #ifdef CODEC_ILBC 1273 #ifdef CODEC_ILBC
1274 case webrtc::kDecoderILBC: 1274 case webrtc::NetEqDecoder::kDecoderILBC:
1275 if (sampfreq == 8000) { 1275 if (sampfreq == 8000) {
1276 ok = WebRtcIlbcfix_EncoderCreate(&iLBCenc_inst[k]); 1276 ok = WebRtcIlbcfix_EncoderCreate(&iLBCenc_inst[k]);
1277 if (ok != 0) { 1277 if (ok != 0) {
1278 printf("Error: Couldn't allocate memory for iLBC encoding " 1278 printf("Error: Couldn't allocate memory for iLBC encoding "
1279 "instance\n"); 1279 "instance\n");
1280 exit(0); 1280 exit(0);
1281 } 1281 }
1282 if ((enc_frameSize == 160) || (enc_frameSize == 240) || 1282 if ((enc_frameSize == 160) || (enc_frameSize == 240) ||
1283 (enc_frameSize == 320) || (enc_frameSize == 480)) { 1283 (enc_frameSize == 320) || (enc_frameSize == 480)) {
1284 } else { 1284 } else {
1285 printf("\nError - iLBC only supports 160, 240, 320 and 480 " 1285 printf("\nError - iLBC only supports 160, 240, 320 and 480 "
1286 "enc_frameSize (20, 30, 40 and 60 ms)\n"); 1286 "enc_frameSize (20, 30, 40 and 60 ms)\n");
1287 exit(0); 1287 exit(0);
1288 } 1288 }
1289 if ((enc_frameSize == 160) || (enc_frameSize == 320)) { 1289 if ((enc_frameSize == 160) || (enc_frameSize == 320)) {
1290 /* 20 ms version */ 1290 /* 20 ms version */
1291 WebRtcIlbcfix_EncoderInit(iLBCenc_inst[k], 20); 1291 WebRtcIlbcfix_EncoderInit(iLBCenc_inst[k], 20);
1292 } else { 1292 } else {
1293 /* 30 ms version */ 1293 /* 30 ms version */
1294 WebRtcIlbcfix_EncoderInit(iLBCenc_inst[k], 30); 1294 WebRtcIlbcfix_EncoderInit(iLBCenc_inst[k], 30);
1295 } 1295 }
1296 } else { 1296 } else {
1297 printf("\nError - iLBC is only developed for 8kHz \n"); 1297 printf("\nError - iLBC is only developed for 8kHz \n");
1298 exit(0); 1298 exit(0);
1299 } 1299 }
1300 break; 1300 break;
1301 #endif 1301 #endif
1302 #ifdef CODEC_ISAC 1302 #ifdef CODEC_ISAC
1303 case webrtc::kDecoderISAC: 1303 case webrtc::NetEqDecoder::kDecoderISAC:
1304 if (sampfreq == 16000) { 1304 if (sampfreq == 16000) {
1305 ok = WebRtcIsac_Create(&ISAC_inst[k]); 1305 ok = WebRtcIsac_Create(&ISAC_inst[k]);
1306 if (ok != 0) { 1306 if (ok != 0) {
1307 printf("Error: Couldn't allocate memory for iSAC instance\n"); 1307 printf("Error: Couldn't allocate memory for iSAC instance\n");
1308 exit(0); 1308 exit(0);
1309 } 1309 }
1310 if ((enc_frameSize == 480) || (enc_frameSize == 960)) { 1310 if ((enc_frameSize == 480) || (enc_frameSize == 960)) {
1311 } else { 1311 } else {
1312 printf("\nError - iSAC only supports frameSize (30 and 60 ms)\n"); 1312 printf("\nError - iSAC only supports frameSize (30 and 60 ms)\n");
1313 exit(0); 1313 exit(0);
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
1349 } 1349 }
1350 WebRtcIsacfix_Control(ISAC_inst[k], bitrate, enc_frameSize >> 4); 1350 WebRtcIsacfix_Control(ISAC_inst[k], bitrate, enc_frameSize >> 4);
1351 } else { 1351 } else {
1352 printf("\nError - iSAC only supports 480 or 960 enc_frameSize (30 or " 1352 printf("\nError - iSAC only supports 480 or 960 enc_frameSize (30 or "
1353 "60 ms)\n"); 1353 "60 ms)\n");
1354 exit(0); 1354 exit(0);
1355 } 1355 }
1356 break; 1356 break;
1357 #endif 1357 #endif
1358 #ifdef CODEC_ISAC_SWB 1358 #ifdef CODEC_ISAC_SWB
1359 case webrtc::kDecoderISACswb: 1359 case webrtc::NetEqDecoder::kDecoderISACswb:
1360 if (sampfreq == 32000) { 1360 if (sampfreq == 32000) {
1361 ok = WebRtcIsac_Create(&ISACSWB_inst[k]); 1361 ok = WebRtcIsac_Create(&ISACSWB_inst[k]);
1362 if (ok != 0) { 1362 if (ok != 0) {
1363 printf("Error: Couldn't allocate memory for iSAC SWB instance\n"); 1363 printf("Error: Couldn't allocate memory for iSAC SWB instance\n");
1364 exit(0); 1364 exit(0);
1365 } 1365 }
1366 if (enc_frameSize == 960) { 1366 if (enc_frameSize == 960) {
1367 } else { 1367 } else {
1368 printf("\nError - iSAC SWB only supports frameSize 30 ms\n"); 1368 printf("\nError - iSAC SWB only supports frameSize 30 ms\n");
1369 exit(0); 1369 exit(0);
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
1428 int NetEQTest_free_coders(webrtc::NetEqDecoder coder, size_t numChannels) { 1428 int NetEQTest_free_coders(webrtc::NetEqDecoder coder, size_t numChannels) {
1429 for (size_t k = 0; k < numChannels; k++) { 1429 for (size_t k = 0; k < numChannels; k++) {
1430 WebRtcVad_Free(VAD_inst[k]); 1430 WebRtcVad_Free(VAD_inst[k]);
1431 #if (defined(CODEC_CNGCODEC8) || defined(CODEC_CNGCODEC16) || \ 1431 #if (defined(CODEC_CNGCODEC8) || defined(CODEC_CNGCODEC16) || \
1432 defined(CODEC_CNGCODEC32) || defined(CODEC_CNGCODEC48)) 1432 defined(CODEC_CNGCODEC32) || defined(CODEC_CNGCODEC48))
1433 WebRtcCng_FreeEnc(CNGenc_inst[k]); 1433 WebRtcCng_FreeEnc(CNGenc_inst[k]);
1434 #endif 1434 #endif
1435 1435
1436 switch (coder) { 1436 switch (coder) {
1437 #ifdef CODEC_PCM16B 1437 #ifdef CODEC_PCM16B
1438 case webrtc::kDecoderPCM16B: 1438 case webrtc::NetEqDecoder::kDecoderPCM16B:
1439 #endif 1439 #endif
1440 #ifdef CODEC_PCM16B_WB 1440 #ifdef CODEC_PCM16B_WB
1441 case webrtc::kDecoderPCM16Bwb: 1441 case webrtc::NetEqDecoder::kDecoderPCM16Bwb:
1442 #endif 1442 #endif
1443 #ifdef CODEC_PCM16B_32KHZ 1443 #ifdef CODEC_PCM16B_32KHZ
1444 case webrtc::kDecoderPCM16Bswb32kHz: 1444 case webrtc::NetEqDecoder::kDecoderPCM16Bswb32kHz:
1445 #endif 1445 #endif
1446 #ifdef CODEC_PCM16B_48KHZ 1446 #ifdef CODEC_PCM16B_48KHZ
1447 case webrtc::kDecoderPCM16Bswb48kHz: 1447 case webrtc::NetEqDecoder::kDecoderPCM16Bswb48kHz:
1448 #endif 1448 #endif
1449 #ifdef CODEC_G711 1449 #ifdef CODEC_G711
1450 case webrtc::kDecoderPCMu: 1450 case webrtc::NetEqDecoder::kDecoderPCMu:
1451 case webrtc::kDecoderPCMa: 1451 case webrtc::NetEqDecoder::kDecoderPCMa:
1452 #endif 1452 #endif
1453 // do nothing 1453 // do nothing
1454 break; 1454 break;
1455 #ifdef CODEC_G729 1455 #ifdef CODEC_G729
1456 case webrtc::kDecoderG729: 1456 case webrtc::NetEqDecoder::kDecoderG729:
1457 WebRtcG729_FreeEnc(G729enc_inst[k]); 1457 WebRtcG729_FreeEnc(G729enc_inst[k]);
1458 break; 1458 break;
1459 #endif 1459 #endif
1460 #ifdef CODEC_G729_1 1460 #ifdef CODEC_G729_1
1461 case webrtc::kDecoderG729_1: 1461 case webrtc::NetEqDecoder::kDecoderG729_1:
1462 WebRtcG7291_Free(G729_1_inst[k]); 1462 WebRtcG7291_Free(G729_1_inst[k]);
1463 break; 1463 break;
1464 #endif 1464 #endif
1465 #ifdef CODEC_SPEEX_8 1465 #ifdef CODEC_SPEEX_8
1466 case webrtc::kDecoderSPEEX_8: 1466 case webrtc::NetEqDecoder::kDecoderSPEEX_8:
1467 WebRtcSpeex_FreeEnc(SPEEX8enc_inst[k]); 1467 WebRtcSpeex_FreeEnc(SPEEX8enc_inst[k]);
1468 break; 1468 break;
1469 #endif 1469 #endif
1470 #ifdef CODEC_SPEEX_16 1470 #ifdef CODEC_SPEEX_16
1471 case webrtc::kDecoderSPEEX_16: 1471 case webrtc::NetEqDecoder::kDecoderSPEEX_16:
1472 WebRtcSpeex_FreeEnc(SPEEX16enc_inst[k]); 1472 WebRtcSpeex_FreeEnc(SPEEX16enc_inst[k]);
1473 break; 1473 break;
1474 #endif 1474 #endif
1475 1475
1476 #ifdef CODEC_G722_1_16 1476 #ifdef CODEC_G722_1_16
1477 case webrtc::kDecoderG722_1_16: 1477 case webrtc::NetEqDecoder::kDecoderG722_1_16:
1478 WebRtcG7221_FreeEnc16(G722_1_16enc_inst[k]); 1478 WebRtcG7221_FreeEnc16(G722_1_16enc_inst[k]);
1479 break; 1479 break;
1480 #endif 1480 #endif
1481 #ifdef CODEC_G722_1_24 1481 #ifdef CODEC_G722_1_24
1482 case webrtc::kDecoderG722_1_24: 1482 case webrtc::NetEqDecoder::kDecoderG722_1_24:
1483 WebRtcG7221_FreeEnc24(G722_1_24enc_inst[k]); 1483 WebRtcG7221_FreeEnc24(G722_1_24enc_inst[k]);
1484 break; 1484 break;
1485 #endif 1485 #endif
1486 #ifdef CODEC_G722_1_32 1486 #ifdef CODEC_G722_1_32
1487 case webrtc::kDecoderG722_1_32: 1487 case webrtc::NetEqDecoder::kDecoderG722_1_32:
1488 WebRtcG7221_FreeEnc32(G722_1_32enc_inst[k]); 1488 WebRtcG7221_FreeEnc32(G722_1_32enc_inst[k]);
1489 break; 1489 break;
1490 #endif 1490 #endif
1491 #ifdef CODEC_G722_1C_24 1491 #ifdef CODEC_G722_1C_24
1492 case webrtc::kDecoderG722_1C_24: 1492 case webrtc::NetEqDecoder::kDecoderG722_1C_24:
1493 WebRtcG7221C_FreeEnc24(G722_1C_24enc_inst[k]); 1493 WebRtcG7221C_FreeEnc24(G722_1C_24enc_inst[k]);
1494 break; 1494 break;
1495 #endif 1495 #endif
1496 #ifdef CODEC_G722_1C_32 1496 #ifdef CODEC_G722_1C_32
1497 case webrtc::kDecoderG722_1C_32: 1497 case webrtc::NetEqDecoder::kDecoderG722_1C_32:
1498 WebRtcG7221C_FreeEnc32(G722_1C_32enc_inst[k]); 1498 WebRtcG7221C_FreeEnc32(G722_1C_32enc_inst[k]);
1499 break; 1499 break;
1500 #endif 1500 #endif
1501 #ifdef CODEC_G722_1C_48 1501 #ifdef CODEC_G722_1C_48
1502 case webrtc::kDecoderG722_1C_48: 1502 case webrtc::NetEqDecoder::kDecoderG722_1C_48:
1503 WebRtcG7221C_FreeEnc48(G722_1C_48enc_inst[k]); 1503 WebRtcG7221C_FreeEnc48(G722_1C_48enc_inst[k]);
1504 break; 1504 break;
1505 #endif 1505 #endif
1506 #ifdef CODEC_G722 1506 #ifdef CODEC_G722
1507 case webrtc::kDecoderG722: 1507 case webrtc::NetEqDecoder::kDecoderG722:
1508 WebRtcG722_FreeEncoder(g722EncState[k]); 1508 WebRtcG722_FreeEncoder(g722EncState[k]);
1509 break; 1509 break;
1510 #endif 1510 #endif
1511 #ifdef CODEC_AMR 1511 #ifdef CODEC_AMR
1512 case webrtc::kDecoderAMR: 1512 case webrtc::NetEqDecoder::kDecoderAMR:
1513 WebRtcAmr_FreeEnc(AMRenc_inst[k]); 1513 WebRtcAmr_FreeEnc(AMRenc_inst[k]);
1514 break; 1514 break;
1515 #endif 1515 #endif
1516 #ifdef CODEC_AMRWB 1516 #ifdef CODEC_AMRWB
1517 case webrtc::kDecoderAMRWB: 1517 case webrtc::NetEqDecoder::kDecoderAMRWB:
1518 WebRtcAmrWb_FreeEnc(AMRWBenc_inst[k]); 1518 WebRtcAmrWb_FreeEnc(AMRWBenc_inst[k]);
1519 break; 1519 break;
1520 #endif 1520 #endif
1521 #ifdef CODEC_ILBC 1521 #ifdef CODEC_ILBC
1522 case webrtc::kDecoderILBC: 1522 case webrtc::NetEqDecoder::kDecoderILBC:
1523 WebRtcIlbcfix_EncoderFree(iLBCenc_inst[k]); 1523 WebRtcIlbcfix_EncoderFree(iLBCenc_inst[k]);
1524 break; 1524 break;
1525 #endif 1525 #endif
1526 #ifdef CODEC_ISAC 1526 #ifdef CODEC_ISAC
1527 case webrtc::kDecoderISAC: 1527 case webrtc::NetEqDecoder::kDecoderISAC:
1528 WebRtcIsac_Free(ISAC_inst[k]); 1528 WebRtcIsac_Free(ISAC_inst[k]);
1529 break; 1529 break;
1530 #endif 1530 #endif
1531 #ifdef NETEQ_ISACFIX_CODEC 1531 #ifdef NETEQ_ISACFIX_CODEC
1532 case webrtc::kDecoderISAC: 1532 case webrtc::NetEqDecoder::kDecoderISAC:
1533 WebRtcIsacfix_Free(ISAC_inst[k]); 1533 WebRtcIsacfix_Free(ISAC_inst[k]);
1534 break; 1534 break;
1535 #endif 1535 #endif
1536 #ifdef CODEC_ISAC_SWB 1536 #ifdef CODEC_ISAC_SWB
1537 case webrtc::kDecoderISACswb: 1537 case webrtc::NetEqDecoder::kDecoderISACswb:
1538 WebRtcIsac_Free(ISACSWB_inst[k]); 1538 WebRtcIsac_Free(ISACSWB_inst[k]);
1539 break; 1539 break;
1540 #endif 1540 #endif
1541 #ifdef CODEC_GSMFR 1541 #ifdef CODEC_GSMFR
1542 case webrtc::kDecoderGSMFR: 1542 case webrtc::NetEqDecoder::kDecoderGSMFR:
1543 WebRtcGSMFR_FreeEnc(GSMFRenc_inst[k]); 1543 WebRtcGSMFR_FreeEnc(GSMFRenc_inst[k]);
1544 break; 1544 break;
1545 #endif 1545 #endif
1546 default: 1546 default:
1547 printf("Error: unknown codec in call to NetEQTest_init_coders.\n"); 1547 printf("Error: unknown codec in call to NetEQTest_init_coders.\n");
1548 exit(0); 1548 exit(0);
1549 break; 1549 break;
1550 } 1550 }
1551 } 1551 }
1552 1552
1553 return (0); 1553 return (0);
1554 } 1554 }
1555 1555
1556 size_t NetEQTest_encode(int coder, 1556 size_t NetEQTest_encode(webrtc::NetEqDecoder coder,
1557 int16_t* indata, 1557 int16_t* indata,
1558 size_t frameLen, 1558 size_t frameLen,
1559 unsigned char* encoded, 1559 unsigned char* encoded,
1560 int sampleRate, 1560 int sampleRate,
1561 int* vad, 1561 int* vad,
1562 int useVAD, 1562 int useVAD,
1563 int bitrate, 1563 int bitrate,
1564 size_t numChannels) { 1564 size_t numChannels) {
1565 size_t cdlen = 0; 1565 size_t cdlen = 0;
1566 int16_t* tempdata; 1566 int16_t* tempdata;
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
1618 first_cng = 0; 1618 first_cng = 0;
1619 return (cdlen); 1619 return (cdlen);
1620 } 1620 }
1621 } 1621 }
1622 1622
1623 // loop over all channels 1623 // loop over all channels
1624 size_t totalLen = 0; 1624 size_t totalLen = 0;
1625 1625
1626 for (size_t k = 0; k < numChannels; k++) { 1626 for (size_t k = 0; k < numChannels; k++) {
1627 /* Encode with the selected coder type */ 1627 /* Encode with the selected coder type */
1628 if (coder == webrtc::kDecoderPCMu) { /*g711 u-law */ 1628 if (coder == webrtc::NetEqDecoder::kDecoderPCMu) { /*g711 u-law */
1629 #ifdef CODEC_G711 1629 #ifdef CODEC_G711
1630 cdlen = WebRtcG711_EncodeU(indata, frameLen, encoded); 1630 cdlen = WebRtcG711_EncodeU(indata, frameLen, encoded);
1631 #endif 1631 #endif
1632 } else if (coder == webrtc::kDecoderPCMa) { /*g711 A-law */ 1632 } else if (coder == webrtc::NetEqDecoder::kDecoderPCMa) { /*g711 A-law */
1633 #ifdef CODEC_G711 1633 #ifdef CODEC_G711
1634 cdlen = WebRtcG711_EncodeA(indata, frameLen, encoded); 1634 cdlen = WebRtcG711_EncodeA(indata, frameLen, encoded);
1635 } 1635 }
1636 #endif 1636 #endif
1637 #ifdef CODEC_PCM16B 1637 #ifdef CODEC_PCM16B
1638 else if ((coder == webrtc::kDecoderPCM16B) || 1638 else if ((coder == webrtc::NetEqDecoder::kDecoderPCM16B) ||
1639 (coder == webrtc::kDecoderPCM16Bwb) || 1639 (coder == webrtc::NetEqDecoder::kDecoderPCM16Bwb) ||
1640 (coder == webrtc::kDecoderPCM16Bswb32kHz) || 1640 (coder == webrtc::NetEqDecoder::kDecoderPCM16Bswb32kHz) ||
1641 (coder == webrtc:: 1641 (coder == webrtc::NetEqDecoder::
1642 kDecoderPCM16Bswb48kHz)) { /*pcm16b (8kHz, 16kHz, 1642 kDecoderPCM16Bswb48kHz)) { /*pcm16b (8kHz, 16kHz,
1643 32kHz or 48kHz) */ 1643 32kHz or 48kHz) */
1644 cdlen = WebRtcPcm16b_Encode(indata, frameLen, encoded); 1644 cdlen = WebRtcPcm16b_Encode(indata, frameLen, encoded);
1645 } 1645 }
1646 #endif 1646 #endif
1647 #ifdef CODEC_G722 1647 #ifdef CODEC_G722
1648 else if (coder == webrtc::kDecoderG722) { /*g722 */ 1648 else if (coder == webrtc::NetEqDecoder::kDecoderG722) { /*g722 */
1649 cdlen = WebRtcG722_Encode(g722EncState[k], indata, frameLen, encoded); 1649 cdlen = WebRtcG722_Encode(g722EncState[k], indata, frameLen, encoded);
1650 assert(cdlen == frameLen >> 1); 1650 assert(cdlen == frameLen >> 1);
1651 } 1651 }
1652 #endif 1652 #endif
1653 #ifdef CODEC_ILBC 1653 #ifdef CODEC_ILBC
1654 else if (coder == webrtc::kDecoderILBC) { /*iLBC */ 1654 else if (coder == webrtc::NetEqDecoder::kDecoderILBC) { /*iLBC */
1655 cdlen = static_cast<size_t>(std::max( 1655 cdlen = static_cast<size_t>(std::max(
1656 WebRtcIlbcfix_Encode(iLBCenc_inst[k], indata, frameLen, encoded), 0)); 1656 WebRtcIlbcfix_Encode(iLBCenc_inst[k], indata, frameLen, encoded), 0));
1657 } 1657 }
1658 #endif 1658 #endif
1659 #if (defined(CODEC_ISAC) || \ 1659 #if (defined(CODEC_ISAC) || \
1660 defined(NETEQ_ISACFIX_CODEC)) // TODO(hlundin): remove all 1660 defined(NETEQ_ISACFIX_CODEC)) // TODO(hlundin): remove all
1661 // NETEQ_ISACFIX_CODEC 1661 // NETEQ_ISACFIX_CODEC
1662 else if (coder == webrtc::kDecoderISAC) { /*iSAC */ 1662 else if (coder == webrtc::NetEqDecoder::kDecoderISAC) { /*iSAC */
1663 int noOfCalls = 0; 1663 int noOfCalls = 0;
1664 int res = 0; 1664 int res = 0;
1665 while (res <= 0) { 1665 while (res <= 0) {
1666 #ifdef CODEC_ISAC /* floating point */ 1666 #ifdef CODEC_ISAC /* floating point */
1667 res = 1667 res =
1668 WebRtcIsac_Encode(ISAC_inst[k], &indata[noOfCalls * 160], encoded); 1668 WebRtcIsac_Encode(ISAC_inst[k], &indata[noOfCalls * 160], encoded);
1669 #else /* fixed point */ 1669 #else /* fixed point */
1670 res = WebRtcIsacfix_Encode(ISAC_inst[k], &indata[noOfCalls * 160], 1670 res = WebRtcIsacfix_Encode(ISAC_inst[k], &indata[noOfCalls * 160],
1671 encoded); 1671 encoded);
1672 #endif 1672 #endif
1673 noOfCalls++; 1673 noOfCalls++;
1674 } 1674 }
1675 cdlen = static_cast<size_t>(res); 1675 cdlen = static_cast<size_t>(res);
1676 } 1676 }
1677 #endif 1677 #endif
1678 #ifdef CODEC_ISAC_SWB 1678 #ifdef CODEC_ISAC_SWB
1679 else if (coder == webrtc::kDecoderISACswb) { /* iSAC SWB */ 1679 else if (coder == webrtc::NetEqDecoder::kDecoderISACswb) { /* iSAC SWB */
1680 int noOfCalls = 0; 1680 int noOfCalls = 0;
1681 int res = 0; 1681 int res = 0;
1682 while (res <= 0) { 1682 while (res <= 0) {
1683 res = WebRtcIsac_Encode(ISACSWB_inst[k], &indata[noOfCalls * 320], 1683 res = WebRtcIsac_Encode(ISACSWB_inst[k], &indata[noOfCalls * 320],
1684 encoded); 1684 encoded);
1685 noOfCalls++; 1685 noOfCalls++;
1686 } 1686 }
1687 cdlen = static_cast<size_t>(res); 1687 cdlen = static_cast<size_t>(res);
1688 } 1688 }
1689 #endif 1689 #endif
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
1837 memmove(ptrL + stride, ptrL, ptrR - ptrL); 1837 memmove(ptrL + stride, ptrL, ptrR - ptrL);
1838 1838
1839 // copy from temp to left pointer 1839 // copy from temp to left pointer
1840 memcpy(ptrL, temp, stride); 1840 memcpy(ptrL, temp, stride);
1841 1841
1842 // advance pointers 1842 // advance pointers
1843 ptrL += stride * 2; 1843 ptrL += stride * 2;
1844 ptrR += stride; 1844 ptrR += stride;
1845 } 1845 }
1846 } 1846 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698