further codec module optimization based on codec_alaw changes by rizzo
authorRussell Bryant <russell@russellbryant.com>
Tue, 23 May 2006 22:57:03 +0000 (22:57 +0000)
committerRussell Bryant <russell@russellbryant.com>
Tue, 23 May 2006 22:57:03 +0000 (22:57 +0000)
(issue #7190, Mithraen)

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@29880 65c4cc65-6c06-0410-ace0-fbb531ad65f3

codecs/codec_a_mu.c
codecs/codec_ulaw.c

index f1b3529..05dbe5c 100644 (file)
@@ -56,14 +56,15 @@ static unsigned char a2mu[256];
 static int alawtoulaw_framein(struct ast_trans_pvt *pvt, struct ast_frame *f)
 {
        int x = f->samples;
-       int in_samples = f->samples;
        unsigned char *src = f->data;
        unsigned char *dst = (unsigned char *)pvt->outbuf + pvt->samples;
 
+       pvt->samples += x;
+       pvt->datalen += x;
+
        while (x--)
                *dst++ = a2mu[*src++];
-       pvt->samples += in_samples;
-       pvt->datalen += in_samples;
+
        return 0;
 }
 
@@ -71,14 +72,15 @@ static int alawtoulaw_framein(struct ast_trans_pvt *pvt, struct ast_frame *f)
 static int ulawtoalaw_framein(struct ast_trans_pvt *pvt, struct ast_frame *f)
 {
        int x = f->samples;
-       int in_samples = f->samples;
        unsigned char *src = f->data;
        unsigned char *dst = (unsigned char *)pvt->outbuf + pvt->samples;
 
+       pvt->samples += x;
+       pvt->datalen += x;
+
        while (x--)
                *dst++ = mu2a[*src++];
-       pvt->samples += in_samples;
-       pvt->datalen += in_samples;
+
        return 0;
 }
 
index 6d66b9b..521b842 100644 (file)
@@ -57,14 +57,14 @@ static int ulawtolin_framein(struct ast_trans_pvt *pvt, struct ast_frame *f)
        int i = f->samples;
        unsigned char *src = f->data;
        int16_t *dst = (int16_t *)pvt->outbuf + pvt->samples;
-       int in_samples = f->samples;
+
+       pvt->samples += i;
+       pvt->datalen += i * 2;  /* 2 bytes/sample */
 
        /* convert and copy in outbuf */
        while (i--)
                *dst++ = AST_MULAW(*src++);
 
-       pvt->samples += in_samples;
-       pvt->datalen += in_samples * 2; /* 2 bytes/sample */
        return 0;
 }
 
@@ -74,13 +74,13 @@ static int lintoulaw_framein(struct ast_trans_pvt *pvt, struct ast_frame *f)
        int i = f->samples;
        char *dst = pvt->outbuf + pvt->samples;
        int16_t *src = f->data;
-       int in_samples = f->samples;
+
+       pvt->samples += i;
+       pvt->datalen += i;      /* 1 byte/sample */
 
        while (i--)
                *dst++ = AST_LIN2MU(*src++);
 
-       pvt->samples += in_samples;
-       pvt->datalen += in_samples;     /* 1 byte/sample */
        return 0;
 }