aboutsummaryrefslogtreecommitdiffstats
path: root/codecs/codec_speex.c
diff options
context:
space:
mode:
authorkpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b>2006-09-08 21:33:32 +0000
committerkpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b>2006-09-08 21:33:32 +0000
commitfba973dd3f53cbcb83134bfc857fdc6bdd697e32 (patch)
tree520f25812033ab463adcd053afe32c47087af47c /codecs/codec_speex.c
parent809b2f32c0fdb4bb781921f07683db56adc97f21 (diff)
minor performance improvement
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@42477 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'codecs/codec_speex.c')
-rw-r--r--codecs/codec_speex.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/codecs/codec_speex.c b/codecs/codec_speex.c
index 06c23e4f0..6978184ae 100644
--- a/codecs/codec_speex.c
+++ b/codecs/codec_speex.c
@@ -274,11 +274,11 @@ static struct ast_frame *lintospeex_frameout(struct ast_trans_pvt *pvt)
#ifdef _SPEEX_TYPES_H
/* Preprocess audio */
if (preproc)
- is_speech = speex_preprocess(tmp->pp, tmp->buf, NULL);
+ is_speech = speex_preprocess(tmp->pp, tmp->buf + samples, NULL);
/* Encode a frame of data */
if (is_speech) {
/* If DTX enabled speex_encode returns 0 during silence */
- is_speech = speex_encode_int(tmp->speex, tmp->buf, &tmp->bits) || !dtx;
+ is_speech = speex_encode_int(tmp->speex, tmp->buf + samples, &tmp->bits) || !dtx;
} else {
/* 5 zeros interpreted by Speex as silence (submode 0) */
speex_bits_pack(&tmp->bits, 0, 5);
@@ -289,18 +289,19 @@ static struct ast_frame *lintospeex_frameout(struct ast_trans_pvt *pvt)
int x;
/* Convert to floating point */
for (x = 0; x < tmp->framesize; x++)
- fbuf[x] = tmp->buf[x];
+ fbuf[x] = tmp->buf[samples + x];
/* Encode a frame of data */
is_speech = speex_encode(tmp->speex, fbuf, &tmp->bits) || !dtx;
}
#endif
samples += tmp->framesize;
pvt->samples -= tmp->framesize;
- /* Move the data at the end of the buffer to the front */
- if (pvt->samples)
- memmove(tmp->buf, tmp->buf + tmp->framesize, pvt->samples * 2);
}
+ /* Move the data at the end of the buffer to the front */
+ if (pvt->samples)
+ memmove(tmp->buf, tmp->buf + samples, pvt->samples * 2);
+
/* Use AST_FRAME_CNG to signify the start of any silence period */
if (is_speech) {
tmp->silent_state = 0;