# HG changeset patch # User Mychaela Falconia # Date 1668848637 0 # Node ID 3cd5ad24b1d4c0e4d920896f823fc812e05187a2 # Parent 2b5770c715ee171890b253314d177c45c5273caf libgsmfrp: implement internal state diff -r 2b5770c715ee -r 3cd5ad24b1d4 libgsmfrp/Makefile --- a/libgsmfrp/Makefile Sat Nov 19 07:21:26 2022 +0000 +++ b/libgsmfrp/Makefile Sat Nov 19 09:03:57 2022 +0000 @@ -1,6 +1,6 @@ CC= gcc CFLAGS= -O2 -OBJS= sidclass.o silence_frame.o +OBJS= sidclass.o silence_frame.o state.o LIB= libgsmfrp.a all: ${LIB} diff -r 2b5770c715ee -r 3cd5ad24b1d4 libgsmfrp/internal.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libgsmfrp/internal.h Sat Nov 19 09:03:57 2022 +0000 @@ -0,0 +1,22 @@ +/* + * This header file is internal to libgsmfrp; + * here we define our state structure. + */ + +enum rx_state { + NO_DATA = 0, + SPEECH, + SPEECH_MUTING, + COMFORT_NOISE, + LOST_SID, +}; + +typedef unsigned char cparam; + +struct gsmfr_preproc_state { + enum rx_state rx_state; + int got_valid_sid; + gsm_frame speech_frame; + cparam cnoise_larc[8]; + cparam cnoise_xmaxc[4]; +}; diff -r 2b5770c715ee -r 3cd5ad24b1d4 libgsmfrp/state.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libgsmfrp/state.c Sat Nov 19 09:03:57 2022 +0000 @@ -0,0 +1,24 @@ +/* + * In this module we implement allocation and initialization + * of state structures for our GSM FR preprocessor. + */ + +#include +#include +#include "gsm_fr_preproc.h" +#include "internal.h" + +struct gsmfr_preproc_state *gsmfr_preproc_create(void) +{ + struct gsmfr_preproc_state *st; + + st = malloc(sizeof(struct gsmfr_preproc_state)); + if (st) + gsmfr_preproc_reset(st); + return st; +} + +void gsmfr_preproc_reset(struct gsmfr_preproc_state *st) +{ + memset(st, 0, sizeof(struct gsmfr_preproc_state)); +}