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

Side by Side Diff: webrtc/modules/audio_coding/codecs/isac/fix/source/isacfix.c

Issue 1235643003: Miscellaneous changes split from https://codereview.webrtc.org/1230503003 . (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: Resync Created 5 years, 5 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 759 matching lines...) Expand 10 before | Expand all | Expand 10 after
770 770
771 int WebRtcIsacfix_Decode(ISACFIX_MainStruct* ISAC_main_inst, 771 int WebRtcIsacfix_Decode(ISACFIX_MainStruct* ISAC_main_inst,
772 const uint8_t* encoded, 772 const uint8_t* encoded,
773 int16_t len, 773 int16_t len,
774 int16_t* decoded, 774 int16_t* decoded,
775 int16_t* speechType) 775 int16_t* speechType)
776 { 776 {
777 ISACFIX_SubStruct *ISAC_inst; 777 ISACFIX_SubStruct *ISAC_inst;
778 /* number of samples (480 or 960), output from decoder */ 778 /* number of samples (480 or 960), output from decoder */
779 /* that were actually used in the encoder/decoder (determined on the fly) */ 779 /* that were actually used in the encoder/decoder (determined on the fly) */
780 int16_t number_of_samples; 780 int16_t number_of_samples;
781 int declen = 0; 781 int declen = 0;
782 782
783 /* typecast pointer to real structure */ 783 /* typecast pointer to real structure */
784 ISAC_inst = (ISACFIX_SubStruct *)ISAC_main_inst; 784 ISAC_inst = (ISACFIX_SubStruct *)ISAC_main_inst;
785 785
786 /* check if decoder initiated */ 786 /* check if decoder initiated */
787 if ((ISAC_inst->initflag & 1) != 1) { 787 if ((ISAC_inst->initflag & 1) != 1) {
788 ISAC_inst->errorcode = ISAC_DECODER_NOT_INITIATED; 788 ISAC_inst->errorcode = ISAC_DECODER_NOT_INITIATED;
789 return (-1); 789 return (-1);
790 } 790 }
791 791
792 /* Sanity check of packet length */ 792 /* Sanity check of packet length */
793 if (len <= 0) { 793 if (len <= 0) {
794 /* return error code if the packet length is null or less */ 794 /* return error code if the packet length is null or less */
795 ISAC_inst->errorcode = ISAC_EMPTY_PACKET; 795 ISAC_inst->errorcode = ISAC_EMPTY_PACKET;
796 return -1; 796 return -1;
797 } else if (len > (STREAM_MAXW16<<1)) { 797 } else if (len > (STREAM_MAXW16<<1)) {
798 /* return error code if length of stream is too long */ 798 /* return error code if length of stream is too long */
799 ISAC_inst->errorcode = ISAC_LENGTH_MISMATCH; 799 ISAC_inst->errorcode = ISAC_LENGTH_MISMATCH;
800 return -1; 800 return -1;
801 } 801 }
802 802
803 InitializeDecoderBitstream(len, &ISAC_inst->ISACdec_obj.bitstr_obj); 803 InitializeDecoderBitstream(len, &ISAC_inst->ISACdec_obj.bitstr_obj);
804 804
805 read_be16(encoded, len, ISAC_inst->ISACdec_obj.bitstr_obj.stream); 805 read_be16(encoded, len, ISAC_inst->ISACdec_obj.bitstr_obj.stream);
806 806
807 /* added for NetEq purposes (VAD/DTX related) */ 807 /* added for NetEq purposes (VAD/DTX related) */
808 *speechType=1; 808 *speechType=1;
809 809
810 declen = WebRtcIsacfix_DecodeImpl(decoded,&ISAC_inst->ISACdec_obj, &number_of_ samples); 810 declen = WebRtcIsacfix_DecodeImpl(decoded, &ISAC_inst->ISACdec_obj,
811 811 &number_of_samples);
812 if (declen < 0) { 812 if (declen < 0) {
813 /* Some error inside the decoder */ 813 /* Some error inside the decoder */
814 ISAC_inst->errorcode = -(int16_t)declen; 814 ISAC_inst->errorcode = -(int16_t)declen;
815 memset(decoded, 0, sizeof(int16_t) * MAX_FRAMESAMPLES); 815 memset(decoded, 0, sizeof(int16_t) * MAX_FRAMESAMPLES);
816 return -1; 816 return -1;
817 } 817 }
818 818
819 /* error check */ 819 /* error check */
820 820
821 if (declen & 0x0001) { 821 if (declen & 1) {
822 if (len != declen && len != declen + (((ISAC_inst->ISACdec_obj.bitstr_obj).s tream[declen>>1]) & 0x00FF) ) { 822 if (len != declen &&
823 len != declen +
824 ((ISAC_inst->ISACdec_obj.bitstr_obj.stream[declen >> 1]) & 0xFF)) {
823 ISAC_inst->errorcode = ISAC_LENGTH_MISMATCH; 825 ISAC_inst->errorcode = ISAC_LENGTH_MISMATCH;
824 memset(decoded, 0, sizeof(int16_t) * number_of_samples); 826 memset(decoded, 0, sizeof(int16_t) * number_of_samples);
825 return -1; 827 return -1;
826 } 828 }
827 } else { 829 } else {
828 if (len != declen && len != declen + (((ISAC_inst->ISACdec_obj.bitstr_obj).s tream[declen>>1]) >> 8) ) { 830 if (len != declen &&
831 len != declen +
832 ((ISAC_inst->ISACdec_obj.bitstr_obj.stream[declen >> 1]) >> 8)) {
829 ISAC_inst->errorcode = ISAC_LENGTH_MISMATCH; 833 ISAC_inst->errorcode = ISAC_LENGTH_MISMATCH;
830 memset(decoded, 0, sizeof(int16_t) * number_of_samples); 834 memset(decoded, 0, sizeof(int16_t) * number_of_samples);
831 return -1; 835 return -1;
832 } 836 }
833 } 837 }
834 838
835 return number_of_samples; 839 return number_of_samples;
836 } 840 }
837 841
838 842
(...skipping 24 matching lines...) Expand all
863 #ifdef WEBRTC_ISAC_FIX_NB_CALLS_ENABLED 867 #ifdef WEBRTC_ISAC_FIX_NB_CALLS_ENABLED
864 int WebRtcIsacfix_DecodeNb(ISACFIX_MainStruct *ISAC_main_inst, 868 int WebRtcIsacfix_DecodeNb(ISACFIX_MainStruct *ISAC_main_inst,
865 const uint16_t *encoded, 869 const uint16_t *encoded,
866 int16_t len, 870 int16_t len,
867 int16_t *decoded, 871 int16_t *decoded,
868 int16_t *speechType) 872 int16_t *speechType)
869 { 873 {
870 ISACFIX_SubStruct *ISAC_inst; 874 ISACFIX_SubStruct *ISAC_inst;
871 /* twice the number of samples (480 or 960), output from decoder */ 875 /* twice the number of samples (480 or 960), output from decoder */
872 /* that were actually used in the encoder/decoder (determined on the fly) */ 876 /* that were actually used in the encoder/decoder (determined on the fly) */
873 int16_t number_of_samples; 877 int16_t number_of_samples;
874 int declen = 0; 878 int declen = 0;
875 int16_t dummy[FRAMESAMPLES/2]; 879 int16_t dummy[FRAMESAMPLES/2];
876 880
877 881
878 /* typecast pointer to real structure */ 882 /* typecast pointer to real structure */
879 ISAC_inst = (ISACFIX_SubStruct *)ISAC_main_inst; 883 ISAC_inst = (ISACFIX_SubStruct *)ISAC_main_inst;
880 884
881 /* check if decoder initiated */ 885 /* check if decoder initiated */
882 if ((ISAC_inst->initflag & 1) != 1) { 886 if ((ISAC_inst->initflag & 1) != 1) {
883 ISAC_inst->errorcode = ISAC_DECODER_NOT_INITIATED; 887 ISAC_inst->errorcode = ISAC_DECODER_NOT_INITIATED;
(...skipping 10 matching lines...) Expand all
894 return -1; 898 return -1;
895 } 899 }
896 900
897 InitializeDecoderBitstream(len, &ISAC_inst->ISACdec_obj.bitstr_obj); 901 InitializeDecoderBitstream(len, &ISAC_inst->ISACdec_obj.bitstr_obj);
898 902
899 read_be16(encoded, len, ISAC_inst->ISACdec_obj.bitstr_obj.stream); 903 read_be16(encoded, len, ISAC_inst->ISACdec_obj.bitstr_obj.stream);
900 904
901 /* added for NetEq purposes (VAD/DTX related) */ 905 /* added for NetEq purposes (VAD/DTX related) */
902 *speechType=1; 906 *speechType=1;
903 907
904 declen = WebRtcIsacfix_DecodeImpl(decoded,&ISAC_inst->ISACdec_obj, &number_of_ samples); 908 declen = WebRtcIsacfix_DecodeImpl(decoded, &ISAC_inst->ISACdec_obj,
905 909 &number_of_samples);
906 if (declen < 0) { 910 if (declen < 0) {
907 /* Some error inside the decoder */ 911 /* Some error inside the decoder */
908 ISAC_inst->errorcode = -(int16_t)declen; 912 ISAC_inst->errorcode = -(int16_t)declen;
909 memset(decoded, 0, sizeof(int16_t) * FRAMESAMPLES); 913 memset(decoded, 0, sizeof(int16_t) * FRAMESAMPLES);
910 return -1; 914 return -1;
911 } 915 }
912 916
913 /* error check */ 917 /* error check */
914 918
915 if (declen & 0x0001) { 919 if (declen & 1) {
916 if (len != declen && len != declen + (((ISAC_inst->ISACdec_obj.bitstr_obj).s tream[declen>>1]) & 0x00FF) ) { 920 if (len != declen &&
921 len != declen +
922 ((ISAC_inst->ISACdec_obj.bitstr_obj.stream[declen >> 1]) & 0xFF)) {
917 ISAC_inst->errorcode = ISAC_LENGTH_MISMATCH; 923 ISAC_inst->errorcode = ISAC_LENGTH_MISMATCH;
918 memset(decoded, 0, sizeof(int16_t) * number_of_samples); 924 memset(decoded, 0, sizeof(int16_t) * number_of_samples);
919 return -1; 925 return -1;
920 } 926 }
921 } else { 927 } else {
922 if (len != declen && len != declen + (((ISAC_inst->ISACdec_obj.bitstr_obj).s tream[declen>>1]) >> 8) ) { 928 if (len != declen &&
929 len != declen +
930 ((ISAC_inst->ISACdec_obj.bitstr_obj.stream[declen >>1]) >> 8)) {
923 ISAC_inst->errorcode = ISAC_LENGTH_MISMATCH; 931 ISAC_inst->errorcode = ISAC_LENGTH_MISMATCH;
924 memset(decoded, 0, sizeof(int16_t) * number_of_samples); 932 memset(decoded, 0, sizeof(int16_t) * number_of_samples);
925 return -1; 933 return -1;
926 } 934 }
927 } 935 }
928 936
929 WebRtcIsacfix_SplitAndFilter2(decoded, decoded, dummy, &ISAC_inst->ISACdec_obj .decimatorstr_obj); 937 WebRtcIsacfix_SplitAndFilter2(decoded, decoded, dummy, &ISAC_inst->ISACdec_obj .decimatorstr_obj);
930 938
931 if (number_of_samples>FRAMESAMPLES) { 939 if (number_of_samples>FRAMESAMPLES) {
932 WebRtcIsacfix_SplitAndFilter2(decoded + FRAMESAMPLES, decoded + FRAMESAMPLES /2, 940 WebRtcIsacfix_SplitAndFilter2(decoded + FRAMESAMPLES, decoded + FRAMESAMPLES /2,
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after
1312 1320
1313 if (encoded_len_bytes < kRequiredEncodedLenBytes) { 1321 if (encoded_len_bytes < kRequiredEncodedLenBytes) {
1314 return -1; 1322 return -1;
1315 } 1323 }
1316 1324
1317 InitializeDecoderBitstream(encoded_len_bytes, &streamdata); 1325 InitializeDecoderBitstream(encoded_len_bytes, &streamdata);
1318 1326
1319 read_be16(encoded, kRequiredEncodedLenBytes, streamdata.stream); 1327 read_be16(encoded, kRequiredEncodedLenBytes, streamdata.stream);
1320 1328
1321 /* decode frame length, needed to get to the rateIndex in the bitstream */ 1329 /* decode frame length, needed to get to the rateIndex in the bitstream */
1322 err = WebRtcIsacfix_DecodeFrameLen(&streamdata, rateIndex); 1330 int16_t frameLength;
1331 err = WebRtcIsacfix_DecodeFrameLen(&streamdata, &frameLength);
1323 if (err<0) // error check 1332 if (err<0) // error check
1324 return err; 1333 return err;
1325 1334
1326 /* decode BW estimation */ 1335 /* decode BW estimation */
1327 err = WebRtcIsacfix_DecodeSendBandwidth(&streamdata, rateIndex); 1336 err = WebRtcIsacfix_DecodeSendBandwidth(&streamdata, rateIndex);
1328 if (err<0) // error check 1337 if (err<0) // error check
1329 return err; 1338 return err;
1330 1339
1331 return 0; 1340 return 0;
1332 } 1341 }
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
1541 assert(inst->initflag & 1); // Decoder initialized. 1550 assert(inst->initflag & 1); // Decoder initialized.
1542 WebRtcIsacfixBw_GetBandwidthInfo(&inst->bwestimator_obj, bwinfo); 1551 WebRtcIsacfixBw_GetBandwidthInfo(&inst->bwestimator_obj, bwinfo);
1543 } 1552 }
1544 1553
1545 void WebRtcIsacfix_SetBandwidthInfo(ISACFIX_MainStruct* ISAC_main_inst, 1554 void WebRtcIsacfix_SetBandwidthInfo(ISACFIX_MainStruct* ISAC_main_inst,
1546 const IsacBandwidthInfo* bwinfo) { 1555 const IsacBandwidthInfo* bwinfo) {
1547 ISACFIX_SubStruct* inst = (ISACFIX_SubStruct*)ISAC_main_inst; 1556 ISACFIX_SubStruct* inst = (ISACFIX_SubStruct*)ISAC_main_inst;
1548 assert(inst->initflag & 2); // Encoder initialized. 1557 assert(inst->initflag & 2); // Encoder initialized.
1549 WebRtcIsacfixBw_SetBandwidthInfo(&inst->bwestimator_obj, bwinfo); 1558 WebRtcIsacfixBw_SetBandwidthInfo(&inst->bwestimator_obj, bwinfo);
1550 } 1559 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698