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 |
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
392 * Output: | 392 * Output: |
393 * - encoded : the encoded data vector | 393 * - encoded : the encoded data vector |
394 * | 394 * |
395 * Return value: | 395 * Return value: |
396 * : >0 - Length (in bytes) of coded data | 396 * : >0 - Length (in bytes) of coded data |
397 * : 0 - The buffer didn't reach the chosen framesize | 397 * : 0 - The buffer didn't reach the chosen framesize |
398 * so it keeps buffering speech samples. | 398 * so it keeps buffering speech samples. |
399 * : -1 - Error | 399 * : -1 - Error |
400 */ | 400 */ |
401 | 401 |
402 int16_t WebRtcIsacfix_Encode(ISACFIX_MainStruct *ISAC_main_inst, | 402 int WebRtcIsacfix_Encode(ISACFIX_MainStruct *ISAC_main_inst, |
403 const int16_t *speechIn, | 403 const int16_t *speechIn, |
404 uint8_t* encoded) | 404 uint8_t* encoded) |
405 { | 405 { |
406 ISACFIX_SubStruct *ISAC_inst; | 406 ISACFIX_SubStruct *ISAC_inst; |
407 int16_t stream_len; | 407 int stream_len; |
408 | 408 |
409 /* typecast pointer to rela structure */ | 409 /* typecast pointer to rela structure */ |
410 ISAC_inst = (ISACFIX_SubStruct *)ISAC_main_inst; | 410 ISAC_inst = (ISACFIX_SubStruct *)ISAC_main_inst; |
411 | 411 |
412 | 412 |
413 /* check if encoder initiated */ | 413 /* check if encoder initiated */ |
414 if ((ISAC_inst->initflag & 2) != 2) { | 414 if ((ISAC_inst->initflag & 2) != 2) { |
415 ISAC_inst->errorcode = ISAC_ENCODER_NOT_INITIATED; | 415 ISAC_inst->errorcode = ISAC_ENCODER_NOT_INITIATED; |
416 return (-1); | 416 return (-1); |
417 } | 417 } |
418 | 418 |
419 stream_len = WebRtcIsacfix_EncodeImpl((int16_t*)speechIn, | 419 stream_len = WebRtcIsacfix_EncodeImpl((int16_t*)speechIn, |
420 &ISAC_inst->ISACenc_obj, | 420 &ISAC_inst->ISACenc_obj, |
421 &ISAC_inst->bwestimator_obj, | 421 &ISAC_inst->bwestimator_obj, |
422 ISAC_inst->CodingMode); | 422 ISAC_inst->CodingMode); |
423 if (stream_len<0) { | 423 if (stream_len<0) { |
424 ISAC_inst->errorcode = - stream_len; | 424 ISAC_inst->errorcode = -(int16_t)stream_len; |
425 return -1; | 425 return -1; |
426 } | 426 } |
427 | 427 |
428 write_be16(ISAC_inst->ISACenc_obj.bitstr_obj.stream, (size_t)stream_len, | 428 write_be16(ISAC_inst->ISACenc_obj.bitstr_obj.stream, (size_t)stream_len, |
429 encoded); | 429 encoded); |
430 return stream_len; | 430 return stream_len; |
431 | 431 |
432 } | 432 } |
433 | 433 |
434 | 434 |
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
760 * - len : bytes in encoded vector | 760 * - len : bytes in encoded vector |
761 * | 761 * |
762 * Output: | 762 * Output: |
763 * - decoded : The decoded vector | 763 * - decoded : The decoded vector |
764 * | 764 * |
765 * Return value : >0 - number of samples in decoded vector | 765 * Return value : >0 - number of samples in decoded vector |
766 * -1 - Error | 766 * -1 - Error |
767 */ | 767 */ |
768 | 768 |
769 | 769 |
770 int16_t WebRtcIsacfix_Decode(ISACFIX_MainStruct* ISAC_main_inst, | 770 int WebRtcIsacfix_Decode(ISACFIX_MainStruct* ISAC_main_inst, |
771 const uint8_t* encoded, | 771 const uint8_t* encoded, |
772 int16_t len, | 772 int16_t len, |
773 int16_t* decoded, | 773 int16_t* decoded, |
774 int16_t* speechType) | 774 int16_t* speechType) |
775 { | 775 { |
776 ISACFIX_SubStruct *ISAC_inst; | 776 ISACFIX_SubStruct *ISAC_inst; |
777 /* number of samples (480 or 960), output from decoder */ | 777 /* number of samples (480 or 960), output from decoder */ |
778 /* that were actually used in the encoder/decoder (determined on the fly) */ | 778 /* that were actually used in the encoder/decoder (determined on the fly) */ |
779 int16_t number_of_samples; | 779 int16_t number_of_samples; |
780 int16_t declen = 0; | 780 int declen = 0; |
781 | 781 |
782 /* typecast pointer to real structure */ | 782 /* typecast pointer to real structure */ |
783 ISAC_inst = (ISACFIX_SubStruct *)ISAC_main_inst; | 783 ISAC_inst = (ISACFIX_SubStruct *)ISAC_main_inst; |
784 | 784 |
785 /* check if decoder initiated */ | 785 /* check if decoder initiated */ |
786 if ((ISAC_inst->initflag & 1) != 1) { | 786 if ((ISAC_inst->initflag & 1) != 1) { |
787 ISAC_inst->errorcode = ISAC_DECODER_NOT_INITIATED; | 787 ISAC_inst->errorcode = ISAC_DECODER_NOT_INITIATED; |
788 return (-1); | 788 return (-1); |
789 } | 789 } |
790 | 790 |
(...skipping 12 matching lines...) Expand all Loading... |
803 | 803 |
804 read_be16(encoded, len, ISAC_inst->ISACdec_obj.bitstr_obj.stream); | 804 read_be16(encoded, len, ISAC_inst->ISACdec_obj.bitstr_obj.stream); |
805 | 805 |
806 /* added for NetEq purposes (VAD/DTX related) */ | 806 /* added for NetEq purposes (VAD/DTX related) */ |
807 *speechType=1; | 807 *speechType=1; |
808 | 808 |
809 declen = WebRtcIsacfix_DecodeImpl(decoded,&ISAC_inst->ISACdec_obj, &number_of_
samples); | 809 declen = WebRtcIsacfix_DecodeImpl(decoded,&ISAC_inst->ISACdec_obj, &number_of_
samples); |
810 | 810 |
811 if (declen < 0) { | 811 if (declen < 0) { |
812 /* Some error inside the decoder */ | 812 /* Some error inside the decoder */ |
813 ISAC_inst->errorcode = -declen; | 813 ISAC_inst->errorcode = -(int16_t)declen; |
814 memset(decoded, 0, sizeof(int16_t) * MAX_FRAMESAMPLES); | 814 memset(decoded, 0, sizeof(int16_t) * MAX_FRAMESAMPLES); |
815 return -1; | 815 return -1; |
816 } | 816 } |
817 | 817 |
818 /* error check */ | 818 /* error check */ |
819 | 819 |
820 if (declen & 0x0001) { | 820 if (declen & 0x0001) { |
821 if (len != declen && len != declen + (((ISAC_inst->ISACdec_obj.bitstr_obj).s
tream[declen>>1]) & 0x00FF) ) { | 821 if (len != declen && len != declen + (((ISAC_inst->ISACdec_obj.bitstr_obj).s
tream[declen>>1]) & 0x00FF) ) { |
822 ISAC_inst->errorcode = ISAC_LENGTH_MISMATCH; | 822 ISAC_inst->errorcode = ISAC_LENGTH_MISMATCH; |
823 memset(decoded, 0, sizeof(int16_t) * number_of_samples); | 823 memset(decoded, 0, sizeof(int16_t) * number_of_samples); |
(...skipping 29 matching lines...) Expand all Loading... |
853 * - len : bytes in encoded vector | 853 * - len : bytes in encoded vector |
854 * | 854 * |
855 * Output: | 855 * Output: |
856 * - decoded : The decoded vector | 856 * - decoded : The decoded vector |
857 * | 857 * |
858 * Return value : >0 - number of samples in decoded vector | 858 * Return value : >0 - number of samples in decoded vector |
859 * -1 - Error | 859 * -1 - Error |
860 */ | 860 */ |
861 | 861 |
862 #ifdef WEBRTC_ISAC_FIX_NB_CALLS_ENABLED | 862 #ifdef WEBRTC_ISAC_FIX_NB_CALLS_ENABLED |
863 int16_t WebRtcIsacfix_DecodeNb(ISACFIX_MainStruct *ISAC_main_inst, | 863 int WebRtcIsacfix_DecodeNb(ISACFIX_MainStruct *ISAC_main_inst, |
864 const uint16_t *encoded, | 864 const uint16_t *encoded, |
865 int16_t len, | 865 int16_t len, |
866 int16_t *decoded, | 866 int16_t *decoded, |
867 int16_t *speechType) | 867 int16_t *speechType) |
868 { | 868 { |
869 ISACFIX_SubStruct *ISAC_inst; | 869 ISACFIX_SubStruct *ISAC_inst; |
870 /* twice the number of samples (480 or 960), output from decoder */ | 870 /* twice the number of samples (480 or 960), output from decoder */ |
871 /* that were actually used in the encoder/decoder (determined on the fly) */ | 871 /* that were actually used in the encoder/decoder (determined on the fly) */ |
872 int16_t number_of_samples; | 872 int16_t number_of_samples; |
873 int16_t declen = 0; | 873 int declen = 0; |
874 int16_t dummy[FRAMESAMPLES/2]; | 874 int16_t dummy[FRAMESAMPLES/2]; |
875 | 875 |
876 | 876 |
877 /* typecast pointer to real structure */ | 877 /* typecast pointer to real structure */ |
878 ISAC_inst = (ISACFIX_SubStruct *)ISAC_main_inst; | 878 ISAC_inst = (ISACFIX_SubStruct *)ISAC_main_inst; |
879 | 879 |
880 /* check if decoder initiated */ | 880 /* check if decoder initiated */ |
881 if ((ISAC_inst->initflag & 1) != 1) { | 881 if ((ISAC_inst->initflag & 1) != 1) { |
882 ISAC_inst->errorcode = ISAC_DECODER_NOT_INITIATED; | 882 ISAC_inst->errorcode = ISAC_DECODER_NOT_INITIATED; |
883 return (-1); | 883 return (-1); |
(...skipping 13 matching lines...) Expand all Loading... |
897 | 897 |
898 read_be16(encoded, len, ISAC_inst->ISACdec_obj.bitstr_obj.stream); | 898 read_be16(encoded, len, ISAC_inst->ISACdec_obj.bitstr_obj.stream); |
899 | 899 |
900 /* added for NetEq purposes (VAD/DTX related) */ | 900 /* added for NetEq purposes (VAD/DTX related) */ |
901 *speechType=1; | 901 *speechType=1; |
902 | 902 |
903 declen = WebRtcIsacfix_DecodeImpl(decoded,&ISAC_inst->ISACdec_obj, &number_of_
samples); | 903 declen = WebRtcIsacfix_DecodeImpl(decoded,&ISAC_inst->ISACdec_obj, &number_of_
samples); |
904 | 904 |
905 if (declen < 0) { | 905 if (declen < 0) { |
906 /* Some error inside the decoder */ | 906 /* Some error inside the decoder */ |
907 ISAC_inst->errorcode = -declen; | 907 ISAC_inst->errorcode = -(int16_t)declen; |
908 memset(decoded, 0, sizeof(int16_t) * FRAMESAMPLES); | 908 memset(decoded, 0, sizeof(int16_t) * FRAMESAMPLES); |
909 return -1; | 909 return -1; |
910 } | 910 } |
911 | 911 |
912 /* error check */ | 912 /* error check */ |
913 | 913 |
914 if (declen & 0x0001) { | 914 if (declen & 0x0001) { |
915 if (len != declen && len != declen + (((ISAC_inst->ISACdec_obj.bitstr_obj).s
tream[declen>>1]) & 0x00FF) ) { | 915 if (len != declen && len != declen + (((ISAC_inst->ISACdec_obj.bitstr_obj).s
tream[declen>>1]) & 0x00FF) ) { |
916 ISAC_inst->errorcode = ISAC_LENGTH_MISMATCH; | 916 ISAC_inst->errorcode = ISAC_LENGTH_MISMATCH; |
917 memset(decoded, 0, sizeof(int16_t) * number_of_samples); | 917 memset(decoded, 0, sizeof(int16_t) * number_of_samples); |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1068 * - ISAC_main_inst : ISAC instance. | 1068 * - ISAC_main_inst : ISAC instance. |
1069 * - rate : limit on the short-term average bit rate, | 1069 * - rate : limit on the short-term average bit rate, |
1070 * in bits/second (between 10000 and 32000) | 1070 * in bits/second (between 10000 and 32000) |
1071 * - framesize : number of milliseconds per frame (30 or 60) | 1071 * - framesize : number of milliseconds per frame (30 or 60) |
1072 * | 1072 * |
1073 * Return value : 0 - ok | 1073 * Return value : 0 - ok |
1074 * -1 - Error | 1074 * -1 - Error |
1075 */ | 1075 */ |
1076 | 1076 |
1077 int16_t WebRtcIsacfix_Control(ISACFIX_MainStruct *ISAC_main_inst, | 1077 int16_t WebRtcIsacfix_Control(ISACFIX_MainStruct *ISAC_main_inst, |
1078 int16_t rate, | 1078 int16_t rate, |
1079 int16_t framesize) | 1079 int framesize) |
1080 { | 1080 { |
1081 ISACFIX_SubStruct *ISAC_inst; | 1081 ISACFIX_SubStruct *ISAC_inst; |
1082 /* typecast pointer to real structure */ | 1082 /* typecast pointer to real structure */ |
1083 ISAC_inst = (ISACFIX_SubStruct *)ISAC_main_inst; | 1083 ISAC_inst = (ISACFIX_SubStruct *)ISAC_main_inst; |
1084 | 1084 |
1085 if (ISAC_inst->CodingMode == 0) | 1085 if (ISAC_inst->CodingMode == 0) |
1086 { | 1086 { |
1087 /* in adaptive mode */ | 1087 /* in adaptive mode */ |
1088 ISAC_inst->errorcode = ISAC_MODE_MISMATCH; | 1088 ISAC_inst->errorcode = ISAC_MODE_MISMATCH; |
1089 return -1; | 1089 return -1; |
1090 } | 1090 } |
1091 | 1091 |
1092 | 1092 |
1093 if (rate >= 10000 && rate <= 32000) | 1093 if (rate >= 10000 && rate <= 32000) |
1094 ISAC_inst->ISACenc_obj.BottleNeck = rate; | 1094 ISAC_inst->ISACenc_obj.BottleNeck = rate; |
1095 else { | 1095 else { |
1096 ISAC_inst->errorcode = ISAC_DISALLOWED_BOTTLENECK; | 1096 ISAC_inst->errorcode = ISAC_DISALLOWED_BOTTLENECK; |
1097 return -1; | 1097 return -1; |
1098 } | 1098 } |
1099 | 1099 |
1100 | 1100 |
1101 | 1101 |
1102 if (framesize == 30 || framesize == 60) | 1102 if (framesize == 30 || framesize == 60) |
1103 ISAC_inst->ISACenc_obj.new_framelength = (FS/1000) * framesize; | 1103 ISAC_inst->ISACenc_obj.new_framelength = (int16_t)((FS/1000) * framesize); |
1104 else { | 1104 else { |
1105 ISAC_inst->errorcode = ISAC_DISALLOWED_FRAME_LENGTH; | 1105 ISAC_inst->errorcode = ISAC_DISALLOWED_FRAME_LENGTH; |
1106 return -1; | 1106 return -1; |
1107 } | 1107 } |
1108 | 1108 |
1109 return 0; | 1109 return 0; |
1110 } | 1110 } |
1111 | 1111 |
1112 | 1112 |
1113 /**************************************************************************** | 1113 /**************************************************************************** |
(...skipping 14 matching lines...) Expand all Loading... |
1128 * - enforceFrameSize : 1 to enforce the given frame-size through out | 1128 * - enforceFrameSize : 1 to enforce the given frame-size through out |
1129 * the adaptation process, 0 to let iSAC change | 1129 * the adaptation process, 0 to let iSAC change |
1130 * the frame-size if required. | 1130 * the frame-size if required. |
1131 * | 1131 * |
1132 * Return value : 0 - ok | 1132 * Return value : 0 - ok |
1133 * -1 - Error | 1133 * -1 - Error |
1134 */ | 1134 */ |
1135 | 1135 |
1136 int16_t WebRtcIsacfix_ControlBwe(ISACFIX_MainStruct *ISAC_main_inst, | 1136 int16_t WebRtcIsacfix_ControlBwe(ISACFIX_MainStruct *ISAC_main_inst, |
1137 int16_t rateBPS, | 1137 int16_t rateBPS, |
1138 int16_t frameSizeMs, | 1138 int frameSizeMs, |
1139 int16_t enforceFrameSize) | 1139 int16_t enforceFrameSize) |
1140 { | 1140 { |
1141 ISACFIX_SubStruct *ISAC_inst; | 1141 ISACFIX_SubStruct *ISAC_inst; |
1142 /* Typecast pointer to real structure */ | 1142 /* Typecast pointer to real structure */ |
1143 ISAC_inst = (ISACFIX_SubStruct *)ISAC_main_inst; | 1143 ISAC_inst = (ISACFIX_SubStruct *)ISAC_main_inst; |
1144 | 1144 |
1145 /* check if encoder initiated */ | 1145 /* check if encoder initiated */ |
1146 if ((ISAC_inst->initflag & 2) != 2) { | 1146 if ((ISAC_inst->initflag & 2) != 2) { |
1147 ISAC_inst->errorcode = ISAC_ENCODER_NOT_INITIATED; | 1147 ISAC_inst->errorcode = ISAC_ENCODER_NOT_INITIATED; |
1148 return (-1); | 1148 return (-1); |
(...skipping 13 matching lines...) Expand all Loading... |
1162 /* if rateBPS is 0, keep the default initial bottleneck value (15000) */ | 1162 /* if rateBPS is 0, keep the default initial bottleneck value (15000) */ |
1163 if ((rateBPS >= 10000) && (rateBPS <= 32000)) { | 1163 if ((rateBPS >= 10000) && (rateBPS <= 32000)) { |
1164 ISAC_inst->bwestimator_obj.sendBwAvg = (((uint32_t)rateBPS) << 7); | 1164 ISAC_inst->bwestimator_obj.sendBwAvg = (((uint32_t)rateBPS) << 7); |
1165 } else if (rateBPS != 0) { | 1165 } else if (rateBPS != 0) { |
1166 ISAC_inst->errorcode = ISAC_DISALLOWED_BOTTLENECK; | 1166 ISAC_inst->errorcode = ISAC_DISALLOWED_BOTTLENECK; |
1167 return -1; | 1167 return -1; |
1168 } | 1168 } |
1169 | 1169 |
1170 /* Set initial framesize. If enforceFrameSize is set the frame size will not c
hange */ | 1170 /* Set initial framesize. If enforceFrameSize is set the frame size will not c
hange */ |
1171 if ((frameSizeMs == 30) || (frameSizeMs == 60)) { | 1171 if ((frameSizeMs == 30) || (frameSizeMs == 60)) { |
1172 ISAC_inst->ISACenc_obj.new_framelength = (FS/1000) * frameSizeMs; | 1172 ISAC_inst->ISACenc_obj.new_framelength = (int16_t)((FS/1000) * frameSizeMs); |
1173 } else { | 1173 } else { |
1174 ISAC_inst->errorcode = ISAC_DISALLOWED_FRAME_LENGTH; | 1174 ISAC_inst->errorcode = ISAC_DISALLOWED_FRAME_LENGTH; |
1175 return -1; | 1175 return -1; |
1176 } | 1176 } |
1177 | 1177 |
1178 return 0; | 1178 return 0; |
1179 } | 1179 } |
1180 | 1180 |
1181 | 1181 |
1182 | 1182 |
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1519 * | 1519 * |
1520 * Output: | 1520 * Output: |
1521 * - version : Pointer to character string | 1521 * - version : Pointer to character string |
1522 * | 1522 * |
1523 */ | 1523 */ |
1524 | 1524 |
1525 void WebRtcIsacfix_version(char *version) | 1525 void WebRtcIsacfix_version(char *version) |
1526 { | 1526 { |
1527 strcpy(version, "3.6.0"); | 1527 strcpy(version, "3.6.0"); |
1528 } | 1528 } |
OLD | NEW |