changeset 3:3cd5ad24b1d4

libgsmfrp: implement internal state
author Mychaela Falconia <falcon@freecalypso.org>
date Sat, 19 Nov 2022 09:03:57 +0000
parents 2b5770c715ee
children 286d5f097eb4
files libgsmfrp/Makefile libgsmfrp/internal.h libgsmfrp/state.c
diffstat 3 files changed, 47 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- 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}
--- /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];
+};
--- /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 <stdlib.h>
+#include <string.h>
+#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));
+}