[asterisk-commits] russell: trunk r98218 - /trunk/codecs/codec_g722.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Jan 11 11:17:55 CST 2008


Author: russell
Date: Fri Jan 11 11:17:54 2008
New Revision: 98218

URL: http://svn.digium.com/view/asterisk?view=rev&rev=98218
Log:
At one point during working on this module, I had the lin/lin16 versions of the
framein callbacks different.  However, they are now the same again, so remove
the duplicate code and use the same functions for the lin/lin16 versions.

Modified:
    trunk/codecs/codec_g722.c

Modified: trunk/codecs/codec_g722.c
URL: http://svn.digium.com/view/asterisk/trunk/codecs/codec_g722.c?view=diff&rev=98218&r1=98217&r2=98218
==============================================================================
--- trunk/codecs/codec_g722.c (original)
+++ trunk/codecs/codec_g722.c Fri Jan 11 11:17:54 2008
@@ -101,28 +101,11 @@
 static int g722tolin_framein(struct ast_trans_pvt *pvt, struct ast_frame *f)
 {
 	struct g722_decoder_pvt *tmp = pvt->pvt;
-	unsigned char *src = f->data;
-	int out_samples;
-
-	out_samples = g722_decode(&tmp->g722, (int16_t *) &pvt->outbuf[pvt->samples * sizeof(int16_t)], 
-		src, f->samples);
-
-	pvt->samples += out_samples;
-
-	pvt->datalen += (out_samples * sizeof(int16_t));
-
-	return 0;
-}
-
-static int g722tolin16_framein(struct ast_trans_pvt *pvt, struct ast_frame *f)
-{
-	struct g722_decoder_pvt *tmp = pvt->pvt;
 	int out_samples;
 
 	out_samples = g722_decode(&tmp->g722, (int16_t *) &pvt->outbuf[pvt->samples * sizeof(int16_t)], 
 		(uint8_t *) f->data, f->samples);
 
-	/* sample rate the same between formats, but don't assume that it won't output more ... */
 	pvt->samples += out_samples;
 
 	pvt->datalen += (out_samples * sizeof(int16_t));
@@ -137,21 +120,6 @@
 
 	outlen = g722_encode(&tmp->g722, (uint8_t *) (&pvt->outbuf[pvt->datalen]), 
 		(int16_t *) f->data, f->samples);
-
-	pvt->samples += outlen;
-
-	pvt->datalen += outlen;
-
-	return 0;
-}
-
-static int lin16tog722_framein(struct ast_trans_pvt *pvt, struct ast_frame *f)
-{
-	struct g722_encoder_pvt *tmp = pvt->pvt;
-	int16_t *src = f->data;
-	int outlen;
-
-	outlen = g722_encode(&tmp->g722, (uint8_t*)(&pvt->outbuf[pvt->datalen]), src, f->samples);
 
 	pvt->samples += outlen;
 
@@ -246,7 +214,7 @@
 	.srcfmt = AST_FORMAT_G722,
 	.dstfmt = AST_FORMAT_SLINEAR16,
 	.newpvt = g722tolin16_new,	/* same for both directions */
-	.framein = g722tolin16_framein,
+	.framein = g722tolin_framein,
 	.sample = g722tolin16_sample,
 	.desc_size = sizeof(struct g722_decoder_pvt),
 	.buffer_samples = BUFFER_SAMPLES / sizeof(int16_t),
@@ -259,7 +227,7 @@
 	.srcfmt = AST_FORMAT_SLINEAR16,
 	.dstfmt = AST_FORMAT_G722,
 	.newpvt = lin16tog722_new,	/* same for both directions */
-	.framein = lin16tog722_framein,
+	.framein = lintog722_framein,
 	.sample = lin16tog722_sample,
 	.desc_size = sizeof(struct g722_encoder_pvt),
 	.buffer_samples = BUFFER_SAMPLES * 2,




More information about the asterisk-commits mailing list