Changeset 1983 for pjproject/trunk/pjmedia/src/pjmedia-codec/ilbc.c
- Timestamp:
- Jun 5, 2008 10:50:40 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjmedia/src/pjmedia-codec/ilbc.c
r1266 r1983 511 511 { 512 512 struct ilbc_codec *ilbc_codec = (struct ilbc_codec*)codec; 513 unsigned i; 514 515 pj_assert(ilbc_codec != NULL); 516 PJ_ASSERT_RETURN(input && output, PJ_EINVAL); 517 518 if (output_buf_len < ilbc_codec->enc_frame_size) 519 return PJMEDIA_CODEC_EFRMTOOSHORT; 520 521 if (input->size != (ilbc_codec->enc_samples_per_frame << 1)) 522 return PJMEDIA_CODEC_EPCMFRMINLEN; 513 pj_int16_t *pcm_in; 514 unsigned nsamples; 515 516 pj_assert(ilbc_codec && input && output); 517 518 pcm_in = (pj_int16_t*)input->buf; 519 nsamples = input->size >> 1; 520 521 PJ_ASSERT_RETURN(nsamples % ilbc_codec->enc_samples_per_frame == 0, 522 PJMEDIA_CODEC_EPCMFRMINLEN); 523 PJ_ASSERT_RETURN(output_buf_len >= ilbc_codec->enc_frame_size * nsamples / 524 ilbc_codec->enc_samples_per_frame, 525 PJMEDIA_CODEC_EFRMTOOSHORT); 523 526 524 527 /* Detect silence */ … … 548 551 } 549 552 550 /* Convert to float */551 for (i=0; i<ilbc_codec->enc_samples_per_frame; ++i) {552 ilbc_codec->enc_block[i] = (float) (((pj_int16_t*)input->buf)[i]);553 }554 555 553 /* Encode */ 556 iLBC_encode((unsigned char *)output->buf, 557 ilbc_codec->enc_block, 558 &ilbc_codec->enc); 554 output->size = 0; 555 while (nsamples >= ilbc_codec->enc_samples_per_frame) { 556 unsigned i; 557 558 /* Convert to float */ 559 for (i=0; i<ilbc_codec->enc_samples_per_frame; ++i) { 560 ilbc_codec->enc_block[i] = (float) (*pcm_in++); 561 } 562 563 iLBC_encode((unsigned char *)output->buf + output->size, 564 ilbc_codec->enc_block, 565 &ilbc_codec->enc); 566 567 output->size += ilbc_codec->enc.no_of_bytes; 568 nsamples -= ilbc_codec->enc_samples_per_frame; 569 } 559 570 560 571 output->type = PJMEDIA_FRAME_TYPE_AUDIO; 561 output->size = ilbc_codec->enc.no_of_bytes;562 572 output->timestamp = input->timestamp; 563 573
Note: See TracChangeset
for help on using the changeset viewer.