aboutsummaryrefslogtreecommitdiffstats
path: root/codecs
diff options
context:
space:
mode:
authormarkster <markster@f38db490-d61c-443f-a65b-d21fe96a405b>2004-03-11 19:57:10 +0000
committermarkster <markster@f38db490-d61c-443f-a65b-d21fe96a405b>2004-03-11 19:57:10 +0000
commitccb009fa09d2f1eb359c08185d1df6ea61377519 (patch)
treea2772c94bdead89b5134d8d8b7d654bff2e5e20c /codecs
parentd9165405b31082e40dd55deba5aa7d340181aa4d (diff)
Make ADPCM frames standard
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@2400 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'codecs')
-rwxr-xr-xcodecs/codec_adpcm.c41
1 files changed, 12 insertions, 29 deletions
diff --git a/codecs/codec_adpcm.c b/codecs/codec_adpcm.c
index 28e4a2794..0a949602e 100755
--- a/codecs/codec_adpcm.c
+++ b/codecs/codec_adpcm.c
@@ -27,7 +27,6 @@
#include <unistd.h>
#define BUFFER_SIZE 8096 /* size for the translation buffers */
-#define BUF_SHIFT 5
static ast_mutex_t localuser_lock = AST_MUTEX_INITIALIZER;
static int localusecnt = 0;
@@ -200,6 +199,10 @@ struct adpcm_decoder_pvt
struct ast_frame f;
char offset[AST_FRIENDLY_OFFSET]; /* Space to build offset */
short outbuf[BUFFER_SIZE]; /* Decoded signed linear values */
+ short ssindex;
+ short signal;
+ unsigned char zero_count;
+ unsigned char next_flag;
int tail;
};
@@ -272,41 +275,21 @@ adpcmtolin_framein (struct ast_translator_pvt *pvt, struct ast_frame *f)
{
struct adpcm_decoder_pvt *tmp = (struct adpcm_decoder_pvt *) pvt;
int x;
- short signal;
- short ssindex;
unsigned char *b;
- unsigned char zero_count;
- unsigned char next_flag;
-
- if (f->datalen < BUF_SHIFT) {
- ast_log(LOG_WARNING, "Didn't have at least %d bytes of input\n", BUF_SHIFT);
- return -1;
- }
- if ((f->datalen - BUF_SHIFT) * 4 > sizeof(tmp->outbuf)) {
+ if (f->datalen * 4 > sizeof(tmp->outbuf)) {
ast_log(LOG_WARNING, "Out of buffer space\n");
return -1;
}
- /* Reset ssindex and signal to frame's specified values */
b = f->data;
- ssindex = b[0];
- if (ssindex < 0)
- ssindex = 0;
- if (ssindex > 48)
- ssindex = 48;
-
- signal = (b[1] << 8) | b[2];
-
- zero_count = b[3];
- next_flag = b[4];
- for (x=BUF_SHIFT;x<f->datalen;x++) {
- decode((b[x] >> 4) & 0xf, &ssindex, &signal, &zero_count, &next_flag);
- tmp->outbuf[tmp->tail++] = signal << 4;
+ for (x=0;x<f->datalen;x++) {
+ decode((b[x] >> 4) & 0xf, &tmp->ssindex, &tmp->signal, &tmp->zero_count, &tmp->next_flag);
+ tmp->outbuf[tmp->tail++] = tmp->signal << 4;
- decode(b[x] & 0x0f, &ssindex, &signal, &zero_count, &next_flag);
- tmp->outbuf[tmp->tail++] = signal << 4;
+ decode(b[x] & 0x0f, &tmp->ssindex, &tmp->signal, &tmp->zero_count, &tmp->next_flag);
+ tmp->outbuf[tmp->tail++] = tmp->signal << 4;
}
return 0;
@@ -408,7 +391,7 @@ lintoadpcm_frameout (struct ast_translator_pvt *pvt)
adpcm0 = adpcm (tmp->inbuf[i], &tmp->ssindex, &tmp->signal, &tmp->zero_count, &tmp->next_flag);
adpcm1 = adpcm (tmp->inbuf[i+1], &tmp->ssindex, &tmp->signal, &tmp->zero_count, &tmp->next_flag);
- tmp->outbuf[i/2 + BUF_SHIFT] = (adpcm0 << 4) | adpcm1;
+ tmp->outbuf[i/2] = (adpcm0 << 4) | adpcm1;
};
@@ -419,7 +402,7 @@ lintoadpcm_frameout (struct ast_translator_pvt *pvt)
tmp->f.offset = AST_FRIENDLY_OFFSET;
tmp->f.src = __PRETTY_FUNCTION__;
tmp->f.data = tmp->outbuf;
- tmp->f.datalen = i_max / 2 + BUF_SHIFT;
+ tmp->f.datalen = i_max / 2;
/*
* If there is a signal left over (there should be no more than