diff options
author | russell <russell@f38db490-d61c-443f-a65b-d21fe96a405b> | 2006-05-05 21:36:17 +0000 |
---|---|---|
committer | russell <russell@f38db490-d61c-443f-a65b-d21fe96a405b> | 2006-05-05 21:36:17 +0000 |
commit | f2fd8957f8df247595d24f1567716e039163bae3 (patch) | |
tree | c3163ccca5d99ddb0dee9a2d0031b19a68a91594 /codecs/codec_a_mu.c | |
parent | be0d2ed294a108888ee91c62b5eb50829587683c (diff) |
minor code optimizations to reduce the number of times that the ast_frame
and ast_trans_pvt pointers have to be dereferenced (issue #7069, Mithraen)
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@25059 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'codecs/codec_a_mu.c')
-rw-r--r-- | codecs/codec_a_mu.c | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/codecs/codec_a_mu.c b/codecs/codec_a_mu.c index 51e38e9cf..6ab79be61 100644 --- a/codecs/codec_a_mu.c +++ b/codecs/codec_a_mu.c @@ -55,28 +55,30 @@ static unsigned char a2mu[256]; /*! \brief convert frame data and store into the buffer */ static int alawtoulaw_framein(struct ast_trans_pvt *pvt, struct ast_frame *f) { - int x; + int i; + int in_samples = f->samples; unsigned char *src = f->data; unsigned char *dst = (unsigned char *)pvt->outbuf + pvt->samples; - for ( x = 0 ; x < f->samples; x++) - dst[x] = a2mu[src[x]]; - pvt->samples += f->samples; - pvt->datalen += f->datalen; + for (i = 0; i < in_samples; i++) + *dst++ = a2mu[*src++]; + pvt->samples += in_samples; + pvt->datalen += in_samples; return 0; } /*! \brief convert frame data and store into the buffer */ static int ulawtoalaw_framein(struct ast_trans_pvt *pvt, struct ast_frame *f) { - int x; + int i; + int in_samples = f->samples; unsigned char *src = f->data; unsigned char *dst = (unsigned char *)pvt->outbuf + pvt->samples; - for ( x = 0 ; x < f->samples; x++) - dst[x] = mu2a[src[x]]; - pvt->samples += f->samples; - pvt->datalen += f->datalen; + for (i = 0; i < in_samples; i++) + *dst++ = mu2a[*src++]; + pvt->samples += in_samples; + pvt->datalen += in_samples; return 0; } |