Changeset 888 for pjproject/trunk/pjmedia/src/pjmedia/g711.c
- Timestamp:
- Jan 20, 2007 5:18:14 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjmedia/src/pjmedia/g711.c
r874 r888 126 126 pj_bool_t vad_enabled; 127 127 pjmedia_silence_det *vad; 128 pj_timestamp last_tx; 128 129 }; 129 130 … … 466 467 467 468 /* Check output buffer length */ 468 if (output_buf_len < input->size / 2)469 if (output_buf_len < (input->size >> 1)) 469 470 return PJMEDIA_CODEC_EFRMTOOSHORT; 470 471 … … 472 473 if (priv->vad_enabled) { 473 474 pj_bool_t is_silence; 475 pj_int32_t silence_period; 476 477 silence_period = pj_timestamp_diff32(&priv->last_tx, 478 &input->timestamp); 474 479 475 480 is_silence = pjmedia_silence_det_detect(priv->vad, input->buf, 476 input->size / 2, NULL); 477 if (is_silence) { 481 (input->size >> 1), NULL); 482 if (is_silence && 483 PJMEDIA_CODEC_MAX_SILENCE_PERIOD != -1 && 484 silence_period < PJMEDIA_CODEC_MAX_SILENCE_PERIOD) 485 { 478 486 output->type = PJMEDIA_FRAME_TYPE_NONE; 479 487 output->buf = NULL; 480 488 output->size = 0; 481 output->timestamp .u64 = input->timestamp.u64;489 output->timestamp = input->timestamp; 482 490 return PJ_SUCCESS; 491 } else { 492 priv->last_tx = input->timestamp; 483 493 } 484 494 } … … 486 496 /* Encode */ 487 497 if (priv->pt == PJMEDIA_RTP_PT_PCMA) { 488 unsigned i ;498 unsigned i, n; 489 499 pj_uint8_t *dst = output->buf; 490 500 491 for (i=0; i!=input->size/2; ++i, ++dst) { 501 n = (input->size >> 1); 502 for (i=0; i!=n; ++i, ++dst) { 492 503 *dst = pjmedia_linear2alaw(samples[i]); 493 504 } 494 505 } else if (priv->pt == PJMEDIA_RTP_PT_PCMU) { 495 unsigned i ;506 unsigned i, n; 496 507 pj_uint8_t *dst = output->buf; 497 508 498 for (i=0; i!=input->size/2; ++i, ++dst) { 509 n = (input->size >> 1); 510 for (i=0; i!=n; ++i, ++dst) { 499 511 *dst = pjmedia_linear2ulaw(samples[i]); 500 512 } … … 505 517 506 518 output->type = PJMEDIA_FRAME_TYPE_AUDIO; 507 output->size = input->size / 2;519 output->size = (input->size >> 1); 508 520 509 521 return PJ_SUCCESS; … … 518 530 519 531 /* Check output buffer length */ 520 PJ_ASSERT_RETURN(output_buf_len >= input->size * 2,532 PJ_ASSERT_RETURN(output_buf_len >= (input->size << 1), 521 533 PJMEDIA_CODEC_EPCMTOOSHORT); 522 534 … … 548 560 549 561 output->type = PJMEDIA_FRAME_TYPE_AUDIO; 550 output->size = input->size * 2;562 output->size = (input->size << 1); 551 563 552 564 if (priv->plc_enabled)
Note: See TracChangeset
for help on using the changeset viewer.