[asterisk-commits] kpfleming: trunk r42477 - /trunk/codecs/

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Fri Sep 8 14:33:32 MST 2006


Author: kpfleming
Date: Fri Sep  8 16:33:32 2006
New Revision: 42477

URL: http://svn.digium.com/view/asterisk?rev=42477&view=rev
Log:
minor performance improvement

Modified:
    trunk/codecs/codec_gsm.c
    trunk/codecs/codec_ilbc.c
    trunk/codecs/codec_lpc10.c
    trunk/codecs/codec_speex.c

Modified: trunk/codecs/codec_gsm.c
URL: http://svn.digium.com/view/asterisk/trunk/codecs/codec_gsm.c?rev=42477&r1=42476&r2=42477&view=diff
==============================================================================
--- trunk/codecs/codec_gsm.c (original)
+++ trunk/codecs/codec_gsm.c Fri Sep  8 16:33:32 2006
@@ -183,14 +183,16 @@
 		return NULL;
 	while (pvt->samples >= GSM_SAMPLES) {
 		/* Encode a frame of data */
-		gsm_encode(tmp->gsm, tmp->buf, (gsm_byte *)pvt->outbuf + datalen);
+		gsm_encode(tmp->gsm, tmp->buf + samples, (gsm_byte *) pvt->outbuf + datalen);
 		datalen += GSM_FRAME_LEN;
 		samples += GSM_SAMPLES;
 		pvt->samples -= GSM_SAMPLES;
-		/* Move the data at the end of the buffer to the front */
-		if (pvt->samples)
-			memmove(tmp->buf, tmp->buf + GSM_SAMPLES, 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);
+
 	return ast_trans_frameout(pvt, datalen, samples);
 }
 

Modified: trunk/codecs/codec_ilbc.c
URL: http://svn.digium.com/view/asterisk/trunk/codecs/codec_ilbc.c?rev=42477&r1=42476&r2=42477&view=diff
==============================================================================
--- trunk/codecs/codec_ilbc.c (original)
+++ trunk/codecs/codec_ilbc.c Fri Sep  8 16:33:32 2006
@@ -176,17 +176,21 @@
 	while (pvt->samples >= ILBC_SAMPLES) {
 		float tmpf[ILBC_SAMPLES];
 		int i;
+
 		/* Encode a frame of data */
-		for ( i = 0 ; i < ILBC_SAMPLES ; i++ )
-			tmpf[i] = tmp->buf[i];
+		for (i = 0 ; i < ILBC_SAMPLES ; i++)
+			tmpf[i] = tmp->buf[samples + i];
 		iLBC_encode((unsigned char *) pvt->outbuf + datalen, tmpf, &tmp->enc);
+
 		datalen += ILBC_FRAME_LEN;
 		samples += ILBC_SAMPLES;
 		pvt->samples -= ILBC_SAMPLES;
-		/* Move the data at the end of the buffer to the front */
-		if (pvt->samples)
-			memmove(tmp->buf, tmp->buf + ILBC_SAMPLES, 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);
+
 	return ast_trans_frameout(pvt, datalen, samples);
 }
 

Modified: trunk/codecs/codec_lpc10.c
URL: http://svn.digium.com/view/asterisk/trunk/codecs/codec_lpc10.c?rev=42477&r1=42476&r2=42477&view=diff
==============================================================================
--- trunk/codecs/codec_lpc10.c (original)
+++ trunk/codecs/codec_lpc10.c Fri Sep  8 16:33:32 2006
@@ -218,9 +218,6 @@
 		/* Use one of the two left over bits to record if this is a 22 or 23 ms frame...
 		   important for IAX use */
 		tmp->longer = 1 - tmp->longer;
-#if 0	/* what the heck was this for? */
-		((char *)(tmp->f.data))[consumed - 1] |= tmp->longer;
-#endif		
 	}
 	/* Move the data at the end of the buffer to the front */
 	if (pvt->samples)

Modified: trunk/codecs/codec_speex.c
URL: http://svn.digium.com/view/asterisk/trunk/codecs/codec_speex.c?rev=42477&r1=42476&r2=42477&view=diff
==============================================================================
--- trunk/codecs/codec_speex.c (original)
+++ trunk/codecs/codec_speex.c Fri Sep  8 16:33:32 2006
@@ -274,11 +274,11 @@
 #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,17 +289,18 @@
 			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) {



More information about the asterisk-commits mailing list