52 #if !defined(INT16_MAX)
53 #define INT16_MAX (32767)
54 #define INT16_MIN (-32767-1)
58 #define ATTENUATION_INCREMENT 0.0025
60 #define ms_to_samples(t) (((t)*DEFAULT_SAMPLE_RATE)/1000)
68 return (int16_t) rint(damp);
108 static int __inline__
amdf_pitch(
int min_pitch,
int max_pitch, int16_t amp[],
int len)
118 for (i = max_pitch; i <= min_pitch; i++) {
120 for (j = 0; j <
len; j++)
121 acc += abs(amp[i + j] - amp[j]);
148 pitch_overlap = s->
pitch >> 2;
149 if (pitch_overlap > len)
154 new_step = 1.0/pitch_overlap;
155 old_step = new_step*gain;
156 new_weight = new_step;
157 old_weight = (1.0 - new_step)*gain;
158 for (i = 0; i < pitch_overlap; i++) {
162 new_weight += new_step;
163 old_weight -= old_step;
164 if (old_weight < 0.0)
193 pitch_overlap = s->
pitch >> 2;
197 for (i = 0; i < s->
pitch - pitch_overlap; i++)
200 new_step = 1.0/pitch_overlap;
201 new_weight = new_step;
204 new_weight += new_step;
213 new_step = 1.0 / pitch_overlap;
215 new_weight = new_step;
216 old_weight = 1.0 - new_step;
217 for (i = 0; i < pitch_overlap; i++) {
219 new_weight += new_step;
220 old_weight -= old_step;
221 if (old_weight < 0.0)
229 for ( ; gain > 0.0 && i <
len; i++) {
235 for ( ; i <
len; i++)
246 memset(s, 0,
sizeof(*s));
#define ATTENUATION_INCREMENT
Asterisk main include file. File version handling, generic pbx functions.
static void normalise_history(plc_state_t *s)
int16_t history[PLC_HISTORY_LEN]
int plc_fillin(plc_state_t *s, int16_t amp[], int len)
Fill-in a block of missing audio samples.
static int16_t fsaturate(double damp)
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
static void save_history(plc_state_t *s, int16_t *buf, int len)
SpanDSP - a series of DSP components for telephony.
int plc_rx(plc_state_t *s, int16_t amp[], int len)
Process a block of received audio samples.
static int __inline__ amdf_pitch(int min_pitch, int max_pitch, int16_t amp[], int len)
float pitchbuf[PLC_PITCH_MIN]
#define ASTERISK_FILE_VERSION(file, version)
Register/unregister a source code file with the core.
plc_state_t * plc_init(plc_state_t *s)
Process a block of received V.29 modem audio samples.