Skip to content
Snippets Groups Projects
Commit c67509e4 authored by Russell Bryant's avatar Russell Bryant
Browse files

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.


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@98218 65c4cc65-6c06-0410-ace0-fbb531ad65f3
parent 911fbb5d
Branches
Tags
No related merge requests found
...@@ -99,22 +99,6 @@ static int g722tolin16_new(struct ast_trans_pvt *pvt) ...@@ -99,22 +99,6 @@ static int g722tolin16_new(struct ast_trans_pvt *pvt)
} }
static int g722tolin_framein(struct ast_trans_pvt *pvt, struct ast_frame *f) 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; struct g722_decoder_pvt *tmp = pvt->pvt;
int out_samples; int out_samples;
...@@ -122,7 +106,6 @@ static int g722tolin16_framein(struct ast_trans_pvt *pvt, struct ast_frame *f) ...@@ -122,7 +106,6 @@ static int g722tolin16_framein(struct ast_trans_pvt *pvt, struct ast_frame *f)
out_samples = g722_decode(&tmp->g722, (int16_t *) &pvt->outbuf[pvt->samples * sizeof(int16_t)], out_samples = g722_decode(&tmp->g722, (int16_t *) &pvt->outbuf[pvt->samples * sizeof(int16_t)],
(uint8_t *) f->data, f->samples); (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->samples += out_samples;
pvt->datalen += (out_samples * sizeof(int16_t)); pvt->datalen += (out_samples * sizeof(int16_t));
...@@ -145,21 +128,6 @@ static int lintog722_framein(struct ast_trans_pvt *pvt, struct ast_frame *f) ...@@ -145,21 +128,6 @@ static int lintog722_framein(struct ast_trans_pvt *pvt, struct ast_frame *f)
return 0; 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;
pvt->datalen += outlen;
return 0;
}
static struct ast_frame *g722tolin_sample(void) static struct ast_frame *g722tolin_sample(void)
{ {
static struct ast_frame f = { static struct ast_frame f = {
...@@ -246,7 +214,7 @@ static struct ast_translator g722tolin16 = { ...@@ -246,7 +214,7 @@ static struct ast_translator g722tolin16 = {
.srcfmt = AST_FORMAT_G722, .srcfmt = AST_FORMAT_G722,
.dstfmt = AST_FORMAT_SLINEAR16, .dstfmt = AST_FORMAT_SLINEAR16,
.newpvt = g722tolin16_new, /* same for both directions */ .newpvt = g722tolin16_new, /* same for both directions */
.framein = g722tolin16_framein, .framein = g722tolin_framein,
.sample = g722tolin16_sample, .sample = g722tolin16_sample,
.desc_size = sizeof(struct g722_decoder_pvt), .desc_size = sizeof(struct g722_decoder_pvt),
.buffer_samples = BUFFER_SAMPLES / sizeof(int16_t), .buffer_samples = BUFFER_SAMPLES / sizeof(int16_t),
...@@ -259,7 +227,7 @@ static struct ast_translator lin16tog722 = { ...@@ -259,7 +227,7 @@ static struct ast_translator lin16tog722 = {
.srcfmt = AST_FORMAT_SLINEAR16, .srcfmt = AST_FORMAT_SLINEAR16,
.dstfmt = AST_FORMAT_G722, .dstfmt = AST_FORMAT_G722,
.newpvt = lin16tog722_new, /* same for both directions */ .newpvt = lin16tog722_new, /* same for both directions */
.framein = lin16tog722_framein, .framein = lintog722_framein,
.sample = lin16tog722_sample, .sample = lin16tog722_sample,
.desc_size = sizeof(struct g722_encoder_pvt), .desc_size = sizeof(struct g722_encoder_pvt),
.buffer_samples = BUFFER_SAMPLES * 2, .buffer_samples = BUFFER_SAMPLES * 2,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment