further codec module optimization based on codec_alaw changes by rizzo
[asterisk/asterisk.git] / codecs / codec_ulaw.c
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;
 }