Chromium Code Reviews| 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 20 matching lines...) Expand all Loading... | |
| 31 // Declare function pointers. | 31 // Declare function pointers. |
| 32 FilterMaLoopFix WebRtcIsacfix_FilterMaLoopFix; | 32 FilterMaLoopFix WebRtcIsacfix_FilterMaLoopFix; |
| 33 Spec2Time WebRtcIsacfix_Spec2Time; | 33 Spec2Time WebRtcIsacfix_Spec2Time; |
| 34 Time2Spec WebRtcIsacfix_Time2Spec; | 34 Time2Spec WebRtcIsacfix_Time2Spec; |
| 35 MatrixProduct1 WebRtcIsacfix_MatrixProduct1; | 35 MatrixProduct1 WebRtcIsacfix_MatrixProduct1; |
| 36 MatrixProduct2 WebRtcIsacfix_MatrixProduct2; | 36 MatrixProduct2 WebRtcIsacfix_MatrixProduct2; |
| 37 | 37 |
| 38 /* This method assumes that |stream_size_bytes| is in valid range, | 38 /* This method assumes that |stream_size_bytes| is in valid range, |
| 39 * i.e. >= 0 && <= STREAM_MAXW16_60MS | 39 * i.e. >= 0 && <= STREAM_MAXW16_60MS |
| 40 */ | 40 */ |
| 41 static void InitializeDecoderBitstream(int stream_size_bytes, | 41 static void InitializeDecoderBitstream(size_t stream_size_bytes, |
| 42 Bitstr_dec* bitstream) { | 42 Bitstr_dec* bitstream) { |
| 43 bitstream->W_upper = 0xFFFFFFFF; | 43 bitstream->W_upper = 0xFFFFFFFF; |
| 44 bitstream->streamval = 0; | 44 bitstream->streamval = 0; |
| 45 bitstream->stream_index = 0; | 45 bitstream->stream_index = 0; |
| 46 bitstream->full = 1; | 46 bitstream->full = 1; |
| 47 bitstream->stream_size = (stream_size_bytes + 1) >> 1; | 47 bitstream->stream_size = (stream_size_bytes + 1) >> 1; |
| 48 memset(bitstream->stream, 0, sizeof(bitstream->stream)); | 48 memset(bitstream->stream, 0, sizeof(bitstream->stream)); |
| 49 } | 49 } |
| 50 | 50 |
| 51 /************************************************************************** | 51 /************************************************************************** |
| (...skipping 562 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 614 * - rtp_seq_number : the RTP number of the packet. | 614 * - rtp_seq_number : the RTP number of the packet. |
| 615 * - arr_ts : the arrival time of the packet (from NetEq) | 615 * - arr_ts : the arrival time of the packet (from NetEq) |
| 616 * in samples. | 616 * in samples. |
| 617 * | 617 * |
| 618 * Return value : 0 - Ok | 618 * Return value : 0 - Ok |
| 619 * -1 - Error | 619 * -1 - Error |
| 620 */ | 620 */ |
| 621 | 621 |
| 622 int16_t WebRtcIsacfix_UpdateBwEstimate1(ISACFIX_MainStruct *ISAC_main_inst, | 622 int16_t WebRtcIsacfix_UpdateBwEstimate1(ISACFIX_MainStruct *ISAC_main_inst, |
| 623 const uint8_t* encoded, | 623 const uint8_t* encoded, |
| 624 int32_t packet_size, | 624 size_t packet_size, |
| 625 uint16_t rtp_seq_number, | 625 uint16_t rtp_seq_number, |
| 626 uint32_t arr_ts) | 626 uint32_t arr_ts) |
| 627 { | 627 { |
| 628 ISACFIX_SubStruct *ISAC_inst; | 628 ISACFIX_SubStruct *ISAC_inst; |
| 629 Bitstr_dec streamdata; | 629 Bitstr_dec streamdata; |
| 630 int16_t err; | 630 int16_t err; |
| 631 const int kRequiredEncodedLenBytes = 10; | 631 const size_t kRequiredEncodedLenBytes = 10; |
| 632 | 632 |
| 633 /* typecast pointer to real structure */ | 633 /* typecast pointer to real structure */ |
| 634 ISAC_inst = (ISACFIX_SubStruct *)ISAC_main_inst; | 634 ISAC_inst = (ISACFIX_SubStruct *)ISAC_main_inst; |
| 635 | 635 |
| 636 /* Sanity check of packet length */ | 636 /* Sanity check of packet length */ |
| 637 if (packet_size <= 0) { | 637 if (packet_size == 0) { |
| 638 /* return error code if the packet length is null or less */ | 638 /* return error code if the packet length is null or less */ |
| 639 ISAC_inst->errorcode = ISAC_EMPTY_PACKET; | 639 ISAC_inst->errorcode = ISAC_EMPTY_PACKET; |
| 640 return -1; | 640 return -1; |
| 641 } else if (packet_size > (STREAM_MAXW16<<1)) { | 641 } else if (packet_size > (STREAM_MAXW16<<1)) { |
| 642 /* return error code if length of stream is too long */ | 642 /* return error code if length of stream is too long */ |
| 643 ISAC_inst->errorcode = ISAC_LENGTH_MISMATCH; | 643 ISAC_inst->errorcode = ISAC_LENGTH_MISMATCH; |
| 644 return -1; | 644 return -1; |
| 645 } | 645 } |
| 646 | 646 |
| 647 /* check if decoder initiated */ | 647 /* check if decoder initiated */ |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 686 * - send_ts : Send Time Stamp from RTP header | 686 * - send_ts : Send Time Stamp from RTP header |
| 687 * - arr_ts : the arrival time of the packet (from NetEq) | 687 * - arr_ts : the arrival time of the packet (from NetEq) |
| 688 * in samples. | 688 * in samples. |
| 689 * | 689 * |
| 690 * Return value : 0 - Ok | 690 * Return value : 0 - Ok |
| 691 * -1 - Error | 691 * -1 - Error |
| 692 */ | 692 */ |
| 693 | 693 |
| 694 int16_t WebRtcIsacfix_UpdateBwEstimate(ISACFIX_MainStruct *ISAC_main_inst, | 694 int16_t WebRtcIsacfix_UpdateBwEstimate(ISACFIX_MainStruct *ISAC_main_inst, |
| 695 const uint8_t* encoded, | 695 const uint8_t* encoded, |
| 696 int32_t packet_size, | 696 size_t packet_size, |
| 697 uint16_t rtp_seq_number, | 697 uint16_t rtp_seq_number, |
| 698 uint32_t send_ts, | 698 uint32_t send_ts, |
| 699 uint32_t arr_ts) | 699 uint32_t arr_ts) |
| 700 { | 700 { |
| 701 ISACFIX_SubStruct *ISAC_inst; | 701 ISACFIX_SubStruct *ISAC_inst; |
| 702 Bitstr_dec streamdata; | 702 Bitstr_dec streamdata; |
| 703 int16_t err; | 703 int16_t err; |
| 704 const int kRequiredEncodedLenBytes = 10; | 704 const size_t kRequiredEncodedLenBytes = 10; |
| 705 | 705 |
| 706 /* typecast pointer to real structure */ | 706 /* typecast pointer to real structure */ |
| 707 ISAC_inst = (ISACFIX_SubStruct *)ISAC_main_inst; | 707 ISAC_inst = (ISACFIX_SubStruct *)ISAC_main_inst; |
| 708 | 708 |
| 709 /* Sanity check of packet length */ | 709 /* Sanity check of packet length */ |
| 710 if (packet_size <= 0) { | 710 if (packet_size == 0) { |
| 711 /* return error code if the packet length is null or less */ | 711 /* return error code if the packet length is null or less */ |
| 712 ISAC_inst->errorcode = ISAC_EMPTY_PACKET; | 712 ISAC_inst->errorcode = ISAC_EMPTY_PACKET; |
| 713 return -1; | 713 return -1; |
| 714 } else if (packet_size < kRequiredEncodedLenBytes) { | 714 } else if (packet_size < kRequiredEncodedLenBytes) { |
| 715 ISAC_inst->errorcode = ISAC_PACKET_TOO_SHORT; | 715 ISAC_inst->errorcode = ISAC_PACKET_TOO_SHORT; |
| 716 return -1; | 716 return -1; |
| 717 } else if (packet_size > (STREAM_MAXW16<<1)) { | 717 } else if (packet_size > (STREAM_MAXW16<<1)) { |
| 718 /* return error code if length of stream is too long */ | 718 /* return error code if length of stream is too long */ |
| 719 ISAC_inst->errorcode = ISAC_LENGTH_MISMATCH; | 719 ISAC_inst->errorcode = ISAC_LENGTH_MISMATCH; |
| 720 return -1; | 720 return -1; |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 763 * Output: | 763 * Output: |
| 764 * - decoded : The decoded vector | 764 * - decoded : The decoded vector |
| 765 * | 765 * |
| 766 * Return value : >0 - number of samples in decoded vector | 766 * Return value : >0 - number of samples in decoded vector |
| 767 * -1 - Error | 767 * -1 - Error |
| 768 */ | 768 */ |
| 769 | 769 |
| 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 size_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 size_t number_of_samples; |
| 781 int declen = 0; | 781 int declen_int = 0; |
| 782 size_t declen; | |
| 782 | 783 |
| 783 /* typecast pointer to real structure */ | 784 /* typecast pointer to real structure */ |
| 784 ISAC_inst = (ISACFIX_SubStruct *)ISAC_main_inst; | 785 ISAC_inst = (ISACFIX_SubStruct *)ISAC_main_inst; |
| 785 | 786 |
| 786 /* check if decoder initiated */ | 787 /* check if decoder initiated */ |
| 787 if ((ISAC_inst->initflag & 1) != 1) { | 788 if ((ISAC_inst->initflag & 1) != 1) { |
| 788 ISAC_inst->errorcode = ISAC_DECODER_NOT_INITIATED; | 789 ISAC_inst->errorcode = ISAC_DECODER_NOT_INITIATED; |
| 789 return (-1); | 790 return (-1); |
| 790 } | 791 } |
| 791 | 792 |
| 792 /* Sanity check of packet length */ | 793 /* Sanity check of packet length */ |
| 793 if (len <= 0) { | 794 if (len == 0) { |
| 794 /* return error code if the packet length is null or less */ | 795 /* return error code if the packet length is null or less */ |
| 795 ISAC_inst->errorcode = ISAC_EMPTY_PACKET; | 796 ISAC_inst->errorcode = ISAC_EMPTY_PACKET; |
| 796 return -1; | 797 return -1; |
| 797 } else if (len > (STREAM_MAXW16<<1)) { | 798 } else if (len > (STREAM_MAXW16<<1)) { |
| 798 /* return error code if length of stream is too long */ | 799 /* return error code if length of stream is too long */ |
| 799 ISAC_inst->errorcode = ISAC_LENGTH_MISMATCH; | 800 ISAC_inst->errorcode = ISAC_LENGTH_MISMATCH; |
| 800 return -1; | 801 return -1; |
| 801 } | 802 } |
| 802 | 803 |
| 803 InitializeDecoderBitstream(len, &ISAC_inst->ISACdec_obj.bitstr_obj); | 804 InitializeDecoderBitstream(len, &ISAC_inst->ISACdec_obj.bitstr_obj); |
| 804 | 805 |
| 805 read_be16(encoded, len, ISAC_inst->ISACdec_obj.bitstr_obj.stream); | 806 read_be16(encoded, len, ISAC_inst->ISACdec_obj.bitstr_obj.stream); |
| 806 | 807 |
| 807 /* added for NetEq purposes (VAD/DTX related) */ | 808 /* added for NetEq purposes (VAD/DTX related) */ |
| 808 *speechType=1; | 809 *speechType=1; |
| 809 | 810 |
| 810 declen = WebRtcIsacfix_DecodeImpl(decoded, &ISAC_inst->ISACdec_obj, | 811 declen_int = WebRtcIsacfix_DecodeImpl(decoded, &ISAC_inst->ISACdec_obj, |
| 811 &number_of_samples); | 812 &number_of_samples); |
| 812 if (declen < 0) { | 813 if (declen_int < 0) { |
| 813 /* Some error inside the decoder */ | 814 /* Some error inside the decoder */ |
| 814 ISAC_inst->errorcode = -(int16_t)declen; | 815 ISAC_inst->errorcode = -(int16_t)declen_int; |
| 815 memset(decoded, 0, sizeof(int16_t) * MAX_FRAMESAMPLES); | 816 memset(decoded, 0, sizeof(int16_t) * MAX_FRAMESAMPLES); |
| 816 return -1; | 817 return -1; |
| 817 } | 818 } |
| 819 declen = (size_t)declen_int; | |
| 818 | 820 |
| 819 /* error check */ | 821 /* error check */ |
| 820 | 822 |
| 821 if (declen & 1) { | 823 if (declen & 1) { |
| 822 if (len != declen && | 824 if (len != declen && |
| 823 len != declen + | 825 len != declen + |
| 824 ((ISAC_inst->ISACdec_obj.bitstr_obj.stream[declen >> 1]) & 0xFF)) { | 826 ((ISAC_inst->ISACdec_obj.bitstr_obj.stream[declen >> 1]) & 0xFF)) { |
| 825 ISAC_inst->errorcode = ISAC_LENGTH_MISMATCH; | 827 ISAC_inst->errorcode = ISAC_LENGTH_MISMATCH; |
| 826 memset(decoded, 0, sizeof(int16_t) * number_of_samples); | 828 memset(decoded, 0, sizeof(int16_t) * number_of_samples); |
| 827 return -1; | 829 return -1; |
| 828 } | 830 } |
| 829 } else { | 831 } else { |
| 830 if (len != declen && | 832 if (len != declen && |
| 831 len != declen + | 833 len != declen + |
| 832 ((ISAC_inst->ISACdec_obj.bitstr_obj.stream[declen >> 1]) >> 8)) { | 834 ((ISAC_inst->ISACdec_obj.bitstr_obj.stream[declen >> 1]) >> 8)) { |
| 833 ISAC_inst->errorcode = ISAC_LENGTH_MISMATCH; | 835 ISAC_inst->errorcode = ISAC_LENGTH_MISMATCH; |
| 834 memset(decoded, 0, sizeof(int16_t) * number_of_samples); | 836 memset(decoded, 0, sizeof(int16_t) * number_of_samples); |
| 835 return -1; | 837 return -1; |
| 836 } | 838 } |
| 837 } | 839 } |
| 838 | 840 |
| 839 return number_of_samples; | 841 return (int)number_of_samples; |
| 840 } | 842 } |
| 841 | 843 |
| 842 | 844 |
| 843 | 845 |
| 844 | 846 |
| 845 | 847 |
| 846 /**************************************************************************** | 848 /**************************************************************************** |
| 847 * WebRtcIsacfix_DecodeNb(...) | 849 * WebRtcIsacfix_DecodeNb(...) |
| 848 * | 850 * |
| 849 * This function decodes a ISAC frame in narrow-band (8 kHz sampling). | 851 * This function decodes a ISAC frame in narrow-band (8 kHz sampling). |
| 850 * Output speech length will be a multiple of 240 samples: 240 or 480 samples, | 852 * Output speech length will be a multiple of 240 samples: 240 or 480 samples, |
| 851 * depending on the framesize (30 or 60 ms). | 853 * depending on the framesize (30 or 60 ms). |
| 852 * | 854 * |
| 853 * The function is enabled if WEBRTC_ISAC_FIX_NB_CALLS_ENABLED is defined | 855 * The function is enabled if WEBRTC_ISAC_FIX_NB_CALLS_ENABLED is defined |
| 854 * | 856 * |
| 855 * Input: | 857 * Input: |
| 856 * - ISAC_main_inst : ISAC instance. | 858 * - ISAC_main_inst : ISAC instance. |
| 857 * - encoded : encoded ISAC frame(s) | 859 * - encoded : encoded ISAC frame(s) |
| 858 * - len : bytes in encoded vector | 860 * - len : bytes in encoded vector |
| 859 * | 861 * |
| 860 * Output: | 862 * Output: |
| 861 * - decoded : The decoded vector | 863 * - decoded : The decoded vector |
| 862 * | 864 * |
| 863 * Return value : >0 - number of samples in decoded vector | 865 * Return value : >0 - number of samples in decoded vector |
| 864 * -1 - Error | 866 * -1 - Error |
| 865 */ | 867 */ |
| 866 | 868 |
| 867 #ifdef WEBRTC_ISAC_FIX_NB_CALLS_ENABLED | 869 #ifdef WEBRTC_ISAC_FIX_NB_CALLS_ENABLED |
| 868 int WebRtcIsacfix_DecodeNb(ISACFIX_MainStruct *ISAC_main_inst, | 870 int WebRtcIsacfix_DecodeNb(ISACFIX_MainStruct *ISAC_main_inst, |
| 869 const uint16_t *encoded, | 871 const uint16_t *encoded, |
|
minyue-webrtc
2015/08/12 16:08:08
It seems that the spacing here was not good. Would
Peter Kasting
2015/08/14 22:32:26
Done (in this file)
| |
| 870 int16_t len, | 872 size_t len, |
| 871 int16_t *decoded, | 873 int16_t *decoded, |
| 872 int16_t *speechType) | 874 int16_t *speechType) |
| 873 { | 875 { |
| 874 ISACFIX_SubStruct *ISAC_inst; | 876 ISACFIX_SubStruct *ISAC_inst; |
| 875 /* twice the number of samples (480 or 960), output from decoder */ | 877 /* twice the number of samples (480 or 960), output from decoder */ |
| 876 /* that were actually used in the encoder/decoder (determined on the fly) */ | 878 /* that were actually used in the encoder/decoder (determined on the fly) */ |
| 877 int16_t number_of_samples; | 879 size_t number_of_samples; |
| 878 int declen = 0; | 880 int declen_int = 0; |
| 881 size_t declen; | |
| 879 int16_t dummy[FRAMESAMPLES/2]; | 882 int16_t dummy[FRAMESAMPLES/2]; |
| 880 | 883 |
| 881 | 884 |
| 882 /* typecast pointer to real structure */ | 885 /* typecast pointer to real structure */ |
| 883 ISAC_inst = (ISACFIX_SubStruct *)ISAC_main_inst; | 886 ISAC_inst = (ISACFIX_SubStruct *)ISAC_main_inst; |
| 884 | 887 |
| 885 /* check if decoder initiated */ | 888 /* check if decoder initiated */ |
| 886 if ((ISAC_inst->initflag & 1) != 1) { | 889 if ((ISAC_inst->initflag & 1) != 1) { |
| 887 ISAC_inst->errorcode = ISAC_DECODER_NOT_INITIATED; | 890 ISAC_inst->errorcode = ISAC_DECODER_NOT_INITIATED; |
| 888 return (-1); | 891 return (-1); |
| 889 } | 892 } |
| 890 | 893 |
| 891 if (len <= 0) { | 894 if (len == 0) { |
| 892 /* return error code if the packet length is null or less */ | 895 /* return error code if the packet length is null or less */ |
| 893 ISAC_inst->errorcode = ISAC_EMPTY_PACKET; | 896 ISAC_inst->errorcode = ISAC_EMPTY_PACKET; |
| 894 return -1; | 897 return -1; |
| 895 } else if (len > (STREAM_MAXW16<<1)) { | 898 } else if (len > (STREAM_MAXW16<<1)) { |
| 896 /* return error code if length of stream is too long */ | 899 /* return error code if length of stream is too long */ |
| 897 ISAC_inst->errorcode = ISAC_LENGTH_MISMATCH; | 900 ISAC_inst->errorcode = ISAC_LENGTH_MISMATCH; |
| 898 return -1; | 901 return -1; |
| 899 } | 902 } |
| 900 | 903 |
| 901 InitializeDecoderBitstream(len, &ISAC_inst->ISACdec_obj.bitstr_obj); | 904 InitializeDecoderBitstream(len, &ISAC_inst->ISACdec_obj.bitstr_obj); |
| 902 | 905 |
| 903 read_be16(encoded, len, ISAC_inst->ISACdec_obj.bitstr_obj.stream); | 906 read_be16(encoded, len, ISAC_inst->ISACdec_obj.bitstr_obj.stream); |
| 904 | 907 |
| 905 /* added for NetEq purposes (VAD/DTX related) */ | 908 /* added for NetEq purposes (VAD/DTX related) */ |
| 906 *speechType=1; | 909 *speechType=1; |
| 907 | 910 |
| 908 declen = WebRtcIsacfix_DecodeImpl(decoded, &ISAC_inst->ISACdec_obj, | 911 declen_int = WebRtcIsacfix_DecodeImpl(decoded,&ISAC_inst->ISACdec_obj, |
| 909 &number_of_samples); | 912 &number_of_samples); |
| 910 if (declen < 0) { | 913 if (declen_int < 0) { |
| 911 /* Some error inside the decoder */ | 914 /* Some error inside the decoder */ |
| 912 ISAC_inst->errorcode = -(int16_t)declen; | 915 ISAC_inst->errorcode = -(int16_t)declen_int; |
| 913 memset(decoded, 0, sizeof(int16_t) * FRAMESAMPLES); | 916 memset(decoded, 0, sizeof(int16_t) * FRAMESAMPLES); |
| 914 return -1; | 917 return -1; |
| 915 } | 918 } |
| 919 declen = (size_t)declen_int; | |
| 916 | 920 |
| 917 /* error check */ | 921 /* error check */ |
| 918 | 922 |
| 919 if (declen & 1) { | 923 if (declen & 1) { |
| 920 if (len != declen && | 924 if (len != declen && |
| 921 len != declen + | 925 len != declen + |
| 922 ((ISAC_inst->ISACdec_obj.bitstr_obj.stream[declen >> 1]) & 0xFF)) { | 926 ((ISAC_inst->ISACdec_obj.bitstr_obj.stream[declen >> 1]) & 0xFF)) { |
| 923 ISAC_inst->errorcode = ISAC_LENGTH_MISMATCH; | 927 ISAC_inst->errorcode = ISAC_LENGTH_MISMATCH; |
| 924 memset(decoded, 0, sizeof(int16_t) * number_of_samples); | 928 memset(decoded, 0, sizeof(int16_t) * number_of_samples); |
| 925 return -1; | 929 return -1; |
| 926 } | 930 } |
| 927 } else { | 931 } else { |
| 928 if (len != declen && | 932 if (len != declen && |
| 929 len != declen + | 933 len != declen + |
| 930 ((ISAC_inst->ISACdec_obj.bitstr_obj.stream[declen >>1]) >> 8)) { | 934 ((ISAC_inst->ISACdec_obj.bitstr_obj.stream[declen >>1]) >> 8)) { |
| 931 ISAC_inst->errorcode = ISAC_LENGTH_MISMATCH; | 935 ISAC_inst->errorcode = ISAC_LENGTH_MISMATCH; |
| 932 memset(decoded, 0, sizeof(int16_t) * number_of_samples); | 936 memset(decoded, 0, sizeof(int16_t) * number_of_samples); |
| 933 return -1; | 937 return -1; |
| 934 } | 938 } |
| 935 } | 939 } |
| 936 | 940 |
| 937 WebRtcIsacfix_SplitAndFilter2(decoded, decoded, dummy, &ISAC_inst->ISACdec_obj .decimatorstr_obj); | 941 WebRtcIsacfix_SplitAndFilter2(decoded, decoded, dummy, &ISAC_inst->ISACdec_obj .decimatorstr_obj); |
| 938 | 942 |
| 939 if (number_of_samples>FRAMESAMPLES) { | 943 if (number_of_samples>FRAMESAMPLES) { |
| 940 WebRtcIsacfix_SplitAndFilter2(decoded + FRAMESAMPLES, decoded + FRAMESAMPLES /2, | 944 WebRtcIsacfix_SplitAndFilter2(decoded + FRAMESAMPLES, decoded + FRAMESAMPLES /2, |
| 941 dummy, &ISAC_inst->ISACdec_obj.decimatorstr_ob j); | 945 dummy, &ISAC_inst->ISACdec_obj.decimatorstr_ob j); |
| 942 } | 946 } |
| 943 | 947 |
| 944 return number_of_samples/2; | 948 return (int)(number_of_samples / 2); |
| 945 } | 949 } |
| 946 #endif /* WEBRTC_ISAC_FIX_NB_CALLS_ENABLED */ | 950 #endif /* WEBRTC_ISAC_FIX_NB_CALLS_ENABLED */ |
| 947 | 951 |
| 948 | 952 |
| 949 /**************************************************************************** | 953 /**************************************************************************** |
| 950 * WebRtcIsacfix_DecodePlcNb(...) | 954 * WebRtcIsacfix_DecodePlcNb(...) |
| 951 * | 955 * |
| 952 * This function conducts PLC for ISAC frame(s) in narrow-band (8kHz sampling). | 956 * This function conducts PLC for ISAC frame(s) in narrow-band (8kHz sampling). |
| 953 * Output speech length will be "240*noOfLostFrames" samples | 957 * Output speech length will be "240*noOfLostFrames" samples |
| 954 * that is equevalent of "30*noOfLostFrames" millisecond. | 958 * that is equevalent of "30*noOfLostFrames" millisecond. |
| 955 * | 959 * |
| 956 * The function is enabled if WEBRTC_ISAC_FIX_NB_CALLS_ENABLED is defined | 960 * The function is enabled if WEBRTC_ISAC_FIX_NB_CALLS_ENABLED is defined |
| 957 * | 961 * |
| 958 * Input: | 962 * Input: |
| 959 * - ISAC_main_inst : ISAC instance. | 963 * - ISAC_main_inst : ISAC instance. |
| 960 * - noOfLostFrames : Number of PLC frames (240 sample=30ms) to produce | 964 * - noOfLostFrames : Number of PLC frames (240 sample=30ms) to produce |
| 961 * | 965 * |
| 962 * Output: | 966 * Output: |
| 963 * - decoded : The decoded vector | 967 * - decoded : The decoded vector |
| 964 * | 968 * |
| 965 * Return value : >0 - number of samples in decoded PLC vector | 969 * Return value : Number of samples in decoded PLC vector |
| 966 * -1 - Error | |
| 967 */ | 970 */ |
| 968 | 971 |
| 969 #ifdef WEBRTC_ISAC_FIX_NB_CALLS_ENABLED | 972 #ifdef WEBRTC_ISAC_FIX_NB_CALLS_ENABLED |
| 970 int16_t WebRtcIsacfix_DecodePlcNb(ISACFIX_MainStruct *ISAC_main_inst, | 973 size_t WebRtcIsacfix_DecodePlcNb(ISACFIX_MainStruct *ISAC_main_inst, |
| 971 int16_t *decoded, | 974 int16_t *decoded, |
| 972 int16_t noOfLostFrames ) | 975 size_t noOfLostFrames ) |
| 973 { | 976 { |
| 974 int16_t no_of_samples, declen, k, ok; | 977 size_t no_of_samples, declen, k; |
| 975 int16_t outframeNB[FRAMESAMPLES]; | 978 int16_t outframeNB[FRAMESAMPLES]; |
| 976 int16_t outframeWB[FRAMESAMPLES]; | 979 int16_t outframeWB[FRAMESAMPLES]; |
| 977 int16_t dummy[FRAMESAMPLES/2]; | 980 int16_t dummy[FRAMESAMPLES/2]; |
| 978 | 981 |
| 979 | 982 |
| 980 ISACFIX_SubStruct *ISAC_inst; | 983 ISACFIX_SubStruct *ISAC_inst; |
| 981 /* typecast pointer to real structure */ | 984 /* typecast pointer to real structure */ |
| 982 ISAC_inst = (ISACFIX_SubStruct *)ISAC_main_inst; | 985 ISAC_inst = (ISACFIX_SubStruct *)ISAC_main_inst; |
| 983 | 986 |
| 984 /* Limit number of frames to two = 60 msec. Otherwise we exceed data vectors * / | 987 /* Limit number of frames to two = 60 msec. Otherwise we exceed data vectors * / |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1021 * that is equevalent of "30*noOfLostFrames" millisecond. | 1024 * that is equevalent of "30*noOfLostFrames" millisecond. |
| 1022 * | 1025 * |
| 1023 * Input: | 1026 * Input: |
| 1024 * - ISAC_main_inst : ISAC instance. | 1027 * - ISAC_main_inst : ISAC instance. |
| 1025 * - noOfLostFrames : Number of PLC frames (480sample = 30ms) | 1028 * - noOfLostFrames : Number of PLC frames (480sample = 30ms) |
| 1026 * to produce | 1029 * to produce |
| 1027 * | 1030 * |
| 1028 * Output: | 1031 * Output: |
| 1029 * - decoded : The decoded vector | 1032 * - decoded : The decoded vector |
| 1030 * | 1033 * |
| 1031 * Return value : >0 - number of samples in decoded PLC vector | 1034 * Return value : Number of samples in decoded PLC vector |
| 1032 * -1 - Error | |
| 1033 */ | 1035 */ |
| 1034 | 1036 |
| 1035 int16_t WebRtcIsacfix_DecodePlc(ISACFIX_MainStruct *ISAC_main_inst, | 1037 size_t WebRtcIsacfix_DecodePlc(ISACFIX_MainStruct *ISAC_main_inst, |
| 1036 int16_t *decoded, | 1038 int16_t *decoded, |
| 1037 int16_t noOfLostFrames) | 1039 size_t noOfLostFrames) |
| 1038 { | 1040 { |
| 1039 | 1041 |
| 1040 int16_t no_of_samples, declen, k; | 1042 size_t no_of_samples, declen, k; |
| 1041 int16_t outframe16[MAX_FRAMESAMPLES]; | 1043 int16_t outframe16[MAX_FRAMESAMPLES]; |
| 1042 | 1044 |
| 1043 ISACFIX_SubStruct *ISAC_inst; | 1045 ISACFIX_SubStruct *ISAC_inst; |
| 1044 /* typecast pointer to real structure */ | 1046 /* typecast pointer to real structure */ |
| 1045 ISAC_inst = (ISACFIX_SubStruct *)ISAC_main_inst; | 1047 ISAC_inst = (ISACFIX_SubStruct *)ISAC_main_inst; |
| 1046 | 1048 |
| 1047 /* Limit number of frames to two = 60 msec. Otherwise we exceed data vectors * / | 1049 /* Limit number of frames to two = 60 msec. Otherwise we exceed data vectors * / |
| 1048 if (noOfLostFrames > 2) { | 1050 if (noOfLostFrames > 2) { |
| 1049 noOfLostFrames = 2; | 1051 noOfLostFrames = 2; |
| 1050 } | 1052 } |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1265 * | 1267 * |
| 1266 * Input: | 1268 * Input: |
| 1267 * - encoded : Encoded bitstream | 1269 * - encoded : Encoded bitstream |
| 1268 * | 1270 * |
| 1269 * Output: | 1271 * Output: |
| 1270 * - frameLength : Length of frame in packet (in samples) | 1272 * - frameLength : Length of frame in packet (in samples) |
| 1271 * | 1273 * |
| 1272 */ | 1274 */ |
| 1273 | 1275 |
| 1274 int16_t WebRtcIsacfix_ReadFrameLen(const uint8_t* encoded, | 1276 int16_t WebRtcIsacfix_ReadFrameLen(const uint8_t* encoded, |
| 1275 int encoded_len_bytes, | 1277 size_t encoded_len_bytes, |
| 1276 int16_t* frameLength) | 1278 size_t* frameLength) |
| 1277 { | 1279 { |
| 1278 Bitstr_dec streamdata; | 1280 Bitstr_dec streamdata; |
| 1279 int16_t err; | 1281 int16_t err; |
| 1280 const int kRequiredEncodedLenBytes = 10; | 1282 const size_t kRequiredEncodedLenBytes = 10; |
| 1281 | 1283 |
| 1282 if (encoded_len_bytes < kRequiredEncodedLenBytes) { | 1284 if (encoded_len_bytes < kRequiredEncodedLenBytes) { |
| 1283 return -1; | 1285 return -1; |
| 1284 } | 1286 } |
| 1285 | 1287 |
| 1286 InitializeDecoderBitstream(encoded_len_bytes, &streamdata); | 1288 InitializeDecoderBitstream(encoded_len_bytes, &streamdata); |
| 1287 | 1289 |
| 1288 read_be16(encoded, kRequiredEncodedLenBytes, streamdata.stream); | 1290 read_be16(encoded, kRequiredEncodedLenBytes, streamdata.stream); |
| 1289 | 1291 |
| 1290 /* decode frame length */ | 1292 /* decode frame length */ |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 1304 * Input: | 1306 * Input: |
| 1305 * - encoded : Encoded bitstream | 1307 * - encoded : Encoded bitstream |
| 1306 * | 1308 * |
| 1307 * Output: | 1309 * Output: |
| 1308 * - frameLength : Length of frame in packet (in samples) | 1310 * - frameLength : Length of frame in packet (in samples) |
| 1309 * - rateIndex : Bandwidth estimate in bitstream | 1311 * - rateIndex : Bandwidth estimate in bitstream |
| 1310 * | 1312 * |
| 1311 */ | 1313 */ |
| 1312 | 1314 |
| 1313 int16_t WebRtcIsacfix_ReadBwIndex(const uint8_t* encoded, | 1315 int16_t WebRtcIsacfix_ReadBwIndex(const uint8_t* encoded, |
| 1314 int encoded_len_bytes, | 1316 size_t encoded_len_bytes, |
| 1315 int16_t* rateIndex) | 1317 int16_t* rateIndex) |
| 1316 { | 1318 { |
| 1317 Bitstr_dec streamdata; | 1319 Bitstr_dec streamdata; |
| 1318 int16_t err; | 1320 int16_t err; |
| 1319 const int kRequiredEncodedLenBytes = 10; | 1321 const size_t kRequiredEncodedLenBytes = 10; |
| 1320 | 1322 |
| 1321 if (encoded_len_bytes < kRequiredEncodedLenBytes) { | 1323 if (encoded_len_bytes < kRequiredEncodedLenBytes) { |
| 1322 return -1; | 1324 return -1; |
| 1323 } | 1325 } |
| 1324 | 1326 |
| 1325 InitializeDecoderBitstream(encoded_len_bytes, &streamdata); | 1327 InitializeDecoderBitstream(encoded_len_bytes, &streamdata); |
| 1326 | 1328 |
| 1327 read_be16(encoded, kRequiredEncodedLenBytes, streamdata.stream); | 1329 read_be16(encoded, kRequiredEncodedLenBytes, streamdata.stream); |
| 1328 | 1330 |
| 1329 /* decode frame length, needed to get to the rateIndex in the bitstream */ | 1331 /* decode frame length, needed to get to the rateIndex in the bitstream */ |
| 1330 int16_t frameLength; | 1332 size_t framelength; |
| 1331 err = WebRtcIsacfix_DecodeFrameLen(&streamdata, &frameLength); | 1333 err = WebRtcIsacfix_DecodeFrameLen(&streamdata, &framelength); |
| 1332 if (err<0) // error check | 1334 if (err<0) // error check |
| 1333 return err; | 1335 return err; |
| 1334 | 1336 |
| 1335 /* decode BW estimation */ | 1337 /* decode BW estimation */ |
| 1336 err = WebRtcIsacfix_DecodeSendBandwidth(&streamdata, rateIndex); | 1338 err = WebRtcIsacfix_DecodeSendBandwidth(&streamdata, rateIndex); |
| 1337 if (err<0) // error check | 1339 if (err<0) // error check |
| 1338 return err; | 1340 return err; |
| 1339 | 1341 |
| 1340 return 0; | 1342 return 0; |
| 1341 } | 1343 } |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1550 assert(inst->initflag & 1); // Decoder initialized. | 1552 assert(inst->initflag & 1); // Decoder initialized. |
| 1551 WebRtcIsacfixBw_GetBandwidthInfo(&inst->bwestimator_obj, bwinfo); | 1553 WebRtcIsacfixBw_GetBandwidthInfo(&inst->bwestimator_obj, bwinfo); |
| 1552 } | 1554 } |
| 1553 | 1555 |
| 1554 void WebRtcIsacfix_SetBandwidthInfo(ISACFIX_MainStruct* ISAC_main_inst, | 1556 void WebRtcIsacfix_SetBandwidthInfo(ISACFIX_MainStruct* ISAC_main_inst, |
| 1555 const IsacBandwidthInfo* bwinfo) { | 1557 const IsacBandwidthInfo* bwinfo) { |
| 1556 ISACFIX_SubStruct* inst = (ISACFIX_SubStruct*)ISAC_main_inst; | 1558 ISACFIX_SubStruct* inst = (ISACFIX_SubStruct*)ISAC_main_inst; |
| 1557 assert(inst->initflag & 2); // Encoder initialized. | 1559 assert(inst->initflag & 2); // Encoder initialized. |
| 1558 WebRtcIsacfixBw_SetBandwidthInfo(&inst->bwestimator_obj, bwinfo); | 1560 WebRtcIsacfixBw_SetBandwidthInfo(&inst->bwestimator_obj, bwinfo); |
| 1559 } | 1561 } |
| OLD | NEW |