codec_g726.c - translate between signed linear and ITU G.726-32kbps (both RFC3551 and AAL2 codeword packing) More...
#include "asterisk.h"#include "asterisk/lock.h"#include "asterisk/linkedlists.h"#include "asterisk/module.h"#include "asterisk/config.h"#include "asterisk/translate.h"#include "asterisk/utils.h"#include "log2comp.h"#include "asterisk/slin.h"#include "ex_g726.h"
Go to the source code of this file.
Data Structures | |
| struct | g726_coder_pvt |
| struct | g726_state |
Defines | |
| #define | BUF_SHIFT 5 |
| #define | BUFFER_SAMPLES 8096 |
| #define | WANT_ASM |
Functions | |
| static void | __reg_module (void) |
| static void | __unreg_module (void) |
| static int | fmult (int an, int srn) |
| static int | g726_decode (int i, struct g726_state *state_ptr) |
| static int | g726_encode (int sl, struct g726_state *state_ptr) |
| static void | g726_init_state (struct g726_state *state_ptr) |
| static int | g726aal2tolin_framein (struct ast_trans_pvt *pvt, struct ast_frame *f) |
| decode packed 4-bit G726 values (AAL2 packing) and store in buffer. | |
| static int | g726tolin_framein (struct ast_trans_pvt *pvt, struct ast_frame *f) |
| decode packed 4-bit G726 values (RFC3551 packing) and store in buffer. | |
| static int | lintog726_framein (struct ast_trans_pvt *pvt, struct ast_frame *f) |
| compress and store data (4-bit G726 samples, RFC3551 packing) in outbuf | |
| static int | lintog726_new (struct ast_trans_pvt *pvt) |
| init a new instance of g726_coder_pvt. | |
| static int | lintog726aal2_framein (struct ast_trans_pvt *pvt, struct ast_frame *f) |
| compress and store data (4-bit G726 samples, AAL2 packing) in outbuf | |
| static int | load_module (void) |
| static int | predictor_pole (struct g726_state *state_ptr) |
| static int | predictor_zero (struct g726_state *state_ptr) |
| static int | quan (int val, int *table, int size) |
| static int | quantize (int d, int y, int *table, int size) |
| static int | reconstruct (int sign, int dqln, int y) |
| static int | reload (void) |
| static int | step_size (struct g726_state *state_ptr) |
| static int | unload_module (void) |
| static void | update (int code_size, int y, int wi, int fi, int dq, int sr, int dqsez, struct g726_state *state_ptr) |
Variables | |
| static struct ast_module_info __MODULE_INFO_SECTION | __mod_info = { __MODULE_INFO_GLOBALS .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT , .description = "ITU G.726-32kbps G726 Transcoder" , .key = ASTERISK_GPL_KEY , .buildopt_sum = AST_BUILDOPT_SUM, .load = load_module, .unload = unload_module, .reload = reload, } |
| static int | _dqlntab [16] |
| static int | _fitab [16] |
| static int | _witab [16] |
| static struct ast_module_info * | ast_module_info = &__mod_info |
| static struct ast_translator | g726aal2tolin |
| static struct ast_translator | g726tolin |
| static struct ast_translator | lintog726 |
| static struct ast_translator | lintog726aal2 |
| static int | qtab_721 [7] = {-124, 80, 178, 246, 300, 349, 400} |
codec_g726.c - translate between signed linear and ITU G.726-32kbps (both RFC3551 and AAL2 codeword packing)
Definition in file codec_g726.c.
| #define BUF_SHIFT 5 |
Definition at line 58 of file codec_g726.c.
| #define BUFFER_SAMPLES 8096 |
Definition at line 57 of file codec_g726.c.
| #define WANT_ASM |
Definition at line 41 of file codec_g726.c.
| static void __reg_module | ( | void | ) | [static] |
Definition at line 860 of file codec_g726.c.
| static void __unreg_module | ( | void | ) | [static] |
Definition at line 860 of file codec_g726.c.
| static int fmult | ( | int | an, |
| int | srn | ||
| ) | [static] |
Definition at line 203 of file codec_g726.c.
References ilog2().
Referenced by predictor_pole(), and predictor_zero().
{
int anmag, anexp, anmant;
int wanexp, wanmant;
int retval;
anmag = (an > 0) ? an : ((-an) & 0x1FFF);
anexp = ilog2(anmag) - 5;
anmant = (anmag == 0) ? 32 :
(anexp >= 0) ? anmag >> anexp : anmag << -anexp;
wanexp = anexp + ((srn >> 6) & 0xF) - 13;
wanmant = (anmant * (srn & 077) + 0x30) >> 4;
retval = (wanexp >= 0) ? ((wanmant << wanexp) & 0x7FFF) :
(wanmant >> -wanexp);
return (((an ^ srn) < 0) ? -retval : retval);
}
| static int g726_decode | ( | int | i, |
| struct g726_state * | state_ptr | ||
| ) | [static] |
Definition at line 576 of file codec_g726.c.
References predictor_pole(), predictor_zero(), reconstruct(), step_size(), and update().
Referenced by g726aal2tolin_framein(), and g726tolin_framein().
{
int sezi, sez, se; /* ACCUM */
int y; /* MIX */
int sr; /* ADDB */
int dq;
int dqsez;
i &= 0x0f; /* mask to get proper bits */
#ifdef NOT_BLI
sezi = predictor_zero(state_ptr);
sez = sezi;
se = sezi + predictor_pole(state_ptr); /* estimated signal */
#else
sezi = predictor_zero(state_ptr);
sez = sezi >> 1;
se = (sezi + predictor_pole(state_ptr)) >> 1; /* estimated signal */
#endif
y = step_size(state_ptr); /* dynamic quantizer step size */
dq = reconstruct(i & 8, _dqlntab[i], y); /* quantized diff. */
#ifdef NOT_BLI
sr = se + dq; /* reconst. signal */
dqsez = dq + sez; /* pole prediction diff. */
#else
sr = (dq < 0) ? se - (dq & 0x3FFF) : se + dq; /* reconst. signal */
dqsez = sr - se + sez; /* pole prediction diff. */
#endif
update(4, y, _witab[i] << 5, _fitab[i], dq, sr, dqsez, state_ptr);
#ifdef NOT_BLI
return (sr >> 10); /* sr was 26-bit dynamic range */
#else
return (sr << 2); /* sr was 14-bit dynamic range */
#endif
}
| static int g726_encode | ( | int | sl, |
| struct g726_state * | state_ptr | ||
| ) | [static] |
Definition at line 622 of file codec_g726.c.
References predictor_pole(), predictor_zero(), quantize(), reconstruct(), step_size(), and update().
Referenced by lintog726_framein(), and lintog726aal2_framein().
{
int sezi, se, sez; /* ACCUM */
int d; /* SUBTA */
int sr; /* ADDB */
int y; /* MIX */
int dqsez; /* ADDC */
int dq, i;
#ifdef NOT_BLI
sl <<= 10; /* 26-bit dynamic range */
sezi = predictor_zero(state_ptr);
sez = sezi;
se = sezi + predictor_pole(state_ptr); /* estimated signal */
#else
sl >>= 2; /* 14-bit dynamic range */
sezi = predictor_zero(state_ptr);
sez = sezi >> 1;
se = (sezi + predictor_pole(state_ptr)) >> 1; /* estimated signal */
#endif
d = sl - se; /* estimation difference */
/* quantize the prediction difference */
y = step_size(state_ptr); /* quantizer step size */
#ifdef NOT_BLI
d /= 0x1000;
#endif
i = quantize(d, y, qtab_721, 7); /* i = G726 code */
dq = reconstruct(i & 8, _dqlntab[i], y); /* quantized est diff */
#ifdef NOT_BLI
sr = se + dq; /* reconst. signal */
dqsez = dq + sez; /* pole prediction diff. */
#else
sr = (dq < 0) ? se - (dq & 0x3FFF) : se + dq; /* reconst. signal */
dqsez = sr - se + sez; /* pole prediction diff. */
#endif
update(4, y, _witab[i] << 5, _fitab[i], dq, sr, dqsez, state_ptr);
return (i);
}
| static void g726_init_state | ( | struct g726_state * | state_ptr | ) | [static] |
Definition at line 121 of file codec_g726.c.
References g726_state::a, g726_state::ap, g726_state::b, g726_state::dml, g726_state::dms, g726_state::dq, g726_state::pk, g726_state::sr, g726_state::td, g726_state::yl, and g726_state::yu.
Referenced by lintog726_new().
{
int cnta;
state_ptr->yl = 34816;
state_ptr->yu = 544;
state_ptr->dms = 0;
state_ptr->dml = 0;
state_ptr->ap = 0;
for (cnta = 0; cnta < 2; cnta++) {
state_ptr->a[cnta] = 0;
state_ptr->pk[cnta] = 0;
#ifdef NOT_BLI
state_ptr->sr[cnta] = 1;
#else
state_ptr->sr[cnta] = 32;
#endif
}
for (cnta = 0; cnta < 6; cnta++) {
state_ptr->b[cnta] = 0;
#ifdef NOT_BLI
state_ptr->dq[cnta] = 1;
#else
state_ptr->dq[cnta] = 32;
#endif
}
state_ptr->td = 0;
}
| static int g726aal2tolin_framein | ( | struct ast_trans_pvt * | pvt, |
| struct ast_frame * | f | ||
| ) | [static] |
decode packed 4-bit G726 values (AAL2 packing) and store in buffer.
Definition at line 691 of file codec_g726.c.
References ast_frame::data, ast_trans_pvt::datalen, ast_frame::datalen, g726_coder_pvt::g726, g726_decode(), ast_trans_pvt::i16, ast_trans_pvt::outbuf, ast_frame::ptr, ast_trans_pvt::pvt, ast_frame::samples, and ast_trans_pvt::samples.
{
struct g726_coder_pvt *tmp = pvt->pvt;
unsigned char *src = f->data.ptr;
int16_t *dst = pvt->outbuf.i16 + pvt->samples;
unsigned int i;
for (i = 0; i < f->datalen; i++) {
*dst++ = g726_decode((src[i] >> 4) & 0xf, &tmp->g726);
*dst++ = g726_decode(src[i] & 0x0f, &tmp->g726);
}
pvt->samples += f->samples;
pvt->datalen += 2 * f->samples; /* 2 bytes/sample */
return 0;
}
| static int g726tolin_framein | ( | struct ast_trans_pvt * | pvt, |
| struct ast_frame * | f | ||
| ) | [static] |
decode packed 4-bit G726 values (RFC3551 packing) and store in buffer.
Definition at line 732 of file codec_g726.c.
References ast_frame::data, ast_trans_pvt::datalen, ast_frame::datalen, g726_coder_pvt::g726, g726_decode(), ast_trans_pvt::i16, ast_trans_pvt::outbuf, ast_frame::ptr, ast_trans_pvt::pvt, ast_frame::samples, and ast_trans_pvt::samples.
{
struct g726_coder_pvt *tmp = pvt->pvt;
unsigned char *src = f->data.ptr;
int16_t *dst = pvt->outbuf.i16 + pvt->samples;
unsigned int i;
for (i = 0; i < f->datalen; i++) {
*dst++ = g726_decode(src[i] & 0x0f, &tmp->g726);
*dst++ = g726_decode((src[i] >> 4) & 0xf, &tmp->g726);
}
pvt->samples += f->samples;
pvt->datalen += 2 * f->samples; /* 2 bytes/sample */
return 0;
}
| static int lintog726_framein | ( | struct ast_trans_pvt * | pvt, |
| struct ast_frame * | f | ||
| ) | [static] |
compress and store data (4-bit G726 samples, RFC3551 packing) in outbuf
Definition at line 751 of file codec_g726.c.
References ast_trans_pvt::c, ast_frame::data, ast_trans_pvt::datalen, g726_coder_pvt::g726, g726_encode(), g726_coder_pvt::next_flag, ast_trans_pvt::outbuf, ast_frame::ptr, ast_trans_pvt::pvt, ast_trans_pvt::samples, and ast_frame::samples.
{
struct g726_coder_pvt *tmp = pvt->pvt;
int16_t *src = f->data.ptr;
unsigned int i;
for (i = 0; i < f->samples; i++) {
unsigned char d = g726_encode(src[i], &tmp->g726); /* this sample */
if (tmp->next_flag & 0x80) { /* merge with leftover sample */
pvt->outbuf.c[pvt->datalen++] = (d << 4) | (tmp->next_flag & 0xf);
pvt->samples += 2; /* 2 samples per byte */
tmp->next_flag = 0;
} else {
tmp->next_flag = 0x80 | d;
}
}
return 0;
}
| static int lintog726_new | ( | struct ast_trans_pvt * | pvt | ) | [static] |
init a new instance of g726_coder_pvt.
Definition at line 681 of file codec_g726.c.
References g726_coder_pvt::g726, g726_init_state(), and ast_trans_pvt::pvt.
{
struct g726_coder_pvt *tmp = pvt->pvt;
g726_init_state(&tmp->g726);
return 0;
}
| static int lintog726aal2_framein | ( | struct ast_trans_pvt * | pvt, |
| struct ast_frame * | f | ||
| ) | [static] |
compress and store data (4-bit G726 samples, AAL2 packing) in outbuf
Definition at line 710 of file codec_g726.c.
References ast_trans_pvt::c, ast_frame::data, ast_trans_pvt::datalen, g726_coder_pvt::g726, g726_encode(), g726_coder_pvt::next_flag, ast_trans_pvt::outbuf, ast_frame::ptr, ast_trans_pvt::pvt, ast_trans_pvt::samples, and ast_frame::samples.
{
struct g726_coder_pvt *tmp = pvt->pvt;
int16_t *src = f->data.ptr;
unsigned int i;
for (i = 0; i < f->samples; i++) {
unsigned char d = g726_encode(src[i], &tmp->g726); /* this sample */
if (tmp->next_flag & 0x80) { /* merge with leftover sample */
pvt->outbuf.c[pvt->datalen++] = ((tmp->next_flag & 0xf)<< 4) | d;
pvt->samples += 2; /* 2 samples per byte */
tmp->next_flag = 0;
} else {
tmp->next_flag = 0x80 | d;
}
}
return 0;
}
| static int load_module | ( | void | ) | [static] |
Definition at line 838 of file codec_g726.c.
References AST_MODULE_LOAD_FAILURE, AST_MODULE_LOAD_SUCCESS, ast_register_translator, and unload_module().
{
int res = 0;
res |= ast_register_translator(&g726tolin);
res |= ast_register_translator(&lintog726);
res |= ast_register_translator(&g726aal2tolin);
res |= ast_register_translator(&lintog726aal2);
if (res) {
unload_module();
return AST_MODULE_LOAD_FAILURE;
}
return AST_MODULE_LOAD_SUCCESS;
}
| static int predictor_pole | ( | struct g726_state * | state_ptr | ) | [static] |
Definition at line 231 of file codec_g726.c.
References g726_state::a, fmult(), and g726_state::sr.
Referenced by g726_decode(), and g726_encode().
| static int predictor_zero | ( | struct g726_state * | state_ptr | ) | [static] |
Definition at line 222 of file codec_g726.c.
References g726_state::b, g726_state::dq, and fmult().
Referenced by g726_decode(), and g726_encode().
| static int quan | ( | int | val, |
| int * | table, | ||
| int | size | ||
| ) | [static] |
| static int quantize | ( | int | d, |
| int | y, | ||
| int * | table, | ||
| int | size | ||
| ) | [static] |
Definition at line 274 of file codec_g726.c.
References ilog2(), and quan().
Referenced by g726_encode().
{
int dqm; /* Magnitude of 'd' */
int exp; /* Integer part of base 2 log of 'd' */
int mant; /* Fractional part of base 2 log */
int dl; /* Log of magnitude of 'd' */
int dln; /* Step size scale factor normalized log */
int i;
/*
* LOG
*
* Compute base 2 log of 'd', and store in 'dl'.
*/
dqm = abs(d);
exp = ilog2(dqm);
if (exp < 0)
exp = 0;
mant = ((dqm << 7) >> exp) & 0x7F; /* Fractional portion. */
dl = (exp << 7) | mant;
/*
* SUBTB
*
* "Divide" by step size multiplier.
*/
dln = dl - (y >> 2);
/*
* QUAN
*
* Obtain codword i for 'd'.
*/
i = quan(dln, table, size);
if (d < 0) /* take 1's complement of i */
return ((size << 1) + 1 - i);
else if (i == 0) /* take 1's complement of 0 */
return ((size << 1) + 1); /* new in 1988 */
else
return (i);
}
| static int reconstruct | ( | int | sign, |
| int | dqln, | ||
| int | y | ||
| ) | [static] |
Definition at line 327 of file codec_g726.c.
Referenced by bridge_p2p_rtp_write(), g726_decode(), and g726_encode().
{
int dql; /* Log of 'dq' magnitude */
int dex; /* Integer part of log */
int dqt;
int dq; /* Reconstructed difference signal sample */
dql = dqln + (y >> 2); /* ADDA */
if (dql < 0) {
#ifdef NOT_BLI
return (sign) ? -1 : 1;
#else
return (sign) ? -0x8000 : 0;
#endif
} else { /* ANTILOG */
dex = (dql >> 7) & 15;
dqt = 128 + (dql & 127);
#ifdef NOT_BLI
dq = ((dqt << 19) >> (14 - dex));
return (sign) ? -dq : dq;
#else
dq = (dqt << 7) >> (14 - dex);
return (sign) ? (dq - 0x8000) : dq;
#endif
}
}
| static int reload | ( | void | ) | [static] |
Definition at line 820 of file codec_g726.c.
References AST_MODULE_LOAD_SUCCESS.
{
return AST_MODULE_LOAD_SUCCESS;
}
| static int step_size | ( | struct g726_state * | state_ptr | ) | [static] |
Definition at line 245 of file codec_g726.c.
References g726_state::ap, g726_state::yl, and g726_state::yu.
Referenced by g726_decode(), and g726_encode().
| static int unload_module | ( | void | ) | [static] |
Definition at line 825 of file codec_g726.c.
References ast_unregister_translator().
Referenced by load_module().
{
int res = 0;
res |= ast_unregister_translator(&g726tolin);
res |= ast_unregister_translator(&lintog726);
res |= ast_unregister_translator(&g726aal2tolin);
res |= ast_unregister_translator(&lintog726aal2);
return res;
}
| static void update | ( | int | code_size, |
| int | y, | ||
| int | wi, | ||
| int | fi, | ||
| int | dq, | ||
| int | sr, | ||
| int | dqsez, | ||
| struct g726_state * | state_ptr | ||
| ) | [static] |
Definition at line 363 of file codec_g726.c.
References g726_state::a, g726_state::ap, g726_state::b, g726_state::dml, g726_state::dms, g726_state::dq, ilog2(), g726_state::pk, g726_state::sr, g726_state::td, g726_state::yl, and g726_state::yu.
Referenced by config_device(), config_line(), g726_decode(), and g726_encode().
{
int cnt;
int mag; /* Adaptive predictor, FLOAT A */
#ifndef NOT_BLI
int exp;
#endif
int a2p=0; /* LIMC */
int a1ul; /* UPA1 */
int pks1; /* UPA2 */
int fa1;
int tr; /* tone/transition detector */
int ylint, thr2, dqthr;
int ylfrac, thr1;
int pk0;
pk0 = (dqsez < 0) ? 1 : 0; /* needed in updating predictor poles */
#ifdef NOT_BLI
mag = abs(dq / 0x1000); /* prediction difference magnitude */
#else
mag = dq & 0x7FFF; /* prediction difference magnitude */
#endif
/* TRANS */
ylint = state_ptr->yl >> 15; /* exponent part of yl */
ylfrac = (state_ptr->yl >> 10) & 0x1F; /* fractional part of yl */
thr1 = (32 + ylfrac) << ylint; /* threshold */
thr2 = (ylint > 9) ? 31 << 10 : thr1; /* limit thr2 to 31 << 10 */
dqthr = (thr2 + (thr2 >> 1)) >> 1; /* dqthr = 0.75 * thr2 */
if (state_ptr->td == 0) /* signal supposed voice */
tr = 0;
else if (mag <= dqthr) /* supposed data, but small mag */
tr = 0; /* treated as voice */
else /* signal is data (modem) */
tr = 1;
/*
* Quantizer scale factor adaptation.
*/
/* FUNCTW & FILTD & DELAY */
/* update non-steady state step size multiplier */
state_ptr->yu = y + ((wi - y) >> 5);
/* LIMB */
if (state_ptr->yu < 544) /* 544 <= yu <= 5120 */
state_ptr->yu = 544;
else if (state_ptr->yu > 5120)
state_ptr->yu = 5120;
/* FILTE & DELAY */
/* update steady state step size multiplier */
state_ptr->yl += state_ptr->yu + ((-state_ptr->yl) >> 6);
/*
* Adaptive predictor coefficients.
*/
if (tr == 1) { /* reset a's and b's for modem signal */
state_ptr->a[0] = 0;
state_ptr->a[1] = 0;
state_ptr->b[0] = 0;
state_ptr->b[1] = 0;
state_ptr->b[2] = 0;
state_ptr->b[3] = 0;
state_ptr->b[4] = 0;
state_ptr->b[5] = 0;
} else { /* update a's and b's */
pks1 = pk0 ^ state_ptr->pk[0]; /* UPA2 */
/* update predictor pole a[1] */
a2p = state_ptr->a[1] - (state_ptr->a[1] >> 7);
if (dqsez != 0) {
fa1 = (pks1) ? state_ptr->a[0] : -state_ptr->a[0];
if (fa1 < -8191) /* a2p = function of fa1 */
a2p -= 0x100;
else if (fa1 > 8191)
a2p += 0xFF;
else
a2p += fa1 >> 5;
if (pk0 ^ state_ptr->pk[1])
/* LIMC */
if (a2p <= -12160)
a2p = -12288;
else if (a2p >= 12416)
a2p = 12288;
else
a2p -= 0x80;
else if (a2p <= -12416)
a2p = -12288;
else if (a2p >= 12160)
a2p = 12288;
else
a2p += 0x80;
}
/* TRIGB & DELAY */
state_ptr->a[1] = a2p;
/* UPA1 */
/* update predictor pole a[0] */
state_ptr->a[0] -= state_ptr->a[0] >> 8;
if (dqsez != 0) {
if (pks1 == 0)
state_ptr->a[0] += 192;
else
state_ptr->a[0] -= 192;
}
/* LIMD */
a1ul = 15360 - a2p;
if (state_ptr->a[0] < -a1ul)
state_ptr->a[0] = -a1ul;
else if (state_ptr->a[0] > a1ul)
state_ptr->a[0] = a1ul;
/* UPB : update predictor zeros b[6] */
for (cnt = 0; cnt < 6; cnt++) {
if (code_size == 5) /* for 40Kbps G.723 */
state_ptr->b[cnt] -= state_ptr->b[cnt] >> 9;
else /* for G.721 and 24Kbps G.723 */
state_ptr->b[cnt] -= state_ptr->b[cnt] >> 8;
if (mag)
{ /* XOR */
if ((dq ^ state_ptr->dq[cnt]) >= 0)
state_ptr->b[cnt] += 128;
else
state_ptr->b[cnt] -= 128;
}
}
}
for (cnt = 5; cnt > 0; cnt--)
state_ptr->dq[cnt] = state_ptr->dq[cnt-1];
#ifdef NOT_BLI
state_ptr->dq[0] = dq;
#else
/* FLOAT A : convert dq[0] to 4-bit exp, 6-bit mantissa f.p. */
if (mag == 0) {
state_ptr->dq[0] = (dq >= 0) ? 0x20 : 0x20 - 0x400;
} else {
exp = ilog2(mag) + 1;
state_ptr->dq[0] = (dq >= 0) ?
(exp << 6) + ((mag << 6) >> exp) :
(exp << 6) + ((mag << 6) >> exp) - 0x400;
}
#endif
state_ptr->sr[1] = state_ptr->sr[0];
#ifdef NOT_BLI
state_ptr->sr[0] = sr;
#else
/* FLOAT B : convert sr to 4-bit exp., 6-bit mantissa f.p. */
if (sr == 0) {
state_ptr->sr[0] = 0x20;
} else if (sr > 0) {
exp = ilog2(sr) + 1;
state_ptr->sr[0] = (exp << 6) + ((sr << 6) >> exp);
} else if (sr > -0x8000) {
mag = -sr;
exp = ilog2(mag) + 1;
state_ptr->sr[0] = (exp << 6) + ((mag << 6) >> exp) - 0x400;
} else
state_ptr->sr[0] = 0x20 - 0x400;
#endif
/* DELAY A */
state_ptr->pk[1] = state_ptr->pk[0];
state_ptr->pk[0] = pk0;
/* TONE */
if (tr == 1) /* this sample has been treated as data */
state_ptr->td = 0; /* next one will be treated as voice */
else if (a2p < -11776) /* small sample-to-sample correlation */
state_ptr->td = 1; /* signal may be data */
else /* signal is voice */
state_ptr->td = 0;
/*
* Adaptation speed control.
*/
state_ptr->dms += (fi - state_ptr->dms) >> 5; /* FILTA */
state_ptr->dml += (((fi << 2) - state_ptr->dml) >> 7); /* FILTB */
if (tr == 1)
state_ptr->ap = 256;
else if (y < 1536) /* SUBTC */
state_ptr->ap += (0x200 - state_ptr->ap) >> 4;
else if (state_ptr->td == 1)
state_ptr->ap += (0x200 - state_ptr->ap) >> 4;
else if (abs((state_ptr->dms << 2) - state_ptr->dml) >=
(state_ptr->dml >> 3))
state_ptr->ap += (0x200 - state_ptr->ap) >> 4;
else
state_ptr->ap += (-state_ptr->ap) >> 4;
}
struct ast_module_info __MODULE_INFO_SECTION __mod_info = { __MODULE_INFO_GLOBALS .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT , .description = "ITU G.726-32kbps G726 Transcoder" , .key = ASTERISK_GPL_KEY , .buildopt_sum = AST_BUILDOPT_SUM, .load = load_module, .unload = unload_module, .reload = reload, } [static] |
Definition at line 860 of file codec_g726.c.
int _dqlntab[16] [static] |
{-2048, 4, 135, 213, 273, 323, 373, 425,
425, 373, 323, 273, 213, 135, 4, -2048}
Definition at line 99 of file codec_g726.c.
int _fitab[16] [static] |
{0, 0, 0, 0x200, 0x200, 0x200, 0x600, 0xE00,
0xE00, 0x600, 0x200, 0x200, 0x200, 0, 0, 0}
Definition at line 110 of file codec_g726.c.
int _witab[16] [static] |
{-12, 18, 41, 64, 112, 198, 355, 1122,
1122, 355, 198, 112, 64, 41, 18, -12}
Definition at line 103 of file codec_g726.c.
struct ast_module_info* ast_module_info = &__mod_info [static] |
Definition at line 860 of file codec_g726.c.
struct ast_translator g726aal2tolin [static] |
Definition at line 796 of file codec_g726.c.
struct ast_translator g726tolin [static] |
Definition at line 772 of file codec_g726.c.
struct ast_translator lintog726 [static] |
Definition at line 784 of file codec_g726.c.
struct ast_translator lintog726aal2 [static] |
Definition at line 808 of file codec_g726.c.
int qtab_721[7] = {-124, 80, 178, 246, 300, 349, 400} [static] |
Definition at line 94 of file codec_g726.c.