diff options
Diffstat (limited to 'mec.h')
-rwxr-xr-x | mec.h | 36 |
1 files changed, 32 insertions, 4 deletions
@@ -80,24 +80,49 @@ typedef struct mark_ec { int lastmax; /* Optimize maximum search */ int maxTy; /* Maximum Ty */ -} mark_ec; +} echo_can_state_t; #define INLINE inline -static INLINE void init_cc(mark_ec *ec) +#ifdef __KERNEL__ +#include <linux/kernel.h> +#include <linux/slab.h> +#define MALLOC(a) kmalloc((a), GFP_KERNEL) +#define FREE(a) kfree((a)) +#else +#include <stdlib.h> +#include <unistd.h> +#include <stdint.h> +#include <string.h> +#define MALLOC(a) malloc(a) +#define FREE(a) free(a) +#endif + +static INLINE echo_can_state_t *echo_can_create(int len, int adaption_mode) { - memset(ec, 0, sizeof(*ec)); + echo_can_state_t *ec; + /* Uhm, we're only one length, sorry. */ + ec = MALLOC(sizeof(echo_can_state_t)); + if (ec) + memset(ec, 0, sizeof(*ec)); + return ec; } #define PASSPOS 32000 #undef PASSPOS -static INLINE short process_cc(mark_ec *ec, short tx, short txabs, short rx, short rxabs) +static INLINE void echo_can_free(echo_can_state_t *ec) +{ + FREE(ec); +} + +static INLINE int16_t echo_can_update(echo_can_state_t *ec, int16_t tx, int16_t rx) { /* Process a sample, where tx is the near end and rx is the far end + echo */ int suppr; int nsuppr; + short rxabs, txabs; register int Lu; register int x; register int pos; @@ -110,6 +135,9 @@ static INLINE short process_cc(mark_ec *ec, short tx, short txabs, short rx, sho int totalupd; #endif + txabs = abs(tx); + rxabs = abs(rx); + ec->pass++; r_hat = 0; |