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 606 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
617 else | 617 else |
618 { | 618 { |
619 break; | 619 break; |
620 } | 620 } |
621 | 621 |
622 if (stream_len < 0 || err < 0) { | 622 if (stream_len < 0 || err < 0) { |
623 /* exit if returned with error */ | 623 /* exit if returned with error */ |
624 errtype=WebRtcIsacfix_GetErrorCode(ISAC_main_inst); | 624 errtype=WebRtcIsacfix_GetErrorCode(ISAC_main_inst); |
625 printf("\nError in encoder: %d.\n", errtype); | 625 printf("\nError in encoder: %d.\n", errtype); |
626 } else { | 626 } else { |
627 if (fwrite(streamdata, sizeof(char), | 627 if (fwrite(streamdata, sizeof(char), stream_len, outbits) != |
628 stream_len, outbits) != (size_t)stream_len) { | 628 (size_t)stream_len) { |
629 return -1; | 629 return -1; |
630 } | 630 } |
631 } | 631 } |
632 | 632 |
633 cur_framesmpls += FRAMESAMPLES_10ms; | 633 cur_framesmpls += FRAMESAMPLES_10ms; |
634 | 634 |
635 /* read next bottleneck rate */ | 635 /* read next bottleneck rate */ |
636 if (f_bn != NULL) { | 636 if (f_bn != NULL) { |
637 int aux_var; | 637 int aux_var; |
638 if (fscanf(f_bn, "%d", &aux_var) == EOF) { | 638 if (fscanf(f_bn, "%d", &aux_var) == EOF) { |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
724 lostFrame = !lostFrame; | 724 lostFrame = !lostFrame; |
725 } else { | 725 } else { |
726 lostFrame = (rand()%100 < packetLossPercent); | 726 lostFrame = (rand()%100 < packetLossPercent); |
727 } | 727 } |
728 | 728 |
729 | 729 |
730 | 730 |
731 /* iSAC decoding */ | 731 /* iSAC decoding */ |
732 if( lostFrame && framecnt > 0) { | 732 if( lostFrame && framecnt > 0) { |
733 if (nbTest !=2) { | 733 if (nbTest !=2) { |
734 declen = WebRtcIsacfix_DecodePlc(ISAC_main_inst, | 734 declen = |
735 decoded, prevFrameSize ); | 735 WebRtcIsacfix_DecodePlc(ISAC_main_inst, decoded, prevFrameSize); |
736 } else { | 736 } else { |
737 #ifdef WEBRTC_ISAC_FIX_NB_CALLS_ENABLED | 737 #ifdef WEBRTC_ISAC_FIX_NB_CALLS_ENABLED |
738 declen = WebRtcIsacfix_DecodePlcNb(ISAC_main_inst, decoded, | 738 declen = WebRtcIsacfix_DecodePlcNb( |
739 prevFrameSize ); | 739 ISAC_main_inst, decoded, prevFrameSize); |
740 #else | 740 #else |
741 declen = -1; | 741 declen = -1; |
742 #endif | 742 #endif |
743 } | 743 } |
744 lostPackets++; | 744 lostPackets++; |
745 } else { | 745 } else { |
746 if (nbTest !=2 ) { | 746 if (nbTest !=2 ) { |
747 short FL; | 747 short FL; |
748 /* Call getFramelen, only used here for function test */ | 748 /* Call getFramelen, only used here for function test */ |
749 err = WebRtcIsacfix_ReadFrameLen( | 749 err = WebRtcIsacfix_ReadFrameLen( |
750 reinterpret_cast<const uint8_t*>(streamdata), stream_len, &FL); | 750 reinterpret_cast<const uint8_t*>(streamdata), stream_len, &FL); |
751 declen = WebRtcIsacfix_Decode( | 751 declen = WebRtcIsacfix_Decode( |
752 ISAC_main_inst, | 752 ISAC_main_inst, |
753 reinterpret_cast<const uint8_t*>(streamdata), | 753 reinterpret_cast<const uint8_t*>(streamdata), |
754 stream_len, | 754 stream_len, |
755 decoded, | 755 decoded, |
756 speechType); | 756 speechType); |
757 /* Error check */ | 757 /* Error check */ |
758 if (err<0 || declen<0 || FL!=declen) { | 758 if (err < 0 || declen < 0 || FL != declen) { |
759 errtype=WebRtcIsacfix_GetErrorCode(ISAC_main_inst); | 759 errtype=WebRtcIsacfix_GetErrorCode(ISAC_main_inst); |
760 printf("\nError in decode_B/or getFrameLen: %d.\n", errtype); | 760 printf("\nError in decode_B/or getFrameLen: %d.\n", errtype); |
761 } | 761 } |
762 prevFrameSize = declen/480; | 762 prevFrameSize = declen/480; |
763 | 763 |
764 } else { | 764 } else { |
765 #ifdef WEBRTC_ISAC_FIX_NB_CALLS_ENABLED | 765 #ifdef WEBRTC_ISAC_FIX_NB_CALLS_ENABLED |
766 declen = WebRtcIsacfix_DecodeNb( ISAC_main_inst, streamdata, | 766 declen = WebRtcIsacfix_DecodeNb( ISAC_main_inst, streamdata, |
767 stream_len, decoded, speechType ); | 767 stream_len, decoded, speechType ); |
768 #else | 768 #else |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
828 fclose(inp); | 828 fclose(inp); |
829 fclose(outp); | 829 fclose(outp); |
830 fclose(outbits); | 830 fclose(outbits); |
831 | 831 |
832 if ( testCE == 1) { | 832 if ( testCE == 1) { |
833 WebRtcIsacfix_FreeInternal(ISAC_main_inst); | 833 WebRtcIsacfix_FreeInternal(ISAC_main_inst); |
834 } | 834 } |
835 WebRtcIsacfix_Free(ISAC_main_inst); | 835 WebRtcIsacfix_Free(ISAC_main_inst); |
836 return 0; | 836 return 0; |
837 } | 837 } |
OLD | NEW |