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)
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;
202 for ( ; i < s->
pitch; i++) {
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));
263 if (!strcasecmp(
var->name,
"genericplc")) {
265 }
else if (!strcasecmp(
var->name,
"genericplc_on_equal_codecs")) {
299 .
requires =
"extconfig",
Asterisk main include file. File version handling, generic pbx functions.
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
struct ast_flags ast_options
@ AST_OPT_FLAG_GENERIC_PLC
@ AST_OPT_FLAG_GENERIC_PLC_ON_EQUAL_CODECS
Configuration File Parser.
#define ast_config_load(filename, flags)
Load a config file.
#define CONFIG_STATUS_FILEMISSING
#define CONFIG_STATUS_FILEUNCHANGED
#define CONFIG_STATUS_FILEINVALID
void ast_config_destroy(struct ast_config *cfg)
Destroys a config.
struct ast_variable * ast_variable_browse(const struct ast_config *config, const char *category_name)
Asterisk module definitions.
@ AST_MODFLAG_GLOBAL_SYMBOLS
#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
#define ast_opt_generic_plc
int plc_fillin(plc_state_t *s, int16_t amp[], int len)
Fill-in a block of missing audio samples.
static void normalise_history(plc_state_t *s)
static int reload_module(void)
static int __inline__ amdf_pitch(int min_pitch, int max_pitch, int16_t amp[], int len)
static int16_t fsaturate(double damp)
static void save_history(plc_state_t *s, int16_t *buf, int len)
plc_state_t * plc_init(plc_state_t *s)
Process a block of received V.29 modem audio samples.
static int load_module(void)
static int unload_module(void)
#define ATTENUATION_INCREMENT
int plc_rx(plc_state_t *s, int16_t amp[], int len)
Process a block of received audio samples.
SpanDSP - a series of DSP components for telephony.
int attribute_pure ast_true(const char *val)
Make sure something is true. Determine if a string containing a boolean value is "true"....
Structure used to handle boolean flags.
Structure for variables, used for configurations and for channel variables.
int16_t history[PLC_HISTORY_LEN]
float pitchbuf[PLC_PITCH_MIN]
#define ast_set2_flag(p, value, flag)