46#define BUFFER_SAMPLES 8096
56static int indsft[8] = { -1, -1, -1, -1, 2, 4, 6, 8 };
63 16, 17, 19, 21, 23, 25, 28, 31, 34, 37, 41, 45, 50, 55, 60, 66, 73,
64 80, 88, 97, 107, 118, 130, 143, 157, 173, 190, 209, 230, 253, 279,
65 307, 337, 371, 408, 449, 494, 544, 598, 658, 724, 796, 876, 963,
66 1060, 1166, 1282, 1411, 1552
99 sign = encoded & 0x08;
102 diff = (((encoded << 1) + 1) * step) >> 3;
111 if ((encoded >> 1) & step & 0x1)
117 if (
state->next_flag & 0x1)
119 else if (
state->next_flag & 0x2)
122 state->signal += diff;
124 if (
state->signal > 2047)
125 state->signal = 2047;
126 else if (
state->signal < -2047)
127 state->signal = -2047;
129 state->next_flag = 0;
133 state->zero_count = 0;
134 else if (++(
state->zero_count) == 24) {
135 state->zero_count = 0;
136 if (
state->signal > 0)
137 state->next_flag = 0x1;
138 else if (
state->signal < 0)
139 state->next_flag = 0x2;
144 if (
state->ssindex < 0)
146 else if (
state->ssindex > 48)
149 return state->signal << 4;
176 diff = csig -
state->signal;
180 encoded = (-diff << 2) / step;
185 encoded = (diff << 2) / step;
233 unsigned char *src = f->
data.
ptr;
237 *dst++ =
decode((*src >> 4) & 0xf, &
tmp->state);
238 *dst++ =
decode(*src++ & 0x0f, &
tmp->state);
268 for (i = 0; i < pvt->
samples; i += 2) {
290 .
name =
"adpcmtolin",
310 .
name =
"lintoadpcm",
Asterisk main include file. File version handling, generic pbx functions.
static struct ast_translator adpcmtolin
static struct ast_translator lintoadpcm
static int lintoadpcm_framein(struct ast_trans_pvt *pvt, struct ast_frame *f)
fill input buffer with 16-bit signed linear PCM values.
static int load_module(void)
static int unload_module(void)
static int adpcm(short csig, struct adpcm_state *state)
static struct ast_frame * lintoadpcm_frameout(struct ast_trans_pvt *pvt)
convert inbuf and store into frame
static int adpcmtolin_framein(struct ast_trans_pvt *pvt, struct ast_frame *f)
decode 4-bit adpcm frame data and store in output buffer
static short decode(int encoded, struct adpcm_state *state)
static struct ast_frame * adpcm_sample(void)
Configuration File Parser.
A set of macros to manage forward-linked lists.
Asterisk locking-related definitions:
Asterisk module definitions.
#define AST_MODULE_INFO(keystr, flags_to_set, desc, fields...)
@ AST_MODULE_SUPPORT_CORE
#define ASTERISK_GPL_KEY
The text the key() function should return.
@ AST_MODULE_LOAD_SUCCESS
@ AST_MODULE_LOAD_DECLINE
Module has failed to load, may be in an inconsistent state.
static struct ast_frame * slin8_sample(void)
Workspace for translating ADPCM signals to signed linear.
Workspace for translating signed linear signals to ADPCM.
int16_t inbuf[BUFFER_SAMPLES]
Data structure associated with a single frame of data.
union ast_frame::@226 data
Default structure for translators, with the basic fields and buffers, all allocated as part of the sa...
int datalen
actual space used in outbuf
union ast_trans_pvt::@287 outbuf
Descriptor of a translator.
Support for translation of data formats. translate.c.
#define ast_register_translator(t)
See __ast_register_translator()
int ast_unregister_translator(struct ast_translator *t)
Unregister a translator Unregisters the given translator.
struct ast_frame * ast_trans_frameout(struct ast_trans_pvt *pvt, int datalen, int samples)
generic frameout function