Version 0.3.0 from FTP

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@556 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Mark Spencer
2002-11-29 02:14:13 +00:00
parent 55dc769bc3
commit d4cce257b2
15 changed files with 124 additions and 86 deletions

View File

@@ -100,14 +100,11 @@ static struct ast_translator_pvt *lpc10_dec_new()
static struct ast_frame *lintolpc10_sample()
{
static struct ast_frame f;
static int longer = 0;
f.frametype = AST_FRAME_VOICE;
f.subclass = AST_FORMAT_SLINEAR;
f.datalen = sizeof(slin_lpc10_ex);
/* Assume 8000 Hz */
f.timelen = LPC10_SAMPLES_PER_FRAME/8;
f.timelen += longer;
longer = 1- longer;
f.samples = LPC10_SAMPLES_PER_FRAME;
f.mallocd = 0;
f.offset = 0;
f.src = __PRETTY_FUNCTION__;
@@ -123,7 +120,7 @@ static struct ast_frame *lpc10tolin_sample()
f.datalen = sizeof(lpc10_slin_ex);
/* All frames are 22 ms long (maybe a little more -- why did he choose
LPC10_SAMPLES_PER_FRAME sample frames anyway?? */
f.timelen = LPC10_SAMPLES_PER_FRAME/8;
f.samples = LPC10_SAMPLES_PER_FRAME;
f.mallocd = 0;
f.offset = 0;
f.src = __PRETTY_FUNCTION__;
@@ -141,7 +138,7 @@ static struct ast_frame *lpc10tolin_frameout(struct ast_translator_pvt *tmp)
tmp->f.subclass = AST_FORMAT_SLINEAR;
tmp->f.datalen = tmp->tail * 2;
/* Assume 8000 Hz */
tmp->f.timelen = tmp->tail / 8;
tmp->f.samples = tmp->tail;
tmp->f.mallocd = 0;
tmp->f.offset = AST_FRIENDLY_OFFSET;
tmp->f.src = __PRETTY_FUNCTION__;
@@ -254,7 +251,7 @@ static struct ast_frame *lintolpc10_frameout(struct ast_translator_pvt *tmp)
if (tmp->tail < LPC10_SAMPLES_PER_FRAME)
return NULL;
/* Start with an empty frame */
tmp->f.timelen = 0;
tmp->f.samples = 0;
tmp->f.datalen = 0;
tmp->f.frametype = AST_FRAME_VOICE;
tmp->f.subclass = AST_FORMAT_LPC10;
@@ -270,9 +267,7 @@ static struct ast_frame *lintolpc10_frameout(struct ast_translator_pvt *tmp)
lpc10_encode(tmpbuf, bits, tmp->lpc10.enc);
build_bits(((unsigned char *)tmp->outbuf) + tmp->f.datalen, bits);
tmp->f.datalen += LPC10_BYTES_IN_COMPRESSED_FRAME;
tmp->f.timelen += 22;
/* We alternate between 22 and 23 ms to simulate 22.5 ms */
tmp->f.timelen += tmp->longer;
tmp->f.samples += LPC10_SAMPLES_PER_FRAME;
/* 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;