Changeset 628 for pjproject/trunk/pjmedia/src/pjmedia-codec/speex_codec.c
- Timestamp:
- Jul 26, 2006 5:04:54 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjmedia/src/pjmedia-codec/speex_codec.c
r582 r628 684 684 { 685 685 struct spx_private *spx; 686 float tmp[642]; /* 20ms at 32KHz + 2 */ 687 pj_int16_t *samp_in; 688 unsigned i, samp_count, sz; 686 unsigned sz; 689 687 int tx; 690 688 … … 699 697 } 700 698 701 /* Copy frame to float buffer. */702 samp_count = input->size / 2;703 pj_assert(samp_count <= PJ_ARRAY_SIZE(tmp));704 samp_in = input->buf;705 for (i=0; i<samp_count; ++i) {706 tmp[i] = samp_in[i];707 }708 709 699 /* Flush all the bits in the struct so we can encode a new frame */ 710 700 speex_bits_reset(&spx->enc_bits); 711 701 712 702 /* Encode the frame */ 713 tx = speex_encode (spx->enc, tmp, &spx->enc_bits);703 tx = speex_encode_int(spx->enc, input->buf, &spx->enc_bits); 714 704 715 705 /* Check if we need not to transmit the frame (DTX) */ … … 744 734 { 745 735 struct spx_private *spx; 746 float tmp[642]; /* 20ms at 32KHz + 2 */747 pj_int16_t *dst_buf;748 unsigned i, count, sz;749 736 750 737 spx = (struct spx_private*) codec->codec_data; … … 765 752 766 753 /* Decode the data */ 767 speex_decode(spx->dec, &spx->dec_bits, tmp); 768 769 /* Check size. */ 770 sz = speex_bits_nbytes(&spx->enc_bits); 771 pj_assert(sz <= output_buf_len); 772 773 /* Copy from float to short samples. */ 774 count = spx_factory.speex_param[spx->param_id].clock_rate * 20 / 1000; 775 pj_assert((count <= output_buf_len/2) && count <= PJ_ARRAY_SIZE(tmp)); 776 dst_buf = output->buf; 777 for (i=0; i<count; ++i) { 778 dst_buf[i] = (pj_int16_t)tmp[i]; 779 } 754 speex_decode_int(spx->dec, &spx->dec_bits, output->buf); 755 780 756 output->type = PJMEDIA_FRAME_TYPE_AUDIO; 781 output->size = count * 2; 757 output->size = speex_bits_nbytes(&spx->dec_bits); 758 pj_assert(output->size <= (int)output_buf_len); 782 759 output->timestamp.u64 = input->timestamp.u64; 783 760 … … 794 771 { 795 772 struct spx_private *spx; 796 float tmp[642]; /* 20ms at 32KHz + 2 */ 797 pj_int16_t *dst_buf; 798 unsigned i, count; 773 unsigned count; 799 774 800 775 /* output_buf_len is unreferenced when building in Release mode */ … … 804 779 805 780 count = spx_factory.speex_param[spx->param_id].clock_rate * 20 / 1000; 806 pj_assert( (count <= output_buf_len/2) && count <= PJ_ARRAY_SIZE(tmp));781 pj_assert(count <= output_buf_len/2); 807 782 808 783 /* Recover packet loss */ 809 speex_decode(spx->dec, NULL, tmp); 810 811 /* Copy from float to short samples. */ 812 dst_buf = output->buf; 813 for (i=0; i<count; ++i) { 814 dst_buf[i] = (pj_int16_t)tmp[i]; 815 } 784 speex_decode_int(spx->dec, NULL, output->buf); 785 816 786 output->size = count * 2; 817 787
Note: See TracChangeset
for help on using the changeset viewer.