Changeset 888 for pjproject/trunk/pjmedia/src/pjmedia-codec/ilbc.c
- Timestamp:
- Jan 20, 2007 5:18:14 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjmedia/src/pjmedia-codec/ilbc.c
r874 r888 129 129 pj_bool_t vad_enabled; 130 130 pj_bool_t plc_enabled; 131 pj_timestamp last_tx; 131 132 132 133 pj_bool_t enc_ready; … … 427 428 return status; 428 429 430 /* Init last_tx (not necessary because of zalloc, but better 431 * be safe in case someone remove zalloc later. 432 */ 433 pj_set_timestamp32(&ilbc_codec->last_tx, 0, 0); 434 429 435 PJ_LOG(5,(ilbc_codec->obj_name, 430 436 "iLBC codec opened, encoder mode=%d, decoder mode=%d", … … 513 519 return PJMEDIA_CODEC_EFRMTOOSHORT; 514 520 515 if (input->size != ilbc_codec->enc_samples_per_frame * 2)521 if (input->size != (ilbc_codec->enc_samples_per_frame << 1)) 516 522 return PJMEDIA_CODEC_EPCMFRMINLEN; 517 523 … … 519 525 if (ilbc_codec->vad_enabled) { 520 526 pj_bool_t is_silence; 527 pj_int32_t silence_period; 528 529 silence_period = pj_timestamp_diff32(&ilbc_codec->last_tx, 530 &input->timestamp); 521 531 522 532 is_silence = pjmedia_silence_det_detect(ilbc_codec->vad, 523 533 input->buf, 524 input->size / 2,534 (input->size >> 1), 525 535 NULL); 526 if (is_silence) { 536 if (is_silence && 537 PJMEDIA_CODEC_MAX_SILENCE_PERIOD != -1 && 538 silence_period < PJMEDIA_CODEC_MAX_SILENCE_PERIOD) 539 { 527 540 output->type = PJMEDIA_FRAME_TYPE_NONE; 528 541 output->buf = NULL; 529 542 output->size = 0; 530 output->timestamp .u64 = input->timestamp.u64;543 output->timestamp = input->timestamp; 531 544 return PJ_SUCCESS; 545 } else { 546 ilbc_codec->last_tx = input->timestamp; 532 547 } 533 548 } … … 545 560 output->type = PJMEDIA_FRAME_TYPE_AUDIO; 546 561 output->size = ilbc_codec->enc.no_of_bytes; 547 output->timestamp .u64 = input->timestamp.u64;562 output->timestamp = input->timestamp; 548 563 549 564 return PJ_SUCCESS; … … 564 579 PJ_ASSERT_RETURN(input && output, PJ_EINVAL); 565 580 566 if (output_buf_len < ilbc_codec->dec_samples_per_frame*2)581 if (output_buf_len < (ilbc_codec->dec_samples_per_frame << 1)) 567 582 return PJMEDIA_CODEC_EPCMTOOSHORT; 568 583 … … 578 593 ((short*)output->buf)[i] = (short)ilbc_codec->dec_block[i]; 579 594 } 580 output->size = ilbc_codec->dec_samples_per_frame * 2;595 output->size = (ilbc_codec->dec_samples_per_frame << 1); 581 596 output->type = PJMEDIA_FRAME_TYPE_AUDIO; 582 output->timestamp .u64 = input->timestamp.u64;597 output->timestamp = input->timestamp; 583 598 584 599 return PJ_SUCCESS; … … 599 614 PJ_ASSERT_RETURN(output, PJ_EINVAL); 600 615 601 if (output_buf_len < ilbc_codec->dec_samples_per_frame*2)616 if (output_buf_len < (ilbc_codec->dec_samples_per_frame << 1)) 602 617 return PJMEDIA_CODEC_EPCMTOOSHORT; 603 618 … … 609 624 ((short*)output->buf)[i] = (short)ilbc_codec->dec_block[i]; 610 625 } 611 output->size = ilbc_codec->dec_samples_per_frame * 2;626 output->size = (ilbc_codec->dec_samples_per_frame << 1); 612 627 output->type = PJMEDIA_FRAME_TYPE_AUDIO; 613 628
Note: See TracChangeset
for help on using the changeset viewer.