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

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

Issue 1227163003: Update audio code to use size_t more correctly, (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: Review comments Created 5 years, 4 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 20 matching lines...) Expand all
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 557 matching lines...) Expand 10 before | Expand all | Expand 10 after
609 * - rtp_seq_number : the RTP number of the packet. 609 * - rtp_seq_number : the RTP number of the packet.
610 * - arr_ts : the arrival time of the packet (from NetEq) 610 * - arr_ts : the arrival time of the packet (from NetEq)
611 * in samples. 611 * in samples.
612 * 612 *
613 * Return value : 0 - Ok 613 * Return value : 0 - Ok
614 * -1 - Error 614 * -1 - Error
615 */ 615 */
616 616
617 int16_t WebRtcIsacfix_UpdateBwEstimate1(ISACFIX_MainStruct *ISAC_main_inst, 617 int16_t WebRtcIsacfix_UpdateBwEstimate1(ISACFIX_MainStruct *ISAC_main_inst,
618 const uint8_t* encoded, 618 const uint8_t* encoded,
619 int32_t packet_size, 619 size_t packet_size,
620 uint16_t rtp_seq_number, 620 uint16_t rtp_seq_number,
621 uint32_t arr_ts) 621 uint32_t arr_ts)
622 { 622 {
623 ISACFIX_SubStruct *ISAC_inst; 623 ISACFIX_SubStruct *ISAC_inst;
624 Bitstr_dec streamdata; 624 Bitstr_dec streamdata;
625 int16_t err; 625 int16_t err;
626 const int kRequiredEncodedLenBytes = 10; 626 const size_t kRequiredEncodedLenBytes = 10;
627 627
628 /* typecast pointer to real structure */ 628 /* typecast pointer to real structure */
629 ISAC_inst = (ISACFIX_SubStruct *)ISAC_main_inst; 629 ISAC_inst = (ISACFIX_SubStruct *)ISAC_main_inst;
630 630
631 /* Sanity check of packet length */ 631 /* Sanity check of packet length */
632 if (packet_size <= 0) { 632 if (packet_size == 0) {
633 /* return error code if the packet length is null or less */ 633 /* return error code if the packet length is null or less */
634 ISAC_inst->errorcode = ISAC_EMPTY_PACKET; 634 ISAC_inst->errorcode = ISAC_EMPTY_PACKET;
635 return -1; 635 return -1;
636 } else if (packet_size > (STREAM_MAXW16<<1)) { 636 } else if (packet_size > (STREAM_MAXW16<<1)) {
637 /* return error code if length of stream is too long */ 637 /* return error code if length of stream is too long */
638 ISAC_inst->errorcode = ISAC_LENGTH_MISMATCH; 638 ISAC_inst->errorcode = ISAC_LENGTH_MISMATCH;
639 return -1; 639 return -1;
640 } 640 }
641 641
642 /* check if decoder initiated */ 642 /* check if decoder initiated */
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
681 * - send_ts : Send Time Stamp from RTP header 681 * - send_ts : Send Time Stamp from RTP header
682 * - arr_ts : the arrival time of the packet (from NetEq) 682 * - arr_ts : the arrival time of the packet (from NetEq)
683 * in samples. 683 * in samples.
684 * 684 *
685 * Return value : 0 - Ok 685 * Return value : 0 - Ok
686 * -1 - Error 686 * -1 - Error
687 */ 687 */
688 688
689 int16_t WebRtcIsacfix_UpdateBwEstimate(ISACFIX_MainStruct *ISAC_main_inst, 689 int16_t WebRtcIsacfix_UpdateBwEstimate(ISACFIX_MainStruct *ISAC_main_inst,
690 const uint8_t* encoded, 690 const uint8_t* encoded,
691 int32_t packet_size, 691 size_t packet_size,
692 uint16_t rtp_seq_number, 692 uint16_t rtp_seq_number,
693 uint32_t send_ts, 693 uint32_t send_ts,
694 uint32_t arr_ts) 694 uint32_t arr_ts)
695 { 695 {
696 ISACFIX_SubStruct *ISAC_inst; 696 ISACFIX_SubStruct *ISAC_inst;
697 Bitstr_dec streamdata; 697 Bitstr_dec streamdata;
698 int16_t err; 698 int16_t err;
699 const int kRequiredEncodedLenBytes = 10; 699 const size_t kRequiredEncodedLenBytes = 10;
700 700
701 /* typecast pointer to real structure */ 701 /* typecast pointer to real structure */
702 ISAC_inst = (ISACFIX_SubStruct *)ISAC_main_inst; 702 ISAC_inst = (ISACFIX_SubStruct *)ISAC_main_inst;
703 703
704 /* Sanity check of packet length */ 704 /* Sanity check of packet length */
705 if (packet_size <= 0) { 705 if (packet_size == 0) {
706 /* return error code if the packet length is null or less */ 706 /* return error code if the packet length is null or less */
707 ISAC_inst->errorcode = ISAC_EMPTY_PACKET; 707 ISAC_inst->errorcode = ISAC_EMPTY_PACKET;
708 return -1; 708 return -1;
709 } else if (packet_size < kRequiredEncodedLenBytes) { 709 } else if (packet_size < kRequiredEncodedLenBytes) {
710 ISAC_inst->errorcode = ISAC_PACKET_TOO_SHORT; 710 ISAC_inst->errorcode = ISAC_PACKET_TOO_SHORT;
711 return -1; 711 return -1;
712 } else if (packet_size > (STREAM_MAXW16<<1)) { 712 } else if (packet_size > (STREAM_MAXW16<<1)) {
713 /* return error code if length of stream is too long */ 713 /* return error code if length of stream is too long */
714 ISAC_inst->errorcode = ISAC_LENGTH_MISMATCH; 714 ISAC_inst->errorcode = ISAC_LENGTH_MISMATCH;
715 return -1; 715 return -1;
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
758 * Output: 758 * Output:
759 * - decoded : The decoded vector 759 * - decoded : The decoded vector
760 * 760 *
761 * Return value : >0 - number of samples in decoded vector 761 * Return value : >0 - number of samples in decoded vector
762 * -1 - Error 762 * -1 - Error
763 */ 763 */
764 764
765 765
766 int WebRtcIsacfix_Decode(ISACFIX_MainStruct* ISAC_main_inst, 766 int WebRtcIsacfix_Decode(ISACFIX_MainStruct* ISAC_main_inst,
767 const uint8_t* encoded, 767 const uint8_t* encoded,
768 int16_t len, 768 size_t len,
769 int16_t* decoded, 769 int16_t* decoded,
770 int16_t* speechType) 770 int16_t* speechType)
771 { 771 {
772 ISACFIX_SubStruct *ISAC_inst; 772 ISACFIX_SubStruct *ISAC_inst;
773 /* number of samples (480 or 960), output from decoder */ 773 /* number of samples (480 or 960), output from decoder */
774 /* that were actually used in the encoder/decoder (determined on the fly) */ 774 /* that were actually used in the encoder/decoder (determined on the fly) */
775 int16_t number_of_samples; 775 size_t number_of_samples;
776 int declen = 0; 776 int declen_int = 0;
777 size_t declen;
777 778
778 /* typecast pointer to real structure */ 779 /* typecast pointer to real structure */
779 ISAC_inst = (ISACFIX_SubStruct *)ISAC_main_inst; 780 ISAC_inst = (ISACFIX_SubStruct *)ISAC_main_inst;
780 781
781 /* check if decoder initiated */ 782 /* check if decoder initiated */
782 if ((ISAC_inst->initflag & 1) != 1) { 783 if ((ISAC_inst->initflag & 1) != 1) {
783 ISAC_inst->errorcode = ISAC_DECODER_NOT_INITIATED; 784 ISAC_inst->errorcode = ISAC_DECODER_NOT_INITIATED;
784 return (-1); 785 return (-1);
785 } 786 }
786 787
787 /* Sanity check of packet length */ 788 /* Sanity check of packet length */
788 if (len <= 0) { 789 if (len == 0) {
789 /* return error code if the packet length is null or less */ 790 /* return error code if the packet length is null or less */
790 ISAC_inst->errorcode = ISAC_EMPTY_PACKET; 791 ISAC_inst->errorcode = ISAC_EMPTY_PACKET;
791 return -1; 792 return -1;
792 } else if (len > (STREAM_MAXW16<<1)) { 793 } else if (len > (STREAM_MAXW16<<1)) {
793 /* return error code if length of stream is too long */ 794 /* return error code if length of stream is too long */
794 ISAC_inst->errorcode = ISAC_LENGTH_MISMATCH; 795 ISAC_inst->errorcode = ISAC_LENGTH_MISMATCH;
795 return -1; 796 return -1;
796 } 797 }
797 798
798 InitializeDecoderBitstream(len, &ISAC_inst->ISACdec_obj.bitstr_obj); 799 InitializeDecoderBitstream(len, &ISAC_inst->ISACdec_obj.bitstr_obj);
799 800
800 read_be16(encoded, len, ISAC_inst->ISACdec_obj.bitstr_obj.stream); 801 read_be16(encoded, len, ISAC_inst->ISACdec_obj.bitstr_obj.stream);
801 802
802 /* added for NetEq purposes (VAD/DTX related) */ 803 /* added for NetEq purposes (VAD/DTX related) */
803 *speechType=1; 804 *speechType=1;
804 805
805 declen = WebRtcIsacfix_DecodeImpl(decoded, &ISAC_inst->ISACdec_obj, 806 declen_int = WebRtcIsacfix_DecodeImpl(decoded, &ISAC_inst->ISACdec_obj,
806 &number_of_samples); 807 &number_of_samples);
807 if (declen < 0) { 808 if (declen_int < 0) {
808 /* Some error inside the decoder */ 809 /* Some error inside the decoder */
809 ISAC_inst->errorcode = -(int16_t)declen; 810 ISAC_inst->errorcode = -(int16_t)declen_int;
810 memset(decoded, 0, sizeof(int16_t) * MAX_FRAMESAMPLES); 811 memset(decoded, 0, sizeof(int16_t) * MAX_FRAMESAMPLES);
811 return -1; 812 return -1;
812 } 813 }
814 declen = (size_t)declen_int;
813 815
814 /* error check */ 816 /* error check */
815 817
816 if (declen & 1) { 818 if (declen & 1) {
817 if (len != declen && 819 if (len != declen &&
818 len != declen + 820 len != declen +
819 ((ISAC_inst->ISACdec_obj.bitstr_obj.stream[declen >> 1]) & 0xFF)) { 821 ((ISAC_inst->ISACdec_obj.bitstr_obj.stream[declen >> 1]) & 0xFF)) {
820 ISAC_inst->errorcode = ISAC_LENGTH_MISMATCH; 822 ISAC_inst->errorcode = ISAC_LENGTH_MISMATCH;
821 memset(decoded, 0, sizeof(int16_t) * number_of_samples); 823 memset(decoded, 0, sizeof(int16_t) * number_of_samples);
822 return -1; 824 return -1;
823 } 825 }
824 } else { 826 } else {
825 if (len != declen && 827 if (len != declen &&
826 len != declen + 828 len != declen +
827 ((ISAC_inst->ISACdec_obj.bitstr_obj.stream[declen >> 1]) >> 8)) { 829 ((ISAC_inst->ISACdec_obj.bitstr_obj.stream[declen >> 1]) >> 8)) {
828 ISAC_inst->errorcode = ISAC_LENGTH_MISMATCH; 830 ISAC_inst->errorcode = ISAC_LENGTH_MISMATCH;
829 memset(decoded, 0, sizeof(int16_t) * number_of_samples); 831 memset(decoded, 0, sizeof(int16_t) * number_of_samples);
830 return -1; 832 return -1;
831 } 833 }
832 } 834 }
833 835
834 return number_of_samples; 836 return (int)number_of_samples;
835 } 837 }
836 838
837 839
838 840
839 841
840 842
841 /**************************************************************************** 843 /****************************************************************************
842 * WebRtcIsacfix_DecodeNb(...) 844 * WebRtcIsacfix_DecodeNb(...)
843 * 845 *
844 * This function decodes a ISAC frame in narrow-band (8 kHz sampling). 846 * This function decodes a ISAC frame in narrow-band (8 kHz sampling).
845 * Output speech length will be a multiple of 240 samples: 240 or 480 samples, 847 * Output speech length will be a multiple of 240 samples: 240 or 480 samples,
846 * depending on the framesize (30 or 60 ms). 848 * depending on the framesize (30 or 60 ms).
847 * 849 *
848 * The function is enabled if WEBRTC_ISAC_FIX_NB_CALLS_ENABLED is defined 850 * The function is enabled if WEBRTC_ISAC_FIX_NB_CALLS_ENABLED is defined
849 * 851 *
850 * Input: 852 * Input:
851 * - ISAC_main_inst : ISAC instance. 853 * - ISAC_main_inst : ISAC instance.
852 * - encoded : encoded ISAC frame(s) 854 * - encoded : encoded ISAC frame(s)
853 * - len : bytes in encoded vector 855 * - len : bytes in encoded vector
854 * 856 *
855 * Output: 857 * Output:
856 * - decoded : The decoded vector 858 * - decoded : The decoded vector
857 * 859 *
858 * Return value : >0 - number of samples in decoded vector 860 * Return value : >0 - number of samples in decoded vector
859 * -1 - Error 861 * -1 - Error
860 */ 862 */
861 863
862 #ifdef WEBRTC_ISAC_FIX_NB_CALLS_ENABLED 864 #ifdef WEBRTC_ISAC_FIX_NB_CALLS_ENABLED
863 int WebRtcIsacfix_DecodeNb(ISACFIX_MainStruct *ISAC_main_inst, 865 int WebRtcIsacfix_DecodeNb(ISACFIX_MainStruct* ISAC_main_inst,
864 const uint16_t *encoded, 866 const uint16_t* encoded,
865 int16_t len, 867 size_t len,
866 int16_t *decoded, 868 int16_t* decoded,
867 int16_t *speechType) 869 int16_t* speechType)
868 { 870 {
869 ISACFIX_SubStruct *ISAC_inst; 871 ISACFIX_SubStruct *ISAC_inst;
870 /* twice the number of samples (480 or 960), output from decoder */ 872 /* twice the number of samples (480 or 960), output from decoder */
871 /* that were actually used in the encoder/decoder (determined on the fly) */ 873 /* that were actually used in the encoder/decoder (determined on the fly) */
872 int16_t number_of_samples; 874 size_t number_of_samples;
873 int declen = 0; 875 int declen_int = 0;
876 size_t declen;
874 int16_t dummy[FRAMESAMPLES/2]; 877 int16_t dummy[FRAMESAMPLES/2];
875 878
876 879
877 /* typecast pointer to real structure */ 880 /* typecast pointer to real structure */
878 ISAC_inst = (ISACFIX_SubStruct *)ISAC_main_inst; 881 ISAC_inst = (ISACFIX_SubStruct *)ISAC_main_inst;
879 882
880 /* check if decoder initiated */ 883 /* check if decoder initiated */
881 if ((ISAC_inst->initflag & 1) != 1) { 884 if ((ISAC_inst->initflag & 1) != 1) {
882 ISAC_inst->errorcode = ISAC_DECODER_NOT_INITIATED; 885 ISAC_inst->errorcode = ISAC_DECODER_NOT_INITIATED;
883 return (-1); 886 return (-1);
884 } 887 }
885 888
886 if (len <= 0) { 889 if (len == 0) {
887 /* return error code if the packet length is null or less */ 890 /* return error code if the packet length is null or less */
888 ISAC_inst->errorcode = ISAC_EMPTY_PACKET; 891 ISAC_inst->errorcode = ISAC_EMPTY_PACKET;
889 return -1; 892 return -1;
890 } else if (len > (STREAM_MAXW16<<1)) { 893 } else if (len > (STREAM_MAXW16<<1)) {
891 /* return error code if length of stream is too long */ 894 /* return error code if length of stream is too long */
892 ISAC_inst->errorcode = ISAC_LENGTH_MISMATCH; 895 ISAC_inst->errorcode = ISAC_LENGTH_MISMATCH;
893 return -1; 896 return -1;
894 } 897 }
895 898
896 InitializeDecoderBitstream(len, &ISAC_inst->ISACdec_obj.bitstr_obj); 899 InitializeDecoderBitstream(len, &ISAC_inst->ISACdec_obj.bitstr_obj);
897 900
898 read_be16(encoded, len, ISAC_inst->ISACdec_obj.bitstr_obj.stream); 901 read_be16(encoded, len, ISAC_inst->ISACdec_obj.bitstr_obj.stream);
899 902
900 /* added for NetEq purposes (VAD/DTX related) */ 903 /* added for NetEq purposes (VAD/DTX related) */
901 *speechType=1; 904 *speechType=1;
902 905
903 declen = WebRtcIsacfix_DecodeImpl(decoded, &ISAC_inst->ISACdec_obj, 906 declen_int = WebRtcIsacfix_DecodeImpl(decoded,&ISAC_inst->ISACdec_obj,
904 &number_of_samples); 907 &number_of_samples);
905 if (declen < 0) { 908 if (declen_int < 0) {
906 /* Some error inside the decoder */ 909 /* Some error inside the decoder */
907 ISAC_inst->errorcode = -(int16_t)declen; 910 ISAC_inst->errorcode = -(int16_t)declen_int;
908 memset(decoded, 0, sizeof(int16_t) * FRAMESAMPLES); 911 memset(decoded, 0, sizeof(int16_t) * FRAMESAMPLES);
909 return -1; 912 return -1;
910 } 913 }
914 declen = (size_t)declen_int;
911 915
912 /* error check */ 916 /* error check */
913 917
914 if (declen & 1) { 918 if (declen & 1) {
915 if (len != declen && 919 if (len != declen &&
916 len != declen + 920 len != declen +
917 ((ISAC_inst->ISACdec_obj.bitstr_obj.stream[declen >> 1]) & 0xFF)) { 921 ((ISAC_inst->ISACdec_obj.bitstr_obj.stream[declen >> 1]) & 0xFF)) {
918 ISAC_inst->errorcode = ISAC_LENGTH_MISMATCH; 922 ISAC_inst->errorcode = ISAC_LENGTH_MISMATCH;
919 memset(decoded, 0, sizeof(int16_t) * number_of_samples); 923 memset(decoded, 0, sizeof(int16_t) * number_of_samples);
920 return -1; 924 return -1;
921 } 925 }
922 } else { 926 } else {
923 if (len != declen && 927 if (len != declen &&
924 len != declen + 928 len != declen +
925 ((ISAC_inst->ISACdec_obj.bitstr_obj.stream[declen >>1]) >> 8)) { 929 ((ISAC_inst->ISACdec_obj.bitstr_obj.stream[declen >>1]) >> 8)) {
926 ISAC_inst->errorcode = ISAC_LENGTH_MISMATCH; 930 ISAC_inst->errorcode = ISAC_LENGTH_MISMATCH;
927 memset(decoded, 0, sizeof(int16_t) * number_of_samples); 931 memset(decoded, 0, sizeof(int16_t) * number_of_samples);
928 return -1; 932 return -1;
929 } 933 }
930 } 934 }
931 935
932 WebRtcIsacfix_SplitAndFilter2(decoded, decoded, dummy, &ISAC_inst->ISACdec_obj .decimatorstr_obj); 936 WebRtcIsacfix_SplitAndFilter2(decoded, decoded, dummy, &ISAC_inst->ISACdec_obj .decimatorstr_obj);
933 937
934 if (number_of_samples>FRAMESAMPLES) { 938 if (number_of_samples>FRAMESAMPLES) {
935 WebRtcIsacfix_SplitAndFilter2(decoded + FRAMESAMPLES, decoded + FRAMESAMPLES /2, 939 WebRtcIsacfix_SplitAndFilter2(decoded + FRAMESAMPLES, decoded + FRAMESAMPLES /2,
936 dummy, &ISAC_inst->ISACdec_obj.decimatorstr_ob j); 940 dummy, &ISAC_inst->ISACdec_obj.decimatorstr_ob j);
937 } 941 }
938 942
939 return number_of_samples/2; 943 return (int)(number_of_samples / 2);
940 } 944 }
941 #endif /* WEBRTC_ISAC_FIX_NB_CALLS_ENABLED */ 945 #endif /* WEBRTC_ISAC_FIX_NB_CALLS_ENABLED */
942 946
943 947
944 /**************************************************************************** 948 /****************************************************************************
945 * WebRtcIsacfix_DecodePlcNb(...) 949 * WebRtcIsacfix_DecodePlcNb(...)
946 * 950 *
947 * This function conducts PLC for ISAC frame(s) in narrow-band (8kHz sampling). 951 * This function conducts PLC for ISAC frame(s) in narrow-band (8kHz sampling).
948 * Output speech length will be "240*noOfLostFrames" samples 952 * Output speech length will be "240*noOfLostFrames" samples
949 * that is equevalent of "30*noOfLostFrames" millisecond. 953 * that is equevalent of "30*noOfLostFrames" millisecond.
950 * 954 *
951 * The function is enabled if WEBRTC_ISAC_FIX_NB_CALLS_ENABLED is defined 955 * The function is enabled if WEBRTC_ISAC_FIX_NB_CALLS_ENABLED is defined
952 * 956 *
953 * Input: 957 * Input:
954 * - ISAC_main_inst : ISAC instance. 958 * - ISAC_main_inst : ISAC instance.
955 * - noOfLostFrames : Number of PLC frames (240 sample=30ms) to produce 959 * - noOfLostFrames : Number of PLC frames (240 sample=30ms) to produce
956 * 960 *
957 * Output: 961 * Output:
958 * - decoded : The decoded vector 962 * - decoded : The decoded vector
959 * 963 *
960 * Return value : >0 - number of samples in decoded PLC vector 964 * Return value : Number of samples in decoded PLC vector
961 * -1 - Error
962 */ 965 */
963 966
964 #ifdef WEBRTC_ISAC_FIX_NB_CALLS_ENABLED 967 #ifdef WEBRTC_ISAC_FIX_NB_CALLS_ENABLED
965 int16_t WebRtcIsacfix_DecodePlcNb(ISACFIX_MainStruct *ISAC_main_inst, 968 size_t WebRtcIsacfix_DecodePlcNb(ISACFIX_MainStruct* ISAC_main_inst,
966 int16_t *decoded, 969 int16_t* decoded,
967 int16_t noOfLostFrames ) 970 size_t noOfLostFrames )
968 { 971 {
969 int16_t no_of_samples, declen, k, ok; 972 size_t no_of_samples, declen, k;
970 int16_t outframeNB[FRAMESAMPLES]; 973 int16_t outframeNB[FRAMESAMPLES];
971 int16_t outframeWB[FRAMESAMPLES]; 974 int16_t outframeWB[FRAMESAMPLES];
972 int16_t dummy[FRAMESAMPLES/2]; 975 int16_t dummy[FRAMESAMPLES/2];
973 976
974 977
975 ISACFIX_SubStruct *ISAC_inst; 978 ISACFIX_SubStruct *ISAC_inst;
976 /* typecast pointer to real structure */ 979 /* typecast pointer to real structure */
977 ISAC_inst = (ISACFIX_SubStruct *)ISAC_main_inst; 980 ISAC_inst = (ISACFIX_SubStruct *)ISAC_main_inst;
978 981
979 /* Limit number of frames to two = 60 msec. Otherwise we exceed data vectors * / 982 /* 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
1016 * that is equevalent of "30*noOfLostFrames" millisecond. 1019 * that is equevalent of "30*noOfLostFrames" millisecond.
1017 * 1020 *
1018 * Input: 1021 * Input:
1019 * - ISAC_main_inst : ISAC instance. 1022 * - ISAC_main_inst : ISAC instance.
1020 * - noOfLostFrames : Number of PLC frames (480sample = 30ms) 1023 * - noOfLostFrames : Number of PLC frames (480sample = 30ms)
1021 * to produce 1024 * to produce
1022 * 1025 *
1023 * Output: 1026 * Output:
1024 * - decoded : The decoded vector 1027 * - decoded : The decoded vector
1025 * 1028 *
1026 * Return value : >0 - number of samples in decoded PLC vector 1029 * Return value : Number of samples in decoded PLC vector
1027 * -1 - Error
1028 */ 1030 */
1029 1031
1030 int16_t WebRtcIsacfix_DecodePlc(ISACFIX_MainStruct *ISAC_main_inst, 1032 size_t WebRtcIsacfix_DecodePlc(ISACFIX_MainStruct* ISAC_main_inst,
1031 int16_t *decoded, 1033 int16_t* decoded,
1032 int16_t noOfLostFrames) 1034 size_t noOfLostFrames)
1033 { 1035 {
1034 1036
1035 int16_t no_of_samples, declen, k; 1037 size_t no_of_samples, declen, k;
1036 int16_t outframe16[MAX_FRAMESAMPLES]; 1038 int16_t outframe16[MAX_FRAMESAMPLES];
1037 1039
1038 ISACFIX_SubStruct *ISAC_inst; 1040 ISACFIX_SubStruct *ISAC_inst;
1039 /* typecast pointer to real structure */ 1041 /* typecast pointer to real structure */
1040 ISAC_inst = (ISACFIX_SubStruct *)ISAC_main_inst; 1042 ISAC_inst = (ISACFIX_SubStruct *)ISAC_main_inst;
1041 1043
1042 /* Limit number of frames to two = 60 msec. Otherwise we exceed data vectors * / 1044 /* Limit number of frames to two = 60 msec. Otherwise we exceed data vectors * /
1043 if (noOfLostFrames > 2) { 1045 if (noOfLostFrames > 2) {
1044 noOfLostFrames = 2; 1046 noOfLostFrames = 2;
1045 } 1047 }
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
1260 * 1262 *
1261 * Input: 1263 * Input:
1262 * - encoded : Encoded bitstream 1264 * - encoded : Encoded bitstream
1263 * 1265 *
1264 * Output: 1266 * Output:
1265 * - frameLength : Length of frame in packet (in samples) 1267 * - frameLength : Length of frame in packet (in samples)
1266 * 1268 *
1267 */ 1269 */
1268 1270
1269 int16_t WebRtcIsacfix_ReadFrameLen(const uint8_t* encoded, 1271 int16_t WebRtcIsacfix_ReadFrameLen(const uint8_t* encoded,
1270 int encoded_len_bytes, 1272 size_t encoded_len_bytes,
1271 int16_t* frameLength) 1273 size_t* frameLength)
1272 { 1274 {
1273 Bitstr_dec streamdata; 1275 Bitstr_dec streamdata;
1274 int16_t err; 1276 int16_t err;
1275 const int kRequiredEncodedLenBytes = 10; 1277 const size_t kRequiredEncodedLenBytes = 10;
1276 1278
1277 if (encoded_len_bytes < kRequiredEncodedLenBytes) { 1279 if (encoded_len_bytes < kRequiredEncodedLenBytes) {
1278 return -1; 1280 return -1;
1279 } 1281 }
1280 1282
1281 InitializeDecoderBitstream(encoded_len_bytes, &streamdata); 1283 InitializeDecoderBitstream(encoded_len_bytes, &streamdata);
1282 1284
1283 read_be16(encoded, kRequiredEncodedLenBytes, streamdata.stream); 1285 read_be16(encoded, kRequiredEncodedLenBytes, streamdata.stream);
1284 1286
1285 /* decode frame length */ 1287 /* decode frame length */
(...skipping 13 matching lines...) Expand all
1299 * Input: 1301 * Input:
1300 * - encoded : Encoded bitstream 1302 * - encoded : Encoded bitstream
1301 * 1303 *
1302 * Output: 1304 * Output:
1303 * - frameLength : Length of frame in packet (in samples) 1305 * - frameLength : Length of frame in packet (in samples)
1304 * - rateIndex : Bandwidth estimate in bitstream 1306 * - rateIndex : Bandwidth estimate in bitstream
1305 * 1307 *
1306 */ 1308 */
1307 1309
1308 int16_t WebRtcIsacfix_ReadBwIndex(const uint8_t* encoded, 1310 int16_t WebRtcIsacfix_ReadBwIndex(const uint8_t* encoded,
1309 int encoded_len_bytes, 1311 size_t encoded_len_bytes,
1310 int16_t* rateIndex) 1312 int16_t* rateIndex)
1311 { 1313 {
1312 Bitstr_dec streamdata; 1314 Bitstr_dec streamdata;
1313 int16_t err; 1315 int16_t err;
1314 const int kRequiredEncodedLenBytes = 10; 1316 const size_t kRequiredEncodedLenBytes = 10;
1315 1317
1316 if (encoded_len_bytes < kRequiredEncodedLenBytes) { 1318 if (encoded_len_bytes < kRequiredEncodedLenBytes) {
1317 return -1; 1319 return -1;
1318 } 1320 }
1319 1321
1320 InitializeDecoderBitstream(encoded_len_bytes, &streamdata); 1322 InitializeDecoderBitstream(encoded_len_bytes, &streamdata);
1321 1323
1322 read_be16(encoded, kRequiredEncodedLenBytes, streamdata.stream); 1324 read_be16(encoded, kRequiredEncodedLenBytes, streamdata.stream);
1323 1325
1324 /* decode frame length, needed to get to the rateIndex in the bitstream */ 1326 /* decode frame length, needed to get to the rateIndex in the bitstream */
1325 int16_t frameLength; 1327 size_t framelength;
1326 err = WebRtcIsacfix_DecodeFrameLen(&streamdata, &frameLength); 1328 err = WebRtcIsacfix_DecodeFrameLen(&streamdata, &framelength);
1327 if (err<0) // error check 1329 if (err<0) // error check
1328 return err; 1330 return err;
1329 1331
1330 /* decode BW estimation */ 1332 /* decode BW estimation */
1331 err = WebRtcIsacfix_DecodeSendBandwidth(&streamdata, rateIndex); 1333 err = WebRtcIsacfix_DecodeSendBandwidth(&streamdata, rateIndex);
1332 if (err<0) // error check 1334 if (err<0) // error check
1333 return err; 1335 return err;
1334 1336
1335 return 0; 1337 return 0;
1336 } 1338 }
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
1545 assert(inst->initflag & 1); // Decoder initialized. 1547 assert(inst->initflag & 1); // Decoder initialized.
1546 WebRtcIsacfixBw_GetBandwidthInfo(&inst->bwestimator_obj, bwinfo); 1548 WebRtcIsacfixBw_GetBandwidthInfo(&inst->bwestimator_obj, bwinfo);
1547 } 1549 }
1548 1550
1549 void WebRtcIsacfix_SetBandwidthInfo(ISACFIX_MainStruct* ISAC_main_inst, 1551 void WebRtcIsacfix_SetBandwidthInfo(ISACFIX_MainStruct* ISAC_main_inst,
1550 const IsacBandwidthInfo* bwinfo) { 1552 const IsacBandwidthInfo* bwinfo) {
1551 ISACFIX_SubStruct* inst = (ISACFIX_SubStruct*)ISAC_main_inst; 1553 ISACFIX_SubStruct* inst = (ISACFIX_SubStruct*)ISAC_main_inst;
1552 assert(inst->initflag & 2); // Encoder initialized. 1554 assert(inst->initflag & 2); // Encoder initialized.
1553 WebRtcIsacfixBw_SetBandwidthInfo(&inst->bwestimator_obj, bwinfo); 1555 WebRtcIsacfixBw_SetBandwidthInfo(&inst->bwestimator_obj, bwinfo);
1554 } 1556 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698